diff options
author | Matthias Springer <me@m-sp.org> | 2024-11-15 09:29:54 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 09:29:54 +0900 |
commit | 2f55de4e317ee93cdca839558acf8be2b5ac2b46 (patch) | |
tree | b17ec11d95569389d822fa971868250246e185eb /llvm/lib | |
parent | eec21ccee0950d52926a79685573db1996e3ba5b (diff) | |
download | llvm-2f55de4e317ee93cdca839558acf8be2b5ac2b46.zip llvm-2f55de4e317ee93cdca839558acf8be2b5ac2b46.tar.gz llvm-2f55de4e317ee93cdca839558acf8be2b5ac2b46.tar.bz2 |
[llvm] `APFloat`: Query `hasNanOrInf` from semantics (#116158)
Whether a floating point type supports NaN or infinity can be queried
from its semantics. No need to hard-code a list of types.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index c566d48..58bf002 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -375,6 +375,10 @@ bool APFloatBase::semanticsHasSignedRepr(const fltSemantics &semantics) { return semantics.hasSignedRepr; } +bool APFloatBase::semanticsHasNanOrInf(const fltSemantics &semantics) { + return semantics.nonFiniteBehavior != fltNonfiniteBehavior::FiniteOnly; +} + bool APFloatBase::isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst) { // Exponent range must be larger. |