From d68d3a9809c1bcaecb89db1400fba66540abbdb5 Mon Sep 17 00:00:00 2001 From: James Price Date: Thu, 7 Apr 2022 13:42:45 +0000 Subject: [PATCH] Add support for increment/decrement statements Refactor the ExpandCompoundAssignment transform to handle these statements, which delivers support for all of the non-WGSL backends. Fixed: tint:1488 Change-Id: I96cdc31851c61f6d92d296447d0b0637907d5fe5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86004 Reviewed-by: Ben Clayton --- docs/tint/origin-trial-changes.md | 1 + .../transform/expand_compound_assignment.cc | 235 ++++++++------ .../transform/expand_compound_assignment.h | 3 + .../expand_compound_assignment_test.cc | 289 ++++++++++++++++++ .../array_element.wgsl.expected.glsl | 17 +- .../array_element.wgsl.expected.hlsl | 16 +- .../decrement/array_element.wgsl.expected.msl | 11 +- .../array_element.wgsl.expected.spvasm | 54 +++- .../decrement/complex.wgsl.expected.glsl | 69 +++-- .../decrement/complex.wgsl.expected.hlsl | 64 ++-- .../decrement/complex.wgsl.expected.msl | 64 ++-- .../decrement/complex.wgsl.expected.spvasm | 186 ++++++++--- .../for_loop_continuing.wgsl.expected.glsl | 21 +- .../for_loop_continuing.wgsl.expected.hlsl | 20 +- .../for_loop_continuing.wgsl.expected.msl | 11 +- .../for_loop_continuing.wgsl.expected.spvasm | 71 ++++- .../for_loop_initializer.wgsl.expected.glsl | 21 +- .../for_loop_initializer.wgsl.expected.hlsl | 20 +- .../for_loop_initializer.wgsl.expected.msl | 11 +- .../for_loop_initializer.wgsl.expected.spvasm | 71 ++++- .../decrement/function.wgsl.expected.glsl | 14 +- .../decrement/function.wgsl.expected.hlsl | 14 +- .../decrement/function.wgsl.expected.msl | 11 +- .../decrement/function.wgsl.expected.spvasm | 41 ++- .../decrement/private.wgsl.expected.glsl | 15 +- .../decrement/private.wgsl.expected.hlsl | 16 +- .../decrement/private.wgsl.expected.msl | 11 +- .../decrement/private.wgsl.expected.spvasm | 40 ++- .../decrement/storage.wgsl.expected.glsl | 19 +- .../decrement/storage.wgsl.expected.hlsl | 16 +- .../decrement/storage.wgsl.expected.msl | 11 +- .../decrement/storage.wgsl.expected.spvasm | 50 ++- .../vector_component.wgsl.expected.glsl | 22 +- .../vector_component.wgsl.expected.hlsl | 19 +- .../vector_component.wgsl.expected.msl | 14 +- .../vector_component.wgsl.expected.spvasm | 60 +++- .../decrement/workgroup.wgsl.expected.glsl | 15 +- .../decrement/workgroup.wgsl.expected.hlsl | 16 +- .../decrement/workgroup.wgsl.expected.msl | 11 +- .../decrement/workgroup.wgsl.expected.spvasm | 39 ++- .../array_element.wgsl.expected.glsl | 17 +- .../array_element.wgsl.expected.hlsl | 16 +- .../increment/array_element.wgsl.expected.msl | 11 +- .../array_element.wgsl.expected.spvasm | 54 +++- .../increment/complex.wgsl.expected.glsl | 69 +++-- .../increment/complex.wgsl.expected.hlsl | 64 ++-- .../increment/complex.wgsl.expected.msl | 64 ++-- .../increment/complex.wgsl.expected.spvasm | 186 ++++++++--- .../for_loop_continuing.wgsl.expected.glsl | 21 +- .../for_loop_continuing.wgsl.expected.hlsl | 20 +- .../for_loop_continuing.wgsl.expected.msl | 11 +- .../for_loop_continuing.wgsl.expected.spvasm | 71 ++++- .../for_loop_initializer.wgsl.expected.glsl | 21 +- .../for_loop_initializer.wgsl.expected.hlsl | 20 +- .../for_loop_initializer.wgsl.expected.msl | 11 +- .../for_loop_initializer.wgsl.expected.spvasm | 71 ++++- .../increment/function.wgsl.expected.glsl | 14 +- .../increment/function.wgsl.expected.hlsl | 14 +- .../increment/function.wgsl.expected.msl | 11 +- .../increment/function.wgsl.expected.spvasm | 41 ++- .../increment/private.wgsl.expected.glsl | 15 +- .../increment/private.wgsl.expected.hlsl | 16 +- .../increment/private.wgsl.expected.msl | 11 +- .../increment/private.wgsl.expected.spvasm | 40 ++- .../increment/storage.wgsl.expected.glsl | 19 +- .../increment/storage.wgsl.expected.hlsl | 16 +- .../increment/storage.wgsl.expected.msl | 11 +- .../increment/storage.wgsl.expected.spvasm | 50 ++- .../vector_component.wgsl.expected.glsl | 22 +- .../vector_component.wgsl.expected.hlsl | 19 +- .../vector_component.wgsl.expected.msl | 14 +- .../vector_component.wgsl.expected.spvasm | 60 +++- .../increment/workgroup.wgsl.expected.glsl | 15 +- .../increment/workgroup.wgsl.expected.hlsl | 16 +- .../increment/workgroup.wgsl.expected.msl | 11 +- .../increment/workgroup.wgsl.expected.spvasm | 39 ++- 76 files changed, 2052 insertions(+), 838 deletions(-) diff --git a/docs/tint/origin-trial-changes.md b/docs/tint/origin-trial-changes.md index 3f3c61d824..31f91ceb81 100644 --- a/docs/tint/origin-trial-changes.md +++ b/docs/tint/origin-trial-changes.md @@ -6,6 +6,7 @@ * Parentheses are no longer required around expressions for if and switch statements [tint:1424](crbug.com/tint/1424) * Compound assignment statements are now supported. [tint:1325](https://crbug.com/tint/1325) +* Postfix increment and decrement statements are now supported. [tint:1488](crbug.com/tint/1488) * The colon in case statements is now optional. [tint:1485](crbug.com/tint/1485) ### Breaking changes diff --git a/src/tint/transform/expand_compound_assignment.cc b/src/tint/transform/expand_compound_assignment.cc index 7c967d3624..3a986a2762 100644 --- a/src/tint/transform/expand_compound_assignment.cc +++ b/src/tint/transform/expand_compound_assignment.cc @@ -17,6 +17,7 @@ #include #include "src/tint/ast/compound_assignment_statement.h" +#include "src/tint/ast/increment_decrement_statement.h" #include "src/tint/program_builder.h" #include "src/tint/sem/block_statement.h" #include "src/tint/sem/expression.h" @@ -36,113 +37,159 @@ ExpandCompoundAssignment::~ExpandCompoundAssignment() = default; bool ExpandCompoundAssignment::ShouldRun(const Program* program, const DataMap&) const { for (auto* node : program->ASTNodes().Objects()) { - if (node->Is()) { + if (node->IsAnyOf()) { return true; } } return false; } +/// Internal class used to collect statement expansions during the transform. +class State { + private: + /// The clone context. + CloneContext& ctx; + + /// The program builder. + ProgramBuilder& b; + + /// The HoistToDeclBefore helper instance. + HoistToDeclBefore hoist_to_decl_before; + + public: + /// Constructor + /// @param context the clone context + explicit State(CloneContext& context) + : ctx(context), b(*ctx.dst), hoist_to_decl_before(ctx) {} + + /// Replace `stmt` with a regular assignment statement of the form: + /// lhs = lhs op rhs + /// The LHS expression will only be evaluated once, and any side effects will + /// be hoisted to `let` declarations above the assignment statement. + /// @param stmt the statement to replace + /// @param lhs the lhs expression from the source statement + /// @param rhs the rhs expression in the destination module + /// @param op the binary operator + void Expand(const ast::Statement* stmt, + const ast::Expression* lhs, + const ast::Expression* rhs, + ast::BinaryOp op) { + // Helper function to create the new LHS expression. This will be called + // twice when building the non-compound assignment statement, so must + // not produce expressions that cause side effects. + std::function new_lhs; + + // Helper function to create a variable that is a pointer to `expr`. + auto hoist_pointer_to = [&](const ast::Expression* expr) { + auto name = b.Sym(); + auto* ptr = b.AddressOf(ctx.Clone(expr)); + auto* decl = b.Decl(b.Const(name, nullptr, ptr)); + hoist_to_decl_before.InsertBefore(ctx.src->Sem().Get(stmt), decl); + return name; + }; + + // Helper function to hoist `expr` to a let declaration. + auto hoist_expr_to_let = [&](const ast::Expression* expr) { + auto name = b.Sym(); + auto* decl = b.Decl(b.Const(name, nullptr, ctx.Clone(expr))); + hoist_to_decl_before.InsertBefore(ctx.src->Sem().Get(stmt), decl); + return name; + }; + + // Helper function that returns `true` if the type of `expr` is a vector. + auto is_vec = [&](const ast::Expression* expr) { + return ctx.src->Sem().Get(expr)->Type()->UnwrapRef()->Is(); + }; + + // Hoist the LHS expression subtree into local constants to produce a new + // LHS that we can evaluate twice. + // We need to special case compound assignments to vector components since + // we cannot take the address of a vector component. + auto* index_accessor = lhs->As(); + auto* member_accessor = lhs->As(); + if (lhs->Is() || + (member_accessor && + member_accessor->structure->Is())) { + // This is the simple case with no side effects, so we can just use the + // original LHS expression directly. + // Before: + // foo.bar += rhs; + // After: + // foo.bar = foo.bar + rhs; + new_lhs = [&]() { return ctx.Clone(lhs); }; + } else if (index_accessor && is_vec(index_accessor->object)) { + // This is the case for vector component via an array accessor. We need + // to capture a pointer to the vector and also the index value. + // Before: + // v[idx()] += rhs; + // After: + // let vec_ptr = &v; + // let index = idx(); + // (*vec_ptr)[index] = (*vec_ptr)[index] + rhs; + auto lhs_ptr = hoist_pointer_to(index_accessor->object); + auto index = hoist_expr_to_let(index_accessor->index); + new_lhs = [&, lhs_ptr, index]() { + return b.IndexAccessor(b.Deref(lhs_ptr), index); + }; + } else if (member_accessor && is_vec(member_accessor->structure)) { + // This is the case for vector component via a member accessor. We just + // need to capture a pointer to the vector. + // Before: + // a[idx()].y += rhs; + // After: + // let vec_ptr = &a[idx()]; + // (*vec_ptr).y = (*vec_ptr).y + rhs; + auto lhs_ptr = hoist_pointer_to(member_accessor->structure); + new_lhs = [&, lhs_ptr]() { + return b.MemberAccessor(b.Deref(lhs_ptr), + ctx.Clone(member_accessor->member)); + }; + } else { + // For all other statements that may have side-effecting expressions, we + // just need to capture a pointer to the whole LHS. + // Before: + // a[idx()] += rhs; + // After: + // let lhs_ptr = &a[idx()]; + // (*lhs_ptr) = (*lhs_ptr) + rhs; + auto lhs_ptr = hoist_pointer_to(lhs); + new_lhs = [&, lhs_ptr]() { return b.Deref(lhs_ptr); }; + } + + // Replace the statement with a regular assignment statement. + auto* value = b.create(op, new_lhs(), rhs); + ctx.Replace(stmt, b.Assign(new_lhs(), value)); + } + + /// Finalize the transformation and clone the module. + void Finalize() { + hoist_to_decl_before.Apply(); + ctx.Clone(); + } +}; + void ExpandCompoundAssignment::Run(CloneContext& ctx, const DataMap&, DataMap&) const { - HoistToDeclBefore hoist_to_decl_before(ctx); - + State state(ctx); for (auto* node : ctx.src->ASTNodes().Objects()) { if (auto* assign = node->As()) { - auto* sem_assign = ctx.src->Sem().Get(assign); - - // Helper function to create the LHS expression. This will be called twice - // when building the non-compound assignment statement, so must not - // produce expressions that cause side effects. - std::function lhs; - - // Helper function to create a variable that is a pointer to `expr`. - auto hoist_pointer_to = [&](const ast::Expression* expr) { - auto name = ctx.dst->Sym(); - auto* ptr = ctx.dst->AddressOf(ctx.Clone(expr)); - auto* decl = ctx.dst->Decl(ctx.dst->Const(name, nullptr, ptr)); - hoist_to_decl_before.InsertBefore(sem_assign, decl); - return name; - }; - - // Helper function to hoist `expr` to a let declaration. - auto hoist_expr_to_let = [&](const ast::Expression* expr) { - auto name = ctx.dst->Sym(); - auto* decl = - ctx.dst->Decl(ctx.dst->Const(name, nullptr, ctx.Clone(expr))); - hoist_to_decl_before.InsertBefore(sem_assign, decl); - return name; - }; - - // Helper function that returns `true` if the type of `expr` is a vector. - auto is_vec = [&](const ast::Expression* expr) { - return ctx.src->Sem().Get(expr)->Type()->UnwrapRef()->Is(); - }; - - // Hoist the LHS expression subtree into local constants to produce a new - // LHS that we can evaluate twice. - // We need to special case compound assignments to vector components since - // we cannot take the address of a vector component. - auto* index_accessor = assign->lhs->As(); - auto* member_accessor = assign->lhs->As(); - if (assign->lhs->Is() || - (member_accessor && - member_accessor->structure->Is())) { - // This is the simple case with no side effects, so we can just use the - // original LHS expression directly. - // Before: - // foo.bar += rhs; - // After: - // foo.bar = foo.bar + rhs; - lhs = [&]() { return ctx.Clone(assign->lhs); }; - } else if (index_accessor && is_vec(index_accessor->object)) { - // This is the case for vector component via an array accessor. We need - // to capture a pointer to the vector and also the index value. - // Before: - // v[idx()] += rhs; - // After: - // let vec_ptr = &v; - // let index = idx(); - // (*vec_ptr)[index] = (*vec_ptr)[index] + rhs; - auto lhs_ptr = hoist_pointer_to(index_accessor->object); - auto index = hoist_expr_to_let(index_accessor->index); - lhs = [&, lhs_ptr, index]() { - return ctx.dst->IndexAccessor(ctx.dst->Deref(lhs_ptr), index); - }; - } else if (member_accessor && is_vec(member_accessor->structure)) { - // This is the case for vector component via a member accessor. We just - // need to capture a pointer to the vector. - // Before: - // a[idx()].y += rhs; - // After: - // let vec_ptr = &a[idx()]; - // (*vec_ptr).y = (*vec_ptr).y + rhs; - auto lhs_ptr = hoist_pointer_to(member_accessor->structure); - lhs = [&, lhs_ptr]() { - return ctx.dst->MemberAccessor(ctx.dst->Deref(lhs_ptr), - ctx.Clone(member_accessor->member)); - }; - } else { - // For all other statements that may have side-effecting expressions, we - // just need to capture a pointer to the whole LHS. - // Before: - // a[idx()] += rhs; - // After: - // let lhs_ptr = &a[idx()]; - // (*lhs_ptr) = (*lhs_ptr) + rhs; - auto lhs_ptr = hoist_pointer_to(assign->lhs); - lhs = [&, lhs_ptr]() { return ctx.dst->Deref(lhs_ptr); }; - } - - // Replace the compound assignment with a regular assignment. - auto* rhs = ctx.dst->create( - assign->op, lhs(), ctx.Clone(assign->rhs)); - ctx.Replace(assign, ctx.dst->Assign(lhs(), rhs)); + state.Expand(assign, assign->lhs, ctx.Clone(assign->rhs), assign->op); + } else if (auto* inc_dec = node->As()) { + // For increment/decrement statements, `i++` becomes `i = i + 1`. + // TODO(jrprice): Simplify this when we have untyped literals. + auto* sem_lhs = ctx.src->Sem().Get(inc_dec->lhs); + const ast::IntLiteralExpression* one = + sem_lhs->Type()->UnwrapRef()->is_signed_integer_scalar() + ? ctx.dst->Expr(1)->As() + : ctx.dst->Expr(1u)->As(); + auto op = + inc_dec->increment ? ast::BinaryOp::kAdd : ast::BinaryOp::kSubtract; + state.Expand(inc_dec, inc_dec->lhs, one, op); } } - hoist_to_decl_before.Apply(); - ctx.Clone(); + state.Finalize(); } } // namespace transform diff --git a/src/tint/transform/expand_compound_assignment.h b/src/tint/transform/expand_compound_assignment.h index 73b0c83a63..644711770d 100644 --- a/src/tint/transform/expand_compound_assignment.h +++ b/src/tint/transform/expand_compound_assignment.h @@ -36,6 +36,9 @@ namespace transform { /// let _idx = bar(); /// (*_vec)[_idx] = (*_vec)[_idx] * 2.0; /// ``` +/// +/// This transform also handles increment and decrement statements in the same +/// manner, by replacing `i++` with `i = i + 1`. class ExpandCompoundAssignment : public Castable { public: diff --git a/src/tint/transform/expand_compound_assignment_test.cc b/src/tint/transform/expand_compound_assignment_test.cc index 4ad02d9a33..dc0992fce8 100644 --- a/src/tint/transform/expand_compound_assignment_test.cc +++ b/src/tint/transform/expand_compound_assignment_test.cc @@ -41,6 +41,17 @@ fn foo() { EXPECT_TRUE(ShouldRun(src)); } +TEST_F(ExpandCompoundAssignmentTest, ShouldRunHasIncrementDecrement) { + auto* src = R"( +fn foo() { + var v : i32; + v++; +} +)"; + + EXPECT_TRUE(ShouldRun(src)); +} + TEST_F(ExpandCompoundAssignmentTest, Basic) { auto* src = R"( fn main() { @@ -452,6 +463,284 @@ fn main() { EXPECT_EQ(expect, str(got)); } +TEST_F(ExpandCompoundAssignmentTest, Increment_I32) { + auto* src = R"( +fn main() { + var v : i32; + v++; +} +)"; + + auto* expect = R"( +fn main() { + var v : i32; + v = (v + 1); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, Increment_U32) { + auto* src = R"( +fn main() { + var v : u32; + v++; +} +)"; + + auto* expect = R"( +fn main() { + var v : u32; + v = (v + 1u); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, Decrement_I32) { + auto* src = R"( +fn main() { + var v : i32; + v--; +} +)"; + + auto* expect = R"( +fn main() { + var v : i32; + v = (v - 1); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, Decrement_U32) { + auto* src = R"( +fn main() { + var v : u32; + v--; +} +)"; + + auto* expect = R"( +fn main() { + var v : u32; + v = (v - 1u); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, Increment_LhsPointer) { + auto* src = R"( +fn main() { + var v : i32; + let p = &v; + *p++; +} +)"; + + auto* expect = R"( +fn main() { + var v : i32; + let p = &(v); + let tint_symbol = &(*(p)); + *(tint_symbol) = (*(tint_symbol) + 1); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, Increment_LhsStructMember) { + auto* src = R"( +struct S { + m : i32, +} + +fn main() { + var s : S; + s.m++; +} +)"; + + auto* expect = R"( +struct S { + m : i32, +} + +fn main() { + var s : S; + s.m = (s.m + 1); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, Increment_LhsArrayElement) { + auto* src = R"( +var a : array; + +fn idx() -> i32 { + a[1] = 42; + return 1; +} + +fn main() { + a[idx()]++; +} +)"; + + auto* expect = R"( +var a : array; + +fn idx() -> i32 { + a[1] = 42; + return 1; +} + +fn main() { + let tint_symbol = &(a[idx()]); + *(tint_symbol) = (*(tint_symbol) + 1); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, + Increment_LhsVectorComponent_ArrayAccessor) { + auto* src = R"( +var v : vec4; + +fn idx() -> i32 { + v.y = 42; + return 1; +} + +fn main() { + v[idx()]++; +} +)"; + + auto* expect = R"( +var v : vec4; + +fn idx() -> i32 { + v.y = 42; + return 1; +} + +fn main() { + let tint_symbol = &(v); + let tint_symbol_1 = idx(); + (*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, + Increment_LhsVectorComponent_MemberAccessor) { + auto* src = R"( +fn main() { + var v : vec4; + v.y++; +} +)"; + + auto* expect = R"( +fn main() { + var v : vec4; + v.y = (v.y + 1); +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(ExpandCompoundAssignmentTest, Increment_ForLoopCont) { + auto* src = R"( +var a : array, 4>; + +var p : i32; + +fn idx1() -> i32 { + p = (p + 1); + return 3; +} + +fn idx2() -> i32 { + p = (p * 3); + return 2; +} + +fn main() { + for (; ; a[idx1()][idx2()]++) { + break; + } +} +)"; + + auto* expect = R"( +var a : array, 4>; + +var p : i32; + +fn idx1() -> i32 { + p = (p + 1); + return 3; +} + +fn idx2() -> i32 { + p = (p * 3); + return 2; +} + +fn main() { + loop { + { + break; + } + + continuing { + let tint_symbol = &(a[idx1()]); + let tint_symbol_1 = idx2(); + (*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1); + } + } +} +)"; + + auto got = Run(src); + + EXPECT_EQ(expect, str(got)); +} + } // namespace } // namespace transform } // namespace tint diff --git a/test/tint/statements/decrement/array_element.wgsl.expected.glsl b/test/tint/statements/decrement/array_element.wgsl.expected.glsl index 9e5435da1c..74f7390adb 100644 --- a/test/tint/statements/decrement/array_element.wgsl.expected.glsl +++ b/test/tint/statements/decrement/array_element.wgsl.expected.glsl @@ -1,10 +1,13 @@ -SKIP: FAILED +#version 310 es - -@group(0) @binding(0) var a : array; - -fn main() { - a[1]--; +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +layout(binding = 0, std430) buffer a_block_1 { + uint inner[]; +} a; +void tint_symbol() { + a.inner[1] = (a.inner[1] - 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/array_element.wgsl.expected.hlsl b/test/tint/statements/decrement/array_element.wgsl.expected.hlsl index 0f960c8a0a..fda70650d8 100644 --- a/test/tint/statements/decrement/array_element.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/array_element.wgsl.expected.hlsl @@ -1,10 +1,10 @@ -SKIP: FAILED - - -@group(0) @binding(0) var a : array; - -fn main() { - a[1]--; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer a : register(u0, space0); + +void main() { + a.Store(4u, asuint((a.Load(4u) - 1u))); +} diff --git a/test/tint/statements/decrement/array_element.wgsl.expected.msl b/test/tint/statements/decrement/array_element.wgsl.expected.msl index f1cd0f6c0b..03752fbd02 100644 --- a/test/tint/statements/decrement/array_element.wgsl.expected.msl +++ b/test/tint/statements/decrement/array_element.wgsl.expected.msl @@ -1,10 +1,7 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var a : array; - -fn tint_symbol() { - a[1]--; +using namespace metal; +void tint_symbol(device uint (*const tint_symbol_2)[1]) { + (*(tint_symbol_2))[1] = ((*(tint_symbol_2))[1] - 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/array_element.wgsl.expected.spvasm b/test/tint/statements/decrement/array_element.wgsl.expected.spvasm index 6cea2ceeea..8f25fe9471 100644 --- a/test/tint/statements/decrement/array_element.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/array_element.wgsl.expected.spvasm @@ -1,10 +1,44 @@ -SKIP: FAILED - - -@group(0) @binding(0) var a : array; - -fn main() { - a[1]--; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %a_block "a_block" + OpMemberName %a_block 0 "inner" + OpName %a "a" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %a_block Block + OpMemberDecorate %a_block 0 Offset 0 + OpDecorate %_runtimearr_uint ArrayStride 4 + OpDecorate %a DescriptorSet 0 + OpDecorate %a Binding 0 + %uint = OpTypeInt 32 0 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %a_block = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer_a_block = OpTypePointer StorageBuffer %a_block + %a = OpVariable %_ptr_StorageBuffer_a_block StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_1 = OpConstant %uint 1 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %6 + %11 = OpLabel + %16 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %int_1 + %17 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %int_1 + %18 = OpLoad %uint %17 + %20 = OpISub %uint %18 %uint_1 + OpStore %16 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/decrement/complex.wgsl.expected.glsl b/test/tint/statements/decrement/complex.wgsl.expected.glsl index 67e2532c5f..a04fd4e9f6 100644 --- a/test/tint/statements/decrement/complex.wgsl.expected.glsl +++ b/test/tint/statements/decrement/complex.wgsl.expected.glsl @@ -1,47 +1,70 @@ -SKIP: FAILED +#version 310 es - -struct S { - a : array, 4>, +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; } +struct S { + ivec4 a[4]; +}; -@group(0) @binding(0) var buffer : array; - -var v : u32; - -fn idx1() -> i32 { - v--; +layout(binding = 0, std430) buffer tint_symbol_block_1 { + S inner[]; +} tint_symbol; +uint v = 0u; +int idx1() { + v = (v - 1u); return 1; } -fn idx2() -> i32 { - v--; +int idx2() { + v = (v - 1u); return 2; } -fn idx3() -> i32 { - v--; +int idx3() { + v = (v - 1u); return 3; } -fn idx4() -> i32 { - v--; +int idx4() { + v = (v - 1u); return 4; } -fn idx5() -> i32 { - v--; +int idx5() { + v = (v - 1u); return 0; } -fn idx6() -> i32 { - v--; +int idx6() { + v = (v - 1u); return 2; } -fn main() { - for(buffer[idx1()].a[idx2()][idx3()]--; (v < 10u); buffer[idx4()].a[idx5()][idx6()]--) { +void tint_symbol_1() { + int tint_symbol_6 = idx1(); + int tint_symbol_7 = idx2(); + int tint_symbol_2_save = tint_symbol_6; + int tint_symbol_2_save_1 = tint_symbol_7; + int tint_symbol_3 = idx3(); + { + tint_symbol.inner[tint_symbol_2_save].a[tint_symbol_2_save_1][tint_symbol_3] = (tint_symbol.inner[tint_symbol_2_save].a[tint_symbol_2_save_1][tint_symbol_3] - 1); + while (true) { + if (!((v < 10u))) { + break; + } + { + } + { + int tint_symbol_8 = idx4(); + int tint_symbol_9 = idx5(); + int tint_symbol_4_save = tint_symbol_8; + int tint_symbol_4_save_1 = tint_symbol_9; + int tint_symbol_5 = idx6(); + tint_symbol.inner[tint_symbol_4_save].a[tint_symbol_4_save_1][tint_symbol_5] = (tint_symbol.inner[tint_symbol_4_save].a[tint_symbol_4_save_1][tint_symbol_5] - 1); + } + } } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/complex.wgsl.expected.hlsl b/test/tint/statements/decrement/complex.wgsl.expected.hlsl index b5f16eb81a..069b822f47 100644 --- a/test/tint/statements/decrement/complex.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/complex.wgsl.expected.hlsl @@ -1,47 +1,63 @@ -SKIP: FAILED - - -struct S { - a : array, 4>, +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -@group(0) @binding(0) var buffer : array; +RWByteAddressBuffer buffer : register(u0, space0); +static uint v = 0u; -var v : u32; - -fn idx1() -> i32 { - v--; +int idx1() { + v = (v - 1u); return 1; } -fn idx2() -> i32 { - v--; +int idx2() { + v = (v - 1u); return 2; } -fn idx3() -> i32 { - v--; +int idx3() { + v = (v - 1u); return 3; } -fn idx4() -> i32 { - v--; +int idx4() { + v = (v - 1u); return 4; } -fn idx5() -> i32 { - v--; +int idx5() { + v = (v - 1u); return 0; } -fn idx6() -> i32 { - v--; +int idx6() { + v = (v - 1u); return 2; } -fn main() { - for(buffer[idx1()].a[idx2()][idx3()]--; (v < 10u); buffer[idx4()].a[idx5()][idx6()]--) { +void main() { + const int tint_symbol_4 = idx1(); + const int tint_symbol_5 = idx2(); + const int tint_symbol_save = tint_symbol_4; + const int tint_symbol_save_1 = tint_symbol_5; + const int tint_symbol_1 = idx3(); + { + buffer.Store((((64u * uint(tint_symbol_save)) + (16u * uint(tint_symbol_save_1))) + (4u * uint(tint_symbol_1))), asuint((asint(buffer.Load((((64u * uint(tint_symbol_save)) + (16u * uint(tint_symbol_save_1))) + (4u * uint(tint_symbol_1))))) - 1))); + [loop] while (true) { + if (!((v < 10u))) { + break; + } + { + } + { + const int tint_symbol_6 = idx4(); + const int tint_symbol_7 = idx5(); + const int tint_symbol_2_save = tint_symbol_6; + const int tint_symbol_2_save_1 = tint_symbol_7; + const int tint_symbol_3 = idx6(); + buffer.Store((((64u * uint(tint_symbol_2_save)) + (16u * uint(tint_symbol_2_save_1))) + (4u * uint(tint_symbol_3))), asuint((asint(buffer.Load((((64u * uint(tint_symbol_2_save)) + (16u * uint(tint_symbol_2_save_1))) + (4u * uint(tint_symbol_3))))) - 1))); + } + } } } - -Failed to generate: error: cannot modify value of type 'i32' diff --git a/test/tint/statements/decrement/complex.wgsl.expected.msl b/test/tint/statements/decrement/complex.wgsl.expected.msl index ad5f5a6ad1..e7e4a6cbee 100644 --- a/test/tint/statements/decrement/complex.wgsl.expected.msl +++ b/test/tint/statements/decrement/complex.wgsl.expected.msl @@ -1,47 +1,67 @@ -SKIP: FAILED +#include +using namespace metal; +struct tint_array_wrapper { + /* 0x0000 */ int4 arr[4]; +}; struct S { - a : array, 4>, -} + /* 0x0000 */ tint_array_wrapper a; +}; -@group(0) @binding(0) var tint_symbol : array; - -var v : u32; - -fn idx1() -> i32 { - v--; +int idx1(thread uint* const tint_symbol_10) { + *(tint_symbol_10) = (*(tint_symbol_10) - 1u); return 1; } -fn idx2() -> i32 { - v--; +int idx2(thread uint* const tint_symbol_11) { + *(tint_symbol_11) = (*(tint_symbol_11) - 1u); return 2; } -fn idx3() -> i32 { - v--; +int idx3(thread uint* const tint_symbol_12) { + *(tint_symbol_12) = (*(tint_symbol_12) - 1u); return 3; } -fn idx4() -> i32 { - v--; +int idx4(thread uint* const tint_symbol_13) { + *(tint_symbol_13) = (*(tint_symbol_13) - 1u); return 4; } -fn idx5() -> i32 { - v--; +int idx5(thread uint* const tint_symbol_14) { + *(tint_symbol_14) = (*(tint_symbol_14) - 1u); return 0; } -fn idx6() -> i32 { - v--; +int idx6(thread uint* const tint_symbol_15) { + *(tint_symbol_15) = (*(tint_symbol_15) - 1u); return 2; } -fn tint_symbol_1() { - for(tint_symbol[idx1()].a[idx2()][idx3()]--; (v < 10u); tint_symbol[idx4()].a[idx5()][idx6()]--) { +void tint_symbol_1(thread uint* const tint_symbol_16, device S (*const tint_symbol_17)[1]) { + int const tint_symbol_6 = idx1(tint_symbol_16); + int const tint_symbol_7 = idx2(tint_symbol_16); + int const tint_symbol_2_save = tint_symbol_6; + int const tint_symbol_2_save_1 = tint_symbol_7; + int const tint_symbol_3 = idx3(tint_symbol_16); + { + (*(tint_symbol_17))[tint_symbol_2_save].a.arr[tint_symbol_2_save_1][tint_symbol_3] = as_type((as_type((*(tint_symbol_17))[tint_symbol_2_save].a.arr[tint_symbol_2_save_1][tint_symbol_3]) - as_type(1))); + while (true) { + if (!((*(tint_symbol_16) < 10u))) { + break; + } + { + } + { + int const tint_symbol_8 = idx4(tint_symbol_16); + int const tint_symbol_9 = idx5(tint_symbol_16); + int const tint_symbol_4_save = tint_symbol_8; + int const tint_symbol_4_save_1 = tint_symbol_9; + int const tint_symbol_5 = idx6(tint_symbol_16); + (*(tint_symbol_17))[tint_symbol_4_save].a.arr[tint_symbol_4_save_1][tint_symbol_5] = as_type((as_type((*(tint_symbol_17))[tint_symbol_4_save].a.arr[tint_symbol_4_save_1][tint_symbol_5]) - as_type(1))); + } + } } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/complex.wgsl.expected.spvasm b/test/tint/statements/decrement/complex.wgsl.expected.spvasm index c5953fca5e..7798efe386 100644 --- a/test/tint/statements/decrement/complex.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/complex.wgsl.expected.spvasm @@ -1,47 +1,139 @@ -SKIP: FAILED - - -struct S { - a : array, 4>, -} - -@group(0) @binding(0) var buffer : array; - -var v : u32; - -fn idx1() -> i32 { - v--; - return 1; -} - -fn idx2() -> i32 { - v--; - return 2; -} - -fn idx3() -> i32 { - v--; - return 3; -} - -fn idx4() -> i32 { - v--; - return 4; -} - -fn idx5() -> i32 { - v--; - return 0; -} - -fn idx6() -> i32 { - v--; - return 2; -} - -fn main() { - for(buffer[idx1()].a[idx2()][idx3()]--; (v < 10u); buffer[idx4()].a[idx5()][idx6()]--) { - } -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 78 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %buffer_block "buffer_block" + OpMemberName %buffer_block 0 "inner" + OpName %S "S" + OpMemberName %S 0 "a" + OpName %buffer "buffer" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %idx1 "idx1" + OpName %idx2 "idx2" + OpName %idx3 "idx3" + OpName %idx4 "idx4" + OpName %idx5 "idx5" + OpName %idx6 "idx6" + OpName %main "main" + OpDecorate %buffer_block Block + OpMemberDecorate %buffer_block 0 Offset 0 + OpMemberDecorate %S 0 Offset 0 + OpDecorate %_arr_v4int_uint_4 ArrayStride 16 + OpDecorate %_runtimearr_S ArrayStride 64 + OpDecorate %buffer DescriptorSet 0 + OpDecorate %buffer Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4 + %S = OpTypeStruct %_arr_v4int_uint_4 +%_runtimearr_S = OpTypeRuntimeArray %S +%buffer_block = OpTypeStruct %_runtimearr_S +%_ptr_StorageBuffer_buffer_block = OpTypePointer StorageBuffer %buffer_block + %buffer = OpVariable %_ptr_StorageBuffer_buffer_block StorageBuffer +%_ptr_Private_uint = OpTypePointer Private %uint + %13 = OpConstantNull %uint + %v = OpVariable %_ptr_Private_uint Private %13 + %void = OpTypeVoid + %14 = OpTypeFunction %void + %18 = OpTypeFunction %int + %uint_1 = OpConstant %uint 1 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 + %int_4 = OpConstant %int 4 + %int_0 = OpConstant %int 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %uint_10 = OpConstant %uint 10 + %bool = OpTypeBool +%unused_entry_point = OpFunction %void None %14 + %17 = OpLabel + OpReturn + OpFunctionEnd + %idx1 = OpFunction %int None %18 + %20 = OpLabel + %21 = OpLoad %uint %v + %23 = OpISub %uint %21 %uint_1 + OpStore %v %23 + OpReturnValue %int_1 + OpFunctionEnd + %idx2 = OpFunction %int None %18 + %26 = OpLabel + %27 = OpLoad %uint %v + %28 = OpISub %uint %27 %uint_1 + OpStore %v %28 + OpReturnValue %int_2 + OpFunctionEnd + %idx3 = OpFunction %int None %18 + %31 = OpLabel + %32 = OpLoad %uint %v + %33 = OpISub %uint %32 %uint_1 + OpStore %v %33 + OpReturnValue %int_3 + OpFunctionEnd + %idx4 = OpFunction %int None %18 + %36 = OpLabel + %37 = OpLoad %uint %v + %38 = OpISub %uint %37 %uint_1 + OpStore %v %38 + OpReturnValue %int_4 + OpFunctionEnd + %idx5 = OpFunction %int None %18 + %41 = OpLabel + %42 = OpLoad %uint %v + %43 = OpISub %uint %42 %uint_1 + OpStore %v %43 + OpReturnValue %int_0 + OpFunctionEnd + %idx6 = OpFunction %int None %18 + %46 = OpLabel + %47 = OpLoad %uint %v + %48 = OpISub %uint %47 %uint_1 + OpStore %v %48 + OpReturnValue %int_2 + OpFunctionEnd + %main = OpFunction %void None %14 + %50 = OpLabel + %51 = OpFunctionCall %int %idx1 + %52 = OpFunctionCall %int %idx2 + %53 = OpFunctionCall %int %idx3 + %56 = OpAccessChain %_ptr_StorageBuffer_int %buffer %uint_0 %51 %uint_0 %52 %53 + %57 = OpAccessChain %_ptr_StorageBuffer_int %buffer %uint_0 %51 %uint_0 %52 %53 + %58 = OpLoad %int %57 + %59 = OpISub %int %58 %int_1 + OpStore %56 %59 + OpBranch %60 + %60 = OpLabel + OpLoopMerge %61 %62 None + OpBranch %63 + %63 = OpLabel + %65 = OpLoad %uint %v + %67 = OpULessThan %bool %65 %uint_10 + %64 = OpLogicalNot %bool %67 + OpSelectionMerge %69 None + OpBranchConditional %64 %70 %69 + %70 = OpLabel + OpBranch %61 + %69 = OpLabel + OpBranch %62 + %62 = OpLabel + %71 = OpFunctionCall %int %idx4 + %72 = OpFunctionCall %int %idx5 + %73 = OpFunctionCall %int %idx6 + %74 = OpAccessChain %_ptr_StorageBuffer_int %buffer %uint_0 %71 %uint_0 %72 %73 + %75 = OpAccessChain %_ptr_StorageBuffer_int %buffer %uint_0 %71 %uint_0 %72 %73 + %76 = OpLoad %int %75 + %77 = OpISub %int %76 %int_1 + OpStore %74 %77 + OpBranch %60 + %61 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.glsl b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.glsl index 1f4cedff11..21a79501a3 100644 --- a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.glsl +++ b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.glsl @@ -1,11 +1,20 @@ -SKIP: FAILED +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct i_block { + uint inner; +}; -@group(0) @binding(0) var i : u32; - -fn main() { - for(; (i < 10u); i--) { +layout(binding = 0, std430) buffer i_block_1 { + uint inner; +} i; +void tint_symbol() { + { + for(; (i.inner < 10u); i.inner = (i.inner - 1u)) { + } } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.hlsl b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.hlsl index 532428f4d5..7baae1bc1b 100644 --- a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.hlsl @@ -1,11 +1,13 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - for(; (i < 10u); i--) { - } +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer i : register(u0, space0); + +void main() { + { + [loop] for(; (i.Load(0u) < 10u); i.Store(0u, asuint((i.Load(0u) - 1u)))) { + } + } +} diff --git a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.msl b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.msl index c11b80d7fb..c91c6b23b2 100644 --- a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.msl +++ b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.msl @@ -1,11 +1,8 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var i : u32; - -fn tint_symbol() { - for(; (i < 10u); i--) { +using namespace metal; +void tint_symbol(device uint* const tint_symbol_1) { + for(; (*(tint_symbol_1) < 10u); *(tint_symbol_1) = (*(tint_symbol_1) - 1u)) { } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.spvasm b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.spvasm index 3e3ebd2962..fc8109e341 100644 --- a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.spvasm @@ -1,11 +1,60 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - for(; (i < 10u); i--) { - } -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i_block "i_block" + OpMemberName %i_block 0 "inner" + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %i_block Block + OpMemberDecorate %i_block 0 Offset 0 + OpDecorate %i DescriptorSet 0 + OpDecorate %i Binding 0 + %uint = OpTypeInt 32 0 + %i_block = OpTypeStruct %uint +%_ptr_StorageBuffer_i_block = OpTypePointer StorageBuffer %i_block + %i = OpVariable %_ptr_StorageBuffer_i_block StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_10 = OpConstant %uint 10 + %bool = OpTypeBool + %uint_1 = OpConstant %uint 1 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %5 + %10 = OpLabel + OpBranch %11 + %11 = OpLabel + OpLoopMerge %12 %13 None + OpBranch %14 + %14 = OpLabel + %18 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %19 = OpLoad %uint %18 + %21 = OpULessThan %bool %19 %uint_10 + %15 = OpLogicalNot %bool %21 + OpSelectionMerge %23 None + OpBranchConditional %15 %24 %23 + %24 = OpLabel + OpBranch %12 + %23 = OpLabel + OpBranch %13 + %13 = OpLabel + %25 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %26 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %27 = OpLoad %uint %26 + %29 = OpISub %uint %27 %uint_1 + OpStore %25 %29 + OpBranch %11 + %12 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.glsl b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.glsl index 941b4f3919..12ce515952 100644 --- a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.glsl +++ b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.glsl @@ -1,11 +1,20 @@ -SKIP: FAILED +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct i_block { + uint inner; +}; -@group(0) @binding(0) var i : u32; - -fn main() { - for(i--; (i < 10u); ) { +layout(binding = 0, std430) buffer i_block_1 { + uint inner; +} i; +void tint_symbol() { + { + for(i.inner = (i.inner - 1u); (i.inner < 10u); ) { + } } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.hlsl b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.hlsl index 9aff109c51..e520f5ecf2 100644 --- a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.hlsl @@ -1,11 +1,13 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - for(i--; (i < 10u); ) { - } +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer i : register(u0, space0); + +void main() { + { + [loop] for(i.Store(0u, asuint((i.Load(0u) - 1u))); (i.Load(0u) < 10u); ) { + } + } +} diff --git a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.msl b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.msl index ebbacb6d51..1f1ebdf859 100644 --- a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.msl +++ b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.msl @@ -1,11 +1,8 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var i : u32; - -fn tint_symbol() { - for(i--; (i < 10u); ) { +using namespace metal; +void tint_symbol(device uint* const tint_symbol_1) { + for(*(tint_symbol_1) = (*(tint_symbol_1) - 1u); (*(tint_symbol_1) < 10u); ) { } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.spvasm b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.spvasm index a95225bfa8..5ccbe4e913 100644 --- a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.spvasm @@ -1,11 +1,60 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - for(i--; (i < 10u); ) { - } -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i_block "i_block" + OpMemberName %i_block 0 "inner" + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %i_block Block + OpMemberDecorate %i_block 0 Offset 0 + OpDecorate %i DescriptorSet 0 + OpDecorate %i Binding 0 + %uint = OpTypeInt 32 0 + %i_block = OpTypeStruct %uint +%_ptr_StorageBuffer_i_block = OpTypePointer StorageBuffer %i_block + %i = OpVariable %_ptr_StorageBuffer_i_block StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_1 = OpConstant %uint 1 + %uint_10 = OpConstant %uint 10 + %bool = OpTypeBool +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %5 + %10 = OpLabel + %13 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %15 = OpLoad %uint %14 + %17 = OpISub %uint %15 %uint_1 + OpStore %13 %17 + OpBranch %18 + %18 = OpLabel + OpLoopMerge %19 %20 None + OpBranch %21 + %21 = OpLabel + %23 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %24 = OpLoad %uint %23 + %26 = OpULessThan %bool %24 %uint_10 + %22 = OpLogicalNot %bool %26 + OpSelectionMerge %28 None + OpBranchConditional %22 %29 %28 + %29 = OpLabel + OpBranch %19 + %28 = OpLabel + OpBranch %20 + %20 = OpLabel + OpBranch %18 + %19 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/decrement/function.wgsl.expected.glsl b/test/tint/statements/decrement/function.wgsl.expected.glsl index ad95151f67..d47e0a49e2 100644 --- a/test/tint/statements/decrement/function.wgsl.expected.glsl +++ b/test/tint/statements/decrement/function.wgsl.expected.glsl @@ -1,9 +1,11 @@ -SKIP: FAILED +#version 310 es - -fn main() { - var i = 0; - i--; +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +void tint_symbol() { + int i = 0; + i = (i - 1); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/function.wgsl.expected.hlsl b/test/tint/statements/decrement/function.wgsl.expected.hlsl index ad95151f67..479225e69b 100644 --- a/test/tint/statements/decrement/function.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/function.wgsl.expected.hlsl @@ -1,9 +1,9 @@ -SKIP: FAILED - - -fn main() { - var i = 0; - i--; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement +void main() { + int i = 0; + i = (i - 1); +} diff --git a/test/tint/statements/decrement/function.wgsl.expected.msl b/test/tint/statements/decrement/function.wgsl.expected.msl index 4242e3ccce..b91e30a952 100644 --- a/test/tint/statements/decrement/function.wgsl.expected.msl +++ b/test/tint/statements/decrement/function.wgsl.expected.msl @@ -1,9 +1,8 @@ -SKIP: FAILED +#include - -fn tint_symbol() { - var i = 0; - i--; +using namespace metal; +void tint_symbol() { + int i = 0; + i = as_type((as_type(i) - as_type(1))); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/function.wgsl.expected.spvasm b/test/tint/statements/decrement/function.wgsl.expected.spvasm index f1adcdfe6f..1eec1fa720 100644 --- a/test/tint/statements/decrement/function.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/function.wgsl.expected.spvasm @@ -1,9 +1,32 @@ -SKIP: FAILED - - -fn main() { - var i = 0; - i--; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 15 +; 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 %main "main" + OpName %i "i" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Function_int = OpTypePointer Function %int + %11 = OpConstantNull %int + %int_1 = OpConstant %int 1 +%unused_entry_point = OpFunction %void None %1 + %4 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %1 + %6 = OpLabel + %i = OpVariable %_ptr_Function_int Function %11 + OpStore %i %int_0 + %12 = OpLoad %int %i + %14 = OpISub %int %12 %int_1 + OpStore %i %14 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/decrement/private.wgsl.expected.glsl b/test/tint/statements/decrement/private.wgsl.expected.glsl index 48cffdb54e..8b46a5f0c2 100644 --- a/test/tint/statements/decrement/private.wgsl.expected.glsl +++ b/test/tint/statements/decrement/private.wgsl.expected.glsl @@ -1,10 +1,11 @@ -SKIP: FAILED +#version 310 es - -var i : i32 = 0; - -fn main() { - i--; +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +int i = 0; +void tint_symbol() { + i = (i - 1); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/private.wgsl.expected.hlsl b/test/tint/statements/decrement/private.wgsl.expected.hlsl index 48cffdb54e..56b4922bb1 100644 --- a/test/tint/statements/decrement/private.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/private.wgsl.expected.hlsl @@ -1,10 +1,10 @@ -SKIP: FAILED - - -var i : i32 = 0; - -fn main() { - i--; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement +static int i = 0; + +void main() { + i = (i - 1); +} diff --git a/test/tint/statements/decrement/private.wgsl.expected.msl b/test/tint/statements/decrement/private.wgsl.expected.msl index c223434589..ad64e49a9a 100644 --- a/test/tint/statements/decrement/private.wgsl.expected.msl +++ b/test/tint/statements/decrement/private.wgsl.expected.msl @@ -1,10 +1,7 @@ -SKIP: FAILED +#include - -var i : i32 = 0; - -fn tint_symbol() { - i--; +using namespace metal; +void tint_symbol(thread int* const tint_symbol_1) { + *(tint_symbol_1) = as_type((as_type(*(tint_symbol_1)) - as_type(1))); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/private.wgsl.expected.spvasm b/test/tint/statements/decrement/private.wgsl.expected.spvasm index 441401d215..1514ee9241 100644 --- a/test/tint/statements/decrement/private.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/private.wgsl.expected.spvasm @@ -1,10 +1,30 @@ -SKIP: FAILED - - -var i : i32 = 0; - -fn main() { - i--; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 14 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Private_int = OpTypePointer Private %int + %i = OpVariable %_ptr_Private_int Private %int_0 + %void = OpTypeVoid + %5 = OpTypeFunction %void + %int_1 = OpConstant %int 1 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %5 + %10 = OpLabel + %11 = OpLoad %int %i + %13 = OpISub %int %11 %int_1 + OpStore %i %13 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/decrement/storage.wgsl.expected.glsl b/test/tint/statements/decrement/storage.wgsl.expected.glsl index 4f603ea5f4..88579d1169 100644 --- a/test/tint/statements/decrement/storage.wgsl.expected.glsl +++ b/test/tint/statements/decrement/storage.wgsl.expected.glsl @@ -1,10 +1,17 @@ -SKIP: FAILED +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct i_block { + uint inner; +}; -@group(0) @binding(0) var i : u32; - -fn main() { - i--; +layout(binding = 0, std430) buffer i_block_1 { + uint inner; +} i; +void tint_symbol() { + i.inner = (i.inner - 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/storage.wgsl.expected.hlsl b/test/tint/statements/decrement/storage.wgsl.expected.hlsl index 28354c5043..99f987877f 100644 --- a/test/tint/statements/decrement/storage.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/storage.wgsl.expected.hlsl @@ -1,10 +1,10 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - i--; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer i : register(u0, space0); + +void main() { + i.Store(0u, asuint((i.Load(0u) - 1u))); +} diff --git a/test/tint/statements/decrement/storage.wgsl.expected.msl b/test/tint/statements/decrement/storage.wgsl.expected.msl index bd9b5d5337..5d5b6ac81e 100644 --- a/test/tint/statements/decrement/storage.wgsl.expected.msl +++ b/test/tint/statements/decrement/storage.wgsl.expected.msl @@ -1,10 +1,7 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var i : u32; - -fn tint_symbol() { - i--; +using namespace metal; +void tint_symbol(device uint* const tint_symbol_1) { + *(tint_symbol_1) = (*(tint_symbol_1) - 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/storage.wgsl.expected.spvasm b/test/tint/statements/decrement/storage.wgsl.expected.spvasm index 133d3f3355..cf6cfafa73 100644 --- a/test/tint/statements/decrement/storage.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/storage.wgsl.expected.spvasm @@ -1,10 +1,40 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - i--; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 18 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i_block "i_block" + OpMemberName %i_block 0 "inner" + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %i_block Block + OpMemberDecorate %i_block 0 Offset 0 + OpDecorate %i DescriptorSet 0 + OpDecorate %i Binding 0 + %uint = OpTypeInt 32 0 + %i_block = OpTypeStruct %uint +%_ptr_StorageBuffer_i_block = OpTypePointer StorageBuffer %i_block + %i = OpVariable %_ptr_StorageBuffer_i_block StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_1 = OpConstant %uint 1 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %5 + %10 = OpLabel + %13 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %15 = OpLoad %uint %14 + %17 = OpISub %uint %15 %uint_1 + OpStore %13 %17 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/decrement/vector_component.wgsl.expected.glsl b/test/tint/statements/decrement/vector_component.wgsl.expected.glsl index f6d1854856..908643ebdf 100644 --- a/test/tint/statements/decrement/vector_component.wgsl.expected.glsl +++ b/test/tint/statements/decrement/vector_component.wgsl.expected.glsl @@ -1,11 +1,19 @@ -SKIP: FAILED +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct a_block { + uvec4 inner; +}; -@group(0) @binding(0) var a : vec4; - -fn main() { - a[1]--; - a.z--; +layout(binding = 0, std430) buffer a_block_1 { + uvec4 inner; +} a; +void tint_symbol() { + int tint_symbol_2 = 1; + a.inner[tint_symbol_2] = (a.inner[tint_symbol_2] - 1u); + a.inner.z = (a.inner.z - 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/vector_component.wgsl.expected.hlsl b/test/tint/statements/decrement/vector_component.wgsl.expected.hlsl index 60ca93b03c..88bf0a8dfc 100644 --- a/test/tint/statements/decrement/vector_component.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/vector_component.wgsl.expected.hlsl @@ -1,11 +1,12 @@ -SKIP: FAILED - - -@group(0) @binding(0) var a : vec4; - -fn main() { - a[1]--; - a.z--; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer a : register(u0, space0); + +void main() { + const int tint_symbol_1 = 1; + a.Store((4u * uint(tint_symbol_1)), asuint((a.Load((4u * uint(tint_symbol_1))) - 1u))); + a.Store(8u, asuint((a.Load(8u) - 1u))); +} diff --git a/test/tint/statements/decrement/vector_component.wgsl.expected.msl b/test/tint/statements/decrement/vector_component.wgsl.expected.msl index 4556d7b368..7211766631 100644 --- a/test/tint/statements/decrement/vector_component.wgsl.expected.msl +++ b/test/tint/statements/decrement/vector_component.wgsl.expected.msl @@ -1,11 +1,9 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var a : vec4; - -fn tint_symbol() { - a[1]--; - a.z--; +using namespace metal; +void tint_symbol(device uint4* const tint_symbol_3) { + int const tint_symbol_2 = 1; + (*(tint_symbol_3))[tint_symbol_2] = ((*(tint_symbol_3))[tint_symbol_2] - 1u); + (*(tint_symbol_3))[2] = ((*(tint_symbol_3))[2] - 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/vector_component.wgsl.expected.spvasm b/test/tint/statements/decrement/vector_component.wgsl.expected.spvasm index 1334066ae2..f7a0664128 100644 --- a/test/tint/statements/decrement/vector_component.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/vector_component.wgsl.expected.spvasm @@ -1,11 +1,49 @@ -SKIP: FAILED - - -@group(0) @binding(0) var a : vec4; - -fn main() { - a[1]--; - a.z--; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %a_block "a_block" + OpMemberName %a_block 0 "inner" + OpName %a "a" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %a_block Block + OpMemberDecorate %a_block 0 Offset 0 + OpDecorate %a DescriptorSet 0 + OpDecorate %a Binding 0 + %uint = OpTypeInt 32 0 + %v4uint = OpTypeVector %uint 4 + %a_block = OpTypeStruct %v4uint +%_ptr_StorageBuffer_a_block = OpTypePointer StorageBuffer %a_block + %a = OpVariable %_ptr_StorageBuffer_a_block StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %6 + %11 = OpLabel + %16 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %int_1 + %17 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %int_1 + %18 = OpLoad %uint %17 + %20 = OpISub %uint %18 %uint_1 + OpStore %16 %20 + %22 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %uint_2 + %23 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %uint_2 + %24 = OpLoad %uint %23 + %25 = OpISub %uint %24 %uint_1 + OpStore %22 %25 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/decrement/workgroup.wgsl.expected.glsl b/test/tint/statements/decrement/workgroup.wgsl.expected.glsl index e3d1fac5bf..88eb4008c4 100644 --- a/test/tint/statements/decrement/workgroup.wgsl.expected.glsl +++ b/test/tint/statements/decrement/workgroup.wgsl.expected.glsl @@ -1,10 +1,11 @@ -SKIP: FAILED +#version 310 es - -var i : i32; - -fn main() { - i--; +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +shared int i; +void tint_symbol() { + i = (i - 1); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/workgroup.wgsl.expected.hlsl b/test/tint/statements/decrement/workgroup.wgsl.expected.hlsl index e3d1fac5bf..b39cd010ec 100644 --- a/test/tint/statements/decrement/workgroup.wgsl.expected.hlsl +++ b/test/tint/statements/decrement/workgroup.wgsl.expected.hlsl @@ -1,10 +1,10 @@ -SKIP: FAILED - - -var i : i32; - -fn main() { - i--; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement +groupshared int i; + +void main() { + i = (i - 1); +} diff --git a/test/tint/statements/decrement/workgroup.wgsl.expected.msl b/test/tint/statements/decrement/workgroup.wgsl.expected.msl index 66b73b188d..06d736fea6 100644 --- a/test/tint/statements/decrement/workgroup.wgsl.expected.msl +++ b/test/tint/statements/decrement/workgroup.wgsl.expected.msl @@ -1,10 +1,7 @@ -SKIP: FAILED +#include - -var i : i32; - -fn tint_symbol() { - i--; +using namespace metal; +void tint_symbol(threadgroup int* const tint_symbol_1) { + *(tint_symbol_1) = as_type((as_type(*(tint_symbol_1)) - as_type(1))); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/decrement/workgroup.wgsl.expected.spvasm b/test/tint/statements/decrement/workgroup.wgsl.expected.spvasm index b6136ad982..837f90d472 100644 --- a/test/tint/statements/decrement/workgroup.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/workgroup.wgsl.expected.spvasm @@ -1,10 +1,29 @@ -SKIP: FAILED - - -var i : i32; - -fn main() { - i--; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 13 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %i = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %int_1 = OpConstant %int 1 +%unused_entry_point = OpFunction %void None %4 + %7 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %4 + %9 = OpLabel + %10 = OpLoad %int %i + %12 = OpISub %int %10 %int_1 + OpStore %i %12 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/array_element.wgsl.expected.glsl b/test/tint/statements/increment/array_element.wgsl.expected.glsl index 5b3648a24e..8c4b54b70c 100644 --- a/test/tint/statements/increment/array_element.wgsl.expected.glsl +++ b/test/tint/statements/increment/array_element.wgsl.expected.glsl @@ -1,10 +1,13 @@ -SKIP: FAILED +#version 310 es - -@group(0) @binding(0) var a : array; - -fn main() { - a[1]++; +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +layout(binding = 0, std430) buffer a_block_1 { + uint inner[]; +} a; +void tint_symbol() { + a.inner[1] = (a.inner[1] + 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/array_element.wgsl.expected.hlsl b/test/tint/statements/increment/array_element.wgsl.expected.hlsl index 006178188a..9db143fafc 100644 --- a/test/tint/statements/increment/array_element.wgsl.expected.hlsl +++ b/test/tint/statements/increment/array_element.wgsl.expected.hlsl @@ -1,10 +1,10 @@ -SKIP: FAILED - - -@group(0) @binding(0) var a : array; - -fn main() { - a[1]++; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer a : register(u0, space0); + +void main() { + a.Store(4u, asuint((a.Load(4u) + 1u))); +} diff --git a/test/tint/statements/increment/array_element.wgsl.expected.msl b/test/tint/statements/increment/array_element.wgsl.expected.msl index d996613a35..0347508612 100644 --- a/test/tint/statements/increment/array_element.wgsl.expected.msl +++ b/test/tint/statements/increment/array_element.wgsl.expected.msl @@ -1,10 +1,7 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var a : array; - -fn tint_symbol() { - a[1]++; +using namespace metal; +void tint_symbol(device uint (*const tint_symbol_2)[1]) { + (*(tint_symbol_2))[1] = ((*(tint_symbol_2))[1] + 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/array_element.wgsl.expected.spvasm b/test/tint/statements/increment/array_element.wgsl.expected.spvasm index 250f739039..7bb17e9d79 100644 --- a/test/tint/statements/increment/array_element.wgsl.expected.spvasm +++ b/test/tint/statements/increment/array_element.wgsl.expected.spvasm @@ -1,10 +1,44 @@ -SKIP: FAILED - - -@group(0) @binding(0) var a : array; - -fn main() { - a[1]++; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %a_block "a_block" + OpMemberName %a_block 0 "inner" + OpName %a "a" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %a_block Block + OpMemberDecorate %a_block 0 Offset 0 + OpDecorate %_runtimearr_uint ArrayStride 4 + OpDecorate %a DescriptorSet 0 + OpDecorate %a Binding 0 + %uint = OpTypeInt 32 0 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %a_block = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer_a_block = OpTypePointer StorageBuffer %a_block + %a = OpVariable %_ptr_StorageBuffer_a_block StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_1 = OpConstant %uint 1 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %6 + %11 = OpLabel + %16 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %int_1 + %17 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %int_1 + %18 = OpLoad %uint %17 + %20 = OpIAdd %uint %18 %uint_1 + OpStore %16 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/complex.wgsl.expected.glsl b/test/tint/statements/increment/complex.wgsl.expected.glsl index f667ccab4a..26c1c10149 100644 --- a/test/tint/statements/increment/complex.wgsl.expected.glsl +++ b/test/tint/statements/increment/complex.wgsl.expected.glsl @@ -1,47 +1,70 @@ -SKIP: FAILED +#version 310 es - -struct S { - a : array, 4>, +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; } +struct S { + ivec4 a[4]; +}; -@group(0) @binding(0) var buffer : array; - -var v : u32; - -fn idx1() -> i32 { - v++; +layout(binding = 0, std430) buffer tint_symbol_block_1 { + S inner[]; +} tint_symbol; +uint v = 0u; +int idx1() { + v = (v + 1u); return 1; } -fn idx2() -> i32 { - v++; +int idx2() { + v = (v + 1u); return 2; } -fn idx3() -> i32 { - v++; +int idx3() { + v = (v + 1u); return 3; } -fn idx4() -> i32 { - v++; +int idx4() { + v = (v + 1u); return 4; } -fn idx5() -> i32 { - v++; +int idx5() { + v = (v + 1u); return 0; } -fn idx6() -> i32 { - v++; +int idx6() { + v = (v + 1u); return 2; } -fn main() { - for(buffer[idx1()].a[idx2()][idx3()]++; (v < 10u); buffer[idx4()].a[idx5()][idx6()]++) { +void tint_symbol_1() { + int tint_symbol_6 = idx1(); + int tint_symbol_7 = idx2(); + int tint_symbol_2_save = tint_symbol_6; + int tint_symbol_2_save_1 = tint_symbol_7; + int tint_symbol_3 = idx3(); + { + tint_symbol.inner[tint_symbol_2_save].a[tint_symbol_2_save_1][tint_symbol_3] = (tint_symbol.inner[tint_symbol_2_save].a[tint_symbol_2_save_1][tint_symbol_3] + 1); + while (true) { + if (!((v < 10u))) { + break; + } + { + } + { + int tint_symbol_8 = idx4(); + int tint_symbol_9 = idx5(); + int tint_symbol_4_save = tint_symbol_8; + int tint_symbol_4_save_1 = tint_symbol_9; + int tint_symbol_5 = idx6(); + tint_symbol.inner[tint_symbol_4_save].a[tint_symbol_4_save_1][tint_symbol_5] = (tint_symbol.inner[tint_symbol_4_save].a[tint_symbol_4_save_1][tint_symbol_5] + 1); + } + } } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/complex.wgsl.expected.hlsl b/test/tint/statements/increment/complex.wgsl.expected.hlsl index bb3ce44c6b..06d410ad12 100644 --- a/test/tint/statements/increment/complex.wgsl.expected.hlsl +++ b/test/tint/statements/increment/complex.wgsl.expected.hlsl @@ -1,47 +1,63 @@ -SKIP: FAILED - - -struct S { - a : array, 4>, +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -@group(0) @binding(0) var buffer : array; +RWByteAddressBuffer buffer : register(u0, space0); +static uint v = 0u; -var v : u32; - -fn idx1() -> i32 { - v++; +int idx1() { + v = (v + 1u); return 1; } -fn idx2() -> i32 { - v++; +int idx2() { + v = (v + 1u); return 2; } -fn idx3() -> i32 { - v++; +int idx3() { + v = (v + 1u); return 3; } -fn idx4() -> i32 { - v++; +int idx4() { + v = (v + 1u); return 4; } -fn idx5() -> i32 { - v++; +int idx5() { + v = (v + 1u); return 0; } -fn idx6() -> i32 { - v++; +int idx6() { + v = (v + 1u); return 2; } -fn main() { - for(buffer[idx1()].a[idx2()][idx3()]++; (v < 10u); buffer[idx4()].a[idx5()][idx6()]++) { +void main() { + const int tint_symbol_4 = idx1(); + const int tint_symbol_5 = idx2(); + const int tint_symbol_save = tint_symbol_4; + const int tint_symbol_save_1 = tint_symbol_5; + const int tint_symbol_1 = idx3(); + { + buffer.Store((((64u * uint(tint_symbol_save)) + (16u * uint(tint_symbol_save_1))) + (4u * uint(tint_symbol_1))), asuint((asint(buffer.Load((((64u * uint(tint_symbol_save)) + (16u * uint(tint_symbol_save_1))) + (4u * uint(tint_symbol_1))))) + 1))); + [loop] while (true) { + if (!((v < 10u))) { + break; + } + { + } + { + const int tint_symbol_6 = idx4(); + const int tint_symbol_7 = idx5(); + const int tint_symbol_2_save = tint_symbol_6; + const int tint_symbol_2_save_1 = tint_symbol_7; + const int tint_symbol_3 = idx6(); + buffer.Store((((64u * uint(tint_symbol_2_save)) + (16u * uint(tint_symbol_2_save_1))) + (4u * uint(tint_symbol_3))), asuint((asint(buffer.Load((((64u * uint(tint_symbol_2_save)) + (16u * uint(tint_symbol_2_save_1))) + (4u * uint(tint_symbol_3))))) + 1))); + } + } } } - -Failed to generate: error: cannot modify value of type 'i32' diff --git a/test/tint/statements/increment/complex.wgsl.expected.msl b/test/tint/statements/increment/complex.wgsl.expected.msl index 45f0182a2b..fbc0f9c862 100644 --- a/test/tint/statements/increment/complex.wgsl.expected.msl +++ b/test/tint/statements/increment/complex.wgsl.expected.msl @@ -1,47 +1,67 @@ -SKIP: FAILED +#include +using namespace metal; +struct tint_array_wrapper { + /* 0x0000 */ int4 arr[4]; +}; struct S { - a : array, 4>, -} + /* 0x0000 */ tint_array_wrapper a; +}; -@group(0) @binding(0) var tint_symbol : array; - -var v : u32; - -fn idx1() -> i32 { - v++; +int idx1(thread uint* const tint_symbol_10) { + *(tint_symbol_10) = (*(tint_symbol_10) + 1u); return 1; } -fn idx2() -> i32 { - v++; +int idx2(thread uint* const tint_symbol_11) { + *(tint_symbol_11) = (*(tint_symbol_11) + 1u); return 2; } -fn idx3() -> i32 { - v++; +int idx3(thread uint* const tint_symbol_12) { + *(tint_symbol_12) = (*(tint_symbol_12) + 1u); return 3; } -fn idx4() -> i32 { - v++; +int idx4(thread uint* const tint_symbol_13) { + *(tint_symbol_13) = (*(tint_symbol_13) + 1u); return 4; } -fn idx5() -> i32 { - v++; +int idx5(thread uint* const tint_symbol_14) { + *(tint_symbol_14) = (*(tint_symbol_14) + 1u); return 0; } -fn idx6() -> i32 { - v++; +int idx6(thread uint* const tint_symbol_15) { + *(tint_symbol_15) = (*(tint_symbol_15) + 1u); return 2; } -fn tint_symbol_1() { - for(tint_symbol[idx1()].a[idx2()][idx3()]++; (v < 10u); tint_symbol[idx4()].a[idx5()][idx6()]++) { +void tint_symbol_1(thread uint* const tint_symbol_16, device S (*const tint_symbol_17)[1]) { + int const tint_symbol_6 = idx1(tint_symbol_16); + int const tint_symbol_7 = idx2(tint_symbol_16); + int const tint_symbol_2_save = tint_symbol_6; + int const tint_symbol_2_save_1 = tint_symbol_7; + int const tint_symbol_3 = idx3(tint_symbol_16); + { + (*(tint_symbol_17))[tint_symbol_2_save].a.arr[tint_symbol_2_save_1][tint_symbol_3] = as_type((as_type((*(tint_symbol_17))[tint_symbol_2_save].a.arr[tint_symbol_2_save_1][tint_symbol_3]) + as_type(1))); + while (true) { + if (!((*(tint_symbol_16) < 10u))) { + break; + } + { + } + { + int const tint_symbol_8 = idx4(tint_symbol_16); + int const tint_symbol_9 = idx5(tint_symbol_16); + int const tint_symbol_4_save = tint_symbol_8; + int const tint_symbol_4_save_1 = tint_symbol_9; + int const tint_symbol_5 = idx6(tint_symbol_16); + (*(tint_symbol_17))[tint_symbol_4_save].a.arr[tint_symbol_4_save_1][tint_symbol_5] = as_type((as_type((*(tint_symbol_17))[tint_symbol_4_save].a.arr[tint_symbol_4_save_1][tint_symbol_5]) + as_type(1))); + } + } } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/complex.wgsl.expected.spvasm b/test/tint/statements/increment/complex.wgsl.expected.spvasm index 4f6b6c693b..9cb91f0c1d 100644 --- a/test/tint/statements/increment/complex.wgsl.expected.spvasm +++ b/test/tint/statements/increment/complex.wgsl.expected.spvasm @@ -1,47 +1,139 @@ -SKIP: FAILED - - -struct S { - a : array, 4>, -} - -@group(0) @binding(0) var buffer : array; - -var v : u32; - -fn idx1() -> i32 { - v++; - return 1; -} - -fn idx2() -> i32 { - v++; - return 2; -} - -fn idx3() -> i32 { - v++; - return 3; -} - -fn idx4() -> i32 { - v++; - return 4; -} - -fn idx5() -> i32 { - v++; - return 0; -} - -fn idx6() -> i32 { - v++; - return 2; -} - -fn main() { - for(buffer[idx1()].a[idx2()][idx3()]++; (v < 10u); buffer[idx4()].a[idx5()][idx6()]++) { - } -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 78 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %buffer_block "buffer_block" + OpMemberName %buffer_block 0 "inner" + OpName %S "S" + OpMemberName %S 0 "a" + OpName %buffer "buffer" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %idx1 "idx1" + OpName %idx2 "idx2" + OpName %idx3 "idx3" + OpName %idx4 "idx4" + OpName %idx5 "idx5" + OpName %idx6 "idx6" + OpName %main "main" + OpDecorate %buffer_block Block + OpMemberDecorate %buffer_block 0 Offset 0 + OpMemberDecorate %S 0 Offset 0 + OpDecorate %_arr_v4int_uint_4 ArrayStride 16 + OpDecorate %_runtimearr_S ArrayStride 64 + OpDecorate %buffer DescriptorSet 0 + OpDecorate %buffer Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4 + %S = OpTypeStruct %_arr_v4int_uint_4 +%_runtimearr_S = OpTypeRuntimeArray %S +%buffer_block = OpTypeStruct %_runtimearr_S +%_ptr_StorageBuffer_buffer_block = OpTypePointer StorageBuffer %buffer_block + %buffer = OpVariable %_ptr_StorageBuffer_buffer_block StorageBuffer +%_ptr_Private_uint = OpTypePointer Private %uint + %13 = OpConstantNull %uint + %v = OpVariable %_ptr_Private_uint Private %13 + %void = OpTypeVoid + %14 = OpTypeFunction %void + %18 = OpTypeFunction %int + %uint_1 = OpConstant %uint 1 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 + %int_4 = OpConstant %int 4 + %int_0 = OpConstant %int 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %uint_10 = OpConstant %uint 10 + %bool = OpTypeBool +%unused_entry_point = OpFunction %void None %14 + %17 = OpLabel + OpReturn + OpFunctionEnd + %idx1 = OpFunction %int None %18 + %20 = OpLabel + %21 = OpLoad %uint %v + %23 = OpIAdd %uint %21 %uint_1 + OpStore %v %23 + OpReturnValue %int_1 + OpFunctionEnd + %idx2 = OpFunction %int None %18 + %26 = OpLabel + %27 = OpLoad %uint %v + %28 = OpIAdd %uint %27 %uint_1 + OpStore %v %28 + OpReturnValue %int_2 + OpFunctionEnd + %idx3 = OpFunction %int None %18 + %31 = OpLabel + %32 = OpLoad %uint %v + %33 = OpIAdd %uint %32 %uint_1 + OpStore %v %33 + OpReturnValue %int_3 + OpFunctionEnd + %idx4 = OpFunction %int None %18 + %36 = OpLabel + %37 = OpLoad %uint %v + %38 = OpIAdd %uint %37 %uint_1 + OpStore %v %38 + OpReturnValue %int_4 + OpFunctionEnd + %idx5 = OpFunction %int None %18 + %41 = OpLabel + %42 = OpLoad %uint %v + %43 = OpIAdd %uint %42 %uint_1 + OpStore %v %43 + OpReturnValue %int_0 + OpFunctionEnd + %idx6 = OpFunction %int None %18 + %46 = OpLabel + %47 = OpLoad %uint %v + %48 = OpIAdd %uint %47 %uint_1 + OpStore %v %48 + OpReturnValue %int_2 + OpFunctionEnd + %main = OpFunction %void None %14 + %50 = OpLabel + %51 = OpFunctionCall %int %idx1 + %52 = OpFunctionCall %int %idx2 + %53 = OpFunctionCall %int %idx3 + %56 = OpAccessChain %_ptr_StorageBuffer_int %buffer %uint_0 %51 %uint_0 %52 %53 + %57 = OpAccessChain %_ptr_StorageBuffer_int %buffer %uint_0 %51 %uint_0 %52 %53 + %58 = OpLoad %int %57 + %59 = OpIAdd %int %58 %int_1 + OpStore %56 %59 + OpBranch %60 + %60 = OpLabel + OpLoopMerge %61 %62 None + OpBranch %63 + %63 = OpLabel + %65 = OpLoad %uint %v + %67 = OpULessThan %bool %65 %uint_10 + %64 = OpLogicalNot %bool %67 + OpSelectionMerge %69 None + OpBranchConditional %64 %70 %69 + %70 = OpLabel + OpBranch %61 + %69 = OpLabel + OpBranch %62 + %62 = OpLabel + %71 = OpFunctionCall %int %idx4 + %72 = OpFunctionCall %int %idx5 + %73 = OpFunctionCall %int %idx6 + %74 = OpAccessChain %_ptr_StorageBuffer_int %buffer %uint_0 %71 %uint_0 %72 %73 + %75 = OpAccessChain %_ptr_StorageBuffer_int %buffer %uint_0 %71 %uint_0 %72 %73 + %76 = OpLoad %int %75 + %77 = OpIAdd %int %76 %int_1 + OpStore %74 %77 + OpBranch %60 + %61 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.glsl b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.glsl index d039199857..50eb4943cb 100644 --- a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.glsl +++ b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.glsl @@ -1,11 +1,20 @@ -SKIP: FAILED +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct i_block { + uint inner; +}; -@group(0) @binding(0) var i : u32; - -fn main() { - for(; (i < 10u); i++) { +layout(binding = 0, std430) buffer i_block_1 { + uint inner; +} i; +void tint_symbol() { + { + for(; (i.inner < 10u); i.inner = (i.inner + 1u)) { + } } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.hlsl b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.hlsl index ed0f720bfe..836d2459e1 100644 --- a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.hlsl +++ b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.hlsl @@ -1,11 +1,13 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - for(; (i < 10u); i++) { - } +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer i : register(u0, space0); + +void main() { + { + [loop] for(; (i.Load(0u) < 10u); i.Store(0u, asuint((i.Load(0u) + 1u)))) { + } + } +} diff --git a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.msl b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.msl index e32c199589..ee234993f4 100644 --- a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.msl +++ b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.msl @@ -1,11 +1,8 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var i : u32; - -fn tint_symbol() { - for(; (i < 10u); i++) { +using namespace metal; +void tint_symbol(device uint* const tint_symbol_1) { + for(; (*(tint_symbol_1) < 10u); *(tint_symbol_1) = (*(tint_symbol_1) + 1u)) { } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.spvasm b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.spvasm index b8e09e5896..b788b1e559 100644 --- a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.spvasm +++ b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.spvasm @@ -1,11 +1,60 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - for(; (i < 10u); i++) { - } -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i_block "i_block" + OpMemberName %i_block 0 "inner" + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %i_block Block + OpMemberDecorate %i_block 0 Offset 0 + OpDecorate %i DescriptorSet 0 + OpDecorate %i Binding 0 + %uint = OpTypeInt 32 0 + %i_block = OpTypeStruct %uint +%_ptr_StorageBuffer_i_block = OpTypePointer StorageBuffer %i_block + %i = OpVariable %_ptr_StorageBuffer_i_block StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_10 = OpConstant %uint 10 + %bool = OpTypeBool + %uint_1 = OpConstant %uint 1 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %5 + %10 = OpLabel + OpBranch %11 + %11 = OpLabel + OpLoopMerge %12 %13 None + OpBranch %14 + %14 = OpLabel + %18 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %19 = OpLoad %uint %18 + %21 = OpULessThan %bool %19 %uint_10 + %15 = OpLogicalNot %bool %21 + OpSelectionMerge %23 None + OpBranchConditional %15 %24 %23 + %24 = OpLabel + OpBranch %12 + %23 = OpLabel + OpBranch %13 + %13 = OpLabel + %25 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %26 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %27 = OpLoad %uint %26 + %29 = OpIAdd %uint %27 %uint_1 + OpStore %25 %29 + OpBranch %11 + %12 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.glsl b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.glsl index 40f942a46d..77942ca5a4 100644 --- a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.glsl +++ b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.glsl @@ -1,11 +1,20 @@ -SKIP: FAILED +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct i_block { + uint inner; +}; -@group(0) @binding(0) var i : u32; - -fn main() { - for(i++; (i < 10u); ) { +layout(binding = 0, std430) buffer i_block_1 { + uint inner; +} i; +void tint_symbol() { + { + for(i.inner = (i.inner + 1u); (i.inner < 10u); ) { + } } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.hlsl b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.hlsl index 1fa9624f54..8653efa400 100644 --- a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.hlsl +++ b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.hlsl @@ -1,11 +1,13 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - for(i++; (i < 10u); ) { - } +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer i : register(u0, space0); + +void main() { + { + [loop] for(i.Store(0u, asuint((i.Load(0u) + 1u))); (i.Load(0u) < 10u); ) { + } + } +} diff --git a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.msl b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.msl index a780f321a3..b29a247989 100644 --- a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.msl +++ b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.msl @@ -1,11 +1,8 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var i : u32; - -fn tint_symbol() { - for(i++; (i < 10u); ) { +using namespace metal; +void tint_symbol(device uint* const tint_symbol_1) { + for(*(tint_symbol_1) = (*(tint_symbol_1) + 1u); (*(tint_symbol_1) < 10u); ) { } } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.spvasm b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.spvasm index a9235f9aba..dffef093d3 100644 --- a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.spvasm +++ b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.spvasm @@ -1,11 +1,60 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - for(i++; (i < 10u); ) { - } -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i_block "i_block" + OpMemberName %i_block 0 "inner" + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %i_block Block + OpMemberDecorate %i_block 0 Offset 0 + OpDecorate %i DescriptorSet 0 + OpDecorate %i Binding 0 + %uint = OpTypeInt 32 0 + %i_block = OpTypeStruct %uint +%_ptr_StorageBuffer_i_block = OpTypePointer StorageBuffer %i_block + %i = OpVariable %_ptr_StorageBuffer_i_block StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_1 = OpConstant %uint 1 + %uint_10 = OpConstant %uint 10 + %bool = OpTypeBool +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %5 + %10 = OpLabel + %13 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %15 = OpLoad %uint %14 + %17 = OpIAdd %uint %15 %uint_1 + OpStore %13 %17 + OpBranch %18 + %18 = OpLabel + OpLoopMerge %19 %20 None + OpBranch %21 + %21 = OpLabel + %23 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %24 = OpLoad %uint %23 + %26 = OpULessThan %bool %24 %uint_10 + %22 = OpLogicalNot %bool %26 + OpSelectionMerge %28 None + OpBranchConditional %22 %29 %28 + %29 = OpLabel + OpBranch %19 + %28 = OpLabel + OpBranch %20 + %20 = OpLabel + OpBranch %18 + %19 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/function.wgsl.expected.glsl b/test/tint/statements/increment/function.wgsl.expected.glsl index 141a0e7ce5..3f86ce8f0c 100644 --- a/test/tint/statements/increment/function.wgsl.expected.glsl +++ b/test/tint/statements/increment/function.wgsl.expected.glsl @@ -1,9 +1,11 @@ -SKIP: FAILED +#version 310 es - -fn main() { - var i = 0; - i++; +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +void tint_symbol() { + int i = 0; + i = (i + 1); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/function.wgsl.expected.hlsl b/test/tint/statements/increment/function.wgsl.expected.hlsl index 141a0e7ce5..900a2d0fb5 100644 --- a/test/tint/statements/increment/function.wgsl.expected.hlsl +++ b/test/tint/statements/increment/function.wgsl.expected.hlsl @@ -1,9 +1,9 @@ -SKIP: FAILED - - -fn main() { - var i = 0; - i++; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement +void main() { + int i = 0; + i = (i + 1); +} diff --git a/test/tint/statements/increment/function.wgsl.expected.msl b/test/tint/statements/increment/function.wgsl.expected.msl index 4c16d002ad..06dde9d7d0 100644 --- a/test/tint/statements/increment/function.wgsl.expected.msl +++ b/test/tint/statements/increment/function.wgsl.expected.msl @@ -1,9 +1,8 @@ -SKIP: FAILED +#include - -fn tint_symbol() { - var i = 0; - i++; +using namespace metal; +void tint_symbol() { + int i = 0; + i = as_type((as_type(i) + as_type(1))); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/function.wgsl.expected.spvasm b/test/tint/statements/increment/function.wgsl.expected.spvasm index d48fc4721e..0ed1409759 100644 --- a/test/tint/statements/increment/function.wgsl.expected.spvasm +++ b/test/tint/statements/increment/function.wgsl.expected.spvasm @@ -1,9 +1,32 @@ -SKIP: FAILED - - -fn main() { - var i = 0; - i++; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 15 +; 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 %main "main" + OpName %i "i" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Function_int = OpTypePointer Function %int + %11 = OpConstantNull %int + %int_1 = OpConstant %int 1 +%unused_entry_point = OpFunction %void None %1 + %4 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %1 + %6 = OpLabel + %i = OpVariable %_ptr_Function_int Function %11 + OpStore %i %int_0 + %12 = OpLoad %int %i + %14 = OpIAdd %int %12 %int_1 + OpStore %i %14 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/private.wgsl.expected.glsl b/test/tint/statements/increment/private.wgsl.expected.glsl index 49753210a7..f0be314c65 100644 --- a/test/tint/statements/increment/private.wgsl.expected.glsl +++ b/test/tint/statements/increment/private.wgsl.expected.glsl @@ -1,10 +1,11 @@ -SKIP: FAILED +#version 310 es - -var i : i32 = 0; - -fn main() { - i++; +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +int i = 0; +void tint_symbol() { + i = (i + 1); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/private.wgsl.expected.hlsl b/test/tint/statements/increment/private.wgsl.expected.hlsl index 49753210a7..d5883bcfd9 100644 --- a/test/tint/statements/increment/private.wgsl.expected.hlsl +++ b/test/tint/statements/increment/private.wgsl.expected.hlsl @@ -1,10 +1,10 @@ -SKIP: FAILED - - -var i : i32 = 0; - -fn main() { - i++; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement +static int i = 0; + +void main() { + i = (i + 1); +} diff --git a/test/tint/statements/increment/private.wgsl.expected.msl b/test/tint/statements/increment/private.wgsl.expected.msl index abefe6265c..4cf93e4c0f 100644 --- a/test/tint/statements/increment/private.wgsl.expected.msl +++ b/test/tint/statements/increment/private.wgsl.expected.msl @@ -1,10 +1,7 @@ -SKIP: FAILED +#include - -var i : i32 = 0; - -fn tint_symbol() { - i++; +using namespace metal; +void tint_symbol(thread int* const tint_symbol_1) { + *(tint_symbol_1) = as_type((as_type(*(tint_symbol_1)) + as_type(1))); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/private.wgsl.expected.spvasm b/test/tint/statements/increment/private.wgsl.expected.spvasm index cc7f59a346..c05c570a5d 100644 --- a/test/tint/statements/increment/private.wgsl.expected.spvasm +++ b/test/tint/statements/increment/private.wgsl.expected.spvasm @@ -1,10 +1,30 @@ -SKIP: FAILED - - -var i : i32 = 0; - -fn main() { - i++; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 14 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Private_int = OpTypePointer Private %int + %i = OpVariable %_ptr_Private_int Private %int_0 + %void = OpTypeVoid + %5 = OpTypeFunction %void + %int_1 = OpConstant %int 1 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %5 + %10 = OpLabel + %11 = OpLoad %int %i + %13 = OpIAdd %int %11 %int_1 + OpStore %i %13 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/storage.wgsl.expected.glsl b/test/tint/statements/increment/storage.wgsl.expected.glsl index fe12521de8..3a8266da77 100644 --- a/test/tint/statements/increment/storage.wgsl.expected.glsl +++ b/test/tint/statements/increment/storage.wgsl.expected.glsl @@ -1,10 +1,17 @@ -SKIP: FAILED +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct i_block { + uint inner; +}; -@group(0) @binding(0) var i : u32; - -fn main() { - i++; +layout(binding = 0, std430) buffer i_block_1 { + uint inner; +} i; +void tint_symbol() { + i.inner = (i.inner + 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/storage.wgsl.expected.hlsl b/test/tint/statements/increment/storage.wgsl.expected.hlsl index 7e72d16dc3..219ed95a3c 100644 --- a/test/tint/statements/increment/storage.wgsl.expected.hlsl +++ b/test/tint/statements/increment/storage.wgsl.expected.hlsl @@ -1,10 +1,10 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - i++; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer i : register(u0, space0); + +void main() { + i.Store(0u, asuint((i.Load(0u) + 1u))); +} diff --git a/test/tint/statements/increment/storage.wgsl.expected.msl b/test/tint/statements/increment/storage.wgsl.expected.msl index 180706525c..527ccd5122 100644 --- a/test/tint/statements/increment/storage.wgsl.expected.msl +++ b/test/tint/statements/increment/storage.wgsl.expected.msl @@ -1,10 +1,7 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var i : u32; - -fn tint_symbol() { - i++; +using namespace metal; +void tint_symbol(device uint* const tint_symbol_1) { + *(tint_symbol_1) = (*(tint_symbol_1) + 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/storage.wgsl.expected.spvasm b/test/tint/statements/increment/storage.wgsl.expected.spvasm index a5dc0876d6..d1c423dabf 100644 --- a/test/tint/statements/increment/storage.wgsl.expected.spvasm +++ b/test/tint/statements/increment/storage.wgsl.expected.spvasm @@ -1,10 +1,40 @@ -SKIP: FAILED - - -@group(0) @binding(0) var i : u32; - -fn main() { - i++; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 18 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i_block "i_block" + OpMemberName %i_block 0 "inner" + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %i_block Block + OpMemberDecorate %i_block 0 Offset 0 + OpDecorate %i DescriptorSet 0 + OpDecorate %i Binding 0 + %uint = OpTypeInt 32 0 + %i_block = OpTypeStruct %uint +%_ptr_StorageBuffer_i_block = OpTypePointer StorageBuffer %i_block + %i = OpVariable %_ptr_StorageBuffer_i_block StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_1 = OpConstant %uint 1 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %5 + %10 = OpLabel + %13 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %i %uint_0 + %15 = OpLoad %uint %14 + %17 = OpIAdd %uint %15 %uint_1 + OpStore %13 %17 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/vector_component.wgsl.expected.glsl b/test/tint/statements/increment/vector_component.wgsl.expected.glsl index 3a8c651d70..a502a86800 100644 --- a/test/tint/statements/increment/vector_component.wgsl.expected.glsl +++ b/test/tint/statements/increment/vector_component.wgsl.expected.glsl @@ -1,11 +1,19 @@ -SKIP: FAILED +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct a_block { + uvec4 inner; +}; -@group(0) @binding(0) var a : vec4; - -fn main() { - a[1]++; - a.z++; +layout(binding = 0, std430) buffer a_block_1 { + uvec4 inner; +} a; +void tint_symbol() { + int tint_symbol_2 = 1; + a.inner[tint_symbol_2] = (a.inner[tint_symbol_2] + 1u); + a.inner.z = (a.inner.z + 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/vector_component.wgsl.expected.hlsl b/test/tint/statements/increment/vector_component.wgsl.expected.hlsl index 67ce149bae..95c9272ea0 100644 --- a/test/tint/statements/increment/vector_component.wgsl.expected.hlsl +++ b/test/tint/statements/increment/vector_component.wgsl.expected.hlsl @@ -1,11 +1,12 @@ -SKIP: FAILED - - -@group(0) @binding(0) var a : vec4; - -fn main() { - a[1]++; - a.z++; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: cannot modify value of type 'u32' +RWByteAddressBuffer a : register(u0, space0); + +void main() { + const int tint_symbol_1 = 1; + a.Store((4u * uint(tint_symbol_1)), asuint((a.Load((4u * uint(tint_symbol_1))) + 1u))); + a.Store(8u, asuint((a.Load(8u) + 1u))); +} diff --git a/test/tint/statements/increment/vector_component.wgsl.expected.msl b/test/tint/statements/increment/vector_component.wgsl.expected.msl index ec37cab55e..872885467b 100644 --- a/test/tint/statements/increment/vector_component.wgsl.expected.msl +++ b/test/tint/statements/increment/vector_component.wgsl.expected.msl @@ -1,11 +1,9 @@ -SKIP: FAILED +#include - -@group(0) @binding(0) var a : vec4; - -fn tint_symbol() { - a[1]++; - a.z++; +using namespace metal; +void tint_symbol(device uint4* const tint_symbol_3) { + int const tint_symbol_2 = 1; + (*(tint_symbol_3))[tint_symbol_2] = ((*(tint_symbol_3))[tint_symbol_2] + 1u); + (*(tint_symbol_3))[2] = ((*(tint_symbol_3))[2] + 1u); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/vector_component.wgsl.expected.spvasm b/test/tint/statements/increment/vector_component.wgsl.expected.spvasm index 67a7efc86c..e9e34be85f 100644 --- a/test/tint/statements/increment/vector_component.wgsl.expected.spvasm +++ b/test/tint/statements/increment/vector_component.wgsl.expected.spvasm @@ -1,11 +1,49 @@ -SKIP: FAILED - - -@group(0) @binding(0) var a : vec4; - -fn main() { - a[1]++; - a.z++; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %a_block "a_block" + OpMemberName %a_block 0 "inner" + OpName %a "a" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + OpDecorate %a_block Block + OpMemberDecorate %a_block 0 Offset 0 + OpDecorate %a DescriptorSet 0 + OpDecorate %a Binding 0 + %uint = OpTypeInt 32 0 + %v4uint = OpTypeVector %uint 4 + %a_block = OpTypeStruct %v4uint +%_ptr_StorageBuffer_a_block = OpTypePointer StorageBuffer %a_block + %a = OpVariable %_ptr_StorageBuffer_a_block StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %6 + %11 = OpLabel + %16 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %int_1 + %17 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %int_1 + %18 = OpLoad %uint %17 + %20 = OpIAdd %uint %18 %uint_1 + OpStore %16 %20 + %22 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %uint_2 + %23 = OpAccessChain %_ptr_StorageBuffer_uint %a %uint_0 %uint_2 + %24 = OpLoad %uint %23 + %25 = OpIAdd %uint %24 %uint_1 + OpStore %22 %25 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/increment/workgroup.wgsl.expected.glsl b/test/tint/statements/increment/workgroup.wgsl.expected.glsl index 8bf31afe37..9602d70c4d 100644 --- a/test/tint/statements/increment/workgroup.wgsl.expected.glsl +++ b/test/tint/statements/increment/workgroup.wgsl.expected.glsl @@ -1,10 +1,11 @@ -SKIP: FAILED +#version 310 es - -var i : i32; - -fn main() { - i++; +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +shared int i; +void tint_symbol() { + i = (i + 1); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/workgroup.wgsl.expected.hlsl b/test/tint/statements/increment/workgroup.wgsl.expected.hlsl index 8bf31afe37..d8306403cb 100644 --- a/test/tint/statements/increment/workgroup.wgsl.expected.hlsl +++ b/test/tint/statements/increment/workgroup.wgsl.expected.hlsl @@ -1,10 +1,10 @@ -SKIP: FAILED - - -var i : i32; - -fn main() { - i++; +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement +groupshared int i; + +void main() { + i = (i + 1); +} diff --git a/test/tint/statements/increment/workgroup.wgsl.expected.msl b/test/tint/statements/increment/workgroup.wgsl.expected.msl index a1f382d1e7..cf757e7ae9 100644 --- a/test/tint/statements/increment/workgroup.wgsl.expected.msl +++ b/test/tint/statements/increment/workgroup.wgsl.expected.msl @@ -1,10 +1,7 @@ -SKIP: FAILED +#include - -var i : i32; - -fn tint_symbol() { - i++; +using namespace metal; +void tint_symbol(threadgroup int* const tint_symbol_1) { + *(tint_symbol_1) = as_type((as_type(*(tint_symbol_1)) + as_type(1))); } -Failed to generate: error: unknown statement type: tint::ast::IncrementDecrementStatement diff --git a/test/tint/statements/increment/workgroup.wgsl.expected.spvasm b/test/tint/statements/increment/workgroup.wgsl.expected.spvasm index 4cdda461bf..2d30eed89b 100644 --- a/test/tint/statements/increment/workgroup.wgsl.expected.spvasm +++ b/test/tint/statements/increment/workgroup.wgsl.expected.spvasm @@ -1,10 +1,29 @@ -SKIP: FAILED - - -var i : i32; - -fn main() { - i++; -} - -Failed to generate: Unknown statement: tint::ast::IncrementDecrementStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 13 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %main "main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %i = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %int_1 = OpConstant %int 1 +%unused_entry_point = OpFunction %void None %4 + %7 = OpLabel + OpReturn + OpFunctionEnd + %main = OpFunction %void None %4 + %9 = OpLabel + %10 = OpLoad %int %i + %12 = OpIAdd %int %10 %int_1 + OpStore %i %12 + OpReturn + OpFunctionEnd