OSDN Git Service

[RISCV] Add support for %pcrel_lo.
[android-x86/external-llvm.git] / test / MC / RISCV / relocations.s
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
5
6 # Check prefixes:
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
10
11 .long foo
12 # RELOC: R_RISCV_32 foo
13
14 .quad foo
15 # RELOC: R_RISCV_64 foo
16
17 lui t1, %hi(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
21
22 lui t1, %hi(foo+4)
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
26
27 addi t1, t1, %lo(foo)
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
31
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
36
37 sb t1, %lo(foo)(a2)
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
41
42 sb t1, %lo(foo+4)(a2)
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
46
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
51
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
56
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
61
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
66
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
71
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
76
77 jal zero, foo
78 # RELOC: R_RISCV_JAL
79 # INSTR: jal zero, foo
80 # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_jal
81
82 bgeu a0, a1, foo
83 # RELOC: R_RISCV_BRANCH
84 # INSTR: bgeu a0, a1, foo
85 # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_branch
86
87 c.jal foo
88 # RELOC: R_RISCV_RVC_JUMP
89 # INSTR: c.jal foo
90 # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_rvc_jump
91
92 c.bnez a0, foo
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