Move array to type/
This CL moves array to the type/ folder. Namespaces are updated as
needed. A FriendlyName method was added to ArrayCount so the sem::
ArrayCount entries do not need to be referenced inside type/.
Bug: tint:1718
Change-Id: I16a8f32b3fab1131b284a6981a5c386081138b08
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113427
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 29eb86e..02b36d5 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -23,12 +23,12 @@
#include <utility>
#include "src/tint/program_builder.h"
-#include "src/tint/sem/array.h"
#include "src/tint/sem/constant.h"
#include "src/tint/sem/member_accessor_expression.h"
#include "src/tint/sem/type_initializer.h"
#include "src/tint/type/abstract_float.h"
#include "src/tint/type/abstract_int.h"
+#include "src/tint/type/array.h"
#include "src/tint/type/bool.h"
#include "src/tint/type/f16.h"
#include "src/tint/type/f32.h"
@@ -486,7 +486,7 @@
auto* zero_el = ZeroValue(builder, m->ColumnType());
return builder.create<Splat>(type, zero_el, m->columns());
},
- [&](const sem::Array* a) -> const ImplConstant* {
+ [&](const type::Array* a) -> const ImplConstant* {
if (auto n = a->ConstantCount()) {
if (auto* zero_el = ZeroValue(builder, a->ElemType())) {
return builder.create<Splat>(type, zero_el, n.value());
@@ -547,7 +547,7 @@
}
return true;
},
- [&](const sem::Array* arr) {
+ [&](const type::Array* arr) {
if (auto count = arr->ConstantCount()) {
for (size_t i = 0; i < count; i++) {
if (!Equal(a->Index(i), b->Index(i))) {
diff --git a/src/tint/resolver/const_eval_construction_test.cc b/src/tint/resolver/const_eval_construction_test.cc
index 30aef8a..2c3bd9b 100644
--- a/src/tint/resolver/const_eval_construction_test.cc
+++ b/src/tint/resolver/const_eval_construction_test.cc
@@ -1318,7 +1318,7 @@
auto* sem = Sem().Get(expr);
ASSERT_NE(sem, nullptr);
- auto* arr = sem->Type()->As<sem::Array>();
+ auto* arr = sem->Type()->As<type::Array>();
ASSERT_NE(arr, nullptr);
EXPECT_TRUE(arr->ElemType()->Is<type::I32>());
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
@@ -1355,7 +1355,7 @@
auto* sem = Sem().Get(expr);
ASSERT_NE(sem, nullptr);
- auto* arr = sem->Type()->As<sem::Array>();
+ auto* arr = sem->Type()->As<type::Array>();
ASSERT_NE(arr, nullptr);
EXPECT_TRUE(arr->ElemType()->Is<type::F32>());
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
@@ -1392,7 +1392,7 @@
auto* sem = Sem().Get(expr);
ASSERT_NE(sem, nullptr);
- auto* arr = sem->Type()->As<sem::Array>();
+ auto* arr = sem->Type()->As<type::Array>();
ASSERT_NE(arr, nullptr);
EXPECT_TRUE(arr->ElemType()->Is<type::Vector>());
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
@@ -1443,7 +1443,7 @@
auto* sem = Sem().Get(expr);
ASSERT_NE(sem, nullptr);
- auto* arr = sem->Type()->As<sem::Array>();
+ auto* arr = sem->Type()->As<type::Array>();
ASSERT_NE(arr, nullptr);
EXPECT_TRUE(arr->ElemType()->Is<sem::Struct>());
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
@@ -1480,7 +1480,7 @@
auto* sem = Sem().Get(expr);
ASSERT_NE(sem, nullptr);
- auto* arr = sem->Type()->As<sem::Array>();
+ auto* arr = sem->Type()->As<type::Array>();
ASSERT_NE(arr, nullptr);
EXPECT_TRUE(arr->ElemType()->Is<type::I32>());
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
@@ -1517,7 +1517,7 @@
auto* sem = Sem().Get(expr);
ASSERT_NE(sem, nullptr);
- auto* arr = sem->Type()->As<sem::Array>();
+ auto* arr = sem->Type()->As<type::Array>();
ASSERT_NE(arr, nullptr);
EXPECT_TRUE(arr->ElemType()->Is<type::F32>());
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
@@ -1555,7 +1555,7 @@
auto* sem = Sem().Get(expr);
ASSERT_NE(sem, nullptr);
- auto* arr = sem->Type()->As<sem::Array>();
+ auto* arr = sem->Type()->As<type::Array>();
ASSERT_NE(arr, nullptr);
EXPECT_TRUE(arr->ElemType()->Is<type::Vector>());
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
@@ -1584,7 +1584,7 @@
auto* sem = Sem().Get(expr);
ASSERT_NE(sem, nullptr);
- auto* arr = sem->Type()->As<sem::Array>();
+ auto* arr = sem->Type()->As<type::Array>();
ASSERT_NE(arr, nullptr);
EXPECT_TRUE(arr->ElemType()->Is<sem::Struct>());
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
@@ -2087,14 +2087,14 @@
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AllEqual());
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AnyZero());
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AllZero());
- EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::Array>());
+ EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<type::Array>());
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As<i32>(), 1_i);
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As<u32>(), 2_i);
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AllEqual());
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AnyZero());
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AllZero());
- EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::Array>());
+ EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<type::Array>());
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As<i32>(), 1_f);
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As<u32>(), 2_f);
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As<f32>(), 3_f);
diff --git a/src/tint/resolver/inferred_type_test.cc b/src/tint/resolver/inferred_type_test.cc
index d7f5548..6406bea 100644
--- a/src/tint/resolver/inferred_type_test.cc
+++ b/src/tint/resolver/inferred_type_test.cc
@@ -135,7 +135,7 @@
TEST_F(ResolverInferredTypeTest, InferArray_Pass) {
auto* type = ty.array(ty.u32(), 10_u);
- auto* expected_type = create<sem::Array>(
+ auto* expected_type = create<type::Array>(
create<type::U32>(), create<type::ConstantArrayCount>(10u), 4u, 4u * 10u, 4u, 4u);
auto* ctor_expr = Construct(type);
diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc
index 99ea338..f6b87f3 100644
--- a/src/tint/resolver/intrinsic_table.cc
+++ b/src/tint/resolver/intrinsic_table.cc
@@ -522,7 +522,7 @@
return true;
}
- if (auto* a = ty->As<sem::Array>()) {
+ if (auto* a = ty->As<type::Array>()) {
if (a->Count()->Is<type::RuntimeArrayCount>()) {
T = a->ElemType();
return true;
@@ -531,8 +531,8 @@
return false;
}
-const sem::Array* build_array(MatchState& state, const type::Type* el) {
- return state.builder.create<sem::Array>(
+const type::Array* build_array(MatchState& state, const type::Type* el) {
+ return state.builder.create<type::Array>(
el,
/* count */ state.builder.create<type::RuntimeArrayCount>(),
/* align */ 0u,
diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc
index 6e12ed6c..4849c4c 100644
--- a/src/tint/resolver/intrinsic_table_test.cc
+++ b/src/tint/resolver/intrinsic_table_test.cc
@@ -253,7 +253,7 @@
TEST_F(IntrinsicTableTest, MatchArray) {
auto* arr =
- create<sem::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<type::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
auto* arr_ptr =
create<type::Pointer>(arr, ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr},
@@ -265,7 +265,7 @@
ASSERT_EQ(result.sem->Parameters().Length(), 1u);
auto* param_type = result.sem->Parameters()[0]->Type();
ASSERT_TRUE(param_type->Is<type::Pointer>());
- EXPECT_TRUE(param_type->As<type::Pointer>()->StoreType()->Is<sem::Array>());
+ EXPECT_TRUE(param_type->As<type::Pointer>()->StoreType()->Is<type::Array>());
}
TEST_F(IntrinsicTableTest, MismatchArray) {
@@ -958,7 +958,7 @@
TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
auto* arr =
- create<sem::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<type::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
auto* f32 = create<type::F32>();
auto result = table->Lookup(InitConvIntrinsic::kVec3, f32, utils::Vector{arr},
sem::EvaluationStage::kConstant, Source{{12, 34}});
diff --git a/src/tint/resolver/is_host_shareable_test.cc b/src/tint/resolver/is_host_shareable_test.cc
index 1344379..1bc38b4 100644
--- a/src/tint/resolver/is_host_shareable_test.cc
+++ b/src/tint/resolver/is_host_shareable_test.cc
@@ -106,14 +106,14 @@
}
TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) {
- auto* arr = create<sem::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
- 20u, 4u, 4u);
+ auto* arr = create<type::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
+ 20u, 4u, 4u);
EXPECT_TRUE(r()->IsHostShareable(arr));
}
TEST_F(ResolverIsHostShareable, ArrayUnsizedOfHostShareable) {
auto* arr =
- create<sem::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<type::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
EXPECT_TRUE(r()->IsHostShareable(arr));
}
diff --git a/src/tint/resolver/is_storeable_test.cc b/src/tint/resolver/is_storeable_test.cc
index 7ed4877..58c0871 100644
--- a/src/tint/resolver/is_storeable_test.cc
+++ b/src/tint/resolver/is_storeable_test.cc
@@ -89,14 +89,14 @@
}
TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) {
- auto* arr = create<sem::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
- 20u, 4u, 4u);
+ auto* arr = create<type::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
+ 20u, 4u, 4u);
EXPECT_TRUE(r()->IsStorable(arr));
}
TEST_F(ResolverIsStorableTest, ArrayUnsizedOfStorable) {
auto* arr =
- create<sem::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<type::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
EXPECT_TRUE(r()->IsStorable(arr));
}
diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc
index 8c63c1f..82f6bdd 100644
--- a/src/tint/resolver/materialize_test.cc
+++ b/src/tint/resolver/materialize_test.cc
@@ -117,7 +117,7 @@
}
}
},
- [&](const sem::Array* a) {
+ [&](const type::Array* a) {
auto count = a->ConstantCount();
ASSERT_NE(count, 0u);
for (uint32_t i = 0; i < count; i++) {
diff --git a/src/tint/resolver/override_test.cc b/src/tint/resolver/override_test.cc
index a97c92d..8d6b8e7 100644
--- a/src/tint/resolver/override_test.cc
+++ b/src/tint/resolver/override_test.cc
@@ -259,7 +259,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
{
- auto* r = Sem().TransitivelyReferencedOverrides(Sem().Get<sem::Array>(arr_ty->type));
+ auto* r = Sem().TransitivelyReferencedOverrides(Sem().Get<type::Array>(arr_ty->type));
ASSERT_NE(r, nullptr);
auto& refs = *r;
ASSERT_EQ(refs.Length(), 2u);
diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc
index 3033786..eb1b7a1 100644
--- a/src/tint/resolver/resolver.cc
+++ b/src/tint/resolver/resolver.cc
@@ -52,7 +52,6 @@
#include "src/tint/ast/while_statement.h"
#include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/resolver/uniformity.h"
-#include "src/tint/sem/array.h"
#include "src/tint/sem/break_if_statement.h"
#include "src/tint/sem/call.h"
#include "src/tint/sem/for_loop_statement.h"
@@ -72,6 +71,7 @@
#include "src/tint/sem/while_statement.h"
#include "src/tint/type/abstract_float.h"
#include "src/tint/type/abstract_int.h"
+#include "src/tint/type/array.h"
#include "src/tint/type/atomic.h"
#include "src/tint/type/depth_multisampled_texture.h"
#include "src/tint/type/depth_texture.h"
@@ -927,7 +927,7 @@
for (auto* var : transitively_referenced_overrides) {
builder_->Sem().AddTransitivelyReferencedOverride(sem, var);
}
- if (auto* arr = sem->Type()->UnwrapRef()->As<sem::Array>()) {
+ if (auto* arr = sem->Type()->UnwrapRef()->As<type::Array>()) {
auto* refs = builder_->Sem().TransitivelyReferencedOverrides(arr);
if (refs) {
for (auto* var : *refs) {
@@ -1742,9 +1742,9 @@
return target_ty ? target_ty : f32m(m->columns(), m->rows());
});
},
- [&](const sem::Array* a) -> const type::Type* {
+ [&](const type::Array* a) -> const type::Type* {
const type::Type* target_el_ty = nullptr;
- if (auto* target_arr_ty = As<sem::Array>(target_ty)) {
+ if (auto* target_arr_ty = As<type::Array>(target_ty)) {
target_el_ty = target_arr_ty->ElemType();
}
if (auto* el_ty = ConcreteType(a->ElemType(), target_el_ty, source)) {
@@ -1869,7 +1869,7 @@
auto* obj_ty = obj_raw_ty->UnwrapRef();
auto* ty = Switch(
obj_ty, //
- [&](const sem::Array* arr) { return arr->ElemType(); },
+ [&](const type::Array* arr) { return arr->ElemType(); },
[&](const type::Vector* vec) { return vec->type(); },
[&](const type::Matrix* mat) {
return builder_->create<type::Vector>(mat->type(), mat->rows());
@@ -2045,7 +2045,7 @@
[&](const type::F16*) { return ct_init_or_conv(InitConvIntrinsic::kF16, nullptr); },
[&](const type::F32*) { return ct_init_or_conv(InitConvIntrinsic::kF32, nullptr); },
[&](const type::Bool*) { return ct_init_or_conv(InitConvIntrinsic::kBool, nullptr); },
- [&](const sem::Array* arr) -> sem::Call* {
+ [&](const type::Array* arr) -> sem::Call* {
auto* call_target = array_inits_.GetOrCreate(
ArrayInitializerSig{{arr, args.Length(), args_stage}},
[&]() -> sem::TypeInitializer* {
@@ -2925,7 +2925,7 @@
return result;
}
-sem::Array* Resolver::Array(const ast::Array* arr) {
+type::Array* Resolver::Array(const ast::Array* arr) {
if (!arr->type) {
AddError("missing array element type", arr->source.End());
return nullptr;
@@ -3053,11 +3053,11 @@
return true;
}
-sem::Array* Resolver::Array(const Source& el_source,
- const Source& count_source,
- const type::Type* el_ty,
- const type::ArrayCount* el_count,
- uint32_t explicit_stride) {
+type::Array* Resolver::Array(const Source& el_source,
+ const Source& count_source,
+ const type::Type* el_ty,
+ const type::ArrayCount* el_count,
+ uint32_t explicit_stride) {
uint32_t el_align = el_ty->Align();
uint32_t el_size = el_ty->Size();
uint64_t implicit_stride = el_size ? utils::RoundUp<uint64_t>(el_align, el_size) : 0;
@@ -3076,9 +3076,9 @@
} else if (el_count->Is<type::RuntimeArrayCount>()) {
size = stride;
}
- auto* out = builder_->create<sem::Array>(el_ty, el_count, el_align, static_cast<uint32_t>(size),
- static_cast<uint32_t>(stride),
- static_cast<uint32_t>(implicit_stride));
+ auto* out = builder_->create<type::Array>(
+ el_ty, el_count, el_align, static_cast<uint32_t>(size), static_cast<uint32_t>(stride),
+ static_cast<uint32_t>(implicit_stride));
if (!validator_.Array(out, el_source)) {
return nullptr;
@@ -3642,7 +3642,7 @@
return true;
}
- if (auto* arr = ty->As<sem::Array>()) {
+ if (auto* arr = ty->As<type::Array>()) {
if (address_space != ast::AddressSpace::kStorage) {
if (arr->Count()->Is<type::RuntimeArrayCount>()) {
AddError("runtime-sized arrays can only be used in the <storage> address space",
diff --git a/src/tint/resolver/resolver.h b/src/tint/resolver/resolver.h
index fdc706c..869cb19 100644
--- a/src/tint/resolver/resolver.h
+++ b/src/tint/resolver/resolver.h
@@ -272,7 +272,7 @@
/// to the AST node.
/// @returns the semantic Array information, or nullptr if an error is raised.
/// @param arr the Array to get semantic information for
- sem::Array* Array(const ast::Array* arr);
+ type::Array* Array(const ast::Array* arr);
/// Resolves and validates the expression used as the count parameter of an array.
/// @param count_expr the expression used as the second template parameter to an array<>.
@@ -297,11 +297,11 @@
/// @param el_ty the Array element type
/// @param el_count the number of elements in the array.
/// @param explicit_stride the explicit byte stride of the array. Zero means implicit stride.
- sem::Array* Array(const Source& el_source,
- const Source& count_source,
- const type::Type* el_ty,
- const type::ArrayCount* el_count,
- uint32_t explicit_stride);
+ type::Array* Array(const Source& el_source,
+ const Source& count_source,
+ const type::Type* el_ty,
+ const type::ArrayCount* el_count,
+ uint32_t explicit_stride);
/// Builds and returns the semantic information for the alias `alias`.
/// This method does not mark the ast::Alias node, nor attach the generated
@@ -426,7 +426,7 @@
// ArrayInitializerSig represents a unique array initializer signature.
// It is a tuple of the array type, number of arguments provided and earliest evaluation stage.
using ArrayInitializerSig =
- utils::UnorderedKeyWrapper<std::tuple<const sem::Array*, size_t, sem::EvaluationStage>>;
+ utils::UnorderedKeyWrapper<std::tuple<const type::Array*, size_t, sem::EvaluationStage>>;
// StructInitializerSig represents a unique structure initializer signature.
// It is a tuple of the structure type, number of arguments provided and earliest evaluation
diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc
index bb67764..a598875 100644
--- a/src/tint/resolver/resolver_test.cc
+++ b/src/tint/resolver/resolver_test.cc
@@ -439,7 +439,7 @@
ASSERT_NE(TypeOf(a), nullptr);
auto* ref = TypeOf(a)->As<type::Reference>();
ASSERT_NE(ref, nullptr);
- auto* ary = ref->StoreType()->As<sem::Array>();
+ auto* ary = ref->StoreType()->As<type::Array>();
EXPECT_EQ(ary->Count(), create<type::ConstantArrayCount>(10u));
}
@@ -452,7 +452,7 @@
ASSERT_NE(TypeOf(a), nullptr);
auto* ref = TypeOf(a)->As<type::Reference>();
ASSERT_NE(ref, nullptr);
- auto* ary = ref->StoreType()->As<sem::Array>();
+ auto* ary = ref->StoreType()->As<type::Array>();
EXPECT_EQ(ary->Count(), create<type::ConstantArrayCount>(10u));
}
@@ -467,7 +467,7 @@
ASSERT_NE(TypeOf(a), nullptr);
auto* ref = TypeOf(a)->As<type::Reference>();
ASSERT_NE(ref, nullptr);
- auto* ary = ref->StoreType()->As<sem::Array>();
+ auto* ary = ref->StoreType()->As<type::Array>();
EXPECT_EQ(ary->Count(), create<type::ConstantArrayCount>(10u));
}
@@ -482,7 +482,7 @@
ASSERT_NE(TypeOf(a), nullptr);
auto* ref = TypeOf(a)->As<type::Reference>();
ASSERT_NE(ref, nullptr);
- auto* ary = ref->StoreType()->As<sem::Array>();
+ auto* ary = ref->StoreType()->As<type::Array>();
EXPECT_EQ(ary->Count(), create<type::ConstantArrayCount>(10u));
}
@@ -497,7 +497,7 @@
ASSERT_NE(TypeOf(a), nullptr);
auto* ref = TypeOf(a)->As<type::Reference>();
ASSERT_NE(ref, nullptr);
- auto* ary = ref->StoreType()->As<sem::Array>();
+ auto* ary = ref->StoreType()->As<type::Array>();
auto* sem_override = Sem().Get<sem::GlobalVariable>(override);
ASSERT_NE(sem_override, nullptr);
EXPECT_EQ(ary->Count(), create<sem::NamedOverrideArrayCount>(sem_override));
@@ -516,12 +516,12 @@
ASSERT_NE(TypeOf(a), nullptr);
auto* ref_a = TypeOf(a)->As<type::Reference>();
ASSERT_NE(ref_a, nullptr);
- auto* ary_a = ref_a->StoreType()->As<sem::Array>();
+ auto* ary_a = ref_a->StoreType()->As<type::Array>();
ASSERT_NE(TypeOf(b), nullptr);
auto* ref_b = TypeOf(b)->As<type::Reference>();
ASSERT_NE(ref_b, nullptr);
- auto* ary_b = ref_b->StoreType()->As<sem::Array>();
+ auto* ary_b = ref_b->StoreType()->As<type::Array>();
auto* sem_override = Sem().Get<sem::GlobalVariable>(override);
ASSERT_NE(sem_override, nullptr);
@@ -542,7 +542,7 @@
ASSERT_NE(TypeOf(a), nullptr);
auto* ref = TypeOf(a)->As<type::Reference>();
ASSERT_NE(ref, nullptr);
- auto* ary = ref->StoreType()->As<sem::Array>();
+ auto* ary = ref->StoreType()->As<type::Array>();
auto* sem_override = Sem().Get<sem::GlobalVariable>(override);
ASSERT_NE(sem_override, nullptr);
EXPECT_EQ(ary->Count(), create<sem::UnnamedOverrideArrayCount>(Sem().Get(cnt)));
@@ -563,12 +563,12 @@
ASSERT_NE(TypeOf(a), nullptr);
auto* ref_a = TypeOf(a)->As<type::Reference>();
ASSERT_NE(ref_a, nullptr);
- auto* ary_a = ref_a->StoreType()->As<sem::Array>();
+ auto* ary_a = ref_a->StoreType()->As<type::Array>();
ASSERT_NE(TypeOf(b), nullptr);
auto* ref_b = TypeOf(b)->As<type::Reference>();
ASSERT_NE(ref_b, nullptr);
- auto* ary_b = ref_b->StoreType()->As<sem::Array>();
+ auto* ary_b = ref_b->StoreType()->As<type::Array>();
auto* sem_override = Sem().Get<sem::GlobalVariable>(override);
ASSERT_NE(sem_override, nullptr);
diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h
index 8829a53..12d8fe3 100644
--- a/src/tint/resolver/resolver_test_helper.h
+++ b/src/tint/resolver/resolver_test_helper.h
@@ -667,7 +667,7 @@
} else {
count = b.create<type::ConstantArrayCount>(N);
}
- return b.create<sem::Array>(
+ return b.create<type::Array>(
/* element */ el,
/* count */ count,
/* align */ el->Align(),
diff --git a/src/tint/resolver/type_initializer_validation_test.cc b/src/tint/resolver/type_initializer_validation_test.cc
index f38823d..6f7d78b 100644
--- a/src/tint/resolver/type_initializer_validation_test.cc
+++ b/src/tint/resolver/type_initializer_validation_test.cc
@@ -494,7 +494,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
@@ -510,7 +510,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
@@ -529,7 +529,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
@@ -548,7 +548,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
@@ -567,7 +567,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
@@ -586,7 +586,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
@@ -605,7 +605,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
@@ -626,7 +626,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
@@ -648,7 +648,7 @@
auto* call = Sem().Get<sem::Call>(tc);
ASSERT_NE(call, nullptr);
- EXPECT_TRUE(call->Type()->Is<sem::Array>());
+ EXPECT_TRUE(call->Type()->Is<type::Array>());
auto* ctor = call->Target()->As<sem::TypeInitializer>();
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc
index 82586cc..9d21314 100644
--- a/src/tint/resolver/validator.cc
+++ b/src/tint/resolver/validator.cc
@@ -47,7 +47,6 @@
#include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/ast/vector.h"
#include "src/tint/ast/workgroup_attribute.h"
-#include "src/tint/sem/array.h"
#include "src/tint/sem/break_if_statement.h"
#include "src/tint/sem/call.h"
#include "src/tint/sem/for_loop_statement.h"
@@ -64,6 +63,7 @@
#include "src/tint/sem/variable.h"
#include "src/tint/sem/while_statement.h"
#include "src/tint/type/abstract_numeric.h"
+#include "src/tint/type/array.h"
#include "src/tint/type/atomic.h"
#include "src/tint/type/depth_multisampled_texture.h"
#include "src/tint/type/depth_texture.h"
@@ -183,7 +183,7 @@
// https://gpuweb.github.io/gpuweb/wgsl/#plain-types-section
bool Validator::IsPlain(const type::Type* type) const {
return type->is_scalar() ||
- type->IsAnyOf<type::Atomic, type::Vector, type::Matrix, sem::Array, sem::Struct>();
+ type->IsAnyOf<type::Atomic, type::Vector, type::Matrix, type::Array, sem::Struct>();
}
// https://gpuweb.github.io/gpuweb/wgsl/#fixed-footprint-types
@@ -193,7 +193,7 @@
[&](const type::Vector*) { return true; }, //
[&](const type::Matrix*) { return true; }, //
[&](const type::Atomic*) { return true; },
- [&](const sem::Array* arr) {
+ [&](const type::Array* arr) {
return !arr->Count()->Is<type::RuntimeArrayCount>() &&
IsFixedFootprint(arr->ElemType());
},
@@ -217,7 +217,7 @@
type, //
[&](const type::Vector* vec) { return IsHostShareable(vec->type()); },
[&](const type::Matrix* mat) { return IsHostShareable(mat->type()); },
- [&](const sem::Array* arr) { return IsHostShareable(arr->ElemType()); },
+ [&](const type::Array* arr) { return IsHostShareable(arr->ElemType()); },
[&](const sem::Struct* str) {
for (auto* member : str->Members()) {
if (!IsHostShareable(member->Type())) {
@@ -398,7 +398,7 @@
auto is_uniform_struct_or_array = [address_space](const type::Type* ty) {
return address_space == ast::AddressSpace::kUniform &&
- ty->IsAnyOf<sem::Array, sem::Struct>();
+ ty->IsAnyOf<type::Array, sem::Struct>();
};
auto is_uniform_struct = [address_space](const type::Type* ty) {
@@ -504,7 +504,7 @@
}
// For uniform buffer array members, validate that array elements are aligned to 16 bytes
- if (auto* arr = store_ty->As<sem::Array>()) {
+ if (auto* arr = store_ty->As<type::Array>()) {
// Recurse into the element type.
// TODO(crbug.com/tint/1388): Ideally we'd pass the source for nested element type here, but
// we can't easily get that from the semantic node. We should consider recursing through the
@@ -1744,7 +1744,7 @@
}
bool Validator::ArrayInitializer(const ast::CallExpression* ctor,
- const sem::Array* array_type) const {
+ const type::Array* array_type) const {
auto& values = ctor->args;
auto* elem_ty = array_type->ElemType();
for (auto* value : values) {
@@ -1968,7 +1968,7 @@
return true;
}
-bool Validator::Array(const sem::Array* arr, const Source& el_source) const {
+bool Validator::Array(const type::Array* arr, const Source& el_source) const {
auto* el_ty = arr->ElemType();
if (!IsPlain(el_ty)) {
@@ -2021,7 +2021,7 @@
utils::Hashset<uint32_t, 8> locations;
for (auto* member : str->Members()) {
- if (auto* r = member->Type()->As<sem::Array>()) {
+ if (auto* r = member->Type()->As<type::Array>()) {
if (r->Count()->Is<type::RuntimeArrayCount>()) {
if (member != str->Members().Back()) {
AddError("runtime arrays may only appear as the last member of a struct",
@@ -2393,7 +2393,7 @@
}
bool Validator::IsArrayWithOverrideCount(const type::Type* ty) const {
- if (auto* arr = ty->UnwrapRef()->As<sem::Array>()) {
+ if (auto* arr = ty->UnwrapRef()->As<type::Array>()) {
if (arr->Count()->IsAnyOf<sem::NamedOverrideArrayCount, sem::UnnamedOverrideArrayCount>()) {
return true;
}
@@ -2474,7 +2474,7 @@
return true;
},
[&](const sem::Struct*) { return check_sub_atomics(); }, //
- [&](const sem::Array*) { return check_sub_atomics(); }, //
+ [&](const type::Array*) { return check_sub_atomics(); }, //
[&](Default) { return true; });
}
diff --git a/src/tint/resolver/validator.h b/src/tint/resolver/validator.h
index 1ecf573..0d6d343 100644
--- a/src/tint/resolver/validator.h
+++ b/src/tint/resolver/validator.h
@@ -154,7 +154,7 @@
/// @param el_source the source of the array element, or the array if the array does not have a
/// locally-declared element AST node.
/// @returns true on success, false otherwise.
- bool Array(const sem::Array* arr, const Source& el_source) const;
+ bool Array(const type::Array* arr, const Source& el_source) const;
/// Validates an array stride attribute
/// @param attr the stride attribute to validate
@@ -432,7 +432,7 @@
/// @param ctor the call expresion to validate
/// @param arr_type the type of the array
/// @returns true on success, false otherwise
- bool ArrayInitializer(const ast::CallExpression* ctor, const sem::Array* arr_type) const;
+ bool ArrayInitializer(const ast::CallExpression* ctor, const type::Array* arr_type) const;
/// Validates a texture builtin function
/// @param call the builtin call to validate
diff --git a/src/tint/resolver/validator_is_storeable_test.cc b/src/tint/resolver/validator_is_storeable_test.cc
index dccdcea..5bca58e 100644
--- a/src/tint/resolver/validator_is_storeable_test.cc
+++ b/src/tint/resolver/validator_is_storeable_test.cc
@@ -89,14 +89,14 @@
}
TEST_F(ValidatorIsStorableTest, ArraySizedOfStorable) {
- auto* arr = create<sem::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
- 20u, 4u, 4u);
+ auto* arr = create<type::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
+ 20u, 4u, 4u);
EXPECT_TRUE(v()->IsStorable(arr));
}
TEST_F(ValidatorIsStorableTest, ArrayUnsizedOfStorable) {
auto* arr =
- create<sem::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<type::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
EXPECT_TRUE(v()->IsStorable(arr));
}