[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>
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index d92862c..840836b 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -2421,6 +2421,9 @@
   }
 
   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 7e1e5f8..3cb8ddf 100644
--- a/src/reader/spirv/function_misc_test.cc
+++ b/src/reader/spirv/function_misc_test.cc
@@ -26,6 +26,7 @@
 namespace spirv {
 namespace {
 
+using ::testing::Eq;
 using ::testing::HasSubstr;
 
 std::string CommonTypes() {
@@ -277,7 +278,24 @@
 })")) << 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