diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 7c29387cfa..98d0c846f7 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -415,9 +415,6 @@ libtint_source_set("libtint_core_all_src") { "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 @@ libtint_source_set("libtint_core_all_src") { "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_core_all_src") { 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_sem_src") { 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 6a38e9e484..9decb9924b 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -291,12 +291,6 @@ list(APPEND TINT_LIB_SRCS 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 @@ list(APPEND TINT_LIB_SRCS 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 499a23f3a7..3420e45675 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 #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 14841fe9d0..c94e8983ea 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -23,8 +23,6 @@ #include #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 @@ template auto Dispatch_ia_iu32(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // - [&](const sem::AbstractInt*) { return f(cs->template As()...); }, + [&](const type::AbstractInt*) { return f(cs->template As()...); }, [&](const sem::I32*) { return f(cs->template As()...); }, [&](const sem::U32*) { return f(cs->template As()...); }); } @@ -80,7 +80,7 @@ template auto Dispatch_ia_iu32_bool(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // - [&](const sem::AbstractInt*) { return f(cs->template As()...); }, + [&](const type::AbstractInt*) { return f(cs->template As()...); }, [&](const sem::I32*) { return f(cs->template As()...); }, [&](const sem::U32*) { return f(cs->template As()...); }, [&](const sem::Bool*) { return f(cs->template As()...); }); @@ -92,8 +92,8 @@ template auto Dispatch_fia_fi32_f16(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // - [&](const sem::AbstractInt*) { return f(cs->template As()...); }, - [&](const sem::AbstractFloat*) { return f(cs->template As()...); }, + [&](const type::AbstractInt*) { return f(cs->template As()...); }, + [&](const type::AbstractFloat*) { return f(cs->template As()...); }, [&](const sem::F32*) { return f(cs->template As()...); }, [&](const sem::I32*) { return f(cs->template As()...); }, [&](const sem::F16*) { return f(cs->template As()...); }); @@ -105,8 +105,8 @@ template auto Dispatch_fia_fiu32_f16(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // - [&](const sem::AbstractInt*) { return f(cs->template As()...); }, - [&](const sem::AbstractFloat*) { return f(cs->template As()...); }, + [&](const type::AbstractInt*) { return f(cs->template As()...); }, + [&](const type::AbstractFloat*) { return f(cs->template As()...); }, [&](const sem::F32*) { return f(cs->template As()...); }, [&](const sem::I32*) { return f(cs->template As()...); }, [&](const sem::U32*) { return f(cs->template As()...); }, @@ -119,8 +119,8 @@ template auto Dispatch_fia_fiu32_f16_bool(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // - [&](const sem::AbstractInt*) { return f(cs->template As()...); }, - [&](const sem::AbstractFloat*) { return f(cs->template As()...); }, + [&](const type::AbstractInt*) { return f(cs->template As()...); }, + [&](const type::AbstractFloat*) { return f(cs->template As()...); }, [&](const sem::F32*) { return f(cs->template As()...); }, [&](const sem::I32*) { return f(cs->template As()...); }, [&](const sem::U32*) { return f(cs->template As()...); }, @@ -134,7 +134,7 @@ template auto Dispatch_fa_f32_f16(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // - [&](const sem::AbstractFloat*) { return f(cs->template As()...); }, + [&](const type::AbstractFloat*) { return f(cs->template As()...); }, [&](const sem::F32*) { return f(cs->template As()...); }, [&](const sem::F16*) { return f(cs->template As()...); }); } @@ -156,13 +156,13 @@ auto Dispatch_bool(F&& f, CONSTANTS&&... cs) { template 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(0)); }); } @@ -2659,11 +2659,11 @@ ConstEval::Result ConstEval::frexp(const type::Type* ty, CreateElement(builder, source, builder.create(), i32(exp)), }; }, - [&](const sem::AbstractFloat*) { + [&](const type::AbstractFloat*) { return FractExp{ - CreateElement(builder, source, builder.create(), + CreateElement(builder, source, builder.create(), AFloat(fract)), - CreateElement(builder, source, builder.create(), AInt(exp)), + CreateElement(builder, source, builder.create(), 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 e5a19ff353..9753ceb656 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 @@ TEST_F(ResolverConstEvalTest, BinaryAbstractShiftLeftRemainsAbstract) { auto* sem2 = Sem().Get(expr2); ASSERT_NE(sem2, nullptr); - auto aint_ty = create(); + auto aint_ty = create(); 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 2c5b15cc70..4f3245e9ae 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 @@ TEST_F(ResolverConstEvalTest, Matrix_AFloat_Construct_From_AInt_Vectors) { auto* cv = sem->ConstantValue(); EXPECT_TYPE(cv->Type(), sem->Type()); EXPECT_TRUE(cv->Index(0)->Type()->Is()); - EXPECT_TRUE(cv->Index(0)->Index(0)->Type()->Is()); + EXPECT_TRUE(cv->Index(0)->Index(0)->Type()->Is()); 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 27b5e54787..2b365883dd 100644 --- a/src/tint/resolver/const_eval_test.h +++ b/src/tint/resolver/const_eval_test.h @@ -41,8 +41,8 @@ template inline void CollectScalars(const sem::Constant* c, utils::Vector& scalars) { Switch( c->Type(), // - [&](const sem::AbstractInt*) { scalars.Push(c->As()); }, - [&](const sem::AbstractFloat*) { scalars.Push(c->As()); }, + [&](const type::AbstractInt*) { scalars.Push(c->As()); }, + [&](const type::AbstractFloat*) { scalars.Push(c->As()); }, [&](const sem::Bool*) { scalars.Push(c->As()); }, [&](const sem::I32*) { scalars.Push(c->As()); }, [&](const sem::U32*) { scalars.Push(c->As()); }, diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 83d355c515..6c70f66436 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 @@ bool match_bool(MatchState&, const type::Type* ty) { return ty->IsAnyOf(); } -const sem::AbstractFloat* build_fa(MatchState& state) { - return state.builder.create(); +const type::AbstractFloat* build_fa(MatchState& state) { + return state.builder.create(); } bool match_fa(MatchState& state, const type::Type* ty) { return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) && - ty->IsAnyOf(); + ty->IsAnyOf(); } -const sem::AbstractInt* build_ia(MatchState& state) { - return state.builder.create(); +const type::AbstractInt* build_ia(MatchState& state) { + return state.builder.create(); } bool match_ia(MatchState& state, const type::Type* ty) { return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) && - ty->IsAnyOf(); + ty->IsAnyOf(); } 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) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } 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) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } 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) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } 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) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } 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, // [&](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 @@ const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const typ el, // [&](const sem::F32*) { return build_f32(); }, // [&](const sem::F16*) { return build_f16(); }, // - [&](const sem::AbstractFloat*) { + [&](const type::AbstractFloat*) { auto* vec = state.builder.create(el, n.Value()); auto* abstract = 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, // [&](const sem::F32*) { return build_f32(); }, // [&](const sem::F16*) { return build_f16(); }, // - [&](const sem::AbstractFloat*) { - auto* i = state.builder.create(); + [&](const type::AbstractFloat*) { + auto* i = state.builder.create(); 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 @@ const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const ty el, // [&](const sem::F32*) { return build_f32(); }, // [&](const sem::F16*) { return build_f16(); }, // - [&](const sem::AbstractFloat*) { + [&](const type::AbstractFloat*) { auto* f = state.builder.create(el, n.Value()); - auto* e = state.builder.create(state.builder.create(), + auto* e = state.builder.create(state.builder.create(), 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 8ce477facb..3cdf65f035 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -529,7 +529,7 @@ TEST_F(IntrinsicTableTest, MismatchOpenSizeMatrix) { } TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) { - auto* af = create(); + auto* af = create(); auto* bool_ = create(); auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_}, sem::EvaluationStage::kConstant, Source{}); @@ -545,7 +545,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) { } TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) { - auto* af = create(); + auto* af = create(); auto* bool_ref = create(create(), 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_Builtin_RuntimeEval) { } TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) { - auto* ai = create(); + auto* ai = create(); auto* u32 = create(); auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kConstant, Source{}, false); @@ -575,7 +575,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) { } TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) { - auto* ai = create(); + auto* ai = create(); auto* u32 = create(); auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kRuntime, Source{}, false); @@ -712,7 +712,7 @@ TEST_F(IntrinsicTableTest, MismatchUnaryOp) { } TEST_F(IntrinsicTableTest, MatchUnaryOp_Constant) { - auto* ai = create(); + auto* ai = create(); 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_Constant) { } TEST_F(IntrinsicTableTest, MatchUnaryOp_Runtime) { - auto* ai = create(); + auto* ai = create(); 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, MismatchTypeInitializerExplicit) { } TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) { - auto* ai = create(); + auto* ai = create(); auto* vec3_ai = create(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, MatchTypeInitializerImplicitVecFromVecAbstract) { } TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) { - auto* af = create(); - auto* vec2_ai = create(create(), 2u); + auto* af = create(); + auto* vec2_ai = create(create(), 2u); auto* vec2_af = create(af, 2u); auto* mat2x2_af = create(vec2_af, 2u); auto result = @@ -909,7 +909,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) { } TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) { - auto* ai = create(); + auto* ai = create(); auto* vec3_ai = create(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_ConstantEval) { } TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) { - auto* ai = create(); + auto* ai = create(); auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai}, sem::EvaluationStage::kRuntime, Source{{12, 34}}); auto* i32 = create(); @@ -983,8 +983,8 @@ TEST_F(IntrinsicTableTest, MismatchTypeConversion) { } TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) { - auto* ai = create(); - auto* af = create(); + auto* ai = create(); + auto* af = create(); auto* vec3_ai = create(ai, 3u); auto* f32 = create(); auto* vec3_f32 = create(f32, 3u); @@ -1000,8 +1000,8 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) { } TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) { - auto* ai = create(); - auto* af = create(); + auto* ai = create(); + auto* af = create(); auto* vec3_ai = create(ai, 3u); auto* vec3_f32 = create(create(), 3u); auto* vec3_i32 = create(create(), 3u); @@ -1030,7 +1030,7 @@ TEST_F(IntrinsicTableTest, OverloadResolution) { // ctor i32(i32) -> i32 // conv i32(T) -> i32 // The first should win overload resolution. - auto* ai = create(); + auto* ai = create(); auto* i32 = create(); 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 24d9999e15..d94256097a 100644 --- a/src/tint/resolver/materialize_test.cc +++ b/src/tint/resolver/materialize_test.cc @@ -1257,7 +1257,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_DefaultType) { ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); - ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); } TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) { @@ -1276,7 +1276,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) { auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); ASSERT_TRUE( - abstract_str->Members()[0]->Type()->As()->type()->Is()); + abstract_str->Members()[0]->Type()->As()->type()->Is()); } TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) { @@ -1295,7 +1295,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) { ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); - ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); } TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) { @@ -1317,7 +1317,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) { auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); ASSERT_TRUE( - abstract_str->Members()[0]->Type()->As()->type()->Is()); + abstract_str->Members()[0]->Type()->As()->type()->Is()); } TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) { @@ -1334,8 +1334,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) { ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); - ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); - ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is()); + ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is()); } TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) { @@ -1356,9 +1356,9 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) { auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); ASSERT_TRUE( - abstract_str->Members()[0]->Type()->As()->type()->Is()); + abstract_str->Members()[0]->Type()->As()->type()->Is()); ASSERT_TRUE( - abstract_str->Members()[1]->Type()->As()->type()->Is()); + abstract_str->Members()[1]->Type()->As()->type()->Is()); } TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) { @@ -1378,8 +1378,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) { ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); - ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); - ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is()); + ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is()); } TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) { @@ -1403,9 +1403,9 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) { auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); ASSERT_TRUE( - abstract_str->Members()[0]->Type()->As()->type()->Is()); + abstract_str->Members()[0]->Type()->As()->type()->Is()); ASSERT_TRUE( - abstract_str->Members()[1]->Type()->As()->type()->Is()); + abstract_str->Members()[1]->Type()->As()->type()->Is()); } } // namespace materialize_abstract_structure diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index a7d43dbf3b..18a6f59b26 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 @@ bool Resolver::WorkgroupSize(const ast::Function* func) { return false; } auto* ty = expr->Type(); - if (!ty->IsAnyOf()) { + if (!ty->IsAnyOf()) { AddError(kErrBadExpr, value->source); return false; } @@ -1178,7 +1178,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) { } // If all arguments are abstract-integers, then materialize to i32. - if (common_ty->Is()) { + if (common_ty->Is()) { common_ty = builder_->create(); } @@ -1726,19 +1726,19 @@ const type::Type* Resolver::ConcreteType(const type::Type* ty, 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::MaybeMaterializeArguments(utils::VectorIs(); + return param_el_ty && !param_el_ty->Is(); } 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* { switch (i->suffix) { case ast::IntLiteralExpression::Suffix::kNone: - return builder_->create(); + return builder_->create(); case ast::IntLiteralExpression::Suffix::kI: return builder_->create(); case ast::IntLiteralExpression::Suffix::kU: @@ -2494,7 +2494,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) { [&](const ast::FloatLiteralExpression* f) -> type::Type* { switch (f->suffix) { case ast::FloatLiteralExpression::Suffix::kNone: - return builder_->create(); + return builder_->create(); case ast::FloatLiteralExpression::Suffix::kF: return builder_->create(); case ast::FloatLiteralExpression::Suffix::kH: diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h index f47719f263..1186fa1393 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 @@ struct DataType { /// @param b the ProgramBuilder /// @return the semantic abstract-float type static inline const type::Type* Sem(ProgramBuilder& b) { - return b.create(); + return b.create(); } /// @param b the ProgramBuilder /// @param args args of size 1 with the abstract-float value to init with @@ -418,7 +418,7 @@ struct DataType { 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(); } + static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } /// @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 61f9a589a2..437f28f90f 100644 --- a/src/tint/resolver/type_initializer_validation_test.cc +++ b/src/tint/resolver/type_initializer_validation_test.cc @@ -610,9 +610,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_AIAIAI) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) { diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index ac3489c68c..1740a069f3 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 @@ bool Validator::SwitchStatement(const ast::SwitchStatement* s) { auto value = selector->Value()->As(); if (auto added = selectors.Add(value, selector->Declaration()->source); !added) { AddError("duplicate switch case '" + - (decl_ty->IsAnyOf() + (decl_ty->IsAnyOf() ? std::to_string(i32(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 auto* ty = rhs_ty->UnwrapRef(); if (!ty->IsConstructible() && - !ty->IsAnyOf()) { + !ty->IsAnyOf()) { 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 acdadf937a..68f4bc2cfb 100644 --- a/src/tint/resolver/variable_test.cc +++ b/src/tint/resolver/variable_test.cc @@ -974,8 +974,8 @@ TEST_F(ResolverVariableTest, LocalConst_ImplicitType_Decls) { ASSERT_TRUE(TypeOf(c_i32)->Is()); ASSERT_TRUE(TypeOf(c_u32)->Is()); ASSERT_TRUE(TypeOf(c_f32)->Is()); - ASSERT_TRUE(TypeOf(c_ai)->Is()); - ASSERT_TRUE(TypeOf(c_af)->Is()); + ASSERT_TRUE(TypeOf(c_ai)->Is()); + ASSERT_TRUE(TypeOf(c_af)->Is()); ASSERT_TRUE(TypeOf(c_vi32)->Is()); ASSERT_TRUE(TypeOf(c_vu32)->Is()); ASSERT_TRUE(TypeOf(c_vf32)->Is()); @@ -1145,8 +1145,8 @@ TEST_F(ResolverVariableTest, GlobalConst_ImplicitType_Decls) { ASSERT_TRUE(TypeOf(c_i32)->Is()); ASSERT_TRUE(TypeOf(c_u32)->Is()); ASSERT_TRUE(TypeOf(c_f32)->Is()); - ASSERT_TRUE(TypeOf(c_ai)->Is()); - ASSERT_TRUE(TypeOf(c_af)->Is()); + ASSERT_TRUE(TypeOf(c_ai)->Is()); + ASSERT_TRUE(TypeOf(c_af)->Is()); ASSERT_TRUE(TypeOf(c_vi32)->Is()); ASSERT_TRUE(TypeOf(c_vu32)->Is()); ASSERT_TRUE(TypeOf(c_vf32)->Is()); diff --git a/src/tint/tint.natvis b/src/tint/tint.natvis index 8e000c3b4d..4e957ffd29 100644 --- a/src/tint/tint.natvis +++ b/src/tint/tint.natvis @@ -236,11 +236,11 @@ - + AbstractInt - + AbstractFloat diff --git a/src/tint/transform/direct_variable_access.cc b/src/tint/transform/direct_variable_access.cc index 07f159a4f6..f187ac8e9e 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 @@ struct DirectVariableAccess::State { if (!idx->UnwrapMaterialize() ->Type() ->UnwrapRef() - ->IsAnyOf()) { + ->IsAnyOf()) { 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 94fbdf303b..cbb16246c7 100644 --- a/src/tint/transform/vectorize_matrix_conversions.cc +++ b/src/tint/transform/vectorize_matrix_conversions.cc @@ -19,10 +19,10 @@ #include #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 e6e1c465c0..27ccf4070e 100644 --- a/src/tint/transform/vectorize_scalar_matrix_initializers.cc +++ b/src/tint/transform/vectorize_scalar_matrix_initializers.cc @@ -18,10 +18,10 @@ #include #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 @@ Transform::ApplyResult VectorizeScalarMatrixInitializers::Apply(const Program* s if (args[0] ->Type() ->UnwrapRef() - ->IsAnyOf()) { + ->IsAnyOf()) { 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 50ddfd3862..5e17f0a8f2 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 @@ std::string AbstractFloat::FriendlyName(const SymbolTable&) const { 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 77b8a78b17..69c12be181 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 -#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 @@ class AbstractFloat final : public Castable { 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 9ab7a0aed6..1506e6f845 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 @@ std::string AbstractInt::FriendlyName(const SymbolTable&) const { 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 91a62997bd..7c7f287128 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 -#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 @@ class AbstractInt final : public Castable { 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 87% rename from src/tint/sem/abstract_numeric.cc rename to src/tint/type/abstract_numeric.cc index e19f13369b..f5fdee85db 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 @@ uint32_t AbstractNumeric::Align() const { 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 665044c739..bc49c2d360 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 #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 @@ class AbstractNumeric : public Castable { 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 99555296d4..a416947986 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 @@ uint32_t Type::Align() const { } bool Type::is_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::is_numeric_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::is_float_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::is_float_matrix() const { @@ -107,7 +107,7 @@ bool Type::is_integer_scalar() const { } bool Type::is_signed_integer_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } 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 { return Is( - [](const sem::Vector* v) { return v->type()->IsAnyOf(); }); + [](const sem::Vector* v) { return v->type()->IsAnyOf(); }); } 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 { - return IsAnyOf() || is_signed_integer_vector(); + return IsAnyOf() || is_signed_integer_vector(); } 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 { - return Is([](const sem::Vector* v) { return v->type()->Is(); }); + return Is([](const sem::Vector* v) { return v->type()->Is(); }); } bool Type::is_abstract_float_vector() const { - return Is([](const sem::Vector* v) { return v->type()->Is(); }); + return Is([](const sem::Vector* v) { return v->type()->Is(); }); } bool Type::is_abstract_integer_scalar_or_vector() const { - return Is() || is_abstract_integer_vector(); + return Is() || is_abstract_integer_vector(); } bool Type::is_abstract_float_scalar_or_vector() const { - return Is() || is_abstract_float_vector(); + return Is() || is_abstract_float_vector(); } bool Type::is_bool_vector() const { @@ -178,7 +178,7 @@ bool Type::is_handle() const { 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 @@ uint32_t Type::ConversionRank(const Type* from, const Type* to) { } 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 d7833b3d7c..9036f8912a 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 tint::type { namespace { struct TypeTest : public TestHelper { - const sem::AbstractFloat* af = create(); - const sem::AbstractInt* ai = create(); + const type::AbstractFloat* af = create(); + const type::AbstractInt* ai = create(); const sem::F32* f32 = create(); const sem::F16* f16 = create(); const sem::I32* i32 = create();