1 ; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -stop-after=machine-cp -mcpu=pwr4 \
2 ; RUN: -mattr=-altivec -verify-machineinstrs < %s | \
5 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec \
6 ; RUN: -mtriple powerpc64-ibm-aix-xcoff < %s | \
7 ; RUN: FileCheck --check-prefix=ASM %s
9 %struct.S5 = type { [5 x i8] }
11 define zeroext i8 @test_byval_5Byte(ptr byval(%struct.S5) align 1 %s) {
13 %arrayidx = getelementptr inbounds %struct.S5, ptr %s, i32 0, i32 0, i32 4
14 %0 = load i8, ptr %arrayidx, align 1
18 ; CHECK-LABEL: name: test_byval_5Byte
21 ; CHECK-NEXT: - { id: 0, type: default, offset: 48, size: 8, alignment: 16,
23 ; CHECK-NEXT: liveins: $x3
24 ; CHECK: STD killed renamable $x3, 0, %fixed-stack.0 :: (store (s64) into %fixed-stack.0, align 16)
25 ; CHECK-NEXT: renamable $x3 = LBZ8 4, %fixed-stack.0 :: (dereferenceable load (s8)
27 ; ASM-LABEL: .test_byval_5Byte:
30 ; ASM-NEXT: lbz 3, 52(1)
34 %struct.S6 = type { [6 x i8] }
36 define zeroext i8 @test_byval_6Byte(ptr byval(%struct.S6) align 1 %s) {
38 %arrayidx = getelementptr inbounds %struct.S6, ptr %s, i32 0, i32 0, i32 5
39 %0 = load i8, ptr %arrayidx, align 1
43 ; CHECK-LABEL: name: test_byval_6Byte
46 ; CHECK-NEXT: - { id: 0, type: default, offset: 48, size: 8, alignment: 16,
48 ; CHECK-NEXT: liveins: $x3
49 ; CHECK: STD killed renamable $x3, 0, %fixed-stack.0 :: (store (s64) into %fixed-stack.0, align 16)
50 ; CHECK-NEXT: renamable $x3 = LBZ8 5, %fixed-stack.0 :: (dereferenceable load (s8)
52 ; ASM-LABEL: .test_byval_6Byte:
55 ; ASM-NEXT: lbz 3, 53(1)
59 %struct.S7 = type { [7 x i8] }
61 define zeroext i8 @test_byval_7Byte(ptr byval(%struct.S7) align 1 %s) {
63 %arrayidx = getelementptr inbounds %struct.S7, ptr %s, i32 0, i32 0, i32 6
64 %0 = load i8, ptr %arrayidx, align 1
68 ; CHECK-LABEL: name: test_byval_7Byte
71 ; CHECK-NEXT: - { id: 0, type: default, offset: 48, size: 8, alignment: 16,
73 ; CHECK-NEXT: liveins: $x3
74 ; CHECK: STD killed renamable $x3, 0, %fixed-stack.0 :: (store (s64) into %fixed-stack.0, align 16)
75 ; CHECK-NEXT: renamable $x3 = LBZ8 6, %fixed-stack.0 :: (dereferenceable load (s8)
77 ; ASM-LABEL: .test_byval_7Byte:
80 ; ASM-NEXT: lbz 3, 54(1)
84 %struct.S8 = type { [8 x i8] }
86 define zeroext i8 @test_byval_8Byte(ptr byval(%struct.S8) align 1 %s) {
88 %arrayidx = getelementptr inbounds %struct.S8, ptr %s, i32 0, i32 0, i32 7
89 %0 = load i8, ptr %arrayidx, align 1
93 ; CHECK-LABEL: name: test_byval_8Byte
96 ; CHECK-NEXT: - { id: 0, type: default, offset: 48, size: 8, alignment: 16,
98 ; CHECK-NEXT: liveins: $x3
99 ; CHECK: renamable $x[[SCRATCH:[0-9]+]] = COPY $x3
100 ; CHECK-DAG: renamable $x3 = RLDICL $x3, 0, 56
101 ; CHECK-DAG: STD killed renamable $x[[SCRATCH]], 0, %fixed-stack.0 :: (store (s64) into %fixed-stack.0, align 16)
104 ; ASM-LABEL: .test_byval_8Byte:
106 ; ASM: mr [[SCRATCH:[0-9]+]], 3
107 ; ASM-DAG: clrldi 3, 3, 56
108 ; ASM-DAG: std [[SCRATCH]], 48(1)
112 %struct.S64 = type { [64 x i8] }
114 @gS64 = external global %struct.S64, align 1
116 define void @call_test_byval_64Byte() {
118 call void @test_byval_64Byte(ptr byval(%struct.S64) align 1 @gS64)
122 declare void @test_byval_64Byte(ptr byval(%struct.S64) align 1)
124 ; CHECK-LABEL: name: call_test_byval_64Byte{{.*}}
126 ; The DAG block permits some invalid inputs for the benefit of allowing more valid orderings.
127 ; CHECK: ADJCALLSTACKDOWN 112, 0, implicit-def dead $r1, implicit $r1
128 ; CHECK-NEXT: renamable $x[[REGADDR:[0-9]+]] = LDtoc @gS64, $x2 :: (load (s64) from got)
129 ; CHECK-DAG: renamable $x3 = LD 0, killed renamable $x[[REGADDR]] :: (load (s64))
130 ; CHECK-DAG: renamable $x4 = LD 8, renamable $x[[REGADDR]] :: (load (s64))
131 ; CHECK-DAG: renamable $x5 = LD 16, renamable $x[[REGADDR]] :: (load (s64))
132 ; CHECK-DAG: renamable $x6 = LD 24, renamable $x[[REGADDR]] :: (load (s64))
133 ; CHECK-DAG: renamable $x7 = LD 32, renamable $x[[REGADDR]] :: (load (s64))
134 ; CHECK-DAG: renamable $x8 = LD 40, renamable $x[[REGADDR]] :: (load (s64))
135 ; CHECK-DAG: renamable $x9 = LD 48, renamable $x[[REGADDR]] :: (load (s64))
136 ; CHECK-DAG: renamable $x10 = LD 56, renamable $x[[REGADDR]] :: (load (s64))
137 ; CHECK-NEXT: BL8_NOP <mcsymbol .test_byval_64Byte[PR]>, csr_ppc64, implicit-def dead $lr8, implicit $rm, implicit $x3, implicit $x4, implicit $x5, implicit $x6, implicit $x7, implicit $x8, implicit $x9, implicit $x10, implicit $x2, implicit-def $r1
138 ; CHECK-NEXT: ADJCALLSTACKUP 112, 0, implicit-def dead $r1, implicit $r1
140 ; ASM-LABEL: .call_test_byval_64Byte:
142 ; ASM: stdu 1, -112(1)
143 ; ASM-NEXT: ld [[REG:[0-9]+]], L..C{{[0-9]+}}(2)
144 ; ASM-DAG: ld 3, 0([[REG]])
145 ; ASM-DAG: ld 4, 8([[REG]])
146 ; ASM-DAG: ld 5, 16([[REG]])
147 ; ASM-DAG: ld 6, 24([[REG]])
148 ; ASM-DAG: ld 7, 32([[REG]])
149 ; ASM-DAG: ld 8, 40([[REG]])
150 ; ASM-DAG: ld 9, 48([[REG]])
151 ; ASM-DAG: ld 10, 56([[REG]])
152 ; ASM-NEXT: bl .test_byval_64Byte