[llvm] 3b7091b - [APFloat] add predicates to fltSemantics for hasZero and hasSignedRepr (#111451)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 9 05:37:43 PDT 2024
Author: Ariel-Burton
Date: 2024-10-09T08:37:40-04:00
New Revision: 3b7091bcf3b48b63724500d821dc7a0ce8ffa3c9
URL: https://github.com/llvm/llvm-project/commit/3b7091bcf3b48b63724500d821dc7a0ce8ffa3c9
DIFF: https://github.com/llvm/llvm-project/commit/3b7091bcf3b48b63724500d821dc7a0ce8ffa3c9.diff
LOG: [APFloat] add predicates to fltSemantics for hasZero and hasSignedRepr (#111451)
We add static methods to APFloatBase to allow the hasZero and
hasSignedRepr properties of fltSemantics to be obtained.
Added:
Modified:
llvm/include/llvm/ADT/APFloat.h
llvm/lib/Support/APFloat.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index c3bbd9d83a0ecb..6f1e24e5da33a9 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -309,6 +309,8 @@ struct APFloatBase {
static ExponentType semanticsMaxExponent(const fltSemantics &);
static unsigned int semanticsSizeInBits(const fltSemantics &);
static unsigned int semanticsIntSizeInBits(const fltSemantics&, bool);
+ static bool semanticsHasZero(const fltSemantics &);
+ static bool semanticsHasSignedRepr(const fltSemantics &);
// Returns true if any number described by \p Src can be precisely represented
// by a normal (not subnormal) value in \p Dst.
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index d1b3c936dc589e..a33b6c4a6ddc63 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -367,6 +367,14 @@ unsigned int APFloatBase::semanticsIntSizeInBits(const fltSemantics &semantics,
return MinBitWidth;
}
+bool APFloatBase::semanticsHasZero(const fltSemantics &semantics) {
+ return semantics.hasZero;
+}
+
+bool APFloatBase::semanticsHasSignedRepr(const fltSemantics &semantics) {
+ return semantics.hasSignedRepr;
+}
+
bool APFloatBase::isRepresentableAsNormalIn(const fltSemantics &Src,
const fltSemantics &Dst) {
// Exponent range must be larger.
More information about the llvm-commits
mailing list