Index: src/IceAPFloat.h |
diff --git a/src/IceAPFloat.h b/src/IceAPFloat.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c374bfb7b13e26581013e80a7954d896a8375d1b |
--- /dev/null |
+++ b/src/IceAPFloat.h |
@@ -0,0 +1,49 @@ |
+//===-- subzero/src/IceAPFloat.h - Constant float conversions --*- C++ -*--===// |
+// |
+// The LLVM Compiler Infrastructure |
+// |
+// This file is distributed under the University of Illinois Open Source |
+// License. See LICENSE.TXT for details. |
+// |
+//===----------------------------------------------------------------------===// |
+/// |
+/// \file |
+/// \brief This file implements a class to represent Subzero float and double |
+/// values. |
+/// |
+/// Note: This is a simplified version of |
+/// llvm/include/llvm/ADT/APFloat.h for use with Subzero. |
+//===----------------------------------------------------------------------===// |
+ |
+#ifndef SUBZERO_SRC_ICEAPFLOAT_H |
+#define SUBZERO_SRC_ICEAPFLOAT_H |
+ |
+#include "IceAPInt.h" |
+ |
+namespace Ice { |
+ |
+/// Takes a 32-bit Int and converts it to the corresponding float value. |
+inline float convertAPIntToFloat(const APInt &Int) { |
+ assert(Int.getBitWidth() == 32); |
+ union { |
+ uint32_t IntValue; |
+ float FloatValue; |
+ } Converter; |
+ Converter.IntValue = static_cast<uint32_t>(Int.getRawData()); |
+ return Converter.FloatValue; |
+} |
+ |
+/// Takes a 64-bit Int and converts it to the corresponding double value. |
Jim Stichnoth
2014/12/12 21:54:15
Consider reducing code duplication:
template<type
Karl
2014/12/12 22:46:12
Done.
|
+inline double convertAPIntToDouble(const APInt &Int) { |
+ assert(Int.getBitWidth() == 64); |
+ union { |
+ uint64_t IntValue; |
+ double DoubleValue; |
+ } Converter; |
+ Converter.IntValue = static_cast<uint64_t>(Int.getRawData()); |
+ return Converter.DoubleValue; |
+} |
+ |
+} // end of namespace Ice |
+ |
+#endif // SUBZERO_SRC_ICEAPFLOAT_H |