xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/arm-arguments.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // REQUIRES: arm-registered-target
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-feature +neon -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=APCS-GNU %s
3f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-feature +neon -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s
4f4a2713aSLionel Sambuc 
5f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define signext i8 @f0()
6f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc signext i8 @f0()
f0(void)7f4a2713aSLionel Sambuc char f0(void) {
8f4a2713aSLionel Sambuc   return 0;
9f4a2713aSLionel Sambuc }
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i8 @f1()
12f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i8 @f1()
13f4a2713aSLionel Sambuc struct s1 { char f0; };
f1(void)14f4a2713aSLionel Sambuc struct s1 f1(void) {}
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i16 @f2()
17f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i16 @f2()
18f4a2713aSLionel Sambuc struct s2 { short f0; };
f2(void)19f4a2713aSLionel Sambuc struct s2 f2(void) {}
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f3()
22f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f3()
23f4a2713aSLionel Sambuc struct s3 { int f0; };
f3(void)24f4a2713aSLionel Sambuc struct s3 f3(void) {}
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f4()
27f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f4()
28f4a2713aSLionel Sambuc struct s4 { struct s4_0 { int f0; } f0; };
f4(void)29f4a2713aSLionel Sambuc struct s4 f4(void) {}
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f5(
32f4a2713aSLionel Sambuc // APCS-GNU: struct.s5* noalias sret
33f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f5()
34f4a2713aSLionel Sambuc struct s5 { struct { } f0; int f1; };
f5(void)35f4a2713aSLionel Sambuc struct s5 f5(void) {}
36f4a2713aSLionel Sambuc 
37f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f6(
38f4a2713aSLionel Sambuc // APCS-GNU: struct.s6* noalias sret
39f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f6()
40f4a2713aSLionel Sambuc struct s6 { int f0[1]; };
f6(void)41f4a2713aSLionel Sambuc struct s6 f6(void) {}
42f4a2713aSLionel Sambuc 
43f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f7()
44f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc void @f7()
45f4a2713aSLionel Sambuc struct s7 { struct { int : 0; } f0; };
f7(void)46f4a2713aSLionel Sambuc struct s7 f7(void) {}
47f4a2713aSLionel Sambuc 
48f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f8(
49f4a2713aSLionel Sambuc // APCS-GNU: struct.s8* noalias sret
50f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc void @f8()
51f4a2713aSLionel Sambuc struct s8 { struct { int : 0; } f0[1]; };
f8(void)52f4a2713aSLionel Sambuc struct s8 f8(void) {}
53f4a2713aSLionel Sambuc 
54f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f9()
55f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f9()
56f4a2713aSLionel Sambuc struct s9 { int f0; int : 0; };
f9(void)57f4a2713aSLionel Sambuc struct s9 f9(void) {}
58f4a2713aSLionel Sambuc 
59f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f10()
60f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f10()
61f4a2713aSLionel Sambuc struct s10 { int f0; int : 0; int : 0; };
f10(void)62f4a2713aSLionel Sambuc struct s10 f10(void) {}
63f4a2713aSLionel Sambuc 
64f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f11(
65f4a2713aSLionel Sambuc // APCS-GNU: struct.s11* noalias sret
66f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f11()
67f4a2713aSLionel Sambuc struct s11 { int : 0; int f0; };
f11(void)68f4a2713aSLionel Sambuc struct s11 f11(void) {}
69f4a2713aSLionel Sambuc 
70f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f12()
71f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f12()
72f4a2713aSLionel Sambuc union u12 { char f0; short f1; int f2; };
f12(void)73f4a2713aSLionel Sambuc union u12 f12(void) {}
74f4a2713aSLionel Sambuc 
75f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f13(
76f4a2713aSLionel Sambuc // APCS-GNU: struct.s13* noalias sret
77f4a2713aSLionel Sambuc 
78f4a2713aSLionel Sambuc // FIXME: This should return a float.
79f4a2713aSLionel Sambuc // AAPCS-FIXME: darm_aapcscc efine float @f13()
80f4a2713aSLionel Sambuc struct s13 { float f0; };
f13(void)81f4a2713aSLionel Sambuc struct s13 f13(void) {}
82f4a2713aSLionel Sambuc 
83f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f14(
84f4a2713aSLionel Sambuc // APCS-GNU: union.u14* noalias sret
85f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f14()
86f4a2713aSLionel Sambuc union u14 { float f0; };
f14(void)87f4a2713aSLionel Sambuc union u14 f14(void) {}
88f4a2713aSLionel Sambuc 
89f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f15()
90f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc void @f15()
f15(struct s7 a0)91f4a2713aSLionel Sambuc void f15(struct s7 a0) {}
92f4a2713aSLionel Sambuc 
93f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f16()
94f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc void @f16()
f16(struct s8 a0)95f4a2713aSLionel Sambuc void f16(struct s8 a0) {}
96f4a2713aSLionel Sambuc 
97f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f17()
98f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f17()
99f4a2713aSLionel Sambuc struct s17 { short f0 : 13; char f1 : 4; };
f17(void)100f4a2713aSLionel Sambuc struct s17 f17(void) {}
101f4a2713aSLionel Sambuc 
102f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f18()
103f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f18()
104f4a2713aSLionel Sambuc struct s18 { short f0; char f1 : 4; };
f18(void)105f4a2713aSLionel Sambuc struct s18 f18(void) {}
106f4a2713aSLionel Sambuc 
107f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f19(
108f4a2713aSLionel Sambuc // APCS-GNU: struct.s19* noalias sret
109f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f19()
110f4a2713aSLionel Sambuc struct s19 { int f0; struct s8 f1; };
f19(void)111f4a2713aSLionel Sambuc struct s19 f19(void) {}
112f4a2713aSLionel Sambuc 
113f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define void @f20(
114f4a2713aSLionel Sambuc // APCS-GNU: struct.s20* noalias sret
115f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f20()
116f4a2713aSLionel Sambuc struct s20 { struct s8 f1; int f0; };
f20(void)117f4a2713aSLionel Sambuc struct s20 f20(void) {}
118f4a2713aSLionel Sambuc 
119f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i8 @f21()
120f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f21()
121f4a2713aSLionel Sambuc struct s21 { struct {} f1; int f0 : 4; };
f21(void)122f4a2713aSLionel Sambuc struct s21 f21(void) {}
123f4a2713aSLionel Sambuc 
124f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i16 @f22()
125f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f23()
126f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i64 @f24()
127f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i128 @f25()
128f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i64 @f26()
129f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i128 @f27()
130f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i16 @f22()
131f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f23()
132f4a2713aSLionel Sambuc // AAPCS: define arm_aapcscc void @f24({{.*}} noalias sret
133f4a2713aSLionel Sambuc // AAPCS: define arm_aapcscc void @f25({{.*}} noalias sret
134f4a2713aSLionel Sambuc // AAPCS: define arm_aapcscc void @f26({{.*}} noalias sret
135f4a2713aSLionel Sambuc // AAPCS: define arm_aapcscc void @f27({{.*}} noalias sret
f22(void)136f4a2713aSLionel Sambuc _Complex char       f22(void) {}
f23(void)137f4a2713aSLionel Sambuc _Complex short      f23(void) {}
f24(void)138f4a2713aSLionel Sambuc _Complex int        f24(void) {}
f25(void)139f4a2713aSLionel Sambuc _Complex long long  f25(void) {}
f26(void)140f4a2713aSLionel Sambuc _Complex float      f26(void) {}
f27(void)141f4a2713aSLionel Sambuc _Complex double     f27(void) {}
142f4a2713aSLionel Sambuc 
143f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i16 @f28()
144f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i16 @f28()
145f4a2713aSLionel Sambuc struct s28 { _Complex char f0; };
f28()146f4a2713aSLionel Sambuc struct s28 f28() {}
147f4a2713aSLionel Sambuc 
148f4a2713aSLionel Sambuc // APCS-GNU-LABEL: define i32 @f29()
149f4a2713aSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc i32 @f29()
150f4a2713aSLionel Sambuc struct s29 { _Complex short f0; };
f29()151f4a2713aSLionel Sambuc struct s29 f29() {}
152f4a2713aSLionel Sambuc 
153f4a2713aSLionel Sambuc // APCS-GNU: define void @f30({{.*}} noalias sret
154f4a2713aSLionel Sambuc // AAPCS: define arm_aapcscc void @f30({{.*}} noalias sret
155f4a2713aSLionel Sambuc struct s30 { _Complex int f0; };
f30()156f4a2713aSLionel Sambuc struct s30 f30() {}
157f4a2713aSLionel Sambuc 
158f4a2713aSLionel Sambuc // PR11905
159f4a2713aSLionel Sambuc struct s31 { char x; };
f31(struct s31 s)160f4a2713aSLionel Sambuc void f31(struct s31 s) { }
161f4a2713aSLionel Sambuc // AAPCS: @f31([1 x i32] %s.coerce)
162f4a2713aSLionel Sambuc // AAPCS: %s = alloca %struct.s31, align 4
163f4a2713aSLionel Sambuc // AAPCS: alloca [1 x i32]
164f4a2713aSLionel Sambuc // AAPCS: store [1 x i32] %s.coerce, [1 x i32]*
165f4a2713aSLionel Sambuc // APCS-GNU: @f31([1 x i32] %s.coerce)
166f4a2713aSLionel Sambuc // APCS-GNU: %s = alloca %struct.s31, align 4
167f4a2713aSLionel Sambuc // APCS-GNU: alloca [1 x i32]
168f4a2713aSLionel Sambuc // APCS-GNU: store [1 x i32] %s.coerce, [1 x i32]*
169f4a2713aSLionel Sambuc 
170f4a2713aSLionel Sambuc // PR13562
171f4a2713aSLionel Sambuc struct s32 { double x; };
f32(struct s32 s)172f4a2713aSLionel Sambuc void f32(struct s32 s) { }
173f4a2713aSLionel Sambuc // AAPCS: @f32([1 x i64] %s.coerce)
174f4a2713aSLionel Sambuc // APCS-GNU: @f32([2 x i32] %s.coerce)
175f4a2713aSLionel Sambuc 
176f4a2713aSLionel Sambuc // PR13350
177f4a2713aSLionel Sambuc struct s33 { char buf[32*32]; };
f33(struct s33 s)178f4a2713aSLionel Sambuc void f33(struct s33 s) { }
179*0a6a1f1dSLionel Sambuc // APCS-GNU-LABEL: define void @f33(%struct.s33* byval align 1 %s)
180*0a6a1f1dSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc void @f33(%struct.s33* byval align 1 %s)
181f4a2713aSLionel Sambuc 
182f4a2713aSLionel Sambuc // PR14048
183f4a2713aSLionel Sambuc struct s34 { char c; };
184f4a2713aSLionel Sambuc void f34(struct s34 s);
g34(struct s34 * s)185f4a2713aSLionel Sambuc void g34(struct s34 *s) { f34(*s); }
186f4a2713aSLionel Sambuc // AAPCS: @g34(%struct.s34* %s)
187*0a6a1f1dSLionel Sambuc // AAPCS: %[[a:.*]] = alloca [1 x i32]
188*0a6a1f1dSLionel Sambuc // AAPCS: load [1 x i32]* %[[a]]
189f4a2713aSLionel Sambuc 
190f4a2713aSLionel Sambuc // rdar://12596507
191f4a2713aSLionel Sambuc struct s35
192f4a2713aSLionel Sambuc {
193f4a2713aSLionel Sambuc    float v[18]; //make sure byval is on.
194f4a2713aSLionel Sambuc } __attribute__((aligned(16)));
195f4a2713aSLionel Sambuc typedef struct s35 s35_with_align;
196f4a2713aSLionel Sambuc 
197f4a2713aSLionel Sambuc typedef __attribute__((neon_vector_type(4))) float float32x4_t;
vaddq_f32(float32x4_t __a,float32x4_t __b)198f4a2713aSLionel Sambuc static __attribute__((__always_inline__, __nodebug__)) float32x4_t vaddq_f32(
199f4a2713aSLionel Sambuc        float32x4_t __a, float32x4_t __b) {
200f4a2713aSLionel Sambuc  return __a + __b;
201f4a2713aSLionel Sambuc }
f35(int i,s35_with_align s1,s35_with_align s2)202f4a2713aSLionel Sambuc float32x4_t f35(int i, s35_with_align s1, s35_with_align s2) {
203f4a2713aSLionel Sambuc   float32x4_t v = vaddq_f32(*(float32x4_t *)&s1,
204f4a2713aSLionel Sambuc                             *(float32x4_t *)&s2);
205f4a2713aSLionel Sambuc   return v;
206f4a2713aSLionel Sambuc }
207*0a6a1f1dSLionel Sambuc // APCS-GNU-LABEL: define <4 x float> @f35(i32 %i, %struct.s35* byval align 16, %struct.s35* byval align 16)
208f4a2713aSLionel Sambuc // APCS-GNU: %[[a:.*]] = alloca %struct.s35, align 16
209f4a2713aSLionel Sambuc // APCS-GNU: %[[b:.*]] = bitcast %struct.s35* %[[a]] to i8*
210f4a2713aSLionel Sambuc // APCS-GNU: %[[c:.*]] = bitcast %struct.s35* %0 to i8*
211f4a2713aSLionel Sambuc // APCS-GNU: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[b]], i8* %[[c]]
212f4a2713aSLionel Sambuc // APCS-GNU: %[[d:.*]] = bitcast %struct.s35* %[[a]] to <4 x float>*
213f4a2713aSLionel Sambuc // APCS-GNU: load <4 x float>* %[[d]], align 16
214*0a6a1f1dSLionel Sambuc // AAPCS-LABEL: define arm_aapcscc <4 x float> @f35(i32 %i, %struct.s35* byval align 16, %struct.s35* byval align 16)
215f4a2713aSLionel Sambuc // AAPCS: %[[a:.*]] = alloca %struct.s35, align 16
216f4a2713aSLionel Sambuc // AAPCS: %[[b:.*]] = bitcast %struct.s35* %[[a]] to i8*
217f4a2713aSLionel Sambuc // AAPCS: %[[c:.*]] = bitcast %struct.s35* %0 to i8*
218f4a2713aSLionel Sambuc // AAPCS: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[b]], i8* %[[c]]
219f4a2713aSLionel Sambuc // AAPCS: %[[d:.*]] = bitcast %struct.s35* %[[a]] to <4 x float>*
220f4a2713aSLionel Sambuc // AAPCS: load <4 x float>* %[[d]], align 16
221