Move abstract types to type folder.
This CL moves the abstract files from sem to type and updates namespaces
as needed.
Bug: tint:1718
Change-Id: I5f0be7e820fc66ea72c1ebe612a6d28034e88be6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113341
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn
index 7c29387..98d0c84 100644
--- a/src/tint/BUILD.gn
+++ b/src/tint/BUILD.gn
@@ -415,9 +415,6 @@
"resolver/validator.cc",
"resolver/validator.h",
"scope_stack.h",
- "sem/abstract_float.h",
- "sem/abstract_int.h",
- "sem/abstract_numeric.h",
"sem/array.h",
"sem/array_count.h",
"sem/atomic.h",
@@ -568,6 +565,9 @@
"transform/while_to_loop.h",
"transform/zero_init_workgroup_memory.cc",
"transform/zero_init_workgroup_memory.h",
+ "type/abstract_float.h",
+ "type/abstract_int.h",
+ "type/abstract_numeric.h",
"type/array_count.h",
"type/depth_multisampled_texture.h",
"type/depth_texture.h",
@@ -633,12 +633,6 @@
libtint_source_set("libtint_sem_src") {
sources = [
- "sem/abstract_float.cc",
- "sem/abstract_float.h",
- "sem/abstract_int.cc",
- "sem/abstract_int.h",
- "sem/abstract_numeric.cc",
- "sem/abstract_numeric.h",
"sem/array.cc",
"sem/array.h",
"sem/array_count.cc",
@@ -725,6 +719,12 @@
libtint_source_set("libtint_type_src") {
sources = [
+ "type/abstract_float.cc",
+ "type/abstract_float.h",
+ "type/abstract_int.cc",
+ "type/abstract_int.h",
+ "type/abstract_numeric.cc",
+ "type/abstract_numeric.h",
"type/array_count.cc",
"type/array_count.h",
"type/depth_multisampled_texture.cc",
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 6a38e9e..9decb99 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -291,12 +291,6 @@
resolver/validator.cc
resolver/validator.h
scope_stack.h
- sem/abstract_float.cc
- sem/abstract_float.h
- sem/abstract_int.cc
- sem/abstract_int.h
- sem/abstract_numeric.cc
- sem/abstract_numeric.h
sem/array.cc
sem/array.h
sem/array_count.cc
@@ -481,6 +475,12 @@
transform/while_to_loop.h
transform/zero_init_workgroup_memory.cc
transform/zero_init_workgroup_memory.h
+ type/abstract_float.cc
+ type/abstract_float.h
+ type/abstract_int.cc
+ type/abstract_int.h
+ type/abstract_numeric.cc
+ type/abstract_numeric.h
type/array_count.cc
type/array_count.h
type/depth_multisampled_texture.cc
diff --git a/src/tint/fuzzers/tint_ast_fuzzer/mutations/wrap_unary_operator.cc b/src/tint/fuzzers/tint_ast_fuzzer/mutations/wrap_unary_operator.cc
index 499a23f..3420e45 100644
--- a/src/tint/fuzzers/tint_ast_fuzzer/mutations/wrap_unary_operator.cc
+++ b/src/tint/fuzzers/tint_ast_fuzzer/mutations/wrap_unary_operator.cc
@@ -18,8 +18,8 @@
#include <vector>
#include "src/tint/program_builder.h"
-#include "src/tint/sem/abstract_float.h"
-#include "src/tint/sem/abstract_int.h"
+#include "src/tint/type/abstract_float.h"
+#include "src/tint/type/abstract_int.h"
namespace tint::fuzzers::ast_fuzzer {
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 14841fe..c94e898 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -23,8 +23,6 @@
#include <utility>
#include "src/tint/program_builder.h"
-#include "src/tint/sem/abstract_float.h"
-#include "src/tint/sem/abstract_int.h"
#include "src/tint/sem/array.h"
#include "src/tint/sem/bool.h"
#include "src/tint/sem/constant.h"
@@ -36,6 +34,8 @@
#include "src/tint/sem/type_initializer.h"
#include "src/tint/sem/u32.h"
#include "src/tint/sem/vector.h"
+#include "src/tint/type/abstract_float.h"
+#include "src/tint/type/abstract_int.h"
#include "src/tint/utils/bitcast.h"
#include "src/tint/utils/compiler_macros.h"
#include "src/tint/utils/map.h"
@@ -69,7 +69,7 @@
auto Dispatch_ia_iu32(F&& f, CONSTANTS&&... cs) {
return Switch(
First(cs...)->Type(), //
- [&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
+ [&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); });
}
@@ -80,7 +80,7 @@
auto Dispatch_ia_iu32_bool(F&& f, CONSTANTS&&... cs) {
return Switch(
First(cs...)->Type(), //
- [&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
+ [&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
[&](const sem::Bool*) { return f(cs->template As<bool>()...); });
@@ -92,8 +92,8 @@
auto Dispatch_fia_fi32_f16(F&& f, CONSTANTS&&... cs) {
return Switch(
First(cs...)->Type(), //
- [&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
- [&](const sem::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
+ [&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
+ [&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::F16*) { return f(cs->template As<f16>()...); });
@@ -105,8 +105,8 @@
auto Dispatch_fia_fiu32_f16(F&& f, CONSTANTS&&... cs) {
return Switch(
First(cs...)->Type(), //
- [&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
- [&](const sem::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
+ [&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
+ [&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
@@ -119,8 +119,8 @@
auto Dispatch_fia_fiu32_f16_bool(F&& f, CONSTANTS&&... cs) {
return Switch(
First(cs...)->Type(), //
- [&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
- [&](const sem::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
+ [&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
+ [&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
@@ -134,7 +134,7 @@
auto Dispatch_fa_f32_f16(F&& f, CONSTANTS&&... cs) {
return Switch(
First(cs...)->Type(), //
- [&](const sem::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
+ [&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
[&](const sem::F16*) { return f(cs->template As<f16>()...); });
}
@@ -156,13 +156,13 @@
template <typename F>
auto ZeroTypeDispatch(const type::Type* type, F&& f) {
return Switch(
- type, //
- [&](const sem::AbstractInt*) { return f(AInt(0)); }, //
- [&](const sem::AbstractFloat*) { return f(AFloat(0)); }, //
- [&](const sem::I32*) { return f(i32(0)); }, //
- [&](const sem::U32*) { return f(u32(0)); }, //
- [&](const sem::F32*) { return f(f32(0)); }, //
- [&](const sem::F16*) { return f(f16(0)); }, //
+ type, //
+ [&](const type::AbstractInt*) { return f(AInt(0)); }, //
+ [&](const type::AbstractFloat*) { return f(AFloat(0)); }, //
+ [&](const sem::I32*) { return f(i32(0)); }, //
+ [&](const sem::U32*) { return f(u32(0)); }, //
+ [&](const sem::F32*) { return f(f32(0)); }, //
+ [&](const sem::F16*) { return f(f16(0)); }, //
[&](const sem::Bool*) { return f(static_cast<bool>(0)); });
}
@@ -2659,11 +2659,11 @@
CreateElement(builder, source, builder.create<sem::I32>(), i32(exp)),
};
},
- [&](const sem::AbstractFloat*) {
+ [&](const type::AbstractFloat*) {
return FractExp{
- CreateElement(builder, source, builder.create<sem::AbstractFloat>(),
+ CreateElement(builder, source, builder.create<type::AbstractFloat>(),
AFloat(fract)),
- CreateElement(builder, source, builder.create<sem::AbstractInt>(), AInt(exp)),
+ CreateElement(builder, source, builder.create<type::AbstractInt>(), AInt(exp)),
};
},
[&](Default) {
diff --git a/src/tint/resolver/const_eval_binary_op_test.cc b/src/tint/resolver/const_eval_binary_op_test.cc
index e5a19ff..9753ceb 100644
--- a/src/tint/resolver/const_eval_binary_op_test.cc
+++ b/src/tint/resolver/const_eval_binary_op_test.cc
@@ -1142,7 +1142,7 @@
auto* sem2 = Sem().Get(expr2);
ASSERT_NE(sem2, nullptr);
- auto aint_ty = create<sem::AbstractInt>();
+ auto aint_ty = create<type::AbstractInt>();
EXPECT_EQ(sem1->Type(), aint_ty);
EXPECT_EQ(sem2->Type(), aint_ty);
}
diff --git a/src/tint/resolver/const_eval_member_access_test.cc b/src/tint/resolver/const_eval_member_access_test.cc
index 2c5b15c..4f3245e 100644
--- a/src/tint/resolver/const_eval_member_access_test.cc
+++ b/src/tint/resolver/const_eval_member_access_test.cc
@@ -83,7 +83,7 @@
auto* cv = sem->ConstantValue();
EXPECT_TYPE(cv->Type(), sem->Type());
EXPECT_TRUE(cv->Index(0)->Type()->Is<sem::Vector>());
- EXPECT_TRUE(cv->Index(0)->Index(0)->Type()->Is<sem::AbstractFloat>());
+ EXPECT_TRUE(cv->Index(0)->Index(0)->Type()->Is<type::AbstractFloat>());
EXPECT_FALSE(cv->AllEqual());
EXPECT_FALSE(cv->AnyZero());
EXPECT_FALSE(cv->AllZero());
diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h
index 27b5e54..2b36588 100644
--- a/src/tint/resolver/const_eval_test.h
+++ b/src/tint/resolver/const_eval_test.h
@@ -41,8 +41,8 @@
inline void CollectScalars(const sem::Constant* c, utils::Vector<builder::Scalar, N>& scalars) {
Switch(
c->Type(), //
- [&](const sem::AbstractInt*) { scalars.Push(c->As<AInt>()); },
- [&](const sem::AbstractFloat*) { scalars.Push(c->As<AFloat>()); },
+ [&](const type::AbstractInt*) { scalars.Push(c->As<AInt>()); },
+ [&](const type::AbstractFloat*) { scalars.Push(c->As<AFloat>()); },
[&](const sem::Bool*) { scalars.Push(c->As<bool>()); },
[&](const sem::I32*) { scalars.Push(c->As<i32>()); },
[&](const sem::U32*) { scalars.Push(c->As<u32>()); },
diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc
index 83d355c..6c70f66 100644
--- a/src/tint/resolver/intrinsic_table.cc
+++ b/src/tint/resolver/intrinsic_table.cc
@@ -20,14 +20,14 @@
#include "src/tint/ast/binary_expression.h"
#include "src/tint/program_builder.h"
-#include "src/tint/sem/abstract_float.h"
-#include "src/tint/sem/abstract_int.h"
-#include "src/tint/sem/abstract_numeric.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"
#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/abstract_numeric.h"
#include "src/tint/type/depth_multisampled_texture.h"
#include "src/tint/type/depth_texture.h"
#include "src/tint/type/external_texture.h"
@@ -352,22 +352,22 @@
return ty->IsAnyOf<Any, sem::Bool>();
}
-const sem::AbstractFloat* build_fa(MatchState& state) {
- return state.builder.create<sem::AbstractFloat>();
+const type::AbstractFloat* build_fa(MatchState& state) {
+ return state.builder.create<type::AbstractFloat>();
}
bool match_fa(MatchState& state, const type::Type* ty) {
return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) &&
- ty->IsAnyOf<Any, sem::AbstractNumeric>();
+ ty->IsAnyOf<Any, type::AbstractNumeric>();
}
-const sem::AbstractInt* build_ia(MatchState& state) {
- return state.builder.create<sem::AbstractInt>();
+const type::AbstractInt* build_ia(MatchState& state) {
+ return state.builder.create<type::AbstractInt>();
}
bool match_ia(MatchState& state, const type::Type* ty) {
return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) &&
- ty->IsAnyOf<Any, sem::AbstractInt>();
+ ty->IsAnyOf<Any, type::AbstractInt>();
}
const sem::Bool* build_bool(MatchState& state) {
@@ -379,7 +379,7 @@
}
bool match_f16(MatchState&, const type::Type* ty) {
- return ty->IsAnyOf<Any, sem::F16, sem::AbstractNumeric>();
+ return ty->IsAnyOf<Any, sem::F16, type::AbstractNumeric>();
}
const sem::F32* build_f32(MatchState& state) {
@@ -387,7 +387,7 @@
}
bool match_f32(MatchState&, const type::Type* ty) {
- return ty->IsAnyOf<Any, sem::F32, sem::AbstractNumeric>();
+ return ty->IsAnyOf<Any, sem::F32, type::AbstractNumeric>();
}
const sem::I32* build_i32(MatchState& state) {
@@ -395,7 +395,7 @@
}
bool match_i32(MatchState&, const type::Type* ty) {
- return ty->IsAnyOf<Any, sem::I32, sem::AbstractInt>();
+ return ty->IsAnyOf<Any, sem::I32, type::AbstractInt>();
}
const sem::U32* build_u32(MatchState& state) {
@@ -403,7 +403,7 @@
}
bool match_u32(MatchState&, const type::Type* ty) {
- return ty->IsAnyOf<Any, sem::U32, sem::AbstractInt>();
+ return ty->IsAnyOf<Any, sem::U32, type::AbstractInt>();
}
bool match_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) {
@@ -846,7 +846,7 @@
el, //
[&](const sem::F32*) { return build_f32(); }, //
[&](const sem::F16*) { return build_f16(); }, //
- [&](const sem::AbstractFloat*) {
+ [&](const type::AbstractFloat*) {
auto* abstract = build_struct(state.builder, "__modf_result_abstract",
{{"fract", el}, {"whole", el}});
abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()});
@@ -874,7 +874,7 @@
el, //
[&](const sem::F32*) { return build_f32(); }, //
[&](const sem::F16*) { return build_f16(); }, //
- [&](const sem::AbstractFloat*) {
+ [&](const type::AbstractFloat*) {
auto* vec = state.builder.create<sem::Vector>(el, n.Value());
auto* abstract =
build_struct(state.builder, prefix + "_abstract", {{"fract", vec}, {"whole", vec}});
@@ -904,8 +904,8 @@
el, //
[&](const sem::F32*) { return build_f32(); }, //
[&](const sem::F16*) { return build_f16(); }, //
- [&](const sem::AbstractFloat*) {
- auto* i = state.builder.create<sem::AbstractInt>();
+ [&](const type::AbstractFloat*) {
+ auto* i = state.builder.create<type::AbstractInt>();
auto* abstract =
build_struct(state.builder, "__frexp_result_abstract", {{"fract", el}, {"exp", i}});
abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()});
@@ -935,9 +935,9 @@
el, //
[&](const sem::F32*) { return build_f32(); }, //
[&](const sem::F16*) { return build_f16(); }, //
- [&](const sem::AbstractFloat*) {
+ [&](const type::AbstractFloat*) {
auto* f = state.builder.create<sem::Vector>(el, n.Value());
- auto* e = state.builder.create<sem::Vector>(state.builder.create<sem::AbstractInt>(),
+ auto* e = state.builder.create<sem::Vector>(state.builder.create<type::AbstractInt>(),
n.Value());
auto* abstract =
build_struct(state.builder, prefix + "_abstract", {{"fract", f}, {"exp", e}});
diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc
index 8ce477f..3cdf65f 100644
--- a/src/tint/resolver/intrinsic_table_test.cc
+++ b/src/tint/resolver/intrinsic_table_test.cc
@@ -529,7 +529,7 @@
}
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
- auto* af = create<sem::AbstractFloat>();
+ auto* af = create<type::AbstractFloat>();
auto* bool_ = create<sem::Bool>();
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_},
sem::EvaluationStage::kConstant, Source{});
@@ -545,7 +545,7 @@
}
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
- auto* af = create<sem::AbstractFloat>();
+ auto* af = create<type::AbstractFloat>();
auto* bool_ref = create<sem::Reference>(create<sem::Bool>(), ast::AddressSpace::kFunction,
ast::Access::kReadWrite);
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref},
@@ -562,7 +562,7 @@
}
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
- auto* ai = create<sem::AbstractInt>();
+ auto* ai = create<type::AbstractInt>();
auto* u32 = create<sem::U32>();
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kConstant,
Source{}, false);
@@ -575,7 +575,7 @@
}
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) {
- auto* ai = create<sem::AbstractInt>();
+ auto* ai = create<type::AbstractInt>();
auto* u32 = create<sem::U32>();
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kRuntime,
Source{}, false);
@@ -712,7 +712,7 @@
}
TEST_F(IntrinsicTableTest, MatchUnaryOp_Constant) {
- auto* ai = create<sem::AbstractInt>();
+ auto* ai = create<type::AbstractInt>();
auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kConstant,
Source{{12, 34}});
EXPECT_EQ(result.result, ai);
@@ -720,7 +720,7 @@
}
TEST_F(IntrinsicTableTest, MatchUnaryOp_Runtime) {
- auto* ai = create<sem::AbstractInt>();
+ auto* ai = create<type::AbstractInt>();
auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kRuntime,
Source{{12, 34}});
EXPECT_NE(result.result, ai);
@@ -879,7 +879,7 @@
}
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) {
- auto* ai = create<sem::AbstractInt>();
+ auto* ai = create<type::AbstractInt>();
auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{vec3_ai},
sem::EvaluationStage::kConstant, Source{{12, 34}});
@@ -892,8 +892,8 @@
}
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) {
- auto* af = create<sem::AbstractFloat>();
- auto* vec2_ai = create<sem::Vector>(create<sem::AbstractInt>(), 2u);
+ auto* af = create<type::AbstractFloat>();
+ auto* vec2_ai = create<sem::Vector>(create<type::AbstractInt>(), 2u);
auto* vec2_af = create<sem::Vector>(af, 2u);
auto* mat2x2_af = create<sem::Matrix>(vec2_af, 2u);
auto result =
@@ -909,7 +909,7 @@
}
TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) {
- auto* ai = create<sem::AbstractInt>();
+ auto* ai = create<type::AbstractInt>();
auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai},
sem::EvaluationStage::kConstant, Source{{12, 34}});
@@ -925,7 +925,7 @@
}
TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) {
- auto* ai = create<sem::AbstractInt>();
+ auto* ai = create<type::AbstractInt>();
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai},
sem::EvaluationStage::kRuntime, Source{{12, 34}});
auto* i32 = create<sem::I32>();
@@ -983,8 +983,8 @@
}
TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) {
- auto* ai = create<sem::AbstractInt>();
- auto* af = create<sem::AbstractFloat>();
+ auto* ai = create<type::AbstractInt>();
+ auto* af = create<type::AbstractFloat>();
auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto* f32 = create<sem::F32>();
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
@@ -1000,8 +1000,8 @@
}
TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) {
- auto* ai = create<sem::AbstractInt>();
- auto* af = create<sem::AbstractFloat>();
+ auto* ai = create<type::AbstractInt>();
+ auto* af = create<type::AbstractFloat>();
auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto* vec3_f32 = create<sem::Vector>(create<sem::F32>(), 3u);
auto* vec3_i32 = create<sem::Vector>(create<sem::I32>(), 3u);
@@ -1030,7 +1030,7 @@
// ctor i32(i32) -> i32
// conv i32<T: scalar_no_i32>(T) -> i32
// The first should win overload resolution.
- auto* ai = create<sem::AbstractInt>();
+ auto* ai = create<type::AbstractInt>();
auto* i32 = create<sem::I32>();
auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai},
sem::EvaluationStage::kConstant, Source{});
diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc
index 24d9999..d942560 100644
--- a/src/tint/resolver/materialize_test.cc
+++ b/src/tint/resolver/materialize_test.cc
@@ -1257,7 +1257,7 @@
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F32>());
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
- ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::AbstractFloat>());
+ ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
}
TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) {
@@ -1276,7 +1276,7 @@
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
ASSERT_TRUE(
- abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractFloat>());
+ abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::AbstractFloat>());
}
TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) {
@@ -1295,7 +1295,7 @@
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F16>());
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
- ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::AbstractFloat>());
+ ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
}
TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) {
@@ -1317,7 +1317,7 @@
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
ASSERT_TRUE(
- abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractFloat>());
+ abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::AbstractFloat>());
}
TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) {
@@ -1334,8 +1334,8 @@
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>());
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
- ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::AbstractFloat>());
- ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<sem::AbstractInt>());
+ ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
+ ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<type::AbstractInt>());
}
TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) {
@@ -1356,9 +1356,9 @@
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
ASSERT_TRUE(
- abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractFloat>());
+ abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::AbstractFloat>());
ASSERT_TRUE(
- abstract_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractInt>());
+ abstract_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<type::AbstractInt>());
}
TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) {
@@ -1378,8 +1378,8 @@
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>());
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
- ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::AbstractFloat>());
- ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<sem::AbstractInt>());
+ ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
+ ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<type::AbstractInt>());
}
TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) {
@@ -1403,9 +1403,9 @@
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
ASSERT_TRUE(
- abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractFloat>());
+ abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::AbstractFloat>());
ASSERT_TRUE(
- abstract_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractInt>());
+ abstract_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<type::AbstractInt>());
}
} // namespace materialize_abstract_structure
diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc
index a7d43db..18a6f59 100644
--- a/src/tint/resolver/resolver.cc
+++ b/src/tint/resolver/resolver.cc
@@ -53,8 +53,6 @@
#include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/resolver/type_alias.h"
#include "src/tint/resolver/uniformity.h"
-#include "src/tint/sem/abstract_float.h"
-#include "src/tint/sem/abstract_int.h"
#include "src/tint/sem/array.h"
#include "src/tint/sem/atomic.h"
#include "src/tint/sem/break_if_statement.h"
@@ -76,6 +74,8 @@
#include "src/tint/sem/type_initializer.h"
#include "src/tint/sem/variable.h"
#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/depth_multisampled_texture.h"
#include "src/tint/type/depth_texture.h"
#include "src/tint/type/multisampled_texture.h"
@@ -1155,7 +1155,7 @@
return false;
}
auto* ty = expr->Type();
- if (!ty->IsAnyOf<sem::I32, sem::U32, sem::AbstractInt>()) {
+ if (!ty->IsAnyOf<sem::I32, sem::U32, type::AbstractInt>()) {
AddError(kErrBadExpr, value->source);
return false;
}
@@ -1178,7 +1178,7 @@
}
// If all arguments are abstract-integers, then materialize to i32.
- if (common_ty->Is<sem::AbstractInt>()) {
+ if (common_ty->Is<type::AbstractInt>()) {
common_ty = builder_->create<sem::I32>();
}
@@ -1726,19 +1726,19 @@
return Switch(
ty, //
- [&](const sem::AbstractInt*) { return target_ty ? target_ty : i32(); },
- [&](const sem::AbstractFloat*) { return target_ty ? target_ty : f32(); },
+ [&](const type::AbstractInt*) { return target_ty ? target_ty : i32(); },
+ [&](const type::AbstractFloat*) { return target_ty ? target_ty : f32(); },
[&](const sem::Vector* v) {
return Switch(
v->type(), //
- [&](const sem::AbstractInt*) { return target_ty ? target_ty : i32v(v->Width()); },
- [&](const sem::AbstractFloat*) {
+ [&](const type::AbstractInt*) { return target_ty ? target_ty : i32v(v->Width()); },
+ [&](const type::AbstractFloat*) {
return target_ty ? target_ty : f32v(v->Width());
});
},
[&](const sem::Matrix* m) {
return Switch(m->type(), //
- [&](const sem::AbstractFloat*) {
+ [&](const type::AbstractFloat*) {
return target_ty ? target_ty : f32m(m->columns(), m->rows());
});
},
@@ -1823,7 +1823,7 @@
bool Resolver::ShouldMaterializeArgument(const type::Type* parameter_ty) const {
const auto* param_el_ty = type::Type::DeepestElementOf(parameter_ty);
- return param_el_ty && !param_el_ty->Is<sem::AbstractNumeric>();
+ return param_el_ty && !param_el_ty->Is<type::AbstractNumeric>();
}
bool Resolver::Convert(const sem::Constant*& c, const type::Type* target_ty, const Source& source) {
@@ -2483,7 +2483,7 @@
[&](const ast::IntLiteralExpression* i) -> type::Type* {
switch (i->suffix) {
case ast::IntLiteralExpression::Suffix::kNone:
- return builder_->create<sem::AbstractInt>();
+ return builder_->create<type::AbstractInt>();
case ast::IntLiteralExpression::Suffix::kI:
return builder_->create<sem::I32>();
case ast::IntLiteralExpression::Suffix::kU:
@@ -2494,7 +2494,7 @@
[&](const ast::FloatLiteralExpression* f) -> type::Type* {
switch (f->suffix) {
case ast::FloatLiteralExpression::Suffix::kNone:
- return builder_->create<sem::AbstractFloat>();
+ return builder_->create<type::AbstractFloat>();
case ast::FloatLiteralExpression::Suffix::kF:
return builder_->create<sem::F32>();
case ast::FloatLiteralExpression::Suffix::kH:
diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h
index f47719f..1186fa1 100644
--- a/src/tint/resolver/resolver_test_helper.h
+++ b/src/tint/resolver/resolver_test_helper.h
@@ -26,12 +26,12 @@
#include "gtest/gtest.h"
#include "src/tint/program_builder.h"
#include "src/tint/resolver/resolver.h"
-#include "src/tint/sem/abstract_float.h"
-#include "src/tint/sem/abstract_int.h"
#include "src/tint/sem/expression.h"
#include "src/tint/sem/statement.h"
#include "src/tint/sem/variable.h"
#include "src/tint/traits.h"
+#include "src/tint/type/abstract_float.h"
+#include "src/tint/type/abstract_int.h"
#include "src/tint/utils/vector.h"
namespace tint::resolver {
@@ -387,7 +387,7 @@
/// @param b the ProgramBuilder
/// @return the semantic abstract-float type
static inline const type::Type* Sem(ProgramBuilder& b) {
- return b.create<sem::AbstractFloat>();
+ return b.create<type::AbstractFloat>();
}
/// @param b the ProgramBuilder
/// @param args args of size 1 with the abstract-float value to init with
@@ -418,7 +418,7 @@
static inline const ast::Type* AST(ProgramBuilder&) { return nullptr; }
/// @param b the ProgramBuilder
/// @return the semantic abstract-int type
- static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::AbstractInt>(); }
+ static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<type::AbstractInt>(); }
/// @param b the ProgramBuilder
/// @param args args of size 1 with the abstract-int value to init with
/// @return a new AST abstract-int literal value expression
diff --git a/src/tint/resolver/type_initializer_validation_test.cc b/src/tint/resolver/type_initializer_validation_test.cc
index 61f9a58..437f28f 100644
--- a/src/tint/resolver/type_initializer_validation_test.cc
+++ b/src/tint/resolver/type_initializer_validation_test.cc
@@ -610,9 +610,9 @@
ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType());
ASSERT_EQ(ctor->Parameters().Length(), 3u);
- EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::AbstractInt>());
- EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::AbstractInt>());
- EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::AbstractInt>());
+ EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::AbstractInt>());
+ EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::AbstractInt>());
+ EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::AbstractInt>());
}
TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) {
diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc
index ac3489c..1740a06 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/abstract_numeric.h"
#include "src/tint/sem/array.h"
#include "src/tint/sem/atomic.h"
#include "src/tint/sem/break_if_statement.h"
@@ -67,6 +66,7 @@
#include "src/tint/sem/type_initializer.h"
#include "src/tint/sem/variable.h"
#include "src/tint/sem/while_statement.h"
+#include "src/tint/type/abstract_numeric.h"
#include "src/tint/type/depth_multisampled_texture.h"
#include "src/tint/type/depth_texture.h"
#include "src/tint/type/multisampled_texture.h"
@@ -2228,7 +2228,7 @@
auto value = selector->Value()->As<uint32_t>();
if (auto added = selectors.Add(value, selector->Declaration()->source); !added) {
AddError("duplicate switch case '" +
- (decl_ty->IsAnyOf<sem::I32, sem::AbstractNumeric>()
+ (decl_ty->IsAnyOf<sem::I32, type::AbstractNumeric>()
? std::to_string(i32(value))
: std::to_string(value)) +
"'",
@@ -2266,7 +2266,7 @@
// https://www.w3.org/TR/WGSL/#phony-assignment-section
auto* ty = rhs_ty->UnwrapRef();
if (!ty->IsConstructible() &&
- !ty->IsAnyOf<sem::Pointer, type::Texture, type::Sampler, sem::AbstractNumeric>()) {
+ !ty->IsAnyOf<sem::Pointer, type::Texture, type::Sampler, type::AbstractNumeric>()) {
AddError("cannot assign '" + sem_.TypeNameOf(rhs_ty) +
"' to '_'. '_' can only be assigned a constructible, pointer, texture or "
"sampler type",
diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc
index acdadf9..68f4bc2 100644
--- a/src/tint/resolver/variable_test.cc
+++ b/src/tint/resolver/variable_test.cc
@@ -974,8 +974,8 @@
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
- ASSERT_TRUE(TypeOf(c_ai)->Is<sem::AbstractInt>());
- ASSERT_TRUE(TypeOf(c_af)->Is<sem::AbstractFloat>());
+ ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
+ ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
@@ -1145,8 +1145,8 @@
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
- ASSERT_TRUE(TypeOf(c_ai)->Is<sem::AbstractInt>());
- ASSERT_TRUE(TypeOf(c_af)->Is<sem::AbstractFloat>());
+ ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
+ ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
diff --git a/src/tint/tint.natvis b/src/tint/tint.natvis
index 8e000c3..4e957ff 100644
--- a/src/tint/tint.natvis
+++ b/src/tint/tint.natvis
@@ -236,11 +236,11 @@
<!-- sem -->
<!--=================================================================-->
- <Type Name="tint::sem::AbstractInt">
+ <Type Name="tint::type::AbstractInt">
<DisplayString>AbstractInt</DisplayString>
</Type>
- <Type Name="tint::sem::AbstractFloat">
+ <Type Name="tint::type::AbstractFloat">
<DisplayString>AbstractFloat</DisplayString>
</Type>
diff --git a/src/tint/transform/direct_variable_access.cc b/src/tint/transform/direct_variable_access.cc
index 07f159a..f187ac8 100644
--- a/src/tint/transform/direct_variable_access.cc
+++ b/src/tint/transform/direct_variable_access.cc
@@ -20,7 +20,6 @@
#include "src/tint/ast/traverse_expressions.h"
#include "src/tint/program_builder.h"
-#include "src/tint/sem/abstract_int.h"
#include "src/tint/sem/call.h"
#include "src/tint/sem/function.h"
#include "src/tint/sem/index_accessor_expression.h"
@@ -30,6 +29,7 @@
#include "src/tint/sem/struct.h"
#include "src/tint/sem/variable.h"
#include "src/tint/transform/utils/hoist_to_decl_before.h"
+#include "src/tint/type/abstract_int.h"
#include "src/tint/utils/reverse.h"
#include "src/tint/utils/scoped_assignment.h"
@@ -573,7 +573,7 @@
if (!idx->UnwrapMaterialize()
->Type()
->UnwrapRef()
- ->IsAnyOf<sem::U32, sem::AbstractInt>()) {
+ ->IsAnyOf<sem::U32, type::AbstractInt>()) {
expr = b.Construct(b.ty.u32(), expr);
}
}
diff --git a/src/tint/transform/vectorize_matrix_conversions.cc b/src/tint/transform/vectorize_matrix_conversions.cc
index 94fbdf3..cbb1624 100644
--- a/src/tint/transform/vectorize_matrix_conversions.cc
+++ b/src/tint/transform/vectorize_matrix_conversions.cc
@@ -19,10 +19,10 @@
#include <utility>
#include "src/tint/program_builder.h"
-#include "src/tint/sem/abstract_numeric.h"
#include "src/tint/sem/call.h"
#include "src/tint/sem/expression.h"
#include "src/tint/sem/type_conversion.h"
+#include "src/tint/type/abstract_numeric.h"
#include "src/tint/utils/hash.h"
#include "src/tint/utils/map.h"
diff --git a/src/tint/transform/vectorize_scalar_matrix_initializers.cc b/src/tint/transform/vectorize_scalar_matrix_initializers.cc
index e6e1c46..27ccf40 100644
--- a/src/tint/transform/vectorize_scalar_matrix_initializers.cc
+++ b/src/tint/transform/vectorize_scalar_matrix_initializers.cc
@@ -18,10 +18,10 @@
#include <utility>
#include "src/tint/program_builder.h"
-#include "src/tint/sem/abstract_numeric.h"
#include "src/tint/sem/call.h"
#include "src/tint/sem/expression.h"
#include "src/tint/sem/type_initializer.h"
+#include "src/tint/type/abstract_numeric.h"
#include "src/tint/utils/map.h"
TINT_INSTANTIATE_TYPEINFO(tint::transform::VectorizeScalarMatrixInitializers);
@@ -84,7 +84,7 @@
if (args[0]
->Type()
->UnwrapRef()
- ->IsAnyOf<sem::Matrix, sem::Vector, sem::AbstractNumeric>()) {
+ ->IsAnyOf<sem::Matrix, sem::Vector, type::AbstractNumeric>()) {
return nullptr;
}
diff --git a/src/tint/sem/abstract_float.cc b/src/tint/type/abstract_float.cc
similarity index 88%
rename from src/tint/sem/abstract_float.cc
rename to src/tint/type/abstract_float.cc
index 50ddfd3..5e17f0a 100644
--- a/src/tint/sem/abstract_float.cc
+++ b/src/tint/type/abstract_float.cc
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/sem/abstract_float.h"
+#include "src/tint/type/abstract_float.h"
#include "src/tint/program_builder.h"
#include "src/tint/utils/hash.h"
-TINT_INSTANTIATE_TYPEINFO(tint::sem::AbstractFloat);
+TINT_INSTANTIATE_TYPEINFO(tint::type::AbstractFloat);
-namespace tint::sem {
+namespace tint::type {
AbstractFloat::AbstractFloat() = default;
AbstractFloat::AbstractFloat(AbstractFloat&&) = default;
@@ -37,4 +37,4 @@
return "abstract-float";
}
-} // namespace tint::sem
+} // namespace tint::type
diff --git a/src/tint/sem/abstract_float.h b/src/tint/type/abstract_float.h
similarity index 86%
rename from src/tint/sem/abstract_float.h
rename to src/tint/type/abstract_float.h
index 77b8a78..69c12be 100644
--- a/src/tint/sem/abstract_float.h
+++ b/src/tint/type/abstract_float.h
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_SEM_ABSTRACT_FLOAT_H_
-#define SRC_TINT_SEM_ABSTRACT_FLOAT_H_
+#ifndef SRC_TINT_TYPE_ABSTRACT_FLOAT_H_
+#define SRC_TINT_TYPE_ABSTRACT_FLOAT_H_
#include <string>
-#include "src/tint/sem/abstract_numeric.h"
+#include "src/tint/type/abstract_numeric.h"
-namespace tint::sem {
+namespace tint::type {
/// An abstract-float type.
/// @see https://www.w3.org/TR/WGSL/#abstractFloat
@@ -44,6 +44,6 @@
std::string FriendlyName(const SymbolTable& symbols) const override;
};
-} // namespace tint::sem
+} // namespace tint::type
-#endif // SRC_TINT_SEM_ABSTRACT_FLOAT_H_
+#endif // SRC_TINT_TYPE_ABSTRACT_FLOAT_H_
diff --git a/src/tint/sem/abstract_int.cc b/src/tint/type/abstract_int.cc
similarity index 88%
rename from src/tint/sem/abstract_int.cc
rename to src/tint/type/abstract_int.cc
index 9ab7a0a..1506e6f 100644
--- a/src/tint/sem/abstract_int.cc
+++ b/src/tint/type/abstract_int.cc
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/sem/abstract_int.h"
+#include "src/tint/type/abstract_int.h"
#include "src/tint/program_builder.h"
#include "src/tint/utils/hash.h"
-TINT_INSTANTIATE_TYPEINFO(tint::sem::AbstractInt);
+TINT_INSTANTIATE_TYPEINFO(tint::type::AbstractInt);
-namespace tint::sem {
+namespace tint::type {
AbstractInt::AbstractInt() = default;
AbstractInt::AbstractInt(AbstractInt&&) = default;
@@ -37,4 +37,4 @@
return "abstract-int";
}
-} // namespace tint::sem
+} // namespace tint::type
diff --git a/src/tint/sem/abstract_int.h b/src/tint/type/abstract_int.h
similarity index 86%
rename from src/tint/sem/abstract_int.h
rename to src/tint/type/abstract_int.h
index 91a6299..7c7f287 100644
--- a/src/tint/sem/abstract_int.h
+++ b/src/tint/type/abstract_int.h
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_SEM_ABSTRACT_INT_H_
-#define SRC_TINT_SEM_ABSTRACT_INT_H_
+#ifndef SRC_TINT_TYPE_ABSTRACT_INT_H_
+#define SRC_TINT_TYPE_ABSTRACT_INT_H_
#include <string>
-#include "src/tint/sem/abstract_numeric.h"
+#include "src/tint/type/abstract_numeric.h"
-namespace tint::sem {
+namespace tint::type {
/// An abstract-int type.
/// @see https://www.w3.org/TR/WGSL/#abstractint
@@ -44,6 +44,6 @@
std::string FriendlyName(const SymbolTable& symbols) const override;
};
-} // namespace tint::sem
+} // namespace tint::type
-#endif // SRC_TINT_SEM_ABSTRACT_INT_H_
+#endif // SRC_TINT_TYPE_ABSTRACT_INT_H_
diff --git a/src/tint/sem/abstract_numeric.cc b/src/tint/type/abstract_numeric.cc
similarity index 86%
rename from src/tint/sem/abstract_numeric.cc
rename to src/tint/type/abstract_numeric.cc
index e19f133..f5fdee8 100644
--- a/src/tint/sem/abstract_numeric.cc
+++ b/src/tint/type/abstract_numeric.cc
@@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/sem/abstract_numeric.h"
+#include "src/tint/type/abstract_numeric.h"
-TINT_INSTANTIATE_TYPEINFO(tint::sem::AbstractNumeric);
+TINT_INSTANTIATE_TYPEINFO(tint::type::AbstractNumeric);
-namespace tint::sem {
+namespace tint::type {
AbstractNumeric::AbstractNumeric()
: Base(type::TypeFlags{
@@ -35,4 +35,4 @@
return 0;
}
-} // namespace tint::sem
+} // namespace tint::type
diff --git a/src/tint/sem/abstract_numeric.h b/src/tint/type/abstract_numeric.h
similarity index 86%
rename from src/tint/sem/abstract_numeric.h
rename to src/tint/type/abstract_numeric.h
index 665044c..bc49c2d 100644
--- a/src/tint/sem/abstract_numeric.h
+++ b/src/tint/type/abstract_numeric.h
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_SEM_ABSTRACT_NUMERIC_H_
-#define SRC_TINT_SEM_ABSTRACT_NUMERIC_H_
+#ifndef SRC_TINT_TYPE_ABSTRACT_NUMERIC_H_
+#define SRC_TINT_TYPE_ABSTRACT_NUMERIC_H_
#include <string>
#include "src/tint/type/type.h"
-namespace tint::sem {
+namespace tint::type {
/// The base class for abstract-int and abstract-float types.
/// @see https://www.w3.org/TR/WGSL/#types-for-creation-time-constants
@@ -39,6 +39,6 @@
uint32_t Align() const override;
};
-} // namespace tint::sem
+} // namespace tint::type
-#endif // SRC_TINT_SEM_ABSTRACT_NUMERIC_H_
+#endif // SRC_TINT_TYPE_ABSTRACT_NUMERIC_H_
diff --git a/src/tint/type/type.cc b/src/tint/type/type.cc
index 9955529..a416947 100644
--- a/src/tint/type/type.cc
+++ b/src/tint/type/type.cc
@@ -14,8 +14,6 @@
#include "src/tint/type/type.h"
-#include "src/tint/sem/abstract_float.h"
-#include "src/tint/sem/abstract_int.h"
#include "src/tint/sem/array.h"
#include "src/tint/sem/bool.h"
#include "src/tint/sem/f16.h"
@@ -27,6 +25,8 @@
#include "src/tint/sem/struct.h"
#include "src/tint/sem/u32.h"
#include "src/tint/sem/vector.h"
+#include "src/tint/type/abstract_float.h"
+#include "src/tint/type/abstract_int.h"
#include "src/tint/type/sampler.h"
#include "src/tint/type/texture.h"
@@ -69,15 +69,15 @@
}
bool Type::is_scalar() const {
- return IsAnyOf<sem::F16, sem::F32, sem::U32, sem::I32, sem::AbstractNumeric, sem::Bool>();
+ return IsAnyOf<sem::F16, sem::F32, sem::U32, sem::I32, type::AbstractNumeric, sem::Bool>();
}
bool Type::is_numeric_scalar() const {
- return IsAnyOf<sem::F16, sem::F32, sem::U32, sem::I32, sem::AbstractNumeric>();
+ return IsAnyOf<sem::F16, sem::F32, sem::U32, sem::I32, type::AbstractNumeric>();
}
bool Type::is_float_scalar() const {
- return IsAnyOf<sem::F16, sem::F32, sem::AbstractNumeric>();
+ return IsAnyOf<sem::F16, sem::F32, type::AbstractNumeric>();
}
bool Type::is_float_matrix() const {
@@ -107,7 +107,7 @@
}
bool Type::is_signed_integer_scalar() const {
- return IsAnyOf<sem::I32, sem::AbstractInt>();
+ return IsAnyOf<sem::I32, type::AbstractInt>();
}
bool Type::is_unsigned_integer_scalar() const {
@@ -116,7 +116,7 @@
bool Type::is_signed_integer_vector() const {
return Is(
- [](const sem::Vector* v) { return v->type()->IsAnyOf<sem::I32, sem::AbstractInt>(); });
+ [](const sem::Vector* v) { return v->type()->IsAnyOf<sem::I32, type::AbstractInt>(); });
}
bool Type::is_unsigned_integer_vector() const {
@@ -128,7 +128,7 @@
}
bool Type::is_signed_integer_scalar_or_vector() const {
- return IsAnyOf<sem::I32, sem::AbstractInt>() || is_signed_integer_vector();
+ return IsAnyOf<sem::I32, type::AbstractInt>() || is_signed_integer_vector();
}
bool Type::is_integer_scalar_or_vector() const {
@@ -136,19 +136,19 @@
}
bool Type::is_abstract_integer_vector() const {
- return Is([](const sem::Vector* v) { return v->type()->Is<sem::AbstractInt>(); });
+ return Is([](const sem::Vector* v) { return v->type()->Is<type::AbstractInt>(); });
}
bool Type::is_abstract_float_vector() const {
- return Is([](const sem::Vector* v) { return v->type()->Is<sem::AbstractFloat>(); });
+ return Is([](const sem::Vector* v) { return v->type()->Is<type::AbstractFloat>(); });
}
bool Type::is_abstract_integer_scalar_or_vector() const {
- return Is<sem::AbstractInt>() || is_abstract_integer_vector();
+ return Is<type::AbstractInt>() || is_abstract_integer_vector();
}
bool Type::is_abstract_float_scalar_or_vector() const {
- return Is<sem::AbstractFloat>() || is_abstract_float_vector();
+ return Is<type::AbstractFloat>() || is_abstract_float_vector();
}
bool Type::is_bool_vector() const {
@@ -178,7 +178,7 @@
bool Type::HoldsAbstract() const {
return Switch(
this, //
- [&](const sem::AbstractNumeric*) { return true; },
+ [&](const type::AbstractNumeric*) { return true; },
[&](const sem::Vector* v) { return v->type()->HoldsAbstract(); },
[&](const sem::Matrix* m) { return m->type()->HoldsAbstract(); },
[&](const sem::Array* a) { return a->ElemType()->HoldsAbstract(); },
@@ -198,21 +198,21 @@
}
return Switch(
from,
- [&](const sem::AbstractFloat*) {
+ [&](const type::AbstractFloat*) {
return Switch(
to, //
[&](const sem::F32*) { return 1; }, //
[&](const sem::F16*) { return 2; }, //
[&](Default) { return kNoConversion; });
},
- [&](const sem::AbstractInt*) {
+ [&](const type::AbstractInt*) {
return Switch(
- to, //
- [&](const sem::I32*) { return 3; }, //
- [&](const sem::U32*) { return 4; }, //
- [&](const sem::AbstractFloat*) { return 5; }, //
- [&](const sem::F32*) { return 6; }, //
- [&](const sem::F16*) { return 7; }, //
+ to, //
+ [&](const sem::I32*) { return 3; }, //
+ [&](const sem::U32*) { return 4; }, //
+ [&](const type::AbstractFloat*) { return 5; }, //
+ [&](const sem::F32*) { return 6; }, //
+ [&](const sem::F16*) { return 7; }, //
[&](Default) { return kNoConversion; });
},
[&](const sem::Vector* from_vec) {
diff --git a/src/tint/type/type_test.cc b/src/tint/type/type_test.cc
index d7833b3..9036f89 100644
--- a/src/tint/type/type_test.cc
+++ b/src/tint/type/type_test.cc
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/sem/abstract_float.h"
-#include "src/tint/sem/abstract_int.h"
#include "src/tint/sem/f16.h"
#include "src/tint/sem/reference.h"
+#include "src/tint/type/abstract_float.h"
+#include "src/tint/type/abstract_int.h"
#include "src/tint/type/array_count.h"
#include "src/tint/type/test_helper.h"
@@ -23,8 +23,8 @@
namespace {
struct TypeTest : public TestHelper {
- const sem::AbstractFloat* af = create<sem::AbstractFloat>();
- const sem::AbstractInt* ai = create<sem::AbstractInt>();
+ const type::AbstractFloat* af = create<type::AbstractFloat>();
+ const type::AbstractInt* ai = create<type::AbstractInt>();
const sem::F32* f32 = create<sem::F32>();
const sem::F16* f16 = create<sem::F16>();
const sem::I32* i32 = create<sem::I32>();