[llvm-commits] CVS: llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Dec 16 23:11:55 PST 2005



Changes in directory llvm/lib/Target/SparcV8:

SparcV8AsmPrinter.cpp updated: 1.42 -> 1.43
---
Log message:

Switch constant pool printing over to use the Shared AsmPrinter version



---
Diffs of the changes:  (+10 -27)

 SparcV8AsmPrinter.cpp |   37 ++++++++++---------------------------
 1 files changed, 10 insertions(+), 27 deletions(-)


Index: llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp
diff -u llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp:1.42 llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp:1.43
--- llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp:1.42	Sat Dec 17 01:04:29 2005
+++ llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp	Sat Dec 17 01:11:43 2005
@@ -35,7 +35,11 @@
   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
 
   struct SparcV8AsmPrinter : public AsmPrinter {
-    SparcV8AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) {}
+    SparcV8AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) {
+      Data16bitsDirective = "\t.half\t";
+      Data32bitsDirective = "\t.word\t";
+      Data64bitsDirective = "\t.xword\t";
+    }
 
     /// We name each basic block in a Function with a unique number, so
     /// that we can consistently refer to them later. This is cleared
@@ -50,7 +54,6 @@
 
     void emitConstantValueOnly(const Constant *CV);
     void emitGlobalConstant(const Constant *CV);
-    void printConstantPool(MachineConstantPool *MCP);
     void printOperand(const MachineInstr *MI, int opNum);
     bool printInstruction(const MachineInstr *MI);  // autogenerated.
     bool runOnMachineFunction(MachineFunction &F);
@@ -277,33 +280,15 @@
   O << "\n";
 }
 
-/// 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 SparcV8AsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector<Constant*> &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  SwitchSection(".section \".rodata\"\n", 0);
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-    O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
-      << "\n";
-    O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t!"
-      << *CP[i] << "\n";
-    emitGlobalConstant(CP[i]);
-  }
-}
-
 /// runOnMachineFunction - This uses the printMachineInstruction()
 /// method to print assembly for each instruction.
 ///
 bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   SetupMachineFunction(MF);
 
+  // Print out constants referenced by the function
+  EmitConstantPool(MF.getConstantPool());
+
   // BBNumber is used here so that a given Printer will never give two
   // BBs the same name. (If you have a better way, please let me know!)
   static unsigned BBNumber = 0;
@@ -312,9 +297,6 @@
   // What's my mangled name?
   CurrentFnName = Mang->getValueName(MF.getFunction());
 
-  // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
-
   // Print out labels for the function.
   O << "\t.text\n";
   O << "\t.align 16\n";
@@ -398,7 +380,8 @@
     O << MO.getSymbolName();
     break;
   case MachineOperand::MO_ConstantPoolIndex:
-    O << ".CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex();
+    O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
+      << MO.getConstantPoolIndex();
     break;
   default:
     O << "<unknown operand type>"; abort (); break;






More information about the llvm-commits mailing list