reduce X86MCInstLower dependencies on asmprinter.
authorChris Lattner <sabre@nondot.org>
Tue, 20 Jul 2010 22:30:53 +0000 (22:30 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 20 Jul 2010 22:30:53 +0000 (22:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108950 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 955b9fe74694c8fa643f10062266c6d1976f7b98..8def738108d347e9f788d71d4779d0fc6c98f92d 100644 (file)
 using namespace llvm;
 
 X86MCInstLower::X86MCInstLower(MCContext &ctx, Mangler *mang,
-                               X86AsmPrinter &asmprinter)
-: Ctx(ctx), Mang(mang), AsmPrinter(asmprinter), MF(*AsmPrinter.MF) {}
+                               X86AsmPrinter &asmprinter,
+                               const TargetMachine &tm)
+: Ctx(ctx), Mang(mang), AsmPrinter(asmprinter), MF(*AsmPrinter.MF),
+  TM(tm), MAI(*TM.getMCAsmInfo()) {}
 
 MachineModuleInfoMachO &X86MCInstLower::getMachOMMI() const {
   return MF.getMMI().getObjFileInfo<MachineModuleInfoMachO>();
@@ -38,8 +40,7 @@ MachineModuleInfoMachO &X86MCInstLower::getMachOMMI() const {
 
 
 MCSymbol *X86MCInstLower::GetPICBaseSymbol() const {
-  const TargetLowering *TLI = AsmPrinter.TM.getTargetLowering();
-  return static_cast<const X86TargetLowering*>(TLI)->
+  return static_cast<const X86TargetLowering*>(TM.getTargetLowering())->
     getPICBaseSymbol(&MF, Ctx);
 }
 
@@ -53,7 +54,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
   
   if (!MO.isGlobal()) {
     assert(MO.isSymbol());
-    Name += AsmPrinter.MAI->getGlobalPrefix();
+    Name += MAI.getGlobalPrefix();
     Name += MO.getSymbolName();
   } else {    
     const GlobalValue *GV = MO.getGlobal();
@@ -175,7 +176,7 @@ MCOperand X86MCInstLower::LowerSymbolOperand(const MachineOperand &MO,
     Expr = MCBinaryExpr::CreateSub(Expr, 
                                MCSymbolRefExpr::Create(GetPICBaseSymbol(), Ctx),
                                    Ctx);
-    if (MO.isJTI() && AsmPrinter.MAI->hasSetDirective()) {
+    if (MO.isJTI() && MAI.hasSetDirective()) {
       // If .set directive is supported, use it to reduce the number of
       // relocations the assembler will generate for differences between
       // local labels. This is only safe when the symbols are in the same
@@ -504,7 +505,7 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
 
 
 void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
-  X86MCInstLower MCInstLowering(OutContext, Mang, *this);
+  X86MCInstLower MCInstLowering(OutContext, Mang, *this, TM);
   switch (MI->getOpcode()) {
   case TargetOpcode::DBG_VALUE:
     if (isVerbose() && OutStreamer.hasRawTextSupport()) {
index 2dd65046131e86cd7738ff187f308b27917eb150..8bfa4c8aacc7b57b78497c4f048989f2283fe6f4 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
+  class MCAsmInfo;
   class MCContext;
   class MCInst;
   class MCOperand;
@@ -22,6 +23,7 @@ namespace llvm {
   class MachineModuleInfoMachO;
   class MachineOperand;
   class Mangler;
+  class TargetMachine;
   class X86AsmPrinter;
   
 /// X86MCInstLower - This class is used to lower an MachineInstr into an MCInst.
@@ -30,8 +32,11 @@ class LLVM_LIBRARY_VISIBILITY X86MCInstLower {
   Mangler *Mang;
   X86AsmPrinter &AsmPrinter;
   const MachineFunction &MF;
+  const TargetMachine &TM;
+  const MCAsmInfo &MAI;
 public:
-  X86MCInstLower(MCContext &ctx, Mangler *mang, X86AsmPrinter &asmprinter);
+  X86MCInstLower(MCContext &ctx, Mangler *mang, X86AsmPrinter &asmprinter,
+                 const TargetMachine &TM);
   
   void Lower(const MachineInstr *MI, MCInst &OutMI) const;