Emit structs when emitting the aliases.
This Cl updates the AST dump command to emit struct members after emitting the type alias. Change-Id: I5e0c3d8f2cc56525586646c613839c2e014d471f Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27320 Commit-Queue: David Neto <dneto@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
df503f0e85
commit
43915bd0a1
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue