[llvm] [APFloat] add predicates to fltSemantics for hasZero and hasSignedRepr (PR #111451)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 12:38:45 PDT 2024
https://github.com/Ariel-Burton updated https://github.com/llvm/llvm-project/pull/111451
>From 1ec3094f15ee45239f2a26482620e4ddc60a62e3 Mon Sep 17 00:00:00 2001
From: Ariel Burton <ariel.burton at ibm.com>
Date: Mon, 7 Oct 2024 23:01:30 +0000
Subject: [PATCH] [APFloat] add predicaes to fltSemantics for hasZero and
hasSignedRepr
We add static methods to APFloatBase to allow the hasZero
and hasSignedRepr properties of fltSemantics to be obtained.
---
llvm/include/llvm/ADT/APFloat.h | 2 ++
llvm/lib/Support/APFloat.cpp | 8 ++++++++
2 files changed, 10 insertions(+)
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.
More information about the llvm-commits
mailing list