[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:
parent
fd3700c0a7
commit
194e0cca3b
|
@ -2421,6 +2421,9 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (inst.opcode()) {
|
switch (inst.opcode()) {
|
||||||
|
case SpvOpNop:
|
||||||
|
return true;
|
||||||
|
|
||||||
case SpvOpStore: {
|
case SpvOpStore: {
|
||||||
// TODO(dneto): Order of evaluation?
|
// TODO(dneto): Order of evaluation?
|
||||||
auto lhs = MakeExpression(inst.GetSingleWordInOperand(0));
|
auto lhs = MakeExpression(inst.GetSingleWordInOperand(0));
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace reader {
|
||||||
namespace spirv {
|
namespace spirv {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using ::testing::Eq;
|
||||||
using ::testing::HasSubstr;
|
using ::testing::HasSubstr;
|
||||||
|
|
||||||
std::string CommonTypes() {
|
std::string CommonTypes() {
|
||||||
|
@ -277,7 +278,24 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
|
||||||
})")) << ToString(fe.ast_body());
|
})")) << 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)
|
// TODO(dneto): OpSizeof : requires Kernel (OpenCL)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in New Issue