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 <bclayton@google.com>
diff --git a/docs/tint/origin-trial-changes.md b/docs/tint/origin-trial-changes.md
index 3f3c61d..31f91ce 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 7c967d3..3a986a2 100644
--- a/src/tint/transform/expand_compound_assignment.cc
+++ b/src/tint/transform/expand_compound_assignment.cc
@@ -17,6 +17,7 @@
#include <utility>
#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 @@
bool ExpandCompoundAssignment::ShouldRun(const Program* program,
const DataMap&) const {
for (auto* node : program->ASTNodes().Objects()) {
- if (node->Is<ast::CompoundAssignmentStatement>()) {
+ if (node->IsAnyOf<ast::CompoundAssignmentStatement,
+ ast::IncrementDecrementStatement>()) {
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<const ast::Expression*()> 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<sem::Vector>();
+ };
+
+ // 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<ast::IndexAccessorExpression>();
+ auto* member_accessor = lhs->As<ast::MemberAccessorExpression>();
+ if (lhs->Is<ast::IdentifierExpression>() ||
+ (member_accessor &&
+ member_accessor->structure->Is<ast::IdentifierExpression>())) {
+ // 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<ast::BinaryExpression>(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<ast::CompoundAssignmentStatement>()) {
- 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<const ast::Expression*()> 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<sem::Vector>();
- };
-
- // 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<ast::IndexAccessorExpression>();
- auto* member_accessor = assign->lhs->As<ast::MemberAccessorExpression>();
- if (assign->lhs->Is<ast::IdentifierExpression>() ||
- (member_accessor &&
- member_accessor->structure->Is<ast::IdentifierExpression>())) {
- // 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<ast::BinaryExpression>(
- 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<ast::IncrementDecrementStatement>()) {
+ // 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<ast::IntLiteralExpression>()
+ : ctx.dst->Expr(1u)->As<ast::IntLiteralExpression>();
+ 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 73b0c83..6447117 100644
--- a/src/tint/transform/expand_compound_assignment.h
+++ b/src/tint/transform/expand_compound_assignment.h
@@ -36,6 +36,9 @@
/// 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<ExpandCompoundAssignment, Transform> {
public:
diff --git a/src/tint/transform/expand_compound_assignment_test.cc b/src/tint/transform/expand_compound_assignment_test.cc
index 4ad02d9..dc0992f 100644
--- a/src/tint/transform/expand_compound_assignment_test.cc
+++ b/src/tint/transform/expand_compound_assignment_test.cc
@@ -41,6 +41,17 @@
EXPECT_TRUE(ShouldRun<ExpandCompoundAssignment>(src));
}
+TEST_F(ExpandCompoundAssignmentTest, ShouldRunHasIncrementDecrement) {
+ auto* src = R"(
+fn foo() {
+ var v : i32;
+ v++;
+}
+)";
+
+ EXPECT_TRUE(ShouldRun<ExpandCompoundAssignment>(src));
+}
+
TEST_F(ExpandCompoundAssignmentTest, Basic) {
auto* src = R"(
fn main() {
@@ -452,6 +463,284 @@
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<ExpandCompoundAssignment>(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<ExpandCompoundAssignment>(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<ExpandCompoundAssignment>(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<ExpandCompoundAssignment>(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<ExpandCompoundAssignment>(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<ExpandCompoundAssignment>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
+TEST_F(ExpandCompoundAssignmentTest, Increment_LhsArrayElement) {
+ auto* src = R"(
+var<private> a : array<i32, 4>;
+
+fn idx() -> i32 {
+ a[1] = 42;
+ return 1;
+}
+
+fn main() {
+ a[idx()]++;
+}
+)";
+
+ auto* expect = R"(
+var<private> a : array<i32, 4>;
+
+fn idx() -> i32 {
+ a[1] = 42;
+ return 1;
+}
+
+fn main() {
+ let tint_symbol = &(a[idx()]);
+ *(tint_symbol) = (*(tint_symbol) + 1);
+}
+)";
+
+ auto got = Run<ExpandCompoundAssignment>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
+TEST_F(ExpandCompoundAssignmentTest,
+ Increment_LhsVectorComponent_ArrayAccessor) {
+ auto* src = R"(
+var<private> v : vec4<i32>;
+
+fn idx() -> i32 {
+ v.y = 42;
+ return 1;
+}
+
+fn main() {
+ v[idx()]++;
+}
+)";
+
+ auto* expect = R"(
+var<private> v : vec4<i32>;
+
+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<ExpandCompoundAssignment>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
+TEST_F(ExpandCompoundAssignmentTest,
+ Increment_LhsVectorComponent_MemberAccessor) {
+ auto* src = R"(
+fn main() {
+ var v : vec4<i32>;
+ v.y++;
+}
+)";
+
+ auto* expect = R"(
+fn main() {
+ var v : vec4<i32>;
+ v.y = (v.y + 1);
+}
+)";
+
+ auto got = Run<ExpandCompoundAssignment>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
+TEST_F(ExpandCompoundAssignmentTest, Increment_ForLoopCont) {
+ auto* src = R"(
+var<private> a : array<vec4<i32>, 4>;
+
+var<private> 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<private> a : array<vec4<i32>, 4>;
+
+var<private> 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<ExpandCompoundAssignment>(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 9e5435d..74f7390 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<storage, read_write> a : array<u32>;
-
-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 0f960c8..fda7065 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<storage, read_write> a : array<u32>;
-
-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 f1cd0f6..03752fb 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> a : array<u32>;
-
-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 6cea2ce..8f25fe9 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<storage, read_write> a : array<u32>;
-
-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 67e2532..a04fd4e 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<vec4<i32>, 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<storage, read_write> buffer : array<S>;
-
-var<private> 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 b5f16eb..069b822 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<vec4<i32>, 4>,
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
}
-@group(0) @binding(0) var<storage, read_write> buffer : array<S>;
+RWByteAddressBuffer buffer : register(u0, space0);
+static uint v = 0u;
-var<private> 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 ad5f5a6..e7e4a6c 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 <metal_stdlib>
+using namespace metal;
+struct tint_array_wrapper {
+ /* 0x0000 */ int4 arr[4];
+};
struct S {
- a : array<vec4<i32>, 4>,
-}
+ /* 0x0000 */ tint_array_wrapper a;
+};
-@group(0) @binding(0) var<storage, read_write> tint_symbol : array<S>;
-
-var<private> 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<int>((as_type<uint>((*(tint_symbol_17))[tint_symbol_2_save].a.arr[tint_symbol_2_save_1][tint_symbol_3]) - as_type<uint>(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<int>((as_type<uint>((*(tint_symbol_17))[tint_symbol_4_save].a.arr[tint_symbol_4_save_1][tint_symbol_5]) - as_type<uint>(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 c5953fc..7798efe 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<vec4<i32>, 4>,
-}
-
-@group(0) @binding(0) var<storage, read_write> buffer : array<S>;
-
-var<private> 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 1f4cedf..21a7950 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<storage, read_write> 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 532428f..7baae1b 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<storage, read_write> 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 c11b80d..c91c6b2 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> 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 3e3ebd2..fc8109e 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<storage, read_write> 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 941b4f3..12ce515 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<storage, read_write> 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 9aff109..e520f5e 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<storage, read_write> 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 ebbacb6..1f1ebdf 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> 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 a95225b..5ccbe4e 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<storage, read_write> 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 ad95151..d47e0a4 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 ad95151..479225e 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 4242e3c..b91e30a 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 <metal_stdlib>
-
-fn tint_symbol() {
- var i = 0;
- i--;
+using namespace metal;
+void tint_symbol() {
+ int i = 0;
+ i = as_type<int>((as_type<uint>(i) - as_type<uint>(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 f1adcdf..1eec1fa 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 48cffdb..8b46a5f 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<private> 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 48cffdb..56b4922 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<private> 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 c223434..ad64e49 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 <metal_stdlib>
-
-var<private> i : i32 = 0;
-
-fn tint_symbol() {
- i--;
+using namespace metal;
+void tint_symbol(thread int* const tint_symbol_1) {
+ *(tint_symbol_1) = as_type<int>((as_type<uint>(*(tint_symbol_1)) - as_type<uint>(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 441401d..1514ee9 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<private> 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 4f603ea..88579d1 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<storage, read_write> 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 28354c5..99f9878 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<storage, read_write> 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 bd9b5d5..5d5b6ac 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> 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 133d3f3..cf6cfaf 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<storage, read_write> 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 f6d1854..908643e 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<storage, read_write> a : vec4<u32>;
-
-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 60ca93b..88bf0a8 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<storage, read_write> a : vec4<u32>;
-
-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 4556d7b..7211766 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> a : vec4<u32>;
-
-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 1334066..f7a0664 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<storage, read_write> a : vec4<u32>;
-
-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 e3d1fac..88eb400 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<workgroup> 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 e3d1fac..b39cd01 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<workgroup> 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 66b73b1..06d736f 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 <metal_stdlib>
-
-var<workgroup> i : i32;
-
-fn tint_symbol() {
- i--;
+using namespace metal;
+void tint_symbol(threadgroup int* const tint_symbol_1) {
+ *(tint_symbol_1) = as_type<int>((as_type<uint>(*(tint_symbol_1)) - as_type<uint>(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 b6136ad..837f90d 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<workgroup> 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 5b3648a..8c4b54b 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<storage, read_write> a : array<u32>;
-
-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 0061781..9db143f 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<storage, read_write> a : array<u32>;
-
-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 d996613..0347508 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> a : array<u32>;
-
-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 250f739..7bb17e9 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<storage, read_write> a : array<u32>;
-
-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 f667cca..26c1c10 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<vec4<i32>, 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<storage, read_write> buffer : array<S>;
-
-var<private> 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 bb3ce44..06d410a 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<vec4<i32>, 4>,
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
}
-@group(0) @binding(0) var<storage, read_write> buffer : array<S>;
+RWByteAddressBuffer buffer : register(u0, space0);
+static uint v = 0u;
-var<private> 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 45f0182..fbc0f9c 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 <metal_stdlib>
+using namespace metal;
+struct tint_array_wrapper {
+ /* 0x0000 */ int4 arr[4];
+};
struct S {
- a : array<vec4<i32>, 4>,
-}
+ /* 0x0000 */ tint_array_wrapper a;
+};
-@group(0) @binding(0) var<storage, read_write> tint_symbol : array<S>;
-
-var<private> 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<int>((as_type<uint>((*(tint_symbol_17))[tint_symbol_2_save].a.arr[tint_symbol_2_save_1][tint_symbol_3]) + as_type<uint>(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<int>((as_type<uint>((*(tint_symbol_17))[tint_symbol_4_save].a.arr[tint_symbol_4_save_1][tint_symbol_5]) + as_type<uint>(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 4f6b6c6..9cb91f0 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<vec4<i32>, 4>,
-}
-
-@group(0) @binding(0) var<storage, read_write> buffer : array<S>;
-
-var<private> 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 d039199..50eb494 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<storage, read_write> 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 ed0f720..836d245 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<storage, read_write> 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 e32c199..ee23499 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> 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 b8e09e5..b788b1e 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<storage, read_write> 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 40f942a..77942ca 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<storage, read_write> 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 1fa9624..8653efa 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<storage, read_write> 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 a780f32..b29a247 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> 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 a9235f9..dffef09 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<storage, read_write> 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 141a0e7..3f86ce8 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 141a0e7..900a2d0 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 4c16d00..06dde9d 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 <metal_stdlib>
-
-fn tint_symbol() {
- var i = 0;
- i++;
+using namespace metal;
+void tint_symbol() {
+ int i = 0;
+ i = as_type<int>((as_type<uint>(i) + as_type<uint>(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 d48fc47..0ed1409 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 4975321..f0be314 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<private> 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 4975321..d5883bc 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<private> 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 abefe62..4cf93e4 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 <metal_stdlib>
-
-var<private> i : i32 = 0;
-
-fn tint_symbol() {
- i++;
+using namespace metal;
+void tint_symbol(thread int* const tint_symbol_1) {
+ *(tint_symbol_1) = as_type<int>((as_type<uint>(*(tint_symbol_1)) + as_type<uint>(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 cc7f59a..c05c570 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<private> 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 fe12521..3a8266d 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<storage, read_write> 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 7e72d16..219ed95 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<storage, read_write> 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 1807065..527ccd5 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> 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 a5dc087..d1c423d 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<storage, read_write> 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 3a8c651..a502a86 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<storage, read_write> a : vec4<u32>;
-
-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 67ce149..95c9272 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<storage, read_write> a : vec4<u32>;
-
-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 ec37cab..8728854 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 <metal_stdlib>
-
-@group(0) @binding(0) var<storage, read_write> a : vec4<u32>;
-
-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 67a7efc..e9e34be 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<storage, read_write> a : vec4<u32>;
-
-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 8bf31af..9602d70 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<workgroup> 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 8bf31af..d830640 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<workgroup> 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 a1f382d..cf757e7 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 <metal_stdlib>
-
-var<workgroup> i : i32;
-
-fn tint_symbol() {
- i++;
+using namespace metal;
+void tint_symbol(threadgroup int* const tint_symbol_1) {
+ *(tint_symbol_1) = as_type<int>((as_type<uint>(*(tint_symbol_1)) + as_type<uint>(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 4cdda46..2d30eed 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<workgroup> 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