ppc64-reloc-directive-pcrel.s
10.2 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
393
394
395
396
397
398
399
400
401
# RUN: llvm-mc -triple=powerpc64le -filetype=obj %s | \
# RUN: llvm-objdump -dr --mcpu=pwr10 - | FileCheck %s
# RUN: llvm-mc -triple=powerpc64 -filetype=obj %s | \
# RUN: llvm-objdump -dr --mcpu=pwr10 - | FileCheck %s
##
# This section of tests contains the MCBinaryExpr as the first parameter of the
# .reloc relocation.
##
.text
.abiversion 2
.globl Minimal
.p2align 4
.type Minimal,@function
Minimal:
.LMinimal$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel1:
.reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK-LABEL: Minimal
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl SingleInsnBetween
.p2align 4
.type SingleInsnBetween,@function
SingleInsnBetween:
.LSingleInsnBetween$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel2:
addi 3, 3, 42
.reloc .Lpcrel2-8,R_PPC64_PCREL_OPT,.-(.Lpcrel2-8)
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK_LABEL: SingleInsnBetween
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0xc
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl MultiInsnBetween # -- Begin function
.p2align 4
.type MultiInsnBetween,@function
MultiInsnBetween:
.LMultiInsnBetween$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel3:
addi 3, 3, 42
addi 3, 3, 42
addi 3, 3, 42
addi 3, 3, 42
addi 3, 3, 42
.reloc .Lpcrel3-8,R_PPC64_PCREL_OPT,.-(.Lpcrel3-8)
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK_LABEL: MultiInsnBetween
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x1c
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl PrefixInsnBetween
.p2align 6
.type PrefixInsnBetween,@function
.space 48 # Add a space to force an alignment of a paddi.
PrefixInsnBetween:
.LPrefixInsnBetween$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel4:
addi 3, 3, 42
paddi 3, 3, 42, 0
addi 3, 3, 42
paddi 3, 3, 42, 0
addi 3, 3, 42
.reloc .Lpcrel4-8,R_PPC64_PCREL_OPT,.-(.Lpcrel4-8)
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK_LABEL: PrefixInsnBetween
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x28
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: nop
# CHECK-NEXT: paddi 3, 3, 42, 0
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: paddi 3, 3, 42, 0
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl SpaceBetween # -- Begin function
.p2align 4
.type SpaceBetween,@function
SpaceBetween:
.LSpaceBetween$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel5:
addi 3, 3, 42
paddi 3, 3, 42, 0
addi 3, 3, 42
.space 40, 0
paddi 3, 3, 42, 0
addi 3, 3, 42
.reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK_LABEL: SpaceBetween
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x50
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: nop
# CHECK-NEXT: paddi 3, 3, 42, 0
# CHECK-NEXT: addi 3, 3, 42
# CHECK: paddi 3, 3, 42, 0
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl Plus
.p2align 4
.type Plus,@function
Plus:
.LPlus$local:
.Lpcrel6:
addi 3, 3, 42
addi 3, 3, 42
pld 3, vec@got@pcrel(0), 1
.reloc .Lpcrel6+8,R_PPC64_PCREL_OPT,.-(.Lpcrel6+8)
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK-LABEL: Plus
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
##
# This section of tests contains the variable MCSymbol as part of the
# MCSymbolRefExpr for the first parameter of the .reloc relocation.
##
.globl VarLabelMinimal # -- Begin function
.p2align 4
.type VarLabelMinimal,@function
VarLabelMinimal:
.LVarLabelMinimal$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel101=.-8
.reloc .Lpcrel101,R_PPC64_PCREL_OPT,.-.Lpcrel101
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK-LABEL: VarLabelMinimal
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl VarLabelSingleInsnBetween
.p2align 4
.type VarLabelSingleInsnBetween,@function
VarLabelSingleInsnBetween:
.LVarLabelSingleInsnBetween$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel102=.-8
addi 3, 3, 42
.reloc .Lpcrel102,R_PPC64_PCREL_OPT,.-.Lpcrel102
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK_LABEL: VarLabelSingleInsnBetween
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0xc
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl VarLabelMultiInsnBetween # -- Begin function
.p2align 4
.type VarLabelMultiInsnBetween,@function
VarLabelMultiInsnBetween:
.LVarLabelMultiInsnBetween$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel103=.-8
addi 3, 3, 42
addi 3, 3, 42
addi 3, 3, 42
addi 3, 3, 42
addi 3, 3, 42
.reloc .Lpcrel103,R_PPC64_PCREL_OPT,.-.Lpcrel103
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK_LABEL: VarLabelMultiInsnBetween
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x1c
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl VarLabelPrefixInsnBetween # -- Begin function
.p2align 4
.type VarLabelPrefixInsnBetween,@function
VarLabelPrefixInsnBetween:
.LVarLabelPrefixInsnBetween$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel104=.-8
addi 3, 3, 42
paddi 3, 3, 42, 0
addi 3, 3, 42
paddi 3, 3, 42, 0
addi 3, 3, 42
.reloc .Lpcrel104,R_PPC64_PCREL_OPT,.-.Lpcrel104
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK_LABEL: VarLabelPrefixInsnBetween
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x24
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: paddi 3, 3, 42, 0
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: paddi 3, 3, 42, 0
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl VarLabelSpaceBetween # -- Begin function
.p2align 4
.type VarLabelSpaceBetween,@function
VarLabelSpaceBetween:
.LVarLabelSpaceBetween$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel105=.-8
addi 3, 3, 42
paddi 3, 3, 42, 0
addi 3, 3, 42
.space 40, 0
paddi 3, 3, 42, 0
addi 3, 3, 42
.reloc .Lpcrel105,R_PPC64_PCREL_OPT,.-.Lpcrel105
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK_LABEL: VarLabelSpaceBetween
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x4c
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: paddi 3, 3, 42, 0
# CHECK-NEXT: addi 3, 3, 42
# CHECK: paddi 3, 3, 42, 0
# CHECK-NEXT: addi 3, 3, 42
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl VarLabelPlus
.p2align 4
.type VarLabelPlus,@function
VarLabelPlus:
.LVarLabelPlus$local:
.Lpcrel106:
addi 3, 3, 42
addi 3, 3, 42
pld 3, vec@got@pcrel(0), 1
.reloc .Lpcrel106+8,R_PPC64_PCREL_OPT,.-(.Lpcrel106+8)
lwa 3, 4(3)
blr
.long 0
.quad 0
# CHECK-LABEL: VarLabelPlus
# CHECK: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
# Check the situation where the PLD requires an alignment nop.
.globl AlignPLD
.p2align 6
.type AlignPLD,@function
.space 60 # Force the pld to require an alignment nop.
AlignPLD:
.LAlignPLD$local:
pld 3, vec@got@pcrel(0), 1
.Lpcrel201:
.reloc .Lpcrel201-8,R_PPC64_PCREL_OPT,.-(.Lpcrel201-8)
lwa 3, 4(3)
blr
# CHECK-LABEL: AlignPLD
# CHECK: nop
# CHECK-NEXT: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
# The label and the pld are on the same line and so the nop is inserted before
# the label and the relocation should work.
.globl AlignPLDSameLine
.p2align 6
.type AlignPLDSameLine,@function
.space 60 # Force the pld to require an alignment nop.
AlignPLDSameLine:
.LAlignPLDSameLine$local:
.Lpcrel202: pld 3, vec@got@pcrel(0), 1
.reloc .Lpcrel202,R_PPC64_PCREL_OPT,.-.Lpcrel202
lwa 3, 4(3)
blr
# CHECK-LABEL: AlignPLDSameLine
# CHECK: nop
# CHECK-NEXT: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl AlignPLDLabelBefore
.p2align 6
.type AlignPLDLabelBefore,@function
.space 60 # Force the pld to require an alignment nop.
AlignPLDLabelBefore:
.LAlignPLDLabelBefore$local:
.Label:
pld 3, vec@got@pcrel(0), 1
.Lpcrel203:
.reloc .Lpcrel203-8,R_PPC64_PCREL_OPT,.-(.Lpcrel203-8)
lwa 3, 4(3)
blr
# CHECK-LABEL: AlignPLDLabelBefore
# CHECK: nop
# CHECK-NEXT: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr
.globl AlignPLDLabelSameLine
.p2align 6
.type AlignPLDLabelSameLine,@function
.space 60 # Force the pld to require an alignment nop.
AlignPLDLabelSameLine:
.Label2: pld 3, vec@got@pcrel(0), 1
.Lpcrel204:
.reloc .Lpcrel204-8,R_PPC64_PCREL_OPT,.-(.Lpcrel204-8)
lwa 3, 4(3)
blr
# CHECK-LABEL: AlignPLDLabelSameLine
# CHECK: nop
# CHECK-NEXT: pld 3, 0(0), 1
# CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
# CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
# CHECK-NEXT: lwa 3, 4(3)
# CHECK-NEXT: blr