[spirv-reader] Support OpNop

An OpNop maps to nothing

Bug: tint:3
Change-Id: Id73601d481971954dd4de706202b5229dcf39871
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23561
Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
David Neto 2020-06-22 20:49:34 +00:00
parent fd3700c0a7
commit 194e0cca3b
2 changed files with 22 additions and 1 deletions

View File

@ -2421,6 +2421,9 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) {
}
switch (inst.opcode()) {
case SpvOpNop:
return true;
case SpvOpStore: {
// TODO(dneto): Order of evaluation?
auto lhs = MakeExpression(inst.GetSingleWordInOperand(0));

View File

@ -26,6 +26,7 @@ namespace reader {
namespace spirv {
namespace {
using ::testing::Eq;
using ::testing::HasSubstr;
std::string CommonTypes() {
@ -277,7 +278,24 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
})")) << ToString(fe.ast_body());
}
// TODO(dneto): OpNop
TEST_F(SpvParserTestMiscInstruction, OpNop) {
const auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
%entry = OpLabel
OpNop
OpReturn
OpFunctionEnd
)";
auto* p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << assembly;
FunctionEmitter fe(p, *spirv_function(100));
EXPECT_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Return{}
)"))
<< ToString(fe.ast_body());
}
// TODO(dneto): OpSizeof : requires Kernel (OpenCL)
} // namespace