diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-22 21:49:34 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-22 21:49:34 +0000 |
commit | 04047fbe1446b160257a2f3949aa4fb2e30dba78 (patch) | |
tree | 061ca8cf0e87b8959626bb853b7fd5b6f444714b /llvm/lib/MC | |
parent | 65f7a3f801de0661361c17a71a59c8cf26b465d0 (diff) | |
download | bcm5719-llvm-04047fbe1446b160257a2f3949aa4fb2e30dba78.tar.gz bcm5719-llvm-04047fbe1446b160257a2f3949aa4fb2e30dba78.zip |
MCInst: Add ::dump_pretty.
llvm-svn: 99216
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 20 | ||||
-rw-r--r-- | llvm/lib/MC/MCInst.cpp | 17 |
2 files changed, 20 insertions, 17 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 2025463a80b..7a23aecf297 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -623,24 +623,10 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst) { AddEncodingComment(Inst); // Show the MCInst if enabled. - if (ShowInst) { - raw_ostream &OS = GetCommentOS(); - OS << "<MCInst #" << Inst.getOpcode(); - - StringRef InstName; - if (InstPrinter) - InstName = InstPrinter->getOpcodeName(Inst.getOpcode()); - if (!InstName.empty()) - OS << ' ' << InstName; - - for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i) { - OS << "\n "; - Inst.getOperand(i).print(OS, &MAI); - } - OS << ">\n"; - } + if (ShowInst) + Inst.dump_pretty(GetCommentOS(), &MAI, InstPrinter.get(), "\n "); - // If we have an AsmPrinter, use that to print, otherwise dump the MCInst. + // If we have an AsmPrinter, use that to print, otherwise print the MCInst. if (InstPrinter) InstPrinter->printInst(&Inst); else diff --git a/llvm/lib/MC/MCInst.cpp b/llvm/lib/MC/MCInst.cpp index 0634c9faf6f..de142dc9553 100644 --- a/llvm/lib/MC/MCInst.cpp +++ b/llvm/lib/MC/MCInst.cpp @@ -9,6 +9,7 @@ #include "llvm/MC/MCInst.h" #include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCInstPrinter.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -43,6 +44,22 @@ void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const { OS << ">"; } +void MCInst::dump_pretty(raw_ostream &OS, const MCAsmInfo *MAI, + const MCInstPrinter *Printer, + StringRef Separator) const { + OS << "<MCInst #" << getOpcode(); + + // Show the instruction opcode name if we have access to a printer. + if (Printer) + OS << ' ' << Printer->getOpcodeName(getOpcode()); + + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + OS << Separator; + getOperand(i).print(OS, MAI); + } + OS << ">\n"; +} + void MCInst::dump() const { print(dbgs(), 0); dbgs() << "\n"; |