Home | History | Annotate | Download | only in CodeGen
      1 // REQUIRES: arm-registered-target
      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 // RUN: %clang_cc1 -triple armv7-unknown-nacl-gnueabi \
     10 // RUN:  -target-cpu cortex-a8 \
     11 // RUN:  -mfloat-abi hard \
     12 // RUN:  -ffreestanding \
     13 // RUN:  -emit-llvm -w -o - %s | FileCheck %s
     14 
     15 #include <arm_neon.h>
     16 
     17 struct homogeneous_struct {
     18   float f[2];
     19   float f3;
     20   float f4;
     21 };
     22 // CHECK: define arm_aapcs_vfpcc %struct.homogeneous_struct @test_struct(float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
     23 extern struct homogeneous_struct struct_callee(struct homogeneous_struct);
     24 struct homogeneous_struct test_struct(struct homogeneous_struct arg) {
     25   return struct_callee(arg);
     26 }
     27 
     28 struct nested_array {
     29   double d[4];
     30 };
     31 // CHECK: define arm_aapcs_vfpcc void @test_array(double %{{.*}}, double %{{.*}}, double %{{.*}}, double %{{.*}})
     32 extern void array_callee(struct nested_array);
     33 void test_array(struct nested_array arg) {
     34   array_callee(arg);
     35 }
     36 
     37 extern void complex_callee(__complex__ double);
     38 // CHECK: define arm_aapcs_vfpcc void @test_complex(double %{{.*}}, double %{{.*}})
     39 void test_complex(__complex__ double cd) {
     40   complex_callee(cd);
     41 }
     42 
     43 // Long double is the same as double on AAPCS, it should be homogeneous.
     44 extern void complex_long_callee(__complex__ long double);
     45 // CHECK: define arm_aapcs_vfpcc void @test_complex_long(double %{{.*}}, double %{{.*}})
     46 void test_complex_long(__complex__ long double cd) {
     47   complex_callee(cd);
     48 }
     49 
     50 // Structs with more than 4 elements of the base type are not treated
     51 // as homogeneous aggregates.  Test that.
     52 
     53 struct big_struct {
     54   float f1;
     55   float f[2];
     56   float f3;
     57   float f4;
     58 };
     59 // CHECK: define arm_aapcs_vfpcc void @test_big([5 x i32] %{{.*}})
     60 extern void big_callee(struct big_struct);
     61 void test_big(struct big_struct arg) {
     62   big_callee(arg);
     63 }
     64 
     65 // Make sure that aggregates with multiple base types are not treated as
     66 // homogeneous aggregates.
     67 
     68 struct heterogeneous_struct {
     69   float f1;
     70   int i2;
     71 };
     72 // CHECK: define arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})
     73 extern void hetero_callee(struct heterogeneous_struct);
     74 void test_hetero(struct heterogeneous_struct arg) {
     75   hetero_callee(arg);
     76 }
     77 
     78 // Neon multi-vector types are homogeneous aggregates.
     79 // CHECK: define arm_aapcs_vfpcc <16 x i8> @f0(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}})
     80 int8x16_t f0(int8x16x4_t v4) {
     81   return vaddq_s8(v4.val[0], v4.val[3]);
     82 }
     83 
     84 // ...and it doesn't matter whether the vectors are exactly the same, as long
     85 // as they have the same size.
     86 
     87 struct neon_struct {
     88   int8x8x2_t v12;
     89   int32x2_t v3;
     90   int16x4_t v4;
     91 };
     92 // CHECK: define arm_aapcs_vfpcc void @test_neon(<8 x i8> %{{.*}}, <8 x i8> %{{.*}}, <2 x i32> %{{.*}}, <4 x i16> %{{.*}})
     93 extern void neon_callee(struct neon_struct);
     94 void test_neon(struct neon_struct arg) {
     95   neon_callee(arg);
     96 }
     97 
     98 // CHECK: define arm_aapcs_vfpcc void @f33(%struct.s33* byval %s)
     99 struct s33 { char buf[32*32]; };
    100 void f33(struct s33 s) { }
    101