forked from OSchip/llvm-project
make asmprinter optional, even though passing in null will cause things to explode right now.
llvm-svn: 108955
This commit is contained in:
parent
837a6cbe03
commit
41ff5d4d91
|
@ -28,11 +28,10 @@
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
X86MCInstLower::X86MCInstLower(MCContext &ctx, Mangler *mang,
|
X86MCInstLower::X86MCInstLower(Mangler *mang, const MachineFunction &mf,
|
||||||
const MachineFunction &mf,
|
X86AsmPrinter *asmprinter)
|
||||||
X86AsmPrinter &asmprinter)
|
: Ctx(mf.getContext()), Mang(mang), MF(mf), TM(mf.getTarget()),
|
||||||
: Ctx(ctx), Mang(mang), MF(mf), TM(mf.getTarget()), MAI(*TM.getMCAsmInfo()),
|
MAI(*TM.getMCAsmInfo()), AsmPrinter(asmprinter) {}
|
||||||
AsmPrinter(asmprinter) {}
|
|
||||||
|
|
||||||
MachineModuleInfoMachO &X86MCInstLower::getMachOMMI() const {
|
MachineModuleInfoMachO &X86MCInstLower::getMachOMMI() const {
|
||||||
return MF.getMMI().getObjFileInfo<MachineModuleInfoMachO>();
|
return MF.getMMI().getObjFileInfo<MachineModuleInfoMachO>();
|
||||||
|
@ -182,7 +181,7 @@ MCOperand X86MCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
||||||
// local labels. This is only safe when the symbols are in the same
|
// local labels. This is only safe when the symbols are in the same
|
||||||
// section so we are restricting it to jumptable references.
|
// section so we are restricting it to jumptable references.
|
||||||
MCSymbol *Label = Ctx.CreateTempSymbol();
|
MCSymbol *Label = Ctx.CreateTempSymbol();
|
||||||
AsmPrinter.OutStreamer.EmitAssignment(Label, Expr);
|
AsmPrinter->OutStreamer.EmitAssignment(Label, Expr);
|
||||||
Expr = MCSymbolRefExpr::Create(Label, Ctx);
|
Expr = MCSymbolRefExpr::Create(Label, Ctx);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -327,14 +326,14 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||||
MCOp = LowerSymbolOperand(MO, GetSymbolFromOperand(MO));
|
MCOp = LowerSymbolOperand(MO, GetSymbolFromOperand(MO));
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_JumpTableIndex:
|
case MachineOperand::MO_JumpTableIndex:
|
||||||
MCOp = LowerSymbolOperand(MO, AsmPrinter.GetJTISymbol(MO.getIndex()));
|
MCOp = LowerSymbolOperand(MO, AsmPrinter->GetJTISymbol(MO.getIndex()));
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
MCOp = LowerSymbolOperand(MO, AsmPrinter.GetCPISymbol(MO.getIndex()));
|
MCOp = LowerSymbolOperand(MO, AsmPrinter->GetCPISymbol(MO.getIndex()));
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_BlockAddress:
|
case MachineOperand::MO_BlockAddress:
|
||||||
MCOp = LowerSymbolOperand(MO,
|
MCOp = LowerSymbolOperand(MO,
|
||||||
AsmPrinter.GetBlockAddressSymbol(MO.getBlockAddress()));
|
AsmPrinter->GetBlockAddressSymbol(MO.getBlockAddress()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +504,7 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||||
|
|
||||||
|
|
||||||
void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||||
X86MCInstLower MCInstLowering(OutContext, Mang, *MF, *this);
|
X86MCInstLower MCInstLowering(Mang, *MF, this);
|
||||||
switch (MI->getOpcode()) {
|
switch (MI->getOpcode()) {
|
||||||
case TargetOpcode::DBG_VALUE:
|
case TargetOpcode::DBG_VALUE:
|
||||||
if (isVerbose() && OutStreamer.hasRawTextSupport()) {
|
if (isVerbose() && OutStreamer.hasRawTextSupport()) {
|
||||||
|
|
|
@ -34,10 +34,12 @@ class LLVM_LIBRARY_VISIBILITY X86MCInstLower {
|
||||||
const TargetMachine &TM;
|
const TargetMachine &TM;
|
||||||
const MCAsmInfo &MAI;
|
const MCAsmInfo &MAI;
|
||||||
|
|
||||||
X86AsmPrinter &AsmPrinter;
|
/// AsmPrinter - This is the asmprinter when emission is actually happening,
|
||||||
|
/// or null if an instruction is being lowered for some other reason.
|
||||||
|
X86AsmPrinter *AsmPrinter;
|
||||||
public:
|
public:
|
||||||
X86MCInstLower(MCContext &ctx, Mangler *mang, const MachineFunction &MF,
|
X86MCInstLower(Mangler *mang, const MachineFunction &MF,
|
||||||
X86AsmPrinter &asmprinter);
|
X86AsmPrinter *asmprinter);
|
||||||
|
|
||||||
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
|
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue