mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
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:
committed by
Dawn LUCI CQ
parent
5ee58b60a8
commit
094ace6f63
@@ -23,8 +23,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/abstract_float.h"
|
||||
#include "src/tint/sem/abstract_int.h"
|
||||
#include "src/tint/sem/array.h"
|
||||
#include "src/tint/sem/bool.h"
|
||||
#include "src/tint/sem/constant.h"
|
||||
@@ -36,6 +34,8 @@
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/sem/u32.h"
|
||||
#include "src/tint/sem/vector.h"
|
||||
#include "src/tint/type/abstract_float.h"
|
||||
#include "src/tint/type/abstract_int.h"
|
||||
#include "src/tint/utils/bitcast.h"
|
||||
#include "src/tint/utils/compiler_macros.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
@@ -69,7 +69,7 @@ template <typename F, typename... CONSTANTS>
|
||||
auto Dispatch_ia_iu32(F&& f, CONSTANTS&&... cs) {
|
||||
return Switch(
|
||||
First(cs...)->Type(), //
|
||||
[&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); });
|
||||
}
|
||||
@@ -80,7 +80,7 @@ template <typename F, typename... CONSTANTS>
|
||||
auto Dispatch_ia_iu32_bool(F&& f, CONSTANTS&&... cs) {
|
||||
return Switch(
|
||||
First(cs...)->Type(), //
|
||||
[&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
|
||||
[&](const sem::Bool*) { return f(cs->template As<bool>()...); });
|
||||
@@ -92,8 +92,8 @@ template <typename F, typename... CONSTANTS>
|
||||
auto Dispatch_fia_fi32_f16(F&& f, CONSTANTS&&... cs) {
|
||||
return Switch(
|
||||
First(cs...)->Type(), //
|
||||
[&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const sem::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
|
||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
||||
[&](const sem::F16*) { return f(cs->template As<f16>()...); });
|
||||
@@ -105,8 +105,8 @@ template <typename F, typename... CONSTANTS>
|
||||
auto Dispatch_fia_fiu32_f16(F&& f, CONSTANTS&&... cs) {
|
||||
return Switch(
|
||||
First(cs...)->Type(), //
|
||||
[&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const sem::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
|
||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
|
||||
@@ -119,8 +119,8 @@ template <typename F, typename... CONSTANTS>
|
||||
auto Dispatch_fia_fiu32_f16_bool(F&& f, CONSTANTS&&... cs) {
|
||||
return Switch(
|
||||
First(cs...)->Type(), //
|
||||
[&](const sem::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const sem::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
|
||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
|
||||
@@ -134,7 +134,7 @@ template <typename F, typename... CONSTANTS>
|
||||
auto Dispatch_fa_f32_f16(F&& f, CONSTANTS&&... cs) {
|
||||
return Switch(
|
||||
First(cs...)->Type(), //
|
||||
[&](const sem::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
|
||||
[&](const sem::F16*) { return f(cs->template As<f16>()...); });
|
||||
}
|
||||
@@ -156,13 +156,13 @@ auto Dispatch_bool(F&& f, CONSTANTS&&... cs) {
|
||||
template <typename F>
|
||||
auto ZeroTypeDispatch(const type::Type* type, F&& f) {
|
||||
return Switch(
|
||||
type, //
|
||||
[&](const sem::AbstractInt*) { return f(AInt(0)); }, //
|
||||
[&](const sem::AbstractFloat*) { return f(AFloat(0)); }, //
|
||||
[&](const sem::I32*) { return f(i32(0)); }, //
|
||||
[&](const sem::U32*) { return f(u32(0)); }, //
|
||||
[&](const sem::F32*) { return f(f32(0)); }, //
|
||||
[&](const sem::F16*) { return f(f16(0)); }, //
|
||||
type, //
|
||||
[&](const type::AbstractInt*) { return f(AInt(0)); }, //
|
||||
[&](const type::AbstractFloat*) { return f(AFloat(0)); }, //
|
||||
[&](const sem::I32*) { return f(i32(0)); }, //
|
||||
[&](const sem::U32*) { return f(u32(0)); }, //
|
||||
[&](const sem::F32*) { return f(f32(0)); }, //
|
||||
[&](const sem::F16*) { return f(f16(0)); }, //
|
||||
[&](const sem::Bool*) { return f(static_cast<bool>(0)); });
|
||||
}
|
||||
|
||||
@@ -2659,11 +2659,11 @@ ConstEval::Result ConstEval::frexp(const type::Type* ty,
|
||||
CreateElement(builder, source, builder.create<sem::I32>(), i32(exp)),
|
||||
};
|
||||
},
|
||||
[&](const sem::AbstractFloat*) {
|
||||
[&](const type::AbstractFloat*) {
|
||||
return FractExp{
|
||||
CreateElement(builder, source, builder.create<sem::AbstractFloat>(),
|
||||
CreateElement(builder, source, builder.create<type::AbstractFloat>(),
|
||||
AFloat(fract)),
|
||||
CreateElement(builder, source, builder.create<sem::AbstractInt>(), AInt(exp)),
|
||||
CreateElement(builder, source, builder.create<type::AbstractInt>(), AInt(exp)),
|
||||
};
|
||||
},
|
||||
[&](Default) {
|
||||
|
||||
@@ -1142,7 +1142,7 @@ TEST_F(ResolverConstEvalTest, BinaryAbstractShiftLeftRemainsAbstract) {
|
||||
auto* sem2 = Sem().Get(expr2);
|
||||
ASSERT_NE(sem2, nullptr);
|
||||
|
||||
auto aint_ty = create<sem::AbstractInt>();
|
||||
auto aint_ty = create<type::AbstractInt>();
|
||||
EXPECT_EQ(sem1->Type(), aint_ty);
|
||||
EXPECT_EQ(sem2->Type(), aint_ty);
|
||||
}
|
||||
|
||||
@@ -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<sem::Vector>());
|
||||
EXPECT_TRUE(cv->Index(0)->Index(0)->Type()->Is<sem::AbstractFloat>());
|
||||
EXPECT_TRUE(cv->Index(0)->Index(0)->Type()->Is<type::AbstractFloat>());
|
||||
EXPECT_FALSE(cv->AllEqual());
|
||||
EXPECT_FALSE(cv->AnyZero());
|
||||
EXPECT_FALSE(cv->AllZero());
|
||||
|
||||
@@ -41,8 +41,8 @@ template <size_t N>
|
||||
inline void CollectScalars(const sem::Constant* c, utils::Vector<builder::Scalar, N>& scalars) {
|
||||
Switch(
|
||||
c->Type(), //
|
||||
[&](const sem::AbstractInt*) { scalars.Push(c->As<AInt>()); },
|
||||
[&](const sem::AbstractFloat*) { scalars.Push(c->As<AFloat>()); },
|
||||
[&](const type::AbstractInt*) { scalars.Push(c->As<AInt>()); },
|
||||
[&](const type::AbstractFloat*) { scalars.Push(c->As<AFloat>()); },
|
||||
[&](const sem::Bool*) { scalars.Push(c->As<bool>()); },
|
||||
[&](const sem::I32*) { scalars.Push(c->As<i32>()); },
|
||||
[&](const sem::U32*) { scalars.Push(c->As<u32>()); },
|
||||
|
||||
@@ -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<Any, sem::Bool>();
|
||||
}
|
||||
|
||||
const sem::AbstractFloat* build_fa(MatchState& state) {
|
||||
return state.builder.create<sem::AbstractFloat>();
|
||||
const type::AbstractFloat* build_fa(MatchState& state) {
|
||||
return state.builder.create<type::AbstractFloat>();
|
||||
}
|
||||
|
||||
bool match_fa(MatchState& state, const type::Type* ty) {
|
||||
return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) &&
|
||||
ty->IsAnyOf<Any, sem::AbstractNumeric>();
|
||||
ty->IsAnyOf<Any, type::AbstractNumeric>();
|
||||
}
|
||||
|
||||
const sem::AbstractInt* build_ia(MatchState& state) {
|
||||
return state.builder.create<sem::AbstractInt>();
|
||||
const type::AbstractInt* build_ia(MatchState& state) {
|
||||
return state.builder.create<type::AbstractInt>();
|
||||
}
|
||||
|
||||
bool match_ia(MatchState& state, const type::Type* ty) {
|
||||
return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) &&
|
||||
ty->IsAnyOf<Any, sem::AbstractInt>();
|
||||
ty->IsAnyOf<Any, type::AbstractInt>();
|
||||
}
|
||||
|
||||
const sem::Bool* build_bool(MatchState& state) {
|
||||
@@ -379,7 +379,7 @@ const sem::F16* build_f16(MatchState& state) {
|
||||
}
|
||||
|
||||
bool match_f16(MatchState&, const type::Type* ty) {
|
||||
return ty->IsAnyOf<Any, sem::F16, sem::AbstractNumeric>();
|
||||
return ty->IsAnyOf<Any, sem::F16, type::AbstractNumeric>();
|
||||
}
|
||||
|
||||
const sem::F32* build_f32(MatchState& state) {
|
||||
@@ -387,7 +387,7 @@ const sem::F32* build_f32(MatchState& state) {
|
||||
}
|
||||
|
||||
bool match_f32(MatchState&, const type::Type* ty) {
|
||||
return ty->IsAnyOf<Any, sem::F32, sem::AbstractNumeric>();
|
||||
return ty->IsAnyOf<Any, sem::F32, type::AbstractNumeric>();
|
||||
}
|
||||
|
||||
const sem::I32* build_i32(MatchState& state) {
|
||||
@@ -395,7 +395,7 @@ const sem::I32* build_i32(MatchState& state) {
|
||||
}
|
||||
|
||||
bool match_i32(MatchState&, const type::Type* ty) {
|
||||
return ty->IsAnyOf<Any, sem::I32, sem::AbstractInt>();
|
||||
return ty->IsAnyOf<Any, sem::I32, type::AbstractInt>();
|
||||
}
|
||||
|
||||
const sem::U32* build_u32(MatchState& state) {
|
||||
@@ -403,7 +403,7 @@ const sem::U32* build_u32(MatchState& state) {
|
||||
}
|
||||
|
||||
bool match_u32(MatchState&, const type::Type* ty) {
|
||||
return ty->IsAnyOf<Any, sem::U32, sem::AbstractInt>();
|
||||
return ty->IsAnyOf<Any, sem::U32, type::AbstractInt>();
|
||||
}
|
||||
|
||||
bool match_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) {
|
||||
@@ -846,7 +846,7 @@ 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<sem::Vector>(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<sem::AbstractInt>();
|
||||
[&](const type::AbstractFloat*) {
|
||||
auto* i = state.builder.create<type::AbstractInt>();
|
||||
auto* abstract =
|
||||
build_struct(state.builder, "__frexp_result_abstract", {{"fract", el}, {"exp", i}});
|
||||
abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()});
|
||||
@@ -935,9 +935,9 @@ 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<sem::Vector>(el, n.Value());
|
||||
auto* e = state.builder.create<sem::Vector>(state.builder.create<sem::AbstractInt>(),
|
||||
auto* e = state.builder.create<sem::Vector>(state.builder.create<type::AbstractInt>(),
|
||||
n.Value());
|
||||
auto* abstract =
|
||||
build_struct(state.builder, prefix + "_abstract", {{"fract", f}, {"exp", e}});
|
||||
|
||||
@@ -529,7 +529,7 @@ TEST_F(IntrinsicTableTest, MismatchOpenSizeMatrix) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
|
||||
auto* af = create<sem::AbstractFloat>();
|
||||
auto* af = create<type::AbstractFloat>();
|
||||
auto* bool_ = create<sem::Bool>();
|
||||
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
@@ -545,7 +545,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
|
||||
auto* af = create<sem::AbstractFloat>();
|
||||
auto* af = create<type::AbstractFloat>();
|
||||
auto* bool_ref = create<sem::Reference>(create<sem::Bool>(), ast::AddressSpace::kFunction,
|
||||
ast::Access::kReadWrite);
|
||||
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref},
|
||||
@@ -562,7 +562,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto* u32 = create<sem::U32>();
|
||||
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kConstant,
|
||||
Source{}, false);
|
||||
@@ -575,7 +575,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto* u32 = create<sem::U32>();
|
||||
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kRuntime,
|
||||
Source{}, false);
|
||||
@@ -712,7 +712,7 @@ TEST_F(IntrinsicTableTest, MismatchUnaryOp) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchUnaryOp_Constant) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kConstant,
|
||||
Source{{12, 34}});
|
||||
EXPECT_EQ(result.result, ai);
|
||||
@@ -720,7 +720,7 @@ TEST_F(IntrinsicTableTest, MatchUnaryOp_Constant) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchUnaryOp_Runtime) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kRuntime,
|
||||
Source{{12, 34}});
|
||||
EXPECT_NE(result.result, ai);
|
||||
@@ -879,7 +879,7 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto* vec3_ai = create<sem::Vector>(ai, 3u);
|
||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{vec3_ai},
|
||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||
@@ -892,8 +892,8 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) {
|
||||
auto* af = create<sem::AbstractFloat>();
|
||||
auto* vec2_ai = create<sem::Vector>(create<sem::AbstractInt>(), 2u);
|
||||
auto* af = create<type::AbstractFloat>();
|
||||
auto* vec2_ai = create<sem::Vector>(create<type::AbstractInt>(), 2u);
|
||||
auto* vec2_af = create<sem::Vector>(af, 2u);
|
||||
auto* mat2x2_af = create<sem::Matrix>(vec2_af, 2u);
|
||||
auto result =
|
||||
@@ -909,7 +909,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto* vec3_ai = create<sem::Vector>(ai, 3u);
|
||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai},
|
||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||
@@ -925,7 +925,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai},
|
||||
sem::EvaluationStage::kRuntime, Source{{12, 34}});
|
||||
auto* i32 = create<sem::I32>();
|
||||
@@ -983,8 +983,8 @@ TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* af = create<sem::AbstractFloat>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto* af = create<type::AbstractFloat>();
|
||||
auto* vec3_ai = create<sem::Vector>(ai, 3u);
|
||||
auto* f32 = create<sem::F32>();
|
||||
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
|
||||
@@ -1000,8 +1000,8 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) {
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) {
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* af = create<sem::AbstractFloat>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto* af = create<type::AbstractFloat>();
|
||||
auto* vec3_ai = create<sem::Vector>(ai, 3u);
|
||||
auto* vec3_f32 = create<sem::Vector>(create<sem::F32>(), 3u);
|
||||
auto* vec3_i32 = create<sem::Vector>(create<sem::I32>(), 3u);
|
||||
@@ -1030,7 +1030,7 @@ TEST_F(IntrinsicTableTest, OverloadResolution) {
|
||||
// ctor i32(i32) -> i32
|
||||
// conv i32<T: scalar_no_i32>(T) -> i32
|
||||
// The first should win overload resolution.
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* ai = create<type::AbstractInt>();
|
||||
auto* i32 = create<sem::I32>();
|
||||
auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
|
||||
@@ -1257,7 +1257,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_DefaultType) {
|
||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F32>());
|
||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::AbstractFloat>());
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
||||
}
|
||||
|
||||
TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) {
|
||||
@@ -1276,7 +1276,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) {
|
||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||
ASSERT_TRUE(
|
||||
abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractFloat>());
|
||||
abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::AbstractFloat>());
|
||||
}
|
||||
|
||||
TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) {
|
||||
@@ -1295,7 +1295,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) {
|
||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F16>());
|
||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::AbstractFloat>());
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
||||
}
|
||||
|
||||
TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) {
|
||||
@@ -1317,7 +1317,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) {
|
||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||
ASSERT_TRUE(
|
||||
abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractFloat>());
|
||||
abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::AbstractFloat>());
|
||||
}
|
||||
|
||||
TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) {
|
||||
@@ -1334,8 +1334,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) {
|
||||
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>());
|
||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::AbstractFloat>());
|
||||
ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<sem::AbstractInt>());
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
||||
ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<type::AbstractInt>());
|
||||
}
|
||||
|
||||
TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) {
|
||||
@@ -1356,9 +1356,9 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) {
|
||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||
ASSERT_TRUE(
|
||||
abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractFloat>());
|
||||
abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::AbstractFloat>());
|
||||
ASSERT_TRUE(
|
||||
abstract_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractInt>());
|
||||
abstract_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<type::AbstractInt>());
|
||||
}
|
||||
|
||||
TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) {
|
||||
@@ -1378,8 +1378,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) {
|
||||
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>());
|
||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::AbstractFloat>());
|
||||
ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<sem::AbstractInt>());
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
||||
ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is<type::AbstractInt>());
|
||||
}
|
||||
|
||||
TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) {
|
||||
@@ -1403,9 +1403,9 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) {
|
||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||
ASSERT_TRUE(
|
||||
abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractFloat>());
|
||||
abstract_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::AbstractFloat>());
|
||||
ASSERT_TRUE(
|
||||
abstract_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<sem::AbstractInt>());
|
||||
abstract_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<type::AbstractInt>());
|
||||
}
|
||||
|
||||
} // namespace materialize_abstract_structure
|
||||
|
||||
@@ -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<sem::I32, sem::U32, sem::AbstractInt>()) {
|
||||
if (!ty->IsAnyOf<sem::I32, sem::U32, type::AbstractInt>()) {
|
||||
AddError(kErrBadExpr, value->source);
|
||||
return false;
|
||||
}
|
||||
@@ -1178,7 +1178,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) {
|
||||
}
|
||||
|
||||
// If all arguments are abstract-integers, then materialize to i32.
|
||||
if (common_ty->Is<sem::AbstractInt>()) {
|
||||
if (common_ty->Is<type::AbstractInt>()) {
|
||||
common_ty = builder_->create<sem::I32>();
|
||||
}
|
||||
|
||||
@@ -1726,19 +1726,19 @@ 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::Vector<const sem::Expression*, N
|
||||
|
||||
bool Resolver::ShouldMaterializeArgument(const type::Type* parameter_ty) const {
|
||||
const auto* param_el_ty = type::Type::DeepestElementOf(parameter_ty);
|
||||
return param_el_ty && !param_el_ty->Is<sem::AbstractNumeric>();
|
||||
return param_el_ty && !param_el_ty->Is<type::AbstractNumeric>();
|
||||
}
|
||||
|
||||
bool Resolver::Convert(const sem::Constant*& c, const type::Type* target_ty, const Source& source) {
|
||||
@@ -2483,7 +2483,7 @@ 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<sem::AbstractInt>();
|
||||
return builder_->create<type::AbstractInt>();
|
||||
case ast::IntLiteralExpression::Suffix::kI:
|
||||
return builder_->create<sem::I32>();
|
||||
case ast::IntLiteralExpression::Suffix::kU:
|
||||
@@ -2494,7 +2494,7 @@ 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<sem::AbstractFloat>();
|
||||
return builder_->create<type::AbstractFloat>();
|
||||
case ast::FloatLiteralExpression::Suffix::kF:
|
||||
return builder_->create<sem::F32>();
|
||||
case ast::FloatLiteralExpression::Suffix::kH:
|
||||
|
||||
@@ -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<AFloat> {
|
||||
/// @param b the ProgramBuilder
|
||||
/// @return the semantic abstract-float type
|
||||
static inline const type::Type* Sem(ProgramBuilder& b) {
|
||||
return b.create<sem::AbstractFloat>();
|
||||
return b.create<type::AbstractFloat>();
|
||||
}
|
||||
/// @param b the ProgramBuilder
|
||||
/// @param args args of size 1 with the abstract-float value to init with
|
||||
@@ -418,7 +418,7 @@ struct DataType<AInt> {
|
||||
static inline const ast::Type* AST(ProgramBuilder&) { return nullptr; }
|
||||
/// @param b the ProgramBuilder
|
||||
/// @return the semantic abstract-int type
|
||||
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::AbstractInt>(); }
|
||||
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<type::AbstractInt>(); }
|
||||
/// @param b the ProgramBuilder
|
||||
/// @param args args of size 1 with the abstract-int value to init with
|
||||
/// @return a new AST abstract-int literal value expression
|
||||
|
||||
@@ -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<sem::AbstractInt>());
|
||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::AbstractInt>());
|
||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::AbstractInt>());
|
||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::AbstractInt>());
|
||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::AbstractInt>());
|
||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::AbstractInt>());
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) {
|
||||
|
||||
@@ -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<uint32_t>();
|
||||
if (auto added = selectors.Add(value, selector->Declaration()->source); !added) {
|
||||
AddError("duplicate switch case '" +
|
||||
(decl_ty->IsAnyOf<sem::I32, sem::AbstractNumeric>()
|
||||
(decl_ty->IsAnyOf<sem::I32, type::AbstractNumeric>()
|
||||
? std::to_string(i32(value))
|
||||
: std::to_string(value)) +
|
||||
"'",
|
||||
@@ -2266,7 +2266,7 @@ 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<sem::Pointer, type::Texture, type::Sampler, sem::AbstractNumeric>()) {
|
||||
!ty->IsAnyOf<sem::Pointer, type::Texture, type::Sampler, type::AbstractNumeric>()) {
|
||||
AddError("cannot assign '" + sem_.TypeNameOf(rhs_ty) +
|
||||
"' to '_'. '_' can only be assigned a constructible, pointer, texture or "
|
||||
"sampler type",
|
||||
|
||||
@@ -974,8 +974,8 @@ TEST_F(ResolverVariableTest, LocalConst_ImplicitType_Decls) {
|
||||
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
|
||||
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
|
||||
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
|
||||
ASSERT_TRUE(TypeOf(c_ai)->Is<sem::AbstractInt>());
|
||||
ASSERT_TRUE(TypeOf(c_af)->Is<sem::AbstractFloat>());
|
||||
ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
|
||||
ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
|
||||
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
||||
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
|
||||
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
|
||||
@@ -1145,8 +1145,8 @@ TEST_F(ResolverVariableTest, GlobalConst_ImplicitType_Decls) {
|
||||
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
|
||||
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
|
||||
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
|
||||
ASSERT_TRUE(TypeOf(c_ai)->Is<sem::AbstractInt>());
|
||||
ASSERT_TRUE(TypeOf(c_af)->Is<sem::AbstractFloat>());
|
||||
ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
|
||||
ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
|
||||
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
||||
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
|
||||
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
|
||||
|
||||
Reference in New Issue
Block a user