1 # RUN: llvm-mc -triple riscv32 -mattr=+c -riscv-no-aliases < %s -show-encoding \
2 # RUN: | FileCheck -check-prefix=INSTR -check-prefix=FIXUP %s
3 # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c < %s \
4 # RUN: | llvm-readobj -r | FileCheck -check-prefix=RELOC %s
7 # RELOC - Check the relocation in the object.
8 # FIXUP - Check the fixup on the instruction.
9 # INSTR - Check the instruction is handled properly by the ASMPrinter
12 # RELOC: R_RISCV_32 foo
15 # RELOC: R_RISCV_64 foo
18 # RELOC: R_RISCV_HI20 foo 0x0
19 # INSTR: lui t1, %hi(foo)
20 # FIXUP: fixup A - offset: 0, value: %hi(foo), kind: fixup_riscv_hi20
23 # RELOC: R_RISCV_HI20 foo 0x4
24 # INSTR: lui t1, %hi(foo+4)
25 # FIXUP: fixup A - offset: 0, value: %hi(foo+4), kind: fixup_riscv_hi20
28 # RELOC: R_RISCV_LO12_I foo 0x0
29 # INSTR: addi t1, t1, %lo(foo)
30 # FIXUP: fixup A - offset: 0, value: %lo(foo), kind: fixup_riscv_lo12_i
32 addi t1, t1, %lo(foo+4)
33 # RELOC: R_RISCV_LO12_I foo 0x4
34 # INSTR: addi t1, t1, %lo(foo+4)
35 # FIXUP: fixup A - offset: 0, value: %lo(foo+4), kind: fixup_riscv_lo12_i
38 # RELOC: R_RISCV_LO12_S foo 0x0
39 # INSTR: sb t1, %lo(foo)(a2)
40 # FIXUP: fixup A - offset: 0, value: %lo(foo), kind: fixup_riscv_lo12_s
43 # RELOC: R_RISCV_LO12_S foo 0x4
44 # INSTR: sb t1, %lo(foo+4)(a2)
45 # FIXUP: fixup A - offset: 0, value: %lo(foo+4), kind: fixup_riscv_lo12_s
47 auipc t1, %pcrel_hi(foo)
48 # RELOC: R_RISCV_PCREL_HI20 foo 0x0
49 # INSTR: auipc t1, %pcrel_hi(foo)
50 # FIXUP: fixup A - offset: 0, value: %pcrel_hi(foo), kind: fixup_riscv_pcrel_hi20
52 auipc t1, %pcrel_hi(foo+4)
53 # RELOC: R_RISCV_PCREL_HI20 foo 0x4
54 # INSTR: auipc t1, %pcrel_hi(foo+4)
55 # FIXUP: fixup A - offset: 0, value: %pcrel_hi(foo+4), kind: fixup_riscv_pcrel_hi20
57 addi t1, t1, %pcrel_lo(foo)
58 # RELOC: R_RISCV_PCREL_LO12_I foo 0x0
59 # INSTR: addi t1, t1, %pcrel_lo(foo)
60 # FIXUP: fixup A - offset: 0, value: %pcrel_lo(foo), kind: fixup_riscv_pcrel_lo12_i
62 addi t1, t1, %pcrel_lo(foo+4)
63 # RELOC: R_RISCV_PCREL_LO12_I foo 0x4
64 # INSTR: addi t1, t1, %pcrel_lo(foo+4)
65 # FIXUP: fixup A - offset: 0, value: %pcrel_lo(foo+4), kind: fixup_riscv_pcrel_lo12_i
67 sb t1, %pcrel_lo(foo)(a2)
68 # RELOC: R_RISCV_PCREL_LO12_S foo 0x0
69 # INSTR: sb t1, %pcrel_lo(foo)(a2)
70 # FIXUP: fixup A - offset: 0, value: %pcrel_lo(foo), kind: fixup_riscv_pcrel_lo12_s
72 sb t1, %pcrel_lo(foo+4)(a2)
73 # RELOC: R_RISCV_PCREL_LO12_S foo 0x4
74 # INSTR: sb t1, %pcrel_lo(foo+4)(a2)
75 # FIXUP: fixup A - offset: 0, value: %pcrel_lo(foo+4), kind: fixup_riscv_pcrel_lo12_s
79 # INSTR: jal zero, foo
80 # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_jal
83 # RELOC: R_RISCV_BRANCH
84 # INSTR: bgeu a0, a1, foo
85 # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_branch
88 # RELOC: R_RISCV_RVC_JUMP
90 # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_rvc_jump
93 # RELOC: R_RISCV_RVC_BRANCH
94 # INSTR: c.bnez a0, foo
95 # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_rvc_branch