@@ -232,11 +232,6 @@ class IEEEFloat final : public APFloatBase {
232
232
// / \name Convenience "constructors"
233
233
// / @{
234
234
235
- // / Returns a float which is bitcasted from an all one value int.
236
- // /
237
- // / \param BitWidth - Select float type
238
- static IEEEFloat getAllOnesValue (unsigned BitWidth);
239
-
240
235
// / @}
241
236
242
237
// / Used to insert APFloat objects, or objects that contain APFloat objects,
@@ -645,8 +640,11 @@ class APFloat : public APFloatBase {
645
640
IEEEFloat IEEE;
646
641
DoubleAPFloat Double;
647
642
648
- explicit Storage (IEEEFloat F) : IEEE (std::move (F)) {}
649
- explicit Storage (DoubleAPFloat F) : Double (std::move (F)) {}
643
+ explicit Storage (IEEEFloat F, const fltSemantics &S);
644
+ explicit Storage (DoubleAPFloat F, const fltSemantics &S)
645
+ : Double (std::move (F)) {
646
+ assert (&S == &PPCDoubleDouble);
647
+ }
650
648
651
649
template <typename ... ArgTypes>
652
650
Storage (const fltSemantics &Semantics, ArgTypes &&... Args) {
@@ -770,8 +768,9 @@ class APFloat : public APFloatBase {
770
768
llvm_unreachable (" This is a workaround for old clang." );
771
769
}
772
770
773
- explicit APFloat (IEEEFloat F) : U(std::move(F)) {}
774
- explicit APFloat (DoubleAPFloat F) : U(std::move(F)) {}
771
+ explicit APFloat (IEEEFloat F, const fltSemantics &S) : U(std::move(F), S) {}
772
+ explicit APFloat (DoubleAPFloat F, const fltSemantics &S)
773
+ : U(std::move(F), S) {}
775
774
776
775
public:
777
776
APFloat (const fltSemantics &Semantics) : U(Semantics) {}
@@ -781,8 +780,8 @@ class APFloat : public APFloatBase {
781
780
APFloat (const fltSemantics &Semantics, uninitializedTag)
782
781
: U(Semantics, uninitialized) {}
783
782
APFloat (const fltSemantics &Semantics, const APInt &I) : U(Semantics, I) {}
784
- explicit APFloat (double d) : U(IEEEFloat(d)) {}
785
- explicit APFloat (float f) : U(IEEEFloat(f)) {}
783
+ explicit APFloat (double d) : U(IEEEFloat(d), IEEEdouble ) {}
784
+ explicit APFloat (float f) : U(IEEEFloat(f), IEEEsingle ) {}
786
785
APFloat (const APFloat &RHS) = default ;
787
786
APFloat (APFloat &&RHS) = default ;
788
787
@@ -881,14 +880,7 @@ class APFloat : public APFloatBase {
881
880
// /
882
881
// / \param BitWidth - Select float type
883
882
// / \param isIEEE - If 128 bit number, select between PPC and IEEE
884
- static APFloat getAllOnesValue (unsigned BitWidth, bool isIEEE = false ) {
885
- if (isIEEE) {
886
- return APFloat (IEEEFloat::getAllOnesValue (BitWidth));
887
- } else {
888
- assert (BitWidth == 128 );
889
- return APFloat (PPCDoubleDouble, APInt::getAllOnesValue (BitWidth));
890
- }
891
- }
883
+ static APFloat getAllOnesValue (unsigned BitWidth, bool isIEEE = false );
892
884
893
885
void Profile (FoldingSetNodeID &NID) const { getIEEE ().Profile (NID); }
894
886
@@ -919,27 +911,28 @@ class APFloat : public APFloatBase {
919
911
opStatus next (bool nextDown) { return getIEEE ().next (nextDown); }
920
912
921
913
APFloat operator +(const APFloat &RHS) const {
922
- return APFloat (getIEEE () + RHS.getIEEE ());
914
+ return APFloat (getIEEE () + RHS.getIEEE (), getSemantics () );
923
915
}
924
916
925
917
APFloat operator -(const APFloat &RHS) const {
926
- return APFloat (getIEEE () - RHS.getIEEE ());
918
+ return APFloat (getIEEE () - RHS.getIEEE (), getSemantics () );
927
919
}
928
920
929
921
APFloat operator *(const APFloat &RHS) const {
930
- return APFloat (getIEEE () * RHS.getIEEE ());
922
+ return APFloat (getIEEE () * RHS.getIEEE (), getSemantics () );
931
923
}
932
924
933
925
APFloat operator /(const APFloat &RHS) const {
934
- return APFloat (getIEEE () / RHS.getIEEE ());
926
+ return APFloat (getIEEE () / RHS.getIEEE (), getSemantics () );
935
927
}
936
928
937
929
void changeSign () { getIEEE ().changeSign (); }
938
930
void clearSign () { getIEEE ().clearSign (); }
939
931
void copySign (const APFloat &RHS) { getIEEE ().copySign (RHS.getIEEE ()); }
940
932
941
933
static APFloat copySign (APFloat Value, const APFloat &Sign) {
942
- return APFloat (IEEEFloat::copySign (Value.getIEEE (), Sign.getIEEE ()));
934
+ return APFloat (IEEEFloat::copySign (Value.getIEEE (), Sign.getIEEE ()),
935
+ Value.getSemantics ());
943
936
}
944
937
945
938
opStatus convert (const fltSemantics &ToSemantics, roundingMode RM,
@@ -1035,15 +1028,15 @@ class APFloat : public APFloatBase {
1035
1028
// / xlC compiler.
1036
1029
hash_code hash_value (const APFloat &Arg);
1037
1030
inline APFloat scalbn (APFloat X, int Exp, APFloat::roundingMode RM) {
1038
- return APFloat (scalbn (X.getIEEE (), Exp, RM));
1031
+ return APFloat (scalbn (X.getIEEE (), Exp, RM), X. getSemantics () );
1039
1032
}
1040
1033
1041
1034
// / \brief Equivalent of C standard library function.
1042
1035
// /
1043
1036
// / While the C standard says Exp is an unspecified value for infinity and nan,
1044
1037
// / this returns INT_MAX for infinities, and INT_MIN for NaNs.
1045
1038
inline APFloat frexp (const APFloat &X, int &Exp, APFloat::roundingMode RM) {
1046
- return APFloat (frexp (X.getIEEE (), Exp, RM));
1039
+ return APFloat (frexp (X.getIEEE (), Exp, RM), X. getSemantics () );
1047
1040
}
1048
1041
// / \brief Returns the absolute value of the argument.
1049
1042
inline APFloat abs (APFloat X) {
0 commit comments