mirror of
https://github.com/azahar-emu/dynarmic
synced 2025-11-11 17:39:59 +01:00
common/fp/op: Add half-precision specialization for FPRecipStepFused
This commit is contained in:
parent
c6e6ec0e69
commit
68d8cd2b13
@ -88,7 +88,7 @@ struct FPInfo<u64> {
|
|||||||
template<typename FPT, bool sign, int exponent, FPT value>
|
template<typename FPT, bool sign, int exponent, FPT value>
|
||||||
constexpr FPT FPValue() {
|
constexpr FPT FPValue() {
|
||||||
if constexpr (value == 0) {
|
if constexpr (value == 0) {
|
||||||
return FPInfo<FPT>::Zero(sign);
|
return FPT(FPInfo<FPT>::Zero(sign));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int point_position = static_cast<int>(FPInfo<FPT>::explicit_mantissa_width);
|
constexpr int point_position = static_cast<int>(FPInfo<FPT>::explicit_mantissa_width);
|
||||||
@ -100,7 +100,7 @@ constexpr FPT FPValue() {
|
|||||||
|
|
||||||
constexpr FPT mantissa = (value << offset) & FPInfo<FPT>::mantissa_mask;
|
constexpr FPT mantissa = (value << offset) & FPInfo<FPT>::mantissa_mask;
|
||||||
constexpr FPT biased_exponent = static_cast<FPT>(normalized_exponent + FPInfo<FPT>::exponent_bias);
|
constexpr FPT biased_exponent = static_cast<FPT>(normalized_exponent + FPInfo<FPT>::exponent_bias);
|
||||||
return FPInfo<FPT>::Zero(sign) | mantissa | (biased_exponent << FPInfo<FPT>::explicit_mantissa_width);
|
return FPT(FPInfo<FPT>::Zero(sign) | mantissa | (biased_exponent << FPInfo<FPT>::explicit_mantissa_width));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Dynarmic::FP
|
} // namespace Dynarmic::FP
|
||||||
|
|||||||
@ -37,18 +37,19 @@ FPT FPRecipStepFused(FPT op1, FPT op2, FPCR fpcr, FPSR& fpsr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inf1 || inf2) {
|
if (inf1 || inf2) {
|
||||||
return FPInfo<FPT>::Infinity(sign1 != sign2);
|
return FPT(FPInfo<FPT>::Infinity(sign1 != sign2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// result_value = 2.0 + (value1 * value2)
|
// result_value = 2.0 + (value1 * value2)
|
||||||
FPUnpacked result_value = FusedMulAdd(ToNormalized(false, 0, 2), value1, value2);
|
const FPUnpacked result_value = FusedMulAdd(ToNormalized(false, 0, 2), value1, value2);
|
||||||
|
|
||||||
if (result_value.mantissa == 0) {
|
if (result_value.mantissa == 0) {
|
||||||
return FPInfo<FPT>::Zero(fpcr.RMode() == RoundingMode::TowardsMinusInfinity);
|
return FPT(FPInfo<FPT>::Zero(fpcr.RMode() == RoundingMode::TowardsMinusInfinity));
|
||||||
}
|
}
|
||||||
return FPRound<FPT>(result_value, fpcr, fpsr);
|
return FPRound<FPT>(result_value, fpcr, fpsr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template u16 FPRecipStepFused<u16>(u16 op1, u16 op2, FPCR fpcr, FPSR& fpsr);
|
||||||
template u32 FPRecipStepFused<u32>(u32 op1, u32 op2, FPCR fpcr, FPSR& fpsr);
|
template u32 FPRecipStepFused<u32>(u32 op1, u32 op2, FPCR fpcr, FPSR& fpsr);
|
||||||
template u64 FPRecipStepFused<u64>(u64 op1, u64 op2, FPCR fpcr, FPSR& fpsr);
|
template u64 FPRecipStepFused<u64>(u64 op1, u64 op2, FPCR fpcr, FPSR& fpsr);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user