Jim Grosbach | f794705 | 2012-07-09 18:34:21 +0000 | [diff] [blame] | 1 | // REQUIRES: arm-registered-target |
Bob Wilson | 194f06a | 2011-08-03 05:58:22 +0000 | [diff] [blame] | 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 | }; |
Bob Wilson | 3b694fa | 2011-11-02 04:51:36 +0000 | [diff] [blame] | 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); |
| 18 | struct homogeneous_struct test_struct(struct homogeneous_struct arg) { |
| 19 | return struct_callee(arg); |
Bob Wilson | 194f06a | 2011-08-03 05:58:22 +0000 | [diff] [blame] | 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); |
| 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 %{{.*}}) |
| 33 | void 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 | |
| 40 | struct 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] %{{.*}}) |
| 47 | extern void big_callee(struct big_struct); |
| 48 | void 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 | |
| 55 | struct heterogeneous_struct { |
| 56 | float f1; |
| 57 | int i2; |
| 58 | }; |
| 59 | // CHECK: define arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}}) |
| 60 | extern void hetero_callee(struct heterogeneous_struct); |
| 61 | void 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> %{{.*}}) |
| 67 | int8x16_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 | |
| 74 | struct 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> %{{.*}}) |
| 80 | extern void neon_callee(struct neon_struct); |
| 81 | void test_neon(struct neon_struct arg) { |
| 82 | neon_callee(arg); |
| 83 | } |