summaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-09-15 18:36:29 +0000
committerOwen Anderson <resistor@mac.com>2011-09-15 18:36:29 +0000
commitede042dc8d59ff48a48ef8e2271f2a7ee8324ba5 (patch)
tree1863d77a0f4430e093ef2933f38f299a5992c74b /lib/Target
parent01afdb3a45f63af540b43b414c6094220a8f91e7 (diff)
downloadllvm-ede042dc8d59ff48a48ef8e2271f2a7ee8324ba5.tar.gz
llvm-ede042dc8d59ff48a48ef8e2271f2a7ee8324ba5.tar.bz2
llvm-ede042dc8d59ff48a48ef8e2271f2a7ee8324ba5.tar.xz
Add support for stored annotations to MCInst, and provide facilities for MC-based InstPrinters to print them out. Enhance the ARM and X86 InstPrinter's to do so in verbose mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp18
-rw-r--r--lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp4
-rw-r--r--lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp4
3 files changed, 23 insertions, 3 deletions
diff --git a/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp b/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
index 7eec0dddf8..289d1921d1 100644
--- a/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
+++ b/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
@@ -71,6 +71,9 @@ 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);
+
return;
}
@@ -87,10 +90,14 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
O << '\t' << getRegisterName(Dst.getReg())
<< ", " << getRegisterName(MO1.getReg());
- if (ARM_AM::getSORegShOp(MO2.getImm()) == ARM_AM::rrx)
+ if (ARM_AM::getSORegShOp(MO2.getImm()) == ARM_AM::rrx) {
+ if (CommentStream) printAnnotations(MI, *CommentStream);
return;
+ }
O << ", #" << translateShiftImm(ARM_AM::getSORegOffset(MO2.getImm()));
+
+ if (CommentStream) printAnnotations(MI, *CommentStream);
return;
}
@@ -104,6 +111,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
O << ".w";
O << '\t';
printRegisterList(MI, 4, O);
+ if (CommentStream) printAnnotations(MI, *CommentStream);
return;
}
if (Opcode == ARM::STR_PRE_IMM && MI->getOperand(2).getReg() == ARM::SP &&
@@ -111,6 +119,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);
return;
}
@@ -123,6 +132,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
O << ".w";
O << '\t';
printRegisterList(MI, 4, O);
+ if (CommentStream) printAnnotations(MI, *CommentStream);
return;
}
if (Opcode == ARM::LDR_POST_IMM && MI->getOperand(2).getReg() == ARM::SP &&
@@ -130,6 +140,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);
return;
}
@@ -141,6 +152,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);
return;
}
@@ -151,6 +163,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);
return;
}
@@ -169,6 +182,7 @@ void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
if (Writeback) O << "!";
O << ", ";
printRegisterList(MI, 3, O);
+ if (CommentStream) printAnnotations(MI, *CommentStream);
return;
}
@@ -177,10 +191,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);
return;
}
printInstruction(MI, O);
+ if (CommentStream) printAnnotations(MI, *CommentStream);
}
void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
diff --git a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
index 591b583831..76a1da4959 100644
--- a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
+++ b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
@@ -45,8 +45,10 @@ void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {
printInstruction(MI, OS);
// If verbose assembly is enabled, we can print some informative comments.
- if (CommentStream)
+ if (CommentStream) {
+ printAnnotations(MI, *CommentStream);
EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
+ }
}
StringRef X86ATTInstPrinter::getOpcodeName(unsigned Opcode) const {
diff --git a/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp b/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
index 506e26cbf7..6cca1d19b3 100644
--- a/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
+++ b/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
@@ -36,8 +36,10 @@ void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {
printInstruction(MI, OS);
// If verbose assembly is enabled, we can print some informative comments.
- if (CommentStream)
+ if (CommentStream) {
+ printAnnotations(MI, *CommentStream);
EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
+ }
}
StringRef X86IntelInstPrinter::getOpcodeName(unsigned Opcode) const {
return getInstructionName(Opcode);