1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
3 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s \
4 ; RUN: | FileCheck %s --check-prefix=LE
5 ; RUN: llc -verify-machineinstrs -target-abi=elfv2 -mtriple=powerpc64-- \
6 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s \
7 ; RUN: | FileCheck %s --check-prefix=BE
10 %struct.Struct = type { i8, i16, i32 }
12 @valChar = external local_unnamed_addr global i8, align 1
13 @valShort = external local_unnamed_addr global i16, align 2
14 @valInt = external global i32, align 4
15 @valUnsigned = external local_unnamed_addr global i32, align 4
16 @valLong = external local_unnamed_addr global i64, align 8
17 @ptr = external local_unnamed_addr global ptr, align 8
18 @array = external local_unnamed_addr global [10 x i32], align 4
19 @structure = external local_unnamed_addr global %struct.Struct, align 4
20 @ptrfunc = external local_unnamed_addr global ptr, align 8
22 define dso_local signext i32 @ReadGlobalVarChar() local_unnamed_addr {
23 ; LE-LABEL: ReadGlobalVarChar:
24 ; LE: # %bb.0: # %entry
25 ; LE-NEXT: pld r3, valChar@got@pcrel(0), 1
27 ; LE-NEXT: .reloc .Lpcrel0-8,R_PPC64_PCREL_OPT,.-(.Lpcrel0-8)
28 ; LE-NEXT: lbz r3, 0(r3)
31 ; BE-LABEL: ReadGlobalVarChar:
32 ; BE: # %bb.0: # %entry
33 ; BE-NEXT: pld r3, valChar@got@pcrel(0), 1
35 ; BE-NEXT: .reloc .Lpcrel0-8,R_PPC64_PCREL_OPT,.-(.Lpcrel0-8)
36 ; BE-NEXT: lbz r3, 0(r3)
39 %0 = load i8, ptr @valChar, align 1
40 %conv = zext i8 %0 to i32
44 define dso_local void @WriteGlobalVarChar() local_unnamed_addr {
45 ; LE-LABEL: WriteGlobalVarChar:
46 ; LE: # %bb.0: # %entry
47 ; LE-NEXT: pld r3, valChar@got@pcrel(0), 1
49 ; LE-NEXT: stb r4, 0(r3)
52 ; BE-LABEL: WriteGlobalVarChar:
53 ; BE: # %bb.0: # %entry
54 ; BE-NEXT: pld r3, valChar@got@pcrel(0), 1
56 ; BE-NEXT: stb r4, 0(r3)
59 store i8 3, ptr @valChar, align 1
63 define dso_local signext i32 @ReadGlobalVarShort() local_unnamed_addr {
64 ; LE-LABEL: ReadGlobalVarShort:
65 ; LE: # %bb.0: # %entry
66 ; LE-NEXT: pld r3, valShort@got@pcrel(0), 1
68 ; LE-NEXT: .reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
69 ; LE-NEXT: lha r3, 0(r3)
72 ; BE-LABEL: ReadGlobalVarShort:
73 ; BE: # %bb.0: # %entry
74 ; BE-NEXT: pld r3, valShort@got@pcrel(0), 1
76 ; BE-NEXT: .reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
77 ; BE-NEXT: lha r3, 0(r3)
80 %0 = load i16, ptr @valShort, align 2
81 %conv = sext i16 %0 to i32
85 define dso_local void @WriteGlobalVarShort() local_unnamed_addr {
86 ; LE-LABEL: WriteGlobalVarShort:
87 ; LE: # %bb.0: # %entry
88 ; LE-NEXT: pld r3, valShort@got@pcrel(0), 1
90 ; LE-NEXT: sth r4, 0(r3)
93 ; BE-LABEL: WriteGlobalVarShort:
94 ; BE: # %bb.0: # %entry
95 ; BE-NEXT: pld r3, valShort@got@pcrel(0), 1
97 ; BE-NEXT: sth r4, 0(r3)
100 store i16 3, ptr @valShort, align 2
104 define dso_local signext i32 @ReadGlobalVarInt() local_unnamed_addr {
105 ; LE-LABEL: ReadGlobalVarInt:
106 ; LE: # %bb.0: # %entry
107 ; LE-NEXT: pld r3, valInt@got@pcrel(0), 1
109 ; LE-NEXT: .reloc .Lpcrel2-8,R_PPC64_PCREL_OPT,.-(.Lpcrel2-8)
110 ; LE-NEXT: lwa r3, 0(r3)
113 ; BE-LABEL: ReadGlobalVarInt:
114 ; BE: # %bb.0: # %entry
115 ; BE-NEXT: pld r3, valInt@got@pcrel(0), 1
117 ; BE-NEXT: .reloc .Lpcrel2-8,R_PPC64_PCREL_OPT,.-(.Lpcrel2-8)
118 ; BE-NEXT: lwa r3, 0(r3)
121 %0 = load i32, ptr @valInt, align 4
125 define dso_local void @WriteGlobalVarInt() local_unnamed_addr {
126 ; LE-LABEL: WriteGlobalVarInt:
127 ; LE: # %bb.0: # %entry
128 ; LE-NEXT: pld r3, valInt@got@pcrel(0), 1
130 ; LE-NEXT: stw r4, 0(r3)
133 ; BE-LABEL: WriteGlobalVarInt:
134 ; BE: # %bb.0: # %entry
135 ; BE-NEXT: pld r3, valInt@got@pcrel(0), 1
137 ; BE-NEXT: stw r4, 0(r3)
140 store i32 33, ptr @valInt, align 4
144 define dso_local signext i32 @ReadGlobalVarUnsigned() local_unnamed_addr {
145 ; LE-LABEL: ReadGlobalVarUnsigned:
146 ; LE: # %bb.0: # %entry
147 ; LE-NEXT: pld r3, valUnsigned@got@pcrel(0), 1
149 ; LE-NEXT: .reloc .Lpcrel3-8,R_PPC64_PCREL_OPT,.-(.Lpcrel3-8)
150 ; LE-NEXT: lwa r3, 0(r3)
153 ; BE-LABEL: ReadGlobalVarUnsigned:
154 ; BE: # %bb.0: # %entry
155 ; BE-NEXT: pld r3, valUnsigned@got@pcrel(0), 1
157 ; BE-NEXT: .reloc .Lpcrel3-8,R_PPC64_PCREL_OPT,.-(.Lpcrel3-8)
158 ; BE-NEXT: lwa r3, 0(r3)
161 %0 = load i32, ptr @valUnsigned, align 4
165 define dso_local void @WriteGlobalVarUnsigned() local_unnamed_addr {
166 ; LE-LABEL: WriteGlobalVarUnsigned:
167 ; LE: # %bb.0: # %entry
168 ; LE-NEXT: pld r3, valUnsigned@got@pcrel(0), 1
170 ; LE-NEXT: stw r4, 0(r3)
173 ; BE-LABEL: WriteGlobalVarUnsigned:
174 ; BE: # %bb.0: # %entry
175 ; BE-NEXT: pld r3, valUnsigned@got@pcrel(0), 1
177 ; BE-NEXT: stw r4, 0(r3)
180 store i32 33, ptr @valUnsigned, align 4
184 define dso_local signext i32 @ReadGlobalVarLong() local_unnamed_addr {
185 ; LE-LABEL: ReadGlobalVarLong:
186 ; LE: # %bb.0: # %entry
187 ; LE-NEXT: pld r3, valLong@got@pcrel(0), 1
189 ; LE-NEXT: .reloc .Lpcrel4-8,R_PPC64_PCREL_OPT,.-(.Lpcrel4-8)
190 ; LE-NEXT: lwa r3, 0(r3)
193 ; BE-LABEL: ReadGlobalVarLong:
194 ; BE: # %bb.0: # %entry
195 ; BE-NEXT: pld r3, valLong@got@pcrel(0), 1
197 ; BE-NEXT: .reloc .Lpcrel4-8,R_PPC64_PCREL_OPT,.-(.Lpcrel4-8)
198 ; BE-NEXT: lwa r3, 4(r3)
201 %0 = load i64, ptr @valLong, align 8
202 %conv = trunc i64 %0 to i32
206 define dso_local void @WriteGlobalVarLong() local_unnamed_addr {
207 ; LE-LABEL: WriteGlobalVarLong:
208 ; LE: # %bb.0: # %entry
209 ; LE-NEXT: pld r3, valLong@got@pcrel(0), 1
210 ; LE-NEXT: li r4, 3333
211 ; LE-NEXT: std r4, 0(r3)
214 ; BE-LABEL: WriteGlobalVarLong:
215 ; BE: # %bb.0: # %entry
216 ; BE-NEXT: pld r3, valLong@got@pcrel(0), 1
217 ; BE-NEXT: li r4, 3333
218 ; BE-NEXT: std r4, 0(r3)
221 store i64 3333, ptr @valLong, align 8
225 define dso_local ptr @ReadGlobalPtr() local_unnamed_addr {
226 ; LE-LABEL: ReadGlobalPtr:
227 ; LE: # %bb.0: # %entry
228 ; LE-NEXT: pld r3, ptr@got@pcrel(0), 1
230 ; LE-NEXT: .reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
231 ; LE-NEXT: ld r3, 0(r3)
234 ; BE-LABEL: ReadGlobalPtr:
235 ; BE: # %bb.0: # %entry
236 ; BE-NEXT: pld r3, ptr@got@pcrel(0), 1
238 ; BE-NEXT: .reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
239 ; BE-NEXT: ld r3, 0(r3)
242 %0 = load ptr, ptr @ptr, align 8
246 define dso_local void @WriteGlobalPtr() local_unnamed_addr {
247 ; LE-LABEL: WriteGlobalPtr:
248 ; LE: # %bb.0: # %entry
249 ; LE-NEXT: pld r3, ptr@got@pcrel(0), 1
252 ; LE-NEXT: .reloc .Lpcrel6-8,R_PPC64_PCREL_OPT,.-(.Lpcrel6-8)
253 ; LE-NEXT: ld r3, 0(r3)
254 ; LE-NEXT: stw r4, 0(r3)
257 ; BE-LABEL: WriteGlobalPtr:
258 ; BE: # %bb.0: # %entry
259 ; BE-NEXT: pld r3, ptr@got@pcrel(0), 1
262 ; BE-NEXT: .reloc .Lpcrel6-8,R_PPC64_PCREL_OPT,.-(.Lpcrel6-8)
263 ; BE-NEXT: ld r3, 0(r3)
264 ; BE-NEXT: stw r4, 0(r3)
267 %0 = load ptr, ptr @ptr, align 8
268 store i32 3, ptr %0, align 4
272 define dso_local nonnull ptr @GlobalVarAddr() local_unnamed_addr {
273 ; LE-LABEL: GlobalVarAddr:
274 ; LE: # %bb.0: # %entry
275 ; LE-NEXT: pld r3, valInt@got@pcrel(0), 1
278 ; BE-LABEL: GlobalVarAddr:
279 ; BE: # %bb.0: # %entry
280 ; BE-NEXT: pld r3, valInt@got@pcrel(0), 1
286 define dso_local signext i32 @ReadGlobalArray() local_unnamed_addr {
287 ; LE-LABEL: ReadGlobalArray:
288 ; LE: # %bb.0: # %entry
289 ; LE-NEXT: pld r3, array@got@pcrel(0), 1
291 ; LE-NEXT: .reloc .Lpcrel7-8,R_PPC64_PCREL_OPT,.-(.Lpcrel7-8)
292 ; LE-NEXT: lwa r3, 12(r3)
295 ; BE-LABEL: ReadGlobalArray:
296 ; BE: # %bb.0: # %entry
297 ; BE-NEXT: pld r3, array@got@pcrel(0), 1
299 ; BE-NEXT: .reloc .Lpcrel7-8,R_PPC64_PCREL_OPT,.-(.Lpcrel7-8)
300 ; BE-NEXT: lwa r3, 12(r3)
303 %0 = load i32, ptr getelementptr inbounds ([10 x i32], ptr @array, i64 0, i64 3), align 4
307 define dso_local void @WriteGlobalArray() local_unnamed_addr {
308 ; LE-LABEL: WriteGlobalArray:
309 ; LE: # %bb.0: # %entry
310 ; LE-NEXT: pld r3, array@got@pcrel(0), 1
312 ; LE-NEXT: stw r4, 12(r3)
315 ; BE-LABEL: WriteGlobalArray:
316 ; BE: # %bb.0: # %entry
317 ; BE-NEXT: pld r3, array@got@pcrel(0), 1
319 ; BE-NEXT: stw r4, 12(r3)
322 store i32 5, ptr getelementptr inbounds ([10 x i32], ptr @array, i64 0, i64 3), align 4
326 define dso_local signext i32 @ReadGlobalStruct() local_unnamed_addr {
327 ; LE-LABEL: ReadGlobalStruct:
328 ; LE: # %bb.0: # %entry
329 ; LE-NEXT: pld r3, structure@got@pcrel(0), 1
331 ; LE-NEXT: .reloc .Lpcrel8-8,R_PPC64_PCREL_OPT,.-(.Lpcrel8-8)
332 ; LE-NEXT: lwa r3, 4(r3)
335 ; BE-LABEL: ReadGlobalStruct:
336 ; BE: # %bb.0: # %entry
337 ; BE-NEXT: pld r3, structure@got@pcrel(0), 1
339 ; BE-NEXT: .reloc .Lpcrel8-8,R_PPC64_PCREL_OPT,.-(.Lpcrel8-8)
340 ; BE-NEXT: lwa r3, 4(r3)
343 %0 = load i32, ptr getelementptr inbounds (%struct.Struct, ptr @structure, i64 0, i32 2), align 4
347 define dso_local void @WriteGlobalStruct() local_unnamed_addr {
348 ; LE-LABEL: WriteGlobalStruct:
349 ; LE: # %bb.0: # %entry
350 ; LE-NEXT: pld r3, structure@got@pcrel(0), 1
352 ; LE-NEXT: stw r4, 4(r3)
355 ; BE-LABEL: WriteGlobalStruct:
356 ; BE: # %bb.0: # %entry
357 ; BE-NEXT: pld r3, structure@got@pcrel(0), 1
359 ; BE-NEXT: stw r4, 4(r3)
362 store i32 3, ptr getelementptr inbounds (%struct.Struct, ptr @structure, i64 0, i32 2), align 4
366 define dso_local void @ReadFuncPtr() local_unnamed_addr {
367 ; LE-LABEL: ReadFuncPtr:
368 ; LE: .localentry ReadFuncPtr, 1
369 ; LE-NEXT: # %bb.0: # %entry
370 ; LE-NEXT: pld r3, ptrfunc@got@pcrel(0), 1
372 ; LE-NEXT: .reloc .Lpcrel9-8,R_PPC64_PCREL_OPT,.-(.Lpcrel9-8)
373 ; LE-NEXT: ld r12, 0(r3)
376 ; LE-NEXT: #TC_RETURNr8 ctr 0
378 ; BE-LABEL: ReadFuncPtr:
379 ; BE: .localentry ReadFuncPtr, 1
380 ; BE-NEXT: # %bb.0: # %entry
381 ; BE-NEXT: pld r3, ptrfunc@got@pcrel(0), 1
383 ; BE-NEXT: .reloc .Lpcrel9-8,R_PPC64_PCREL_OPT,.-(.Lpcrel9-8)
384 ; BE-NEXT: ld r12, 0(r3)
387 ; BE-NEXT: #TC_RETURNr8 ctr 0
389 %0 = load ptr, ptr @ptrfunc, align 8
394 define dso_local void @WriteFuncPtr() local_unnamed_addr {
395 ; LE-LABEL: WriteFuncPtr:
396 ; LE: # %bb.0: # %entry
397 ; LE-NEXT: pld r3, ptrfunc@got@pcrel(0), 1
398 ; LE-NEXT: pld r4, function@got@pcrel(0), 1
399 ; LE-NEXT: std r4, 0(r3)
402 ; BE-LABEL: WriteFuncPtr:
403 ; BE: # %bb.0: # %entry
404 ; BE-NEXT: pld r3, ptrfunc@got@pcrel(0), 1
405 ; BE-NEXT: pld r4, function@got@pcrel(0), 1
406 ; BE-NEXT: std r4, 0(r3)
409 store ptr @function, ptr @ptrfunc, align 8
413 declare void @function(...)