| #include <metal_stdlib> |
| using namespace metal; |
| |
| template<typename T, size_t N> |
| struct tint_array { |
| const constant T& operator[](size_t i) const constant { return elements[i]; } |
| device T& operator[](size_t i) device { return elements[i]; } |
| const device T& operator[](size_t i) const device { return elements[i]; } |
| thread T& operator[](size_t i) thread { return elements[i]; } |
| const thread T& operator[](size_t i) const thread { return elements[i]; } |
| threadgroup T& operator[](size_t i) threadgroup { return elements[i]; } |
| const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; } |
| T elements[N]; |
| }; |
| |
| struct S { |
| /* 0x0000 */ tint_array<int4, 4> arr; |
| }; |
| |
| struct tint_module_vars_struct { |
| thread tint_array<int4, 4>* src_private; |
| threadgroup tint_array<int4, 4>* src_workgroup; |
| const constant S* src_uniform; |
| device S* src_storage; |
| threadgroup tint_array<int4, 4>* dst; |
| threadgroup tint_array<tint_array<tint_array<int, 2>, 3>, 4>* dst_nested; |
| }; |
| |
| struct tint_symbol_4 { |
| tint_array<int4, 4> tint_symbol_1; |
| tint_array<int4, 4> tint_symbol_2; |
| tint_array<tint_array<tint_array<int, 2>, 3>, 4> tint_symbol_3; |
| }; |
| |
| tint_array<int4, 4> ret_arr() { |
| return tint_array<int4, 4>{}; |
| } |
| |
| S ret_struct_arr() { |
| return S{}; |
| } |
| |
| void foo(tint_array<int4, 4> src_param, tint_module_vars_struct tint_module_vars) { |
| tint_array<int4, 4> src_function = {}; |
| (*tint_module_vars.dst) = tint_array<int4, 4>{int4(1), int4(2), int4(3), int4(3)}; |
| (*tint_module_vars.dst) = src_param; |
| (*tint_module_vars.dst) = ret_arr(); |
| tint_array<int4, 4> const src_let = tint_array<int4, 4>{}; |
| (*tint_module_vars.dst) = src_let; |
| (*tint_module_vars.dst) = src_function; |
| (*tint_module_vars.dst) = (*tint_module_vars.src_private); |
| (*tint_module_vars.dst) = (*tint_module_vars.src_workgroup); |
| (*tint_module_vars.dst) = ret_struct_arr().arr; |
| (*tint_module_vars.dst) = (*tint_module_vars.src_uniform).arr; |
| (*tint_module_vars.dst) = (*tint_module_vars.src_storage).arr; |
| tint_array<tint_array<tint_array<int, 2>, 3>, 4> src_nested = {}; |
| (*tint_module_vars.dst_nested) = src_nested; |
| } |
| |
| void tint_symbol_inner(uint tint_local_index, tint_module_vars_struct tint_module_vars) { |
| { |
| uint v = 0u; |
| v = tint_local_index; |
| while(true) { |
| uint const v_1 = v; |
| if ((v_1 >= 4u)) { |
| break; |
| } |
| (*tint_module_vars.src_workgroup)[v_1] = int4(0); |
| (*tint_module_vars.dst)[v_1] = int4(0); |
| { |
| v = (v_1 + 1u); |
| } |
| continue; |
| } |
| } |
| { |
| uint v_2 = 0u; |
| v_2 = tint_local_index; |
| while(true) { |
| uint const v_3 = v_2; |
| if ((v_3 >= 24u)) { |
| break; |
| } |
| (*tint_module_vars.dst_nested)[(v_3 / 6u)][((v_3 / 2u) % 3u)][(v_3 % 2u)] = 0; |
| { |
| v_2 = (v_3 + 1u); |
| } |
| continue; |
| } |
| } |
| threadgroup_barrier(mem_flags::mem_threadgroup); |
| tint_array<int4, 4> const val = tint_array<int4, 4>{}; |
| foo(val, tint_module_vars); |
| } |
| |
| kernel void tint_symbol(uint tint_local_index [[thread_index_in_threadgroup]], threadgroup tint_symbol_4* v_4 [[threadgroup(0)]], const constant S* src_uniform [[buffer(0)]], device S* src_storage [[buffer(1)]]) { |
| thread tint_array<int4, 4> src_private = {}; |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.src_private=(&src_private), .src_workgroup=(&(*v_4).tint_symbol_1), .src_uniform=src_uniform, .src_storage=src_storage, .dst=(&(*v_4).tint_symbol_2), .dst_nested=(&(*v_4).tint_symbol_3)}; |
| tint_symbol_inner(tint_local_index, tint_module_vars); |
| } |