LLVM: include/llvm/ADT/APFloat.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LLVM_ADT_APFLOAT_H

16#define LLVM_ADT_APFLOAT_H

17

23#include

24

25#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \

26 do { \

27 if (usesLayout(getSemantics())) \

28 return U.IEEE.METHOD_CALL; \

29 if (usesLayout(getSemantics())) \

30 return U.Double.METHOD_CALL; \

31 llvm_unreachable("Unexpected semantics"); \

32 } while (false)

33

34namespace llvm {

35

36struct fltSemantics;

37class APSInt;

38class StringRef;

39class APFloat;

40class raw_ostream;

41

42template class Expected;

43template class SmallVectorImpl;

44

45

46

47

48

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

146

147

149

150

151

158

159

160

161

162

163

164

165

166

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

193

194

196

197

198

199

200

201

203

204

206

207

208

209

211

212

213

214

215

216

218

219

220

221

222

223

225

226

228

229

230

232

233

234

235

236

237

239

240

241

243

244

245

247

248

249

251

254 };

255

258

279

280

281

283

284

285

286

288

289

290

291

298

299

301

309

310

311

312

313

314

315

316

317

326

327

334

335

339

340

346

356

357

358

361

362

363

365};

366

368

399

401public:

402

403

404

414

415

416

417

419

420

421

422

423

424

425

426

427

432

434

438

440

441

442

443

444

445

447

448

449

450

451

452

464#ifdef HAS_IEE754_FLOAT128

465 float128 convertToQuad() const;

466#endif

468

469

470

471

472

473

475

476

477

479

480

482

483

484

485

488

489

490

491

492

493

494

495

497

498

499

500

501

503

504

505

506

507

509

510

511 bool isZero() const { return category == fltCategory::fcZero; }

512

513

514

516

517

519

520

522

523

525

526

527

528

529

530

533 bool isNonZero() const { return category != fltCategory::fcZero; }

537

538

539

541

542

543

545

546

547

549

550

552

553

554

557

558

559

560

561

562

563

564

565

566

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

596 unsigned FormatMaxPadding = 3, bool TruncateZero = true) const;

597

598

599

601

602

603

606

607

608

612 }

613

614

615

616

617

618

619

620

621

622

624

625

627

629

630

631

632

635 void makeNaN(bool SNaN = false, bool Neg = false,

636 const APInt *fill = nullptr);

637 void makeInf(bool Neg = false);

638 void makeZero(bool Neg = false);

640

641

642

643

644

646

647

648

650

651private:

652

653

654

656 const integerPart *significandParts() const;

657 unsigned int partCount() const;

658

659

660

661

662

663

668 bool ignoreAddend = false);

671 void incrementSignificand();

673 void shiftSignificandLeft(unsigned int);

674 lostFraction shiftSignificandRight(unsigned int);

675 unsigned int significandLSB() const;

676 unsigned int significandMSB() const;

677 void zeroSignificand();

678 unsigned int getNumHighBits() const;

679

680 bool isSignificandAllOnes() const;

681 bool isSignificandAllOnesExceptLSB() const;

682

683 bool isSignificandAllZeros() const;

684 bool isSignificandAllZerosExceptMSB() const;

685

686

687

688

689

690

696

697

698

699

700

701

702 bool convertFromStringSpecials(StringRef str);

709 bool *) const;

714 char *convertNormalToHexString(char *, unsigned int, bool,

716 opStatus roundSignificandWithExponent(const integerPart *, unsigned int, int,

721

722

723

724 template <const fltSemantics &S> APInt convertIEEEFloatToAPInt() const;

725 APInt convertHalfAPFloatToAPInt() const;

726 APInt convertBFloatAPFloatToAPInt() const;

727 APInt convertFloatAPFloatToAPInt() const;

728 APInt convertDoubleAPFloatToAPInt() const;

729 APInt convertQuadrupleAPFloatToAPInt() const;

730 APInt convertF80LongDoubleAPFloatToAPInt() const;

731 APInt convertPPCDoubleDoubleLegacyAPFloatToAPInt() const;

732 APInt convertFloat8E5M2APFloatToAPInt() const;

733 APInt convertFloat8E5M2FNUZAPFloatToAPInt() const;

734 APInt convertFloat8E4M3APFloatToAPInt() const;

735 APInt convertFloat8E4M3FNAPFloatToAPInt() const;

736 APInt convertFloat8E4M3FNUZAPFloatToAPInt() const;

737 APInt convertFloat8E4M3B11FNUZAPFloatToAPInt() const;

738 APInt convertFloat8E3M4APFloatToAPInt() const;

739 APInt convertFloatTF32APFloatToAPInt() const;

740 APInt convertFloat8E8M0FNUAPFloatToAPInt() const;

741 APInt convertFloat6E3M2FNAPFloatToAPInt() const;

742 APInt convertFloat6E2M3FNAPFloatToAPInt() const;

743 APInt convertFloat4E2M1FNAPFloatToAPInt() const;

745 template <const fltSemantics &S> void initFromIEEEAPInt(const APInt &api);

746 void initFromHalfAPInt(const APInt &api);

747 void initFromBFloatAPInt(const APInt &api);

748 void initFromFloatAPInt(const APInt &api);

749 void initFromDoubleAPInt(const APInt &api);

750 void initFromQuadrupleAPInt(const APInt &api);

751 void initFromF80LongDoubleAPInt(const APInt &api);

752 void initFromPPCDoubleDoubleLegacyAPInt(const APInt &api);

753 void initFromFloat8E5M2APInt(const APInt &api);

754 void initFromFloat8E5M2FNUZAPInt(const APInt &api);

755 void initFromFloat8E4M3APInt(const APInt &api);

756 void initFromFloat8E4M3FNAPInt(const APInt &api);

757 void initFromFloat8E4M3FNUZAPInt(const APInt &api);

758 void initFromFloat8E4M3B11FNUZAPInt(const APInt &api);

759 void initFromFloat8E3M4APInt(const APInt &api);

760 void initFromFloatTF32APInt(const APInt &api);

761 void initFromFloat8E8M0FNUAPInt(const APInt &api);

762 void initFromFloat6E3M2FNAPInt(const APInt &api);

763 void initFromFloat6E2M3FNAPInt(const APInt &api);

764 void initFromFloat4E2M1FNAPInt(const APInt &api);

765

767 void copySignificand(const IEEEFloat &);

768 void freeSignificand();

769

770

771

773

774

775

776

777 union Significand {

780 } significand;

781

782

784

785

786

787

788

790

791

792 unsigned int sign : 1;

793};

794

795hash_code hash_value(const IEEEFloat &Arg);

796int ilogb(const IEEEFloat &Arg);

799

800

801

802

803

805

807 std::unique_ptr<APFloat[]> Floats;

808

811

814

815public:

823

826

828

833

845

848

854 void makeNaN(bool SNaN, bool Neg, const APInt *fill);

855

861

863 unsigned int Width, bool IsSigned, roundingMode RM,

864 bool *IsExact) const;

867 unsigned int InputSize, bool IsSigned,

870 unsigned int InputSize, bool IsSigned,

874

880

882 unsigned FormatMaxPadding, bool TruncateZero = true) const;

883

885

890

894};

895

899

900}

901

902

903

907

908 static_assert(std::is_standard_layout::value);

909

910 union Storage {

914

917 : Double(std::move(F)) {

919 }

920

921 template <typename... ArgTypes>

923 if (usesLayout(Semantics)) {

925 return;

926 }

927 if (usesLayout(Semantics)) {

929 return;

930 }

932 }

933

934 ~Storage() {

935 if (usesLayout(*semantics)) {

936 IEEE.~IEEEFloat();

937 return;

938 }

939 if (usesLayout(*semantics)) {

940 Double.~DoubleAPFloat();

941 return;

942 }

944 }

945

946 Storage(const Storage &RHS) {

947 if (usesLayout(*RHS.semantics)) {

949 return;

950 }

951 if (usesLayout(*RHS.semantics)) {

953 return;

954 }

956 }

957

958 Storage(Storage &&RHS) {

959 if (usesLayout(*RHS.semantics)) {

961 return;

962 }

963 if (usesLayout(*RHS.semantics)) {

965 return;

966 }

968 }

969

970 Storage &operator=(const Storage &RHS) {

971 if (usesLayout(*semantics) &&

972 usesLayout(*RHS.semantics)) {

974 } else if (usesLayout(*semantics) &&

975 usesLayout(*RHS.semantics)) {

976 Double = RHS.Double;

977 } else if (this != &RHS) {

978 this->~Storage();

979 new (this) Storage(RHS);

980 }

981 return *this;

982 }

983

984 Storage &operator=(Storage &&RHS) {

985 if (usesLayout(*semantics) &&

986 usesLayout(*RHS.semantics)) {

987 IEEE = std::move(RHS.IEEE);

988 } else if (usesLayout(*semantics) &&

989 usesLayout(*RHS.semantics)) {

990 Double = std::move(RHS.Double);

991 } else if (this != &RHS) {

992 this->~Storage();

993 new (this) Storage(std::move(RHS));

994 }

995 return *this;

996 }

997 } U;

998

1000 static_assert(std::is_same<T, IEEEFloat>::value ||

1001 std::is_same<T, DoubleAPFloat>::value);

1002 if (std::is_same<T, DoubleAPFloat>::value) {

1004 }

1006 }

1007

1009 if (usesLayout(*U.semantics))

1010 return U.IEEE;

1011 if (usesLayout(*U.semantics))

1012 return U.Double.getFirst().U.IEEE;

1014 }

1015

1016 const IEEEFloat &getIEEE() const {

1017 if (usesLayout(*U.semantics))

1018 return U.IEEE;

1019 if (usesLayout(*U.semantics))

1020 return U.Double.getFirst().U.IEEE;

1022 }

1023

1025

1027

1028 void makeNaN(bool SNaN, bool Neg, const APInt *fill) {

1030 }

1031

1032 void makeLargest(bool Neg) {

1034 }

1035

1036 void makeSmallest(bool Neg) {

1038 }

1039

1040 void makeSmallestNormalized(bool Neg) {

1042 }

1043

1046 : U(std::move(F), S) {}

1047

1050 "Should only compare APFloats with the same semantics");

1052 return U.IEEE.compareAbsoluteValue(RHS.U.IEEE);

1053 if (usesLayout(getSemantics()))

1054 return U.Double.compareAbsoluteValue(RHS.U.Double);

1056 }

1057

1058public:

1062 template <typename T,

1063 typename = std::enable_if_t<std::is_floating_point::value>>

1065

1073

1075

1077

1078

1079

1080

1083 Val.makeZero(Negative);

1084 return Val;

1085 }

1086

1087

1088

1089

1092 if (Negative)

1094 return Val;

1095 }

1096

1097

1098

1099

1102 Val.makeInf(Negative);

1103 return Val;

1104 }

1105

1106

1107

1108

1109

1110

1113 if (payload) {

1114 APInt intPayload(64, payload);

1115 return getQNaN(Sem, Negative, &intPayload);

1116 } else {

1117 return getQNaN(Sem, Negative, nullptr);

1118 }

1119 }

1120

1121

1123 const APInt *payload = nullptr) {

1125 Val.makeNaN(false, Negative, payload);

1126 return Val;

1127 }

1128

1129

1131 const APInt *payload = nullptr) {

1133 Val.makeNaN(true, Negative, payload);

1134 return Val;

1135 }

1136

1137

1138

1139

1142 Val.makeLargest(Negative);

1143 return Val;

1144 }

1145

1146

1147

1148

1149

1152 Val.makeSmallest(Negative);

1153 return Val;

1154 }

1155

1156

1157

1158

1159

1161 bool Negative = false) {

1163 Val.makeSmallestNormalized(Negative);

1164 return Val;

1165 }

1166

1167

1168

1169

1171

1172

1173

1174

1177 }

1178

1179

1180

1182

1185 "Should only call on two APFloats with the same semantics");

1187 return U.IEEE.add(RHS.U.IEEE, RM);

1188 if (usesLayout(getSemantics()))

1189 return U.Double.add(RHS.U.Double, RM);

1191 }

1194 "Should only call on two APFloats with the same semantics");

1196 return U.IEEE.subtract(RHS.U.IEEE, RM);

1197 if (usesLayout(getSemantics()))

1198 return U.Double.subtract(RHS.U.Double, RM);

1200 }

1203 "Should only call on two APFloats with the same semantics");

1205 return U.IEEE.multiply(RHS.U.IEEE, RM);

1206 if (usesLayout(getSemantics()))

1207 return U.Double.multiply(RHS.U.Double, RM);

1209 }

1212 "Should only call on two APFloats with the same semantics");

1214 return U.IEEE.divide(RHS.U.IEEE, RM);

1215 if (usesLayout(getSemantics()))

1216 return U.Double.divide(RHS.U.Double, RM);

1218 }

1221 "Should only call on two APFloats with the same semantics");

1223 return U.IEEE.remainder(RHS.U.IEEE);

1224 if (usesLayout(getSemantics()))

1225 return U.Double.remainder(RHS.U.Double);

1227 }

1230 "Should only call on two APFloats with the same semantics");

1232 return U.IEEE.mod(RHS.U.IEEE);

1233 if (usesLayout(getSemantics()))

1234 return U.Double.mod(RHS.U.Double);

1236 }

1240 "Should only call on APFloats with the same semantics");

1242 "Should only call on APFloats with the same semantics");

1244 return U.IEEE.fusedMultiplyAdd(Multiplicand.U.IEEE, Addend.U.IEEE, RM);

1245 if (usesLayout(getSemantics()))

1246 return U.Double.fusedMultiplyAdd(Multiplicand.U.Double, Addend.U.Double,

1247 RM);

1249 }

1252 }

1253

1254

1255

1258 }

1259

1260

1263 Result.changeSign();

1264 return Result;

1265 }

1266

1267

1268

1272 return Result;

1273 }

1274

1275

1276

1280 return Result;

1281 }

1282

1283

1284

1288 return Result;

1289 }

1290

1291

1292

1296 return Result;

1297 }

1298

1303 }

1307 }

1308

1309

1310

1312 Value.copySign(Sign);

1314 }

1315

1316

1317

1320 Result.getIEEE().makeQuiet();

1321 return Result;

1322 }

1323

1325 bool *losesInfo);

1327 unsigned int Width, bool IsSigned, roundingMode RM,

1328 bool *IsExact) const {

1331 }

1333 bool *IsExact) const;

1337 }

1339 unsigned int InputSize, bool IsSigned,

1343 }

1345 unsigned int InputSize, bool IsSigned,

1349 }

1353 }

1354

1355

1356

1357

1358

1359

1361

1362

1363

1364

1365

1366

1367#ifdef HAS_IEE754_FLOAT128

1368 float128 convertToQuad() const;

1369#endif

1370

1371

1372

1373

1374

1375

1377

1379

1381

1384 }

1385

1388 }

1389

1393 }

1394

1398 }

1399

1402 "Should only compare APFloats with the same semantics");

1404 return U.IEEE.compare(RHS.U.IEEE);

1405 if (usesLayout(getSemantics()))

1406 return U.Double.compare(RHS.U.Double);

1408 }

1409

1412 return false;

1414 return U.IEEE.bitwiseIsEqual(RHS.U.IEEE);

1415 if (usesLayout(getSemantics()))

1416 return U.Double.bitwiseIsEqual(RHS.U.Double);

1418 }

1419

1420

1421

1422

1423

1424

1425

1426

1427

1433 }

1434

1439 }

1440

1444

1448

1451

1464

1467 }

1468

1469

1471

1474

1476 unsigned FormatMaxPadding = 3, bool TruncateZero = true) const {

1478 toString(Str, FormatPrecision, FormatMaxPadding, TruncateZero));

1479 }

1480

1482 void dump() const;

1483

1486 }

1487

1491 }

1492

1496 }

1497

1504};

1505

1507 "Empty base class optimization is not performed.");

1508

1509

1510

1511

1512

1515 if (APFloat::usesLayoutdetail::IEEEFloat(X.getSemantics()))

1516 return APFloat(scalbn(X.U.IEEE, Exp, RM), X.getSemantics());

1517 if (APFloat::usesLayoutdetail::DoubleAPFloat(X.getSemantics()))

1518 return APFloat(scalbn(X.U.Double, Exp, RM), X.getSemantics());

1520}

1521

1522

1523

1524

1525

1527 if (APFloat::usesLayoutdetail::IEEEFloat(X.getSemantics()))

1528 return APFloat(frexp(X.U.IEEE, Exp, RM), X.getSemantics());

1529 if (APFloat::usesLayoutdetail::DoubleAPFloat(X.getSemantics()))

1530 return APFloat(frexp(X.U.Double, Exp, RM), X.getSemantics());

1532}

1533

1535 X.clearSign();

1536 return X;

1537}

1538

1539

1541 X.changeSign();

1542 return X;

1543}

1544

1545

1546

1547

1550 if (A.isNaN())

1551 return B;

1552 if (B.isNaN())

1553 return A;

1554 if (A.isZero() && B.isZero() && (A.isNegative() != B.isNegative()))

1555 return A.isNegative() ? A : B;

1556 return B < A ? B : A;

1557}

1558

1559

1560

1561

1564 if (A.isNaN())

1565 return B;

1566 if (B.isNaN())

1567 return A;

1568 if (A.isZero() && B.isZero() && (A.isNegative() != B.isNegative()))

1569 return A.isNegative() ? B : A;

1570 return A < B ? B : A;

1571}

1572

1573

1574

1575

1578 if (A.isNaN())

1579 return A.makeQuiet();

1580 if (B.isNaN())

1581 return B.makeQuiet();

1582 if (A.isZero() && B.isZero() && (A.isNegative() != B.isNegative()))

1583 return A.isNegative() ? A : B;

1584 return B < A ? B : A;

1585}

1586

1587

1588

1591 if (A.isNaN())

1592 return B.isNaN() ? B.makeQuiet() : B;

1593 if (B.isNaN())

1594 return A;

1595 if (A.isZero() && B.isZero() && (A.isNegative() != B.isNegative()))

1596 return A.isNegative() ? A : B;

1597 return B < A ? B : A;

1598}

1599

1600

1601

1602

1605 if (A.isNaN())

1606 return A.makeQuiet();

1607 if (B.isNaN())

1608 return B.makeQuiet();

1609 if (A.isZero() && B.isZero() && (A.isNegative() != B.isNegative()))

1610 return A.isNegative() ? B : A;

1611 return A < B ? B : A;

1612}

1613

1614

1615

1618 if (A.isNaN())

1619 return B.isNaN() ? B.makeQuiet() : B;

1620 if (B.isNaN())

1621 return A;

1622 if (A.isZero() && B.isZero() && (A.isNegative() != B.isNegative()))

1623 return A.isNegative() ? B : A;

1624 return A < B ? B : A;

1625}

1626

1628 V.print(OS);

1629 return OS;

1630}

1631

1632

1633

1634

1635

1637

1639 if (this != &RHS) {

1642 }

1643 return *this;

1644}

1645

1650

1651}

1652

1653}

1654

1655#undef APFLOAT_DISPATCH_ON_SEMANTICS

1656#endif

#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL)

This file implements a class to represent arbitrary precision integral constant values and operations...

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is MaybeLiveUses might be modified but its content should be ignored(since it might not be complete). DeadArgumentEliminationPass

static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")

Utilities for dealing with flags related to floating point properties and mode controls.

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)

Factory for QNaN values.

static APFloat getSNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)

Factory for SNaN values.

opStatus divide(const APFloat &RHS, roundingMode RM)

bool getExactInverse(APFloat *inv) const

APFloat & operator=(APFloat &&RHS)=default

bool isFiniteNonZero() const

APFloat(const APFloat &RHS)=default

void copySign(const APFloat &RHS)

opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)

LLVM_READONLY int getExactLog2Abs() const

opStatus subtract(const APFloat &RHS, roundingMode RM)

bool bitwiseIsEqual(const APFloat &RHS) const

APFloat operator+(const APFloat &RHS) const

Add two APFloats, rounding ties to the nearest even.

double convertToDouble() const

Converts this APFloat to host double value.

bool isPosInfinity() const

APFloat(APFloat &&RHS)=default

void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const

bool isExactlyValue(double V) const

We don't rely on operator== working on double values, as it returns true for things that are clearly ...

opStatus add(const APFloat &RHS, roundingMode RM)

LLVM_READONLY int getExactLog2() const

APFloat & operator=(const APFloat &RHS)=default

static APFloat getAllOnesValue(const fltSemantics &Semantics)

Returns a float which is bitcasted from an all one value int.

APFloat(const fltSemantics &Semantics, integerPart I)

bool operator!=(const APFloat &RHS) const

APFloat(const fltSemantics &Semantics, T V)=delete

const fltSemantics & getSemantics() const

APFloat operator-(const APFloat &RHS) const

Subtract two APFloats, rounding ties to the nearest even.

APFloat operator*(const APFloat &RHS) const

Multiply two APFloats, rounding ties to the nearest even.

APFloat(const fltSemantics &Semantics)

opStatus convertFromSignExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)

bool operator<(const APFloat &RHS) const

APFloat makeQuiet() const

Assuming this is an IEEE-754 NaN value, quiet its signaling bit.

opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)

static APFloat getOne(const fltSemantics &Sem, bool Negative=false)

Factory for Positive and Negative One.

unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const

opStatus multiply(const APFloat &RHS, roundingMode RM)

float convertToFloat() const

Converts this APFloat to host float value.

bool operator>(const APFloat &RHS) const

opStatus fusedMultiplyAdd(const APFloat &Multiplicand, const APFloat &Addend, roundingMode RM)

APFloat operator/(const APFloat &RHS) const

Divide the first APFloat by the second, rounding ties to the nearest even.

opStatus remainder(const APFloat &RHS)

APFloat operator-() const

Negate an APFloat.

static APFloat getSmallestNormalized(const fltSemantics &Sem, bool Negative=false)

Returns the smallest (by magnitude) normalized finite number in the given semantics.

APInt bitcastToAPInt() const

friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM)

static APFloat getLargest(const fltSemantics &Sem, bool Negative=false)

Returns the largest finite number in the given semantics.

opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const

opStatus next(bool nextDown)

static APFloat getInf(const fltSemantics &Sem, bool Negative=false)

Factory for Positive and Negative Infinity.

friend APFloat scalbn(APFloat X, int Exp, roundingMode RM)

bool operator>=(const APFloat &RHS) const

bool needsCleanup() const

static APFloat getSmallest(const fltSemantics &Sem, bool Negative=false)

Returns the smallest (by magnitude) finite number in the given semantics.

FPClassTest classify() const

Return the FPClassTest which will return true for the value.

bool operator==(const APFloat &RHS) const

opStatus mod(const APFloat &RHS)

friend int ilogb(const APFloat &Arg)

Expected< opStatus > convertFromString(StringRef, roundingMode)

fltCategory getCategory() const

APFloat(const fltSemantics &Semantics, uninitializedTag)

bool isNegInfinity() const

void print(raw_ostream &) const

static APFloat copySign(APFloat Value, const APFloat &Sign)

A static helper to produce a copy of an APFloat value with its sign copied from some other APFloat.

opStatus roundToIntegral(roundingMode RM)

friend hash_code hash_value(const APFloat &Arg)

See friend declarations above.

static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)

Factory for NaN values.

static bool hasSignificand(const fltSemantics &Sem)

Returns true if the given semantics has actual significand.

static APFloat getZero(const fltSemantics &Sem, bool Negative=false)

Factory for Positive and Negative Zero.

cmpResult compare(const APFloat &RHS) const

opStatus convertFromZeroExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)

bool isSmallestNormalized() const

APFloat(const fltSemantics &Semantics, const APInt &I)

bool operator<=(const APFloat &RHS) const

Class for arbitrary precision integers.

static constexpr unsigned APINT_BITS_PER_WORD

Bits in a word.

An arbitrary precision integer that knows its signedness.

Tagged union holding either a T or a Error.

FoldingSetNodeID - This class is used to gather all the unique data bits of a node.

MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

StringRef - Represent a constant reference to a string, i.e.

LLVM Value Representation.

void makeSmallestNormalized(bool Neg)

DoubleAPFloat & operator=(const DoubleAPFloat &RHS)

LLVM_READONLY int getExactLog2() const

opStatus remainder(const DoubleAPFloat &RHS)

opStatus multiply(const DoubleAPFloat &RHS, roundingMode RM)

fltCategory getCategory() const

bool bitwiseIsEqual(const DoubleAPFloat &RHS) const

LLVM_READONLY int getExactLog2Abs() const

opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)

opStatus convertFromZeroExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)

APInt bitcastToAPInt() const

bool getExactInverse(APFloat *inv) const

Expected< opStatus > convertFromString(StringRef, roundingMode)

opStatus subtract(const DoubleAPFloat &RHS, roundingMode RM)

cmpResult compareAbsoluteValue(const DoubleAPFloat &RHS) const

opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const

void makeSmallest(bool Neg)

opStatus next(bool nextDown)

friend DoubleAPFloat scalbn(const DoubleAPFloat &X, int Exp, roundingMode)

opStatus divide(const DoubleAPFloat &RHS, roundingMode RM)

friend hash_code hash_value(const DoubleAPFloat &Arg)

bool isSmallestNormalized() const

opStatus mod(const DoubleAPFloat &RHS)

void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision, unsigned FormatMaxPadding, bool TruncateZero=true) const

void makeLargest(bool Neg)

cmpResult compare(const DoubleAPFloat &RHS) const

opStatus roundToIntegral(roundingMode RM)

opStatus convertFromSignExtendedInteger(const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)

opStatus fusedMultiplyAdd(const DoubleAPFloat &Multiplicand, const DoubleAPFloat &Addend, roundingMode RM)

unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const

bool needsCleanup() const

opStatus add(const DoubleAPFloat &RHS, roundingMode RM)

friend DoubleAPFloat frexp(const DoubleAPFloat &X, int &Exp, roundingMode)

void makeNaN(bool SNaN, bool Neg, const APInt *fill)

unsigned int convertToHexString(char *dst, unsigned int hexDigits, bool upperCase, roundingMode) const

Write out a hexadecimal representation of the floating point value to DST, which must be of sufficien...

cmpResult compareAbsoluteValue(const IEEEFloat &) const

opStatus mod(const IEEEFloat &)

C fmod, or llvm frem.

fltCategory getCategory() const

opStatus convertFromAPInt(const APInt &, bool, roundingMode)

bool isFiniteNonZero() const

bool getExactInverse(APFloat *inv) const

If this value has an exact multiplicative inverse, store it in inv and return true.

bool needsCleanup() const

Returns whether this instance allocated memory.

void makeLargest(bool Neg=false)

Make this number the largest magnitude normal number in the given semantics.

LLVM_READONLY int getExactLog2Abs() const

APInt bitcastToAPInt() const

cmpResult compare(const IEEEFloat &) const

IEEE comparison with another floating point number (NaNs compare unordered, 0==-0).

bool isNegative() const

IEEE-754R isSignMinus: Returns true if and only if the current value is negative.

opStatus divide(const IEEEFloat &, roundingMode)

bool isNaN() const

Returns true if and only if the float is a quiet or signaling NaN.

opStatus remainder(const IEEEFloat &)

IEEE remainder.

double convertToDouble() const

opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)

float convertToFloat() const

opStatus subtract(const IEEEFloat &, roundingMode)

void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const

Converts this value into a decimal string.

void makeSmallest(bool Neg=false)

Make this number the smallest magnitude denormal number in the given semantics.

void makeInf(bool Neg=false)

opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)

bool isNormal() const

IEEE-754R isNormal: Returns true if and only if the current value is normal.

friend IEEEFloat frexp(const IEEEFloat &X, int &Exp, roundingMode)

bool isSmallestNormalized() const

Returns true if this is the smallest (by magnitude) normalized finite number in the given semantics.

bool isLargest() const

Returns true if and only if the number has the largest possible finite magnitude in the current seman...

opStatus add(const IEEEFloat &, roundingMode)

bool isFinite() const

Returns true if and only if the current value is zero, subnormal, or normal.

Expected< opStatus > convertFromString(StringRef, roundingMode)

void makeNaN(bool SNaN=false, bool Neg=false, const APInt *fill=nullptr)

friend int ilogb(const IEEEFloat &Arg)

Returns the exponent of the internal representation of the APFloat.

opStatus multiply(const IEEEFloat &, roundingMode)

friend hash_code hash_value(const IEEEFloat &Arg)

Overload to compute a hash code for an APFloat value.

opStatus roundToIntegral(roundingMode)

IEEEFloat & operator=(const IEEEFloat &)

friend IEEEFloat scalbn(IEEEFloat X, int Exp, roundingMode)

Returns: X * 2^Exp for integral exponents.

bool bitwiseIsEqual(const IEEEFloat &) const

Bitwise comparison for equality (QNaNs compare equal, 0!=-0).

void makeSmallestNormalized(bool Negative=false)

Returns the smallest (by magnitude) normalized finite number in the given semantics.

bool isInteger() const

Returns true if and only if the number is an exact integer.

opStatus fusedMultiplyAdd(const IEEEFloat &, const IEEEFloat &, roundingMode)

opStatus next(bool nextDown)

IEEE-754R 5.3.1: nextUp/nextDown.

bool isInfinity() const

IEEE-754R isInfinite(): Returns true if and only if the float is infinity.

const fltSemantics & getSemantics() const

bool isZero() const

Returns true if and only if the float is plus or minus zero.

bool isSignaling() const

Returns true if and only if the float is a signaling NaN.

bool operator==(const IEEEFloat &) const =delete

The definition of equality is not straightforward for floating point, so we won't use operator==.

void makeZero(bool Neg=false)

LLVM_READONLY int getExactLog2() const

bool isDenormal() const

IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal.

opStatus convertToInteger(MutableArrayRef< integerPart >, unsigned int, bool, roundingMode, bool *) const

bool isSmallest() const

Returns true if and only if the number has the smallest possible non-zero magnitude in the current se...

An opaque object representing a hash code.

This class implements an extremely fast bulk output stream that can only output to a stream.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

static constexpr opStatus opInexact

APFloatBase::roundingMode roundingMode

static constexpr fltCategory fcNaN

static constexpr opStatus opDivByZero

static constexpr opStatus opOverflow

static constexpr cmpResult cmpLessThan

static constexpr roundingMode rmTowardPositive

static constexpr uninitializedTag uninitialized

static constexpr fltCategory fcZero

static constexpr opStatus opOK

static constexpr cmpResult cmpGreaterThan

static constexpr unsigned integerPartWidth

APFloatBase::ExponentType ExponentType

hash_code hash_value(const IEEEFloat &Arg)

static constexpr fltCategory fcNormal

static constexpr opStatus opInvalidOp

IEEEFloat scalbn(IEEEFloat X, int Exp, roundingMode)

APFloatBase::fltCategory fltCategory

IEEEFloat frexp(const IEEEFloat &Val, int &Exp, roundingMode RM)

static constexpr cmpResult cmpUnordered

static constexpr roundingMode rmTowardNegative

static constexpr fltCategory fcInfinity

static constexpr roundingMode rmNearestTiesToAway

static constexpr roundingMode rmTowardZero

static constexpr opStatus opUnderflow

static constexpr roundingMode rmNearestTiesToEven

int ilogb(const IEEEFloat &Arg)

static constexpr cmpResult cmpEqual

This is an optimization pass for GlobalISel generic memory operations.

hash_code hash_value(const FixedPointSemantics &Val)

APFloat abs(APFloat X)

Returns the absolute value of the argument.

LLVM_READONLY APFloat maximum(const APFloat &A, const APFloat &B)

Implements IEEE 754-2019 maximum semantics.

APFloat frexp(const APFloat &X, int &Exp, APFloat::roundingMode RM)

Equivalent of C standard library function.

LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)

Implements IEEE-754 2019 maximumNumber semantics.

lostFraction

Enum that represents what fraction of the LSB truncated bits of an fp number represent.

LLVM_READONLY APFloat minimumnum(const APFloat &A, const APFloat &B)

Implements IEEE 754-2019 minimumNumber semantics.

FPClassTest

Floating-point class tests, supported by 'is_fpclass' intrinsic.

APFloat scalbn(APFloat X, int Exp, APFloat::roundingMode RM)

@ First

Helpers to iterate all locations in the MemoryEffectsBase class.

LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)

Implements IEEE-754 2019 minimumNumber semantics.

RoundingMode

Rounding mode.

@ TowardZero

roundTowardZero.

@ NearestTiesToEven

roundTiesToEven.

@ TowardPositive

roundTowardPositive.

@ NearestTiesToAway

roundTiesToAway.

@ TowardNegative

roundTowardNegative.

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

APFloat neg(APFloat X)

Returns the negated value of the argument.

LLVM_READONLY APFloat minimum(const APFloat &A, const APFloat &B)

Implements IEEE 754-2019 minimum semantics.

LLVM_READONLY APFloat maximumnum(const APFloat &A, const APFloat &B)

Implements IEEE 754-2019 maximumNumber semantics.

A self-contained host- and target-independent arbitrary-precision floating-point software implementat...

static const llvm::fltSemantics & EnumToSemantics(Semantics S)

static const fltSemantics & IEEEsingle() LLVM_READNONE

static bool semanticsHasInf(const fltSemantics &)

static const fltSemantics & Float6E3M2FN() LLVM_READNONE

static constexpr roundingMode rmNearestTiesToAway

cmpResult

IEEE-754R 5.11: Floating Point Comparison Relations.

static const fltSemantics & PPCDoubleDoubleLegacy() LLVM_READNONE

static constexpr roundingMode rmTowardNegative

static ExponentType semanticsMinExponent(const fltSemantics &)

llvm::RoundingMode roundingMode

IEEE-754R 4.3: Rounding-direction attributes.

static constexpr roundingMode rmNearestTiesToEven

static unsigned int semanticsSizeInBits(const fltSemantics &)

static bool semanticsHasSignedRepr(const fltSemantics &)

static const fltSemantics & Float8E4M3() LLVM_READNONE

static unsigned getSizeInBits(const fltSemantics &Sem)

Returns the size of the floating point number (in bits) in the given semantics.

static const fltSemantics & Float8E4M3FN() LLVM_READNONE

static const fltSemantics & PPCDoubleDouble() LLVM_READNONE

static constexpr roundingMode rmTowardZero

static const fltSemantics & x87DoubleExtended() LLVM_READNONE

uninitializedTag

Convenience enum used to construct an uninitialized APFloat.

static const fltSemantics & IEEEquad() LLVM_READNONE

static const fltSemantics & Float4E2M1FN() LLVM_READNONE

static const fltSemantics & Float8E8M0FNU() LLVM_READNONE

static const fltSemantics & Float8E4M3B11FNUZ() LLVM_READNONE

static const fltSemantics & Bogus() LLVM_READNONE

A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real.

static ExponentType semanticsMaxExponent(const fltSemantics &)

static unsigned int semanticsPrecision(const fltSemantics &)

static const fltSemantics & IEEEdouble() LLVM_READNONE

static bool semanticsHasNaN(const fltSemantics &)

static const fltSemantics & Float8E5M2() LLVM_READNONE

static Semantics SemanticsToEnum(const llvm::fltSemantics &Sem)

static constexpr unsigned integerPartWidth

static const fltSemantics & IEEEhalf() LLVM_READNONE

APInt::WordType integerPart

static constexpr roundingMode rmTowardPositive

static bool semanticsHasZero(const fltSemantics &)

static bool isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst)

static const fltSemantics & Float8E4M3FNUZ() LLVM_READNONE

IlogbErrorKinds

Enumeration of ilogb error results.

static const fltSemantics & BFloat() LLVM_READNONE

static const fltSemantics & FloatTF32() LLVM_READNONE

static bool isRepresentableBy(const fltSemantics &A, const fltSemantics &B)

static const fltSemantics & Float8E5M2FNUZ() LLVM_READNONE

static const fltSemantics & Float6E2M3FN() LLVM_READNONE

fltCategory

Category of internally-represented number.

@ S_PPCDoubleDoubleLegacy

static const fltSemantics & Float8E3M4() LLVM_READNONE

opStatus

IEEE-754R 7: Default exception handling.

int32_t ExponentType

A signed type to represent a floating point numbers unbiased exponent.

static unsigned int semanticsIntSizeInBits(const fltSemantics &, bool)