ppc64-got-to-pcrel-relaxation.s
10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# REQUIRES: ppc
# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=powerpc64le %p/Inputs/ppc64-got-to-pcrel-relaxation-def.s -o %t2.o
# RUN: ld.lld --shared %t2.o -o %t2.so --soname=t2
# RUN: ld.lld %t1.o %t2.o -o %t
# RUN: ld.lld %t1.o %t2.so -o %ts
# RUN: ld.lld %t1.o %t2.o -o %tn --no-pcrel-optimize
# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t | FileCheck %s --check-prefix=CHECK-S
# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %ts | FileCheck %s --check-prefix=CHECK-D
# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %tn | FileCheck %s --check-prefix=CHECK-D
# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=powerpc64 %p/Inputs/ppc64-got-to-pcrel-relaxation-def.s -o %t2.o
# RUN: ld.lld --shared %t2.o -o %t2.so --soname=t2
# RUN: ld.lld %t1.o %t2.o -o %t
# RUN: ld.lld %t1.o %t2.so -o %ts
# RUN: ld.lld %t1.o %t2.o -o %tn --no-pcrel-optimize
# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t | FileCheck %s --check-prefix=CHECK-S
# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %ts | FileCheck %s --check-prefix=CHECK-D
# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %tn | FileCheck %s --check-prefix=CHECK-D
# CHECK-S-LABEL: <check_LBZ_STB>:
# CHECK-S-NEXT: plbz 10
# CHECK-S-NEXT: paddi 9
# CHECK-S-NEXT: li 3, 0
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: rldicl 9, 9, 9, 60
# CHECK-S-NEXT: add 9, 9, 10
# CHECK-S-NEXT: pstb 9
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LBZ_STB>:
# CHECK-D-NEXT: pld 8
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: li 3, 0
# CHECK-D-NEXT: lbz 10, 0(8)
# CHECK-D-NEXT: rldicl 9, 9, 9, 60
# CHECK-D-NEXT: add 9, 9, 10
# CHECK-D-NEXT: pld 10
# CHECK-D-NEXT: stb 9, 0(10)
# CHECK-D-NEXT: blr
check_LBZ_STB:
pld 8,useVal@got@pcrel(0),1
.Lpcrel1:
pld 9,useAddr@got@pcrel(0),1
li 3,0
.reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
lbz 10,0(8)
rldicl 9,9,9,60
add 9,9,10
pld 10,storeVal@got@pcrel(0),1
.Lpcrel2:
.reloc .Lpcrel2-8,R_PPC64_PCREL_OPT,.-(.Lpcrel2-8)
stb 9,0(10)
blr
# CHECK-S-LABEL: <check_LHZ_STH>:
# CHECK-S-NEXT: plhz 3
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: psth 3
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LHZ_STH>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: lhz 3, 0(9)
# CHECK-D-NEXT: nop
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: sth 3, 0(9)
# CHECK-D-NEXT: blr
check_LHZ_STH:
pld 9,useVal_ushort@got@pcrel(0),1
.Lpcrel3:
.reloc .Lpcrel3-8,R_PPC64_PCREL_OPT,.-(.Lpcrel3-8)
lhz 3,0(9)
pld 9,storeVal_ushort@got@pcrel(0),1
.Lpcrel4:
.reloc .Lpcrel4-8,R_PPC64_PCREL_OPT,.-(.Lpcrel4-8)
sth 3,0(9)
blr
# CHECK-S-LABEL: <check_LWZ_STW>:
# CHECK-S-NEXT: plwz 3
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: pstw 3
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LWZ_STW>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: lwz 3, 0(9)
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: stw 3, 0(9)
# CHECK-D-NEXT: blr
check_LWZ_STW:
pld 9,useVal_uint@got@pcrel(0),1
.Lpcrel5:
.reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
lwz 3,0(9)
pld 9,storeVal_uint@got@pcrel(0),1
.Lpcrel6:
.reloc .Lpcrel6-8,R_PPC64_PCREL_OPT,.-(.Lpcrel6-8)
stw 3,0(9)
blr
# CHECK-S-LABEL: <check_LFS_STFS>:
# CHECK-S-NEXT: plfs 1
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: pstfs 1
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LFS_STFS>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: lfs 1, 0(9)
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: stfs 1, 0(9)
# CHECK-D-NEXT: blr
check_LFS_STFS:
pld 9,useVal_float@got@pcrel(0),1
.Lpcrel7:
.reloc .Lpcrel7-8,R_PPC64_PCREL_OPT,.-(.Lpcrel7-8)
lfs 1,0(9)
pld 9,storeVal_float@got@pcrel(0),1
.Lpcrel8:
.reloc .Lpcrel8-8,R_PPC64_PCREL_OPT,.-(.Lpcrel8-8)
stfs 1,0(9)
blr
# CHECK-S-LABEL: <check_LFD_STFD>:
# CHECK-S-NEXT: plfd 1
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: pstfd 1
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LFD_STFD>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: lfd 1, 0(9)
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: stfd 1, 0(9)
# CHECK-D-NEXT: blr
check_LFD_STFD:
pld 9,useVal_double@got@pcrel(0),1
.Lpcrel9:
.reloc .Lpcrel9-8,R_PPC64_PCREL_OPT,.-(.Lpcrel9-8)
lfd 1,0(9)
pld 9,storeVal_double@got@pcrel(0),1
.Lpcrel10:
.reloc .Lpcrel10-8,R_PPC64_PCREL_OPT,.-(.Lpcrel10-8)
stfd 1,0(9)
blr
# CHECK-S-LABEL: <check_LWA_STW>:
# CHECK-S-NEXT: mr 9, 3
# CHECK-S-NEXT: plwa 3
# CHECK-S-NEXT: pstw 9
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LWA_STW>:
# CHECK-D-NEXT: mr 9, 3
# CHECK-D-NEXT: pld 8
# CHECK-D-NEXT: pld 10
# CHECK-D-NEXT: lwa 3, 0(8)
# CHECK-D-NEXT: stw 9, 0(10)
# CHECK-D-NEXT: blr
check_LWA_STW:
mr 9,3
pld 8,useVal_sint@got@pcrel(0),1
.Lpcrel11:
pld 10,storeVal_sint@got@pcrel(0),1
.Lpcrel12:
.reloc .Lpcrel11-8,R_PPC64_PCREL_OPT,.-(.Lpcrel11-8)
lwa 3,0(8)
.reloc .Lpcrel12-8,R_PPC64_PCREL_OPT,.-(.Lpcrel12-8)
stw 9,0(10)
blr
# CHECK-S-LABEL: <check_LHA_STH>:
# CHECK-S-NEXT: mr 9, 3
# CHECK-S-NEXT: plha 3
# CHECK-S-NEXT: psth 9
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LHA_STH>:
# CHECK-D-NEXT: mr 9, 3
# CHECK-D-NEXT: pld 8
# CHECK-D-NEXT: pld 10
# CHECK-D-NEXT: lha 3, 0(8)
# CHECK-D-NEXT: sth 9, 0(10)
# CHECK-D-NEXT: blr
check_LHA_STH:
mr 9,3
pld 8,useVal_sshort@got@pcrel(0),1
.Lpcrel13:
pld 10,storeVal_sshort@got@pcrel(0),1
.Lpcrel14:
.reloc .Lpcrel13-8,R_PPC64_PCREL_OPT,.-(.Lpcrel13-8)
lha 3,0(8)
.reloc .Lpcrel14-8,R_PPC64_PCREL_OPT,.-(.Lpcrel14-8)
sth 9,0(10)
blr
# CHECK-S-LABEL: <check_LD_STD>:
# CHECK-S-NEXT: pld 3
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: pstd 3
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LD_STD>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: ld 3, 0(9)
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: std 3, 0(9)
# CHECK-D-NEXT: blr
check_LD_STD:
pld 9,useVal_longlong@got@pcrel(0),1
.Lpcrel15:
.reloc .Lpcrel15-8,R_PPC64_PCREL_OPT,.-(.Lpcrel15-8)
ld 3,0(9)
pld 9,storeVal_longlong@got@pcrel(0),1
.Lpcrel16:
.reloc .Lpcrel16-8,R_PPC64_PCREL_OPT,.-(.Lpcrel16-8)
std 3,0(9)
blr
# CHECK-S-LABEL: <check_LXV_STXV>:
# CHECK-S-NEXT: plxv 34
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: pstxv 34
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LXV_STXV>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: lxv 34, 0(9)
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: stxv 34, 0(9)
# CHECK-D-NEXT: blr
check_LXV_STXV:
pld 9,useVal_vector@got@pcrel(0),1
.Lpcrel17:
.reloc .Lpcrel17-8,R_PPC64_PCREL_OPT,.-(.Lpcrel17-8)
lxv 34,0(9)
pld 9,storeVal_vector@got@pcrel(0),1
.Lpcrel18:
.reloc .Lpcrel18-8,R_PPC64_PCREL_OPT,.-(.Lpcrel18-8)
stxv 34,0(9)
blr
# CHECK-S-LABEL: <check_LXSSP_STXSSP>:
# CHECK-S-NEXT: plxssp 1
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: pstxssp 1
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LXSSP_STXSSP>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: lxssp 1, 0(9)
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: stxssp 1, 0(9)
# CHECK-D-NEXT: blr
check_LXSSP_STXSSP:
pld 9,useVal_float@got@pcrel(0),1
.Lpcrel19:
.reloc .Lpcrel19-8,R_PPC64_PCREL_OPT,.-(.Lpcrel19-8)
lxssp 1,0(9)
pld 9,storeVal_float@got@pcrel(0),1
.Lpcrel20:
.reloc .Lpcrel20-8,R_PPC64_PCREL_OPT,.-(.Lpcrel20-8)
stxssp 1,0(9)
blr
# CHECK-S-LABEL: <check_LXSD_STXSD>:
# CHECK-S-NEXT: plxsd 1, [[#ADDR1:]]
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: pstxsd 1, [[#ADDR2:]]
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LXSD_STXSD>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: lxsd 1, 0(9)
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: stxsd 1, 0(9)
# CHECK-D-NEXT: blr
check_LXSD_STXSD:
pld 9,useVal_double@got@pcrel(0),1
.Lpcrel21:
.reloc .Lpcrel21-8,R_PPC64_PCREL_OPT,.-(.Lpcrel21-8)
lxsd 1,0(9)
pld 9,storeVal_double@got@pcrel(0),1
.Lpcrel22:
.reloc .Lpcrel22-8,R_PPC64_PCREL_OPT,.-(.Lpcrel22-8)
stxsd 1,0(9)
blr
# The respective displacements are computed relative to the PC which advanced
# by 28 bytes in this function. Since the displacements in the two access
# instructions are 8 and 32 so the displacements are those computed above minus
# 20 and plus 4 (+8 - 28 and +32 - 28) respectively.
# CHECK-S-LABEL: <check_LXSD_STXSD_aggr>:
# CHECK-S-NEXT: plxsd 1, [[#ADDR1-20]]
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: pstxsd 1, [[#ADDR2+4]]
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LXSD_STXSD_aggr>:
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: lxsd 1, 8(9)
# CHECK-D-NEXT: pld 9
# CHECK-D-NEXT: stxsd 1, 32(9)
# CHECK-D-NEXT: blr
check_LXSD_STXSD_aggr:
pld 9,useVal_double@got@pcrel(0),1
.Lpcrel23:
.reloc .Lpcrel23-8,R_PPC64_PCREL_OPT,.-(.Lpcrel23-8)
lxsd 1,8(9)
pld 9,storeVal_double@got@pcrel(0),1
.Lpcrel24:
.reloc .Lpcrel24-8,R_PPC64_PCREL_OPT,.-(.Lpcrel24-8)
stxsd 1,32(9)
blr
# This includes a nop but that is not emitted by the linker.
# It is an alignment nop to prevent the prefixed instruction from
# crossing a 64-byte boundary.
# CHECK-S-LABEL: <check_LD_STD_W_PADDI>:
# CHECK-S-NEXT: paddi 9
# CHECK-S-NEXT: ld 3, 0(9)
# CHECK-S-NEXT: nop
# CHECK-S-NEXT: paddi 9
# CHECK-S-NEXT: std 3, 0(9)
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LD_STD_W_PADDI>:
# CHECK-D-NEXT: paddi 9
# CHECK-D-NEXT: ld 3, 0(9)
# CHECK-D-NEXT: nop
# CHECK-D-NEXT: paddi 9
# CHECK-D-NEXT: std 3, 0(9)
# CHECK-D-NEXT: blr
check_LD_STD_W_PADDI:
paddi 9,0,useVal_longlong@got@pcrel,1
.Lpcrel25:
.reloc .Lpcrel25-8,R_PPC64_PCREL_OPT,.-(.Lpcrel25-8)
ld 3,0(9)
paddi 9,0,storeVal_longlong@got@pcrel,1
.Lpcrel26:
.reloc .Lpcrel26-8,R_PPC64_PCREL_OPT,.-(.Lpcrel26-8)
std 3,0(9)
blr
# CHECK-S-LABEL: <check_LXSD_STXSD_aggr_notoc>:
# CHECK-S-NEXT: paddi 3, 0, -12, 1
# CHECK-S-NEXT: lwz 4, 8(3)
# CHECK-S-NEXT: paddi 3, 0, -24, 1
# CHECK-S-NEXT: stw 4, 32(3)
# CHECK-S-NEXT: blr
# CHECK-D-LABEL: <check_LXSD_STXSD_aggr_notoc>:
# CHECK-D-NEXT: paddi 3, 0, -12, 1
# CHECK-D-NEXT: lwz 4, 8(3)
# CHECK-D-NEXT: paddi 3, 0, -24, 1
# CHECK-D-NEXT: stw 4, 32(3)
# CHECK-D-NEXT: blr
.type Arr,@object # @Arr
.globl Arr
.p2align 2
Arr:
.long 11 # 0xb
.long 22 # 0x16
.long 33 # 0x21
check_LXSD_STXSD_aggr_notoc:
paddi 3, 0, Arr@PCREL, 1
.Lpcrel27:
.reloc .Lpcrel27-8,R_PPC64_PCREL_OPT,.-(.Lpcrel27-8)
lwz 4,8(3)
paddi 3, 0, Arr@PCREL, 1
.Lpcrel28:
.reloc .Lpcrel28-8,R_PPC64_PCREL_OPT,.-(.Lpcrel28-8)
stw 4,32(3)
blr