[PATCH] Updated the Intel X86 disassembler to output annotated markup.
Richard Mitton
richard at codersnotes.com
Tue Jul 30 17:34:24 PDT 2013
I hate arcanist so much already. I fixed this diff to *only* include the files actually relevant to this single patch.
http://llvm-reviews.chandlerc.com/D1244
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1244?vs=3092&id=3095#toc
Files:
lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
Index: lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
===================================================================
--- lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
+++ lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
@@ -25,10 +25,14 @@
#include <cctype>
using namespace llvm;
+// Include the auto-generated portion of the assembly writer.
+//#define PRINT_ALIAS_INSTR
#include "X86GenAsmWriter1.inc"
void X86IntelInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
- OS << getRegisterName(RegNo);
+ OS << markup("<reg:")
+ << getRegisterName(RegNo)
+ << markup(">");
}
void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
@@ -142,10 +146,15 @@
if (Op.isReg()) {
printRegName(O, Op.getReg());
} else if (Op.isImm()) {
- O << formatImm((int64_t)Op.getImm());
+ // Print X86 immediates as signed values.
+ O << markup("<imm:")
+ << formatImm((int64_t)Op.getImm())
+ << markup(">");
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- O << *Op.getExpr();
+ O << markup("<imm:")
+ << *Op.getExpr()
+ << markup(">");
}
}
@@ -157,6 +166,8 @@
const MCOperand &DispSpec = MI->getOperand(Op+3);
const MCOperand &SegReg = MI->getOperand(Op+4);
+ O << markup("<mem:");
+
// If this has a segment register, print it.
if (SegReg.getReg()) {
printOperand(MI, Op+4, O);
@@ -174,7 +185,12 @@
if (IndexReg.getReg()) {
if (NeedPlus) O << " + ";
if (ScaleVal != 1)
- O << ScaleVal << '*';
+ {
+ O << markup("<imm:")
+ << ScaleVal // never printed in hex.
+ << markup(">")
+ << '*';
+ }
printOperand(MI, Op+2, O);
NeedPlus = true;
}
@@ -199,4 +215,5 @@
}
O << ']';
+ O << markup(">");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1244.2.patch
Type: text/x-patch
Size: 1822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130730/2f9ca97e/attachment.bin>
More information about the llvm-commits
mailing list