[llvm] [APFloat] add predicaes to fltSemantics for hasZero and hasSignedRepr (PR #111451)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 15:56:00 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: None (Ariel-Burton)
<details>
<summary>Changes</summary>
We add static methods to APFloatBase to allow the hasZero and hasSignedRepr properties of fltSemantics to be obtained.
---
Full diff: https://github.com/llvm/llvm-project/pull/111451.diff
2 Files Affected:
- (modified) llvm/include/llvm/ADT/APFloat.h (+2)
- (modified) llvm/lib/Support/APFloat.cpp (+8)
``````````diff
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index 40131c83a8ef45..e7e32be0ef595c 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 03413f6eb6fe71..25500d29c4e4ea 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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/111451
More information about the llvm-commits
mailing list