[obj2yaml] - Fix a comment. NFC.
[llvm-complete.git] / test / MC / RISCV / fixups.s
blob1ec704857343ba063689436ac344bacb03db5fb4
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
10 # applied correctly
12 .LBB0:
13 lui t1, %hi(val)
14 # CHECK-FIXUP: fixup A - offset: 0, value: %hi(val), kind: fixup_riscv_hi20
15 # CHECK-INSTR: lui t1, 74565
17 lw a0, %lo(val)(t1)
18 # CHECK-FIXUP: fixup A - offset: 0, value: %lo(val), kind: fixup_riscv_lo12_i
19 # CHECK-INSTR: lw a0, 1656(t1)
20 addi a1, t1, %lo(val)
21 # CHECK-FIXUP: fixup A - offset: 0, value: %lo(val), kind: fixup_riscv_lo12_i
22 # CHECK-INSTR: addi a1, t1, 1656
23 sw a0, %lo(val)(t1)
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)
38 jal zero, .LBB0
39 # CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_riscv_jal
40 # CHECK-INSTR: jal zero, -28
41 jal zero, .LBB2
42 # CHECK-FIXUP: fixup A - offset: 0, value: .LBB2, kind: fixup_riscv_jal
43 # CHECK-INSTR: jal zero, 330996
44 beq a0, a1, .LBB0
45 # CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_riscv_branch
46 # CHECK-INSTR: beq a0, a1, -36
47 blt a0, a1, .LBB1
48 # CHECK-FIXUP: fixup A - offset: 0, value: .LBB1, kind: fixup_riscv_branch
49 # CHECK-INSTR: blt a0, a1, 1108
51 .fill 1104
53 .LBB1:
55 .fill 329876
56 addi zero, zero, 0
57 .LBB2:
59 .set val, 0x12345678
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.
66 func:
67 .fill 100
68 call func
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)
73 .fill 10000
74 call func
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)
79 .fill 20888
80 call func
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)