reader/spirv - add type hierarchy

Don't create disjoint AST type nodes.
Instead use a new bespoke type hierarchy that can Build() the required
AST nodes.

Change-Id: I523f97054de2c553095056c0bafc17c48064cf53
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49966
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2021-05-10 17:25:21 +00:00
committed by Commit Bot service account
parent c705b6caac
commit cbbe576415
16 changed files with 1641 additions and 552 deletions

View File

@@ -617,26 +617,32 @@ class ProgramBuilder {
/// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array
/// @param stride the array stride
/// @param stride the array stride. 0 represents implicit stride
/// @return the tint AST type for a array of size `n` of type `T`
ast::Array* array(typ::Type subtype, uint32_t n, uint32_t stride) const {
subtype = MaybeCreateTypename(subtype);
return array(subtype, n,
{builder->create<ast::StrideDecoration>(stride)});
ast::DecorationList decos;
if (stride) {
decos.emplace_back(builder->create<ast::StrideDecoration>(stride));
}
return array(subtype, n, std::move(decos));
}
/// @param source the Source of the node
/// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array
/// @param stride the array stride
/// @param stride the array stride. 0 represents implicit stride
/// @return the tint AST type for a array of size `n` of type `T`
ast::Array* array(const Source& source,
typ::Type subtype,
uint32_t n,
uint32_t stride) const {
subtype = MaybeCreateTypename(subtype);
return array(source, subtype, n,
{builder->create<ast::StrideDecoration>(stride)});
ast::DecorationList decos;
if (stride) {
decos.emplace_back(builder->create<ast::StrideDecoration>(stride));
}
return array(source, subtype, n, std::move(decos));
}
/// @return the tint AST type for an array of size `N` of type `T`