summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-03 06:28:13 +0000
committerChris Lattner <sabre@nondot.org>2010-02-03 06:28:13 +0000
commit44f7325de557a7a30f564aa91ebaa0da8ee8dccc (patch)
treee3f08dbff5f0987cea96a38cceb45353123cafaa /llvm/lib
parent3eef965b06584d1d67fbcf011125141300691e13 (diff)
downloadbcm5719-llvm-44f7325de557a7a30f564aa91ebaa0da8ee8dccc.tar.gz
bcm5719-llvm-44f7325de557a7a30f564aa91ebaa0da8ee8dccc.zip
print instruction encodings with the existing comment facilities,
so that llvm-mc -show-encoding prints like this: hlt ## encoding: [0xf4] instead of like this: hlt # encoding: [0xf4] llvm-svn: 95207
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCAsmStreamer.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index f3a2223dc7d..5c11db72e2f 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -527,28 +527,27 @@ void MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo, StringRef Filename){
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
assert(CurSection && "Cannot emit contents before setting section!");
+ // Show the encoding in a comment if we have a code emitter.
+ if (Emitter) {
+ SmallString<256> Code;
+ raw_svector_ostream VecOS(Code);
+ Emitter->EncodeInstruction(Inst, VecOS);
+ VecOS.flush();
+
+ raw_ostream &OS = GetCommentOS();
+ OS << "encoding: [";
+ for (unsigned i = 0, e = Code.size(); i != e; ++i) {
+ if (i)
+ OS << ',';
+ OS << format("%#04x", uint8_t(Code[i]));
+ }
+ OS << "]\n";
+ }
+
// If we have an AsmPrinter, use that to print.
if (InstPrinter) {
InstPrinter->printInst(&Inst);
EmitEOL();
-
- // Show the encoding if we have a code emitter.
- if (Emitter) {
- SmallString<256> Code;
- raw_svector_ostream VecOS(Code);
- Emitter->EncodeInstruction(Inst, VecOS);
- VecOS.flush();
-
- OS.indent(20);
- OS << " # encoding: [";
- for (unsigned i = 0, e = Code.size(); i != e; ++i) {
- if (i)
- OS << ',';
- OS << format("%#04x", uint8_t(Code[i]));
- }
- OS << "]\n";
- }
-
return;
}
OpenPOWER on IntegriCloud