annotate clang/test/CodeGen/arm-homogenous.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 0572611fdcc8
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // REQUIRES: arm-registered-target
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -triple armv7---eabi -target-abi aapcs -mfloat-abi hard -emit-llvm %s -o - | FileCheck %s
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 // RUN: %clang_cc1 -triple arm64-apple-darwin9 -target-abi darwinpcs \
anatofuz
parents:
diff changeset
5 // RUN: -ffreestanding -emit-llvm -w -o - %s | FileCheck -check-prefix=CHECK64 %s
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 // RUN: %clang_cc1 -triple arm64-linux-gnu -ffreestanding -emit-llvm -w -o - %s \
anatofuz
parents:
diff changeset
8 // RUN: | FileCheck --check-prefix=CHECK64 %s
anatofuz
parents:
diff changeset
9 typedef long long int64_t;
anatofuz
parents:
diff changeset
10 typedef unsigned int uint32_t;
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 /* This is not a homogenous aggregate - fundamental types are different */
anatofuz
parents:
diff changeset
13 typedef union {
anatofuz
parents:
diff changeset
14 float f[4];
anatofuz
parents:
diff changeset
15 uint32_t i[4];
anatofuz
parents:
diff changeset
16 } union_with_first_floats;
anatofuz
parents:
diff changeset
17 union_with_first_floats g_u_f;
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 extern void takes_union_with_first_floats(union_with_first_floats a);
anatofuz
parents:
diff changeset
20 extern union_with_first_floats returns_union_with_first_floats(void);
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 void test_union_with_first_floats(void) {
anatofuz
parents:
diff changeset
23 takes_union_with_first_floats(g_u_f);
anatofuz
parents:
diff changeset
24 }
anatofuz
parents:
diff changeset
25 // CHECK: declare arm_aapcs_vfpcc void @takes_union_with_first_floats([4 x i32])
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 void test_return_union_with_first_floats(void) {
anatofuz
parents:
diff changeset
28 g_u_f = returns_union_with_first_floats();
anatofuz
parents:
diff changeset
29 }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
30 // CHECK: declare arm_aapcs_vfpcc void @returns_union_with_first_floats(%union.union_with_first_floats* sret(%union.union_with_first_floats) align 4)
150
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 /* This is not a homogenous aggregate - fundamental types are different */
anatofuz
parents:
diff changeset
33 typedef union {
anatofuz
parents:
diff changeset
34 uint32_t i[4];
anatofuz
parents:
diff changeset
35 float f[4];
anatofuz
parents:
diff changeset
36 } union_with_non_first_floats;
anatofuz
parents:
diff changeset
37 union_with_non_first_floats g_u_nf_f;
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 extern void takes_union_with_non_first_floats(union_with_non_first_floats a);
anatofuz
parents:
diff changeset
40 extern union_with_non_first_floats returns_union_with_non_first_floats(void);
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 void test_union_with_non_first_floats(void) {
anatofuz
parents:
diff changeset
43 takes_union_with_non_first_floats(g_u_nf_f);
anatofuz
parents:
diff changeset
44 }
anatofuz
parents:
diff changeset
45 // CHECK: declare arm_aapcs_vfpcc void @takes_union_with_non_first_floats([4 x i32])
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 void test_return_union_with_non_first_floats(void) {
anatofuz
parents:
diff changeset
48 g_u_nf_f = returns_union_with_non_first_floats();
anatofuz
parents:
diff changeset
49 }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
50 // CHECK: declare arm_aapcs_vfpcc void @returns_union_with_non_first_floats(%union.union_with_non_first_floats* sret(%union.union_with_non_first_floats) align 4)
150
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 /* This is not a homogenous aggregate - fundamental types are different */
anatofuz
parents:
diff changeset
53 typedef struct {
anatofuz
parents:
diff changeset
54 float a;
anatofuz
parents:
diff changeset
55 union_with_first_floats b;
anatofuz
parents:
diff changeset
56 } struct_with_union_with_first_floats;
anatofuz
parents:
diff changeset
57 struct_with_union_with_first_floats g_s_f;
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 extern void takes_struct_with_union_with_first_floats(struct_with_union_with_first_floats a);
anatofuz
parents:
diff changeset
60 extern struct_with_union_with_first_floats returns_struct_with_union_with_first_floats(void);
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 void test_struct_with_union_with_first_floats(void) {
anatofuz
parents:
diff changeset
63 takes_struct_with_union_with_first_floats(g_s_f);
anatofuz
parents:
diff changeset
64 }
anatofuz
parents:
diff changeset
65 // CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_first_floats([5 x i32])
anatofuz
parents:
diff changeset
66
anatofuz
parents:
diff changeset
67 void test_return_struct_with_union_with_first_floats(void) {
anatofuz
parents:
diff changeset
68 g_s_f = returns_struct_with_union_with_first_floats();
anatofuz
parents:
diff changeset
69 }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
70 // CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_first_floats(%struct.struct_with_union_with_first_floats* sret(%struct.struct_with_union_with_first_floats) align 4)
150
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 /* This is not a homogenous aggregate - fundamental types are different */
anatofuz
parents:
diff changeset
73 typedef struct {
anatofuz
parents:
diff changeset
74 float a;
anatofuz
parents:
diff changeset
75 union_with_non_first_floats b;
anatofuz
parents:
diff changeset
76 } struct_with_union_with_non_first_floats;
anatofuz
parents:
diff changeset
77 struct_with_union_with_non_first_floats g_s_nf_f;
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 extern void takes_struct_with_union_with_non_first_floats(struct_with_union_with_non_first_floats a);
anatofuz
parents:
diff changeset
80 extern struct_with_union_with_non_first_floats returns_struct_with_union_with_non_first_floats(void);
anatofuz
parents:
diff changeset
81
anatofuz
parents:
diff changeset
82 void test_struct_with_union_with_non_first_floats(void) {
anatofuz
parents:
diff changeset
83 takes_struct_with_union_with_non_first_floats(g_s_nf_f);
anatofuz
parents:
diff changeset
84 }
anatofuz
parents:
diff changeset
85 // CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_non_first_floats([5 x i32])
anatofuz
parents:
diff changeset
86
anatofuz
parents:
diff changeset
87 void test_return_struct_with_union_with_non_first_floats(void) {
anatofuz
parents:
diff changeset
88 g_s_nf_f = returns_struct_with_union_with_non_first_floats();
anatofuz
parents:
diff changeset
89 }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
90 // CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_non_first_floats(%struct.struct_with_union_with_non_first_floats* sret(%struct.struct_with_union_with_non_first_floats) align 4)
150
anatofuz
parents:
diff changeset
91
anatofuz
parents:
diff changeset
92 /* Plain array is not a homogenous aggregate */
anatofuz
parents:
diff changeset
93 extern void takes_array_of_floats(float a[4]);
anatofuz
parents:
diff changeset
94 void test_array_of_floats(void) {
anatofuz
parents:
diff changeset
95 float a[4] = {1.0, 2.0, 3.0, 4.0};
anatofuz
parents:
diff changeset
96 takes_array_of_floats(a);
anatofuz
parents:
diff changeset
97 }
anatofuz
parents:
diff changeset
98 // CHECK: declare arm_aapcs_vfpcc void @takes_array_of_floats(float*)
anatofuz
parents:
diff changeset
99
anatofuz
parents:
diff changeset
100 /* Struct-type homogenous aggregate */
anatofuz
parents:
diff changeset
101 typedef struct {
anatofuz
parents:
diff changeset
102 float x, y, z, w;
anatofuz
parents:
diff changeset
103 } struct_with_fundamental_elems;
anatofuz
parents:
diff changeset
104 struct_with_fundamental_elems g_s;
anatofuz
parents:
diff changeset
105
anatofuz
parents:
diff changeset
106 extern void takes_struct_with_fundamental_elems(struct_with_fundamental_elems a);
anatofuz
parents:
diff changeset
107 extern struct_with_fundamental_elems returns_struct_with_fundamental_elems(void);
anatofuz
parents:
diff changeset
108
anatofuz
parents:
diff changeset
109 void test_struct_with_fundamental_elems(void) {
anatofuz
parents:
diff changeset
110 takes_struct_with_fundamental_elems(g_s);
anatofuz
parents:
diff changeset
111 // CHECK: call arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(%struct.struct_with_fundamental_elems {{.*}})
anatofuz
parents:
diff changeset
112 }
anatofuz
parents:
diff changeset
113 // CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(%struct.struct_with_fundamental_elems)
anatofuz
parents:
diff changeset
114
anatofuz
parents:
diff changeset
115 void test_return_struct_with_fundamental_elems(void) {
anatofuz
parents:
diff changeset
116 g_s = returns_struct_with_fundamental_elems();
anatofuz
parents:
diff changeset
117 // CHECK: call arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems()
anatofuz
parents:
diff changeset
118 }
anatofuz
parents:
diff changeset
119 // CHECK: declare arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems()
anatofuz
parents:
diff changeset
120
anatofuz
parents:
diff changeset
121 /* Array-type homogenous aggregate */
anatofuz
parents:
diff changeset
122 typedef struct {
anatofuz
parents:
diff changeset
123 float xyzw[4];
anatofuz
parents:
diff changeset
124 } struct_with_array;
anatofuz
parents:
diff changeset
125 struct_with_array g_s_a;
anatofuz
parents:
diff changeset
126
anatofuz
parents:
diff changeset
127 extern void takes_struct_with_array(struct_with_array a);
anatofuz
parents:
diff changeset
128 extern struct_with_array returns_struct_with_array(void);
anatofuz
parents:
diff changeset
129
anatofuz
parents:
diff changeset
130 void test_struct_with_array(void) {
anatofuz
parents:
diff changeset
131 takes_struct_with_array(g_s_a);
anatofuz
parents:
diff changeset
132 // CHECK: call arm_aapcs_vfpcc void @takes_struct_with_array(%struct.struct_with_array {{.*}})
anatofuz
parents:
diff changeset
133 }
anatofuz
parents:
diff changeset
134 // CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_array(%struct.struct_with_array)
anatofuz
parents:
diff changeset
135
anatofuz
parents:
diff changeset
136 void test_return_struct_with_array(void) {
anatofuz
parents:
diff changeset
137 g_s_a = returns_struct_with_array();
anatofuz
parents:
diff changeset
138 // CHECK: call arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array()
anatofuz
parents:
diff changeset
139 }
anatofuz
parents:
diff changeset
140 // CHECK: declare arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array()
anatofuz
parents:
diff changeset
141
anatofuz
parents:
diff changeset
142 /* This union is a homogenous aggregate. Check that it's passed properly */
anatofuz
parents:
diff changeset
143 typedef union {
anatofuz
parents:
diff changeset
144 struct_with_fundamental_elems xyzw;
anatofuz
parents:
diff changeset
145 float a[3];
anatofuz
parents:
diff changeset
146 } union_with_struct_with_fundamental_elems;
anatofuz
parents:
diff changeset
147 union_with_struct_with_fundamental_elems g_u_s_fe;
anatofuz
parents:
diff changeset
148
anatofuz
parents:
diff changeset
149 extern void takes_union_with_struct_with_fundamental_elems(union_with_struct_with_fundamental_elems a);
anatofuz
parents:
diff changeset
150 extern union_with_struct_with_fundamental_elems returns_union_with_struct_with_fundamental_elems(void);
anatofuz
parents:
diff changeset
151
anatofuz
parents:
diff changeset
152 void test_union_with_struct_with_fundamental_elems(void) {
anatofuz
parents:
diff changeset
153 takes_union_with_struct_with_fundamental_elems(g_u_s_fe);
anatofuz
parents:
diff changeset
154 // CHECK: call arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(%union.union_with_struct_with_fundamental_elems {{.*}})
anatofuz
parents:
diff changeset
155 }
anatofuz
parents:
diff changeset
156 // CHECK: declare arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(%union.union_with_struct_with_fundamental_elems)
anatofuz
parents:
diff changeset
157
anatofuz
parents:
diff changeset
158 void test_return_union_with_struct_with_fundamental_elems(void) {
anatofuz
parents:
diff changeset
159 g_u_s_fe = returns_union_with_struct_with_fundamental_elems();
anatofuz
parents:
diff changeset
160 // CHECK: call arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems()
anatofuz
parents:
diff changeset
161 }
anatofuz
parents:
diff changeset
162 // CHECK: declare arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems()
anatofuz
parents:
diff changeset
163
anatofuz
parents:
diff changeset
164 // Make sure HAs that can be partially fit into VFP registers will be allocated
anatofuz
parents:
diff changeset
165 // on stack and that later VFP candidates will go on stack as well.
anatofuz
parents:
diff changeset
166 typedef struct {
anatofuz
parents:
diff changeset
167 double x;
anatofuz
parents:
diff changeset
168 double a2;
anatofuz
parents:
diff changeset
169 double a3;
anatofuz
parents:
diff changeset
170 double a4;
anatofuz
parents:
diff changeset
171 } struct_of_four_doubles;
anatofuz
parents:
diff changeset
172 extern void takes_struct_of_four_doubles(double a, struct_of_four_doubles b, struct_of_four_doubles c, double d);
anatofuz
parents:
diff changeset
173 struct_of_four_doubles g_s4d;
anatofuz
parents:
diff changeset
174
anatofuz
parents:
diff changeset
175 void test_struct_of_four_doubles(void) {
anatofuz
parents:
diff changeset
176 // CHECK: test_struct_of_four_doubles
anatofuz
parents:
diff changeset
177 // CHECK: call arm_aapcs_vfpcc void @takes_struct_of_four_doubles(double {{.*}}, %struct.struct_of_four_doubles {{.*}}, %struct.struct_of_four_doubles {{.*}}, double {{.*}})
anatofuz
parents:
diff changeset
178 // CHECK64: test_struct_of_four_doubles
anatofuz
parents:
diff changeset
179 // CHECK64: call void @takes_struct_of_four_doubles(double {{.*}}, [4 x double] {{.*}}, [4 x double] {{.*}}, double {{.*}})
anatofuz
parents:
diff changeset
180 takes_struct_of_four_doubles(3.0, g_s4d, g_s4d, 4.0);
anatofuz
parents:
diff changeset
181 }
anatofuz
parents:
diff changeset
182
anatofuz
parents:
diff changeset
183 extern void takes_struct_of_four_doubles_variadic(double a, struct_of_four_doubles b, struct_of_four_doubles c, double d, ...);
anatofuz
parents:
diff changeset
184
anatofuz
parents:
diff changeset
185 void test_struct_of_four_doubles_variadic(void) {
anatofuz
parents:
diff changeset
186 // CHECK: test_struct_of_four_doubles_variadic
anatofuz
parents:
diff changeset
187 // CHECK: call arm_aapcs_vfpcc void (double, [4 x i64], [4 x i64], double, ...) @takes_struct_of_four_doubles_variadic(double {{.*}}, [4 x i64] {{.*}}, [4 x i64] {{.*}}, double {{.*}})
anatofuz
parents:
diff changeset
188 takes_struct_of_four_doubles_variadic(3.0, g_s4d, g_s4d, 4.0);
anatofuz
parents:
diff changeset
189 }
anatofuz
parents:
diff changeset
190
anatofuz
parents:
diff changeset
191 extern void takes_struct_with_backfill(float f1, double a, float f2, struct_of_four_doubles b, struct_of_four_doubles c, double d);
anatofuz
parents:
diff changeset
192 void test_struct_with_backfill(void) {
anatofuz
parents:
diff changeset
193 // CHECK: test_struct_with_backfill
anatofuz
parents:
diff changeset
194 // CHECK: call arm_aapcs_vfpcc void @takes_struct_with_backfill(float {{.*}}, double {{.*}}, float {{.*}}, %struct.struct_of_four_doubles {{.*}}, %struct.struct_of_four_doubles {{.*}}, double {{.*}})
anatofuz
parents:
diff changeset
195 takes_struct_with_backfill(3.0, 3.1, 3.2, g_s4d, g_s4d, 4.0);
anatofuz
parents:
diff changeset
196 }
anatofuz
parents:
diff changeset
197
anatofuz
parents:
diff changeset
198 typedef __attribute__(( ext_vector_type(8) )) char __char8;
anatofuz
parents:
diff changeset
199 typedef __attribute__(( ext_vector_type(4) )) short __short4;
anatofuz
parents:
diff changeset
200 typedef struct {
anatofuz
parents:
diff changeset
201 __char8 a1;
anatofuz
parents:
diff changeset
202 __short4 a2;
anatofuz
parents:
diff changeset
203 __char8 a3;
anatofuz
parents:
diff changeset
204 __short4 a4;
anatofuz
parents:
diff changeset
205 } struct_of_vecs;
anatofuz
parents:
diff changeset
206 extern void takes_struct_of_vecs(double a, struct_of_vecs b, struct_of_vecs c, double d);
anatofuz
parents:
diff changeset
207 struct_of_vecs g_vec;
anatofuz
parents:
diff changeset
208
anatofuz
parents:
diff changeset
209 void test_struct_of_vecs(void) {
anatofuz
parents:
diff changeset
210 // CHECK: test_struct_of_vecs
anatofuz
parents:
diff changeset
211 // CHECK: call arm_aapcs_vfpcc void @takes_struct_of_vecs(double {{.*}}, %struct.struct_of_vecs {{.*}}, %struct.struct_of_vecs {{.*}}, double {{.*}})
anatofuz
parents:
diff changeset
212 // CHECK64: test_struct_of_vecs
anatofuz
parents:
diff changeset
213 // CHECK64: call void @takes_struct_of_vecs(double {{.*}}, [4 x <8 x i8>] {{.*}}, [4 x <8 x i8>] {{.*}}, double {{.*}})
anatofuz
parents:
diff changeset
214 takes_struct_of_vecs(3.0, g_vec, g_vec, 4.0);
anatofuz
parents:
diff changeset
215 }
anatofuz
parents:
diff changeset
216
anatofuz
parents:
diff changeset
217 typedef struct {
anatofuz
parents:
diff changeset
218 double a;
anatofuz
parents:
diff changeset
219 long double b;
anatofuz
parents:
diff changeset
220 } struct_of_double_and_long_double;
anatofuz
parents:
diff changeset
221 struct_of_double_and_long_double g_dld;
anatofuz
parents:
diff changeset
222
anatofuz
parents:
diff changeset
223 struct_of_double_and_long_double test_struct_of_double_and_long_double(void) {
anatofuz
parents:
diff changeset
224 return g_dld;
anatofuz
parents:
diff changeset
225 }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
226 // CHECK: define{{.*}} arm_aapcs_vfpcc %struct.struct_of_double_and_long_double @test_struct_of_double_and_long_double()
150
anatofuz
parents:
diff changeset
227
anatofuz
parents:
diff changeset
228 // FIXME: Tests necessary:
anatofuz
parents:
diff changeset
229 // - Vectors
anatofuz
parents:
diff changeset
230 // - C++ stuff