/// that converts an MCInst to valid target assembly syntax.
class MCInstPrinter {
protected:
- /// O - The main stream to emit instruction text to.
- raw_ostream &O;
-
/// CommentStream - a stream that comments can be emitted to if desired.
/// Each comment must end with a newline. This will be null if verbose
/// assembly emission is disable.
raw_ostream *CommentStream;
const MCAsmInfo &MAI;
public:
- MCInstPrinter(raw_ostream &o, const MCAsmInfo &mai)
- : O(o), CommentStream(0), MAI(mai) {}
+ MCInstPrinter(const MCAsmInfo &mai)
+ : CommentStream(0), MAI(mai) {}
virtual ~MCInstPrinter();
/// setCommentStream - Specify a stream to emit comments to.
void setCommentStream(raw_ostream &OS) { CommentStream = &OS; }
- /// printInst - Print the specified MCInst to the current raw_ostream.
+ /// printInst - Print the specified MCInst to the specified raw_ostream.
///
- virtual void printInst(const MCInst *MI) = 0;
+ virtual void printInst(const MCInst *MI, raw_ostream &OS) = 0;
/// getOpcodeName - Return the name of the specified opcode enum (e.g.
/// "MOV32ri") or empty if we can't resolve it.
typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T);
typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,
unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- raw_ostream &O);
+ const MCAsmInfo &MAI);
typedef MCCodeEmitter *(*CodeEmitterCtorTy)(const Target &T,
TargetMachine &TM,
MCContext &Ctx);
}
MCInstPrinter *createMCInstPrinter(unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- raw_ostream &O) const {
+ const MCAsmInfo &MAI) const {
if (!MCInstPrinterCtorFn)
return 0;
- return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, O);
+ return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI);
}
default: return true;
case CGFT_AssemblyFile: {
MCInstPrinter *InstPrinter =
- getTarget().createMCInstPrinter(MAI.getAssemblerDialect(), MAI, Out);
+ getTarget().createMCInstPrinter(MAI.getAssemblerDialect(), MAI);
AsmStreamer.reset(createAsmStreamer(*Context, Out,
getTargetData()->isLittleEndian(),
getVerboseAsm(), InstPrinter,
// If we have an AsmPrinter, use that to print, otherwise print the MCInst.
if (InstPrinter)
- InstPrinter->printInst(&Inst);
+ InstPrinter->printInst(&Inst, OS);
else
Inst.print(OS, &MAI);
EmitEOL();
static MCInstPrinter *createARMMCInstPrinter(const Target &T,
unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- raw_ostream &O) {
+ const MCAsmInfo &MAI) {
if (SyntaxVariant == 0)
- return new ARMInstPrinter(O, MAI, false);
+ return new ARMInstPrinter(MAI, false);
return 0;
}
}
}
-void ARMInstPrinter::printInst(const MCInst *MI) {
+void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
// Check for MOVs and print canonical forms, instead.
if (MI->getOpcode() == ARM::MOVs) {
const MCOperand &Dst = MI->getOperand(0);
class ARMInstPrinter : public MCInstPrinter {
bool VerboseAsm;
public:
- ARMInstPrinter(raw_ostream &O, const MCAsmInfo &MAI, bool verboseAsm)
- : MCInstPrinter(O, MAI), VerboseAsm(verboseAsm) {}
+ ARMInstPrinter(const MCAsmInfo &MAI, bool verboseAsm)
+ : MCInstPrinter(MAI), VerboseAsm(verboseAsm) {}
- virtual void printInst(const MCInst *MI);
+ virtual void printInst(const MCInst *MI, raw_ostream &O);
// Autogenerated by tblgen.
void printInstruction(const MCInst *MI, raw_ostream &O);
}
void printMCInst(const MCInst *MI) {
- MSP430InstPrinter(O, *MAI).printInstruction(MI, O);
+ MSP430InstPrinter(*MAI).printInstruction(MI, O);
}
void printOperand(const MachineInstr *MI, int OpNum,
const char* Modifier = 0);
static MCInstPrinter *createMSP430MCInstPrinter(const Target &T,
unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- raw_ostream &O) {
+ const MCAsmInfo &MAI) {
if (SyntaxVariant == 0)
- return new MSP430InstPrinter(O, MAI);
+ return new MSP430InstPrinter(MAI);
return 0;
}
#include "MSP430GenAsmWriter.inc"
#undef MachineInstr
-void MSP430InstPrinter::printInst(const MCInst *MI) {
+void MSP430InstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
printInstruction(MI, O);
}
#include "llvm/MC/MCInstPrinter.h"
-namespace llvm
-{
-
+namespace llvm {
class MCOperand;
class MSP430InstPrinter : public MCInstPrinter {
public:
- MSP430InstPrinter(raw_ostream &O, const MCAsmInfo &MAI) :
- MCInstPrinter(O, MAI) {
+ MSP430InstPrinter(const MCAsmInfo &MAI) : MCInstPrinter(MAI) {
}
- virtual void printInst(const MCInst *MI);
+ virtual void printInst(const MCInst *MI, raw_ostream &O);
// Autogenerated by tblgen.
void printInstruction(const MCInst *MI, raw_ostream &O);
#include "X86GenAsmWriter.inc"
#undef MachineInstr
-void X86ATTInstPrinter::printInst(const MCInst *MI) {
- printInstruction(MI, O);
+void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {
+ printInstruction(MI, OS);
}
StringRef X86ATTInstPrinter::getOpcodeName(unsigned Opcode) const {
return getInstructionName(Opcode);
class X86ATTInstPrinter : public MCInstPrinter {
public:
- X86ATTInstPrinter(raw_ostream &O, const MCAsmInfo &MAI)
- : MCInstPrinter(O, MAI) {}
+ X86ATTInstPrinter(const MCAsmInfo &MAI) : MCInstPrinter(MAI) {}
- virtual void printInst(const MCInst *MI);
+ virtual void printInst(const MCInst *MI, raw_ostream &OS);
virtual StringRef getOpcodeName(unsigned Opcode) const;
// Autogenerated by tblgen.
static MCInstPrinter *createX86MCInstPrinter(const Target &T,
unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- raw_ostream &O) {
+ const MCAsmInfo &MAI) {
if (SyntaxVariant == 0)
- return new X86ATTInstPrinter(O, MAI);
+ return new X86ATTInstPrinter(MAI);
if (SyntaxVariant == 1)
- return new X86IntelInstPrinter(O, MAI);
+ return new X86IntelInstPrinter(MAI);
return 0;
}
#include "X86GenAsmWriter1.inc"
#undef MachineInstr
-void X86IntelInstPrinter::printInst(const MCInst *MI) {
- printInstruction(MI, O);
+void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {
+ printInstruction(MI, OS);
}
StringRef X86IntelInstPrinter::getOpcodeName(unsigned Opcode) const {
return getInstructionName(Opcode);
class X86IntelInstPrinter : public MCInstPrinter {
public:
- X86IntelInstPrinter(raw_ostream &O, const MCAsmInfo &MAI)
- : MCInstPrinter(O, MAI) {}
+ X86IntelInstPrinter(const MCAsmInfo &MAI)
+ : MCInstPrinter(MAI) {}
- virtual void printInst(const MCInst *MI);
+ virtual void printInst(const MCInst *MI, raw_ostream &OS);
virtual StringRef getOpcodeName(unsigned Opcode) const;
// Autogenerated by tblgen.
InstString.reset(new std::string);
InstStream.reset(new raw_string_ostream(*InstString));
-
- InstPrinter.reset(Tgt->createMCInstPrinter(syntaxVariant,
- *AsmInfo,
- *InstStream));
+ InstPrinter.reset(Tgt->createMCInstPrinter(syntaxVariant, *AsmInfo));
if (!InstPrinter)
return;
return (programCounters.find(registerID) != programCounters.end());
}
-int EDDisassembler::printInst(std::string& str,
- MCInst& inst) {
+int EDDisassembler::printInst(std::string &str, MCInst &inst) {
PrinterMutex.acquire();
- InstPrinter->printInst(&inst);
+ InstPrinter->printInst(&inst, *InstStream);
InstStream->flush();
str = *InstString;
InstString->clear();
}
static bool PrintInsts(const MCDisassembler &DisAsm,
- MCInstPrinter &Printer, const ByteArrayTy &Bytes,
- SourceMgr &SM) {
+ MCInstPrinter &Printer, const ByteArrayTy &Bytes,
+ SourceMgr &SM) {
// Wrap the vector in a MemoryObject.
VectorMemoryObject memoryObject(Bytes);
if (DisAsm.getInstruction(Inst, Size, memoryObject, Index,
/*REMOVE*/ nulls())) {
- Printer.printInst(&Inst);
+ Printer.printInst(&Inst, outs());
outs() << "\n";
}
else {
return -1;
}
- OwningPtr<MCInstPrinter> IP(T.createMCInstPrinter(0, *AsmInfo, outs()));
+ OwningPtr<MCInstPrinter> IP(T.createMCInstPrinter(0, *AsmInfo));
if (!IP) {
errs() << "error: no instruction printer for target " << Triple << '\n';
return -1;
if (FileType == OFT_AssemblyFile) {
MCInstPrinter *IP =
- TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out);
+ TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI);
if (ShowEncoding)
CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
Str.reset(createAsmStreamer(Ctx, *Out,TM->getTargetData()->isLittleEndian(),