mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
615374a840
Add support for 'objdump -print-imm-hex' for imm64, operand imm and branch target. If user programs encode immediate values as hex numbers, such an option will make it easy to correlate asm insns with source code. This option also makes it easy to correlate imm values with insn encoding. There is one changed behavior in this patch. In old way, we print the 64bit imm as u64: O << (uint64_t)Op.getImm(); and the new way is: O << formatImm(Op.getImm()); The formatImm is defined in llvm/MC/MCInstPrinter.h as format_object<int64_t> formatImm(int64_t Value) So the new way to print 64bit imm is i64 type. If a 64bit value has the highest bit set, the old way will print the value as a positive value and the new way will print as a negative value. The new way is consistent with x86_64. For the code (see the test program): ... if (a == 0xABCDABCDabcdabcdULL) ... x86_64 objdump, with and without -print-imm-hex, looks like: 48 b8 cd ab cd ab cd ab cd ab movabsq $-6067004223159161907, %rax 48 b8 cd ab cd ab cd ab cd ab movabsq $-0x5432543254325433, %rax Signed-off-by: Yonghong Song <yhs@fb.com> llvm-svn: 321215
66 lines
2.3 KiB
LLVM
66 lines
2.3 KiB
LLVM
; RUN: llc -march=bpfel -filetype=obj -o - %s | llvm-objdump -d - | FileCheck --check-prefix=CHECK-DEC %s
|
|
; RUN: llc -march=bpfel -filetype=obj -o - %s | llvm-objdump -d -print-imm-hex - | FileCheck --check-prefix=CHECK-HEX %s
|
|
|
|
; Source Code:
|
|
; int gbl;
|
|
; int test(unsigned long long a, unsigned long long b) {
|
|
; int ret = 0;
|
|
; if (a == 0xABCDABCDabcdabcdULL) {
|
|
; gbl = gbl * gbl * 2;
|
|
; ret = 1;
|
|
; goto out;
|
|
; }
|
|
; if (b == 0xABCDabcdabcdULL) {
|
|
; gbl = gbl * 4;
|
|
; ret = 2;
|
|
; }
|
|
; out:
|
|
; return ret;
|
|
; }
|
|
|
|
@gbl = common local_unnamed_addr global i32 0, align 4
|
|
|
|
; Function Attrs: norecurse nounwind
|
|
define i32 @test(i64, i64) local_unnamed_addr #0 {
|
|
; CHECK-LABEL: test
|
|
%3 = icmp eq i64 %0, -6067004223159161907
|
|
br i1 %3, label %4, label %8
|
|
; CHECK-DEC: 18 03 00 00 cd ab cd ab 00 00 00 00 cd ab cd ab r3 = -6067004223159161907 ll
|
|
; CHECK-DEC: 5d 31 07 00 00 00 00 00 if r1 != r3 goto +7
|
|
; CHECK-HEX: 18 03 00 00 cd ab cd ab 00 00 00 00 cd ab cd ab r3 = -0x5432543254325433 ll
|
|
; CHECK-HEX: 5d 31 07 00 00 00 00 00 if r1 != r3 goto +0x7
|
|
|
|
; <label>:4: ; preds = %2
|
|
%5 = load i32, i32* @gbl, align 4
|
|
%6 = shl i32 %5, 1
|
|
; CHECK-DEC: 67 01 00 00 01 00 00 00 r1 <<= 1
|
|
; CHECK-HEX: 67 01 00 00 01 00 00 00 r1 <<= 0x1
|
|
%7 = mul i32 %6, %5
|
|
br label %13
|
|
|
|
; <label>:8: ; preds = %2
|
|
%9 = icmp eq i64 %1, 188899839028173
|
|
; CHECK-DEC: 18 01 00 00 cd ab cd ab 00 00 00 00 cd ab 00 00 r1 = 188899839028173 ll
|
|
; CHECK-HEX: 18 01 00 00 cd ab cd ab 00 00 00 00 cd ab 00 00 r1 = 0xabcdabcdabcd ll
|
|
br i1 %9, label %10, label %16
|
|
|
|
; <label>:10: ; preds = %8
|
|
%11 = load i32, i32* @gbl, align 4
|
|
%12 = shl nsw i32 %11, 2
|
|
br label %13
|
|
|
|
; <label>:13: ; preds = %4, %10
|
|
%14 = phi i32 [ %12, %10 ], [ %7, %4 ]
|
|
%15 = phi i32 [ 2, %10 ], [ 1, %4 ]
|
|
store i32 %14, i32* @gbl, align 4
|
|
; CHECK-DEC: 63 12 00 00 00 00 00 00 *(u32 *)(r2 + 0) = r1
|
|
; CHECK-HEX: 63 12 00 00 00 00 00 00 *(u32 *)(r2 + 0x0) = r1
|
|
br label %16
|
|
|
|
; <label>:16: ; preds = %13, %8
|
|
%17 = phi i32 [ 0, %8 ], [ %15, %13 ]
|
|
ret i32 %17
|
|
}
|
|
|
|
attributes #0 = { norecurse nounwind }
|