@@ -164,42 +164,7 @@ static constexpr fltSemantics semFloat4E2M1FN = {
164164 2 , 0 , 2 , 4 , fltNonfiniteBehavior::FiniteOnly};
165165static constexpr fltSemantics semX87DoubleExtended = {16383 , -16382 , 64 , 80 };
166166static constexpr fltSemantics semBogus = {0 , 0 , 0 , 0 };
167-
168- /* The IBM double-double semantics. Such a number consists of a pair of IEEE
169- 64-bit doubles (Hi, Lo), where |Hi| > |Lo|, and if normal,
170- (double)(Hi + Lo) == Hi. The numeric value it's modeling is Hi + Lo.
171- Therefore it has two 53-bit mantissa parts that aren't necessarily adjacent
172- to each other, and two 11-bit exponents.
173-
174- Note: we need to make the value different from semBogus as otherwise
175- an unsafe optimization may collapse both values to a single address,
176- and we heavily rely on them having distinct addresses. */
177167static constexpr fltSemantics semPPCDoubleDouble = {-1 , 0 , 0 , 128 };
178-
179- /* These are legacy semantics for the fallback, inaccrurate implementation of
180- IBM double-double, if the accurate semPPCDoubleDouble doesn't handle the
181- operation. It's equivalent to having an IEEE number with consecutive 106
182- bits of mantissa and 11 bits of exponent.
183-
184- It's not equivalent to IBM double-double. For example, a legit IBM
185- double-double, 1 + epsilon:
186-
187- 1 + epsilon = 1 + (1 >> 1076)
188-
189- is not representable by a consecutive 106 bits of mantissa.
190-
191- Currently, these semantics are used in the following way:
192-
193- semPPCDoubleDouble -> (IEEEdouble, IEEEdouble) ->
194- (64-bit APInt, 64-bit APInt) -> (128-bit APInt) ->
195- semPPCDoubleDoubleLegacy -> IEEE operations
196-
197- We use bitcastToAPInt() to get the bit representation (in APInt) of the
198- underlying IEEEdouble, then use the APInt constructor to construct the
199- legacy IEEE float.
200-
201- TODO: Implement all operations in semPPCDoubleDouble, and delete these
202- semantics. */
203168static constexpr fltSemantics semPPCDoubleDoubleLegacy = {1023 , -1022 + 53 ,
204169 53 + 53 , 128 };
205170
@@ -217,6 +182,8 @@ const llvm::fltSemantics &APFloatBase::EnumToSemantics(Semantics S) {
217182 return IEEEquad ();
218183 case S_PPCDoubleDouble:
219184 return PPCDoubleDouble ();
185+ case S_PPCDoubleDoubleLegacy:
186+ return PPCDoubleDoubleLegacy ();
220187 case S_Float8E5M2:
221188 return Float8E5M2 ();
222189 case S_Float8E5M2FNUZ:
@@ -261,6 +228,8 @@ APFloatBase::SemanticsToEnum(const llvm::fltSemantics &Sem) {
261228 return S_IEEEquad;
262229 else if (&Sem == &llvm::APFloat::PPCDoubleDouble ())
263230 return S_PPCDoubleDouble;
231+ else if (&Sem == &llvm::APFloat::PPCDoubleDoubleLegacy ())
232+ return S_PPCDoubleDoubleLegacy;
264233 else if (&Sem == &llvm::APFloat::Float8E5M2 ())
265234 return S_Float8E5M2;
266235 else if (&Sem == &llvm::APFloat::Float8E5M2FNUZ ())
@@ -299,6 +268,9 @@ const fltSemantics &APFloatBase::IEEEquad() { return semIEEEquad; }
299268const fltSemantics &APFloatBase::PPCDoubleDouble () {
300269 return semPPCDoubleDouble;
301270}
271+ const fltSemantics &APFloatBase::PPCDoubleDoubleLegacy () {
272+ return semPPCDoubleDoubleLegacy;
273+ }
302274const fltSemantics &APFloatBase::Float8E5M2 () { return semFloat8E5M2; }
303275const fltSemantics &APFloatBase::Float8E5M2FNUZ () { return semFloat8E5M2FNUZ; }
304276const fltSemantics &APFloatBase::Float8E4M3 () { return semFloat8E4M3; }
@@ -3574,7 +3546,7 @@ APInt IEEEFloat::convertF80LongDoubleAPFloatToAPInt() const {
35743546 return APInt (80 , words);
35753547}
35763548
3577- APInt IEEEFloat::convertPPCDoubleDoubleAPFloatToAPInt () const {
3549+ APInt IEEEFloat::convertPPCDoubleDoubleLegacyAPFloatToAPInt () const {
35783550 assert (semantics == (const llvm::fltSemantics *)&semPPCDoubleDoubleLegacy);
35793551 assert (partCount ()==2 );
35803552
@@ -3796,7 +3768,7 @@ APInt IEEEFloat::bitcastToAPInt() const {
37963768 return convertQuadrupleAPFloatToAPInt ();
37973769
37983770 if (semantics == (const llvm::fltSemantics *)&semPPCDoubleDoubleLegacy)
3799- return convertPPCDoubleDoubleAPFloatToAPInt ();
3771+ return convertPPCDoubleDoubleLegacyAPFloatToAPInt ();
38003772
38013773 if (semantics == (const llvm::fltSemantics *)&semFloat8E5M2)
38023774 return convertFloat8E5M2APFloatToAPInt ();
@@ -3900,7 +3872,7 @@ void IEEEFloat::initFromF80LongDoubleAPInt(const APInt &api) {
39003872 }
39013873}
39023874
3903- void IEEEFloat::initFromPPCDoubleDoubleAPInt (const APInt &api) {
3875+ void IEEEFloat::initFromPPCDoubleDoubleLegacyAPInt (const APInt &api) {
39043876 uint64_t i1 = api.getRawData ()[0 ];
39053877 uint64_t i2 = api.getRawData ()[1 ];
39063878 opStatus fs;
@@ -4119,7 +4091,7 @@ void IEEEFloat::initFromAPInt(const fltSemantics *Sem, const APInt &api) {
41194091 if (Sem == &semIEEEquad)
41204092 return initFromQuadrupleAPInt (api);
41214093 if (Sem == &semPPCDoubleDoubleLegacy)
4122- return initFromPPCDoubleDoubleAPInt (api);
4094+ return initFromPPCDoubleDoubleLegacyAPInt (api);
41234095 if (Sem == &semFloat8E5M2)
41244096 return initFromFloat8E5M2APInt (api);
41254097 if (Sem == &semFloat8E5M2FNUZ)
@@ -4145,7 +4117,7 @@ void IEEEFloat::initFromAPInt(const fltSemantics *Sem, const APInt &api) {
41454117 if (Sem == &semFloat4E2M1FN)
41464118 return initFromFloat4E2M1FNAPInt (api);
41474119
4148- llvm_unreachable (nullptr );
4120+ llvm_unreachable (" unsupported semantics " );
41494121}
41504122
41514123// / Make this number the largest magnitude normal number in the given
0 commit comments