Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 //===-- subzero/src/IceAPFloat.h - Constant float conversions --*- C++ -*--===// | |
| 2 // | |
| 3 // The LLVM Compiler Infrastructure | |
| 4 // | |
| 5 // This file is distributed under the University of Illinois Open Source | |
| 6 // License. See LICENSE.TXT for details. | |
| 7 // | |
| 8 //===----------------------------------------------------------------------===// | |
| 9 /// | |
| 10 /// \file | |
| 11 /// \brief This file implements a class to represent Subzero float and double | |
| 12 /// values. | |
| 13 /// | |
| 14 /// Note: This is a simplified version of | |
| 15 /// llvm/include/llvm/ADT/APFloat.h for use with Subzero. | |
| 16 //===----------------------------------------------------------------------===// | |
| 17 | |
| 18 #ifndef SUBZERO_SRC_ICEAPFLOAT_H | |
| 19 #define SUBZERO_SRC_ICEAPFLOAT_H | |
| 20 | |
| 21 #include "IceAPInt.h" | |
| 22 | |
| 23 namespace Ice { | |
| 24 | |
| 25 template <typename IntType, typename FpType> | |
| 26 inline FpType convertAPIntToFp(const APInt &Int) { | |
| 27 static_assert(sizeof(IntType) == sizeof(FpType), | |
| 28 "IntType and FpType shoudl be the same width"); | |
|
Jim Stichnoth
2014/12/12 22:53:37
should
Karl
2014/12/15 17:52:55
Done.
| |
| 29 assert(Int.getBitWidth() == sizeof(IntType) * CHAR_BIT); | |
| 30 union { | |
| 31 IntType IntValue; | |
| 32 FpType FpValue; | |
| 33 } Converter; | |
| 34 Converter.IntValue = static_cast<IntType>(Int.getRawData()); | |
| 35 return Converter.FpValue; | |
| 36 } | |
| 37 | |
| 38 } // end of namespace Ice | |
| 39 | |
| 40 #endif // SUBZERO_SRC_ICEAPFLOAT_H | |
| OLD | NEW |