X86MCInstLower now depends on AsmPrinter being around.
authorChris Lattner <sabre@nondot.org>
Thu, 22 Jul 2010 21:10:04 +0000 (21:10 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 22 Jul 2010 21:10:04 +0000 (21:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109154 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86MCInstLower.cpp
lib/Target/X86/X86MCInstLower.h

index 3eb12a969c7a97a027222ff091a1b57619cf4e8f..e55b7265cb92fa45b44e2dc01e600b23da816de3 100644 (file)
@@ -29,7 +29,7 @@
 using namespace llvm;
 
 X86MCInstLower::X86MCInstLower(Mangler *mang, const MachineFunction &mf,
-                               X86AsmPrinter *asmprinter)
+                               X86AsmPrinter &asmprinter)
 : Ctx(mf.getContext()), Mang(mang), MF(mf), TM(mf.getTarget()),
   MAI(*TM.getMCAsmInfo()), AsmPrinter(asmprinter) {}
 
@@ -181,7 +181,7 @@ MCOperand X86MCInstLower::LowerSymbolOperand(const MachineOperand &MO,
       // local labels. This is only safe when the symbols are in the same
       // section so we are restricting it to jumptable references.
       MCSymbol *Label = Ctx.CreateTempSymbol();
-      AsmPrinter->OutStreamer.EmitAssignment(Label, Expr);
+      AsmPrinter.OutStreamer.EmitAssignment(Label, Expr);
       Expr = MCSymbolRefExpr::Create(Label, Ctx);
     }
     break;
@@ -320,38 +320,20 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
                        MO.getMBB()->getSymbol(), Ctx));
       break;
     case MachineOperand::MO_GlobalAddress:
-      // If we don't have an asmprinter, we're converting to MCInst to get
-      // instruction sizes, which doesn't need precise value information for
-      // symbols, just lower to a 0 immediate.
-      if (AsmPrinter != 0)
-        MCOp = LowerSymbolOperand(MO, GetSymbolFromOperand(MO));
-      else
-        MCOp = MCOperand::CreateImm(0);
+      MCOp = LowerSymbolOperand(MO, GetSymbolFromOperand(MO));
       break;
     case MachineOperand::MO_ExternalSymbol:
-      if (AsmPrinter != 0)
-        MCOp = LowerSymbolOperand(MO, GetSymbolFromOperand(MO));
-      else
-        MCOp = MCOperand::CreateImm(0);
+      MCOp = LowerSymbolOperand(MO, GetSymbolFromOperand(MO));
       break;
     case MachineOperand::MO_JumpTableIndex:
-      if (AsmPrinter != 0)
-        MCOp = LowerSymbolOperand(MO, AsmPrinter->GetJTISymbol(MO.getIndex()));
-      else
-        MCOp = MCOperand::CreateImm(0);
+      MCOp = LowerSymbolOperand(MO, AsmPrinter.GetJTISymbol(MO.getIndex()));
       break;
     case MachineOperand::MO_ConstantPoolIndex:
-      if (AsmPrinter != 0)
-        MCOp = LowerSymbolOperand(MO, AsmPrinter->GetCPISymbol(MO.getIndex()));
-      else
-        MCOp = MCOperand::CreateImm(0);
+      MCOp = LowerSymbolOperand(MO, AsmPrinter.GetCPISymbol(MO.getIndex()));
       break;
     case MachineOperand::MO_BlockAddress:
-      if (AsmPrinter != 0)
-        MCOp = LowerSymbolOperand(MO,
-                       AsmPrinter->GetBlockAddressSymbol(MO.getBlockAddress()));
-      else
-        MCOp = MCOperand::CreateImm(0);
+      MCOp = LowerSymbolOperand(MO,
+                     AsmPrinter.GetBlockAddressSymbol(MO.getBlockAddress()));
       break;
     }
     
@@ -522,7 +504,7 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
 
 
 void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
-  X86MCInstLower MCInstLowering(Mang, *MF, this);
+  X86MCInstLower MCInstLowering(Mang, *MF, *this);
   switch (MI->getOpcode()) {
   case TargetOpcode::DBG_VALUE:
     if (isVerbose() && OutStreamer.hasRawTextSupport()) {
index 0d493c4b47eb3a0ec5e211f92a26ce25207b17a2..539b09be6fd746dac27e0e9b942c88876623d74f 100644 (file)
@@ -33,13 +33,10 @@ class LLVM_LIBRARY_VISIBILITY X86MCInstLower {
   const MachineFunction &MF;
   const TargetMachine &TM;
   const MCAsmInfo &MAI;
-
-  /// AsmPrinter - This is the asmprinter when emission is actually happening,
-  /// or null if an instruction is being lowered for some other reason.
-  X86AsmPrinter *AsmPrinter;
+  X86AsmPrinter &AsmPrinter;
 public:
   X86MCInstLower(Mangler *mang, const MachineFunction &MF,
-                 X86AsmPrinter *asmprinter);
+                 X86AsmPrinter &asmprinter);
   
   void Lower(const MachineInstr *MI, MCInst &OutMI) const;