[PATCH] D18195: [mips] Use `formatImm` call to print immediate value in the `MipsInstPrinter`

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 13:28:44 PDT 2016


atanasyan created this revision.
atanasyan added a reviewer: dsanders.
atanasyan added a subscriber: llvm-commits.
atanasyan set the repository for this revision to rL LLVM.
Herald added a reviewer: vkalintiris.
Herald added a subscriber: dsanders.

That allows, for example, to print hex-formatted immediates using llvm-objdump --print-imm-hex command line option.

Repository:
  rL LLVM

http://reviews.llvm.org/D18195

Files:
  lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
  test/MC/Mips/hex-immediates.s

Index: test/MC/Mips/hex-immediates.s
===================================================================
--- /dev/null
+++ 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
Index: lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
===================================================================
--- lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
+++ lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
@@ -195,7 +195,7 @@
   }
 
   if (Op.isImm()) {
-    O << Op.getImm();
+    O << formatImm(Op.getImm());
     return;
   }
 
@@ -211,7 +211,7 @@
     Imm -= Offset;
     Imm &= (1 << Bits) - 1;
     Imm += Offset;
-    O << Imm;
+    O << formatImm(Imm);
     return;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18195.50763.patch
Type: text/x-patch
Size: 954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160315/cffc0240/attachment.bin>


More information about the llvm-commits mailing list