blob: fdd87e05495fd5b90846fb8a1bc134725c749ae8 [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
Tim Northoveradfa45f2012-07-20 22:29:29 +000037// Long double is the same as double on AAPCS, it should be homogeneous.
38extern void complex_long_callee(__complex__ long double);
39// CHECK: define arm_aapcs_vfpcc void @test_complex_long(double %{{.*}}, double %{{.*}})
40void test_complex_long(__complex__ long double cd) {
41 complex_callee(cd);
42}
43
Bob Wilson194f06a2011-08-03 05:58:22 +000044// Structs with more than 4 elements of the base type are not treated
45// as homogeneous aggregates. Test that.
46
47struct 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] %{{.*}})
54extern void big_callee(struct big_struct);
55void 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
62struct heterogeneous_struct {
63 float f1;
64 int i2;
65};
66// CHECK: define arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})
67extern void hetero_callee(struct heterogeneous_struct);
68void 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> %{{.*}})
74int8x16_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
81struct 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> %{{.*}})
87extern void neon_callee(struct neon_struct);
88void test_neon(struct neon_struct arg) {
89 neon_callee(arg);
90}