Don't attach annotations to MCInst's. Instead, have the disassembler return, and...
authorOwen Anderson <resistor@mac.com>
Thu, 15 Sep 2011 23:38:46 +0000 (23:38 +0000)
committerOwen Anderson <resistor@mac.com>
Thu, 15 Sep 2011 23:38:46 +0000 (23:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139876 91177308-0d34-0410-b5e6-96231b3b80d8

31 files changed:
include/llvm/MC/MCDisassembler.h
include/llvm/MC/MCInst.h
include/llvm/MC/MCInstPrinter.h
lib/MC/MCAsmStreamer.cpp
lib/MC/MCDisassembler/Disassembler.cpp
lib/MC/MCDisassembler/EDDisassembler.cpp
lib/MC/MCInst.cpp
lib/MC/MCInstPrinter.cpp
lib/Target/ARM/Disassembler/ARMDisassembler.cpp
lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
lib/Target/ARM/InstPrinter/ARMInstPrinter.h
lib/Target/MBlaze/Disassembler/MBlazeDisassembler.cpp
lib/Target/MBlaze/Disassembler/MBlazeDisassembler.h
lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp
lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.h
lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
lib/Target/MSP430/InstPrinter/MSP430InstPrinter.h
lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
lib/Target/Mips/InstPrinter/MipsInstPrinter.h
lib/Target/PTX/PTXMCAsmStreamer.cpp
lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h
lib/Target/X86/Disassembler/X86Disassembler.cpp
lib/Target/X86/Disassembler/X86Disassembler.h
lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
lib/Target/X86/InstPrinter/X86ATTInstPrinter.h
lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
lib/Target/X86/InstPrinter/X86IntelInstPrinter.h
tools/llvm-mc/Disassembler.cpp
tools/llvm-objdump/MCFunction.cpp
tools/llvm-objdump/llvm-objdump.cpp

index 404b8aa98522ea08a1465684ba4eea63f980d0b9..f7a9f1c9d9a775e938e4d55e994c3651f70bc0de 100644 (file)
@@ -70,6 +70,7 @@ public:
   /// @param address  - The address, in the memory space of region, of the first
   ///                   byte of the instruction.
   /// @param vStream  - The stream to print warnings and diagnostic messages on.
+  /// @param cStream  - The stream to print comments and annotations on.
   /// @return         - MCDisassembler::Success if the instruction is valid,
   ///                   MCDisassembler::SoftFail if the instruction was 
   ///                                            disassemblable but invalid,
@@ -78,7 +79,8 @@ public:
                                        uint64_t& size,
                                        const MemoryObject &region,
                                        uint64_t address,
-                                       raw_ostream &vStream) const = 0;
+                                       raw_ostream &vStream,
+                                       raw_ostream &cStream) const = 0;
 
   /// getEDInfo - Returns the enhanced instruction information corresponding to
   ///   the disassembler.
index d443536d40f979bfab2fdacd1bc2738c47d5e2b8..d384764774958e01d363873c410f626e55a7a5a6 100644 (file)
@@ -129,7 +129,6 @@ public:
 class MCInst {
   unsigned Opcode;
   SmallVector<MCOperand, 8> Operands;
-  SmallVector<std::string, 1> Annotations;
 public:
   MCInst() : Opcode(0) {}
 
@@ -145,15 +144,7 @@ public:
     Operands.push_back(Op);
   }
 
-  void addAnnotation(const std::string &Annot) {
-    Annotations.push_back(Annot);
-  }
-
-  void clear() {
-    Operands.clear();
-    Annotations.clear();
-  }
-
+  void clear() { Operands.clear(); }
   size_t size() { return Operands.size(); }
 
   typedef SmallVector<MCOperand, 8>::iterator iterator;
@@ -163,9 +154,6 @@ public:
     return Operands.insert(I, Op);
   }
 
-  size_t getNumAnnotations() const { return Annotations.size(); }
-  std::string getAnnotation(size_t i) const { return Annotations[i]; }
-
   void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
   void dump() const;
 
index 4c12d10d5be02448e5b97da1442745b81b5185c4..01ad2d3f8088247d2f6f3653513073057fd5f8eb 100644 (file)
@@ -28,6 +28,9 @@ protected:
 
   /// The current set of available features.
   unsigned AvailableFeatures;
+
+  /// Utility function for printing annotations.
+  void printAnnotation(raw_ostream &OS, StringRef Annot);
 public:
   MCInstPrinter(const MCAsmInfo &mai)
     : CommentStream(0), MAI(mai), AvailableFeatures(0) {}
@@ -39,11 +42,8 @@ public:
 
   /// printInst - Print the specified MCInst to the specified raw_ostream.
   ///
-  virtual void printInst(const MCInst *MI, raw_ostream &OS) = 0;
-
-  /// printAnnotations - Print the annotation comments attached to specified
-  /// MCInst to the specified raw_ostream.
-  void printAnnotations(const MCInst *MI, raw_ostream &OS);
+  virtual void printInst(const MCInst *MI, raw_ostream &OS,
+                         StringRef Annot) = 0;
 
   /// getOpcodeName - Return the name of the specified opcode enum (e.g.
   /// "MOV32ri") or empty if we can't resolve it.
index 68154345c8d2adb678ab5e861b64519443fec0dd..3fcbb05907bcf564fd52707729994386793ae406 100644 (file)
@@ -1244,7 +1244,7 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
 
   // If we have an AsmPrinter, use that to print, otherwise print the MCInst.
   if (InstPrinter)
-    InstPrinter->printInst(&Inst, OS);
+    InstPrinter->printInst(&Inst, OS, "");
   else
     Inst.print(OS, &MAI);
   EmitEOL();
index 858a58cf35e988da5ee358f403d2147330e10803..14fab08b87485eb2963caaa761c149cdc5e20304 100644 (file)
@@ -144,7 +144,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
   MCInstPrinter *IP = DC->getIP();
   MCDisassembler::DecodeStatus S;
   S = DisAsm->getInstruction(Inst, Size, MemoryObject, PC,
-                             /*REMOVE*/ nulls());
+                             /*REMOVE*/ nulls(), DC->CommentStream);
   switch (S) {
   case MCDisassembler::Fail:
   case MCDisassembler::SoftFail:
@@ -152,28 +152,16 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
     return 0;
 
   case MCDisassembler::Success: {
-    SmallVector<char, 64> InsnStr;
-    raw_svector_ostream OS(InsnStr);
-    IP->printInst(&Inst, OS);
-    OS.flush();
-
     DC->CommentStream.flush();
-    assert(DC->CommentsToEmit.back() == '\n');
-
-    DC->CommentsToEmit.push_back('\n');
     StringRef Comments = DC->CommentsToEmit.str();
 
-    do {
-      // Emit a line of comments.
-      size_t Position = Comments.find('\n');
-      OS << ' ' << DC->getAsmInfo()->getCommentString()
-         << ' ' << Comments.substr(0, Position) << '\n';
-
-      Comments = Comments.substr(Position+1);
-    } while (!Comments.empty());
+    SmallVector<char, 64> InsnStr;
+    raw_svector_ostream OS(InsnStr);
+    IP->printInst(&Inst, OS, Comments);
+    OS.flush();
 
-    DC->CommentsToEmit.clear();
     // Tell the comment stream that the vector changed underneath it.
+    DC->CommentsToEmit.clear();
     DC->CommentStream.resync();
 
     assert(OutStringSize != 0 && "Output buffer cannot be zero size");
index 70b6300d74b97a5ed106c0b8665a27549c07f19e..83362a21f77b32a445e05943d48f24c7b855f756 100644 (file)
@@ -246,7 +246,7 @@ EDInst *EDDisassembler::createInst(EDByteReaderCallback byteReader,
   
   MCDisassembler::DecodeStatus S;
   S = Disassembler->getInstruction(*inst, byteSize, memoryObject, address,
-                                   ErrorStream);
+                                   ErrorStream, nulls());
   switch (S) {
   case MCDisassembler::Fail:
   case MCDisassembler::SoftFail:
@@ -327,7 +327,7 @@ bool EDDisassembler::registerIsProgramCounter(unsigned registerID) {
 int EDDisassembler::printInst(std::string &str, MCInst &inst) {
   PrinterMutex.acquire();
   
-  InstPrinter->printInst(&inst, *InstStream);
+  InstPrinter->printInst(&inst, *InstStream, "");
   InstStream->flush();
   str = *InstString;
   InstString->clear();
index ec97acc554f5786c85263523a67f4ecd58a02bf8..4cb628b395c3fba2ca0a61d26fa32499f235d217 100644 (file)
@@ -41,16 +41,6 @@ void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
     OS << " ";
     getOperand(i).print(OS, MAI);
   }
-
-  if (getNumAnnotations()) {
-    OS << " # Annots: ";
-    for (unsigned i = 0, e = getNumAnnotations(); i != e; ++i) {
-      OS << " \"";
-      OS << getAnnotation(i);
-      OS << '"';
-    }
-  }
-
   OS << ">";
 }
 
@@ -67,17 +57,6 @@ void MCInst::dump_pretty(raw_ostream &OS, const MCAsmInfo *MAI,
     OS << Separator;
     getOperand(i).print(OS, MAI);
   }
-
-  if (getNumAnnotations()) {
-    OS << " # Annots: ";
-    for (unsigned i = 0, e = getNumAnnotations(); i != e; ++i) {
-      OS << Separator;
-      OS << '"';
-      OS << getAnnotation(i);
-      OS << '"';
-    }
-  }
-
   OS << ">";
 }
 
index f0fa2cda4a8319ac0a2fb851a3ba0c8b58c34062..e15e10761699473f0959ab9e4c92610572877ef0 100644 (file)
@@ -8,8 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/MC/MCInstPrinter.h"
-#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCInst.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
@@ -27,8 +25,6 @@ void MCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
   assert(0 && "Target should implement this");
 }
 
-void MCInstPrinter::printAnnotations(const MCInst *MI, raw_ostream &OS) {
-  for (unsigned i = 0, e = MI->getNumAnnotations(); i != e; ++i) {
-    OS << MI->getAnnotation(i) << "\n";
-  }
+void MCInstPrinter::printAnnotation(raw_ostream &OS, StringRef Annot) {
+  if (!Annot.empty()) OS << Annot << "\n";
 }
index 6b86e41c45231909d067a4405d3e7a93d81c6579..685b921b4ed58136e64b9277376cb79d3528831d 100644 (file)
@@ -47,7 +47,8 @@ public:
                               uint64_t &size,
                               const MemoryObject &region,
                               uint64_t address,
-                              raw_ostream &vStream) const;
+                              raw_ostream &vStream,
+                              raw_ostream &cStream) const;
 
   /// getEDInfo - See MCDisassembler.
   EDInstInfo *getEDInfo() const;
@@ -71,7 +72,8 @@ public:
                               uint64_t &size,
                               const MemoryObject &region,
                               uint64_t address,
-                              raw_ostream &vStream) const;
+                              raw_ostream &vStream,
+                              raw_ostream &cStream) const;
 
   /// getEDInfo - See MCDisassembler.
   EDInstInfo *getEDInfo() const;
@@ -328,7 +330,8 @@ EDInstInfo *ThumbDisassembler::getEDInfo() const {
 DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
                                              const MemoryObject &Region,
                                              uint64_t Address,
-                                             raw_ostream &os) const {
+                                             raw_ostream &os,
+                                             raw_ostream &cs) const {
   uint8_t bytes[4];
 
   assert(!(STI.getFeatureBits() & ARM::ModeThumb) &&
@@ -527,7 +530,8 @@ void ThumbDisassembler::UpdateThumbVFPPredicate(MCInst &MI) const {
 DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
                                                const MemoryObject &Region,
                                                uint64_t Address,
-                                               raw_ostream &os) const {
+                                               raw_ostream &os,
+                                               raw_ostream &cs) const {
   uint8_t bytes[4];
 
   assert((STI.getFeatureBits() & ARM::ModeThumb) &&
index 289d1921d1c3e6b1d1d5788708d37d5d609aa645..0a0f1d07b53cf658f2e9a64def67dae189687946 100644 (file)
@@ -51,7 +51,8 @@ void ARMInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
   OS << getRegisterName(RegNo);
 }
 
-void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
+void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
+                               StringRef Annot) {
   unsigned Opcode = MI->getOpcode();
 
   // Check for MOVs and print canonical forms, instead.
@@ -71,9 +72,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
 
     O << ", " << getRegisterName(MO2.getReg());
     assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
-
-    if (CommentStream) printAnnotations(MI, *CommentStream);
-
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
 
@@ -91,13 +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) printAnnotations(MI, *CommentStream);
+      if (CommentStream) printAnnotation(*CommentStream, Annot);
       return;
     }
 
     O << ", #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
-
-    if (CommentStream) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
 
@@ -111,7 +109,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
       O << ".w";
     O << '\t';
     printRegisterList(MI, 4, O);
-    if (CommentStream) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
   if (Opcode == ARM::STR_PRE_IMM && MI->getOperand(2).getReg() == ARM::SP &&
@@ -119,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) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
 
@@ -132,7 +130,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
       O << ".w";
     O << '\t';
     printRegisterList(MI, 4, O);
-    if (CommentStream) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
   if (Opcode == ARM::LDR_POST_IMM && MI->getOperand(2).getReg() == ARM::SP &&
@@ -140,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) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
 
@@ -152,7 +150,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
     printPredicateOperand(MI, 2, O);
     O << '\t';
     printRegisterList(MI, 4, O);
-    if (CommentStream) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
 
@@ -163,7 +161,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
     printPredicateOperand(MI, 2, O);
     O << '\t';
     printRegisterList(MI, 4, O);
-    if (CommentStream) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
 
@@ -182,7 +180,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
     if (Writeback) O << "!";
     O << ", ";
     printRegisterList(MI, 3, O);
-    if (CommentStream) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
 
@@ -191,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) printAnnotations(MI, *CommentStream);
+    if (CommentStream) printAnnotation(*CommentStream, Annot);
     return;
   }
 
   printInstruction(MI, O);
-  if (CommentStream) printAnnotations(MI, *CommentStream);
+  if (CommentStream) printAnnotation(*CommentStream, Annot);
 }
 
 void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
index fd4c9c46fa1dc85565cb4128cf1d64791661cc16..a411e92f3bcf6c9f41cf5e1cc765b5cf8bbbc2ea 100644 (file)
@@ -25,7 +25,7 @@ class ARMInstPrinter : public MCInstPrinter {
 public:
     ARMInstPrinter(const MCAsmInfo &MAI, const MCSubtargetInfo &STI);
 
-  virtual void printInst(const MCInst *MI, raw_ostream &O);
+  virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
   virtual StringRef getOpcodeName(unsigned Opcode) const;
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
 
index 999080a5b04d65ab75613ac6e079acf2a94d5b03..fd761f1ca8c15b6519fe4103605a27c12412abd3 100644 (file)
@@ -497,7 +497,8 @@ MCDisassembler::DecodeStatus MBlazeDisassembler::getInstruction(MCInst &instr,
                                         uint64_t &size,
                                         const MemoryObject &region,
                                         uint64_t address,
-                                        raw_ostream &vStream) const {
+                                        raw_ostream &vStream,
+                                        raw_ostream &cStream) const {
   // The machine instruction.
   uint32_t insn;
   uint64_t read;
index 3d689dbcfeaf062060fa3d1615310705a9805351..0ac0d89efbe788270542be75bc26266128a10f65 100644 (file)
@@ -44,7 +44,8 @@ public:
                       uint64_t &size,
                       const MemoryObject &region,
                       uint64_t address,
-                      raw_ostream &vStream) const;
+                      raw_ostream &vStream,
+                      raw_ostream &cStream) const;
 
   /// getEDInfo - See MCDisassembler.
   EDInstInfo *getEDInfo() const;
index a7fd287990b7f4d6fe635610084b37bf0b45b371..7ece492c2f186588ecf58188e8ae3fceb7ce1345 100644 (file)
@@ -25,8 +25,10 @@ using namespace llvm;
 // Include the auto-generated portion of the assembly writer.
 #include "MBlazeGenAsmWriter.inc"
 
-void MBlazeInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
+void MBlazeInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
+                                  StringRef Annot) {
   printInstruction(MI, O);
+  if (CommentStream) printAnnotation(*CommentStream, Annot);
 }
 
 void MBlazeInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
index eacca410b9867e238c2aaa6b2d934b8747220e95..570ab08a07aad056378d84289a70db8ea7c4b597 100644 (file)
@@ -24,7 +24,7 @@ namespace llvm {
     MBlazeInstPrinter(const MCAsmInfo &MAI)
       : MCInstPrinter(MAI) {}
 
-    virtual void printInst(const MCInst *MI, raw_ostream &O);
+    virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
 
     // Autogenerated by tblgen.
     void printInstruction(const MCInst *MI, raw_ostream &O);
index e10d4fe7ca1654cf3e6b9c847cd4e92ac6a62f14..18151f4c6dee45a035f0017358c5e2855e4cdcd9 100644 (file)
@@ -25,8 +25,10 @@ using namespace llvm;
 // Include the auto-generated portion of the assembly writer.
 #include "MSP430GenAsmWriter.inc"
 
-void MSP430InstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
+void MSP430InstPrinter::printInst(const MCInst *MI, raw_ostream &O,
+                                  StringRef Annot) {
   printInstruction(MI, O);
+  if (CommentStream) printAnnotation(*CommentStream, Annot);
 }
 
 void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo,
index 82b342eccf7778842d84a6b4205366cb82bf8707..a1984a8aec197be0bf8911dc161b3f5709e9d8ca 100644 (file)
@@ -24,7 +24,7 @@ namespace llvm {
     MSP430InstPrinter(const MCAsmInfo &MAI)
         : MCInstPrinter(MAI) {}
 
-    virtual void printInst(const MCInst *MI, raw_ostream &O);
+    virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
 
     // Autogenerated by tblgen.
     void printInstruction(const MCInst *MI, raw_ostream &O);
index cb8992910521588b471960e2e97fab70e47855e3..7c7dca28626cabd73b04cc1038b0ded812e8548b 100644 (file)
@@ -69,8 +69,10 @@ void MipsInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
   OS << '$' << LowercaseString(getRegisterName(RegNo));
 }
 
-void MipsInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
+void MipsInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
+                                StringRef Annot) {
   printInstruction(MI, O);
+  if (CommentStream) printAnnotation(*CommentStream, Annot);
 }
 
 void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
index 76309a2471b98e35edf275a9816bd5d5f228347b..5c1116538c61021cd70eb9840e6f8f538527307e 100644 (file)
@@ -86,7 +86,7 @@ public:
   
   virtual StringRef getOpcodeName(unsigned Opcode) const;
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
-  virtual void printInst(const MCInst *MI, raw_ostream &O);
+  virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
   
 private:
   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
index 5003fb5b8f5d68ba0477cf3a1006c0594a683164..4925cbfcb915354989c6d60c70922a31c840892d 100644 (file)
@@ -513,7 +513,7 @@ void PTXMCAsmStreamer::EmitInstruction(const MCInst &Inst) {
 
   // If we have an AsmPrinter, use that to print, otherwise print the MCInst.
   if (InstPrinter)
-    InstPrinter->printInst(&Inst, OS);
+    InstPrinter->printInst(&Inst, OS, "");
   else
     Inst.print(OS, &MAI);
   EmitEOL();
index 8f34b19925ee40d7c34484c57553c8eabdb4c334..c22b13a447b8754974d808e86da62c7a74f4f156 100644 (file)
@@ -31,7 +31,8 @@ void PPCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
   OS << getRegisterName(RegNo);
 }
 
-void PPCInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
+void PPCInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
+                               StringRef Annot) {
   // Check for slwi/srwi mnemonics.
   if (MI->getOpcode() == PPC::RLWINM) {
     unsigned char SH = MI->getOperand(2).getImm();
@@ -50,6 +51,8 @@ void PPCInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
       O << ", ";
       printOperand(MI, 1, O);
       O << ", " << (unsigned int)SH;
+
+      if (CommentStream) printAnnotation(*CommentStream, Annot);
       return;
     }
   }
@@ -60,6 +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);
     return;
   }
   
@@ -73,11 +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);
       return;
     }
   }
   
   printInstruction(MI, O);
+  if (CommentStream) printAnnotation(*CommentStream, Annot);
 }
 
 
index d022a4496e84025de5c1b7e4882270ee7e67e461..4ed4b765c1c70c916e2648bd6da83a20a4f769d8 100644 (file)
@@ -32,7 +32,7 @@ public:
   }
   
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
-  virtual void printInst(const MCInst *MI, raw_ostream &O);
+  virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
   virtual StringRef getOpcodeName(unsigned Opcode) const;
   
   static const char *getInstructionName(unsigned Opcode);
index e5774bfd1605353a7de534f5e8ea92a89038bb05..884e690efae4fdca1b9a6198364ebe79bdf52fcc 100644 (file)
@@ -114,7 +114,8 @@ X86GenericDisassembler::getInstruction(MCInst &instr,
                                        uint64_t &size,
                                        const MemoryObject &region,
                                        uint64_t address,
-                                       raw_ostream &vStream) const {
+                                       raw_ostream &vStream,
+                                       raw_ostream &cStream) const {
   InternalInstruction internalInstr;
   
   int ret = decodeInstruction(&internalInstr,
index 419b8703097da45f35974e8cf48f15b68f534d25..6ac9a0ff1019a5a9a10dd627b87622941da3d625 100644 (file)
@@ -117,7 +117,8 @@ public:
                               uint64_t &size,
                               const MemoryObject &region,
                               uint64_t address,
-                              raw_ostream &vStream) const;
+                              raw_ostream &vStream,
+                              raw_ostream &cStream) const;
 
   /// getEDInfo - See MCDisassembler.
   EDInstInfo *getEDInfo() const;
index 76a1da49595f6638fbc8f7d8f3fb5067b3ee3fad..1fefd5751172f84e0faa71aa8265bb67a43b1b19 100644 (file)
@@ -39,14 +39,15 @@ void X86ATTInstPrinter::printRegName(raw_ostream &OS,
   OS << '%' << getRegisterName(RegNo);
 }
 
-void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {
+void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
+                                  StringRef Annot) {
   // Try to print any aliases first.
   if (!printAliasInstr(MI, OS))
     printInstruction(MI, OS);
   
   // If verbose assembly is enabled, we can print some informative comments.
   if (CommentStream) {
-    printAnnotations(MI, *CommentStream);
+    printAnnotation(*CommentStream, Annot);
     EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
   }
 }
index 5426e5cf38d9a7c28599dcb5fbe75e2ce12b4972..0293869b0a9b5efd24c853faf97193ddb33a4d5a 100644 (file)
@@ -25,7 +25,7 @@ public:
   X86ATTInstPrinter(const MCAsmInfo &MAI);
   
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
-  virtual void printInst(const MCInst *MI, raw_ostream &OS);
+  virtual void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot);
   virtual StringRef getOpcodeName(unsigned Opcode) const;
 
   // Autogenerated by tblgen, returns true if we successfully printed an
index 6cca1d19b3878be727b5df30a778456a0ec79066..8ff3ac89e43025ebb7f7fa162f3b60af51f1f284 100644 (file)
@@ -32,12 +32,13 @@ void X86IntelInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
   OS << getRegisterName(RegNo);
 }
 
-void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {
+void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
+                                    StringRef Annot) {
   printInstruction(MI, OS);
   
   // If verbose assembly is enabled, we can print some informative comments.
   if (CommentStream) {
-    printAnnotations(MI, *CommentStream);
+    printAnnotation(*CommentStream, Annot);
     EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
   }
 }
index e84a1940017d25f5149c0fa293cc662590c9cc22..6d5ec6226a9eb460de7e6eb425f3f2affea6a324 100644 (file)
@@ -27,7 +27,7 @@ public:
     : MCInstPrinter(MAI) {}
 
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
-  virtual void printInst(const MCInst *MI, raw_ostream &OS);
+  virtual void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot);
   virtual StringRef getOpcodeName(unsigned Opcode) const;
   
   // Autogenerated by tblgen.
index 60384f6c63ac3e341cdc703e393492c2af8a0efc..a9381b591a1f6cff30b4455bcdd20f4490ce59a8 100644 (file)
@@ -68,7 +68,7 @@ static bool PrintInsts(const MCDisassembler &DisAsm,
 
     MCDisassembler::DecodeStatus S;
     S = DisAsm.getInstruction(Inst, Size, memoryObject, Index,
-                              /*REMOVE*/ nulls());
+                              /*REMOVE*/ nulls(), nulls());
     switch (S) {
     case MCDisassembler::Fail:
       SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second),
@@ -83,7 +83,7 @@ static bool PrintInsts(const MCDisassembler &DisAsm,
       // Fall through
 
     case MCDisassembler::Success:
-      Printer.printInst(&Inst, Out);
+      Printer.printInst(&Inst, Out, "");
       Out << "\n";
       break;
     }
index 418e9d050c1a2f6a8fc084c37c16c71096d233a6..5f1649694dfabc7e6a51aa75c6f6c1f4b706acc6 100644 (file)
@@ -40,7 +40,7 @@ MCFunction::createFunctionFromMC(StringRef Name, const MCDisassembler *DisAsm,
   for (uint64_t Index = Start; Index < End; Index += Size) {
     MCInst Inst;
 
-    if (DisAsm->getInstruction(Inst, Size, Region, Index, DebugOut)) {
+    if (DisAsm->getInstruction(Inst, Size, Region, Index, DebugOut, nulls())) {
       if (Ana->isBranch(Inst)) {
         uint64_t targ = Ana->evaluateBranch(Inst, Index, Size);
         // FIXME: Distinguish relocations from nop jumps.
index c0022d403ed1d147db38dee4788158048380e5ef..4cfd4f4164a8f3cbaf20ba1ffb6f120f46f0b39b 100644 (file)
@@ -262,13 +262,14 @@ static void DisassembleInput(const StringRef &Filename) {
       if (!CFG) {
         for (Index = Start; Index < End; Index += Size) {
           MCInst Inst;
+
           if (DisAsm->getInstruction(Inst, Size, memoryObject, Index,
-                                     DebugOut)) {
+                                     DebugOut, nulls())) {
             uint64_t addr;
             if (error(i->getAddress(addr))) break;
             outs() << format("%8x:\t", addr + Index);
             DumpBytes(StringRef(Bytes.data() + Index, Size));
-            IP->printInst(&Inst, outs());
+            IP->printInst(&Inst, outs(), "");
             outs() << "\n";
           } else {
             errs() << ToolName << ": warning: invalid instruction encoding\n";
@@ -323,7 +324,7 @@ static void DisassembleInput(const StringRef &Filename) {
             // Simple loops.
             if (fi->second.contains(&fi->second))
               outs() << '\t';
-            IP->printInst(&Inst.Inst, outs());
+            IP->printInst(&Inst.Inst, outs(), "");
             outs() << '\n';
           }
         }
@@ -359,7 +360,7 @@ static void DisassembleInput(const StringRef &Filename) {
             // Escape special chars and print the instruction in mnemonic form.
             std::string Str;
             raw_string_ostream OS(Str);
-            IP->printInst(&i->second.getInsts()[ii].Inst, OS);
+            IP->printInst(&i->second.getInsts()[ii].Inst, OS, "");
             Out << DOT::EscapeString(OS.str()) << '|';
           }
           Out << "<o>\" shape=\"record\" ];\n";