Anton Korobeynikov | 00000b0 | 2012-04-13 11:23:39 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple armv7---eabi -target-abi aapcs -mfloat-abi hard -emit-llvm %s -o - | FileCheck %s |
Anton Korobeynikov | a8063c3 | 2012-04-23 09:02:13 +0000 | [diff] [blame^] | 2 | |
| 3 | typedef long long int64_t; |
| 4 | typedef unsigned int uint32_t; |
Anton Korobeynikov | 00000b0 | 2012-04-13 11:23:39 +0000 | [diff] [blame] | 5 | |
| 6 | /* This is not a homogenous aggregate - fundamental types are different */ |
| 7 | typedef union { |
| 8 | float f[4]; |
| 9 | uint32_t i[4]; |
| 10 | } union_with_first_floats; |
| 11 | union_with_first_floats g_u_f; |
| 12 | |
| 13 | extern void takes_union_with_first_floats(union_with_first_floats a); |
| 14 | extern union_with_first_floats returns_union_with_first_floats(void); |
| 15 | |
| 16 | void test_union_with_first_floats(void) { |
| 17 | takes_union_with_first_floats(g_u_f); |
| 18 | } |
| 19 | // CHECK: declare arm_aapcs_vfpcc void @takes_union_with_first_floats([4 x i32]) |
| 20 | |
| 21 | void test_return_union_with_first_floats(void) { |
| 22 | g_u_f = returns_union_with_first_floats(); |
| 23 | } |
| 24 | // CHECK: declare arm_aapcs_vfpcc void @returns_union_with_first_floats(%union.union_with_first_floats* sret) |
| 25 | |
| 26 | /* This is not a homogenous aggregate - fundamental types are different */ |
| 27 | typedef union { |
| 28 | uint32_t i[4]; |
| 29 | float f[4]; |
| 30 | } union_with_non_first_floats; |
| 31 | union_with_non_first_floats g_u_nf_f; |
| 32 | |
| 33 | extern void takes_union_with_non_first_floats(union_with_non_first_floats a); |
| 34 | extern union_with_non_first_floats returns_union_with_non_first_floats(void); |
| 35 | |
| 36 | void test_union_with_non_first_floats(void) { |
| 37 | takes_union_with_non_first_floats(g_u_nf_f); |
| 38 | } |
| 39 | // CHECK: declare arm_aapcs_vfpcc void @takes_union_with_non_first_floats([4 x i32]) |
| 40 | |
| 41 | void test_return_union_with_non_first_floats(void) { |
| 42 | g_u_nf_f = returns_union_with_non_first_floats(); |
| 43 | } |
| 44 | // CHECK: declare arm_aapcs_vfpcc void @returns_union_with_non_first_floats(%union.union_with_non_first_floats* sret) |
| 45 | |
| 46 | /* This is not a homogenous aggregate - fundamental types are different */ |
| 47 | typedef struct { |
| 48 | float a; |
| 49 | union_with_first_floats b; |
| 50 | } struct_with_union_with_first_floats; |
| 51 | struct_with_union_with_first_floats g_s_f; |
| 52 | |
| 53 | extern void takes_struct_with_union_with_first_floats(struct_with_union_with_first_floats a); |
| 54 | extern struct_with_union_with_first_floats returns_struct_with_union_with_first_floats(void); |
| 55 | |
| 56 | void test_struct_with_union_with_first_floats(void) { |
| 57 | takes_struct_with_union_with_first_floats(g_s_f); |
| 58 | } |
| 59 | // CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_first_floats([5 x i32]) |
| 60 | |
| 61 | void test_return_struct_with_union_with_first_floats(void) { |
| 62 | g_s_f = returns_struct_with_union_with_first_floats(); |
| 63 | } |
| 64 | // CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_first_floats(%struct.struct_with_union_with_first_floats* sret) |
| 65 | |
| 66 | /* This is not a homogenous aggregate - fundamental types are different */ |
| 67 | typedef struct { |
| 68 | float a; |
| 69 | union_with_non_first_floats b; |
| 70 | } struct_with_union_with_non_first_floats; |
| 71 | struct_with_union_with_non_first_floats g_s_nf_f; |
| 72 | |
| 73 | extern void takes_struct_with_union_with_non_first_floats(struct_with_union_with_non_first_floats a); |
| 74 | extern struct_with_union_with_non_first_floats returns_struct_with_union_with_non_first_floats(void); |
| 75 | |
| 76 | void test_struct_with_union_with_non_first_floats(void) { |
| 77 | takes_struct_with_union_with_non_first_floats(g_s_nf_f); |
| 78 | } |
| 79 | // CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_non_first_floats([5 x i32]) |
| 80 | |
| 81 | void test_return_struct_with_union_with_non_first_floats(void) { |
| 82 | g_s_nf_f = returns_struct_with_union_with_non_first_floats(); |
| 83 | } |
| 84 | // CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_non_first_floats(%struct.struct_with_union_with_non_first_floats* sret) |
| 85 | |
| 86 | /* Plain array is not a homogenous aggregate */ |
| 87 | extern void takes_array_of_floats(float a[4]); |
| 88 | void test_array_of_floats(void) { |
| 89 | float a[4] = {1.0, 2.0, 3.0, 4.0}; |
| 90 | takes_array_of_floats(a); |
| 91 | } |
| 92 | // CHECK: declare arm_aapcs_vfpcc void @takes_array_of_floats(float*) |
| 93 | |
| 94 | /* Struct-type homogenous aggregate */ |
| 95 | typedef struct { |
| 96 | float x, y, z, w; |
| 97 | } struct_with_fundamental_elems; |
| 98 | struct_with_fundamental_elems g_s; |
| 99 | |
| 100 | extern void takes_struct_with_fundamental_elems(struct_with_fundamental_elems a); |
| 101 | extern struct_with_fundamental_elems returns_struct_with_fundamental_elems(void); |
| 102 | |
| 103 | void test_struct_with_fundamental_elems(void) { |
| 104 | takes_struct_with_fundamental_elems(g_s); |
| 105 | // CHECK: call arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(float {{.*}}, float {{.*}}, float{{.*}}, float {{.*}}) |
| 106 | } |
| 107 | // CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(float, float, float, float) |
| 108 | |
| 109 | void test_return_struct_with_fundamental_elems(void) { |
| 110 | g_s = returns_struct_with_fundamental_elems(); |
| 111 | // CHECK: call arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems() |
| 112 | } |
| 113 | // CHECK: declare arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems() |
| 114 | |
| 115 | /* Array-type homogenous aggregate */ |
| 116 | typedef struct { |
| 117 | float xyzw[4]; |
| 118 | } struct_with_array; |
| 119 | struct_with_array g_s_a; |
| 120 | |
| 121 | extern void takes_struct_with_array(struct_with_array a); |
| 122 | extern struct_with_array returns_struct_with_array(void); |
| 123 | |
| 124 | void test_struct_with_array(void) { |
| 125 | takes_struct_with_array(g_s_a); |
| 126 | // CHECK: call arm_aapcs_vfpcc void @takes_struct_with_array(float {{.*}}, float {{.*}}, float {{.*}}, float {{.*}}) |
| 127 | } |
| 128 | // CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_array(float, float, float, float) |
| 129 | |
| 130 | void test_return_struct_with_array(void) { |
| 131 | g_s_a = returns_struct_with_array(); |
| 132 | // CHECK: call arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array() |
| 133 | } |
| 134 | // CHECK: declare arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array() |
| 135 | |
| 136 | /* This union is a homogenous aggregate. Check that it's passed properly */ |
| 137 | typedef union { |
| 138 | struct_with_fundamental_elems xyzw; |
| 139 | float a[3]; |
| 140 | } union_with_struct_with_fundamental_elems; |
| 141 | union_with_struct_with_fundamental_elems g_u_s_fe; |
| 142 | |
| 143 | extern void takes_union_with_struct_with_fundamental_elems(union_with_struct_with_fundamental_elems a); |
| 144 | extern union_with_struct_with_fundamental_elems returns_union_with_struct_with_fundamental_elems(void); |
| 145 | |
| 146 | void test_union_with_struct_with_fundamental_elems(void) { |
| 147 | takes_union_with_struct_with_fundamental_elems(g_u_s_fe); |
| 148 | // CHECK: call arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(float {{.*}}, float {{.*}}, float {{.*}}, float {{.*}}) |
| 149 | } |
| 150 | // CHECK: declare arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(float, float, float, float) |
| 151 | |
| 152 | void test_return_union_with_struct_with_fundamental_elems(void) { |
| 153 | g_u_s_fe = returns_union_with_struct_with_fundamental_elems(); |
| 154 | // CHECK: call arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems() |
| 155 | } |
| 156 | // CHECK: declare arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems() |
| 157 | |
| 158 | // FIXME: Tests necessary: |
| 159 | // - Vectors |
| 160 | // - C++ stuff |