diff --git a/src/ast/module.cc b/src/ast/module.cc index 74a081cce7..ffb4132430 100644 --- a/src/ast/module.cc +++ b/src/ast/module.cc @@ -16,6 +16,8 @@ #include +#include "src/ast/type/struct_type.h" + namespace tint { namespace ast { @@ -95,7 +97,13 @@ std::string Module::to_str() const { ep->to_str(out, indent); } for (auto* const alias : alias_types_) { + for (size_t i = 0; i < indent; ++i) { + out << " "; + } out << alias->name() << " -> " << alias->type()->type_name() << std::endl; + if (alias->type()->IsStruct()) { + alias->type()->AsStruct()->impl()->to_str(out, indent); + } } for (const auto& func : functions_) { func->to_str(out, indent); diff --git a/src/reader/spirv/function_memory_test.cc b/src/reader/spirv/function_memory_test.cc index f7c3f4e4cf..149b304c66 100644 --- a/src/reader/spirv/function_memory_test.cc +++ b/src/reader/spirv/function_memory_test.cc @@ -748,8 +748,12 @@ TEST_F(SpvParserTest, RemapStorageBuffer_TypesAndVarDeclarations) { storage_buffer __alias_S__struct_S } -RTArr -> __array__u32_stride_4 -S -> __struct_S)")); + RTArr -> __array__u32_stride_4 + S -> __struct_S + [[block]] Struct{ + StructMember{[[ offset 0 ]] field0: __u32} + StructMember{[[ offset 4 ]] field1: __alias_RTArr__array__u32_stride_4} + })")); } TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_NonCascaded) { diff --git a/src/reader/spirv/parser_impl_module_var_test.cc b/src/reader/spirv/parser_impl_module_var_test.cc index 3839f42e75..139358eaa0 100644 --- a/src/reader/spirv/parser_impl_module_var_test.cc +++ b/src/reader/spirv/parser_impl_module_var_test.cc @@ -1310,7 +1310,12 @@ TEST_F(SpvParserTest, ModuleScopeVar_NonReadableDecoration_DroppedForNow) { storage_buffer __alias_S__struct_S } -S -> __struct_S + S -> __struct_S + [[block]] Struct{ + StructMember{field0: __u32} + StructMember{field1: __f32} + StructMember{field2: __array__u32_2} + } })")) << module_str; } @@ -1332,7 +1337,12 @@ TEST_F(SpvParserTest, ModuleScopeVar_NonWritableDecoration_DroppedForNow) { storage_buffer __alias_S__struct_S } -S -> __struct_S + S -> __struct_S + [[block]] Struct{ + StructMember{field0: __u32} + StructMember{field1: __f32} + StructMember{field2: __array__u32_2} + } })")) << module_str; } @@ -1358,7 +1368,10 @@ TEST_F(SpvParserTest, ModuleScopeVar_ColMajorDecoration_Dropped) { storage_buffer __alias_S__struct_S } -S -> __struct_S + S -> __struct_S + [[block]] Struct{ + StructMember{field0: __mat_2_3__f32} + } })")) << module_str; } @@ -1384,7 +1397,10 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixStrideDecoration_Dropped) { storage_buffer __alias_S__struct_S } -S -> __struct_S + S -> __struct_S + [[block]] Struct{ + StructMember{field0: __mat_2_3__f32} + } })")) << module_str; } diff --git a/src/reader/spirv/parser_impl_named_types_test.cc b/src/reader/spirv/parser_impl_named_types_test.cc index 4d5939abbe..a942e1a591 100644 --- a/src/reader/spirv/parser_impl_named_types_test.cc +++ b/src/reader/spirv/parser_impl_named_types_test.cc @@ -60,8 +60,16 @@ TEST_F(SpvParserTest, NamedTypes_Dup_EmitBoth) { %s2 = OpTypeStruct %uint %uint )")); EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error(); - EXPECT_THAT(p->module().to_str(), - HasSubstr("S -> __struct_S\nS_1 -> __struct_S_1")); + EXPECT_THAT(p->module().to_str(), HasSubstr(R"(S -> __struct_S + Struct{ + StructMember{field0: __u32} + StructMember{field1: __u32} + } + S_1 -> __struct_S_1 + Struct{ + StructMember{field0: __u32} + StructMember{field1: __u32} + })")); } // TODO(dneto): Should we make an alias for an un-decoratrd array with @@ -89,7 +97,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArray_Dup_EmitBoth) { )")); EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_THAT(p->module().to_str(), - HasSubstr("RTArr -> __array__u32_stride_8\nRTArr_1 -> " + HasSubstr("RTArr -> __array__u32_stride_8\n RTArr_1 -> " "__array__u32_stride_8\n")); } @@ -129,10 +137,9 @@ TEST_F(SpvParserTest, NamedTypes_AnonArray_Dup_EmitBoth) { %arr2 = OpTypeArray %uint %uint_5 )")); EXPECT_TRUE(p->BuildAndParseInternalModule()); - EXPECT_THAT( - p->module().to_str(), - HasSubstr( - "Arr -> __array__u32_5_stride_8\nArr_1 -> __array__u32_5_stride_")); + EXPECT_THAT(p->module().to_str(), + HasSubstr("Arr -> __array__u32_5_stride_8\n Arr_1 -> " + "__array__u32_5_stride_8")); } // TODO(dneto): Handle arrays sized by a spec constant.