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>
This commit is contained in:
dan sinclair 2022-12-08 15:33:01 +00:00 committed by Dawn LUCI CQ
parent 5ee58b60a8
commit 094ace6f63
27 changed files with 176 additions and 176 deletions

View File

@ -415,9 +415,6 @@ libtint_source_set("libtint_core_all_src") {
"resolver/validator.cc", "resolver/validator.cc",
"resolver/validator.h", "resolver/validator.h",
"scope_stack.h", "scope_stack.h",
"sem/abstract_float.h",
"sem/abstract_int.h",
"sem/abstract_numeric.h",
"sem/array.h", "sem/array.h",
"sem/array_count.h", "sem/array_count.h",
"sem/atomic.h", "sem/atomic.h",
@ -568,6 +565,9 @@ libtint_source_set("libtint_core_all_src") {
"transform/while_to_loop.h", "transform/while_to_loop.h",
"transform/zero_init_workgroup_memory.cc", "transform/zero_init_workgroup_memory.cc",
"transform/zero_init_workgroup_memory.h", "transform/zero_init_workgroup_memory.h",
"type/abstract_float.h",
"type/abstract_int.h",
"type/abstract_numeric.h",
"type/array_count.h", "type/array_count.h",
"type/depth_multisampled_texture.h", "type/depth_multisampled_texture.h",
"type/depth_texture.h", "type/depth_texture.h",
@ -633,12 +633,6 @@ libtint_source_set("libtint_core_all_src") {
libtint_source_set("libtint_sem_src") { libtint_source_set("libtint_sem_src") {
sources = [ 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.cc",
"sem/array.h", "sem/array.h",
"sem/array_count.cc", "sem/array_count.cc",
@ -725,6 +719,12 @@ libtint_source_set("libtint_sem_src") {
libtint_source_set("libtint_type_src") { libtint_source_set("libtint_type_src") {
sources = [ 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.cc",
"type/array_count.h", "type/array_count.h",
"type/depth_multisampled_texture.cc", "type/depth_multisampled_texture.cc",

View File

@ -291,12 +291,6 @@ list(APPEND TINT_LIB_SRCS
resolver/validator.cc resolver/validator.cc
resolver/validator.h resolver/validator.h
scope_stack.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.cc
sem/array.h sem/array.h
sem/array_count.cc sem/array_count.cc
@ -481,6 +475,12 @@ list(APPEND TINT_LIB_SRCS
transform/while_to_loop.h transform/while_to_loop.h
transform/zero_init_workgroup_memory.cc transform/zero_init_workgroup_memory.cc
transform/zero_init_workgroup_memory.h 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.cc
type/array_count.h type/array_count.h
type/depth_multisampled_texture.cc type/depth_multisampled_texture.cc

View File

@ -18,8 +18,8 @@
#include <vector> #include <vector>
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/sem/abstract_float.h" #include "src/tint/type/abstract_float.h"
#include "src/tint/sem/abstract_int.h" #include "src/tint/type/abstract_int.h"
namespace tint::fuzzers::ast_fuzzer { namespace tint::fuzzers::ast_fuzzer {

View File

@ -23,8 +23,6 @@
#include <utility> #include <utility>
#include "src/tint/program_builder.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/array.h" #include "src/tint/sem/array.h"
#include "src/tint/sem/bool.h" #include "src/tint/sem/bool.h"
#include "src/tint/sem/constant.h" #include "src/tint/sem/constant.h"
@ -36,6 +34,8 @@
#include "src/tint/sem/type_initializer.h" #include "src/tint/sem/type_initializer.h"
#include "src/tint/sem/u32.h" #include "src/tint/sem/u32.h"
#include "src/tint/sem/vector.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/bitcast.h"
#include "src/tint/utils/compiler_macros.h" #include "src/tint/utils/compiler_macros.h"
#include "src/tint/utils/map.h" #include "src/tint/utils/map.h"
@ -69,7 +69,7 @@ template <typename F, typename... CONSTANTS>
auto Dispatch_ia_iu32(F&& f, CONSTANTS&&... cs) { auto Dispatch_ia_iu32(F&& f, CONSTANTS&&... cs) {
return Switch( return Switch(
First(cs...)->Type(), // 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::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); }); [&](const sem::U32*) { return f(cs->template As<u32>()...); });
} }
@ -80,7 +80,7 @@ template <typename F, typename... CONSTANTS>
auto Dispatch_ia_iu32_bool(F&& f, CONSTANTS&&... cs) { auto Dispatch_ia_iu32_bool(F&& f, CONSTANTS&&... cs) {
return Switch( return Switch(
First(cs...)->Type(), // 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::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); }, [&](const sem::U32*) { return f(cs->template As<u32>()...); },
[&](const sem::Bool*) { return f(cs->template As<bool>()...); }); [&](const sem::Bool*) { return f(cs->template As<bool>()...); });
@ -92,8 +92,8 @@ template <typename F, typename... CONSTANTS>
auto Dispatch_fia_fi32_f16(F&& f, CONSTANTS&&... cs) { auto Dispatch_fia_fi32_f16(F&& f, CONSTANTS&&... cs) {
return Switch( return Switch(
First(cs...)->Type(), // First(cs...)->Type(), //
[&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); }, [&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
[&](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::F32*) { return f(cs->template As<f32>()...); },
[&](const sem::I32*) { return f(cs->template As<i32>()...); }, [&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::F16*) { return f(cs->template As<f16>()...); }); [&](const sem::F16*) { return f(cs->template As<f16>()...); });
@ -105,8 +105,8 @@ template <typename F, typename... CONSTANTS>
auto Dispatch_fia_fiu32_f16(F&& f, CONSTANTS&&... cs) { auto Dispatch_fia_fiu32_f16(F&& f, CONSTANTS&&... cs) {
return Switch( return Switch(
First(cs...)->Type(), // First(cs...)->Type(), //
[&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); }, [&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
[&](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::F32*) { return f(cs->template As<f32>()...); },
[&](const sem::I32*) { return f(cs->template As<i32>()...); }, [&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); }, [&](const sem::U32*) { return f(cs->template As<u32>()...); },
@ -119,8 +119,8 @@ template <typename F, typename... CONSTANTS>
auto Dispatch_fia_fiu32_f16_bool(F&& f, CONSTANTS&&... cs) { auto Dispatch_fia_fiu32_f16_bool(F&& f, CONSTANTS&&... cs) {
return Switch( return Switch(
First(cs...)->Type(), // First(cs...)->Type(), //
[&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); }, [&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
[&](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::F32*) { return f(cs->template As<f32>()...); },
[&](const sem::I32*) { return f(cs->template As<i32>()...); }, [&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); }, [&](const sem::U32*) { return f(cs->template As<u32>()...); },
@ -134,7 +134,7 @@ template <typename F, typename... CONSTANTS>
auto Dispatch_fa_f32_f16(F&& f, CONSTANTS&&... cs) { auto Dispatch_fa_f32_f16(F&& f, CONSTANTS&&... cs) {
return Switch( return Switch(
First(cs...)->Type(), // 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::F32*) { return f(cs->template As<f32>()...); },
[&](const sem::F16*) { return f(cs->template As<f16>()...); }); [&](const sem::F16*) { return f(cs->template As<f16>()...); });
} }
@ -156,13 +156,13 @@ auto Dispatch_bool(F&& f, CONSTANTS&&... cs) {
template <typename F> template <typename F>
auto ZeroTypeDispatch(const type::Type* type, F&& f) { auto ZeroTypeDispatch(const type::Type* type, F&& f) {
return Switch( return Switch(
type, // type, //
[&](const sem::AbstractInt*) { return f(AInt(0)); }, // [&](const type::AbstractInt*) { return f(AInt(0)); }, //
[&](const sem::AbstractFloat*) { return f(AFloat(0)); }, // [&](const type::AbstractFloat*) { return f(AFloat(0)); }, //
[&](const sem::I32*) { return f(i32(0)); }, // [&](const sem::I32*) { return f(i32(0)); }, //
[&](const sem::U32*) { return f(u32(0)); }, // [&](const sem::U32*) { return f(u32(0)); }, //
[&](const sem::F32*) { return f(f32(0)); }, // [&](const sem::F32*) { return f(f32(0)); }, //
[&](const sem::F16*) { return f(f16(0)); }, // [&](const sem::F16*) { return f(f16(0)); }, //
[&](const sem::Bool*) { return f(static_cast<bool>(0)); }); [&](const sem::Bool*) { return f(static_cast<bool>(0)); });
} }
@ -2659,11 +2659,11 @@ ConstEval::Result ConstEval::frexp(const type::Type* ty,
CreateElement(builder, source, builder.create<sem::I32>(), i32(exp)), CreateElement(builder, source, builder.create<sem::I32>(), i32(exp)),
}; };
}, },
[&](const sem::AbstractFloat*) { [&](const type::AbstractFloat*) {
return FractExp{ return FractExp{
CreateElement(builder, source, builder.create<sem::AbstractFloat>(), CreateElement(builder, source, builder.create<type::AbstractFloat>(),
AFloat(fract)), AFloat(fract)),
CreateElement(builder, source, builder.create<sem::AbstractInt>(), AInt(exp)), CreateElement(builder, source, builder.create<type::AbstractInt>(), AInt(exp)),
}; };
}, },
[&](Default) { [&](Default) {

View File

@ -1142,7 +1142,7 @@ TEST_F(ResolverConstEvalTest, BinaryAbstractShiftLeftRemainsAbstract) {
auto* sem2 = Sem().Get(expr2); auto* sem2 = Sem().Get(expr2);
ASSERT_NE(sem2, nullptr); ASSERT_NE(sem2, nullptr);
auto aint_ty = create<sem::AbstractInt>(); auto aint_ty = create<type::AbstractInt>();
EXPECT_EQ(sem1->Type(), aint_ty); EXPECT_EQ(sem1->Type(), aint_ty);
EXPECT_EQ(sem2->Type(), aint_ty); EXPECT_EQ(sem2->Type(), aint_ty);
} }

View File

@ -83,7 +83,7 @@ TEST_F(ResolverConstEvalTest, Matrix_AFloat_Construct_From_AInt_Vectors) {
auto* cv = sem->ConstantValue(); auto* cv = sem->ConstantValue();
EXPECT_TYPE(cv->Type(), sem->Type()); EXPECT_TYPE(cv->Type(), sem->Type());
EXPECT_TRUE(cv->Index(0)->Type()->Is<sem::Vector>()); 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->AllEqual());
EXPECT_FALSE(cv->AnyZero()); EXPECT_FALSE(cv->AnyZero());
EXPECT_FALSE(cv->AllZero()); EXPECT_FALSE(cv->AllZero());

View File

@ -41,8 +41,8 @@ template <size_t N>
inline void CollectScalars(const sem::Constant* c, utils::Vector<builder::Scalar, N>& scalars) { inline void CollectScalars(const sem::Constant* c, utils::Vector<builder::Scalar, N>& scalars) {
Switch( Switch(
c->Type(), // c->Type(), //
[&](const sem::AbstractInt*) { scalars.Push(c->As<AInt>()); }, [&](const type::AbstractInt*) { scalars.Push(c->As<AInt>()); },
[&](const sem::AbstractFloat*) { scalars.Push(c->As<AFloat>()); }, [&](const type::AbstractFloat*) { scalars.Push(c->As<AFloat>()); },
[&](const sem::Bool*) { scalars.Push(c->As<bool>()); }, [&](const sem::Bool*) { scalars.Push(c->As<bool>()); },
[&](const sem::I32*) { scalars.Push(c->As<i32>()); }, [&](const sem::I32*) { scalars.Push(c->As<i32>()); },
[&](const sem::U32*) { scalars.Push(c->As<u32>()); }, [&](const sem::U32*) { scalars.Push(c->As<u32>()); },

View File

@ -20,14 +20,14 @@
#include "src/tint/ast/binary_expression.h" #include "src/tint/ast/binary_expression.h"
#include "src/tint/program_builder.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/atomic.h"
#include "src/tint/sem/evaluation_stage.h" #include "src/tint/sem/evaluation_stage.h"
#include "src/tint/sem/pipeline_stage_set.h" #include "src/tint/sem/pipeline_stage_set.h"
#include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_conversion.h"
#include "src/tint/sem/type_initializer.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_multisampled_texture.h"
#include "src/tint/type/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/type/external_texture.h" #include "src/tint/type/external_texture.h"
@ -352,22 +352,22 @@ bool match_bool(MatchState&, const type::Type* ty) {
return ty->IsAnyOf<Any, sem::Bool>(); return ty->IsAnyOf<Any, sem::Bool>();
} }
const sem::AbstractFloat* build_fa(MatchState& state) { const type::AbstractFloat* build_fa(MatchState& state) {
return state.builder.create<sem::AbstractFloat>(); return state.builder.create<type::AbstractFloat>();
} }
bool match_fa(MatchState& state, const type::Type* ty) { bool match_fa(MatchState& state, const type::Type* ty) {
return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) && 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) { const type::AbstractInt* build_ia(MatchState& state) {
return state.builder.create<sem::AbstractInt>(); return state.builder.create<type::AbstractInt>();
} }
bool match_ia(MatchState& state, const type::Type* ty) { bool match_ia(MatchState& state, const type::Type* ty) {
return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) && 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) { const sem::Bool* build_bool(MatchState& state) {
@ -379,7 +379,7 @@ const sem::F16* build_f16(MatchState& state) {
} }
bool match_f16(MatchState&, const type::Type* ty) { 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) { const sem::F32* build_f32(MatchState& state) {
@ -387,7 +387,7 @@ const sem::F32* build_f32(MatchState& state) {
} }
bool match_f32(MatchState&, const type::Type* ty) { 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) { const sem::I32* build_i32(MatchState& state) {
@ -395,7 +395,7 @@ const sem::I32* build_i32(MatchState& state) {
} }
bool match_i32(MatchState&, const type::Type* ty) { 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) { const sem::U32* build_u32(MatchState& state) {
@ -403,7 +403,7 @@ const sem::U32* build_u32(MatchState& state) {
} }
bool match_u32(MatchState&, const type::Type* ty) { 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) { bool match_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) {
@ -846,7 +846,7 @@ const sem::Struct* build_modf_result(MatchState& state, const type::Type* el) {
el, // el, //
[&](const sem::F32*) { return build_f32(); }, // [&](const sem::F32*) { return build_f32(); }, //
[&](const sem::F16*) { return build_f16(); }, // [&](const sem::F16*) { return build_f16(); }, //
[&](const sem::AbstractFloat*) { [&](const type::AbstractFloat*) {
auto* abstract = build_struct(state.builder, "__modf_result_abstract", auto* abstract = build_struct(state.builder, "__modf_result_abstract",
{{"fract", el}, {"whole", el}}); {{"fract", el}, {"whole", el}});
abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()}); abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()});
@ -874,7 +874,7 @@ const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const typ
el, // el, //
[&](const sem::F32*) { return build_f32(); }, // [&](const sem::F32*) { return build_f32(); }, //
[&](const sem::F16*) { return build_f16(); }, // [&](const sem::F16*) { return build_f16(); }, //
[&](const sem::AbstractFloat*) { [&](const type::AbstractFloat*) {
auto* vec = state.builder.create<sem::Vector>(el, n.Value()); auto* vec = state.builder.create<sem::Vector>(el, n.Value());
auto* abstract = auto* abstract =
build_struct(state.builder, prefix + "_abstract", {{"fract", vec}, {"whole", vec}}); build_struct(state.builder, prefix + "_abstract", {{"fract", vec}, {"whole", vec}});
@ -904,8 +904,8 @@ const sem::Struct* build_frexp_result(MatchState& state, const type::Type* el) {
el, // el, //
[&](const sem::F32*) { return build_f32(); }, // [&](const sem::F32*) { return build_f32(); }, //
[&](const sem::F16*) { return build_f16(); }, // [&](const sem::F16*) { return build_f16(); }, //
[&](const sem::AbstractFloat*) { [&](const type::AbstractFloat*) {
auto* i = state.builder.create<sem::AbstractInt>(); auto* i = state.builder.create<type::AbstractInt>();
auto* abstract = auto* abstract =
build_struct(state.builder, "__frexp_result_abstract", {{"fract", el}, {"exp", i}}); build_struct(state.builder, "__frexp_result_abstract", {{"fract", el}, {"exp", i}});
abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()}); abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()});
@ -935,9 +935,9 @@ const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const ty
el, // el, //
[&](const sem::F32*) { return build_f32(); }, // [&](const sem::F32*) { return build_f32(); }, //
[&](const sem::F16*) { return build_f16(); }, // [&](const sem::F16*) { return build_f16(); }, //
[&](const sem::AbstractFloat*) { [&](const type::AbstractFloat*) {
auto* f = state.builder.create<sem::Vector>(el, n.Value()); 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()); n.Value());
auto* abstract = auto* abstract =
build_struct(state.builder, prefix + "_abstract", {{"fract", f}, {"exp", e}}); build_struct(state.builder, prefix + "_abstract", {{"fract", f}, {"exp", e}});

View File

@ -529,7 +529,7 @@ TEST_F(IntrinsicTableTest, MismatchOpenSizeMatrix) {
} }
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
auto* af = create<sem::AbstractFloat>(); auto* af = create<type::AbstractFloat>();
auto* bool_ = create<sem::Bool>(); auto* bool_ = create<sem::Bool>();
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_}, auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});
@ -545,7 +545,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
} }
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) { 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, auto* bool_ref = create<sem::Reference>(create<sem::Bool>(), ast::AddressSpace::kFunction,
ast::Access::kReadWrite); ast::Access::kReadWrite);
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref}, auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref},
@ -562,7 +562,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
} }
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
auto* ai = create<sem::AbstractInt>(); auto* ai = create<type::AbstractInt>();
auto* u32 = create<sem::U32>(); auto* u32 = create<sem::U32>();
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kConstant, auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kConstant,
Source{}, false); Source{}, false);
@ -575,7 +575,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
} }
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) {
auto* ai = create<sem::AbstractInt>(); auto* ai = create<type::AbstractInt>();
auto* u32 = create<sem::U32>(); auto* u32 = create<sem::U32>();
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kRuntime, auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kRuntime,
Source{}, false); Source{}, false);
@ -712,7 +712,7 @@ TEST_F(IntrinsicTableTest, MismatchUnaryOp) {
} }
TEST_F(IntrinsicTableTest, MatchUnaryOp_Constant) { 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, auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kConstant,
Source{{12, 34}}); Source{{12, 34}});
EXPECT_EQ(result.result, ai); EXPECT_EQ(result.result, ai);
@ -720,7 +720,7 @@ TEST_F(IntrinsicTableTest, MatchUnaryOp_Constant) {
} }
TEST_F(IntrinsicTableTest, MatchUnaryOp_Runtime) { 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, auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kRuntime,
Source{{12, 34}}); Source{{12, 34}});
EXPECT_NE(result.result, ai); EXPECT_NE(result.result, ai);
@ -879,7 +879,7 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) {
} }
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) { TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) {
auto* ai = create<sem::AbstractInt>(); auto* ai = create<type::AbstractInt>();
auto* vec3_ai = create<sem::Vector>(ai, 3u); auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{vec3_ai}, auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{vec3_ai},
sem::EvaluationStage::kConstant, Source{{12, 34}}); sem::EvaluationStage::kConstant, Source{{12, 34}});
@ -892,8 +892,8 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) {
} }
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) { TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) {
auto* af = create<sem::AbstractFloat>(); auto* af = create<type::AbstractFloat>();
auto* vec2_ai = create<sem::Vector>(create<sem::AbstractInt>(), 2u); auto* vec2_ai = create<sem::Vector>(create<type::AbstractInt>(), 2u);
auto* vec2_af = create<sem::Vector>(af, 2u); auto* vec2_af = create<sem::Vector>(af, 2u);
auto* mat2x2_af = create<sem::Matrix>(vec2_af, 2u); auto* mat2x2_af = create<sem::Matrix>(vec2_af, 2u);
auto result = auto result =
@ -909,7 +909,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) {
} }
TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) { TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) {
auto* ai = create<sem::AbstractInt>(); auto* ai = create<type::AbstractInt>();
auto* vec3_ai = create<sem::Vector>(ai, 3u); auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai}, auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai},
sem::EvaluationStage::kConstant, Source{{12, 34}}); sem::EvaluationStage::kConstant, Source{{12, 34}});
@ -925,7 +925,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) {
} }
TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) { 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}, auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai},
sem::EvaluationStage::kRuntime, Source{{12, 34}}); sem::EvaluationStage::kRuntime, Source{{12, 34}});
auto* i32 = create<sem::I32>(); auto* i32 = create<sem::I32>();
@ -983,8 +983,8 @@ TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
} }
TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) { TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) {
auto* ai = create<sem::AbstractInt>(); auto* ai = create<type::AbstractInt>();
auto* af = create<sem::AbstractFloat>(); auto* af = create<type::AbstractFloat>();
auto* vec3_ai = create<sem::Vector>(ai, 3u); auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto* f32 = create<sem::F32>(); auto* f32 = create<sem::F32>();
auto* vec3_f32 = create<sem::Vector>(f32, 3u); auto* vec3_f32 = create<sem::Vector>(f32, 3u);
@ -1000,8 +1000,8 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) {
} }
TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) { TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) {
auto* ai = create<sem::AbstractInt>(); auto* ai = create<type::AbstractInt>();
auto* af = create<sem::AbstractFloat>(); auto* af = create<type::AbstractFloat>();
auto* vec3_ai = create<sem::Vector>(ai, 3u); auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto* vec3_f32 = create<sem::Vector>(create<sem::F32>(), 3u); auto* vec3_f32 = create<sem::Vector>(create<sem::F32>(), 3u);
auto* vec3_i32 = create<sem::Vector>(create<sem::I32>(), 3u); auto* vec3_i32 = create<sem::Vector>(create<sem::I32>(), 3u);
@ -1030,7 +1030,7 @@ TEST_F(IntrinsicTableTest, OverloadResolution) {
// ctor i32(i32) -> i32 // ctor i32(i32) -> i32
// conv i32<T: scalar_no_i32>(T) -> i32 // conv i32<T: scalar_no_i32>(T) -> i32
// The first should win overload resolution. // The first should win overload resolution.
auto* ai = create<sem::AbstractInt>(); auto* ai = create<type::AbstractInt>();
auto* i32 = create<sem::I32>(); auto* i32 = create<sem::I32>();
auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai}, auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai},
sem::EvaluationStage::kConstant, Source{}); sem::EvaluationStage::kConstant, Source{});

View File

@ -1257,7 +1257,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_DefaultType) {
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F32>()); ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F32>());
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>()); ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
auto* abstract_str = materialize->Expr()->Type()->As<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) { TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) {
@ -1276,7 +1276,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) {
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>(); 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()->Is<sem::Vector>());
ASSERT_TRUE( 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) { TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) {
@ -1295,7 +1295,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) {
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F16>()); ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F16>());
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>()); ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
auto* abstract_str = materialize->Expr()->Type()->As<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) { TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) {
@ -1317,7 +1317,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) {
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>(); 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()->Is<sem::Vector>());
ASSERT_TRUE( 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) { TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) {
@ -1334,8 +1334,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) {
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>()); ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>());
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>()); ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
auto* abstract_str = materialize->Expr()->Type()->As<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>());
ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<sem::AbstractInt>()); ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<type::AbstractInt>());
} }
TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) { TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) {
@ -1356,9 +1356,9 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) {
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>(); 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()->Is<sem::Vector>());
ASSERT_TRUE( 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( 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) { TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) {
@ -1378,8 +1378,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) {
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>()); ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>());
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>()); ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
auto* abstract_str = materialize->Expr()->Type()->As<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>());
ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<sem::AbstractInt>()); ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<type::AbstractInt>());
} }
TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) { TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) {
@ -1403,9 +1403,9 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) {
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>(); 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()->Is<sem::Vector>());
ASSERT_TRUE( 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( 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 } // namespace materialize_abstract_structure

View File

@ -53,8 +53,6 @@
#include "src/tint/ast/workgroup_attribute.h" #include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/resolver/type_alias.h" #include "src/tint/resolver/type_alias.h"
#include "src/tint/resolver/uniformity.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/array.h"
#include "src/tint/sem/atomic.h" #include "src/tint/sem/atomic.h"
#include "src/tint/sem/break_if_statement.h" #include "src/tint/sem/break_if_statement.h"
@ -76,6 +74,8 @@
#include "src/tint/sem/type_initializer.h" #include "src/tint/sem/type_initializer.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/sem/while_statement.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_multisampled_texture.h"
#include "src/tint/type/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/type/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
@ -1155,7 +1155,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) {
return false; return false;
} }
auto* ty = expr->Type(); 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); AddError(kErrBadExpr, value->source);
return false; return false;
} }
@ -1178,7 +1178,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) {
} }
// If all arguments are abstract-integers, then materialize to i32. // 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>(); common_ty = builder_->create<sem::I32>();
} }
@ -1726,19 +1726,19 @@ const type::Type* Resolver::ConcreteType(const type::Type* ty,
return Switch( return Switch(
ty, // ty, //
[&](const sem::AbstractInt*) { return target_ty ? target_ty : i32(); }, [&](const type::AbstractInt*) { return target_ty ? target_ty : i32(); },
[&](const sem::AbstractFloat*) { return target_ty ? target_ty : f32(); }, [&](const type::AbstractFloat*) { return target_ty ? target_ty : f32(); },
[&](const sem::Vector* v) { [&](const sem::Vector* v) {
return Switch( return Switch(
v->type(), // v->type(), //
[&](const sem::AbstractInt*) { return target_ty ? target_ty : i32v(v->Width()); }, [&](const type::AbstractInt*) { return target_ty ? target_ty : i32v(v->Width()); },
[&](const sem::AbstractFloat*) { [&](const type::AbstractFloat*) {
return target_ty ? target_ty : f32v(v->Width()); return target_ty ? target_ty : f32v(v->Width());
}); });
}, },
[&](const sem::Matrix* m) { [&](const sem::Matrix* m) {
return Switch(m->type(), // return Switch(m->type(), //
[&](const sem::AbstractFloat*) { [&](const type::AbstractFloat*) {
return target_ty ? target_ty : f32m(m->columns(), m->rows()); return target_ty ? target_ty : f32m(m->columns(), m->rows());
}); });
}, },
@ -1823,7 +1823,7 @@ bool Resolver::MaybeMaterializeArguments(utils::Vector<const sem::Expression*, N
bool Resolver::ShouldMaterializeArgument(const type::Type* parameter_ty) const { bool Resolver::ShouldMaterializeArgument(const type::Type* parameter_ty) const {
const auto* param_el_ty = type::Type::DeepestElementOf(parameter_ty); 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) { bool Resolver::Convert(const sem::Constant*& c, const type::Type* target_ty, const Source& source) {
@ -2483,7 +2483,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
[&](const ast::IntLiteralExpression* i) -> type::Type* { [&](const ast::IntLiteralExpression* i) -> type::Type* {
switch (i->suffix) { switch (i->suffix) {
case ast::IntLiteralExpression::Suffix::kNone: case ast::IntLiteralExpression::Suffix::kNone:
return builder_->create<sem::AbstractInt>(); return builder_->create<type::AbstractInt>();
case ast::IntLiteralExpression::Suffix::kI: case ast::IntLiteralExpression::Suffix::kI:
return builder_->create<sem::I32>(); return builder_->create<sem::I32>();
case ast::IntLiteralExpression::Suffix::kU: case ast::IntLiteralExpression::Suffix::kU:
@ -2494,7 +2494,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
[&](const ast::FloatLiteralExpression* f) -> type::Type* { [&](const ast::FloatLiteralExpression* f) -> type::Type* {
switch (f->suffix) { switch (f->suffix) {
case ast::FloatLiteralExpression::Suffix::kNone: case ast::FloatLiteralExpression::Suffix::kNone:
return builder_->create<sem::AbstractFloat>(); return builder_->create<type::AbstractFloat>();
case ast::FloatLiteralExpression::Suffix::kF: case ast::FloatLiteralExpression::Suffix::kF:
return builder_->create<sem::F32>(); return builder_->create<sem::F32>();
case ast::FloatLiteralExpression::Suffix::kH: case ast::FloatLiteralExpression::Suffix::kH:

View File

@ -26,12 +26,12 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/resolver/resolver.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/expression.h"
#include "src/tint/sem/statement.h" #include "src/tint/sem/statement.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/traits.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" #include "src/tint/utils/vector.h"
namespace tint::resolver { namespace tint::resolver {
@ -387,7 +387,7 @@ struct DataType<AFloat> {
/// @param b the ProgramBuilder /// @param b the ProgramBuilder
/// @return the semantic abstract-float type /// @return the semantic abstract-float type
static inline const type::Type* Sem(ProgramBuilder& b) { static inline const type::Type* Sem(ProgramBuilder& b) {
return b.create<sem::AbstractFloat>(); return b.create<type::AbstractFloat>();
} }
/// @param b the ProgramBuilder /// @param b the ProgramBuilder
/// @param args args of size 1 with the abstract-float value to init with /// @param args args of size 1 with the abstract-float value to init with
@ -418,7 +418,7 @@ struct DataType<AInt> {
static inline const ast::Type* AST(ProgramBuilder&) { return nullptr; } static inline const ast::Type* AST(ProgramBuilder&) { return nullptr; }
/// @param b the ProgramBuilder /// @param b the ProgramBuilder
/// @return the semantic abstract-int type /// @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 b the ProgramBuilder
/// @param args args of size 1 with the abstract-int value to init with /// @param args args of size 1 with the abstract-int value to init with
/// @return a new AST abstract-int literal value expression /// @return a new AST abstract-int literal value expression

View File

@ -610,9 +610,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_AIAIAI) {
ASSERT_NE(ctor, nullptr); ASSERT_NE(ctor, nullptr);
EXPECT_EQ(call->Type(), ctor->ReturnType()); EXPECT_EQ(call->Type(), ctor->ReturnType());
ASSERT_EQ(ctor->Parameters().Length(), 3u); ASSERT_EQ(ctor->Parameters().Length(), 3u);
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::AbstractInt>()); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::AbstractInt>());
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::AbstractInt>()); EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::AbstractInt>());
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::AbstractInt>()); EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::AbstractInt>());
} }
TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) { TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) {

View File

@ -47,7 +47,6 @@
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/ast/vector.h" #include "src/tint/ast/vector.h"
#include "src/tint/ast/workgroup_attribute.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/array.h"
#include "src/tint/sem/atomic.h" #include "src/tint/sem/atomic.h"
#include "src/tint/sem/break_if_statement.h" #include "src/tint/sem/break_if_statement.h"
@ -67,6 +66,7 @@
#include "src/tint/sem/type_initializer.h" #include "src/tint/sem/type_initializer.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/sem/while_statement.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_multisampled_texture.h"
#include "src/tint/type/depth_texture.h" #include "src/tint/type/depth_texture.h"
#include "src/tint/type/multisampled_texture.h" #include "src/tint/type/multisampled_texture.h"
@ -2228,7 +2228,7 @@ bool Validator::SwitchStatement(const ast::SwitchStatement* s) {
auto value = selector->Value()->As<uint32_t>(); auto value = selector->Value()->As<uint32_t>();
if (auto added = selectors.Add(value, selector->Declaration()->source); !added) { if (auto added = selectors.Add(value, selector->Declaration()->source); !added) {
AddError("duplicate switch case '" + 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(i32(value))
: std::to_string(value)) + : std::to_string(value)) +
"'", "'",
@ -2266,7 +2266,7 @@ bool Validator::Assignment(const ast::Statement* a, const type::Type* rhs_ty) co
// https://www.w3.org/TR/WGSL/#phony-assignment-section // https://www.w3.org/TR/WGSL/#phony-assignment-section
auto* ty = rhs_ty->UnwrapRef(); auto* ty = rhs_ty->UnwrapRef();
if (!ty->IsConstructible() && 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) + AddError("cannot assign '" + sem_.TypeNameOf(rhs_ty) +
"' to '_'. '_' can only be assigned a constructible, pointer, texture or " "' to '_'. '_' can only be assigned a constructible, pointer, texture or "
"sampler type", "sampler type",

View File

@ -974,8 +974,8 @@ TEST_F(ResolverVariableTest, LocalConst_ImplicitType_Decls) {
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>()); ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>()); ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>()); ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
ASSERT_TRUE(TypeOf(c_ai)->Is<sem::AbstractInt>()); ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
ASSERT_TRUE(TypeOf(c_af)->Is<sem::AbstractFloat>()); ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>()); ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>()); ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>()); ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
@ -1145,8 +1145,8 @@ TEST_F(ResolverVariableTest, GlobalConst_ImplicitType_Decls) {
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>()); ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>()); ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>()); ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
ASSERT_TRUE(TypeOf(c_ai)->Is<sem::AbstractInt>()); ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
ASSERT_TRUE(TypeOf(c_af)->Is<sem::AbstractFloat>()); ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>()); ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>()); ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>()); ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());

View File

@ -236,11 +236,11 @@
<!-- sem --> <!-- sem -->
<!--=================================================================--> <!--=================================================================-->
<Type Name="tint::sem::AbstractInt"> <Type Name="tint::type::AbstractInt">
<DisplayString>AbstractInt</DisplayString> <DisplayString>AbstractInt</DisplayString>
</Type> </Type>
<Type Name="tint::sem::AbstractFloat"> <Type Name="tint::type::AbstractFloat">
<DisplayString>AbstractFloat</DisplayString> <DisplayString>AbstractFloat</DisplayString>
</Type> </Type>

View File

@ -20,7 +20,6 @@
#include "src/tint/ast/traverse_expressions.h" #include "src/tint/ast/traverse_expressions.h"
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/sem/abstract_int.h"
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/function.h" #include "src/tint/sem/function.h"
#include "src/tint/sem/index_accessor_expression.h" #include "src/tint/sem/index_accessor_expression.h"
@ -30,6 +29,7 @@
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/variable.h" #include "src/tint/sem/variable.h"
#include "src/tint/transform/utils/hoist_to_decl_before.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/reverse.h"
#include "src/tint/utils/scoped_assignment.h" #include "src/tint/utils/scoped_assignment.h"
@ -573,7 +573,7 @@ struct DirectVariableAccess::State {
if (!idx->UnwrapMaterialize() if (!idx->UnwrapMaterialize()
->Type() ->Type()
->UnwrapRef() ->UnwrapRef()
->IsAnyOf<sem::U32, sem::AbstractInt>()) { ->IsAnyOf<sem::U32, type::AbstractInt>()) {
expr = b.Construct(b.ty.u32(), expr); expr = b.Construct(b.ty.u32(), expr);
} }
} }

View File

@ -19,10 +19,10 @@
#include <utility> #include <utility>
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/sem/abstract_numeric.h"
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/expression.h" #include "src/tint/sem/expression.h"
#include "src/tint/sem/type_conversion.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/hash.h"
#include "src/tint/utils/map.h" #include "src/tint/utils/map.h"

View File

@ -18,10 +18,10 @@
#include <utility> #include <utility>
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/sem/abstract_numeric.h"
#include "src/tint/sem/call.h" #include "src/tint/sem/call.h"
#include "src/tint/sem/expression.h" #include "src/tint/sem/expression.h"
#include "src/tint/sem/type_initializer.h" #include "src/tint/sem/type_initializer.h"
#include "src/tint/type/abstract_numeric.h"
#include "src/tint/utils/map.h" #include "src/tint/utils/map.h"
TINT_INSTANTIATE_TYPEINFO(tint::transform::VectorizeScalarMatrixInitializers); TINT_INSTANTIATE_TYPEINFO(tint::transform::VectorizeScalarMatrixInitializers);
@ -84,7 +84,7 @@ Transform::ApplyResult VectorizeScalarMatrixInitializers::Apply(const Program* s
if (args[0] if (args[0]
->Type() ->Type()
->UnwrapRef() ->UnwrapRef()
->IsAnyOf<sem::Matrix, sem::Vector, sem::AbstractNumeric>()) { ->IsAnyOf<sem::Matrix, sem::Vector, type::AbstractNumeric>()) {
return nullptr; return nullptr;
} }

View File

@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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/program_builder.h"
#include "src/tint/utils/hash.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() = default;
AbstractFloat::AbstractFloat(AbstractFloat&&) = default; AbstractFloat::AbstractFloat(AbstractFloat&&) = default;
@ -37,4 +37,4 @@ std::string AbstractFloat::FriendlyName(const SymbolTable&) const {
return "abstract-float"; return "abstract-float";
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_ABSTRACT_FLOAT_H_ #ifndef SRC_TINT_TYPE_ABSTRACT_FLOAT_H_
#define SRC_TINT_SEM_ABSTRACT_FLOAT_H_ #define SRC_TINT_TYPE_ABSTRACT_FLOAT_H_
#include <string> #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. /// An abstract-float type.
/// @see https://www.w3.org/TR/WGSL/#abstractFloat /// @see https://www.w3.org/TR/WGSL/#abstractFloat
@ -44,6 +44,6 @@ class AbstractFloat final : public Castable<AbstractFloat, AbstractNumeric> {
std::string FriendlyName(const SymbolTable& symbols) const override; 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_

View File

@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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/program_builder.h"
#include "src/tint/utils/hash.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() = default;
AbstractInt::AbstractInt(AbstractInt&&) = default; AbstractInt::AbstractInt(AbstractInt&&) = default;
@ -37,4 +37,4 @@ std::string AbstractInt::FriendlyName(const SymbolTable&) const {
return "abstract-int"; return "abstract-int";
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_ABSTRACT_INT_H_ #ifndef SRC_TINT_TYPE_ABSTRACT_INT_H_
#define SRC_TINT_SEM_ABSTRACT_INT_H_ #define SRC_TINT_TYPE_ABSTRACT_INT_H_
#include <string> #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. /// An abstract-int type.
/// @see https://www.w3.org/TR/WGSL/#abstractint /// @see https://www.w3.org/TR/WGSL/#abstractint
@ -44,6 +44,6 @@ class AbstractInt final : public Castable<AbstractInt, AbstractNumeric> {
std::string FriendlyName(const SymbolTable& symbols) const override; 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_

View File

@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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() AbstractNumeric::AbstractNumeric()
: Base(type::TypeFlags{ : Base(type::TypeFlags{
@ -35,4 +35,4 @@ uint32_t AbstractNumeric::Align() const {
return 0; return 0;
} }
} // namespace tint::sem } // namespace tint::type

View File

@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TINT_SEM_ABSTRACT_NUMERIC_H_ #ifndef SRC_TINT_TYPE_ABSTRACT_NUMERIC_H_
#define SRC_TINT_SEM_ABSTRACT_NUMERIC_H_ #define SRC_TINT_TYPE_ABSTRACT_NUMERIC_H_
#include <string> #include <string>
#include "src/tint/type/type.h" #include "src/tint/type/type.h"
namespace tint::sem { namespace tint::type {
/// The base class for abstract-int and abstract-float types. /// The base class for abstract-int and abstract-float types.
/// @see https://www.w3.org/TR/WGSL/#types-for-creation-time-constants /// @see https://www.w3.org/TR/WGSL/#types-for-creation-time-constants
@ -39,6 +39,6 @@ class AbstractNumeric : public Castable<AbstractNumeric, type::Type> {
uint32_t Align() const override; 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_

View File

@ -14,8 +14,6 @@
#include "src/tint/type/type.h" #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/array.h"
#include "src/tint/sem/bool.h" #include "src/tint/sem/bool.h"
#include "src/tint/sem/f16.h" #include "src/tint/sem/f16.h"
@ -27,6 +25,8 @@
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
#include "src/tint/sem/u32.h" #include "src/tint/sem/u32.h"
#include "src/tint/sem/vector.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/sampler.h"
#include "src/tint/type/texture.h" #include "src/tint/type/texture.h"
@ -69,15 +69,15 @@ uint32_t Type::Align() const {
} }
bool Type::is_scalar() const { 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 { 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 { 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 { bool Type::is_float_matrix() const {
@ -107,7 +107,7 @@ bool Type::is_integer_scalar() const {
} }
bool Type::is_signed_integer_scalar() const { 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 { bool Type::is_unsigned_integer_scalar() const {
@ -116,7 +116,7 @@ bool Type::is_unsigned_integer_scalar() const {
bool Type::is_signed_integer_vector() const { bool Type::is_signed_integer_vector() const {
return Is( 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 { bool Type::is_unsigned_integer_vector() const {
@ -128,7 +128,7 @@ bool Type::is_unsigned_integer_scalar_or_vector() const {
} }
bool Type::is_signed_integer_scalar_or_vector() const { 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 { bool Type::is_integer_scalar_or_vector() const {
@ -136,19 +136,19 @@ bool Type::is_integer_scalar_or_vector() const {
} }
bool Type::is_abstract_integer_vector() const { 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 { 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 { 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 { 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 { bool Type::is_bool_vector() const {
@ -178,7 +178,7 @@ bool Type::is_handle() const {
bool Type::HoldsAbstract() const { bool Type::HoldsAbstract() const {
return Switch( return Switch(
this, // this, //
[&](const sem::AbstractNumeric*) { return true; }, [&](const type::AbstractNumeric*) { return true; },
[&](const sem::Vector* v) { return v->type()->HoldsAbstract(); }, [&](const sem::Vector* v) { return v->type()->HoldsAbstract(); },
[&](const sem::Matrix* m) { return m->type()->HoldsAbstract(); }, [&](const sem::Matrix* m) { return m->type()->HoldsAbstract(); },
[&](const sem::Array* a) { return a->ElemType()->HoldsAbstract(); }, [&](const sem::Array* a) { return a->ElemType()->HoldsAbstract(); },
@ -198,21 +198,21 @@ uint32_t Type::ConversionRank(const Type* from, const Type* to) {
} }
return Switch( return Switch(
from, from,
[&](const sem::AbstractFloat*) { [&](const type::AbstractFloat*) {
return Switch( return Switch(
to, // to, //
[&](const sem::F32*) { return 1; }, // [&](const sem::F32*) { return 1; }, //
[&](const sem::F16*) { return 2; }, // [&](const sem::F16*) { return 2; }, //
[&](Default) { return kNoConversion; }); [&](Default) { return kNoConversion; });
}, },
[&](const sem::AbstractInt*) { [&](const type::AbstractInt*) {
return Switch( return Switch(
to, // to, //
[&](const sem::I32*) { return 3; }, // [&](const sem::I32*) { return 3; }, //
[&](const sem::U32*) { return 4; }, // [&](const sem::U32*) { return 4; }, //
[&](const sem::AbstractFloat*) { return 5; }, // [&](const type::AbstractFloat*) { return 5; }, //
[&](const sem::F32*) { return 6; }, // [&](const sem::F32*) { return 6; }, //
[&](const sem::F16*) { return 7; }, // [&](const sem::F16*) { return 7; }, //
[&](Default) { return kNoConversion; }); [&](Default) { return kNoConversion; });
}, },
[&](const sem::Vector* from_vec) { [&](const sem::Vector* from_vec) {

View File

@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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/f16.h"
#include "src/tint/sem/reference.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/array_count.h"
#include "src/tint/type/test_helper.h" #include "src/tint/type/test_helper.h"
@ -23,8 +23,8 @@ namespace tint::type {
namespace { namespace {
struct TypeTest : public TestHelper { struct TypeTest : public TestHelper {
const sem::AbstractFloat* af = create<sem::AbstractFloat>(); const type::AbstractFloat* af = create<type::AbstractFloat>();
const sem::AbstractInt* ai = create<sem::AbstractInt>(); const type::AbstractInt* ai = create<type::AbstractInt>();
const sem::F32* f32 = create<sem::F32>(); const sem::F32* f32 = create<sem::F32>();
const sem::F16* f16 = create<sem::F16>(); const sem::F16* f16 = create<sem::F16>();
const sem::I32* i32 = create<sem::I32>(); const sem::I32* i32 = create<sem::I32>();