summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2016-03-17 10:43:36 +0000
committerSimon Atanasyan <simon@atanasyan.com>2016-03-17 10:43:36 +0000
commit58ee875296e1f32d561f5cde1a9bcc8383c032c9 (patch)
tree314a15cfe548de017d435915c4678db5ba052970
parentd65377da7808928963bc1685dd5eb510039fa068 (diff)
downloadbcm5719-llvm-58ee875296e1f32d561f5cde1a9bcc8383c032c9.tar.gz
bcm5719-llvm-58ee875296e1f32d561f5cde1a9bcc8383c032c9.zip
[mips] Use `formatImm` call to print immediate value in the `MipsInstPrinter`
That allows, for example, to print hex-formatted immediates using llvm-objdump --print-imm-hex command line option. Differential Revision: http://reviews.llvm.org/D18195 llvm-svn: 263704
-rw-r--r--llvm/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp4
-rw-r--r--llvm/test/MC/Mips/hex-immediates.s11
2 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp b/llvm/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
index f2ef0b2ad77..768ed20f4db 100644
--- a/llvm/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
+++ b/llvm/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
@@ -195,7 +195,7 @@ void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
}
if (Op.isImm()) {
- O << Op.getImm();
+ O << formatImm(Op.getImm());
return;
}
@@ -211,7 +211,7 @@ void MipsInstPrinter::printUImm(const MCInst *MI, int opNum, raw_ostream &O) {
Imm -= Offset;
Imm &= (1 << Bits) - 1;
Imm += Offset;
- O << Imm;
+ O << formatImm(Imm);
return;
}
diff --git a/llvm/test/MC/Mips/hex-immediates.s b/llvm/test/MC/Mips/hex-immediates.s
new file mode 100644
index 00000000000..7bf6f71266e
--- /dev/null
+++ b/llvm/test/MC/Mips/hex-immediates.s
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -filetype=obj %s -triple=mips-unknown-linux \
+# RUN: | llvm-objdump -d --print-imm-hex - | FileCheck %s
+
+# CHECK: jal 0x20
+# CHECK: addiu $sp, $sp, -0x20
+# CHECK: sw $2, 0x10($fp)
+
+jal 32
+addiu $sp, $sp, -32
+sw $2, 16($fp)
+lui $2, 2
OpenPOWER on IntegriCloud