1 # RUN: llvm-mc %s -triple=riscv32 \
2 # RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-NOPIC,CHECK-RV32
3 # RUN: llvm-mc %s -triple=riscv64 \
4 # RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-NOPIC,CHECK-RV64
5 # RUN: llvm-mc %s -triple=riscv32 -position-independent \
6 # RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-PIC,CHECK-RV32,CHECK-PIC-RV32
7 # RUN: llvm-mc %s -triple=riscv64 -position-independent \
8 # RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-PIC,CHECK-RV64,CHECK-PIC-RV64
11 # CHECK: auipc a0, %pcrel_hi(a_symbol)
12 # CHECK: addi a0, a0, %pcrel_lo(.Lpcrel_hi0)
16 # CHECK: auipc a1, %pcrel_hi(another_symbol)
17 # CHECK: addi a1, a1, %pcrel_lo(.Lpcrel_hi1)
18 lla a1
, another_symbol
20 # Check that we can load the address of symbols that are spelled like a register
22 # CHECK: auipc a2, %pcrel_hi(zero)
23 # CHECK: addi a2, a2, %pcrel_lo(.Lpcrel_hi2)
27 # CHECK: auipc a3, %pcrel_hi(ra)
28 # CHECK: addi a3, a3, %pcrel_lo(.Lpcrel_hi3)
32 # CHECK: auipc a4, %pcrel_hi(f1)
33 # CHECK: addi a4, a4, %pcrel_lo(.Lpcrel_hi4)
37 # CHECK: auipc a5, %pcrel_hi(a_symbol+2040)
38 # CHECK: addi a5, a5, %pcrel_lo(.Lpcrel_hi5)
39 lla a5
, a_symbol
+ (0xFF << 3)
42 # CHECK-NOPIC: auipc a0, %pcrel_hi(a_symbol)
43 # CHECK-NOPIC: addi a0, a0, %pcrel_lo(.Lpcrel_hi6)
44 # CHECK-PIC: auipc a0, %got_pcrel_hi(a_symbol)
45 # CHECK-PIC-RV32: lw a0, %pcrel_lo(.Lpcrel_hi6)(a0)
46 # CHECK-PIC-RV64: ld a0, %pcrel_lo(.Lpcrel_hi6)(a0)
50 # CHECK-NOPIC: auipc a1, %pcrel_hi(another_symbol)
51 # CHECK-NOPIC: addi a1, a1, %pcrel_lo(.Lpcrel_hi7)
52 # CHECK-PIC: auipc a1, %got_pcrel_hi(another_symbol)
53 # CHECK-PIC-RV32: lw a1, %pcrel_lo(.Lpcrel_hi7)(a1)
54 # CHECK-PIC-RV64: ld a1, %pcrel_lo(.Lpcrel_hi7)(a1)
57 # Check that we can load the address of symbols that are spelled like a register
59 # CHECK-NOPIC: auipc a2, %pcrel_hi(zero)
60 # CHECK-NOPIC: addi a2, a2, %pcrel_lo(.Lpcrel_hi8)
61 # CHECK-PIC: auipc a2, %got_pcrel_hi(zero)
62 # CHECK-PIC-RV32: lw a2, %pcrel_lo(.Lpcrel_hi8)(a2)
63 # CHECK-PIC-RV64: ld a2, %pcrel_lo(.Lpcrel_hi8)(a2)
67 # CHECK-NOPIC: auipc a3, %pcrel_hi(ra)
68 # CHECK-NOPIC: addi a3, a3, %pcrel_lo(.Lpcrel_hi9)
69 # CHECK-PIC: auipc a3, %got_pcrel_hi(ra)
70 # CHECK-PIC-RV32: lw a3, %pcrel_lo(.Lpcrel_hi9)(a3)
71 # CHECK-PIC-RV64: ld a3, %pcrel_lo(.Lpcrel_hi9)(a3)
74 # CHECK: .Lpcrel_hi10:
75 # CHECK-NOPIC: auipc a4, %pcrel_hi(f1)
76 # CHECK-NOPIC: addi a4, a4, %pcrel_lo(.Lpcrel_hi10)
77 # CHECK-PIC: auipc a4, %got_pcrel_hi(f1)
78 # CHECK-PIC-RV32: lw a4, %pcrel_lo(.Lpcrel_hi10)(a4)
79 # CHECK-PIC-RV64: ld a4, %pcrel_lo(.Lpcrel_hi10)(a4)
82 # CHECK: .Lpcrel_hi11:
83 # CHECK: auipc a0, %tls_ie_pcrel_hi(a_symbol)
84 # CHECK-RV32: lw a0, %pcrel_lo(.Lpcrel_hi11)(a0)
85 # CHECK-RV64: ld a0, %pcrel_lo(.Lpcrel_hi11)(a0)
86 la.tls.ie a0
, a_symbol
88 # CHECK: .Lpcrel_hi12:
89 # CHECK: auipc a1, %tls_ie_pcrel_hi(another_symbol)
90 # CHECK-RV32: lw a1, %pcrel_lo(.Lpcrel_hi12)(a1)
91 # CHECK-RV64: ld a1, %pcrel_lo(.Lpcrel_hi12)(a1)
92 la.tls.ie a1
, another_symbol
94 # Check that we can load the address of symbols that are spelled like a register
95 # CHECK: .Lpcrel_hi13:
96 # CHECK: auipc a2, %tls_ie_pcrel_hi(zero)
97 # CHECK-RV32: lw a2, %pcrel_lo(.Lpcrel_hi13)(a2)
98 # CHECK-RV64: ld a2, %pcrel_lo(.Lpcrel_hi13)(a2)
101 # CHECK: .Lpcrel_hi14:
102 # CHECK: auipc a3, %tls_ie_pcrel_hi(ra)
103 # CHECK-RV32: lw a3, %pcrel_lo(.Lpcrel_hi14)(a3)
104 # CHECK-RV64: ld a3, %pcrel_lo(.Lpcrel_hi14)(a3)
107 # CHECK: .Lpcrel_hi15:
108 # CHECK: auipc a4, %tls_ie_pcrel_hi(f1)
109 # CHECK-RV32: lw a4, %pcrel_lo(.Lpcrel_hi15)(a4)
110 # CHECK-RV64: ld a4, %pcrel_lo(.Lpcrel_hi15)(a4)
113 # CHECK: .Lpcrel_hi16:
114 # CHECK: auipc a0, %tls_gd_pcrel_hi(a_symbol)
115 # CHECK: addi a0, a0, %pcrel_lo(.Lpcrel_hi16)
116 la.tls.gd a0
, a_symbol
118 # CHECK: .Lpcrel_hi17:
119 # CHECK: auipc a1, %tls_gd_pcrel_hi(another_symbol)
120 # CHECK: addi a1, a1, %pcrel_lo(.Lpcrel_hi17)
121 la.tls.gd a1
, another_symbol
123 # Check that we can load the address of symbols that are spelled like a register
124 # CHECK: .Lpcrel_hi18:
125 # CHECK: auipc a2, %tls_gd_pcrel_hi(zero)
126 # CHECK: addi a2, a2, %pcrel_lo(.Lpcrel_hi18)
129 # CHECK: .Lpcrel_hi19:
130 # CHECK: auipc a3, %tls_gd_pcrel_hi(ra)
131 # CHECK: addi a3, a3, %pcrel_lo(.Lpcrel_hi19)
134 # CHECK: .Lpcrel_hi20:
135 # CHECK: auipc a4, %tls_gd_pcrel_hi(f1)
136 # CHECK: addi a4, a4, %pcrel_lo(.Lpcrel_hi20)
139 # CHECK: .Lpcrel_hi21:
140 # CHECK: auipc a0, %pcrel_hi(a_symbol)
141 # CHECK: lb a0, %pcrel_lo(.Lpcrel_hi21)(a0)
144 # CHECK: .Lpcrel_hi22:
145 # CHECK: auipc a1, %pcrel_hi(a_symbol)
146 # CHECK: lh a1, %pcrel_lo(.Lpcrel_hi22)(a1)
149 # CHECK: .Lpcrel_hi23:
150 # CHECK: auipc a2, %pcrel_hi(a_symbol)
151 # CHECK: lhu a2, %pcrel_lo(.Lpcrel_hi23)(a2)
154 # CHECK: .Lpcrel_hi24:
155 # CHECK: auipc a3, %pcrel_hi(a_symbol)
156 # CHECK: lw a3, %pcrel_lo(.Lpcrel_hi24)(a3)
159 # CHECK: .Lpcrel_hi25:
160 # CHECK: auipc a4, %pcrel_hi(a_symbol)
161 # CHECK: sb a3, %pcrel_lo(.Lpcrel_hi25)(a4)
164 # CHECK: .Lpcrel_hi26:
165 # CHECK: auipc a4, %pcrel_hi(a_symbol)
166 # CHECK: sh a3, %pcrel_lo(.Lpcrel_hi26)(a4)
169 # CHECK: .Lpcrel_hi27:
170 # CHECK: auipc a4, %pcrel_hi(a_symbol)
171 # CHECK: sw a3, %pcrel_lo(.Lpcrel_hi27)(a4)
174 # Check that we can load the address of symbols that are spelled like a register
175 # CHECK: .Lpcrel_hi28:
176 # CHECK: auipc a2, %pcrel_hi(zero)
177 # CHECK: lw a2, %pcrel_lo(.Lpcrel_hi28)(a2)
180 # CHECK: .Lpcrel_hi29:
181 # CHECK: auipc a4, %pcrel_hi(zero)
182 # CHECK: sw a3, %pcrel_lo(.Lpcrel_hi29)(a4)