1 // REQUIRES: arm-registered-target
2 // RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \
3 // RUN: -target-abi aapcs \
4 // RUN: -target-cpu cortex-a8 \
5 // RUN: -mfloat-abi hard \
6 // RUN: -ffreestanding \
7 // RUN: -emit-llvm -w -o - %s | FileCheck %s
8
9 #include <arm_neon.h>
10
11 struct homogeneous_struct {
12 float f[2];
13 float f3;
14 float f4;
15 };
16 // CHECK: define arm_aapcs_vfpcc %struct.homogeneous_struct @test_struct(float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
17 extern struct homogeneous_struct struct_callee(struct homogeneous_struct);
test_struct(struct homogeneous_struct arg)18 struct homogeneous_struct test_struct(struct homogeneous_struct arg) {
19 return struct_callee(arg);
20 }
21
22 struct nested_array {
23 double d[4];
24 };
25 // CHECK: define arm_aapcs_vfpcc void @test_array(double %{{.*}}, double %{{.*}}, double %{{.*}}, double %{{.*}})
26 extern void array_callee(struct nested_array);
test_array(struct nested_array arg)27 void test_array(struct nested_array arg) {
28 array_callee(arg);
29 }
30
31 extern void complex_callee(__complex__ double);
32 // CHECK: define arm_aapcs_vfpcc void @test_complex(double %{{.*}}, double %{{.*}})
test_complex(__complex__ double cd)33 void test_complex(__complex__ double cd) {
34 complex_callee(cd);
35 }
36
37 // Long double is the same as double on AAPCS, it should be homogeneous.
38 extern void complex_long_callee(__complex__ long double);
39 // CHECK: define arm_aapcs_vfpcc void @test_complex_long(double %{{.*}}, double %{{.*}})
test_complex_long(__complex__ long double cd)40 void test_complex_long(__complex__ long double cd) {
41 complex_callee(cd);
42 }
43
44 // Structs with more than 4 elements of the base type are not treated
45 // as homogeneous aggregates. Test that.
46
47 struct big_struct {
48 float f1;
49 float f[2];
50 float f3;
51 float f4;
52 };
53 // CHECK: define arm_aapcs_vfpcc void @test_big([5 x i32] %{{.*}})
54 extern void big_callee(struct big_struct);
test_big(struct big_struct arg)55 void test_big(struct big_struct arg) {
56 big_callee(arg);
57 }
58
59 // Make sure that aggregates with multiple base types are not treated as
60 // homogeneous aggregates.
61
62 struct heterogeneous_struct {
63 float f1;
64 int i2;
65 };
66 // CHECK: define arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})
67 extern void hetero_callee(struct heterogeneous_struct);
test_hetero(struct heterogeneous_struct arg)68 void test_hetero(struct heterogeneous_struct arg) {
69 hetero_callee(arg);
70 }
71
72 // Neon multi-vector types are homogeneous aggregates.
73 // CHECK: define arm_aapcs_vfpcc <16 x i8> @f0(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}})
f0(int8x16x4_t v4)74 int8x16_t f0(int8x16x4_t v4) {
75 return vaddq_s8(v4.val[0], v4.val[3]);
76 }
77
78 // ...and it doesn't matter whether the vectors are exactly the same, as long
79 // as they have the same size.
80
81 struct neon_struct {
82 int8x8x2_t v12;
83 int32x2_t v3;
84 int16x4_t v4;
85 };
86 // CHECK: define arm_aapcs_vfpcc void @test_neon(<8 x i8> %{{.*}}, <8 x i8> %{{.*}}, <2 x i32> %{{.*}}, <4 x i16> %{{.*}})
87 extern void neon_callee(struct neon_struct);
test_neon(struct neon_struct arg)88 void test_neon(struct neon_struct arg) {
89 neon_callee(arg);
90 }
91
92 // CHECK: define arm_aapcs_vfpcc void @f33(%struct.s33* byval %s)
93 struct s33 { char buf[32*32]; };
f33(struct s33 s)94 void f33(struct s33 s) { }
95