tint/resolver: Consistently use ConstEval::Result
Fixed: tint:1661 Change-Id: I527b5e2d03abeb53b177a1c69952953864ec0913 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111240 Commit-Queue: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
8a68537de2
commit
b2e6b7b865
|
@ -1561,11 +1561,7 @@ ConstEval::Result ConstEval::OpXor(const sem::Type* ty,
|
||||||
return Dispatch_ia_iu32(create, c0, c1);
|
return Dispatch_ia_iu32(create, c0, c1);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto r = TransformElements(builder, ty, transform, args[0], args[1]);
|
return TransformElements(builder, ty, transform, args[0], args[1]);
|
||||||
if (builder.Diagnostics().contains_errors()) {
|
|
||||||
return utils::Failure;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstEval::Result ConstEval::OpShiftLeft(const sem::Type* ty,
|
ConstEval::Result ConstEval::OpShiftLeft(const sem::Type* ty,
|
||||||
|
@ -1590,13 +1586,13 @@ ConstEval::Result ConstEval::OpShiftLeft(const sem::Type* ty,
|
||||||
UT mask = ~UT{0} << (bit_width - must_match_msb);
|
UT mask = ~UT{0} << (bit_width - must_match_msb);
|
||||||
if ((e1u & mask) != 0 && (e1u & mask) != mask) {
|
if ((e1u & mask) != 0 && (e1u & mask) != mask) {
|
||||||
AddError("shift left operation results in sign change", source);
|
AddError("shift left operation results in sign change", source);
|
||||||
return nullptr;
|
return utils::Failure;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If shift value >= bit_width, then any non-zero value would overflow
|
// If shift value >= bit_width, then any non-zero value would overflow
|
||||||
if (e1 != 0) {
|
if (e1 != 0) {
|
||||||
AddError(OverflowErrorMessage(e1, "<<", e2), source);
|
AddError(OverflowErrorMessage(e1, "<<", e2), source);
|
||||||
return nullptr;
|
return utils::Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's UB in C++ to shift by greater or equal to the bit width (even if the lhs
|
// It's UB in C++ to shift by greater or equal to the bit width (even if the lhs
|
||||||
|
@ -1612,7 +1608,7 @@ ConstEval::Result ConstEval::OpShiftLeft(const sem::Type* ty,
|
||||||
"shift left value must be less than the bit width of the lhs, which is " +
|
"shift left value must be less than the bit width of the lhs, which is " +
|
||||||
std::to_string(bit_width),
|
std::to_string(bit_width),
|
||||||
source);
|
source);
|
||||||
return nullptr;
|
return utils::Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (std::is_signed_v<T>) {
|
if constexpr (std::is_signed_v<T>) {
|
||||||
|
@ -1622,7 +1618,7 @@ ConstEval::Result ConstEval::OpShiftLeft(const sem::Type* ty,
|
||||||
UT mask = ~UT{0} << (bit_width - must_match_msb);
|
UT mask = ~UT{0} << (bit_width - must_match_msb);
|
||||||
if ((e1u & mask) != 0 && (e1u & mask) != mask) {
|
if ((e1u & mask) != 0 && (e1u & mask) != mask) {
|
||||||
AddError("shift left operation results in sign change", source);
|
AddError("shift left operation results in sign change", source);
|
||||||
return nullptr;
|
return utils::Failure;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If T is an unsigned integer type, and any of the e2 most significant bits of
|
// If T is an unsigned integer type, and any of the e2 most significant bits of
|
||||||
|
@ -1632,6 +1628,7 @@ ConstEval::Result ConstEval::OpShiftLeft(const sem::Type* ty,
|
||||||
UT mask = ~UT{0} << (bit_width - must_be_zero_msb);
|
UT mask = ~UT{0} << (bit_width - must_be_zero_msb);
|
||||||
if ((e1u & mask) != 0) {
|
if ((e1u & mask) != 0) {
|
||||||
AddError(OverflowErrorMessage(e1, "<<", e2), source);
|
AddError(OverflowErrorMessage(e1, "<<", e2), source);
|
||||||
|
return utils::Failure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1647,14 +1644,10 @@ ConstEval::Result ConstEval::OpShiftLeft(const sem::Type* ty,
|
||||||
if (!sem::Type::DeepestElementOf(args[1]->Type())->Is<sem::U32>()) {
|
if (!sem::Type::DeepestElementOf(args[1]->Type())->Is<sem::U32>()) {
|
||||||
TINT_ICE(Resolver, builder.Diagnostics())
|
TINT_ICE(Resolver, builder.Diagnostics())
|
||||||
<< "Element type of rhs of ShiftLeft must be a u32";
|
<< "Element type of rhs of ShiftLeft must be a u32";
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto r = TransformElements(builder, ty, transform, args[0], args[1]);
|
|
||||||
if (builder.Diagnostics().contains_errors()) {
|
|
||||||
return utils::Failure;
|
return utils::Failure;
|
||||||
}
|
}
|
||||||
return r;
|
|
||||||
|
return TransformElements(builder, ty, transform, args[0], args[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstEval::Result ConstEval::abs(const sem::Type* ty,
|
ConstEval::Result ConstEval::abs(const sem::Type* ty,
|
||||||
|
@ -1758,11 +1751,7 @@ ConstEval::Result ConstEval::asinh(const sem::Type* ty,
|
||||||
return Dispatch_fa_f32_f16(create, c0);
|
return Dispatch_fa_f32_f16(create, c0);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto r = TransformElements(builder, ty, transform, args[0]);
|
return TransformElements(builder, ty, transform, args[0]);
|
||||||
if (builder.Diagnostics().contains_errors()) {
|
|
||||||
return utils::Failure;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstEval::Result ConstEval::atan(const sem::Type* ty,
|
ConstEval::Result ConstEval::atan(const sem::Type* ty,
|
||||||
|
|
Loading…
Reference in New Issue