| #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 tint_module_vars_struct { |
| device tint_array<int, 10>* output; |
| }; |
| |
| kernel void foo(device tint_array<int, 10>* output [[buffer(0)]]) { |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.output=output}; |
| int i = 0; |
| { |
| uint2 tint_loop_idx = 0u; |
| while(true) { |
| if (all((tint_loop_idx == uint2(4294967295u)))) { |
| break; |
| } |
| int x = (*tint_module_vars.output)[min(uint(i), 9u)]; |
| { |
| 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); |
| int x_1 = (*tint_module_vars.output)[min(uint(x), 9u)]; |
| i = as_type<int>((as_type<uint>(i) + as_type<uint>(x_1))); |
| if ((i > 10)) { break; } |
| } |
| continue; |
| } |
| } |
| (*tint_module_vars.output)[0u] = i; |
| } |