IR: Implement FPRecipEstimate
This commit is contained in:
parent
c1dcfe29f7
commit
fc2d33ae7b
1 changed files with 5 additions and 5 deletions
|
@ -16,7 +16,6 @@
|
||||||
#include "common/fp/process_exception.h"
|
#include "common/fp/process_exception.h"
|
||||||
#include "common/fp/process_nan.h"
|
#include "common/fp/process_nan.h"
|
||||||
#include "common/fp/unpacked.h"
|
#include "common/fp/unpacked.h"
|
||||||
#include "common/safe_ops.h"
|
|
||||||
|
|
||||||
namespace Dynarmic::FP {
|
namespace Dynarmic::FP {
|
||||||
|
|
||||||
|
@ -91,9 +90,9 @@ FPT FPRecipEstimate(FPT op, FPCR fpcr, FPSR& fpsr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const u64 scaled = Safe::LogicalShiftRight(value.mantissa, normalized_point_position - 8);
|
const u64 scaled = value.mantissa >> (normalized_point_position - 8);
|
||||||
u64 estimate = static_cast<u64>(RecipEstimate(scaled)) << (FPInfo<FPT>::explicit_mantissa_width - 8);
|
u64 estimate = static_cast<u64>(RecipEstimate(scaled)) << (FPInfo<FPT>::explicit_mantissa_width - 8);
|
||||||
int result_exponent = -value.exponent;
|
int result_exponent = -(value.exponent + 1);
|
||||||
if (result_exponent < FPInfo<FPT>::exponent_min) {
|
if (result_exponent < FPInfo<FPT>::exponent_min) {
|
||||||
switch (result_exponent) {
|
switch (result_exponent) {
|
||||||
case (FPInfo<FPT>::exponent_min - 1):
|
case (FPInfo<FPT>::exponent_min - 1):
|
||||||
|
@ -103,16 +102,17 @@ FPT FPRecipEstimate(FPT op, FPCR fpcr, FPSR& fpsr) {
|
||||||
case (FPInfo<FPT>::exponent_min - 2):
|
case (FPInfo<FPT>::exponent_min - 2):
|
||||||
estimate |= FPInfo<FPT>::implicit_leading_bit;
|
estimate |= FPInfo<FPT>::implicit_leading_bit;
|
||||||
estimate >>= 2;
|
estimate >>= 2;
|
||||||
result_exponent = 0;
|
result_exponent++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FPT bits_sign = FPInfo<FPT>::Zero(sign);
|
||||||
const FPT bits_exponent = static_cast<FPT>(result_exponent + FPInfo<FPT>::exponent_bias);
|
const FPT bits_exponent = static_cast<FPT>(result_exponent + FPInfo<FPT>::exponent_bias);
|
||||||
const FPT bits_mantissa = static_cast<FPT>(estimate);
|
const FPT bits_mantissa = static_cast<FPT>(estimate);
|
||||||
return (bits_exponent << FPInfo<FPT>::explicit_mantissa_width) | (bits_mantissa & FPInfo<FPT>::mantissa_mask);
|
return (bits_exponent << FPInfo<FPT>::explicit_mantissa_width) | (bits_mantissa & FPInfo<FPT>::mantissa_mask) | bits_sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
template u32 FPRecipEstimate<u32>(u32 op, FPCR fpcr, FPSR& fpsr);
|
template u32 FPRecipEstimate<u32>(u32 op, FPCR fpcr, FPSR& fpsr);
|
||||||
|
|
Loading…
Reference in a new issue