summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-09-21 00:25:23 +0000
committerOwen Anderson <resistor@mac.com>2011-09-21 00:25:23 +0000
commit317eaf19937813d630166bfec7b933a98ea89aa5 (patch)
tree32ad1598b803064d80b4277c2791ac76808cdb87 /lib
parenteeef9e81802e7753236ed2087c6d7e9bcf0190cf (diff)
downloadllvm-317eaf19937813d630166bfec7b933a98ea89aa5.tar.gz
llvm-317eaf19937813d630166bfec7b933a98ea89aa5.tar.bz2
llvm-317eaf19937813d630166bfec7b933a98ea89aa5.tar.xz
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140217 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCDisassembler/Disassembler.cpp2
-rw-r--r--lib/MC/MCInstPrinter.cpp8
-rw-r--r--lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp24
-rw-r--r--lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp2
-rw-r--r--lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp2
-rw-r--r--lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp2
-rw-r--r--lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp8
-rw-r--r--lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp2
-rw-r--r--lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp2
9 files changed, 28 insertions, 24 deletions
diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp
index 14fab08b87..07e005627f 100644
--- a/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/lib/MC/MCDisassembler/Disassembler.cpp
@@ -82,8 +82,6 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
Ctx, DisAsm, IP);
assert(DC && "Allocation failure!");
- IP->setCommentStream(DC->CommentStream);
-
return DC;
}
diff --git a/lib/MC/MCInstPrinter.cpp b/lib/MC/MCInstPrinter.cpp
index e15e107616..5dbd4b015d 100644
--- a/lib/MC/MCInstPrinter.cpp
+++ b/lib/MC/MCInstPrinter.cpp
@@ -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";
+ }
}
diff --git a/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp b/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
index 5bbd19fd75..277d44cfac 100644
--- a/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
+++ b/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
@@ -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,
diff --git a/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp b/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp
index 7ece492c2f..f470be30f0 100644
--- a/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp
+++ b/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp
@@ -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,
diff --git a/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp b/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
index 18151f4c6d..10a8f9ac70 100644
--- a/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
+++ b/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
@@ -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,
diff --git a/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp b/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
index 7c7dca2862..e26fb1474c 100644
--- a/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
+++ b/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
@@ -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,
diff --git a/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp b/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
index c22b13a447..ac5eb77ead 100644
--- a/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
+++ b/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
@@ -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);
}
diff --git a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
index 1fefd57511..029d491260 100644
--- a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
+++ b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
@@ -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);
}
}
diff --git a/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp b/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
index 8ff3ac89e4..f9ab5aeee1 100644
--- a/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
+++ b/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
@@ -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);
}
}