Remove NOP.

The NOP command was added for complete SPIR-V bijectivity which is no
longer a goal of WGSL. The NOP command has been removed from the spec,
so remove from Tint.

Change-Id: Ic640d9d3b987a19668dc169ff549444921c5bbb8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22160
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
dan sinclair 2020-05-26 15:05:54 +00:00
parent 53f2026fc5
commit 5370390096
31 changed files with 115 additions and 399 deletions

View File

@ -266,8 +266,6 @@ source_set("libtint_core_src") {
"src/ast/module.h",
"src/ast/node.cc",
"src/ast/node.h",
"src/ast/nop_statement.cc",
"src/ast/nop_statement.h",
"src/ast/null_literal.cc",
"src/ast/null_literal.h",
"src/ast/pipeline_stage.cc",
@ -605,7 +603,6 @@ source_set("tint_unittests_core_src") {
"src/ast/loop_statement_test.cc",
"src/ast/member_accessor_expression_test.cc",
"src/ast/module_test.cc",
"src/ast/nop_statement_test.cc",
"src/ast/null_literal_test.cc",
"src/ast/return_statement_test.cc",
"src/ast/scalar_constructor_expression_test.cc",
@ -829,7 +826,6 @@ source_set("tint_unittests_wgsl_writer_src") {
"src/writer/wgsl/generator_impl_kill_test.cc",
"src/writer/wgsl/generator_impl_loop_test.cc",
"src/writer/wgsl/generator_impl_member_accessor_test.cc",
"src/writer/wgsl/generator_impl_nop_test.cc",
"src/writer/wgsl/generator_impl_relational_test.cc",
"src/writer/wgsl/generator_impl_return_test.cc",
"src/writer/wgsl/generator_impl_switch_test.cc",

View File

@ -103,8 +103,6 @@ set(TINT_LIB_SRCS
ast/module.h
ast/node.cc
ast/node.h
ast/nop_statement.cc
ast/nop_statement.h
ast/null_literal.cc
ast/null_literal.h
ast/pipeline_stage.cc
@ -284,7 +282,6 @@ set(TINT_TEST_SRCS
ast/loop_statement_test.cc
ast/member_accessor_expression_test.cc
ast/module_test.cc
ast/nop_statement_test.cc
ast/null_literal_test.cc
ast/binary_expression_test.cc
ast/return_statement_test.cc
@ -478,7 +475,6 @@ if(${TINT_BUILD_WGSL_WRITER})
writer/wgsl/generator_impl_kill_test.cc
writer/wgsl/generator_impl_loop_test.cc
writer/wgsl/generator_impl_member_accessor_test.cc
writer/wgsl/generator_impl_nop_test.cc
writer/wgsl/generator_impl_relational_test.cc
writer/wgsl/generator_impl_return_test.cc
writer/wgsl/generator_impl_switch_test.cc

View File

@ -17,7 +17,7 @@
#include "gtest/gtest.h"
#include "src/ast/bool_literal.h"
#include "src/ast/if_statement.h"
#include "src/ast/nop_statement.h"
#include "src/ast/kill_statement.h"
#include "src/ast/type/bool_type.h"
namespace tint {
@ -30,22 +30,22 @@ TEST_F(CaseStatementTest, Creation) {
ast::type::BoolType bool_type;
auto b = std::make_unique<BoolLiteral>(&bool_type, true);
StatementList stmts;
stmts.push_back(std::make_unique<NopStatement>());
stmts.push_back(std::make_unique<KillStatement>());
auto* bool_ptr = b.get();
auto* nop_ptr = stmts[0].get();
auto* kill_ptr = stmts[0].get();
CaseStatement c(std::move(b), std::move(stmts));
EXPECT_EQ(c.condition(), bool_ptr);
ASSERT_EQ(c.body().size(), 1u);
EXPECT_EQ(c.body()[0].get(), nop_ptr);
EXPECT_EQ(c.body()[0].get(), kill_ptr);
}
TEST_F(CaseStatementTest, Creation_WithSource) {
ast::type::BoolType bool_type;
auto b = std::make_unique<BoolLiteral>(&bool_type, true);
StatementList stmts;
stmts.push_back(std::make_unique<NopStatement>());
stmts.push_back(std::make_unique<KillStatement>());
CaseStatement c(Source{20, 2}, std::move(b), std::move(stmts));
auto src = c.source();
@ -55,7 +55,7 @@ TEST_F(CaseStatementTest, Creation_WithSource) {
TEST_F(CaseStatementTest, IsDefault_WithoutCondition) {
StatementList stmts;
stmts.push_back(std::make_unique<NopStatement>());
stmts.push_back(std::make_unique<KillStatement>());
CaseStatement c;
c.set_body(std::move(stmts));
@ -84,7 +84,7 @@ TEST_F(CaseStatementTest, IsValid_NullBodyStatement) {
ast::type::BoolType bool_type;
auto b = std::make_unique<BoolLiteral>(&bool_type, true);
StatementList stmts;
stmts.push_back(std::make_unique<NopStatement>());
stmts.push_back(std::make_unique<KillStatement>());
stmts.push_back(nullptr);
CaseStatement c(std::move(b), std::move(stmts));
@ -105,26 +105,26 @@ TEST_F(CaseStatementTest, ToStr_WithCondition) {
ast::type::BoolType bool_type;
auto b = std::make_unique<BoolLiteral>(&bool_type, true);
StatementList stmts;
stmts.push_back(std::make_unique<NopStatement>());
stmts.push_back(std::make_unique<KillStatement>());
CaseStatement c(std::move(b), std::move(stmts));
std::ostringstream out;
c.to_str(out, 2);
EXPECT_EQ(out.str(), R"( Case true{
Nop{}
Kill{}
}
)");
}
TEST_F(CaseStatementTest, ToStr_WithoutCondition) {
StatementList stmts;
stmts.push_back(std::make_unique<NopStatement>());
stmts.push_back(std::make_unique<KillStatement>());
CaseStatement c(nullptr, std::move(stmts));
std::ostringstream out;
c.to_str(out, 2);
EXPECT_EQ(out.str(), R"( Default{
Nop{}
Kill{}
}
)");
}

View File

@ -17,7 +17,7 @@
#include "gtest/gtest.h"
#include "src/ast/bool_literal.h"
#include "src/ast/if_statement.h"
#include "src/ast/nop_statement.h"
#include "src/ast/kill_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/type/bool_type.h"
@ -32,15 +32,15 @@ TEST_F(ElseStatementTest, Creation) {
auto cond = std::make_unique<ScalarConstructorExpression>(
std::make_unique<BoolLiteral>(&bool_type, true));
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
auto* cond_ptr = cond.get();
auto* nop_ptr = body[0].get();
auto* kill_ptr = body[0].get();
ElseStatement e(std::move(cond), std::move(body));
EXPECT_EQ(e.condition(), cond_ptr);
ASSERT_EQ(e.body().size(), 1u);
EXPECT_EQ(e.body()[0].get(), nop_ptr);
EXPECT_EQ(e.body()[0].get(), kill_ptr);
}
TEST_F(ElseStatementTest, Creation_WithSource) {
@ -75,7 +75,7 @@ TEST_F(ElseStatementTest, IsValid) {
TEST_F(ElseStatementTest, IsValid_WithBody) {
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
ElseStatement e(std::move(body));
EXPECT_TRUE(e.IsValid());
@ -83,7 +83,7 @@ TEST_F(ElseStatementTest, IsValid_WithBody) {
TEST_F(ElseStatementTest, IsValid_WithNullBodyStatement) {
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
body.push_back(nullptr);
ElseStatement e(std::move(body));
@ -109,7 +109,7 @@ TEST_F(ElseStatementTest, ToStr) {
auto cond = std::make_unique<ScalarConstructorExpression>(
std::make_unique<BoolLiteral>(&bool_type, true));
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
ElseStatement e(std::move(cond), std::move(body));
std::ostringstream out;
@ -119,7 +119,7 @@ TEST_F(ElseStatementTest, ToStr) {
ScalarConstructor{true}
)
{
Nop{}
Kill{}
}
}
)");
@ -127,14 +127,14 @@ TEST_F(ElseStatementTest, ToStr) {
TEST_F(ElseStatementTest, ToStr_NoCondition) {
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
ElseStatement e(std::move(body));
std::ostringstream out;
e.to_str(out, 2);
EXPECT_EQ(out.str(), R"( Else{
{
Nop{}
Kill{}
}
}
)");

View File

@ -15,7 +15,7 @@
#include "src/ast/function.h"
#include "gtest/gtest.h"
#include "src/ast/nop_statement.h"
#include "src/ast/kill_statement.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/type/void_type.h"
@ -66,7 +66,7 @@ TEST_F(FunctionTest, IsValid) {
std::make_unique<Variable>("var", StorageClass::kNone, &i32));
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
Function f("func", std::move(params), &void_type);
f.set_body(std::move(body));
@ -129,7 +129,7 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) {
std::make_unique<Variable>("var", StorageClass::kNone, &i32));
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
body.push_back(nullptr);
Function f("func", std::move(params), &void_type);
@ -146,7 +146,7 @@ TEST_F(FunctionTest, IsValid_InvalidBodyStatement) {
std::make_unique<Variable>("var", StorageClass::kNone, &i32));
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
body.push_back(nullptr);
Function f("func", std::move(params), &void_type);
@ -159,7 +159,7 @@ TEST_F(FunctionTest, ToStr) {
type::I32Type i32;
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
Function f("func", {}, &void_type);
f.set_body(std::move(body));
@ -169,7 +169,7 @@ TEST_F(FunctionTest, ToStr) {
EXPECT_EQ(out.str(), R"( Function func -> __void
()
{
Nop{}
Kill{}
}
)");
}
@ -183,7 +183,7 @@ TEST_F(FunctionTest, ToStr_WithParams) {
std::make_unique<Variable>("var", StorageClass::kNone, &i32));
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
Function f("func", std::move(params), &void_type);
f.set_body(std::move(body));
@ -199,7 +199,7 @@ TEST_F(FunctionTest, ToStr_WithParams) {
}
)
{
Nop{}
Kill{}
}
)");
}

View File

@ -17,7 +17,6 @@
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/kill_statement.h"
#include "src/ast/nop_statement.h"
namespace tint {
namespace ast {
@ -28,7 +27,7 @@ using IfStatementTest = testing::Test;
TEST_F(IfStatementTest, Creation) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
auto* cond_ptr = cond.get();
auto* stmt_ptr = body[0].get();
@ -42,7 +41,7 @@ TEST_F(IfStatementTest, Creation) {
TEST_F(IfStatementTest, Creation_WithSource) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
IfStatement stmt(Source{20, 2}, std::move(cond), std::move(body));
auto src = stmt.source();
@ -58,7 +57,7 @@ TEST_F(IfStatementTest, IsIf) {
TEST_F(IfStatementTest, IsValid) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
IfStatement stmt(std::move(cond), std::move(body));
EXPECT_TRUE(stmt.IsValid());
@ -67,7 +66,7 @@ TEST_F(IfStatementTest, IsValid) {
TEST_F(IfStatementTest, IsValid_WithElseStatements) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
ElseStatementList else_stmts;
else_stmts.push_back(std::make_unique<ElseStatement>());
@ -81,7 +80,7 @@ TEST_F(IfStatementTest, IsValid_WithElseStatements) {
TEST_F(IfStatementTest, IsValid_MissingCondition) {
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
IfStatement stmt(nullptr, std::move(body));
EXPECT_FALSE(stmt.IsValid());
@ -90,7 +89,7 @@ TEST_F(IfStatementTest, IsValid_MissingCondition) {
TEST_F(IfStatementTest, IsValid_InvalidCondition) {
auto cond = std::make_unique<IdentifierExpression>("");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
IfStatement stmt(std::move(cond), std::move(body));
EXPECT_FALSE(stmt.IsValid());
@ -99,7 +98,7 @@ TEST_F(IfStatementTest, IsValid_InvalidCondition) {
TEST_F(IfStatementTest, IsValid_NullBodyStatement) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
body.push_back(nullptr);
IfStatement stmt(std::move(cond), std::move(body));
@ -109,7 +108,7 @@ TEST_F(IfStatementTest, IsValid_NullBodyStatement) {
TEST_F(IfStatementTest, IsValid_InvalidBodyStatement) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
body.push_back(std::make_unique<IfStatement>());
IfStatement stmt(std::move(cond), std::move(body));
@ -119,7 +118,7 @@ TEST_F(IfStatementTest, IsValid_InvalidBodyStatement) {
TEST_F(IfStatementTest, IsValid_NullElseStatement) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
ElseStatementList else_stmts;
else_stmts.push_back(std::make_unique<ElseStatement>());
@ -135,7 +134,7 @@ TEST_F(IfStatementTest, IsValid_NullElseStatement) {
TEST_F(IfStatementTest, IsValid_InvalidElseStatement) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
ElseStatementList else_stmts;
else_stmts.push_back(std::make_unique<ElseStatement>());
@ -149,7 +148,7 @@ TEST_F(IfStatementTest, IsValid_InvalidElseStatement) {
TEST_F(IfStatementTest, IsValid_MultipleElseWiththoutCondition) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
ElseStatementList else_stmts;
else_stmts.push_back(std::make_unique<ElseStatement>());
@ -163,7 +162,7 @@ TEST_F(IfStatementTest, IsValid_MultipleElseWiththoutCondition) {
TEST_F(IfStatementTest, IsValid_ElseNotLast) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
ElseStatementList else_stmts;
else_stmts.push_back(std::make_unique<ElseStatement>());
@ -178,7 +177,7 @@ TEST_F(IfStatementTest, IsValid_ElseNotLast) {
TEST_F(IfStatementTest, ToStr) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
IfStatement stmt(std::move(cond), std::move(body));
@ -189,7 +188,7 @@ TEST_F(IfStatementTest, ToStr) {
Identifier{cond}
)
{
Nop{}
Kill{}
}
}
)");
@ -198,13 +197,13 @@ TEST_F(IfStatementTest, ToStr) {
TEST_F(IfStatementTest, ToStr_WithElseStatements) {
auto cond = std::make_unique<IdentifierExpression>("cond");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
StatementList else_if_body;
else_if_body.push_back(std::make_unique<KillStatement>());
StatementList else_body;
else_body.push_back(std::make_unique<NopStatement>());
else_body.push_back(std::make_unique<KillStatement>());
else_body.push_back(std::make_unique<KillStatement>());
ElseStatementList else_stmts;
@ -224,7 +223,7 @@ TEST_F(IfStatementTest, ToStr_WithElseStatements) {
Identifier{cond}
)
{
Nop{}
Kill{}
}
}
Else{
@ -237,7 +236,7 @@ TEST_F(IfStatementTest, ToStr_WithElseStatements) {
}
Else{
{
Nop{}
Kill{}
Kill{}
}
}

View File

@ -20,7 +20,6 @@
#include "gtest/gtest.h"
#include "src/ast/if_statement.h"
#include "src/ast/kill_statement.h"
#include "src/ast/nop_statement.h"
namespace tint {
namespace ast {
@ -34,7 +33,7 @@ TEST_F(LoopStatementTest, Creation) {
auto* b_ptr = body[0].get();
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
auto* c_ptr = continuing[0].get();
LoopStatement l(std::move(body), std::move(continuing));
@ -49,7 +48,7 @@ TEST_F(LoopStatementTest, Creation_WithSource) {
body.push_back(std::make_unique<KillStatement>());
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
LoopStatement l(Source{20, 2}, std::move(body), std::move(continuing));
auto src = l.source();
@ -75,7 +74,7 @@ TEST_F(LoopStatementTest, HasContinuing_WithContinuing) {
body.push_back(std::make_unique<KillStatement>());
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
LoopStatement l(std::move(body), std::move(continuing));
EXPECT_TRUE(l.has_continuing());
@ -86,7 +85,7 @@ TEST_F(LoopStatementTest, IsValid) {
body.push_back(std::make_unique<KillStatement>());
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
LoopStatement l(std::move(body), std::move(continuing));
EXPECT_TRUE(l.IsValid());
@ -111,7 +110,7 @@ TEST_F(LoopStatementTest, IsValid_NullBodyStatement) {
body.push_back(nullptr);
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
LoopStatement l(std::move(body), std::move(continuing));
EXPECT_FALSE(l.IsValid());
@ -123,7 +122,7 @@ TEST_F(LoopStatementTest, IsValid_InvalidBodyStatement) {
body.push_back(std::make_unique<IfStatement>());
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
LoopStatement l(std::move(body), std::move(continuing));
EXPECT_FALSE(l.IsValid());
@ -134,7 +133,7 @@ TEST_F(LoopStatementTest, IsValid_NullContinuingStatement) {
body.push_back(std::make_unique<KillStatement>());
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
continuing.push_back(nullptr);
LoopStatement l(std::move(body), std::move(continuing));
@ -146,7 +145,7 @@ TEST_F(LoopStatementTest, IsValid_InvalidContinuingStatement) {
body.push_back(std::make_unique<KillStatement>());
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
continuing.push_back(std::make_unique<IfStatement>());
LoopStatement l(std::move(body), std::move(continuing));
@ -171,7 +170,7 @@ TEST_F(LoopStatementTest, ToStr_WithContinuing) {
body.push_back(std::make_unique<KillStatement>());
StatementList continuing;
continuing.push_back(std::make_unique<NopStatement>());
continuing.push_back(std::make_unique<KillStatement>());
LoopStatement l(std::move(body), std::move(continuing));
std::ostringstream out;
@ -179,7 +178,7 @@ TEST_F(LoopStatementTest, ToStr_WithContinuing) {
EXPECT_EQ(out.str(), R"( Loop{
Kill{}
continuing {
Nop{}
Kill{}
}
}
)");

View File

@ -1,40 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/ast/nop_statement.h"
namespace tint {
namespace ast {
NopStatement::NopStatement() : Statement() {}
NopStatement::NopStatement(const Source& source) : Statement(source) {}
NopStatement::~NopStatement() = default;
bool NopStatement::IsNop() const {
return true;
}
bool NopStatement::IsValid() const {
return true;
}
void NopStatement::to_str(std::ostream& out, size_t indent) const {
make_indent(out, indent);
out << "Nop{}" << std::endl;
}
} // namespace ast
} // namespace tint

View File

@ -1,53 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_AST_NOP_STATEMENT_H_
#define SRC_AST_NOP_STATEMENT_H_
#include "src/ast/statement.h"
namespace tint {
namespace ast {
/// A nop statement
class NopStatement : public Statement {
public:
/// Constructor
NopStatement();
/// Constructor
/// @param source the nop statement source
explicit NopStatement(const Source& source);
/// Move constructor
NopStatement(NopStatement&&) = default;
~NopStatement() override;
/// @returns true if this is a nop statement
bool IsNop() const override;
/// @returns true if the node is valid
bool IsValid() const override;
/// Writes a representation of the node to the output stream
/// @param out the stream to write to
/// @param indent number of spaces to indent the node when writing
void to_str(std::ostream& out, size_t indent) const override;
private:
NopStatement(const NopStatement&) = delete;
};
} // namespace ast
} // namespace tint
#endif // SRC_AST_NOP_STATEMENT_H_

View File

@ -1,59 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/ast/nop_statement.h"
#include <sstream>
#include "gtest/gtest.h"
namespace tint {
namespace ast {
namespace {
using NopStatementTest = testing::Test;
TEST_F(NopStatementTest, Creation) {
NopStatement n;
EXPECT_EQ(n.line(), 0u);
EXPECT_EQ(n.column(), 0u);
}
TEST_F(NopStatementTest, Creation_WithSource) {
NopStatement n(Source{20, 2});
EXPECT_EQ(n.line(), 20u);
EXPECT_EQ(n.column(), 2u);
}
TEST_F(NopStatementTest, IsNop) {
NopStatement n;
EXPECT_TRUE(n.IsNop());
}
TEST_F(NopStatementTest, IsValid) {
NopStatement n;
EXPECT_TRUE(n.IsValid());
}
TEST_F(NopStatementTest, ToStr) {
NopStatement n;
std::ostringstream out;
n.to_str(out, 2);
EXPECT_EQ(out.str(), R"( Nop{}
)");
}
} // namespace
} // namespace ast
} // namespace tint

View File

@ -25,7 +25,6 @@
#include "src/ast/if_statement.h"
#include "src/ast/kill_statement.h"
#include "src/ast/loop_statement.h"
#include "src/ast/nop_statement.h"
#include "src/ast/return_statement.h"
#include "src/ast/switch_statement.h"
#include "src/ast/unless_statement.h"
@ -78,10 +77,6 @@ bool Statement::IsLoop() const {
return false;
}
bool Statement::IsNop() const {
return false;
}
bool Statement::IsReturn() const {
return false;
}
@ -143,11 +138,6 @@ const LoopStatement* Statement::AsLoop() const {
return static_cast<const LoopStatement*>(this);
}
const NopStatement* Statement::AsNop() const {
assert(IsNop());
return static_cast<const NopStatement*>(this);
}
const ReturnStatement* Statement::AsReturn() const {
assert(IsReturn());
return static_cast<const ReturnStatement*>(this);
@ -213,11 +203,6 @@ LoopStatement* Statement::AsLoop() {
return static_cast<LoopStatement*>(this);
}
NopStatement* Statement::AsNop() {
assert(IsNop());
return static_cast<NopStatement*>(this);
}
ReturnStatement* Statement::AsReturn() {
assert(IsReturn());
return static_cast<ReturnStatement*>(this);

View File

@ -32,7 +32,6 @@ class FallthroughStatement;
class IfStatement;
class KillStatement;
class LoopStatement;
class NopStatement;
class ReturnStatement;
class SwitchStatement;
class UnlessStatement;
@ -61,8 +60,6 @@ class Statement : public Node {
virtual bool IsKill() const;
/// @returns true if this is a loop statement
virtual bool IsLoop() const;
/// @returns true if this is a nop statement
virtual bool IsNop() const;
/// @returns true if this is a return statement
virtual bool IsReturn() const;
/// @returns true if this is a switch statement
@ -90,8 +87,6 @@ class Statement : public Node {
const KillStatement* AsKill() const;
/// @returns the statement as a const loop statement
const LoopStatement* AsLoop() const;
/// @returns the statement as a const nop statement
const NopStatement* AsNop() const;
/// @returns the statement as a const return statement
const ReturnStatement* AsReturn() const;
/// @returns the statement as a const switch statement
@ -119,8 +114,6 @@ class Statement : public Node {
KillStatement* AsKill();
/// @returns the statement as a loop statement
LoopStatement* AsLoop();
/// @returns the statement as a nop statement
NopStatement* AsNop();
/// @returns the statement as a return statement
ReturnStatement* AsReturn();
/// @returns the statement as a switch statement

View File

@ -17,7 +17,7 @@
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/if_statement.h"
#include "src/ast/nop_statement.h"
#include "src/ast/kill_statement.h"
namespace tint {
namespace ast {
@ -28,21 +28,21 @@ using UnlessStatementTest = testing::Test;
TEST_F(UnlessStatementTest, Creation) {
auto ident = std::make_unique<IdentifierExpression>("ident");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
auto* ident_ptr = ident.get();
auto* nop_ptr = body[0].get();
auto* kill_ptr = body[0].get();
UnlessStatement u(std::move(ident), std::move(body));
EXPECT_EQ(u.condition(), ident_ptr);
ASSERT_EQ(u.body().size(), 1u);
EXPECT_EQ(u.body()[0].get(), nop_ptr);
EXPECT_EQ(u.body()[0].get(), kill_ptr);
}
TEST_F(UnlessStatementTest, Creation_WithSource) {
auto ident = std::make_unique<IdentifierExpression>("ident");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
UnlessStatement u(Source{20, 2}, std::move(ident), std::move(body));
auto src = u.source();
@ -58,7 +58,7 @@ TEST_F(UnlessStatementTest, IsUnless) {
TEST_F(UnlessStatementTest, IsValid) {
auto ident = std::make_unique<IdentifierExpression>("ident");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
UnlessStatement u(std::move(ident), std::move(body));
EXPECT_TRUE(u.IsValid());
@ -66,7 +66,7 @@ TEST_F(UnlessStatementTest, IsValid) {
TEST_F(UnlessStatementTest, IsValid_NullCondition) {
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
UnlessStatement u;
u.set_body(std::move(body));
@ -76,7 +76,7 @@ TEST_F(UnlessStatementTest, IsValid_NullCondition) {
TEST_F(UnlessStatementTest, IsValid_InvalidCondition) {
auto ident = std::make_unique<IdentifierExpression>("");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
UnlessStatement u(std::move(ident), std::move(body));
EXPECT_FALSE(u.IsValid());
@ -85,7 +85,7 @@ TEST_F(UnlessStatementTest, IsValid_InvalidCondition) {
TEST_F(UnlessStatementTest, IsValid_NullBodyStatement) {
auto ident = std::make_unique<IdentifierExpression>("ident");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
body.push_back(nullptr);
UnlessStatement u(std::move(ident), std::move(body));
@ -95,7 +95,7 @@ TEST_F(UnlessStatementTest, IsValid_NullBodyStatement) {
TEST_F(UnlessStatementTest, IsValid_InvalidBodyStatement) {
auto ident = std::make_unique<IdentifierExpression>("ident");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
body.push_back(std::make_unique<IfStatement>());
UnlessStatement u(std::move(ident), std::move(body));
@ -105,7 +105,7 @@ TEST_F(UnlessStatementTest, IsValid_InvalidBodyStatement) {
TEST_F(UnlessStatementTest, ToStr) {
auto ident = std::make_unique<IdentifierExpression>("ident");
StatementList body;
body.push_back(std::make_unique<NopStatement>());
body.push_back(std::make_unique<KillStatement>());
UnlessStatement u(std::move(ident), std::move(body));
std::ostringstream out;
@ -115,7 +115,7 @@ TEST_F(UnlessStatementTest, ToStr) {
Identifier{ident}
)
{
Nop{}
Kill{}
}
}
)");

View File

@ -1632,10 +1632,8 @@ TypedExpression FunctionEmitter::MakeAccessChain(
pointee_type->AsVector()->element_count() <= index_const_val) {
Fail() << "Access chain %" << inst.result_id() << " index %"
<< inst.GetSingleWordInOperand(index) << " value "
<< index_const_val
<< " is out of bounds for vector of "
<< pointee_type->AsVector()->element_count()
<< " elements";
<< index_const_val << " is out of bounds for vector of "
<< pointee_type->AsVector()->element_count() << " elements";
return {};
}
if (uint64_t(index_const_val) >=
@ -1659,17 +1657,20 @@ TypedExpression FunctionEmitter::MakeAccessChain(
case spvtools::opt::analysis::Type::kMatrix:
// Use array syntax.
next_expr = std::make_unique<ast::ArrayAccessorExpression>(
std::move(current_expr.expr), std::move(MakeOperand(inst, index).expr));
std::move(current_expr.expr),
std::move(MakeOperand(inst, index).expr));
pointee_type = pointee_type->AsMatrix()->element_type();
break;
case spvtools::opt::analysis::Type::kArray:
next_expr = std::make_unique<ast::ArrayAccessorExpression>(
std::move(current_expr.expr), std::move(MakeOperand(inst, index).expr));
std::move(current_expr.expr),
std::move(MakeOperand(inst, index).expr));
pointee_type = pointee_type->AsArray()->element_type();
break;
case spvtools::opt::analysis::Type::kRuntimeArray:
next_expr = std::make_unique<ast::ArrayAccessorExpression>(
std::move(current_expr.expr), std::move(MakeOperand(inst, index).expr));
std::move(current_expr.expr),
std::move(MakeOperand(inst, index).expr));
pointee_type = pointee_type->AsRuntimeArray()->element_type();
break;
case spvtools::opt::analysis::Type::kStruct: {
@ -1683,9 +1684,8 @@ TypedExpression FunctionEmitter::MakeAccessChain(
if ((index_const_val < 0) ||
pointee_type->AsStruct()->element_types().size() <=
uint64_t(index_const_val)) {
Fail() << "Access chain %" << inst.result_id()
<< " index value " << index_const_val
<< " is out of bounds for structure %"
Fail() << "Access chain %" << inst.result_id() << " index value "
<< index_const_val << " is out of bounds for structure %"
<< type_mgr_->GetId(pointee_type) << " having "
<< pointee_type->AsStruct()->element_types().size()
<< " elements";
@ -1703,8 +1703,7 @@ TypedExpression FunctionEmitter::MakeAccessChain(
}
default:
Fail() << "Access chain with unknown pointee type %"
<< type_mgr_->GetId(pointee_type) << " "
<< pointee_type->str();
<< type_mgr_->GetId(pointee_type) << " " << pointee_type->str();
return {};
}
current_expr.reset(TypedExpression(

View File

@ -586,8 +586,6 @@ Token Lexer::check_keyword(const Source& source, const std::string& str) {
return {Token::Type::kMat4x3, source, "mat4x3"};
if (str == "mat4x4")
return {Token::Type::kMat4x4, source, "mat4x4"};
if (str == "nop")
return {Token::Type::kNop, source, "nop"};
if (str == "num_workgroups")
return {Token::Type::kNumWorkgroups, source, "num_workgroups"};
if (str == "offset")

View File

@ -468,7 +468,6 @@ INSTANTIATE_TEST_SUITE_P(
TokenData{"mat4x2", Token::Type::kMat4x2},
TokenData{"mat4x3", Token::Type::kMat4x3},
TokenData{"mat4x4", Token::Type::kMat4x4},
TokenData{"nop", Token::Type::kNop},
TokenData{"num_workgroups", Token::Type::kNumWorkgroups},
TokenData{"offset", Token::Type::kOffset},
TokenData{"out", Token::Type::kOut},

View File

@ -38,7 +38,6 @@
#include "src/ast/kill_statement.h"
#include "src/ast/location_decoration.h"
#include "src/ast/member_accessor_expression.h"
#include "src/ast/nop_statement.h"
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/set_decoration.h"
@ -1450,7 +1449,6 @@ ast::StatementList ParserImpl::statements() {
// | break_stmt SEMICOLON
// | continue_stmt SEMICOLON
// | KILL SEMICOLON
// | NOP SEMICOLON
// | assignment_expression SEMICOLON
std::unique_ptr<ast::Statement> ParserImpl::statement() {
auto t = peek();
@ -1552,18 +1550,6 @@ std::unique_ptr<ast::Statement> ParserImpl::statement() {
return std::make_unique<ast::KillStatement>(source);
}
if (t.IsNop()) {
auto source = t.source();
next(); // Consume the peek
t = next();
if (!t.IsSemicolon()) {
set_error(t, "missing ;");
return nullptr;
}
return std::make_unique<ast::NopStatement>(source);
}
auto assign = assignment_stmt();
if (has_error())
return nullptr;

View File

@ -24,15 +24,13 @@ namespace {
TEST_F(ParserImplTest, BodyStmt) {
auto* p = parser(R"({
kill;
nop;
return 1 + b / 2;
})");
auto e = p->body_stmt();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_EQ(e.size(), 3u);
ASSERT_EQ(e.size(), 2u);
EXPECT_TRUE(e[0]->IsKill());
EXPECT_TRUE(e[1]->IsNop());
EXPECT_TRUE(e[2]->IsReturn());
EXPECT_TRUE(e[1]->IsReturn());
}
TEST_F(ParserImplTest, BodyStmt_Empty) {

View File

@ -22,19 +22,19 @@ namespace wgsl {
namespace {
TEST_F(ParserImplTest, ContinuingStmt) {
auto* p = parser("continuing { nop; }");
auto* p = parser("continuing { kill; }");
auto e = p->continuing_stmt();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_EQ(e.size(), 1u);
ASSERT_TRUE(e[0]->IsNop());
ASSERT_TRUE(e[0]->IsKill());
}
TEST_F(ParserImplTest, ContinuingStmt_InvalidBody) {
auto* p = parser("continuing { nop }");
auto* p = parser("continuing { kill }");
auto e = p->continuing_stmt();
ASSERT_TRUE(p->has_error());
ASSERT_EQ(e.size(), 0u);
EXPECT_EQ(p->error(), "1:18: missing ;");
EXPECT_EQ(p->error(), "1:19: missing ;");
}
} // namespace

View File

@ -22,25 +22,25 @@ namespace wgsl {
namespace {
TEST_F(ParserImplTest, LoopStmt_BodyNoContinuing) {
auto* p = parser("loop { nop; }");
auto* p = parser("loop { kill; }");
auto e = p->loop_stmt();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e, nullptr);
ASSERT_EQ(e->body().size(), 1u);
EXPECT_TRUE(e->body()[0]->IsNop());
EXPECT_TRUE(e->body()[0]->IsKill());
EXPECT_EQ(e->continuing().size(), 0u);
}
TEST_F(ParserImplTest, LoopStmt_BodyWithContinuing) {
auto* p = parser("loop { nop; continuing { kill; }}");
auto* p = parser("loop { kill; continuing { kill; }}");
auto e = p->loop_stmt();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e, nullptr);
ASSERT_EQ(e->body().size(), 1u);
EXPECT_TRUE(e->body()[0]->IsNop());
EXPECT_TRUE(e->body()[0]->IsKill());
EXPECT_EQ(e->continuing().size(), 1u);
EXPECT_TRUE(e->continuing()[0]->IsKill());

View File

@ -253,22 +253,6 @@ TEST_F(ParserImplTest, Statement_Kill_MissingSemicolon) {
EXPECT_EQ(p->error(), "1:5: missing ;");
}
TEST_F(ParserImplTest, Statement_Nop) {
auto* p = parser("nop;");
auto e = p->statement();
ASSERT_FALSE(p->has_error()) << p->error();
EXPECT_NE(e, nullptr);
ASSERT_TRUE(e->IsNop());
}
TEST_F(ParserImplTest, Statement_Nop_MissingSemicolon) {
auto* p = parser("nop");
auto e = p->statement();
ASSERT_TRUE(p->has_error());
EXPECT_EQ(e, nullptr);
EXPECT_EQ(p->error(), "1:4: missing ;");
}
} // namespace
} // namespace wgsl
} // namespace reader

View File

@ -23,13 +23,12 @@ namespace wgsl {
namespace {
TEST_F(ParserImplTest, Statements) {
auto* p = parser("nop; kill; return;");
auto* p = parser("kill; return;");
auto e = p->statements();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_EQ(e.size(), 3u);
EXPECT_TRUE(e[0]->IsNop());
EXPECT_TRUE(e[1]->IsKill());
EXPECT_TRUE(e[2]->IsReturn());
ASSERT_EQ(e.size(), 2u);
EXPECT_TRUE(e[0]->IsKill());
EXPECT_TRUE(e[1]->IsReturn());
}
TEST_F(ParserImplTest, Statements_Empty) {

View File

@ -223,8 +223,6 @@ std::string Token::TypeToName(Type type) {
return "mat4x3";
case Token::Type::kMat4x4:
return "mat4x4";
case Token::Type::kNop:
return "nop";
case Token::Type::kNumWorkgroups:
return "num_workgroups";
case Token::Type::kOffset:

View File

@ -234,8 +234,6 @@ class Token {
kMat4x3,
/// A 'mat4x4'
kMat4x4,
/// A 'nop'
kNop,
/// A 'num_workgroups'
kNumWorkgroups,
/// A 'offset'
@ -547,8 +545,6 @@ class Token {
bool IsMat4x3() const { return type_ == Type::kMat4x3; }
/// @returns true if token is a 'mat4x4'
bool IsMat4x4() const { return type_ == Type::kMat4x4; }
/// @returns true if token is a 'nop'
bool IsNop() const { return type_ == Type::kNop; }
/// @returns true if token is a 'num_workgroups'
bool IsNumWorkgroups() const { return type_ == Type::kNumWorkgroups; }
/// @returns true if token is a 'offset'

View File

@ -183,9 +183,6 @@ bool TypeDeterminer::DetermineResultType(ast::Statement* stmt) {
return DetermineStatements(l->body()) &&
DetermineStatements(l->continuing());
}
if (stmt->IsNop()) {
return true;
}
if (stmt->IsReturn()) {
auto* r = stmt->AsReturn();
return DetermineResultType(r->value());

View File

@ -45,7 +45,7 @@ TEST_F(BinaryWriterTest, Preamble) {
TEST_F(BinaryWriterTest, Float) {
ast::Module mod;
Builder b(&mod);
b.push_preamble(spv::Op::OpNop, {Operand::Float(2.4f)});
b.push_preamble(spv::Op::OpKill, {Operand::Float(2.4f)});
BinaryWriter bw;
bw.WriteBuilder(b);
@ -59,7 +59,7 @@ TEST_F(BinaryWriterTest, Float) {
TEST_F(BinaryWriterTest, Int) {
ast::Module mod;
Builder b(&mod);
b.push_preamble(spv::Op::OpNop, {Operand::Int(2)});
b.push_preamble(spv::Op::OpKill, {Operand::Int(2)});
BinaryWriter bw;
bw.WriteBuilder(b);
@ -71,7 +71,7 @@ TEST_F(BinaryWriterTest, Int) {
TEST_F(BinaryWriterTest, String) {
ast::Module mod;
Builder b(&mod);
b.push_preamble(spv::Op::OpNop, {Operand::String("my_string")});
b.push_preamble(spv::Op::OpKill, {Operand::String("my_string")});
BinaryWriter bw;
bw.WriteBuilder(b);
@ -96,7 +96,7 @@ TEST_F(BinaryWriterTest, String) {
TEST_F(BinaryWriterTest, String_Multiple4Length) {
ast::Module mod;
Builder b(&mod);
b.push_preamble(spv::Op::OpNop, {Operand::String("mystring")});
b.push_preamble(spv::Op::OpKill, {Operand::String("mystring")});
BinaryWriter bw;
bw.WriteBuilder(b);
@ -119,8 +119,8 @@ TEST_F(BinaryWriterTest, String_Multiple4Length) {
}
TEST_F(BinaryWriterTest, TestInstructionWriter) {
Instruction i1{spv::Op::OpNop, {Operand::Int(2)}};
Instruction i2{spv::Op::OpNop, {Operand::Int(4)}};
Instruction i1{spv::Op::OpKill, {Operand::Int(2)}};
Instruction i2{spv::Op::OpKill, {Operand::Int(4)}};
BinaryWriter bw;
bw.WriteInstruction(i1);

View File

@ -736,9 +736,6 @@ bool GeneratorImpl::EmitStatement(ast::Statement* stmt) {
if (stmt->IsLoop()) {
return EmitLoop(stmt->AsLoop());
}
if (stmt->IsNop()) {
return EmitNop(stmt->AsNop());
}
if (stmt->IsReturn()) {
return EmitReturn(stmt->AsReturn());
}
@ -920,12 +917,6 @@ bool GeneratorImpl::EmitLoop(ast::LoopStatement* stmt) {
return true;
}
bool GeneratorImpl::EmitNop(ast::NopStatement*) {
make_indent();
out_ << "nop;" << std::endl;
return true;
}
bool GeneratorImpl::EmitReturn(ast::ReturnStatement* stmt) {
make_indent();

View File

@ -162,10 +162,6 @@ class GeneratorImpl {
/// @param expr the member accessor expression
/// @returns true if the member accessor was emitted
bool EmitMemberAccessor(ast::MemberAccessorExpression* expr);
/// Handles generating a nop statement
/// @param stmt the nop statement
/// @returns true if the statement was successfully emitted
bool EmitNop(ast::NopStatement* stmt);
/// Handles return statements
/// @param stmt the statement to emit
/// @returns true if the statement was successfully emitted

View File

@ -17,7 +17,6 @@
#include "gtest/gtest.h"
#include "src/ast/kill_statement.h"
#include "src/ast/loop_statement.h"
#include "src/ast/nop_statement.h"
#include "src/writer/wgsl/generator_impl.h"
namespace tint {
@ -48,7 +47,7 @@ TEST_F(GeneratorImplTest, Emit_LoopWithContinuing) {
body.push_back(std::make_unique<ast::KillStatement>());
ast::StatementList continuing;
continuing.push_back(std::make_unique<ast::NopStatement>());
continuing.push_back(std::make_unique<ast::KillStatement>());
ast::LoopStatement l(std::move(body), std::move(continuing));
@ -60,7 +59,7 @@ TEST_F(GeneratorImplTest, Emit_LoopWithContinuing) {
kill;
continuing {
nop;
kill;
}
}
)");

View File

@ -1,39 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "gtest/gtest.h"
#include "src/ast/nop_statement.h"
#include "src/writer/wgsl/generator_impl.h"
namespace tint {
namespace writer {
namespace wgsl {
namespace {
using GeneratorImplTest = testing::Test;
TEST_F(GeneratorImplTest, Emit_Nop) {
ast::NopStatement n;
GeneratorImpl g;
g.increment_indent();
ASSERT_TRUE(g.EmitStatement(&n)) << g.error();
EXPECT_EQ(g.result(), " nop;\n");
}
} // namespace
} // namespace wgsl
} // namespace writer
} // namespace tint

View File

@ -17,7 +17,6 @@
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/kill_statement.h"
#include "src/ast/nop_statement.h"
#include "src/ast/unless_statement.h"
#include "src/writer/wgsl/generator_impl.h"
@ -32,7 +31,7 @@ TEST_F(GeneratorImplTest, Emit_Unless) {
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
ast::StatementList body;
body.push_back(std::make_unique<ast::NopStatement>());
body.push_back(std::make_unique<ast::KillStatement>());
body.push_back(std::make_unique<ast::KillStatement>());
ast::UnlessStatement u(std::move(cond), std::move(body));
@ -42,7 +41,7 @@ TEST_F(GeneratorImplTest, Emit_Unless) {
ASSERT_TRUE(g.EmitStatement(&u)) << g.error();
EXPECT_EQ(g.result(), R"( unless (cond) {
nop;
kill;
kill;
}
)");