diff --git a/include/llvm/MC/MCInstPrinter.h b/include/llvm/MC/MCInstPrinter.h index 1c04564ebc5..d62a9dae7c5 100644 --- a/include/llvm/MC/MCInstPrinter.h +++ b/include/llvm/MC/MCInstPrinter.h @@ -13,13 +13,17 @@ namespace llvm { class MCInst; class raw_ostream; +class MCAsmInfo; + /// MCInstPrinter - This is an instance of a target assembly language printer /// that converts an MCInst to valid target assembly syntax. class MCInstPrinter { +protected: raw_ostream &O; + const MCAsmInfo &MAI; public: - MCInstPrinter(raw_ostream &o) : O(o) {} + MCInstPrinter(raw_ostream &o, const MCAsmInfo &mai) : O(o), MAI(mai) {} virtual ~MCInstPrinter(); diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 4aef27e3303..c2c3855df72 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -48,7 +48,7 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed"); //===----------------------------------------------------------------------===// void X86ATTAsmPrinter::printMCInst(const MCInst *MI) { - X86ATTInstPrinter(O, MAI).printInstruction(MI); + X86ATTInstPrinter(O, *MAI).printInstruction(MI); } void X86ATTAsmPrinter::PrintPICBaseSymbol() const { diff --git a/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp index f943ccf7e35..7576ab371d0 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp @@ -27,6 +27,8 @@ using namespace llvm; #include "X86GenAsmWriter.inc" #undef MachineInstr +void X86ATTInstPrinter::printInst(const MCInst *MI) { printInstruction(MI); } + void X86ATTInstPrinter::printSSECC(const MCInst *MI, unsigned Op) { switch (MI->getOperand(Op).getImm()) { default: llvm_unreachable("Invalid ssecc argument!"); @@ -55,7 +57,7 @@ void X86ATTInstPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) { O << Op.getImm(); else { assert(Op.isExpr() && "unknown pcrel immediate operand"); - Op.getExpr()->print(O, MAI); + Op.getExpr()->print(O, &MAI); } } @@ -71,7 +73,7 @@ void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, } else { assert(Op.isExpr() && "unknown operand kind in printOperand"); O << '$'; - Op.getExpr()->print(O, MAI); + Op.getExpr()->print(O, &MAI); } } @@ -86,7 +88,7 @@ void X86ATTInstPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) { O << DispVal; } else { assert(DispSpec.isExpr() && "non-immediate displacement for LEA?"); - DispSpec.getExpr()->print(O, MAI); + DispSpec.getExpr()->print(O, &MAI); } if (IndexReg.getReg() || BaseReg.getReg()) { diff --git a/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.h b/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.h index 5969ca939a1..4aa738e61e8 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.h +++ b/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.h @@ -14,18 +14,19 @@ #ifndef X86_ATT_INST_PRINTER_H #define X86_ATT_INST_PRINTER_H -namespace llvm { - class MCAsmInfo; - class MCInst; - class MCOperand; - class raw_ostream; - -class X86ATTInstPrinter { - raw_ostream &O; - const MCAsmInfo *MAI; -public: - X86ATTInstPrinter(raw_ostream &o, const MCAsmInfo *mai) : O(o), MAI(mai) {} +#include "llvm/MC/MCInstPrinter.h" +namespace llvm { + class MCOperand; + +class X86ATTInstPrinter : public MCInstPrinter { +public: + X86ATTInstPrinter(raw_ostream &O, const MCAsmInfo &MAI) + : MCInstPrinter(O, MAI) {} + + + virtual void printInst(const MCInst *MI); + // Autogenerated by tblgen. void printInstruction(const MCInst *MI); static const char *getRegisterName(unsigned RegNo);