OLD | NEW |
1 //===- subzero/src/IceUtils.h - Utility functions ---------------*- C++ -*-===// | 1 //===- subzero/src/IceUtils.h - Utility functions ---------------*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return (value >> shift) | (value << (32 - shift)); | 116 return (value >> shift) | (value << (32 - shift)); |
117 } | 117 } |
118 | 118 |
119 /// Returns true if Val is +0.0. It requires T to be a floating point type. | 119 /// Returns true if Val is +0.0. It requires T to be a floating point type. |
120 template <typename T> static bool isPositiveZero(T Val) { | 120 template <typename T> static bool isPositiveZero(T Val) { |
121 static_assert(std::is_floating_point<T>::value, | 121 static_assert(std::is_floating_point<T>::value, |
122 "Input type must be floating point"); | 122 "Input type must be floating point"); |
123 return Val == 0 && !std::signbit(Val); | 123 return Val == 0 && !std::signbit(Val); |
124 } | 124 } |
125 | 125 |
| 126 /// An RAII class to ensure that a boolean flag is restored to its previous |
| 127 /// value upon function exit. |
| 128 /// |
| 129 /// Used in places like RandomizationPoolingPause and generating target helper |
| 130 /// calls. |
| 131 class BoolFlagSaver { |
| 132 BoolFlagSaver() = delete; |
| 133 BoolFlagSaver(const BoolFlagSaver &) = delete; |
| 134 BoolFlagSaver &operator=(const BoolFlagSaver &) = delete; |
| 135 |
| 136 public: |
| 137 BoolFlagSaver(bool &F, bool NewValue) : OldValue(F), Flag(F) { F = NewValue; } |
| 138 ~BoolFlagSaver() { Flag = OldValue; } |
| 139 |
| 140 private: |
| 141 const bool OldValue; |
| 142 bool &Flag; |
| 143 }; |
| 144 |
126 } // end of namespace Utils | 145 } // end of namespace Utils |
127 } // end of namespace Ice | 146 } // end of namespace Ice |
128 | 147 |
129 #endif // SUBZERO_SRC_ICEUTILS_H | 148 #endif // SUBZERO_SRC_ICEUTILS_H |
OLD | NEW |