[PATCH] D8413: Add getSizeInBits function to the APFloat class
Tamas Berghammer
tberghammer at google.com
Thu Jul 9 03:14:02 PDT 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL241793: Add getSizeInBits function to the APFloat class (authored by tberghammer).
Changed prior to commit:
http://reviews.llvm.org/D8413?vs=23762&id=29306#toc
Repository:
rL LLVM
http://reviews.llvm.org/D8413
Files:
llvm/trunk/include/llvm/ADT/APFloat.h
llvm/trunk/lib/Support/APFloat.cpp
Index: llvm/trunk/lib/Support/APFloat.cpp
===================================================================
--- llvm/trunk/lib/Support/APFloat.cpp
+++ llvm/trunk/lib/Support/APFloat.cpp
@@ -52,14 +52,17 @@
/* Number of bits in the significand. This includes the integer
bit. */
unsigned int precision;
+
+ /* Number of bits actually used in the semantics. */
+ unsigned int sizeInBits;
};
- const fltSemantics APFloat::IEEEhalf = { 15, -14, 11 };
- const fltSemantics APFloat::IEEEsingle = { 127, -126, 24 };
- const fltSemantics APFloat::IEEEdouble = { 1023, -1022, 53 };
- const fltSemantics APFloat::IEEEquad = { 16383, -16382, 113 };
- const fltSemantics APFloat::x87DoubleExtended = { 16383, -16382, 64 };
- const fltSemantics APFloat::Bogus = { 0, 0, 0 };
+ const fltSemantics APFloat::IEEEhalf = { 15, -14, 11, 16 };
+ const fltSemantics APFloat::IEEEsingle = { 127, -126, 24, 32 };
+ const fltSemantics APFloat::IEEEdouble = { 1023, -1022, 53, 64 };
+ const fltSemantics APFloat::IEEEquad = { 16383, -16382, 113, 128 };
+ const fltSemantics APFloat::x87DoubleExtended = { 16383, -16382, 64, 80 };
+ const fltSemantics APFloat::Bogus = { 0, 0, 0, 0 };
/* The PowerPC format consists of two doubles. It does not map cleanly
onto the usual format above. It is approximated using twice the
@@ -72,7 +75,7 @@
to represent all possible values held by a PPC double-double number,
for example: (long double) 1.0 + (long double) 0x1p-106
Should this be replaced by a full emulation of PPC double-double? */
- const fltSemantics APFloat::PPCDoubleDouble = { 1023, -1022 + 53, 53 + 53 };
+ const fltSemantics APFloat::PPCDoubleDouble = { 1023, -1022 + 53, 53 + 53, 128 };
/* A tight upper bound on number of parts required to hold the value
pow(5, power) is
@@ -2416,7 +2419,7 @@
roundingMode rounding_mode)
{
unsigned int parts, pow5PartCount;
- fltSemantics calcSemantics = { 32767, -32767, 0 };
+ fltSemantics calcSemantics = { 32767, -32767, 0, 0 };
integerPart pow5Parts[maxPowerOfFiveParts];
bool isNearest;
@@ -3368,6 +3371,10 @@
}
}
+unsigned APFloat::getSizeInBits(const fltSemantics &Sem) {
+ return Sem.sizeInBits;
+}
+
/// Make this number the largest magnitude normal number in the given
/// semantics.
void APFloat::makeLargest(bool Negative) {
Index: llvm/trunk/include/llvm/ADT/APFloat.h
===================================================================
--- llvm/trunk/include/llvm/ADT/APFloat.h
+++ llvm/trunk/include/llvm/ADT/APFloat.h
@@ -276,6 +276,10 @@
/// \param isIEEE - If 128 bit number, select between PPC and IEEE
static APFloat getAllOnesValue(unsigned BitWidth, bool isIEEE = false);
+ /// Returns the size of the floating point number (in bits) in the given
+ /// semantics.
+ static unsigned getSizeInBits(const fltSemantics &Sem);
+
/// @}
/// Used to insert APFloat objects, or objects that contain APFloat objects,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8413.29306.patch
Type: text/x-patch
Size: 3023 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150709/7f2568e1/attachment.bin>
More information about the llvm-commits
mailing list