@@ -125,14 +125,6 @@ struct fltSemantics {
125125
126126 /* Whether this semantics can represent signed values */
127127 bool hasSignedRepr = true ;
128-
129- // Returns true if any number described by this semantics can be precisely
130- // represented by the specified semantics. Does not take into account
131- // the value of fltNonfiniteBehavior.
132- bool isRepresentableBy (const fltSemantics &S) const {
133- return maxExponent <= S.maxExponent && minExponent >= S.minExponent &&
134- precision <= S.precision ;
135- }
136128};
137129
138130static constexpr fltSemantics semIEEEhalf = {15 , -14 , 11 , 16 };
@@ -290,6 +282,13 @@ const fltSemantics &APFloatBase::x87DoubleExtended() {
290282}
291283const fltSemantics &APFloatBase::Bogus () { return semBogus; }
292284
285+ bool APFloatBase::isRepresentableBy (const fltSemantics &A,
286+ const fltSemantics &B) {
287+ return A.maxExponent <= B.maxExponent && A.minExponent >= B.minExponent &&
288+ A.precision <= B.precision && A.hasSignedRepr == B.hasSignedRepr &&
289+ A.hasZero == B.hasZero ;
290+ }
291+
293292constexpr RoundingMode APFloatBase::rmNearestTiesToEven;
294293constexpr RoundingMode APFloatBase::rmTowardPositive;
295294constexpr RoundingMode APFloatBase::rmTowardNegative;
@@ -5527,7 +5526,7 @@ APFloat::opStatus APFloat::convertToInteger(APSInt &result,
55275526double APFloat::convertToDouble () const {
55285527 if (&getSemantics () == (const llvm::fltSemantics *)&semIEEEdouble)
55295528 return getIEEE ().convertToDouble ();
5530- assert (getSemantics (). isRepresentableBy ( semIEEEdouble) &&
5529+ assert (isRepresentableBy ( getSemantics (), semIEEEdouble) &&
55315530 " Float semantics is not representable by IEEEdouble" );
55325531 APFloat Temp = *this ;
55335532 bool LosesInfo;
@@ -5541,7 +5540,7 @@ double APFloat::convertToDouble() const {
55415540float128 APFloat::convertToQuad () const {
55425541 if (&getSemantics () == (const llvm::fltSemantics *)&semIEEEquad)
55435542 return getIEEE ().convertToQuad ();
5544- assert (getSemantics (). isRepresentableBy ( semIEEEquad) &&
5543+ assert (isRepresentableBy ( getSemantics (), semIEEEquad) &&
55455544 " Float semantics is not representable by IEEEquad" );
55465545 APFloat Temp = *this ;
55475546 bool LosesInfo;
@@ -5555,7 +5554,7 @@ float128 APFloat::convertToQuad() const {
55555554float APFloat::convertToFloat () const {
55565555 if (&getSemantics () == (const llvm::fltSemantics *)&semIEEEsingle)
55575556 return getIEEE ().convertToFloat ();
5558- assert (getSemantics (). isRepresentableBy ( semIEEEsingle) &&
5557+ assert (isRepresentableBy ( getSemantics (), semIEEEsingle) &&
55595558 " Float semantics is not representable by IEEEsingle" );
55605559 APFloat Temp = *this ;
55615560 bool LosesInfo;
0 commit comments