blob: 45204ed2b9e3a7bd7bc11e7ebbf84d4ed34d7d61 [file] [log] [blame]
Jim Grosbachf7947052012-07-09 18:34:21 +00001// REQUIRES: arm-registered-target
Bob Wilson194f06a2011-08-03 05:58:22 +00002// 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
11struct homogeneous_struct {
12 float f[2];
13 float f3;
14 float f4;
15};
Bob Wilson3b694fa2011-11-02 04:51:36 +000016// CHECK: define arm_aapcs_vfpcc %struct.homogeneous_struct @test_struct(float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
17extern struct homogeneous_struct struct_callee(struct homogeneous_struct);
18struct homogeneous_struct test_struct(struct homogeneous_struct arg) {
19 return struct_callee(arg);
Bob Wilson194f06a2011-08-03 05:58:22 +000020}
21
22struct nested_array {
23 double d[4];
24};
25// CHECK: define arm_aapcs_vfpcc void @test_array(double %{{.*}}, double %{{.*}}, double %{{.*}}, double %{{.*}})
26extern void array_callee(struct nested_array);
27void test_array(struct nested_array arg) {
28 array_callee(arg);
29}
30
31extern void complex_callee(__complex__ double);
32// CHECK: define arm_aapcs_vfpcc void @test_complex(double %{{.*}}, double %{{.*}})
33void test_complex(__complex__ double cd) {
34 complex_callee(cd);
35}
36
37// Structs with more than 4 elements of the base type are not treated
38// as homogeneous aggregates. Test that.
39
40struct big_struct {
41 float f1;
42 float f[2];
43 float f3;
44 float f4;
45};
46// CHECK: define arm_aapcs_vfpcc void @test_big([5 x i32] %{{.*}})
47extern void big_callee(struct big_struct);
48void test_big(struct big_struct arg) {
49 big_callee(arg);
50}
51
52// Make sure that aggregates with multiple base types are not treated as
53// homogeneous aggregates.
54
55struct heterogeneous_struct {
56 float f1;
57 int i2;
58};
59// CHECK: define arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})
60extern void hetero_callee(struct heterogeneous_struct);
61void test_hetero(struct heterogeneous_struct arg) {
62 hetero_callee(arg);
63}
64
65// Neon multi-vector types are homogeneous aggregates.
66// CHECK: define arm_aapcs_vfpcc <16 x i8> @f0(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}})
67int8x16_t f0(int8x16x4_t v4) {
68 return vaddq_s8(v4.val[0], v4.val[3]);
69}
70
71// ...and it doesn't matter whether the vectors are exactly the same, as long
72// as they have the same size.
73
74struct neon_struct {
75 int8x8x2_t v12;
76 int32x2_t v3;
77 int16x4_t v4;
78};
79// CHECK: define arm_aapcs_vfpcc void @test_neon(<8 x i8> %{{.*}}, <8 x i8> %{{.*}}, <2 x i32> %{{.*}}, <4 x i16> %{{.*}})
80extern void neon_callee(struct neon_struct);
81void test_neon(struct neon_struct arg) {
82 neon_callee(arg);
83}