diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index d92862caab..840836bbb6 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -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)); diff --git a/src/reader/spirv/function_misc_test.cc b/src/reader/spirv/function_misc_test.cc index 7e1e5f89dd..3cb8ddfcd0 100644 --- a/src/reader/spirv/function_misc_test.cc +++ b/src/reader/spirv/function_misc_test.cc @@ -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