tint/transform: fix PromoteInitializersToLet for constant expressions

Fix more edge cases uncovered with tint:1781

Fixed: tint:1781
Change-Id: I58d120185f47c10bc9fe55dd95a198d496c4ec94
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113024
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2022-12-09 12:34:36 +00:00 committed by Dawn LUCI CQ
parent dd0d45102a
commit f528d33d52
73 changed files with 653 additions and 824 deletions

View File

@ -25,7 +25,12 @@ struct NodeID {
/// Equality operator
/// @param other the other NodeID
/// @returns true if the NodeIDs are the same
bool operator==(const NodeID& other) const { return value == other.value; }
bool operator==(NodeID other) const { return value == other.value; }
/// Less-than comparison operator
/// @param other the other NodeID
/// @returns true if the other comes before this node
bool operator<(NodeID other) const { return value < other.value; }
/// The numerical value for the node identifier
size_t value = 0;

View File

@ -16,11 +16,14 @@
#include <utility>
#include "src/tint/ast/traverse_expressions.h"
#include "src/tint/program_builder.h"
#include "src/tint/sem/call.h"
#include "src/tint/sem/statement.h"
#include "src/tint/sem/type_initializer.h"
#include "src/tint/transform/utils/hoist_to_decl_before.h"
#include "src/tint/type/struct.h"
#include "src/tint/utils/hashset.h"
TINT_INSTANTIATE_TYPEINFO(tint::transform::PromoteInitializersToLet);
@ -36,87 +39,111 @@ Transform::ApplyResult PromoteInitializersToLet::Apply(const Program* src,
ProgramBuilder b;
CloneContext ctx{&b, src, /* auto_clone_symbols */ true};
HoistToDeclBefore hoist_to_decl_before(ctx);
bool any_promoted = false;
// Hoists array and structure initializers to a constant variable, declared
// just before the statement of usage.
auto promote = [&](const sem::Expression* expr) {
auto* sem_stmt = expr->Stmt();
if (!sem_stmt) {
// Expression is outside of a statement. This usually means the
// expression is part of a global (module-scope) constant declaration.
// These must be constexpr, and so cannot contain the type of
// expressions that must be sanitized.
return true;
// Returns true if the expression should be hoisted to a new let statement before the
// expression's statement.
auto should_hoist = [&](const sem::Expression* expr) {
if (!expr->Type()->IsAnyOf<type::Array, type::StructBase>()) {
// We only care about array and struct initializers
return false;
}
auto* stmt = sem_stmt->Declaration();
// Check whether the expression is an array or structure constructor
{
// Follow const-chains
auto* root_expr = expr;
if (expr->Stage() == sem::EvaluationStage::kConstant) {
while (auto* user = root_expr->UnwrapMaterialize()->As<sem::VariableUser>()) {
root_expr = user->Variable()->Initializer();
}
}
if (auto* src_var_decl = stmt->As<ast::VariableDeclStatement>()) {
if (src_var_decl->variable->initializer == expr->Declaration()) {
// This statement is just a variable declaration with the
// initializer as the initializer value. This is what we're
// attempting to transform to, and so ignore.
return true;
auto* ctor = root_expr->UnwrapMaterialize()->As<sem::Call>();
if (!ctor || !ctor->Target()->Is<sem::TypeInitializer>()) {
// Root expression is not a type constructor. Not interested in this.
return false;
}
}
auto* src_ty = expr->Type();
if (!src_ty->IsAnyOf<type::Array, sem::Struct>()) {
// We only care about array and struct initializers
return true;
if (auto* src_var_decl = expr->Stmt()->Declaration()->As<ast::VariableDeclStatement>()) {
if (src_var_decl->variable->initializer == expr->Declaration()) {
// This statement is just a variable declaration with the initializer as the
// initializer value. This is what we're attempting to transform to, and so
// ignore.
return false;
}
}
any_promoted = true;
return hoist_to_decl_before.Add(expr, expr->Declaration(),
HoistToDeclBefore::VariableKind::kLet);
return true;
};
// A list of expressions that should be hoisted.
utils::Vector<const sem::Expression*, 32> to_hoist;
// A set of expressions that are constant, which _may_ need to be hoisted.
utils::Hashset<const ast::Expression*, 32> const_chains;
// Walk the AST nodes. This order guarantees that leaf-expressions are visited first.
for (auto* node : src->ASTNodes().Objects()) {
bool ok = Switch(
node, //
[&](const ast::CallExpression* expr) {
if (auto* sem = src->Sem().Get(expr)) {
auto* ctor = sem->UnwrapMaterialize()->As<sem::Call>();
if (ctor->Target()->Is<sem::TypeInitializer>()) {
return promote(sem);
}
if (auto* sem = src->Sem().Get<sem::Expression>(node)) {
auto* stmt = sem->Stmt();
if (!stmt) {
// Expression is outside of a statement. This usually means the expression is part
// of a global (module-scope) constant declaration. These must be constexpr, and so
// cannot contain the type of expressions that must be sanitized.
continue;
}
if (sem->Stage() == sem::EvaluationStage::kConstant) {
// Expression is constant. We only need to hoist expressions if they're the
// outermost constant expression in a chain. Remove the immediate child nodes of the
// expression from const_chains, and add this expression to the const_chains. As we
// visit leaf-expressions first, this means the content of const_chains only
// contains the outer-most constant expressions.
auto* expr = sem->Declaration();
bool ok = ast::TraverseExpressions(
expr, b.Diagnostics(), [&](const ast::Expression* child) {
const_chains.Remove(child);
return child == expr ? ast::TraverseAction::Descend
: ast::TraverseAction::Skip;
});
if (!ok) {
return Program(std::move(b));
}
return true;
},
[&](const ast::IdentifierExpression* expr) {
if (auto* sem = src->Sem().Get(expr)) {
if (auto* user = sem->UnwrapMaterialize()->As<sem::VariableUser>()) {
// Identifier resolves to a variable
if (auto* stmt = user->Stmt()) {
if (auto* decl = stmt->Declaration()->As<ast::VariableDeclStatement>();
decl && decl->variable->Is<ast::Const>()) {
// The identifier is used on the RHS of a 'const' declaration.
// Ignore.
return true;
}
}
if (user->Variable()->Declaration()->Is<ast::Const>()) {
// The identifier resolves to a 'const' variable, but isn't used to
// initialize another 'const'. This needs promoting.
return promote(user);
}
}
}
return true;
},
[&](Default) { return true; });
if (!ok) {
return Program(std::move(b));
const_chains.Add(expr);
} else if (should_hoist(sem)) {
to_hoist.Push(sem);
}
}
}
if (!any_promoted) {
// After walking the full AST, const_chains only contains the outer-most constant expressions.
// Check if any of these need hoisting, and append those to to_hoist.
for (auto* expr : const_chains) {
if (auto* sem = src->Sem().Get(expr); should_hoist(sem)) {
to_hoist.Push(sem);
}
}
if (to_hoist.IsEmpty()) {
// Nothing to do. Skip.
return SkipTransform;
}
// The order of to_hoist is currently undefined. Sort by AST node id, which will make this
// deterministic.
to_hoist.Sort([&](auto* expr_a, auto* expr_b) {
return expr_a->Declaration()->node_id < expr_b->Declaration()->node_id;
});
// Hoist all the expression in to_hoist to a constant variable, declared just before the
// statement of usage.
HoistToDeclBefore hoist_to_decl_before(ctx);
for (auto* expr : to_hoist) {
if (!hoist_to_decl_before.Add(expr, expr->Declaration(),
HoistToDeclBefore::VariableKind::kLet)) {
return Program(std::move(b));
}
}
ctx.Clone();
return Program(std::move(b));
}

View File

@ -30,7 +30,21 @@ TEST_F(PromoteInitializersToLetTest, EmptyModule) {
EXPECT_EQ(expect, str(got));
}
TEST_F(PromoteInitializersToLetTest, BasicArray) {
TEST_F(PromoteInitializersToLetTest, BasicConstArray) {
auto* src = R"(
fn f() {
const f0 = 1.0;
const f1 = 2.0;
const f2 = 3.0;
const f3 = 4.0;
var i = array<f32, 4u>(f0, f1, f2, f3)[2];
}
)";
EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
}
TEST_F(PromoteInitializersToLetTest, BasicRuntimeArray) {
auto* src = R"(
fn f() {
var f0 = 1.0;
@ -52,13 +66,12 @@ fn f() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(PromoteInitializersToLetTest, BasicStruct) {
TEST_F(PromoteInitializersToLetTest, BasicConstStruct) {
auto* src = R"(
struct S {
a : i32,
@ -69,6 +82,23 @@ struct S {
fn f() {
var x = S(1, 2.0, vec3<f32>()).b;
}
)";
EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
}
TEST_F(PromoteInitializersToLetTest, BasicRuntimeStruct) {
auto* src = R"(
struct S {
a : i32,
b : f32,
c : vec3<f32>,
};
fn f() {
let runtime_value = 1;
var x = S(runtime_value, 2.0, vec3<f32>()).b;
}
)";
auto* expect = R"(
@ -79,12 +109,12 @@ struct S {
}
fn f() {
let tint_symbol = S(1, 2.0, vec3<f32>());
let runtime_value = 1;
let tint_symbol = S(runtime_value, 2.0, vec3<f32>());
var x = tint_symbol.b;
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -93,7 +123,8 @@ fn f() {
TEST_F(PromoteInitializersToLetTest, BasicStruct_OutOfOrder) {
auto* src = R"(
fn f() {
var x = S(1, 2.0, vec3<f32>()).b;
let runtime_value = 1;
var x = S(runtime_value, 2.0, vec3<f32>()).b;
}
struct S {
@ -105,7 +136,8 @@ struct S {
auto* expect = R"(
fn f() {
let tint_symbol = S(1, 2.0, vec3<f32>());
let runtime_value = 1;
let tint_symbol = S(runtime_value, 2.0, vec3<f32>());
var x = tint_symbol.b;
}
@ -116,7 +148,6 @@ struct S {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -133,29 +164,29 @@ const C = array<f32, 2u>(f0, f1);
fn f() {
var f0 = 100.0;
var f1 = 100.0;
var i = C[1];
var i = C[1]; // Not hoisted, as the final const value is not an array
}
)";
auto* expect = R"(
const f0 = 1.0;
const f1 = 2.0;
const C = array<f32, 2u>(f0, f1);
EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
}
TEST_F(PromoteInitializersToLetTest, GlobalConstBasicArray_OutOfOrder) {
auto* src = R"(
fn f() {
var f0 = 100.0;
var f1 = 100.0;
let tint_symbol = C;
var i = tint_symbol[1];
var i = C[1];
}
const C = array<f32, 2u>(f0, f1);
const f0 = 1.0;
const f1 = 2.0;
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
}
TEST_F(PromoteInitializersToLetTest, GlobalConstArrayDynamicIndex) {
@ -183,43 +214,6 @@ fn vs_main(@builtin(vertex_index) in_vertex_index : u32) -> @builtin(position) v
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(PromoteInitializersToLetTest, GlobalConstBasicArray_OutOfOrder) {
auto* src = R"(
fn f() {
var f0 = 100.0;
var f1 = 100.0;
var i = C[1];
}
const C = array<f32, 2u>(f0, f1);
const f0 = 1.0;
const f1 = 2.0;
)";
auto* expect = R"(
fn f() {
var f0 = 100.0;
var f1 = 100.0;
let tint_symbol = C;
var i = tint_symbol[1];
}
const C = array<f32, 2u>(f0, f1);
const f0 = 1.0;
const f1 = 2.0;
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -231,7 +225,21 @@ fn f() {
const f0 = 1.0;
const f1 = 2.0;
const C = array<f32, 2u>(f0, f1);
var i = C[1];
var i = C[1]; // Not hoisted, as the final const value is not an array
}
)";
EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
}
TEST_F(PromoteInitializersToLetTest, LocalConstBasicArrayRuntimeIndex) {
auto* src = R"(
fn f() {
const f0 = 1.0;
const f1 = 2.0;
const C = array<f32, 2u>(f0, f1);
let runtime_value = 1;
var i = C[runtime_value];
}
)";
@ -240,12 +248,12 @@ fn f() {
const f0 = 1.0;
const f1 = 2.0;
const C = array<f32, 2u>(f0, f1);
let runtime_value = 1;
let tint_symbol = C;
var i = tint_symbol[1];
var i = tint_symbol[runtime_value];
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -255,7 +263,7 @@ TEST_F(PromoteInitializersToLetTest, ArrayInForLoopInit) {
auto* src = R"(
fn f() {
var insert_after = 1;
for(var i = array<f32, 4u>(0.0, 1.0, 2.0, 3.0)[2]; ; ) {
for(var i = array<f32, 4u>(0.0, 1.0, 2.0, 3.0)[insert_after]; ; ) {
break;
}
}
@ -265,13 +273,12 @@ fn f() {
fn f() {
var insert_after = 1;
let tint_symbol = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
for(var i = tint_symbol[2]; ; ) {
for(var i = tint_symbol[insert_after]; ; ) {
break;
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -281,8 +288,9 @@ TEST_F(PromoteInitializersToLetTest, LocalConstArrayInForLoopInit) {
auto* src = R"(
fn f() {
const arr = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
let runtime_value = 1;
var insert_after = 1;
for(var i = arr[2]; ; ) {
for(var i = arr[runtime_value]; ; ) {
break;
}
}
@ -291,15 +299,15 @@ fn f() {
auto* expect = R"(
fn f() {
const arr = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
let runtime_value = 1;
var insert_after = 1;
let tint_symbol = arr;
for(var i = tint_symbol[2]; ; ) {
for(var i = tint_symbol[runtime_value]; ; ) {
break;
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -310,8 +318,9 @@ TEST_F(PromoteInitializersToLetTest, GlobalConstArrayInForLoopInit) {
const arr = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
fn f() {
let runtime_value = 1;
var insert_after = 1;
for(var i = arr[2]; ; ) {
for(var i = arr[runtime_value]; ; ) {
break;
}
}
@ -321,15 +330,15 @@ fn f() {
const arr = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
fn f() {
let runtime_value = 1;
var insert_after = 1;
let tint_symbol = arr;
for(var i = tint_symbol[2]; ; ) {
for(var i = tint_symbol[runtime_value]; ; ) {
break;
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -343,9 +352,13 @@ struct S {
c : vec3<f32>,
};
fn get_b_runtime(s : S) -> f32 {
return s.b;
}
fn f() {
var insert_after = 1;
for(var x = S(1, 2.0, vec3<f32>()).b; ; ) {
for(var x = get_b_runtime(S(1, 2.0, vec3<f32>())); ; ) {
break;
}
}
@ -358,16 +371,19 @@ struct S {
c : vec3<f32>,
}
fn get_b_runtime(s : S) -> f32 {
return s.b;
}
fn f() {
var insert_after = 1;
let tint_symbol = S(1, 2.0, vec3<f32>());
for(var x = tint_symbol.b; ; ) {
for(var x = get_b_runtime(tint_symbol); ; ) {
break;
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -377,11 +393,15 @@ TEST_F(PromoteInitializersToLetTest, StructInForLoopInit_OutOfOrder) {
auto* src = R"(
fn f() {
var insert_after = 1;
for(var x = S(1, 2.0, vec3<f32>()).b; ; ) {
for(var x = get_b_runtime(S(1, 2.0, vec3<f32>())); ; ) {
break;
}
}
fn get_b_runtime(s : S) -> f32 {
return s.b;
}
struct S {
a : i32,
b : f32,
@ -393,11 +413,15 @@ struct S {
fn f() {
var insert_after = 1;
let tint_symbol = S(1, 2.0, vec3<f32>());
for(var x = tint_symbol.b; ; ) {
for(var x = get_b_runtime(tint_symbol); ; ) {
break;
}
}
fn get_b_runtime(s : S) -> f32 {
return s.b;
}
struct S {
a : i32,
b : f32,
@ -405,7 +429,6 @@ struct S {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -440,7 +463,6 @@ fn f() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -449,9 +471,10 @@ fn f() {
TEST_F(PromoteInitializersToLetTest, LocalConstArrayInForLoopCond) {
auto* src = R"(
fn f() {
let runtime_value = 0;
const f = 1.0;
const arr = array<f32, 1u>(f);
for(var i = f; i == arr[0]; i = i + 1.0) {
for(var i = f; i == arr[runtime_value]; i = i + 1.0) {
var marker = 1;
}
}
@ -459,13 +482,14 @@ fn f() {
auto* expect = R"(
fn f() {
let runtime_value = 0;
const f = 1.0;
const arr = array<f32, 1u>(f);
{
var i = f;
loop {
let tint_symbol = arr;
if (!((i == tint_symbol[0]))) {
if (!((i == tint_symbol[runtime_value]))) {
break;
}
{
@ -480,7 +504,6 @@ fn f() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -493,7 +516,8 @@ const f = 1.0;
const arr = array<f32, 1u>(f);
fn F() {
for(var i = f; i == arr[0]; i = i + 1.0) {
let runtime_value = 0;
for(var i = f; i == arr[runtime_value]; i = i + 1.0) {
var marker = 1;
}
}
@ -505,11 +529,12 @@ const f = 1.0;
const arr = array<f32, 1u>(f);
fn F() {
let runtime_value = 0;
{
var i = f;
loop {
let tint_symbol = arr;
if (!((i == tint_symbol[0]))) {
if (!((i == tint_symbol[runtime_value]))) {
break;
}
{
@ -524,7 +549,6 @@ fn F() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -533,8 +557,9 @@ fn F() {
TEST_F(PromoteInitializersToLetTest, ArrayInForLoopCont) {
auto* src = R"(
fn f() {
let runtime_value = 0;
var f = 0.0;
for(; f < 10.0; f = f + array<f32, 1u>(1.0)[0]) {
for(; f < 10.0; f = f + array<f32, 1u>(1.0)[runtime_value]) {
var marker = 1;
}
}
@ -542,6 +567,7 @@ fn f() {
auto* expect = R"(
fn f() {
let runtime_value = 0;
var f = 0.0;
loop {
if (!((f < 10.0))) {
@ -553,13 +579,12 @@ fn f() {
continuing {
let tint_symbol = array<f32, 1u>(1.0);
f = (f + tint_symbol[0]);
f = (f + tint_symbol[runtime_value]);
}
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -568,9 +593,10 @@ fn f() {
TEST_F(PromoteInitializersToLetTest, LocalConstArrayInForLoopCont) {
auto* src = R"(
fn f() {
let runtime_value = 0;
const arr = array<f32, 1u>(1.0);
var f = 0.0;
for(; f < 10.0; f = f + arr[0]) {
for(; f < 10.0; f = f + arr[runtime_value]) {
var marker = 1;
}
}
@ -578,6 +604,7 @@ fn f() {
auto* expect = R"(
fn f() {
let runtime_value = 0;
const arr = array<f32, 1u>(1.0);
var f = 0.0;
loop {
@ -590,13 +617,12 @@ fn f() {
continuing {
let tint_symbol = arr;
f = (f + tint_symbol[0]);
f = (f + tint_symbol[runtime_value]);
}
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -607,8 +633,9 @@ TEST_F(PromoteInitializersToLetTest, GlobalConstArrayInForLoopCont) {
const arr = array<f32, 1u>(1.0);
fn f() {
let runtime_value = 0;
var f = 0.0;
for(; f < 10.0; f = f + arr[0]) {
for(; f < 10.0; f = f + arr[runtime_value]) {
var marker = 1;
}
}
@ -618,6 +645,7 @@ fn f() {
const arr = array<f32, 1u>(1.0);
fn f() {
let runtime_value = 0;
var f = 0.0;
loop {
if (!((f < 10.0))) {
@ -629,13 +657,12 @@ fn f() {
continuing {
let tint_symbol = arr;
f = (f + tint_symbol[0]);
f = (f + tint_symbol[runtime_value]);
}
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -644,9 +671,10 @@ fn f() {
TEST_F(PromoteInitializersToLetTest, ArrayInForLoopInitCondCont) {
auto* src = R"(
fn f() {
for(var f = array<f32, 1u>(0.0)[0];
f < array<f32, 1u>(1.0)[0];
f = f + array<f32, 1u>(2.0)[0]) {
let runtime_value = 0;
for(var f = array<f32, 1u>(0.0)[runtime_value];
f < array<f32, 1u>(1.0)[runtime_value];
f = f + array<f32, 1u>(2.0)[runtime_value]) {
var marker = 1;
}
}
@ -654,12 +682,13 @@ fn f() {
auto* expect = R"(
fn f() {
let runtime_value = 0;
let tint_symbol = array<f32, 1u>(0.0);
{
var f = tint_symbol[0];
var f = tint_symbol[runtime_value];
loop {
let tint_symbol_1 = array<f32, 1u>(1.0);
if (!((f < tint_symbol_1[0]))) {
if (!((f < tint_symbol_1[runtime_value]))) {
break;
}
{
@ -668,14 +697,13 @@ fn f() {
continuing {
let tint_symbol_2 = array<f32, 1u>(2.0);
f = (f + tint_symbol_2[0]);
f = (f + tint_symbol_2[runtime_value]);
}
}
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -684,10 +712,11 @@ fn f() {
TEST_F(PromoteInitializersToLetTest, LocalConstArrayInForLoopInitCondCont) {
auto* src = R"(
fn f() {
let runtime_value = 0;
const arr_a = array<f32, 1u>(0.0);
const arr_b = array<f32, 1u>(1.0);
const arr_c = array<f32, 1u>(2.0);
for(var f = arr_a[0]; f < arr_b[0]; f = f + arr_c[0]) {
for(var f = arr_a[runtime_value]; f < arr_b[runtime_value]; f = f + arr_c[runtime_value]) {
var marker = 1;
}
}
@ -695,15 +724,16 @@ fn f() {
auto* expect = R"(
fn f() {
let runtime_value = 0;
const arr_a = array<f32, 1u>(0.0);
const arr_b = array<f32, 1u>(1.0);
const arr_c = array<f32, 1u>(2.0);
let tint_symbol = arr_a;
{
var f = tint_symbol[0];
var f = tint_symbol[runtime_value];
loop {
let tint_symbol_1 = arr_b;
if (!((f < tint_symbol_1[0]))) {
if (!((f < tint_symbol_1[runtime_value]))) {
break;
}
{
@ -712,14 +742,13 @@ fn f() {
continuing {
let tint_symbol_2 = arr_c;
f = (f + tint_symbol_2[0]);
f = (f + tint_symbol_2[runtime_value]);
}
}
}
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -751,7 +780,6 @@ fn f() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -802,7 +830,6 @@ fn f() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -811,15 +838,16 @@ fn f() {
TEST_F(PromoteInitializersToLetTest, LocalConstArrayInElseIfChain) {
auto* src = R"(
fn f() {
let runtime_value = 0;
const f = 1.0;
const arr = array<f32, 2u>(f, f);
if (true) {
var marker = 0;
} else if (true) {
var marker = 1;
} else if (f == arr[0]) {
} else if (f == arr[runtime_value]) {
var marker = 2;
} else if (f == arr[1]) {
} else if (f == arr[runtime_value + 1]) {
var marker = 3;
} else if (true) {
var marker = 4;
@ -831,6 +859,7 @@ fn f() {
auto* expect = R"(
fn f() {
let runtime_value = 0;
const f = 1.0;
const arr = array<f32, 2u>(f, f);
if (true) {
@ -839,11 +868,11 @@ fn f() {
var marker = 1;
} else {
let tint_symbol = arr;
if ((f == tint_symbol[0])) {
if ((f == tint_symbol[runtime_value])) {
var marker = 2;
} else {
let tint_symbol_1 = arr;
if ((f == tint_symbol_1[1])) {
if ((f == tint_symbol_1[(runtime_value + 1)])) {
var marker = 3;
} else if (true) {
var marker = 4;
@ -855,7 +884,6 @@ fn f() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -868,13 +896,14 @@ const f = 1.0;
const arr = array<f32, 2u>(f, f);
fn F() {
let runtime_value = 0;
if (true) {
var marker = 0;
} else if (true) {
var marker = 1;
} else if (f == arr[0]) {
} else if (f == arr[runtime_value]) {
var marker = 2;
} else if (f == arr[1]) {
} else if (f == arr[runtime_value + 1]) {
var marker = 3;
} else if (true) {
var marker = 4;
@ -890,17 +919,18 @@ const f = 1.0;
const arr = array<f32, 2u>(f, f);
fn F() {
let runtime_value = 0;
if (true) {
var marker = 0;
} else if (true) {
var marker = 1;
} else {
let tint_symbol = arr;
if ((f == tint_symbol[0])) {
if ((f == tint_symbol[runtime_value])) {
var marker = 2;
} else {
let tint_symbol_1 = arr;
if ((f == tint_symbol_1[1])) {
if ((f == tint_symbol_1[(runtime_value + 1)])) {
var marker = 3;
} else if (true) {
var marker = 4;
@ -912,35 +942,43 @@ fn F() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(PromoteInitializersToLetTest, ArrayInArrayArray) {
TEST_F(PromoteInitializersToLetTest, ArrayInArrayArrayConstIndex) {
auto* src = R"(
fn f() {
var i = array<array<f32, 2u>, 2u>(array<f32, 2u>(1.0, 2.0), array<f32, 2u>(3.0, 4.0))[0][1];
}
)";
auto* expect = R"(
EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
}
TEST_F(PromoteInitializersToLetTest, ArrayInArrayArrayRuntimeIndex) {
auto* src = R"(
fn f() {
let tint_symbol = array<f32, 2u>(1.0, 2.0);
let tint_symbol_1 = array<f32, 2u>(3.0, 4.0);
let tint_symbol_2 = array<array<f32, 2u>, 2u>(tint_symbol, tint_symbol_1);
var i = tint_symbol_2[0][1];
let runtime_value = 1;
var i = array<array<f32, 2u>, 2u>(array<f32, 2u>(1.0, 2.0), array<f32, 2u>(3.0, 4.0))[runtime_value][runtime_value + 1];
}
)";
auto* expect = R"(
fn f() {
let runtime_value = 1;
let tint_symbol = array<array<f32, 2u>, 2u>(array<f32, 2u>(1.0, 2.0), array<f32, 2u>(3.0, 4.0));
var i = tint_symbol[runtime_value][(runtime_value + 1)];
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(PromoteInitializersToLetTest, LocalConstArrayInArrayArray) {
TEST_F(PromoteInitializersToLetTest, LocalConstArrayInArrayArrayConstIndex) {
auto* src = R"(
fn f() {
const arr_0 = array<f32, 2u>(1.0, 2.0);
@ -948,19 +986,33 @@ fn f() {
const arr_2 = array<array<f32, 2u>, 2u>(arr_0, arr_1);
var i = arr_2[0][1];
}
)";
EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
}
TEST_F(PromoteInitializersToLetTest, LocalConstArrayInArrayArrayRuntimeIndex) {
auto* src = R"(
fn f() {
let runtime_value = 1;
const arr_0 = array<f32, 2u>(1.0, 2.0);
const arr_1 = array<f32, 2u>(3.0, 4.0);
const arr_2 = array<array<f32, 2u>, 2u>(arr_0, arr_1);
var i = arr_2[runtime_value][runtime_value + 1];
}
)";
auto* expect = R"(
fn f() {
let runtime_value = 1;
const arr_0 = array<f32, 2u>(1.0, 2.0);
const arr_1 = array<f32, 2u>(3.0, 4.0);
const arr_2 = array<array<f32, 2u>, 2u>(arr_0, arr_1);
let tint_symbol = arr_2;
var i = tint_symbol[0][1];
var i = tint_symbol[runtime_value][(runtime_value + 1)];
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -975,7 +1027,8 @@ const arr_1 = array<f32, 2u>(3.0, 4.0);
const arr_2 = array<array<f32, 2u>, 2u>(arr_0, arr_1);
fn f() {
var i = arr_2[0][1];
let runtime_value = 1;
var i = arr_2[runtime_value][runtime_value + 1];
}
)";
@ -987,12 +1040,12 @@ const arr_1 = array<f32, 2u>(3.0, 4.0);
const arr_2 = array<array<f32, 2u>, 2u>(arr_0, arr_1);
fn f() {
let runtime_value = 1;
let tint_symbol = arr_2;
var i = tint_symbol[0][1];
var i = tint_symbol[runtime_value][(runtime_value + 1)];
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -1014,8 +1067,12 @@ struct S3 {
a : S2,
};
fn get_a(s : S3) -> S2 {
return s.a;
}
fn f() {
var x = S3(S2(1, S1(2), 3)).a.b.a;
var x = get_a(S3(S2(1, S1(2), 3))).b.a;
}
)";
@ -1034,15 +1091,16 @@ struct S3 {
a : S2,
}
fn get_a(s : S3) -> S2 {
return s.a;
}
fn f() {
let tint_symbol = S1(2);
let tint_symbol_1 = S2(1, tint_symbol, 3);
let tint_symbol_2 = S3(tint_symbol_1);
var x = tint_symbol_2.a.b.a;
let tint_symbol = S3(S2(1, S1(2), 3));
var x = get_a(tint_symbol).b.a;
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -1058,8 +1116,12 @@ struct S2 {
a : array<S1, 3u>,
};
fn get_a(s : S2) -> array<S1, 3u> {
return s.a;
}
fn f() {
var x = S2(array<S1, 3u>(S1(1), S1(2), S1(3))).a[1].a;
var x = get_a(S2(array<S1, 3u>(S1(1), S1(2), S1(3))))[1].a;
}
)";
@ -1072,17 +1134,16 @@ struct S2 {
a : array<S1, 3u>,
}
fn get_a(s : S2) -> array<S1, 3u> {
return s.a;
}
fn f() {
let tint_symbol = S1(1);
let tint_symbol_1 = S1(2);
let tint_symbol_2 = S1(3);
let tint_symbol_3 = array<S1, 3u>(tint_symbol, tint_symbol_1, tint_symbol_2);
let tint_symbol_4 = S2(tint_symbol_3);
var x = tint_symbol_4.a[1].a;
let tint_symbol = S2(array<S1, 3u>(S1(1), S1(2), S1(3)));
var x = get_a(tint_symbol)[1].a;
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -1091,7 +1152,11 @@ fn f() {
TEST_F(PromoteInitializersToLetTest, Mixed_OutOfOrder) {
auto* src = R"(
fn f() {
var x = S2(array<S1, 3u>(S1(1), S1(2), S1(3))).a[1].a;
var x = get_a(S2(array<S1, 3u>(S1(1), S1(2), S1(3))))[1].a;
}
fn get_a(s : S2) -> array<S1, 3u> {
return s.a;
}
struct S2 {
@ -1105,12 +1170,12 @@ struct S1 {
auto* expect = R"(
fn f() {
let tint_symbol = S1(1);
let tint_symbol_1 = S1(2);
let tint_symbol_2 = S1(3);
let tint_symbol_3 = array<S1, 3u>(tint_symbol, tint_symbol_1, tint_symbol_2);
let tint_symbol_4 = S2(tint_symbol_3);
var x = tint_symbol_4.a[1].a;
let tint_symbol = S2(array<S1, 3u>(S1(1), S1(2), S1(3)));
var x = get_a(tint_symbol)[1].a;
}
fn get_a(s : S2) -> array<S1, 3u> {
return s.a;
}
struct S2 {
@ -1122,7 +1187,6 @@ struct S1 {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -1144,7 +1208,6 @@ const module_str : F = F(2.0);
auto* expect = src;
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -1166,7 +1229,6 @@ const module_arr : array<f32, 4u> = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
auto* expect = src;
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));
@ -1246,7 +1308,6 @@ fn Z() {
}
)";
DataMap data;
auto got = Run<PromoteInitializersToLet>(src);
EXPECT_EQ(expect, str(got));

View File

@ -43,6 +43,18 @@ class Hashset : public HashmapBase<KEY, void, N, HASH, EQUAL> {
struct NoValue {};
return this->template Put<PutMode::kAdd>(std::forward<V>(value), NoValue{});
}
/// @returns the set entries of the map as a vector
/// @note the order of the returned vector is non-deterministic between compilers.
template <size_t N2 = N>
utils::Vector<KEY, N2> Vector() const {
utils::Vector<KEY, N2> out;
out.Reserve(this->Count());
for (auto& value : *this) {
out.Push(value);
}
return out;
}
};
} // namespace tint::utils

View File

@ -91,6 +91,16 @@ TEST(Hashset, Iterator) {
EXPECT_THAT(set, testing::UnorderedElementsAre("one", "two", "three", "four"));
}
TEST(Hashset, Vector) {
Hashset<std::string, 8> set;
set.Add("one");
set.Add("four");
set.Add("three");
set.Add("two");
auto vec = set.Vector();
EXPECT_THAT(vec, testing::UnorderedElementsAre("one", "two", "three", "four"));
}
TEST(Hashset, Soak) {
std::mt19937 rnd;
std::unordered_set<std::string> reference;

View File

@ -186,12 +186,14 @@ TEST_F(GlslSanitizerTest, PromoteStructInitializerToConstVar) {
Member("b", ty.vec3<f32>()),
Member("c", ty.i32()),
});
auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2_f, 3_f, 4_f), 4_i);
auto* runtime_value = Var("runtime_value", Expr(3_f));
auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2_f, runtime_value, 4_f), 4_i);
auto* struct_access = MemberAccessor(struct_init, "b");
auto* pos = Var("pos", ty.vec3<f32>(), struct_access);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
Decl(runtime_value),
Decl(pos),
},
utils::Vector{
@ -213,7 +215,8 @@ struct S {
};
void tint_symbol() {
S tint_symbol_1 = S(1, vec3(2.0f, 3.0f, 4.0f), 4);
float runtime_value = 3.0f;
S tint_symbol_1 = S(1, vec3(2.0f, runtime_value, 4.0f), 4);
vec3 pos = tint_symbol_1.b;
}

View File

@ -197,17 +197,19 @@ TEST_F(HlslSanitizerTest, PromoteArrayInitializerToConstVar) {
}
TEST_F(HlslSanitizerTest, PromoteStructInitializerToConstVar) {
auto* runtime_value = Var("runtime_value", Expr(3_f));
auto* str = Structure("S", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.vec3<f32>()),
Member("c", ty.i32()),
});
auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2_f, 3_f, 4_f), 4_i);
auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2_f, runtime_value, 4_f), 4_i);
auto* struct_access = MemberAccessor(struct_init, "b");
auto* pos = Var("pos", ty.vec3<f32>(), struct_access);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
Decl(runtime_value),
Decl(pos),
},
utils::Vector{
@ -226,7 +228,8 @@ TEST_F(HlslSanitizerTest, PromoteStructInitializerToConstVar) {
};
void main() {
const S tint_symbol = {1, float3(2.0f, 3.0f, 4.0f), 4};
float runtime_value = 3.0f;
const S tint_symbol = {1, float3(2.0f, runtime_value, 4.0f), 4};
float3 pos = tint_symbol.b;
return;
}

View File

@ -5,33 +5,19 @@ void main() {
const int nonempty[4] = {1, 2, 3, 4};
const int nonempty_with_expr[4] = {1, x, (x + 1), nonempty[3]};
const int nested_empty[2][3][4] = (int[2][3][4])0;
const int tint_symbol[4] = {1, 2, 3, 4};
const int tint_symbol_1[4] = {5, 6, 7, 8};
const int tint_symbol_2[4] = {9, 10, 11, 12};
const int tint_symbol_3[3][4] = {tint_symbol, tint_symbol_1, tint_symbol_2};
const int tint_symbol_4[4] = {13, 14, 15, 16};
const int tint_symbol_5[4] = {17, 18, 19, 20};
const int tint_symbol_6[4] = {21, 22, 23, 24};
const int tint_symbol_7[3][4] = {tint_symbol_4, tint_symbol_5, tint_symbol_6};
const int nested_nonempty[2][3][4] = {tint_symbol_3, tint_symbol_7};
const int tint_symbol_8[4] = {1, 2, x, (x + 1)};
const int tint_symbol_9[4] = {5, 6, nonempty[2], (nonempty[3] + 1)};
const int tint_symbol_10[3][4] = {tint_symbol_8, tint_symbol_9, nonempty};
const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_10, nested_nonempty[1]};
const int tint_symbol_11[4] = (int[4])0;
const int subexpr_empty = tint_symbol_11[1];
const int tint_symbol_12[4] = {1, 2, 3, 4};
const int subexpr_nonempty = tint_symbol_12[2];
const int tint_symbol_13[4] = {1, x, (x + 1), nonempty[3]};
const int subexpr_nonempty_with_expr = tint_symbol_13[2];
const int tint_symbol_14[2][4] = (int[2][4])0;
const int subexpr_nested_empty[4] = tint_symbol_14[1];
const int tint_symbol_15[4] = {1, 2, 3, 4};
const int tint_symbol_16[4] = {5, 6, 7, 8};
const int tint_symbol_17[2][4] = {tint_symbol_15, tint_symbol_16};
const int subexpr_nested_nonempty[4] = tint_symbol_17[1];
const int tint_symbol_18[4] = {1, x, (x + 1), nonempty[3]};
const int tint_symbol_19[2][4] = {tint_symbol_18, nested_nonempty[1][2]};
const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_19[1];
const int nested_nonempty[2][3][4] = {{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}, {{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}}};
const int tint_symbol[4] = {1, 2, x, (x + 1)};
const int tint_symbol_1[4] = {5, 6, nonempty[2], (nonempty[3] + 1)};
const int tint_symbol_2[3][4] = {tint_symbol, tint_symbol_1, nonempty};
const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_2, nested_nonempty[1]};
const int subexpr_empty = 0;
const int subexpr_nonempty = 3;
const int tint_symbol_3[4] = {1, x, (x + 1), nonempty[3]};
const int subexpr_nonempty_with_expr = tint_symbol_3[2];
const int subexpr_nested_empty[4] = (int[4])0;
const int subexpr_nested_nonempty[4] = {5, 6, 7, 8};
const int tint_symbol_4[4] = {1, x, (x + 1), nonempty[3]};
const int tint_symbol_5[2][4] = {tint_symbol_4, nested_nonempty[1][2]};
const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_5[1];
return;
}

View File

@ -5,33 +5,19 @@ void main() {
const int nonempty[4] = {1, 2, 3, 4};
const int nonempty_with_expr[4] = {1, x, (x + 1), nonempty[3]};
const int nested_empty[2][3][4] = (int[2][3][4])0;
const int tint_symbol[4] = {1, 2, 3, 4};
const int tint_symbol_1[4] = {5, 6, 7, 8};
const int tint_symbol_2[4] = {9, 10, 11, 12};
const int tint_symbol_3[3][4] = {tint_symbol, tint_symbol_1, tint_symbol_2};
const int tint_symbol_4[4] = {13, 14, 15, 16};
const int tint_symbol_5[4] = {17, 18, 19, 20};
const int tint_symbol_6[4] = {21, 22, 23, 24};
const int tint_symbol_7[3][4] = {tint_symbol_4, tint_symbol_5, tint_symbol_6};
const int nested_nonempty[2][3][4] = {tint_symbol_3, tint_symbol_7};
const int tint_symbol_8[4] = {1, 2, x, (x + 1)};
const int tint_symbol_9[4] = {5, 6, nonempty[2], (nonempty[3] + 1)};
const int tint_symbol_10[3][4] = {tint_symbol_8, tint_symbol_9, nonempty};
const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_10, nested_nonempty[1]};
const int tint_symbol_11[4] = (int[4])0;
const int subexpr_empty = tint_symbol_11[1];
const int tint_symbol_12[4] = {1, 2, 3, 4};
const int subexpr_nonempty = tint_symbol_12[2];
const int tint_symbol_13[4] = {1, x, (x + 1), nonempty[3]};
const int subexpr_nonempty_with_expr = tint_symbol_13[2];
const int tint_symbol_14[2][4] = (int[2][4])0;
const int subexpr_nested_empty[4] = tint_symbol_14[1];
const int tint_symbol_15[4] = {1, 2, 3, 4};
const int tint_symbol_16[4] = {5, 6, 7, 8};
const int tint_symbol_17[2][4] = {tint_symbol_15, tint_symbol_16};
const int subexpr_nested_nonempty[4] = tint_symbol_17[1];
const int tint_symbol_18[4] = {1, x, (x + 1), nonempty[3]};
const int tint_symbol_19[2][4] = {tint_symbol_18, nested_nonempty[1][2]};
const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_19[1];
const int nested_nonempty[2][3][4] = {{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}, {{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}}};
const int tint_symbol[4] = {1, 2, x, (x + 1)};
const int tint_symbol_1[4] = {5, 6, nonempty[2], (nonempty[3] + 1)};
const int tint_symbol_2[3][4] = {tint_symbol, tint_symbol_1, nonempty};
const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_2, nested_nonempty[1]};
const int subexpr_empty = 0;
const int subexpr_nonempty = 3;
const int tint_symbol_3[4] = {1, x, (x + 1), nonempty[3]};
const int subexpr_nonempty_with_expr = tint_symbol_3[2];
const int subexpr_nested_empty[4] = (int[4])0;
const int subexpr_nested_nonempty[4] = {5, 6, 7, 8};
const int tint_symbol_4[4] = {1, x, (x + 1), nonempty[3]};
const int tint_symbol_5[2][4] = {tint_symbol_4, nested_nonempty[1][2]};
const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_5[1];
return;
}

View File

@ -6,34 +6,20 @@ void tint_symbol() {
int nonempty[4] = int[4](1, 2, 3, 4);
int nonempty_with_expr[4] = int[4](1, x, (x + 1), nonempty[3]);
int nested_empty[2][3][4] = int[2][3][4](int[3][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0), int[4](0, 0, 0, 0)), int[3][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0), int[4](0, 0, 0, 0)));
int tint_symbol_1[4] = int[4](1, 2, 3, 4);
int tint_symbol_2[4] = int[4](5, 6, 7, 8);
int tint_symbol_3[4] = int[4](9, 10, 11, 12);
int tint_symbol_4[3][4] = int[3][4](tint_symbol_1, tint_symbol_2, tint_symbol_3);
int tint_symbol_5[4] = int[4](13, 14, 15, 16);
int tint_symbol_6[4] = int[4](17, 18, 19, 20);
int tint_symbol_7[4] = int[4](21, 22, 23, 24);
int tint_symbol_8[3][4] = int[3][4](tint_symbol_5, tint_symbol_6, tint_symbol_7);
int nested_nonempty[2][3][4] = int[2][3][4](tint_symbol_4, tint_symbol_8);
int tint_symbol_9[4] = int[4](1, 2, x, (x + 1));
int tint_symbol_10[4] = int[4](5, 6, nonempty[2], (nonempty[3] + 1));
int tint_symbol_11[3][4] = int[3][4](tint_symbol_9, tint_symbol_10, nonempty);
int nested_nonempty_with_expr[2][3][4] = int[2][3][4](tint_symbol_11, nested_nonempty[1]);
int tint_symbol_12[4] = int[4](0, 0, 0, 0);
int subexpr_empty = tint_symbol_12[1];
int tint_symbol_13[4] = int[4](1, 2, 3, 4);
int subexpr_nonempty = tint_symbol_13[2];
int tint_symbol_14[4] = int[4](1, x, (x + 1), nonempty[3]);
int subexpr_nonempty_with_expr = tint_symbol_14[2];
int tint_symbol_15[2][4] = int[2][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0));
int subexpr_nested_empty[4] = tint_symbol_15[1];
int tint_symbol_16[4] = int[4](1, 2, 3, 4);
int tint_symbol_17[4] = int[4](5, 6, 7, 8);
int tint_symbol_18[2][4] = int[2][4](tint_symbol_16, tint_symbol_17);
int subexpr_nested_nonempty[4] = tint_symbol_18[1];
int tint_symbol_19[4] = int[4](1, x, (x + 1), nonempty[3]);
int tint_symbol_20[2][4] = int[2][4](tint_symbol_19, nested_nonempty[1][2]);
int subexpr_nested_nonempty_with_expr[4] = tint_symbol_20[1];
int nested_nonempty[2][3][4] = int[2][3][4](int[3][4](int[4](1, 2, 3, 4), int[4](5, 6, 7, 8), int[4](9, 10, 11, 12)), int[3][4](int[4](13, 14, 15, 16), int[4](17, 18, 19, 20), int[4](21, 22, 23, 24)));
int tint_symbol_1[4] = int[4](1, 2, x, (x + 1));
int tint_symbol_2[4] = int[4](5, 6, nonempty[2], (nonempty[3] + 1));
int tint_symbol_3[3][4] = int[3][4](tint_symbol_1, tint_symbol_2, nonempty);
int nested_nonempty_with_expr[2][3][4] = int[2][3][4](tint_symbol_3, nested_nonempty[1]);
int subexpr_empty = 0;
int subexpr_nonempty = 3;
int tint_symbol_4[4] = int[4](1, x, (x + 1), nonempty[3]);
int subexpr_nonempty_with_expr = tint_symbol_4[2];
int subexpr_nested_empty[4] = int[4](0, 0, 0, 0);
int subexpr_nested_nonempty[4] = int[4](5, 6, 7, 8);
int tint_symbol_5[4] = int[4](1, x, (x + 1), nonempty[3]);
int tint_symbol_6[2][4] = int[2][4](tint_symbol_5, nested_nonempty[1][2]);
int subexpr_nested_nonempty_with_expr[4] = tint_symbol_6[1];
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -20,34 +20,20 @@ kernel void tint_symbol() {
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, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), nonempty[3]};
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, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1)))};
tint_array<int, 4> const tint_symbol_10 = tint_array<int, 4>{5, 6, nonempty[2], as_type<int>((as_type<uint>(nonempty[3]) + 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 = tint_symbol_12[1];
tint_array<int, 4> const tint_symbol_13 = tint_array<int, 4>{1, 2, 3, 4};
int const subexpr_nonempty = tint_symbol_13[2];
tint_array<int, 4> const tint_symbol_14 = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), nonempty[3]};
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, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), nonempty[3]};
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];
tint_array<tint_array<tint_array<int, 4>, 3>, 2> const nested_nonempty = tint_array<tint_array<tint_array<int, 4>, 3>, 2>{tint_array<tint_array<int, 4>, 3>{tint_array<int, 4>{1, 2, 3, 4}, tint_array<int, 4>{5, 6, 7, 8}, tint_array<int, 4>{9, 10, 11, 12}}, tint_array<tint_array<int, 4>, 3>{tint_array<int, 4>{13, 14, 15, 16}, tint_array<int, 4>{17, 18, 19, 20}, tint_array<int, 4>{21, 22, 23, 24}}};
tint_array<int, 4> const tint_symbol_1 = tint_array<int, 4>{1, 2, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1)))};
tint_array<int, 4> const tint_symbol_2 = tint_array<int, 4>{5, 6, nonempty[2], as_type<int>((as_type<uint>(nonempty[3]) + as_type<uint>(1)))};
tint_array<tint_array<int, 4>, 3> const tint_symbol_3 = tint_array<tint_array<int, 4>, 3>{tint_symbol_1, tint_symbol_2, 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_3, nested_nonempty[1]};
int const subexpr_empty = 0;
int const subexpr_nonempty = 3;
tint_array<int, 4> const tint_symbol_4 = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), nonempty[3]};
int const subexpr_nonempty_with_expr = tint_symbol_4[2];
tint_array<int, 4> const subexpr_nested_empty = tint_array<int, 4>{};
tint_array<int, 4> const subexpr_nested_nonempty = tint_array<int, 4>{5, 6, 7, 8};
tint_array<int, 4> const tint_symbol_5 = tint_array<int, 4>{1, x, as_type<int>((as_type<uint>(x) + as_type<uint>(1))), nonempty[3]};
tint_array<tint_array<int, 4>, 2> const tint_symbol_6 = tint_array<tint_array<int, 4>, 2>{tint_symbol_5, nested_nonempty[1][2]};
tint_array<int, 4> const subexpr_nested_nonempty_with_expr = tint_symbol_6[1];
return;
}

View File

@ -7,5 +7,6 @@ const faceNormals = array<Normals, 1>(
@vertex
fn main() -> @builtin(position) vec4<f32> {
return vec4(faceNormals[0].f, 1.);
let zero = 0;
return vec4(faceNormals[zero].f, 1.);
}

View File

@ -7,8 +7,9 @@ struct tint_symbol {
};
float4 main_inner() {
const int zero = 0;
const Normals tint_symbol_1[1] = {{float3(0.0f, 0.0f, 1.0f)}};
return float4(tint_symbol_1[0].f, 1.0f);
return float4(tint_symbol_1[zero].f, 1.0f);
}
tint_symbol main() {

View File

@ -7,8 +7,9 @@ struct tint_symbol {
};
float4 main_inner() {
const int zero = 0;
const Normals tint_symbol_1[1] = {{float3(0.0f, 0.0f, 1.0f)}};
return float4(tint_symbol_1[0].f, 1.0f);
return float4(tint_symbol_1[zero].f, 1.0f);
}
tint_symbol main() {

View File

@ -5,8 +5,9 @@ struct Normals {
};
vec4 tint_symbol() {
int zero = 0;
Normals tint_symbol_1[1] = Normals[1](Normals(vec3(0.0f, 0.0f, 1.0f)));
return vec4(tint_symbol_1[0].f, 1.0f);
return vec4(tint_symbol_1[zero].f, 1.0f);
}
void main() {

View File

@ -23,8 +23,9 @@ struct tint_symbol_1 {
};
float4 tint_symbol_inner() {
int const zero = 0;
tint_array<Normals, 1> const tint_symbol_2 = tint_array<Normals, 1>{Normals{.f=float3(0.0f, 0.0f, 1.0f)}};
return float4(tint_symbol_2[0].f, 1.0f);
return float4(tint_symbol_2[zero].f, 1.0f);
}
vertex tint_symbol_1 tint_symbol() {

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 19
; Bound: 39
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -9,9 +9,14 @@
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
OpName %main_inner "main_inner"
OpName %Normals "Normals"
OpMemberName %Normals 0 "f"
OpName %var_for_index "var_for_index"
OpName %main "main"
OpDecorate %value BuiltIn Position
OpDecorate %vertex_point_size BuiltIn PointSize
OpMemberDecorate %Normals 0 Offset 0
OpDecorate %_arr_Normals_uint_1 ArrayStride 16
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@ -21,18 +26,39 @@
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%9 = OpTypeFunction %v4float
%int = OpTypeInt 32 1
%13 = OpConstantNull %int
%v3float = OpTypeVector %float 3
%Normals = OpTypeStruct %v3float
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_arr_Normals_uint_1 = OpTypeArray %Normals %uint_1
%float_1 = OpConstant %float 1
%13 = OpConstantComposite %v4float %8 %8 %float_1 %float_1
%20 = OpConstantComposite %v3float %8 %8 %float_1
%21 = OpConstantComposite %Normals %20
%22 = OpConstantComposite %_arr_Normals_uint_1 %21
%_ptr_Function__arr_Normals_uint_1 = OpTypePointer Function %_arr_Normals_uint_1
%25 = OpConstantNull %_arr_Normals_uint_1
%uint_0 = OpConstant %uint 0
%_ptr_Function_v3float = OpTypePointer Function %v3float
%void = OpTypeVoid
%14 = OpTypeFunction %void
%34 = OpTypeFunction %void
%main_inner = OpFunction %v4float None %9
%11 = OpLabel
OpReturnValue %13
%var_for_index = OpVariable %_ptr_Function__arr_Normals_uint_1 Function %25
OpStore %var_for_index %22
%28 = OpAccessChain %_ptr_Function_v3float %var_for_index %13 %uint_0
%29 = OpLoad %v3float %28
%30 = OpCompositeExtract %float %29 0
%31 = OpCompositeExtract %float %29 1
%32 = OpCompositeExtract %float %29 2
%33 = OpCompositeConstruct %v4float %30 %31 %32 %float_1
OpReturnValue %33
OpFunctionEnd
%main = OpFunction %void None %14
%17 = OpLabel
%18 = OpFunctionCall %v4float %main_inner
OpStore %value %18
%main = OpFunction %void None %34
%37 = OpLabel
%38 = OpFunctionCall %v4float %main_inner
OpStore %value %38
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd

View File

@ -6,5 +6,6 @@ const faceNormals = array<Normals, 1>(Normals(vec3(0, 0, 1)));
@vertex
fn main() -> @builtin(position) vec4<f32> {
return vec4(faceNormals[0].f, 1.0);
let zero = 0;
return vec4(faceNormals[zero].f, 1.0);
}

View File

@ -0,0 +1,7 @@
struct S {
a : i32, b : f32
}
fn f() {
const v = S(1, 2.0).a == 0;
}

View File

@ -0,0 +1,7 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
void f() {
}

View File

@ -0,0 +1,7 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
void f() {
}

View File

@ -0,0 +1,14 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
struct S {
int a;
float b;
};
void f() {
}

View File

@ -0,0 +1,11 @@
#include <metal_stdlib>
using namespace metal;
struct S {
int a;
float b;
};
void f() {
}

View File

@ -0,0 +1,21 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 7
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,8 @@
struct S {
a : i32,
b : f32,
}
fn f() {
const v = (S(1, 2.0).a == 0);
}

View File

@ -1,12 +1,6 @@
struct frexp_result_f32 {
float fract;
int exp;
};
[numthreads(1, 1, 1)]
void main() {
const frexp_result_f32 tint_symbol_1 = {0.625f, 1};
const float fract = tint_symbol_1.fract;
const frexp_result_f32 tint_symbol_2 = {0.625f, 1};
const int exp = tint_symbol_2.exp;
const float fract = 0.625f;
const int exp = 1;
return;
}

View File

@ -1,12 +1,6 @@
struct frexp_result_f32 {
float fract;
int exp;
};
[numthreads(1, 1, 1)]
void main() {
const frexp_result_f32 tint_symbol_1 = {0.625f, 1};
const float fract = tint_symbol_1.fract;
const frexp_result_f32 tint_symbol_2 = {0.625f, 1};
const int exp = tint_symbol_2.exp;
const float fract = 0.625f;
const int exp = 1;
return;
}

View File

@ -1,16 +1,8 @@
#version 310 es
struct frexp_result_f32 {
float fract;
int exp;
};
void tint_symbol() {
frexp_result_f32 tint_symbol_4 = frexp_result_f32(0.625f, 1);
float tint_symbol_2 = tint_symbol_4.fract;
frexp_result_f32 tint_symbol_5 = frexp_result_f32(0.625f, 1);
int tint_symbol_3 = tint_symbol_5.exp;
float tint_symbol_2 = 0.625f;
int tint_symbol_3 = 1;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,16 +1,9 @@
#include <metal_stdlib>
using namespace metal;
struct frexp_result_f32 {
float fract;
int exp;
};
kernel void tint_symbol() {
frexp_result_f32 const tint_symbol_1 = frexp_result_f32{.fract=0.625f, .exp=1};
float const fract = tint_symbol_1.fract;
frexp_result_f32 const tint_symbol_2 = frexp_result_f32{.fract=0.625f, .exp=1};
int const exp = tint_symbol_2.exp;
float const fract = 0.625f;
int const exp = 1;
return;
}

View File

@ -1,12 +1,6 @@
struct frexp_result_vec2_f32 {
float2 fract;
int2 exp;
};
[numthreads(1, 1, 1)]
void main() {
const frexp_result_vec2_f32 tint_symbol_1 = {float2(0.625f, 0.9375f), int2(1, 2)};
const float2 fract = tint_symbol_1.fract;
const frexp_result_vec2_f32 tint_symbol_2 = {float2(0.625f, 0.9375f), int2(1, 2)};
const int2 exp = tint_symbol_2.exp;
const float2 fract = float2(0.625f, 0.9375f);
const int2 exp = int2(1, 2);
return;
}

View File

@ -1,12 +1,6 @@
struct frexp_result_vec2_f32 {
float2 fract;
int2 exp;
};
[numthreads(1, 1, 1)]
void main() {
const frexp_result_vec2_f32 tint_symbol_1 = {float2(0.625f, 0.9375f), int2(1, 2)};
const float2 fract = tint_symbol_1.fract;
const frexp_result_vec2_f32 tint_symbol_2 = {float2(0.625f, 0.9375f), int2(1, 2)};
const int2 exp = tint_symbol_2.exp;
const float2 fract = float2(0.625f, 0.9375f);
const int2 exp = int2(1, 2);
return;
}

View File

@ -1,16 +1,8 @@
#version 310 es
struct frexp_result_vec2_f32 {
vec2 fract;
ivec2 exp;
};
void tint_symbol() {
frexp_result_vec2_f32 tint_symbol_4 = frexp_result_vec2_f32(vec2(0.625f, 0.9375f), ivec2(1, 2));
vec2 tint_symbol_2 = tint_symbol_4.fract;
frexp_result_vec2_f32 tint_symbol_5 = frexp_result_vec2_f32(vec2(0.625f, 0.9375f), ivec2(1, 2));
ivec2 tint_symbol_3 = tint_symbol_5.exp;
vec2 tint_symbol_2 = vec2(0.625f, 0.9375f);
ivec2 tint_symbol_3 = ivec2(1, 2);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,16 +1,9 @@
#include <metal_stdlib>
using namespace metal;
struct frexp_result_vec2_f32 {
float2 fract;
int2 exp;
};
kernel void tint_symbol() {
frexp_result_vec2_f32 const tint_symbol_1 = frexp_result_vec2_f32{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)};
float2 const fract = tint_symbol_1.fract;
frexp_result_vec2_f32 const tint_symbol_2 = frexp_result_vec2_f32{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)};
int2 const exp = tint_symbol_2.exp;
float2 const fract = float2(0.625f, 0.9375f);
int2 const exp = int2(1, 2);
return;
}

View File

@ -1,12 +1,6 @@
struct modf_result_f32 {
float fract;
float whole;
};
[numthreads(1, 1, 1)]
void main() {
const modf_result_f32 tint_symbol_1 = {0.25f, 1.0f};
const float fract = tint_symbol_1.fract;
const modf_result_f32 tint_symbol_2 = {0.25f, 1.0f};
const float whole = tint_symbol_2.whole;
const float fract = 0.25f;
const float whole = 1.0f;
return;
}

View File

@ -1,12 +1,6 @@
struct modf_result_f32 {
float fract;
float whole;
};
[numthreads(1, 1, 1)]
void main() {
const modf_result_f32 tint_symbol_1 = {0.25f, 1.0f};
const float fract = tint_symbol_1.fract;
const modf_result_f32 tint_symbol_2 = {0.25f, 1.0f};
const float whole = tint_symbol_2.whole;
const float fract = 0.25f;
const float whole = 1.0f;
return;
}

View File

@ -1,16 +1,8 @@
#version 310 es
struct modf_result_f32 {
float fract;
float whole;
};
void tint_symbol() {
modf_result_f32 tint_symbol_3 = modf_result_f32(0.25f, 1.0f);
float tint_symbol_2 = tint_symbol_3.fract;
modf_result_f32 tint_symbol_4 = modf_result_f32(0.25f, 1.0f);
float whole = tint_symbol_4.whole;
float tint_symbol_2 = 0.25f;
float whole = 1.0f;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,16 +1,9 @@
#include <metal_stdlib>
using namespace metal;
struct modf_result_f32 {
float fract;
float whole;
};
kernel void tint_symbol() {
modf_result_f32 const tint_symbol_1 = modf_result_f32{.fract=0.25f, .whole=1.0f};
float const fract = tint_symbol_1.fract;
modf_result_f32 const tint_symbol_2 = modf_result_f32{.fract=0.25f, .whole=1.0f};
float const whole = tint_symbol_2.whole;
float const fract = 0.25f;
float const whole = 1.0f;
return;
}

View File

@ -1,12 +1,6 @@
struct modf_result_vec2_f32 {
float2 fract;
float2 whole;
};
[numthreads(1, 1, 1)]
void main() {
const modf_result_vec2_f32 tint_symbol_1 = {float2(0.25f, 0.75f), float2(1.0f, 3.0f)};
const float2 fract = tint_symbol_1.fract;
const modf_result_vec2_f32 tint_symbol_2 = {float2(0.25f, 0.75f), float2(1.0f, 3.0f)};
const float2 whole = tint_symbol_2.whole;
const float2 fract = float2(0.25f, 0.75f);
const float2 whole = float2(1.0f, 3.0f);
return;
}

View File

@ -1,12 +1,6 @@
struct modf_result_vec2_f32 {
float2 fract;
float2 whole;
};
[numthreads(1, 1, 1)]
void main() {
const modf_result_vec2_f32 tint_symbol_1 = {float2(0.25f, 0.75f), float2(1.0f, 3.0f)};
const float2 fract = tint_symbol_1.fract;
const modf_result_vec2_f32 tint_symbol_2 = {float2(0.25f, 0.75f), float2(1.0f, 3.0f)};
const float2 whole = tint_symbol_2.whole;
const float2 fract = float2(0.25f, 0.75f);
const float2 whole = float2(1.0f, 3.0f);
return;
}

View File

@ -1,16 +1,8 @@
#version 310 es
struct modf_result_vec2_f32 {
vec2 fract;
vec2 whole;
};
void tint_symbol() {
modf_result_vec2_f32 tint_symbol_3 = modf_result_vec2_f32(vec2(0.25f, 0.75f), vec2(1.0f, 3.0f));
vec2 tint_symbol_2 = tint_symbol_3.fract;
modf_result_vec2_f32 tint_symbol_4 = modf_result_vec2_f32(vec2(0.25f, 0.75f), vec2(1.0f, 3.0f));
vec2 whole = tint_symbol_4.whole;
vec2 tint_symbol_2 = vec2(0.25f, 0.75f);
vec2 whole = vec2(1.0f, 3.0f);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,16 +1,9 @@
#include <metal_stdlib>
using namespace metal;
struct modf_result_vec2_f32 {
float2 fract;
float2 whole;
};
kernel void tint_symbol() {
modf_result_vec2_f32 const tint_symbol_1 = modf_result_vec2_f32{.fract=float2(0.25f, 0.75f), .whole=float2(1.0f, 3.0f)};
float2 const fract = tint_symbol_1.fract;
modf_result_vec2_f32 const tint_symbol_2 = modf_result_vec2_f32{.fract=float2(0.25f, 0.75f), .whole=float2(1.0f, 3.0f)};
float2 const whole = tint_symbol_2.whole;
float2 const fract = float2(0.25f, 0.75f);
float2 const whole = float2(1.0f, 3.0f);
return;
}

View File

@ -5,12 +5,8 @@ void unused_entry_point() {
void f() {
int i = 0;
while (true) {
const int tint_symbol[1] = {1};
if (!((i < tint_symbol[0]))) {
break;
}
{
{
for(; (i < 1); ) {
}
}
}

View File

@ -5,12 +5,8 @@ void unused_entry_point() {
void f() {
int i = 0;
while (true) {
const int tint_symbol[1] = {1};
if (!((i < tint_symbol[0]))) {
break;
}
{
{
for(; (i < 1); ) {
}
}
}

View File

@ -6,12 +6,8 @@ void unused_entry_point() {
}
void f() {
int i = 0;
while (true) {
int tint_symbol[1] = int[1](1);
if (!((i < tint_symbol[0]))) {
break;
}
{
{
for(; (i < 1); ) {
}
}
}

View File

@ -1,28 +1,9 @@
#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];
};
void f() {
int i = 0;
while (true) {
tint_array<int, 1> const tint_symbol = tint_array<int, 1>{1};
if (!((i < tint_symbol[0]))) {
break;
}
{
}
for(; (i < 1); ) {
}
}

View File

@ -3,18 +3,10 @@ void unused_entry_point() {
return;
}
struct S {
int i;
};
void f() {
int i = 0;
while (true) {
const S tint_symbol = {1};
if (!((i < tint_symbol.i))) {
break;
}
{
{
for(; (i < 1); ) {
}
}
}

View File

@ -3,18 +3,10 @@ void unused_entry_point() {
return;
}
struct S {
int i;
};
void f() {
int i = 0;
while (true) {
const S tint_symbol = {1};
if (!((i < tint_symbol.i))) {
break;
}
{
{
for(; (i < 1); ) {
}
}
}

View File

@ -10,12 +10,8 @@ struct S {
void f() {
int i = 0;
while (true) {
S tint_symbol = S(1);
if (!((i < tint_symbol.i))) {
break;
}
{
{
for(; (i < 1); ) {
}
}
}

View File

@ -7,13 +7,7 @@ struct S {
void f() {
int i = 0;
while (true) {
S const tint_symbol = S{.i=1};
if (!((i < tint_symbol.i))) {
break;
}
{
}
for(; (i < 1); ) {
}
}

View File

@ -5,15 +5,8 @@ void unused_entry_point() {
void f() {
int i = 0;
while (true) {
if (true) {
break;
}
{
}
{
const int tint_symbol[1] = {1};
i = (i + tint_symbol[0]);
{
for(; false; i = (i + 1)) {
}
}
}

View File

@ -5,15 +5,8 @@ void unused_entry_point() {
void f() {
int i = 0;
while (true) {
if (true) {
break;
}
{
}
{
const int tint_symbol[1] = {1};
i = (i + tint_symbol[0]);
{
for(; false; i = (i + 1)) {
}
}
}

View File

@ -6,15 +6,8 @@ void unused_entry_point() {
}
void f() {
int i = 0;
while (true) {
if (true) {
break;
}
{
}
{
int tint_symbol[1] = int[1](1);
i = (i + tint_symbol[0]);
{
for(; false; i = (i + 1)) {
}
}
}

View File

@ -1,31 +1,9 @@
#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];
};
void f() {
int i = 0;
while (true) {
if (true) {
break;
}
{
}
{
tint_array<int, 1> const tint_symbol = tint_array<int, 1>{1};
i = as_type<int>((as_type<uint>(i) + as_type<uint>(tint_symbol[0])));
}
for(; false; i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)))) {
}
}

View File

@ -3,23 +3,9 @@ void unused_entry_point() {
return;
}
struct S {
int i;
};
void f() {
{
int i = 0;
while (true) {
if (true) {
break;
}
{
}
{
const S tint_symbol = {1};
i = (i + tint_symbol.i);
}
for(int i = 0; false; i = (i + 1)) {
}
}
}

View File

@ -3,23 +3,9 @@ void unused_entry_point() {
return;
}
struct S {
int i;
};
void f() {
{
int i = 0;
while (true) {
if (true) {
break;
}
{
}
{
const S tint_symbol = {1};
i = (i + tint_symbol.i);
}
for(int i = 0; false; i = (i + 1)) {
}
}
}

View File

@ -10,17 +10,7 @@ struct S {
void f() {
{
int i = 0;
while (true) {
if (true) {
break;
}
{
}
{
S tint_symbol = S(1);
i = (i + tint_symbol.i);
}
for(int i = 0; false; i = (i + 1)) {
}
}
}

View File

@ -6,19 +6,7 @@ struct S {
};
void f() {
{
int i = 0;
while (true) {
if (true) {
break;
}
{
}
{
S const tint_symbol = S{.i=1};
i = as_type<int>((as_type<uint>(i) + as_type<uint>(tint_symbol.i)));
}
}
for(int i = 0; false; i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)))) {
}
}

View File

@ -4,9 +4,8 @@ void unused_entry_point() {
}
void f() {
const int tint_symbol[1] = {1};
{
for(int i = tint_symbol[0]; false; ) {
for(int i = 1; false; ) {
}
}
}

View File

@ -4,9 +4,8 @@ void unused_entry_point() {
}
void f() {
const int tint_symbol[1] = {1};
{
for(int i = tint_symbol[0]; false; ) {
for(int i = 1; false; ) {
}
}
}

View File

@ -5,9 +5,8 @@ void unused_entry_point() {
return;
}
void f() {
int tint_symbol[1] = int[1](1);
{
for(int i = tint_symbol[0]; false; ) {
for(int i = 1; false; ) {
}
}
}

View File

@ -1,22 +1,8 @@
#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];
};
void f() {
tint_array<int, 1> const tint_symbol = tint_array<int, 1>{1};
for(int i = tint_symbol[0]; false; ) {
for(int i = 1; false; ) {
}
}

View File

@ -3,14 +3,9 @@ void unused_entry_point() {
return;
}
struct S {
int i;
};
void f() {
const S tint_symbol = {1};
{
for(int i = tint_symbol.i; false; ) {
for(int i = 1; false; ) {
}
}
}

View File

@ -3,14 +3,9 @@ void unused_entry_point() {
return;
}
struct S {
int i;
};
void f() {
const S tint_symbol = {1};
{
for(int i = tint_symbol.i; false; ) {
for(int i = 1; false; ) {
}
}
}

View File

@ -9,9 +9,8 @@ struct S {
};
void f() {
S tint_symbol = S(1);
{
for(int i = tint_symbol.i; false; ) {
for(int i = 1; false; ) {
}
}
}

View File

@ -6,8 +6,7 @@ struct S {
};
void f() {
S const tint_symbol = S{.i=1};
for(int i = tint_symbol.i; false; ) {
for(int i = 1; false; ) {
}
}

View File

@ -24,35 +24,23 @@ void main() {
const S1 nonempty = {1, 2, 3, 4};
const S1 nonempty_with_expr = {1, x, (x + 1), nonempty.d};
const S3 nested_empty = (S3)0;
const S1 tint_symbol = {2, 3, 4, 5};
const S1 tint_symbol_1 = {7, 8, 9, 10};
const S2 tint_symbol_2 = {6, tint_symbol_1};
const S3 nested_nonempty = {1, tint_symbol, tint_symbol_2};
const S3 nested_nonempty = {1, {2, 3, 4, 5}, {6, {7, 8, 9, 10}}};
const S1 tint_symbol = {2, x, (x + 1), nested_nonempty.i.f.d};
const S2 tint_symbol_1 = {6, nonempty};
const S3 nested_nonempty_with_expr = {1, tint_symbol, tint_symbol_1};
const int subexpr_empty = 0;
const int subexpr_nonempty = 2;
const S1 tint_symbol_2 = {1, x, (x + 1), nonempty.d};
const int subexpr_nonempty_with_expr = tint_symbol_2.c;
const S1 subexpr_nested_empty = (S1)0;
const S1 subexpr_nested_nonempty = {2, 3, 4, 5};
const S1 tint_symbol_3 = {2, x, (x + 1), nested_nonempty.i.f.d};
const S2 tint_symbol_4 = {6, nonempty};
const S3 nested_nonempty_with_expr = {1, tint_symbol_3, tint_symbol_4};
const S1 tint_symbol_5 = (S1)0;
const int subexpr_empty = tint_symbol_5.a;
const S1 tint_symbol_6 = {1, 2, 3, 4};
const int subexpr_nonempty = tint_symbol_6.b;
const S1 tint_symbol_7 = {1, x, (x + 1), nonempty.d};
const int subexpr_nonempty_with_expr = tint_symbol_7.c;
const S2 tint_symbol_8 = (S2)0;
const S1 subexpr_nested_empty = tint_symbol_8.f;
const S1 tint_symbol_9 = {2, 3, 4, 5};
const S2 tint_symbol_10 = {1, tint_symbol_9};
const S1 subexpr_nested_nonempty = tint_symbol_10.f;
const S1 tint_symbol_11 = {2, x, (x + 1), nested_nonempty.i.f.d};
const S2 tint_symbol_12 = {1, tint_symbol_11};
const S1 subexpr_nested_nonempty_with_expr = tint_symbol_12.f;
const S2 tint_symbol_4 = {1, tint_symbol_3};
const S1 subexpr_nested_nonempty_with_expr = tint_symbol_4.f;
const T aosoa_empty[2] = (T[2])0;
const int tint_symbol_13[2] = {1, 2};
const T tint_symbol_14 = {tint_symbol_13};
const int tint_symbol_15[2] = {3, 4};
const T tint_symbol_16 = {tint_symbol_15};
const T aosoa_nonempty[2] = {tint_symbol_14, tint_symbol_16};
const int tint_symbol_17[2] = {1, (aosoa_nonempty[0].a[0] + 1)};
const T tint_symbol_18 = {tint_symbol_17};
const T aosoa_nonempty_with_expr[2] = {tint_symbol_18, aosoa_nonempty[1]};
const T aosoa_nonempty[2] = {{{1, 2}}, {{3, 4}}};
const int tint_symbol_5[2] = {1, (aosoa_nonempty[0].a[0] + 1)};
const T tint_symbol_6 = {tint_symbol_5};
const T aosoa_nonempty_with_expr[2] = {tint_symbol_6, aosoa_nonempty[1]};
return;
}

View File

@ -24,35 +24,23 @@ void main() {
const S1 nonempty = {1, 2, 3, 4};
const S1 nonempty_with_expr = {1, x, (x + 1), nonempty.d};
const S3 nested_empty = (S3)0;
const S1 tint_symbol = {2, 3, 4, 5};
const S1 tint_symbol_1 = {7, 8, 9, 10};
const S2 tint_symbol_2 = {6, tint_symbol_1};
const S3 nested_nonempty = {1, tint_symbol, tint_symbol_2};
const S3 nested_nonempty = {1, {2, 3, 4, 5}, {6, {7, 8, 9, 10}}};
const S1 tint_symbol = {2, x, (x + 1), nested_nonempty.i.f.d};
const S2 tint_symbol_1 = {6, nonempty};
const S3 nested_nonempty_with_expr = {1, tint_symbol, tint_symbol_1};
const int subexpr_empty = 0;
const int subexpr_nonempty = 2;
const S1 tint_symbol_2 = {1, x, (x + 1), nonempty.d};
const int subexpr_nonempty_with_expr = tint_symbol_2.c;
const S1 subexpr_nested_empty = (S1)0;
const S1 subexpr_nested_nonempty = {2, 3, 4, 5};
const S1 tint_symbol_3 = {2, x, (x + 1), nested_nonempty.i.f.d};
const S2 tint_symbol_4 = {6, nonempty};
const S3 nested_nonempty_with_expr = {1, tint_symbol_3, tint_symbol_4};
const S1 tint_symbol_5 = (S1)0;
const int subexpr_empty = tint_symbol_5.a;
const S1 tint_symbol_6 = {1, 2, 3, 4};
const int subexpr_nonempty = tint_symbol_6.b;
const S1 tint_symbol_7 = {1, x, (x + 1), nonempty.d};
const int subexpr_nonempty_with_expr = tint_symbol_7.c;
const S2 tint_symbol_8 = (S2)0;
const S1 subexpr_nested_empty = tint_symbol_8.f;
const S1 tint_symbol_9 = {2, 3, 4, 5};
const S2 tint_symbol_10 = {1, tint_symbol_9};
const S1 subexpr_nested_nonempty = tint_symbol_10.f;
const S1 tint_symbol_11 = {2, x, (x + 1), nested_nonempty.i.f.d};
const S2 tint_symbol_12 = {1, tint_symbol_11};
const S1 subexpr_nested_nonempty_with_expr = tint_symbol_12.f;
const S2 tint_symbol_4 = {1, tint_symbol_3};
const S1 subexpr_nested_nonempty_with_expr = tint_symbol_4.f;
const T aosoa_empty[2] = (T[2])0;
const int tint_symbol_13[2] = {1, 2};
const T tint_symbol_14 = {tint_symbol_13};
const int tint_symbol_15[2] = {3, 4};
const T tint_symbol_16 = {tint_symbol_15};
const T aosoa_nonempty[2] = {tint_symbol_14, tint_symbol_16};
const int tint_symbol_17[2] = {1, (aosoa_nonempty[0].a[0] + 1)};
const T tint_symbol_18 = {tint_symbol_17};
const T aosoa_nonempty_with_expr[2] = {tint_symbol_18, aosoa_nonempty[1]};
const T aosoa_nonempty[2] = {{{1, 2}}, {{3, 4}}};
const int tint_symbol_5[2] = {1, (aosoa_nonempty[0].a[0] + 1)};
const T tint_symbol_6 = {tint_symbol_5};
const T aosoa_nonempty_with_expr[2] = {tint_symbol_6, aosoa_nonempty[1]};
return;
}

View File

@ -28,36 +28,24 @@ void tint_symbol() {
S1 nonempty = S1(1, 2, 3, 4);
S1 nonempty_with_expr = S1(1, x, (x + 1), nonempty.d);
S3 nested_empty = S3(0, S1(0, 0, 0, 0), S2(0, S1(0, 0, 0, 0)));
S1 tint_symbol_1 = S1(2, 3, 4, 5);
S1 tint_symbol_2 = S1(7, 8, 9, 10);
S2 tint_symbol_3 = S2(6, tint_symbol_2);
S3 nested_nonempty = S3(1, tint_symbol_1, tint_symbol_3);
S3 nested_nonempty = S3(1, S1(2, 3, 4, 5), S2(6, S1(7, 8, 9, 10)));
S1 tint_symbol_1 = S1(2, x, (x + 1), nested_nonempty.i.f.d);
S2 tint_symbol_2 = S2(6, nonempty);
S3 nested_nonempty_with_expr = S3(1, tint_symbol_1, tint_symbol_2);
int subexpr_empty = 0;
int subexpr_nonempty = 2;
S1 tint_symbol_3 = S1(1, x, (x + 1), nonempty.d);
int subexpr_nonempty_with_expr = tint_symbol_3.c;
S1 subexpr_nested_empty = S1(0, 0, 0, 0);
S1 subexpr_nested_nonempty = S1(2, 3, 4, 5);
S1 tint_symbol_4 = S1(2, x, (x + 1), nested_nonempty.i.f.d);
S2 tint_symbol_5 = S2(6, nonempty);
S3 nested_nonempty_with_expr = S3(1, tint_symbol_4, tint_symbol_5);
S1 tint_symbol_6 = S1(0, 0, 0, 0);
int subexpr_empty = tint_symbol_6.a;
S1 tint_symbol_7 = S1(1, 2, 3, 4);
int subexpr_nonempty = tint_symbol_7.b;
S1 tint_symbol_8 = S1(1, x, (x + 1), nonempty.d);
int subexpr_nonempty_with_expr = tint_symbol_8.c;
S2 tint_symbol_9 = S2(0, S1(0, 0, 0, 0));
S1 subexpr_nested_empty = tint_symbol_9.f;
S1 tint_symbol_10 = S1(2, 3, 4, 5);
S2 tint_symbol_11 = S2(1, tint_symbol_10);
S1 subexpr_nested_nonempty = tint_symbol_11.f;
S1 tint_symbol_12 = S1(2, x, (x + 1), nested_nonempty.i.f.d);
S2 tint_symbol_13 = S2(1, tint_symbol_12);
S1 subexpr_nested_nonempty_with_expr = tint_symbol_13.f;
S2 tint_symbol_5 = S2(1, tint_symbol_4);
S1 subexpr_nested_nonempty_with_expr = tint_symbol_5.f;
T aosoa_empty[2] = T[2](T(int[2](0, 0)), T(int[2](0, 0)));
int tint_symbol_14[2] = int[2](1, 2);
T tint_symbol_15 = T(tint_symbol_14);
int tint_symbol_16[2] = int[2](3, 4);
T tint_symbol_17 = T(tint_symbol_16);
T aosoa_nonempty[2] = T[2](tint_symbol_15, tint_symbol_17);
int tint_symbol_18[2] = int[2](1, (aosoa_nonempty[0].a[0] + 1));
T tint_symbol_19 = T(tint_symbol_18);
T aosoa_nonempty_with_expr[2] = T[2](tint_symbol_19, aosoa_nonempty[1]);
T aosoa_nonempty[2] = T[2](T(int[2](1, 2)), T(int[2](3, 4)));
int tint_symbol_6[2] = int[2](1, (aosoa_nonempty[0].a[0] + 1));
T tint_symbol_7 = T(tint_symbol_6);
T aosoa_nonempty_with_expr[2] = T[2](tint_symbol_7, aosoa_nonempty[1]);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -42,36 +42,24 @@ kernel void tint_symbol() {
S1 const nonempty = S1{.a=1, .b=2, .c=3, .d=4};
S1 const nonempty_with_expr = {.a=1, .b=x, .c=as_type<int>((as_type<uint>(x) + as_type<uint>(1))), .d=nonempty.d};
S3 const nested_empty = S3{};
S1 const tint_symbol_1 = S1{.a=2, .b=3, .c=4, .d=5};
S1 const tint_symbol_2 = S1{.a=7, .b=8, .c=9, .d=10};
S2 const tint_symbol_3 = {.e=6, .f=tint_symbol_2};
S3 const nested_nonempty = {.g=1, .h=tint_symbol_1, .i=tint_symbol_3};
S3 const nested_nonempty = S3{.g=1, .h=S1{.a=2, .b=3, .c=4, .d=5}, .i=S2{.e=6, .f=S1{.a=7, .b=8, .c=9, .d=10}}};
S1 const tint_symbol_1 = {.a=2, .b=x, .c=as_type<int>((as_type<uint>(x) + as_type<uint>(1))), .d=nested_nonempty.i.f.d};
S2 const tint_symbol_2 = {.e=6, .f=nonempty};
S3 const nested_nonempty_with_expr = {.g=1, .h=tint_symbol_1, .i=tint_symbol_2};
int const subexpr_empty = 0;
int const subexpr_nonempty = 2;
S1 const tint_symbol_3 = {.a=1, .b=x, .c=as_type<int>((as_type<uint>(x) + as_type<uint>(1))), .d=nonempty.d};
int const subexpr_nonempty_with_expr = tint_symbol_3.c;
S1 const subexpr_nested_empty = S1{};
S1 const subexpr_nested_nonempty = S1{.a=2, .b=3, .c=4, .d=5};
S1 const tint_symbol_4 = {.a=2, .b=x, .c=as_type<int>((as_type<uint>(x) + as_type<uint>(1))), .d=nested_nonempty.i.f.d};
S2 const tint_symbol_5 = {.e=6, .f=nonempty};
S3 const nested_nonempty_with_expr = {.g=1, .h=tint_symbol_4, .i=tint_symbol_5};
S1 const tint_symbol_6 = S1{};
int const subexpr_empty = tint_symbol_6.a;
S1 const tint_symbol_7 = S1{.a=1, .b=2, .c=3, .d=4};
int const subexpr_nonempty = tint_symbol_7.b;
S1 const tint_symbol_8 = {.a=1, .b=x, .c=as_type<int>((as_type<uint>(x) + as_type<uint>(1))), .d=nonempty.d};
int const subexpr_nonempty_with_expr = tint_symbol_8.c;
S2 const tint_symbol_9 = S2{};
S1 const subexpr_nested_empty = tint_symbol_9.f;
S1 const tint_symbol_10 = S1{.a=2, .b=3, .c=4, .d=5};
S2 const tint_symbol_11 = {.e=1, .f=tint_symbol_10};
S1 const subexpr_nested_nonempty = tint_symbol_11.f;
S1 const tint_symbol_12 = {.a=2, .b=x, .c=as_type<int>((as_type<uint>(x) + as_type<uint>(1))), .d=nested_nonempty.i.f.d};
S2 const tint_symbol_13 = {.e=1, .f=tint_symbol_12};
S1 const subexpr_nested_nonempty_with_expr = tint_symbol_13.f;
S2 const tint_symbol_5 = {.e=1, .f=tint_symbol_4};
S1 const subexpr_nested_nonempty_with_expr = tint_symbol_5.f;
tint_array<T, 2> const aosoa_empty = tint_array<T, 2>{};
tint_array<int, 2> const tint_symbol_14 = tint_array<int, 2>{1, 2};
T const tint_symbol_15 = {.a=tint_symbol_14};
tint_array<int, 2> const tint_symbol_16 = tint_array<int, 2>{3, 4};
T const tint_symbol_17 = {.a=tint_symbol_16};
tint_array<T, 2> const aosoa_nonempty = tint_array<T, 2>{tint_symbol_15, tint_symbol_17};
tint_array<int, 2> const tint_symbol_18 = tint_array<int, 2>{1, as_type<int>((as_type<uint>(aosoa_nonempty[0].a[0]) + as_type<uint>(1)))};
T const tint_symbol_19 = {.a=tint_symbol_18};
tint_array<T, 2> const aosoa_nonempty_with_expr = tint_array<T, 2>{tint_symbol_19, aosoa_nonempty[1]};
tint_array<T, 2> const aosoa_nonempty = tint_array<T, 2>{T{.a=tint_array<int, 2>{1, 2}}, T{.a=tint_array<int, 2>{3, 4}}};
tint_array<int, 2> const tint_symbol_6 = tint_array<int, 2>{1, as_type<int>((as_type<uint>(aosoa_nonempty[0].a[0]) + as_type<uint>(1)))};
T const tint_symbol_7 = {.a=tint_symbol_6};
tint_array<T, 2> const aosoa_nonempty_with_expr = tint_array<T, 2>{tint_symbol_7, aosoa_nonempty[1]};
return;
}

View File

@ -1,8 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
int zero[2][3] = (int[2][3])0;
const int tint_symbol[3] = {1, 2, 3};
const int tint_symbol_1[3] = {4, 5, 6};
int init[2][3] = {tint_symbol, tint_symbol_1};
int init[2][3] = {{1, 2, 3}, {4, 5, 6}};
return;
}

View File

@ -1,8 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
int zero[2][3] = (int[2][3])0;
const int tint_symbol[3] = {1, 2, 3};
const int tint_symbol_1[3] = {4, 5, 6};
int init[2][3] = {tint_symbol, tint_symbol_1};
int init[2][3] = {{1, 2, 3}, {4, 5, 6}};
return;
}

View File

@ -2,9 +2,7 @@
void tint_symbol() {
int zero[2][3] = int[2][3](int[3](0, 0, 0), int[3](0, 0, 0));
int tint_symbol_1[3] = int[3](1, 2, 3);
int tint_symbol_2[3] = int[3](4, 5, 6);
int init[2][3] = int[2][3](tint_symbol_1, tint_symbol_2);
int init[2][3] = int[2][3](int[3](1, 2, 3), int[3](4, 5, 6));
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -16,9 +16,7 @@ struct tint_array {
kernel void tint_symbol() {
tint_array<tint_array<int, 3>, 2> zero = {};
tint_array<int, 3> const tint_symbol_1 = tint_array<int, 3>{1, 2, 3};
tint_array<int, 3> const tint_symbol_2 = tint_array<int, 3>{4, 5, 6};
tint_array<tint_array<int, 3>, 2> init = tint_array<tint_array<int, 3>, 2>{tint_symbol_1, tint_symbol_2};
tint_array<tint_array<int, 3>, 2> init = tint_array<tint_array<int, 3>, 2>{tint_array<int, 3>{1, 2, 3}, tint_array<int, 3>{4, 5, 6}};
return;
}