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 // This file declares some utility functions. | 10 // This file declares some utility functions. |
(...skipping 60 matching lines...) Loading... |
71 return (X & (N - 1)) == 0; | 71 return (X & (N - 1)) == 0; |
72 } | 72 } |
73 | 73 |
74 static inline uint64_t OffsetToAlignment(uint64_t Pos, uint64_t Align) { | 74 static inline uint64_t OffsetToAlignment(uint64_t Pos, uint64_t Align) { |
75 assert(llvm::isPowerOf2_64(Align)); | 75 assert(llvm::isPowerOf2_64(Align)); |
76 uint64_t Mod = Pos & (Align - 1); | 76 uint64_t Mod = Pos & (Align - 1); |
77 if (Mod == 0) | 77 if (Mod == 0) |
78 return 0; | 78 return 0; |
79 return Align - Mod; | 79 return Align - Mod; |
80 } | 80 } |
| 81 |
| 82 // Precondition: 0 <= shift < 32 |
| 83 static inline uint32_t rotateLeft32(uint32_t value, uint32_t shift) { |
| 84 if (shift == 0) |
| 85 return value; |
| 86 return (value << shift) | (value >> (32 - shift)); |
| 87 } |
| 88 |
| 89 static inline uint32_t rotateRight32(uint32_t value, uint32_t shift) { |
| 90 if (shift == 0) |
| 91 return value; |
| 92 return (value >> shift) | (value << (32 - shift)); |
| 93 } |
81 }; | 94 }; |
82 | 95 |
83 } // end of namespace Ice | 96 } // end of namespace Ice |
84 | 97 |
85 #endif // SUBZERO_SRC_ICEUTILS_H | 98 #endif // SUBZERO_SRC_ICEUTILS_H |
OLD | NEW |