[llvm-commits] [llvm] r140217 - in /llvm/trunk/lib: MC/MCDisassembler/Disassembler.cpp MC/MCInstPrinter.cpp Target/ARM/InstPrinter/ARMInstPrinter.cpp Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp Target/MSP430/InstPrinter/MSP430InstPrinter.cpp Target/Mips/InstPrinter/MipsInstPrinter.cpp Target/PowerPC/InstPrinter/PPCInstPrinter.cpp Target/X86/InstPrinter/X86ATTInstPrinter.cpp Target/X86/InstPrinter/X86IntelInstPrinter.cpp

Owen Anderson resistor at mac.com
Tue Sep 20 17:25:23 PDT 2011


Author: resistor
Date: Tue Sep 20 19:25:23 2011
New Revision: 140217

URL: http://llvm.org/viewvc/llvm-project?rev=140217&view=rev
Log:
In the disassembler C API, be careful not to confuse the comment streamer that the disassembler outputs annotations on with the streamer that the InstPrinter will print them on.

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

Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original)
+++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Tue Sep 20 19:25:23 2011
@@ -82,8 +82,6 @@
                                                 Ctx, DisAsm, IP);
   assert(DC && "Allocation failure!");
 
-  IP->setCommentStream(DC->CommentStream);
-
   return DC;
 }
 

Modified: llvm/trunk/lib/MC/MCInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCInstPrinter.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCInstPrinter.cpp (original)
+++ llvm/trunk/lib/MC/MCInstPrinter.cpp Tue Sep 20 19:25:23 2011
@@ -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::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";
+  }
 }

Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Tue Sep 20 19:25:23 2011
@@ -72,7 +72,7 @@
 
     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 @@
       << ", " << 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 @@
       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 @@
     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 @@
       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 @@
     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 @@
     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 @@
     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 @@
     if (Writeback) O << "!";
     O << ", ";
     printRegisterList(MI, 3, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
 
@@ -189,12 +189,12 @@
       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,

Modified: llvm/trunk/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp Tue Sep 20 19:25:23 2011
@@ -28,7 +28,7 @@
 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,

Modified: llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp Tue Sep 20 19:25:23 2011
@@ -28,7 +28,7 @@
 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,

Modified: llvm/trunk/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp Tue Sep 20 19:25:23 2011
@@ -72,7 +72,7 @@
 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,

Modified: llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp Tue Sep 20 19:25:23 2011
@@ -52,7 +52,7 @@
       printOperand(MI, 1, O);
       O << ", " << (unsigned int)SH;
 
-      if (CommentStream) printAnnotation(*CommentStream, Annot);
+      if (CommentStream) printAnnotation(O, Annot);
       return;
     }
   }
@@ -63,7 +63,7 @@
     printOperand(MI, 0, O);
     O << ", ";
     printOperand(MI, 1, O);
-    if (CommentStream) printAnnotation(*CommentStream, Annot);
+    if (CommentStream) printAnnotation(O, Annot);
     return;
   }
   
@@ -77,13 +77,13 @@
       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);
 }
 
 

Modified: llvm/trunk/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp Tue Sep 20 19:25:23 2011
@@ -47,7 +47,7 @@
   
   // If verbose assembly is enabled, we can print some informative comments.
   if (CommentStream) {
-    printAnnotation(*CommentStream, Annot);
+    printAnnotation(OS, Annot);
     EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
   }
 }

Modified: llvm/trunk/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp?rev=140217&r1=140216&r2=140217&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp Tue Sep 20 19:25:23 2011
@@ -38,7 +38,7 @@
   
   // If verbose assembly is enabled, we can print some informative comments.
   if (CommentStream) {
-    printAnnotation(*CommentStream, Annot);
+    printAnnotation(OS, Annot);
     EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
   }
 }





More information about the llvm-commits mailing list