mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
[ADT] Add the scalbn function for APFloat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219473 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -3906,3 +3906,20 @@ APFloat::makeZero(bool Negative) {
|
||||
exponent = semantics->minExponent-1;
|
||||
APInt::tcSet(significandParts(), 0, partCount());
|
||||
}
|
||||
|
||||
APFloat llvm::scalbn(APFloat X, int Exp) {
|
||||
if (X.isInfinity() || X.isZero() || X.isNaN())
|
||||
return std::move(X);
|
||||
|
||||
auto MaxExp = X.getSemantics().maxExponent;
|
||||
auto MinExp = X.getSemantics().minExponent;
|
||||
if (Exp > (MaxExp - X.exponent))
|
||||
// Overflow saturates to infinity.
|
||||
return APFloat::getInf(X.getSemantics(), X.isNegative());
|
||||
if (Exp < (MinExp - X.exponent))
|
||||
// Underflow saturates to zero.
|
||||
return APFloat::getZero(X.getSemantics(), X.isNegative());
|
||||
|
||||
X.exponent += Exp;
|
||||
return std::move(X);
|
||||
}
|
||||
|
Reference in New Issue
Block a user