class formatted_raw_ostream;
class MCCodeEmitter;
class TargetAsmBackend;
+class MachineInstr;
+class AsmPrinter;
+class MCInst;
MCCodeEmitter *createARMMCCodeEmitter(const Target &,
TargetMachine &TM,
extern Target TheARMTarget, TheThumbTarget;
+void LowerToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP);
+
} // end namespace llvm;
#endif
#include "ARMConstantPoolValue.h"
#include "InstPrinter/ARMInstPrinter.h"
#include "ARMMachineFunctionInfo.h"
-#include "ARMMCInstLower.h"
#include "ARMTargetMachine.h"
#include "ARMTargetObjectFile.h"
#include "llvm/Analysis/DebugInfo.h"
}
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");
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;
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;
}
MCInst TmpInst;
- MCInstLowering.Lower(MI, TmpInst);
+ LowerToMCInst(MI, TmpInst, *this);
OutStreamer.EmitInstruction(TmpInst);
}
//
//===----------------------------------------------------------------------===//
-#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");
}
-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) {
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();
OutMI.addOperand(MCOp);
}
-
}
+++ /dev/null
-//===-- 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