[spirv-reader] Test EmitFunctionDeclaration

Tests FunctionEmitter directly.
This is mostly refactoring to be able to selectively run parts of the
parsing flow, and to access relevant internal data.

Bug: tint:3
Change-Id: Ic2b166a2e9623a7e30e6769806088d12e78dcf45
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18704
Reviewed-by: dan sinclair <dsinclair@google.com>
diff --git a/src/reader/spirv/parser_impl_test_helper.h b/src/reader/spirv/parser_impl_test_helper.h
index 66a48df..4f52e09 100644
--- a/src/reader/spirv/parser_impl_test_helper.h
+++ b/src/reader/spirv/parser_impl_test_helper.h
@@ -20,6 +20,7 @@
 #include <vector>
 
 #include "gtest/gtest.h"
+#include "source/opt/ir_context.h"
 #include "src/context.h"
 #include "src/reader/spirv/parser_impl.h"
 
@@ -47,6 +48,14 @@
     return impl_.get();
   }
 
+  /// Gets the internal representation of the function with the given ID.
+  /// Assumes ParserImpl::BuildInternalRepresentation has been run and
+  /// succeeded.
+  /// @returns the internal representation of the function
+  spvtools::opt::Function* spirv_function(uint32_t id) {
+    return impl_->ir_context()->GetFunction(id);
+  }
+
  private:
   std::unique_ptr<ParserImpl> impl_;
   Context ctx_;