Switch to using the shared constant pool printer, along with using shorter
authorChris Lattner <sabre@nondot.org>
Mon, 21 Nov 2005 08:32:23 +0000 (08:32 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 21 Nov 2005 08:32:23 +0000 (08:32 +0000)
CPI ids

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

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

index 30cfd7433a8267b6cf220194ac37149152fc8704..3a1ac86576fabac727defd3f8bfe9615d014eda1 100755 (executable)
@@ -29,7 +29,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   O << "\n\n";
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
   SwitchSection("\t.text\n", MF.getFunction());
@@ -176,7 +176,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
     O << "]";
     return;
   } else if (BaseReg.isConstantPoolIndex()) {
-    O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_"
+    O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
       << BaseReg.getConstantPoolIndex();
     if (DispSpec.getImmedValue())
       O << "+" << DispSpec.getImmedValue();
index 1a7d3680228c56dc5b890ef4fc2be4c9e03792b0..cbba018b7b561323df28024a3bf33297d22d5953 100644 (file)
@@ -68,37 +68,12 @@ bool X86SharedAsmPrinter::doInitialization(Module& M) {
     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
+    ConstantPoolSection = "\t.const\n";
   }
 
   return AsmPrinter::doInitialization(M);
 }
 
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void X86SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector<Constant*> &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  SwitchSection(forDarwin ? "\t.const\n" : "\t.section .rodata\n", 0);
-  
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-    // 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
-      EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
-    O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i
-      << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n";
-    EmitGlobalConstant(CP[i]);
-  }
-}
-
 bool X86SharedAsmPrinter::doFinalization(Module &M) {
   const TargetData &TD = TM.getTargetData();
 
index ff6597d0b2c8483e29c7457a946206b7cbdfc85c..61dd2f295e72b96e61e35a2e9f9fcff4db4941af 100755 (executable)
@@ -32,7 +32,6 @@ struct X86SharedAsmPrinter : public AsmPrinter {
     : AsmPrinter(O, TM), forCygwin(false), forDarwin(false) { }
 
   bool doInitialization(Module &M);
-  void printConstantPool(MachineConstantPool *MCP);
   bool doFinalization(Module &M);
 
   bool forCygwin;
index 6a8fcabe9755d0963dca6eadcf0bb33d420ce6b4..1c9f803a0e111fba333991056e1f4e5d39664669 100755 (executable)
@@ -29,7 +29,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   O << "\n\n";
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
   SwitchSection("\t.text\n", MF.getFunction());
@@ -143,7 +143,7 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
     O << "]";
     return;
   } else if (BaseReg.isConstantPoolIndex()) {
-    O << "[" << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_"
+    O << "[" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
       << BaseReg.getConstantPoolIndex();
 
     if (IndexReg.getReg()) {