2 # RUN: rm -rf %t && split-file %s %t
4 # RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/a.s -o %t/a.la32.o
5 # RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/a.s -o %t/a.la64.o
6 # RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/extreme.s -o %t/extreme.o
8 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x11000 --section-start=.text=0x11ffc -o %t/case1.la32
9 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x11000 --section-start=.text=0x11ffc -o %t/case1.la64
10 # RUN: llvm-objdump -d --no-show-raw-insn %t/case1.la32 | FileCheck %s --check-prefix=CASE1
11 # RUN: llvm-objdump -d --no-show-raw-insn %t/case1.la64 | FileCheck %s --check-prefix=CASE1
12 # CASE1: pcalau12i $a0, 0
13 # CASE1-NEXT: ld.w $a0, $a0, 0
15 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x11000 --section-start=.text=0x12000 -o %t/case2.la32
16 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x11000 --section-start=.text=0x12000 -o %t/case2.la64
17 # RUN: llvm-objdump -d --no-show-raw-insn %t/case2.la32 | FileCheck %s --check-prefix=CASE2
18 # RUN: llvm-objdump -d --no-show-raw-insn %t/case2.la64 | FileCheck %s --check-prefix=CASE2
19 # CASE2: pcalau12i $a0, -1
20 # CASE2-NEXT: ld.w $a0, $a0, 0
22 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x117ff --section-start=.text=0x12000 -o %t/case3.la32
23 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x117ff --section-start=.text=0x12000 -o %t/case3.la64
24 # RUN: llvm-objdump -d --no-show-raw-insn %t/case3.la32 | FileCheck %s --check-prefix=CASE3
25 # RUN: llvm-objdump -d --no-show-raw-insn %t/case3.la64 | FileCheck %s --check-prefix=CASE3
26 # CASE3: pcalau12i $a0, -1
27 # CASE3-NEXT: ld.w $a0, $a0, 2047
29 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x11800 --section-start=.text=0x12000 -o %t/case4.la32
30 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x11800 --section-start=.text=0x12000 -o %t/case4.la64
31 # RUN: llvm-objdump -d --no-show-raw-insn %t/case4.la32 | FileCheck %s --check-prefix=CASE4
32 # RUN: llvm-objdump -d --no-show-raw-insn %t/case4.la64 | FileCheck %s --check-prefix=CASE4
33 # CASE4: pcalau12i $a0, 0
34 # CASE4-NEXT: ld.w $a0, $a0, -2048
36 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x12004 --section-start=.text=0x11ffc -o %t/case5.la32
37 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x12004 --section-start=.text=0x11ffc -o %t/case5.la64
38 # RUN: llvm-objdump -d --no-show-raw-insn %t/case5.la32 | FileCheck %s --check-prefix=CASE5
39 # RUN: llvm-objdump -d --no-show-raw-insn %t/case5.la64 | FileCheck %s --check-prefix=CASE5
40 # CASE5: pcalau12i $a0, 1
41 # CASE5-NEXT: ld.w $a0, $a0, 4
43 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x12800 --section-start=.text=0x11ffc -o %t/case6.la32
44 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x12800 --section-start=.text=0x11ffc -o %t/case6.la64
45 # RUN: llvm-objdump -d --no-show-raw-insn %t/case6.la32 | FileCheck %s --check-prefix=CASE6
46 # RUN: llvm-objdump -d --no-show-raw-insn %t/case6.la64 | FileCheck %s --check-prefix=CASE6
47 # CASE6: pcalau12i $a0, 2
48 # CASE6-NEXT: ld.w $a0, $a0, -2048
50 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x7ffff123 --section-start=.text=0x0 -o %t/case7.la32
51 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x7ffff123 --section-start=.text=0x0 -o %t/case7.la64
52 # RUN: llvm-objdump -d --no-show-raw-insn %t/case7.la32 | FileCheck %s --check-prefix=CASE7
53 # RUN: llvm-objdump -d --no-show-raw-insn %t/case7.la64 | FileCheck %s --check-prefix=CASE7
54 # CASE7: pcalau12i $a0, 524287
55 # CASE7-NEXT: ld.w $a0, $a0, 291
57 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x7ffffabc --section-start=.text=0x0 -o %t/case8.la32
58 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x7ffffabc --section-start=.text=0x0 -o %t/case8.la64
59 # RUN: llvm-objdump -d --no-show-raw-insn %t/case8.la32 | FileCheck %s --check-prefix=CASE8
60 # RUN: llvm-objdump -d --no-show-raw-insn %t/case8.la64 | FileCheck %s --check-prefix=CASE8
61 # CASE8: pcalau12i $a0, -524288
62 # CASE8-NEXT: ld.w $a0, $a0, -1348
64 # RUN: ld.lld %t/a.la32.o --section-start=.rodata=0x10123 --section-start=.text=0x80010000 -o %t/case9.la32
65 # RUN: ld.lld %t/a.la64.o --section-start=.rodata=0x10123 --section-start=.text=0x80010000 -o %t/case9.la64
66 # RUN: llvm-objdump -d --no-show-raw-insn %t/case9.la32 | FileCheck %s --check-prefix=CASE9
67 # RUN: llvm-objdump -d --no-show-raw-insn %t/case9.la64 | FileCheck %s --check-prefix=CASE9
68 # CASE9: pcalau12i $a0, -524288
69 # CASE9-NEXT: ld.w $a0, $a0, 291
71 ## page delta = 0x4443333322222000, page offset = 0x111
72 ## %pc_lo12 = 0x111 = 273
73 ## %pc_hi20 = 0x22222 = 139810
74 ## %pc64_lo20 = 0x33333 = 209715
75 ## %pc64_hi12 = 0x444 = 1092
76 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0x4443333334567111 --section-start=.text=0x0000000012345678 -o %t/extreme0
77 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme0 | FileCheck %s --check-prefix=EXTREME0
78 # EXTREME0: addi.d $t0, $zero, 273
79 # EXTREME0-NEXT: pcalau12i $t1, 139810
80 # EXTREME0-NEXT: lu32i.d $t0, 209715
81 # EXTREME0-NEXT: lu52i.d $t0, $t0, 1092
83 ## page delta = 0x4443333222223000, page offset = 0x888
84 ## %pc_lo12 = 0x888 = -1912
85 ## %pc_hi20 = 0x22223 = 139811
86 ## %pc64_lo20 = 0x33332 = 209714
87 ## %pc64_hi12 = 0x444 = 1092
88 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0x4443333334567888 --section-start=.text=0x0000000012345678 -o %t/extreme1
89 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme1 | FileCheck %s --check-prefix=EXTREME1
90 # EXTREME1: addi.d $t0, $zero, -1912
91 # EXTREME1-NEXT: pcalau12i $t1, 139811
92 # EXTREME1-NEXT: lu32i.d $t0, 209714
93 # EXTREME1-NEXT: lu52i.d $t0, $t0, 1092
95 ## page delta = 0x4443333499999000, page offset = 0x111
96 ## %pc_lo12 = 0x111 = 273
97 ## %pc_hi20 = 0x99999 = -419431
98 ## %pc64_lo20 = 0x33334 = 209716
99 ## %pc64_hi12 = 0x444 = 1092
100 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0x44433333abcde111 --section-start=.text=0x0000000012345678 -o %t/extreme2
101 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme2 | FileCheck %s --check-prefix=EXTREME2
102 # EXTREME2: addi.d $t0, $zero, 273
103 # EXTREME2-NEXT: pcalau12i $t1, -419431
104 # EXTREME2-NEXT: lu32i.d $t0, 209716
105 # EXTREME2-NEXT: lu52i.d $t0, $t0, 1092
107 ## page delta = 0x444333339999a000, page offset = 0x888
108 ## %pc_lo12 = 0x888 = -1912
109 ## %pc_hi20 = 0x9999a = -419430
110 ## %pc64_lo20 = 0x33333 = 209715
111 ## %pc64_hi12 = 0x444 = 1092
112 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0x44433333abcde888 --section-start=.text=0x0000000012345678 -o %t/extreme3
113 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme3 | FileCheck %s --check-prefix=EXTREME3
114 # EXTREME3: addi.d $t0, $zero, -1912
115 # EXTREME3-NEXT: pcalau12i $t1, -419430
116 # EXTREME3-NEXT: lu32i.d $t0, 209715
117 # EXTREME3-NEXT: lu52i.d $t0, $t0, 1092
119 ## page delta = 0x444aaaaa22222000, page offset = 0x111
120 ## %pc_lo12 = 0x111 = 273
121 ## %pc_hi20 = 0x22222 = 139810
122 ## %pc64_lo20 = 0xaaaaa = -349526
123 ## %pc64_hi12 = 0x444 = 1092
124 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0x444aaaaa34567111 --section-start=.text=0x0000000012345678 -o %t/extreme4
125 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme4 | FileCheck %s --check-prefix=EXTREME4
126 # EXTREME4: addi.d $t0, $zero, 273
127 # EXTREME4-NEXT: pcalau12i $t1, 139810
128 # EXTREME4-NEXT: lu32i.d $t0, -349526
129 # EXTREME4-NEXT: lu52i.d $t0, $t0, 1092
131 ## page delta = 0x444aaaa922223000, page offset = 0x888
132 ## %pc_lo12 = 0x888 = -1912
133 ## %pc_hi20 = 0x22223 = 139811
134 ## %pc64_lo20 = 0xaaaa9 = -349527
135 ## %pc64_hi12 = 0x444 = 1092
136 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0x444aaaaa34567888 --section-start=.text=0x0000000012345678 -o %t/extreme5
137 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme5 | FileCheck %s --check-prefix=EXTREME5
138 # EXTREME5: addi.d $t0, $zero, -1912
139 # EXTREME5-NEXT: pcalau12i $t1, 139811
140 # EXTREME5-NEXT: lu32i.d $t0, -349527
141 # EXTREME5-NEXT: lu52i.d $t0, $t0, 1092
143 ## page delta = 0x444aaaab99999000, page offset = 0x111
144 ## %pc_lo12 = 0x111 = 273
145 ## %pc_hi20 = 0x99999 = -419431
146 ## %pc64_lo20 = 0xaaaab = -349525
147 ## %pc64_hi12 = 0x444 = 1092
148 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0x444aaaaaabcde111 --section-start=.text=0x0000000012345678 -o %t/extreme6
149 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme6 | FileCheck %s --check-prefix=EXTREME6
150 # EXTREME6: addi.d $t0, $zero, 273
151 # EXTREME6-NEXT: pcalau12i $t1, -419431
152 # EXTREME6-NEXT: lu32i.d $t0, -349525
153 # EXTREME6-NEXT: lu52i.d $t0, $t0, 1092
155 ## page delta = 0x444aaaaa9999a000, page offset = 0x888
156 ## %pc_lo12 = 0x888 = -1912
157 ## %pc_hi20 = 0x9999a = -419430
158 ## %pc64_lo20 = 0xaaaaa = -349526
159 ## %pc64_hi12 = 0x444 = 1092
160 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0x444aaaaaabcde888 --section-start=.text=0x0000000012345678 -o %t/extreme7
161 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme7 | FileCheck %s --check-prefix=EXTREME7
162 # EXTREME7: addi.d $t0, $zero, -1912
163 # EXTREME7-NEXT: pcalau12i $t1, -419430
164 # EXTREME7-NEXT: lu32i.d $t0, -349526
165 # EXTREME7-NEXT: lu52i.d $t0, $t0, 1092
167 ## page delta = 0xbbb3333322222000, page offset = 0x111
168 ## %pc_lo12 = 0x111 = 273
169 ## %pc_hi20 = 0x22222 = 139810
170 ## %pc64_lo20 = 0x33333 = 209715
171 ## %pc64_hi12 = 0xbbb = -1093
172 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0xbbb3333334567111 --section-start=.text=0x0000000012345678 -o %t/extreme8
173 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme8 | FileCheck %s --check-prefix=EXTREME8
174 # EXTREME8: addi.d $t0, $zero, 273
175 # EXTREME8-NEXT: pcalau12i $t1, 139810
176 # EXTREME8-NEXT: lu32i.d $t0, 209715
177 # EXTREME8-NEXT: lu52i.d $t0, $t0, -1093
179 ## page delta = 0xbbb3333222223000, page offset = 0x888
180 ## %pc_lo12 = 0x888 = -1912
181 ## %pc_hi20 = 0x22223 = 139811
182 ## %pc64_lo20 = 0x33332 = 209714
183 ## %pc64_hi12 = 0xbbb = -1093
184 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0xbbb3333334567888 --section-start=.text=0x0000000012345678 -o %t/extreme9
185 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme9 | FileCheck %s --check-prefix=EXTREME9
186 # EXTREME9: addi.d $t0, $zero, -1912
187 # EXTREME9-NEXT: pcalau12i $t1, 139811
188 # EXTREME9-NEXT: lu32i.d $t0, 209714
189 # EXTREME9-NEXT: lu52i.d $t0, $t0, -1093
191 ## page delta = 0xbbb3333499999000, page offset = 0x111
192 ## %pc_lo12 = 0x111 = 273
193 ## %pc_hi20 = 0x99999 = -419431
194 ## %pc64_lo20 = 0x33334 = 209716
195 ## %pc64_hi12 = 0xbbb = -1093
196 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0xbbb33333abcde111 --section-start=.text=0x0000000012345678 -o %t/extreme10
197 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme10 | FileCheck %s --check-prefix=EXTREME10
198 # EXTREME10: addi.d $t0, $zero, 273
199 # EXTREME10-NEXT: pcalau12i $t1, -419431
200 # EXTREME10-NEXT: lu32i.d $t0, 209716
201 # EXTREME10-NEXT: lu52i.d $t0, $t0, -1093
203 ## page delta = 0xbbb333339999a000, page offset = 0x888
204 ## %pc_lo12 = 0x888 = -1912
205 ## %pc_hi20 = 0x9999a = -419430
206 ## %pc64_lo20 = 0x33333 = 209715
207 ## %pc64_hi12 = 0xbbb = -1093
208 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0xbbb33333abcde888 --section-start=.text=0x0000000012345678 -o %t/extreme11
209 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme11 | FileCheck %s --check-prefix=EXTREME11
210 # EXTREME11: addi.d $t0, $zero, -1912
211 # EXTREME11-NEXT: pcalau12i $t1, -419430
212 # EXTREME11-NEXT: lu32i.d $t0, 209715
213 # EXTREME11-NEXT: lu52i.d $t0, $t0, -1093
215 ## page delta = 0xbbbaaaaa22222000, page offset = 0x111
216 ## %pc_lo12 = 0x111 = 273
217 ## %pc_hi20 = 0x22222 = 139810
218 ## %pc64_lo20 = 0xaaaaa = -349526
219 ## %pc64_hi12 = 0xbbb = -1093
220 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0xbbbaaaaa34567111 --section-start=.text=0x0000000012345678 -o %t/extreme12
221 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme12 | FileCheck %s --check-prefix=EXTREME12
222 # EXTREME12: addi.d $t0, $zero, 273
223 # EXTREME12-NEXT: pcalau12i $t1, 139810
224 # EXTREME12-NEXT: lu32i.d $t0, -349526
225 # EXTREME12-NEXT: lu52i.d $t0, $t0, -1093
227 ## page delta = 0xbbbaaaa922223000, page offset = 0x888
228 ## %pc_lo12 = 0x888 = -1912
229 ## %pc_hi20 = 0x22223 = 139811
230 ## %pc64_lo20 = 0xaaaa9 = -349527
231 ## %pc64_hi12 = 0xbbb = -1093
232 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0xbbbaaaaa34567888 --section-start=.text=0x0000000012345678 -o %t/extreme13
233 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme13 | FileCheck %s --check-prefix=EXTREME13
234 # EXTREME13: addi.d $t0, $zero, -1912
235 # EXTREME13-NEXT: pcalau12i $t1, 139811
236 # EXTREME13-NEXT: lu32i.d $t0, -349527
237 # EXTREME13-NEXT: lu52i.d $t0, $t0, -1093
239 ## page delta = 0xbbbaaaab99999000, page offset = 0x111
240 ## %pc_lo12 = 0x111 = 273
241 ## %pc_hi20 = 0x99999 = -419431
242 ## %pc64_lo20 = 0xaaaab = -349525
243 ## %pc64_hi12 = 0xbbb = -1093
244 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0xbbbaaaaaabcde111 --section-start=.text=0x0000000012345678 -o %t/extreme14
245 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme14 | FileCheck %s --check-prefix=EXTREME14
246 # EXTREME14: addi.d $t0, $zero, 273
247 # EXTREME14-NEXT: pcalau12i $t1, -419431
248 # EXTREME14-NEXT: lu32i.d $t0, -349525
249 # EXTREME14-NEXT: lu52i.d $t0, $t0, -1093
251 ## page delta = 0xbbbaaaaa9999a000, page offset = 0x888
252 ## %pc_lo12 = 0x888 = -1912
253 ## %pc_hi20 = 0x9999a = -419430
254 ## %pc64_lo20 = 0xaaaaa = -349526
255 ## %pc64_hi12 = 0xbbb = -1093
256 # RUN: ld.lld %t/extreme.o --section-start=.rodata=0xbbbaaaaaabcde888 --section-start=.text=0x0000000012345678 -o %t/extreme15
257 # RUN: llvm-objdump -d --no-show-raw-insn %t/extreme15 | FileCheck %s --check-prefix=EXTREME15
258 # EXTREME15: addi.d $t0, $zero, -1912
259 # EXTREME15-NEXT: pcalau12i $t1, -419430
260 # EXTREME15-NEXT: lu32i.d $t0, -349526
261 # EXTREME15-NEXT: lu52i.d $t0, $t0, -1093
270 pcalau12i $a0
, %pc_hi20
(x
)
271 ld.w $a0
, $a0
, %pc_lo12
(x
)
280 addi.d $t0
, $zero
, %pc_lo12
(x
)
281 pcalau12i $t1
, %pc_hi20
(x
)
282 lu32i.d $t0
, %pc64_lo20
(x
)
283 lu52i.d $t0
, $t0
, %pc64_hi12
(x
)