resolver: Remove rule that call statements to functions must return void

Fixed: tint:1256
Change-Id: Ibff78a1009d57afd7af8867952a9444daaf13a9c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67201
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2021-10-21 20:36:04 +00:00 committed by Tint LUCI CQ
parent 38ed53ce8f
commit 72789de9f5
42 changed files with 318 additions and 353 deletions

View File

@ -11,6 +11,7 @@
### New Features
* `any()` and `all()` now support a `bool` parameter. These simply return the passed argument. [tint:1253](https://crbug.com/tint/1253)
* Call statements may now include functions that return a value (`ignore()` is no longer needed).
### Fixes

View File

@ -103,7 +103,7 @@ fn f1(p0 : f32, p1 : i32) -> f32 {
[[stage(fragment)]]
fn main() {
ignore(f1(1.0, 2));
f1(1.0, 2);
}
let declaration_order_check_0 : i32 = 1;

View File

@ -2233,8 +2233,8 @@ TEST_P(InspectorGetMultisampledTextureResourceBindingsTestWithParam,
Func("ep", ast::VariableList(), ty.void_(),
ast::StatementList{
Ignore(Call("textureLoad", "foo_texture", "foo_coords",
"foo_sample_index")),
CallStmt(Call("textureLoad", "foo_texture", "foo_coords",
"foo_sample_index")),
},
ast::DecorationList{
Stage(ast::PipelineStage::kFragment),
@ -2475,7 +2475,7 @@ TEST_P(InspectorGetDepthTextureResourceBindingsTestWithParam,
Func("ep", ast::VariableList(), ty.void_(),
ast::StatementList{
Ignore(Call("textureDimensions", "dt")),
CallStmt(Call("textureDimensions", "dt")),
},
ast::DecorationList{
Stage(ast::PipelineStage::kFragment),
@ -2519,7 +2519,7 @@ TEST_F(InspectorGetDepthMultisampledTextureResourceBindingsTest,
Func("ep", ast::VariableList(), ty.void_(),
ast::StatementList{
Ignore(Call("textureDimensions", "tex")),
CallStmt(Call("textureDimensions", "tex")),
},
ast::DecorationList{
Stage(ast::PipelineStage::kFragment),
@ -2544,7 +2544,7 @@ TEST_F(InspectorGetExternalTextureResourceBindingsTest, Simple) {
Func("ep", ast::VariableList(), ty.void_(),
ast::StatementList{
Ignore(Call("textureDimensions", "et")),
CallStmt(Call("textureDimensions", "et")),
},
ast::DecorationList{
Stage(ast::PipelineStage::kFragment),

View File

@ -40,7 +40,7 @@ void InspectorBuilder::MakeCallerBodyFunction(std::string caller,
ast::StatementList body;
body.reserve(callees.size() + 1);
for (auto callee : callees) {
body.push_back(create<ast::CallStatement>(Call(callee)));
body.push_back(CallStmt(Call(callee)));
}
body.push_back(Return());

View File

@ -121,7 +121,7 @@ const ast::Statement* ProgramBuilder::WrapInStatement(const ast::Literal* lit) {
const ast::Statement* ProgramBuilder::WrapInStatement(
const ast::Expression* expr) {
if (auto* ce = expr->As<ast::CallExpression>()) {
return Ignore(ce);
return CallStmt(ce);
}
// Create a temporary variable of inferred type from expr.
return Decl(Const(symbols_.New(), nullptr, expr));

View File

@ -1619,6 +1619,20 @@ class ProgramBuilder {
ExprList(std::forward<ARGS>(args)...));
}
/// @param source the source information
/// @param call the call expression to wrap in a call statement
/// @returns a `ast::CallStatement` for the given call expression
const ast::CallStatement* CallStmt(const Source& source,
const ast::CallExpression* call) {
return create<ast::CallStatement>(source, call);
}
/// @param call the call expression to wrap in a call statement
/// @returns a `ast::CallStatement` for the given call expression
const ast::CallStatement* CallStmt(const ast::CallExpression* call) {
return create<ast::CallStatement>(call);
}
/// @param source the source information
/// @returns a `ast::PhonyExpression`
const ast::PhonyExpression* Phony(const Source& source) {

View File

@ -986,7 +986,7 @@ TEST_P(FloatAllMatching, Scalar) {
params.push_back(Expr(1.0f));
}
auto* builtin = Call(name, params);
Func("func", {}, ty.void_(), {Ignore(builtin)},
Func("func", {}, ty.void_(), {CallStmt(builtin)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1002,7 +1002,7 @@ TEST_P(FloatAllMatching, Vec2) {
params.push_back(vec2<f32>(1.0f, 1.0f));
}
auto* builtin = Call(name, params);
Func("func", {}, ty.void_(), {Ignore(builtin)},
Func("func", {}, ty.void_(), {CallStmt(builtin)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1018,7 +1018,7 @@ TEST_P(FloatAllMatching, Vec3) {
params.push_back(vec3<f32>(1.0f, 1.0f, 1.0f));
}
auto* builtin = Call(name, params);
Func("func", {}, ty.void_(), {Ignore(builtin)},
Func("func", {}, ty.void_(), {CallStmt(builtin)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1034,7 +1034,7 @@ TEST_P(FloatAllMatching, Vec4) {
params.push_back(vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
}
auto* builtin = Call(name, params);
Func("func", {}, ty.void_(), {Ignore(builtin)},
Func("func", {}, ty.void_(), {CallStmt(builtin)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
EXPECT_TRUE(r()->Resolve()) << r()->error();

View File

@ -33,7 +33,7 @@ TEST_F(ResolverCallValidationTest, Recursive_Invalid) {
Func("main", params0, ty.void_(),
ast::StatementList{
create<ast::CallStatement>(call_expr),
CallStmt(call_expr),
},
ast::DecorationList{
Stage(ast::PipelineStage::kVertex),
@ -56,7 +56,7 @@ TEST_F(ResolverCallValidationTest, Undeclared_Invalid) {
Func("main", params0, ty.f32(),
ast::StatementList{
create<ast::CallStatement>(call_expr),
CallStmt(call_expr),
Return(),
},
ast::DecorationList{});
@ -109,23 +109,19 @@ TEST_F(ResolverCallValidationTest, MismatchedArgs) {
}
TEST_F(ResolverCallValidationTest, UnusedRetval) {
// fn func() -> f32 { return 1.0; }
// fn main() {func(); return; }
// fn func() { return; }
Func("func", {}, ty.f32(), {Return(Expr(1.0f))}, {});
Func("main", {}, ty.f32(),
Func("main", {}, ty.void_(),
ast::StatementList{
create<ast::CallStatement>(Source{{12, 34}}, Call("func")),
CallStmt(Source{{12, 34}}, Call("func")),
Return(),
},
{});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: result of called function was not used. If this was "
"intentional wrap the function call in ignore()");
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverCallValidationTest, PointerArgument_VariableIdentExpr) {
@ -139,8 +135,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_VariableIdentExpr) {
Func("main", {}, ty.void_(),
ast::StatementList{
Decl(Var("z", ty.i32(), Expr(1))),
create<ast::CallStatement>(
Call("foo", AddressOf(Source{{12, 34}}, Expr("z")))),
CallStmt(Call("foo", AddressOf(Source{{12, 34}}, Expr("z")))),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -157,8 +152,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_ConstIdentExpr) {
Func("main", {}, ty.void_(),
ast::StatementList{
Decl(Const("z", ty.i32(), Expr(1))),
create<ast::CallStatement>(
Call("foo", AddressOf(Expr(Source{{12, 34}}, "z")))),
CallStmt(Call("foo", AddressOf(Expr(Source{{12, 34}}, "z")))),
});
EXPECT_FALSE(r()->Resolve());
@ -178,7 +172,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_NotIdentExprVar) {
Func("main", {}, ty.void_(),
ast::StatementList{
Decl(Var("v", ty.Of(S))),
create<ast::CallStatement>(Call(
CallStmt(Call(
"foo", AddressOf(Source{{12, 34}}, MemberAccessor("v", "m")))),
});
@ -201,9 +195,8 @@ TEST_F(ResolverCallValidationTest, PointerArgument_AddressOfMemberAccessor) {
Func("main", {}, ty.void_(),
ast::StatementList{
Decl(Const("v", ty.Of(S), Construct(ty.Of(S)))),
create<ast::CallStatement>(Call(
"foo",
AddressOf(Expr(Source{{12, 34}}, MemberAccessor("v", "m"))))),
CallStmt(Call("foo", AddressOf(Expr(Source{{12, 34}},
MemberAccessor("v", "m"))))),
});
EXPECT_FALSE(r()->Resolve());
@ -218,8 +211,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_FunctionParam) {
Func("foo", {Param("p", ty.pointer<i32>(ast::StorageClass::kFunction))},
ty.void_(), {});
Func("bar", {Param("p", ty.pointer<i32>(ast::StorageClass::kFunction))},
ty.void_(),
ast::StatementList{create<ast::CallStatement>(Call("foo", Expr("p")))});
ty.void_(), ast::StatementList{CallStmt(Call("foo", Expr("p")))});
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -237,12 +229,11 @@ TEST_F(ResolverCallValidationTest, PointerArgument_FunctionParamWithMain) {
Func("foo", {Param("p", ty.pointer<i32>(ast::StorageClass::kFunction))},
ty.void_(), {});
Func("bar", {Param("p", ty.pointer<i32>(ast::StorageClass::kFunction))},
ty.void_(),
ast::StatementList{create<ast::CallStatement>(Call("foo", Expr("p")))});
ty.void_(), ast::StatementList{CallStmt(Call("foo", Expr("p")))});
Func("main", ast::VariableList{}, ty.void_(),
{
Decl(Var("v", ty.i32(), Expr(1))),
create<ast::CallStatement>(Call("foo", AddressOf(Expr("v")))),
CallStmt(Call("foo", AddressOf(Expr("v")))),
},
{
Stage(ast::PipelineStage::kFragment),

View File

@ -399,7 +399,7 @@ TEST_F(ResolverFunctionValidationTest, CannotCallEntryPoint) {
Func("func", ast::VariableList{}, ty.void_(),
{
create<ast::CallStatement>(Call(Source{{12, 34}}, "entrypoint")),
CallStmt(Call(Source{{12, 34}}, "entrypoint")),
});
EXPECT_FALSE(r()->Resolve());

View File

@ -506,7 +506,7 @@ TEST_P(ResolverIntrinsicTest_Barrier, InferType) {
auto param = GetParam();
auto* call = Call(param.name);
WrapInFunction(create<ast::CallStatement>(call));
WrapInFunction(CallStmt(call));
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
@ -517,7 +517,7 @@ TEST_P(ResolverIntrinsicTest_Barrier, Error_TooManyParams) {
auto param = GetParam();
auto* call = Call(param.name, vec4<f32>(1.f, 2.f, 3.f, 4.f), 1.0f);
WrapInFunction(create<ast::CallStatement>(call));
WrapInFunction(CallStmt(call));
EXPECT_FALSE(r()->Resolve());
@ -1943,9 +1943,7 @@ TEST_P(ResolverIntrinsicTest_Texture, Call) {
param.BuildSamplerVariable(this);
auto* call = Call(param.function, param.args(this));
auto* stmt = ast::intrinsic::test::ReturnsVoid(param.overload)
? create<ast::CallStatement>(call)
: Ignore(call);
auto* stmt = CallStmt(call);
Func("func", {}, ty.void_(), {stmt}, {Stage(ast::PipelineStage::kFragment)});
ASSERT_TRUE(r()->Resolve()) << r()->error();

View File

@ -40,7 +40,8 @@ TEST_F(ResolverIntrinsicValidationTest, InvalidPipelineStageDirect) {
auto* dpdx = create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"),
ast::ExpressionList{Expr(1.0f)});
Func(Source{{1, 2}}, "func", ast::VariableList{}, ty.void_(), {Ignore(dpdx)},
Func(Source{{1, 2}}, "func", ast::VariableList{}, ty.void_(),
{CallStmt(dpdx)},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
EXPECT_FALSE(r()->Resolve());
@ -56,16 +57,13 @@ TEST_F(ResolverIntrinsicValidationTest, InvalidPipelineStageIndirect) {
auto* dpdx = create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"),
ast::ExpressionList{Expr(1.0f)});
Func(Source{{1, 2}}, "f0", {}, ty.void_(), {Ignore(dpdx)});
Func(Source{{1, 2}}, "f0", {}, ty.void_(), {CallStmt(dpdx)});
Func(Source{{3, 4}}, "f1", {}, ty.void_(),
{create<ast::CallStatement>(Call("f0"))});
Func(Source{{3, 4}}, "f1", {}, ty.void_(), {CallStmt(Call("f0"))});
Func(Source{{5, 6}}, "f2", {}, ty.void_(),
{create<ast::CallStatement>(Call("f1"))});
Func(Source{{5, 6}}, "f2", {}, ty.void_(), {CallStmt(Call("f1"))});
Func(Source{{7, 8}}, "main", {}, ty.void_(),
{create<ast::CallStatement>(Call("f2"))},
Func(Source{{7, 8}}, "main", {}, ty.void_(), {CallStmt(Call("f2"))},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
EXPECT_FALSE(r()->Resolve());
@ -141,7 +139,7 @@ TEST_P(IntrinsicTextureSamplerValidationTest, ConstExpr) {
}
auto* call = Call(param.function, args);
Func("func", {}, ty.void_(), {Ignore(call)},
Func("func", {}, ty.void_(), {CallStmt(call)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
if (offset.is_valid) {
@ -175,7 +173,7 @@ TEST_P(IntrinsicTextureSamplerValidationTest, ConstExprOfConstExpr) {
Construct(ty.vec2<i32>(), offset.y, offset.z)));
}
auto* call = Call(param.function, args);
Func("func", {}, ty.void_(), {Ignore(call)},
Func("func", {}, ty.void_(), {CallStmt(call)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
if (offset.is_valid) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -206,7 +204,7 @@ TEST_P(IntrinsicTextureSamplerValidationTest, EmptyVectorConstructor) {
}
auto* call = Call(param.function, args);
Func("func", {}, ty.void_(), {Ignore(call)},
Func("func", {}, ty.void_(), {CallStmt(call)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -232,7 +230,7 @@ TEST_P(IntrinsicTextureSamplerValidationTest, GlobalConst) {
}
auto* call = Call(param.function, args);
Func("func", {}, ty.void_(), {Ignore(call)},
Func("func", {}, ty.void_(), {CallStmt(call)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
EXPECT_FALSE(r()->Resolve());
std::stringstream err;
@ -261,7 +259,7 @@ TEST_P(IntrinsicTextureSamplerValidationTest, ScalarConst) {
}
auto* call = Call(param.function, args);
Func("func", {}, ty.void_(), {Decl(x), Ignore(call)},
Func("func", {}, ty.void_(), {Decl(x), CallStmt(call)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
EXPECT_FALSE(r()->Resolve());
std::stringstream err;

View File

@ -2475,21 +2475,7 @@ bool Resolver::ValidateCall(const ast::CallExpression* call) {
return true;
}
bool Resolver::ValidateCallStatement(const ast::CallStatement* stmt) {
const sem::Type* return_type = TypeOf(stmt->expr);
if (!return_type->Is<sem::Void>()) {
// https://gpuweb.github.io/gpuweb/wgsl/#function-call-statement
// A function call statement executes a function call where the called
// function does not return a value. If the called function returns a value,
// that value must be consumed either through assignment, evaluation in
// another expression or through use of the ignore built-in function (see
// §16.13 Value-steering functions).
AddError(
"result of called function was not used. If this was intentional wrap "
"the function call in ignore()",
stmt->source);
return false;
}
bool Resolver::ValidateCallStatement(const ast::CallStatement*) {
return true;
}

View File

@ -270,7 +270,7 @@ TEST_F(ResolverTest, Stmt_Call) {
auto* expr = Call("my_func");
auto* call = create<ast::CallStatement>(expr);
auto* call = CallStmt(expr);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1947,22 +1947,22 @@ TEST_F(ResolverTest, Function_EntryPoints_LinearTime) {
for (int i = levels - 1; i >= 0; i--) {
Func(fn_a(i), {}, ty.void_(),
{
create<ast::CallStatement>(Call(fn_a(i + 1))),
create<ast::CallStatement>(Call(fn_b(i + 1))),
CallStmt(Call(fn_a(i + 1))),
CallStmt(Call(fn_b(i + 1))),
},
{});
Func(fn_b(i), {}, ty.void_(),
{
create<ast::CallStatement>(Call(fn_a(i + 1))),
create<ast::CallStatement>(Call(fn_b(i + 1))),
CallStmt(Call(fn_a(i + 1))),
CallStmt(Call(fn_b(i + 1))),
},
{});
}
Func("main", {}, ty.void_(),
{
create<ast::CallStatement>(Call(fn_a(0))),
create<ast::CallStatement>(Call(fn_b(0))),
CallStmt(Call(fn_a(0))),
CallStmt(Call(fn_b(0))),
},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});

View File

@ -90,10 +90,8 @@ TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInFragmentStage) {
auto* stmt = Assign(Expr("dst"), Expr(Source{{3, 4}}, "wg"));
Func(Source{{5, 6}}, "f2", {}, ty.void_(), {stmt});
Func(Source{{7, 8}}, "f1", {}, ty.void_(),
{create<ast::CallStatement>(Call("f2"))});
Func(Source{{9, 10}}, "f0", {}, ty.void_(),
{create<ast::CallStatement>(Call("f1"))},
Func(Source{{7, 8}}, "f1", {}, ty.void_(), {CallStmt(Call("f2"))});
Func(Source{{9, 10}}, "f0", {}, ty.void_(), {CallStmt(Call("f1"))},
ast::DecorationList{Stage(ast::PipelineStage::kFragment)});
EXPECT_FALSE(r()->Resolve());

View File

@ -193,14 +193,13 @@ void CalculateArrayLength::Run(CloneContext& ctx, const DataMap&, DataMap&) {
ast::StorageClass::kNone, ctx.dst->Expr(0u)));
// Call storage_buffer.GetDimensions(&buffer_size_result)
auto* call_get_dims =
ctx.dst->create<ast::CallStatement>(ctx.dst->Call(
// BufferSizeIntrinsic(X, ARGS...) is
// translated to:
// X.GetDimensions(ARGS..) by the writer
buffer_size, ctx.Clone(storage_buffer_expr),
ctx.dst->AddressOf(ctx.dst->Expr(
buffer_size_result->variable->symbol))));
auto* call_get_dims = ctx.dst->CallStmt(ctx.dst->Call(
// BufferSizeIntrinsic(X, ARGS...) is
// translated to:
// X.GetDimensions(ARGS..) by the writer
buffer_size, ctx.Clone(storage_buffer_expr),
ctx.dst->AddressOf(
ctx.dst->Expr(buffer_size_result->variable->symbol))));
// Calculate actual array length
// total_storage_buffer_size - array_offset

View File

@ -497,7 +497,7 @@ struct CanonicalizeEntryPointIO::State {
};
if (func_sem->ReturnType()->Is<sem::Void>()) {
// The function call is just a statement with no result.
wrapper_body.push_back(ctx.dst->create<ast::CallStatement>(call_inner));
wrapper_body.push_back(ctx.dst->CallStmt(call_inner));
} else {
// Capture the result of calling the original function.
auto* inner_result = ctx.dst->Const(

View File

@ -606,8 +606,8 @@ struct DecomposeMemoryAccess::State {
auto* arr_el = b.IndexAccessor(array, i);
auto* el_offset =
b.Add(b.Expr("offset"), b.Mul(i, arr_ty->Stride()));
auto* store_stmt = b.create<ast::CallStatement>(
b.Call(store, "buffer", el_offset, arr_el));
auto* store_stmt =
b.CallStmt(b.Call(store, "buffer", el_offset, arr_el));
auto* for_loop =
b.For(for_init, for_cond, for_cont, b.Block(store_stmt));
@ -619,7 +619,7 @@ struct DecomposeMemoryAccess::State {
auto* offset = b.Add("offset", i * mat_ty->ColumnStride());
auto* access = b.IndexAccessor("value", i);
auto* call = b.Call(store, "buffer", offset, access);
body.emplace_back(b.create<ast::CallStatement>(call));
body.emplace_back(b.CallStmt(call));
}
} else if (auto* str = el_ty->As<sem::Struct>()) {
for (auto* member : str->Members()) {
@ -629,7 +629,7 @@ struct DecomposeMemoryAccess::State {
Symbol store =
StoreFunc(buf_ty, member->Type()->UnwrapRef(), var_user);
auto* call = b.Call(store, "buffer", offset, access);
body.emplace_back(b.create<ast::CallStatement>(call));
body.emplace_back(b.CallStmt(call));
}
}
b.Func(name, params, b.ty.void_(), body);
@ -995,7 +995,7 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) {
store.target.var->As<sem::VariableUser>());
auto* call = ctx.dst->Call(func, ctx.CloneWithoutTransform(buf), offset,
ctx.Clone(value));
return ctx.dst->create<ast::CallStatement>(call);
return ctx.dst->CallStmt(call);
});
}

View File

@ -1235,28 +1235,28 @@ struct SB {
[[stage(compute), workgroup_size(1)]]
fn main() {
atomicStore(&sb.a, 123);
ignore(atomicLoad(&sb.a));
ignore(atomicAdd(&sb.a, 123));
ignore(atomicSub(&sb.a, 123));
ignore(atomicMax(&sb.a, 123));
ignore(atomicMin(&sb.a, 123));
ignore(atomicAnd(&sb.a, 123));
ignore(atomicOr(&sb.a, 123));
ignore(atomicXor(&sb.a, 123));
ignore(atomicExchange(&sb.a, 123));
ignore(atomicCompareExchangeWeak(&sb.a, 123, 345));
atomicLoad(&sb.a);
atomicAdd(&sb.a, 123);
atomicSub(&sb.a, 123);
atomicMax(&sb.a, 123);
atomicMin(&sb.a, 123);
atomicAnd(&sb.a, 123);
atomicOr(&sb.a, 123);
atomicXor(&sb.a, 123);
atomicExchange(&sb.a, 123);
atomicCompareExchangeWeak(&sb.a, 123, 345);
atomicStore(&sb.b, 123u);
ignore(atomicLoad(&sb.b));
ignore(atomicAdd(&sb.b, 123u));
ignore(atomicSub(&sb.b, 123u));
ignore(atomicMax(&sb.b, 123u));
ignore(atomicMin(&sb.b, 123u));
ignore(atomicAnd(&sb.b, 123u));
ignore(atomicOr(&sb.b, 123u));
ignore(atomicXor(&sb.b, 123u));
ignore(atomicExchange(&sb.b, 123u));
ignore(atomicCompareExchangeWeak(&sb.b, 123u, 345u));
atomicLoad(&sb.b);
atomicAdd(&sb.b, 123u);
atomicSub(&sb.b, 123u);
atomicMax(&sb.b, 123u);
atomicMin(&sb.b, 123u);
atomicAnd(&sb.b, 123u);
atomicOr(&sb.b, 123u);
atomicXor(&sb.b, 123u);
atomicExchange(&sb.b, 123u);
atomicCompareExchangeWeak(&sb.b, 123u, 345u);
}
)";
@ -1339,27 +1339,27 @@ fn tint_symbol_21([[internal(disable_validation__ignore_constructible_function_p
[[stage(compute), workgroup_size(1)]]
fn main() {
tint_symbol(sb, 16u, 123);
ignore(tint_symbol_1(sb, 16u));
ignore(tint_symbol_2(sb, 16u, 123));
ignore(tint_symbol_3(sb, 16u, 123));
ignore(tint_symbol_4(sb, 16u, 123));
ignore(tint_symbol_5(sb, 16u, 123));
ignore(tint_symbol_6(sb, 16u, 123));
ignore(tint_symbol_7(sb, 16u, 123));
ignore(tint_symbol_8(sb, 16u, 123));
ignore(tint_symbol_9(sb, 16u, 123));
ignore(tint_symbol_10(sb, 16u, 123, 345));
tint_symbol_1(sb, 16u);
tint_symbol_2(sb, 16u, 123);
tint_symbol_3(sb, 16u, 123);
tint_symbol_4(sb, 16u, 123);
tint_symbol_5(sb, 16u, 123);
tint_symbol_6(sb, 16u, 123);
tint_symbol_7(sb, 16u, 123);
tint_symbol_8(sb, 16u, 123);
tint_symbol_9(sb, 16u, 123);
tint_symbol_10(sb, 16u, 123, 345);
tint_symbol_11(sb, 20u, 123u);
ignore(tint_symbol_12(sb, 20u));
ignore(tint_symbol_13(sb, 20u, 123u));
ignore(tint_symbol_14(sb, 20u, 123u));
ignore(tint_symbol_15(sb, 20u, 123u));
ignore(tint_symbol_16(sb, 20u, 123u));
ignore(tint_symbol_17(sb, 20u, 123u));
ignore(tint_symbol_18(sb, 20u, 123u));
ignore(tint_symbol_19(sb, 20u, 123u));
ignore(tint_symbol_20(sb, 20u, 123u));
ignore(tint_symbol_21(sb, 20u, 123u, 345u));
tint_symbol_12(sb, 20u);
tint_symbol_13(sb, 20u, 123u);
tint_symbol_14(sb, 20u, 123u);
tint_symbol_15(sb, 20u, 123u);
tint_symbol_16(sb, 20u, 123u);
tint_symbol_17(sb, 20u, 123u);
tint_symbol_18(sb, 20u, 123u);
tint_symbol_19(sb, 20u, 123u);
tint_symbol_20(sb, 20u, 123u);
tint_symbol_21(sb, 20u, 123u, 345u);
}
)";
@ -1381,27 +1381,27 @@ var<workgroup> w : S;
[[stage(compute), workgroup_size(1)]]
fn main() {
atomicStore(&(w.a), 123);
ignore(atomicLoad(&(w.a)));
ignore(atomicAdd(&(w.a), 123));
ignore(atomicSub(&(w.a), 123));
ignore(atomicMax(&(w.a), 123));
ignore(atomicMin(&(w.a), 123));
ignore(atomicAnd(&(w.a), 123));
ignore(atomicOr(&(w.a), 123));
ignore(atomicXor(&(w.a), 123));
ignore(atomicExchange(&(w.a), 123));
ignore(atomicCompareExchangeWeak(&(w.a), 123, 345));
atomicLoad(&(w.a));
atomicAdd(&(w.a), 123);
atomicSub(&(w.a), 123);
atomicMax(&(w.a), 123);
atomicMin(&(w.a), 123);
atomicAnd(&(w.a), 123);
atomicOr(&(w.a), 123);
atomicXor(&(w.a), 123);
atomicExchange(&(w.a), 123);
atomicCompareExchangeWeak(&(w.a), 123, 345);
atomicStore(&(w.b), 123u);
ignore(atomicLoad(&(w.b)));
ignore(atomicAdd(&(w.b), 123u));
ignore(atomicSub(&(w.b), 123u));
ignore(atomicMax(&(w.b), 123u));
ignore(atomicMin(&(w.b), 123u));
ignore(atomicAnd(&(w.b), 123u));
ignore(atomicOr(&(w.b), 123u));
ignore(atomicXor(&(w.b), 123u));
ignore(atomicExchange(&(w.b), 123u));
ignore(atomicCompareExchangeWeak(&(w.b), 123u, 345u));
atomicLoad(&(w.b));
atomicAdd(&(w.b), 123u);
atomicSub(&(w.b), 123u);
atomicMax(&(w.b), 123u);
atomicMin(&(w.b), 123u);
atomicAnd(&(w.b), 123u);
atomicOr(&(w.b), 123u);
atomicXor(&(w.b), 123u);
atomicExchange(&(w.b), 123u);
atomicCompareExchangeWeak(&(w.b), 123u, 345u);
}
)";

View File

@ -53,7 +53,7 @@ fn test(vert_idx : u32) -> u32 {
[[stage(vertex)]]
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(test(vert_idx));
test(vert_idx);
return vec4<f32>();
}
)";
@ -72,7 +72,7 @@ fn test(vert_idx : u32) -> u32 {
[[stage(vertex)]]
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(test((vert_idx + tint_symbol_1.first_vertex_index)));
test((vert_idx + tint_symbol_1.first_vertex_index));
return vec4<f32>();
}
)";
@ -100,7 +100,7 @@ fn test(inst_idx : u32) -> u32 {
[[stage(vertex)]]
fn entry([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(test(inst_idx));
test(inst_idx);
return vec4<f32>();
}
)";
@ -119,7 +119,7 @@ fn test(inst_idx : u32) -> u32 {
[[stage(vertex)]]
fn entry([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(test((inst_idx + tint_symbol_1.first_instance_index)));
test((inst_idx + tint_symbol_1.first_instance_index));
return vec4<f32>();
}
)";
@ -152,7 +152,7 @@ struct Inputs {
[[stage(vertex)]]
fn entry(inputs : Inputs) -> [[builtin(position)]] vec4<f32> {
ignore(test(inputs.instance_idx, inputs.vert_idx));
test(inputs.instance_idx, inputs.vert_idx);
return vec4<f32>();
}
)";
@ -179,7 +179,7 @@ struct Inputs {
[[stage(vertex)]]
fn entry(inputs : Inputs) -> [[builtin(position)]] vec4<f32> {
ignore(test((inputs.instance_idx + tint_symbol_1.first_instance_index), (inputs.vert_idx + tint_symbol_1.first_vertex_index)));
test((inputs.instance_idx + tint_symbol_1.first_instance_index), (inputs.vert_idx + tint_symbol_1.first_vertex_index));
return vec4<f32>();
}
)";
@ -211,7 +211,7 @@ fn func2(vert_idx : u32) -> u32 {
[[stage(vertex)]]
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(func2(vert_idx));
func2(vert_idx);
return vec4<f32>();
}
)";
@ -234,7 +234,7 @@ fn func2(vert_idx : u32) -> u32 {
[[stage(vertex)]]
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(func2((vert_idx + tint_symbol_1.first_vertex_index)));
func2((vert_idx + tint_symbol_1.first_vertex_index));
return vec4<f32>();
}
)";
@ -262,19 +262,19 @@ fn func(i : u32) -> u32 {
[[stage(vertex)]]
fn entry_a([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(func(vert_idx));
func(vert_idx);
return vec4<f32>();
}
[[stage(vertex)]]
fn entry_b([[builtin(vertex_index)]] vert_idx : u32, [[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(func(vert_idx + inst_idx));
func(vert_idx + inst_idx);
return vec4<f32>();
}
[[stage(vertex)]]
fn entry_c([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(func(inst_idx));
func(inst_idx);
return vec4<f32>();
}
)";
@ -294,19 +294,19 @@ fn func(i : u32) -> u32 {
[[stage(vertex)]]
fn entry_a([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(func((vert_idx + tint_symbol_1.first_vertex_index)));
func((vert_idx + tint_symbol_1.first_vertex_index));
return vec4<f32>();
}
[[stage(vertex)]]
fn entry_b([[builtin(vertex_index)]] vert_idx : u32, [[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(func(((vert_idx + tint_symbol_1.first_vertex_index) + (inst_idx + tint_symbol_1.first_instance_index))));
func(((vert_idx + tint_symbol_1.first_vertex_index) + (inst_idx + tint_symbol_1.first_instance_index)));
return vec4<f32>();
}
[[stage(vertex)]]
fn entry_c([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
ignore(func((inst_idx + tint_symbol_1.first_instance_index)));
func((inst_idx + tint_symbol_1.first_instance_index));
return vec4<f32>();
}
)";

View File

@ -670,14 +670,14 @@ fn f() {
var level_idx : i32;
var sample_idx : i32;
ignore(textureLoad(tex_1d, 1, level_idx));
ignore(textureLoad(tex_2d, vec2<i32>(1, 2), level_idx));
ignore(textureLoad(tex_2d_arr, vec2<i32>(1, 2), array_idx, level_idx));
ignore(textureLoad(tex_3d, vec3<i32>(1, 2, 3), level_idx));
ignore(textureLoad(tex_ms_2d, vec2<i32>(1, 2), sample_idx));
ignore(textureLoad(tex_depth_2d, vec2<i32>(1, 2), level_idx));
ignore(textureLoad(tex_depth_2d_arr, vec2<i32>(1, 2), array_idx, level_idx));
ignore(textureLoad(tex_external, vec2<i32>(1, 2)));
textureLoad(tex_1d, 1, level_idx);
textureLoad(tex_2d, vec2<i32>(1, 2), level_idx);
textureLoad(tex_2d_arr, vec2<i32>(1, 2), array_idx, level_idx);
textureLoad(tex_3d, vec3<i32>(1, 2, 3), level_idx);
textureLoad(tex_ms_2d, vec2<i32>(1, 2), sample_idx);
textureLoad(tex_depth_2d, vec2<i32>(1, 2), level_idx);
textureLoad(tex_depth_2d_arr, vec2<i32>(1, 2), array_idx, level_idx);
textureLoad(tex_external, vec2<i32>(1, 2));
}
)";
@ -703,14 +703,14 @@ fn f() {
var array_idx : i32;
var level_idx : i32;
var sample_idx : i32;
ignore(textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1))) - i32(1))), clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1))));
ignore(textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1))));
ignore(textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1))));
ignore(textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1))) - vec3<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1))));
ignore(textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1))), sample_idx));
ignore(textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1))));
ignore(textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_depth_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1))));
ignore(textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1)))));
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1))) - i32(1))), clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1)));
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1)));
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1)));
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1))) - vec3<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1)));
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1))), sample_idx);
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1)));
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_depth_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1)));
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1))));
}
)";

View File

@ -260,7 +260,7 @@ struct ZeroInitWorkgroupMemory::State {
// Append a single workgroup barrier after the zero initialization.
ctx.InsertFront(fn->body->statements,
b.create<ast::CallStatement>(b.Call("workgroupBarrier")));
b.CallStmt(b.Call("workgroupBarrier")));
}
/// BuildZeroingExpr is a function that builds a sub-expression used to zero
@ -286,8 +286,7 @@ struct ZeroInitWorkgroupMemory::State {
auto* zero_init = b.Construct(CreateASTTypeFor(ctx, atomic->Type()));
auto expr = get_expr(1u);
auto* store = b.Call("atomicStore", b.AddressOf(expr.expr), zero_init);
statements.emplace_back(Statement{b.create<ast::CallStatement>(store),
expr.num_iterations,
statements.emplace_back(Statement{b.CallStmt(store), expr.num_iterations,
expr.array_indices});
return;
}

View File

@ -521,7 +521,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Call_WithLogical) {
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr("b"),
Expr("d"))));
auto* expr = create<ast::CallStatement>(Call("foo", params));
auto* expr = CallStmt(Call("foo", params));
WrapInFunction(expr);
GeneratorImpl& gen = Build();

View File

@ -65,7 +65,7 @@ TEST_F(GlslGeneratorImplTest_Call, EmitStatement_Call) {
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = create<ast::CallStatement>(Call("my_func", "param1", "param2"));
auto* call = CallStmt(Call("my_func", "param1", "param2"));
WrapInFunction(call);
GeneratorImpl& gen = Build();

View File

@ -167,7 +167,7 @@ TEST_P(GlslIntrinsicTest, Emit) {
auto* call = GenerateCall(param.intrinsic, param.type, this);
ASSERT_NE(nullptr, call) << "Unhandled intrinsic";
Func("func", {}, ty.void_(), {Ignore(call)},
Func("func", {}, ty.void_(), {CallStmt(call)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();
@ -536,7 +536,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack2x16Float) {
TEST_F(GlslGeneratorImplTest_Intrinsic, StorageBarrier) {
Func("main", {}, ty.void_(),
{create<ast::CallStatement>(Call("storageBarrier"))},
{CallStmt(Call("storageBarrier"))},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1),
@ -555,7 +555,7 @@ void main() {
TEST_F(GlslGeneratorImplTest_Intrinsic, WorkgroupBarrier) {
Func("main", {}, ty.void_(),
{create<ast::CallStatement>(Call("workgroupBarrier"))},
{CallStmt(Call("workgroupBarrier"))},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1),
@ -577,7 +577,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Ignore) {
ty.i32(), {Return(Mul(Add("a", "b"), "c"))});
Func("main", {}, ty.void_(),
{create<ast::CallStatement>(Call("ignore", Call("f", 1, 2, 3)))},
{CallStmt(Call("ignore", Call("f", 1, 2, 3)))},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1),

View File

@ -240,9 +240,7 @@ TEST_P(GlslGeneratorIntrinsicTextureTest, Call) {
param.BuildSamplerVariable(this);
auto* call = Call(param.function, param.args(this));
auto* stmt = ast::intrinsic::test::ReturnsVoid(param.overload)
? create<ast::CallStatement>(call)
: Ignore(call);
auto* stmt = CallStmt(call);
Func("main", {}, ty.void_(), {stmt}, {Stage(ast::PipelineStage::kFragment)});

View File

@ -44,7 +44,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(create<ast::CallStatement>(Call("a_statement")));
auto* continuing = Block(CallStmt(Call("a_statement")));
auto* l = Loop(body, continuing);
WrapInFunction(l);
@ -70,7 +70,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(create<ast::CallStatement>(Call("a_statement")));
auto* continuing = Block(CallStmt(Call("a_statement")));
auto* inner = Loop(body, continuing);
body = Block(inner);
@ -159,8 +159,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoop) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(nullptr, nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(nullptr, nullptr, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -184,7 +184,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -209,7 +209,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f = For(Decl(Var("b", nullptr, multi_stmt)), nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -237,8 +237,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(nullptr, true, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f = For(nullptr, true, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -263,8 +262,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f = For(nullptr, multi_stmt, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(nullptr, multi_stmt, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -294,7 +293,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
auto* v = Decl(Var("i", ty.i32()));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)),
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -321,7 +320,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
Expr(true), Expr(false));
auto* v = Decl(Var("i", ty.bool_()));
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt),
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -350,7 +349,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), true, Assign("i", Add("i", 1)),
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -379,9 +378,9 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
auto* multi_stmt_c = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f = For(Decl(Var("i", nullptr, multi_stmt_a)), multi_stmt_b,
Assign("i", multi_stmt_c),
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(Decl(Var("i", nullptr, multi_stmt_a)), multi_stmt_b,
Assign("i", multi_stmt_c), Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();

View File

@ -319,7 +319,7 @@ TEST_P(GlslDepthTexturesTest, Emit) {
create<ast::GroupDecoration>(2),
});
Func("main", {}, ty.void_(), {Ignore(Call("textureDimensions", "tex"))},
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();
@ -348,7 +348,7 @@ TEST_F(GlslDepthMultisampledTexturesTest, Emit) {
create<ast::GroupDecoration>(2),
});
Func("main", {}, ty.void_(), {Ignore(Call("textureDimensions", "tex"))},
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();
@ -392,7 +392,7 @@ TEST_P(GlslSampledTexturesTest, Emit) {
create<ast::GroupDecoration>(2),
});
Func("main", {}, ty.void_(), {Ignore(Call("textureDimensions", "tex"))},
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();
@ -528,7 +528,7 @@ TEST_P(GlslStorageTexturesTest, Emit) {
create<ast::GroupDecoration>(2),
});
Func("main", {}, ty.void_(), {Ignore(Call("textureDimensions", "tex"))},
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();

View File

@ -521,7 +521,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) {
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr("b"),
Expr("d"))));
auto* expr = create<ast::CallStatement>(Call("foo", params));
auto* expr = CallStmt(Call("foo", params));
WrapInFunction(expr);
GeneratorImpl& gen = Build();

View File

@ -65,7 +65,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) {
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = create<ast::CallStatement>(Call("my_func", "param1", "param2"));
auto* call = CallStmt(Call("my_func", "param1", "param2"));
WrapInFunction(call);
GeneratorImpl& gen = Build();

View File

@ -167,7 +167,7 @@ TEST_P(HlslIntrinsicTest, Emit) {
auto* call = GenerateCall(param.intrinsic, param.type, this);
ASSERT_NE(nullptr, call) << "Unhandled intrinsic";
Func("func", {}, ty.void_(), {Ignore(call)},
Func("func", {}, ty.void_(), {CallStmt(call)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();
@ -317,7 +317,7 @@ modf_result tint_modf(float param_0) {
[numthreads(1, 1, 1)]
void test_function() {
tint_modf(1.0f);
(void) tint_modf(1.0f);
return;
}
)");
@ -343,7 +343,7 @@ modf_result_vec3 tint_modf(float3 param_0) {
[numthreads(1, 1, 1)]
void test_function() {
tint_modf(float3(0.0f, 0.0f, 0.0f));
(void) tint_modf(float3(0.0f, 0.0f, 0.0f));
return;
}
)");
@ -369,7 +369,7 @@ frexp_result tint_frexp(float param_0) {
[numthreads(1, 1, 1)]
void test_function() {
tint_frexp(1.0f);
(void) tint_frexp(1.0f);
return;
}
)");
@ -395,7 +395,7 @@ frexp_result_vec3 tint_frexp(float3 param_0) {
[numthreads(1, 1, 1)]
void test_function() {
tint_frexp(float3(0.0f, 0.0f, 0.0f));
(void) tint_frexp(float3(0.0f, 0.0f, 0.0f));
return;
}
)");
@ -418,7 +418,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Scalar) {
[numthreads(1, 1, 1)]
void test_function() {
float val = 0.0f;
tint_isNormal(val);
(void) tint_isNormal(val);
return;
}
)");
@ -441,7 +441,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Vector) {
[numthreads(1, 1, 1)]
void test_function() {
float3 val = float3(0.0f, 0.0f, 0.0f);
tint_isNormal(val);
(void) tint_isNormal(val);
return;
}
)");
@ -463,7 +463,7 @@ static float4 p1 = float4(0.0f, 0.0f, 0.0f, 0.0f);
[numthreads(1, 1, 1)]
void test_function() {
tint_pack4x8snorm(p1);
(void) tint_pack4x8snorm(p1);
return;
}
)");
@ -485,7 +485,7 @@ static float4 p1 = float4(0.0f, 0.0f, 0.0f, 0.0f);
[numthreads(1, 1, 1)]
void test_function() {
tint_pack4x8unorm(p1);
(void) tint_pack4x8unorm(p1);
return;
}
)");
@ -507,7 +507,7 @@ static float2 p1 = float2(0.0f, 0.0f);
[numthreads(1, 1, 1)]
void test_function() {
tint_pack2x16snorm(p1);
(void) tint_pack2x16snorm(p1);
return;
}
)");
@ -529,7 +529,7 @@ static float2 p1 = float2(0.0f, 0.0f);
[numthreads(1, 1, 1)]
void test_function() {
tint_pack2x16unorm(p1);
(void) tint_pack2x16unorm(p1);
return;
}
)");
@ -551,7 +551,7 @@ static float2 p1 = float2(0.0f, 0.0f);
[numthreads(1, 1, 1)]
void test_function() {
tint_pack2x16float(p1);
(void) tint_pack2x16float(p1);
return;
}
)");
@ -574,7 +574,7 @@ static uint p1 = 0u;
[numthreads(1, 1, 1)]
void test_function() {
tint_unpack4x8snorm(p1);
(void) tint_unpack4x8snorm(p1);
return;
}
)");
@ -597,7 +597,7 @@ static uint p1 = 0u;
[numthreads(1, 1, 1)]
void test_function() {
tint_unpack4x8unorm(p1);
(void) tint_unpack4x8unorm(p1);
return;
}
)");
@ -620,7 +620,7 @@ static uint p1 = 0u;
[numthreads(1, 1, 1)]
void test_function() {
tint_unpack2x16snorm(p1);
(void) tint_unpack2x16snorm(p1);
return;
}
)");
@ -643,7 +643,7 @@ static uint p1 = 0u;
[numthreads(1, 1, 1)]
void test_function() {
tint_unpack2x16unorm(p1);
(void) tint_unpack2x16unorm(p1);
return;
}
)");
@ -665,15 +665,14 @@ static uint p1 = 0u;
[numthreads(1, 1, 1)]
void test_function() {
tint_unpack2x16float(p1);
(void) tint_unpack2x16float(p1);
return;
}
)");
}
TEST_F(HlslGeneratorImplTest_Intrinsic, StorageBarrier) {
Func("main", {}, ty.void_(),
{create<ast::CallStatement>(Call("storageBarrier"))},
Func("main", {}, ty.void_(), {CallStmt(Call("storageBarrier"))},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1),
@ -691,8 +690,7 @@ void main() {
}
TEST_F(HlslGeneratorImplTest_Intrinsic, WorkgroupBarrier) {
Func("main", {}, ty.void_(),
{create<ast::CallStatement>(Call("workgroupBarrier"))},
Func("main", {}, ty.void_(), {CallStmt(Call("workgroupBarrier"))},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1),
@ -713,8 +711,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Ignore) {
Func("f", {Param("a", ty.i32()), Param("b", ty.i32()), Param("c", ty.i32())},
ty.i32(), {Return(Mul(Add("a", "b"), "c"))});
Func("main", {}, ty.void_(),
{create<ast::CallStatement>(Call("ignore", Call("f", 1, 2, 3)))},
Func("main", {}, ty.void_(), {CallStmt(Call("ignore", Call("f", 1, 2, 3)))},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1),

View File

@ -335,9 +335,7 @@ TEST_P(HlslGeneratorIntrinsicTextureTest, Call) {
param.BuildSamplerVariable(this);
auto* call = Call(param.function, param.args(this));
auto* stmt = ast::intrinsic::test::ReturnsVoid(param.overload)
? create<ast::CallStatement>(call)
: Ignore(call);
auto* stmt = CallStmt(call);
Func("main", {}, ty.void_(), {stmt}, {Stage(ast::PipelineStage::kFragment)});

View File

@ -44,7 +44,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(create<ast::CallStatement>(Call("a_statement")));
auto* continuing = Block(CallStmt(Call("a_statement")));
auto* l = Loop(body, continuing);
WrapInFunction(l);
@ -70,7 +70,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(create<ast::CallStatement>(Call("a_statement")));
auto* continuing = Block(CallStmt(Call("a_statement")));
auto* inner = Loop(body, continuing);
body = Block(inner);
@ -159,8 +159,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoop) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(nullptr, nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(nullptr, nullptr, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -184,7 +184,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -209,7 +209,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f = For(Decl(Var("b", nullptr, multi_stmt)), nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -237,8 +237,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(nullptr, true, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f = For(nullptr, true, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -263,8 +262,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f = For(nullptr, multi_stmt, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(nullptr, multi_stmt, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -294,7 +293,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
auto* v = Decl(Var("i", ty.i32()));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)),
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -321,7 +320,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
Expr(true), Expr(false));
auto* v = Decl(Var("i", ty.bool_()));
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt),
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -350,7 +349,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), true, Assign("i", Add("i", 1)),
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -379,9 +378,9 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
auto* multi_stmt_c = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f = For(Decl(Var("i", nullptr, multi_stmt_a)), multi_stmt_b,
Assign("i", multi_stmt_c),
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(Decl(Var("i", nullptr, multi_stmt_a)), multi_stmt_b,
Assign("i", multi_stmt_c), Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();

View File

@ -338,7 +338,7 @@ TEST_P(HlslDepthTexturesTest, Emit) {
create<ast::GroupDecoration>(2),
});
Func("main", {}, ty.void_(), {Ignore(Call("textureDimensions", "tex"))},
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();
@ -369,7 +369,7 @@ TEST_F(HlslDepthMultisampledTexturesTest, Emit) {
create<ast::GroupDecoration>(2),
});
Func("main", {}, ty.void_(), {Ignore(Call("textureDimensions", "tex"))},
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();
@ -414,7 +414,7 @@ TEST_P(HlslSampledTexturesTest, Emit) {
create<ast::GroupDecoration>(2),
});
Func("main", {}, ty.void_(), {Ignore(Call("textureDimensions", "tex"))},
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();
@ -548,7 +548,7 @@ TEST_P(HlslStorageTexturesTest, Emit) {
Global("tex", t, ast::DecorationList{GroupAndBinding(2, 1)});
Func("main", {}, ty.void_(), {Ignore(Call("textureDimensions", "tex"))},
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});
GeneratorImpl& gen = Build();

View File

@ -66,7 +66,7 @@ TEST_F(MslGeneratorImplTest, EmitStatement_Call) {
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = Call("my_func", "param1", "param2");
auto* stmt = create<ast::CallStatement>(call);
auto* stmt = CallStmt(call);
WrapInFunction(stmt);
GeneratorImpl& gen = Build();

View File

@ -299,7 +299,7 @@ TEST_F(MslGeneratorImplTest, Intrinsic_Call) {
TEST_F(MslGeneratorImplTest, StorageBarrier) {
auto* call = Call("storageBarrier");
WrapInFunction(create<ast::CallStatement>(call));
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -310,7 +310,7 @@ TEST_F(MslGeneratorImplTest, StorageBarrier) {
TEST_F(MslGeneratorImplTest, WorkgroupBarrier) {
auto* call = Call("workgroupBarrier");
WrapInFunction(create<ast::CallStatement>(call));
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -347,7 +347,7 @@ TEST_F(MslGeneratorImplTest, Ignore) {
Func("f", {Param("a", ty.i32()), Param("b", ty.i32()), Param("c", ty.i32())},
ty.i32(), {Return(Mul(Add("a", "b"), "c"))});
Func("func", {}, ty.void_(), {Ignore(Call("f", 1, 2, 3))},
Func("func", {}, ty.void_(), {CallStmt(Call("f", 1, 2, 3))},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1),
@ -364,7 +364,7 @@ int f(int a, int b, int c) {
}
kernel void func() {
(void) f(1, 2, 3);
f(1, 2, 3);
return;
}

View File

@ -244,11 +244,8 @@ TEST_P(MslGeneratorIntrinsicTextureTest, Call) {
param.BuildTextureVariable(this);
param.BuildSamplerVariable(this);
auto* call =
create<ast::CallExpression>(Expr(param.function), param.args(this));
auto* stmt = ast::intrinsic::test::ReturnsVoid(param.overload)
? create<ast::CallStatement>(call)
: Ignore(call);
auto* call = Call(Expr(param.function), param.args(this));
auto* stmt = CallStmt(call);
Func("main", {}, ty.void_(), {stmt}, {Stage(ast::PipelineStage::kFragment)});

View File

@ -43,7 +43,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(create<ast::CallStatement>(Call("a_statement")));
auto* continuing = Block(CallStmt(Call("a_statement")));
auto* l = Loop(body, continuing);
WrapInFunction(l);
@ -68,7 +68,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) {
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(create<ast::CallStatement>(Call("a_statement")));
auto* continuing = Block(CallStmt(Call("a_statement")));
auto* inner = Loop(body, continuing);
body = Block(inner);
@ -152,8 +152,8 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoop) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(nullptr, nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(nullptr, nullptr, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -175,7 +175,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleInit) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -199,8 +199,8 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInit) {
Global("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
auto* multi_stmt = Block(Ignore(1), Ignore(2));
auto* f = For(multi_stmt, nullptr, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(multi_stmt, nullptr, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -227,8 +227,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleCond) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(nullptr, true, nullptr,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f = For(nullptr, true, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -251,7 +250,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleCont) {
auto* v = Decl(Var("i", ty.i32()));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)),
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -277,8 +276,8 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtCont) {
Global("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
auto* multi_stmt = Block(Ignore(1), Ignore(2));
auto* f = For(nullptr, nullptr, multi_stmt,
Block(create<ast::CallStatement>(Call("a_statement"))));
auto* f =
For(nullptr, nullptr, multi_stmt, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -304,7 +303,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleInitCondCont) {
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), true, Assign("i", Add("i", 1)),
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -332,7 +331,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInitCondCont) {
auto* multi_stmt_a = Block(Ignore(1), Ignore(2));
auto* multi_stmt_b = Block(Ignore(3), Ignore(4));
auto* f = For(multi_stmt_a, Expr(true), multi_stmt_b,
Block(create<ast::CallStatement>(Call("a_statement"))));
Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
GeneratorImpl& gen = Build();

View File

@ -82,7 +82,7 @@ TEST_F(BuilderTest, Statement_Call) {
auto* func =
Func("main", {}, ty.void_(), ast::StatementList{}, ast::DecorationList{});
auto* expr = Ignore(Call("a_func", 1.f, 1.f));
auto* expr = CallStmt(Call("a_func", 1.f, 1.f));
WrapInFunction(expr);
@ -100,7 +100,7 @@ OpName %10 "main"
%1 = OpTypeFunction %2 %2 %2
%9 = OpTypeVoid
%8 = OpTypeFunction %9
%14 = OpConstant %2 1
%13 = OpConstant %2 1
%3 = OpFunction %2 None %1
%4 = OpFunctionParameter %2
%5 = OpFunctionParameter %2
@ -110,7 +110,7 @@ OpReturnValue %7
OpFunctionEnd
%10 = OpFunction %9 None %8
%11 = OpLabel
%13 = OpFunctionCall %2 %3 %14 %14
%12 = OpFunctionCall %2 %3 %13 %13
OpReturn
OpFunctionEnd
)");

View File

@ -439,7 +439,7 @@ TEST_P(IntrinsicDeriveTest, Call_Derivative_Scalar) {
auto* var = Global("v", ty.f32(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
Func("func", {}, ty.void_(), {Ignore(expr)},
Func("func", {}, ty.void_(), {CallStmt(expr)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
spirv::Builder& b = Build();
@ -465,7 +465,7 @@ TEST_P(IntrinsicDeriveTest, Call_Derivative_Vector) {
auto* var = Global("v", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
Func("func", {}, ty.void_(), {Ignore(expr)},
Func("func", {}, ty.void_(), {CallStmt(expr)},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
spirv::Builder& b = Build();
@ -563,8 +563,8 @@ TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
auto* expr2 = Call("textureSampleCompare", "texture", "sampler",
vec2<f32>(1.0f, 2.0f), 2.0f);
Func("f1", {}, ty.void_(), {Ignore(expr1)}, {});
Func("f2", {}, ty.void_(), {Ignore(expr2)}, {});
Func("f1", {}, ty.void_(), {CallStmt(expr1)}, {});
Func("f2", {}, ty.void_(), {CallStmt(expr2)}, {});
spirv::Builder& b = Build();
@ -1478,7 +1478,7 @@ INSTANTIATE_TEST_SUITE_P(IntrinsicBuilderTest,
TEST_F(IntrinsicBuilderTest, Call_Modf) {
auto* expr = Call("modf", vec2<f32>(1.0f, 2.0f));
Func("a_func", {}, ty.void_(), {Ignore(expr)},
Func("a_func", {}, ty.void_(), {CallStmt(expr)},
{Stage(ast::PipelineStage::kFragment)});
spirv::Builder& b = Build();
@ -1486,27 +1486,27 @@ TEST_F(IntrinsicBuilderTest, Call_Modf) {
ASSERT_TRUE(b.Build()) << b.error();
auto got = DumpBuilder(b);
auto* expect = R"(OpCapability Shader
%10 = OpExtInstImport "GLSL.std.450"
%9 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %3 "a_func"
OpExecutionMode %3 OriginUpperLeft
OpName %3 "a_func"
OpName %7 "_modf_result_vec2"
OpMemberName %7 0 "fract"
OpMemberName %7 1 "whole"
OpMemberDecorate %7 0 Offset 0
OpMemberDecorate %7 1 Offset 8
OpName %6 "_modf_result_vec2"
OpMemberName %6 0 "fract"
OpMemberName %6 1 "whole"
OpMemberDecorate %6 0 Offset 0
OpMemberDecorate %6 1 Offset 8
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%9 = OpTypeFloat 32
%8 = OpTypeVector %9 2
%7 = OpTypeStruct %8 %8
%11 = OpConstant %9 1
%12 = OpConstant %9 2
%13 = OpConstantComposite %8 %11 %12
%8 = OpTypeFloat 32
%7 = OpTypeVector %8 2
%6 = OpTypeStruct %7 %7
%10 = OpConstant %8 1
%11 = OpConstant %8 2
%12 = OpConstantComposite %7 %10 %11
%3 = OpFunction %2 None %1
%4 = OpLabel
%6 = OpExtInst %7 %10 ModfStruct %13
%5 = OpExtInst %6 %9 ModfStruct %12
OpReturn
OpFunctionEnd
)";
@ -1517,7 +1517,7 @@ OpFunctionEnd
TEST_F(IntrinsicBuilderTest, Call_Frexp) {
auto* expr = Call("frexp", vec2<f32>(1.0f, 2.0f));
Func("a_func", {}, ty.void_(), {Ignore(expr)},
Func("a_func", {}, ty.void_(), {CallStmt(expr)},
{Stage(ast::PipelineStage::kFragment)});
spirv::Builder& b = Build();
@ -1525,29 +1525,29 @@ TEST_F(IntrinsicBuilderTest, Call_Frexp) {
ASSERT_TRUE(b.Build()) << b.error();
auto got = DumpBuilder(b);
auto* expect = R"(OpCapability Shader
%12 = OpExtInstImport "GLSL.std.450"
%11 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %3 "a_func"
OpExecutionMode %3 OriginUpperLeft
OpName %3 "a_func"
OpName %7 "_frexp_result_vec2"
OpMemberName %7 0 "sig"
OpMemberName %7 1 "exp"
OpMemberDecorate %7 0 Offset 0
OpMemberDecorate %7 1 Offset 8
OpName %6 "_frexp_result_vec2"
OpMemberName %6 0 "sig"
OpMemberName %6 1 "exp"
OpMemberDecorate %6 0 Offset 0
OpMemberDecorate %6 1 Offset 8
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%9 = OpTypeFloat 32
%8 = OpTypeVector %9 2
%11 = OpTypeInt 32 1
%10 = OpTypeVector %11 2
%7 = OpTypeStruct %8 %10
%13 = OpConstant %9 1
%14 = OpConstant %9 2
%15 = OpConstantComposite %8 %13 %14
%8 = OpTypeFloat 32
%7 = OpTypeVector %8 2
%10 = OpTypeInt 32 1
%9 = OpTypeVector %10 2
%6 = OpTypeStruct %7 %9
%12 = OpConstant %8 1
%13 = OpConstant %8 2
%14 = OpConstantComposite %7 %12 %13
%3 = OpFunction %2 None %1
%4 = OpLabel
%6 = OpExtInst %7 %12 FrexpStruct %15
%5 = OpExtInst %6 %11 FrexpStruct %14
OpReturn
OpFunctionEnd
)";
@ -1642,7 +1642,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
Func("a_func", ast::VariableList{}, ty.void_(),
ast::StatementList{
Ignore(expr),
CallStmt(expr),
},
ast::DecorationList{
Stage(ast::PipelineStage::kFragment),
@ -1661,12 +1661,12 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
%1 = OpVariable %2 StorageBuffer
%7 = OpTypeVoid
%6 = OpTypeFunction %7
%12 = OpTypeInt 32 0
%11 = OpTypeInt 32 0
)";
auto got_types = DumpInstructions(b.types());
EXPECT_EQ(expected_types, got_types);
auto* expected_instructions = R"(%11 = OpArrayLength %12 %1 0
auto* expected_instructions = R"(%10 = OpArrayLength %11 %1 0
)";
auto got_instructions = DumpInstructions(b.functions()[0].instructions());
EXPECT_EQ(expected_instructions, got_instructions);
@ -1691,7 +1691,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
Func("a_func", ast::VariableList{}, ty.void_(),
ast::StatementList{
Ignore(expr),
CallStmt(expr),
},
ast::DecorationList{
Stage(ast::PipelineStage::kFragment),
@ -1710,12 +1710,12 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
%1 = OpVariable %2 StorageBuffer
%7 = OpTypeVoid
%6 = OpTypeFunction %7
%12 = OpTypeInt 32 0
%11 = OpTypeInt 32 0
)";
auto got_types = DumpInstructions(b.types());
EXPECT_EQ(expected_types, got_types);
auto* expected_instructions = R"(%11 = OpArrayLength %12 %1 1
auto* expected_instructions = R"(%10 = OpArrayLength %11 %1 1
)";
auto got_instructions = DumpInstructions(b.functions()[0].instructions());
EXPECT_EQ(expected_instructions, got_instructions);
@ -1740,7 +1740,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets) {
ast::StatementList{
Decl(p),
Decl(p2),
Ignore(expr),
CallStmt(expr),
},
ast::DecorationList{
Stage(ast::PipelineStage::kFragment),
@ -1759,12 +1759,12 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets) {
%1 = OpVariable %2 StorageBuffer
%7 = OpTypeVoid
%6 = OpTypeFunction %7
%12 = OpTypeInt 32 0
%11 = OpTypeInt 32 0
)";
auto got_types = DumpInstructions(b.types());
EXPECT_EQ(expected_types, got_types);
auto* expected_instructions = R"(%11 = OpArrayLength %12 %1 0
auto* expected_instructions = R"(%10 = OpArrayLength %11 %1 0
)";
auto got_instructions = DumpInstructions(b.functions()[0].instructions());
EXPECT_EQ(expected_instructions, got_instructions);
@ -1802,7 +1802,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) {
Decl(p),
Decl(p2),
Decl(p3),
Ignore(expr),
CallStmt(expr),
},
ast::DecorationList{
Stage(ast::PipelineStage::kFragment),
@ -1821,12 +1821,12 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) {
%1 = OpVariable %2 StorageBuffer
%7 = OpTypeVoid
%6 = OpTypeFunction %7
%12 = OpTypeInt 32 0
%11 = OpTypeInt 32 0
)";
auto got_types = DumpInstructions(b.types());
EXPECT_EQ(expected_types, got_types);
auto* expected_instructions = R"(%11 = OpArrayLength %12 %1 0
auto* expected_instructions = R"(%10 = OpArrayLength %11 %1 0
)";
auto got_instructions = DumpInstructions(b.functions()[0].instructions());
EXPECT_EQ(expected_instructions, got_instructions);
@ -1929,9 +1929,9 @@ TEST_F(IntrinsicBuilderTest, Call_AtomicStore) {
ast::StatementList{
Decl(Var("u", nullptr, Expr(1u))),
Decl(Var("i", nullptr, Expr(2))),
create<ast::CallStatement>(
CallStmt(
Call("atomicStore", AddressOf(MemberAccessor("b", "u")), "u")),
create<ast::CallStatement>(
CallStmt(
Call("atomicStore", AddressOf(MemberAccessor("b", "i")), "i")),
},
ast::DecorationList{Stage(ast::PipelineStage::kFragment)});
@ -2421,7 +2421,7 @@ INSTANTIATE_TEST_SUITE_P(
TEST_F(IntrinsicBuilderTest, Call_WorkgroupBarrier) {
Func("f", ast::VariableList{}, ty.void_(),
ast::StatementList{
create<ast::CallStatement>(Call("workgroupBarrier")),
CallStmt(Call("workgroupBarrier")),
},
ast::DecorationList{
Stage(ast::PipelineStage::kCompute),
@ -2454,7 +2454,7 @@ TEST_F(IntrinsicBuilderTest, Call_WorkgroupBarrier) {
TEST_F(IntrinsicBuilderTest, Call_StorageBarrier) {
Func("f", ast::VariableList{}, ty.void_(),
ast::StatementList{
create<ast::CallStatement>(Call("storageBarrier")),
CallStmt(Call("storageBarrier")),
},
ast::DecorationList{
Stage(ast::PipelineStage::kCompute),
@ -2491,7 +2491,7 @@ TEST_F(IntrinsicBuilderTest, Call_Ignore) {
Func("main", {}, ty.void_(),
{
create<ast::CallStatement>(Call("ignore", Call("f", 1, 2, 3))),
CallStmt(Call("ignore", Call("f", 1, 2, 3))),
},
{
Stage(ast::PipelineStage::kCompute),

View File

@ -3173,9 +3173,7 @@ TEST_P(IntrinsicTextureTest, Call) {
auto* sampler = param.BuildSamplerVariable(this);
auto* call = Call(param.function, param.args(this));
auto* stmt = ast::intrinsic::test::ReturnsVoid(param.overload)
? create<ast::CallStatement>(call)
: Ignore(call);
auto* stmt = CallStmt(call);
Func("func", {}, ty.void_(), {stmt}, {Stage(ast::PipelineStage::kFragment)});
spirv::Builder& b = Build();
@ -3202,9 +3200,7 @@ TEST_P(IntrinsicTextureTest, ValidateSPIRV) {
auto* call = Call(param.function, param.args(this));
auto* stmt = ast::intrinsic::test::ReturnsVoid(param.overload)
? create<ast::CallStatement>(call)
: Ignore(call);
auto* stmt = CallStmt(call);
Func("main", {}, ty.void_(), {stmt}, {Stage(ast::PipelineStage::kFragment)});
spirv::Builder& b = Build();
@ -3224,9 +3220,7 @@ TEST_P(IntrinsicTextureTest, OutsideFunction_IsError) {
auto* sampler = param.BuildSamplerVariable(this);
auto* call = Call(param.function, param.args(this));
auto* stmt = ast::intrinsic::test::ReturnsVoid(param.overload)
? create<ast::CallStatement>(call)
: Ignore(call);
auto* stmt = CallStmt(call);
Func("func", {}, ty.void_(), {stmt},
{create<ast::StageDecoration>(ast::PipelineStage::kFragment)});

View File

@ -66,7 +66,7 @@ TEST_F(WgslGeneratorImplTest, EmitStatement_Call) {
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = Call("my_func", "param1", "param2");
auto* stmt = create<ast::CallStatement>(call);
auto* stmt = CallStmt(call);
WrapInFunction(stmt);
GeneratorImpl& gen = Build();

View File

@ -43,7 +43,7 @@ TEST_F(WgslGeneratorImplTest, Emit_LoopWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(create<ast::CallStatement>(Call("a_statement")));
auto* continuing = Block(CallStmt(Call("a_statement")));
auto* l = Loop(body, continuing);
WrapInFunction(l);