tint/writer/msl: Generate an array<T,N> helper

And remove the WrapArraysInStructs transform.

Wrapping arrays in structures becomes troublesome for `const` arrays, as
currently WGSL does not allow `const` structures.

MSL 2.0+ has a builtin array<> helper, but we're targetting MSL 1.2, so
we have to emit our own. Fortunately, it can be done with a few lines of
templated code.

This produces significantly cleaner output.

Change-Id: Ifc92ef21e09befa252a07c856c4b5afdc51cc2e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94540
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton
2022-06-24 17:01:59 +00:00
committed by Dawn LUCI CQ
parent 3c054304a8
commit f47887d207
218 changed files with 3637 additions and 2269 deletions

View File

@@ -1,16 +1,25 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
/* 0x0000 */ int4 arr[4];
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_wrapper arr;
/* 0x0000 */ tint_array<int4, 4> arr;
};
tint_array_wrapper ret_arr() {
tint_array_wrapper const tint_symbol_1 = {.arr={}};
tint_array<int4, 4> ret_arr() {
tint_array<int4, 4> const tint_symbol_1 = tint_array<int4, 4>{};
return tint_symbol_1;
}
@@ -19,26 +28,14 @@ S ret_struct_arr() {
return tint_symbol_2;
}
struct tint_array_wrapper_3 {
int arr[2];
};
struct tint_array_wrapper_2 {
tint_array_wrapper_3 arr[3];
};
struct tint_array_wrapper_1 {
tint_array_wrapper_2 arr[4];
};
void foo(tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, const constant S* const tint_symbol_6, device S* const tint_symbol_7) {
tint_array_wrapper src_function = {};
tint_array_wrapper dst = {};
tint_array_wrapper const tint_symbol_3 = {.arr={int4(1), int4(2), int4(3), int4(3)}};
void foo(tint_array<int4, 4> src_param, thread tint_array<int4, 4>* const tint_symbol_4, threadgroup tint_array<int4, 4>* const tint_symbol_5, const constant S* const tint_symbol_6, device S* const tint_symbol_7) {
tint_array<int4, 4> src_function = {};
tint_array<int4, 4> dst = {};
tint_array<int4, 4> const tint_symbol_3 = tint_array<int4, 4>{int4(1), int4(2), int4(3), int4(3)};
dst = tint_symbol_3;
dst = src_param;
dst = ret_arr();
tint_array_wrapper const src_let = {.arr={}};
tint_array<int4, 4> const src_let = tint_array<int4, 4>{};
dst = src_let;
dst = src_function;
dst = *(tint_symbol_4);
@@ -47,8 +44,8 @@ void foo(tint_array_wrapper src_param, thread tint_array_wrapper* const tint_sym
dst = tint_symbol.arr;
dst = (*(tint_symbol_6)).arr;
dst = (*(tint_symbol_7)).arr;
tint_array_wrapper_1 dst_nested = {};
tint_array_wrapper_1 src_nested = {};
tint_array<tint_array<tint_array<int, 2>, 3>, 4> dst_nested = {};
tint_array<tint_array<tint_array<int, 2>, 3>, 4> src_nested = {};
dst_nested = src_nested;
}

View File

@@ -1,28 +1,25 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
/* 0x0000 */ int4 arr[4];
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_wrapper arr;
/* 0x0000 */ tint_array<int4, 4> arr;
};
struct tint_array_wrapper_3 {
int arr[2];
};
struct tint_array_wrapper_2 {
tint_array_wrapper_3 arr[3];
};
struct tint_array_wrapper_1 {
tint_array_wrapper_2 arr[4];
};
tint_array_wrapper ret_arr() {
tint_array_wrapper const tint_symbol_1 = {.arr={}};
tint_array<int4, 4> ret_arr() {
tint_array<int4, 4> const tint_symbol_1 = tint_array<int4, 4>{};
return tint_symbol_1;
}
@@ -31,13 +28,13 @@ S ret_struct_arr() {
return tint_symbol_2;
}
void foo(tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_4, thread tint_array_wrapper* const tint_symbol_5, threadgroup tint_array_wrapper* const tint_symbol_6, const constant S* const tint_symbol_7, device S* const tint_symbol_8, thread tint_array_wrapper_1* const tint_symbol_9) {
tint_array_wrapper src_function = {};
tint_array_wrapper const tint_symbol_3 = {.arr={int4(1), int4(2), int4(3), int4(3)}};
void foo(tint_array<int4, 4> src_param, thread tint_array<int4, 4>* const tint_symbol_4, thread tint_array<int4, 4>* const tint_symbol_5, threadgroup tint_array<int4, 4>* const tint_symbol_6, const constant S* const tint_symbol_7, device S* const tint_symbol_8, thread tint_array<tint_array<tint_array<int, 2>, 3>, 4>* const tint_symbol_9) {
tint_array<int4, 4> src_function = {};
tint_array<int4, 4> const tint_symbol_3 = tint_array<int4, 4>{int4(1), int4(2), int4(3), int4(3)};
*(tint_symbol_4) = tint_symbol_3;
*(tint_symbol_4) = src_param;
*(tint_symbol_4) = ret_arr();
tint_array_wrapper const src_let = {.arr={}};
tint_array<int4, 4> const src_let = tint_array<int4, 4>{};
*(tint_symbol_4) = src_let;
*(tint_symbol_4) = src_function;
*(tint_symbol_4) = *(tint_symbol_5);
@@ -46,7 +43,7 @@ void foo(tint_array_wrapper src_param, thread tint_array_wrapper* const tint_sym
*(tint_symbol_4) = tint_symbol.arr;
*(tint_symbol_4) = (*(tint_symbol_7)).arr;
*(tint_symbol_4) = (*(tint_symbol_8)).arr;
tint_array_wrapper_1 src_nested = {};
tint_array<tint_array<tint_array<int, 2>, 3>, 4> src_nested = {};
*(tint_symbol_9) = src_nested;
}

View File

@@ -1,32 +1,29 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
/* 0x0000 */ int4 arr[4];
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_wrapper arr;
};
struct tint_array_wrapper_3 {
/* 0x0000 */ int arr[2];
};
struct tint_array_wrapper_2 {
/* 0x0000 */ tint_array_wrapper_3 arr[3];
};
struct tint_array_wrapper_1 {
/* 0x0000 */ tint_array_wrapper_2 arr[4];
/* 0x0000 */ tint_array<int4, 4> arr;
};
struct S_nested {
/* 0x0000 */ tint_array_wrapper_1 arr;
/* 0x0000 */ tint_array<tint_array<tint_array<int, 2>, 3>, 4> arr;
};
tint_array_wrapper ret_arr() {
tint_array_wrapper const tint_symbol_2 = {.arr={}};
tint_array<int4, 4> ret_arr() {
tint_array<int4, 4> const tint_symbol_2 = tint_array<int4, 4>{};
return tint_symbol_2;
}
@@ -35,14 +32,14 @@ S ret_struct_arr() {
return tint_symbol_3;
}
void foo(tint_array_wrapper src_param, device S* const tint_symbol_5, thread tint_array_wrapper* const tint_symbol_6, threadgroup tint_array_wrapper* const tint_symbol_7, const constant S* const tint_symbol_8, device S* const tint_symbol_9, device S_nested* const tint_symbol_10) {
tint_array_wrapper src_function = {};
tint_array_wrapper const tint_symbol_4 = {.arr={int4(1), int4(2), int4(3), int4(3)}};
void foo(tint_array<int4, 4> src_param, device S* const tint_symbol_5, thread tint_array<int4, 4>* const tint_symbol_6, threadgroup tint_array<int4, 4>* const tint_symbol_7, const constant S* const tint_symbol_8, device S* const tint_symbol_9, device S_nested* const tint_symbol_10) {
tint_array<int4, 4> src_function = {};
tint_array<int4, 4> const tint_symbol_4 = tint_array<int4, 4>{int4(1), int4(2), int4(3), int4(3)};
(*(tint_symbol_5)).arr = tint_symbol_4;
(*(tint_symbol_5)).arr = src_param;
tint_array_wrapper const tint_symbol = ret_arr();
tint_array<int4, 4> const tint_symbol = ret_arr();
(*(tint_symbol_5)).arr = tint_symbol;
tint_array_wrapper const src_let = {.arr={}};
tint_array<int4, 4> const src_let = tint_array<int4, 4>{};
(*(tint_symbol_5)).arr = src_let;
(*(tint_symbol_5)).arr = src_function;
(*(tint_symbol_5)).arr = *(tint_symbol_6);
@@ -51,7 +48,7 @@ void foo(tint_array_wrapper src_param, device S* const tint_symbol_5, thread tin
(*(tint_symbol_5)).arr = tint_symbol_1.arr;
(*(tint_symbol_5)).arr = (*(tint_symbol_8)).arr;
(*(tint_symbol_5)).arr = (*(tint_symbol_9)).arr;
tint_array_wrapper_1 src_nested = {};
tint_array<tint_array<tint_array<int, 2>, 3>, 4> src_nested = {};
(*(tint_symbol_10)).arr = src_nested;
}

View File

@@ -1,27 +1,32 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
int arr[4];
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 {
tint_array_wrapper arr;
};
struct tint_array_wrapper_1 {
tint_array_wrapper arr[2];
tint_array<int, 4> arr;
};
void foo() {
tint_array_wrapper const src = {.arr={}};
tint_array_wrapper dst = {};
tint_array<int, 4> const src = tint_array<int, 4>{};
tint_array<int, 4> dst = {};
S dst_struct = {};
tint_array_wrapper_1 dst_array = {};
tint_array<tint_array<int, 4>, 2> dst_array = {};
dst_struct.arr = src;
dst_array.arr[1] = src;
dst_array[1] = src;
dst = src;
dst_struct.arr = src;
dst_array.arr[0] = src;
dst_array[0] = src;
}

View File

@@ -1,28 +1,25 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
/* 0x0000 */ int4 arr[4];
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_wrapper arr;
/* 0x0000 */ tint_array<int4, 4> arr;
};
struct tint_array_wrapper_3 {
int arr[2];
};
struct tint_array_wrapper_2 {
tint_array_wrapper_3 arr[3];
};
struct tint_array_wrapper_1 {
tint_array_wrapper_2 arr[4];
};
tint_array_wrapper ret_arr() {
tint_array_wrapper const tint_symbol_1 = {.arr={}};
tint_array<int4, 4> ret_arr() {
tint_array<int4, 4> const tint_symbol_1 = tint_array<int4, 4>{};
return tint_symbol_1;
}
@@ -31,13 +28,13 @@ S ret_struct_arr() {
return tint_symbol_2;
}
void foo(tint_array_wrapper src_param, threadgroup tint_array_wrapper* const tint_symbol_4, thread tint_array_wrapper* const tint_symbol_5, threadgroup tint_array_wrapper* const tint_symbol_6, const constant S* const tint_symbol_7, device S* const tint_symbol_8, threadgroup tint_array_wrapper_1* const tint_symbol_9) {
tint_array_wrapper src_function = {};
tint_array_wrapper const tint_symbol_3 = {.arr={int4(1), int4(2), int4(3), int4(3)}};
void foo(tint_array<int4, 4> src_param, threadgroup tint_array<int4, 4>* const tint_symbol_4, thread tint_array<int4, 4>* const tint_symbol_5, threadgroup tint_array<int4, 4>* const tint_symbol_6, const constant S* const tint_symbol_7, device S* const tint_symbol_8, threadgroup tint_array<tint_array<tint_array<int, 2>, 3>, 4>* const tint_symbol_9) {
tint_array<int4, 4> src_function = {};
tint_array<int4, 4> const tint_symbol_3 = tint_array<int4, 4>{int4(1), int4(2), int4(3), int4(3)};
*(tint_symbol_4) = tint_symbol_3;
*(tint_symbol_4) = src_param;
*(tint_symbol_4) = ret_arr();
tint_array_wrapper const src_let = {.arr={}};
tint_array<int4, 4> const src_let = tint_array<int4, 4>{};
*(tint_symbol_4) = src_let;
*(tint_symbol_4) = src_function;
*(tint_symbol_4) = *(tint_symbol_5);
@@ -46,7 +43,7 @@ void foo(tint_array_wrapper src_param, threadgroup tint_array_wrapper* const tin
*(tint_symbol_4) = tint_symbol.arr;
*(tint_symbol_4) = (*(tint_symbol_7)).arr;
*(tint_symbol_4) = (*(tint_symbol_8)).arr;
tint_array_wrapper_1 src_nested = {};
tint_array<tint_array<tint_array<int, 2>, 3>, 4> src_nested = {};
*(tint_symbol_9) = src_nested;
}

View File

@@ -1,34 +1,35 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
float arr[4];
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];
};
float f1(tint_array_wrapper a) {
return a.arr[3];
float f1(tint_array<float, 4> a) {
return a[3];
}
struct tint_array_wrapper_1 {
tint_array_wrapper arr[3];
};
float f2(tint_array_wrapper_1 a) {
return a.arr[2].arr[3];
float f2(tint_array<tint_array<float, 4>, 3> a) {
return a[2][3];
}
struct tint_array_wrapper_2 {
tint_array_wrapper_1 arr[2];
};
float f3(tint_array_wrapper_2 a) {
return a.arr[1].arr[2].arr[3];
float f3(tint_array<tint_array<tint_array<float, 4>, 3>, 2> a) {
return a[1][2][3];
}
kernel void tint_symbol() {
tint_array_wrapper const a1 = {.arr={}};
tint_array_wrapper_1 const a2 = {.arr={}};
tint_array_wrapper_2 const a3 = {.arr={}};
tint_array<float, 4> const a1 = tint_array<float, 4>{};
tint_array<tint_array<float, 4>, 3> const a2 = tint_array<tint_array<float, 4>, 3>{};
tint_array<tint_array<tint_array<float, 4>, 3>, 2> const a3 = tint_array<tint_array<tint_array<float, 4>, 3>, 2>{};
float const v1 = f1(a1);
float const v2 = f2(a2);
float const v3 = f3(a3);

View File

@@ -1,42 +1,43 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
float arr[4];
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];
};
tint_array_wrapper f1() {
tint_array_wrapper const tint_symbol_6 = {.arr={}};
tint_array<float, 4> f1() {
tint_array<float, 4> const tint_symbol_6 = tint_array<float, 4>{};
return tint_symbol_6;
}
struct tint_array_wrapper_1 {
tint_array_wrapper arr[3];
};
tint_array_wrapper_1 f2() {
tint_array_wrapper const tint_symbol_1 = f1();
tint_array_wrapper const tint_symbol_2 = f1();
tint_array_wrapper const tint_symbol_3 = f1();
tint_array_wrapper_1 const tint_symbol_7 = {.arr={tint_symbol_1, tint_symbol_2, tint_symbol_3}};
tint_array<tint_array<float, 4>, 3> f2() {
tint_array<float, 4> const tint_symbol_1 = f1();
tint_array<float, 4> const tint_symbol_2 = f1();
tint_array<float, 4> const tint_symbol_3 = f1();
tint_array<tint_array<float, 4>, 3> const tint_symbol_7 = tint_array<tint_array<float, 4>, 3>{tint_symbol_1, tint_symbol_2, tint_symbol_3};
return tint_symbol_7;
}
struct tint_array_wrapper_2 {
tint_array_wrapper_1 arr[2];
};
tint_array_wrapper_2 f3() {
tint_array_wrapper_1 const tint_symbol_4 = f2();
tint_array_wrapper_1 const tint_symbol_5 = f2();
tint_array_wrapper_2 const tint_symbol_8 = {.arr={tint_symbol_4, tint_symbol_5}};
tint_array<tint_array<tint_array<float, 4>, 3>, 2> f3() {
tint_array<tint_array<float, 4>, 3> const tint_symbol_4 = f2();
tint_array<tint_array<float, 4>, 3> const tint_symbol_5 = f2();
tint_array<tint_array<tint_array<float, 4>, 3>, 2> const tint_symbol_8 = tint_array<tint_array<tint_array<float, 4>, 3>, 2>{tint_symbol_4, tint_symbol_5};
return tint_symbol_8;
}
kernel void tint_symbol() {
tint_array_wrapper const a1 = f1();
tint_array_wrapper_1 const a2 = f2();
tint_array_wrapper_2 const a3 = f3();
tint_array<float, 4> const a1 = f1();
tint_array<tint_array<float, 4>, 3> const a2 = f2();
tint_array<tint_array<tint_array<float, 4>, 3>, 2> const a3 = f3();
return;
}

View File

@@ -1,19 +1,28 @@
#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];
};
constant int slen = 4;
constant uint ulen = 4u;
struct tint_array_wrapper {
float arr[4];
};
fragment void tint_symbol() {
tint_array_wrapper signed_literal = {};
tint_array_wrapper unsigned_literal = {};
tint_array_wrapper signed_constant = {};
tint_array_wrapper unsigned_constant = {};
tint_array<float, 4> signed_literal = {};
tint_array<float, 4> unsigned_literal = {};
tint_array<float, 4> signed_constant = {};
tint_array<float, 4> unsigned_constant = {};
signed_literal = unsigned_constant;
signed_constant = unsigned_literal;
return;

View File

@@ -1,40 +1,41 @@
#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 strided_arr {
/* 0x0000 */ float el;
/* 0x0004 */ int8_t tint_pad[4];
};
struct tint_array_wrapper {
/* 0x0000 */ strided_arr arr[2];
};
struct tint_array_wrapper_1 {
/* 0x0000 */ tint_array_wrapper arr[3];
/* 0x0004 */ tint_array<int8_t, 4> tint_pad;
};
struct strided_arr_1 {
/* 0x0000 */ tint_array_wrapper_1 el;
/* 0x0030 */ int8_t tint_pad_1[80];
};
struct tint_array_wrapper_2 {
/* 0x0000 */ strided_arr_1 arr[4];
/* 0x0000 */ tint_array<tint_array<strided_arr, 2>, 3> el;
/* 0x0030 */ tint_array<int8_t, 80> tint_pad_1;
};
struct S {
/* 0x0000 */ tint_array_wrapper_2 a;
/* 0x0000 */ tint_array<strided_arr_1, 4> a;
};
void f_1(device S* const tint_symbol_1) {
tint_array_wrapper_2 const x_19 = (*(tint_symbol_1)).a;
tint_array_wrapper_1 const x_24 = (*(tint_symbol_1)).a.arr[3].el;
tint_array_wrapper const x_28 = (*(tint_symbol_1)).a.arr[3].el.arr[2];
float const x_32 = (*(tint_symbol_1)).a.arr[3].el.arr[2].arr[1].el;
tint_array_wrapper_2 const tint_symbol = {.arr={}};
tint_array<strided_arr_1, 4> const x_19 = (*(tint_symbol_1)).a;
tint_array<tint_array<strided_arr, 2>, 3> const x_24 = (*(tint_symbol_1)).a[3].el;
tint_array<strided_arr, 2> const x_28 = (*(tint_symbol_1)).a[3].el[2];
float const x_32 = (*(tint_symbol_1)).a[3].el[2][1].el;
tint_array<strided_arr_1, 4> const tint_symbol = tint_array<strided_arr_1, 4>{};
(*(tint_symbol_1)).a = tint_symbol;
(*(tint_symbol_1)).a.arr[3].el.arr[2].arr[1].el = 5.0f;
(*(tint_symbol_1)).a[3].el[2][1].el = 5.0f;
return;
}

View File

@@ -1,56 +1,53 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
int arr[4];
};
struct tint_array_wrapper_2 {
tint_array_wrapper arr[3];
};
struct tint_array_wrapper_1 {
tint_array_wrapper_2 arr[2];
};
struct tint_array_wrapper_3 {
tint_array_wrapper arr[2];
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];
};
kernel void tint_symbol() {
int const x = 42;
tint_array_wrapper const empty = {.arr={}};
tint_array_wrapper const nonempty = {.arr={1, 2, 3, 4}};
tint_array_wrapper const nonempty_with_expr = {.arr={1, 42, as_type<int>((as_type<uint>(42) + as_type<uint>(1))), nonempty.arr[3]}};
tint_array_wrapper_1 const nested_empty = {.arr={}};
tint_array_wrapper const tint_symbol_1 = {.arr={1, 2, 3, 4}};
tint_array_wrapper const tint_symbol_2 = {.arr={5, 6, 7, 8}};
tint_array_wrapper const tint_symbol_3 = {.arr={9, 10, 11, 12}};
tint_array_wrapper_2 const tint_symbol_4 = {.arr={tint_symbol_1, tint_symbol_2, tint_symbol_3}};
tint_array_wrapper const tint_symbol_5 = {.arr={13, 14, 15, 16}};
tint_array_wrapper const tint_symbol_6 = {.arr={17, 18, 19, 20}};
tint_array_wrapper const tint_symbol_7 = {.arr={21, 22, 23, 24}};
tint_array_wrapper_2 const tint_symbol_8 = {.arr={tint_symbol_5, tint_symbol_6, tint_symbol_7}};
tint_array_wrapper_1 const nested_nonempty = {.arr={tint_symbol_4, tint_symbol_8}};
tint_array_wrapper const tint_symbol_9 = {.arr={1, 2, 42, as_type<int>((as_type<uint>(42) + as_type<uint>(1)))}};
tint_array_wrapper const tint_symbol_10 = {.arr={5, 6, nonempty.arr[2], as_type<int>((as_type<uint>(nonempty.arr[3]) + as_type<uint>(1)))}};
tint_array_wrapper_2 const tint_symbol_11 = {.arr={tint_symbol_9, tint_symbol_10, nonempty}};
tint_array_wrapper_1 const nested_nonempty_with_expr = {.arr={tint_symbol_11, nested_nonempty.arr[1]}};
tint_array_wrapper const tint_symbol_12 = {.arr={}};
int const subexpr_empty = tint_symbol_12.arr[1];
tint_array_wrapper const tint_symbol_13 = {.arr={1, 2, 3, 4}};
int const subexpr_nonempty = tint_symbol_13.arr[2];
tint_array_wrapper const tint_symbol_14 = {.arr={1, 42, as_type<int>((as_type<uint>(42) + as_type<uint>(1))), nonempty.arr[3]}};
int const subexpr_nonempty_with_expr = tint_symbol_14.arr[2];
tint_array_wrapper_3 const tint_symbol_15 = {.arr={}};
tint_array_wrapper const subexpr_nested_empty = tint_symbol_15.arr[1];
tint_array_wrapper const tint_symbol_16 = {.arr={1, 2, 3, 4}};
tint_array_wrapper const tint_symbol_17 = {.arr={5, 6, 7, 8}};
tint_array_wrapper_3 const tint_symbol_18 = {.arr={tint_symbol_16, tint_symbol_17}};
tint_array_wrapper const subexpr_nested_nonempty = tint_symbol_18.arr[1];
tint_array_wrapper const tint_symbol_19 = {.arr={1, 42, as_type<int>((as_type<uint>(42) + as_type<uint>(1))), nonempty.arr[3]}};
tint_array_wrapper_3 const tint_symbol_20 = {.arr={tint_symbol_19, nested_nonempty.arr[1].arr[2]}};
tint_array_wrapper const subexpr_nested_nonempty_with_expr = tint_symbol_20.arr[1];
tint_array<int, 4> const empty = tint_array<int, 4>{};
tint_array<int, 4> const nonempty = tint_array<int, 4>{1, 2, 3, 4};
tint_array<int, 4> const nonempty_with_expr = tint_array<int, 4>{1, 42, as_type<int>((as_type<uint>(42) + as_type<uint>(1))), 4};
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_empty = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{};
tint_array<int, 4> const tint_symbol_1 = tint_array<int, 4>{1, 2, 3, 4};
tint_array<int, 4> const tint_symbol_2 = tint_array<int, 4>{5, 6, 7, 8};
tint_array<int, 4> const tint_symbol_3 = tint_array<int, 4>{9, 10, 11, 12};
tint_array<tint_array<int, 4>, 3> const tint_symbol_4 = tint_array<tint_array<int, 4>, 3>{tint_symbol_1, tint_symbol_2, tint_symbol_3};
tint_array<int, 4> const tint_symbol_5 = tint_array<int, 4>{13, 14, 15, 16};
tint_array<int, 4> const tint_symbol_6 = tint_array<int, 4>{17, 18, 19, 20};
tint_array<int, 4> const tint_symbol_7 = tint_array<int, 4>{21, 22, 23, 24};
tint_array<tint_array<int, 4>, 3> const tint_symbol_8 = tint_array<tint_array<int, 4>, 3>{tint_symbol_5, tint_symbol_6, tint_symbol_7};
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_nonempty = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{tint_symbol_4, tint_symbol_8};
tint_array<int, 4> const tint_symbol_9 = tint_array<int, 4>{1, 2, 42, as_type<int>((as_type<uint>(42) + as_type<uint>(1)))};
tint_array<int, 4> const tint_symbol_10 = tint_array<int, 4>{5, 6, 3, as_type<int>((as_type<uint>(4) + as_type<uint>(1)))};
tint_array<tint_array<int, 4>, 3> const tint_symbol_11 = tint_array<tint_array<int, 4>, 3>{tint_symbol_9, tint_symbol_10, nonempty};
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_nonempty_with_expr = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{tint_symbol_11, nested_nonempty[1]};
tint_array<int, 4> const tint_symbol_12 = tint_array<int, 4>{};
int const subexpr_empty = 0;
tint_array<int, 4> const tint_symbol_13 = tint_array<int, 4>{1, 2, 3, 4};
int const subexpr_nonempty = 3;
tint_array<int, 4> const tint_symbol_14 = tint_array<int, 4>{1, 42, as_type<int>((as_type<uint>(42) + as_type<uint>(1))), 4};
int const subexpr_nonempty_with_expr = tint_symbol_14[2];
tint_array<tint_array<int, 4>, 2> const tint_symbol_15 = tint_array<tint_array<int, 4>, 2>{};
tint_array<int, 4> const subexpr_nested_empty = tint_symbol_15[1];
tint_array<int, 4> const tint_symbol_16 = tint_array<int, 4>{1, 2, 3, 4};
tint_array<int, 4> const tint_symbol_17 = tint_array<int, 4>{5, 6, 7, 8};
tint_array<tint_array<int, 4>, 2> const tint_symbol_18 = tint_array<tint_array<int, 4>, 2>{tint_symbol_16, tint_symbol_17};
tint_array<int, 4> const subexpr_nested_nonempty = tint_symbol_18[1];
tint_array<int, 4> const tint_symbol_19 = tint_array<int, 4>{1, 42, as_type<int>((as_type<uint>(42) + as_type<uint>(1))), 4};
tint_array<tint_array<int, 4>, 2> const tint_symbol_20 = tint_array<tint_array<int, 4>, 2>{tint_symbol_19, nested_nonempty[1][2]};
tint_array<int, 4> const subexpr_nested_nonempty_with_expr = tint_symbol_20[1];
return;
}