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 <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
David Neto 2021-05-04 20:17:41 +00:00 committed by Commit Bot service account
parent c6ed25cd3e
commit df48b955b2
20 changed files with 761 additions and 659 deletions

View File

@ -743,6 +743,23 @@ FunctionEmitter::FunctionEmitter(ParserImpl* pi,
const spvtools::opt::Function& function) const spvtools::opt::Function& function)
: FunctionEmitter(pi, function, nullptr) {} : 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::~FunctionEmitter() = default;
FunctionEmitter::StatementBlock::StatementBlock( FunctionEmitter::StatementBlock::StatementBlock(

View File

@ -397,6 +397,9 @@ class FunctionEmitter {
FunctionEmitter(ParserImpl* pi, FunctionEmitter(ParserImpl* pi,
const spvtools::opt::Function& function, const spvtools::opt::Function& function,
const EntryPointInfo* ep_info); 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 /// Destructor
~FunctionEmitter(); ~FunctionEmitter();

View File

@ -146,7 +146,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -172,7 +172,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -200,7 +200,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -228,7 +228,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -258,7 +258,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -288,7 +288,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -320,7 +320,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -352,7 +352,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -386,7 +386,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -412,7 +412,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -467,7 +467,7 @@ TEST_P(SpvBinaryArithTest, EmitExpression) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
std::ostringstream ss; std::ostringstream ss;
ss << R"(VariableConst{ ss << R"(VariableConst{
@ -512,7 +512,7 @@ TEST_P(SpvBinaryArithGeneralTest, EmitExpression) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
std::ostringstream ss; std::ostringstream ss;
ss << R"(VariableConst{ ss << R"(VariableConst{
@ -990,7 +990,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Scalar_UnsignedResult) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -1025,7 +1025,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -1135,7 +1135,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Scalar_UnsignedResult) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -1170,7 +1170,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -1222,7 +1222,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_10 x_10
@ -1250,7 +1250,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_10 x_10
@ -1278,7 +1278,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_10 x_10
@ -1306,7 +1306,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_10 x_10
@ -1334,7 +1334,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_10 x_10
@ -1362,7 +1362,7 @@ TEST_F(SpvBinaryArithTestBasic, Dot) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_3 x_3
@ -1394,7 +1394,7 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(got, HasSubstr(R"(VariableConst{ EXPECT_THAT(got, HasSubstr(R"(VariableConst{
@ -1520,7 +1520,7 @@ TEST_P(SpvBinaryDerivativeTest, Derivatives) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_2 x_2
@ -1566,7 +1566,7 @@ TEST_F(SpvUnaryArithTest, Transpose_2x2) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto* expected = R"( const auto* expected = R"(
VariableDeclStatement{ VariableDeclStatement{
@ -1599,7 +1599,7 @@ TEST_F(SpvUnaryArithTest, Transpose_2x3) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
// Note, in the AST dump mat_2_3 means 2 rows and 3 columns. // Note, in the AST dump mat_2_3 means 2 rows and 3 columns.
// So the column vectors have 2 elements. // So the column vectors have 2 elements.
@ -1635,7 +1635,7 @@ TEST_F(SpvUnaryArithTest, Transpose_3x2) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto* expected = R"( const auto* expected = R"(
VariableDeclStatement{ VariableDeclStatement{

View File

@ -149,7 +149,7 @@ TEST_P(SpvBinaryBitTest, EmitExpression) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
std::ostringstream ss; std::ostringstream ss;
ss << R"(VariableConst{ ss << R"(VariableConst{
@ -194,7 +194,7 @@ TEST_P(SpvBinaryBitGeneralTest, EmitExpression) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
std::ostringstream ss; std::ostringstream ss;
ss << R"(VariableConst{ ss << R"(VariableConst{
@ -692,7 +692,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -718,7 +718,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -746,7 +746,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -774,7 +774,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -800,7 +800,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -830,7 +830,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -862,7 +862,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -893,7 +893,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -947,7 +947,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Uint) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -975,7 +975,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Int) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1005,7 +1005,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Uint) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1035,7 +1035,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Int) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1063,7 +1063,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_UintVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1091,7 +1091,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_IntVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1121,7 +1121,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_UintVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1151,7 +1151,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_IntVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1179,7 +1179,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Uint) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1207,7 +1207,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Int) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1237,7 +1237,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Uint) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1267,7 +1267,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Int) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1295,7 +1295,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_UintVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1323,7 +1323,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_IntVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1353,7 +1353,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_UintVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1383,7 +1383,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_IntVector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(

View File

@ -85,7 +85,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) {
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ 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_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Return{ 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(); 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(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -176,7 +176,7 @@ Assignment{
Return{})")); Return{})"));
} }
{ {
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50)); auto fe = p->function_emitter(50);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Return{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Return{
{ {

File diff suppressed because it is too large Load Diff

View File

@ -85,7 +85,7 @@ TEST_F(SpvParserTest_Composite_Construct, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -142,7 +142,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -182,7 +182,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -212,7 +212,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -246,7 +246,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -276,7 +276,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), Eq("OpCompositeExtract %1 index value 900 is out of " EXPECT_THAT(p->error(), Eq("OpCompositeExtract %1 index value 900 is out of "
"bounds for vector of 2 elements")); "bounds for vector of 2 elements"));
@ -296,7 +296,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -326,7 +326,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody()) << p->error();
EXPECT_THAT(p->error(), Eq("OpCompositeExtract %2 index value 3 is out of " EXPECT_THAT(p->error(), Eq("OpCompositeExtract %2 index value 3 is out of "
"bounds for matrix of 3 elements")); "bounds for matrix of 3 elements"));
@ -346,7 +346,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -379,7 +379,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -410,7 +410,7 @@ TEST_F(SpvParserTest_CompositeExtract, RuntimeArray_IsError) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody()) << p->error();
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
HasSubstr("can't do OpCompositeExtract on a runtime array: ")); HasSubstr("can't do OpCompositeExtract on a runtime array: "));
@ -430,7 +430,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -471,7 +471,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = fe.ast_body(); auto got = fe.ast_body();
EXPECT_THAT(ToString(p->builder(), got), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), got), HasSubstr(R"(
@ -516,7 +516,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_IndexTooBigError) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), Eq("OpCompositeExtract %2 index value 40 is out of " EXPECT_THAT(p->error(), Eq("OpCompositeExtract %2 index value 40 is out of "
"bounds for structure %26 having 3 members")); "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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -575,7 +575,7 @@ TEST_F(SpvParserTest_CompositeInsert, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto body_str = ToString(p->builder(), fe.ast_body()); auto body_str = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
@ -621,7 +621,7 @@ TEST_F(SpvParserTest_CompositeInsert, Vector_IndexTooBigError) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), Eq("OpCompositeInsert %1 index value 900 is out of " EXPECT_THAT(p->error(), Eq("OpCompositeInsert %1 index value 900 is out of "
"bounds for vector of 2 elements")); "bounds for vector of 2 elements"));
@ -641,7 +641,7 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto body_str = ToString(p->builder(), fe.ast_body()); auto body_str = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
@ -691,7 +691,7 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix_IndexTooBigError) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody()) << p->error();
EXPECT_THAT(p->error(), Eq("OpCompositeInsert %2 index value 3 is out of " EXPECT_THAT(p->error(), Eq("OpCompositeInsert %2 index value 3 is out of "
"bounds for matrix of 3 elements")); "bounds for matrix of 3 elements"));
@ -711,7 +711,7 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto body_str = ToString(p->builder(), fe.ast_body()); auto body_str = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
@ -761,7 +761,7 @@ TEST_F(SpvParserTest_CompositeInsert, Array) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto body_str = ToString(p->builder(), fe.ast_body()); auto body_str = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
@ -808,7 +808,7 @@ TEST_F(SpvParserTest_CompositeInsert, RuntimeArray_IsError) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody()) << p->error();
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
HasSubstr("can't do OpCompositeInsert on a runtime array: ")); HasSubstr("can't do OpCompositeInsert on a runtime array: "));
@ -828,7 +828,7 @@ TEST_F(SpvParserTest_CompositeInsert, Struct) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto body_str = ToString(p->builder(), fe.ast_body()); auto body_str = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
@ -902,7 +902,7 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_DifferOnlyInMemberName) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto body_str = ToString(p->builder(), fe.ast_body()); auto body_str = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
@ -1037,7 +1037,7 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_IndexTooBigError) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), Eq("OpCompositeInsert %2 index value 40 is out of " EXPECT_THAT(p->error(), Eq("OpCompositeInsert %2 index value 40 is out of "
"bounds for structure %26 having 3 members")); "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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto body_str = ToString(p->builder(), fe.ast_body()); auto body_str = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
@ -1130,7 +1130,7 @@ TEST_F(SpvParserTest_CopyObject, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1169,7 +1169,7 @@ TEST_F(SpvParserTest_CopyObject, Pointer) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1210,7 +1210,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_10 x_10
@ -1252,7 +1252,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_10 x_10
@ -1310,7 +1310,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_10 x_10
@ -1340,7 +1340,7 @@ TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_FALSE(fe.EmitBody()) << p->error();
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("invalid vectorshuffle ID %10: index too large: 9")); Eq("invalid vectorshuffle ID %10: index too large: 9"));
@ -1361,7 +1361,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, SignedIndex) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto got = ToString(p->builder(), fe.ast_body()); const auto got = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(got, HasSubstr(R"(VariableConst{ EXPECT_THAT(got, HasSubstr(R"(VariableConst{
@ -1391,7 +1391,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, UnsignedIndex) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto got = ToString(p->builder(), fe.ast_body()); const auto got = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(got, HasSubstr(R"(VariableConst{ EXPECT_THAT(got, HasSubstr(R"(VariableConst{
@ -1424,7 +1424,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, Sample) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto got = ToString(p->builder(), fe.ast_body()); const auto got = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(got, HasSubstr(R"( EXPECT_THAT(got, HasSubstr(R"(

View File

@ -76,7 +76,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -101,7 +101,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -130,7 +130,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_BadArg) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid")); HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid"));
@ -146,7 +146,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_BadArg) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid")); HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid"));
@ -162,7 +162,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_BadArg) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid")); HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid"));
@ -178,7 +178,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_BadArg) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid")); 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
HasSubstr("operand for conversion to floating point must be " 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT( EXPECT_THAT(
p->error(), p->error(),
@ -230,7 +230,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -256,7 +256,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -284,7 +284,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -310,7 +310,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -337,7 +337,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_BadArgType) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), Eq("operand for conversion to floating point must be " EXPECT_THAT(p->error(), Eq("operand for conversion to floating point must be "
"integral scalar or vector, but got: __bool")); "integral scalar or vector, but got: __bool"));
@ -353,7 +353,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_BadArgType) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("operand for conversion to floating point must be integral " 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -399,7 +399,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -425,7 +425,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -453,7 +453,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -478,7 +478,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_BadArgType) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("operand for conversion to signed integer must be floating " 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("operand for conversion to signed integer must be floating " 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -539,7 +539,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -567,7 +567,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -593,7 +593,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -620,7 +620,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_BadArgType) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("operand for conversion to unsigned integer must be floating " 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("operand for conversion to unsigned integer must be floating " 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -683,7 +683,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -709,7 +709,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1
@ -737,7 +737,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{
x_1 x_1

View File

@ -53,7 +53,7 @@ TEST_F(SpvParserTest, Emit_VoidFunctionWithoutParams) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.Emit()); EXPECT_TRUE(fe.Emit());
auto got = p->program().to_str(); auto got = p->program().to_str();
std::string expect = R"(Module{ std::string expect = R"(Module{
@ -76,7 +76,7 @@ TEST_F(SpvParserTest, Emit_NonVoidResultType) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.Emit()); EXPECT_TRUE(fe.Emit());
auto got = p->program().to_str(); auto got = p->program().to_str();
@ -108,7 +108,7 @@ TEST_F(SpvParserTest, Emit_MixedParamTypes) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.Emit()); EXPECT_TRUE(fe.Emit());
auto got = p->program().to_str(); auto got = p->program().to_str();
@ -152,7 +152,7 @@ TEST_F(SpvParserTest, Emit_GenerateParamNames) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.Emit()); EXPECT_TRUE(fe.Emit());
auto got = p->program().to_str(); auto got = p->program().to_str();

View File

@ -181,7 +181,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -212,7 +212,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -243,7 +243,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -275,7 +275,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -307,7 +307,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -338,7 +338,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -369,7 +369,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -401,7 +401,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -433,7 +433,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -467,7 +467,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -500,7 +500,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -533,7 +533,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -565,7 +565,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -598,7 +598,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -631,7 +631,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -738,7 +738,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -770,7 +770,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -802,7 +802,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -835,7 +835,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -868,7 +868,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -902,7 +902,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -948,7 +948,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -981,7 +981,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1013,7 +1013,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1047,7 +1047,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1092,7 +1092,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SAbs) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1144,7 +1144,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMax) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
auto body = ToString(p->builder(), fe.ast_body()); auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1202,7 +1202,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMin) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
auto body = ToString(p->builder(), fe.ast_body()); auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1260,7 +1260,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SClamp) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
auto body = ToString(p->builder(), fe.ast_body()); auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1320,7 +1320,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMax) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
auto body = ToString(p->builder(), fe.ast_body()); auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1378,7 +1378,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMin) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
auto body = ToString(p->builder(), fe.ast_body()); auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1436,7 +1436,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UClamp) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
auto body = ToString(p->builder(), fe.ast_body()); auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1512,7 +1512,7 @@ TEST_P(SpvParserTest_GlslStd450_DataPacking, Valid) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(
@ -1556,7 +1556,7 @@ TEST_P(SpvParserTest_GlslStd450_DataUnpacking, Valid) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
const auto body = ToString(p->builder(), fe.ast_body()); const auto body = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body, HasSubstr(R"( EXPECT_THAT(body, HasSubstr(R"(

View File

@ -200,7 +200,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -226,7 +226,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -280,7 +280,7 @@ TEST_P(SpvBinaryLogicalTest, EmitExpression) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << "\n" << p->error() << "\n"
<< assembly; << assembly;
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
std::ostringstream ss; std::ostringstream ss;
ss << R"(VariableConst{ ss << R"(VariableConst{
@ -718,7 +718,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -748,7 +748,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -786,7 +786,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -816,7 +816,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -854,7 +854,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -884,7 +884,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -922,7 +922,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -952,7 +952,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -990,7 +990,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -1020,7 +1020,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -1058,7 +1058,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -1088,7 +1088,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -1126,7 +1126,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1158,7 +1158,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1190,7 +1190,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1222,7 +1222,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1262,7 +1262,7 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1308,7 +1308,7 @@ TEST_F(SpvLogicalTest, Any) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1342,7 +1342,7 @@ TEST_F(SpvLogicalTest, All) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1376,7 +1376,7 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1406,7 +1406,7 @@ TEST_F(SpvLogicalTest, IsNan_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1440,7 +1440,7 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -1470,7 +1470,7 @@ TEST_F(SpvLogicalTest, IsInf_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{

View File

@ -44,7 +44,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreBoolConst) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
Identifier[not set]{x_1} Identifier[not set]{x_1}
@ -76,7 +76,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreUintConst) {
OpReturn OpReturn
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
Identifier[not set]{x_1} Identifier[not set]{x_1}
@ -104,7 +104,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreIntConst) {
OpReturn OpReturn
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
Identifier[not set]{x_1} Identifier[not set]{x_1}
@ -132,7 +132,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreFloatConst) {
OpReturn OpReturn
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
Identifier[not set]{x_1} Identifier[not set]{x_1}
@ -161,7 +161,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadBool) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(
VariableConst{ VariableConst{
@ -190,7 +190,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadScalar) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -232,7 +232,7 @@ TEST_F(SpvParserTest, EmitStatement_UseLoadedScalarTwice) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -270,7 +270,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) {
OpReturn OpReturn
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
Identifier[not set]{x_1} Identifier[not set]{x_1}
@ -337,7 +337,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorSwizzle) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()); EXPECT_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
MemberAccessor[not set]{ MemberAccessor[not set]{
@ -370,7 +370,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorConstOutOfBounds) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), Eq("Access chain %2 index %42 value 42 is out of " EXPECT_THAT(p->error(), Eq("Access chain %2 index %42 value 42 is out of "
"bounds for vector of 4 elements")); "bounds for vector of 4 elements"));
@ -400,7 +400,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorNonConstIndex) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()); EXPECT_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
ArrayAccessor[not set]{ ArrayAccessor[not set]{
@ -437,7 +437,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Matrix) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()); EXPECT_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
ArrayAccessor[not set]{ ArrayAccessor[not set]{
@ -480,7 +480,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Array) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()); EXPECT_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
ArrayAccessor[not set]{ ArrayAccessor[not set]{
@ -522,7 +522,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()); EXPECT_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
MemberAccessor[not set]{ MemberAccessor[not set]{
@ -570,7 +570,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_DifferOnlyMemberName) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()); EXPECT_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
MemberAccessor[not set]{ MemberAccessor[not set]{
@ -616,7 +616,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_StructNonConstIndex) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), Eq("Access chain %2 index %10 is a non-constant " EXPECT_THAT(p->error(), Eq("Access chain %2 index %10 is a non-constant "
"index into a structure %55")); "index into a structure %55"));
@ -647,7 +647,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_StructConstOutOfBounds) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), Eq("Access chain %2 index value 99 is out of bounds " EXPECT_THAT(p->error(), Eq("Access chain %2 index value 99 is out of bounds "
"for structure %55 having 2 members")); "for structure %55 having 2 members"));
@ -680,7 +680,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_RuntimeArray) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()); EXPECT_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
ArrayAccessor[not set]{ ArrayAccessor[not set]{
@ -720,7 +720,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Compound_Matrix_Vector) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()); EXPECT_TRUE(fe.EmitBody());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
MemberAccessor[not set]{ MemberAccessor[not set]{
@ -755,7 +755,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_InvalidPointeeType) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << assembly << p->error();
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_FALSE(fe.EmitBody()); EXPECT_FALSE(fe.EmitBody());
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
HasSubstr("Access chain with unknown or invalid pointee type " 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); 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_TRUE(fe.EmitBody()) << p->error();
const auto got = ToString(p->builder(), fe.ast_body()); const auto got = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(got, HasSubstr(R"(Assignment{ EXPECT_THAT(got, HasSubstr(R"(Assignment{
@ -870,7 +870,7 @@ TEST_F(SpvParserTest,
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); 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_TRUE(fe.EmitBody()) << p->error();
const auto got = ToString(p->builder(), fe.ast_body()); const auto got = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(got, HasSubstr(R"(Assignment{ EXPECT_THAT(got, HasSubstr(R"(Assignment{
@ -910,7 +910,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{
ArrayAccessor[not set]{ ArrayAccessor[not set]{
@ -942,7 +942,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -997,7 +997,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithHoisting) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_EQ(ToString(p->builder(), fe.ast_body()), EXPECT_EQ(ToString(p->builder(), fe.ast_body()),
R"(VariableDeclStatement{ R"(VariableDeclStatement{
@ -1084,7 +1084,7 @@ TEST_F(SpvParserTest, ArrayLength) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); 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_TRUE(fe.EmitBody()) << p->error();
const auto body_str = ToString(p->builder(), fe.ast_body()); const auto body_str = ToString(p->builder(), fe.ast_body());
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{

View File

@ -62,7 +62,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_BeforeFunction_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -126,7 +126,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_BeforeFunction_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -205,7 +205,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Scalar) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -266,7 +266,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -327,7 +327,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -369,7 +369,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -402,7 +402,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
HasSubstr(R"(VariableDeclStatement{ HasSubstr(R"(VariableDeclStatement{
@ -434,7 +434,7 @@ TEST_F(SpvParserTestMiscInstruction, OpNop) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< p->error() << assembly; << 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_TRUE(fe.EmitBody()) << p->error();
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), Eq(R"(Return{} 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); 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); auto* result = fe.Swizzle(GetParam().index);
if (GetParam().expected_error.empty()) { if (GetParam().expected_error.empty()) {

View File

@ -84,7 +84,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_AnonymousVars) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -123,7 +123,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_NamedVars) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -162,7 +162,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MixedTypes) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -204,7 +204,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarInitializers) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -278,7 +278,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarNullInitializers) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -338,7 +338,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -377,7 +377,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -424,7 +424,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -459,7 +459,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -494,7 +494,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -529,7 +529,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -564,7 +564,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -604,7 +604,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
EXPECT_THAT(ToString(p->builder(), fe.ast_body()), EXPECT_THAT(ToString(p->builder(), fe.ast_body()),
@ -649,7 +649,7 @@ TEST_F(SpvParserTest,
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -769,7 +769,7 @@ TEST_F(SpvParserTest,
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -868,7 +868,7 @@ TEST_F(
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -984,7 +984,7 @@ TEST_F(
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
// We don't hoist x_1 into its own mutable variable. It is emitted as // 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -1158,7 +1158,7 @@ TEST_F(
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -1239,7 +1239,7 @@ TEST_F(SpvParserTest,
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
// We don't hoist x_1 into its own mutable variable. It is emitted as // 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)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -1459,7 +1459,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_MultiBlockLoopIndex) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -1617,7 +1617,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_ValueFromLoopBodyAndContinuing) {
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
<< assembly << p->error(); << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -1786,7 +1786,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromElseAndThen) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -1908,7 +1908,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromHeaderAndThen) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -2032,7 +2032,7 @@ TEST_F(SpvParserTest,
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());
@ -2122,7 +2122,7 @@ TEST_F(SpvParserTest, EmitStatement_UseInPhiCountsAsUse) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << 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_TRUE(fe.EmitBody()) << p->error();
auto got = ToString(p->builder(), fe.ast_body()); auto got = ToString(p->builder(), fe.ast_body());

View File

@ -537,6 +537,9 @@ class ParserImpl : Reader {
return function_to_ep_info_[entry_point]; return function_to_ep_info_[entry_point];
} }
/// Returns the SPIR-V binary.
const std::vector<uint32_t>& spv_binary() { return spv_binary_; }
private: private:
/// Converts a specific SPIR-V type to a Tint type. Integer case /// Converts a specific SPIR-V type to a Tint type. Integer case
typ::Type ConvertType(const spvtools::opt::analysis::Integer* int_ty); typ::Type ConvertType(const spvtools::opt::analysis::Integer* int_ty);

View File

@ -26,14 +26,14 @@ using ::testing::Eq;
TEST_F(SpvParserTest, ConvertType_PreservesExistingFailure) { TEST_F(SpvParserTest, ConvertType_PreservesExistingFailure) {
auto p = parser(std::vector<uint32_t>{}); auto p = parser(std::vector<uint32_t>{});
p->Fail() << "boing"; p->Fail() << "boing";
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT(p->error(), Eq("boing")); EXPECT_THAT(p->error(), Eq("boing"));
} }
TEST_F(SpvParserTest, ConvertType_RequiresInternalRepresntation) { TEST_F(SpvParserTest, ConvertType_RequiresInternalRepresntation) {
auto p = parser(std::vector<uint32_t>{}); auto p = parser(std::vector<uint32_t>{});
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT( EXPECT_THAT(
p->error(), p->error(),
@ -44,7 +44,7 @@ TEST_F(SpvParserTest, ConvertType_NotAnId) {
auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\"")); auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_EQ(nullptr, type); EXPECT_EQ(nullptr, type);
EXPECT_THAT(p->error(), Eq("ID is not a SPIR-V type: 10")); 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\"")); auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(1); auto* type = p->ConvertType(1);
EXPECT_EQ(nullptr, type); EXPECT_EQ(nullptr, type);
EXPECT_THAT(p->error(), Eq("ID is not a SPIR-V type: 1")); 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")); auto p = parser(test::Assemble("%70 = OpTypePipe WriteOnly"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(70); auto* type = p->ConvertType(70);
EXPECT_EQ(nullptr, type); EXPECT_EQ(nullptr, type);
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("unknown SPIR-V type with ID 70: %70 = OpTypePipe WriteOnly")); 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")); auto p = parser(test::Assemble("%1 = OpTypeVoid"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(1); auto* type = p->ConvertType(1);
EXPECT_TRUE(type->Is<sem::Void>()); EXPECT_TRUE(type->Is<sem::Void>());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
} }
@ -83,7 +83,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) {
auto p = parser(test::Assemble("%100 = OpTypeBool")); auto p = parser(test::Assemble("%100 = OpTypeBool"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(100); auto* type = p->ConvertType(100);
EXPECT_TRUE(type->Is<sem::Bool>()); EXPECT_TRUE(type->Is<sem::Bool>());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
} }
@ -92,7 +92,7 @@ TEST_F(SpvParserTest, ConvertType_I32) {
auto p = parser(test::Assemble("%2 = OpTypeInt 32 1")); auto p = parser(test::Assemble("%2 = OpTypeInt 32 1"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(2); auto* type = p->ConvertType(2);
EXPECT_TRUE(type->Is<sem::I32>()); EXPECT_TRUE(type->Is<sem::I32>());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
} }
@ -101,7 +101,7 @@ TEST_F(SpvParserTest, ConvertType_U32) {
auto p = parser(test::Assemble("%3 = OpTypeInt 32 0")); auto p = parser(test::Assemble("%3 = OpTypeInt 32 0"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::U32>()); EXPECT_TRUE(type->Is<sem::U32>());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
} }
@ -110,7 +110,7 @@ TEST_F(SpvParserTest, ConvertType_F32) {
auto p = parser(test::Assemble("%4 = OpTypeFloat 32")); auto p = parser(test::Assemble("%4 = OpTypeFloat 32"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(4); auto* type = p->ConvertType(4);
EXPECT_TRUE(type->Is<sem::F32>()); EXPECT_TRUE(type->Is<sem::F32>());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
} }
@ -119,7 +119,7 @@ TEST_F(SpvParserTest, ConvertType_BadIntWidth) {
auto p = parser(test::Assemble("%5 = OpTypeInt 17 1")); auto p = parser(test::Assemble("%5 = OpTypeInt 17 1"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(5); auto* type = p->ConvertType(5);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT(p->error(), Eq("unhandled integer width: 17")); 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")); auto p = parser(test::Assemble("%6 = OpTypeFloat 19"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(6); auto* type = p->ConvertType(6);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT(p->error(), Eq("unhandled float width: 19")); EXPECT_THAT(p->error(), Eq("unhandled float width: 19"));
} }
@ -140,7 +140,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidVectorElement) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(20); auto* type = p->ConvertType(20);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT(p->error(), Eq("unknown SPIR-V type: 5")); EXPECT_THAT(p->error(), Eq("unknown SPIR-V type: 5"));
} }
@ -154,17 +154,17 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto v2xf32 = p->ConvertType(20); auto* v2xf32 = p->ConvertType(20);
EXPECT_TRUE(v2xf32->Is<sem::Vector>()); EXPECT_TRUE(v2xf32->Is<sem::Vector>());
EXPECT_TRUE(v2xf32->As<sem::Vector>()->type()->Is<sem::F32>()); EXPECT_TRUE(v2xf32->As<sem::Vector>()->type()->Is<sem::F32>());
EXPECT_EQ(v2xf32->As<sem::Vector>()->size(), 2u); EXPECT_EQ(v2xf32->As<sem::Vector>()->size(), 2u);
auto v3xf32 = p->ConvertType(30); auto* v3xf32 = p->ConvertType(30);
EXPECT_TRUE(v3xf32->Is<sem::Vector>()); EXPECT_TRUE(v3xf32->Is<sem::Vector>());
EXPECT_TRUE(v3xf32->As<sem::Vector>()->type()->Is<sem::F32>()); EXPECT_TRUE(v3xf32->As<sem::Vector>()->type()->Is<sem::F32>());
EXPECT_EQ(v3xf32->As<sem::Vector>()->size(), 3u); EXPECT_EQ(v3xf32->As<sem::Vector>()->size(), 3u);
auto v4xf32 = p->ConvertType(40); auto* v4xf32 = p->ConvertType(40);
EXPECT_TRUE(v4xf32->Is<sem::Vector>()); EXPECT_TRUE(v4xf32->Is<sem::Vector>());
EXPECT_TRUE(v4xf32->As<sem::Vector>()->type()->Is<sem::F32>()); EXPECT_TRUE(v4xf32->As<sem::Vector>()->type()->Is<sem::F32>());
EXPECT_EQ(v4xf32->As<sem::Vector>()->size(), 4u); EXPECT_EQ(v4xf32->As<sem::Vector>()->size(), 4u);
@ -181,17 +181,17 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto v2xi32 = p->ConvertType(20); auto* v2xi32 = p->ConvertType(20);
EXPECT_TRUE(v2xi32->Is<sem::Vector>()); EXPECT_TRUE(v2xi32->Is<sem::Vector>());
EXPECT_TRUE(v2xi32->As<sem::Vector>()->type()->Is<sem::I32>()); EXPECT_TRUE(v2xi32->As<sem::Vector>()->type()->Is<sem::I32>());
EXPECT_EQ(v2xi32->As<sem::Vector>()->size(), 2u); EXPECT_EQ(v2xi32->As<sem::Vector>()->size(), 2u);
auto v3xi32 = p->ConvertType(30); auto* v3xi32 = p->ConvertType(30);
EXPECT_TRUE(v3xi32->Is<sem::Vector>()); EXPECT_TRUE(v3xi32->Is<sem::Vector>());
EXPECT_TRUE(v3xi32->As<sem::Vector>()->type()->Is<sem::I32>()); EXPECT_TRUE(v3xi32->As<sem::Vector>()->type()->Is<sem::I32>());
EXPECT_EQ(v3xi32->As<sem::Vector>()->size(), 3u); EXPECT_EQ(v3xi32->As<sem::Vector>()->size(), 3u);
auto v4xi32 = p->ConvertType(40); auto* v4xi32 = p->ConvertType(40);
EXPECT_TRUE(v4xi32->Is<sem::Vector>()); EXPECT_TRUE(v4xi32->Is<sem::Vector>());
EXPECT_TRUE(v4xi32->As<sem::Vector>()->type()->Is<sem::I32>()); EXPECT_TRUE(v4xi32->As<sem::Vector>()->type()->Is<sem::I32>());
EXPECT_EQ(v4xi32->As<sem::Vector>()->size(), 4u); EXPECT_EQ(v4xi32->As<sem::Vector>()->size(), 4u);
@ -208,17 +208,17 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto v2xu32 = p->ConvertType(20); auto* v2xu32 = p->ConvertType(20);
EXPECT_TRUE(v2xu32->Is<sem::Vector>()); EXPECT_TRUE(v2xu32->Is<sem::Vector>());
EXPECT_TRUE(v2xu32->As<sem::Vector>()->type()->Is<sem::U32>()); EXPECT_TRUE(v2xu32->As<sem::Vector>()->type()->Is<sem::U32>());
EXPECT_EQ(v2xu32->As<sem::Vector>()->size(), 2u); EXPECT_EQ(v2xu32->As<sem::Vector>()->size(), 2u);
auto v3xu32 = p->ConvertType(30); auto* v3xu32 = p->ConvertType(30);
EXPECT_TRUE(v3xu32->Is<sem::Vector>()); EXPECT_TRUE(v3xu32->Is<sem::Vector>());
EXPECT_TRUE(v3xu32->As<sem::Vector>()->type()->Is<sem::U32>()); EXPECT_TRUE(v3xu32->As<sem::Vector>()->type()->Is<sem::U32>());
EXPECT_EQ(v3xu32->As<sem::Vector>()->size(), 3u); EXPECT_EQ(v3xu32->As<sem::Vector>()->size(), 3u);
auto v4xu32 = p->ConvertType(40); auto* v4xu32 = p->ConvertType(40);
EXPECT_TRUE(v4xu32->Is<sem::Vector>()); EXPECT_TRUE(v4xu32->Is<sem::Vector>());
EXPECT_TRUE(v4xu32->As<sem::Vector>()->type()->Is<sem::U32>()); EXPECT_TRUE(v4xu32->As<sem::Vector>()->type()->Is<sem::U32>());
EXPECT_EQ(v4xu32->As<sem::Vector>()->size(), 4u); EXPECT_EQ(v4xu32->As<sem::Vector>()->size(), 4u);
@ -234,7 +234,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidMatrixElement) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(20); auto* type = p->ConvertType(20);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT(p->error(), Eq("unknown SPIR-V type: 5")); EXPECT_THAT(p->error(), Eq("unknown SPIR-V type: 5"));
} }
@ -260,55 +260,55 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto m22 = p->ConvertType(22); auto* m22 = p->ConvertType(22);
EXPECT_TRUE(m22->Is<sem::Matrix>()); EXPECT_TRUE(m22->Is<sem::Matrix>());
EXPECT_TRUE(m22->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m22->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m22->As<sem::Matrix>()->rows(), 2u); EXPECT_EQ(m22->As<sem::Matrix>()->rows(), 2u);
EXPECT_EQ(m22->As<sem::Matrix>()->columns(), 2u); EXPECT_EQ(m22->As<sem::Matrix>()->columns(), 2u);
auto m23 = p->ConvertType(23); auto* m23 = p->ConvertType(23);
EXPECT_TRUE(m23->Is<sem::Matrix>()); EXPECT_TRUE(m23->Is<sem::Matrix>());
EXPECT_TRUE(m23->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m23->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m23->As<sem::Matrix>()->rows(), 2u); EXPECT_EQ(m23->As<sem::Matrix>()->rows(), 2u);
EXPECT_EQ(m23->As<sem::Matrix>()->columns(), 3u); EXPECT_EQ(m23->As<sem::Matrix>()->columns(), 3u);
auto m24 = p->ConvertType(24); auto* m24 = p->ConvertType(24);
EXPECT_TRUE(m24->Is<sem::Matrix>()); EXPECT_TRUE(m24->Is<sem::Matrix>());
EXPECT_TRUE(m24->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m24->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m24->As<sem::Matrix>()->rows(), 2u); EXPECT_EQ(m24->As<sem::Matrix>()->rows(), 2u);
EXPECT_EQ(m24->As<sem::Matrix>()->columns(), 4u); EXPECT_EQ(m24->As<sem::Matrix>()->columns(), 4u);
auto m32 = p->ConvertType(32); auto* m32 = p->ConvertType(32);
EXPECT_TRUE(m32->Is<sem::Matrix>()); EXPECT_TRUE(m32->Is<sem::Matrix>());
EXPECT_TRUE(m32->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m32->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m32->As<sem::Matrix>()->rows(), 3u); EXPECT_EQ(m32->As<sem::Matrix>()->rows(), 3u);
EXPECT_EQ(m32->As<sem::Matrix>()->columns(), 2u); EXPECT_EQ(m32->As<sem::Matrix>()->columns(), 2u);
auto m33 = p->ConvertType(33); auto* m33 = p->ConvertType(33);
EXPECT_TRUE(m33->Is<sem::Matrix>()); EXPECT_TRUE(m33->Is<sem::Matrix>());
EXPECT_TRUE(m33->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m33->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m33->As<sem::Matrix>()->rows(), 3u); EXPECT_EQ(m33->As<sem::Matrix>()->rows(), 3u);
EXPECT_EQ(m33->As<sem::Matrix>()->columns(), 3u); EXPECT_EQ(m33->As<sem::Matrix>()->columns(), 3u);
auto m34 = p->ConvertType(34); auto* m34 = p->ConvertType(34);
EXPECT_TRUE(m34->Is<sem::Matrix>()); EXPECT_TRUE(m34->Is<sem::Matrix>());
EXPECT_TRUE(m34->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m34->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m34->As<sem::Matrix>()->rows(), 3u); EXPECT_EQ(m34->As<sem::Matrix>()->rows(), 3u);
EXPECT_EQ(m34->As<sem::Matrix>()->columns(), 4u); EXPECT_EQ(m34->As<sem::Matrix>()->columns(), 4u);
auto m42 = p->ConvertType(42); auto* m42 = p->ConvertType(42);
EXPECT_TRUE(m42->Is<sem::Matrix>()); EXPECT_TRUE(m42->Is<sem::Matrix>());
EXPECT_TRUE(m42->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m42->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m42->As<sem::Matrix>()->rows(), 4u); EXPECT_EQ(m42->As<sem::Matrix>()->rows(), 4u);
EXPECT_EQ(m42->As<sem::Matrix>()->columns(), 2u); EXPECT_EQ(m42->As<sem::Matrix>()->columns(), 2u);
auto m43 = p->ConvertType(43); auto* m43 = p->ConvertType(43);
EXPECT_TRUE(m43->Is<sem::Matrix>()); EXPECT_TRUE(m43->Is<sem::Matrix>());
EXPECT_TRUE(m43->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m43->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m43->As<sem::Matrix>()->rows(), 4u); EXPECT_EQ(m43->As<sem::Matrix>()->rows(), 4u);
EXPECT_EQ(m43->As<sem::Matrix>()->columns(), 3u); EXPECT_EQ(m43->As<sem::Matrix>()->columns(), 3u);
auto m44 = p->ConvertType(44); auto* m44 = p->ConvertType(44);
EXPECT_TRUE(m44->Is<sem::Matrix>()); EXPECT_TRUE(m44->Is<sem::Matrix>());
EXPECT_TRUE(m44->As<sem::Matrix>()->type()->Is<sem::F32>()); EXPECT_TRUE(m44->As<sem::Matrix>()->type()->Is<sem::F32>());
EXPECT_EQ(m44->As<sem::Matrix>()->rows(), 4u); EXPECT_EQ(m44->As<sem::Matrix>()->rows(), 4u);
@ -324,7 +324,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr); ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->UnwrapAliasIfNeeded()->Is<sem::ArrayType>()); EXPECT_TRUE(type->UnwrapAliasIfNeeded()->Is<sem::ArrayType>());
auto* arr_type = type->UnwrapAliasIfNeeded()->As<sem::ArrayType>(); auto* arr_type = type->UnwrapAliasIfNeeded()->As<sem::ArrayType>();
@ -345,7 +345,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_InvalidDecoration) {
%10 = OpTypeRuntimeArray %uint %10 = OpTypeRuntimeArray %uint
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT( EXPECT_THAT(
p->error(), p->error(),
@ -359,7 +359,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) {
%10 = OpTypeRuntimeArray %uint %10 = OpTypeRuntimeArray %uint
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr); ASSERT_NE(type, nullptr);
auto* arr_type = type->UnwrapAliasIfNeeded()->As<sem::ArrayType>(); auto* arr_type = type->UnwrapAliasIfNeeded()->As<sem::ArrayType>();
EXPECT_TRUE(arr_type->IsRuntimeArray()); EXPECT_TRUE(arr_type->IsRuntimeArray());
@ -378,7 +378,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_ZeroIsError) {
%10 = OpTypeRuntimeArray %uint %10 = OpTypeRuntimeArray %uint
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("invalid array type ID 10: ArrayStride can't be 0")); Eq("invalid array type ID 10: ArrayStride can't be 0"));
@ -393,7 +393,7 @@ TEST_F(SpvParserTest,
%10 = OpTypeRuntimeArray %uint %10 = OpTypeRuntimeArray %uint
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("invalid array type ID 10: multiple ArrayStride decorations")); Eq("invalid array type ID 10: multiple ArrayStride decorations"));
@ -407,7 +407,7 @@ TEST_F(SpvParserTest, ConvertType_Array) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr); ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<sem::ArrayType>()); EXPECT_TRUE(type->Is<sem::ArrayType>());
auto* arr_type = type->As<sem::ArrayType>(); auto* arr_type = type->As<sem::ArrayType>();
@ -430,7 +430,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantValue) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_EQ(type, nullptr); ASSERT_EQ(type, nullptr);
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("Array type 10 length is a specialization constant")); Eq("Array type 10 length is a specialization constant"));
@ -445,7 +445,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantExpr) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_EQ(type, nullptr); ASSERT_EQ(type, nullptr);
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("Array type 10 length is a specialization constant")); Eq("Array type 10 length is a specialization constant"));
@ -463,7 +463,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadTooBig) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_EQ(type, nullptr); ASSERT_EQ(type, nullptr);
// TODO(dneto): Right now it's rejected earlier in the flow because // TODO(dneto): Right now it's rejected earlier in the flow because
// we can't even utter the uint64 type. // we can't even utter the uint64 type.
@ -478,7 +478,7 @@ TEST_F(SpvParserTest, ConvertType_Array_InvalidDecoration) {
%10 = OpTypeArray %uint %uint_5 %10 = OpTypeArray %uint %uint_5
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT( EXPECT_THAT(
p->error(), p->error(),
@ -494,7 +494,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr); ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->UnwrapAliasIfNeeded()->Is<sem::ArrayType>()); EXPECT_TRUE(type->UnwrapAliasIfNeeded()->Is<sem::ArrayType>());
auto* arr_type = type->UnwrapAliasIfNeeded()->As<sem::ArrayType>(); auto* arr_type = type->UnwrapAliasIfNeeded()->As<sem::ArrayType>();
@ -517,7 +517,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_ZeroIsError) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_EQ(type, nullptr); ASSERT_EQ(type, nullptr);
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("invalid array type ID 10: ArrayStride can't be 0")); 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()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_EQ(type, nullptr); ASSERT_EQ(type, nullptr);
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("invalid array type ID 10: multiple ArrayStride decorations")); 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->BuildInternalModule());
EXPECT_TRUE(p->RegisterUserAndStructMemberNames()); EXPECT_TRUE(p->RegisterUserAndStructMemberNames());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr); ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<sem::StructType>()); EXPECT_TRUE(type->Is<sem::StructType>());
@ -569,7 +569,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
EXPECT_TRUE(p->RegisterUserAndStructMemberNames()); EXPECT_TRUE(p->RegisterUserAndStructMemberNames());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr); ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<sem::StructType>()); EXPECT_TRUE(type->Is<sem::StructType>());
@ -594,7 +594,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
EXPECT_TRUE(p->RegisterUserAndStructMemberNames()); EXPECT_TRUE(p->RegisterUserAndStructMemberNames());
auto type = p->ConvertType(10); auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr); ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<sem::StructType>()); EXPECT_TRUE(type->Is<sem::StructType>());
@ -621,7 +621,7 @@ TEST_F(SpvParserTest, ConvertType_InvalidPointeetype) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()) << p->error(); EXPECT_TRUE(p->BuildInternalModule()) << p->error();
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_EQ(type, nullptr); EXPECT_EQ(type, nullptr);
EXPECT_THAT(p->error(), EXPECT_THAT(p->error(),
Eq("SPIR-V pointer type with ID 3 has invalid pointee type 42")); 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()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -660,7 +660,7 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -676,7 +676,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -692,7 +692,7 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -708,7 +708,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -724,7 +724,7 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -740,7 +740,7 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -756,7 +756,7 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -772,7 +772,7 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
auto* ptr_ty = type->As<sem::Pointer>(); auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr); EXPECT_NE(ptr_ty, nullptr);
@ -790,7 +790,7 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(3); auto* type = p->ConvertType(3);
EXPECT_NE(type, nullptr); EXPECT_NE(type, nullptr);
EXPECT_TRUE(type->Is<sem::Pointer>()); EXPECT_TRUE(type->Is<sem::Pointer>());
@ -814,7 +814,7 @@ TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(1); auto* type = p->ConvertType(1);
EXPECT_TRUE(type->Is<sem::Void>()); EXPECT_TRUE(type->Is<sem::Void>());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
} }
@ -827,7 +827,7 @@ TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(1); auto* type = p->ConvertType(1);
EXPECT_TRUE(type->Is<sem::Void>()); EXPECT_TRUE(type->Is<sem::Void>());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
} }
@ -840,7 +840,7 @@ TEST_F(SpvParserTest, ConvertType_SampledImage_PretendVoid) {
)")); )"));
EXPECT_TRUE(p->BuildInternalModule()); EXPECT_TRUE(p->BuildInternalModule());
auto type = p->ConvertType(1); auto* type = p->ConvertType(1);
EXPECT_TRUE(type->Is<sem::Void>()); EXPECT_TRUE(type->Is<sem::Void>());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
} }

View File

@ -4827,7 +4827,7 @@ TEST_P(SpvParserTest_ImageCoordsTest, MakeCoordinateOperandsForImageAccess) {
EXPECT_THAT(p->error(), StartsWith(GetParam().expected_error)) << assembly; EXPECT_THAT(p->error(), StartsWith(GetParam().expected_error)) << assembly;
} else { } else {
EXPECT_TRUE(p->error().empty()) << p->error(); 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 // We actually have to generate the module to cache expressions for the
// result IDs, particularly the OpCopyObject // result IDs, particularly the OpCopyObject
fe.Emit(); fe.Emit();
@ -5691,7 +5691,7 @@ TEST_F(SpvParserTest, NeverGenerateConstDeclForHandle_UseVariableDirectly) {
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
EXPECT_TRUE(p->BuildAndParseInternalModule()) << 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(fe.EmitBody()) << p->error();
EXPECT_TRUE(p->error().empty()) << p->error(); EXPECT_TRUE(p->error().empty()) << p->error();
const auto got = ToString(p->builder(), fe.ast_body()); const auto got = ToString(p->builder(), fe.ast_body());

View File

@ -1999,7 +1999,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_UsedInFunction) {
OpFunctionEnd OpFunctionEnd
)")); )"));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); 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(fe.EmitBody()) << p->error();
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());

View File

@ -17,15 +17,102 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <unordered_set>
#include <utility>
#include <vector> #include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "source/opt/ir_context.h"
#include "src/demangler.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/parser_impl.h"
#include "src/reader/spirv/usage.h"
namespace tint { namespace tint {
namespace reader { namespace reader {
namespace spirv { namespace spirv {
namespace test {
// A test class that wraps ParseImpl
class ParserImplWrapperForTest {
public:
explicit ParserImplWrapperForTest(const std::vector<uint32_t>& 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<uint32_t>& 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<EntryPointInfo>& 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 /// SPIR-V Parser test class
template <typename T> template <typename T>
@ -37,23 +124,14 @@ class SpvParserTestBase : public T {
/// Retrieves the parser from the helper /// Retrieves the parser from the helper
/// @param input the SPIR-V binary to parse /// @param input the SPIR-V binary to parse
/// @returns a parser for the given binary /// @returns a parser for the given binary
std::unique_ptr<ParserImpl> parser(const std::vector<uint32_t>& input) { std::unique_ptr<test::ParserImplWrapperForTest> parser(
auto parser = std::make_unique<ParserImpl>(input); const std::vector<uint32_t>& input) {
auto parser = std::make_unique<test::ParserImplWrapperForTest>(input);
// Don't run the Resolver when building the program. // Don't run the Resolver when building the program.
// We're not interested in type information with these tests. // We're not interested in type information with these tests.
parser->builder().SetResolveOnBuild(false); parser->builder().SetResolveOnBuild(false);
return parser; 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. // Use this form when you don't need to template any further.

View File

@ -74,7 +74,8 @@ std::string Disassemble(const std::vector<uint32_t>& spirv_module) {
}); });
std::string result; 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(); EXPECT_TRUE(success) << errors.str();
return result; return result;