Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 1 | // REQUIRES: amdgpu-registered-target |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s |
| 3 | // RUN: %clang_cc1 -triple r600-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 4 | |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 5 | typedef __attribute__(( ext_vector_type(2) )) char char2; |
| 6 | typedef __attribute__(( ext_vector_type(3) )) char char3; |
| 7 | typedef __attribute__(( ext_vector_type(4) )) char char4; |
| 8 | |
| 9 | typedef __attribute__(( ext_vector_type(2) )) short short2; |
| 10 | typedef __attribute__(( ext_vector_type(3) )) short short3; |
| 11 | typedef __attribute__(( ext_vector_type(4) )) short short4; |
| 12 | |
| 13 | typedef __attribute__(( ext_vector_type(2) )) int int2; |
| 14 | typedef __attribute__(( ext_vector_type(3) )) int int3; |
| 15 | typedef __attribute__(( ext_vector_type(4) )) int int4; |
| 16 | typedef __attribute__(( ext_vector_type(16) )) int int16; |
| 17 | typedef __attribute__(( ext_vector_type(32) )) int int32; |
| 18 | |
| 19 | // CHECK: %struct.empty_struct = type {} |
| 20 | typedef struct empty_struct |
| 21 | { |
| 22 | } empty_struct; |
| 23 | |
| 24 | // CHECK-NOT: %struct.single_element_struct_arg |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 25 | typedef struct single_element_struct_arg |
| 26 | { |
| 27 | int i; |
| 28 | } single_element_struct_arg_t; |
| 29 | |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 30 | // CHECK-NOT: %struct.nested_single_element_struct_arg |
| 31 | typedef struct nested_single_element_struct_arg |
| 32 | { |
| 33 | single_element_struct_arg_t i; |
| 34 | } nested_single_element_struct_arg_t; |
| 35 | |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 36 | // CHECK: %struct.struct_arg = type { i32, float, i32 } |
| 37 | typedef struct struct_arg |
| 38 | { |
| 39 | int i1; |
| 40 | float f; |
| 41 | int i2; |
| 42 | } struct_arg_t; |
| 43 | |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 44 | // CHECK: %struct.struct_padding_arg = type { i8, i64 } |
| 45 | typedef struct struct_padding_arg |
| 46 | { |
| 47 | char i1; |
| 48 | long f; |
| 49 | } struct_padding_arg; |
| 50 | |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 51 | // CHECK: %struct.struct_of_arrays_arg = type { [2 x i32], float, [4 x i32], [3 x float], i32 } |
| 52 | typedef struct struct_of_arrays_arg |
| 53 | { |
| 54 | int i1[2]; |
| 55 | float f1; |
| 56 | int i2[4]; |
| 57 | float f2[3]; |
| 58 | int i3; |
| 59 | } struct_of_arrays_arg_t; |
| 60 | |
| 61 | // CHECK: %struct.struct_of_structs_arg = type { i32, float, %struct.struct_arg, i32 } |
| 62 | typedef struct struct_of_structs_arg |
| 63 | { |
| 64 | int i1; |
| 65 | float f1; |
| 66 | struct_arg_t s1; |
| 67 | int i2; |
| 68 | } struct_of_structs_arg_t; |
| 69 | |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 70 | // CHECK: %union.transparent_u = type { i32 } |
| 71 | typedef union |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 72 | { |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 73 | int b1; |
| 74 | float b2; |
| 75 | } transparent_u __attribute__((__transparent_union__)); |
| 76 | |
| 77 | // CHECK: %struct.single_array_element_struct_arg = type { [4 x i32] } |
| 78 | typedef struct single_array_element_struct_arg |
| 79 | { |
| 80 | int i[4]; |
| 81 | } single_array_element_struct_arg_t; |
| 82 | |
| 83 | // CHECK: %struct.single_struct_element_struct_arg = type { %struct.inner } |
| 84 | // CHECK: %struct.inner = type { i32, i64 } |
| 85 | typedef struct single_struct_element_struct_arg |
| 86 | { |
| 87 | struct inner { |
| 88 | int a; |
| 89 | long b; |
| 90 | } s; |
| 91 | } single_struct_element_struct_arg_t; |
| 92 | |
| 93 | // CHECK: %struct.different_size_type_pair |
| 94 | typedef struct different_size_type_pair { |
| 95 | long l; |
| 96 | int i; |
| 97 | } different_size_type_pair; |
| 98 | |
| 99 | // CHECK: %struct.flexible_array = type { i32, [0 x i32] } |
| 100 | typedef struct flexible_array |
| 101 | { |
| 102 | int i; |
| 103 | int flexible[]; |
| 104 | } flexible_array; |
| 105 | |
| 106 | // CHECK: %struct.struct_arr16 = type { [16 x i32] } |
| 107 | typedef struct struct_arr16 |
| 108 | { |
| 109 | int arr[16]; |
| 110 | } struct_arr16; |
| 111 | |
| 112 | // CHECK: %struct.struct_arr32 = type { [32 x i32] } |
| 113 | typedef struct struct_arr32 |
| 114 | { |
| 115 | int arr[32]; |
| 116 | } struct_arr32; |
| 117 | |
| 118 | // CHECK: %struct.struct_arr33 = type { [33 x i32] } |
| 119 | typedef struct struct_arr33 |
| 120 | { |
| 121 | int arr[33]; |
| 122 | } struct_arr33; |
| 123 | |
| 124 | // CHECK: %struct.struct_char_arr32 = type { [32 x i8] } |
| 125 | typedef struct struct_char_arr32 |
| 126 | { |
| 127 | char arr[32]; |
| 128 | } struct_char_arr32; |
| 129 | |
| 130 | // CHECK-NOT: %struct.struct_char_x8 |
| 131 | typedef struct struct_char_x8 { |
| 132 | char x, y, z, w; |
| 133 | char a, b, c, d; |
| 134 | } struct_char_x8; |
| 135 | |
| 136 | // CHECK-NOT: %struct.struct_char_x4 |
| 137 | typedef struct struct_char_x4 { |
| 138 | char x, y, z, w; |
| 139 | } struct_char_x4; |
| 140 | |
| 141 | // CHECK-NOT: %struct.struct_char_x3 |
| 142 | typedef struct struct_char_x3 { |
| 143 | char x, y, z; |
| 144 | } struct_char_x3; |
| 145 | |
| 146 | // CHECK-NOT: %struct.struct_char_x2 |
| 147 | typedef struct struct_char_x2 { |
| 148 | char x, y; |
| 149 | } struct_char_x2; |
| 150 | |
| 151 | // CHECK-NOT: %struct.struct_char_x1 |
| 152 | typedef struct struct_char_x1 { |
| 153 | char x; |
| 154 | } struct_char_x1; |
| 155 | |
| 156 | // 4 registers from fields, 5 if padding included. |
| 157 | // CHECK: %struct.nested = type { i8, i64 } |
| 158 | // CHECK: %struct.num_regs_nested_struct = type { i32, %struct.nested } |
| 159 | typedef struct num_regs_nested_struct { |
| 160 | int x; |
| 161 | struct nested { |
| 162 | char z; |
| 163 | long y; |
| 164 | } inner; |
| 165 | } num_regs_nested_struct; |
| 166 | |
| 167 | // CHECK: %struct.double_nested = type { %struct.inner_inner } |
| 168 | // CHECK: %struct.inner_inner = type { i8, i32, i8 } |
| 169 | // CHECK: %struct.double_nested_struct = type { i32, %struct.double_nested, i16 } |
| 170 | typedef struct double_nested_struct { |
| 171 | int x; |
| 172 | struct double_nested { |
| 173 | struct inner_inner { |
| 174 | char y; |
| 175 | int q; |
| 176 | char z; |
| 177 | } inner_inner; |
| 178 | } inner; |
| 179 | |
| 180 | short w; |
| 181 | } double_nested_struct; |
| 182 | |
| 183 | // This is a large struct, but uses fewer registers than the limit. |
| 184 | // CHECK: %struct.large_struct_padding = type { i8, i32, i8, i32, i8, i8, i16, i16, [3 x i8], i64, i32, i8, i32, i16, i8 } |
| 185 | typedef struct large_struct_padding { |
| 186 | char e0; |
| 187 | int e1; |
| 188 | char e2; |
| 189 | int e3; |
| 190 | char e4; |
| 191 | char e5; |
| 192 | short e6; |
| 193 | short e7; |
| 194 | char e8[3]; |
| 195 | long e9; |
| 196 | int e10; |
| 197 | char e11; |
| 198 | int e12; |
| 199 | short e13; |
| 200 | char e14; |
| 201 | } large_struct_padding; |
| 202 | |
| 203 | // CHECK: %struct.int3_pair = type { <3 x i32>, <3 x i32> } |
| 204 | // The number of registers computed should be 6, not 8. |
| 205 | typedef struct int3_pair { |
| 206 | int3 dx; |
| 207 | int3 dy; |
| 208 | } int3_pair; |
| 209 | |
| 210 | // CHECK: %struct.struct_4regs = type { i32, i32, i32, i32 } |
| 211 | typedef struct struct_4regs |
| 212 | { |
| 213 | int x; |
| 214 | int y; |
| 215 | int z; |
| 216 | int w; |
| 217 | } struct_4regs; |
| 218 | |
| 219 | // CHECK: void @kernel_empty_struct_arg(%struct.empty_struct %s.coerce) |
| 220 | __kernel void kernel_empty_struct_arg(empty_struct s) { } |
| 221 | |
| 222 | // CHECK: void @kernel_single_element_struct_arg(i32 %arg1.coerce) |
| 223 | __kernel void kernel_single_element_struct_arg(single_element_struct_arg_t arg1) { } |
| 224 | |
| 225 | // CHECK: void @kernel_nested_single_element_struct_arg(i32 %arg1.coerce) |
| 226 | __kernel void kernel_nested_single_element_struct_arg(nested_single_element_struct_arg_t arg1) { } |
| 227 | |
| 228 | // CHECK: void @kernel_struct_arg(%struct.struct_arg %arg1.coerce) |
| 229 | __kernel void kernel_struct_arg(struct_arg_t arg1) { } |
| 230 | |
| 231 | // CHECK: void @kernel_struct_padding_arg(%struct.struct_padding_arg %arg1.coerce) |
| 232 | __kernel void kernel_struct_padding_arg(struct_padding_arg arg1) { } |
| 233 | |
| 234 | // CHECK: void @kernel_test_struct_of_arrays_arg(%struct.struct_of_arrays_arg %arg1.coerce) |
| 235 | __kernel void kernel_test_struct_of_arrays_arg(struct_of_arrays_arg_t arg1) { } |
| 236 | |
| 237 | // CHECK: void @kernel_struct_of_structs_arg(%struct.struct_of_structs_arg %arg1.coerce) |
| 238 | __kernel void kernel_struct_of_structs_arg(struct_of_structs_arg_t arg1) { } |
| 239 | |
| 240 | // CHECK: void @test_kernel_transparent_union_arg(%union.transparent_u %u.coerce) |
| 241 | __kernel void test_kernel_transparent_union_arg(transparent_u u) { } |
| 242 | |
| 243 | // CHECK: void @kernel_single_array_element_struct_arg(%struct.single_array_element_struct_arg %arg1.coerce) |
| 244 | __kernel void kernel_single_array_element_struct_arg(single_array_element_struct_arg_t arg1) { } |
| 245 | |
| 246 | // CHECK: void @kernel_single_struct_element_struct_arg(%struct.single_struct_element_struct_arg %arg1.coerce) |
| 247 | __kernel void kernel_single_struct_element_struct_arg(single_struct_element_struct_arg_t arg1) { } |
| 248 | |
| 249 | // CHECK: void @kernel_different_size_type_pair_arg(%struct.different_size_type_pair %arg1.coerce) |
| 250 | __kernel void kernel_different_size_type_pair_arg(different_size_type_pair arg1) { } |
| 251 | |
| 252 | // CHECK: define void @func_f32_arg(float %arg) |
| 253 | void func_f32_arg(float arg) { } |
| 254 | |
| 255 | // CHECK: define void @func_v2i16_arg(<2 x i16> %arg) |
| 256 | void func_v2i16_arg(short2 arg) { } |
| 257 | |
| 258 | // CHECK: define void @func_v3i32_arg(<3 x i32> %arg) |
| 259 | void func_v3i32_arg(int3 arg) { } |
| 260 | |
| 261 | // CHECK: define void @func_v4i32_arg(<4 x i32> %arg) |
| 262 | void func_v4i32_arg(int4 arg) { } |
| 263 | |
| 264 | // CHECK: define void @func_v16i32_arg(<16 x i32> %arg) |
| 265 | void func_v16i32_arg(int16 arg) { } |
| 266 | |
| 267 | // CHECK: define void @func_v32i32_arg(<32 x i32> %arg) |
| 268 | void func_v32i32_arg(int32 arg) { } |
| 269 | |
| 270 | // CHECK: define void @func_empty_struct_arg() |
| 271 | void func_empty_struct_arg(empty_struct empty) { } |
| 272 | |
| 273 | // CHECK: void @func_single_element_struct_arg(i32 %arg1.coerce) |
| 274 | void func_single_element_struct_arg(single_element_struct_arg_t arg1) { } |
| 275 | |
| 276 | // CHECK: void @func_nested_single_element_struct_arg(i32 %arg1.coerce) |
| 277 | void func_nested_single_element_struct_arg(nested_single_element_struct_arg_t arg1) { } |
| 278 | |
| 279 | // CHECK: void @func_struct_arg(i32 %arg1.coerce0, float %arg1.coerce1, i32 %arg1.coerce2) |
| 280 | void func_struct_arg(struct_arg_t arg1) { } |
| 281 | |
| 282 | // CHECK: void @func_struct_padding_arg(i8 %arg1.coerce0, i64 %arg1.coerce1) |
| 283 | void func_struct_padding_arg(struct_padding_arg arg1) { } |
| 284 | |
| 285 | // CHECK: define void @func_struct_char_x8([2 x i32] %arg.coerce) |
| 286 | void func_struct_char_x8(struct_char_x8 arg) { } |
| 287 | |
| 288 | // CHECK: define void @func_struct_char_x4(i32 %arg.coerce) |
| 289 | void func_struct_char_x4(struct_char_x4 arg) { } |
| 290 | |
| 291 | // CHECK: define void @func_struct_char_x3(i32 %arg.coerce) |
| 292 | void func_struct_char_x3(struct_char_x3 arg) { } |
| 293 | |
| 294 | // CHECK: define void @func_struct_char_x2(i16 %arg.coerce) |
| 295 | void func_struct_char_x2(struct_char_x2 arg) { } |
| 296 | |
| 297 | // CHECK: define void @func_struct_char_x1(i8 %arg.coerce) |
| 298 | void func_struct_char_x1(struct_char_x1 arg) { } |
| 299 | |
| 300 | // CHECK: void @func_transparent_union_arg(i32 %u.coerce) |
| 301 | void func_transparent_union_arg(transparent_u u) { } |
| 302 | |
| 303 | // CHECK: void @func_single_array_element_struct_arg([4 x i32] %arg1.coerce) |
| 304 | void func_single_array_element_struct_arg(single_array_element_struct_arg_t arg1) { } |
| 305 | |
| 306 | // CHECK: void @func_single_struct_element_struct_arg(%struct.inner %arg1.coerce) |
| 307 | void func_single_struct_element_struct_arg(single_struct_element_struct_arg_t arg1) { } |
| 308 | |
| 309 | // CHECK: void @func_different_size_type_pair_arg(i64 %arg1.coerce0, i32 %arg1.coerce1) |
| 310 | void func_different_size_type_pair_arg(different_size_type_pair arg1) { } |
| 311 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 312 | // CHECK: void @func_flexible_array_arg(%struct.flexible_array addrspace(5)* byval nocapture align 4 %arg) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 313 | void func_flexible_array_arg(flexible_array arg) { } |
| 314 | |
| 315 | // CHECK: define float @func_f32_ret() |
| 316 | float func_f32_ret() |
| 317 | { |
| 318 | return 0.0f; |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 319 | } |
| 320 | |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 321 | // CHECK: define void @func_empty_struct_ret() |
| 322 | empty_struct func_empty_struct_ret() |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 323 | { |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 324 | empty_struct s = {}; |
| 325 | return s; |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 326 | } |
| 327 | |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 328 | // CHECK: define i32 @single_element_struct_ret() |
| 329 | // CHECK: ret i32 0 |
| 330 | single_element_struct_arg_t single_element_struct_ret() |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 331 | { |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 332 | single_element_struct_arg_t s = { 0 }; |
| 333 | return s; |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 334 | } |
| 335 | |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 336 | // CHECK: define i32 @nested_single_element_struct_ret() |
| 337 | // CHECK: ret i32 0 |
| 338 | nested_single_element_struct_arg_t nested_single_element_struct_ret() |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 339 | { |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 340 | nested_single_element_struct_arg_t s = { 0 }; |
| 341 | return s; |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 342 | } |
| 343 | |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 344 | // CHECK: define %struct.struct_arg @func_struct_ret() |
| 345 | // CHECK: ret %struct.struct_arg zeroinitializer |
| 346 | struct_arg_t func_struct_ret() |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 347 | { |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 348 | struct_arg_t s = { 0 }; |
| 349 | return s; |
Matt Arsenault | 88d7da0 | 2016-08-22 19:25:59 +0000 | [diff] [blame] | 350 | } |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 351 | |
| 352 | // CHECK: define %struct.struct_padding_arg @func_struct_padding_ret() |
| 353 | // CHECK: ret %struct.struct_padding_arg zeroinitializer |
| 354 | struct_padding_arg func_struct_padding_ret() |
| 355 | { |
| 356 | struct_padding_arg s = { 0 }; |
| 357 | return s; |
| 358 | } |
| 359 | |
| 360 | // CHECK: define [2 x i32] @func_struct_char_x8_ret() |
| 361 | // CHECK: ret [2 x i32] zeroinitializer |
| 362 | struct_char_x8 func_struct_char_x8_ret() |
| 363 | { |
| 364 | struct_char_x8 s = { 0 }; |
| 365 | return s; |
| 366 | } |
| 367 | |
| 368 | // CHECK: define i32 @func_struct_char_x4_ret() |
| 369 | // CHECK: ret i32 0 |
| 370 | struct_char_x4 func_struct_char_x4_ret() |
| 371 | { |
| 372 | struct_char_x4 s = { 0 }; |
| 373 | return s; |
| 374 | } |
| 375 | |
| 376 | // CHECK: define i32 @func_struct_char_x3_ret() |
| 377 | // CHECK: ret i32 0 |
| 378 | struct_char_x3 func_struct_char_x3_ret() |
| 379 | { |
| 380 | struct_char_x3 s = { 0 }; |
| 381 | return s; |
| 382 | } |
| 383 | |
| 384 | // CHECK: define i16 @func_struct_char_x2_ret() |
| 385 | struct_char_x2 func_struct_char_x2_ret() |
| 386 | { |
| 387 | struct_char_x2 s = { 0 }; |
| 388 | return s; |
| 389 | } |
| 390 | |
| 391 | // CHECK: define i8 @func_struct_char_x1_ret() |
| 392 | // CHECK: ret i8 0 |
| 393 | struct_char_x1 func_struct_char_x1_ret() |
| 394 | { |
| 395 | struct_char_x1 s = { 0 }; |
| 396 | return s; |
| 397 | } |
| 398 | |
| 399 | // CHECK: define %struct.struct_arr16 @func_ret_struct_arr16() |
| 400 | // CHECK: ret %struct.struct_arr16 zeroinitializer |
| 401 | struct_arr16 func_ret_struct_arr16() |
| 402 | { |
| 403 | struct_arr16 s = { 0 }; |
| 404 | return s; |
| 405 | } |
| 406 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 407 | // CHECK: define void @func_ret_struct_arr32(%struct.struct_arr32 addrspace(5)* noalias nocapture sret %agg.result) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 408 | struct_arr32 func_ret_struct_arr32() |
| 409 | { |
| 410 | struct_arr32 s = { 0 }; |
| 411 | return s; |
| 412 | } |
| 413 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 414 | // CHECK: define void @func_ret_struct_arr33(%struct.struct_arr33 addrspace(5)* noalias nocapture sret %agg.result) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 415 | struct_arr33 func_ret_struct_arr33() |
| 416 | { |
| 417 | struct_arr33 s = { 0 }; |
| 418 | return s; |
| 419 | } |
| 420 | |
| 421 | // CHECK: define %struct.struct_char_arr32 @func_ret_struct_char_arr32() |
| 422 | struct_char_arr32 func_ret_struct_char_arr32() |
| 423 | { |
| 424 | struct_char_arr32 s = { 0 }; |
| 425 | return s; |
| 426 | } |
| 427 | |
| 428 | // CHECK: define i32 @func_transparent_union_ret() local_unnamed_addr #0 { |
| 429 | // CHECK: ret i32 0 |
| 430 | transparent_u func_transparent_union_ret() |
| 431 | { |
| 432 | transparent_u u = { 0 }; |
| 433 | return u; |
| 434 | } |
| 435 | |
| 436 | // CHECK: define %struct.different_size_type_pair @func_different_size_type_pair_ret() |
| 437 | different_size_type_pair func_different_size_type_pair_ret() |
| 438 | { |
| 439 | different_size_type_pair s = { 0 }; |
| 440 | return s; |
| 441 | } |
| 442 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 443 | // CHECK: define void @func_flexible_array_ret(%struct.flexible_array addrspace(5)* noalias nocapture sret %agg.result) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 444 | flexible_array func_flexible_array_ret() |
| 445 | { |
| 446 | flexible_array s = { 0 }; |
| 447 | return s; |
| 448 | } |
| 449 | |
| 450 | // CHECK: define void @func_reg_state_lo(<4 x i32> %arg0, <4 x i32> %arg1, <4 x i32> %arg2, i32 %arg3, i32 %s.coerce0, float %s.coerce1, i32 %s.coerce2) |
| 451 | void func_reg_state_lo(int4 arg0, int4 arg1, int4 arg2, int arg3, struct_arg_t s) { } |
| 452 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 453 | // CHECK: define void @func_reg_state_hi(<4 x i32> %arg0, <4 x i32> %arg1, <4 x i32> %arg2, i32 %arg3, i32 %arg4, %struct.struct_arg addrspace(5)* byval nocapture align 4 %s) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 454 | void func_reg_state_hi(int4 arg0, int4 arg1, int4 arg2, int arg3, int arg4, struct_arg_t s) { } |
| 455 | |
| 456 | // XXX - Why don't the inner structs flatten? |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 457 | // CHECK: define void @func_reg_state_num_regs_nested_struct(<4 x i32> %arg0, i32 %arg1, i32 %arg2.coerce0, %struct.nested %arg2.coerce1, i32 %arg3.coerce0, %struct.nested %arg3.coerce1, %struct.num_regs_nested_struct addrspace(5)* byval nocapture align 8 %arg4) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 458 | void func_reg_state_num_regs_nested_struct(int4 arg0, int arg1, num_regs_nested_struct arg2, num_regs_nested_struct arg3, num_regs_nested_struct arg4) { } |
| 459 | |
| 460 | // CHECK: define void @func_double_nested_struct_arg(<4 x i32> %arg0, i32 %arg1, i32 %arg2.coerce0, %struct.double_nested %arg2.coerce1, i16 %arg2.coerce2) |
| 461 | void func_double_nested_struct_arg(int4 arg0, int arg1, double_nested_struct arg2) { } |
| 462 | |
| 463 | // CHECK: define %struct.double_nested_struct @func_double_nested_struct_ret(<4 x i32> %arg0, i32 %arg1) |
| 464 | double_nested_struct func_double_nested_struct_ret(int4 arg0, int arg1) { |
| 465 | double_nested_struct s = { 0 }; |
| 466 | return s; |
| 467 | } |
| 468 | |
| 469 | // CHECK: define void @func_large_struct_padding_arg_direct(i8 %arg.coerce0, i32 %arg.coerce1, i8 %arg.coerce2, i32 %arg.coerce3, i8 %arg.coerce4, i8 %arg.coerce5, i16 %arg.coerce6, i16 %arg.coerce7, [3 x i8] %arg.coerce8, i64 %arg.coerce9, i32 %arg.coerce10, i8 %arg.coerce11, i32 %arg.coerce12, i16 %arg.coerce13, i8 %arg.coerce14) |
| 470 | void func_large_struct_padding_arg_direct(large_struct_padding arg) { } |
| 471 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 472 | // CHECK: define void @func_large_struct_padding_arg_store(%struct.large_struct_padding addrspace(1)* nocapture %out, %struct.large_struct_padding addrspace(5)* byval nocapture readonly align 8 %arg) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 473 | void func_large_struct_padding_arg_store(global large_struct_padding* out, large_struct_padding arg) { |
| 474 | *out = arg; |
| 475 | } |
| 476 | |
| 477 | // CHECK: define void @v3i32_reg_count(<3 x i32> %arg1, <3 x i32> %arg2, <3 x i32> %arg3, <3 x i32> %arg4, i32 %arg5.coerce0, float %arg5.coerce1, i32 %arg5.coerce2) |
| 478 | void v3i32_reg_count(int3 arg1, int3 arg2, int3 arg3, int3 arg4, struct_arg_t arg5) { } |
| 479 | |
| 480 | // Function signature from blender, nothing should be passed byval. The v3i32 |
| 481 | // should not count as 4 passed registers. |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 482 | // CHECK: define void @v3i32_pair_reg_count(%struct.int3_pair addrspace(5)* nocapture %arg0, <3 x i32> %arg1.coerce0, <3 x i32> %arg1.coerce1, <3 x i32> %arg2, <3 x i32> %arg3.coerce0, <3 x i32> %arg3.coerce1, <3 x i32> %arg4, float %arg5) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 483 | void v3i32_pair_reg_count(int3_pair *arg0, int3_pair arg1, int3 arg2, int3_pair arg3, int3 arg4, float arg5) { } |
| 484 | |
| 485 | // Each short4 should fit pack into 2 registers. |
| 486 | // CHECK: define void @v4i16_reg_count(<4 x i16> %arg0, <4 x i16> %arg1, <4 x i16> %arg2, <4 x i16> %arg3, <4 x i16> %arg4, <4 x i16> %arg5, i32 %arg6.coerce0, i32 %arg6.coerce1, i32 %arg6.coerce2, i32 %arg6.coerce3) |
| 487 | void v4i16_reg_count(short4 arg0, short4 arg1, short4 arg2, short4 arg3, |
| 488 | short4 arg4, short4 arg5, struct_4regs arg6) { } |
| 489 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 490 | // CHECK: define void @v4i16_pair_reg_count_over(<4 x i16> %arg0, <4 x i16> %arg1, <4 x i16> %arg2, <4 x i16> %arg3, <4 x i16> %arg4, <4 x i16> %arg5, <4 x i16> %arg6, %struct.struct_4regs addrspace(5)* byval nocapture align 4 %arg7) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 491 | void v4i16_pair_reg_count_over(short4 arg0, short4 arg1, short4 arg2, short4 arg3, |
| 492 | short4 arg4, short4 arg5, short4 arg6, struct_4regs arg7) { } |
| 493 | |
| 494 | // CHECK: define void @v3i16_reg_count(<3 x i16> %arg0, <3 x i16> %arg1, <3 x i16> %arg2, <3 x i16> %arg3, <3 x i16> %arg4, <3 x i16> %arg5, i32 %arg6.coerce0, i32 %arg6.coerce1, i32 %arg6.coerce2, i32 %arg6.coerce3) |
| 495 | void v3i16_reg_count(short3 arg0, short3 arg1, short3 arg2, short3 arg3, |
| 496 | short3 arg4, short3 arg5, struct_4regs arg6) { } |
| 497 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 498 | // CHECK: define void @v3i16_reg_count_over(<3 x i16> %arg0, <3 x i16> %arg1, <3 x i16> %arg2, <3 x i16> %arg3, <3 x i16> %arg4, <3 x i16> %arg5, <3 x i16> %arg6, %struct.struct_4regs addrspace(5)* byval nocapture align 4 %arg7) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 499 | void v3i16_reg_count_over(short3 arg0, short3 arg1, short3 arg2, short3 arg3, |
| 500 | short3 arg4, short3 arg5, short3 arg6, struct_4regs arg7) { } |
| 501 | |
| 502 | // CHECK: define void @v2i16_reg_count(<2 x i16> %arg0, <2 x i16> %arg1, <2 x i16> %arg2, <2 x i16> %arg3, <2 x i16> %arg4, <2 x i16> %arg5, <2 x i16> %arg6, <2 x i16> %arg7, <2 x i16> %arg8, <2 x i16> %arg9, <2 x i16> %arg10, <2 x i16> %arg11, i32 %arg13.coerce0, i32 %arg13.coerce1, i32 %arg13.coerce2, i32 %arg13.coerce3) |
| 503 | void v2i16_reg_count(short2 arg0, short2 arg1, short2 arg2, short2 arg3, |
| 504 | short2 arg4, short2 arg5, short2 arg6, short2 arg7, |
| 505 | short2 arg8, short2 arg9, short2 arg10, short2 arg11, |
| 506 | struct_4regs arg13) { } |
| 507 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 508 | // CHECK: define void @v2i16_reg_count_over(<2 x i16> %arg0, <2 x i16> %arg1, <2 x i16> %arg2, <2 x i16> %arg3, <2 x i16> %arg4, <2 x i16> %arg5, <2 x i16> %arg6, <2 x i16> %arg7, <2 x i16> %arg8, <2 x i16> %arg9, <2 x i16> %arg10, <2 x i16> %arg11, <2 x i16> %arg12, %struct.struct_4regs addrspace(5)* byval nocapture align 4 %arg13) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 509 | void v2i16_reg_count_over(short2 arg0, short2 arg1, short2 arg2, short2 arg3, |
| 510 | short2 arg4, short2 arg5, short2 arg6, short2 arg7, |
| 511 | short2 arg8, short2 arg9, short2 arg10, short2 arg11, |
| 512 | short2 arg12, struct_4regs arg13) { } |
| 513 | |
| 514 | // CHECK: define void @v2i8_reg_count(<2 x i8> %arg0, <2 x i8> %arg1, <2 x i8> %arg2, <2 x i8> %arg3, <2 x i8> %arg4, <2 x i8> %arg5, i32 %arg6.coerce0, i32 %arg6.coerce1, i32 %arg6.coerce2, i32 %arg6.coerce3) |
| 515 | void v2i8_reg_count(char2 arg0, char2 arg1, char2 arg2, char2 arg3, |
| 516 | char2 arg4, char2 arg5, struct_4regs arg6) { } |
| 517 | |
Yaxun Liu | f5f45e5 | 2018-02-02 16:08:24 +0000 | [diff] [blame] | 518 | // CHECK: define void @v2i8_reg_count_over(<2 x i8> %arg0, <2 x i8> %arg1, <2 x i8> %arg2, <2 x i8> %arg3, <2 x i8> %arg4, <2 x i8> %arg5, i32 %arg6, %struct.struct_4regs addrspace(5)* byval nocapture align 4 %arg7) |
Matt Arsenault | 3fe7395 | 2017-08-09 21:44:58 +0000 | [diff] [blame] | 519 | void v2i8_reg_count_over(char2 arg0, char2 arg1, char2 arg2, char2 arg3, |
| 520 | char2 arg4, char2 arg5, int arg6, struct_4regs arg7) { } |
| 521 | |
| 522 | // CHECK: define void @num_regs_left_64bit_aggregate(<4 x i32> %arg0, <4 x i32> %arg1, <4 x i32> %arg2, <3 x i32> %arg3, [2 x i32] %arg4.coerce, i32 %arg5) |
| 523 | void num_regs_left_64bit_aggregate(int4 arg0, int4 arg1, int4 arg2, int3 arg3, struct_char_x8 arg4, int arg5) { } |