llvm.org GIT mirror llvm / 1612a61
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 Chris Lattner 9 years ago
4 changed file(s) with 19 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
2727 class formatted_raw_ostream;
2828 class MCCodeEmitter;
2929 class TargetAsmBackend;
30 class MachineInstr;
31 class AsmPrinter;
32 class MCInst;
3033
3134 MCCodeEmitter *createARMMCCodeEmitter(const Target &,
3235 TargetMachine &TM,
5053
5154 extern Target TheARMTarget, TheThumbTarget;
5255
56 void LowerToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP);
57
5358 } // end namespace llvm;
5459
5560 #endif
1818 #include "ARMConstantPoolValue.h"
1919 #include "InstPrinter/ARMInstPrinter.h"
2020 #include "ARMMachineFunctionInfo.h"
21 #include "ARMMCInstLower.h"
2221 #include "ARMTargetMachine.h"
2322 #include "ARMTargetObjectFile.h"
2423 #include "llvm/Analysis/DebugInfo.h"
799798 }
800799
801800 void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
802 ARMMCInstLower MCInstLowering(OutContext, *Mang, *this);
803801 switch (MI->getOpcode()) {
804802 default: break;
805803 case ARM::t2MOVi32imm: assert(0 && "Should be lowered by thumb2it pass");
930928 case ARM::t2BR_JT: {
931929 // Lower and emit the instruction itself, then the jump table following it.
932930 MCInst TmpInst;
933 MCInstLowering.Lower(MI, TmpInst);
931 LowerToMCInst(MI, TmpInst, *this);
934932 OutStreamer.EmitInstruction(TmpInst);
935933 EmitJump2Table(MI);
936934 return;
941939 case ARM::BR_JTadd: {
942940 // Lower and emit the instruction itself, then the jump table following it.
943941 MCInst TmpInst;
944 MCInstLowering.Lower(MI, TmpInst);
942 LowerToMCInst(MI, TmpInst, *this);
945943 OutStreamer.EmitInstruction(TmpInst);
946944 EmitJumpTable(MI);
947945 return;
12521250 }
12531251
12541252 MCInst TmpInst;
1255 MCInstLowering.Lower(MI, TmpInst);
1253 LowerToMCInst(MI, TmpInst, *this);
12561254 OutStreamer.EmitInstruction(TmpInst);
12571255 }
12581256
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #include "ARMMCInstLower.h"
1514 #include "ARM.h"
1615 #include "llvm/CodeGen/AsmPrinter.h"
1716 #include "llvm/Constants.h"
2524 #include "llvm/ADT/SmallString.h"
2625 using namespace llvm;
2726
28 MCOperand ARMMCInstLower::
29 GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol) const {
27
28 static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
29 AsmPrinter &Printer) {
30 MCContext &Ctx = Printer.OutContext;
3031 const MCExpr *Expr;
3132 switch (MO.getTargetFlags()) {
3233 default: assert(0 && "Unknown target flag on symbol operand");
5253
5354 }
5455
55 void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
56 void llvm::LowerToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP){
5657 OutMI.setOpcode(MI->getOpcode());
5758
5859 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
7475 break;
7576 case MachineOperand::MO_MachineBasicBlock:
7677 MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
77 MO.getMBB()->getSymbol(), Ctx));
78 MO.getMBB()->getSymbol(), AP.OutContext));
7879 break;
7980 case MachineOperand::MO_GlobalAddress:
80 MCOp = GetSymbolRef(MO, Printer.Mang->getSymbol(MO.getGlobal()));
81 MCOp = GetSymbolRef(MO, AP.Mang->getSymbol(MO.getGlobal()), AP);
8182 break;
8283 case MachineOperand::MO_ExternalSymbol:
8384 MCOp = GetSymbolRef(MO,
84 Printer.GetExternalSymbolSymbol(MO.getSymbolName()));
85 AP.GetExternalSymbolSymbol(MO.getSymbolName()), AP);
8586 break;
8687 case MachineOperand::MO_JumpTableIndex:
87 MCOp = GetSymbolRef(MO, Printer.GetJTISymbol(MO.getIndex()));
88 MCOp = GetSymbolRef(MO, AP.GetJTISymbol(MO.getIndex()), AP);
8889 break;
8990 case MachineOperand::MO_ConstantPoolIndex:
90 MCOp = GetSymbolRef(MO, Printer.GetCPISymbol(MO.getIndex()));
91 MCOp = GetSymbolRef(MO, AP.GetCPISymbol(MO.getIndex()), AP);
9192 break;
9293 case MachineOperand::MO_BlockAddress:
93 MCOp = GetSymbolRef(MO,
94 Printer.GetBlockAddressSymbol(MO.getBlockAddress()));
94 MCOp = GetSymbolRef(MO,AP.GetBlockAddressSymbol(MO.getBlockAddress()),AP);
9595 break;
9696 case MachineOperand::MO_FPImmediate:
9797 APFloat Val = MO.getFPImm()->getValueAPF();
103103
104104 OutMI.addOperand(MCOp);
105105 }
106
107106 }
+0
-43
lib/Target/ARM/ARMMCInstLower.h less more
None //===-- ARMMCInstLower.h - Lower MachineInstr to MCInst -------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef ARM_MCINSTLOWER_H
10 #define ARM_MCINSTLOWER_H
11
12 #include "llvm/Support/Compiler.h"
13
14 namespace llvm {
15 class AsmPrinter;
16 class MCAsmInfo;
17 class MCContext;
18 class MCInst;
19 class MCOperand;
20 class MCSymbol;
21 class MachineInstr;
22 class MachineOperand;
23 class Mangler;
24
25 /// ARMMCInstLower - This class is used to lower an MachineInstr into an MCInst.
26 class LLVM_LIBRARY_VISIBILITY ARMMCInstLower {
27 MCContext &Ctx;
28 Mangler &Mang;
29 AsmPrinter &Printer;
30 public:
31 ARMMCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter &printer)
32 : Ctx(ctx), Mang(mang), Printer(printer) {}
33
34 void Lower(const MachineInstr *MI, MCInst &OutMI) const;
35
36 private:
37 MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Sym) const;
38 };
39
40 } // end namespace llvm
41
42 #endif