1 # RUN: llvm-mc -triple riscv32 -riscv-no-aliases < %s -show-encoding \
2 # RUN: | FileCheck -check-prefix=CHECK-FIXUP %s
3 # RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
4 # RUN: | llvm-objdump -M no-aliases -d - \
5 # RUN: | FileCheck -check-prefix=CHECK-INSTR %s
6 # RUN: llvm-mc -filetype=obj -triple=riscv32 %s \
7 # RUN: | llvm-readobj -r | FileCheck %s -check-prefix=CHECK-REL
9 # Checks that fixups that can be resolved within the same object file are
14 # CHECK-FIXUP: fixup A - offset: 0, value: %hi(val), kind: fixup_riscv_hi20
15 # CHECK-INSTR: lui t1, 74565
18 # CHECK-FIXUP: fixup A - offset: 0, value: %lo(val), kind: fixup_riscv_lo12_i
19 # CHECK-INSTR: lw a0, 1656(t1)
21 # CHECK-FIXUP: fixup A - offset: 0, value: %lo(val), kind: fixup_riscv_lo12_i
22 # CHECK-INSTR: addi a1, t1, 1656
24 # CHECK-FIXUP: fixup A - offset: 0, value: %lo(val), kind: fixup_riscv_lo12_s
25 # CHECK-INSTR: sw a0, 1656(t1)
28 auipc t1
, %pcrel_hi
(.LBB0)
29 # CHECK-FIXUP: fixup A - offset: 0, value: %pcrel_hi(.LBB0), kind: fixup_riscv_pcrel_hi20
30 # CHECK-INSTR: auipc t1, 0
31 addi t1
, t1
, %pcrel_lo
(1b)
32 # CHECK-FIXUP: fixup A - offset: 0, value: %pcrel_lo(.Ltmp0), kind: fixup_riscv_pcrel_lo12_i
33 # CHECK-INSTR: addi t1, t1, -16
34 sw t1
, %pcrel_lo
(1b)(t1
)
35 # CHECK-FIXUP: fixup A - offset: 0, value: %pcrel_lo(.Ltmp0), kind: fixup_riscv_pcrel_lo12_s
36 # CHECK-INSTR: sw t1, -16(t1)
39 # CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_riscv_jal
40 # CHECK-INSTR: jal zero, -28
42 # CHECK-FIXUP: fixup A - offset: 0, value: .LBB2, kind: fixup_riscv_jal
43 # CHECK-INSTR: jal zero, 330996
45 # CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_riscv_branch
46 # CHECK-INSTR: beq a0, a1, -36
48 # CHECK-FIXUP: fixup A - offset: 0, value: .LBB1, kind: fixup_riscv_branch
49 # CHECK-INSTR: blt a0, a1, 1108
61 # CHECK-REL-NOT: R_RISCV
63 # Testing the function call offset could resovled by assembler
64 # when the function and the callsite within the same compile unit
65 # and the linker relaxation is disabled.
69 # CHECK-FIXUP: fixup A - offset: 0, value: func, kind: fixup_riscv_call
70 # CHECK-INSTR: auipc ra, 0
71 # CHECK-INSTR: jalr ra, -100(ra)
75 # CHECK-FIXUP: fixup A - offset: 0, value: func, kind: fixup_riscv_call
76 # CHECK-INSTR: auipc ra, 1048574
77 # CHECK-INSTR: jalr ra, -1916(ra)
81 # CHECK-FIXUP: fixup A - offset: 0, value: func, kind: fixup_riscv_call
82 # CHECK-INSTR: auipc ra, 1048568
83 # CHECK-INSTR: jalr ra, 1764(ra)