Migrate from using ast::Module to Program
Enforce all places where Dawn passes in or returns a ast::Module, now takes a `const Program* ` or returns a `Program`. As the end goal of all this is to have immutable Programs, all Program inputs take a pointer instead of moving the actual object. As consumers of a Program are now all const, we have to const_cast to work around all the places we've been incorrectly mutating a ast::Module. These const_casts are temporary, and will be fixed in the next set of changes. Depends on https://dawn-review.googlesource.com/c/dawn/+/38522 Bug: tint:390 Change-Id: Ie05b112b16134937d1b601e9b713ea4ec4e1c677 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38541 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
be610ba987
commit
c40f627bea
3
BUILD.gn
3
BUILD.gn
|
@ -373,6 +373,7 @@ source_set("libtint_core_src") {
|
||||||
"src/inspector/scalar.h",
|
"src/inspector/scalar.h",
|
||||||
"src/namer.cc",
|
"src/namer.cc",
|
||||||
"src/namer.h",
|
"src/namer.h",
|
||||||
|
"src/program.cc",
|
||||||
"src/program.h",
|
"src/program.h",
|
||||||
"src/reader/reader.cc",
|
"src/reader/reader.cc",
|
||||||
"src/reader/reader.h",
|
"src/reader/reader.h",
|
||||||
|
@ -791,7 +792,6 @@ source_set("tint_unittests_core_src") {
|
||||||
"src/ast/loop_statement_test.cc",
|
"src/ast/loop_statement_test.cc",
|
||||||
"src/ast/member_accessor_expression_test.cc",
|
"src/ast/member_accessor_expression_test.cc",
|
||||||
"src/ast/module_clone_test.cc",
|
"src/ast/module_clone_test.cc",
|
||||||
"src/ast/module_test.cc",
|
|
||||||
"src/ast/null_literal_test.cc",
|
"src/ast/null_literal_test.cc",
|
||||||
"src/ast/return_statement_test.cc",
|
"src/ast/return_statement_test.cc",
|
||||||
"src/ast/scalar_constructor_expression_test.cc",
|
"src/ast/scalar_constructor_expression_test.cc",
|
||||||
|
@ -817,6 +817,7 @@ source_set("tint_unittests_core_src") {
|
||||||
"src/diagnostic/printer_test.cc",
|
"src/diagnostic/printer_test.cc",
|
||||||
"src/inspector/inspector_test.cc",
|
"src/inspector/inspector_test.cc",
|
||||||
"src/namer_test.cc",
|
"src/namer_test.cc",
|
||||||
|
"src/program_test.cc",
|
||||||
"src/scope_stack_test.cc",
|
"src/scope_stack_test.cc",
|
||||||
"src/symbol_table_test.cc",
|
"src/symbol_table_test.cc",
|
||||||
"src/symbol_test.cc",
|
"src/symbol_test.cc",
|
||||||
|
|
|
@ -47,15 +47,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
|
|
||||||
tint::Source::File file("test.wgsl", str);
|
tint::Source::File file("test.wgsl", str);
|
||||||
|
|
||||||
// Parse the wgsl, create the src module
|
// Parse the wgsl, create the src program
|
||||||
tint::reader::wgsl::ParserImpl parser(&file);
|
tint::reader::wgsl::ParserImpl parser(&file);
|
||||||
parser.set_max_errors(1);
|
parser.set_max_errors(1);
|
||||||
if (!parser.Parse()) {
|
if (!parser.Parse()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto src = parser.module();
|
auto src = parser.program();
|
||||||
|
|
||||||
// Clone the src module to dst
|
// Clone the src program to dst
|
||||||
auto dst = src.Clone();
|
auto dst = src.Clone();
|
||||||
|
|
||||||
// Expect the demangled AST printed with to_str() to match
|
// Expect the demangled AST printed with to_str() to match
|
||||||
|
@ -78,24 +78,25 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
ASSERT_EQ(src_types.count(dst_type.second), 0u);
|
ASSERT_EQ(src_types.count(dst_type.second), 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regenerate the wgsl for the src module. We use this instead of the original
|
// Regenerate the wgsl for the src program. We use this instead of the
|
||||||
// source so that reformatting doesn't impact the final wgsl comparision.
|
// original source so that reformatting doesn't impact the final wgsl
|
||||||
// Note that the src module is moved into the generator and this generator has
|
// comparison.
|
||||||
// a limited scope, so that the src module is released before we attempt to
|
|
||||||
// print the dst module.
|
|
||||||
// This guarantee that all the source module nodes and types are destructed
|
|
||||||
// and freed.
|
|
||||||
// ASAN should error if there's any remaining references in dst when we try to
|
|
||||||
// reconstruct the WGSL.
|
|
||||||
std::string src_wgsl;
|
std::string src_wgsl;
|
||||||
{
|
{
|
||||||
tint::writer::wgsl::Generator src_gen(std::move(src));
|
tint::writer::wgsl::Generator src_gen(&src);
|
||||||
ASSERT_TRUE(src_gen.Generate());
|
ASSERT_TRUE(src_gen.Generate());
|
||||||
src_wgsl = src_gen.result();
|
src_wgsl = src_gen.result();
|
||||||
|
|
||||||
|
// Move the src program to a temporary that'll be dropped, so that the src
|
||||||
|
// program is released before we attempt to print the dst program. This
|
||||||
|
// guarantee that all the source program nodes and types are destructed and
|
||||||
|
// freed. ASAN should error if there's any remaining references in dst when
|
||||||
|
// we try to reconstruct the WGSL.
|
||||||
|
auto tmp = std::move(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the dst module, check it matches the original source
|
// Print the dst program, check it matches the original source
|
||||||
tint::writer::wgsl::Generator dst_gen(std::move(dst));
|
tint::writer::wgsl::Generator dst_gen(&dst);
|
||||||
ASSERT_TRUE(dst_gen.Generate());
|
ASSERT_TRUE(dst_gen.Generate());
|
||||||
auto dst_wgsl = dst_gen.result();
|
auto dst_wgsl = dst_gen.result();
|
||||||
ASSERT_EQ(src_wgsl, dst_wgsl);
|
ASSERT_EQ(src_wgsl, dst_wgsl);
|
||||||
|
|
|
@ -76,23 +76,23 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mod = parser->module();
|
auto program = parser->program();
|
||||||
if (!mod.IsValid()) {
|
if (!program.IsValid()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeDeterminer td(&mod);
|
TypeDeterminer td(&program);
|
||||||
if (!td.Determine()) {
|
if (!td.Determine()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Validator v;
|
Validator v;
|
||||||
if (!v.Validate(&mod)) {
|
if (!v.Validate(&program)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inspector_enabled_) {
|
if (inspector_enabled_) {
|
||||||
inspector::Inspector inspector(mod);
|
inspector::Inspector inspector(&program);
|
||||||
|
|
||||||
auto entry_points = inspector.GetEntryPoints();
|
auto entry_points = inspector.GetEntryPoints();
|
||||||
if (inspector.has_error()) {
|
if (inspector.has_error()) {
|
||||||
|
@ -154,12 +154,12 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transform_manager_) {
|
if (transform_manager_) {
|
||||||
auto out = transform_manager_->Run(&mod);
|
auto out = transform_manager_->Run(&program);
|
||||||
if (out.diagnostics.contains_errors()) {
|
if (out.diagnostics.contains_errors()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod = std::move(out.module);
|
program = std::move(out.program);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<writer::Writer> writer;
|
std::unique_ptr<writer::Writer> writer;
|
||||||
|
@ -167,22 +167,22 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
|
||||||
switch (output_) {
|
switch (output_) {
|
||||||
case OutputFormat::kWGSL:
|
case OutputFormat::kWGSL:
|
||||||
#if TINT_BUILD_WGSL_WRITER
|
#if TINT_BUILD_WGSL_WRITER
|
||||||
writer = std::make_unique<writer::wgsl::Generator>(std::move(mod));
|
writer = std::make_unique<writer::wgsl::Generator>(&program);
|
||||||
#endif // TINT_BUILD_WGSL_WRITER
|
#endif // TINT_BUILD_WGSL_WRITER
|
||||||
break;
|
break;
|
||||||
case OutputFormat::kSpv:
|
case OutputFormat::kSpv:
|
||||||
#if TINT_BUILD_SPV_WRITER
|
#if TINT_BUILD_SPV_WRITER
|
||||||
writer = std::make_unique<writer::spirv::Generator>(std::move(mod));
|
writer = std::make_unique<writer::spirv::Generator>(&program);
|
||||||
#endif // TINT_BUILD_SPV_WRITER
|
#endif // TINT_BUILD_SPV_WRITER
|
||||||
break;
|
break;
|
||||||
case OutputFormat::kHLSL:
|
case OutputFormat::kHLSL:
|
||||||
#if TINT_BUILD_HLSL_WRITER
|
#if TINT_BUILD_HLSL_WRITER
|
||||||
writer = std::make_unique<writer::hlsl::Generator>(std::move(mod));
|
writer = std::make_unique<writer::hlsl::Generator>(&program);
|
||||||
#endif // TINT_BUILD_HLSL_WRITER
|
#endif // TINT_BUILD_HLSL_WRITER
|
||||||
break;
|
break;
|
||||||
case OutputFormat::kMSL:
|
case OutputFormat::kMSL:
|
||||||
#if TINT_BUILD_MSL_WRITER
|
#if TINT_BUILD_MSL_WRITER
|
||||||
writer = std::make_unique<writer::msl::Generator>(std::move(mod));
|
writer = std::make_unique<writer::msl::Generator>(&program);
|
||||||
#endif // TINT_BUILD_MSL_WRITER
|
#endif // TINT_BUILD_MSL_WRITER
|
||||||
break;
|
break;
|
||||||
case OutputFormat::kNone:
|
case OutputFormat::kNone:
|
||||||
|
|
|
@ -496,22 +496,22 @@ int main(int argc, const char** argv) {
|
||||||
diag_formatter.format(reader->diagnostics(), diag_printer.get());
|
diag_formatter.format(reader->diagnostics(), diag_printer.get());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
auto mod = reader->module();
|
auto program = reader->program();
|
||||||
if (!mod.IsValid()) {
|
if (!program.IsValid()) {
|
||||||
std::cerr << "Invalid module generated..." << std::endl;
|
std::cerr << "Invalid program generated..." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tint::TypeDeterminer td(&mod);
|
tint::TypeDeterminer td(&program);
|
||||||
if (!td.Determine()) {
|
if (!td.Determine()) {
|
||||||
std::cerr << "Type Determination: " << td.error() << std::endl;
|
std::cerr << "Type Determination: " << td.error() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.dump_ast) {
|
if (options.dump_ast) {
|
||||||
auto ast_str = mod.to_str();
|
auto ast_str = program.to_str();
|
||||||
if (options.demangle) {
|
if (options.demangle) {
|
||||||
ast_str = tint::Demangler().Demangle(mod, ast_str);
|
ast_str = tint::Demangler().Demangle(program, ast_str);
|
||||||
}
|
}
|
||||||
std::cout << std::endl << ast_str << std::endl;
|
std::cout << std::endl << ast_str << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ int main(int argc, const char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tint::Validator v;
|
tint::Validator v;
|
||||||
if (!v.Validate(&mod)) {
|
if (!v.Validate(&program)) {
|
||||||
diag_formatter.format(v.diagnostics(), diag_printer.get());
|
diag_formatter.format(v.diagnostics(), diag_printer.get());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -546,37 +546,40 @@ int main(int argc, const char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto out = transform_manager.Run(&mod);
|
auto out = transform_manager.Run(&program);
|
||||||
if (out.diagnostics.contains_errors()) {
|
if (out.diagnostics.contains_errors()) {
|
||||||
diag_formatter.format(out.diagnostics, diag_printer.get());
|
diag_formatter.format(out.diagnostics, diag_printer.get());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod = std::move(out.module);
|
program = std::move(out.program);
|
||||||
|
|
||||||
std::unique_ptr<tint::writer::Writer> writer;
|
std::unique_ptr<tint::writer::Writer> writer;
|
||||||
|
|
||||||
#if TINT_BUILD_SPV_WRITER
|
#if TINT_BUILD_SPV_WRITER
|
||||||
if (options.format == Format::kSpirv || options.format == Format::kSpvAsm) {
|
if (options.format == Format::kSpirv || options.format == Format::kSpvAsm) {
|
||||||
writer = std::make_unique<tint::writer::spirv::Generator>(std::move(mod));
|
writer =
|
||||||
|
std::make_unique<tint::writer::spirv::Generator>(&program);
|
||||||
}
|
}
|
||||||
#endif // TINT_BUILD_SPV_WRITER
|
#endif // TINT_BUILD_SPV_WRITER
|
||||||
|
|
||||||
#if TINT_BUILD_WGSL_WRITER
|
#if TINT_BUILD_WGSL_WRITER
|
||||||
if (options.format == Format::kWgsl) {
|
if (options.format == Format::kWgsl) {
|
||||||
writer = std::make_unique<tint::writer::wgsl::Generator>(std::move(mod));
|
writer =
|
||||||
|
std::make_unique<tint::writer::wgsl::Generator>(&program);
|
||||||
}
|
}
|
||||||
#endif // TINT_BUILD_WGSL_WRITER
|
#endif // TINT_BUILD_WGSL_WRITER
|
||||||
|
|
||||||
#if TINT_BUILD_MSL_WRITER
|
#if TINT_BUILD_MSL_WRITER
|
||||||
if (options.format == Format::kMsl) {
|
if (options.format == Format::kMsl) {
|
||||||
writer = std::make_unique<tint::writer::msl::Generator>(std::move(mod));
|
writer = std::make_unique<tint::writer::msl::Generator>(&program);
|
||||||
}
|
}
|
||||||
#endif // TINT_BUILD_MSL_WRITER
|
#endif // TINT_BUILD_MSL_WRITER
|
||||||
|
|
||||||
#if TINT_BUILD_HLSL_WRITER
|
#if TINT_BUILD_HLSL_WRITER
|
||||||
if (options.format == Format::kHlsl) {
|
if (options.format == Format::kHlsl) {
|
||||||
writer = std::make_unique<tint::writer::hlsl::Generator>(std::move(mod));
|
writer =
|
||||||
|
std::make_unique<tint::writer::hlsl::Generator>(&program);
|
||||||
}
|
}
|
||||||
#endif // TINT_BUILD_HLSL_WRITER
|
#endif // TINT_BUILD_HLSL_WRITER
|
||||||
|
|
||||||
|
@ -641,7 +644,7 @@ int main(int argc, const char** argv) {
|
||||||
auto* w = static_cast<tint::writer::Text*>(writer.get());
|
auto* w = static_cast<tint::writer::Text*>(writer.get());
|
||||||
auto output = w->result();
|
auto output = w->result();
|
||||||
if (options.demangle) {
|
if (options.demangle) {
|
||||||
output = tint::Demangler().Demangle(mod, output);
|
output = tint::Demangler().Demangle(program, output);
|
||||||
}
|
}
|
||||||
if (!WriteFile(options.output_file, "w", output)) {
|
if (!WriteFile(options.output_file, "w", output)) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -187,6 +187,7 @@ set(TINT_LIB_SRCS
|
||||||
inspector/scalar.h
|
inspector/scalar.h
|
||||||
namer.cc
|
namer.cc
|
||||||
namer.h
|
namer.h
|
||||||
|
program.cc
|
||||||
program.h
|
program.h
|
||||||
reader/reader.cc
|
reader/reader.cc
|
||||||
reader/reader.h
|
reader/reader.h
|
||||||
|
@ -421,7 +422,6 @@ if(${TINT_BUILD_TESTS})
|
||||||
ast/loop_statement_test.cc
|
ast/loop_statement_test.cc
|
||||||
ast/member_accessor_expression_test.cc
|
ast/member_accessor_expression_test.cc
|
||||||
ast/module_clone_test.cc
|
ast/module_clone_test.cc
|
||||||
ast/module_test.cc
|
|
||||||
ast/null_literal_test.cc
|
ast/null_literal_test.cc
|
||||||
ast/return_statement_test.cc
|
ast/return_statement_test.cc
|
||||||
ast/scalar_constructor_expression_test.cc
|
ast/scalar_constructor_expression_test.cc
|
||||||
|
@ -447,6 +447,7 @@ if(${TINT_BUILD_TESTS})
|
||||||
diagnostic/printer_test.cc
|
diagnostic/printer_test.cc
|
||||||
inspector/inspector_test.cc
|
inspector/inspector_test.cc
|
||||||
namer_test.cc
|
namer_test.cc
|
||||||
|
program_test.cc
|
||||||
scope_stack_test.cc
|
scope_stack_test.cc
|
||||||
symbol_table_test.cc
|
symbol_table_test.cc
|
||||||
symbol_test.cc
|
symbol_test.cc
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/access_decoration.h"
|
#include "src/ast/access_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::AccessDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::AccessDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/array_accessor_expression.h"
|
#include "src/ast/array_accessor_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::ArrayAccessorExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::ArrayAccessorExpression);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/assignment_statement.h"
|
#include "src/ast/assignment_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::AssignmentStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::AssignmentStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/binary_expression.h"
|
#include "src/ast/binary_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::BinaryExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::BinaryExpression);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/binding_decoration.h"
|
#include "src/ast/binding_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::BindingDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::BindingDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/bitcast_expression.h"
|
#include "src/ast/bitcast_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::BitcastExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::BitcastExpression);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/block_statement.h"
|
#include "src/ast/block_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::BlockStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::BlockStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/bool_literal.h"
|
#include "src/ast/bool_literal.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::BoolLiteral);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::BoolLiteral);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/break_statement.h"
|
#include "src/ast/break_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::BreakStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::BreakStatement);
|
||||||
|
|
||||||
|
|
|
@ -17,15 +17,15 @@
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
TypesBuilder::TypesBuilder(Module* mod)
|
TypesBuilder::TypesBuilder(Program* p)
|
||||||
: bool_(mod->create<type::Bool>()),
|
: bool_(p->create<type::Bool>()),
|
||||||
f32(mod->create<type::F32>()),
|
f32(p->create<type::F32>()),
|
||||||
i32(mod->create<type::I32>()),
|
i32(p->create<type::I32>()),
|
||||||
u32(mod->create<type::U32>()),
|
u32(p->create<type::U32>()),
|
||||||
void_(mod->create<type::Void>()),
|
void_(p->create<type::Void>()),
|
||||||
mod_(mod) {}
|
program_(p) {}
|
||||||
|
|
||||||
Builder::Builder(Module* m) : mod(m), ty(m) {}
|
Builder::Builder(Program* p) : program(p), ty(p), mod(p) {}
|
||||||
|
|
||||||
Builder::~Builder() = default;
|
Builder::~Builder() = default;
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ Variable* Builder::Var(const std::string& name,
|
||||||
type::Type* type,
|
type::Type* type,
|
||||||
Expression* constructor,
|
Expression* constructor,
|
||||||
VariableDecorationList decorations) {
|
VariableDecorationList decorations) {
|
||||||
auto* var = create<Variable>(mod->RegisterSymbol(name), storage, type, false,
|
auto* var = create<Variable>(program->RegisterSymbol(name), storage, type,
|
||||||
constructor, decorations);
|
false, constructor, decorations);
|
||||||
OnVariableBuilt(var);
|
OnVariableBuilt(var);
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ Variable* Builder::Var(const Source& source,
|
||||||
type::Type* type,
|
type::Type* type,
|
||||||
Expression* constructor,
|
Expression* constructor,
|
||||||
VariableDecorationList decorations) {
|
VariableDecorationList decorations) {
|
||||||
auto* var = create<Variable>(source, mod->RegisterSymbol(name), storage, type,
|
auto* var = create<Variable>(source, program->RegisterSymbol(name), storage,
|
||||||
false, constructor, decorations);
|
type, false, constructor, decorations);
|
||||||
OnVariableBuilt(var);
|
OnVariableBuilt(var);
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ Variable* Builder::Const(const std::string& name,
|
||||||
type::Type* type,
|
type::Type* type,
|
||||||
Expression* constructor,
|
Expression* constructor,
|
||||||
VariableDecorationList decorations) {
|
VariableDecorationList decorations) {
|
||||||
auto* var = create<Variable>(mod->RegisterSymbol(name), storage, type, true,
|
auto* var = create<Variable>(program->RegisterSymbol(name), storage, type,
|
||||||
constructor, decorations);
|
true, constructor, decorations);
|
||||||
OnVariableBuilt(var);
|
OnVariableBuilt(var);
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
@ -81,16 +81,16 @@ Variable* Builder::Const(const Source& source,
|
||||||
type::Type* type,
|
type::Type* type,
|
||||||
Expression* constructor,
|
Expression* constructor,
|
||||||
VariableDecorationList decorations) {
|
VariableDecorationList decorations) {
|
||||||
auto* var = create<Variable>(source, mod->RegisterSymbol(name), storage, type,
|
auto* var = create<Variable>(source, program->RegisterSymbol(name), storage,
|
||||||
true, constructor, decorations);
|
type, true, constructor, decorations);
|
||||||
OnVariableBuilt(var);
|
OnVariableBuilt(var);
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuilderWithModule::BuilderWithModule() : Builder(new Module()) {}
|
BuilderWithProgram::BuilderWithProgram() : Builder(new Program()) {}
|
||||||
|
|
||||||
BuilderWithModule::~BuilderWithModule() {
|
BuilderWithProgram::~BuilderWithProgram() {
|
||||||
delete mod;
|
delete program;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "src/ast/float_literal.h"
|
#include "src/ast/float_literal.h"
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/member_accessor_expression.h"
|
#include "src/ast/member_accessor_expression.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
|
@ -36,6 +35,7 @@
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
|
#include "src/program.h"
|
||||||
#include "src/type/alias_type.h"
|
#include "src/type/alias_type.h"
|
||||||
#include "src/type/array_type.h"
|
#include "src/type/array_type.h"
|
||||||
#include "src/type/bool_type.h"
|
#include "src/type/bool_type.h"
|
||||||
|
@ -56,8 +56,8 @@ namespace ast {
|
||||||
class TypesBuilder {
|
class TypesBuilder {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param mod the module
|
/// @param program the program
|
||||||
explicit TypesBuilder(Module* mod);
|
explicit TypesBuilder(Program* program);
|
||||||
|
|
||||||
/// A boolean type
|
/// A boolean type
|
||||||
type::Bool* const bool_;
|
type::Bool* const bool_;
|
||||||
|
@ -79,80 +79,80 @@ class TypesBuilder {
|
||||||
/// @return the tint AST type for a 2-element vector of the C type `T`.
|
/// @return the tint AST type for a 2-element vector of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Vector* vec2() const {
|
type::Vector* vec2() const {
|
||||||
return mod_->create<type::Vector>(Of<T>(), 2);
|
return program_->create<type::Vector>(Of<T>(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 3-element vector of the C type `T`.
|
/// @return the tint AST type for a 3-element vector of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Vector* vec3() const {
|
type::Vector* vec3() const {
|
||||||
return mod_->create<type::Vector>(Of<T>(), 3);
|
return program_->create<type::Vector>(Of<T>(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 4-element vector of the C type `T`.
|
/// @return the tint AST type for a 4-element vector of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Type* vec4() const {
|
type::Type* vec4() const {
|
||||||
return mod_->create<type::Vector>(Of<T>(), 4);
|
return program_->create<type::Vector>(Of<T>(), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat2x2() const {
|
type::Matrix* mat2x2() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 2, 2);
|
return program_->create<type::Matrix>(Of<T>(), 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat2x3() const {
|
type::Matrix* mat2x3() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 3, 2);
|
return program_->create<type::Matrix>(Of<T>(), 3, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 2x4 matrix of the C type `T`.
|
/// @return the tint AST type for a 2x4 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat2x4() const {
|
type::Matrix* mat2x4() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 4, 2);
|
return program_->create<type::Matrix>(Of<T>(), 4, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 3x2 matrix of the C type `T`.
|
/// @return the tint AST type for a 3x2 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat3x2() const {
|
type::Matrix* mat3x2() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 2, 3);
|
return program_->create<type::Matrix>(Of<T>(), 2, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 3x3 matrix of the C type `T`.
|
/// @return the tint AST type for a 3x3 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat3x3() const {
|
type::Matrix* mat3x3() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 3, 3);
|
return program_->create<type::Matrix>(Of<T>(), 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 3x4 matrix of the C type `T`.
|
/// @return the tint AST type for a 3x4 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat3x4() const {
|
type::Matrix* mat3x4() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 4, 3);
|
return program_->create<type::Matrix>(Of<T>(), 4, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 4x2 matrix of the C type `T`.
|
/// @return the tint AST type for a 4x2 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat4x2() const {
|
type::Matrix* mat4x2() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 2, 4);
|
return program_->create<type::Matrix>(Of<T>(), 2, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 4x3 matrix of the C type `T`.
|
/// @return the tint AST type for a 4x3 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat4x3() const {
|
type::Matrix* mat4x3() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 3, 4);
|
return program_->create<type::Matrix>(Of<T>(), 3, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 4x4 matrix of the C type `T`.
|
/// @return the tint AST type for a 4x4 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Matrix* mat4x4() const {
|
type::Matrix* mat4x4() const {
|
||||||
return mod_->create<type::Matrix>(Of<T>(), 4, 4);
|
return program_->create<type::Matrix>(Of<T>(), 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param subtype the array element type
|
/// @param subtype the array element type
|
||||||
/// @param n the array size. 0 represents a runtime-array.
|
/// @param n the array size. 0 represents a runtime-array.
|
||||||
/// @return the tint AST type for a array of size `n` of type `T`
|
/// @return the tint AST type for a array of size `n` of type `T`
|
||||||
type::Array* array(type::Type* subtype, uint32_t n) const {
|
type::Array* array(type::Type* subtype, uint32_t n) const {
|
||||||
return mod_->create<type::Array>(subtype, n, ArrayDecorationList{});
|
return program_->create<type::Array>(subtype, n, ArrayDecorationList{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for an array of size `N` of type `T`
|
/// @return the tint AST type for an array of size `N` of type `T`
|
||||||
|
@ -166,21 +166,21 @@ class TypesBuilder {
|
||||||
/// @param type the alias type
|
/// @param type the alias type
|
||||||
/// @returns the alias pointer
|
/// @returns the alias pointer
|
||||||
type::Alias* alias(const std::string& name, type::Type* type) const {
|
type::Alias* alias(const std::string& name, type::Type* type) const {
|
||||||
return mod_->create<type::Alias>(mod_->RegisterSymbol(name), type);
|
return program_->create<type::Alias>(program_->RegisterSymbol(name), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST pointer to type `T` with the given StorageClass.
|
/// @return the tint AST pointer to type `T` with the given StorageClass.
|
||||||
/// @param storage_class the storage class of the pointer
|
/// @param storage_class the storage class of the pointer
|
||||||
template <typename T>
|
template <typename T>
|
||||||
type::Pointer* pointer(StorageClass storage_class) const {
|
type::Pointer* pointer(StorageClass storage_class) const {
|
||||||
return mod_->create<type::Pointer>(Of<T>(), storage_class);
|
return program_->create<type::Pointer>(Of<T>(), storage_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param name the struct name
|
/// @param name the struct name
|
||||||
/// @param impl the struct implementation
|
/// @param impl the struct implementation
|
||||||
/// @returns a struct pointer
|
/// @returns a struct pointer
|
||||||
type::Struct* struct_(const std::string& name, ast::Struct* impl) const {
|
type::Struct* struct_(const std::string& name, ast::Struct* impl) const {
|
||||||
return mod_->create<type::Struct>(mod_->RegisterSymbol(name), impl);
|
return program_->create<type::Struct>(program_->RegisterSymbol(name), impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -192,7 +192,7 @@ class TypesBuilder {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct CToAST {};
|
struct CToAST {};
|
||||||
|
|
||||||
Module* const mod_;
|
Program* const program_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Helper for building common AST constructs.
|
/// Helper for building common AST constructs.
|
||||||
|
@ -216,8 +216,8 @@ class Builder {
|
||||||
using f32 = float;
|
using f32 = float;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param mod the module to use in the builder
|
/// @param program the program to build
|
||||||
explicit Builder(Module* mod);
|
explicit Builder(Program* program);
|
||||||
virtual ~Builder();
|
virtual ~Builder();
|
||||||
|
|
||||||
/// @param expr the expression
|
/// @param expr the expression
|
||||||
|
@ -227,20 +227,20 @@ class Builder {
|
||||||
/// @param name the identifier name
|
/// @param name the identifier name
|
||||||
/// @return an IdentifierExpression with the given name
|
/// @return an IdentifierExpression with the given name
|
||||||
IdentifierExpression* Expr(const std::string& name) {
|
IdentifierExpression* Expr(const std::string& name) {
|
||||||
return create<IdentifierExpression>(mod->RegisterSymbol(name));
|
return create<IdentifierExpression>(program->RegisterSymbol(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param source the source information
|
/// @param source the source information
|
||||||
/// @param name the identifier name
|
/// @param name the identifier name
|
||||||
/// @return an IdentifierExpression with the given name
|
/// @return an IdentifierExpression with the given name
|
||||||
IdentifierExpression* Expr(const Source& source, const std::string& name) {
|
IdentifierExpression* Expr(const Source& source, const std::string& name) {
|
||||||
return create<IdentifierExpression>(source, mod->RegisterSymbol(name));
|
return create<IdentifierExpression>(source, program->RegisterSymbol(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param name the identifier name
|
/// @param name the identifier name
|
||||||
/// @return an IdentifierExpression with the given name
|
/// @return an IdentifierExpression with the given name
|
||||||
IdentifierExpression* Expr(const char* name) {
|
IdentifierExpression* Expr(const char* name) {
|
||||||
return create<IdentifierExpression>(mod->RegisterSymbol(name));
|
return create<IdentifierExpression>(program->RegisterSymbol(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param value the boolean value
|
/// @param value the boolean value
|
||||||
|
@ -602,7 +602,7 @@ class Builder {
|
||||||
/// @param val the offset value
|
/// @param val the offset value
|
||||||
/// @returns the offset decoration pointer
|
/// @returns the offset decoration pointer
|
||||||
StructMemberOffsetDecoration* MemberOffset(uint32_t val) {
|
StructMemberOffsetDecoration* MemberOffset(uint32_t val) {
|
||||||
return mod->create<StructMemberOffsetDecoration>(source_, val);
|
return program->create<StructMemberOffsetDecoration>(source_, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a Function
|
/// Creates a Function
|
||||||
|
@ -619,9 +619,9 @@ class Builder {
|
||||||
type::Type* type,
|
type::Type* type,
|
||||||
ast::StatementList body,
|
ast::StatementList body,
|
||||||
ast::FunctionDecorationList decorations) {
|
ast::FunctionDecorationList decorations) {
|
||||||
return mod->create<ast::Function>(source, mod->RegisterSymbol(name), params,
|
return program->create<ast::Function>(
|
||||||
type, create<ast::BlockStatement>(body),
|
source, program->RegisterSymbol(name), params, type,
|
||||||
decorations);
|
create<ast::BlockStatement>(body), decorations);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a Function
|
/// Creates a Function
|
||||||
|
@ -636,7 +636,7 @@ class Builder {
|
||||||
type::Type* type,
|
type::Type* type,
|
||||||
ast::StatementList body,
|
ast::StatementList body,
|
||||||
ast::FunctionDecorationList decorations) {
|
ast::FunctionDecorationList decorations) {
|
||||||
return create<ast::Function>(mod->RegisterSymbol(name), params, type,
|
return create<ast::Function>(program->RegisterSymbol(name), params, type,
|
||||||
create<ast::BlockStatement>(body),
|
create<ast::BlockStatement>(body),
|
||||||
decorations);
|
decorations);
|
||||||
}
|
}
|
||||||
|
@ -649,8 +649,8 @@ class Builder {
|
||||||
StructMember* Member(const Source& source,
|
StructMember* Member(const Source& source,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
type::Type* type) {
|
type::Type* type) {
|
||||||
return mod->create<StructMember>(source, mod->RegisterSymbol(name), type,
|
return program->create<StructMember>(source, program->RegisterSymbol(name),
|
||||||
StructMemberDecorationList{});
|
type, StructMemberDecorationList{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a StructMember
|
/// Creates a StructMember
|
||||||
|
@ -658,8 +658,8 @@ class Builder {
|
||||||
/// @param type the struct member type
|
/// @param type the struct member type
|
||||||
/// @returns the struct member pointer
|
/// @returns the struct member pointer
|
||||||
StructMember* Member(const std::string& name, type::Type* type) {
|
StructMember* Member(const std::string& name, type::Type* type) {
|
||||||
return mod->create<StructMember>(source_, mod->RegisterSymbol(name), type,
|
return program->create<StructMember>(source_, program->RegisterSymbol(name),
|
||||||
StructMemberDecorationList{});
|
type, StructMemberDecorationList{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a StructMember
|
/// Creates a StructMember
|
||||||
|
@ -670,8 +670,8 @@ class Builder {
|
||||||
StructMember* Member(const std::string& name,
|
StructMember* Member(const std::string& name,
|
||||||
type::Type* type,
|
type::Type* type,
|
||||||
StructMemberDecorationList decos) {
|
StructMemberDecorationList decos) {
|
||||||
return mod->create<StructMember>(source_, mod->RegisterSymbol(name), type,
|
return program->create<StructMember>(source_, program->RegisterSymbol(name),
|
||||||
decos);
|
type, decos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new Node owned by the Module, with the explicit Source.
|
/// Creates a new Node owned by the Module, with the explicit Source.
|
||||||
|
@ -682,7 +682,7 @@ class Builder {
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
traits::EnableIfIsType<T, Node>* create(const Source& source,
|
traits::EnableIfIsType<T, Node>* create(const Source& source,
|
||||||
ARGS&&... args) {
|
ARGS&&... args) {
|
||||||
return mod->create<T>(source, std::forward<ARGS>(args)...);
|
return program->create<T>(source, std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new Node owned by the Module, with the explicit Source.
|
/// Creates a new Node owned by the Module, with the explicit Source.
|
||||||
|
@ -692,7 +692,7 @@ class Builder {
|
||||||
/// @returns the node pointer
|
/// @returns the node pointer
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
traits::EnableIfIsType<T, Node>* create(Source&& source, ARGS&&... args) {
|
traits::EnableIfIsType<T, Node>* create(Source&& source, ARGS&&... args) {
|
||||||
return mod->create<T>(std::move(source), std::forward<ARGS>(args)...);
|
return program->create<T>(std::move(source), std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new type::Type owned by the Module, using the Builder's
|
/// Creates a new type::Type owned by the Module, using the Builder's
|
||||||
|
@ -702,7 +702,7 @@ class Builder {
|
||||||
/// @returns the node pointer
|
/// @returns the node pointer
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
traits::EnableIfIsType<T, Node>* create(ARGS&&... args) {
|
traits::EnableIfIsType<T, Node>* create(ARGS&&... args) {
|
||||||
return mod->create<T>(source_, std::forward<ARGS>(args)...);
|
return program->create<T>(source_, std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new type::Type owned by the Module.
|
/// Creates a new type::Type owned by the Module.
|
||||||
|
@ -720,7 +720,7 @@ class Builder {
|
||||||
traits::EnableIfIsType<T, type::Type>* create(ARGS&&... args) {
|
traits::EnableIfIsType<T, type::Type>* create(ARGS&&... args) {
|
||||||
static_assert(std::is_base_of<type::Type, T>::value,
|
static_assert(std::is_base_of<type::Type, T>::value,
|
||||||
"T does not derive from type::Type");
|
"T does not derive from type::Type");
|
||||||
return mod->create<T>(std::forward<ARGS>(args)...);
|
return program->create<T>(std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the current builder source to `src`
|
/// Sets the current builder source to `src`
|
||||||
|
@ -731,11 +731,14 @@ class Builder {
|
||||||
/// @param loc the Source used for future create() calls
|
/// @param loc the Source used for future create() calls
|
||||||
void SetSource(const Source::Location& loc) { source_ = Source(loc); }
|
void SetSource(const Source::Location& loc) { source_ = Source(loc); }
|
||||||
|
|
||||||
/// The builder module
|
/// The builder program
|
||||||
Module* const mod;
|
Program* const program;
|
||||||
/// The builder types
|
/// The builder types
|
||||||
const TypesBuilder ty;
|
const TypesBuilder ty;
|
||||||
|
|
||||||
|
/// [DEPRECATED] Temporary alias to #program
|
||||||
|
Program* const mod;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Called whenever a new variable is built with `Var()`.
|
/// Called whenever a new variable is built with `Var()`.
|
||||||
virtual void OnVariableBuilt(Variable*) {}
|
virtual void OnVariableBuilt(Variable*) {}
|
||||||
|
@ -744,11 +747,11 @@ class Builder {
|
||||||
Source source_;
|
Source source_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// BuilderWithModule is a `Builder` that constructs and owns its `Module`.
|
/// BuilderWithProgram is a `Builder` that constructs and owns its `Program`.
|
||||||
class BuilderWithModule : public Builder {
|
class BuilderWithProgram : public Builder {
|
||||||
public:
|
public:
|
||||||
BuilderWithModule();
|
BuilderWithProgram();
|
||||||
~BuilderWithModule() override;
|
~BuilderWithProgram() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! @cond Doxygen_Suppress
|
//! @cond Doxygen_Suppress
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/builtin_decoration.h"
|
#include "src/ast/builtin_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::BuiltinDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::BuiltinDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/call_expression.h"
|
#include "src/ast/call_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::CallExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::CallExpression);
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "src/ast/call_statement.h"
|
#include "src/ast/call_statement.h"
|
||||||
|
|
||||||
#include "src/ast/call_expression.h"
|
#include "src/ast/call_expression.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::CallStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::CallStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/case_statement.h"
|
#include "src/ast/case_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::CaseStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::CaseStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/constant_id_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::ConstantIdDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::ConstantIdDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/continue_statement.h"
|
#include "src/ast/continue_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::ContinueStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::ContinueStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/discard_statement.h"
|
#include "src/ast/discard_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::DiscardStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::DiscardStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/else_statement.h"
|
#include "src/ast/else_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::ElseStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::ElseStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/fallthrough_statement.h"
|
#include "src/ast/fallthrough_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::FallthroughStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::FallthroughStatement);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::FloatLiteral);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::FloatLiteral);
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
#include "src/ast/variable.h"
|
#include "src/ast/variable.h"
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
#include "src/type/multisampled_texture_type.h"
|
#include "src/type/multisampled_texture_type.h"
|
||||||
#include "src/type/sampled_texture_type.h"
|
#include "src/type/sampled_texture_type.h"
|
||||||
#include "src/type/texture_type.h"
|
#include "src/type/texture_type.h"
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/group_decoration.h"
|
#include "src/ast/group_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::GroupDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::GroupDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::IdentifierExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::IdentifierExpression);
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "src/ast/if_statement.h"
|
#include "src/ast/if_statement.h"
|
||||||
|
|
||||||
#include "src/ast/else_statement.h"
|
#include "src/ast/else_statement.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::IfStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::IfStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/location_decoration.h"
|
#include "src/ast/location_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::LocationDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::LocationDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/loop_statement.h"
|
#include "src/ast/loop_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::LoopStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::LoopStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/member_accessor_expression.h"
|
#include "src/ast/member_accessor_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::MemberAccessorExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::MemberAccessorExpression);
|
||||||
|
|
||||||
|
|
|
@ -14,117 +14,10 @@
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/module.h"
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "src/clone_context.h"
|
|
||||||
#include "src/type/struct_type.h"
|
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
Module::Module() = default;
|
// Placeholder
|
||||||
|
|
||||||
Module::Module(Module&&) = default;
|
|
||||||
|
|
||||||
Module& Module::operator=(Module&& rhs) = default;
|
|
||||||
|
|
||||||
Module::~Module() = default;
|
|
||||||
|
|
||||||
Module Module::Clone() const {
|
|
||||||
Module out;
|
|
||||||
CloneContext(&out, this).Clone();
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::Clone(CloneContext* ctx) const {
|
|
||||||
for (auto* ty : constructed_types_) {
|
|
||||||
ctx->dst->constructed_types_.emplace_back(ctx->Clone(ty));
|
|
||||||
}
|
|
||||||
for (auto* var : global_variables_) {
|
|
||||||
ctx->dst->global_variables_.emplace_back(ctx->Clone(var));
|
|
||||||
}
|
|
||||||
for (auto* func : functions_) {
|
|
||||||
ctx->dst->functions_.emplace_back(ctx->Clone(func));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol Module::RegisterSymbol(const std::string& name) {
|
|
||||||
return symbol_table_.Register(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol Module::GetSymbol(const std::string& name) const {
|
|
||||||
return symbol_table_.GetSymbol(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Module::SymbolToName(const Symbol sym) const {
|
|
||||||
return symbol_table_.NameFor(sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Module::IsValid() const {
|
|
||||||
for (auto* var : global_variables_) {
|
|
||||||
if (var == nullptr || !var->IsValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto* const ty : constructed_types_) {
|
|
||||||
if (ty == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (auto* alias = ty->As<type::Alias>()) {
|
|
||||||
if (alias->type() == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (auto* str = alias->type()->As<type::Struct>()) {
|
|
||||||
if (!str->symbol().IsValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (auto* str = ty->As<type::Struct>()) {
|
|
||||||
if (!str->symbol().IsValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto* func : functions_) {
|
|
||||||
if (func == nullptr || !func->IsValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Module::to_str() const {
|
|
||||||
std::ostringstream out;
|
|
||||||
|
|
||||||
out << "Module{" << std::endl;
|
|
||||||
const auto indent = 2;
|
|
||||||
for (auto* const ty : constructed_types_) {
|
|
||||||
for (size_t i = 0; i < indent; ++i) {
|
|
||||||
out << " ";
|
|
||||||
}
|
|
||||||
if (auto* alias = ty->As<type::Alias>()) {
|
|
||||||
out << alias->symbol().to_str() << " -> " << alias->type()->type_name()
|
|
||||||
<< std::endl;
|
|
||||||
if (auto* str = alias->type()->As<type::Struct>()) {
|
|
||||||
str->impl()->to_str(out, indent);
|
|
||||||
}
|
|
||||||
} else if (auto* str = ty->As<type::Struct>()) {
|
|
||||||
out << str->symbol().to_str() << " ";
|
|
||||||
str->impl()->to_str(out, indent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto* var : global_variables_) {
|
|
||||||
var->to_str(out, indent);
|
|
||||||
}
|
|
||||||
for (auto* func : functions_) {
|
|
||||||
func->to_str(out, indent);
|
|
||||||
}
|
|
||||||
out << "}" << std::endl;
|
|
||||||
|
|
||||||
return out.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
141
src/ast/module.h
141
src/ast/module.h
|
@ -15,149 +15,10 @@
|
||||||
#ifndef SRC_AST_MODULE_H_
|
#ifndef SRC_AST_MODULE_H_
|
||||||
#define SRC_AST_MODULE_H_
|
#define SRC_AST_MODULE_H_
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "src/ast/function.h"
|
|
||||||
#include "src/ast/variable.h"
|
|
||||||
#include "src/block_allocator.h"
|
|
||||||
#include "src/symbol_table.h"
|
|
||||||
#include "src/traits.h"
|
|
||||||
#include "src/type/alias_type.h"
|
|
||||||
#include "src/type/type_manager.h"
|
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
/// Represents all the source in a given program.
|
// Placeholder
|
||||||
class Module {
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
Module();
|
|
||||||
|
|
||||||
/// Move constructor
|
|
||||||
Module(Module&&);
|
|
||||||
|
|
||||||
/// Move assignment operator
|
|
||||||
/// @param rhs the Module to move
|
|
||||||
/// @return this Module
|
|
||||||
Module& operator=(Module&& rhs);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
~Module();
|
|
||||||
|
|
||||||
/// @return a deep copy of this module
|
|
||||||
Module Clone() const;
|
|
||||||
|
|
||||||
/// Clone this module into `ctx->mod` using the provided CloneContext
|
|
||||||
/// The module will be cloned in this order:
|
|
||||||
/// * Constructed types
|
|
||||||
/// * Global variables
|
|
||||||
/// * Functions
|
|
||||||
/// @param ctx the clone context
|
|
||||||
void Clone(CloneContext* ctx) const;
|
|
||||||
|
|
||||||
/// Add a global variable to the module
|
|
||||||
/// @param var the variable to add
|
|
||||||
void AddGlobalVariable(Variable* var) { global_variables_.push_back(var); }
|
|
||||||
/// @returns the global variables for the module
|
|
||||||
const VariableList& global_variables() const { return global_variables_; }
|
|
||||||
|
|
||||||
/// @returns the global variables for the module
|
|
||||||
VariableList& global_variables() { return global_variables_; }
|
|
||||||
|
|
||||||
/// Adds a constructed type to the module.
|
|
||||||
/// The type must be an alias or a struct.
|
|
||||||
/// @param type the constructed type to add
|
|
||||||
void AddConstructedType(type::Type* type) {
|
|
||||||
constructed_types_.push_back(type);
|
|
||||||
}
|
|
||||||
/// @returns the constructed types in the module
|
|
||||||
const std::vector<type::Type*>& constructed_types() const {
|
|
||||||
return constructed_types_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @returns the functions declared in the translation unit
|
|
||||||
const FunctionList& Functions() const { return functions_; }
|
|
||||||
|
|
||||||
/// @returns the functions declared in the translation unit
|
|
||||||
FunctionList& Functions() { return functions_; }
|
|
||||||
|
|
||||||
/// @returns true if all required fields in the AST are present.
|
|
||||||
bool IsValid() const;
|
|
||||||
|
|
||||||
/// @returns a string representation of the module
|
|
||||||
std::string to_str() const;
|
|
||||||
|
|
||||||
/// Creates a new Node owned by the Module. When the Module is
|
|
||||||
/// destructed, the Node will also be destructed.
|
|
||||||
/// @param args the arguments to pass to the type constructor
|
|
||||||
/// @returns the node pointer
|
|
||||||
template <typename T, typename... ARGS>
|
|
||||||
traits::EnableIfIsType<T, Node>* create(ARGS&&... args) {
|
|
||||||
return ast_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new type::Type owned by the Module.
|
|
||||||
/// When the Module is destructed, owned Module and the returned
|
|
||||||
/// `Type` will also be destructed.
|
|
||||||
/// Types are unique (de-aliased), and so calling create() for the same `T`
|
|
||||||
/// and arguments will return the same pointer.
|
|
||||||
/// @warning Use this method to acquire a type only if all of its type
|
|
||||||
/// information is provided in the constructor arguments `args`.<br>
|
|
||||||
/// If the type requires additional configuration after construction that
|
|
||||||
/// affect its fundamental type, build the type with `std::make_unique`, make
|
|
||||||
/// any necessary alterations and then call unique_type() instead.
|
|
||||||
/// @param args the arguments to pass to the type constructor
|
|
||||||
/// @returns the de-aliased type pointer
|
|
||||||
template <typename T, typename... ARGS>
|
|
||||||
traits::EnableIfIsType<T, type::Type>* create(ARGS&&... args) {
|
|
||||||
static_assert(std::is_base_of<type::Type, T>::value,
|
|
||||||
"T does not derive from type::Type");
|
|
||||||
return type_mgr_.Get<T>(std::forward<ARGS>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns all the declared types in the module
|
|
||||||
/// @returns the mapping from name string to type.
|
|
||||||
const std::unordered_map<std::string, type::Type*>& types() {
|
|
||||||
return type_mgr_.types();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @returns all the declared nodes in the module
|
|
||||||
BlockAllocator<Node>::View nodes() { return ast_nodes_.Objects(); }
|
|
||||||
|
|
||||||
/// Registers `name` as a symbol
|
|
||||||
/// @param name the name to register
|
|
||||||
/// @returns the symbol for the `name`. If `name` is already registered the
|
|
||||||
/// previously generated symbol will be returned.
|
|
||||||
Symbol RegisterSymbol(const std::string& name);
|
|
||||||
|
|
||||||
/// Returns the symbol for `name`
|
|
||||||
/// @param name the name to lookup
|
|
||||||
/// @returns the symbol for name or symbol::kInvalid
|
|
||||||
Symbol GetSymbol(const std::string& name) const;
|
|
||||||
|
|
||||||
/// Returns the `name` for `sym`
|
|
||||||
/// @param sym the symbol to retrieve the name for
|
|
||||||
/// @returns the use provided `name` for the symbol or "" if not found
|
|
||||||
std::string SymbolToName(const Symbol sym) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Module(const Module&) = delete;
|
|
||||||
|
|
||||||
SymbolTable symbol_table_;
|
|
||||||
VariableList global_variables_;
|
|
||||||
// The constructed types are owned by the type manager
|
|
||||||
std::vector<type::Type*> constructed_types_;
|
|
||||||
FunctionList functions_;
|
|
||||||
BlockAllocator<Node> ast_nodes_;
|
|
||||||
type::Manager type_mgr_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
|
@ -108,12 +108,12 @@ fn main() -> void {
|
||||||
|
|
||||||
)");
|
)");
|
||||||
|
|
||||||
// Parse the wgsl, create the src module
|
// Parse the wgsl, create the src program
|
||||||
reader::wgsl::Parser parser(&file);
|
reader::wgsl::Parser parser(&file);
|
||||||
ASSERT_TRUE(parser.Parse()) << parser.error();
|
ASSERT_TRUE(parser.Parse()) << parser.error();
|
||||||
auto src = parser.module();
|
auto src = parser.program();
|
||||||
|
|
||||||
// Clone the src module to dst
|
// Clone the src program to dst
|
||||||
auto dst = src.Clone();
|
auto dst = src.Clone();
|
||||||
|
|
||||||
// Expect the AST printed with to_str() to match
|
// Expect the AST printed with to_str() to match
|
||||||
|
@ -138,24 +138,25 @@ fn main() -> void {
|
||||||
<< dst_type.second->type_name();
|
<< dst_type.second->type_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regenerate the wgsl for the src module. We use this instead of the original
|
// Regenerate the wgsl for the src program. We use this instead of the
|
||||||
// source so that reformatting doesn't impact the final wgsl comparision.
|
// original source so that reformatting doesn't impact the final wgsl
|
||||||
// Note that the src module is moved into the generator and this generator has
|
// comparison.
|
||||||
// a limited scope, so that the src module is released before we attempt to
|
|
||||||
// print the dst module.
|
|
||||||
// This guarantee that all the source module nodes and types are destructed
|
|
||||||
// and freed.
|
|
||||||
// ASAN should error if there's any remaining references in dst when we try to
|
|
||||||
// reconstruct the WGSL.
|
|
||||||
std::string src_wgsl;
|
std::string src_wgsl;
|
||||||
{
|
{
|
||||||
writer::wgsl::Generator src_gen(std::move(src));
|
tint::writer::wgsl::Generator src_gen(&src);
|
||||||
ASSERT_TRUE(src_gen.Generate()) << src_gen.error();
|
ASSERT_TRUE(src_gen.Generate());
|
||||||
src_wgsl = src_gen.result();
|
src_wgsl = src_gen.result();
|
||||||
|
|
||||||
|
// Move the src program to a temporary that'll be dropped, so that the src
|
||||||
|
// program is released before we attempt to print the dst program. This
|
||||||
|
// guarantee that all the source program nodes and types are destructed and
|
||||||
|
// freed. ASAN should error if there's any remaining references in dst when
|
||||||
|
// we try to reconstruct the WGSL.
|
||||||
|
auto tmp = std::move(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the dst module, check it matches the original source
|
// Print the dst program, check it matches the original source
|
||||||
writer::wgsl::Generator dst_gen(std::move(dst));
|
tint::writer::wgsl::Generator dst_gen(&dst);
|
||||||
ASSERT_TRUE(dst_gen.Generate());
|
ASSERT_TRUE(dst_gen.Generate());
|
||||||
auto dst_wgsl = dst_gen.result();
|
auto dst_wgsl = dst_gen.result();
|
||||||
ASSERT_EQ(src_wgsl, dst_wgsl);
|
ASSERT_EQ(src_wgsl, dst_wgsl);
|
||||||
|
|
|
@ -32,8 +32,6 @@ class Type;
|
||||||
|
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
class Module;
|
|
||||||
|
|
||||||
/// AST base class node
|
/// AST base class node
|
||||||
class Node : public Castable<Node> {
|
class Node : public Castable<Node> {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/null_literal.h"
|
#include "src/ast/null_literal.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::NullLiteral);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::NullLiteral);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/return_statement.h"
|
#include "src/ast/return_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::ReturnStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::ReturnStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/scalar_constructor_expression.h"
|
#include "src/ast/scalar_constructor_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::ScalarConstructorExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::ScalarConstructorExpression);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/sint_literal.h"
|
#include "src/ast/sint_literal.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::SintLiteral);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::SintLiteral);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/stage_decoration.h"
|
#include "src/ast/stage_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::StageDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::StageDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/stride_decoration.h"
|
#include "src/ast/stride_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::StrideDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::StrideDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
|
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::Struct);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::Struct);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/struct_block_decoration.h"
|
#include "src/ast/struct_block_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructBlockDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructBlockDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
|
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMember);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMember);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMemberOffsetDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMemberOffsetDecoration);
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
|
|
||||||
#include "src/ast/case_statement.h"
|
#include "src/ast/case_statement.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::SwitchStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::SwitchStatement);
|
||||||
|
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/builder.h"
|
#include "src/ast/builder.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/demangler.h"
|
#include "src/demangler.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
/// Helper class for testing
|
/// Helper class for testing
|
||||||
template <typename BASE>
|
template <typename BASE>
|
||||||
class TestHelperBase : public BASE, public BuilderWithModule {
|
class TestHelperBase : public BASE, public BuilderWithProgram {
|
||||||
public:
|
public:
|
||||||
/// Demangles the given string
|
/// Demangles the given string
|
||||||
/// @param s the string to demangle
|
/// @param s the string to demangle
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::TypeConstructorExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::TypeConstructorExpression);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/uint_literal.h"
|
#include "src/ast/uint_literal.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::UintLiteral);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::UintLiteral);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/unary_op_expression.h"
|
#include "src/ast/unary_op_expression.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::UnaryOpExpression);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::UnaryOpExpression);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "src/ast/constant_id_decoration.h"
|
#include "src/ast/constant_id_decoration.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::Variable);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::Variable);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::VariableDeclStatement);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::VariableDeclStatement);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "src/ast/workgroup_decoration.h"
|
#include "src/ast/workgroup_decoration.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_CLASS_ID(tint::ast::WorkgroupDecoration);
|
TINT_INSTANTIATE_CLASS_ID(tint::ast::WorkgroupDecoration);
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
#include "src/clone_context.h"
|
#include "src/clone_context.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
#include "src/program.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
||||||
CloneContext::CloneContext(ast::Module* to, ast::Module const* from)
|
CloneContext::CloneContext(Program* to, Program const* from)
|
||||||
: dst(to), src(from) {}
|
: dst(to), src(from) {}
|
||||||
CloneContext::~CloneContext() = default;
|
CloneContext::~CloneContext() = default;
|
||||||
|
|
||||||
|
|
|
@ -27,29 +27,27 @@
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
namespace ast {
|
class Program;
|
||||||
class Module;
|
|
||||||
} // namespace ast
|
|
||||||
|
|
||||||
/// CloneContext holds the state used while cloning AST nodes and types.
|
/// CloneContext holds the state used while cloning AST nodes and types.
|
||||||
class CloneContext {
|
class CloneContext {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param to the target module to clone into
|
/// @param to the target program to clone into
|
||||||
/// @param from the source module to clone from
|
/// @param from the source program to clone from
|
||||||
CloneContext(ast::Module* to, ast::Module const* from);
|
CloneContext(Program* to, Program const* from);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~CloneContext();
|
~CloneContext();
|
||||||
|
|
||||||
/// Clones the Node or type::Type `a` into the module #dst if `a` is not
|
/// Clones the Node or type::Type `a` into the program #dst if `a` is not
|
||||||
/// null. If `a` is null, then Clone() returns null. If `a` has been cloned
|
/// null. If `a` is null, then Clone() returns null. If `a` has been cloned
|
||||||
/// already by this CloneContext then the same cloned pointer is returned.
|
/// already by this CloneContext then the same cloned pointer is returned.
|
||||||
///
|
///
|
||||||
/// Clone() may use a function registered with ReplaceAll() to create a
|
/// Clone() may use a function registered with ReplaceAll() to create a
|
||||||
/// transformed version of the object. See ReplaceAll() for more information.
|
/// transformed version of the object. See ReplaceAll() for more information.
|
||||||
///
|
///
|
||||||
/// The Node or type::Type `a` must be owned by the module #src.
|
/// The Node or type::Type `a` must be owned by the program #src.
|
||||||
///
|
///
|
||||||
/// @note Semantic information such as resolved expression type and intrinsic
|
/// @note Semantic information such as resolved expression type and intrinsic
|
||||||
/// information is not cloned.
|
/// information is not cloned.
|
||||||
|
@ -78,7 +76,7 @@ class CloneContext {
|
||||||
|
|
||||||
/// Clones the Source `s` into `dst`
|
/// Clones the Source `s` into `dst`
|
||||||
/// TODO(bclayton) - Currently this 'clone' is a shallow copy. If/when
|
/// TODO(bclayton) - Currently this 'clone' is a shallow copy. If/when
|
||||||
/// `Source.File`s are owned by the `Module` this should make a copy of the
|
/// `Source.File`s are owned by the Program this should make a copy of the
|
||||||
/// file.
|
/// file.
|
||||||
/// @param s the `Source` to clone
|
/// @param s the `Source` to clone
|
||||||
/// @return the cloned source
|
/// @return the cloned source
|
||||||
|
@ -86,15 +84,15 @@ class CloneContext {
|
||||||
|
|
||||||
/// Clones the Symbol `s` into `dst`
|
/// Clones the Symbol `s` into `dst`
|
||||||
///
|
///
|
||||||
/// The Symbol `s` must be owned by the module #src.
|
/// The Symbol `s` must be owned by the program #src.
|
||||||
///
|
///
|
||||||
/// @param s the Symbol to clone
|
/// @param s the Symbol to clone
|
||||||
/// @return the cloned source
|
/// @return the cloned source
|
||||||
Symbol Clone(const Symbol& s) const;
|
Symbol Clone(const Symbol& s) const;
|
||||||
|
|
||||||
/// Clones each of the elements of the vector `v` into the module #dst->
|
/// Clones each of the elements of the vector `v` into the program #dst.
|
||||||
///
|
///
|
||||||
/// All the elements of the vector `v` must be owned by the module #src.
|
/// All the elements of the vector `v` must be owned by the program #src.
|
||||||
///
|
///
|
||||||
/// @param v the vector to clone
|
/// @param v the vector to clone
|
||||||
/// @return the cloned vector
|
/// @return the cloned vector
|
||||||
|
@ -147,14 +145,14 @@ class CloneContext {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clone performs the clone of the entire module #src to #dst.
|
/// Clone performs the clone of the entire program #src to #dst.
|
||||||
void Clone();
|
void Clone();
|
||||||
|
|
||||||
/// The target module to clone into.
|
/// The target program to clone into.
|
||||||
ast::Module* const dst;
|
Program* const dst;
|
||||||
|
|
||||||
/// The source module to clone from.
|
/// The source program to clone from.
|
||||||
ast::Module const* const src;
|
Program const* const src;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using Transform = std::function<CastableBase*(CastableBase*)>;
|
using Transform = std::function<CastableBase*(CastableBase*)>;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
#include "src/program.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -44,7 +44,7 @@ struct Replaceable : public Castable<Replaceable, Cloneable> {};
|
||||||
struct Replacement : public Castable<Replacement, Replaceable> {};
|
struct Replacement : public Castable<Replacement, Replaceable> {};
|
||||||
|
|
||||||
TEST(CloneContext, Clone) {
|
TEST(CloneContext, Clone) {
|
||||||
ast::Module original;
|
Program original;
|
||||||
auto* original_root = original.create<Cloneable>();
|
auto* original_root = original.create<Cloneable>();
|
||||||
original_root->a = original.create<Cloneable>();
|
original_root->a = original.create<Cloneable>();
|
||||||
original_root->a->b = original.create<Cloneable>();
|
original_root->a->b = original.create<Cloneable>();
|
||||||
|
@ -63,7 +63,7 @@ TEST(CloneContext, Clone) {
|
||||||
//
|
//
|
||||||
// C: Clonable
|
// C: Clonable
|
||||||
|
|
||||||
ast::Module cloned;
|
Program cloned;
|
||||||
auto* cloned_root = CloneContext(&cloned, &original).Clone(original_root);
|
auto* cloned_root = CloneContext(&cloned, &original).Clone(original_root);
|
||||||
|
|
||||||
EXPECT_NE(cloned_root->a, nullptr);
|
EXPECT_NE(cloned_root->a, nullptr);
|
||||||
|
@ -88,7 +88,7 @@ TEST(CloneContext, Clone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CloneContext, CloneWithReplacements) {
|
TEST(CloneContext, CloneWithReplacements) {
|
||||||
ast::Module original;
|
Program original;
|
||||||
auto* original_root = original.create<Cloneable>();
|
auto* original_root = original.create<Cloneable>();
|
||||||
original_root->a = original.create<Cloneable>();
|
original_root->a = original.create<Cloneable>();
|
||||||
original_root->a->b = original.create<Replaceable>();
|
original_root->a->b = original.create<Replaceable>();
|
||||||
|
@ -107,7 +107,7 @@ TEST(CloneContext, CloneWithReplacements) {
|
||||||
// C: Clonable
|
// C: Clonable
|
||||||
// R: Replaceable
|
// R: Replaceable
|
||||||
|
|
||||||
ast::Module cloned;
|
Program cloned;
|
||||||
auto* cloned_root = CloneContext(&cloned, &original)
|
auto* cloned_root = CloneContext(&cloned, &original)
|
||||||
.ReplaceAll([&](CloneContext* ctx, Replaceable* in) {
|
.ReplaceAll([&](CloneContext* ctx, Replaceable* in) {
|
||||||
auto* out = cloned.create<Replacement>();
|
auto* out = cloned.create<Replacement>();
|
||||||
|
|
|
@ -26,7 +26,7 @@ Demangler::Demangler() = default;
|
||||||
|
|
||||||
Demangler::~Demangler() = default;
|
Demangler::~Demangler() = default;
|
||||||
|
|
||||||
std::string Demangler::Demangle(const ast::Module& mod,
|
std::string Demangler::Demangle(const Program& program,
|
||||||
const std::string& str) const {
|
const std::string& str) const {
|
||||||
auto ret = str;
|
auto ret = str;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ std::string Demangler::Demangle(const ast::Module& mod,
|
||||||
auto id = ret.substr(start_idx, len);
|
auto id = ret.substr(start_idx, len);
|
||||||
|
|
||||||
Symbol sym(std::stoi(id));
|
Symbol sym(std::stoi(id));
|
||||||
auto name = mod.SymbolToName(sym);
|
auto name = program.SymbolToName(sym);
|
||||||
ret.replace(idx, end_idx - idx, name);
|
ret.replace(idx, end_idx - idx, name);
|
||||||
|
|
||||||
pos = idx + name.length();
|
pos = idx + name.length();
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
#include "src/program.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ class Demangler {
|
||||||
~Demangler();
|
~Demangler();
|
||||||
|
|
||||||
/// Transforms given string and replaces any symbols with original names
|
/// Transforms given string and replaces any symbols with original names
|
||||||
/// @param mod the module where the symbols are registered
|
/// @param program the program where the symbols are registered
|
||||||
/// @param str the string to replace
|
/// @param str the string to replace
|
||||||
/// @returns the string with any symbol replacements performed.
|
/// @returns the string with any symbol replacements performed.
|
||||||
std::string Demangle(const ast::Module& mod, const std::string& str) const;
|
std::string Demangle(const Program& program, const std::string& str) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "src/demangler.h"
|
#include "src/demangler.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -22,7 +23,7 @@ namespace {
|
||||||
using DemanglerTest = testing::Test;
|
using DemanglerTest = testing::Test;
|
||||||
|
|
||||||
TEST_F(DemanglerTest, NoSymbols) {
|
TEST_F(DemanglerTest, NoSymbols) {
|
||||||
ast::Module m;
|
Program m;
|
||||||
m.RegisterSymbol("sym1");
|
m.RegisterSymbol("sym1");
|
||||||
|
|
||||||
Demangler d;
|
Demangler d;
|
||||||
|
@ -30,7 +31,7 @@ TEST_F(DemanglerTest, NoSymbols) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DemanglerTest, Symbol) {
|
TEST_F(DemanglerTest, Symbol) {
|
||||||
ast::Module m;
|
Program m;
|
||||||
m.RegisterSymbol("sym1");
|
m.RegisterSymbol("sym1");
|
||||||
|
|
||||||
Demangler d;
|
Demangler d;
|
||||||
|
@ -38,7 +39,7 @@ TEST_F(DemanglerTest, Symbol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DemanglerTest, MultipleSymbols) {
|
TEST_F(DemanglerTest, MultipleSymbols) {
|
||||||
ast::Module m;
|
Program m;
|
||||||
m.RegisterSymbol("sym1");
|
m.RegisterSymbol("sym1");
|
||||||
m.RegisterSymbol("sym2");
|
m.RegisterSymbol("sym2");
|
||||||
|
|
||||||
|
|
|
@ -43,29 +43,27 @@
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace inspector {
|
namespace inspector {
|
||||||
|
|
||||||
Inspector::Inspector(const ast::Module& module) : module_(module) {}
|
Inspector::Inspector(const Program* program) : program_(*program) {}
|
||||||
|
|
||||||
Inspector::Inspector(const Program* program) : Inspector(program->module) {}
|
|
||||||
|
|
||||||
Inspector::~Inspector() = default;
|
Inspector::~Inspector() = default;
|
||||||
|
|
||||||
std::vector<EntryPoint> Inspector::GetEntryPoints() {
|
std::vector<EntryPoint> Inspector::GetEntryPoints() {
|
||||||
std::vector<EntryPoint> result;
|
std::vector<EntryPoint> result;
|
||||||
|
|
||||||
for (auto* func : module_.Functions()) {
|
for (auto* func : program_.Functions()) {
|
||||||
if (!func->IsEntryPoint()) {
|
if (!func->IsEntryPoint()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntryPoint entry_point;
|
EntryPoint entry_point;
|
||||||
entry_point.name = module_.SymbolToName(func->symbol());
|
entry_point.name = program_.SymbolToName(func->symbol());
|
||||||
entry_point.remapped_name = module_.SymbolToName(func->symbol());
|
entry_point.remapped_name = program_.SymbolToName(func->symbol());
|
||||||
entry_point.stage = func->pipeline_stage();
|
entry_point.stage = func->pipeline_stage();
|
||||||
std::tie(entry_point.workgroup_size_x, entry_point.workgroup_size_y,
|
std::tie(entry_point.workgroup_size_x, entry_point.workgroup_size_y,
|
||||||
entry_point.workgroup_size_z) = func->workgroup_size();
|
entry_point.workgroup_size_z) = func->workgroup_size();
|
||||||
|
|
||||||
for (auto* var : func->referenced_module_variables()) {
|
for (auto* var : func->referenced_module_variables()) {
|
||||||
auto name = module_.SymbolToName(var->symbol());
|
auto name = program_.SymbolToName(var->symbol());
|
||||||
if (var->HasBuiltinDecoration()) {
|
if (var->HasBuiltinDecoration()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +106,7 @@ std::string Inspector::GetRemappedNameForEntryPoint(
|
||||||
|
|
||||||
std::map<uint32_t, Scalar> Inspector::GetConstantIDs() {
|
std::map<uint32_t, Scalar> Inspector::GetConstantIDs() {
|
||||||
std::map<uint32_t, Scalar> result;
|
std::map<uint32_t, Scalar> result;
|
||||||
for (auto* var : module_.global_variables()) {
|
for (auto* var : program_.global_variables()) {
|
||||||
if (!var->HasConstantIdDecoration()) {
|
if (!var->HasConstantIdDecoration()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +283,7 @@ std::vector<ResourceBinding> Inspector::GetMultisampledTextureResourceBindings(
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Function* Inspector::FindEntryPointByName(const std::string& name) {
|
ast::Function* Inspector::FindEntryPointByName(const std::string& name) {
|
||||||
auto* func = module_.Functions().Find(module_.GetSymbol(name));
|
auto* func = program_.Functions().Find(program_.GetSymbol(name));
|
||||||
if (!func) {
|
if (!func) {
|
||||||
error_ += name + " was not found!";
|
error_ += name + " was not found!";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/ast/pipeline_stage.h"
|
#include "src/ast/pipeline_stage.h"
|
||||||
#include "src/inspector/entry_point.h"
|
#include "src/inspector/entry_point.h"
|
||||||
#include "src/inspector/scalar.h"
|
#include "src/inspector/scalar.h"
|
||||||
|
@ -68,13 +67,9 @@ struct ResourceBinding {
|
||||||
SampledKind sampled_kind;
|
SampledKind sampled_kind;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Extracts information from a module
|
/// Extracts information from a program
|
||||||
class Inspector {
|
class Inspector {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
|
||||||
/// @param module Shader module to extract information from.
|
|
||||||
explicit Inspector(const ast::Module& module);
|
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program Shader program to extract information from.
|
/// @param program Shader program to extract information from.
|
||||||
explicit Inspector(const Program* program);
|
explicit Inspector(const Program* program);
|
||||||
|
@ -134,7 +129,7 @@ class Inspector {
|
||||||
const std::string& entry_point);
|
const std::string& entry_point);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ast::Module& module_;
|
const Program& program_;
|
||||||
std::string error_;
|
std::string error_;
|
||||||
|
|
||||||
/// @param name name of the entry point to find
|
/// @param name name of the entry point to find
|
||||||
|
|
|
@ -67,11 +67,11 @@ namespace tint {
|
||||||
namespace inspector {
|
namespace inspector {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class InspectorHelper : public ast::BuilderWithModule {
|
class InspectorHelper : public ast::BuilderWithProgram {
|
||||||
public:
|
public:
|
||||||
InspectorHelper()
|
InspectorHelper()
|
||||||
: td_(std::make_unique<TypeDeterminer>(mod)),
|
: td_(std::make_unique<TypeDeterminer>(mod)),
|
||||||
inspector_(std::make_unique<Inspector>(*mod)),
|
inspector_(std::make_unique<Inspector>(mod)),
|
||||||
sampler_type_(type::SamplerKind::kSampler),
|
sampler_type_(type::SamplerKind::kSampler),
|
||||||
comparison_sampler_type_(type::SamplerKind::kComparisonSampler) {}
|
comparison_sampler_type_(type::SamplerKind::kComparisonSampler) {}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
return {struct_type, std::move(access_type)};
|
return {struct_type, std::move(access_type)};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a binding variable with a struct type to the module
|
/// Adds a binding variable with a struct type to the program
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param type the type to use
|
/// @param type the type to use
|
||||||
/// @param storage_class the storage class to use
|
/// @param storage_class the storage class to use
|
||||||
|
@ -337,7 +337,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
mod->AddGlobalVariable(var);
|
mod->AddGlobalVariable(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an uniform buffer variable to the module
|
/// Adds an uniform buffer variable to the program
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param type the type to use
|
/// @param type the type to use
|
||||||
/// @param group the binding/group/ to use for the uniform buffer
|
/// @param group the binding/group/ to use for the uniform buffer
|
||||||
|
@ -349,7 +349,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
AddBinding(name, type, ast::StorageClass::kUniform, group, binding);
|
AddBinding(name, type, ast::StorageClass::kUniform, group, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a storage buffer variable to the module
|
/// Adds a storage buffer variable to the program
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param type the type to use
|
/// @param type the type to use
|
||||||
/// @param group the binding/group to use for the storage buffer
|
/// @param group the binding/group to use for the storage buffer
|
||||||
|
@ -398,7 +398,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
ast::FunctionDecorationList{});
|
ast::FunctionDecorationList{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a regular sampler variable to the module
|
/// Adds a regular sampler variable to the program
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param group the binding/group to use for the storage buffer
|
/// @param group the binding/group to use for the storage buffer
|
||||||
/// @param binding the binding number to use for the storage buffer
|
/// @param binding the binding number to use for the storage buffer
|
||||||
|
@ -407,7 +407,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
binding);
|
binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a comparison sampler variable to the module
|
/// Adds a comparison sampler variable to the program
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param group the binding/group to use for the storage buffer
|
/// @param group the binding/group to use for the storage buffer
|
||||||
/// @param binding the binding number to use for the storage buffer
|
/// @param binding the binding number to use for the storage buffer
|
||||||
|
@ -444,7 +444,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
return create<type::MultisampledTexture>(dim, type);
|
return create<type::MultisampledTexture>(dim, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a sampled texture variable to the module
|
/// Adds a sampled texture variable to the program
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param type the type to use
|
/// @param type the type to use
|
||||||
/// @param group the binding/group to use for the sampled texture
|
/// @param group the binding/group to use for the sampled texture
|
||||||
|
@ -456,7 +456,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
|
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a multi-sampled texture variable to the module
|
/// Adds a multi-sampled texture variable to the program
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param type the type to use
|
/// @param type the type to use
|
||||||
/// @param group the binding/group to use for the multi-sampled texture
|
/// @param group the binding/group to use for the multi-sampled texture
|
||||||
|
@ -473,7 +473,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
||||||
Var(name, ast::StorageClass::kUniformConstant, type));
|
Var(name, ast::StorageClass::kUniformConstant, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a depth texture variable to the module
|
/// Adds a depth texture variable to the program
|
||||||
/// @param name the name of the variable
|
/// @param name the name of the variable
|
||||||
/// @param type the type to use
|
/// @param type the type to use
|
||||||
void AddDepthTexture(const std::string& name, type::Type* type) {
|
void AddDepthTexture(const std::string& name, type::Type* type) {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
||||||
Namer::Namer(ast::Module* mod) : module_(mod) {}
|
Namer::Namer(Program* program) : program_(program) {}
|
||||||
|
|
||||||
Namer::~Namer() = default;
|
Namer::~Namer() = default;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ std::string Namer::GenerateName(const std::string& prefix) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
MangleNamer::MangleNamer(ast::Module* mod) : Namer(mod) {}
|
MangleNamer::MangleNamer(Program* program) : Namer(program) {}
|
||||||
|
|
||||||
MangleNamer::~MangleNamer() = default;
|
MangleNamer::~MangleNamer() = default;
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ std::string MangleNamer::NameFor(const Symbol& sym) {
|
||||||
return sym.to_str();
|
return sym.to_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
UnsafeNamer::UnsafeNamer(ast::Module* mod) : Namer(mod) {}
|
UnsafeNamer::UnsafeNamer(Program* program) : Namer(program) {}
|
||||||
|
|
||||||
UnsafeNamer::~UnsafeNamer() = default;
|
UnsafeNamer::~UnsafeNamer() = default;
|
||||||
|
|
||||||
std::string UnsafeNamer::NameFor(const Symbol& sym) {
|
std::string UnsafeNamer::NameFor(const Symbol& sym) {
|
||||||
return module_->SymbolToName(sym);
|
return program_->SymbolToName(sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
18
src/namer.h
18
src/namer.h
|
@ -19,7 +19,7 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
#include "src/program.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ namespace tint {
|
||||||
class Namer {
|
class Namer {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param mod the module this namer works with
|
/// @param program the program this namer works with
|
||||||
explicit Namer(ast::Module* mod);
|
explicit Namer(Program* program);
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~Namer();
|
virtual ~Namer();
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ class Namer {
|
||||||
/// @returns true if `name` has already been used
|
/// @returns true if `name` has already been used
|
||||||
bool IsUsed(const std::string& name);
|
bool IsUsed(const std::string& name);
|
||||||
|
|
||||||
/// The module storing the symbol table
|
/// The program storing the symbol table
|
||||||
ast::Module* module_ = nullptr;
|
Program* program_ = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The list of names taken by the remapper
|
// The list of names taken by the remapper
|
||||||
|
@ -60,8 +60,8 @@ class Namer {
|
||||||
class MangleNamer : public Namer {
|
class MangleNamer : public Namer {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param mod the module to retrieve names from
|
/// @param program the program to retrieve names from
|
||||||
explicit MangleNamer(ast::Module* mod);
|
explicit MangleNamer(Program* program);
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~MangleNamer() override;
|
~MangleNamer() override;
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ class MangleNamer : public Namer {
|
||||||
class UnsafeNamer : public Namer {
|
class UnsafeNamer : public Namer {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param mod the module to retrieve names from
|
/// @param program the program to retrieve names from
|
||||||
explicit UnsafeNamer(ast::Module* mod);
|
explicit UnsafeNamer(Program* program);
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~UnsafeNamer() override;
|
~UnsafeNamer() override;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "src/namer.h"
|
#include "src/namer.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/ast/module.h"
|
#include "src/program.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -23,7 +23,7 @@ namespace {
|
||||||
using NamerTest = testing::Test;
|
using NamerTest = testing::Test;
|
||||||
|
|
||||||
TEST_F(NamerTest, GenerateName) {
|
TEST_F(NamerTest, GenerateName) {
|
||||||
ast::Module m;
|
Program m;
|
||||||
MangleNamer n(&m);
|
MangleNamer n(&m);
|
||||||
EXPECT_EQ("name", n.GenerateName("name"));
|
EXPECT_EQ("name", n.GenerateName("name"));
|
||||||
EXPECT_EQ("name_0", n.GenerateName("name"));
|
EXPECT_EQ("name_0", n.GenerateName("name"));
|
||||||
|
@ -33,7 +33,7 @@ TEST_F(NamerTest, GenerateName) {
|
||||||
using MangleNamerTest = testing::Test;
|
using MangleNamerTest = testing::Test;
|
||||||
|
|
||||||
TEST_F(MangleNamerTest, ReturnsName) {
|
TEST_F(MangleNamerTest, ReturnsName) {
|
||||||
ast::Module m;
|
Program m;
|
||||||
auto s = m.RegisterSymbol("my_sym");
|
auto s = m.RegisterSymbol("my_sym");
|
||||||
|
|
||||||
MangleNamer n(&m);
|
MangleNamer n(&m);
|
||||||
|
@ -41,7 +41,7 @@ TEST_F(MangleNamerTest, ReturnsName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MangleNamerTest, ReturnsSameValueForSameName) {
|
TEST_F(MangleNamerTest, ReturnsSameValueForSameName) {
|
||||||
ast::Module m;
|
Program m;
|
||||||
auto s1 = m.RegisterSymbol("my_sym");
|
auto s1 = m.RegisterSymbol("my_sym");
|
||||||
auto s2 = m.RegisterSymbol("my_sym2");
|
auto s2 = m.RegisterSymbol("my_sym2");
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ TEST_F(MangleNamerTest, ReturnsSameValueForSameName) {
|
||||||
|
|
||||||
using UnsafeNamerTest = testing::Test;
|
using UnsafeNamerTest = testing::Test;
|
||||||
TEST_F(UnsafeNamerTest, ReturnsName) {
|
TEST_F(UnsafeNamerTest, ReturnsName) {
|
||||||
ast::Module m;
|
Program m;
|
||||||
auto s = m.RegisterSymbol("my_sym");
|
auto s = m.RegisterSymbol("my_sym");
|
||||||
|
|
||||||
UnsafeNamer n(&m);
|
UnsafeNamer n(&m);
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
// Copyright 2021 The Tint Authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "src/program.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "src/clone_context.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
|
||||||
|
namespace tint {
|
||||||
|
|
||||||
|
Program::Program() = default;
|
||||||
|
|
||||||
|
Program::Program(Program&&) = default;
|
||||||
|
|
||||||
|
Program& Program::operator=(Program&& rhs) = default;
|
||||||
|
|
||||||
|
Program::~Program() = default;
|
||||||
|
|
||||||
|
Program Program::Clone() const {
|
||||||
|
Program out;
|
||||||
|
CloneContext(&out, this).Clone();
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Program::Clone(CloneContext* ctx) const {
|
||||||
|
for (auto* ty : constructed_types_) {
|
||||||
|
ctx->dst->constructed_types_.emplace_back(ctx->Clone(ty));
|
||||||
|
}
|
||||||
|
for (auto* var : global_variables_) {
|
||||||
|
ctx->dst->global_variables_.emplace_back(ctx->Clone(var));
|
||||||
|
}
|
||||||
|
for (auto* func : functions_) {
|
||||||
|
ctx->dst->functions_.emplace_back(ctx->Clone(func));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Symbol Program::RegisterSymbol(const std::string& name) {
|
||||||
|
return symbol_table_.Register(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Symbol Program::GetSymbol(const std::string& name) const {
|
||||||
|
return symbol_table_.GetSymbol(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Program::SymbolToName(const Symbol sym) const {
|
||||||
|
return symbol_table_.NameFor(sym);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Program::IsValid() const {
|
||||||
|
for (auto* var : global_variables_) {
|
||||||
|
if (var == nullptr || !var->IsValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto* const ty : constructed_types_) {
|
||||||
|
if (ty == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (auto* alias = ty->As<type::Alias>()) {
|
||||||
|
if (alias->type() == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (auto* str = alias->type()->As<type::Struct>()) {
|
||||||
|
if (!str->symbol().IsValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (auto* str = ty->As<type::Struct>()) {
|
||||||
|
if (!str->symbol().IsValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto* func : functions_) {
|
||||||
|
if (func == nullptr || !func->IsValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Program::to_str() const {
|
||||||
|
std::ostringstream out;
|
||||||
|
|
||||||
|
out << "Module{" << std::endl;
|
||||||
|
const auto indent = 2;
|
||||||
|
for (auto* const ty : constructed_types_) {
|
||||||
|
for (size_t i = 0; i < indent; ++i) {
|
||||||
|
out << " ";
|
||||||
|
}
|
||||||
|
if (auto* alias = ty->As<type::Alias>()) {
|
||||||
|
out << alias->symbol().to_str() << " -> " << alias->type()->type_name()
|
||||||
|
<< std::endl;
|
||||||
|
if (auto* str = alias->type()->As<type::Struct>()) {
|
||||||
|
str->impl()->to_str(out, indent);
|
||||||
|
}
|
||||||
|
} else if (auto* str = ty->As<type::Struct>()) {
|
||||||
|
out << str->symbol().to_str() << " ";
|
||||||
|
str->impl()->to_str(out, indent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto* var : global_variables_) {
|
||||||
|
var->to_str(out, indent);
|
||||||
|
}
|
||||||
|
for (auto* func : functions_) {
|
||||||
|
func->to_str(out, indent);
|
||||||
|
}
|
||||||
|
out << "}" << std::endl;
|
||||||
|
|
||||||
|
return out.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tint
|
144
src/program.h
144
src/program.h
|
@ -15,25 +15,151 @@
|
||||||
#ifndef SRC_PROGRAM_H_
|
#ifndef SRC_PROGRAM_H_
|
||||||
#define SRC_PROGRAM_H_
|
#define SRC_PROGRAM_H_
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
#include "src/ast/function.h"
|
||||||
|
#include "src/ast/variable.h"
|
||||||
|
#include "src/block_allocator.h"
|
||||||
|
#include "src/symbol_table.h"
|
||||||
|
#include "src/traits.h"
|
||||||
|
#include "src/type/alias_type.h"
|
||||||
|
#include "src/type/type_manager.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
||||||
/// Program is (currently) a simple wrapper of to ast::Module.
|
/// Represents all the source in a given program.
|
||||||
/// This wrapper is used as a stepping stone to having Dawn use tint::Program
|
|
||||||
/// instead of tint::ast::Module.
|
|
||||||
class Program {
|
class Program {
|
||||||
public:
|
public:
|
||||||
/// The wrapped module
|
/// Constructor
|
||||||
ast::Module module;
|
Program();
|
||||||
|
|
||||||
/// @returns true if all required fields in the module are present.
|
/// Move constructor
|
||||||
bool IsValid() const { return module.IsValid(); }
|
Program(Program&&);
|
||||||
|
|
||||||
|
/// Move assignment operator
|
||||||
|
/// @param rhs the Program to move
|
||||||
|
/// @return this Program
|
||||||
|
Program& operator=(Program&& rhs);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
~Program();
|
||||||
|
|
||||||
/// @return a deep copy of this program
|
/// @return a deep copy of this program
|
||||||
Program Clone() const { return Program{module.Clone()}; }
|
Program Clone() const;
|
||||||
|
|
||||||
|
/// Clone this program into `ctx->mod` using the provided CloneContext
|
||||||
|
/// The program will be cloned in this order:
|
||||||
|
/// * Constructed types
|
||||||
|
/// * Global variables
|
||||||
|
/// * Functions
|
||||||
|
/// @param ctx the clone context
|
||||||
|
void Clone(CloneContext* ctx) const;
|
||||||
|
|
||||||
|
/// Add a global variable to the program
|
||||||
|
/// @param var the variable to add
|
||||||
|
void AddGlobalVariable(ast::Variable* var) {
|
||||||
|
global_variables_.push_back(var);
|
||||||
|
}
|
||||||
|
/// @returns the global variables for the program
|
||||||
|
const ast::VariableList& global_variables() const {
|
||||||
|
return global_variables_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @returns the global variables for the program
|
||||||
|
ast::VariableList& global_variables() { return global_variables_; }
|
||||||
|
|
||||||
|
/// Adds a constructed type to the program.
|
||||||
|
/// The type must be an alias or a struct.
|
||||||
|
/// @param type the constructed type to add
|
||||||
|
void AddConstructedType(type::Type* type) {
|
||||||
|
constructed_types_.push_back(type);
|
||||||
|
}
|
||||||
|
/// @returns the constructed types in the program
|
||||||
|
const std::vector<type::Type*>& constructed_types() const {
|
||||||
|
return constructed_types_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @returns the functions declared in the translation unit
|
||||||
|
const ast::FunctionList& Functions() const { return functions_; }
|
||||||
|
|
||||||
|
/// @returns the functions declared in the translation unit
|
||||||
|
ast::FunctionList& Functions() { return functions_; }
|
||||||
|
|
||||||
|
/// @returns true if all required fields in the AST are present.
|
||||||
|
bool IsValid() const;
|
||||||
|
|
||||||
|
/// @returns a string representation of the program
|
||||||
|
std::string to_str() const;
|
||||||
|
|
||||||
|
/// Creates a new Node owned by the Program. When the Program is
|
||||||
|
/// destructed, the Node will also be destructed.
|
||||||
|
/// @param args the arguments to pass to the type constructor
|
||||||
|
/// @returns the node pointer
|
||||||
|
template <typename T, typename... ARGS>
|
||||||
|
traits::EnableIfIsType<T, ast::Node>* create(ARGS&&... args) {
|
||||||
|
return ast_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new type::Type owned by the Program.
|
||||||
|
/// When the Program is destructed, owned Program and the returned
|
||||||
|
/// `Type` will also be destructed.
|
||||||
|
/// Types are unique (de-aliased), and so calling create() for the same `T`
|
||||||
|
/// and arguments will return the same pointer.
|
||||||
|
/// @warning Use this method to acquire a type only if all of its type
|
||||||
|
/// information is provided in the constructor arguments `args`.<br>
|
||||||
|
/// If the type requires additional configuration after construction that
|
||||||
|
/// affect its fundamental type, build the type with `std::make_unique`, make
|
||||||
|
/// any necessary alterations and then call unique_type() instead.
|
||||||
|
/// @param args the arguments to pass to the type constructor
|
||||||
|
/// @returns the de-aliased type pointer
|
||||||
|
template <typename T, typename... ARGS>
|
||||||
|
traits::EnableIfIsType<T, type::Type>* create(ARGS&&... args) {
|
||||||
|
static_assert(std::is_base_of<type::Type, T>::value,
|
||||||
|
"T does not derive from type::Type");
|
||||||
|
return type_mgr_.Get<T>(std::forward<ARGS>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns all the declared types in the program
|
||||||
|
/// @returns the mapping from name string to type.
|
||||||
|
const std::unordered_map<std::string, type::Type*>& types() {
|
||||||
|
return type_mgr_.types();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @returns all the declared nodes in the program
|
||||||
|
BlockAllocator<ast::Node>::View nodes() { return ast_nodes_.Objects(); }
|
||||||
|
|
||||||
|
/// Registers `name` as a symbol
|
||||||
|
/// @param name the name to register
|
||||||
|
/// @returns the symbol for the `name`. If `name` is already registered the
|
||||||
|
/// previously generated symbol will be returned.
|
||||||
|
Symbol RegisterSymbol(const std::string& name);
|
||||||
|
|
||||||
|
/// Returns the symbol for `name`
|
||||||
|
/// @param name the name to lookup
|
||||||
|
/// @returns the symbol for name or symbol::kInvalid
|
||||||
|
Symbol GetSymbol(const std::string& name) const;
|
||||||
|
|
||||||
|
/// Returns the `name` for `sym`
|
||||||
|
/// @param sym the symbol to retrieve the name for
|
||||||
|
/// @returns the use provided `name` for the symbol or "" if not found
|
||||||
|
std::string SymbolToName(const Symbol sym) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Program(const Program&) = delete;
|
||||||
|
|
||||||
|
SymbolTable symbol_table_;
|
||||||
|
ast::VariableList global_variables_;
|
||||||
|
// The constructed types are owned by the type manager
|
||||||
|
std::vector<type::Type*> constructed_types_;
|
||||||
|
ast::FunctionList functions_;
|
||||||
|
BlockAllocator<ast::Node> ast_nodes_;
|
||||||
|
type::Manager type_mgr_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
#include "src/program.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -26,82 +26,81 @@
|
||||||
#include "src/type/struct_type.h"
|
#include "src/type/struct_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ModuleTest = TestHelper;
|
using ProgramTest = ast::TestHelper;
|
||||||
|
|
||||||
TEST_F(ModuleTest, Creation) {
|
TEST_F(ProgramTest, Creation) {
|
||||||
EXPECT_EQ(mod->Functions().size(), 0u);
|
EXPECT_EQ(mod->Functions().size(), 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, ToStrEmitsPreambleAndPostamble) {
|
TEST_F(ProgramTest, ToStrEmitsPreambleAndPostamble) {
|
||||||
const auto str = mod->to_str();
|
const auto str = mod->to_str();
|
||||||
auto* const expected = "Module{\n}\n";
|
auto* const expected = "Module{\n}\n";
|
||||||
EXPECT_EQ(str, expected);
|
EXPECT_EQ(str, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Empty) {
|
TEST_F(ProgramTest, IsValid_Empty) {
|
||||||
EXPECT_TRUE(mod->IsValid());
|
EXPECT_TRUE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_GlobalVariable) {
|
TEST_F(ProgramTest, IsValid_GlobalVariable) {
|
||||||
auto* var = Var("var", StorageClass::kInput, ty.f32);
|
auto* var = Var("var", ast::StorageClass::kInput, ty.f32);
|
||||||
mod->AddGlobalVariable(var);
|
mod->AddGlobalVariable(var);
|
||||||
EXPECT_TRUE(mod->IsValid());
|
EXPECT_TRUE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Null_GlobalVariable) {
|
TEST_F(ProgramTest, IsValid_Null_GlobalVariable) {
|
||||||
mod->AddGlobalVariable(nullptr);
|
mod->AddGlobalVariable(nullptr);
|
||||||
EXPECT_FALSE(mod->IsValid());
|
EXPECT_FALSE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Invalid_GlobalVariable) {
|
TEST_F(ProgramTest, IsValid_Invalid_GlobalVariable) {
|
||||||
auto* var = Var("var", StorageClass::kInput, nullptr);
|
auto* var = Var("var", ast::StorageClass::kInput, nullptr);
|
||||||
mod->AddGlobalVariable(var);
|
mod->AddGlobalVariable(var);
|
||||||
EXPECT_FALSE(mod->IsValid());
|
EXPECT_FALSE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Alias) {
|
TEST_F(ProgramTest, IsValid_Alias) {
|
||||||
auto* alias = ty.alias("alias", ty.f32);
|
auto* alias = ty.alias("alias", ty.f32);
|
||||||
mod->AddConstructedType(alias);
|
mod->AddConstructedType(alias);
|
||||||
EXPECT_TRUE(mod->IsValid());
|
EXPECT_TRUE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Null_Alias) {
|
TEST_F(ProgramTest, IsValid_Null_Alias) {
|
||||||
mod->AddConstructedType(nullptr);
|
mod->AddConstructedType(nullptr);
|
||||||
EXPECT_FALSE(mod->IsValid());
|
EXPECT_FALSE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Struct) {
|
TEST_F(ProgramTest, IsValid_Struct) {
|
||||||
auto* st = ty.struct_("name", {});
|
auto* st = ty.struct_("name", {});
|
||||||
auto* alias = ty.alias("name", st);
|
auto* alias = ty.alias("name", st);
|
||||||
mod->AddConstructedType(alias);
|
mod->AddConstructedType(alias);
|
||||||
EXPECT_TRUE(mod->IsValid());
|
EXPECT_TRUE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Struct_EmptyName) {
|
TEST_F(ProgramTest, IsValid_Struct_EmptyName) {
|
||||||
auto* st = ty.struct_("", {});
|
auto* st = ty.struct_("", {});
|
||||||
auto* alias = ty.alias("name", st);
|
auto* alias = ty.alias("name", st);
|
||||||
mod->AddConstructedType(alias);
|
mod->AddConstructedType(alias);
|
||||||
EXPECT_FALSE(mod->IsValid());
|
EXPECT_FALSE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Function) {
|
TEST_F(ProgramTest, IsValid_Function) {
|
||||||
auto* func = Func("main", VariableList(), ty.f32, StatementList{},
|
auto* func = Func("main", ast::VariableList(), ty.f32, ast::StatementList{},
|
||||||
ast::FunctionDecorationList{});
|
ast::FunctionDecorationList{});
|
||||||
|
|
||||||
mod->Functions().Add(func);
|
mod->Functions().Add(func);
|
||||||
EXPECT_TRUE(mod->IsValid());
|
EXPECT_TRUE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Null_Function) {
|
TEST_F(ProgramTest, IsValid_Null_Function) {
|
||||||
mod->Functions().Add(nullptr);
|
mod->Functions().Add(nullptr);
|
||||||
EXPECT_FALSE(mod->IsValid());
|
EXPECT_FALSE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Invalid_Function) {
|
TEST_F(ProgramTest, IsValid_Invalid_Function) {
|
||||||
auto* func = Func("main", VariableList{}, nullptr, StatementList{},
|
auto* func = Func("main", ast::VariableList{}, nullptr, ast::StatementList{},
|
||||||
ast::FunctionDecorationList{});
|
ast::FunctionDecorationList{});
|
||||||
|
|
||||||
mod->Functions().Add(func);
|
mod->Functions().Add(func);
|
||||||
|
@ -109,5 +108,4 @@ TEST_F(ModuleTest, IsValid_Invalid_Function) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
} // namespace tint
|
|
@ -18,7 +18,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/diagnostic/diagnostic.h"
|
#include "src/diagnostic/diagnostic.h"
|
||||||
#include "src/diagnostic/formatter.h"
|
#include "src/diagnostic/formatter.h"
|
||||||
#include "src/program.h"
|
#include "src/program.h"
|
||||||
|
@ -47,11 +46,8 @@ class Reader {
|
||||||
/// @returns the full list of diagnostic messages.
|
/// @returns the full list of diagnostic messages.
|
||||||
const diag::List& diagnostics() const { return diags_; }
|
const diag::List& diagnostics() const { return diags_; }
|
||||||
|
|
||||||
/// @returns the module. The module in the parser will be reset after this.
|
/// @returns the program. The program in the parser will be reset after this.
|
||||||
virtual ast::Module module() = 0;
|
virtual Program program() = 0;
|
||||||
|
|
||||||
/// @returns the program. The module in the parser will be reset after this.
|
|
||||||
Program program() { return Program{module()}; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
|
|
@ -632,16 +632,16 @@ struct SwitchStatementBuilder
|
||||||
/// @param cond the switch statement condition
|
/// @param cond the switch statement condition
|
||||||
explicit SwitchStatementBuilder(ast::Expression* cond) : condition(cond) {}
|
explicit SwitchStatementBuilder(ast::Expression* cond) : condition(cond) {}
|
||||||
|
|
||||||
/// @param mod the ast Module to build into
|
/// @param program the program to build into
|
||||||
/// @returns the built ast::SwitchStatement
|
/// @returns the built ast::SwitchStatement
|
||||||
ast::SwitchStatement* Build(ast::Module* mod) const override {
|
ast::SwitchStatement* Build(Program* program) const override {
|
||||||
// We've listed cases in reverse order in the switch statement.
|
// We've listed cases in reverse order in the switch statement.
|
||||||
// Reorder them to match the presentation order in WGSL.
|
// Reorder them to match the presentation order in WGSL.
|
||||||
auto reversed_cases = cases;
|
auto reversed_cases = cases;
|
||||||
std::reverse(reversed_cases.begin(), reversed_cases.end());
|
std::reverse(reversed_cases.begin(), reversed_cases.end());
|
||||||
|
|
||||||
return mod->create<ast::SwitchStatement>(Source{}, condition,
|
return program->create<ast::SwitchStatement>(Source{}, condition,
|
||||||
reversed_cases);
|
reversed_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Switch statement condition
|
/// Switch statement condition
|
||||||
|
@ -658,10 +658,10 @@ struct IfStatementBuilder
|
||||||
/// @param c the if-statement condition
|
/// @param c the if-statement condition
|
||||||
explicit IfStatementBuilder(ast::Expression* c) : cond(c) {}
|
explicit IfStatementBuilder(ast::Expression* c) : cond(c) {}
|
||||||
|
|
||||||
/// @param mod the ast Module to build into
|
/// @param program the program to build into
|
||||||
/// @returns the built ast::IfStatement
|
/// @returns the built ast::IfStatement
|
||||||
ast::IfStatement* Build(ast::Module* mod) const override {
|
ast::IfStatement* Build(Program* program) const override {
|
||||||
return mod->create<ast::IfStatement>(Source{}, cond, body, else_stmts);
|
return program->create<ast::IfStatement>(Source{}, cond, body, else_stmts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If-statement condition
|
/// If-statement condition
|
||||||
|
@ -676,10 +676,10 @@ struct IfStatementBuilder
|
||||||
/// @see StatementBuilder
|
/// @see StatementBuilder
|
||||||
struct LoopStatementBuilder
|
struct LoopStatementBuilder
|
||||||
: public Castable<LoopStatementBuilder, StatementBuilder> {
|
: public Castable<LoopStatementBuilder, StatementBuilder> {
|
||||||
/// @param mod the ast Module to build into
|
/// @param program the program to build into
|
||||||
/// @returns the built ast::LoopStatement
|
/// @returns the built ast::LoopStatement
|
||||||
ast::LoopStatement* Build(ast::Module* mod) const override {
|
ast::LoopStatement* Build(Program* program) const override {
|
||||||
return mod->create<ast::LoopStatement>(Source{}, body, continuing);
|
return program->create<ast::LoopStatement>(Source{}, body, continuing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loop-statement block body
|
/// Loop-statement block body
|
||||||
|
@ -717,7 +717,7 @@ FunctionEmitter::FunctionEmitter(ParserImpl* pi,
|
||||||
const spvtools::opt::Function& function,
|
const spvtools::opt::Function& function,
|
||||||
const EntryPointInfo* ep_info)
|
const EntryPointInfo* ep_info)
|
||||||
: parser_impl_(*pi),
|
: parser_impl_(*pi),
|
||||||
ast_module_(pi->get_module()),
|
program_(pi->get_program()),
|
||||||
ir_context_(*(pi->ir_context())),
|
ir_context_(*(pi->ir_context())),
|
||||||
def_use_mgr_(ir_context_.get_def_use_mgr()),
|
def_use_mgr_(ir_context_.get_def_use_mgr()),
|
||||||
constant_mgr_(ir_context_.get_constant_mgr()),
|
constant_mgr_(ir_context_.get_constant_mgr()),
|
||||||
|
@ -725,7 +725,7 @@ FunctionEmitter::FunctionEmitter(ParserImpl* pi,
|
||||||
fail_stream_(pi->fail_stream()),
|
fail_stream_(pi->fail_stream()),
|
||||||
namer_(pi->namer()),
|
namer_(pi->namer()),
|
||||||
function_(function),
|
function_(function),
|
||||||
i32_(ast_module_.create<type::I32>()),
|
i32_(program_.create<type::I32>()),
|
||||||
ep_info_(ep_info) {
|
ep_info_(ep_info) {
|
||||||
PushNewStatementBlock(nullptr, 0, nullptr);
|
PushNewStatementBlock(nullptr, 0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -749,12 +749,12 @@ FunctionEmitter::StatementBlock::StatementBlock(StatementBlock&& other) =
|
||||||
|
|
||||||
FunctionEmitter::StatementBlock::~StatementBlock() = default;
|
FunctionEmitter::StatementBlock::~StatementBlock() = default;
|
||||||
|
|
||||||
void FunctionEmitter::StatementBlock::Finalize(ast::Module* mod) {
|
void FunctionEmitter::StatementBlock::Finalize(Program* program) {
|
||||||
assert(!finalized_ /* Finalize() must only be called once */);
|
assert(!finalized_ /* Finalize() must only be called once */);
|
||||||
|
|
||||||
for (size_t i = 0; i < statements_.size(); i++) {
|
for (size_t i = 0; i < statements_.size(); i++) {
|
||||||
if (auto* builder = statements_[i]->As<StatementBuilder>()) {
|
if (auto* builder = statements_[i]->As<StatementBuilder>()) {
|
||||||
statements_[i] = builder->Build(mod);
|
statements_[i] = builder->Build(program);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,7 +786,7 @@ void FunctionEmitter::PushGuard(const std::string& guard_name,
|
||||||
const auto& top = statements_stack_.back();
|
const auto& top = statements_stack_.back();
|
||||||
|
|
||||||
auto* cond = create<ast::IdentifierExpression>(
|
auto* cond = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(guard_name));
|
Source{}, program_.RegisterSymbol(guard_name));
|
||||||
auto* builder = AddStatementBuilder<IfStatementBuilder>(cond);
|
auto* builder = AddStatementBuilder<IfStatementBuilder>(cond);
|
||||||
|
|
||||||
PushNewStatementBlock(
|
PushNewStatementBlock(
|
||||||
|
@ -811,7 +811,7 @@ void FunctionEmitter::PushTrueGuard(uint32_t end_id) {
|
||||||
const ast::StatementList FunctionEmitter::ast_body() {
|
const ast::StatementList FunctionEmitter::ast_body() {
|
||||||
assert(!statements_stack_.empty());
|
assert(!statements_stack_.empty());
|
||||||
auto& entry = statements_stack_[0];
|
auto& entry = statements_stack_[0];
|
||||||
entry.Finalize(&ast_module_);
|
entry.Finalize(&program_);
|
||||||
return entry.GetStatements();
|
return entry.GetStatements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,14 +855,13 @@ bool FunctionEmitter::Emit() {
|
||||||
<< statements_stack_.size();
|
<< statements_stack_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
statements_stack_[0].Finalize(&ast_module_);
|
statements_stack_[0].Finalize(&program_);
|
||||||
|
|
||||||
auto& statements = statements_stack_[0].GetStatements();
|
auto& statements = statements_stack_[0].GetStatements();
|
||||||
auto* body = create<ast::BlockStatement>(Source{}, statements);
|
auto* body = create<ast::BlockStatement>(Source{}, statements);
|
||||||
ast_module_.Functions().Add(
|
program_.Functions().Add(create<ast::Function>(
|
||||||
create<ast::Function>(decl.source, ast_module_.RegisterSymbol(decl.name),
|
decl.source, program_.RegisterSymbol(decl.name), std::move(decl.params),
|
||||||
std::move(decl.params), decl.return_type, body,
|
decl.return_type, body, std::move(decl.decorations)));
|
||||||
std::move(decl.decorations)));
|
|
||||||
|
|
||||||
// Maintain the invariant by repopulating the one and only element.
|
// Maintain the invariant by repopulating the one and only element.
|
||||||
statements_stack_.clear();
|
statements_stack_.clear();
|
||||||
|
@ -2013,7 +2012,7 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) {
|
||||||
return TypedExpression{
|
return TypedExpression{
|
||||||
parser_impl_.ConvertType(def_use_mgr_->GetDef(id)->type_id()),
|
parser_impl_.ConvertType(def_use_mgr_->GetDef(id)->type_id()),
|
||||||
create<ast::IdentifierExpression>(Source{},
|
create<ast::IdentifierExpression>(Source{},
|
||||||
ast_module_.RegisterSymbol(name))};
|
program_.RegisterSymbol(name))};
|
||||||
}
|
}
|
||||||
if (singly_used_values_.count(id)) {
|
if (singly_used_values_.count(id)) {
|
||||||
auto expr = std::move(singly_used_values_[id]);
|
auto expr = std::move(singly_used_values_[id]);
|
||||||
|
@ -2035,7 +2034,7 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) {
|
||||||
auto name = namer_.Name(inst->result_id());
|
auto name = namer_.Name(inst->result_id());
|
||||||
return TypedExpression{parser_impl_.ConvertType(inst->type_id()),
|
return TypedExpression{parser_impl_.ConvertType(inst->type_id()),
|
||||||
create<ast::IdentifierExpression>(
|
create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(name))};
|
Source{}, program_.RegisterSymbol(name))};
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -2079,7 +2078,7 @@ bool FunctionEmitter::EmitBasicBlock(const BlockInfo& block_info) {
|
||||||
// Close off previous constructs.
|
// Close off previous constructs.
|
||||||
while (!statements_stack_.empty() &&
|
while (!statements_stack_.empty() &&
|
||||||
(statements_stack_.back().GetEndId() == block_info.id)) {
|
(statements_stack_.back().GetEndId() == block_info.id)) {
|
||||||
statements_stack_.back().Finalize(&ast_module_);
|
statements_stack_.back().Finalize(&program_);
|
||||||
statements_stack_.pop_back();
|
statements_stack_.pop_back();
|
||||||
}
|
}
|
||||||
if (statements_stack_.empty()) {
|
if (statements_stack_.empty()) {
|
||||||
|
@ -2265,8 +2264,8 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) {
|
||||||
if (!guard_name.empty()) {
|
if (!guard_name.empty()) {
|
||||||
// Declare the guard variable just before the "if", initialized to true.
|
// Declare the guard variable just before the "if", initialized to true.
|
||||||
auto* guard_var =
|
auto* guard_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
ast_module_.RegisterSymbol(guard_name), // symbol
|
program_.RegisterSymbol(guard_name), // symbol
|
||||||
ast::StorageClass::kFunction, // storage_class
|
ast::StorageClass::kFunction, // storage_class
|
||||||
parser_impl_.Bool(), // type
|
parser_impl_.Bool(), // type
|
||||||
false, // is_const
|
false, // is_const
|
||||||
|
@ -2673,7 +2672,7 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed(
|
||||||
return create<ast::AssignmentStatement>(
|
return create<ast::AssignmentStatement>(
|
||||||
Source{},
|
Source{},
|
||||||
create<ast::IdentifierExpression>(
|
create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(flow_guard)),
|
Source{}, program_.RegisterSymbol(flow_guard)),
|
||||||
MakeFalse(Source{}));
|
MakeFalse(Source{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2794,7 +2793,7 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info,
|
||||||
assert(!phi_var_name.empty());
|
assert(!phi_var_name.empty());
|
||||||
auto* var = create<ast::Variable>(
|
auto* var = create<ast::Variable>(
|
||||||
Source{}, // source
|
Source{}, // source
|
||||||
ast_module_.RegisterSymbol(phi_var_name), // symbol
|
program_.RegisterSymbol(phi_var_name), // symbol
|
||||||
ast::StorageClass::kFunction, // storage_class
|
ast::StorageClass::kFunction, // storage_class
|
||||||
parser_impl_.ConvertType(def_inst->type_id()), // type
|
parser_impl_.ConvertType(def_inst->type_id()), // type
|
||||||
false, // is_const
|
false, // is_const
|
||||||
|
@ -2832,8 +2831,8 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info,
|
||||||
auto expr = MakeExpression(assignment.value);
|
auto expr = MakeExpression(assignment.value);
|
||||||
AddStatement(create<ast::AssignmentStatement>(
|
AddStatement(create<ast::AssignmentStatement>(
|
||||||
Source{},
|
Source{},
|
||||||
create<ast::IdentifierExpression>(
|
create<ast::IdentifierExpression>(Source{},
|
||||||
Source{}, ast_module_.RegisterSymbol(var_name)),
|
program_.RegisterSymbol(var_name)),
|
||||||
expr.expr));
|
expr.expr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2871,7 +2870,7 @@ bool FunctionEmitter::EmitConstDefOrWriteToHoistedVar(
|
||||||
AddStatement(create<ast::AssignmentStatement>(
|
AddStatement(create<ast::AssignmentStatement>(
|
||||||
Source{},
|
Source{},
|
||||||
create<ast::IdentifierExpression>(Source{},
|
create<ast::IdentifierExpression>(Source{},
|
||||||
ast_module_.RegisterSymbol(name)),
|
program_.RegisterSymbol(name)),
|
||||||
ast_expr.expr));
|
ast_expr.expr));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3010,7 +3009,7 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) {
|
||||||
TypedExpression expr{
|
TypedExpression expr{
|
||||||
parser_impl_.ConvertType(inst.type_id()),
|
parser_impl_.ConvertType(inst.type_id()),
|
||||||
create<ast::IdentifierExpression>(
|
create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(def_info->phi_var))};
|
Source{}, program_.RegisterSymbol(def_info->phi_var))};
|
||||||
return EmitConstDefOrWriteToHoistedVar(inst, expr);
|
return EmitConstDefOrWriteToHoistedVar(inst, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3073,7 +3072,7 @@ TypedExpression FunctionEmitter::MaybeEmitCombinatorialValue(
|
||||||
create<ast::CallExpression>(
|
create<ast::CallExpression>(
|
||||||
Source{},
|
Source{},
|
||||||
create<ast::IdentifierExpression>(
|
create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(unary_builtin_name)),
|
Source{}, program_.RegisterSymbol(unary_builtin_name)),
|
||||||
std::move(params))};
|
std::move(params))};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3178,8 +3177,8 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* func = create<ast::IdentifierExpression>(
|
auto* func = create<ast::IdentifierExpression>(Source{},
|
||||||
Source{}, ast_module_.RegisterSymbol(name));
|
program_.RegisterSymbol(name));
|
||||||
ast::ExpressionList operands;
|
ast::ExpressionList operands;
|
||||||
type::Type* first_operand_type = nullptr;
|
type::Type* first_operand_type = nullptr;
|
||||||
// All parameters to GLSL.std.450 extended instructions are IDs.
|
// All parameters to GLSL.std.450 extended instructions are IDs.
|
||||||
|
@ -3205,20 +3204,20 @@ ast::IdentifierExpression* FunctionEmitter::Swizzle(uint32_t i) {
|
||||||
}
|
}
|
||||||
const char* names[] = {"x", "y", "z", "w"};
|
const char* names[] = {"x", "y", "z", "w"};
|
||||||
return create<ast::IdentifierExpression>(
|
return create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(names[i & 3]));
|
Source{}, program_.RegisterSymbol(names[i & 3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::IdentifierExpression* FunctionEmitter::PrefixSwizzle(uint32_t n) {
|
ast::IdentifierExpression* FunctionEmitter::PrefixSwizzle(uint32_t n) {
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case 1:
|
case 1:
|
||||||
return create<ast::IdentifierExpression>(Source{},
|
return create<ast::IdentifierExpression>(Source{},
|
||||||
ast_module_.RegisterSymbol("x"));
|
program_.RegisterSymbol("x"));
|
||||||
case 2:
|
case 2:
|
||||||
return create<ast::IdentifierExpression>(
|
return create<ast::IdentifierExpression>(Source{},
|
||||||
Source{}, ast_module_.RegisterSymbol("xy"));
|
program_.RegisterSymbol("xy"));
|
||||||
case 3:
|
case 3:
|
||||||
return create<ast::IdentifierExpression>(
|
return create<ast::IdentifierExpression>(Source{},
|
||||||
Source{}, ast_module_.RegisterSymbol("xyz"));
|
program_.RegisterSymbol("xyz"));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3313,7 +3312,7 @@ TypedExpression FunctionEmitter::MakeAccessChain(
|
||||||
|
|
||||||
auto name = namer_.Name(base_id);
|
auto name = namer_.Name(base_id);
|
||||||
current_expr.expr = create<ast::IdentifierExpression>(
|
current_expr.expr = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(name));
|
Source{}, program_.RegisterSymbol(name));
|
||||||
current_expr.type = parser_impl_.ConvertType(ptr_ty_id);
|
current_expr.type = parser_impl_.ConvertType(ptr_ty_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3406,7 +3405,7 @@ TypedExpression FunctionEmitter::MakeAccessChain(
|
||||||
auto name =
|
auto name =
|
||||||
namer_.GetMemberName(pointee_type_id, uint32_t(index_const_val));
|
namer_.GetMemberName(pointee_type_id, uint32_t(index_const_val));
|
||||||
auto* member_access = create<ast::IdentifierExpression>(
|
auto* member_access = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(name));
|
Source{}, program_.RegisterSymbol(name));
|
||||||
|
|
||||||
next_expr = create<ast::MemberAccessorExpression>(
|
next_expr = create<ast::MemberAccessorExpression>(
|
||||||
Source{}, current_expr.expr, member_access);
|
Source{}, current_expr.expr, member_access);
|
||||||
|
@ -3527,7 +3526,7 @@ TypedExpression FunctionEmitter::MakeCompositeExtract(
|
||||||
}
|
}
|
||||||
auto name = namer_.GetMemberName(current_type_id, uint32_t(index_val));
|
auto name = namer_.GetMemberName(current_type_id, uint32_t(index_val));
|
||||||
auto* member_access = create<ast::IdentifierExpression>(
|
auto* member_access = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(name));
|
Source{}, program_.RegisterSymbol(name));
|
||||||
|
|
||||||
next_expr = create<ast::MemberAccessorExpression>(
|
next_expr = create<ast::MemberAccessorExpression>(
|
||||||
Source{}, current_expr.expr, member_access);
|
Source{}, current_expr.expr, member_access);
|
||||||
|
@ -3700,7 +3699,7 @@ type::Type* FunctionEmitter::RemapStorageClass(type::Type* type,
|
||||||
// buffer pointer.
|
// buffer pointer.
|
||||||
const auto sc = GetStorageClassForPointerValue(result_id);
|
const auto sc = GetStorageClassForPointerValue(result_id);
|
||||||
if (ast_ptr_type->storage_class() != sc) {
|
if (ast_ptr_type->storage_class() != sc) {
|
||||||
return parser_impl_.get_module().create<type::Pointer>(
|
return parser_impl_.get_program().create<type::Pointer>(
|
||||||
ast_ptr_type->type(), sc);
|
ast_ptr_type->type(), sc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3932,7 +3931,7 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) {
|
||||||
// We ignore function attributes such as Inline, DontInline, Pure, Const.
|
// We ignore function attributes such as Inline, DontInline, Pure, Const.
|
||||||
auto name = namer_.Name(inst.GetSingleWordInOperand(0));
|
auto name = namer_.Name(inst.GetSingleWordInOperand(0));
|
||||||
auto* function = create<ast::IdentifierExpression>(
|
auto* function = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(name));
|
Source{}, program_.RegisterSymbol(name));
|
||||||
|
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
for (uint32_t iarg = 1; iarg < inst.NumInOperands(); ++iarg) {
|
for (uint32_t iarg = 1; iarg < inst.NumInOperands(); ++iarg) {
|
||||||
|
@ -3961,7 +3960,7 @@ TypedExpression FunctionEmitter::MakeIntrinsicCall(
|
||||||
ss << intrinsic;
|
ss << intrinsic;
|
||||||
auto name = ss.str();
|
auto name = ss.str();
|
||||||
auto* ident = create<ast::IdentifierExpression>(
|
auto* ident = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(name));
|
Source{}, program_.RegisterSymbol(name));
|
||||||
ident->set_intrinsic(intrinsic);
|
ident->set_intrinsic(intrinsic);
|
||||||
|
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
|
@ -4004,12 +4003,11 @@ TypedExpression FunctionEmitter::MakeSimpleSelect(
|
||||||
params.push_back(operand2.expr);
|
params.push_back(operand2.expr);
|
||||||
// The condition goes last.
|
// The condition goes last.
|
||||||
params.push_back(condition.expr);
|
params.push_back(condition.expr);
|
||||||
return {operand1.type,
|
return {operand1.type, create<ast::CallExpression>(
|
||||||
create<ast::CallExpression>(
|
Source{},
|
||||||
Source{},
|
create<ast::IdentifierExpression>(
|
||||||
create<ast::IdentifierExpression>(
|
Source{}, program_.RegisterSymbol("select")),
|
||||||
Source{}, ast_module_.RegisterSymbol("select")),
|
std::move(params))};
|
||||||
std::move(params))};
|
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -4058,7 +4056,7 @@ ast::Expression* FunctionEmitter::GetImageExpression(
|
||||||
}
|
}
|
||||||
auto name = namer_.Name(image->result_id());
|
auto name = namer_.Name(image->result_id());
|
||||||
return create<ast::IdentifierExpression>(GetSourceForInst(inst),
|
return create<ast::IdentifierExpression>(GetSourceForInst(inst),
|
||||||
ast_module_.RegisterSymbol(name));
|
program_.RegisterSymbol(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Expression* FunctionEmitter::GetSamplerExpression(
|
ast::Expression* FunctionEmitter::GetSamplerExpression(
|
||||||
|
@ -4074,7 +4072,7 @@ ast::Expression* FunctionEmitter::GetSamplerExpression(
|
||||||
}
|
}
|
||||||
auto name = namer_.Name(image->result_id());
|
auto name = namer_.Name(image->result_id());
|
||||||
return create<ast::IdentifierExpression>(GetSourceForInst(inst),
|
return create<ast::IdentifierExpression>(GetSourceForInst(inst),
|
||||||
ast_module_.RegisterSymbol(name));
|
program_.RegisterSymbol(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
|
@ -4261,7 +4259,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* ident = create<ast::IdentifierExpression>(
|
auto* ident = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(builtin_name));
|
Source{}, program_.RegisterSymbol(builtin_name));
|
||||||
auto* call_expr =
|
auto* call_expr =
|
||||||
create<ast::CallExpression>(Source{}, ident, std::move(params));
|
create<ast::CallExpression>(Source{}, ident, std::move(params));
|
||||||
|
|
||||||
|
@ -4569,14 +4567,14 @@ TypedExpression FunctionEmitter::MakeArrayLength(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* member_ident = create<ast::IdentifierExpression>(
|
auto* member_ident = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(field_name));
|
Source{}, program_.RegisterSymbol(field_name));
|
||||||
auto* member_access = create<ast::MemberAccessorExpression>(
|
auto* member_access = create<ast::MemberAccessorExpression>(
|
||||||
Source{}, MakeExpression(struct_ptr_id).expr, member_ident);
|
Source{}, MakeExpression(struct_ptr_id).expr, member_ident);
|
||||||
|
|
||||||
// Generate the intrinsic function call.
|
// Generate the intrinsic function call.
|
||||||
std::string call_ident_str = "arrayLength";
|
std::string call_ident_str = "arrayLength";
|
||||||
auto* call_ident = create<ast::IdentifierExpression>(
|
auto* call_ident = create<ast::IdentifierExpression>(
|
||||||
Source{}, ast_module_.RegisterSymbol(call_ident_str));
|
Source{}, program_.RegisterSymbol(call_ident_str));
|
||||||
call_ident->set_intrinsic(ast::Intrinsic::kArrayLength);
|
call_ident->set_intrinsic(ast::Intrinsic::kArrayLength);
|
||||||
|
|
||||||
ast::ExpressionList params{member_access};
|
ast::ExpressionList params{member_access};
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
#include "src/ast/case_statement.h"
|
#include "src/ast/case_statement.h"
|
||||||
#include "src/ast/expression.h"
|
#include "src/ast/expression.h"
|
||||||
#include "src/ast/identifier_expression.h"
|
#include "src/ast/identifier_expression.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/ast/statement.h"
|
#include "src/ast/statement.h"
|
||||||
#include "src/ast/storage_class.h"
|
#include "src/ast/storage_class.h"
|
||||||
|
#include "src/program.h"
|
||||||
#include "src/reader/spirv/construct.h"
|
#include "src/reader/spirv/construct.h"
|
||||||
#include "src/reader/spirv/entry_point_info.h"
|
#include "src/reader/spirv/entry_point_info.h"
|
||||||
#include "src/reader/spirv/fail_stream.h"
|
#include "src/reader/spirv/fail_stream.h"
|
||||||
|
@ -345,9 +345,9 @@ class StatementBuilder : public Castable<StatementBuilder, ast::Statement> {
|
||||||
/// Constructor
|
/// Constructor
|
||||||
StatementBuilder() : Base(Source{}) {}
|
StatementBuilder() : Base(Source{}) {}
|
||||||
|
|
||||||
/// @param mod the ast Module to build into
|
/// @param program the program to build into
|
||||||
/// @returns the build AST node
|
/// @returns the built AST node
|
||||||
virtual ast::Statement* Build(ast::Module* mod) const = 0;
|
virtual ast::Statement* Build(Program* program) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool IsValid() const override;
|
bool IsValid() const override;
|
||||||
|
@ -355,15 +355,15 @@ class StatementBuilder : public Castable<StatementBuilder, ast::Statement> {
|
||||||
void to_str(std::ostream& out, size_t indent) const override;
|
void to_str(std::ostream& out, size_t indent) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A FunctionEmitter emits a SPIR-V function onto a Tint AST module.
|
/// A FunctionEmitter emits a SPIR-V function onto a Tint program.
|
||||||
class FunctionEmitter {
|
class FunctionEmitter {
|
||||||
public:
|
public:
|
||||||
/// Creates a FunctionEmitter, and prepares to write to the AST module
|
/// Creates a FunctionEmitter, and prepares to write to the program
|
||||||
/// in `pi`
|
/// in `pi`
|
||||||
/// @param pi a ParserImpl which has already executed BuildInternalModule
|
/// @param pi a ParserImpl which has already executed BuildInternalModule
|
||||||
/// @param function the function to emit
|
/// @param function the function to emit
|
||||||
FunctionEmitter(ParserImpl* pi, const spvtools::opt::Function& function);
|
FunctionEmitter(ParserImpl* pi, const spvtools::opt::Function& function);
|
||||||
/// Creates a FunctionEmitter, and prepares to write to the AST module
|
/// Creates a FunctionEmitter, and prepares to write to the program
|
||||||
/// in `pi`
|
/// in `pi`
|
||||||
/// @param pi a ParserImpl which has already executed BuildInternalModule
|
/// @param pi a ParserImpl which has already executed BuildInternalModule
|
||||||
/// @param function the function to emit
|
/// @param function the function to emit
|
||||||
|
@ -374,7 +374,7 @@ class FunctionEmitter {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~FunctionEmitter();
|
~FunctionEmitter();
|
||||||
|
|
||||||
/// Emits the function to AST module.
|
/// Emits the function to program.
|
||||||
/// @return whether emission succeeded
|
/// @return whether emission succeeded
|
||||||
bool Emit();
|
bool Emit();
|
||||||
|
|
||||||
|
@ -964,8 +964,8 @@ class FunctionEmitter {
|
||||||
/// Replaces any StatementBuilders with the built result, and calls the
|
/// Replaces any StatementBuilders with the built result, and calls the
|
||||||
/// completion callback (if set). Must only be called once, after all
|
/// completion callback (if set). Must only be called once, after all
|
||||||
/// statements have been added with Add().
|
/// statements have been added with Add().
|
||||||
/// @param mod the module
|
/// @param program the program
|
||||||
void Finalize(ast::Module* mod);
|
void Finalize(Program* program);
|
||||||
|
|
||||||
/// Add() adds `statement` to the block.
|
/// Add() adds `statement` to the block.
|
||||||
/// Add() must not be called after calling Finalize().
|
/// Add() must not be called after calling Finalize().
|
||||||
|
@ -1049,13 +1049,13 @@ class FunctionEmitter {
|
||||||
/// @returns the node pointer
|
/// @returns the node pointer
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
T* create(ARGS&&... args) const {
|
T* create(ARGS&&... args) const {
|
||||||
return ast_module_.create<T>(std::forward<ARGS>(args)...);
|
return program_.create<T>(std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
using StatementsStack = std::vector<StatementBlock>;
|
using StatementsStack = std::vector<StatementBlock>;
|
||||||
|
|
||||||
ParserImpl& parser_impl_;
|
ParserImpl& parser_impl_;
|
||||||
ast::Module& ast_module_;
|
Program& program_;
|
||||||
spvtools::opt::IRContext& ir_context_;
|
spvtools::opt::IRContext& ir_context_;
|
||||||
spvtools::opt::analysis::DefUseManager* def_use_mgr_;
|
spvtools::opt::analysis::DefUseManager* def_use_mgr_;
|
||||||
spvtools::opt::analysis::ConstantManager* constant_mgr_;
|
spvtools::opt::analysis::ConstantManager* constant_mgr_;
|
||||||
|
|
|
@ -139,7 +139,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -151,7 +151,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
|
TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
|
||||||
|
@ -166,7 +166,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -180,7 +180,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) {
|
TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) {
|
||||||
|
@ -195,7 +195,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -209,7 +209,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
|
TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
|
||||||
|
@ -224,7 +224,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -240,7 +240,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) {
|
TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) {
|
||||||
|
@ -255,7 +255,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -271,7 +271,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
|
TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
|
||||||
|
@ -286,7 +286,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -304,7 +304,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) {
|
TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) {
|
||||||
|
@ -319,7 +319,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -337,7 +337,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
|
TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
|
||||||
|
@ -352,7 +352,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -372,7 +372,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, FNegate_Scalar) {
|
TEST_F(SpvUnaryArithTest, FNegate_Scalar) {
|
||||||
|
@ -387,7 +387,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -399,7 +399,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryArithTest, FNegate_Vector) {
|
TEST_F(SpvUnaryArithTest, FNegate_Vector) {
|
||||||
|
@ -414,7 +414,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -430,7 +430,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BinaryData {
|
struct BinaryData {
|
||||||
|
@ -478,7 +478,7 @@ TEST_P(SpvBinaryArithTest, EmitExpression) {
|
||||||
<< GetParam().ast_type << "\n {\n Binary[not set]{"
|
<< GetParam().ast_type << "\n {\n Binary[not set]{"
|
||||||
<< "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op
|
<< "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op
|
||||||
<< "\n " << GetParam().ast_rhs;
|
<< "\n " << GetParam().ast_rhs;
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(ss.str()))
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(ss.str()))
|
||||||
<< assembly;
|
<< assembly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Scalar_UnsignedResult) {
|
||||||
<< assembly;
|
<< assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -736,7 +736,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) {
|
||||||
<< assembly;
|
<< assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -759,7 +759,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -847,7 +847,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Scalar_UnsignedResult) {
|
||||||
<< assembly;
|
<< assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -882,7 +882,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) {
|
||||||
<< assembly;
|
<< assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -905,7 +905,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
@ -935,7 +935,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_10
|
x_10
|
||||||
none
|
none
|
||||||
|
@ -948,7 +948,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
|
TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
|
||||||
|
@ -965,7 +965,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_10
|
x_10
|
||||||
none
|
none
|
||||||
|
@ -978,7 +978,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
|
TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
|
||||||
|
@ -995,7 +995,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_10
|
x_10
|
||||||
none
|
none
|
||||||
|
@ -1008,7 +1008,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) {
|
TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) {
|
||||||
|
@ -1025,7 +1025,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_10
|
x_10
|
||||||
none
|
none
|
||||||
|
@ -1038,7 +1038,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
|
TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
|
||||||
|
@ -1055,7 +1055,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_10
|
x_10
|
||||||
none
|
none
|
||||||
|
@ -1068,7 +1068,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBinaryArithTestBasic, Dot) {
|
TEST_F(SpvBinaryArithTestBasic, Dot) {
|
||||||
|
@ -1085,7 +1085,7 @@ TEST_F(SpvBinaryArithTestBasic, Dot) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_3
|
x_3
|
||||||
none
|
none
|
||||||
|
@ -1100,7 +1100,7 @@ TEST_F(SpvBinaryArithTestBasic, Dot) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvBinaryArithTestBasic, OuterProduct) {
|
TEST_F(SpvBinaryArithTestBasic, OuterProduct) {
|
||||||
|
@ -1119,7 +1119,7 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(got, HasSubstr(R"(VariableConst{
|
EXPECT_THAT(got, HasSubstr(R"(VariableConst{
|
||||||
x_3
|
x_3
|
||||||
none
|
none
|
||||||
|
|
|
@ -163,7 +163,7 @@ TEST_P(SpvBinaryBitTest, EmitExpression) {
|
||||||
<< GetParam().ast_type << "\n {\n Binary[not set]{"
|
<< GetParam().ast_type << "\n {\n Binary[not set]{"
|
||||||
<< "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op
|
<< "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op
|
||||||
<< "\n " << GetParam().ast_rhs;
|
<< "\n " << GetParam().ast_rhs;
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(ss.str()))
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(ss.str()))
|
||||||
<< assembly;
|
<< assembly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -413,7 +413,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
|
TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
|
||||||
|
@ -428,7 +428,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -442,7 +442,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryBitTest, Not_Uint_Int) {
|
TEST_F(SpvUnaryBitTest, Not_Uint_Int) {
|
||||||
|
@ -457,7 +457,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -471,7 +471,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
|
TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
|
||||||
|
@ -486,7 +486,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -498,7 +498,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) {
|
TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) {
|
||||||
|
@ -513,7 +513,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -529,7 +529,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
|
TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
|
||||||
|
@ -544,7 +544,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -562,7 +562,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) {
|
TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) {
|
||||||
|
@ -577,7 +577,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -595,7 +595,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
|
TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
|
||||||
const auto assembly = CommonTypes() + R"(
|
const auto assembly = CommonTypes() + R"(
|
||||||
|
@ -609,7 +609,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -625,7 +625,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BitTestPreamble() {
|
std::string BitTestPreamble() {
|
||||||
|
@ -664,7 +664,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Uint) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -692,7 +692,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Int) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -722,7 +722,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Uint) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -752,7 +752,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Int) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -780,7 +780,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_UintVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -808,7 +808,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_IntVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -838,7 +838,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_UintVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -868,7 +868,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_IntVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -896,7 +896,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Uint) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -924,7 +924,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Int) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -954,7 +954,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Uint) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -984,7 +984,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Int) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1012,7 +1012,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_UintVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1040,7 +1040,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_IntVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1070,7 +1070,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_UintVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1100,7 +1100,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_IntVector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body = ToString(p->get_module(), fe.ast_body());
|
const auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
|
|
@ -46,8 +46,8 @@ TEST_F(SpvParserTest, EmitStatement_VoidCallNoParams) {
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||||
const auto module_ast_str = p->get_module().to_str();
|
const auto program_ast_str = p->get_program().to_str();
|
||||||
EXPECT_THAT(module_ast_str, Eq(R"(Module{
|
EXPECT_THAT(program_ast_str, Eq(R"(Module{
|
||||||
Function tint_symbol_1 -> __void
|
Function tint_symbol_1 -> __void
|
||||||
()
|
()
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ TEST_F(SpvParserTest, EmitStatement_VoidCallNoParams) {
|
||||||
Return{}
|
Return{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)")) << module_ast_str;
|
)")) << program_ast_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) {
|
TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) {
|
||||||
|
@ -90,7 +90,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) {
|
||||||
{
|
{
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -106,17 +106,17 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Return{})"))
|
Return{})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Return{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(Return{
|
||||||
{
|
{
|
||||||
ScalarConstructor[not set]{42}
|
ScalarConstructor[not set]{42}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParamsUsedTwice) {
|
||||||
{
|
{
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_10
|
x_10
|
||||||
|
@ -178,16 +178,16 @@ Assignment{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
}
|
}
|
||||||
Return{})"))
|
Return{})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Return{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(Return{
|
||||||
{
|
{
|
||||||
ScalarConstructor[not set]{42}
|
ScalarConstructor[not set]{42}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,9 +216,9 @@ TEST_F(SpvParserTest, EmitStatement_CallWithParams) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast_str =
|
const auto program_ast_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_ast_str, HasSubstr(R"(Module{
|
EXPECT_THAT(program_ast_str, HasSubstr(R"(Module{
|
||||||
Function x_50 -> __u32
|
Function x_50 -> __u32
|
||||||
(
|
(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
|
@ -264,7 +264,7 @@ TEST_F(SpvParserTest, EmitStatement_CallWithParams) {
|
||||||
}
|
}
|
||||||
Return{}
|
Return{}
|
||||||
}
|
}
|
||||||
})")) << module_ast_str;
|
})")) << program_ast_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -7361,7 +7361,7 @@ TEST_F(SpvParserTest, EmitBody_IfBreak_FromThen_ForwardWithinThen) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -7473,7 +7473,7 @@ TEST_F(SpvParserTest, EmitBody_IfBreak_FromElse_ForwardWithinElse) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -7600,7 +7600,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error() << assembly;
|
EXPECT_TRUE(fe.EmitBody()) << p->error() << assembly;
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -7791,7 +7791,7 @@ TEST_F(SpvParserTest, EmitBody_If_Empty) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{false}
|
ScalarConstructor[not set]{false}
|
||||||
|
@ -7827,7 +7827,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_NoElse) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -7875,7 +7875,7 @@ TEST_F(SpvParserTest, EmitBody_If_NoThen_Else) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -7931,7 +7931,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Else) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -7998,7 +7998,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Else_Premerge) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8070,7 +8070,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Premerge) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8134,7 +8134,7 @@ TEST_F(SpvParserTest, EmitBody_If_Else_Premerge) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8219,7 +8219,7 @@ TEST_F(SpvParserTest, EmitBody_If_Nest_If) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8309,7 +8309,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_TrueBackedge) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8364,7 +8364,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_FalseBackedge) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8415,7 +8415,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_BothBackedge) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8458,7 +8458,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_UnconditionalBackege) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8509,7 +8509,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_SingleBlockContinue) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8574,7 +8574,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_MultiBlockContinue) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8648,7 +8648,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_ContinueNestIf) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8720,7 +8720,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_MultiBlockContinueIsEntireLoop) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -8778,7 +8778,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Never) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -8838,7 +8838,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_TrueToBody_FalseBreaks) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -8905,7 +8905,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_FalseToBody_TrueBreaks) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -8979,7 +8979,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_NestedIfContinue) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
If{
|
If{
|
||||||
(
|
(
|
||||||
|
@ -9037,7 +9037,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyAlwaysBreaks) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -9086,7 +9086,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromTrue) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -9142,7 +9142,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromFalse) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -9204,7 +9204,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromTrue_Early) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -9266,7 +9266,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromFalse_Early) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -9319,7 +9319,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_NoCases) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -9364,7 +9364,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_OneCase) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -9418,7 +9418,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_TwoCases) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -9478,7 +9478,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_CasesWithDup) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -9544,7 +9544,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsCase_NoDupCases) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -9615,7 +9615,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsCase_WithDupCase) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -9687,7 +9687,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_Case_SintValue) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -9757,7 +9757,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_Case_UintValue) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -9809,7 +9809,7 @@ TEST_F(SpvParserTest, EmitBody_Return_TopLevel) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Return{}
|
auto* expect = R"(Return{}
|
||||||
)";
|
)";
|
||||||
ASSERT_EQ(expect, got);
|
ASSERT_EQ(expect, got);
|
||||||
|
@ -9835,7 +9835,7 @@ TEST_F(SpvParserTest, EmitBody_Return_InsideIf) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{false}
|
ScalarConstructor[not set]{false}
|
||||||
|
@ -9875,7 +9875,7 @@ TEST_F(SpvParserTest, EmitBody_Return_InsideLoop) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Return{}
|
Return{}
|
||||||
}
|
}
|
||||||
|
@ -9905,7 +9905,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_TopLevel) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Return{
|
auto* expect = R"(Return{
|
||||||
{
|
{
|
||||||
ScalarConstructor[not set]{2}
|
ScalarConstructor[not set]{2}
|
||||||
|
@ -9944,7 +9944,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_InsideIf) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{false}
|
ScalarConstructor[not set]{false}
|
||||||
|
@ -10001,7 +10001,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_Loop) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Return{
|
Return{
|
||||||
{
|
{
|
||||||
|
@ -10031,7 +10031,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_TopLevel) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Discard{}
|
auto* expect = R"(Discard{}
|
||||||
)";
|
)";
|
||||||
ASSERT_EQ(expect, got);
|
ASSERT_EQ(expect, got);
|
||||||
|
@ -10057,7 +10057,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideIf) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{false}
|
ScalarConstructor[not set]{false}
|
||||||
|
@ -10097,7 +10097,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideLoop) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Discard{}
|
Discard{}
|
||||||
}
|
}
|
||||||
|
@ -10119,7 +10119,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_TopLevel) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Return{}
|
auto* expect = R"(Return{}
|
||||||
)";
|
)";
|
||||||
ASSERT_EQ(expect, got);
|
ASSERT_EQ(expect, got);
|
||||||
|
@ -10145,7 +10145,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InsideIf) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{false}
|
ScalarConstructor[not set]{false}
|
||||||
|
@ -10185,7 +10185,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InsideLoop) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Return{}
|
Return{}
|
||||||
}
|
}
|
||||||
|
@ -10215,7 +10215,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InNonVoidFunction) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Return{
|
auto* expect = R"(Return{
|
||||||
{
|
{
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -10249,7 +10249,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_BackEdge_MultiBlockLoop) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
continuing {
|
continuing {
|
||||||
Assignment{
|
Assignment{
|
||||||
|
@ -10284,7 +10284,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_BackEdge_SingleBlockLoop) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -10321,7 +10321,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_SwitchBreak_LastInCase) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -10381,7 +10381,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_SwitchBreak_NotLastInCase) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -10452,7 +10452,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopBreak_MultiBlockLoop_FromBody) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -10534,7 +10534,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
continuing {
|
continuing {
|
||||||
Assignment{
|
Assignment{
|
||||||
|
@ -10576,7 +10576,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_LastInLoopConstruct) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
|
@ -10630,7 +10630,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_BeforeLast) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
If{
|
If{
|
||||||
(
|
(
|
||||||
|
@ -10699,7 +10699,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_FromSwitch) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -10769,7 +10769,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_IfBreak_FromThen) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{false}
|
ScalarConstructor[not set]{false}
|
||||||
|
@ -10812,7 +10812,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_IfBreak_FromElse) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{false}
|
ScalarConstructor[not set]{false}
|
||||||
|
@ -10864,7 +10864,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_Fallthrough) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -10915,7 +10915,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_Forward) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11019,7 +11019,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Back_SingleBlock_Back) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -11062,7 +11062,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -11113,7 +11113,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -11171,7 +11171,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -11227,7 +11227,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -11287,7 +11287,7 @@ TEST_F(SpvParserTest,
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11348,7 +11348,7 @@ TEST_F(SpvParserTest,
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11431,7 +11431,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Continue_OnTrue) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11526,7 +11526,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Continue_OnFalse) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11611,7 +11611,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Forward_OnTrue) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11680,7 +11680,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Forward_OnFalse) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11747,7 +11747,7 @@ TEST_F(SpvParserTest,
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11821,7 +11821,7 @@ TEST_F(SpvParserTest,
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -11890,7 +11890,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -11948,7 +11948,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12021,7 +12021,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Continue_OnTrue) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12117,7 +12117,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Continue_OnFalse) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12256,7 +12256,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Forward_OnTrue) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12337,7 +12337,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Forward_OnFalse) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12405,7 +12405,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Continue_FromHeader) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12462,7 +12462,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12534,7 +12534,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12622,7 +12622,7 @@ TEST_F(
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12701,7 +12701,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopContinue_FromSwitch) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -12789,7 +12789,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_IfBreak_OnTrue) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12886,7 +12886,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_IfBreak_OnFalse) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -12982,7 +12982,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Fallthrough_OnTrue) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -13091,7 +13091,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Fallthrough_OnFalse) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -13188,7 +13188,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Forward_OnTrue) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -13269,7 +13269,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Forward_OnFalse) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -13333,7 +13333,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_IfBreak_IfBreak_Same) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -13418,7 +13418,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Fallthrough_Fallthrough_Same) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -13509,7 +13509,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Forward_Forward_Same) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{var_1}
|
Identifier[not set]{var_1}
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
|
@ -13578,7 +13578,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = "unhandled case";
|
auto* expect = "unhandled case";
|
||||||
ASSERT_EQ(expect, got);
|
ASSERT_EQ(expect, got);
|
||||||
}
|
}
|
||||||
|
@ -13613,7 +13613,7 @@ TEST_F(SpvParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = "unhandled case";
|
auto* expect = "unhandled case";
|
||||||
ASSERT_EQ(expect, got);
|
ASSERT_EQ(expect, got);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ TEST_F(SpvParserTest_Composite_Construct, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -128,7 +128,7 @@ VariableDeclStatement{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_Composite_Construct, Matrix) {
|
TEST_F(SpvParserTest_Composite_Construct, Matrix) {
|
||||||
|
@ -143,7 +143,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -169,7 +169,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_Composite_Construct, Array) {
|
TEST_F(SpvParserTest_Composite_Construct, Array) {
|
||||||
|
@ -184,7 +184,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -200,7 +200,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_Composite_Construct, Struct) {
|
TEST_F(SpvParserTest_Composite_Construct, Struct) {
|
||||||
|
@ -215,7 +215,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -233,7 +233,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
using SpvParserTest_CompositeExtract = SpvParserTest;
|
using SpvParserTest_CompositeExtract = SpvParserTest;
|
||||||
|
@ -250,7 +250,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -266,7 +266,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {
|
TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {
|
||||||
|
@ -301,7 +301,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
none
|
none
|
||||||
|
@ -313,7 +313,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) {
|
TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) {
|
||||||
|
@ -352,7 +352,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
none
|
none
|
||||||
|
@ -367,7 +367,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_CompositeExtract, Array) {
|
TEST_F(SpvParserTest_CompositeExtract, Array) {
|
||||||
|
@ -386,7 +386,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
none
|
none
|
||||||
|
@ -398,7 +398,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_CompositeExtract, RuntimeArray_IsError) {
|
TEST_F(SpvParserTest_CompositeExtract, RuntimeArray_IsError) {
|
||||||
|
@ -437,7 +437,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
none
|
none
|
||||||
|
@ -449,7 +449,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
|
TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
|
||||||
|
@ -480,7 +480,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 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->get_module(), got), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), got), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
none
|
none
|
||||||
|
@ -492,8 +492,8 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), got);
|
<< ToString(p->get_program(), got);
|
||||||
EXPECT_THAT(ToString(p->get_module(), got), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), got), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_4
|
x_4
|
||||||
none
|
none
|
||||||
|
@ -505,7 +505,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), got);
|
<< ToString(p->get_program(), got);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_CompositeExtract, Struct_IndexTooBigError) {
|
TEST_F(SpvParserTest_CompositeExtract, Struct_IndexTooBigError) {
|
||||||
|
@ -546,7 +546,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
none
|
none
|
||||||
|
@ -567,7 +567,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
using SpvParserTest_CopyObject = SpvParserTest;
|
using SpvParserTest_CopyObject = SpvParserTest;
|
||||||
|
@ -585,7 +585,7 @@ TEST_F(SpvParserTest_CopyObject, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -605,7 +605,7 @@ VariableDeclStatement{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_CopyObject, Pointer) {
|
TEST_F(SpvParserTest_CopyObject, Pointer) {
|
||||||
|
@ -624,7 +624,7 @@ TEST_F(SpvParserTest_CopyObject, Pointer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -644,7 +644,7 @@ VariableDeclStatement{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
using SpvParserTest_VectorShuffle = SpvParserTest;
|
using SpvParserTest_VectorShuffle = SpvParserTest;
|
||||||
|
@ -665,7 +665,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_10
|
x_10
|
||||||
none
|
none
|
||||||
|
@ -692,7 +692,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) {
|
TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) {
|
||||||
|
@ -708,7 +708,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_10
|
x_10
|
||||||
none
|
none
|
||||||
|
@ -751,7 +751,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) {
|
TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) {
|
||||||
|
@ -768,7 +768,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_10
|
x_10
|
||||||
none
|
none
|
||||||
|
@ -784,7 +784,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) {
|
TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -93,7 +93,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, Bitcast_Vector) {
|
TEST_F(SpvUnaryConversionTest, Bitcast_Vector) {
|
||||||
|
@ -108,7 +108,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -123,7 +123,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertSToF_BadArg) {
|
TEST_F(SpvUnaryConversionTest, ConvertSToF_BadArg) {
|
||||||
|
@ -238,7 +238,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -250,7 +250,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) {
|
||||||
|
@ -266,7 +266,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -280,7 +280,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) {
|
||||||
|
@ -296,7 +296,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -308,7 +308,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) {
|
||||||
|
@ -324,7 +324,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -338,7 +338,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_BadArgType) {
|
TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_BadArgType) {
|
||||||
|
@ -387,7 +387,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -401,7 +401,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) {
|
||||||
|
@ -417,7 +417,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -429,7 +429,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) {
|
||||||
|
@ -445,7 +445,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -459,7 +459,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) {
|
||||||
|
@ -475,7 +475,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -487,7 +487,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_BadArgType) {
|
TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_BadArgType) {
|
||||||
|
@ -537,7 +537,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -549,7 +549,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) {
|
||||||
|
@ -565,7 +565,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -579,7 +579,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) {
|
||||||
|
@ -595,7 +595,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -607,7 +607,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) {
|
||||||
|
@ -623,7 +623,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -637,7 +637,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_BadArgType) {
|
TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_BadArgType) {
|
||||||
|
@ -687,7 +687,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToSigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -701,7 +701,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToSigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) {
|
||||||
|
@ -717,7 +717,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -729,7 +729,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) {
|
||||||
|
@ -745,7 +745,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -759,7 +759,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) {
|
TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) {
|
||||||
|
@ -775,7 +775,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableConst{
|
HasSubstr(R"(VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -787,7 +787,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(dneto): OpSConvert // only if multiple widths
|
// TODO(dneto): OpSConvert // only if multiple widths
|
||||||
|
|
|
@ -59,7 +59,7 @@ TEST_F(SpvParserTest, Emit_VoidFunctionWithoutParams) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.Emit());
|
EXPECT_TRUE(fe.Emit());
|
||||||
auto got = Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
auto got = Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
std::string expect = R"(Module{
|
std::string expect = R"(Module{
|
||||||
Function x_100 -> __void
|
Function x_100 -> __void
|
||||||
()
|
()
|
||||||
|
@ -83,7 +83,7 @@ TEST_F(SpvParserTest, Emit_NonVoidResultType) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.Emit());
|
EXPECT_TRUE(fe.Emit());
|
||||||
|
|
||||||
auto got = Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
auto got = Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
std::string expect = R"(Module{
|
std::string expect = R"(Module{
|
||||||
Function x_100 -> __f32
|
Function x_100 -> __f32
|
||||||
()
|
()
|
||||||
|
@ -115,7 +115,7 @@ TEST_F(SpvParserTest, Emit_MixedParamTypes) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.Emit());
|
EXPECT_TRUE(fe.Emit());
|
||||||
|
|
||||||
auto got = Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
auto got = Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
std::string expect = R"(Module{
|
std::string expect = R"(Module{
|
||||||
Function x_100 -> __void
|
Function x_100 -> __void
|
||||||
(
|
(
|
||||||
|
@ -159,7 +159,7 @@ TEST_F(SpvParserTest, Emit_GenerateParamNames) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.Emit());
|
EXPECT_TRUE(fe.Emit());
|
||||||
|
|
||||||
auto got = Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
auto got = Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
std::string expect = R"(Module{
|
std::string expect = R"(Module{
|
||||||
Function x_100 -> __void
|
Function x_100 -> __void
|
||||||
(
|
(
|
||||||
|
|
|
@ -183,7 +183,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -191,14 +191,14 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{f1}
|
Identifier[not set]{f1}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) {
|
||||||
|
@ -212,7 +212,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -220,14 +220,14 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2f1}
|
Identifier[not set]{v2f1}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
|
||||||
|
@ -241,7 +241,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -249,7 +249,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{f1}
|
Identifier[not set]{f1}
|
||||||
Identifier[not set]{f2}
|
Identifier[not set]{f2}
|
||||||
|
@ -257,7 +257,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
|
||||||
|
@ -271,7 +271,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -279,7 +279,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2f1}
|
Identifier[not set]{v2f1}
|
||||||
Identifier[not set]{v2f2}
|
Identifier[not set]{v2f2}
|
||||||
|
@ -287,7 +287,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) {
|
||||||
|
@ -301,7 +301,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -309,14 +309,14 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{f1}
|
Identifier[not set]{f1}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) {
|
||||||
|
@ -330,7 +330,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -338,14 +338,14 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2f1}
|
Identifier[not set]{v2f1}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
|
||||||
|
@ -359,7 +359,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -367,7 +367,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{f1}
|
Identifier[not set]{f1}
|
||||||
Identifier[not set]{f2}
|
Identifier[not set]{f2}
|
||||||
|
@ -375,7 +375,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
|
||||||
|
@ -389,7 +389,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -397,7 +397,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2f1}
|
Identifier[not set]{v2f1}
|
||||||
Identifier[not set]{v2f2}
|
Identifier[not set]{v2f2}
|
||||||
|
@ -405,7 +405,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
|
||||||
|
@ -419,7 +419,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -427,7 +427,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{f1}
|
Identifier[not set]{f1}
|
||||||
Identifier[not set]{f2}
|
Identifier[not set]{f2}
|
||||||
|
@ -436,7 +436,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
|
||||||
|
@ -451,7 +451,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -459,7 +459,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2f1}
|
Identifier[not set]{v2f1}
|
||||||
Identifier[not set]{v2f2}
|
Identifier[not set]{v2f2}
|
||||||
|
@ -468,7 +468,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) {
|
||||||
|
@ -482,7 +482,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -490,7 +490,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{f1}
|
Identifier[not set]{f1}
|
||||||
Identifier[not set]{u1}
|
Identifier[not set]{u1}
|
||||||
|
@ -498,7 +498,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) {
|
||||||
|
@ -513,7 +513,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -521,7 +521,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2f1}
|
Identifier[not set]{v2f1}
|
||||||
Identifier[not set]{v2u1}
|
Identifier[not set]{v2u1}
|
||||||
|
@ -529,7 +529,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) {
|
||||||
|
@ -543,7 +543,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -551,7 +551,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{f1}
|
Identifier[not set]{f1}
|
||||||
Identifier[not set]{i1}
|
Identifier[not set]{i1}
|
||||||
|
@ -559,7 +559,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) {
|
||||||
|
@ -574,7 +574,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -582,7 +582,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2f1}
|
Identifier[not set]{v2f1}
|
||||||
Identifier[not set]{v2i1}
|
Identifier[not set]{v2i1}
|
||||||
|
@ -590,7 +590,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) {
|
TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) {
|
||||||
|
@ -605,7 +605,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -613,7 +613,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v3f1}
|
Identifier[not set]{v3f1}
|
||||||
Identifier[not set]{v3f2}
|
Identifier[not set]{v3f2}
|
||||||
|
@ -621,7 +621,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Samples,
|
INSTANTIATE_TEST_SUITE_P(Samples,
|
||||||
|
@ -709,7 +709,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -717,14 +717,14 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{i1}
|
Identifier[not set]{i1}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) {
|
||||||
|
@ -739,7 +739,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -747,14 +747,14 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2i1}
|
Identifier[not set]{v2i1}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) {
|
||||||
|
@ -769,7 +769,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -777,7 +777,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{i1}
|
Identifier[not set]{i1}
|
||||||
Identifier[not set]{i2}
|
Identifier[not set]{i2}
|
||||||
|
@ -785,7 +785,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) {
|
||||||
|
@ -800,7 +800,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -808,7 +808,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2i1}
|
Identifier[not set]{v2i1}
|
||||||
Identifier[not set]{v2i2}
|
Identifier[not set]{v2i2}
|
||||||
|
@ -816,7 +816,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
|
||||||
|
@ -831,7 +831,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -839,7 +839,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{i1}
|
Identifier[not set]{i1}
|
||||||
Identifier[not set]{i2}
|
Identifier[not set]{i2}
|
||||||
|
@ -848,7 +848,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) {
|
||||||
|
@ -863,7 +863,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -871,7 +871,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2i1}
|
Identifier[not set]{v2i1}
|
||||||
Identifier[not set]{v2i2}
|
Identifier[not set]{v2i2}
|
||||||
|
@ -880,7 +880,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Samples,
|
INSTANTIATE_TEST_SUITE_P(Samples,
|
||||||
|
@ -907,7 +907,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -915,7 +915,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{u1}
|
Identifier[not set]{u1}
|
||||||
Identifier[not set]{u2}
|
Identifier[not set]{u2}
|
||||||
|
@ -923,7 +923,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) {
|
||||||
|
@ -938,7 +938,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -946,7 +946,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2u1}
|
Identifier[not set]{v2u1}
|
||||||
Identifier[not set]{v2u2}
|
Identifier[not set]{v2u2}
|
||||||
|
@ -954,7 +954,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) {
|
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) {
|
||||||
|
@ -968,7 +968,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -976,7 +976,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{u1}
|
Identifier[not set]{u1}
|
||||||
Identifier[not set]{u2}
|
Identifier[not set]{u2}
|
||||||
|
@ -985,7 +985,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) {
|
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) {
|
||||||
|
@ -1000,7 +1000,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -1008,7 +1008,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) {
|
||||||
{
|
{
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{)" + GetParam().wgsl_func +
|
Identifier[not set]{)" + GetParam().wgsl_func +
|
||||||
R"(}
|
R"(}
|
||||||
(
|
(
|
||||||
Identifier[not set]{v2u1}
|
Identifier[not set]{v2u1}
|
||||||
Identifier[not set]{v2u2}
|
Identifier[not set]{v2u2}
|
||||||
|
@ -1017,7 +1017,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Samples,
|
INSTANTIATE_TEST_SUITE_P(Samples,
|
||||||
|
@ -1043,7 +1043,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SAbs) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto body = ToString(p->get_module(), fe.ast_body());
|
auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1095,7 +1095,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMax) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto body = ToString(p->get_module(), fe.ast_body());
|
auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1153,7 +1153,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMin) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto body = ToString(p->get_module(), fe.ast_body());
|
auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1211,7 +1211,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SClamp) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto body = ToString(p->get_module(), fe.ast_body());
|
auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1271,7 +1271,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMax) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto body = ToString(p->get_module(), fe.ast_body());
|
auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1329,7 +1329,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMin) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto body = ToString(p->get_module(), fe.ast_body());
|
auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1387,7 +1387,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UClamp) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
auto body = ToString(p->get_module(), fe.ast_body());
|
auto body = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body, HasSubstr(R"(
|
EXPECT_THAT(body, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
|
|
@ -206,7 +206,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -218,7 +218,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) {
|
TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) {
|
||||||
|
@ -233,7 +233,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -249,7 +249,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BinaryData {
|
struct BinaryData {
|
||||||
|
@ -296,7 +296,7 @@ TEST_P(SpvBinaryLogicalTest, EmitExpression) {
|
||||||
<< GetParam().ast_type << "\n {\n Binary[not set]{"
|
<< GetParam().ast_type << "\n {\n Binary[not set]{"
|
||||||
<< "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op
|
<< "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op
|
||||||
<< "\n " << GetParam().ast_rhs;
|
<< "\n " << GetParam().ast_rhs;
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(ss.str()))
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(ss.str()))
|
||||||
<< assembly;
|
<< assembly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,7 +702,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -718,7 +718,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordEqual_Vector) {
|
TEST_F(SpvFUnordTest, FUnordEqual_Vector) {
|
||||||
|
@ -733,7 +733,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -757,7 +757,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) {
|
TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) {
|
||||||
|
@ -772,7 +772,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -788,7 +788,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) {
|
TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) {
|
||||||
|
@ -803,7 +803,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -827,7 +827,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) {
|
TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) {
|
||||||
|
@ -842,7 +842,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -858,7 +858,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordLessThan_Vector) {
|
TEST_F(SpvFUnordTest, FUnordLessThan_Vector) {
|
||||||
|
@ -873,7 +873,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -897,7 +897,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) {
|
TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) {
|
||||||
|
@ -912,7 +912,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -928,7 +928,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) {
|
TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) {
|
||||||
|
@ -943,7 +943,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -967,7 +967,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) {
|
TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) {
|
||||||
|
@ -982,7 +982,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -998,7 +998,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) {
|
TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) {
|
||||||
|
@ -1013,7 +1013,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -1037,7 +1037,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) {
|
TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) {
|
||||||
|
@ -1052,7 +1052,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -1068,7 +1068,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) {
|
TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) {
|
||||||
|
@ -1083,7 +1083,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -1107,7 +1107,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) {
|
TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) {
|
||||||
|
@ -1122,7 +1122,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1139,7 +1139,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) {
|
TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) {
|
||||||
|
@ -1154,7 +1154,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1171,7 +1171,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) {
|
TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) {
|
||||||
|
@ -1186,7 +1186,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1203,7 +1203,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) {
|
TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) {
|
||||||
|
@ -1218,7 +1218,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1243,7 +1243,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) {
|
TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) {
|
||||||
|
@ -1258,7 +1258,7 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1287,7 +1287,7 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
using SpvLogicalTest = SpvParserTestBase<::testing::Test>;
|
using SpvLogicalTest = SpvParserTestBase<::testing::Test>;
|
||||||
|
@ -1304,7 +1304,7 @@ TEST_F(SpvLogicalTest, Any) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1323,7 +1323,7 @@ TEST_F(SpvLogicalTest, Any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvLogicalTest, All) {
|
TEST_F(SpvLogicalTest, All) {
|
||||||
|
@ -1338,7 +1338,7 @@ TEST_F(SpvLogicalTest, All) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1357,7 +1357,7 @@ TEST_F(SpvLogicalTest, All) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvLogicalTest, IsNan_Scalar) {
|
TEST_F(SpvLogicalTest, IsNan_Scalar) {
|
||||||
|
@ -1372,7 +1372,7 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1387,7 +1387,7 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvLogicalTest, IsNan_Vector) {
|
TEST_F(SpvLogicalTest, IsNan_Vector) {
|
||||||
|
@ -1402,7 +1402,7 @@ TEST_F(SpvLogicalTest, IsNan_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1421,7 +1421,7 @@ TEST_F(SpvLogicalTest, IsNan_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvLogicalTest, IsInf_Scalar) {
|
TEST_F(SpvLogicalTest, IsInf_Scalar) {
|
||||||
|
@ -1436,7 +1436,7 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1451,7 +1451,7 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvLogicalTest, IsInf_Vector) {
|
TEST_F(SpvLogicalTest, IsInf_Vector) {
|
||||||
|
@ -1466,7 +1466,7 @@ TEST_F(SpvLogicalTest, IsInf_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1485,7 +1485,7 @@ TEST_F(SpvLogicalTest, IsInf_Vector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(dneto): Kernel-guarded instructions.
|
// TODO(dneto): Kernel-guarded instructions.
|
||||||
|
|
|
@ -51,7 +51,8 @@ TEST_F(SpvParserTest, EmitStatement_StoreBoolConst) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
ScalarConstructor[not set]{true}
|
ScalarConstructor[not set]{true}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +84,8 @@ TEST_F(SpvParserTest, EmitStatement_StoreUintConst) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
ScalarConstructor[not set]{42}
|
ScalarConstructor[not set]{42}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +113,8 @@ TEST_F(SpvParserTest, EmitStatement_StoreIntConst) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
ScalarConstructor[not set]{42}
|
ScalarConstructor[not set]{42}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +142,8 @@ TEST_F(SpvParserTest, EmitStatement_StoreFloatConst) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
ScalarConstructor[not set]{42.000000}
|
ScalarConstructor[not set]{42.000000}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +172,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadBool) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
none
|
none
|
||||||
|
@ -197,7 +201,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadScalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
|
@ -239,7 +243,7 @@ TEST_F(SpvParserTest, EmitStatement_UseLoadedScalarTwice) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
|
@ -277,7 +281,8 @@ TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
ScalarConstructor[not set]{42}
|
ScalarConstructor[not set]{42}
|
||||||
})"));
|
})"));
|
||||||
|
@ -344,13 +349,14 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorSwizzle) {
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
MemberAccessor[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
Identifier[not set]{z}
|
Identifier[not set]{z}
|
||||||
}
|
}
|
||||||
ScalarConstructor[not set]{42}
|
ScalarConstructor[not set]{42}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorConstOutOfBounds) {
|
TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorConstOutOfBounds) {
|
||||||
|
@ -407,7 +413,8 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorNonConstIndex) {
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
ArrayAccessor[not set]{
|
ArrayAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
Identifier[not set]{x_11}
|
Identifier[not set]{x_11}
|
||||||
|
@ -444,7 +451,8 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Matrix) {
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
ArrayAccessor[not set]{
|
ArrayAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
ScalarConstructor[not set]{2}
|
ScalarConstructor[not set]{2}
|
||||||
|
@ -487,7 +495,8 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Array) {
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
ArrayAccessor[not set]{
|
ArrayAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
ScalarConstructor[not set]{2}
|
ScalarConstructor[not set]{2}
|
||||||
|
@ -529,7 +538,8 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct) {
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
MemberAccessor[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
Identifier[not set]{age}
|
Identifier[not set]{age}
|
||||||
|
@ -577,7 +587,8 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_DifferOnlyMemberName) {
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
MemberAccessor[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
Identifier[not set]{age}
|
Identifier[not set]{age}
|
||||||
|
@ -590,7 +601,7 @@ Assignment{
|
||||||
Identifier[not set]{ancientness}
|
Identifier[not set]{ancientness}
|
||||||
}
|
}
|
||||||
ScalarConstructor[not set]{420.000000}
|
ScalarConstructor[not set]{420.000000}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitStatement_AccessChain_StructNonConstIndex) {
|
TEST_F(SpvParserTest, EmitStatement_AccessChain_StructNonConstIndex) {
|
||||||
|
@ -687,7 +698,8 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_RuntimeArray) {
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
ArrayAccessor[not set]{
|
ArrayAccessor[not set]{
|
||||||
MemberAccessor[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
|
@ -727,7 +739,8 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Compound_Matrix_Vector) {
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody());
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
MemberAccessor[not set]{
|
MemberAccessor[not set]{
|
||||||
ArrayAccessor[not set]{
|
ArrayAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
|
@ -801,7 +814,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_TypesAndVarDeclarations) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||||
<< assembly << p->error();
|
<< assembly << p->error();
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
RTArr -> __array__u32_stride_4
|
RTArr -> __array__u32_stride_4
|
||||||
S Struct{
|
S Struct{
|
||||||
|
@ -836,7 +849,8 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_NonCascaded) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
MemberAccessor[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
Identifier[not set]{field0}
|
Identifier[not set]{field0}
|
||||||
|
@ -852,7 +866,7 @@ Assignment{
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
}
|
}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body())
|
})")) << ToString(p->get_program(), fe.ast_body())
|
||||||
<< p->error();
|
<< p->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,7 +889,8 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
|
HasSubstr(R"(Assignment{
|
||||||
ArrayAccessor[not set]{
|
ArrayAccessor[not set]{
|
||||||
MemberAccessor[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{myvar}
|
Identifier[not set]{myvar}
|
||||||
|
@ -884,7 +899,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) {
|
||||||
ScalarConstructor[not set]{1}
|
ScalarConstructor[not set]{1}
|
||||||
}
|
}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body())
|
})")) << ToString(p->get_program(), fe.ast_body())
|
||||||
<< p->error();
|
<< p->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -908,7 +923,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_2
|
x_2
|
||||||
|
@ -928,7 +943,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) {
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{x_2}
|
Identifier[not set]{x_2}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body())
|
})")) << ToString(p->get_program(), fe.ast_body())
|
||||||
<< p->error();
|
<< p->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,7 +979,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithHoisting) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
Eq(R"(VariableDeclStatement{
|
Eq(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_2
|
x_2
|
||||||
|
@ -999,7 +1014,7 @@ Assignment{
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
}
|
}
|
||||||
Return{}
|
Return{}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body())
|
)")) << ToString(p->get_program(), fe.ast_body())
|
||||||
<< p->error();
|
<< p->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,7 +1067,7 @@ TEST_F(SpvParserTest, ArrayLength) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
const auto body_str = ToString(p->get_module(), fe.ast_body());
|
const auto body_str = ToString(p->get_program(), fe.ast_body());
|
||||||
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
|
EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
|
|
@ -68,7 +68,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Scalar) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_11
|
x_11
|
||||||
|
@ -108,7 +108,7 @@ VariableDeclStatement{
|
||||||
ScalarConstructor[not set]{0.000000}
|
ScalarConstructor[not set]{0.000000}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) {
|
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) {
|
||||||
|
@ -129,7 +129,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_11
|
x_11
|
||||||
|
@ -171,7 +171,7 @@ VariableDeclStatement{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
|
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
|
||||||
|
@ -190,7 +190,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_11
|
x_11
|
||||||
|
@ -212,7 +212,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
|
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
|
||||||
|
@ -232,7 +232,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_11
|
x_11
|
||||||
|
@ -246,7 +246,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
|
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
|
||||||
|
@ -265,7 +265,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_11
|
x_11
|
||||||
|
@ -281,7 +281,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(p->get_module(), fe.ast_body());
|
})")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTestMiscInstruction, OpNop) {
|
TEST_F(SpvParserTestMiscInstruction, OpNop) {
|
||||||
|
@ -297,8 +297,8 @@ TEST_F(SpvParserTestMiscInstruction, OpNop) {
|
||||||
<< p->error() << assembly;
|
<< p->error() << assembly;
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), Eq(R"(Return{}
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), Eq(R"(Return{}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body());
|
)")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test swizzle generation.
|
// Test swizzle generation.
|
||||||
|
@ -329,7 +329,7 @@ TEST_P(SpvParserSwizzleTest, Sample) {
|
||||||
ASSERT_NE(result, nullptr);
|
ASSERT_NE(result, nullptr);
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
result->to_str(ss, 0);
|
result->to_str(ss, 0);
|
||||||
auto str = Demangler().Demangle(p->get_module(), ss.str());
|
auto str = Demangler().Demangle(p->get_program(), ss.str());
|
||||||
EXPECT_THAT(str, Eq(GetParam().expected_expr));
|
EXPECT_THAT(str, Eq(GetParam().expected_expr));
|
||||||
} else {
|
} else {
|
||||||
EXPECT_EQ(result, nullptr);
|
EXPECT_EQ(result, nullptr);
|
||||||
|
|
|
@ -91,7 +91,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_AnonymousVars) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_1
|
x_1
|
||||||
|
@ -130,7 +130,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_NamedVars) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
a
|
a
|
||||||
|
@ -169,7 +169,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MixedTypes) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
a
|
a
|
||||||
|
@ -211,7 +211,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarInitializers) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
a
|
a
|
||||||
|
@ -285,7 +285,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarNullInitializers) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
a
|
a
|
||||||
|
@ -345,7 +345,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_200
|
x_200
|
||||||
|
@ -360,7 +360,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body());
|
)")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
|
TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
|
||||||
|
@ -384,7 +384,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_200
|
x_200
|
||||||
|
@ -431,7 +431,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_200
|
x_200
|
||||||
|
@ -446,7 +446,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body());
|
)")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) {
|
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) {
|
||||||
|
@ -466,7 +466,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_200
|
x_200
|
||||||
|
@ -481,7 +481,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body());
|
)")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
|
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
|
||||||
|
@ -500,7 +500,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_200
|
x_200
|
||||||
|
@ -515,7 +515,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body());
|
)")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) {
|
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) {
|
||||||
|
@ -535,7 +535,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_200
|
x_200
|
||||||
|
@ -550,7 +550,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body());
|
)")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
|
TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
|
||||||
|
@ -570,7 +570,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_200
|
x_200
|
||||||
|
@ -590,7 +590,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body());
|
)")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) {
|
TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) {
|
||||||
|
@ -610,7 +610,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||||
|
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()),
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()),
|
||||||
HasSubstr(R"(VariableDeclStatement{
|
HasSubstr(R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_200
|
x_200
|
||||||
|
@ -630,7 +630,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)")) << ToString(p->get_module(), fe.ast_body());
|
)")) << ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest,
|
TEST_F(SpvParserTest,
|
||||||
|
@ -655,7 +655,7 @@ TEST_F(SpvParserTest,
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect =
|
auto* expect =
|
||||||
R"(VariableDeclStatement{
|
R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
|
@ -703,7 +703,7 @@ TEST_F(SpvParserTest, EmitStatement_CombinatorialValue_Immediate_UsedTwice) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(VariableDeclStatement{
|
auto* expect = R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_25
|
x_25
|
||||||
|
@ -775,7 +775,7 @@ TEST_F(SpvParserTest,
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(VariableDeclStatement{
|
auto* expect = R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_25
|
x_25
|
||||||
|
@ -874,7 +874,7 @@ TEST_F(
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Assignment{
|
auto* expect = R"(Assignment{
|
||||||
Identifier[not set]{x_1}
|
Identifier[not set]{x_1}
|
||||||
ScalarConstructor[not set]{0}
|
ScalarConstructor[not set]{0}
|
||||||
|
@ -992,7 +992,7 @@ TEST_F(
|
||||||
|
|
||||||
// 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
|
||||||
// a const definition.
|
// a const definition.
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(VariableDeclStatement{
|
auto* expect = R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1077,7 +1077,7 @@ TEST_F(SpvParserTest,
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{true}
|
ScalarConstructor[not set]{true}
|
||||||
|
@ -1164,7 +1164,7 @@ TEST_F(
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(If{
|
auto* expect = R"(If{
|
||||||
(
|
(
|
||||||
ScalarConstructor[not set]{true}
|
ScalarConstructor[not set]{true}
|
||||||
|
@ -1247,7 +1247,7 @@ TEST_F(SpvParserTest,
|
||||||
|
|
||||||
// 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
|
||||||
// a const definition.
|
// a const definition.
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(VariableDeclStatement{
|
auto* expect = R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
|
@ -1321,7 +1321,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_SingleBlockLoopIndex) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
VariableDeclStatement{
|
VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
|
@ -1465,7 +1465,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_MultiBlockLoopIndex) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(Loop{
|
auto* expect = R"(Loop{
|
||||||
VariableDeclStatement{
|
VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
|
@ -1623,7 +1623,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_ValueFromLoopBodyAndContinuing) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(VariableDeclStatement{
|
auto* expect = R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_101
|
x_101
|
||||||
|
@ -1792,7 +1792,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromElseAndThen) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(VariableDeclStatement{
|
auto* expect = R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_101
|
x_101
|
||||||
|
@ -1914,7 +1914,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromHeaderAndThen) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(VariableDeclStatement{
|
auto* expect = R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_101
|
x_101
|
||||||
|
@ -2022,7 +2022,7 @@ TEST_F(SpvParserTest, EmitStatement_UseInPhiCountsAsUse) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
|
|
||||||
auto got = ToString(p->get_module(), fe.ast_body());
|
auto got = ToString(p->get_program(), fe.ast_body());
|
||||||
auto* expect = R"(VariableDeclStatement{
|
auto* expect = R"(VariableDeclStatement{
|
||||||
Variable{
|
Variable{
|
||||||
x_101_phi
|
x_101_phi
|
||||||
|
|
|
@ -38,8 +38,8 @@ bool Parser::Parse() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Module Parser::module() {
|
Program Parser::program() {
|
||||||
return impl_->module();
|
return impl_->program();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
|
|
|
@ -40,8 +40,8 @@ class Parser : public Reader {
|
||||||
/// @returns true if the parse was successful, false otherwise.
|
/// @returns true if the parse was successful, false otherwise.
|
||||||
bool Parse() override;
|
bool Parse() override;
|
||||||
|
|
||||||
/// @returns the module. The module in the parser will be reset after this.
|
/// @returns the program. The program in the parser will be reset after this.
|
||||||
ast::Module module() override;
|
Program program() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<ParserImpl> impl_;
|
std::unique_ptr<ParserImpl> impl_;
|
||||||
|
|
|
@ -255,7 +255,7 @@ ParserImpl::ParserImpl(const std::vector<uint32_t>& spv_binary)
|
||||||
: Reader(),
|
: Reader(),
|
||||||
spv_binary_(spv_binary),
|
spv_binary_(spv_binary),
|
||||||
fail_stream_(&success_, &errors_),
|
fail_stream_(&success_, &errors_),
|
||||||
bool_type_(ast_module_.create<type::Bool>()),
|
bool_type_(program_.create<type::Bool>()),
|
||||||
namer_(fail_stream_),
|
namer_(fail_stream_),
|
||||||
enum_converter_(fail_stream_),
|
enum_converter_(fail_stream_),
|
||||||
tools_context_(kInputEnv) {
|
tools_context_(kInputEnv) {
|
||||||
|
@ -307,10 +307,10 @@ bool ParserImpl::Parse() {
|
||||||
return success_;
|
return success_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Module ParserImpl::module() {
|
Program ParserImpl::program() {
|
||||||
// TODO(dneto): Should we clear out spv_binary_ here, to reduce
|
// TODO(dneto): Should we clear out spv_binary_ here, to reduce
|
||||||
// memory usage?
|
// memory usage?
|
||||||
return std::move(ast_module_);
|
return std::move(program_);
|
||||||
}
|
}
|
||||||
|
|
||||||
type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||||
|
@ -344,7 +344,7 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||||
|
|
||||||
switch (spirv_type->kind()) {
|
switch (spirv_type->kind()) {
|
||||||
case spvtools::opt::analysis::Type::kVoid:
|
case spvtools::opt::analysis::Type::kVoid:
|
||||||
return save(ast_module_.create<type::Void>());
|
return save(program_.create<type::Void>());
|
||||||
case spvtools::opt::analysis::Type::kBool:
|
case spvtools::opt::analysis::Type::kBool:
|
||||||
return save(bool_type_);
|
return save(bool_type_);
|
||||||
case spvtools::opt::analysis::Type::kInteger:
|
case spvtools::opt::analysis::Type::kInteger:
|
||||||
|
@ -374,7 +374,7 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||||
case spvtools::opt::analysis::Type::kImage:
|
case spvtools::opt::analysis::Type::kImage:
|
||||||
// Fake it for sampler and texture types. These are handled in an
|
// Fake it for sampler and texture types. These are handled in an
|
||||||
// entirely different way.
|
// entirely different way.
|
||||||
return save(ast_module_.create<type::Void>());
|
return save(program_.create<type::Void>());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -713,8 +713,8 @@ bool ParserImpl::RegisterEntryPoints() {
|
||||||
type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Integer* int_ty) {
|
const spvtools::opt::analysis::Integer* int_ty) {
|
||||||
if (int_ty->width() == 32) {
|
if (int_ty->width() == 32) {
|
||||||
type::Type* signed_ty = ast_module_.create<type::I32>();
|
type::Type* signed_ty = program_.create<type::I32>();
|
||||||
type::Type* unsigned_ty = ast_module_.create<type::U32>();
|
type::Type* unsigned_ty = program_.create<type::U32>();
|
||||||
signed_type_for_[unsigned_ty] = signed_ty;
|
signed_type_for_[unsigned_ty] = signed_ty;
|
||||||
unsigned_type_for_[signed_ty] = unsigned_ty;
|
unsigned_type_for_[signed_ty] = unsigned_ty;
|
||||||
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
|
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
|
||||||
|
@ -726,7 +726,7 @@ type::Type* ParserImpl::ConvertType(
|
||||||
type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Float* float_ty) {
|
const spvtools::opt::analysis::Float* float_ty) {
|
||||||
if (float_ty->width() == 32) {
|
if (float_ty->width() == 32) {
|
||||||
return ast_module_.create<type::F32>();
|
return program_.create<type::F32>();
|
||||||
}
|
}
|
||||||
Fail() << "unhandled float width: " << float_ty->width();
|
Fail() << "unhandled float width: " << float_ty->width();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -739,16 +739,16 @@ type::Type* ParserImpl::ConvertType(
|
||||||
if (ast_elem_ty == nullptr) {
|
if (ast_elem_ty == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* this_ty = ast_module_.create<type::Vector>(ast_elem_ty, num_elem);
|
auto* this_ty = program_.create<type::Vector>(ast_elem_ty, num_elem);
|
||||||
// Generate the opposite-signedness vector type, if this type is integral.
|
// Generate the opposite-signedness vector type, if this type is integral.
|
||||||
if (unsigned_type_for_.count(ast_elem_ty)) {
|
if (unsigned_type_for_.count(ast_elem_ty)) {
|
||||||
auto* other_ty = ast_module_.create<type::Vector>(
|
auto* other_ty = program_.create<type::Vector>(
|
||||||
unsigned_type_for_[ast_elem_ty], num_elem);
|
unsigned_type_for_[ast_elem_ty], num_elem);
|
||||||
signed_type_for_[other_ty] = this_ty;
|
signed_type_for_[other_ty] = this_ty;
|
||||||
unsigned_type_for_[this_ty] = other_ty;
|
unsigned_type_for_[this_ty] = other_ty;
|
||||||
} else if (signed_type_for_.count(ast_elem_ty)) {
|
} else if (signed_type_for_.count(ast_elem_ty)) {
|
||||||
auto* other_ty = ast_module_.create<type::Vector>(
|
auto* other_ty =
|
||||||
signed_type_for_[ast_elem_ty], num_elem);
|
program_.create<type::Vector>(signed_type_for_[ast_elem_ty], num_elem);
|
||||||
unsigned_type_for_[other_ty] = this_ty;
|
unsigned_type_for_[other_ty] = this_ty;
|
||||||
signed_type_for_[this_ty] = other_ty;
|
signed_type_for_[this_ty] = other_ty;
|
||||||
}
|
}
|
||||||
|
@ -765,7 +765,7 @@ type::Type* ParserImpl::ConvertType(
|
||||||
if (ast_scalar_ty == nullptr) {
|
if (ast_scalar_ty == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ast_module_.create<type::Matrix>(ast_scalar_ty, num_rows, num_columns);
|
return program_.create<type::Matrix>(ast_scalar_ty, num_rows, num_columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
type::Type* ParserImpl::ConvertType(
|
type::Type* ParserImpl::ConvertType(
|
||||||
|
@ -947,7 +947,7 @@ type::Type* ParserImpl::ConvertType(
|
||||||
}
|
}
|
||||||
const auto member_name = namer_.GetMemberName(type_id, member_index);
|
const auto member_name = namer_.GetMemberName(type_id, member_index);
|
||||||
auto* ast_struct_member = create<ast::StructMember>(
|
auto* ast_struct_member = create<ast::StructMember>(
|
||||||
Source{}, ast_module_.RegisterSymbol(member_name), ast_member_ty,
|
Source{}, program_.RegisterSymbol(member_name), ast_member_ty,
|
||||||
std::move(ast_member_decorations));
|
std::move(ast_member_decorations));
|
||||||
ast_members.push_back(ast_struct_member);
|
ast_members.push_back(ast_struct_member);
|
||||||
}
|
}
|
||||||
|
@ -963,13 +963,13 @@ type::Type* ParserImpl::ConvertType(
|
||||||
namer_.SuggestSanitizedName(type_id, "S");
|
namer_.SuggestSanitizedName(type_id, "S");
|
||||||
|
|
||||||
auto name = namer_.GetName(type_id);
|
auto name = namer_.GetName(type_id);
|
||||||
auto* result = ast_module_.create<type::Struct>(
|
auto* result =
|
||||||
ast_module_.RegisterSymbol(name), ast_struct);
|
program_.create<type::Struct>(program_.RegisterSymbol(name), ast_struct);
|
||||||
id_to_type_[type_id] = result;
|
id_to_type_[type_id] = result;
|
||||||
if (num_non_writable_members == members.size()) {
|
if (num_non_writable_members == members.size()) {
|
||||||
read_only_struct_types_.insert(result);
|
read_only_struct_types_.insert(result);
|
||||||
}
|
}
|
||||||
ast_module_.AddConstructedType(result);
|
program_.AddConstructedType(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,7 +1003,7 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id,
|
||||||
ast_storage_class = ast::StorageClass::kStorage;
|
ast_storage_class = ast::StorageClass::kStorage;
|
||||||
remap_buffer_block_type_.insert(type_id);
|
remap_buffer_block_type_.insert(type_id);
|
||||||
}
|
}
|
||||||
return ast_module_.create<type::Pointer>(ast_elem_ty, ast_storage_class);
|
return program_.create<type::Pointer>(ast_elem_ty, ast_storage_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::RegisterTypes() {
|
bool ParserImpl::RegisterTypes() {
|
||||||
|
@ -1091,7 +1091,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
||||||
MakeVariable(inst.result_id(), ast::StorageClass::kNone, ast_type,
|
MakeVariable(inst.result_id(), ast::StorageClass::kNone, ast_type,
|
||||||
true, ast_expr, std::move(spec_id_decos));
|
true, ast_expr, std::move(spec_id_decos));
|
||||||
if (ast_var) {
|
if (ast_var) {
|
||||||
ast_module_.AddGlobalVariable(ast_var);
|
program_.AddGlobalVariable(ast_var);
|
||||||
scalar_spec_constants_.insert(inst.result_id());
|
scalar_spec_constants_.insert(inst.result_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1129,11 +1129,11 @@ void ParserImpl::MaybeGenerateAlias(uint32_t type_id,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto name = namer_.GetName(type_id);
|
const auto name = namer_.GetName(type_id);
|
||||||
auto* ast_alias_type = ast_module_.create<type::Alias>(
|
auto* ast_alias_type = program_.create<type::Alias>(
|
||||||
ast_module_.RegisterSymbol(name), ast_underlying_type);
|
program_.RegisterSymbol(name), ast_underlying_type);
|
||||||
// Record this new alias as the AST type for this SPIR-V ID.
|
// Record this new alias as the AST type for this SPIR-V ID.
|
||||||
id_to_type_[type_id] = ast_alias_type;
|
id_to_type_[type_id] = ast_alias_type;
|
||||||
ast_module_.AddConstructedType(ast_alias_type);
|
program_.AddConstructedType(ast_alias_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::EmitModuleScopeVariables() {
|
bool ParserImpl::EmitModuleScopeVariables() {
|
||||||
|
@ -1209,7 +1209,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
||||||
ast_constructor, ast::VariableDecorationList{});
|
ast_constructor, ast::VariableDecorationList{});
|
||||||
// TODO(dneto): initializers (a.k.a. constructor expression)
|
// TODO(dneto): initializers (a.k.a. constructor expression)
|
||||||
if (ast_var) {
|
if (ast_var) {
|
||||||
ast_module_.AddGlobalVariable(ast_var);
|
program_.AddGlobalVariable(ast_var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1226,7 +1226,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
||||||
create<ast::BuiltinDecoration>(Source{}, ast::Builtin::kPosition),
|
create<ast::BuiltinDecoration>(Source{}, ast::Builtin::kPosition),
|
||||||
});
|
});
|
||||||
|
|
||||||
ast_module_.AddGlobalVariable(var);
|
program_.AddGlobalVariable(var);
|
||||||
}
|
}
|
||||||
return success_;
|
return success_;
|
||||||
}
|
}
|
||||||
|
@ -1248,7 +1248,7 @@ ast::Variable* ParserImpl::MakeVariable(
|
||||||
auto access = read_only_struct_types_.count(type)
|
auto access = read_only_struct_types_.count(type)
|
||||||
? ast::AccessControl::kReadOnly
|
? ast::AccessControl::kReadOnly
|
||||||
: ast::AccessControl::kReadWrite;
|
: ast::AccessControl::kReadWrite;
|
||||||
type = ast_module_.create<type::AccessControl>(access, type);
|
type = program_.create<type::AccessControl>(access, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& deco : GetDecorationsFor(id)) {
|
for (auto& deco : GetDecorationsFor(id)) {
|
||||||
|
@ -1306,13 +1306,13 @@ ast::Variable* ParserImpl::MakeVariable(
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name = namer_.Name(id);
|
std::string name = namer_.Name(id);
|
||||||
return create<ast::Variable>(Source{}, // source
|
return create<ast::Variable>(Source{}, // source
|
||||||
ast_module_.RegisterSymbol(name), // symbol
|
program_.RegisterSymbol(name), // symbol
|
||||||
sc, // storage_class
|
sc, // storage_class
|
||||||
type, // type
|
type, // type
|
||||||
is_const, // is_const
|
is_const, // is_const
|
||||||
constructor, // constructor
|
constructor, // constructor
|
||||||
decorations); // decorations
|
decorations); // decorations
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
||||||
|
@ -1451,7 +1451,7 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
|
||||||
if (const auto* mat_ty = type->As<type::Matrix>()) {
|
if (const auto* mat_ty = type->As<type::Matrix>()) {
|
||||||
// Matrix components are columns
|
// Matrix components are columns
|
||||||
auto* column_ty =
|
auto* column_ty =
|
||||||
ast_module_.create<type::Vector>(mat_ty->type(), mat_ty->rows());
|
program_.create<type::Vector>(mat_ty->type(), mat_ty->rows());
|
||||||
ast::ExpressionList ast_components;
|
ast::ExpressionList ast_components;
|
||||||
for (size_t i = 0; i < mat_ty->columns(); ++i) {
|
for (size_t i = 0; i < mat_ty->columns(); ++i) {
|
||||||
ast_components.emplace_back(MakeNullValue(column_ty));
|
ast_components.emplace_back(MakeNullValue(column_ty));
|
||||||
|
@ -1546,14 +1546,14 @@ type::Type* ParserImpl::GetSignedIntMatchingShape(type::Type* other) {
|
||||||
if (other == nullptr) {
|
if (other == nullptr) {
|
||||||
Fail() << "no type provided";
|
Fail() << "no type provided";
|
||||||
}
|
}
|
||||||
auto* i32 = ast_module_.create<type::I32>();
|
auto* i32 = program_.create<type::I32>();
|
||||||
if (other->Is<type::F32>() || other->Is<type::U32>() ||
|
if (other->Is<type::F32>() || other->Is<type::U32>() ||
|
||||||
other->Is<type::I32>()) {
|
other->Is<type::I32>()) {
|
||||||
return i32;
|
return i32;
|
||||||
}
|
}
|
||||||
auto* vec_ty = other->As<type::Vector>();
|
auto* vec_ty = other->As<type::Vector>();
|
||||||
if (vec_ty) {
|
if (vec_ty) {
|
||||||
return ast_module_.create<type::Vector>(i32, vec_ty->size());
|
return program_.create<type::Vector>(i32, vec_ty->size());
|
||||||
}
|
}
|
||||||
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1564,14 +1564,14 @@ type::Type* ParserImpl::GetUnsignedIntMatchingShape(type::Type* other) {
|
||||||
Fail() << "no type provided";
|
Fail() << "no type provided";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* u32 = ast_module_.create<type::U32>();
|
auto* u32 = program_.create<type::U32>();
|
||||||
if (other->Is<type::F32>() || other->Is<type::U32>() ||
|
if (other->Is<type::F32>() || other->Is<type::U32>() ||
|
||||||
other->Is<type::I32>()) {
|
other->Is<type::I32>()) {
|
||||||
return u32;
|
return u32;
|
||||||
}
|
}
|
||||||
auto* vec_ty = other->As<type::Vector>();
|
auto* vec_ty = other->As<type::Vector>();
|
||||||
if (vec_ty) {
|
if (vec_ty) {
|
||||||
return ast_module_.create<type::Vector>(u32, vec_ty->size());
|
return program_.create<type::Vector>(u32, vec_ty->size());
|
||||||
}
|
}
|
||||||
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1845,7 +1845,7 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
// Construct the Tint handle type.
|
// Construct the Tint handle type.
|
||||||
type::Type* ast_store_type = nullptr;
|
type::Type* ast_store_type = nullptr;
|
||||||
if (usage.IsSampler()) {
|
if (usage.IsSampler()) {
|
||||||
ast_store_type = ast_module_.create<type::Sampler>(
|
ast_store_type = program_.create<type::Sampler>(
|
||||||
usage.IsComparisonSampler() ? type::SamplerKind::kComparisonSampler
|
usage.IsComparisonSampler() ? type::SamplerKind::kComparisonSampler
|
||||||
: type::SamplerKind::kSampler);
|
: type::SamplerKind::kSampler);
|
||||||
} else if (usage.IsTexture()) {
|
} else if (usage.IsTexture()) {
|
||||||
|
@ -1876,13 +1876,13 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
|
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
|
||||||
// treat that as a depth texture.
|
// treat that as a depth texture.
|
||||||
if (image_type->depth() || usage.IsDepthTexture()) {
|
if (image_type->depth() || usage.IsDepthTexture()) {
|
||||||
ast_store_type = ast_module_.create<type::DepthTexture>(dim);
|
ast_store_type = program_.create<type::DepthTexture>(dim);
|
||||||
} else if (image_type->is_multisampled()) {
|
} else if (image_type->is_multisampled()) {
|
||||||
// Multisampled textures are never depth textures.
|
// Multisampled textures are never depth textures.
|
||||||
ast_store_type = ast_module_.create<type::MultisampledTexture>(
|
ast_store_type = program_.create<type::MultisampledTexture>(
|
||||||
dim, ast_sampled_component_type);
|
dim, ast_sampled_component_type);
|
||||||
} else {
|
} else {
|
||||||
ast_store_type = ast_module_.create<type::SampledTexture>(
|
ast_store_type = program_.create<type::SampledTexture>(
|
||||||
dim, ast_sampled_component_type);
|
dim, ast_sampled_component_type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1893,8 +1893,8 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
if (format == type::ImageFormat::kNone) {
|
if (format == type::ImageFormat::kNone) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ast_store_type = ast_module_.create<type::AccessControl>(
|
ast_store_type = program_.create<type::AccessControl>(
|
||||||
access, ast_module_.create<type::StorageTexture>(dim, format));
|
access, program_.create<type::StorageTexture>(dim, format));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Fail() << "unsupported: UniformConstant variable is not a recognized "
|
Fail() << "unsupported: UniformConstant variable is not a recognized "
|
||||||
|
@ -1904,7 +1904,7 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Form the pointer type.
|
// Form the pointer type.
|
||||||
auto* result = ast_module_.create<type::Pointer>(
|
auto* result = program_.create<type::Pointer>(
|
||||||
ast_store_type, ast::StorageClass::kUniformConstant);
|
ast_store_type, ast::StorageClass::kUniformConstant);
|
||||||
// Remember it for later.
|
// Remember it for later.
|
||||||
handle_type_[&var] = result;
|
handle_type_[&var] = result;
|
||||||
|
@ -1922,7 +1922,7 @@ type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) {
|
||||||
case type::ImageFormat::kRg32Uint:
|
case type::ImageFormat::kRg32Uint:
|
||||||
case type::ImageFormat::kRgba16Uint:
|
case type::ImageFormat::kRgba16Uint:
|
||||||
case type::ImageFormat::kRgba32Uint:
|
case type::ImageFormat::kRgba32Uint:
|
||||||
return ast_module_.create<type::U32>();
|
return program_.create<type::U32>();
|
||||||
|
|
||||||
case type::ImageFormat::kR8Sint:
|
case type::ImageFormat::kR8Sint:
|
||||||
case type::ImageFormat::kR16Sint:
|
case type::ImageFormat::kR16Sint:
|
||||||
|
@ -1933,7 +1933,7 @@ type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) {
|
||||||
case type::ImageFormat::kRg32Sint:
|
case type::ImageFormat::kRg32Sint:
|
||||||
case type::ImageFormat::kRgba16Sint:
|
case type::ImageFormat::kRgba16Sint:
|
||||||
case type::ImageFormat::kRgba32Sint:
|
case type::ImageFormat::kRgba32Sint:
|
||||||
return ast_module_.create<type::I32>();
|
return program_.create<type::I32>();
|
||||||
|
|
||||||
case type::ImageFormat::kR8Unorm:
|
case type::ImageFormat::kR8Unorm:
|
||||||
case type::ImageFormat::kRg8Unorm:
|
case type::ImageFormat::kRg8Unorm:
|
||||||
|
@ -1952,7 +1952,7 @@ type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) {
|
||||||
case type::ImageFormat::kRg32Float:
|
case type::ImageFormat::kRg32Float:
|
||||||
case type::ImageFormat::kRgba16Float:
|
case type::ImageFormat::kRgba16Float:
|
||||||
case type::ImageFormat::kRgba32Float:
|
case type::ImageFormat::kRgba32Float:
|
||||||
return ast_module_.create<type::F32>();
|
return program_.create<type::F32>();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1992,7 +1992,7 @@ type::Type* ParserImpl::GetTexelTypeForFormat(type::ImageFormat format) {
|
||||||
case type::ImageFormat::kRg8Uint:
|
case type::ImageFormat::kRg8Uint:
|
||||||
case type::ImageFormat::kRg8Unorm:
|
case type::ImageFormat::kRg8Unorm:
|
||||||
// Two channels
|
// Two channels
|
||||||
return ast_module_.create<type::Vector>(component_type, 2);
|
return program_.create<type::Vector>(component_type, 2);
|
||||||
|
|
||||||
case type::ImageFormat::kBgra8Unorm:
|
case type::ImageFormat::kBgra8Unorm:
|
||||||
case type::ImageFormat::kBgra8UnormSrgb:
|
case type::ImageFormat::kBgra8UnormSrgb:
|
||||||
|
@ -2009,7 +2009,7 @@ type::Type* ParserImpl::GetTexelTypeForFormat(type::ImageFormat format) {
|
||||||
case type::ImageFormat::kRgba8Unorm:
|
case type::ImageFormat::kRgba8Unorm:
|
||||||
case type::ImageFormat::kRgba8UnormSrgb:
|
case type::ImageFormat::kRgba8UnormSrgb:
|
||||||
// Four channels
|
// Four channels
|
||||||
return ast_module_.create<type::Vector>(component_type, 4);
|
return program_.create<type::Vector>(component_type, 4);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
#include "source/opt/types.h"
|
#include "source/opt/types.h"
|
||||||
#include "spirv-tools/libspirv.hpp"
|
#include "spirv-tools/libspirv.hpp"
|
||||||
#include "src/ast/expression.h"
|
#include "src/ast/expression.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/ast/struct_member_decoration.h"
|
#include "src/ast/struct_member_decoration.h"
|
||||||
|
#include "src/program.h"
|
||||||
#include "src/reader/reader.h"
|
#include "src/reader/reader.h"
|
||||||
#include "src/reader/spirv/entry_point_info.h"
|
#include "src/reader/spirv/entry_point_info.h"
|
||||||
#include "src/reader/spirv/enum_converter.h"
|
#include "src/reader/spirv/enum_converter.h"
|
||||||
|
@ -95,12 +95,12 @@ class ParserImpl : Reader {
|
||||||
/// @returns true if the parse was successful, false otherwise.
|
/// @returns true if the parse was successful, false otherwise.
|
||||||
bool Parse() override;
|
bool Parse() override;
|
||||||
|
|
||||||
/// @returns the module. The module in the parser will be reset after this.
|
/// @returns the program. The program in the parser will be reset after this.
|
||||||
ast::Module module() override;
|
Program program() override;
|
||||||
|
|
||||||
/// Returns a pointer to the module, without resetting it.
|
/// Returns a reference to the program, without resetting it.
|
||||||
/// @returns the module
|
/// @returns the program
|
||||||
ast::Module& get_module() { return ast_module_; }
|
Program& get_program() { return program_; }
|
||||||
|
|
||||||
/// Logs failure, ands return a failure stream to accumulate diagnostic
|
/// Logs failure, ands return a failure stream to accumulate diagnostic
|
||||||
/// messages. By convention, a failure should only be logged along with
|
/// messages. By convention, a failure should only be logged along with
|
||||||
|
@ -118,14 +118,14 @@ class ParserImpl : Reader {
|
||||||
const std::string error() { return errors_.str(); }
|
const std::string error() { return errors_.str(); }
|
||||||
|
|
||||||
/// Builds an internal representation of the SPIR-V binary,
|
/// Builds an internal representation of the SPIR-V binary,
|
||||||
/// and parses it into a Tint AST module. Diagnostics are emitted
|
/// and parses it into a Tint program. Diagnostics are emitted
|
||||||
/// to the error stream.
|
/// to the error stream.
|
||||||
/// @returns true if it was successful.
|
/// @returns true if it was successful.
|
||||||
bool BuildAndParseInternalModule() {
|
bool BuildAndParseInternalModule() {
|
||||||
return BuildInternalModule() && ParseInternalModule();
|
return BuildInternalModule() && ParseInternalModule();
|
||||||
}
|
}
|
||||||
/// Builds an internal representation of the SPIR-V binary,
|
/// Builds an internal representation of the SPIR-V binary,
|
||||||
/// and parses the module, except functions, into a Tint AST module.
|
/// and parses the module, except functions, into a Tint program.
|
||||||
/// Diagnostics are emitted to the error stream.
|
/// Diagnostics are emitted to the error stream.
|
||||||
/// @returns true if it was successful.
|
/// @returns true if it was successful.
|
||||||
bool BuildAndParseInternalModuleExceptFunctions() {
|
bool BuildAndParseInternalModuleExceptFunctions() {
|
||||||
|
@ -524,20 +524,20 @@ class ParserImpl : Reader {
|
||||||
bool ParseArrayDecorations(const spvtools::opt::analysis::Type* spv_type,
|
bool ParseArrayDecorations(const spvtools::opt::analysis::Type* spv_type,
|
||||||
ast::ArrayDecorationList* decorations);
|
ast::ArrayDecorationList* decorations);
|
||||||
|
|
||||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
/// Creates a new `ast::Node` owned by the Program. When the Program is
|
||||||
/// destructed, the `ast::Node` will also be destructed.
|
/// destructed, the `ast::Node` will also be destructed.
|
||||||
/// @param args the arguments to pass to the type constructor
|
/// @param args the arguments to pass to the type constructor
|
||||||
/// @returns the node pointer
|
/// @returns the node pointer
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
T* create(ARGS&&... args) {
|
T* create(ARGS&&... args) {
|
||||||
return ast_module_.create<T>(std::forward<ARGS>(args)...);
|
return program_.create<T>(std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The SPIR-V binary we're parsing
|
// The SPIR-V binary we're parsing
|
||||||
std::vector<uint32_t> spv_binary_;
|
std::vector<uint32_t> spv_binary_;
|
||||||
|
|
||||||
// The resulting module in Tint AST form.
|
// The resulting module in Tint AST form.
|
||||||
ast::Module ast_module_;
|
Program program_;
|
||||||
|
|
||||||
// Is the parse successful?
|
// Is the parse successful?
|
||||||
bool success_ = true;
|
bool success_ = true;
|
||||||
|
|
|
@ -566,7 +566,7 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
||||||
EXPECT_TRUE(type->Is<type::Struct>());
|
EXPECT_TRUE(type->Is<type::Struct>());
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), ss.str()), Eq(R"(Struct{
|
||||||
StructMember{field0: __u32}
|
StructMember{field0: __u32}
|
||||||
StructMember{field1: __f32}
|
StructMember{field1: __f32}
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
|
||||||
EXPECT_TRUE(type->Is<type::Struct>());
|
EXPECT_TRUE(type->Is<type::Struct>());
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), ss.str()), Eq(R"(Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
StructMember{field0: __u32}
|
StructMember{field0: __u32}
|
||||||
}
|
}
|
||||||
|
@ -612,7 +612,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
|
||||||
EXPECT_TRUE(type->Is<type::Struct>());
|
EXPECT_TRUE(type->Is<type::Struct>());
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
type->As<type::Struct>()->impl()->to_str(ss, 0);
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), ss.str()), Eq(R"(Struct{
|
||||||
StructMember{[[ offset 0 ]] field0: __f32}
|
StructMember{[[ offset 0 ]] field0: __f32}
|
||||||
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
|
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
|
||||||
StructMember{[[ offset 16 ]] field2: __mat_2_2__f32}
|
StructMember{[[ offset 16 ]] field2: __mat_2_2__f32}
|
||||||
|
|
|
@ -53,8 +53,8 @@ TEST_F(SpvParserTest, EmitFunctions_NoFunctions) {
|
||||||
auto p = parser(test::Assemble(CommonTypes()));
|
auto p = parser(test::Assemble(CommonTypes()));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast = p->get_module().to_str();
|
const auto program_ast = p->get_program().to_str();
|
||||||
EXPECT_THAT(module_ast, Not(HasSubstr("Function{")));
|
EXPECT_THAT(program_ast, Not(HasSubstr("Function{")));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctions_FunctionWithoutBody) {
|
TEST_F(SpvParserTest, EmitFunctions_FunctionWithoutBody) {
|
||||||
|
@ -64,8 +64,8 @@ TEST_F(SpvParserTest, EmitFunctions_FunctionWithoutBody) {
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast = p->get_module().to_str();
|
const auto program_ast = p->get_program().to_str();
|
||||||
EXPECT_THAT(module_ast, Not(HasSubstr("Function{")));
|
EXPECT_THAT(program_ast, Not(HasSubstr("Function{")));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctions_Function_EntryPoint_Vertex) {
|
TEST_F(SpvParserTest, EmitFunctions_Function_EntryPoint_Vertex) {
|
||||||
|
@ -79,10 +79,10 @@ OpFunctionEnd)";
|
||||||
auto p = parser(test::Assemble(input));
|
auto p = parser(test::Assemble(input));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||||
ASSERT_TRUE(p->error().empty()) << p->error();
|
ASSERT_TRUE(p->error().empty()) << p->error();
|
||||||
const auto module_ast = p->get_module().to_str();
|
const auto program_ast = p->get_program().to_str();
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function )" + p->get_module().GetSymbol("main").to_str() +
|
Function )" + p->get_program().GetSymbol("main").to_str() +
|
||||||
R"( -> __void
|
R"( -> __void
|
||||||
StageDecoration{vertex}
|
StageDecoration{vertex}
|
||||||
()
|
()
|
||||||
{)"));
|
{)"));
|
||||||
|
@ -99,10 +99,10 @@ OpFunctionEnd)";
|
||||||
auto p = parser(test::Assemble(input));
|
auto p = parser(test::Assemble(input));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||||
ASSERT_TRUE(p->error().empty()) << p->error();
|
ASSERT_TRUE(p->error().empty()) << p->error();
|
||||||
const auto module_ast = p->get_module().to_str();
|
const auto program_ast = p->get_program().to_str();
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function )" + p->get_module().GetSymbol("main").to_str() +
|
Function )" + p->get_program().GetSymbol("main").to_str() +
|
||||||
R"( -> __void
|
R"( -> __void
|
||||||
StageDecoration{fragment}
|
StageDecoration{fragment}
|
||||||
()
|
()
|
||||||
{)"));
|
{)"));
|
||||||
|
@ -119,10 +119,10 @@ OpFunctionEnd)";
|
||||||
auto p = parser(test::Assemble(input));
|
auto p = parser(test::Assemble(input));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||||
ASSERT_TRUE(p->error().empty()) << p->error();
|
ASSERT_TRUE(p->error().empty()) << p->error();
|
||||||
const auto module_ast = p->get_module().to_str();
|
const auto program_ast = p->get_program().to_str();
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function )" + p->get_module().GetSymbol("main").to_str() +
|
Function )" + p->get_program().GetSymbol("main").to_str() +
|
||||||
R"( -> __void
|
R"( -> __void
|
||||||
StageDecoration{compute}
|
StageDecoration{compute}
|
||||||
()
|
()
|
||||||
{)"));
|
{)"));
|
||||||
|
@ -141,16 +141,16 @@ OpFunctionEnd)";
|
||||||
auto p = parser(test::Assemble(input));
|
auto p = parser(test::Assemble(input));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||||
ASSERT_TRUE(p->error().empty()) << p->error();
|
ASSERT_TRUE(p->error().empty()) << p->error();
|
||||||
const auto module_ast = p->get_module().to_str();
|
const auto program_ast = p->get_program().to_str();
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function )" + p->get_module().GetSymbol("frag_main").to_str() +
|
Function )" + p->get_program().GetSymbol("frag_main").to_str() +
|
||||||
R"( -> __void
|
R"( -> __void
|
||||||
StageDecoration{fragment}
|
StageDecoration{fragment}
|
||||||
()
|
()
|
||||||
{)"));
|
{)"));
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function )" + p->get_module().GetSymbol("comp_main").to_str() +
|
Function )" + p->get_program().GetSymbol("comp_main").to_str() +
|
||||||
R"( -> __void
|
R"( -> __void
|
||||||
StageDecoration{compute}
|
StageDecoration{compute}
|
||||||
()
|
()
|
||||||
{)"));
|
{)"));
|
||||||
|
@ -165,10 +165,10 @@ TEST_F(SpvParserTest, EmitFunctions_VoidFunctionWithoutParams) {
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast = p->get_module().to_str();
|
const auto program_ast = p->get_program().to_str();
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function )" + p->get_module().GetSymbol("main").to_str() +
|
Function )" + p->get_program().GetSymbol("main").to_str() +
|
||||||
R"( -> __void
|
R"( -> __void
|
||||||
()
|
()
|
||||||
{)"));
|
{)"));
|
||||||
}
|
}
|
||||||
|
@ -199,9 +199,9 @@ TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) {
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast =
|
const auto program_ast =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function leaf -> __u32
|
Function leaf -> __u32
|
||||||
()
|
()
|
||||||
{
|
{
|
||||||
|
@ -253,7 +253,7 @@ TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) {
|
||||||
}
|
}
|
||||||
Return{}
|
Return{}
|
||||||
}
|
}
|
||||||
})")) << module_ast;
|
})")) << program_ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctions_NonVoidResultType) {
|
TEST_F(SpvParserTest, EmitFunctions_NonVoidResultType) {
|
||||||
|
@ -267,9 +267,9 @@ TEST_F(SpvParserTest, EmitFunctions_NonVoidResultType) {
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast =
|
const auto program_ast =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function ret_float -> __f32
|
Function ret_float -> __f32
|
||||||
()
|
()
|
||||||
{
|
{
|
||||||
|
@ -279,7 +279,7 @@ TEST_F(SpvParserTest, EmitFunctions_NonVoidResultType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< module_ast;
|
<< program_ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitFunctions_MixedParamTypes) {
|
TEST_F(SpvParserTest, EmitFunctions_MixedParamTypes) {
|
||||||
|
@ -297,9 +297,9 @@ TEST_F(SpvParserTest, EmitFunctions_MixedParamTypes) {
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast =
|
const auto program_ast =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function mixed_params -> __void
|
Function mixed_params -> __void
|
||||||
(
|
(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
|
@ -337,9 +337,9 @@ TEST_F(SpvParserTest, EmitFunctions_GenerateParamNames) {
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast =
|
const auto program_ast =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||||
Function mixed_params -> __void
|
Function mixed_params -> __void
|
||||||
(
|
(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
|
@ -361,7 +361,7 @@ TEST_F(SpvParserTest, EmitFunctions_GenerateParamNames) {
|
||||||
{
|
{
|
||||||
Return{}
|
Return{}
|
||||||
})"))
|
})"))
|
||||||
<< module_ast;
|
<< program_ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -1129,9 +1129,9 @@ TEST_P(SpvParserTest_DeclUnderspecifiedHandle, Variable) {
|
||||||
auto p = parser(test::Assemble(assembly));
|
auto p = parser(test::Assemble(assembly));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly;
|
||||||
EXPECT_TRUE(p->error().empty()) << p->error();
|
EXPECT_TRUE(p->error().empty()) << p->error();
|
||||||
const auto module =
|
const auto program =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module, HasSubstr(GetParam().var_decl)) << module;
|
EXPECT_THAT(program, HasSubstr(GetParam().var_decl)) << program;
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Samplers,
|
INSTANTIATE_TEST_SUITE_P(Samplers,
|
||||||
|
@ -1306,12 +1306,12 @@ TEST_P(SpvParserTest_SampledImageAccessTest, Variable) {
|
||||||
auto p = parser(test::Assemble(assembly));
|
auto p = parser(test::Assemble(assembly));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly;
|
||||||
EXPECT_TRUE(p->error().empty()) << p->error();
|
EXPECT_TRUE(p->error().empty()) << p->error();
|
||||||
const auto module =
|
const auto program =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module, HasSubstr(GetParam().var_decl))
|
EXPECT_THAT(program, HasSubstr(GetParam().var_decl))
|
||||||
<< "DECLARATIONS ARE BAD " << module;
|
<< "DECLARATIONS ARE BAD " << program;
|
||||||
EXPECT_THAT(module, HasSubstr(GetParam().texture_builtin))
|
EXPECT_THAT(program, HasSubstr(GetParam().texture_builtin))
|
||||||
<< "TEXTURE BUILTIN IS BAD " << module << assembly;
|
<< "TEXTURE BUILTIN IS BAD " << program << assembly;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(dneto): Test variable declaration and texture builtins provoked by
|
// TODO(dneto): Test variable declaration and texture builtins provoked by
|
||||||
|
@ -2556,12 +2556,12 @@ TEST_P(SpvParserTest_ImageAccessTest, Variable) {
|
||||||
auto p = parser(test::Assemble(assembly));
|
auto p = parser(test::Assemble(assembly));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly;
|
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly;
|
||||||
EXPECT_TRUE(p->error().empty()) << p->error();
|
EXPECT_TRUE(p->error().empty()) << p->error();
|
||||||
const auto module =
|
const auto program =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module, HasSubstr(GetParam().var_decl))
|
EXPECT_THAT(program, HasSubstr(GetParam().var_decl))
|
||||||
<< "DECLARATIONS ARE BAD " << module;
|
<< "DECLARATIONS ARE BAD " << program;
|
||||||
EXPECT_THAT(module, HasSubstr(GetParam().texture_builtin))
|
EXPECT_THAT(program, HasSubstr(GetParam().texture_builtin))
|
||||||
<< "TEXTURE BUILTIN IS BAD " << module << assembly;
|
<< "TEXTURE BUILTIN IS BAD " << program << assembly;
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(ImageWrite_OptionalParams,
|
INSTANTIATE_TEST_SUITE_P(ImageWrite_OptionalParams,
|
||||||
|
@ -3712,7 +3712,7 @@ TEST_P(SpvParserTest_ImageCoordsTest, MakeCoordinateOperandsForImageAccess) {
|
||||||
for (auto* expr : result) {
|
for (auto* expr : result) {
|
||||||
ASSERT_NE(expr, nullptr);
|
ASSERT_NE(expr, nullptr);
|
||||||
result_strings.push_back(
|
result_strings.push_back(
|
||||||
Demangler().Demangle(p->get_module(), expr->str()));
|
Demangler().Demangle(p->get_program(), expr->str()));
|
||||||
}
|
}
|
||||||
EXPECT_THAT(result_strings,
|
EXPECT_THAT(result_strings,
|
||||||
::testing::ContainerEq(GetParam().expected_expressions));
|
::testing::ContainerEq(GetParam().expected_expressions));
|
||||||
|
|
|
@ -35,8 +35,8 @@ TEST_F(SpvParserTest, Import_NoImport) {
|
||||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast = p->module().to_str();
|
const auto program_ast = p->program().to_str();
|
||||||
EXPECT_THAT(module_ast, Not(HasSubstr("Import")));
|
EXPECT_THAT(program_ast, Not(HasSubstr("Import")));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, Import_ImportGlslStd450) {
|
TEST_F(SpvParserTest, Import_ImportGlslStd450) {
|
||||||
|
|
|
@ -70,8 +70,8 @@ TEST_F(SpvModuleScopeVarParserTest, NoVar) {
|
||||||
auto p = parser(test::Assemble(""));
|
auto p = parser(test::Assemble(""));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_ast = p->module().to_str();
|
const auto program_ast = p->program().to_str();
|
||||||
EXPECT_THAT(module_ast, Not(HasSubstr("Variable")));
|
EXPECT_THAT(program_ast, Not(HasSubstr("Variable")));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvModuleScopeVarParserTest, BadStorageClass_NotAWebGPUStorageClass) {
|
TEST_F(SpvModuleScopeVarParserTest, BadStorageClass_NotAWebGPUStorageClass) {
|
||||||
|
@ -144,7 +144,7 @@ TEST_F(SpvModuleScopeVarParserTest, AnonWorkgroupVar) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
x_52
|
x_52
|
||||||
|
@ -164,7 +164,7 @@ TEST_F(SpvModuleScopeVarParserTest, NamedWorkgroupVar) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
the_counter
|
the_counter
|
||||||
|
@ -184,7 +184,7 @@ TEST_F(SpvModuleScopeVarParserTest, PrivateVar) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
my_own_private_idaho
|
my_own_private_idaho
|
||||||
|
@ -204,7 +204,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinVertexIndex) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -255,7 +255,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinPosition_MapsToModuleScopeVec4Var) {
|
||||||
EXPECT_EQ(position_info.storage_class, SpvStorageClassOutput);
|
EXPECT_EQ(position_info.storage_class, SpvStorageClassOutput);
|
||||||
EXPECT_EQ(position_info.per_vertex_var_id, 1u);
|
EXPECT_EQ(position_info.per_vertex_var_id, 1u);
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -336,7 +336,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinPosition_StorePosition) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{gl_Position}
|
Identifier[not set]{gl_Position}
|
||||||
|
@ -390,7 +390,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Assignment{
|
Assignment{
|
||||||
Identifier[not set]{gl_Position}
|
Identifier[not set]{gl_Position}
|
||||||
|
@ -422,7 +422,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Assignment{
|
Assignment{
|
||||||
MemberAccessor[not set]{
|
MemberAccessor[not set]{
|
||||||
|
@ -454,7 +454,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
{
|
{
|
||||||
Assignment{
|
Assignment{
|
||||||
|
@ -485,7 +485,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinPointSize_Write1_IsErased) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_EQ(module_str, R"(Module{
|
EXPECT_EQ(module_str, R"(Module{
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -542,7 +542,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinPointSize_ReadReplaced) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_EQ(module_str, R"(Module{
|
EXPECT_EQ(module_str, R"(Module{
|
||||||
Variable{
|
Variable{
|
||||||
x_900
|
x_900
|
||||||
|
@ -610,7 +610,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_EQ(module_str, R"(Module{
|
EXPECT_EQ(module_str, R"(Module{
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -662,7 +662,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinPointSize_Loose_Write1_IsErased) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_EQ(module_str, R"(Module{
|
EXPECT_EQ(module_str, R"(Module{
|
||||||
Function x_500 -> __void
|
Function x_500 -> __void
|
||||||
()
|
()
|
||||||
|
@ -707,7 +707,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinPointSize_Loose_ReadReplaced) {
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_EQ(module_str, R"(Module{
|
EXPECT_EQ(module_str, R"(Module{
|
||||||
Variable{
|
Variable{
|
||||||
x_900
|
x_900
|
||||||
|
@ -744,7 +744,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_EQ(module_str, R"(Module{
|
EXPECT_EQ(module_str, R"(Module{
|
||||||
Function x_500 -> __void
|
Function x_500 -> __void
|
||||||
()
|
()
|
||||||
|
@ -772,7 +772,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty()) << p->error();
|
EXPECT_TRUE(p->error().empty()) << p->error();
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_EQ(module_str, R"(Module{
|
EXPECT_EQ(module_str, R"(Module{
|
||||||
Function x_500 -> __void
|
Function x_500 -> __void
|
||||||
()
|
()
|
||||||
|
@ -877,7 +877,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarInitializers) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_1
|
x_1
|
||||||
private
|
private
|
||||||
|
@ -935,7 +935,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarNullInitializers) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_1
|
x_1
|
||||||
private
|
private
|
||||||
|
@ -985,7 +985,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarUndefInitializers) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_1
|
x_1
|
||||||
private
|
private
|
||||||
|
@ -1030,7 +1030,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1054,7 +1054,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorBoolNullInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1078,7 +1078,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorBoolUndefInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1102,7 +1102,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorUintNullInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1126,7 +1126,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorUintUndefInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1150,7 +1150,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorIntNullInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1174,7 +1174,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorIntUndefInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1198,7 +1198,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorFloatNullInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1222,7 +1222,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorFloatUndefInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1252,7 +1252,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1289,7 +1289,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixNullInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1326,7 +1326,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixUndefInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1364,7 +1364,7 @@ TEST_F(SpvModuleScopeVarParserTest, ArrayInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1388,7 +1388,7 @@ TEST_F(SpvModuleScopeVarParserTest, ArrayNullInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1412,7 +1412,7 @@ TEST_F(SpvModuleScopeVarParserTest, ArrayUndefInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1438,7 +1438,7 @@ TEST_F(SpvModuleScopeVarParserTest, StructInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1468,7 +1468,7 @@ TEST_F(SpvModuleScopeVarParserTest, StructNullInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1498,7 +1498,7 @@ TEST_F(SpvModuleScopeVarParserTest, StructUndefInitializer) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1530,7 +1530,7 @@ TEST_F(SpvModuleScopeVarParserTest, LocationDecoration_Valid) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1583,7 +1583,7 @@ TEST_F(SpvModuleScopeVarParserTest, DescriptorGroupDecoration_Valid) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1638,7 +1638,7 @@ TEST_F(SpvModuleScopeVarParserTest, BindingDecoration_Valid) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1693,7 +1693,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1725,7 +1725,7 @@ TEST_F(SpvModuleScopeVarParserTest, ColMajorDecoration_Dropped) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1755,7 +1755,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixStrideDecoration_Dropped) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1805,7 +1805,7 @@ TEST_F(SpvModuleScopeVarParserTest, StorageBuffer_NonWritable_AllMembers) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1835,7 +1835,7 @@ TEST_F(SpvModuleScopeVarParserTest, StorageBuffer_NonWritable_NotAllMembers) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1868,7 +1868,7 @@ TEST_F(
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1893,7 +1893,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_True) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1919,7 +1919,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_False) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1945,7 +1945,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_U32) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1971,7 +1971,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_I32) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1997,7 +1997,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_F32) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -2024,7 +2024,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str =
|
const auto module_str =
|
||||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
Demangler().Demangle(p->get_program(), p->get_program().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
myconst
|
myconst
|
||||||
|
@ -2053,7 +2053,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_UsedInFunction) {
|
||||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(
|
EXPECT_THAT(ToString(p->get_program(), fe.ast_body()), HasSubstr(R"(
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_1
|
x_1
|
||||||
none
|
none
|
||||||
|
@ -2066,7 +2066,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_UsedInFunction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"))
|
})"))
|
||||||
<< ToString(p->get_module(), fe.ast_body());
|
<< ToString(p->get_program(), fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
#include "src/type/array_type.h"
|
|
||||||
#include "src/type/matrix_type.h"
|
|
||||||
#include "src/type/struct_type.h"
|
|
||||||
#include "src/type/vector_type.h"
|
|
||||||
#include "src/demangler.h"
|
#include "src/demangler.h"
|
||||||
#include "src/reader/spirv/parser_impl.h"
|
#include "src/reader/spirv/parser_impl.h"
|
||||||
#include "src/reader/spirv/parser_impl_test_helper.h"
|
#include "src/reader/spirv/parser_impl_test_helper.h"
|
||||||
#include "src/reader/spirv/spirv_tools_helpers_test.h"
|
#include "src/reader/spirv/spirv_tools_helpers_test.h"
|
||||||
|
#include "src/type/array_type.h"
|
||||||
|
#include "src/type/matrix_type.h"
|
||||||
|
#include "src/type/struct_type.h"
|
||||||
|
#include "src/type/vector_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
@ -40,7 +40,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonStruct) {
|
||||||
%s = OpTypeStruct %uint %uint
|
%s = OpTypeStruct %uint %uint
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), p->get_program().to_str()),
|
||||||
HasSubstr("S Struct"));
|
HasSubstr("S Struct"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedStruct) {
|
||||||
%s = OpTypeStruct %uint %uint
|
%s = OpTypeStruct %uint %uint
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), p->get_program().to_str()),
|
||||||
HasSubstr("mystruct Struct"));
|
HasSubstr("mystruct Struct"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(SpvParserTest, NamedTypes_Dup_EmitBoth) {
|
||||||
%s2 = OpTypeStruct %uint %uint
|
%s2 = OpTypeStruct %uint %uint
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), p->get_program().to_str()),
|
||||||
HasSubstr(R"(S Struct{
|
HasSubstr(R"(S Struct{
|
||||||
StructMember{field0: __u32}
|
StructMember{field0: __u32}
|
||||||
StructMember{field1: __u32}
|
StructMember{field1: __u32}
|
||||||
|
@ -84,7 +84,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArrayWithDecoration) {
|
||||||
%arr = OpTypeRuntimeArray %uint
|
%arr = OpTypeRuntimeArray %uint
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), p->get_program().to_str()),
|
||||||
HasSubstr("RTArr -> __array__u32_stride_8\n"));
|
HasSubstr("RTArr -> __array__u32_stride_8\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArray_Dup_EmitBoth) {
|
||||||
%arr2 = OpTypeRuntimeArray %uint
|
%arr2 = OpTypeRuntimeArray %uint
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), p->get_program().to_str()),
|
||||||
HasSubstr("RTArr -> __array__u32_stride_8\n RTArr_1 -> "
|
HasSubstr("RTArr -> __array__u32_stride_8\n RTArr_1 -> "
|
||||||
"__array__u32_stride_8\n"));
|
"__array__u32_stride_8\n"));
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedRTArray) {
|
||||||
%arr = OpTypeRuntimeArray %uint
|
%arr = OpTypeRuntimeArray %uint
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), p->get_program().to_str()),
|
||||||
HasSubstr("myrtarr -> __array__u32_stride_8\n"));
|
HasSubstr("myrtarr -> __array__u32_stride_8\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedArray) {
|
||||||
%arr2 = OpTypeArray %uint %uint_5
|
%arr2 = OpTypeArray %uint %uint_5
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), p->get_program().to_str()),
|
||||||
HasSubstr("myarr -> __array__u32_5_stride_8"));
|
HasSubstr("myarr -> __array__u32_5_stride_8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonArray_Dup_EmitBoth) {
|
||||||
%arr2 = OpTypeArray %uint %uint_5
|
%arr2 = OpTypeArray %uint %uint_5
|
||||||
)"));
|
)"));
|
||||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||||
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
|
EXPECT_THAT(Demangler().Demangle(p->get_program(), p->get_program().to_str()),
|
||||||
HasSubstr("Arr -> __array__u32_5_stride_8\n Arr_1 -> "
|
HasSubstr("Arr -> __array__u32_5_stride_8\n Arr_1 -> "
|
||||||
"__array__u32_5_stride_8"));
|
"__array__u32_5_stride_8"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,16 +58,16 @@ class SpvParserTestBase : public T {
|
||||||
using SpvParserTest = SpvParserTestBase<::testing::Test>;
|
using SpvParserTest = SpvParserTestBase<::testing::Test>;
|
||||||
|
|
||||||
/// Returns the string dump of a statement list.
|
/// Returns the string dump of a statement list.
|
||||||
/// @param mod the module
|
/// @param program the program
|
||||||
/// @param stmts the statement list
|
/// @param stmts the statement list
|
||||||
/// @returns the string dump of a statement list.
|
/// @returns the string dump of a statement list.
|
||||||
inline std::string ToString(const ast::Module& mod,
|
inline std::string ToString(const Program& program,
|
||||||
const ast::StatementList& stmts) {
|
const ast::StatementList& stmts) {
|
||||||
std::ostringstream outs;
|
std::ostringstream outs;
|
||||||
for (const auto* stmt : stmts) {
|
for (const auto* stmt : stmts) {
|
||||||
stmt->to_str(outs, 0);
|
stmt->to_str(outs, 0);
|
||||||
}
|
}
|
||||||
return Demangler().Demangle(mod, outs.str());
|
return Demangler().Demangle(program, outs.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
|
|
|
@ -35,8 +35,8 @@ bool Parser::Parse() {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Module Parser::module() {
|
Program Parser::program() {
|
||||||
return impl_->module();
|
return impl_->program();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wgsl
|
} // namespace wgsl
|
||||||
|
|
|
@ -39,8 +39,8 @@ class Parser : public Reader {
|
||||||
/// @returns true if the parse was successful, false otherwise.
|
/// @returns true if the parse was successful, false otherwise.
|
||||||
bool Parse() override;
|
bool Parse() override;
|
||||||
|
|
||||||
/// @returns the module. The module in the parser will be reset after this.
|
/// @returns the program. The program in the parser will be reset after this.
|
||||||
ast::Module module() override;
|
Program program() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<ParserImpl> impl_;
|
std::unique_ptr<ParserImpl> impl_;
|
||||||
|
|
|
@ -293,7 +293,7 @@ void ParserImpl::translation_unit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(module_.IsValid());
|
assert(program_.IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
// global_decl
|
// global_decl
|
||||||
|
@ -323,7 +323,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
||||||
if (!expect("variable declaration", Token::Type::kSemicolon))
|
if (!expect("variable declaration", Token::Type::kSemicolon))
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
module_.AddGlobalVariable(gv.value);
|
program_.AddGlobalVariable(gv.value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
||||||
if (!expect("constant declaration", Token::Type::kSemicolon))
|
if (!expect("constant declaration", Token::Type::kSemicolon))
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
module_.AddGlobalVariable(gc.value);
|
program_.AddGlobalVariable(gc.value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
||||||
if (!expect("type alias", Token::Type::kSemicolon))
|
if (!expect("type alias", Token::Type::kSemicolon))
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
module_.AddConstructedType(ta.value);
|
program_.AddConstructedType(ta.value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,8 +361,8 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
||||||
|
|
||||||
auto* type = str.value;
|
auto* type = str.value;
|
||||||
register_constructed(
|
register_constructed(
|
||||||
module_.SymbolToName(type->As<type::Struct>()->symbol()), type);
|
program_.SymbolToName(type->As<type::Struct>()->symbol()), type);
|
||||||
module_.AddConstructedType(type);
|
program_.AddConstructedType(type);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
||||||
if (func.errored)
|
if (func.errored)
|
||||||
errored = true;
|
errored = true;
|
||||||
if (func.matched) {
|
if (func.matched) {
|
||||||
module_.Functions().Add(func.value);
|
program_.Functions().Add(func.value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,8 +435,8 @@ Maybe<ast::Variable*> ParserImpl::global_variable_decl(
|
||||||
constructor = expr.value;
|
constructor = expr.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return create<ast::Variable>(decl->source, // source
|
return create<ast::Variable>(decl->source, // source
|
||||||
module_.RegisterSymbol(decl->name), // symbol
|
program_.RegisterSymbol(decl->name), // symbol
|
||||||
decl->storage_class, // storage_class
|
decl->storage_class, // storage_class
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
false, // is_const
|
false, // is_const
|
||||||
|
@ -463,8 +463,8 @@ Maybe<ast::Variable*> ParserImpl::global_constant_decl() {
|
||||||
if (init.errored)
|
if (init.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return create<ast::Variable>(decl->source, // source
|
return create<ast::Variable>(decl->source, // source
|
||||||
module_.RegisterSymbol(decl->name), // symbol
|
program_.RegisterSymbol(decl->name), // symbol
|
||||||
ast::StorageClass::kNone, // storage_class
|
ast::StorageClass::kNone, // storage_class
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
true, // is_const
|
true, // is_const
|
||||||
|
@ -514,7 +514,7 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<type::SampledTexture>(dim.value, subtype.value);
|
return program_.create<type::SampledTexture>(dim.value, subtype.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ms_dim = multisampled_texture_type();
|
auto ms_dim = multisampled_texture_type();
|
||||||
|
@ -525,8 +525,8 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<type::MultisampledTexture>(ms_dim.value,
|
return program_.create<type::MultisampledTexture>(ms_dim.value,
|
||||||
subtype.value);
|
subtype.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto storage = storage_texture_type();
|
auto storage = storage_texture_type();
|
||||||
|
@ -539,7 +539,7 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
if (format.errored)
|
if (format.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<type::StorageTexture>(storage.value, format.value);
|
return program_.create<type::StorageTexture>(storage.value, format.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
|
@ -553,9 +553,9 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
if (format.errored)
|
if (format.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<type::AccessControl>(
|
return program_.create<type::AccessControl>(
|
||||||
ac_storage->second,
|
ac_storage->second,
|
||||||
module_.create<type::StorageTexture>(ac_storage->first, format.value));
|
program_.create<type::StorageTexture>(ac_storage->first, format.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
@ -566,10 +566,11 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||||
// | SAMPLER_COMPARISON
|
// | SAMPLER_COMPARISON
|
||||||
Maybe<type::Type*> ParserImpl::sampler_type() {
|
Maybe<type::Type*> ParserImpl::sampler_type() {
|
||||||
if (match(Token::Type::kSampler))
|
if (match(Token::Type::kSampler))
|
||||||
return module_.create<type::Sampler>(type::SamplerKind::kSampler);
|
return program_.create<type::Sampler>(type::SamplerKind::kSampler);
|
||||||
|
|
||||||
if (match(Token::Type::kComparisonSampler))
|
if (match(Token::Type::kComparisonSampler))
|
||||||
return module_.create<type::Sampler>(type::SamplerKind::kComparisonSampler);
|
return program_.create<type::Sampler>(
|
||||||
|
type::SamplerKind::kComparisonSampler);
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
|
@ -714,16 +715,17 @@ ParserImpl::storage_texture_type_access_control() {
|
||||||
// | TEXTURE_DEPTH_CUBE_ARRAY
|
// | TEXTURE_DEPTH_CUBE_ARRAY
|
||||||
Maybe<type::Type*> ParserImpl::depth_texture_type() {
|
Maybe<type::Type*> ParserImpl::depth_texture_type() {
|
||||||
if (match(Token::Type::kTextureDepth2d))
|
if (match(Token::Type::kTextureDepth2d))
|
||||||
return module_.create<type::DepthTexture>(type::TextureDimension::k2d);
|
return program_.create<type::DepthTexture>(type::TextureDimension::k2d);
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepth2dArray))
|
if (match(Token::Type::kTextureDepth2dArray))
|
||||||
return module_.create<type::DepthTexture>(type::TextureDimension::k2dArray);
|
return program_.create<type::DepthTexture>(
|
||||||
|
type::TextureDimension::k2dArray);
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepthCube))
|
if (match(Token::Type::kTextureDepthCube))
|
||||||
return module_.create<type::DepthTexture>(type::TextureDimension::kCube);
|
return program_.create<type::DepthTexture>(type::TextureDimension::kCube);
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepthCubeArray))
|
if (match(Token::Type::kTextureDepthCubeArray))
|
||||||
return module_.create<type::DepthTexture>(
|
return program_.create<type::DepthTexture>(
|
||||||
type::TextureDimension::kCubeArray);
|
type::TextureDimension::kCubeArray);
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
@ -909,7 +911,7 @@ Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_variable_ident_decl(
|
||||||
for (auto* deco : access_decos) {
|
for (auto* deco : access_decos) {
|
||||||
// If we have an access control decoration then we take it and wrap our
|
// If we have an access control decoration then we take it and wrap our
|
||||||
// type up with that decoration
|
// type up with that decoration
|
||||||
ty = module_.create<type::AccessControl>(
|
ty = program_.create<type::AccessControl>(
|
||||||
deco->As<ast::AccessDecoration>()->value(), ty);
|
deco->As<ast::AccessDecoration>()->value(), ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,8 +973,8 @@ Maybe<type::Type*> ParserImpl::type_alias() {
|
||||||
if (!type.matched)
|
if (!type.matched)
|
||||||
return add_error(peek(), "invalid type alias");
|
return add_error(peek(), "invalid type alias");
|
||||||
|
|
||||||
auto* alias = module_.create<type::Alias>(module_.RegisterSymbol(name.value),
|
auto* alias = program_.create<type::Alias>(
|
||||||
type.value);
|
program_.RegisterSymbol(name.value), type.value);
|
||||||
register_constructed(name.value, alias);
|
register_constructed(name.value, alias);
|
||||||
|
|
||||||
return alias;
|
return alias;
|
||||||
|
@ -1030,16 +1032,16 @@ Maybe<type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kBool))
|
if (match(Token::Type::kBool))
|
||||||
return module_.create<type::Bool>();
|
return program_.create<type::Bool>();
|
||||||
|
|
||||||
if (match(Token::Type::kF32))
|
if (match(Token::Type::kF32))
|
||||||
return module_.create<type::F32>();
|
return program_.create<type::F32>();
|
||||||
|
|
||||||
if (match(Token::Type::kI32))
|
if (match(Token::Type::kI32))
|
||||||
return module_.create<type::I32>();
|
return program_.create<type::I32>();
|
||||||
|
|
||||||
if (match(Token::Type::kU32))
|
if (match(Token::Type::kU32))
|
||||||
return module_.create<type::U32>();
|
return program_.create<type::U32>();
|
||||||
|
|
||||||
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
|
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
|
||||||
next(); // Consume the peek
|
next(); // Consume the peek
|
||||||
|
@ -1097,7 +1099,7 @@ Expect<type::Type*> ParserImpl::expect_type_decl_pointer() {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<type::Pointer>(subtype.value, sc.value);
|
return program_.create<type::Pointer>(subtype.value, sc.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1114,7 +1116,7 @@ Expect<type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<type::Vector>(subtype.value, count);
|
return program_.create<type::Vector>(subtype.value, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect<type::Type*> ParserImpl::expect_type_decl_array(
|
Expect<type::Type*> ParserImpl::expect_type_decl_array(
|
||||||
|
@ -1158,7 +1160,7 @@ Expect<type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.create<type::Matrix>(subtype.value, rows, columns);
|
return program_.create<type::Matrix>(subtype.value, rows, columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
// storage_class
|
// storage_class
|
||||||
|
@ -1225,7 +1227,7 @@ Maybe<type::Struct*> ParserImpl::struct_decl(ast::DecorationList& decos) {
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return create<type::Struct>(
|
return create<type::Struct>(
|
||||||
module_.RegisterSymbol(name.value),
|
program_.RegisterSymbol(name.value),
|
||||||
create<ast::Struct>(source, std::move(body.value),
|
create<ast::Struct>(source, std::move(body.value),
|
||||||
std::move(struct_decos.value)));
|
std::move(struct_decos.value)));
|
||||||
}
|
}
|
||||||
|
@ -1280,7 +1282,7 @@ Expect<ast::StructMember*> ParserImpl::expect_struct_member(
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return create<ast::StructMember>(decl->source,
|
return create<ast::StructMember>(decl->source,
|
||||||
module_.RegisterSymbol(decl->name),
|
program_.RegisterSymbol(decl->name),
|
||||||
decl->type, std::move(member_decos.value));
|
decl->type, std::move(member_decos.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1317,7 +1319,7 @@ Maybe<ast::Function*> ParserImpl::function_decl(ast::DecorationList& decos) {
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return create<ast::Function>(
|
return create<ast::Function>(
|
||||||
header->source, module_.RegisterSymbol(header->name), header->params,
|
header->source, program_.RegisterSymbol(header->name), header->params,
|
||||||
header->return_type, body.value, func_decos.value);
|
header->return_type, body.value, func_decos.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1326,7 +1328,7 @@ Maybe<ast::Function*> ParserImpl::function_decl(ast::DecorationList& decos) {
|
||||||
// | VOID
|
// | VOID
|
||||||
Maybe<type::Type*> ParserImpl::function_type_decl() {
|
Maybe<type::Type*> ParserImpl::function_type_decl() {
|
||||||
if (match(Token::Type::kVoid))
|
if (match(Token::Type::kVoid))
|
||||||
return module_.create<type::Void>();
|
return program_.create<type::Void>();
|
||||||
|
|
||||||
return type_decl();
|
return type_decl();
|
||||||
}
|
}
|
||||||
|
@ -1386,8 +1388,8 @@ Expect<ast::VariableList> ParserImpl::expect_param_list() {
|
||||||
ast::VariableList ret;
|
ast::VariableList ret;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
auto* var =
|
auto* var =
|
||||||
create<ast::Variable>(decl->source, // source
|
create<ast::Variable>(decl->source, // source
|
||||||
module_.RegisterSymbol(decl->name), // symbol
|
program_.RegisterSymbol(decl->name), // symbol
|
||||||
ast::StorageClass::kNone, // storage_class
|
ast::StorageClass::kNone, // storage_class
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
true, // is_const
|
true, // is_const
|
||||||
|
@ -1657,8 +1659,8 @@ Maybe<ast::VariableDeclStatement*> ParserImpl::variable_stmt() {
|
||||||
return add_error(peek(), "missing constructor for const declaration");
|
return add_error(peek(), "missing constructor for const declaration");
|
||||||
|
|
||||||
auto* var =
|
auto* var =
|
||||||
create<ast::Variable>(decl->source, // source
|
create<ast::Variable>(decl->source, // source
|
||||||
module_.RegisterSymbol(decl->name), // symbol
|
program_.RegisterSymbol(decl->name), // symbol
|
||||||
ast::StorageClass::kNone, // storage_class
|
ast::StorageClass::kNone, // storage_class
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
true, // is_const
|
true, // is_const
|
||||||
|
@ -1686,8 +1688,8 @@ Maybe<ast::VariableDeclStatement*> ParserImpl::variable_stmt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* var =
|
auto* var =
|
||||||
create<ast::Variable>(decl->source, // source
|
create<ast::Variable>(decl->source, // source
|
||||||
module_.RegisterSymbol(decl->name), // symbol
|
program_.RegisterSymbol(decl->name), // symbol
|
||||||
decl->storage_class, // storage_class
|
decl->storage_class, // storage_class
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
false, // is_const
|
false, // is_const
|
||||||
|
@ -2089,7 +2091,7 @@ Maybe<ast::CallStatement*> ParserImpl::func_call_stmt() {
|
||||||
Source{},
|
Source{},
|
||||||
create<ast::CallExpression>(source,
|
create<ast::CallExpression>(source,
|
||||||
create<ast::IdentifierExpression>(
|
create<ast::IdentifierExpression>(
|
||||||
source, module_.RegisterSymbol(name)),
|
source, program_.RegisterSymbol(name)),
|
||||||
std::move(params)));
|
std::move(params)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2162,7 +2164,7 @@ Maybe<ast::Expression*> ParserImpl::primary_expression() {
|
||||||
|
|
||||||
if (match(Token::Type::kIdentifier))
|
if (match(Token::Type::kIdentifier))
|
||||||
return create<ast::IdentifierExpression>(
|
return create<ast::IdentifierExpression>(
|
||||||
t.source(), module_.RegisterSymbol(t.to_str()));
|
t.source(), program_.RegisterSymbol(t.to_str()));
|
||||||
|
|
||||||
auto type = type_decl();
|
auto type = type_decl();
|
||||||
if (type.errored)
|
if (type.errored)
|
||||||
|
@ -2238,7 +2240,7 @@ Maybe<ast::Expression*> ParserImpl::postfix_expr(ast::Expression* prefix) {
|
||||||
return postfix_expr(create<ast::MemberAccessorExpression>(
|
return postfix_expr(create<ast::MemberAccessorExpression>(
|
||||||
ident.source, prefix,
|
ident.source, prefix,
|
||||||
create<ast::IdentifierExpression>(
|
create<ast::IdentifierExpression>(
|
||||||
ident.source, module_.RegisterSymbol(ident.value))));
|
ident.source, program_.RegisterSymbol(ident.value))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return prefix;
|
return prefix;
|
||||||
|
@ -2738,19 +2740,19 @@ Maybe<ast::AssignmentStatement*> ParserImpl::assignment_stmt() {
|
||||||
Maybe<ast::Literal*> ParserImpl::const_literal() {
|
Maybe<ast::Literal*> ParserImpl::const_literal() {
|
||||||
auto t = peek();
|
auto t = peek();
|
||||||
if (match(Token::Type::kTrue)) {
|
if (match(Token::Type::kTrue)) {
|
||||||
auto* type = module_.create<type::Bool>();
|
auto* type = program_.create<type::Bool>();
|
||||||
return create<ast::BoolLiteral>(Source{}, type, true);
|
return create<ast::BoolLiteral>(Source{}, type, true);
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kFalse)) {
|
if (match(Token::Type::kFalse)) {
|
||||||
auto* type = module_.create<type::Bool>();
|
auto* type = program_.create<type::Bool>();
|
||||||
return create<ast::BoolLiteral>(Source{}, type, false);
|
return create<ast::BoolLiteral>(Source{}, type, false);
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kSintLiteral)) {
|
if (match(Token::Type::kSintLiteral)) {
|
||||||
auto* type = module_.create<type::I32>();
|
auto* type = program_.create<type::I32>();
|
||||||
return create<ast::SintLiteral>(Source{}, type, t.to_i32());
|
return create<ast::SintLiteral>(Source{}, type, t.to_i32());
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kUintLiteral)) {
|
if (match(Token::Type::kUintLiteral)) {
|
||||||
auto* type = module_.create<type::U32>();
|
auto* type = program_.create<type::U32>();
|
||||||
return create<ast::UintLiteral>(Source{}, type, t.to_u32());
|
return create<ast::UintLiteral>(Source{}, type, t.to_u32());
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kFloatLiteral)) {
|
if (match(Token::Type::kFloatLiteral)) {
|
||||||
|
@ -2759,7 +2761,7 @@ Maybe<ast::Literal*> ParserImpl::const_literal() {
|
||||||
next(); // Consume 'f'
|
next(); // Consume 'f'
|
||||||
add_error(p.source(), "float literals must not be suffixed with 'f'");
|
add_error(p.source(), "float literals must not be suffixed with 'f'");
|
||||||
}
|
}
|
||||||
auto* type = module_.create<type::F32>();
|
auto* type = program_.create<type::F32>();
|
||||||
return create<ast::FloatLiteral>(Source{}, type, t.to_f32());
|
return create<ast::FloatLiteral>(Source{}, type, t.to_f32());
|
||||||
}
|
}
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include "src/ast/if_statement.h"
|
#include "src/ast/if_statement.h"
|
||||||
#include "src/ast/literal.h"
|
#include "src/ast/literal.h"
|
||||||
#include "src/ast/loop_statement.h"
|
#include "src/ast/loop_statement.h"
|
||||||
#include "src/ast/module.h"
|
|
||||||
#include "src/ast/pipeline_stage.h"
|
#include "src/ast/pipeline_stage.h"
|
||||||
#include "src/ast/return_statement.h"
|
#include "src/ast/return_statement.h"
|
||||||
#include "src/ast/statement.h"
|
#include "src/ast/statement.h"
|
||||||
|
@ -53,6 +52,7 @@
|
||||||
#include "src/ast/variable_decoration.h"
|
#include "src/ast/variable_decoration.h"
|
||||||
#include "src/diagnostic/diagnostic.h"
|
#include "src/diagnostic/diagnostic.h"
|
||||||
#include "src/diagnostic/formatter.h"
|
#include "src/diagnostic/formatter.h"
|
||||||
|
#include "src/program.h"
|
||||||
#include "src/reader/wgsl/parser_impl_detail.h"
|
#include "src/reader/wgsl/parser_impl_detail.h"
|
||||||
#include "src/reader/wgsl/token.h"
|
#include "src/reader/wgsl/token.h"
|
||||||
#include "src/type/storage_texture_type.h"
|
#include "src/type/storage_texture_type.h"
|
||||||
|
@ -307,11 +307,11 @@ class ParserImpl {
|
||||||
/// @returns the diagnostic messages
|
/// @returns the diagnostic messages
|
||||||
diag::List& diagnostics() { return diags_; }
|
diag::List& diagnostics() { return diags_; }
|
||||||
|
|
||||||
/// @returns the module. The module in the parser will be reset after this.
|
/// @returns the program. The program in the parser will be reset after this.
|
||||||
ast::Module module() { return std::move(module_); }
|
Program program() { return std::move(program_); }
|
||||||
|
|
||||||
/// @returns a pointer to the module, without resetting it.
|
/// @returns a pointer to the module, without resetting it.
|
||||||
ast::Module& get_module() { return module_; }
|
Program& get_program() { return program_; }
|
||||||
|
|
||||||
/// @returns the next token
|
/// @returns the next token
|
||||||
Token next();
|
Token next();
|
||||||
|
@ -829,7 +829,7 @@ class ParserImpl {
|
||||||
/// @returns the node pointer
|
/// @returns the node pointer
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
T* create(ARGS&&... args) {
|
T* create(ARGS&&... args) {
|
||||||
return module_.create<T>(std::forward<ARGS>(args)...);
|
return program_.create<T>(std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
diag::List diags_;
|
diag::List diags_;
|
||||||
|
@ -839,7 +839,7 @@ class ParserImpl {
|
||||||
std::vector<Token::Type> sync_tokens_;
|
std::vector<Token::Type> sync_tokens_;
|
||||||
int silence_errors_ = 0;
|
int silence_errors_ = 0;
|
||||||
std::unordered_map<std::string, type::Type*> registered_constructs_;
|
std::unordered_map<std::string, type::Type*> registered_constructs_;
|
||||||
ast::Module module_;
|
Program program_;
|
||||||
size_t max_errors_ = 25;
|
size_t max_errors_ = 25;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue