llvm.org GIT mirror llvm / 159c735
APFloat cleanup: Remove now unused "arithmeticOK" logic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166954 91177308-0d34-0410-b5e6-96231b3b80d8 Ulrich Weigand 6 years ago
1 changed file(s) with 8 addition(s) and 42 deletion(s). Raw diff Collapse all Expand all
4545 /* Number of bits in the significand. This includes the integer
4646 bit. */
4747 unsigned int precision;
48
49 /* True if arithmetic is supported. */
50 unsigned int arithmeticOK;
5148 };
5249
53 const fltSemantics APFloat::IEEEhalf = { 15, -14, 11, true };
54 const fltSemantics APFloat::IEEEsingle = { 127, -126, 24, true };
55 const fltSemantics APFloat::IEEEdouble = { 1023, -1022, 53, true };
56 const fltSemantics APFloat::IEEEquad = { 16383, -16382, 113, true };
57 const fltSemantics APFloat::x87DoubleExtended = { 16383, -16382, 64, true };
58 const fltSemantics APFloat::Bogus = { 0, 0, 0, true };
50 const fltSemantics APFloat::IEEEhalf = { 15, -14, 11 };
51 const fltSemantics APFloat::IEEEsingle = { 127, -126, 24 };
52 const fltSemantics APFloat::IEEEdouble = { 1023, -1022, 53 };
53 const fltSemantics APFloat::IEEEquad = { 16383, -16382, 113 };
54 const fltSemantics APFloat::x87DoubleExtended = { 16383, -16382, 64 };
55 const fltSemantics APFloat::Bogus = { 0, 0, 0 };
5956
6057 /* The PowerPC format consists of two doubles. It does not map cleanly
6158 onto the usual format above. It is approximated using twice the
6865 to represent all possible values held by a PPC double-double number,
6966 for example: (long double) 1.0 + (long double) 0x1p-106
7067 Should this be replaced by a full emulation of PPC double-double? */
71 const fltSemantics APFloat::PPCDoubleDouble =
72 { 1023, -1022 + 53, 53 + 53, true };
68 const fltSemantics APFloat::PPCDoubleDouble = { 1023, -1022 + 53, 53 + 53 };
7369
7470 /* A tight upper bound on number of parts required to hold the value
7571 pow(5, power) is
122118 return r + 10;
123119
124120 return -1U;
125 }
126
127 static inline void
128 assertArithmeticOK(const llvm::fltSemantics &semantics) {
129 assert(semantics.arithmeticOK &&
130 "Compile-time arithmetic does not support these semantics");
131121 }
132122
133123 /* Return the value of a decimal exponent of the form
730720 }
731721
732722 APFloat::APFloat(const fltSemantics &ourSemantics, integerPart value) {
733 assertArithmeticOK(ourSemantics);
734723 initialize(&ourSemantics);
735724 sign = 0;
736725 zeroSignificand();
740729 }
741730
742731 APFloat::APFloat(const fltSemantics &ourSemantics) {
743 assertArithmeticOK(ourSemantics);
744732 initialize(&ourSemantics);
745733 category = fcZero;
746734 sign = false;
747735 }
748736
749737 APFloat::APFloat(const fltSemantics &ourSemantics, uninitializedTag tag) {
750 assertArithmeticOK(ourSemantics);
751738 // Allocates storage if necessary but does not initialize it.
752739 initialize(&ourSemantics);
753740 }
754741
755742 APFloat::APFloat(const fltSemantics &ourSemantics,
756743 fltCategory ourCategory, bool negative) {
757 assertArithmeticOK(ourSemantics);
758744 initialize(&ourSemantics);
759745 category = ourCategory;
760746 sign = negative;
765751 }
766752
767753 APFloat::APFloat(const fltSemantics &ourSemantics, StringRef text) {
768 assertArithmeticOK(ourSemantics);
769754 initialize(&ourSemantics);
770755 convertFromString(text, rmNearestTiesToEven);
771756 }
15571542 {
15581543 opStatus fs;
15591544
1560 assertArithmeticOK(*semantics);
1561
15621545 fs = addOrSubtractSpecials(rhs, subtract);
15631546
15641547 /* This return code means it was not a simple case. */
16031586 {
16041587 opStatus fs;
16051588
1606 assertArithmeticOK(*semantics);
16071589 sign ^= rhs.sign;
16081590 fs = multiplySpecials(rhs);
16091591
16231605 {
16241606 opStatus fs;
16251607
1626 assertArithmeticOK(*semantics);
16271608 sign ^= rhs.sign;
16281609 fs = divideSpecials(rhs);
16291610
16451626 APFloat V = *this;
16461627 unsigned int origSign = sign;
16471628
1648 assertArithmeticOK(*semantics);
16491629 fs = V.divide(rhs, rmNearestTiesToEven);
16501630 if (fs == opDivByZero)
16511631 return fs;
16801660 APFloat::mod(const APFloat &rhs, roundingMode rounding_mode)
16811661 {
16821662 opStatus fs;
1683 assertArithmeticOK(*semantics);
16841663 fs = modSpecials(rhs);
16851664
16861665 if (category == fcNormal && rhs.category == fcNormal) {
17241703 {
17251704 opStatus fs;
17261705
1727 assertArithmeticOK(*semantics);
1728
17291706 /* Post-multiplication sign, before addition. */
17301707 sign ^= multiplicand.sign;
17311708
17661743 /* Rounding-mode corrrect round to integral value. */
17671744 APFloat::opStatus APFloat::roundToIntegral(roundingMode rounding_mode) {
17681745 opStatus fs;
1769 assertArithmeticOK(*semantics);
17701746
17711747 // If the exponent is large enough, we know that this value is already
17721748 // integral, and the arithmetic below would potentially cause it to saturate
18131789 {
18141790 cmpResult result;
18151791
1816 assertArithmeticOK(*semantics);
18171792 assert(semantics == rhs.semantics);
18181793
18191794 switch (convolve(category, rhs.category)) {
18981873 int shift;
18991874 const fltSemantics &fromSemantics = *semantics;
19001875
1901 assertArithmeticOK(fromSemantics);
1902 assertArithmeticOK(toSemantics);
19031876 lostFraction = lfExactlyZero;
19041877 newPartCount = partCountForBits(toSemantics.precision + 1);
19051878 oldPartCount = partCount();
19841957 const integerPart *src;
19851958 unsigned int dstPartsCount, truncatedBits;
19861959
1987 assertArithmeticOK(*semantics);
1988
19891960 *isExact = false;
19901961
19911962 /* Handle the three special cases first. */
21472118 integerPart *dst;
21482119 lostFraction lost_fraction;
21492120
2150 assertArithmeticOK(*semantics);
21512121 category = fcNormal;
21522122 omsb = APInt::tcMSB(src, srcCount) + 1;
21532123 dst = significandParts();
21982168 {
21992169 opStatus status;
22002170
2201 assertArithmeticOK(*semantics);
22022171 if (isSigned &&
22032172 APInt::tcExtractBit(src, srcCount * integerPartWidth - 1)) {
22042173 integerPart *copy;
23322301 roundingMode rounding_mode)
23332302 {
23342303 unsigned int parts, pow5PartCount;
2335 fltSemantics calcSemantics = { 32767, -32767, 0, true };
2304 fltSemantics calcSemantics = { 32767, -32767, 0 };
23362305 integerPart pow5Parts[maxPowerOfFiveParts];
23372306 bool isNearest;
23382307
25242493 APFloat::opStatus
25252494 APFloat::convertFromString(StringRef str, roundingMode rounding_mode)
25262495 {
2527 assertArithmeticOK(*semantics);
25282496 assert(!str.empty() && "Invalid string length");
25292497
25302498 /* Handle a leading minus sign. */
25752543 bool upperCase, roundingMode rounding_mode) const
25762544 {
25772545 char *p;
2578
2579 assertArithmeticOK(*semantics);
25802546
25812547 p = dst;
25822548 if (sign)