print instruction encodings with the existing comment facilities,
authorChris Lattner <sabre@nondot.org>
Wed, 3 Feb 2010 06:28:13 +0000 (06:28 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 3 Feb 2010 06:28:13 +0000 (06:28 +0000)
so that llvm-mc -show-encoding prints like this:

hlt                                                 ## encoding: [0xf4]

instead of like this:

hlt
                     # encoding: [0xf4]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95207 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCAsmStreamer.cpp

index f3a2223dc7dda1b0863a0a7a3dfe0ad83e01f11b..5c11db72e2f40c89fea1330a8b38aa3fd5199d2f 100644 (file)
@@ -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;
   }