mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Move atomic to type/
This CL moves atomic to type/ and updates the namespaces. Bug: tint:1718 Change-Id: I3331bc0dfae2ccede52b5589b7d3cc443366096a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113424 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
Dan Sinclair
parent
0e780da882
commit
d8a084585f
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "src/tint/resolver/resolver.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/type/atomic.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
@@ -31,7 +31,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) {
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
ASSERT_TRUE(TypeOf(g)->Is<type::Reference>());
|
||||
auto* atomic = TypeOf(g)->UnwrapRef()->As<sem::Atomic>();
|
||||
auto* atomic = TypeOf(g)->UnwrapRef()->As<type::Atomic>();
|
||||
ASSERT_NE(atomic, nullptr);
|
||||
EXPECT_TRUE(atomic->Type()->Is<type::I32>());
|
||||
}
|
||||
@@ -41,7 +41,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
ASSERT_TRUE(TypeOf(g)->Is<type::Reference>());
|
||||
auto* atomic = TypeOf(g)->UnwrapRef()->As<sem::Atomic>();
|
||||
auto* atomic = TypeOf(g)->UnwrapRef()->As<type::Atomic>();
|
||||
ASSERT_NE(atomic, nullptr);
|
||||
EXPECT_TRUE(atomic->Type()->Is<type::U32>());
|
||||
}
|
||||
@@ -56,7 +56,7 @@ TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
|
||||
auto* str = TypeOf(g)->UnwrapRef()->As<sem::Struct>();
|
||||
ASSERT_NE(str, nullptr);
|
||||
ASSERT_EQ(str->Members().Length(), 1u);
|
||||
auto* atomic = str->Members()[0]->Type()->As<sem::Atomic>();
|
||||
auto* atomic = str->Members()[0]->Type()->As<type::Atomic>();
|
||||
ASSERT_NE(atomic, nullptr);
|
||||
ASSERT_TRUE(atomic->Type()->Is<type::I32>());
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "src/tint/resolver/resolver.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/type/atomic.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "src/tint/ast/binary_expression.h"
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/sem/evaluation_stage.h"
|
||||
#include "src/tint/sem/pipeline_stage_set.h"
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
@@ -28,6 +27,7 @@
|
||||
#include "src/tint/type/abstract_float.h"
|
||||
#include "src/tint/type/abstract_int.h"
|
||||
#include "src/tint/type/abstract_numeric.h"
|
||||
#include "src/tint/type/atomic.h"
|
||||
#include "src/tint/type/depth_multisampled_texture.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/external_texture.h"
|
||||
@@ -569,15 +569,15 @@ bool match_atomic(MatchState&, const type::Type* ty, const type::Type*& T) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (auto* a = ty->As<sem::Atomic>()) {
|
||||
if (auto* a = ty->As<type::Atomic>()) {
|
||||
T = a->Type();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const sem::Atomic* build_atomic(MatchState& state, const type::Type* T) {
|
||||
return state.builder.create<sem::Atomic>(T);
|
||||
const type::Atomic* build_atomic(MatchState& state, const type::Type* T) {
|
||||
return state.builder.create<type::Atomic>(T);
|
||||
}
|
||||
|
||||
bool match_sampler(MatchState&, const type::Type* ty) {
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/type/atomic.h"
|
||||
#include "src/tint/type/depth_multisampled_texture.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/external_texture.h"
|
||||
@@ -229,7 +229,7 @@ TEST_F(IntrinsicTableTest, MismatchBool) {
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchPointer) {
|
||||
auto* i32 = create<type::I32>();
|
||||
auto* atomicI32 = create<sem::Atomic>(i32);
|
||||
auto* atomicI32 = create<type::Atomic>(i32);
|
||||
auto* ptr =
|
||||
create<type::Pointer>(atomicI32, ast::AddressSpace::kWorkgroup, ast::Access::kReadWrite);
|
||||
auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{ptr},
|
||||
@@ -244,7 +244,7 @@ TEST_F(IntrinsicTableTest, MatchPointer) {
|
||||
|
||||
TEST_F(IntrinsicTableTest, MismatchPointer) {
|
||||
auto* i32 = create<type::I32>();
|
||||
auto* atomicI32 = create<sem::Atomic>(i32);
|
||||
auto* atomicI32 = create<type::Atomic>(i32);
|
||||
auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{atomicI32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_EQ(result.sem, nullptr);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/type/atomic.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
@@ -101,8 +101,8 @@ TEST_F(ResolverIsHostShareable, Pointer) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, Atomic) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Atomic>(create<type::I32>())));
|
||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Atomic>(create<type::U32>())));
|
||||
EXPECT_TRUE(r()->IsHostShareable(create<type::Atomic>(create<type::I32>())));
|
||||
EXPECT_TRUE(r()->IsHostShareable(create<type::Atomic>(create<type::U32>())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/type/atomic.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
@@ -84,8 +84,8 @@ TEST_F(ResolverIsStorableTest, Pointer) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsStorableTest, Atomic) {
|
||||
EXPECT_TRUE(r()->IsStorable(create<sem::Atomic>(create<type::I32>())));
|
||||
EXPECT_TRUE(r()->IsStorable(create<sem::Atomic>(create<type::U32>())));
|
||||
EXPECT_TRUE(r()->IsStorable(create<type::Atomic>(create<type::I32>())));
|
||||
EXPECT_TRUE(r()->IsStorable(create<type::Atomic>(create<type::U32>())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) {
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#include "src/tint/ast/workgroup_attribute.h"
|
||||
#include "src/tint/resolver/uniformity.h"
|
||||
#include "src/tint/sem/array.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/sem/break_if_statement.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/for_loop_statement.h"
|
||||
@@ -73,6 +72,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/atomic.h"
|
||||
#include "src/tint/type/depth_multisampled_texture.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
@@ -247,9 +247,9 @@ type::Type* Resolver::Type(const ast::Type* ty) {
|
||||
return nullptr;
|
||||
},
|
||||
[&](const ast::Array* t) { return Array(t); },
|
||||
[&](const ast::Atomic* t) -> sem::Atomic* {
|
||||
[&](const ast::Atomic* t) -> type::Atomic* {
|
||||
if (auto* el = Type(t->type)) {
|
||||
auto* a = builder_->create<sem::Atomic>(el);
|
||||
auto* a = builder_->create<type::Atomic>(el);
|
||||
if (!validator_.Atomic(t, a)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -2964,7 +2964,7 @@ sem::Array* Resolver::Array(const ast::Array* arr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (el_ty->Is<sem::Atomic>()) {
|
||||
if (el_ty->Is<type::Atomic>()) {
|
||||
atomic_composite_info_.Add(out, &arr->type->source);
|
||||
} else {
|
||||
if (auto found = atomic_composite_info_.Get(el_ty)) {
|
||||
@@ -3309,7 +3309,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) {
|
||||
|
||||
for (size_t i = 0; i < sem_members.Length(); i++) {
|
||||
auto* mem_type = sem_members[i]->Type();
|
||||
if (mem_type->Is<sem::Atomic>()) {
|
||||
if (mem_type->Is<type::Atomic>()) {
|
||||
atomic_composite_info_.Add(out, &sem_members[i]->Source());
|
||||
break;
|
||||
} else {
|
||||
|
||||
@@ -59,7 +59,6 @@ class WhileStatement;
|
||||
} // namespace tint::ast
|
||||
namespace tint::sem {
|
||||
class Array;
|
||||
class Atomic;
|
||||
class BlockStatement;
|
||||
class Builtin;
|
||||
class CaseStatement;
|
||||
@@ -72,6 +71,9 @@ class SwitchStatement;
|
||||
class TypeInitializer;
|
||||
class WhileStatement;
|
||||
} // namespace tint::sem
|
||||
namespace tint::type {
|
||||
class Atomic;
|
||||
} // namespace tint::type
|
||||
|
||||
namespace tint::resolver {
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "src/tint/ast/vector.h"
|
||||
#include "src/tint/ast/workgroup_attribute.h"
|
||||
#include "src/tint/sem/array.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/sem/break_if_statement.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/for_loop_statement.h"
|
||||
@@ -65,6 +64,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/atomic.h"
|
||||
#include "src/tint/type/depth_multisampled_texture.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
@@ -183,7 +183,7 @@ void Validator::AddNote(const std::string& msg, const Source& source) const {
|
||||
// https://gpuweb.github.io/gpuweb/wgsl/#plain-types-section
|
||||
bool Validator::IsPlain(const type::Type* type) const {
|
||||
return type->is_scalar() ||
|
||||
type->IsAnyOf<sem::Atomic, type::Vector, type::Matrix, sem::Array, sem::Struct>();
|
||||
type->IsAnyOf<type::Atomic, type::Vector, type::Matrix, sem::Array, sem::Struct>();
|
||||
}
|
||||
|
||||
// https://gpuweb.github.io/gpuweb/wgsl/#fixed-footprint-types
|
||||
@@ -192,7 +192,7 @@ bool Validator::IsFixedFootprint(const type::Type* type) const {
|
||||
type, //
|
||||
[&](const type::Vector*) { return true; }, //
|
||||
[&](const type::Matrix*) { return true; }, //
|
||||
[&](const sem::Atomic*) { return true; },
|
||||
[&](const type::Atomic*) { return true; },
|
||||
[&](const sem::Array* arr) {
|
||||
return !arr->Count()->Is<type::RuntimeArrayCount>() &&
|
||||
IsFixedFootprint(arr->ElemType());
|
||||
@@ -226,7 +226,7 @@ bool Validator::IsHostShareable(const type::Type* type) const {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
[&](const sem::Atomic* atomic) { return IsHostShareable(atomic->Type()); });
|
||||
[&](const type::Atomic* atomic) { return IsHostShareable(atomic->Type()); });
|
||||
}
|
||||
|
||||
// https://gpuweb.github.io/gpuweb/wgsl.html#storable-types
|
||||
@@ -260,7 +260,7 @@ const ast::Statement* Validator::ClosestContinuing(bool stop_at_loop,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Validator::Atomic(const ast::Atomic* a, const sem::Atomic* s) const {
|
||||
bool Validator::Atomic(const ast::Atomic* a, const type::Atomic* s) const {
|
||||
// https://gpuweb.github.io/gpuweb/wgsl/#atomic-types
|
||||
// T must be either u32 or i32.
|
||||
if (!s->Type()->IsAnyOf<type::U32, type::I32>()) {
|
||||
@@ -2466,7 +2466,7 @@ bool Validator::CheckTypeAccessAddressSpace(
|
||||
|
||||
return Switch(
|
||||
store_ty, //
|
||||
[&](const sem::Atomic*) {
|
||||
[&](const type::Atomic*) {
|
||||
if (auto* err = atomic_error()) {
|
||||
AddError(err, source);
|
||||
return false;
|
||||
|
||||
@@ -49,7 +49,6 @@ class WhileStatement;
|
||||
} // namespace tint::ast
|
||||
namespace tint::sem {
|
||||
class Array;
|
||||
class Atomic;
|
||||
class BlockStatement;
|
||||
class BreakIfStatement;
|
||||
class Builtin;
|
||||
@@ -64,6 +63,9 @@ class SwitchStatement;
|
||||
class TypeInitializer;
|
||||
class WhileStatement;
|
||||
} // namespace tint::sem
|
||||
namespace tint::type {
|
||||
class Atomic;
|
||||
} // namespace tint::type
|
||||
|
||||
namespace tint::resolver {
|
||||
|
||||
@@ -167,7 +169,7 @@ class Validator {
|
||||
/// @param a the atomic ast node
|
||||
/// @param s the atomic sem node
|
||||
/// @returns true on success, false otherwise.
|
||||
bool Atomic(const ast::Atomic* a, const sem::Atomic* s) const;
|
||||
bool Atomic(const ast::Atomic* a, const type::Atomic* s) const;
|
||||
|
||||
/// Validates a pointer type
|
||||
/// @param a the pointer ast node
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/type/atomic.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
@@ -84,8 +84,8 @@ TEST_F(ValidatorIsStorableTest, Pointer) {
|
||||
}
|
||||
|
||||
TEST_F(ValidatorIsStorableTest, Atomic) {
|
||||
EXPECT_TRUE(v()->IsStorable(create<sem::Atomic>(create<type::I32>())));
|
||||
EXPECT_TRUE(v()->IsStorable(create<sem::Atomic>(create<type::U32>())));
|
||||
EXPECT_TRUE(v()->IsStorable(create<type::Atomic>(create<type::I32>())));
|
||||
EXPECT_TRUE(v()->IsStorable(create<type::Atomic>(create<type::U32>())));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorIsStorableTest, ArraySizedOfStorable) {
|
||||
|
||||
Reference in New Issue
Block a user