| OLD | NEW |
| 1 //===- subzero/src/IceDefs.h - Common Subzero declaraions -------*- C++ -*-===// | 1 //===- subzero/src/IceDefs.h - Common Subzero declaraions -------*- 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 // This file declares various useful types and classes that have | 10 // This file declares various useful types and classes that have |
| 11 // widespread use across Subzero. Every Subzero source file is | 11 // widespread use across Subzero. Every Subzero source file is |
| 12 // expected to include IceDefs.h. | 12 // expected to include IceDefs.h. |
| 13 // | 13 // |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #ifndef SUBZERO_SRC_ICEDEFS_H | 16 #ifndef SUBZERO_SRC_ICEDEFS_H |
| 17 #define SUBZERO_SRC_ICEDEFS_H | 17 #define SUBZERO_SRC_ICEDEFS_H |
| 18 | 18 |
| 19 #include <stdint.h> // TODO: <cstdint> with C++11 | 19 #include <stdint.h> // TODO: <cstdint> with C++11 |
| 20 | 20 |
| 21 #include <cassert> | 21 #include <cassert> |
| 22 #include <cstdio> // snprintf | 22 #include <cstdio> // snprintf |
| 23 #include <functional> // std::less | 23 #include <functional> // std::less |
| 24 #include <limits> |
| 24 #include <list> | 25 #include <list> |
| 25 #include <map> | 26 #include <map> |
| 26 #include <set> | 27 #include <set> |
| 27 #include <string> | 28 #include <string> |
| 28 #include <vector> | 29 #include <vector> |
| 29 | 30 |
| 30 #include "llvm/ADT/ArrayRef.h" | 31 #include "llvm/ADT/ArrayRef.h" |
| 31 #include "llvm/ADT/BitVector.h" | 32 #include "llvm/ADT/BitVector.h" |
| 32 #include "llvm/ADT/SmallBitVector.h" | 33 #include "llvm/ADT/SmallBitVector.h" |
| 33 #include "llvm/ADT/STLExtras.h" | 34 #include "llvm/ADT/STLExtras.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return End.getWallTime() - Start.getWallTime(); | 122 return End.getWallTime() - Start.getWallTime(); |
| 122 } | 123 } |
| 123 void printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const; | 124 void printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const; |
| 124 | 125 |
| 125 private: | 126 private: |
| 126 const llvm::TimeRecord Start; | 127 const llvm::TimeRecord Start; |
| 127 Timer(const Timer &) LLVM_DELETED_FUNCTION; | 128 Timer(const Timer &) LLVM_DELETED_FUNCTION; |
| 128 Timer &operator=(const Timer &) LLVM_DELETED_FUNCTION; | 129 Timer &operator=(const Timer &) LLVM_DELETED_FUNCTION; |
| 129 }; | 130 }; |
| 130 | 131 |
| 132 template <typename T> bool WouldOverflowAdd(T X, T Y) { |
| 133 return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) || |
| 134 (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y))); |
| 135 } |
| 136 |
| 131 } // end of namespace Ice | 137 } // end of namespace Ice |
| 132 | 138 |
| 133 #endif // SUBZERO_SRC_ICEDEFS_H | 139 #endif // SUBZERO_SRC_ICEDEFS_H |
| OLD | NEW |