Naturally align doubles in the constant pool, set PrivateGlobalPrefix on
authorChris Lattner <sabre@nondot.org>
Mon, 21 Nov 2005 06:46:22 +0000 (06:46 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 21 Nov 2005 06:46:22 +0000 (06:46 +0000)
darwin, use it when printing the constant pool indices so the labels are
appropriately private, emit cp entries to .const instead of .data on darwin
and only emit a single .section for the constant pool, not one for each
entry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24440 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86IntelAsmPrinter.cpp

index 14f47c0cd55963d094871b5f470f02aaebc17d99..70332a38a23adefe69d7a9e3c5dabcda7be986f7 100755 (executable)
@@ -174,7 +174,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
     O << "]";
     return;
   } else if (BaseReg.isConstantPoolIndex()) {
-    O << ".CPI" << CurrentFnName << "_"
+    O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_"
       << BaseReg.getConstantPoolIndex();
     if (DispSpec.getImmedValue())
       O << "+" << DispSpec.getImmedValue();
index ac06cbc89d6b74e62b3a630e8bc9737973f1061f..18c7c4b81b10b3114bf9a4f038a9ed49f268d711 100644 (file)
@@ -18,6 +18,7 @@
 #include "X86IntelAsmPrinter.h"
 #include "X86.h"
 #include "llvm/Module.h"
+#include "llvm/Type.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/Support/Mangler.h"
@@ -66,6 +67,7 @@ bool X86SharedAsmPrinter::doInitialization(Module& M) {
     AlignmentIsInBytes = false;
     Data64bitsDirective = 0;       // we can't emit a 64-bit unit
     ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
+    PrivateGlobalPrefix = "L";     // Marker for constant pool idxs
   }
 
   return AsmPrinter::doInitialization(M);
@@ -82,14 +84,21 @@ void X86SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
 
   if (CP.empty()) return;
 
+  if (forDarwin) {
+    O << "\t.const\n";
+  } else {
+    O << "\t.section .rodata\n";
+  }
+  
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-    if (forDarwin)
-      O << "\t.data\n";
+    // FIXME: force doubles to be naturally aligned.  We should handle this
+    // more correctly in the future.
+    if (CP[i]->getType() == Type::DoubleTy)
+      emitAlignment(3);
     else
-      O << "\t.section .rodata\n";
-    emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
-    O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString
-      << *CP[i] << "\n";
+      emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
+    O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i
+      << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n";
     emitGlobalConstant(CP[i]);
   }
 }
index 9cf7c29d77d1d919e315f8463dfb30c57705ec75..a9d7c63ccda8ca409d1b51c6a658cf61ecc63a78 100755 (executable)
@@ -141,7 +141,7 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
     O << "]";
     return;
   } else if (BaseReg.isConstantPoolIndex()) {
-    O << "[.CPI" << CurrentFnName << "_"
+    O << "[" << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_"
       << BaseReg.getConstantPoolIndex();
 
     if (IndexReg.getReg()) {