Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / PowerPC / ppc64-reloc-directive-pcrel.s
bloba31ea568fd8d57c427c53d9f117ec9b31c1c3671
1 # RUN: llvm-mc -triple=powerpc64le -filetype=obj %s | \
2 # RUN: llvm-objdump -dr --mcpu=pwr10 - | FileCheck %s
3 # RUN: llvm-mc -triple=powerpc64 -filetype=obj %s | \
4 # RUN: llvm-objdump -dr --mcpu=pwr10 - | FileCheck %s
7 ##
8 # This section of tests contains the MCBinaryExpr as the first parameter of the
9 # .reloc relocation.
11 .text
12 .abiversion 2
13 .globl Minimal
14 .p2align 4
15 .type Minimal,@function
16 Minimal:
17 .LMinimal$local:
18 pld 3, vec@got@pcrel(0), 1
19 .Lpcrel1:
20 .reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
21 lwa 3, 4(3)
22 blr
23 .long 0
24 .quad 0
25 # CHECK-LABEL: Minimal
26 # CHECK: pld 3, 0(0), 1
27 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
28 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
29 # CHECK-NEXT: lwa 3, 4(3)
30 # CHECK-NEXT: blr
32 .globl SingleInsnBetween
33 .p2align 4
34 .type SingleInsnBetween,@function
35 SingleInsnBetween:
36 .LSingleInsnBetween$local:
37 pld 3, vec@got@pcrel(0), 1
38 .Lpcrel2:
39 addi 3, 3, 42
40 .reloc .Lpcrel2-8,R_PPC64_PCREL_OPT,.-(.Lpcrel2-8)
41 lwa 3, 4(3)
42 blr
43 .long 0
44 .quad 0
45 # CHECK-LABEL: SingleInsnBetween
46 # CHECK: pld 3, 0(0), 1
47 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
48 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0xc
49 # CHECK-NEXT: addi 3, 3, 42
50 # CHECK-NEXT: lwa 3, 4(3)
51 # CHECK-NEXT: blr
54 .globl MultiInsnBetween # -- Begin function
55 .p2align 4
56 .type MultiInsnBetween,@function
57 MultiInsnBetween:
58 .LMultiInsnBetween$local:
59 pld 3, vec@got@pcrel(0), 1
60 .Lpcrel3:
61 addi 3, 3, 42
62 addi 3, 3, 42
63 addi 3, 3, 42
64 addi 3, 3, 42
65 addi 3, 3, 42
66 .reloc .Lpcrel3-8,R_PPC64_PCREL_OPT,.-(.Lpcrel3-8)
67 lwa 3, 4(3)
68 blr
69 .long 0
70 .quad 0
71 # CHECK-LABEL: MultiInsnBetween
72 # CHECK: pld 3, 0(0), 1
73 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
74 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x1c
75 # CHECK-NEXT: addi 3, 3, 42
76 # CHECK-NEXT: addi 3, 3, 42
77 # CHECK-NEXT: addi 3, 3, 42
78 # CHECK-NEXT: addi 3, 3, 42
79 # CHECK-NEXT: addi 3, 3, 42
80 # CHECK-NEXT: lwa 3, 4(3)
81 # CHECK-NEXT: blr
83 .globl PrefixInsnBetween
84 .p2align 6
85 .type PrefixInsnBetween,@function
86 .space 48 # Add a space to force an alignment of a paddi.
87 PrefixInsnBetween:
88 .LPrefixInsnBetween$local:
89 pld 3, vec@got@pcrel(0), 1
90 .Lpcrel4:
91 addi 3, 3, 42
92 paddi 3, 3, 42, 0
93 addi 3, 3, 42
94 paddi 3, 3, 42, 0
95 addi 3, 3, 42
96 .reloc .Lpcrel4-8,R_PPC64_PCREL_OPT,.-(.Lpcrel4-8)
97 lwa 3, 4(3)
98 blr
99 .long 0
100 .quad 0
101 # CHECK-LABEL: PrefixInsnBetween
102 # CHECK: pld 3, 0(0), 1
103 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
104 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x28
105 # CHECK-NEXT: addi 3, 3, 42
106 # CHECK-NEXT: nop
107 # CHECK-NEXT: paddi 3, 3, 42, 0
108 # CHECK-NEXT: addi 3, 3, 42
109 # CHECK-NEXT: paddi 3, 3, 42, 0
110 # CHECK-NEXT: addi 3, 3, 42
111 # CHECK-NEXT: lwa 3, 4(3)
112 # CHECK-NEXT: blr
115 .globl SpaceBetween # -- Begin function
116 .p2align 4
117 .type SpaceBetween,@function
118 SpaceBetween:
119 .LSpaceBetween$local:
120 pld 3, vec@got@pcrel(0), 1
121 .Lpcrel5:
122 addi 3, 3, 42
123 paddi 3, 3, 42, 0
124 addi 3, 3, 42
125 .space 40, 0
126 paddi 3, 3, 42, 0
127 addi 3, 3, 42
128 .reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
129 lwa 3, 4(3)
131 .long 0
132 .quad 0
133 # CHECK-LABEL: SpaceBetween
134 # CHECK: pld 3, 0(0), 1
135 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
136 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x50
137 # CHECK-NEXT: addi 3, 3, 42
138 # CHECK-NEXT: nop
139 # CHECK-NEXT: paddi 3, 3, 42, 0
140 # CHECK-NEXT: addi 3, 3, 42
141 # CHECK: paddi 3, 3, 42, 0
142 # CHECK-NEXT: addi 3, 3, 42
143 # CHECK-NEXT: lwa 3, 4(3)
144 # CHECK-NEXT: blr
147 .globl Plus
148 .p2align 4
149 .type Plus,@function
150 Plus:
151 .LPlus$local:
152 .Lpcrel6:
153 addi 3, 3, 42
154 addi 3, 3, 42
155 pld 3, vec@got@pcrel(0), 1
156 .reloc .Lpcrel6+8,R_PPC64_PCREL_OPT,.-(.Lpcrel6+8)
157 lwa 3, 4(3)
159 .long 0
160 .quad 0
161 # CHECK-LABEL: Plus
162 # CHECK: pld 3, 0(0), 1
163 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
164 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
165 # CHECK-NEXT: lwa 3, 4(3)
166 # CHECK-NEXT: blr
169 # This section of tests contains the variable MCSymbol as part of the
170 # MCSymbolRefExpr for the first parameter of the .reloc relocation.
172 .globl VarLabelMinimal # -- Begin function
173 .p2align 4
174 .type VarLabelMinimal,@function
175 VarLabelMinimal:
176 .LVarLabelMinimal$local:
177 pld 3, vec@got@pcrel(0), 1
178 .Lpcrel101=.-8
179 .reloc .Lpcrel101,R_PPC64_PCREL_OPT,.-.Lpcrel101
180 lwa 3, 4(3)
182 .long 0
183 .quad 0
184 # CHECK-LABEL: VarLabelMinimal
185 # CHECK: pld 3, 0(0), 1
186 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
187 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
188 # CHECK-NEXT: lwa 3, 4(3)
189 # CHECK-NEXT: blr
192 .globl VarLabelSingleInsnBetween
193 .p2align 4
194 .type VarLabelSingleInsnBetween,@function
195 VarLabelSingleInsnBetween:
196 .LVarLabelSingleInsnBetween$local:
197 pld 3, vec@got@pcrel(0), 1
198 .Lpcrel102=.-8
199 addi 3, 3, 42
200 .reloc .Lpcrel102,R_PPC64_PCREL_OPT,.-.Lpcrel102
201 lwa 3, 4(3)
203 .long 0
204 .quad 0
205 # CHECK-LABEL: VarLabelSingleInsnBetween
206 # CHECK: pld 3, 0(0), 1
207 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
208 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0xc
209 # CHECK-NEXT: addi 3, 3, 42
210 # CHECK-NEXT: lwa 3, 4(3)
211 # CHECK-NEXT: blr
213 .globl VarLabelMultiInsnBetween # -- Begin function
214 .p2align 4
215 .type VarLabelMultiInsnBetween,@function
216 VarLabelMultiInsnBetween:
217 .LVarLabelMultiInsnBetween$local:
218 pld 3, vec@got@pcrel(0), 1
219 .Lpcrel103=.-8
220 addi 3, 3, 42
221 addi 3, 3, 42
222 addi 3, 3, 42
223 addi 3, 3, 42
224 addi 3, 3, 42
225 .reloc .Lpcrel103,R_PPC64_PCREL_OPT,.-.Lpcrel103
226 lwa 3, 4(3)
228 .long 0
229 .quad 0
230 # CHECK-LABEL: VarLabelMultiInsnBetween
231 # CHECK: pld 3, 0(0), 1
232 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
233 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x1c
234 # CHECK-NEXT: addi 3, 3, 42
235 # CHECK-NEXT: addi 3, 3, 42
236 # CHECK-NEXT: addi 3, 3, 42
237 # CHECK-NEXT: addi 3, 3, 42
238 # CHECK-NEXT: addi 3, 3, 42
239 # CHECK-NEXT: lwa 3, 4(3)
240 # CHECK-NEXT: blr
243 .globl VarLabelPrefixInsnBetween # -- Begin function
244 .p2align 4
245 .type VarLabelPrefixInsnBetween,@function
246 VarLabelPrefixInsnBetween:
247 .LVarLabelPrefixInsnBetween$local:
248 pld 3, vec@got@pcrel(0), 1
249 .Lpcrel104=.-8
250 addi 3, 3, 42
251 paddi 3, 3, 42, 0
252 addi 3, 3, 42
253 paddi 3, 3, 42, 0
254 addi 3, 3, 42
255 .reloc .Lpcrel104,R_PPC64_PCREL_OPT,.-.Lpcrel104
256 lwa 3, 4(3)
258 .long 0
259 .quad 0
260 # CHECK-LABEL: VarLabelPrefixInsnBetween
261 # CHECK: pld 3, 0(0), 1
262 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
263 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x24
264 # CHECK-NEXT: addi 3, 3, 42
265 # CHECK-NEXT: paddi 3, 3, 42, 0
266 # CHECK-NEXT: addi 3, 3, 42
267 # CHECK-NEXT: paddi 3, 3, 42, 0
268 # CHECK-NEXT: addi 3, 3, 42
269 # CHECK-NEXT: lwa 3, 4(3)
270 # CHECK-NEXT: blr
273 .globl VarLabelSpaceBetween # -- Begin function
274 .p2align 4
275 .type VarLabelSpaceBetween,@function
276 VarLabelSpaceBetween:
277 .LVarLabelSpaceBetween$local:
278 pld 3, vec@got@pcrel(0), 1
279 .Lpcrel105=.-8
280 addi 3, 3, 42
281 paddi 3, 3, 42, 0
282 addi 3, 3, 42
283 .space 40, 0
284 paddi 3, 3, 42, 0
285 addi 3, 3, 42
286 .reloc .Lpcrel105,R_PPC64_PCREL_OPT,.-.Lpcrel105
287 lwa 3, 4(3)
289 .long 0
290 .quad 0
291 # CHECK-LABEL: VarLabelSpaceBetween
292 # CHECK: pld 3, 0(0), 1
293 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
294 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x4c
295 # CHECK-NEXT: addi 3, 3, 42
296 # CHECK-NEXT: paddi 3, 3, 42, 0
297 # CHECK-NEXT: addi 3, 3, 42
298 # CHECK: paddi 3, 3, 42, 0
299 # CHECK-NEXT: addi 3, 3, 42
300 # CHECK-NEXT: lwa 3, 4(3)
301 # CHECK-NEXT: blr
304 .globl VarLabelPlus
305 .p2align 4
306 .type VarLabelPlus,@function
307 VarLabelPlus:
308 .LVarLabelPlus$local:
309 .Lpcrel106:
310 addi 3, 3, 42
311 addi 3, 3, 42
312 pld 3, vec@got@pcrel(0), 1
313 .reloc .Lpcrel106+8,R_PPC64_PCREL_OPT,.-(.Lpcrel106+8)
314 lwa 3, 4(3)
316 .long 0
317 .quad 0
318 # CHECK-LABEL: VarLabelPlus
319 # CHECK: pld 3, 0(0), 1
320 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
321 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
322 # CHECK-NEXT: lwa 3, 4(3)
323 # CHECK-NEXT: blr
325 # Check the situation where the PLD requires an alignment nop.
326 .globl AlignPLD
327 .p2align 6
328 .type AlignPLD,@function
329 .space 60 # Force the pld to require an alignment nop.
330 AlignPLD:
331 .LAlignPLD$local:
332 pld 3, vec@got@pcrel(0), 1
333 .Lpcrel201:
334 .reloc .Lpcrel201-8,R_PPC64_PCREL_OPT,.-(.Lpcrel201-8)
335 lwa 3, 4(3)
337 # CHECK-LABEL: AlignPLD
338 # CHECK: nop
339 # CHECK-NEXT: pld 3, 0(0), 1
340 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
341 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
342 # CHECK-NEXT: lwa 3, 4(3)
343 # CHECK-NEXT: blr
345 # The label and the pld are on the same line and so the nop is inserted before
346 # the label and the relocation should work.
347 .globl AlignPLDSameLine
348 .p2align 6
349 .type AlignPLDSameLine,@function
350 .space 60 # Force the pld to require an alignment nop.
351 AlignPLDSameLine:
352 .LAlignPLDSameLine$local:
353 .Lpcrel202: pld 3, vec@got@pcrel(0), 1
354 .reloc .Lpcrel202,R_PPC64_PCREL_OPT,.-.Lpcrel202
355 lwa 3, 4(3)
357 # CHECK-LABEL: AlignPLDSameLine
358 # CHECK: nop
359 # CHECK-NEXT: pld 3, 0(0), 1
360 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
361 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
362 # CHECK-NEXT: lwa 3, 4(3)
363 # CHECK-NEXT: blr
365 .globl AlignPLDLabelBefore
366 .p2align 6
367 .type AlignPLDLabelBefore,@function
368 .space 60 # Force the pld to require an alignment nop.
369 AlignPLDLabelBefore:
370 .LAlignPLDLabelBefore$local:
371 .Label:
372 pld 3, vec@got@pcrel(0), 1
373 .Lpcrel203:
374 .reloc .Lpcrel203-8,R_PPC64_PCREL_OPT,.-(.Lpcrel203-8)
375 lwa 3, 4(3)
377 # CHECK-LABEL: AlignPLDLabelBefore
378 # CHECK: nop
379 # CHECK-NEXT: pld 3, 0(0), 1
380 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
381 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
382 # CHECK-NEXT: lwa 3, 4(3)
383 # CHECK-NEXT: blr
385 .globl AlignPLDLabelSameLine
386 .p2align 6
387 .type AlignPLDLabelSameLine,@function
388 .space 60 # Force the pld to require an alignment nop.
389 AlignPLDLabelSameLine:
390 .Label2: pld 3, vec@got@pcrel(0), 1
391 .Lpcrel204:
392 .reloc .Lpcrel204-8,R_PPC64_PCREL_OPT,.-(.Lpcrel204-8)
393 lwa 3, 4(3)
395 # CHECK-LABEL: AlignPLDLabelSameLine
396 # CHECK: nop
397 # CHECK-NEXT: pld 3, 0(0), 1
398 # CHECK-NEXT: R_PPC64_GOT_PCREL34 vec
399 # CHECK-NEXT: R_PPC64_PCREL_OPT *ABS*+0x8
400 # CHECK-NEXT: lwa 3, 4(3)
401 # CHECK-NEXT: blr