summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-10 00:10:18 +0000
committerChris Lattner <sabre@nondot.org>2010-02-10 00:10:18 +0000
commit482bf69bfe033b5730f316d92d7503d4a99bd6b9 (patch)
treec6a5d6f11cc29dcea5ef56aa62268002bf718506 /llvm/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
parent509be1fe5ec243bfe9553bf2abaa53e239b34d69 (diff)
downloadbcm5719-llvm-482bf69bfe033b5730f316d92d7503d4a99bd6b9.tar.gz
bcm5719-llvm-482bf69bfe033b5730f316d92d7503d4a99bd6b9.zip
Add ability for MCInstPrinters to add comments for instructions.
Enhance the x86 backend to show the hex values of immediates in comments when they are large. For example: movl $1072693248, 4(%esp) ## imm = 0x3FF00000 llvm-svn: 95728
Diffstat (limited to 'llvm/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp')
-rw-r--r--llvm/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp b/llvm/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
index 81b0e8ffb79..38ccbf9d501 100644
--- a/llvm/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
+++ b/llvm/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
@@ -18,6 +18,7 @@
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/FormattedStream.h"
#include "X86GenInstrNames.inc"
using namespace llvm;
@@ -65,6 +66,10 @@ void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo) {
O << '%' << getRegisterName(Op.getReg());
} else if (Op.isImm()) {
O << '$' << Op.getImm();
+
+ if (CommentStream && (Op.getImm() > 255 || Op.getImm() < -256))
+ *CommentStream << format("imm = 0x%X\n", Op.getImm());
+
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
O << '$' << *Op.getExpr();
OpenPOWER on IntegriCloud