Chris Lattner | 22fd4ba | 2010-08-25 23:39:14 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s| FileCheck %s |
Eli Friedman | ee1ad99 | 2011-12-02 00:11:43 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx | FileCheck %s -check-prefix=AVX |
Chris Lattner | a8b7a7d | 2010-08-26 06:28:35 +0000 | [diff] [blame] | 3 | #include <stdarg.h> |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 4 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 5 | // CHECK: define signext i8 @f0() |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 6 | char f0(void) { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 7 | return 0; |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 8 | } |
| 9 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 10 | // CHECK: define signext i16 @f1() |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 11 | short f1(void) { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 12 | return 0; |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 13 | } |
| 14 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 15 | // CHECK: define i32 @f2() |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 16 | int f2(void) { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 17 | return 0; |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 18 | } |
| 19 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 20 | // CHECK: define float @f3() |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 21 | float f3(void) { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 22 | return 0; |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 23 | } |
| 24 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 25 | // CHECK: define double @f4() |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 26 | double f4(void) { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 27 | return 0; |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 30 | // CHECK: define x86_fp80 @f5() |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 31 | long double f5(void) { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 32 | return 0; |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 35 | // CHECK: define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8* %a4) |
Daniel Dunbar | 644f4c3 | 2009-02-14 02:09:24 +0000 | [diff] [blame] | 36 | void f6(char a0, short a1, int a2, long long a3, void *a4) { |
| 37 | } |
Anders Carlsson | 730f909 | 2009-02-26 17:38:19 +0000 | [diff] [blame] | 38 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 39 | // CHECK: define void @f7(i32 %a0) |
| 40 | typedef enum { A, B, C } e7; |
| 41 | void f7(e7 a0) { |
Mike Stump | 4b87142 | 2009-02-26 19:00:14 +0000 | [diff] [blame] | 42 | } |
Daniel Dunbar | 100f402 | 2009-03-06 17:50:25 +0000 | [diff] [blame] | 43 | |
| 44 | // Test merging/passing of upper eightbyte with X87 class. |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 45 | // |
John McCall | 410ffb2 | 2011-08-25 23:04:34 +0000 | [diff] [blame] | 46 | // CHECK: define void @f8_1(%union.u8* noalias sret %agg.result) |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 47 | // CHECK: define void @f8_2(%union.u8* byval align 16 %a0) |
Daniel Dunbar | 100f402 | 2009-03-06 17:50:25 +0000 | [diff] [blame] | 48 | union u8 { |
| 49 | long double a; |
| 50 | int b; |
| 51 | }; |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 52 | union u8 f8_1() { while (1) {} } |
Daniel Dunbar | 100f402 | 2009-03-06 17:50:25 +0000 | [diff] [blame] | 53 | void f8_2(union u8 a0) {} |
Daniel Dunbar | 8236bf1 | 2009-05-08 22:26:44 +0000 | [diff] [blame] | 54 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 55 | // CHECK: define i64 @f9() |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 56 | struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} } |
Daniel Dunbar | 8236bf1 | 2009-05-08 22:26:44 +0000 | [diff] [blame] | 57 | |
Chris Lattner | 225e286 | 2010-06-29 00:14:52 +0000 | [diff] [blame] | 58 | // CHECK: define void @f10(i64 %a0.coerce) |
Daniel Dunbar | 8236bf1 | 2009-05-08 22:26:44 +0000 | [diff] [blame] | 59 | struct s10 { int a; int b; int : 0; }; |
| 60 | void f10(struct s10 a0) {} |
| 61 | |
John McCall | 410ffb2 | 2011-08-25 23:04:34 +0000 | [diff] [blame] | 62 | // CHECK: define void @f11(%union.anon* noalias sret %agg.result) |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 63 | union { long double a; float b; } f11() { while (1) {} } |
Daniel Dunbar | 20e95c5 | 2009-05-12 15:22:40 +0000 | [diff] [blame] | 64 | |
Chris Lattner | e2962be | 2010-07-29 07:30:00 +0000 | [diff] [blame] | 65 | // CHECK: define i32 @f12_0() |
| 66 | // CHECK: define void @f12_1(i32 %a0.coerce) |
Daniel Dunbar | 7ef455b | 2009-05-13 18:54:26 +0000 | [diff] [blame] | 67 | struct s12 { int a __attribute__((aligned(16))); }; |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 68 | struct s12 f12_0(void) { while (1) {} } |
Daniel Dunbar | 7ef455b | 2009-05-13 18:54:26 +0000 | [diff] [blame] | 69 | void f12_1(struct s12 a0) {} |
| 70 | |
Daniel Dunbar | 3a5f5c5 | 2009-05-22 17:33:44 +0000 | [diff] [blame] | 71 | // Check that sret parameter is accounted for when checking available integer |
| 72 | // registers. |
John McCall | 410ffb2 | 2011-08-25 23:04:34 +0000 | [diff] [blame] | 73 | // CHECK: define void @f13(%struct.s13_0* noalias sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, {{.*}}* byval align 8 %e, i32 %f) |
Daniel Dunbar | 3a5f5c5 | 2009-05-22 17:33:44 +0000 | [diff] [blame] | 74 | |
| 75 | struct s13_0 { long long f0[3]; }; |
Daniel Dunbar | 55a759b | 2009-08-23 19:28:59 +0000 | [diff] [blame] | 76 | struct s13_1 { long long f0[2]; }; |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 77 | struct s13_0 f13(int a, int b, int c, int d, |
Daniel Dunbar | 55a759b | 2009-08-23 19:28:59 +0000 | [diff] [blame] | 78 | struct s13_1 e, int f) { while (1) {} } |
Daniel Dunbar | 3a5f5c5 | 2009-05-22 17:33:44 +0000 | [diff] [blame] | 79 | |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 80 | // CHECK: define void @f14({{.*}}, i8 signext %X) |
| 81 | void f14(int a, int b, int c, int d, int e, int f, char X) {} |
| 82 | |
| 83 | // CHECK: define void @f15({{.*}}, i8* %X) |
| 84 | void f15(int a, int b, int c, int d, int e, int f, void *X) {} |
| 85 | |
| 86 | // CHECK: define void @f16({{.*}}, float %X) |
Daniel Dunbar | 86e13ee | 2009-05-26 16:37:37 +0000 | [diff] [blame] | 87 | void f16(float a, float b, float c, float d, float e, float f, float g, float h, |
| 88 | float X) {} |
Daniel Dunbar | 0aa1cba | 2010-04-21 19:10:54 +0000 | [diff] [blame] | 89 | |
| 90 | // CHECK: define void @f17({{.*}}, x86_fp80 %X) |
Daniel Dunbar | 86e13ee | 2009-05-26 16:37:37 +0000 | [diff] [blame] | 91 | void f17(float a, float b, float c, float d, float e, float f, float g, float h, |
| 92 | long double X) {} |
| 93 | |
Chris Lattner | faf23b7 | 2010-06-28 19:56:59 +0000 | [diff] [blame] | 94 | // Check for valid coercion. The struct should be passed/returned as i32, not |
| 95 | // as i64 for better code quality. |
| 96 | // rdar://8135035 |
Chris Lattner | 225e286 | 2010-06-29 00:14:52 +0000 | [diff] [blame] | 97 | // CHECK: define void @f18(i32 %a, i32 %f18_arg1.coerce) |
Daniel Dunbar | 55a759b | 2009-08-23 19:28:59 +0000 | [diff] [blame] | 98 | struct f18_s0 { int f0; }; |
| 99 | void f18(int a, struct f18_s0 f18_arg1) { while (1) {} } |
Daniel Dunbar | fdf4986 | 2009-06-05 07:58:54 +0000 | [diff] [blame] | 100 | |
Daniel Dunbar | 46c54fb | 2010-04-21 19:49:55 +0000 | [diff] [blame] | 101 | // Check byval alignment. |
| 102 | |
| 103 | // CHECK: define void @f19(%struct.s19* byval align 16 %x) |
| 104 | struct s19 { |
| 105 | long double a; |
| 106 | }; |
| 107 | void f19(struct s19 x) {} |
| 108 | |
| 109 | // CHECK: define void @f20(%struct.s20* byval align 32 %x) |
| 110 | struct __attribute__((aligned(32))) s20 { |
| 111 | int x; |
| 112 | int y; |
| 113 | }; |
| 114 | void f20(struct s20 x) {} |
Chris Lattner | 9c254f0 | 2010-06-29 06:01:59 +0000 | [diff] [blame] | 115 | |
| 116 | struct StringRef { |
| 117 | long x; |
| 118 | const char *Ptr; |
| 119 | }; |
| 120 | |
| 121 | // rdar://7375902 |
| 122 | // CHECK: define i8* @f21(i64 %S.coerce0, i8* %S.coerce1) |
| 123 | const char *f21(struct StringRef S) { return S.x+S.Ptr; } |
| 124 | |
Chris Lattner | 121b3fa | 2010-07-05 20:21:00 +0000 | [diff] [blame] | 125 | // PR7567 |
| 126 | typedef __attribute__ ((aligned(16))) struct f22s { unsigned long long x[2]; } L; |
| 127 | void f22(L x, L y) { } |
| 128 | // CHECK: @f22 |
| 129 | // CHECK: %x = alloca{{.*}}, align 16 |
| 130 | // CHECK: %y = alloca{{.*}}, align 16 |
| 131 | |
| 132 | |
Chris Lattner | 1daf808 | 2010-07-28 22:15:08 +0000 | [diff] [blame] | 133 | |
| 134 | // PR7714 |
| 135 | struct f23S { |
| 136 | short f0; |
| 137 | unsigned f1; |
| 138 | int f2; |
| 139 | }; |
| 140 | |
Chris Lattner | 519f68c | 2010-07-28 23:06:14 +0000 | [diff] [blame] | 141 | |
Chris Lattner | 1daf808 | 2010-07-28 22:15:08 +0000 | [diff] [blame] | 142 | void f23(int A, struct f23S B) { |
| 143 | // CHECK: define void @f23(i32 %A, i64 %B.coerce0, i32 %B.coerce1) |
| 144 | } |
| 145 | |
Chris Lattner | 519f68c | 2010-07-28 23:06:14 +0000 | [diff] [blame] | 146 | struct f24s { long a; int b; }; |
Chris Lattner | 1daf808 | 2010-07-28 22:15:08 +0000 | [diff] [blame] | 147 | |
Chris Lattner | 519f68c | 2010-07-28 23:06:14 +0000 | [diff] [blame] | 148 | struct f23S f24(struct f23S *X, struct f24s *P2) { |
| 149 | return *X; |
| 150 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 151 | // CHECK: define { i64, i32 } @f24(%struct.f23S* %X, %struct.f24s* %P2) |
Chris Lattner | 519f68c | 2010-07-28 23:06:14 +0000 | [diff] [blame] | 152 | } |
Chris Lattner | 1daf808 | 2010-07-28 22:15:08 +0000 | [diff] [blame] | 153 | |
Chris Lattner | 800588f | 2010-07-29 06:26:06 +0000 | [diff] [blame] | 154 | // rdar://8248065 |
Chris Lattner | ab5722e | 2010-07-28 23:47:21 +0000 | [diff] [blame] | 155 | typedef float v4f32 __attribute__((__vector_size__(16))); |
Chris Lattner | ab5722e | 2010-07-28 23:47:21 +0000 | [diff] [blame] | 156 | v4f32 f25(v4f32 X) { |
Chris Lattner | 800588f | 2010-07-29 06:26:06 +0000 | [diff] [blame] | 157 | // CHECK: define <4 x float> @f25(<4 x float> %X) |
| 158 | // CHECK-NOT: alloca |
Chris Lattner | c10ab19 | 2010-07-29 17:14:05 +0000 | [diff] [blame] | 159 | // CHECK: alloca <4 x float> |
Chris Lattner | 800588f | 2010-07-29 06:26:06 +0000 | [diff] [blame] | 160 | // CHECK-NOT: alloca |
Chris Lattner | c10ab19 | 2010-07-29 17:14:05 +0000 | [diff] [blame] | 161 | // CHECK: store <4 x float> %X, <4 x float>* |
Chris Lattner | 800588f | 2010-07-29 06:26:06 +0000 | [diff] [blame] | 162 | // CHECK-NOT: store |
| 163 | // CHECK: ret <4 x float> |
Chris Lattner | ab5722e | 2010-07-28 23:47:21 +0000 | [diff] [blame] | 164 | return X+X; |
| 165 | } |
| 166 | |
Chris Lattner | 4711cb0 | 2010-07-29 04:46:19 +0000 | [diff] [blame] | 167 | struct foo26 { |
| 168 | int *X; |
| 169 | float *Y; |
| 170 | }; |
Chris Lattner | ab5722e | 2010-07-28 23:47:21 +0000 | [diff] [blame] | 171 | |
Chris Lattner | 4711cb0 | 2010-07-29 04:46:19 +0000 | [diff] [blame] | 172 | struct foo26 f26(struct foo26 *P) { |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 173 | // CHECK: define { i32*, float* } @f26(%struct.foo26* %P) |
Chris Lattner | 4711cb0 | 2010-07-29 04:46:19 +0000 | [diff] [blame] | 174 | return *P; |
| 175 | } |
Chris Lattner | 15842bd | 2010-07-29 05:02:29 +0000 | [diff] [blame] | 176 | |
| 177 | |
| 178 | struct v4f32wrapper { |
| 179 | v4f32 v; |
| 180 | }; |
| 181 | |
| 182 | struct v4f32wrapper f27(struct v4f32wrapper X) { |
| 183 | // CHECK: define <4 x float> @f27(<4 x float> %X.coerce) |
| 184 | return X; |
Chris Lattner | e2962be | 2010-07-29 07:30:00 +0000 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | // rdar://5711709 |
| 188 | struct f28c { |
| 189 | double x; |
| 190 | int y; |
| 191 | }; |
| 192 | void f28(struct f28c C) { |
| 193 | // CHECK: define void @f28(double %C.coerce0, i32 %C.coerce1) |
| 194 | } |
| 195 | |
Chris Lattner | 021c3a3 | 2010-07-29 07:43:55 +0000 | [diff] [blame] | 196 | struct f29a { |
| 197 | struct c { |
| 198 | double x; |
| 199 | int y; |
| 200 | } x[1]; |
| 201 | }; |
| 202 | |
| 203 | void f29a(struct f29a A) { |
| 204 | // CHECK: define void @f29a(double %A.coerce0, i32 %A.coerce1) |
| 205 | } |
Chris Lattner | 9e45a3d | 2010-07-29 17:34:39 +0000 | [diff] [blame] | 206 | |
| 207 | // rdar://8249586 |
| 208 | struct S0 { char f0[8]; char f2; char f3; char f4; }; |
| 209 | void f30(struct S0 p_4) { |
| 210 | // CHECK: define void @f30(i64 %p_4.coerce0, i24 %p_4.coerce1) |
| 211 | } |
Chris Lattner | f47c944 | 2010-07-29 18:13:09 +0000 | [diff] [blame] | 212 | |
| 213 | // Pass the third element as a float when followed by tail padding. |
| 214 | // rdar://8251384 |
| 215 | struct f31foo { float a, b, c; }; |
| 216 | float f31(struct f31foo X) { |
Chris Lattner | 22fd4ba | 2010-08-25 23:39:14 +0000 | [diff] [blame] | 217 | // CHECK: define float @f31(<2 x float> %X.coerce0, float %X.coerce1) |
Chris Lattner | f47c944 | 2010-07-29 18:13:09 +0000 | [diff] [blame] | 218 | return X.c; |
| 219 | } |
| 220 | |
Chris Lattner | 22fd4ba | 2010-08-25 23:39:14 +0000 | [diff] [blame] | 221 | _Complex float f32(_Complex float A, _Complex float B) { |
| 222 | // rdar://6379669 |
| 223 | // CHECK: define <2 x float> @f32(<2 x float> %A.coerce, <2 x float> %B.coerce) |
| 224 | return A+B; |
| 225 | } |
| 226 | |
Chris Lattner | f47c944 | 2010-07-29 18:13:09 +0000 | [diff] [blame] | 227 | |
Chris Lattner | a8b7a7d | 2010-08-26 06:28:35 +0000 | [diff] [blame] | 228 | // rdar://8357396 |
| 229 | struct f33s { long x; float c,d; }; |
| 230 | |
| 231 | void f33(va_list X) { |
| 232 | va_arg(X, struct f33s); |
| 233 | } |
| 234 | |
Chris Lattner | 473f8e7 | 2010-08-26 18:03:20 +0000 | [diff] [blame] | 235 | typedef unsigned long long v1i64 __attribute__((__vector_size__(8))); |
| 236 | |
| 237 | // rdar://8359248 |
| 238 | // CHECK: define i64 @f34(i64 %arg.coerce) |
| 239 | v1i64 f34(v1i64 arg) { return arg; } |
Chris Lattner | a8b7a7d | 2010-08-26 06:28:35 +0000 | [diff] [blame] | 240 | |
Chris Lattner | 0fefa41 | 2010-08-26 18:13:50 +0000 | [diff] [blame] | 241 | |
| 242 | // rdar://8358475 |
| 243 | // CHECK: define i64 @f35(i64 %arg.coerce) |
| 244 | typedef unsigned long v1i64_2 __attribute__((__vector_size__(8))); |
| 245 | v1i64_2 f35(v1i64_2 arg) { return arg+arg; } |
| 246 | |
John McCall | 67a5773 | 2011-04-21 01:20:55 +0000 | [diff] [blame] | 247 | // rdar://9122143 |
| 248 | // CHECK: declare void @func(%struct._str* byval align 16) |
| 249 | typedef struct _str { |
| 250 | union { |
| 251 | long double a; |
| 252 | long c; |
| 253 | }; |
| 254 | } str; |
| 255 | |
| 256 | void func(str s); |
| 257 | str ss; |
| 258 | void f9122143() |
| 259 | { |
| 260 | func(ss); |
| 261 | } |
| 262 | |
Eli Friedman | 14508ff | 2011-07-02 00:57:27 +0000 | [diff] [blame] | 263 | // CHECK: define double @f36(double %arg.coerce) |
| 264 | typedef unsigned v2i32 __attribute((__vector_size__(8))); |
| 265 | v2i32 f36(v2i32 arg) { return arg; } |
Bruno Cardoso Lopes | 4943c15 | 2011-07-11 22:41:29 +0000 | [diff] [blame] | 266 | |
Eli Friedman | ee1ad99 | 2011-12-02 00:11:43 +0000 | [diff] [blame] | 267 | // AVX: declare void @f38(<8 x float>) |
| 268 | // AVX: declare void @f37(<8 x float>) |
| 269 | // CHECK: declare void @f38(%struct.s256* byval align 32) |
| 270 | // CHECK: declare void @f37(<8 x float>* byval align 32) |
Bruno Cardoso Lopes | 4943c15 | 2011-07-11 22:41:29 +0000 | [diff] [blame] | 271 | typedef float __m256 __attribute__ ((__vector_size__ (32))); |
| 272 | typedef struct { |
| 273 | __m256 m; |
| 274 | } s256; |
| 275 | |
| 276 | s256 x38; |
| 277 | __m256 x37; |
| 278 | |
| 279 | void f38(s256 x); |
| 280 | void f37(__m256 x); |
| 281 | void f39() { f38(x38); f37(x37); } |
| 282 | |
Bruno Cardoso Lopes | 089d892 | 2011-07-12 01:27:38 +0000 | [diff] [blame] | 283 | // The two next tests make sure that the struct below is passed |
| 284 | // in the same way regardless of avx being used |
| 285 | |
Bruno Cardoso Lopes | b8981df | 2011-07-13 21:58:55 +0000 | [diff] [blame] | 286 | // CHECK: declare void @func40(%struct.t128* byval align 16) |
Bruno Cardoso Lopes | 4943c15 | 2011-07-11 22:41:29 +0000 | [diff] [blame] | 287 | typedef float __m128 __attribute__ ((__vector_size__ (16))); |
Bruno Cardoso Lopes | ccafadb | 2011-07-12 00:30:27 +0000 | [diff] [blame] | 288 | typedef struct t128 { |
Bruno Cardoso Lopes | 4943c15 | 2011-07-11 22:41:29 +0000 | [diff] [blame] | 289 | __m128 m; |
| 290 | __m128 n; |
| 291 | } two128; |
| 292 | |
| 293 | extern void func40(two128 s); |
| 294 | void func41(two128 s) { |
| 295 | func40(s); |
| 296 | } |
| 297 | |
Bruno Cardoso Lopes | b8981df | 2011-07-13 21:58:55 +0000 | [diff] [blame] | 298 | // CHECK: declare void @func42(%struct.t128_2* byval align 16) |
Bruno Cardoso Lopes | 089d892 | 2011-07-12 01:27:38 +0000 | [diff] [blame] | 299 | typedef struct xxx { |
| 300 | __m128 array[2]; |
| 301 | } Atwo128; |
| 302 | typedef struct t128_2 { |
| 303 | Atwo128 x; |
| 304 | } SA; |
| 305 | |
| 306 | extern void func42(SA s); |
| 307 | void func43(SA s) { |
| 308 | func42(s); |
| 309 | } |
Eli Friedman | 8d2fe42 | 2011-11-18 02:44:19 +0000 | [diff] [blame] | 310 | |
| 311 | // CHECK: define i32 @f44 |
| 312 | // CHECK: ptrtoint |
| 313 | // CHECK-NEXT: and {{.*}}, -32 |
| 314 | // CHECK-NEXT: inttoptr |
| 315 | typedef int T44 __attribute((vector_size(32))); |
| 316 | struct s44 { T44 x; int y; }; |
| 317 | int f44(int i, ...) { |
| 318 | __builtin_va_list ap; |
| 319 | __builtin_va_start(ap, i); |
| 320 | struct s44 s = __builtin_va_arg(ap, struct s44); |
| 321 | __builtin_va_end(ap); |
| 322 | return s.y; |
| 323 | } |
Tanya Lattner | ce27567 | 2011-11-28 23:18:11 +0000 | [diff] [blame] | 324 | |
| 325 | // Text that vec3 returns the correct LLVM IR type. |
Eli Friedman | ee1ad99 | 2011-12-02 00:11:43 +0000 | [diff] [blame] | 326 | // AVX: define i32 @foo(<3 x i64> %X) |
Tanya Lattner | ce27567 | 2011-11-28 23:18:11 +0000 | [diff] [blame] | 327 | typedef long long3 __attribute((ext_vector_type(3))); |
| 328 | int foo(long3 X) |
| 329 | { |
| 330 | return 0; |
| 331 | } |
Eli Friedman | 3ed7903 | 2011-12-01 04:53:19 +0000 | [diff] [blame] | 332 | |
| 333 | // Make sure we don't use a varargs convention for a function without a |
| 334 | // prototype where AVX types are involved. |
Eli Friedman | ee1ad99 | 2011-12-02 00:11:43 +0000 | [diff] [blame] | 335 | // AVX: @test45 |
| 336 | // AVX: call i32 bitcast (i32 (...)* @f45 to i32 (<8 x float>)*) |
Eli Friedman | 3ed7903 | 2011-12-01 04:53:19 +0000 | [diff] [blame] | 337 | int f45(); |
| 338 | __m256 x45; |
| 339 | void test45() { f45(x45); } |
Eli Friedman | ee1ad99 | 2011-12-02 00:11:43 +0000 | [diff] [blame] | 340 | |
| 341 | // Make sure we use byval to pass 64-bit vectors in memory; the LLVM call |
| 342 | // lowering can't handle this case correctly because it runs after legalization. |
| 343 | // CHECK: @test46 |
| 344 | // CHECK: call void @f46({{.*}}<2 x float>* byval align 8 {{.*}}, <2 x float>* byval align 8 {{.*}}) |
| 345 | typedef float v46 __attribute((vector_size(8))); |
| 346 | void f46(v46,v46,v46,v46,v46,v46,v46,v46,v46,v46); |
| 347 | void test46() { v46 x = {1,2}; f46(x,x,x,x,x,x,x,x,x,x); } |
Daniel Dunbar | edfac03 | 2012-03-10 01:03:58 +0000 | [diff] [blame] | 348 | |
| 349 | // Check that we pass the struct below without using byval, which helps out |
| 350 | // codegen. |
| 351 | // |
| 352 | // CHECK: @test47 |
| 353 | // CHECK: call void @f47(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}) |
| 354 | struct s47 { unsigned a; }; |
| 355 | void f47(int,int,int,int,int,int,struct s47); |
| 356 | void test47(int a, struct s47 b) { f47(a, a, a, a, a, a, b); } |