[llvm] be9f363 - [AVRInstPrinter] printOperand: support llvm-objdump --print-imm-hex
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 12 08:15:09 PDT 2020
Author: Fangrui Song
Date: 2020-07-12T08:14:52-07:00
New Revision: be9f363704a802b10b30d853f1bb6571e5ebed94
URL: https://github.com/llvm/llvm-project/commit/be9f363704a802b10b30d853f1bb6571e5ebed94
DIFF: https://github.com/llvm/llvm-project/commit/be9f363704a802b10b30d853f1bb6571e5ebed94.diff
LOG: [AVRInstPrinter] printOperand: support llvm-objdump --print-imm-hex
Differential Revision: https://reviews.llvm.org/D83634
Added:
llvm/test/MC/AVR/hex-immediates.s
Modified:
llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp
index 815a309a8cae..42fac5e2e000 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp
@@ -131,7 +131,7 @@ void AVRInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
O << getPrettyRegisterName(Op.getReg(), MRI);
}
} else if (Op.isImm()) {
- O << Op.getImm();
+ O << formatImm(Op.getImm());
} else {
assert(Op.isExpr() && "Unknown operand kind in printOperand");
O << *Op.getExpr();
diff --git a/llvm/test/MC/AVR/hex-immediates.s b/llvm/test/MC/AVR/hex-immediates.s
new file mode 100644
index 000000000000..ca4c8b9f3355
--- /dev/null
+++ b/llvm/test/MC/AVR/hex-immediates.s
@@ -0,0 +1,7 @@
+; RUN: llvm-mc -filetype=obj -triple=avr %s -o %t
+; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=DEC
+; RUN: llvm-objdump -d --print-imm-hex %t | FileCheck %s --check-prefix=HEX
+
+; DEC: ldi r24, 66
+; HEX: ldi r24, 0x42
+ ldi r24, 0x42
More information about the llvm-commits
mailing list