mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Moved sem::ArrayCount to an inherited structure
This CL moves the ArrayCount from a variant to use inheritance. This will allow the sem to have different array count classes from the IR. The ArrayCounts, similar to types, are unique across the code base and are provided by the TypeManager. Bug: tint:1718 Change-Id: Ib9c7c9df881e7a34cc3def2ff29571f536d66244 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112441 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
71e6bcf1af
commit
4b1d79e292
@@ -109,11 +109,11 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const sem::Type*
|
||||
if (a->IsRuntimeSized()) {
|
||||
return ctx.dst->ty.array(el, nullptr, std::move(attrs));
|
||||
}
|
||||
if (auto* override = std::get_if<sem::NamedOverrideArrayCount>(&a->Count())) {
|
||||
if (auto* override = a->Count()->As<sem::NamedOverrideArrayCount>()) {
|
||||
auto* count = ctx.Clone(override->variable->Declaration());
|
||||
return ctx.dst->ty.array(el, count, std::move(attrs));
|
||||
}
|
||||
if (auto* override = std::get_if<sem::UnnamedOverrideArrayCount>(&a->Count())) {
|
||||
if (auto* override = a->Count()->As<sem::UnnamedOverrideArrayCount>()) {
|
||||
// If the array count is an unnamed (complex) override expression, then its not safe to
|
||||
// redeclare this type as we'd end up with two types that would not compare equal.
|
||||
// See crbug.com/tint/1764.
|
||||
|
||||
@@ -69,8 +69,8 @@ TEST_F(CreateASTTypeForTest, Vector) {
|
||||
|
||||
TEST_F(CreateASTTypeForTest, ArrayImplicitStride) {
|
||||
auto* arr = create([](ProgramBuilder& b) {
|
||||
return b.create<sem::Array>(b.create<sem::F32>(), sem::ConstantArrayCount{2u}, 4u, 4u, 32u,
|
||||
32u);
|
||||
return b.create<sem::Array>(b.create<sem::F32>(), b.create<sem::ConstantArrayCount>(2u), 4u,
|
||||
4u, 32u, 32u);
|
||||
});
|
||||
ASSERT_TRUE(arr->Is<ast::Array>());
|
||||
ASSERT_TRUE(arr->As<ast::Array>()->type->Is<ast::F32>());
|
||||
@@ -83,8 +83,8 @@ TEST_F(CreateASTTypeForTest, ArrayImplicitStride) {
|
||||
|
||||
TEST_F(CreateASTTypeForTest, ArrayNonImplicitStride) {
|
||||
auto* arr = create([](ProgramBuilder& b) {
|
||||
return b.create<sem::Array>(b.create<sem::F32>(), sem::ConstantArrayCount{2u}, 4u, 4u, 64u,
|
||||
32u);
|
||||
return b.create<sem::Array>(b.create<sem::F32>(), b.create<sem::ConstantArrayCount>(2u), 4u,
|
||||
4u, 64u, 32u);
|
||||
});
|
||||
ASSERT_TRUE(arr->Is<ast::Array>());
|
||||
ASSERT_TRUE(arr->As<ast::Array>()->type->Is<ast::F32>());
|
||||
|
||||
Reference in New Issue
Block a user