2 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t1.o
3 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %p/Inputs/ppc64-got-to-pcrel-relaxation-def.s -o %t2.o
4 # RUN: ld.lld --shared %t2.o -o %t2.so --soname=t2
5 # RUN: ld.lld %t1.o %t2.o -o %t
6 # RUN: ld.lld %t1.o %t2.so -o %ts
7 # RUN: ld.lld %t1.o %t2.o -o %tn --no-pcrel-optimize
8 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=CHECK-S
9 # RUN: llvm-objdump -d --no-show-raw-insn %ts | FileCheck %s --check-prefix=CHECK-D
10 # RUN: llvm-objdump -d --no-show-raw-insn %tn | FileCheck %s --check-prefix=CHECK-D
12 # RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t1.o
13 # RUN: llvm-mc -filetype=obj -triple=powerpc64 %p/Inputs/ppc64-got-to-pcrel-relaxation-def.s -o %t2.o
14 # RUN: ld.lld --shared %t2.o -o %t2.so --soname=t2
15 # RUN: ld.lld %t1.o %t2.o -o %t
16 # RUN: ld.lld %t1.o %t2.so -o %ts
17 # RUN: ld.lld %t1.o %t2.o -o %tn --no-pcrel-optimize
18 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=CHECK-S
19 # RUN: llvm-objdump -d --no-show-raw-insn %ts | FileCheck %s --check-prefix=CHECK-D
20 # RUN: llvm-objdump -d --no-show-raw-insn %tn | FileCheck %s --check-prefix=CHECK-D
22 # CHECK-S-LABEL: <check_LBZ_STB>:
23 # CHECK-S-NEXT: plbz 10
24 # CHECK-S-NEXT: paddi 9
25 # CHECK-S-NEXT: li 3, 0
27 # CHECK-S-NEXT: rldicl 9, 9, 9, 60
28 # CHECK-S-NEXT: add 9, 9, 10
29 # CHECK-S-NEXT: pstb 9
33 # CHECK-D-LABEL: <check_LBZ_STB>:
36 # CHECK-D-NEXT: li 3, 0
37 # CHECK-D-NEXT: lbz 10, 0(8)
38 # CHECK-D-NEXT: rldicl 9, 9, 9, 60
39 # CHECK-D-NEXT: add 9, 9, 10
40 # CHECK-D-NEXT: pld 10
41 # CHECK-D-NEXT: stb 9, 0(10)
44 pld
8,useVal@got@pcrel
(0),1
46 pld
9,useAddr@got@pcrel
(0),1
48 .reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
52 pld
10,storeVal@got@pcrel
(0),1
54 .reloc .Lpcrel2-8,R_PPC64_PCREL_OPT,.-(.Lpcrel2-8)
58 # CHECK-S-LABEL: <check_LHZ_STH>:
59 # CHECK-S-NEXT: plhz 3
62 # CHECK-S-NEXT: psth 3
66 # CHECK-D-LABEL: <check_LHZ_STH>:
68 # CHECK-D-NEXT: lhz 3, 0(9)
71 # CHECK-D-NEXT: sth 3, 0(9)
74 pld
9,useVal_ushort@got@pcrel
(0),1
76 .reloc .Lpcrel3-8,R_PPC64_PCREL_OPT,.-(.Lpcrel3-8)
78 pld
9,storeVal_ushort@got@pcrel
(0),1
80 .reloc .Lpcrel4-8,R_PPC64_PCREL_OPT,.-(.Lpcrel4-8)
84 # CHECK-S-LABEL: <check_LWZ_STW>:
85 # CHECK-S-NEXT: plwz 3
87 # CHECK-S-NEXT: pstw 3
91 # CHECK-D-LABEL: <check_LWZ_STW>:
93 # CHECK-D-NEXT: lwz 3, 0(9)
95 # CHECK-D-NEXT: stw 3, 0(9)
98 pld
9,useVal_uint@got@pcrel
(0),1
100 .reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
102 pld
9,storeVal_uint@got@pcrel
(0),1
104 .reloc .Lpcrel6-8,R_PPC64_PCREL_OPT,.-(.Lpcrel6-8)
108 # CHECK-S-LABEL: <check_LFS_STFS>:
109 # CHECK-S-NEXT: plfs 1
111 # CHECK-S-NEXT: pstfs 1
115 # CHECK-D-LABEL: <check_LFS_STFS>:
116 # CHECK-D-NEXT: pld 9
117 # CHECK-D-NEXT: lfs 1, 0(9)
118 # CHECK-D-NEXT: pld 9
119 # CHECK-D-NEXT: stfs 1, 0(9)
122 pld
9,useVal_float@got@pcrel
(0),1
124 .reloc .Lpcrel7-8,R_PPC64_PCREL_OPT,.-(.Lpcrel7-8)
126 pld
9,storeVal_float@got@pcrel
(0),1
128 .reloc .Lpcrel8-8,R_PPC64_PCREL_OPT,.-(.Lpcrel8-8)
132 # CHECK-S-LABEL: <check_LFD_STFD>:
133 # CHECK-S-NEXT: plfd 1
135 # CHECK-S-NEXT: pstfd 1
139 # CHECK-D-LABEL: <check_LFD_STFD>:
140 # CHECK-D-NEXT: pld 9
141 # CHECK-D-NEXT: lfd 1, 0(9)
142 # CHECK-D-NEXT: pld 9
143 # CHECK-D-NEXT: stfd 1, 0(9)
146 pld
9,useVal_double@got@pcrel
(0),1
148 .reloc .Lpcrel9-8,R_PPC64_PCREL_OPT,.-(.Lpcrel9-8)
150 pld
9,storeVal_double@got@pcrel
(0),1
152 .reloc .Lpcrel10-8,R_PPC64_PCREL_OPT,.-(.Lpcrel10-8)
156 # CHECK-S-LABEL: <check_LWA_STW>:
157 # CHECK-S-NEXT: mr 9, 3
158 # CHECK-S-NEXT: plwa 3
159 # CHECK-S-NEXT: pstw 9
164 # CHECK-D-LABEL: <check_LWA_STW>:
165 # CHECK-D-NEXT: mr 9, 3
166 # CHECK-D-NEXT: pld 8
167 # CHECK-D-NEXT: pld 10
168 # CHECK-D-NEXT: lwa 3, 0(8)
169 # CHECK-D-NEXT: stw 9, 0(10)
173 pld
8,useVal_sint@got@pcrel
(0),1
175 pld
10,storeVal_sint@got@pcrel
(0),1
177 .reloc .Lpcrel11-8,R_PPC64_PCREL_OPT,.-(.Lpcrel11-8)
179 .reloc .Lpcrel12-8,R_PPC64_PCREL_OPT,.-(.Lpcrel12-8)
183 # CHECK-S-LABEL: <check_LHA_STH>:
184 # CHECK-S-NEXT: mr 9, 3
185 # CHECK-S-NEXT: plha 3
186 # CHECK-S-NEXT: psth 9
191 # CHECK-D-LABEL: <check_LHA_STH>:
192 # CHECK-D-NEXT: mr 9, 3
193 # CHECK-D-NEXT: pld 8
194 # CHECK-D-NEXT: pld 10
195 # CHECK-D-NEXT: lha 3, 0(8)
196 # CHECK-D-NEXT: sth 9, 0(10)
200 pld
8,useVal_sshort@got@pcrel
(0),1
202 pld
10,storeVal_sshort@got@pcrel
(0),1
204 .reloc .Lpcrel13-8,R_PPC64_PCREL_OPT,.-(.Lpcrel13-8)
206 .reloc .Lpcrel14-8,R_PPC64_PCREL_OPT,.-(.Lpcrel14-8)
210 # CHECK-S-LABEL: <check_LD_STD>:
211 # CHECK-S-NEXT: pld 3
213 # CHECK-S-NEXT: pstd 3
217 # CHECK-D-LABEL: <check_LD_STD>:
218 # CHECK-D-NEXT: pld 9
219 # CHECK-D-NEXT: ld 3, 0(9)
220 # CHECK-D-NEXT: pld 9
221 # CHECK-D-NEXT: std 3, 0(9)
224 pld
9,useVal_longlong@got@pcrel
(0),1
226 .reloc .Lpcrel15-8,R_PPC64_PCREL_OPT,.-(.Lpcrel15-8)
228 pld
9,storeVal_longlong@got@pcrel
(0),1
230 .reloc .Lpcrel16-8,R_PPC64_PCREL_OPT,.-(.Lpcrel16-8)
234 # CHECK-S-LABEL: <check_LXV_STXV>:
235 # CHECK-S-NEXT: plxv 34
237 # CHECK-S-NEXT: pstxv 34
241 # CHECK-D-LABEL: <check_LXV_STXV>:
242 # CHECK-D-NEXT: pld 9
243 # CHECK-D-NEXT: lxv 34, 0(9)
244 # CHECK-D-NEXT: pld 9
245 # CHECK-D-NEXT: stxv 34, 0(9)
248 pld
9,useVal_vector@got@pcrel
(0),1
250 .reloc .Lpcrel17-8,R_PPC64_PCREL_OPT,.-(.Lpcrel17-8)
252 pld
9,storeVal_vector@got@pcrel
(0),1
254 .reloc .Lpcrel18-8,R_PPC64_PCREL_OPT,.-(.Lpcrel18-8)
258 # CHECK-S-LABEL: <check_LXSSP_STXSSP>:
259 # CHECK-S-NEXT: plxssp 1
261 # CHECK-S-NEXT: pstxssp 1
265 # CHECK-D-LABEL: <check_LXSSP_STXSSP>:
266 # CHECK-D-NEXT: pld 9
267 # CHECK-D-NEXT: lxssp 1, 0(9)
268 # CHECK-D-NEXT: pld 9
269 # CHECK-D-NEXT: stxssp 1, 0(9)
272 pld
9,useVal_float@got@pcrel
(0),1
274 .reloc .Lpcrel19-8,R_PPC64_PCREL_OPT,.-(.Lpcrel19-8)
276 pld
9,storeVal_float@got@pcrel
(0),1
278 .reloc .Lpcrel20-8,R_PPC64_PCREL_OPT,.-(.Lpcrel20-8)
282 # CHECK-S-LABEL: <check_LXSD_STXSD>:
283 # CHECK-S-NEXT: plxsd 1, [[#ADDR1:]]
285 # CHECK-S-NEXT: pstxsd 1, [[#ADDR2:]]
289 # CHECK-D-LABEL: <check_LXSD_STXSD>:
290 # CHECK-D-NEXT: pld 9
291 # CHECK-D-NEXT: lxsd 1, 0(9)
292 # CHECK-D-NEXT: pld 9
293 # CHECK-D-NEXT: stxsd 1, 0(9)
296 pld
9,useVal_double@got@pcrel
(0),1
298 .reloc .Lpcrel21-8,R_PPC64_PCREL_OPT,.-(.Lpcrel21-8)
300 pld
9,storeVal_double@got@pcrel
(0),1
302 .reloc .Lpcrel22-8,R_PPC64_PCREL_OPT,.-(.Lpcrel22-8)
306 # The respective displacements are computed relative to the PC which advanced
307 # by 28 bytes in this function. Since the displacements in the two access
308 # instructions are 8 and 32 so the displacements are those computed above minus
309 # 20 and plus 4 (+8 - 28 and +32 - 28) respectively.
310 # CHECK-S-LABEL: <check_LXSD_STXSD_aggr>:
311 # CHECK-S-NEXT: plxsd 1, [[#ADDR1-20]]
313 # CHECK-S-NEXT: pstxsd 1, [[#ADDR2+4]]
317 # CHECK-D-LABEL: <check_LXSD_STXSD_aggr>:
318 # CHECK-D-NEXT: pld 9
319 # CHECK-D-NEXT: lxsd 1, 8(9)
320 # CHECK-D-NEXT: pld 9
321 # CHECK-D-NEXT: stxsd 1, 32(9)
323 check_LXSD_STXSD_aggr
:
324 pld
9,useVal_double@got@pcrel
(0),1
326 .reloc .Lpcrel23-8,R_PPC64_PCREL_OPT,.-(.Lpcrel23-8)
328 pld
9,storeVal_double@got@pcrel
(0),1
330 .reloc .Lpcrel24-8,R_PPC64_PCREL_OPT,.-(.Lpcrel24-8)
334 # This includes a nop but that is not emitted by the linker.
335 # It is an alignment nop to prevent the prefixed instruction from
336 # crossing a 64-byte boundary.
337 # CHECK-S-LABEL: <check_LD_STD_W_PADDI>:
338 # CHECK-S-NEXT: paddi 9
339 # CHECK-S-NEXT: ld 3, 0(9)
341 # CHECK-S-NEXT: paddi 9
342 # CHECK-S-NEXT: std 3, 0(9)
345 # CHECK-D-LABEL: <check_LD_STD_W_PADDI>:
346 # CHECK-D-NEXT: paddi 9
347 # CHECK-D-NEXT: ld 3, 0(9)
349 # CHECK-D-NEXT: paddi 9
350 # CHECK-D-NEXT: std 3, 0(9)
352 check_LD_STD_W_PADDI
:
353 paddi
9,0,useVal_longlong@got@pcrel
,1
355 .reloc .Lpcrel25-8,R_PPC64_PCREL_OPT,.-(.Lpcrel25-8)
357 paddi
9,0,storeVal_longlong@got@pcrel
,1
359 .reloc .Lpcrel26-8,R_PPC64_PCREL_OPT,.-(.Lpcrel26-8)
362 # CHECK-S-LABEL: <check_LXSD_STXSD_aggr_notoc>:
363 # CHECK-S-NEXT: paddi 3, 0, -12, 1
364 # CHECK-S-NEXT: lwz 4, 8(3)
365 # CHECK-S-NEXT: paddi 3, 0, -24, 1
366 # CHECK-S-NEXT: stw 4, 32(3)
369 # CHECK-D-LABEL: <check_LXSD_STXSD_aggr_notoc>:
370 # CHECK-D-NEXT: paddi 3, 0, -12, 1
371 # CHECK-D-NEXT: lwz 4, 8(3)
372 # CHECK-D-NEXT: paddi 3, 0, -24, 1
373 # CHECK-D-NEXT: stw 4, 32(3)
375 .type Arr,@object # @Arr
382 check_LXSD_STXSD_aggr_notoc
:
383 paddi
3, 0, Arr@PCREL
, 1
385 .reloc .Lpcrel27-8,R_PPC64_PCREL_OPT,.-(.Lpcrel27-8)
387 paddi
3, 0, Arr@PCREL
, 1
389 .reloc .Lpcrel28-8,R_PPC64_PCREL_OPT,.-(.Lpcrel28-8)