[llvm-commits] [llvm] r95207 - /llvm/trunk/lib/MC/MCAsmStreamer.cpp
Chris Lattner
sabre at nondot.org
Tue Feb 2 22:28:13 PST 2010
Author: lattner
Date: Wed Feb 3 00:28:13 2010
New Revision: 95207
URL: http://llvm.org/viewvc/llvm-project?rev=95207&view=rev
Log:
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]
Modified:
llvm/trunk/lib/MC/MCAsmStreamer.cpp
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=95207&r1=95206&r2=95207&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Wed Feb 3 00:28:13 2010
@@ -527,28 +527,27 @@
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;
}
More information about the llvm-commits
mailing list