File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,8 @@ struct APFloatBase {
311
311
static unsigned int semanticsIntSizeInBits (const fltSemantics&, bool );
312
312
static bool semanticsHasZero (const fltSemantics &);
313
313
static bool semanticsHasSignedRepr (const fltSemantics &);
314
+ static bool semanticsHasInf (const fltSemantics &);
315
+ static bool semanticsHasNan (const fltSemantics &);
314
316
315
317
// Returns true if any number described by \p Src can be precisely represented
316
318
// by a normal (not subnormal) value in \p Dst.
@@ -1127,19 +1129,11 @@ class APFloat : public APFloatBase {
1127
1129
// / \param Semantics - type float semantics
1128
1130
static APFloat getAllOnesValue (const fltSemantics &Semantics);
1129
1131
1130
- // / Returns true if the given semantics supports either NaN or Infinity.
1132
+ // / Returns true if the given semantics supports NaN or Infinity.
1131
1133
// /
1132
1134
// / \param Sem - type float semantics
1133
1135
static bool hasNanOrInf (const fltSemantics &Sem) {
1134
- switch (SemanticsToEnum (Sem)) {
1135
- default :
1136
- return true ;
1137
- // Below Semantics do not support {NaN or Inf}
1138
- case APFloat::S_Float6E3M2FN:
1139
- case APFloat::S_Float6E2M3FN:
1140
- case APFloat::S_Float4E2M1FN:
1141
- return false ;
1142
- }
1136
+ return semanticsHasNan (Sem) || semanticsHasInf (Sem);
1143
1137
}
1144
1138
1145
1139
// / Returns true if the given semantics has actual significand.
Original file line number Diff line number Diff line change @@ -375,6 +375,15 @@ bool APFloatBase::semanticsHasSignedRepr(const fltSemantics &semantics) {
375
375
return semantics.hasSignedRepr ;
376
376
}
377
377
378
+ bool APFloatBase::semanticsHasInf (const fltSemantics &semantics) {
379
+ return semantics.nonFiniteBehavior != fltNonfiniteBehavior::NanOnly
380
+ && semantics.nonFiniteBehavior != fltNonfiniteBehavior::FiniteOnly;
381
+ }
382
+
383
+ bool APFloatBase::semanticsHasNan (const fltSemantics &semantics) {
384
+ return semantics.nonFiniteBehavior != fltNonfiniteBehavior::FiniteOnly;
385
+ }
386
+
378
387
bool APFloatBase::isRepresentableAsNormalIn (const fltSemantics &Src,
379
388
const fltSemantics &Dst) {
380
389
// Exponent range must be larger.
You can’t perform that action at this time.
0 commit comments