1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

Add assertions to MathExtras max/min functions

llvm-svn: 271515
This commit is contained in:
Dylan McKay 2016-06-02 12:00:34 +00:00
parent 2e72cbb66e
commit 988d28a2c2

View File

@ -312,11 +312,25 @@ inline bool isShiftedUInt(uint64_t x) {
}
/// Gets the maximum value for a N-bit unsigned integer.
inline uint64_t maxUIntN(uint64_t N) { return (UINT64_C(1) << N) - 1; }
inline uint64_t maxUIntN(uint64_t N) {
assert(N > 0 && N <= 64 && "integer width out of range");
return (UINT64_C(1) << N) - 1;
}
/// Gets the minimum value for a N-bit signed integer.
inline int64_t minIntN(int64_t N) { return -(INT64_C(1)<<(N-1)); }
inline int64_t minIntN(int64_t N) {
assert(N > 0 && N <= 64 && "integer width out of range");
return -(INT64_C(1)<<(N-1));
}
/// Gets the maximum value for a N-bit signed integer.
inline int64_t maxIntN(int64_t N) { return (INT64_C(1)<<(N-1)) - 1; }
inline int64_t maxIntN(int64_t N) {
assert(N > 0 && N <= 64 && "integer width out of range");
return (INT64_C(1)<<(N-1)) - 1;
}
/// isUIntN - Checks if an unsigned integer fits into the given (dynamic)
/// bit width.