In the disassembler C API, be careful not to confuse the comment streamer that the...
authorOwen Anderson <resistor@mac.com>
Wed, 21 Sep 2011 00:25:23 +0000 (00:25 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 21 Sep 2011 00:25:23 +0000 (00:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140217 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCDisassembler/Disassembler.cpp
lib/MC/MCInstPrinter.cpp
lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp
lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp

index 14fab08b87485eb2963caaa761c149cdc5e20304..07e005627fd7751fb5bd107170b5eadd6d1c7cc4 100644 (file)
@@ -82,8 +82,6 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
                                                 Ctx, DisAsm, IP);
   assert(DC && "Allocation failure!");
 
-  IP->setCommentStream(DC->CommentStream);
-
   return DC;
 }
 
index e15e10761699473f0959ab9e4c92610572877ef0..5dbd4b015d70de3ebb0f37decf119c6274560dc0 100644 (file)
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/MC/MCInstPrinter.h"
+#include "llvm/MC/MCAsmInfo.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
@@ -26,5 +27,10 @@ void MCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
 }
 
 void MCInstPrinter::printAnnotation(raw_ostream &OS, StringRef Annot) {
-  if (!Annot.empty()) OS << Annot << "\n";
+  if (!Annot.empty()) {
+    if (CommentStream)
+      (*CommentStream) << Annot << "\n";
+    else
+      OS << " " << MAI.getCommentString() << " " << Annot << "\n";
+  }
 }
index 5bbd19fd757c1983cb8d5ce44baa7e6cb5fe5b62..277d44cfacac718bb5fa05a857741270bd9cf1a7 100644 (file)
@@ -72,7 +72,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
 
     O << ", " << getRegisterName(MO2.getReg());
     assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
@@ -90,12 +90,12 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
       << ", " << getRegisterName(MO1.getReg());
 
     if (ARM_AM::getSORegShOp(MO2.getImm()) == ARM_AM::rrx) {
-      if (CommentStream) printAnnotation(*CommentStream, Annot);
+      if (CommentStream) printAnnotation(O, Annot);
       return;
     }
 
     O << ", #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
@@ -109,7 +109,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
       O << ".w";
     O << '\t';
     printRegisterList(MI, 4, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
   if (Opcode == ARM::STR_PRE_IMM && MI->getOperand(2).getReg() == ARM::SP &&
@@ -117,7 +117,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
     O << '\t' << "push";
     printPredicateOperand(MI, 4, O);
     O << "\t{" << getRegisterName(MI->getOperand(1).getReg()) << "}";
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
@@ -130,7 +130,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
       O << ".w";
     O << '\t';
     printRegisterList(MI, 4, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
   if (Opcode == ARM::LDR_POST_IMM && MI->getOperand(2).getReg() == ARM::SP &&
@@ -138,7 +138,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
     O << '\t' << "pop";
     printPredicateOperand(MI, 5, O);
     O << "\t{" << getRegisterName(MI->getOperand(0).getReg()) << "}";
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
@@ -150,7 +150,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
     printPredicateOperand(MI, 2, O);
     O << '\t';
     printRegisterList(MI, 4, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
@@ -161,7 +161,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
     printPredicateOperand(MI, 2, O);
     O << '\t';
     printRegisterList(MI, 4, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
@@ -180,7 +180,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
     if (Writeback) O << "!";
     O << ", ";
     printRegisterList(MI, 3, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
@@ -189,12 +189,12 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
       MI->getOperand(1).getReg() == ARM::R8) {
     O << "\tnop";
     printPredicateOperand(MI, 2, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
   printInstruction(MI, O);
-  if (CommentStream) printAnnotation(*CommentStream, Annot);
+  if (CommentStream) printAnnotation(O, Annot);
 }
 
 void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
index 7ece492c2f186588ecf58188e8ae3fceb7ce1345..f470be30f024520304c3b6474a6daf0dff5bd801 100644 (file)
@@ -28,7 +28,7 @@ using namespace llvm;
 void MBlazeInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
                                   StringRef Annot) {
   printInstruction(MI, O);
-  if (CommentStream) printAnnotation(*CommentStream, Annot);
+  if (CommentStream) printAnnotation(O, Annot);
 }
 
 void MBlazeInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
index 18151f4c6dee45a035f0017358c5e2855e4cdcd9..10a8f9ac70b5bc9bd43a1ed4a5b8fb44cf388c8b 100644 (file)
@@ -28,7 +28,7 @@ using namespace llvm;
 void MSP430InstPrinter::printInst(const MCInst *MI, raw_ostream &O,
                                   StringRef Annot) {
   printInstruction(MI, O);
-  if (CommentStream) printAnnotation(*CommentStream, Annot);
+  if (CommentStream) printAnnotation(O, Annot);
 }
 
 void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo,
index 7c7dca28626cabd73b04cc1038b0ded812e8548b..e26fb1474cd97c501c3b2c9d5b0079180e207d4c 100644 (file)
@@ -72,7 +72,7 @@ void MipsInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
 void MipsInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
                                 StringRef Annot) {
   printInstruction(MI, O);
-  if (CommentStream) printAnnotation(*CommentStream, Annot);
+  if (CommentStream) printAnnotation(O, Annot);
 }
 
 void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
index c22b13a447b8754974d808e86da62c7a74f4f156..ac5eb77ead4a4973bdcdb868d1d7bdcfd15d5783 100644 (file)
@@ -52,7 +52,7 @@ void PPCInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
       printOperand(MI, 1, O);
       O << ", " << (unsigned int)SH;
 
-      if (CommentStream) printAnnotation(*CommentStream, Annot);
+      if (CommentStream) printAnnotation(O, Annot);
       return;
     }
   }
@@ -63,7 +63,7 @@ void PPCInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
     printOperand(MI, 0, O);
     O << ", ";
     printOperand(MI, 1, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
   
@@ -77,13 +77,13 @@ void PPCInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
       O << ", ";
       printOperand(MI, 1, O);
       O << ", " << (unsigned int)SH;
-      if (CommentStream) printAnnotation(*CommentStream, Annot);
+      if (CommentStream) printAnnotation(O, Annot);
       return;
     }
   }
   
   printInstruction(MI, O);
-  if (CommentStream) printAnnotation(*CommentStream, Annot);
+  if (CommentStream) printAnnotation(O, Annot);
 }
 
 
index 1fefd5751172f84e0faa71aa8265bb67a43b1b19..029d491260f6b4fef0d9478db3b0e3d4fd564ad0 100644 (file)
@@ -47,7 +47,7 @@ void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
   
   // If verbose assembly is enabled, we can print some informative comments.
   if (CommentStream) {
-    printAnnotation(*CommentStream, Annot);
+    printAnnotation(OS, Annot);
     EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
   }
 }
index 8ff3ac89e43025ebb7f7fa162f3b60af51f1f284..f9ab5aeee122cdec0ea209b2802fccb8a12f400e 100644 (file)
@@ -38,7 +38,7 @@ void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
   
   // If verbose assembly is enabled, we can print some informative comments.
   if (CommentStream) {
-    printAnnotation(*CommentStream, Annot);
+    printAnnotation(OS, Annot);
     EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
   }
 }