tint/sem: Treat abstract-numerics as scalars.

This tracks the WGSL spec and reduces tint complexity.

Change-Id: I240a87fc7bb7f51d9e0ff180af4911cd00a33758
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97581
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2022-07-29 13:08:11 +00:00
committed by Dawn LUCI CQ
parent 6fe1f515d4
commit ea84b9b072
3 changed files with 15 additions and 25 deletions

View File

@@ -68,19 +68,15 @@ bool Type::IsConstructible() const {
}
bool Type::is_scalar() const {
return IsAnyOf<F16, F32, U32, I32, Bool>();
}
bool Type::is_abstract_or_scalar() const {
return IsAnyOf<F16, F32, U32, I32, Bool, AbstractNumeric>();
return IsAnyOf<F16, F32, U32, I32, AbstractNumeric, Bool>();
}
bool Type::is_numeric_scalar() const {
return IsAnyOf<F16, F32, U32, I32>();
return IsAnyOf<F16, F32, U32, I32, AbstractNumeric>();
}
bool Type::is_float_scalar() const {
return IsAnyOf<F16, F32>();
return IsAnyOf<F16, F32, AbstractNumeric>();
}
bool Type::is_float_matrix() const {
@@ -117,7 +113,7 @@ bool Type::is_unsigned_integer_scalar() const {
}
bool Type::is_signed_integer_vector() const {
return Is([](const Vector* v) { return v->type()->Is<I32>(); });
return Is([](const Vector* v) { return v->type()->IsAnyOf<I32>(); });
}
bool Type::is_unsigned_integer_vector() const {
@@ -136,10 +132,6 @@ bool Type::is_integer_scalar_or_vector() const {
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
}
bool Type::is_abstract_scalar_vector() const {
return Is([](const Vector* v) { return v->type()->Is<sem::AbstractNumeric>(); });
}
bool Type::is_abstract_integer_vector() const {
return Is([](const Vector* v) { return v->type()->Is<sem::AbstractInt>(); });
}
@@ -148,10 +140,6 @@ bool Type::is_abstract_float_vector() const {
return Is([](const Vector* v) { return v->type()->Is<sem::AbstractFloat>(); });
}
bool Type::is_abstract_scalar_or_vector() const {
return Is<sem::AbstractNumeric>() || is_abstract_scalar_vector();
}
bool Type::is_abstract_integer_scalar_or_vector() const {
return Is<sem::AbstractInt>() || is_abstract_integer_vector();
}
@@ -228,7 +216,7 @@ uint32_t Type::ConversionRank(const Type* from, const Type* to) {
}
const Type* Type::ElementOf(const Type* ty, uint32_t* count /* = nullptr */) {
if (ty->is_abstract_or_scalar()) {
if (ty->is_scalar()) {
if (count) {
*count = 1;
}

View File

@@ -71,8 +71,6 @@ class Type : public Castable<Type, Node> {
/// @returns true if this type is a scalar
bool is_scalar() const;
/// @returns true if this type is a scalar or an abstract numeric
bool is_abstract_or_scalar() const;
/// @returns true if this type is a numeric scalar
bool is_numeric_scalar() const;
/// @returns true if this type is a float scalar
@@ -103,14 +101,10 @@ class Type : public Castable<Type, Node> {
bool is_signed_scalar_or_vector() const;
/// @returns true if this type is an integer scalar or vector
bool is_integer_scalar_or_vector() const;
/// @returns true if this type is an abstract scalar vector
bool is_abstract_scalar_vector() const;
/// @returns true if this type is an abstract integer vector
bool is_abstract_integer_vector() const;
/// @returns true if this type is an abstract float vector
bool is_abstract_float_vector() const;
/// @returns true if this type is an abstract scalar or vector
bool is_abstract_scalar_or_vector() const;
/// @returns true if this type is an abstract integer scalar or vector
bool is_abstract_integer_scalar_or_vector() const;
/// @returns true if this type is an abstract float scalar or vector