2012-07-10 02:34:21 +08:00
|
|
|
// REQUIRES: arm-registered-target
|
2014-11-19 06:36:11 +08:00
|
|
|
// REQUIRES: aarch64-registered-target
|
2011-08-03 13:58:22 +08:00
|
|
|
// RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \
|
|
|
|
// RUN: -target-abi aapcs \
|
|
|
|
// RUN: -target-cpu cortex-a8 \
|
|
|
|
// RUN: -mfloat-abi hard \
|
|
|
|
// RUN: -ffreestanding \
|
|
|
|
// RUN: -emit-llvm -w -o - %s | FileCheck %s
|
|
|
|
|
2012-10-12 00:55:58 +08:00
|
|
|
// RUN: %clang_cc1 -triple armv7-unknown-nacl-gnueabi \
|
|
|
|
// RUN: -target-cpu cortex-a8 \
|
|
|
|
// RUN: -mfloat-abi hard \
|
|
|
|
// RUN: -ffreestanding \
|
|
|
|
// RUN: -emit-llvm -w -o - %s | FileCheck %s
|
|
|
|
|
2014-04-16 23:33:48 +08:00
|
|
|
// RUN: %clang_cc1 -triple arm64-apple-darwin9 -target-feature +neon \
|
2014-03-29 23:09:45 +08:00
|
|
|
// RUN: -ffreestanding \
|
|
|
|
// RUN: -emit-llvm -w -o - %s | FileCheck -check-prefix=CHECK64 %s
|
|
|
|
|
|
|
|
#include <arm_neon.h>
|
2011-08-03 13:58:22 +08:00
|
|
|
|
|
|
|
struct homogeneous_struct {
|
|
|
|
float f[2];
|
|
|
|
float f3;
|
|
|
|
float f4;
|
|
|
|
};
|
2014-05-10 00:21:39 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc %struct.homogeneous_struct @test_struct(%struct.homogeneous_struct %{{.*}})
|
2014-11-28 05:02:49 +08:00
|
|
|
// CHECK64: define %struct.homogeneous_struct @test_struct([4 x float] %{{.*}})
|
2011-11-02 12:51:36 +08:00
|
|
|
extern struct homogeneous_struct struct_callee(struct homogeneous_struct);
|
|
|
|
struct homogeneous_struct test_struct(struct homogeneous_struct arg) {
|
|
|
|
return struct_callee(arg);
|
2011-08-03 13:58:22 +08:00
|
|
|
}
|
|
|
|
|
2014-05-10 00:21:39 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_struct_variadic(%struct.homogeneous_struct* {{.*}}, ...)
|
2014-01-28 18:56:36 +08:00
|
|
|
struct homogeneous_struct test_struct_variadic(struct homogeneous_struct arg, ...) {
|
|
|
|
return struct_callee(arg);
|
|
|
|
}
|
|
|
|
|
2011-08-03 13:58:22 +08:00
|
|
|
struct nested_array {
|
|
|
|
double d[4];
|
|
|
|
};
|
2014-05-10 00:21:39 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_array(%struct.nested_array %{{.*}})
|
2014-11-28 05:02:49 +08:00
|
|
|
// CHECK64: define void @test_array([4 x double] %{{.*}})
|
2011-08-03 13:58:22 +08:00
|
|
|
extern void array_callee(struct nested_array);
|
|
|
|
void test_array(struct nested_array arg) {
|
|
|
|
array_callee(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void complex_callee(__complex__ double);
|
2014-05-10 00:21:39 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_complex({ double, double } %{{.*}})
|
2014-11-28 05:02:49 +08:00
|
|
|
// CHECK64: define void @test_complex([2 x double] %cd.coerce)
|
2011-08-03 13:58:22 +08:00
|
|
|
void test_complex(__complex__ double cd) {
|
|
|
|
complex_callee(cd);
|
|
|
|
}
|
|
|
|
|
2012-07-21 06:29:29 +08:00
|
|
|
// Long double is the same as double on AAPCS, it should be homogeneous.
|
|
|
|
extern void complex_long_callee(__complex__ long double);
|
2014-05-10 00:21:39 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_complex_long({ double, double } %{{.*}})
|
2012-07-21 06:29:29 +08:00
|
|
|
void test_complex_long(__complex__ long double cd) {
|
|
|
|
complex_callee(cd);
|
|
|
|
}
|
|
|
|
|
2011-08-03 13:58:22 +08:00
|
|
|
// Structs with more than 4 elements of the base type are not treated
|
|
|
|
// as homogeneous aggregates. Test that.
|
|
|
|
|
|
|
|
struct big_struct {
|
|
|
|
float f1;
|
|
|
|
float f[2];
|
|
|
|
float f3;
|
|
|
|
float f4;
|
|
|
|
};
|
2014-11-08 06:30:50 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_big([5 x i32] %{{.*}})
|
2014-03-29 23:09:45 +08:00
|
|
|
// CHECK64: define void @test_big(%struct.big_struct* %{{.*}})
|
|
|
|
// CHECK64: call void @llvm.memcpy
|
|
|
|
// CHECK64: call void @big_callee(%struct.big_struct*
|
2011-08-03 13:58:22 +08:00
|
|
|
extern void big_callee(struct big_struct);
|
|
|
|
void test_big(struct big_struct arg) {
|
|
|
|
big_callee(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure that aggregates with multiple base types are not treated as
|
|
|
|
// homogeneous aggregates.
|
|
|
|
|
|
|
|
struct heterogeneous_struct {
|
|
|
|
float f1;
|
|
|
|
int i2;
|
|
|
|
};
|
2014-11-08 06:30:50 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})
|
2014-03-29 23:09:45 +08:00
|
|
|
// CHECK64: define void @test_hetero(i64 %{{.*}})
|
2011-08-03 13:58:22 +08:00
|
|
|
extern void hetero_callee(struct heterogeneous_struct);
|
|
|
|
void test_hetero(struct heterogeneous_struct arg) {
|
|
|
|
hetero_callee(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Neon multi-vector types are homogeneous aggregates.
|
2014-05-10 00:21:39 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc <16 x i8> @f0(%struct.int8x16x4_t %{{.*}})
|
2014-11-28 05:02:49 +08:00
|
|
|
// CHECK64: define <16 x i8> @f0([4 x <16 x i8>] %{{.*}})
|
2011-08-03 13:58:22 +08:00
|
|
|
int8x16_t f0(int8x16x4_t v4) {
|
|
|
|
return vaddq_s8(v4.val[0], v4.val[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ...and it doesn't matter whether the vectors are exactly the same, as long
|
|
|
|
// as they have the same size.
|
|
|
|
|
|
|
|
struct neon_struct {
|
|
|
|
int8x8x2_t v12;
|
|
|
|
int32x2_t v3;
|
|
|
|
int16x4_t v4;
|
|
|
|
};
|
2014-05-10 00:21:39 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_neon(%struct.neon_struct %{{.*}})
|
2014-11-28 05:02:49 +08:00
|
|
|
// CHECK64: define void @test_neon([4 x <8 x i8>] %{{.*}})
|
2011-08-03 13:58:22 +08:00
|
|
|
extern void neon_callee(struct neon_struct);
|
|
|
|
void test_neon(struct neon_struct arg) {
|
|
|
|
neon_callee(arg);
|
|
|
|
}
|
2012-08-14 05:23:55 +08:00
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define arm_aapcs_vfpcc void @f33(%struct.s33* byval(%struct.s33) align 4 %s)
|
2012-08-14 05:23:55 +08:00
|
|
|
struct s33 { char buf[32*32]; };
|
|
|
|
void f33(struct s33 s) { }
|
2014-02-11 17:25:50 +08:00
|
|
|
|
|
|
|
typedef struct { long long x; int y; } struct_long_long_int;
|
|
|
|
// CHECK: define arm_aapcs_vfpcc 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, i32 %j, i64 %k, i32 %l)
|
|
|
|
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) {}
|
|
|
|
|
2015-02-25 01:22:40 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc 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, i32 %j, [2 x i64] %k.coerce)
|
2014-02-11 17:25:50 +08:00
|
|
|
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) {}
|
|
|
|
|
2020-03-25 00:36:19 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_3(%struct.struct_long_long_int* noalias sret align 8 %agg.result, double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, [2 x i64] %k.coerce)
|
2014-02-11 17:25:50 +08:00
|
|
|
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) {}
|
2014-05-07 18:39:12 +08:00
|
|
|
|
|
|
|
typedef struct { int a; int b:4; int c; } struct_int_bitfield_int;
|
2015-02-25 01:22:40 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc 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, i32 %j, i32 %k, [3 x i32] %l.coerce)
|
2014-05-07 18:39:12 +08:00
|
|
|
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) {}
|
2014-05-19 21:10:05 +08:00
|
|
|
|
|
|
|
// Note: this struct requires internal padding
|
|
|
|
typedef struct { int x; long long y; } struct_int_long_long;
|
2015-02-25 01:22:40 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc 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, i32 %j, [2 x i64] %k.coerce)
|
2014-05-19 21:10:05 +08:00
|
|
|
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) {}
|
2014-06-27 21:59:27 +08:00
|
|
|
|
|
|
|
// This very large struct (passed byval) uses up the GPRs, so no padding is needed
|
|
|
|
typedef struct { int x[17]; } struct_seventeen_ints;
|
|
|
|
typedef struct { int x[4]; } struct_four_ints;
|
2019-06-06 05:12:14 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_5(%struct.struct_seventeen_ints* byval(%struct.struct_seventeen_ints) align 4 %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, double %j, [4 x i32] %k.coerce)
|
2014-06-27 21:59:27 +08:00
|
|
|
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) {}
|
2014-07-18 17:09:31 +08:00
|
|
|
|
|
|
|
// Here, parameter k would need padding to prevent it from being split, but it
|
|
|
|
// is passed ByVal (due to being > 64 bytes), so the backend handles this instead.
|
|
|
|
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) {}
|
2019-06-06 05:12:14 +08:00
|
|
|
// CHECK: define arm_aapcs_vfpcc 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, i32 %j, %struct.struct_seventeen_ints* byval(%struct.struct_seventeen_ints) align 4 %k)
|