From df48b955b2e587ae89098b969a512ed665109e6c Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 4 May 2021 20:17:41 +0000 Subject: [PATCH] spirv-reader: update tests to wrap parser impl This is a step to being able to dump the SPIR-V for successfully converted modules. Bug: tint:756 Change-Id: Ifa48c88835ff10824c542a4e13d8a2d3a7f7f484 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49604 Commit-Queue: David Neto Auto-Submit: David Neto Reviewed-by: Ben Clayton --- src/reader/spirv/function.cc | 17 + src/reader/spirv/function.h | 3 + src/reader/spirv/function_arithmetic_test.cc | 54 +- src/reader/spirv/function_bit_test.cc | 52 +- src/reader/spirv/function_call_test.cc | 8 +- src/reader/spirv/function_cfg_test.cc | 664 +++++++++--------- src/reader/spirv/function_composite_test.cc | 70 +- src/reader/spirv/function_conversion_test.cc | 60 +- src/reader/spirv/function_decl_test.cc | 8 +- .../spirv/function_glsl_std_450_test.cc | 68 +- src/reader/spirv/function_logical_test.cc | 52 +- src/reader/spirv/function_memory_test.cc | 52 +- src/reader/spirv/function_misc_test.cc | 18 +- src/reader/spirv/function_var_test.cc | 56 +- src/reader/spirv/parser_impl.h | 3 + .../spirv/parser_impl_convert_type_test.cc | 124 ++-- src/reader/spirv/parser_impl_handle_test.cc | 4 +- .../spirv/parser_impl_module_var_test.cc | 2 +- src/reader/spirv/parser_impl_test_helper.h | 102 ++- src/reader/spirv/spirv_tools_helpers_test.cc | 3 +- 20 files changed, 761 insertions(+), 659 deletions(-) diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index 00270423c3..be82b9a63b 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -743,6 +743,23 @@ FunctionEmitter::FunctionEmitter(ParserImpl* pi, const spvtools::opt::Function& function) : FunctionEmitter(pi, function, nullptr) {} +FunctionEmitter::FunctionEmitter(FunctionEmitter&& other) + : parser_impl_(other.parser_impl_), + builder_(other.builder_), + ir_context_(other.ir_context_), + def_use_mgr_(ir_context_.get_def_use_mgr()), + constant_mgr_(ir_context_.get_constant_mgr()), + type_mgr_(ir_context_.get_type_mgr()), + fail_stream_(other.fail_stream_), + namer_(other.namer_), + function_(other.function_), + sample_mask_in_id(other.sample_mask_out_id), + sample_mask_out_id(other.sample_mask_in_id), + ep_info_(other.ep_info_) { + other.statements_stack_.clear(); + PushNewStatementBlock(nullptr, 0, nullptr); +} + FunctionEmitter::~FunctionEmitter() = default; FunctionEmitter::StatementBlock::StatementBlock( diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h index 24393dd769..bb3a138201 100644 --- a/src/reader/spirv/function.h +++ b/src/reader/spirv/function.h @@ -397,6 +397,9 @@ class FunctionEmitter { FunctionEmitter(ParserImpl* pi, const spvtools::opt::Function& function, const EntryPointInfo* ep_info); + /// Move constructor. Only valid when the other object was newly created. + /// @param other the emitter to clone + FunctionEmitter(FunctionEmitter&& other); /// Destructor ~FunctionEmitter(); diff --git a/src/reader/spirv/function_arithmetic_test.cc b/src/reader/spirv/function_arithmetic_test.cc index 869729a605..4e8ee20ee6 100644 --- a/src/reader/spirv/function_arithmetic_test.cc +++ b/src/reader/spirv/function_arithmetic_test.cc @@ -146,7 +146,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -172,7 +172,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -200,7 +200,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -228,7 +228,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -258,7 +258,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -288,7 +288,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -320,7 +320,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -352,7 +352,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -386,7 +386,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -412,7 +412,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -467,7 +467,7 @@ TEST_P(SpvBinaryArithTest, EmitExpression) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); std::ostringstream ss; ss << R"(VariableConst{ @@ -512,7 +512,7 @@ TEST_P(SpvBinaryArithGeneralTest, EmitExpression) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); std::ostringstream ss; ss << R"(VariableConst{ @@ -990,7 +990,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Scalar_UnsignedResult) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -1025,7 +1025,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -1135,7 +1135,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Scalar_UnsignedResult) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -1170,7 +1170,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -1222,7 +1222,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 @@ -1250,7 +1250,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 @@ -1278,7 +1278,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 @@ -1306,7 +1306,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 @@ -1334,7 +1334,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 @@ -1362,7 +1362,7 @@ TEST_F(SpvBinaryArithTestBasic, Dot) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_3 @@ -1394,7 +1394,7 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(VariableConst{ @@ -1520,7 +1520,7 @@ TEST_P(SpvBinaryDerivativeTest, Derivatives) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_2 @@ -1566,7 +1566,7 @@ TEST_F(SpvUnaryArithTest, Transpose_2x2) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto* expected = R"( VariableDeclStatement{ @@ -1599,7 +1599,7 @@ TEST_F(SpvUnaryArithTest, Transpose_2x3) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); // Note, in the AST dump mat_2_3 means 2 rows and 3 columns. // So the column vectors have 2 elements. @@ -1635,7 +1635,7 @@ TEST_F(SpvUnaryArithTest, Transpose_3x2) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto* expected = R"( VariableDeclStatement{ diff --git a/src/reader/spirv/function_bit_test.cc b/src/reader/spirv/function_bit_test.cc index 3873ec0be8..936054577b 100644 --- a/src/reader/spirv/function_bit_test.cc +++ b/src/reader/spirv/function_bit_test.cc @@ -149,7 +149,7 @@ TEST_P(SpvBinaryBitTest, EmitExpression) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); std::ostringstream ss; ss << R"(VariableConst{ @@ -194,7 +194,7 @@ TEST_P(SpvBinaryBitGeneralTest, EmitExpression) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); std::ostringstream ss; ss << R"(VariableConst{ @@ -692,7 +692,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -718,7 +718,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -746,7 +746,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -774,7 +774,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -800,7 +800,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -830,7 +830,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -862,7 +862,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -893,7 +893,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -947,7 +947,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Uint) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -975,7 +975,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Int) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1005,7 +1005,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Uint) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1035,7 +1035,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Int) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1063,7 +1063,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_UintVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1091,7 +1091,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_IntVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1121,7 +1121,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_UintVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1151,7 +1151,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_IntVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1179,7 +1179,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Uint) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1207,7 +1207,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Int) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1237,7 +1237,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Uint) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1267,7 +1267,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Int) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1295,7 +1295,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_UintVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1323,7 +1323,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_IntVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1353,7 +1353,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_UintVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1383,7 +1383,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_IntVector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( diff --git a/src/reader/spirv/function_call_test.cc b/src/reader/spirv/function_call_test.cc index e7aa477866..0206f1d959 100644 --- a/src/reader/spirv/function_call_test.cc +++ b/src/reader/spirv/function_call_test.cc @@ -85,7 +85,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); { - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -106,7 +106,7 @@ Return{})")); } { - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50)); + auto fe = p->function_emitter(50); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Return{ { @@ -141,7 +141,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParamsUsedTwice) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); { - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -176,7 +176,7 @@ Assignment{ Return{})")); } { - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50)); + auto fe = p->function_emitter(50); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Return{ { diff --git a/src/reader/spirv/function_cfg_test.cc b/src/reader/spirv/function_cfg_test.cc index af990383bf..d5f186993d 100644 --- a/src/reader/spirv/function_cfg_test.cc +++ b/src/reader/spirv/function_cfg_test.cc @@ -129,7 +129,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_SingleBlock) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.TerminatorsAreValid()); } @@ -147,7 +147,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_Sequence) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.TerminatorsAreValid()) << p->error(); } @@ -172,7 +172,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_If) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.TerminatorsAreValid()) << p->error(); } @@ -200,7 +200,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_Switch) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.TerminatorsAreValid()); } @@ -222,7 +222,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_Loop_SingleBlock) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.TerminatorsAreValid()); } @@ -250,7 +250,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_Loop_Simple) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.TerminatorsAreValid()); } @@ -265,7 +265,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_Kill) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.TerminatorsAreValid()); } @@ -280,7 +280,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_Unreachable) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.TerminatorsAreValid()); } @@ -310,7 +310,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_DisallowLoopToEntryBlock) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.TerminatorsAreValid()); EXPECT_THAT(p->error(), Eq("Block 20 branches to function entry block 10")); @@ -326,7 +326,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_DisallowNonBlock) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.TerminatorsAreValid()); EXPECT_THAT(p->error(), @@ -352,7 +352,7 @@ TEST_F(SpvParserTest, TerminatorsAreValid_DisallowBlockInDifferentFunction) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.TerminatorsAreValid()); EXPECT_THAT(p->error(), Eq("Block 10 in function 100 branches to 210 which " @@ -369,7 +369,7 @@ TEST_F(SpvParserTest, RegisterMerges_NoMerges) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.RegisterMerges()); @@ -399,7 +399,7 @@ TEST_F(SpvParserTest, RegisterMerges_GoodSelectionMerge_BranchConditional) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.RegisterMerges()); @@ -448,7 +448,7 @@ TEST_F(SpvParserTest, RegisterMerges_GoodSelectionMerge_Switch) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.RegisterMerges()); @@ -497,7 +497,7 @@ TEST_F(SpvParserTest, RegisterMerges_GoodLoopMerge_SingleBlockLoop) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.RegisterMerges()); @@ -550,7 +550,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.RegisterMerges()); @@ -606,7 +606,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.RegisterMerges()); @@ -663,7 +663,7 @@ TEST_F( OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_TRUE(fe.RegisterMerges()); @@ -712,7 +712,7 @@ TEST_F(SpvParserTest, RegisterMerges_SelectionMerge_BadTerminator) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT(p->error(), Eq("Selection header 10 does not end in an " @@ -742,7 +742,7 @@ TEST_F(SpvParserTest, RegisterMerges_LoopMerge_BadTerminator) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT(p->error(), Eq("Loop header 20 does not end in an OpBranch or " @@ -766,7 +766,7 @@ TEST_F(SpvParserTest, RegisterMerges_BadMergeBlock) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT(p->error(), @@ -790,7 +790,7 @@ TEST_F(SpvParserTest, RegisterMerges_HeaderIsItsOwnMerge) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT(p->error(), @@ -824,7 +824,7 @@ TEST_F(SpvParserTest, RegisterMerges_MergeReused) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT( @@ -849,7 +849,7 @@ TEST_F(SpvParserTest, RegisterMerges_EntryBlockIsLoopHeader) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT(p->error(), @@ -873,7 +873,7 @@ TEST_F(SpvParserTest, RegisterMerges_BadContinueTarget) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT(p->error(), @@ -901,7 +901,7 @@ TEST_F(SpvParserTest, RegisterMerges_MergeSameAsContinue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT(p->error(), @@ -945,7 +945,7 @@ TEST_F(SpvParserTest, RegisterMerges_ContinueReused) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT(p->error(), Eq("Block 40 declared as continue target for more " @@ -972,7 +972,7 @@ TEST_F(SpvParserTest, RegisterMerges_SingleBlockLoop_NotItsOwnContinue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); EXPECT_FALSE(fe.RegisterMerges()); EXPECT_THAT( @@ -990,7 +990,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_OneBlock) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1017,7 +1017,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_IgnoreStaticalyUnreachable) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1040,7 +1040,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_KillIsDeadEnd) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1063,7 +1063,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_UnreachableIsDeadEnd) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1086,7 +1086,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_ReorderSequence) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1120,7 +1120,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_DupConditionalBranch) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1147,7 +1147,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_RespectConditionalBranchOrder) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1171,7 +1171,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_TrueOnlyBranch) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1195,7 +1195,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_FalseOnlyBranch) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1222,7 +1222,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_SwitchOrderNaturallyReversed) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1253,7 +1253,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1283,7 +1283,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Switch_DefaultSameAsACase) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1317,7 +1317,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_RespectSwitchCaseFallthrough) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1353,7 +1353,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1386,7 +1386,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1423,7 +1423,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1465,7 +1465,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1514,7 +1514,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Nest_If_Contains_If) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1564,7 +1564,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Nest_If_In_SwitchCase) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1614,7 +1614,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Nest_IfFallthrough_In_SwitchCase) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1658,7 +1658,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Nest_IfBreak_In_SwitchCase) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1683,7 +1683,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_SingleBlock_Simple) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1707,7 +1707,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_SingleBlock_Infinite) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1731,7 +1731,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_SingleBlock_DupInfinite) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1760,7 +1760,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_HeaderHasBreakIf) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1789,7 +1789,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_HeaderHasBreakUnless) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1818,7 +1818,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_BodyHasBreak) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1850,7 +1850,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_BodyHasBreakIf) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1883,7 +1883,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_BodyHasBreakUnless) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1923,7 +1923,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Body_If) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1960,7 +1960,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Body_If_Break) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -1993,7 +1993,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_BodyHasContinueIf) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2026,7 +2026,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_BodyHasContinueUnless) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2063,7 +2063,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Body_If_Continue) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2103,7 +2103,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Body_Switch) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2145,7 +2145,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Body_Switch_CaseBreaks) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2185,7 +2185,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Body_Switch_CaseContinues) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2218,7 +2218,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_BodyHasSwitchContinueBreak) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2250,7 +2250,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Continue_Sequence) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2289,7 +2289,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Continue_ContainsIf) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2318,7 +2318,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Continue_HasBreakIf) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2347,7 +2347,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Continue_HasBreakUnless) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2376,7 +2376,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Continue_SwitchBreak) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2418,7 +2418,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Loop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2461,7 +2461,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Loop_InnerBreak) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2504,7 +2504,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Loop_InnerContinue) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2547,7 +2547,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Loop_InnerContinueBreaks) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2590,7 +2590,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Loop_InnerContinueContinues) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2638,7 +2638,7 @@ TEST_F(SpvParserTest, ComputeBlockOrder_Loop_Loop_SwitchBackedgeBreakContinue) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); @@ -2667,7 +2667,7 @@ TEST_F(SpvParserTest, VerifyHeaderContinueMergeOrder_Selection_Good) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2692,7 +2692,7 @@ TEST_F(SpvParserTest, VerifyHeaderContinueMergeOrder_SingleBlockLoop_Good) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2720,7 +2720,7 @@ TEST_F(SpvParserTest, VerifyHeaderContinueMergeOrder_MultiBlockLoop_Good) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2752,7 +2752,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2790,7 +2790,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2827,7 +2827,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2850,7 +2850,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2877,7 +2877,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2912,7 +2912,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -2959,7 +2959,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3003,7 +3003,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_SwitchSelection) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3040,7 +3040,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_SingleBlockLoop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3088,7 +3088,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3137,7 +3137,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3181,7 +3181,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3230,7 +3230,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3289,7 +3289,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_Nest_If_If) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3349,7 +3349,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_Nest_Switch_If) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3399,7 +3399,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_Nest_If_Switch) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3453,7 +3453,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_Nest_Loop_Loop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3508,7 +3508,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_Nest_Loop_If) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3559,7 +3559,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_Nest_LoopContinue_If) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3603,7 +3603,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_Nest_If_SingleBlockLoop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3652,7 +3652,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_Nest_If_MultiBlockLoop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); fe.RegisterMerges(); @@ -3705,7 +3705,7 @@ TEST_F(SpvParserTest, LabelControlFlowConstructs_LoopInterallyDiverge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); ASSERT_TRUE(FlowLabelControlFlowConstructs(&fe)) << p->error(); const auto& constructs = fe.constructs(); EXPECT_EQ(constructs.size(), 4u); @@ -3745,7 +3745,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_DefaultIsLongRangeBackedge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -3777,7 +3777,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_DefaultIsSelfLoop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -3812,7 +3812,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_DefaultCantEscapeSwitch) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -3851,7 +3851,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_DefaultForTwoSwitches_AsMerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -3895,7 +3895,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -3924,7 +3924,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_CaseIsLongRangeBackedge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -3953,7 +3953,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_CaseIsSelfLoop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -3984,7 +3984,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_CaseCanBeSwitchMerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4015,7 +4015,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_CaseCantEscapeSwitch) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4051,7 +4051,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_CaseForMoreThanOneSwitch) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4091,7 +4091,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_CaseIsMergeForAnotherConstruct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4113,7 +4113,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_NoSwitch) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4147,7 +4147,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_DefaultIsMerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4185,7 +4185,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_DefaultIsNotMerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4223,7 +4223,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_CaseIsNotDefault) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4258,7 +4258,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_CaseIsDefault) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4296,7 +4296,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_ManyCasesWithSameValue_IsError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4326,7 +4326,7 @@ TEST_F(SpvParserTest, FindSwitchCaseHeaders_ManyValuesWithSameCase) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -4369,7 +4369,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_BranchEscapesIfConstruct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)) << p->error(); // Some further processing EXPECT_THAT( @@ -4400,7 +4400,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ReturnInContinueConstruct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)) << p->error(); EXPECT_THAT(p->error(), Eq("Invalid function exit at block 50 from continue " "construct starting at 50")); @@ -4428,7 +4428,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_KillInContinueConstruct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Invalid function exit at block 50 from continue " "construct starting at 50")); @@ -4456,7 +4456,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_UnreachableInContinueConstruct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Invalid function exit at block 50 from continue " "construct starting at 50")); @@ -4484,7 +4484,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_BackEdge_NotInContinueConstruct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -4517,7 +4517,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Invalid exit (50->20) from continue construct: 50 is not the " @@ -4551,7 +4551,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_BackEdge_ToWrongHeader) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Invalid backedge (50->10): does not branch to " "the corresponding loop header, expected 20")); @@ -4573,7 +4573,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_BackEdge_SingleBlockLoop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi20 = fe.GetBlockInfo(20); @@ -4605,7 +4605,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi40 = fe.GetBlockInfo(40); @@ -4641,7 +4641,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi50 = fe.GetBlockInfo(50); @@ -4677,7 +4677,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)) << p->error(); auto* bi50 = fe.GetBlockInfo(50); @@ -4711,7 +4711,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_PrematureExitFromContinueConstruct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Invalid exit (40->99) from continue construct: 40 is not the " @@ -4736,7 +4736,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(20); @@ -4764,7 +4764,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(20); @@ -4795,7 +4795,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(20); @@ -4823,7 +4823,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_LoopBreak_FromContinueConstructHeader) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -4848,7 +4848,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_FromIfHeader) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(20); @@ -4876,7 +4876,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_FromIfThenElse) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); // Then clause @@ -4911,7 +4911,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_BypassesMerge_IsError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -4951,7 +4951,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_EscapeSwitchCase_IsError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -4975,7 +4975,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchCaseDirect) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(10); @@ -5000,7 +5000,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchCaseBody) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(20); @@ -5028,7 +5028,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchDefaultBody) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5053,7 +5053,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchDefaultIsMerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(10); @@ -5085,7 +5085,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromNestedIf_Unconditional) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5117,7 +5117,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromNestedIf_Conditional) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5145,7 +5145,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_BypassesMerge_IsError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -5180,7 +5180,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromNestedLoop_IsError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -5212,7 +5212,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromNestedSwitch_IsError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -5242,7 +5242,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_LoopBreak_FromLoopBody) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5276,7 +5276,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_LoopBreak_FromContinueConstructTail) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(60); @@ -5307,7 +5307,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_LoopBreak_FromLoopBodyDirect) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5346,7 +5346,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(40); @@ -5385,7 +5385,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(40); @@ -5427,7 +5427,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Invalid exit (50->99) from continue construct: 50 is not the " @@ -5461,7 +5461,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -5498,7 +5498,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -5528,7 +5528,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_LoopContinue_LoopBodyToContinue) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5566,7 +5566,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_LoopContinue_FromNestedIf) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(40); @@ -5604,7 +5604,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_LoopContinue_ConditionalFromNestedIf) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(40); @@ -5643,7 +5643,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)) << p->error(); auto* bi = fe.GetBlockInfo(40); @@ -5679,7 +5679,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -5717,7 +5717,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -5758,7 +5758,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)) << p->error(); auto* bi = fe.GetBlockInfo(40); @@ -5798,7 +5798,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(40); @@ -5849,7 +5849,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -5879,7 +5879,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Fallthrough_CaseTailToCase) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5910,7 +5910,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Fallthrough_CaseTailToDefaultNotMerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5941,7 +5941,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Fallthrough_DefaultToCase) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(30); @@ -5981,7 +5981,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -6015,7 +6015,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Control flow diverges at block 20 (to 25, 30) but it is not " @@ -6061,7 +6061,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Invalid exit (40->20) from continue construct: 40 is not the " @@ -6100,7 +6100,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowFindSwitchCaseHeaders(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 40, 50, 99)); EXPECT_THAT(p->error(), @@ -6143,7 +6143,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Branch from 10 to 50 bypasses continue target 40 " "(dominance rule violated)")); @@ -6184,7 +6184,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 40, 50, 49, 99)); EXPECT_THAT(p->error(), Eq("Branch from 10 to 50 bypasses continue target 40 " @@ -6228,7 +6228,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -6274,7 +6274,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -6297,7 +6297,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Forward_IfToThen) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(10); @@ -6322,7 +6322,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Forward_IfToElse) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(10); @@ -6347,7 +6347,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Forward_SwitchToCase) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(10); @@ -6375,7 +6375,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Forward_SwitchToDefaultNotMerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(10); @@ -6406,7 +6406,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Forward_LoopHeadToBody) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(20); @@ -6439,7 +6439,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -6470,7 +6470,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -6504,7 +6504,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), // Weird error, but still we caught it. @@ -6544,7 +6544,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -6578,7 +6578,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -6611,7 +6611,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowFindSwitchCaseHeaders(&fe)); EXPECT_THAT(p->error(), Eq("Block 50 is a case block for switch-selection header 10 and " @@ -6643,7 +6643,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowFindSwitchCaseHeaders(&fe)); EXPECT_THAT(p->error(), Eq("Block 50 is the default block for switch-selection header 10 " @@ -6672,7 +6672,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_TooManyBackedges) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -6697,7 +6697,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_NeededMerge_BranchConditional) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Control flow diverges at block 20 (to 30, 40) but it is not " @@ -6722,7 +6722,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_NeededMerge_Switch) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), Eq("Control flow diverges at block 10 (to 99, 20) but it is not " @@ -6756,7 +6756,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Pathological_Forward_LoopHeadSplitBody) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(20); @@ -6793,7 +6793,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Pathological_Forward_Premerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi20 = fe.GetBlockInfo(20); @@ -6834,7 +6834,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_Pathological_Forward_Regardless) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi10 = fe.GetBlockInfo(10); @@ -6857,7 +6857,7 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_NoIf) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); auto* bi = fe.GetBlockInfo(10); @@ -6886,7 +6886,7 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_ThenElse) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); auto* bi10 = fe.GetBlockInfo(10); @@ -6930,7 +6930,7 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_IfOnly) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); auto* bi10 = fe.GetBlockInfo(10); @@ -6968,7 +6968,7 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_ElseOnly) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); auto* bi10 = fe.GetBlockInfo(10); @@ -7009,7 +7009,7 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_Regardless) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 80, 99)); @@ -7043,7 +7043,7 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_Premerge_Simple) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 30, 80, 99)); @@ -7078,7 +7078,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 30, 80, 99)); @@ -7113,7 +7113,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 30, 20, 80, 99)); @@ -7154,7 +7154,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); // Error out sooner in the flow EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(p->error(), @@ -7183,7 +7183,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_FromThen_ForwardWithinThen) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 80, 99)); @@ -7221,7 +7221,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_FromElse_ForwardWithinElse) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 30, 80, 99)); @@ -7258,7 +7258,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_WithForwardToPremerge) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 30, 80, 99)); @@ -7297,7 +7297,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT( p->error(), @@ -7330,7 +7330,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT( p->error(), @@ -7369,7 +7369,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(p->error(), Eq("Block 70 is the merge block for 50 but has alternate paths " @@ -7408,7 +7408,7 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_TrueBranch_LoopBreak_Ok) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(p->error(), Eq("")); } @@ -7444,7 +7444,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(p->error(), Eq("")); } @@ -7474,7 +7474,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(p->error(), Eq("")); } @@ -7509,7 +7509,7 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_FalseBranch_LoopBreak_Ok) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(p->error(), Eq("")); } @@ -7545,7 +7545,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(p->error(), Eq("")); } @@ -7575,7 +7575,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(FlowFindIfSelectionInternalHeaders(&fe)); EXPECT_THAT(p->error(), Eq("")); } @@ -7610,7 +7610,7 @@ TEST_F(SpvParserTest, EmitBody_IfBreak_FromThen_ForwardWithinThen) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -7722,7 +7722,7 @@ TEST_F(SpvParserTest, EmitBody_IfBreak_FromElse_ForwardWithinElse) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -7849,7 +7849,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error() << assembly; auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -8017,7 +8017,7 @@ TEST_F(SpvParserTest, BlockIsContinueForMoreThanOneHeader) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); fe.RegisterBasicBlocks(); fe.ComputeBlockOrderAndPositions(); EXPECT_TRUE(fe.VerifyHeaderContinueMergeOrder()); @@ -8039,7 +8039,7 @@ TEST_F(SpvParserTest, EmitBody_If_Empty) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8075,7 +8075,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_NoElse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8123,7 +8123,7 @@ TEST_F(SpvParserTest, EmitBody_If_NoThen_Else) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8179,7 +8179,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Else) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8246,7 +8246,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Else_Premerge) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8318,7 +8318,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Premerge) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8382,7 +8382,7 @@ TEST_F(SpvParserTest, EmitBody_If_Else_Premerge) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8467,7 +8467,7 @@ TEST_F(SpvParserTest, EmitBody_If_Nest_If) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8557,7 +8557,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_TrueBackedge) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8612,7 +8612,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_FalseBackedge) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8663,7 +8663,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_BothBackedge) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8706,7 +8706,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_UnconditionalBackege) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8757,7 +8757,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_SingleBlockContinue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8822,7 +8822,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_MultiBlockContinue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8896,7 +8896,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_ContinueNestIf) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -8969,7 +8969,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_MultiBlockContinueIsEntireLoop) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -9027,7 +9027,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Never) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -9087,7 +9087,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_TrueToBody_FalseBreaks) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -9154,7 +9154,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_FalseToBody_TrueBreaks) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -9228,7 +9228,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_NestedIfContinue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -9285,7 +9285,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyAlwaysBreaks) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9334,7 +9334,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromTrue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9390,7 +9390,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromFalse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9452,7 +9452,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromTrue_Early) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9514,7 +9514,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromFalse_Early) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9567,7 +9567,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_NoCases) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9612,7 +9612,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_OneCase) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9666,7 +9666,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_TwoCases) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9726,7 +9726,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_CasesWithDup) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9792,7 +9792,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsCase_NoDupCases) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9863,7 +9863,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsCase_WithDupCase) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -9935,7 +9935,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_Case_SintValue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10005,7 +10005,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_Case_UintValue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10057,7 +10057,7 @@ TEST_F(SpvParserTest, EmitBody_Return_TopLevel) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10083,7 +10083,7 @@ TEST_F(SpvParserTest, EmitBody_Return_InsideIf) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10123,7 +10123,7 @@ TEST_F(SpvParserTest, EmitBody_Return_InsideLoop) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10153,7 +10153,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_TopLevel) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); + auto fe = p->function_emitter(200); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10192,7 +10192,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_InsideIf) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); + auto fe = p->function_emitter(200); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10249,7 +10249,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_Loop) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); + auto fe = p->function_emitter(200); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10279,7 +10279,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_TopLevel) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10305,7 +10305,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideIf) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10345,7 +10345,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideLoop) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10367,7 +10367,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_TopLevel) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10393,7 +10393,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InsideIf) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10433,7 +10433,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InsideLoop) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10463,7 +10463,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InNonVoidFunction) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); + auto fe = p->function_emitter(200); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10497,7 +10497,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_BackEdge_MultiBlockLoop) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10532,7 +10532,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_BackEdge_SingleBlockLoop) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10569,7 +10569,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_SwitchBreak_LastInCase) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10629,7 +10629,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_SwitchBreak_NotLastInCase) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10700,7 +10700,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopBreak_MultiBlockLoop_FromBody) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -10753,7 +10753,7 @@ TEST_F( OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()) << p->error(); EXPECT_THAT(p->error(), Eq("Invalid exit (40->99) from continue construct: 40 is not the " @@ -10783,7 +10783,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -10825,7 +10825,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_LastInLoopConstruct) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -10879,7 +10879,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_BeforeLast) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -10948,7 +10948,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_FromSwitch) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11018,7 +11018,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_IfBreak_FromThen) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ @@ -11061,7 +11061,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_IfBreak_FromElse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ @@ -11112,7 +11112,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_Fallthrough) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -11164,7 +11164,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_Forward) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11268,7 +11268,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Back_SingleBlock_Back) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11311,7 +11311,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11362,7 +11362,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11420,7 +11420,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11476,7 +11476,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11535,7 +11535,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -11596,7 +11596,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -11679,7 +11679,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Continue_OnTrue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -11774,7 +11774,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Continue_OnFalse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -11860,7 +11860,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Forward_OnTrue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11929,7 +11929,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Forward_OnFalse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -11995,7 +11995,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -12069,7 +12069,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -12139,7 +12139,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12197,7 +12197,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12270,7 +12270,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Continue_OnTrue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12366,7 +12366,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Continue_OnFalse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12464,7 +12464,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()) << p->error(); EXPECT_THAT( p->error(), @@ -12505,7 +12505,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Forward_OnTrue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12586,7 +12586,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Forward_OnFalse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12654,7 +12654,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Continue_FromHeader) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12711,7 +12711,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12783,7 +12783,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12871,7 +12871,7 @@ TEST_F( OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -12950,7 +12950,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopContinue_FromSwitch) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13038,7 +13038,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_IfBreak_OnTrue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13135,7 +13135,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_IfBreak_OnFalse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13231,7 +13231,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Fallthrough_OnTrue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13340,7 +13340,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Fallthrough_OnFalse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13437,7 +13437,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Forward_OnTrue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13518,7 +13518,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Forward_OnFalse) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13582,7 +13582,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_IfBreak_IfBreak_Same) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13634,7 +13634,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(FlowClassifyCFGEdges(&fe)); EXPECT_THAT( p->error(), @@ -13666,7 +13666,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Fallthrough_Fallthrough_Same) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -13733,7 +13733,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); // The weird forward branch pulls in 40 as part of the selection rather than // as a case. @@ -13758,7 +13758,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Forward_Forward_Same) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ @@ -13792,7 +13792,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("Control flow diverges at block 10 (to 20, 99) but it is not " @@ -13813,7 +13813,7 @@ TEST_F(SpvParserTest, Switch_NotAsSelectionHeader_Simple) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT( p->error(), @@ -13849,7 +13849,7 @@ TEST_F(SpvParserTest, OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT( p->error(), @@ -13884,7 +13884,7 @@ TEST_F(SpvParserTest, Switch_NotAsSelectionHeader_DefaultBranchIsContinue) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT( p->error(), @@ -13901,7 +13901,7 @@ TEST_F(SpvParserTest, SiblingLoopConstruct_Null) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_EQ(fe.SiblingLoopConstruct(nullptr), nullptr); } @@ -13916,7 +13916,7 @@ TEST_F(SpvParserTest, SiblingLoopConstruct_NotAContinue) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); ASSERT_TRUE(FlowLabelControlFlowConstructs(&fe)) << p->error(); const Construct* c = fe.GetBlockInfo(10)->construct; EXPECT_NE(c, nullptr); @@ -13941,7 +13941,7 @@ TEST_F(SpvParserTest, SiblingLoopConstruct_SingleBlockLoop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); ASSERT_TRUE(FlowLabelControlFlowConstructs(&fe)) << p->error(); const Construct* c = fe.GetBlockInfo(20)->construct; EXPECT_EQ(c->kind, Construct::kContinue); @@ -13970,7 +13970,7 @@ TEST_F(SpvParserTest, SiblingLoopConstruct_ContinueIsWholeMultiBlockLoop) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); ASSERT_TRUE(FlowLabelControlFlowConstructs(&fe)) << p->error(); const Construct* c = fe.GetBlockInfo(20)->construct; EXPECT_EQ(c->kind, Construct::kContinue); @@ -13998,7 +13998,7 @@ TEST_F(SpvParserTest, SiblingLoopConstruct_HasSiblingLoop) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); ASSERT_TRUE(FlowLabelControlFlowConstructs(&fe)) << p->error(); const Construct* c = fe.GetBlockInfo(30)->construct; EXPECT_EQ(c->kind, Construct::kContinue); @@ -14038,7 +14038,7 @@ TEST_F(SpvParserTest, EmitBody_IfSelection_TrueBranch_LoopBreak) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -14087,7 +14087,7 @@ TEST_F(SpvParserTest, EmitBody_TrueBranch_LoopContinue) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -14129,7 +14129,7 @@ TEST_F(SpvParserTest, EmitBody_TrueBranch_SwitchBreak) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Switch{ @@ -14184,7 +14184,7 @@ TEST_F(SpvParserTest, EmitBody_FalseBranch_LoopBreak) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -14236,7 +14236,7 @@ TEST_F(SpvParserTest, EmitBody_FalseBranch_LoopContinue) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ @@ -14282,7 +14282,7 @@ TEST_F(SpvParserTest, EmitBody_FalseBranch_SwitchBreak) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Switch{ @@ -14344,7 +14344,7 @@ TEST_F(SpvParserTest, EmitBody_LoopInternallyDiverge_Simple) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ diff --git a/src/reader/spirv/function_composite_test.cc b/src/reader/spirv/function_composite_test.cc index 89fa2430c2..b2db5e796d 100644 --- a/src/reader/spirv/function_composite_test.cc +++ b/src/reader/spirv/function_composite_test.cc @@ -85,7 +85,7 @@ TEST_F(SpvParserTest_Composite_Construct, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -142,7 +142,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -182,7 +182,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -212,7 +212,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -246,7 +246,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -276,7 +276,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("OpCompositeExtract %1 index value 900 is out of " "bounds for vector of 2 elements")); @@ -296,7 +296,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -326,7 +326,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()) << p->error(); EXPECT_THAT(p->error(), Eq("OpCompositeExtract %2 index value 3 is out of " "bounds for matrix of 3 elements")); @@ -346,7 +346,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -379,7 +379,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -410,7 +410,7 @@ TEST_F(SpvParserTest_CompositeExtract, RuntimeArray_IsError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()) << p->error(); EXPECT_THAT(p->error(), HasSubstr("can't do OpCompositeExtract on a runtime array: ")); @@ -430,7 +430,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -471,7 +471,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = fe.ast_body(); EXPECT_THAT(ToString(p->builder(), got), HasSubstr(R"( @@ -516,7 +516,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_IndexTooBigError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("OpCompositeExtract %2 index value 40 is out of " "bounds for structure %26 having 3 members")); @@ -538,7 +538,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -575,7 +575,7 @@ TEST_F(SpvParserTest_CompositeInsert, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ @@ -621,7 +621,7 @@ TEST_F(SpvParserTest_CompositeInsert, Vector_IndexTooBigError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("OpCompositeInsert %1 index value 900 is out of " "bounds for vector of 2 elements")); @@ -641,7 +641,7 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ @@ -691,7 +691,7 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix_IndexTooBigError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()) << p->error(); EXPECT_THAT(p->error(), Eq("OpCompositeInsert %2 index value 3 is out of " "bounds for matrix of 3 elements")); @@ -711,7 +711,7 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ @@ -761,7 +761,7 @@ TEST_F(SpvParserTest_CompositeInsert, Array) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ @@ -808,7 +808,7 @@ TEST_F(SpvParserTest_CompositeInsert, RuntimeArray_IsError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()) << p->error(); EXPECT_THAT(p->error(), HasSubstr("can't do OpCompositeInsert on a runtime array: ")); @@ -828,7 +828,7 @@ TEST_F(SpvParserTest_CompositeInsert, Struct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ @@ -902,7 +902,7 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_DifferOnlyInMemberName) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ @@ -1037,7 +1037,7 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_IndexTooBigError) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("OpCompositeInsert %2 index value 40 is out of " "bounds for structure %26 having 3 members")); @@ -1059,7 +1059,7 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_Array_Matrix_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ @@ -1130,7 +1130,7 @@ TEST_F(SpvParserTest_CopyObject, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1169,7 +1169,7 @@ TEST_F(SpvParserTest_CopyObject, Pointer) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1210,7 +1210,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 @@ -1252,7 +1252,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 @@ -1310,7 +1310,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 @@ -1340,7 +1340,7 @@ TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()) << p->error(); EXPECT_THAT(p->error(), Eq("invalid vectorshuffle ID %10: index too large: 9")); @@ -1361,7 +1361,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, SignedIndex) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(VariableConst{ @@ -1391,7 +1391,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, UnsignedIndex) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(VariableConst{ @@ -1424,7 +1424,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, Sample) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"( diff --git a/src/reader/spirv/function_conversion_test.cc b/src/reader/spirv/function_conversion_test.cc index dd0728dc6b..e92d9d1c93 100644 --- a/src/reader/spirv/function_conversion_test.cc +++ b/src/reader/spirv/function_conversion_test.cc @@ -76,7 +76,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -101,7 +101,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -130,7 +130,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_BadArg) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid")); @@ -146,7 +146,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_BadArg) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid")); @@ -162,7 +162,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_BadArg) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid")); @@ -178,7 +178,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_BadArg) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid")); @@ -194,7 +194,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_BadArgType) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), HasSubstr("operand for conversion to floating point must be " @@ -211,7 +211,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_BadArgType) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT( p->error(), @@ -230,7 +230,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -256,7 +256,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -284,7 +284,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -310,7 +310,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -337,7 +337,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_BadArgType) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("operand for conversion to floating point must be " "integral scalar or vector, but got: __bool")); @@ -353,7 +353,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_BadArgType) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("operand for conversion to floating point must be integral " @@ -371,7 +371,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -399,7 +399,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -425,7 +425,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -453,7 +453,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -478,7 +478,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_BadArgType) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("operand for conversion to signed integer must be floating " @@ -495,7 +495,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_BadArgType) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("operand for conversion to signed integer must be floating " @@ -513,7 +513,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -539,7 +539,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -567,7 +567,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -593,7 +593,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -620,7 +620,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_BadArgType) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("operand for conversion to unsigned integer must be floating " @@ -637,7 +637,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_BadArgType) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("operand for conversion to unsigned integer must be floating " @@ -655,7 +655,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToSigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -683,7 +683,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -709,7 +709,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 @@ -737,7 +737,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 diff --git a/src/reader/spirv/function_decl_test.cc b/src/reader/spirv/function_decl_test.cc index 420e520f06..cb38e8f0ed 100644 --- a/src/reader/spirv/function_decl_test.cc +++ b/src/reader/spirv/function_decl_test.cc @@ -53,7 +53,7 @@ TEST_F(SpvParserTest, Emit_VoidFunctionWithoutParams) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.Emit()); auto got = p->program().to_str(); std::string expect = R"(Module{ @@ -76,7 +76,7 @@ TEST_F(SpvParserTest, Emit_NonVoidResultType) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.Emit()); auto got = p->program().to_str(); @@ -108,7 +108,7 @@ TEST_F(SpvParserTest, Emit_MixedParamTypes) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.Emit()); auto got = p->program().to_str(); @@ -152,7 +152,7 @@ TEST_F(SpvParserTest, Emit_GenerateParamNames) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.Emit()); auto got = p->program().to_str(); diff --git a/src/reader/spirv/function_glsl_std_450_test.cc b/src/reader/spirv/function_glsl_std_450_test.cc index da3b7b0ab3..3a44c0daa0 100644 --- a/src/reader/spirv/function_glsl_std_450_test.cc +++ b/src/reader/spirv/function_glsl_std_450_test.cc @@ -181,7 +181,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -212,7 +212,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -243,7 +243,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -275,7 +275,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -307,7 +307,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -338,7 +338,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -369,7 +369,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -401,7 +401,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -433,7 +433,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -467,7 +467,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -500,7 +500,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -533,7 +533,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -565,7 +565,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -598,7 +598,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -631,7 +631,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -738,7 +738,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -770,7 +770,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -802,7 +802,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -835,7 +835,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -868,7 +868,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -902,7 +902,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -948,7 +948,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -981,7 +981,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1013,7 +1013,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1047,7 +1047,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1092,7 +1092,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SAbs) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1144,7 +1144,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMax) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1202,7 +1202,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMin) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1260,7 +1260,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SClamp) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1320,7 +1320,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMax) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1378,7 +1378,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMin) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1436,7 +1436,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UClamp) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1512,7 +1512,7 @@ TEST_P(SpvParserTest_GlslStd450_DataPacking, Valid) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( @@ -1556,7 +1556,7 @@ TEST_P(SpvParserTest_GlslStd450_DataUnpacking, Valid) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( diff --git a/src/reader/spirv/function_logical_test.cc b/src/reader/spirv/function_logical_test.cc index 1cc991709d..6c4cf6174f 100644 --- a/src/reader/spirv/function_logical_test.cc +++ b/src/reader/spirv/function_logical_test.cc @@ -200,7 +200,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -226,7 +226,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -280,7 +280,7 @@ TEST_P(SpvBinaryLogicalTest, EmitExpression) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); std::ostringstream ss; ss << R"(VariableConst{ @@ -718,7 +718,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -748,7 +748,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -786,7 +786,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -816,7 +816,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -854,7 +854,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -884,7 +884,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -922,7 +922,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -952,7 +952,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -990,7 +990,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -1020,7 +1020,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -1058,7 +1058,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -1088,7 +1088,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -1126,7 +1126,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1158,7 +1158,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1190,7 +1190,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1222,7 +1222,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1262,7 +1262,7 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1308,7 +1308,7 @@ TEST_F(SpvLogicalTest, Any) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1342,7 +1342,7 @@ TEST_F(SpvLogicalTest, All) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1376,7 +1376,7 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1406,7 +1406,7 @@ TEST_F(SpvLogicalTest, IsNan_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1440,7 +1440,7 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -1470,7 +1470,7 @@ TEST_F(SpvLogicalTest, IsInf_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ diff --git a/src/reader/spirv/function_memory_test.cc b/src/reader/spirv/function_memory_test.cc index 2870f5aa82..85d7d9bc67 100644 --- a/src/reader/spirv/function_memory_test.cc +++ b/src/reader/spirv/function_memory_test.cc @@ -44,7 +44,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreBoolConst) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} @@ -76,7 +76,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreUintConst) { OpReturn )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} @@ -104,7 +104,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreIntConst) { OpReturn )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} @@ -132,7 +132,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreFloatConst) { OpReturn )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} @@ -161,7 +161,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadBool) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ @@ -190,7 +190,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadScalar) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -232,7 +232,7 @@ TEST_F(SpvParserTest, EmitStatement_UseLoadedScalarTwice) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -270,7 +270,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) { OpReturn )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} @@ -337,7 +337,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorSwizzle) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ @@ -370,7 +370,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorConstOutOfBounds) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("Access chain %2 index %42 value 42 is out of " "bounds for vector of 4 elements")); @@ -400,7 +400,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorNonConstIndex) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ @@ -437,7 +437,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Matrix) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ @@ -480,7 +480,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Array) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ @@ -522,7 +522,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ @@ -570,7 +570,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_DifferOnlyMemberName) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ @@ -616,7 +616,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_StructNonConstIndex) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("Access chain %2 index %10 is a non-constant " "index into a structure %55")); @@ -647,7 +647,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_StructConstOutOfBounds) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), Eq("Access chain %2 index value 99 is out of bounds " "for structure %55 having 2 members")); @@ -680,7 +680,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_RuntimeArray) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ @@ -720,7 +720,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Compound_Matrix_Vector) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ @@ -755,7 +755,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_InvalidPointeeType) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_FALSE(fe.EmitBody()); EXPECT_THAT(p->error(), HasSubstr("Access chain with unknown or invalid pointee type " @@ -828,7 +828,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_NonCascaded) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(Assignment{ @@ -870,7 +870,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(Assignment{ @@ -910,7 +910,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ @@ -942,7 +942,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -997,7 +997,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithHoisting) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_EQ(ToString(p->builder(), fe.ast_body()), R"(VariableDeclStatement{ @@ -1084,7 +1084,7 @@ TEST_F(SpvParserTest, ArrayLength) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); const auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ diff --git a/src/reader/spirv/function_misc_test.cc b/src/reader/spirv/function_misc_test.cc index b523d8b471..5f4a1978ae 100644 --- a/src/reader/spirv/function_misc_test.cc +++ b/src/reader/spirv/function_misc_test.cc @@ -62,7 +62,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_BeforeFunction_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -126,7 +126,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_BeforeFunction_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -205,7 +205,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Scalar) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -266,7 +266,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -327,7 +327,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -369,7 +369,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -402,7 +402,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ @@ -434,7 +434,7 @@ TEST_F(SpvParserTestMiscInstruction, OpNop) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), Eq(R"(Return{} )")); @@ -460,7 +460,7 @@ TEST_P(SpvParserSwizzleTest, Sample) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); auto* result = fe.Swizzle(GetParam().index); if (GetParam().expected_error.empty()) { diff --git a/src/reader/spirv/function_var_test.cc b/src/reader/spirv/function_var_test.cc index 7bf5b0eba9..a66e851bf2 100644 --- a/src/reader/spirv/function_var_test.cc +++ b/src/reader/spirv/function_var_test.cc @@ -84,7 +84,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_AnonymousVars) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -123,7 +123,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_NamedVars) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -162,7 +162,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MixedTypes) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -204,7 +204,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarInitializers) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -278,7 +278,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarNullInitializers) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -338,7 +338,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -377,7 +377,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -424,7 +424,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -459,7 +459,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); auto got = ToString(p->builder(), fe.ast_body()); @@ -494,7 +494,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -529,7 +529,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -564,7 +564,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -604,7 +604,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_THAT(ToString(p->builder(), fe.ast_body()), @@ -649,7 +649,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -697,7 +697,7 @@ TEST_F(SpvParserTest, EmitStatement_CombinatorialValue_Immediate_UsedTwice) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -769,7 +769,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -868,7 +868,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -984,7 +984,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); // We don't hoist x_1 into its own mutable variable. It is emitted as @@ -1071,7 +1071,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -1158,7 +1158,7 @@ TEST_F( )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -1239,7 +1239,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); // We don't hoist x_1 into its own mutable variable. It is emitted as @@ -1315,7 +1315,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_SingleBlockLoopIndex) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -1459,7 +1459,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_MultiBlockLoopIndex) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -1617,7 +1617,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_ValueFromLoopBodyAndContinuing) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -1786,7 +1786,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromElseAndThen) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -1908,7 +1908,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromHeaderAndThen) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -2032,7 +2032,7 @@ TEST_F(SpvParserTest, )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); @@ -2122,7 +2122,7 @@ TEST_F(SpvParserTest, EmitStatement_UseInPhiCountsAsUse) { )"; auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = ToString(p->builder(), fe.ast_body()); diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h index 0c147d3141..325c750fee 100644 --- a/src/reader/spirv/parser_impl.h +++ b/src/reader/spirv/parser_impl.h @@ -537,6 +537,9 @@ class ParserImpl : Reader { return function_to_ep_info_[entry_point]; } + /// Returns the SPIR-V binary. + const std::vector& spv_binary() { return spv_binary_; } + private: /// Converts a specific SPIR-V type to a Tint type. Integer case typ::Type ConvertType(const spvtools::opt::analysis::Integer* int_ty); diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc index 088cbe4f88..2249277755 100644 --- a/src/reader/spirv/parser_impl_convert_type_test.cc +++ b/src/reader/spirv/parser_impl_convert_type_test.cc @@ -26,14 +26,14 @@ using ::testing::Eq; TEST_F(SpvParserTest, ConvertType_PreservesExistingFailure) { auto p = parser(std::vector{}); p->Fail() << "boing"; - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); EXPECT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("boing")); } TEST_F(SpvParserTest, ConvertType_RequiresInternalRepresntation) { auto p = parser(std::vector{}); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); EXPECT_EQ(type, nullptr); EXPECT_THAT( p->error(), @@ -44,7 +44,7 @@ TEST_F(SpvParserTest, ConvertType_NotAnId) { auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\"")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); EXPECT_EQ(type, nullptr); EXPECT_EQ(nullptr, type); EXPECT_THAT(p->error(), Eq("ID is not a SPIR-V type: 10")); @@ -54,7 +54,7 @@ TEST_F(SpvParserTest, ConvertType_IdExistsButIsNotAType) { auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\"")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(1); + auto* type = p->ConvertType(1); EXPECT_EQ(nullptr, type); EXPECT_THAT(p->error(), Eq("ID is not a SPIR-V type: 1")); } @@ -64,7 +64,7 @@ TEST_F(SpvParserTest, ConvertType_UnhandledType) { auto p = parser(test::Assemble("%70 = OpTypePipe WriteOnly")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(70); + auto* type = p->ConvertType(70); EXPECT_EQ(nullptr, type); EXPECT_THAT(p->error(), Eq("unknown SPIR-V type with ID 70: %70 = OpTypePipe WriteOnly")); @@ -74,7 +74,7 @@ TEST_F(SpvParserTest, ConvertType_Void) { auto p = parser(test::Assemble("%1 = OpTypeVoid")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(1); + auto* type = p->ConvertType(1); EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -83,7 +83,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) { auto p = parser(test::Assemble("%100 = OpTypeBool")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(100); + auto* type = p->ConvertType(100); EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -92,7 +92,7 @@ TEST_F(SpvParserTest, ConvertType_I32) { auto p = parser(test::Assemble("%2 = OpTypeInt 32 1")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(2); + auto* type = p->ConvertType(2); EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -101,7 +101,7 @@ TEST_F(SpvParserTest, ConvertType_U32) { auto p = parser(test::Assemble("%3 = OpTypeInt 32 0")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -110,7 +110,7 @@ TEST_F(SpvParserTest, ConvertType_F32) { auto p = parser(test::Assemble("%4 = OpTypeFloat 32")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(4); + auto* type = p->ConvertType(4); EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -119,7 +119,7 @@ TEST_F(SpvParserTest, ConvertType_BadIntWidth) { auto p = parser(test::Assemble("%5 = OpTypeInt 17 1")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(5); + auto* type = p->ConvertType(5); EXPECT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("unhandled integer width: 17")); } @@ -128,7 +128,7 @@ TEST_F(SpvParserTest, ConvertType_BadFloatWidth) { auto p = parser(test::Assemble("%6 = OpTypeFloat 19")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(6); + auto* type = p->ConvertType(6); EXPECT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("unhandled float width: 19")); } @@ -140,7 +140,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidVectorElement) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(20); + auto* type = p->ConvertType(20); EXPECT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("unknown SPIR-V type: 5")); } @@ -154,17 +154,17 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto v2xf32 = p->ConvertType(20); + auto* v2xf32 = p->ConvertType(20); EXPECT_TRUE(v2xf32->Is()); EXPECT_TRUE(v2xf32->As()->type()->Is()); EXPECT_EQ(v2xf32->As()->size(), 2u); - auto v3xf32 = p->ConvertType(30); + auto* v3xf32 = p->ConvertType(30); EXPECT_TRUE(v3xf32->Is()); EXPECT_TRUE(v3xf32->As()->type()->Is()); EXPECT_EQ(v3xf32->As()->size(), 3u); - auto v4xf32 = p->ConvertType(40); + auto* v4xf32 = p->ConvertType(40); EXPECT_TRUE(v4xf32->Is()); EXPECT_TRUE(v4xf32->As()->type()->Is()); EXPECT_EQ(v4xf32->As()->size(), 4u); @@ -181,17 +181,17 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto v2xi32 = p->ConvertType(20); + auto* v2xi32 = p->ConvertType(20); EXPECT_TRUE(v2xi32->Is()); EXPECT_TRUE(v2xi32->As()->type()->Is()); EXPECT_EQ(v2xi32->As()->size(), 2u); - auto v3xi32 = p->ConvertType(30); + auto* v3xi32 = p->ConvertType(30); EXPECT_TRUE(v3xi32->Is()); EXPECT_TRUE(v3xi32->As()->type()->Is()); EXPECT_EQ(v3xi32->As()->size(), 3u); - auto v4xi32 = p->ConvertType(40); + auto* v4xi32 = p->ConvertType(40); EXPECT_TRUE(v4xi32->Is()); EXPECT_TRUE(v4xi32->As()->type()->Is()); EXPECT_EQ(v4xi32->As()->size(), 4u); @@ -208,17 +208,17 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto v2xu32 = p->ConvertType(20); + auto* v2xu32 = p->ConvertType(20); EXPECT_TRUE(v2xu32->Is()); EXPECT_TRUE(v2xu32->As()->type()->Is()); EXPECT_EQ(v2xu32->As()->size(), 2u); - auto v3xu32 = p->ConvertType(30); + auto* v3xu32 = p->ConvertType(30); EXPECT_TRUE(v3xu32->Is()); EXPECT_TRUE(v3xu32->As()->type()->Is()); EXPECT_EQ(v3xu32->As()->size(), 3u); - auto v4xu32 = p->ConvertType(40); + auto* v4xu32 = p->ConvertType(40); EXPECT_TRUE(v4xu32->Is()); EXPECT_TRUE(v4xu32->As()->type()->Is()); EXPECT_EQ(v4xu32->As()->size(), 4u); @@ -234,7 +234,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidMatrixElement) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(20); + auto* type = p->ConvertType(20); EXPECT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("unknown SPIR-V type: 5")); } @@ -260,55 +260,55 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto m22 = p->ConvertType(22); + auto* m22 = p->ConvertType(22); EXPECT_TRUE(m22->Is()); EXPECT_TRUE(m22->As()->type()->Is()); EXPECT_EQ(m22->As()->rows(), 2u); EXPECT_EQ(m22->As()->columns(), 2u); - auto m23 = p->ConvertType(23); + auto* m23 = p->ConvertType(23); EXPECT_TRUE(m23->Is()); EXPECT_TRUE(m23->As()->type()->Is()); EXPECT_EQ(m23->As()->rows(), 2u); EXPECT_EQ(m23->As()->columns(), 3u); - auto m24 = p->ConvertType(24); + auto* m24 = p->ConvertType(24); EXPECT_TRUE(m24->Is()); EXPECT_TRUE(m24->As()->type()->Is()); EXPECT_EQ(m24->As()->rows(), 2u); EXPECT_EQ(m24->As()->columns(), 4u); - auto m32 = p->ConvertType(32); + auto* m32 = p->ConvertType(32); EXPECT_TRUE(m32->Is()); EXPECT_TRUE(m32->As()->type()->Is()); EXPECT_EQ(m32->As()->rows(), 3u); EXPECT_EQ(m32->As()->columns(), 2u); - auto m33 = p->ConvertType(33); + auto* m33 = p->ConvertType(33); EXPECT_TRUE(m33->Is()); EXPECT_TRUE(m33->As()->type()->Is()); EXPECT_EQ(m33->As()->rows(), 3u); EXPECT_EQ(m33->As()->columns(), 3u); - auto m34 = p->ConvertType(34); + auto* m34 = p->ConvertType(34); EXPECT_TRUE(m34->Is()); EXPECT_TRUE(m34->As()->type()->Is()); EXPECT_EQ(m34->As()->rows(), 3u); EXPECT_EQ(m34->As()->columns(), 4u); - auto m42 = p->ConvertType(42); + auto* m42 = p->ConvertType(42); EXPECT_TRUE(m42->Is()); EXPECT_TRUE(m42->As()->type()->Is()); EXPECT_EQ(m42->As()->rows(), 4u); EXPECT_EQ(m42->As()->columns(), 2u); - auto m43 = p->ConvertType(43); + auto* m43 = p->ConvertType(43); EXPECT_TRUE(m43->Is()); EXPECT_TRUE(m43->As()->type()->Is()); EXPECT_EQ(m43->As()->rows(), 4u); EXPECT_EQ(m43->As()->columns(), 3u); - auto m44 = p->ConvertType(44); + auto* m44 = p->ConvertType(44); EXPECT_TRUE(m44->Is()); EXPECT_TRUE(m44->As()->type()->Is()); EXPECT_EQ(m44->As()->rows(), 4u); @@ -324,7 +324,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->UnwrapAliasIfNeeded()->Is()); auto* arr_type = type->UnwrapAliasIfNeeded()->As(); @@ -345,7 +345,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_InvalidDecoration) { %10 = OpTypeRuntimeArray %uint )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); EXPECT_EQ(type, nullptr); EXPECT_THAT( p->error(), @@ -359,7 +359,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) { %10 = OpTypeRuntimeArray %uint )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); auto* arr_type = type->UnwrapAliasIfNeeded()->As(); EXPECT_TRUE(arr_type->IsRuntimeArray()); @@ -378,7 +378,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_ZeroIsError) { %10 = OpTypeRuntimeArray %uint )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); EXPECT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("invalid array type ID 10: ArrayStride can't be 0")); @@ -393,7 +393,7 @@ TEST_F(SpvParserTest, %10 = OpTypeRuntimeArray %uint )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); EXPECT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("invalid array type ID 10: multiple ArrayStride decorations")); @@ -407,7 +407,7 @@ TEST_F(SpvParserTest, ConvertType_Array) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->Is()); auto* arr_type = type->As(); @@ -430,7 +430,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantValue) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("Array type 10 length is a specialization constant")); @@ -445,7 +445,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantExpr) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("Array type 10 length is a specialization constant")); @@ -463,7 +463,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadTooBig) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_EQ(type, nullptr); // TODO(dneto): Right now it's rejected earlier in the flow because // we can't even utter the uint64 type. @@ -478,7 +478,7 @@ TEST_F(SpvParserTest, ConvertType_Array_InvalidDecoration) { %10 = OpTypeArray %uint %uint_5 )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); EXPECT_EQ(type, nullptr); EXPECT_THAT( p->error(), @@ -494,7 +494,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->UnwrapAliasIfNeeded()->Is()); auto* arr_type = type->UnwrapAliasIfNeeded()->As(); @@ -517,7 +517,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_ZeroIsError) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("invalid array type ID 10: ArrayStride can't be 0")); @@ -533,7 +533,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_SpecifiedTwiceIsError) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("invalid array type ID 10: multiple ArrayStride decorations")); @@ -548,7 +548,7 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) { EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->RegisterUserAndStructMemberNames()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->Is()); @@ -569,7 +569,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) { EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->RegisterUserAndStructMemberNames()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->Is()); @@ -594,7 +594,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) { EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->RegisterUserAndStructMemberNames()); - auto type = p->ConvertType(10); + auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->Is()); @@ -621,7 +621,7 @@ TEST_F(SpvParserTest, ConvertType_InvalidPointeetype) { )")); EXPECT_TRUE(p->BuildInternalModule()) << p->error(); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_EQ(type, nullptr); EXPECT_THAT(p->error(), Eq("SPIR-V pointer type with ID 3 has invalid pointee type 42")); @@ -644,7 +644,7 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -660,7 +660,7 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -676,7 +676,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -692,7 +692,7 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -708,7 +708,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -724,7 +724,7 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -740,7 +740,7 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -756,7 +756,7 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -772,7 +772,7 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_TRUE(type->Is()); auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); @@ -790,7 +790,7 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(3); + auto* type = p->ConvertType(3); EXPECT_NE(type, nullptr); EXPECT_TRUE(type->Is()); @@ -814,7 +814,7 @@ TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(1); + auto* type = p->ConvertType(1); EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -827,7 +827,7 @@ TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(1); + auto* type = p->ConvertType(1); EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -840,7 +840,7 @@ TEST_F(SpvParserTest, ConvertType_SampledImage_PretendVoid) { )")); EXPECT_TRUE(p->BuildInternalModule()); - auto type = p->ConvertType(1); + auto* type = p->ConvertType(1); EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } diff --git a/src/reader/spirv/parser_impl_handle_test.cc b/src/reader/spirv/parser_impl_handle_test.cc index 89c23e6bd7..757d18bd5c 100644 --- a/src/reader/spirv/parser_impl_handle_test.cc +++ b/src/reader/spirv/parser_impl_handle_test.cc @@ -4827,7 +4827,7 @@ TEST_P(SpvParserTest_ImageCoordsTest, MakeCoordinateOperandsForImageAccess) { EXPECT_THAT(p->error(), StartsWith(GetParam().expected_error)) << assembly; } else { EXPECT_TRUE(p->error().empty()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); // We actually have to generate the module to cache expressions for the // result IDs, particularly the OpCopyObject fe.Emit(); @@ -5691,7 +5691,7 @@ TEST_F(SpvParserTest, NeverGenerateConstDeclForHandle_UseVariableDirectly) { )"; auto p = parser(test::Assemble(assembly)); EXPECT_TRUE(p->BuildAndParseInternalModule()) << assembly; - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(p->error().empty()) << p->error(); const auto got = ToString(p->builder(), fe.ast_body()); diff --git a/src/reader/spirv/parser_impl_module_var_test.cc b/src/reader/spirv/parser_impl_module_var_test.cc index bb5d9f42af..03a6801d1b 100644 --- a/src/reader/spirv/parser_impl_module_var_test.cc +++ b/src/reader/spirv/parser_impl_module_var_test.cc @@ -1999,7 +1999,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_UsedInFunction) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); - FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); + auto fe = p->function_emitter(100); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(p->error().empty()); diff --git a/src/reader/spirv/parser_impl_test_helper.h b/src/reader/spirv/parser_impl_test_helper.h index 298012f58a..0d9dcc6a03 100644 --- a/src/reader/spirv/parser_impl_test_helper.h +++ b/src/reader/spirv/parser_impl_test_helper.h @@ -17,15 +17,102 @@ #include #include +#include +#include #include #include "gtest/gtest.h" +#include "source/opt/ir_context.h" #include "src/demangler.h" +#include "src/reader/spirv/fail_stream.h" +#include "src/reader/spirv/function.h" +#include "src/reader/spirv/namer.h" #include "src/reader/spirv/parser_impl.h" +#include "src/reader/spirv/usage.h" namespace tint { namespace reader { namespace spirv { +namespace test { + +// A test class that wraps ParseImpl +class ParserImplWrapperForTest { + public: + explicit ParserImplWrapperForTest(const std::vector& input) + : impl_(input) {} + + // Returns a new function emitter for the given function ID. + // Assumes ParserImpl::BuildInternalRepresentation has been run and + // succeeded. + FunctionEmitter function_emitter(uint32_t function_id) { + auto* spirv_function = impl_.ir_context()->GetFunction(function_id); + return FunctionEmitter(&impl_, *spirv_function); + } + + // Forward methods used by tests to the real implementation. + bool Parse() { return impl_.Parse(); } + Program program() { return impl_.program(); } + Namer& namer() { return impl_.namer(); } + ProgramBuilder& builder() { return impl_.builder(); } + const std::string error() { return impl_.error(); } + FailStream& Fail() { return impl_.Fail(); } + spvtools::opt::IRContext* ir_context() { return impl_.ir_context(); } + bool BuildInternalModule() { return impl_.BuildInternalModule(); } + bool BuildAndParseInternalModuleExceptFunctions() { + return impl_.BuildAndParseInternalModuleExceptFunctions(); + } + bool BuildAndParseInternalModule() { + return impl_.BuildAndParseInternalModule(); + } + bool RegisterUserAndStructMemberNames() { + return impl_.RegisterUserAndStructMemberNames(); + } + const std::unordered_set& glsl_std_450_imports() const { + return impl_.glsl_std_450_imports(); + } + sem::Type* ConvertType(uint32_t id) { return impl_.ConvertType(id); } + DecorationList GetDecorationsFor(uint32_t id) const { + return impl_.GetDecorationsFor(id); + } + DecorationList GetDecorationsForMember(uint32_t id, + uint32_t member_index) const { + return impl_.GetDecorationsForMember(id, member_index); + } + ast::Decoration* ConvertMemberDecoration(uint32_t struct_type_id, + uint32_t member_index, + const Decoration& decoration) { + return impl_.ConvertMemberDecoration(struct_type_id, member_index, + decoration); + } + const spvtools::opt::Instruction* GetMemoryObjectDeclarationForHandle( + uint32_t id, + bool follow_image) { + return impl_.GetMemoryObjectDeclarationForHandle(id, follow_image); + } + const std::vector& GetEntryPointInfo(uint32_t entry_point) { + return impl_.GetEntryPointInfo(entry_point); + } + Usage GetHandleUsage(uint32_t id) const { return impl_.GetHandleUsage(id); } + bool RegisterHandleUsage() { return impl_.RegisterHandleUsage(); } + bool EmitModuleScopeVariables() { return impl_.EmitModuleScopeVariables(); } + const spvtools::opt::Instruction* GetInstructionForTest(uint32_t id) const { + return impl_.GetInstructionForTest(id); + } + bool RegisterTypes() { return impl_.RegisterTypes(); } + const ParserImpl::BuiltInPositionInfo& GetBuiltInPositionInfo() { + return impl_.GetBuiltInPositionInfo(); + } + Source GetSourceForResultIdForTest(uint32_t id) const { + return impl_.GetSourceForResultIdForTest(id); + } + void SetHLSLStylePipelineIO() { impl_.SetHLSLStylePipelineIO(); } + bool UseHLSLStylePipelineIO() const { return impl_.UseHLSLStylePipelineIO(); } + + private: + ParserImpl impl_; +}; + +} // namespace test /// SPIR-V Parser test class template @@ -37,23 +124,14 @@ class SpvParserTestBase : public T { /// Retrieves the parser from the helper /// @param input the SPIR-V binary to parse /// @returns a parser for the given binary - std::unique_ptr parser(const std::vector& input) { - auto parser = std::make_unique(input); + std::unique_ptr parser( + const std::vector& input) { + auto parser = std::make_unique(input); // Don't run the Resolver when building the program. // We're not interested in type information with these tests. parser->builder().SetResolveOnBuild(false); return parser; } - - /// Gets the internal representation of the function with the given ID. - /// Assumes ParserImpl::BuildInternalRepresentation has been run and - /// succeeded. - /// @param parser the parser - /// @param id the SPIR-V ID of the function - /// @returns the internal representation of the function - spvtools::opt::Function* spirv_function(ParserImpl* parser, uint32_t id) { - return parser->ir_context()->GetFunction(id); - } }; // Use this form when you don't need to template any further. diff --git a/src/reader/spirv/spirv_tools_helpers_test.cc b/src/reader/spirv/spirv_tools_helpers_test.cc index a74f2df930..0c97d0f904 100644 --- a/src/reader/spirv/spirv_tools_helpers_test.cc +++ b/src/reader/spirv/spirv_tools_helpers_test.cc @@ -74,7 +74,8 @@ std::string Disassemble(const std::vector& spirv_module) { }); std::string result; - const auto success = tools.Disassemble(spirv_module, &result); + const auto success = tools.Disassemble( + spirv_module, &result, 0 /* no friendly names, so we get raw IDs */); EXPECT_TRUE(success) << errors.str(); return result;