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
This commit is contained in:
Chris Lattner 2010-11-14 20:58:38 +00:00
parent 01928b9a40
commit 1612a619f1
4 changed files with 19 additions and 60 deletions

View 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

View 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);
}

View File

@ -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);
}
}

View File

@ -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