ARM: honor hex immediate formatting for ldr/str i12 offsets.
authorJim Grosbach <grosbach@apple.com>
Wed, 11 Jun 2014 20:26:45 +0000 (20:26 +0000)
committerJim Grosbach <grosbach@apple.com>
Wed, 11 Jun 2014 20:26:45 +0000 (20:26 +0000)
Previously we would always print the offset as decimal, regardless of
the formatting requested. Now we use the formatImm() helper so the value
is printed as the client (LLDB in the motivating example) requested.

Before:
ldr.w r8, [sp, #180] @ always

After:
ldr.w r8, [sp, #0xb4] @ when printing hex immediates
ldr.w r8, [sp, #0180] @ when printing decimal immediates

rdar://17237103

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210701 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
test/MC/Disassembler/ARM/hex-immediates.txt

index e4b785def87caf1eba627f65631212cf90b3938c..228fb5756ca862de0c46597cc2417dd805e6555f 100644 (file)
@@ -1092,13 +1092,13 @@ void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
   if (isSub) {
     O << ", "
       << markup("<imm:")
-      << "#-" << -OffImm
+      << "#-" << formatImm(-OffImm)
       << markup(">");
   }
   else if (AlwaysPrintImm0 || OffImm > 0) {
     O << ", "
       << markup("<imm:")
-      << "#" << OffImm
+      << "#" << formatImm(OffImm)
       << markup(">");
   }
   O << "]" << markup(">");
index f30e05b59042d484e088534c1e665280dc71cf8f..875d6679d239e99cc73ec659cfe02a253a846e51 100644 (file)
@@ -3,3 +3,9 @@
 0x08 0x4c
 # CHECK: sub   sp, #0x84
 0xa1 0xb0
+# CHECK: ldr  r0, [sp, #0xb4]
+0x2d 0x98
+# CHECK: str.w  r8, [sp, #0xb4]
+0xcd 0xf8 0xb4 0x80
+# CHECK: ldr.w  r8, [sp, #0xb4]
+0xdd 0xf8 0xb4 0x80