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