llvm.org GIT mirror llvm / 112f239
simplify and tidy up git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119066 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
3 changed file(s) with 16 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
801801 void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
802802 ARMMCInstLower MCInstLowering(OutContext, *Mang, *this);
803803 switch (MI->getOpcode()) {
804 case ARM::t2MOVi32imm:
805 assert(0 && "Should be lowered by thumb2it pass");
806804 default: break;
805 case ARM::t2MOVi32imm: assert(0 && "Should be lowered by thumb2it pass");
807806 case ARM::DBG_VALUE: {
808807 if (isVerbose() && OutStreamer.hasRawTextSupport()) {
809808 SmallString<128> TmpStr;
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #include "ARMMCInstLower.h"
1415 #include "ARM.h"
15 #include "ARMMCInstLower.h"
1616 #include "llvm/CodeGen/AsmPrinter.h"
1717 #include "llvm/Constants.h"
1818 #include "llvm/CodeGen/MachineBasicBlock.h"
8181
8282
8383
84 MCSymbol *ARMMCInstLower::
84 const MCSymbolRefExpr *ARMMCInstLower::
8585 GetJumpTableSymbol(const MachineOperand &MO) const {
8686 SmallString<256> Name;
8787 raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "JTI"
9393 }
9494
9595 // Create a symbol for the name.
96 return Ctx.GetOrCreateSymbol(Name.str());
96 return MCSymbolRefExpr::Create(Ctx.GetOrCreateSymbol(Name.str()), Ctx);
9797 }
9898
99 MCSymbol *ARMMCInstLower::
99 const MCSymbolRefExpr *ARMMCInstLower::
100100 GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
101101 SmallString<256> Name;
102102 raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "CPI"
108108 }
109109
110110 // Create a symbol for the name.
111 return Ctx.GetOrCreateSymbol(Name.str());
112 }
113
114 MCOperand ARMMCInstLower::
115 LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const {
116 // FIXME: We would like an efficient form for this, so we don't have to do a
117 // lot of extra uniquing.
118 const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, Ctx);
119
120 switch (MO.getTargetFlags()) {
121 default: assert(0 && "Unknown target flag on Symbol operand");
122 case 0: break;
123 }
124
125 if (!MO.isJTI() && MO.getOffset())
126 Expr = MCBinaryExpr::CreateAdd(Expr,
127 MCConstantExpr::Create(MO.getOffset(), Ctx),
128 Ctx);
129 return MCOperand::CreateExpr(Expr);
111 return MCSymbolRefExpr::Create(Ctx.GetOrCreateSymbol(Name.str()), Ctx);
130112 }
131113
132114 MCOperand ARMMCInstLower::
172154 MCOp = LowerSymbolRefOperand(MO, GetExternalSymbolSymbol(MO));
173155 break;
174156 case MachineOperand::MO_JumpTableIndex:
175 MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
157 MCOp = LowerSymbolRefOperand(MO, GetJumpTableSymbol(MO));
176158 break;
177159 case MachineOperand::MO_ConstantPoolIndex:
178 MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
160 MCOp = LowerSymbolRefOperand(MO, GetConstantPoolIndexSymbol(MO));
179161 break;
180162 case MachineOperand::MO_BlockAddress:
181 MCOp = LowerSymbolOperand(MO, Printer.GetBlockAddressSymbol(
182 MO.getBlockAddress()));
163 MCOp = LowerSymbolRefOperand(MO,
164 MCSymbolRefExpr::Create(Printer.GetBlockAddressSymbol(
165 MO.getBlockAddress()), Ctx));
183166 break;
184167 case MachineOperand::MO_FPImmediate:
185168 APFloat Val = MO.getFPImm()->getValueAPF();
3131 MCContext &Ctx;
3232 Mangler &Mang;
3333 AsmPrinter &Printer;
34
35 //const ARMSubtarget &getSubtarget() const;
3634 public:
3735 ARMMCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter &printer)
3836 : Ctx(ctx), Mang(mang), Printer(printer) {}
3937
4038 void Lower(const MachineInstr *MI, MCInst &OutMI) const;
4139
42 //MCSymbol *GetPICBaseSymbol() const;
40 private:
4341 MCSymbol *GetGlobalAddressSymbol(const GlobalValue *GV) const;
4442 const MCSymbolRefExpr *GetSymbolRef(const MachineOperand &MO) const;
4543 const MCSymbolRefExpr *GetExternalSymbolSymbol(const MachineOperand &MO)
4644 const;
47 MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
48 MCSymbol *GetConstantPoolIndexSymbol(const MachineOperand &MO) const;
45 const MCSymbolRefExpr *GetJumpTableSymbol(const MachineOperand &MO) const;
46 const MCSymbolRefExpr *
47 GetConstantPoolIndexSymbol(const MachineOperand &MO) const;
4948 MCOperand LowerSymbolRefOperand(const MachineOperand &MO,
5049 const MCSymbolRefExpr *Expr) const;
51 MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
52
53 /*
54 private:
55 MachineModuleInfoMachO &getMachOMMI() const;
56 */
5750 };
5851
59 }
52 } // end namespace llvm
6053
6154 #endif