| #include <metal_stdlib> |
| using namespace metal; |
| |
| struct S { |
| int a; |
| float4 b; |
| float2x2 c; |
| }; |
| |
| struct tint_module_vars_struct { |
| device S* v; |
| thread uint* i; |
| }; |
| |
| 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]; |
| }; |
| |
| int idx1(tint_module_vars_struct tint_module_vars) { |
| (*tint_module_vars.i) = ((*tint_module_vars.i) + 1u); |
| return 1; |
| } |
| |
| int idx2(tint_module_vars_struct tint_module_vars) { |
| (*tint_module_vars.i) = ((*tint_module_vars.i) + 2u); |
| return 1; |
| } |
| |
| int idx3(tint_module_vars_struct tint_module_vars) { |
| (*tint_module_vars.i) = ((*tint_module_vars.i) + 3u); |
| return 1; |
| } |
| |
| void foo(tint_module_vars_struct tint_module_vars) { |
| tint_array<float, 4> a = tint_array<float, 4>{}; |
| { |
| uint2 tint_loop_idx = 0u; |
| thread float* const v_1 = (&a[min(uint(idx1(tint_module_vars)), 3u)]); |
| (*v_1) = ((*v_1) * 2.0f); |
| while(true) { |
| if (all((tint_loop_idx == uint2(4294967295u)))) { |
| break; |
| } |
| if ((a[min(uint(idx2(tint_module_vars)), 3u)] < 10.0f)) { |
| } else { |
| break; |
| } |
| { |
| uint const tint_low_inc = (tint_loop_idx.x + 1u); |
| tint_loop_idx.x = tint_low_inc; |
| uint const tint_carry = uint((tint_low_inc == 0u)); |
| tint_loop_idx.y = (tint_loop_idx.y + tint_carry); |
| thread float* const v_2 = (&a[min(uint(idx3(tint_module_vars)), 3u)]); |
| (*v_2) = ((*v_2) + 1.0f); |
| } |
| continue; |
| } |
| } |
| } |