LLVM 20.0.0git
|
This class represents a range of floating-point values. More...
#include "llvm/IR/ConstantFPRange.h"
Public Member Functions | |
ConstantFPRange (const APFloat &Value) | |
Initialize a range to hold the single specified value. | |
ConstantFPRange (APFloat LowerVal, APFloat UpperVal, bool MayBeQNaN, bool MayBeSNaN) | |
Initialize a range of values explicitly. | |
bool | fcmp (FCmpInst::Predicate Pred, const ConstantFPRange &Other) const |
Does the predicate Pred hold between ranges this and Other ? NOTE: false does not mean that inverse predicate holds! | |
const APFloat & | getLower () const |
Return the lower value for this range. | |
const APFloat & | getUpper () const |
Return the upper value for this range. | |
bool | containsNaN () const |
bool | containsQNaN () const |
bool | containsSNaN () const |
bool | isNaNOnly () const |
const fltSemantics & | getSemantics () const |
Get the semantics of this ConstantFPRange. | |
bool | isFullSet () const |
Return true if this set contains all of the elements possible for this data-type. | |
bool | isEmptySet () const |
Return true if this set contains no members. | |
bool | contains (const APFloat &Val) const |
Return true if the specified value is in the set. | |
bool | contains (const ConstantFPRange &CR) const |
Return true if the other range is a subset of this one. | |
const APFloat * | getSingleElement (bool ExcludesNaN=false) const |
If this set contains a single element, return it, otherwise return null. | |
bool | isSingleElement (bool ExcludesNaN=false) const |
Return true if this set contains exactly one member. | |
std::optional< bool > | getSignBit () const |
Return true if the sign bit of all values in this range is 1. | |
bool | operator== (const ConstantFPRange &CR) const |
Return true if this range is equal to another range. | |
bool | operator!= (const ConstantFPRange &CR) const |
Return true if this range is not equal to another range. | |
FPClassTest | classify () const |
Return the FPClassTest which will return true for the value. | |
void | print (raw_ostream &OS) const |
Print out the bounds to a stream. | |
void | dump () const |
Allow printing from a debugger easily. | |
ConstantFPRange | intersectWith (const ConstantFPRange &CR) const |
Return the range that results from the intersection of this range with another range. | |
ConstantFPRange | unionWith (const ConstantFPRange &CR) const |
Return the smallest range that results from the union of this range with another range. | |
Static Public Member Functions | |
static ConstantFPRange | getEmpty (const fltSemantics &Sem) |
Create empty constant range with the given semantics. | |
static ConstantFPRange | getFull (const fltSemantics &Sem) |
Create full constant range with the given semantics. | |
static ConstantFPRange | getFinite (const fltSemantics &Sem) |
Helper for (-inf, inf) to represent all finite values. | |
static ConstantFPRange | getNonNaN (const fltSemantics &Sem) |
Helper for [-inf, inf] to represent all non-NaN values. | |
static ConstantFPRange | getNonNaN (APFloat LowerVal, APFloat UpperVal) |
Create a range which doesn't contain NaNs. | |
static ConstantFPRange | getMayBeNaN (APFloat LowerVal, APFloat UpperVal) |
Create a range which may contain NaNs. | |
static ConstantFPRange | getNaNOnly (const fltSemantics &Sem, bool MayBeQNaN, bool MayBeSNaN) |
Create a range which only contains NaNs. | |
static ConstantFPRange | makeAllowedFCmpRegion (FCmpInst::Predicate Pred, const ConstantFPRange &Other) |
Produce the smallest range such that all values that may satisfy the given predicate with any value contained within Other is contained in the returned range. | |
static ConstantFPRange | makeSatisfyingFCmpRegion (FCmpInst::Predicate Pred, const ConstantFPRange &Other) |
Produce the largest range such that all values in the returned range satisfy the given predicate with all values contained within Other. | |
static std::optional< ConstantFPRange > | makeExactFCmpRegion (FCmpInst::Predicate Pred, const APFloat &Other) |
Produce the exact range such that all values in the returned range satisfy the given predicate with any value contained within Other. | |
This class represents a range of floating-point values.
Definition at line 36 of file ConstantFPRange.h.
Initialize a range to hold the single specified value.
Definition at line 45 of file ConstantFPRange.cpp.
ConstantFPRange::ConstantFPRange | ( | APFloat | LowerVal, |
APFloat | UpperVal, | ||
bool | MayBeQNaN, | ||
bool | MayBeSNaN | ||
) |
Initialize a range of values explicitly.
Note: If LowerVal
is greater than UpperVal
, please use the canonical form [Inf, -Inf].
Definition at line 83 of file ConstantFPRange.cpp.
References assert(), llvm::APFloat::getSemantics(), and isNonCanonicalEmptySet().
FPClassTest ConstantFPRange::classify | ( | ) | const |
Return the FPClassTest which will return true for the value.
Definition at line 334 of file ConstantFPRange.cpp.
References assert(), llvm::APFloat::classify(), llvm::fcNone, llvm::fcQNan, llvm::fcSNan, and isNaNOnly().
Return true if the specified value is in the set.
Definition at line 292 of file ConstantFPRange.cpp.
References assert(), llvm::APFloatBase::cmpGreaterThan, llvm::APFloat::getSemantics(), getSemantics(), llvm::APFloat::isNaN(), llvm::APFloat::isSignaling(), and strictCompare().
Referenced by fcmp().
bool ConstantFPRange::contains | ( | const ConstantFPRange & | CR | ) | const |
Return true if the other range is a subset of this one.
Definition at line 302 of file ConstantFPRange.cpp.
References assert(), llvm::APFloatBase::cmpGreaterThan, getSemantics(), and strictCompare().
|
inline |
Definition at line 141 of file ConstantFPRange.h.
|
inline |
Definition at line 142 of file ConstantFPRange.h.
Referenced by extendZeroIfEqual().
|
inline |
Definition at line 143 of file ConstantFPRange.h.
Referenced by extendZeroIfEqual().
LLVM_DUMP_METHOD void ConstantFPRange::dump | ( | ) | const |
Allow printing from a debugger easily.
Definition at line 374 of file ConstantFPRange.cpp.
References llvm::dbgs(), and print().
bool ConstantFPRange::fcmp | ( | FCmpInst::Predicate | Pred, |
const ConstantFPRange & | Other | ||
) | const |
Does the predicate Pred
hold between ranges this and Other
? NOTE: false does not mean that inverse predicate holds!
Definition at line 277 of file ConstantFPRange.cpp.
References contains(), makeSatisfyingFCmpRegion(), and llvm::Other.
|
inlinestatic |
Create empty constant range with the given semantics.
Definition at line 68 of file ConstantFPRange.h.
|
static |
Helper for (-inf, inf) to represent all finite values.
Definition at line 92 of file ConstantFPRange.cpp.
References llvm::APFloat::getLargest().
|
inlinestatic |
Create full constant range with the given semantics.
Definition at line 73 of file ConstantFPRange.h.
Return the lower value for this range.
Definition at line 136 of file ConstantFPRange.h.
Referenced by extendZeroIfEqual(), and setNaNField().
|
inlinestatic |
Create a range which may contain NaNs.
Definition at line 90 of file ConstantFPRange.h.
|
static |
Create a range which only contains NaNs.
Definition at line 98 of file ConstantFPRange.cpp.
References llvm::APFloat::getInf().
Referenced by makeAllowedFCmpRegion(), and makeSatisfyingFCmpRegion().
|
inlinestatic |
Create a range which doesn't contain NaNs.
Definition at line 84 of file ConstantFPRange.h.
|
static |
Helper for [-inf, inf] to represent all non-NaN values.
Definition at line 105 of file ConstantFPRange.cpp.
References llvm::APFloat::getInf().
Referenced by makeAllowedFCmpRegion(), makeGreaterThan(), makeLessThan(), and makeSatisfyingFCmpRegion().
|
inline |
Get the semantics of this ConstantFPRange.
Definition at line 147 of file ConstantFPRange.h.
Referenced by contains(), intersectWith(), and unionWith().
std::optional< bool > ConstantFPRange::getSignBit | ( | ) | const |
Return true if the sign bit of all values in this range is 1.
Return false if the sign bit of all values in this range is 0. Otherwise, return std::nullopt.
Definition at line 322 of file ConstantFPRange.cpp.
References llvm::APFloat::isNegative().
If this set contains a single element, return it, otherwise return null.
If ExcludesNaN
is true, return the non-NaN single element.
Definition at line 316 of file ConstantFPRange.cpp.
References llvm::APFloat::bitwiseIsEqual().
Return the upper value for this range.
Definition at line 139 of file ConstantFPRange.h.
References llvm::Upper.
Referenced by extendZeroIfEqual(), and setNaNField().
ConstantFPRange ConstantFPRange::intersectWith | ( | const ConstantFPRange & | CR | ) | const |
Return the range that results from the intersection of this range with another range.
Definition at line 378 of file ConstantFPRange.cpp.
References assert(), canonicalizeRange(), getSemantics(), llvm::maxnum(), and llvm::minnum().
bool ConstantFPRange::isEmptySet | ( | ) | const |
Return true if this set contains no members.
Definition at line 287 of file ConstantFPRange.cpp.
References llvm::APFloat::isNegInfinity(), and llvm::APFloat::isPosInfinity().
Referenced by print().
bool ConstantFPRange::isFullSet | ( | ) | const |
Return true if this set contains all of the elements possible for this data-type.
Definition at line 282 of file ConstantFPRange.cpp.
References llvm::APFloat::isNegInfinity(), and llvm::APFloat::isPosInfinity().
Referenced by print().
bool ConstantFPRange::isNaNOnly | ( | ) | const |
Definition at line 33 of file ConstantFPRange.cpp.
References llvm::APFloat::isNegInfinity(), and llvm::APFloat::isPosInfinity().
Referenced by classify(), and print().
Return true if this set contains exactly one member.
If ExcludesNaN
is true, return true if this set contains exactly one non-NaN member.
Definition at line 169 of file ConstantFPRange.h.
|
static |
Produce the smallest range such that all values that may satisfy the given predicate with any value contained within Other is contained in the returned range.
Formally, this returns a superset of 'union over all y in Other . { x : fcmp op x y is true }'. If the exact answer is not representable as a ConstantFPRange, the return value will be a proper superset of the above.
Example: Pred = ole and Other = float [2, 5] returns Result = [-inf, 5]
Definition at line 164 of file ConstantFPRange.cpp.
References extendZeroIfEqual(), llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ONE, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UEQ, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNE, llvm::CmpInst::FCMP_UNO, llvm::APFloat::getInf(), llvm::APFloat::getLargest(), getNaNOnly(), getNonNaN(), llvm::CmpInst::isOrdered(), llvm::CmpInst::isUnordered(), llvm_unreachable, makeGreaterThan(), makeLessThan(), llvm::Other, and setNaNField().
|
static |
Produce the exact range such that all values in the returned range satisfy the given predicate with any value contained within Other.
Formally, this returns { x : fcmp op x Other is true }.
Example: Pred = olt and Other = float 3 returns [-inf, 3) If the exact answer is not representable as a ConstantFPRange, returns std::nullopt.
Definition at line 269 of file ConstantFPRange.cpp.
References llvm::CmpInst::FCMP_ONE, llvm::CmpInst::FCMP_UNE, makeSatisfyingFCmpRegion(), and llvm::Other.
|
static |
Produce the largest range such that all values in the returned range satisfy the given predicate with all values contained within Other.
Formally, this returns a subset of 'intersection over all y in Other . { x : fcmp op x y is true }'. If the exact answer is not representable as a ConstantFPRange, the return value will be a proper subset of the above.
Example: Pred = ole and Other = float [2, 5] returns [-inf, 2]
Definition at line 222 of file ConstantFPRange.cpp.
References extendZeroIfEqual(), llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ONE, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UEQ, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNE, llvm::CmpInst::FCMP_UNO, llvm::fcNan, llvm::fcZero, getNaNOnly(), getNonNaN(), llvm::CmpInst::isOrdered(), llvm::CmpInst::isUnordered(), llvm_unreachable, makeGreaterThan(), makeLessThan(), llvm::Other, and setNaNField().
Referenced by fcmp(), and makeExactFCmpRegion().
|
inline |
Return true if this range is not equal to another range.
Definition at line 181 of file ConstantFPRange.h.
References llvm::operator==().
bool ConstantFPRange::operator== | ( | const ConstantFPRange & | CR | ) | const |
Return true if this range is equal to another range.
Definition at line 328 of file ConstantFPRange.cpp.
References llvm::APFloat::bitwiseIsEqual().
void ConstantFPRange::print | ( | raw_ostream & | OS | ) | const |
Print out the bounds to a stream.
Definition at line 350 of file ConstantFPRange.cpp.
References isEmptySet(), isFullSet(), isNaNOnly(), and OS.
Referenced by dump(), and llvm::operator<<().
ConstantFPRange ConstantFPRange::unionWith | ( | const ConstantFPRange & | CR | ) | const |
Return the smallest range that results from the union of this range with another range.
The resultant range is guaranteed to include the elements of both sets, but may contain more.
Definition at line 388 of file ConstantFPRange.cpp.
References assert(), getSemantics(), llvm::maxnum(), and llvm::minnum().