Skip to content

[APFloat] add predicates to fltSemantics for hasZero and hasSignedRepr #111451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Ariel-Burton
Copy link
Contributor

We add static methods to APFloatBase to allow the hasZero and hasSignedRepr properties of fltSemantics to be obtained.

@llvmbot
Copy link
Member

llvmbot commented Oct 7, 2024

@llvm/pr-subscribers-llvm-adt

Author: None (Ariel-Burton)

Changes

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 --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.

@llvmbot
Copy link
Member

llvmbot commented Oct 7, 2024

@llvm/pr-subscribers-llvm-support

Author: None (Ariel-Burton)

Changes

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 --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.

We add static methods to APFloatBase to allow the hasZero
and hasSignedRepr properties of fltSemantics to be obtained.
@Ariel-Burton Ariel-Burton changed the title [APFloat] add predicaes to fltSemantics for hasZero and hasSignedRepr [APFloat] add predicates to fltSemantics for hasZero and hasSignedRepr Oct 7, 2024
Copy link
Contributor

@durga4github durga4github left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@abhina-sree abhina-sree merged commit 3b7091b into llvm:main Oct 9, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants