summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
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
commitd1814791ade377c9020669e372066d7319773833 (patch)
tree2575bf161f925a2468b340c778a9c2b0ef63ae0f /llvm/lib/MC
parent53e2e48de7691f602a327c6a6c7d848b63f7ffbd (diff)
downloadbcm5719-llvm-d1814791ade377c9020669e372066d7319773833.tar.gz
bcm5719-llvm-d1814791ade377c9020669e372066d7319773833.zip
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.
llvm-svn: 139820
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/MCInst.cpp21
-rw-r--r--llvm/lib/MC/MCInstPrinter.cpp9
2 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCInst.cpp b/llvm/lib/MC/MCInst.cpp
index 4cb628b395c..ec97acc554f 100644
--- a/llvm/lib/MC/MCInst.cpp
+++ b/llvm/lib/MC/MCInst.cpp
@@ -41,6 +41,16 @@ 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 << ">";
}
@@ -57,6 +67,17 @@ 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 << ">";
}
diff --git a/llvm/lib/MC/MCInstPrinter.cpp b/llvm/lib/MC/MCInstPrinter.cpp
index 81a939ffaae..f0fa2cda4a8 100644
--- a/llvm/lib/MC/MCInstPrinter.cpp
+++ b/llvm/lib/MC/MCInstPrinter.cpp
@@ -8,7 +8,10 @@
//===----------------------------------------------------------------------===//
#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;
MCInstPrinter::~MCInstPrinter() {
@@ -23,3 +26,9 @@ StringRef MCInstPrinter::getOpcodeName(unsigned Opcode) const {
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";
+ }
+}
OpenPOWER on IntegriCloud