[spirv-reader] Convert from KillStatement to DiscardStatement
This CL changes the SPIRV-Reader to generate DiscardStatements instead of KillStatements for an OpKill. Bug: tint:168 Change-Id: Ic4223b614c822c6ad449f61aedaddc9605c42535 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25642 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
f75f2cd22e
commit
23508f4339
|
@ -38,11 +38,11 @@
|
||||||
#include "src/ast/case_statement.h"
|
#include "src/ast/case_statement.h"
|
||||||
#include "src/ast/cast_expression.h"
|
#include "src/ast/cast_expression.h"
|
||||||
#include "src/ast/continue_statement.h"
|
#include "src/ast/continue_statement.h"
|
||||||
|
#include "src/ast/discard_statement.h"
|
||||||
#include "src/ast/else_statement.h"
|
#include "src/ast/else_statement.h"
|
||||||
#include "src/ast/fallthrough_statement.h"
|
#include "src/ast/fallthrough_statement.h"
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/if_statement.h"
|
#include "src/ast/if_statement.h"
|
||||||
#include "src/ast/kill_statement.h"
|
|
||||||
#include "src/ast/loop_statement.h"
|
#include "src/ast/loop_statement.h"
|
||||||
#include "src/ast/member_accessor_expression.h"
|
#include "src/ast/member_accessor_expression.h"
|
||||||
#include "src/ast/return_statement.h"
|
#include "src/ast/return_statement.h"
|
||||||
|
@ -2194,7 +2194,7 @@ bool FunctionEmitter::EmitNormalTerminator(const BlockInfo& block_info) {
|
||||||
case SpvOpKill:
|
case SpvOpKill:
|
||||||
// For now, assume SPIR-V OpKill has same semantics as WGSL kill.
|
// For now, assume SPIR-V OpKill has same semantics as WGSL kill.
|
||||||
// TODO(dneto): https://github.com/gpuweb/gpuweb/issues/676
|
// TODO(dneto): https://github.com/gpuweb/gpuweb/issues/676
|
||||||
AddStatement(std::make_unique<ast::KillStatement>());
|
AddStatement(std::make_unique<ast::DiscardStatement>());
|
||||||
return true;
|
return true;
|
||||||
case SpvOpUnreachable:
|
case SpvOpUnreachable:
|
||||||
// Translate as if it's a return. This avoids the problem where WGSL
|
// Translate as if it's a return. This avoids the problem where WGSL
|
||||||
|
|
|
@ -9947,7 +9947,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_TopLevel) {
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Kill{}
|
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Discard{}
|
||||||
)")) << ToString(fe.ast_body());
|
)")) << ToString(fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9976,10 +9976,10 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideIf) {
|
||||||
ScalarConstructor{false}
|
ScalarConstructor{false}
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Kill{}
|
Discard{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Kill{}
|
Discard{}
|
||||||
)")) << ToString(fe.ast_body());
|
)")) << ToString(fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10010,9 +10010,9 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideLoop) {
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Loop{
|
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Loop{
|
||||||
Kill{}
|
Discard{}
|
||||||
}
|
}
|
||||||
Kill{}
|
Discard{}
|
||||||
)")) << ToString(fe.ast_body());
|
)")) << ToString(fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ const char* kWGSLReservedWords[] = {
|
||||||
"constant_id",
|
"constant_id",
|
||||||
"continue",
|
"continue",
|
||||||
"default",
|
"default",
|
||||||
|
"discard",
|
||||||
"do",
|
"do",
|
||||||
"else",
|
"else",
|
||||||
"elseif",
|
"elseif",
|
||||||
|
@ -62,7 +63,6 @@ const char* kWGSLReservedWords[] = {
|
||||||
"image",
|
"image",
|
||||||
"import",
|
"import",
|
||||||
"in",
|
"in",
|
||||||
"kill",
|
|
||||||
"let",
|
"let",
|
||||||
"location",
|
"location",
|
||||||
"loop",
|
"loop",
|
||||||
|
@ -106,7 +106,8 @@ const char* kWGSLReservedWords[] = {
|
||||||
"while",
|
"while",
|
||||||
"workgroup",
|
"workgroup",
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
Namer::Namer(const FailStream& fail_stream) : fail_stream_(fail_stream) {
|
Namer::Namer(const FailStream& fail_stream) : fail_stream_(fail_stream) {
|
||||||
for (const auto* reserved : kWGSLReservedWords) {
|
for (const auto* reserved : kWGSLReservedWords) {
|
||||||
|
|
|
@ -340,6 +340,7 @@ INSTANTIATE_TEST_SUITE_P(SpvParserTest_ReservedWords,
|
||||||
"constant_id",
|
"constant_id",
|
||||||
"continue",
|
"continue",
|
||||||
"default",
|
"default",
|
||||||
|
"discard",
|
||||||
"do",
|
"do",
|
||||||
"else",
|
"else",
|
||||||
"elseif",
|
"elseif",
|
||||||
|
@ -360,7 +361,6 @@ INSTANTIATE_TEST_SUITE_P(SpvParserTest_ReservedWords,
|
||||||
"image",
|
"image",
|
||||||
"import",
|
"import",
|
||||||
"in",
|
"in",
|
||||||
"kill",
|
|
||||||
"let",
|
"let",
|
||||||
"location",
|
"location",
|
||||||
"loop",
|
"loop",
|
||||||
|
|
Loading…
Reference in New Issue