blob: b671626939c9f4a5d2acd17bbdc85a8ea438d43d [file] [log] [blame]
Jim Grosbachf7947052012-07-09 18:34:21 +00001// REQUIRES: arm-registered-target
Amara Emerson2440fb12013-09-16 18:07:35 +00002// 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
3// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-feature +neon -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s
Daniel Dunbar16a08082009-09-14 00:56:55 +00004
Stephen Lin93ab6bf2013-08-15 06:47:53 +00005// APCS-GNU-LABEL: define signext i8 @f0()
6// AAPCS-LABEL: define arm_aapcscc signext i8 @f0()
Daniel Dunbar16a08082009-09-14 00:56:55 +00007char f0(void) {
8 return 0;
9}
10
Stephen Lin93ab6bf2013-08-15 06:47:53 +000011// APCS-GNU-LABEL: define i8 @f1()
12// AAPCS-LABEL: define arm_aapcscc i8 @f1()
Daniel Dunbar16a08082009-09-14 00:56:55 +000013struct s1 { char f0; };
14struct s1 f1(void) {}
15
Stephen Lin93ab6bf2013-08-15 06:47:53 +000016// APCS-GNU-LABEL: define i16 @f2()
17// AAPCS-LABEL: define arm_aapcscc i16 @f2()
Daniel Dunbar16a08082009-09-14 00:56:55 +000018struct s2 { short f0; };
19struct s2 f2(void) {}
20
Stephen Lin93ab6bf2013-08-15 06:47:53 +000021// APCS-GNU-LABEL: define i32 @f3()
22// AAPCS-LABEL: define arm_aapcscc i32 @f3()
Daniel Dunbar16a08082009-09-14 00:56:55 +000023struct s3 { int f0; };
24struct s3 f3(void) {}
25
Stephen Lin93ab6bf2013-08-15 06:47:53 +000026// APCS-GNU-LABEL: define i32 @f4()
27// AAPCS-LABEL: define arm_aapcscc i32 @f4()
Daniel Dunbar16a08082009-09-14 00:56:55 +000028struct s4 { struct s4_0 { int f0; } f0; };
29struct s4 f4(void) {}
30
Stephen Lin93ab6bf2013-08-15 06:47:53 +000031// APCS-GNU-LABEL: define void @f5(
Bill Wendling5e314742013-01-31 23:17:12 +000032// APCS-GNU: struct.s5* noalias sret
Stephen Lin93ab6bf2013-08-15 06:47:53 +000033// AAPCS-LABEL: define arm_aapcscc i32 @f5()
Daniel Dunbar16a08082009-09-14 00:56:55 +000034struct s5 { struct { } f0; int f1; };
35struct s5 f5(void) {}
36
Stephen Lin93ab6bf2013-08-15 06:47:53 +000037// APCS-GNU-LABEL: define void @f6(
Bill Wendling5e314742013-01-31 23:17:12 +000038// APCS-GNU: struct.s6* noalias sret
Stephen Lin93ab6bf2013-08-15 06:47:53 +000039// AAPCS-LABEL: define arm_aapcscc i32 @f6()
Daniel Dunbar16a08082009-09-14 00:56:55 +000040struct s6 { int f0[1]; };
41struct s6 f6(void) {}
42
Stephen Lin93ab6bf2013-08-15 06:47:53 +000043// APCS-GNU-LABEL: define void @f7()
44// AAPCS-LABEL: define arm_aapcscc void @f7()
Daniel Dunbar16a08082009-09-14 00:56:55 +000045struct s7 { struct { int : 0; } f0; };
46struct s7 f7(void) {}
47
Stephen Lin93ab6bf2013-08-15 06:47:53 +000048// APCS-GNU-LABEL: define void @f8(
Bill Wendling5e314742013-01-31 23:17:12 +000049// APCS-GNU: struct.s8* noalias sret
Stephen Lin93ab6bf2013-08-15 06:47:53 +000050// AAPCS-LABEL: define arm_aapcscc void @f8()
Daniel Dunbar16a08082009-09-14 00:56:55 +000051struct s8 { struct { int : 0; } f0[1]; };
52struct s8 f8(void) {}
53
Stephen Lin93ab6bf2013-08-15 06:47:53 +000054// APCS-GNU-LABEL: define i32 @f9()
55// AAPCS-LABEL: define arm_aapcscc i32 @f9()
Daniel Dunbar16a08082009-09-14 00:56:55 +000056struct s9 { int f0; int : 0; };
57struct s9 f9(void) {}
58
Stephen Lin93ab6bf2013-08-15 06:47:53 +000059// APCS-GNU-LABEL: define i32 @f10()
60// AAPCS-LABEL: define arm_aapcscc i32 @f10()
Daniel Dunbar16a08082009-09-14 00:56:55 +000061struct s10 { int f0; int : 0; int : 0; };
62struct s10 f10(void) {}
63
Stephen Lin93ab6bf2013-08-15 06:47:53 +000064// APCS-GNU-LABEL: define void @f11(
Bill Wendling5e314742013-01-31 23:17:12 +000065// APCS-GNU: struct.s11* noalias sret
Stephen Lin93ab6bf2013-08-15 06:47:53 +000066// AAPCS-LABEL: define arm_aapcscc i32 @f11()
Daniel Dunbar16a08082009-09-14 00:56:55 +000067struct s11 { int : 0; int f0; };
68struct s11 f11(void) {}
69
Stephen Lin93ab6bf2013-08-15 06:47:53 +000070// APCS-GNU-LABEL: define i32 @f12()
71// AAPCS-LABEL: define arm_aapcscc i32 @f12()
Daniel Dunbar16a08082009-09-14 00:56:55 +000072union u12 { char f0; short f1; int f2; };
73union u12 f12(void) {}
Daniel Dunbarb0d58192009-09-14 02:20:34 +000074
Stephen Lin93ab6bf2013-08-15 06:47:53 +000075// APCS-GNU-LABEL: define void @f13(
Bill Wendling5e314742013-01-31 23:17:12 +000076// APCS-GNU: struct.s13* noalias sret
Daniel Dunbarb0d58192009-09-14 02:20:34 +000077
78// FIXME: This should return a float.
Rafael Espindola75d0f822010-06-16 17:49:52 +000079// AAPCS-FIXME: darm_aapcscc efine float @f13()
Daniel Dunbarb0d58192009-09-14 02:20:34 +000080struct s13 { float f0; };
81struct s13 f13(void) {}
82
Stephen Lin93ab6bf2013-08-15 06:47:53 +000083// APCS-GNU-LABEL: define void @f14(
Bill Wendling5e314742013-01-31 23:17:12 +000084// APCS-GNU: union.u14* noalias sret
Stephen Lin93ab6bf2013-08-15 06:47:53 +000085// AAPCS-LABEL: define arm_aapcscc i32 @f14()
Daniel Dunbarb0d58192009-09-14 02:20:34 +000086union u14 { float f0; };
87union u14 f14(void) {}
Daniel Dunbar42025572009-09-14 21:54:03 +000088
Stephen Lin93ab6bf2013-08-15 06:47:53 +000089// APCS-GNU-LABEL: define void @f15()
90// AAPCS-LABEL: define arm_aapcscc void @f15()
Daniel Dunbar42025572009-09-14 21:54:03 +000091void f15(struct s7 a0) {}
92
Stephen Lin93ab6bf2013-08-15 06:47:53 +000093// APCS-GNU-LABEL: define void @f16()
94// AAPCS-LABEL: define arm_aapcscc void @f16()
Daniel Dunbar42025572009-09-14 21:54:03 +000095void f16(struct s8 a0) {}
Daniel Dunbar679855a2010-01-29 03:22:29 +000096
Stephen Lin93ab6bf2013-08-15 06:47:53 +000097// APCS-GNU-LABEL: define i32 @f17()
98// AAPCS-LABEL: define arm_aapcscc i32 @f17()
Daniel Dunbar679855a2010-01-29 03:22:29 +000099struct s17 { short f0 : 13; char f1 : 4; };
100struct s17 f17(void) {}
101
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000102// APCS-GNU-LABEL: define i32 @f18()
103// AAPCS-LABEL: define arm_aapcscc i32 @f18()
Daniel Dunbar679855a2010-01-29 03:22:29 +0000104struct s18 { short f0; char f1 : 4; };
105struct s18 f18(void) {}
106
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000107// APCS-GNU-LABEL: define void @f19(
Bill Wendling5e314742013-01-31 23:17:12 +0000108// APCS-GNU: struct.s19* noalias sret
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000109// AAPCS-LABEL: define arm_aapcscc i32 @f19()
Daniel Dunbar679855a2010-01-29 03:22:29 +0000110struct s19 { int f0; struct s8 f1; };
111struct s19 f19(void) {}
112
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000113// APCS-GNU-LABEL: define void @f20(
Bill Wendling5e314742013-01-31 23:17:12 +0000114// APCS-GNU: struct.s20* noalias sret
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000115// AAPCS-LABEL: define arm_aapcscc i32 @f20()
Daniel Dunbar679855a2010-01-29 03:22:29 +0000116struct s20 { struct s8 f1; int f0; };
117struct s20 f20(void) {}
118
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000119// APCS-GNU-LABEL: define i8 @f21()
120// AAPCS-LABEL: define arm_aapcscc i32 @f21()
Daniel Dunbar679855a2010-01-29 03:22:29 +0000121struct s21 { struct {} f1; int f0 : 4; };
122struct s21 f21(void) {}
Daniel Dunbar4cc753f2010-02-01 23:31:19 +0000123
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000124// APCS-GNU-LABEL: define i16 @f22()
125// APCS-GNU-LABEL: define i32 @f23()
126// APCS-GNU-LABEL: define i64 @f24()
127// APCS-GNU-LABEL: define i128 @f25()
128// APCS-GNU-LABEL: define i64 @f26()
129// APCS-GNU-LABEL: define i128 @f27()
130// AAPCS-LABEL: define arm_aapcscc i16 @f22()
131// AAPCS-LABEL: define arm_aapcscc i32 @f23()
Bill Wendling5e314742013-01-31 23:17:12 +0000132// AAPCS: define arm_aapcscc void @f24({{.*}} noalias sret
133// AAPCS: define arm_aapcscc void @f25({{.*}} noalias sret
134// AAPCS: define arm_aapcscc void @f26({{.*}} noalias sret
135// AAPCS: define arm_aapcscc void @f27({{.*}} noalias sret
Daniel Dunbar4cc753f2010-02-01 23:31:19 +0000136_Complex char f22(void) {}
137_Complex short f23(void) {}
138_Complex int f24(void) {}
139_Complex long long f25(void) {}
140_Complex float f26(void) {}
141_Complex double f27(void) {}
Daniel Dunbar45815812010-02-01 23:31:26 +0000142
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000143// APCS-GNU-LABEL: define i16 @f28()
144// AAPCS-LABEL: define arm_aapcscc i16 @f28()
Daniel Dunbar45815812010-02-01 23:31:26 +0000145struct s28 { _Complex char f0; };
146struct s28 f28() {}
147
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000148// APCS-GNU-LABEL: define i32 @f29()
149// AAPCS-LABEL: define arm_aapcscc i32 @f29()
Daniel Dunbar45815812010-02-01 23:31:26 +0000150struct s29 { _Complex short f0; };
151struct s29 f29() {}
152
Bill Wendling5e314742013-01-31 23:17:12 +0000153// APCS-GNU: define void @f30({{.*}} noalias sret
154// AAPCS: define arm_aapcscc void @f30({{.*}} noalias sret
Daniel Dunbar45815812010-02-01 23:31:26 +0000155struct s30 { _Complex int f0; };
156struct s30 f30() {}
Evgeniy Stepanova6ce20e2012-02-10 09:30:15 +0000157
158// PR11905
159struct s31 { char x; };
160void f31(struct s31 s) { }
161// AAPCS: @f31([1 x i32] %s.coerce)
162// AAPCS: %s = alloca %struct.s31, align 4
Evgeniy Stepanov1067d052012-02-10 10:04:01 +0000163// AAPCS: alloca [1 x i32]
164// AAPCS: store [1 x i32] %s.coerce, [1 x i32]*
Evgeniy Stepanova6ce20e2012-02-10 09:30:15 +0000165// APCS-GNU: @f31([1 x i32] %s.coerce)
166// APCS-GNU: %s = alloca %struct.s31, align 4
Evgeniy Stepanov1067d052012-02-10 10:04:01 +0000167// APCS-GNU: alloca [1 x i32]
168// APCS-GNU: store [1 x i32] %s.coerce, [1 x i32]*
Eli Friedman79f30982012-08-09 00:31:40 +0000169
170// PR13562
171struct s32 { double x; };
172void f32(struct s32 s) { }
173// AAPCS: @f32([1 x i64] %s.coerce)
174// APCS-GNU: @f32([2 x i32] %s.coerce)
Manman Ren16ba7c82012-08-10 20:42:31 +0000175
176// PR13350
177struct s33 { char buf[32*32]; };
178void f33(struct s33 s) { }
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700179// APCS-GNU-LABEL: define void @f33(%struct.s33* byval align 4 %s)
180// AAPCS-LABEL: define arm_aapcscc void @f33(%struct.s33* byval align 4 %s)
Chandler Carruthf82232c2012-10-10 11:29:08 +0000181
182// PR14048
183struct s34 { char c; };
184void f34(struct s34 s);
185void g34(struct s34 *s) { f34(*s); }
Chandler Carruthf82232c2012-10-10 11:29:08 +0000186// AAPCS: @g34(%struct.s34* %s)
Stephen Hines176edba2014-12-01 14:53:08 -0800187// AAPCS: %[[a:.*]] = alloca [1 x i32]
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700188// AAPCS: load [1 x i32], [1 x i32]* %[[a]]
Manman Ren885ad692012-11-06 04:58:01 +0000189
190// rdar://12596507
191struct s35
192{
193 float v[18]; //make sure byval is on.
194} __attribute__((aligned(16)));
195typedef struct s35 s35_with_align;
196
197typedef __attribute__((neon_vector_type(4))) float float32x4_t;
198static __attribute__((__always_inline__, __nodebug__)) float32x4_t vaddq_f32(
199 float32x4_t __a, float32x4_t __b) {
200 return __a + __b;
201}
202float32x4_t f35(int i, s35_with_align s1, s35_with_align s2) {
203 float32x4_t v = vaddq_f32(*(float32x4_t *)&s1,
204 *(float32x4_t *)&s2);
205 return v;
206}
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700207// APCS-GNU-LABEL: define <4 x float> @f35(i32 %i, %struct.s35* byval align 4, %struct.s35* byval align 4)
Manman Ren885ad692012-11-06 04:58:01 +0000208// APCS-GNU: %[[a:.*]] = alloca %struct.s35, align 16
209// APCS-GNU: %[[b:.*]] = bitcast %struct.s35* %[[a]] to i8*
210// APCS-GNU: %[[c:.*]] = bitcast %struct.s35* %0 to i8*
211// APCS-GNU: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[b]], i8* %[[c]]
212// APCS-GNU: %[[d:.*]] = bitcast %struct.s35* %[[a]] to <4 x float>*
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700213// APCS-GNU: load <4 x float>, <4 x float>* %[[d]], align 16
214// AAPCS-LABEL: define arm_aapcscc <4 x float> @f35(i32 %i, %struct.s35* byval align 8, %struct.s35* byval align 8)
Manman Ren885ad692012-11-06 04:58:01 +0000215// AAPCS: %[[a:.*]] = alloca %struct.s35, align 16
216// AAPCS: %[[b:.*]] = bitcast %struct.s35* %[[a]] to i8*
217// AAPCS: %[[c:.*]] = bitcast %struct.s35* %0 to i8*
218// AAPCS: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[b]], i8* %[[c]]
219// AAPCS: %[[d:.*]] = bitcast %struct.s35* %[[a]] to <4 x float>*
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700220// AAPCS: load <4 x float>, <4 x float>* %[[d]], align 16