even more simplifications. ARM MCInstLowering is now just
authorChris Lattner <sabre@nondot.org>
Sun, 14 Nov 2010 20:58:38 +0000 (20:58 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 14 Nov 2010 20:58:38 +0000 (20:58 +0000)
a single function instead of a class.  It doesn't need the
complexity that X86 does.

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

lib/Target/ARM/ARM.h
lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/ARM/ARMMCInstLower.cpp
lib/Target/ARM/ARMMCInstLower.h [deleted file]

index 8c98bc984ab7befb67e6c1631a9e561ac9c4bb0c..a21757d393e7a5e074897017707e2534effba87a 100644 (file)
@@ -28,6 +28,9 @@ class JITCodeEmitter;
 class formatted_raw_ostream;
 class MCCodeEmitter;
 class TargetAsmBackend;
+class MachineInstr;
+class AsmPrinter;
+class MCInst;
 
 MCCodeEmitter *createARMMCCodeEmitter(const Target &,
                                       TargetMachine &TM,
@@ -51,6 +54,8 @@ FunctionPass *createThumb2SizeReductionPass();
 
 extern Target TheARMTarget, TheThumbTarget;
 
+void LowerToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP);
+  
 } // end namespace llvm;
 
 #endif
index 2d5b4c41c4cc9e4e12bbb2e917b6b6f6b7763a6c..cf48d20808445ff99b580f7b62a00c72ad976975 100644 (file)
@@ -19,7 +19,6 @@
 #include "ARMConstantPoolValue.h"
 #include "InstPrinter/ARMInstPrinter.h"
 #include "ARMMachineFunctionInfo.h"
-#include "ARMMCInstLower.h"
 #include "ARMTargetMachine.h"
 #include "ARMTargetObjectFile.h"
 #include "llvm/Analysis/DebugInfo.h"
@@ -800,7 +799,6 @@ void ARMAsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
 }
 
 void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
-  ARMMCInstLower MCInstLowering(OutContext, *Mang, *this);
   switch (MI->getOpcode()) {
   default: break;
   case ARM::t2MOVi32imm: assert(0 && "Should be lowered by thumb2it pass");
@@ -931,7 +929,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
   case ARM::t2BR_JT: {
     // Lower and emit the instruction itself, then the jump table following it.
     MCInst TmpInst;
-    MCInstLowering.Lower(MI, TmpInst);
+    LowerToMCInst(MI, TmpInst, *this);
     OutStreamer.EmitInstruction(TmpInst);
     EmitJump2Table(MI);
     return;
@@ -942,7 +940,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
   case ARM::BR_JTadd: {
     // Lower and emit the instruction itself, then the jump table following it.
     MCInst TmpInst;
-    MCInstLowering.Lower(MI, TmpInst);
+    LowerToMCInst(MI, TmpInst, *this);
     OutStreamer.EmitInstruction(TmpInst);
     EmitJumpTable(MI);
     return;
@@ -1253,7 +1251,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
   }
 
   MCInst TmpInst;
-  MCInstLowering.Lower(MI, TmpInst);
+  LowerToMCInst(MI, TmpInst, *this);
   OutStreamer.EmitInstruction(TmpInst);
 }
 
index e500ca827258c213f12e7861766509f6255b311c..6e7fa47c520c597b75cbc56547bc402b754206f9 100644 (file)
@@ -12,7 +12,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "ARMMCInstLower.h"
 #include "ARM.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/Constants.h"
 #include "llvm/ADT/SmallString.h"
 using namespace llvm;
 
-MCOperand ARMMCInstLower::
-GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol) const {
+
+static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
+                              AsmPrinter &Printer) {
+  MCContext &Ctx = Printer.OutContext;
   const MCExpr *Expr;
   switch (MO.getTargetFlags()) {
   default: assert(0 && "Unknown target flag on symbol operand");
@@ -53,7 +54,7 @@ GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol) const {
   
 }
 
-void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
+void llvm::LowerToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP){
   OutMI.setOpcode(MI->getOpcode());
 
   for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
@@ -75,24 +76,23 @@ void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
       break;
     case MachineOperand::MO_MachineBasicBlock:
       MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
-                       MO.getMBB()->getSymbol(), Ctx));
+                       MO.getMBB()->getSymbol(), AP.OutContext));
       break;
     case MachineOperand::MO_GlobalAddress:
-      MCOp = GetSymbolRef(MO, Printer.Mang->getSymbol(MO.getGlobal()));
+      MCOp = GetSymbolRef(MO, AP.Mang->getSymbol(MO.getGlobal()), AP);
       break;
     case MachineOperand::MO_ExternalSymbol:
       MCOp = GetSymbolRef(MO, 
-                          Printer.GetExternalSymbolSymbol(MO.getSymbolName()));
+                          AP.GetExternalSymbolSymbol(MO.getSymbolName()), AP);
       break;
     case MachineOperand::MO_JumpTableIndex:
-      MCOp = GetSymbolRef(MO, Printer.GetJTISymbol(MO.getIndex()));
+      MCOp = GetSymbolRef(MO, AP.GetJTISymbol(MO.getIndex()), AP);
       break;
     case MachineOperand::MO_ConstantPoolIndex:
-      MCOp = GetSymbolRef(MO, Printer.GetCPISymbol(MO.getIndex()));
+      MCOp = GetSymbolRef(MO, AP.GetCPISymbol(MO.getIndex()), AP);
       break;
     case MachineOperand::MO_BlockAddress:
-      MCOp = GetSymbolRef(MO,
-                          Printer.GetBlockAddressSymbol(MO.getBlockAddress()));
+      MCOp = GetSymbolRef(MO,AP.GetBlockAddressSymbol(MO.getBlockAddress()),AP);
       break;
     case MachineOperand::MO_FPImmediate:
       APFloat Val = MO.getFPImm()->getValueAPF();
@@ -104,5 +104,4 @@ void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
 
     OutMI.addOperand(MCOp);
   }
-
 }
diff --git a/lib/Target/ARM/ARMMCInstLower.h b/lib/Target/ARM/ARMMCInstLower.h
deleted file mode 100644 (file)
index caab7e9..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//===-- ARMMCInstLower.h - Lower MachineInstr to MCInst -------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef ARM_MCINSTLOWER_H
-#define ARM_MCINSTLOWER_H
-
-#include "llvm/Support/Compiler.h"
-
-namespace llvm {
-  class AsmPrinter;
-  class MCAsmInfo;
-  class MCContext;
-  class MCInst;
-  class MCOperand;
-  class MCSymbol;
-  class MachineInstr;
-  class MachineOperand;
-  class Mangler;
-
-/// ARMMCInstLower - This class is used to lower an MachineInstr into an MCInst.
-class LLVM_LIBRARY_VISIBILITY ARMMCInstLower {
-  MCContext &Ctx;
-  Mangler &Mang;
-  AsmPrinter &Printer;
-public:
-  ARMMCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter &printer)
-    : Ctx(ctx), Mang(mang), Printer(printer) {}
-
-  void Lower(const MachineInstr *MI, MCInst &OutMI) const;
-
-private:
-  MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Sym) const;
-};
-
-} // end namespace llvm
-
-#endif