[PATCH] Add getSizeInBits function to the APFloat class
Tamas Berghammer
tberghammer at google.com
Wed Mar 18 08:02:16 PDT 2015
Use hard coded size values
http://reviews.llvm.org/D8413
Files:
include/llvm/ADT/APFloat.h
lib/Support/APFloat.cpp
Index: include/llvm/ADT/APFloat.h
===================================================================
--- include/llvm/ADT/APFloat.h
+++ 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,
Index: lib/Support/APFloat.cpp
===================================================================
--- lib/Support/APFloat.cpp
+++ lib/Support/APFloat.cpp
@@ -3368,6 +3368,30 @@
}
}
+unsigned APFloat::getSizeInBits(const fltSemantics &Sem)
+{
+ if (&Sem == (const llvm::fltSemantics*)&IEEEhalf)
+ return 16;
+
+ if (&Sem == (const llvm::fltSemantics*)&IEEEsingle)
+ return 32;
+
+ if (&Sem == (const llvm::fltSemantics*)&IEEEdouble)
+ return 64;
+
+ if (&Sem == (const llvm::fltSemantics*)&x87DoubleExtended)
+ return 80;
+
+ if (&Sem == (const llvm::fltSemantics*)&IEEEquad)
+ return 128;
+
+ if (&Sem == (const llvm::fltSemantics*)&PPCDoubleDouble)
+ return 128;
+
+ assert(false && "unknown semantics!");
+ return 0;
+}
+
/// Make this number the largest magnitude normal number in the given
/// semantics.
void APFloat::makeLargest(bool Negative) {
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8413.22185.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150318/24e5cc61/attachment.bin>
More information about the llvm-commits
mailing list