sem: Fold together sem::Array and sem::ArrayType

There's now no need to have both.
Removes a whole bunch of Sem().Get() smell, and simplifies the resolver.

Also fixes a long-standing issue where an array with an explicit, but equal-to-implicit-stride attribute would result in a different type to an array without the decoration.

Bug: tint:724
Fixed: tint:782
Change-Id: I0202459009cd45be427cdb621993a5a3b07ff51e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50301
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2021-05-07 20:58:34 +00:00
committed by Commit Bot service account
parent 6732e8561c
commit 4cd5eea87e
62 changed files with 486 additions and 591 deletions

View File

@@ -61,7 +61,7 @@
#include "src/program_id.h"
#include "src/sem/access_control_type.h"
#include "src/sem/alias_type.h"
#include "src/sem/array_type.h"
#include "src/sem/array.h"
#include "src/sem/bool_type.h"
#include "src/sem/depth_texture_type.h"
#include "src/sem/external_texture_type.h"
@@ -595,15 +595,11 @@ class ProgramBuilder {
/// @param n the array size. 0 represents a runtime-array
/// @param decos the optional decorations for the array
/// @return the tint AST type for a array of size `n` of type `T`
typ::Array array(typ::Type subtype,
uint32_t n = 0,
ast::DecorationList decos = {}) const {
ast::Array* array(typ::Type subtype,
uint32_t n = 0,
ast::DecorationList decos = {}) const {
subtype = MaybeCreateTypename(subtype);
return {subtype.ast ? builder->create<ast::Array>(subtype, n, decos)
: nullptr,
subtype.sem ? builder->create<sem::ArrayType>(subtype, n,
std::move(decos))
: nullptr};
return builder->create<ast::Array>(subtype, n, decos);
}
/// @param source the Source of the node
@@ -611,24 +607,19 @@ class ProgramBuilder {
/// @param n the array size. 0 represents a runtime-array
/// @param decos the optional decorations for the array
/// @return the tint AST type for a array of size `n` of type `T`
typ::Array array(const Source& source,
typ::Type subtype,
uint32_t n = 0,
ast::DecorationList decos = {}) const {
ast::Array* array(const Source& source,
typ::Type subtype,
uint32_t n = 0,
ast::DecorationList decos = {}) const {
subtype = MaybeCreateTypename(subtype);
return {
subtype.ast ? builder->create<ast::Array>(source, subtype, n, decos)
: nullptr,
subtype.sem
? builder->create<sem::ArrayType>(subtype, n, std::move(decos))
: nullptr};
return builder->create<ast::Array>(source, subtype, n, decos);
}
/// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array
/// @param stride the array stride
/// @return the tint AST type for a array of size `n` of type `T`
typ::Array array(typ::Type subtype, uint32_t n, uint32_t stride) const {
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)});
@@ -639,10 +630,10 @@ class ProgramBuilder {
/// @param n the array size. 0 represents a runtime-array
/// @param stride the array stride
/// @return the tint AST type for a array of size `n` of type `T`
typ::Array array(const Source& source,
typ::Type subtype,
uint32_t n,
uint32_t stride) const {
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)});
@@ -650,14 +641,14 @@ class ProgramBuilder {
/// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0>
typ::Array array() const {
ast::Array* array() const {
return array(Of<T>(), N);
}
/// @param stride the array stride
/// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0>
typ::Array array(uint32_t stride) const {
ast::Array* array(uint32_t stride) const {
return array(Of<T>(), N, stride);
}