brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.6 KiB · e60ed1e Raw
145 lines · c
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 %s7 8// RUN: %clang_cc1 -triple arm64-apple-darwin9 -target-feature +neon \9// RUN:   -ffreestanding \10// RUN:   -emit-llvm -w -o - %s | FileCheck -check-prefix=CHECK64 %s11 12// REQUIRES: arm-registered-target13// REQUIRES: aarch64-registered-target14 15#include <arm_neon.h>16 17struct homogeneous_struct {18  float f[2];19  float f3;20  float f4;21};22// CHECK: define{{.*}} arm_aapcs_vfpcc %struct.homogeneous_struct @test_struct(%struct.homogeneous_struct %{{.*}})23// CHECK64: define{{.*}} %struct.homogeneous_struct @test_struct([4 x float] alignstack(8) %{{.*}})24extern struct homogeneous_struct struct_callee(struct homogeneous_struct);25struct homogeneous_struct test_struct(struct homogeneous_struct arg) {26  return struct_callee(arg);27}28 29// CHECK: define{{.*}} arm_aapcs_vfpcc void @test_struct_variadic(ptr {{.*}}, ...)30struct homogeneous_struct test_struct_variadic(struct homogeneous_struct arg, ...) {31  return struct_callee(arg);32}33 34struct nested_array {35  double d[4];36};37// CHECK: define{{.*}} arm_aapcs_vfpcc void @test_array(%struct.nested_array %{{.*}})38// CHECK64: define{{.*}} void @test_array([4 x double] alignstack(8) %{{.*}})39extern void array_callee(struct nested_array);40void test_array(struct nested_array arg) {41  array_callee(arg);42}43 44extern void complex_callee(__complex__ double);45// CHECK: define{{.*}} arm_aapcs_vfpcc void @test_complex({ double, double } noundef %{{.*}})46// CHECK64: define{{.*}} void @test_complex([2 x double] noundef alignstack(8) %cd.coerce)47void test_complex(__complex__ double cd) {48  complex_callee(cd);49}50 51// Long double is the same as double on AAPCS, it should be homogeneous.52extern void complex_long_callee(__complex__ long double);53// CHECK: define{{.*}} arm_aapcs_vfpcc void @test_complex_long({ double, double } noundef %{{.*}})54void test_complex_long(__complex__ long double cd) {55  complex_callee(cd);56}57 58// Structs with more than 4 elements of the base type are not treated59// as homogeneous aggregates.  Test that.60 61struct big_struct {62  float f1;63  float f[2];64  float f3;65  float f4;66};67// CHECK: define{{.*}} arm_aapcs_vfpcc void @test_big([5 x i32] %{{.*}})68// CHECK64: define{{.*}} void @test_big(ptr dead_on_return noundef %{{.*}})69// CHECK64: call void @llvm.memcpy70// CHECK64: call void @big_callee(ptr71extern void big_callee(struct big_struct);72void test_big(struct big_struct arg) {73  big_callee(arg);74}75 76// Make sure that aggregates with multiple base types are not treated as77// homogeneous aggregates.78 79struct heterogeneous_struct {80  float f1;81  int i2;82};83// CHECK: define{{.*}} arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})84// CHECK64: define{{.*}} void @test_hetero(i64 %{{.*}})85extern void hetero_callee(struct heterogeneous_struct);86void test_hetero(struct heterogeneous_struct arg) {87  hetero_callee(arg);88}89 90// Neon multi-vector types are homogeneous aggregates.91// CHECK: define{{.*}} arm_aapcs_vfpcc <16 x i8> @f0(%struct.int8x16x4_t %{{.*}})92// CHECK64: define{{.*}} <16 x i8> @f0([4 x <16 x i8>] alignstack(16) %{{.*}})93int8x16_t f0(int8x16x4_t v4) {94  return vaddq_s8(v4.val[0], v4.val[3]);95}96 97// ...and it doesn't matter whether the vectors are exactly the same, as long98// as they have the same size.99 100struct neon_struct {101  int8x8x2_t v12;102  int32x2_t v3;103  int16x4_t v4;104};105// CHECK: define{{.*}} arm_aapcs_vfpcc void @test_neon(%struct.neon_struct %{{.*}})106// CHECK64: define{{.*}} void @test_neon([4 x <8 x i8>] alignstack(8) %{{.*}})107extern void neon_callee(struct neon_struct);108void test_neon(struct neon_struct arg) {109  neon_callee(arg);110}111 112// CHECK-LABEL: define{{.*}} arm_aapcs_vfpcc void @f33(ptr noundef byval(%struct.s33) align 4 %s)113struct s33 { char buf[32*32]; };114void f33(struct s33 s) { }115 116typedef struct { long long x; int y; } struct_long_long_int;117// 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)118void 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) {}119 120// 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)121void 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) {}122 123// 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)124struct_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) {}125 126typedef struct { int a; int b:4; int c; } struct_int_bitfield_int;127// 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)128void 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) {}129 130// Note: this struct requires internal padding131typedef struct { int x; long long y; } struct_int_long_long;132// 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)133void 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) {}134 135// This very large struct (passed byval) uses up the GPRs, so no padding is needed136typedef struct { int x[17]; } struct_seventeen_ints;137typedef struct { int x[4]; } struct_four_ints;138// 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)139void 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) {}140 141// Here, parameter k would need padding to prevent it from being split, but it142// is passed ByVal (due to being > 64 bytes), so the backend handles this instead.143void 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) {}144// 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)145