diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-06 20:11:55 +0000 |
commit | 5f757f3ff9144b609b3c433dfd370cc6bdc191ad (patch) | |
tree | 1b4e980b866cd26a00af34c0a653eb640bd09caf /contrib/llvm-project/llvm/lib/Support/APFloat.cpp | |
parent | 3e1c8a35f741a5d114d0ba670b15191355711fe9 (diff) | |
parent | 312c0ed19cc5276a17bacf2120097bec4515b0f1 (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/APFloat.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Support/APFloat.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/APFloat.cpp b/contrib/llvm-project/llvm/lib/Support/APFloat.cpp index 4a73739b5282..0a4f5ac01553 100644 --- a/contrib/llvm-project/llvm/lib/Support/APFloat.cpp +++ b/contrib/llvm-project/llvm/lib/Support/APFloat.cpp @@ -3148,7 +3148,7 @@ bool IEEEFloat::convertFromStringSpecials(StringRef str) { return false; } - if (str.startswith("nan") || str.startswith("NaN")) { + if (str.starts_with("nan") || str.starts_with("NaN")) { str = str.drop_front(3); // A NaN without payload. @@ -4292,6 +4292,35 @@ bool IEEEFloat::getExactInverse(APFloat *inv) const { return true; } +int IEEEFloat::getExactLog2Abs() const { + if (!isFinite() || isZero()) + return INT_MIN; + + const integerPart *Parts = significandParts(); + const int PartCount = partCountForBits(semantics->precision); + + int PopCount = 0; + for (int i = 0; i < PartCount; ++i) { + PopCount += llvm::popcount(Parts[i]); + if (PopCount > 1) + return INT_MIN; + } + + if (exponent != semantics->minExponent) + return exponent; + + int CountrParts = 0; + for (int i = 0; i < PartCount; + ++i, CountrParts += APInt::APINT_BITS_PER_WORD) { + if (Parts[i] != 0) { + return exponent - semantics->precision + CountrParts + + llvm::countr_zero(Parts[i]) + 1; + } + } + + llvm_unreachable("didn't find the set bit"); +} + bool IEEEFloat::isSignaling() const { if (!isNaN()) return false; @@ -5087,6 +5116,16 @@ bool DoubleAPFloat::getExactInverse(APFloat *inv) const { return Ret; } +int DoubleAPFloat::getExactLog2() const { + // TODO: Implement me + return INT_MIN; +} + +int DoubleAPFloat::getExactLog2Abs() const { + // TODO: Implement me + return INT_MIN; +} + DoubleAPFloat scalbn(const DoubleAPFloat &Arg, int Exp, APFloat::roundingMode RM) { assert(Arg.Semantics == &semPPCDoubleDouble && "Unexpected Semantics"); |