diff options
author | Chris Lattner <sabre@nondot.org> | 2010-11-14 20:58:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-11-14 20:58:38 +0000 |
commit | 1612a619f18cbb328df5b2d8d268dd5e02a4a483 (patch) | |
tree | 79793d1e0e0666f8c27f015ce7e8ea7250270c33 /lib | |
parent | 01928b9a406d2f3b3efb36794b3729b6738884a6 (diff) | |
download | external_llvm-1612a619f18cbb328df5b2d8d268dd5e02a4a483.zip external_llvm-1612a619f18cbb328df5b2d8d268dd5e02a4a483.tar.gz external_llvm-1612a619f18cbb328df5b2d8d268dd5e02a4a483.tar.bz2 |
even more simplifications. ARM MCInstLowering is now just
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/ARM/ARM.h | 5 | ||||
-rw-r--r-- | lib/Target/ARM/ARMAsmPrinter.cpp | 8 | ||||
-rw-r--r-- | lib/Target/ARM/ARMMCInstLower.cpp | 23 | ||||
-rw-r--r-- | lib/Target/ARM/ARMMCInstLower.h | 43 |
4 files changed, 19 insertions, 60 deletions
diff --git a/lib/Target/ARM/ARM.h b/lib/Target/ARM/ARM.h index 8c98bc9..a21757d 100644 --- a/lib/Target/ARM/ARM.h +++ b/lib/Target/ARM/ARM.h @@ -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 diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index 2d5b4c4..cf48d20 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -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); } diff --git a/lib/Target/ARM/ARMMCInstLower.cpp b/lib/Target/ARM/ARMMCInstLower.cpp index e500ca8..6e7fa47 100644 --- a/lib/Target/ARM/ARMMCInstLower.cpp +++ b/lib/Target/ARM/ARMMCInstLower.cpp @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#include "ARMMCInstLower.h" #include "ARM.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/Constants.h" @@ -26,8 +25,10 @@ #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 index caab7e9..0000000 --- a/lib/Target/ARM/ARMMCInstLower.h +++ /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 |