1 // 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
8 // RUN: %clang_cc1 -triple armv7-unknown-nacl-gnueabi \
9 // RUN: -target-cpu cortex-a8 \
10 // RUN: -mfloat-abi hard \
11 // RUN: -ffreestanding \
12 // RUN: -emit-llvm -w -o - %s | FileCheck %s
14 // RUN: %clang_cc1 -triple arm64-apple-darwin9 -target-feature +neon \
15 // RUN: -ffreestanding \
16 // RUN: -emit-llvm -w -o - %s | FileCheck -check-prefix=CHECK64 %s
18 // REQUIRES: arm-registered-target
19 // REQUIRES: aarch64-registered-target
23 struct homogeneous_struct
{
28 // CHECK: define{{.*}} arm_aapcs_vfpcc %struct.homogeneous_struct @test_struct(%struct.homogeneous_struct %{{.*}})
29 // CHECK64: define{{.*}} %struct.homogeneous_struct @test_struct([4 x float] alignstack(8) %{{.*}})
30 extern struct homogeneous_struct
struct_callee(struct homogeneous_struct
);
31 struct homogeneous_struct
test_struct(struct homogeneous_struct arg
) {
32 return struct_callee(arg
);
35 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_struct_variadic(ptr {{.*}}, ...)
36 struct homogeneous_struct
test_struct_variadic(struct homogeneous_struct arg
, ...) {
37 return struct_callee(arg
);
43 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_array(%struct.nested_array %{{.*}})
44 // CHECK64: define{{.*}} void @test_array([4 x double] alignstack(8) %{{.*}})
45 extern void array_callee(struct nested_array
);
46 void test_array(struct nested_array arg
) {
50 extern void complex_callee(__complex__
double);
51 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_complex({ double, double } noundef %{{.*}})
52 // CHECK64: define{{.*}} void @test_complex([2 x double] noundef alignstack(8) %cd.coerce)
53 void test_complex(__complex__
double cd
) {
57 // Long double is the same as double on AAPCS, it should be homogeneous.
58 extern void complex_long_callee(__complex__
long double);
59 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_complex_long({ double, double } noundef %{{.*}})
60 void test_complex_long(__complex__
long double cd
) {
64 // Structs with more than 4 elements of the base type are not treated
65 // as homogeneous aggregates. Test that.
73 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_big([5 x i32] %{{.*}})
74 // CHECK64: define{{.*}} void @test_big(ptr noundef %{{.*}})
75 // CHECK64: call void @llvm.memcpy
76 // CHECK64: call void @big_callee(ptr
77 extern void big_callee(struct big_struct
);
78 void test_big(struct big_struct arg
) {
82 // Make sure that aggregates with multiple base types are not treated as
83 // homogeneous aggregates.
85 struct heterogeneous_struct
{
89 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})
90 // CHECK64: define{{.*}} void @test_hetero(i64 %{{.*}})
91 extern void hetero_callee(struct heterogeneous_struct
);
92 void test_hetero(struct heterogeneous_struct arg
) {
96 // Neon multi-vector types are homogeneous aggregates.
97 // CHECK: define{{.*}} arm_aapcs_vfpcc <16 x i8> @f0(%struct.int8x16x4_t %{{.*}})
98 // CHECK64: define{{.*}} <16 x i8> @f0([4 x <16 x i8>] alignstack(16) %{{.*}})
99 int8x16_t
f0(int8x16x4_t v4
) {
100 return vaddq_s8(v4
.val
[0], v4
.val
[3]);
103 // ...and it doesn't matter whether the vectors are exactly the same, as long
104 // as they have the same size.
111 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_neon(%struct.neon_struct %{{.*}})
112 // CHECK64: define{{.*}} void @test_neon([4 x <8 x i8>] alignstack(8) %{{.*}})
113 extern void neon_callee(struct neon_struct
);
114 void test_neon(struct neon_struct arg
) {
118 // CHECK-LABEL: define{{.*}} arm_aapcs_vfpcc void @f33(ptr noundef byval(%struct.s33) align 4 %s)
119 struct s33
{ char buf
[32*32]; };
120 void f33(struct s33 s
) { }
122 typedef struct { long long x
; int y
; } struct_long_long_int
;
123 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_1(double noundef %a, double noundef %b, double noundef %c, double noundef %d, double noundef %e, double noundef %f, double noundef %g, double noundef %h, double noundef %i, i32 noundef %j, i64 noundef %k, i32 noundef %l)
124 void test_vfp_stack_gpr_split_1(double a
, double b
, double c
, double d
, double e
, double f
, double g
, double h
, double i
, int j
, long long k
, int l
) {}
126 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_2(double noundef %a, double noundef %b, double noundef %c, double noundef %d, double noundef %e, double noundef %f, double noundef %g, double noundef %h, double noundef %i, i32 noundef %j, [2 x i64] %k.coerce)
127 void test_vfp_stack_gpr_split_2(double a
, double b
, double c
, double d
, double e
, double f
, double g
, double h
, double i
, int j
, struct_long_long_int k
) {}
129 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_3(ptr dead_on_unwind noalias writable sret(%struct.struct_long_long_int) align 8 %agg.result, double noundef %a, double noundef %b, double noundef %c, double noundef %d, double noundef %e, double noundef %f, double noundef %g, double noundef %h, double noundef %i, [2 x i64] %k.coerce)
130 struct_long_long_int
test_vfp_stack_gpr_split_3(double a
, double b
, double c
, double d
, double e
, double f
, double g
, double h
, double i
, struct_long_long_int k
) {}
132 typedef struct { int a
; int b
:4; int c
; } struct_int_bitfield_int
;
133 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_test_vfp_stack_gpr_split_bitfield(double noundef %a, double noundef %b, double noundef %c, double noundef %d, double noundef %e, double noundef %f, double noundef %g, double noundef %h, double noundef %i, i32 noundef %j, i32 noundef %k, [3 x i32] %l.coerce)
134 void test_test_vfp_stack_gpr_split_bitfield(double a
, double b
, double c
, double d
, double e
, double f
, double g
, double h
, double i
, int j
, int k
, struct_int_bitfield_int l
) {}
136 // Note: this struct requires internal padding
137 typedef struct { int x
; long long y
; } struct_int_long_long
;
138 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_4(double noundef %a, double noundef %b, double noundef %c, double noundef %d, double noundef %e, double noundef %f, double noundef %g, double noundef %h, double noundef %i, i32 noundef %j, [2 x i64] %k.coerce)
139 void test_vfp_stack_gpr_split_4(double a
, double b
, double c
, double d
, double e
, double f
, double g
, double h
, double i
, int j
, struct_int_long_long k
) {}
141 // This very large struct (passed byval) uses up the GPRs, so no padding is needed
142 typedef struct { int x
[17]; } struct_seventeen_ints
;
143 typedef struct { int x
[4]; } struct_four_ints
;
144 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_5(ptr noundef byval(%struct.struct_seventeen_ints) align 4 %a, double noundef %b, double noundef %c, double noundef %d, double noundef %e, double noundef %f, double noundef %g, double noundef %h, double noundef %i, double noundef %j, [4 x i32] %k.coerce)
145 void test_vfp_stack_gpr_split_5(struct_seventeen_ints a
, double b
, double c
, double d
, double e
, double f
, double g
, double h
, double i
, double j
, struct_four_ints k
) {}
147 // Here, parameter k would need padding to prevent it from being split, but it
148 // is passed ByVal (due to being > 64 bytes), so the backend handles this instead.
149 void test_vfp_stack_gpr_split_6(double a
, double b
, double c
, double d
, double e
, double f
, double g
, double h
, double i
, int j
, struct_seventeen_ints k
) {}
150 // CHECK: define{{.*}} arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_6(double noundef %a, double noundef %b, double noundef %c, double noundef %d, double noundef %e, double noundef %f, double noundef %g, double noundef %h, double noundef %i, i32 noundef %j, ptr noundef byval(%struct.struct_seventeen_ints) align 4 %k)