David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 1 | #include <metal_stdlib> |
| 2 | |
| 3 | using namespace metal; |
Ben Clayton | f47887d | 2022-06-24 17:01:59 +0000 | [diff] [blame] | 4 | |
| 5 | template<typename T, size_t N> |
| 6 | struct tint_array { |
| 7 | const constant T& operator[](size_t i) const constant { return elements[i]; } |
| 8 | device T& operator[](size_t i) device { return elements[i]; } |
| 9 | const device T& operator[](size_t i) const device { return elements[i]; } |
| 10 | thread T& operator[](size_t i) thread { return elements[i]; } |
| 11 | const thread T& operator[](size_t i) const thread { return elements[i]; } |
| 12 | threadgroup T& operator[](size_t i) threadgroup { return elements[i]; } |
| 13 | const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; } |
| 14 | T elements[N]; |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 15 | }; |
Ben Clayton | 8ec32a6 | 2022-02-09 23:55:51 +0000 | [diff] [blame] | 16 | |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 17 | struct tint_private_vars_struct { |
| 18 | tint_array<int4, 4> src_private; |
| 19 | }; |
| 20 | |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 21 | struct S { |
Ben Clayton | f47887d | 2022-06-24 17:01:59 +0000 | [diff] [blame] | 22 | /* 0x0000 */ tint_array<int4, 4> arr; |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 23 | }; |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 24 | |
Ben Clayton | f47887d | 2022-06-24 17:01:59 +0000 | [diff] [blame] | 25 | tint_array<int4, 4> ret_arr() { |
| 26 | tint_array<int4, 4> const tint_symbol_1 = tint_array<int4, 4>{}; |
Antonio Maiorano | 93baaae | 2022-03-15 15:35:13 +0000 | [diff] [blame] | 27 | return tint_symbol_1; |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | S ret_struct_arr() { |
dan sinclair | 3abad2c | 2022-08-11 02:28:01 +0000 | [diff] [blame] | 31 | S const tint_symbol_2 = S{}; |
Antonio Maiorano | 93baaae | 2022-03-15 15:35:13 +0000 | [diff] [blame] | 32 | return tint_symbol_2; |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 33 | } |
| 34 | |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 35 | void foo(tint_array<int4, 4> src_param, thread tint_private_vars_struct* const tint_private_vars, threadgroup tint_array<int4, 4>* const tint_symbol_4, const constant S* const tint_symbol_5, device S* const tint_symbol_6) { |
Ben Clayton | f47887d | 2022-06-24 17:01:59 +0000 | [diff] [blame] | 36 | tint_array<int4, 4> src_function = {}; |
| 37 | tint_array<int4, 4> dst = {}; |
| 38 | tint_array<int4, 4> const tint_symbol_3 = tint_array<int4, 4>{int4(1), int4(2), int4(3), int4(3)}; |
Antonio Maiorano | 93baaae | 2022-03-15 15:35:13 +0000 | [diff] [blame] | 39 | dst = tint_symbol_3; |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 40 | dst = src_param; |
| 41 | dst = ret_arr(); |
Ben Clayton | f47887d | 2022-06-24 17:01:59 +0000 | [diff] [blame] | 42 | tint_array<int4, 4> const src_let = tint_array<int4, 4>{}; |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 43 | dst = src_let; |
| 44 | dst = src_function; |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 45 | dst = (*(tint_private_vars)).src_private; |
| 46 | dst = *(tint_symbol_4); |
Antonio Maiorano | 93baaae | 2022-03-15 15:35:13 +0000 | [diff] [blame] | 47 | S const tint_symbol = ret_struct_arr(); |
| 48 | dst = tint_symbol.arr; |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 49 | dst = (*(tint_symbol_5)).arr; |
James Price | e548db9 | 2021-10-28 15:00:39 +0000 | [diff] [blame] | 50 | dst = (*(tint_symbol_6)).arr; |
Ben Clayton | f47887d | 2022-06-24 17:01:59 +0000 | [diff] [blame] | 51 | tint_array<tint_array<tint_array<int, 2>, 3>, 4> dst_nested = {}; |
| 52 | tint_array<tint_array<tint_array<int, 2>, 3>, 4> src_nested = {}; |
David Neto | 1e19b55 | 2021-06-17 09:10:04 +0000 | [diff] [blame] | 53 | dst_nested = src_nested; |
| 54 | } |
| 55 | |