diff options
author | Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com> | 2024-06-27 11:33:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-27 11:33:47 +0100 |
commit | 3f537a00dc7e623f63fd5e8b1c0b430d546f7386 (patch) | |
tree | 7b530681ebe619cdc486376497c4b47f910a4362 | |
parent | 253a294b54a6096a0b66f840931dd0e345d70c4f (diff) | |
download | llvm-3f537a00dc7e623f63fd5e8b1c0b430d546f7386.zip llvm-3f537a00dc7e623f63fd5e8b1c0b430d546f7386.tar.gz llvm-3f537a00dc7e623f63fd5e8b1c0b430d546f7386.tar.bz2 |
MathExtras: s/constexpr inline/constexpr/ (NFC) (#96890)
constexpr implies inline.
-rw-r--r-- | llvm/include/llvm/Support/MathExtras.h | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h index 5bcefe4..3bba999 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -135,22 +135,22 @@ template <typename T> T reverseBits(T Val) { // ambiguity. /// Return the high 32 bits of a 64 bit value. -constexpr inline uint32_t Hi_32(uint64_t Value) { +constexpr uint32_t Hi_32(uint64_t Value) { return static_cast<uint32_t>(Value >> 32); } /// Return the low 32 bits of a 64 bit value. -constexpr inline uint32_t Lo_32(uint64_t Value) { +constexpr uint32_t Lo_32(uint64_t Value) { return static_cast<uint32_t>(Value); } /// Make a 64-bit integer from a high / low pair of 32-bit integers. -constexpr inline uint64_t Make_64(uint32_t High, uint32_t Low) { +constexpr uint64_t Make_64(uint32_t High, uint32_t Low) { return ((uint64_t)High << 32) | (uint64_t)Low; } /// Checks if an integer fits into the given bit width. -template <unsigned N> constexpr inline bool isInt(int64_t x) { +template <unsigned N> constexpr bool isInt(int64_t x) { if constexpr (N == 0) return 0 == x; if constexpr (N == 8) @@ -167,14 +167,14 @@ template <unsigned N> constexpr inline bool isInt(int64_t x) { /// Checks if a signed integer is an N bit number shifted left by S. template <unsigned N, unsigned S> -constexpr inline bool isShiftedInt(int64_t x) { +constexpr bool isShiftedInt(int64_t x) { static_assert(S < 64, "isShiftedInt<N, S> with S >= 64 is too much."); static_assert(N + S <= 64, "isShiftedInt<N, S> with N + S > 64 is too wide."); return isInt<N + S>(x) && (x % (UINT64_C(1) << S) == 0); } /// Checks if an unsigned integer fits into the given bit width. -template <unsigned N> constexpr inline bool isUInt(uint64_t x) { +template <unsigned N> constexpr bool isUInt(uint64_t x) { if constexpr (N == 0) return 0 == x; if constexpr (N == 8) @@ -191,7 +191,7 @@ template <unsigned N> constexpr inline bool isUInt(uint64_t x) { /// Checks if a unsigned integer is an N bit number shifted left by S. template <unsigned N, unsigned S> -constexpr inline bool isShiftedUInt(uint64_t x) { +constexpr bool isShiftedUInt(uint64_t x) { static_assert(S < 64, "isShiftedUInt<N, S> with S >= 64 is too much."); static_assert(N + S <= 64, "isShiftedUInt<N, S> with N + S > 64 is too wide."); @@ -248,36 +248,36 @@ inline bool isIntN(unsigned N, int64_t x) { /// Return true if the argument is a non-empty sequence of ones starting at the /// least significant bit with the remainder zero (32 bit version). /// Ex. isMask_32(0x0000FFFFU) == true. -constexpr inline bool isMask_32(uint32_t Value) { +constexpr bool isMask_32(uint32_t Value) { return Value && ((Value + 1) & Value) == 0; } /// Return true if the argument is a non-empty sequence of ones starting at the /// least significant bit with the remainder zero (64 bit version). -constexpr inline bool isMask_64(uint64_t Value) { +constexpr bool isMask_64(uint64_t Value) { return Value && ((Value + 1) & Value) == 0; } /// Return true if the argument contains a non-empty sequence of ones with the /// remainder zero (32 bit version.) Ex. isShiftedMask_32(0x0000FF00U) == true. -constexpr inline bool isShiftedMask_32(uint32_t Value) { +constexpr bool isShiftedMask_32(uint32_t Value) { return Value && isMask_32((Value - 1) | Value); } /// Return true if the argument contains a non-empty sequence of ones with the /// remainder zero (64 bit version.) -constexpr inline bool isShiftedMask_64(uint64_t Value) { +constexpr bool isShiftedMask_64(uint64_t Value) { return Value && isMask_64((Value - 1) | Value); } /// Return true if the argument is a power of two > 0. /// Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.) -constexpr inline bool isPowerOf2_32(uint32_t Value) { +constexpr bool isPowerOf2_32(uint32_t Value) { return llvm::has_single_bit(Value); } /// Return true if the argument is a power of two > 0 (64 bit edition.) -constexpr inline bool isPowerOf2_64(uint64_t Value) { +constexpr bool isPowerOf2_64(uint64_t Value) { return llvm::has_single_bit(Value); } @@ -310,13 +310,13 @@ inline bool isShiftedMask_64(uint64_t Value, unsigned &MaskIdx, /// Compile time Log2. /// Valid only for positive powers of two. -template <size_t kValue> constexpr inline size_t CTLog2() { +template <size_t kValue> constexpr size_t CTLog2() { static_assert(kValue > 0 && llvm::isPowerOf2_64(kValue), "Value is not a valid power of 2"); return 1 + CTLog2<kValue / 2>(); } -template <> constexpr inline size_t CTLog2<1>() { return 0; } +template <> constexpr size_t CTLog2<1>() { return 0; } /// Return the floor log base 2 of the specified value, -1 if the value is zero. /// (32 bit edition.) @@ -346,7 +346,7 @@ inline unsigned Log2_64_Ceil(uint64_t Value) { /// A and B are either alignments or offsets. Return the minimum alignment that /// may be assumed after adding the two together. -constexpr inline uint64_t MinAlign(uint64_t A, uint64_t B) { +constexpr uint64_t MinAlign(uint64_t A, uint64_t B) { // The largest power of 2 that divides both A and B. // // Replace "-Value" by "1+~Value" in the following commented code to avoid @@ -357,7 +357,7 @@ constexpr inline uint64_t MinAlign(uint64_t A, uint64_t B) { /// Returns the next power of two (in 64-bits) that is strictly greater than A. /// Returns zero on overflow. -constexpr inline uint64_t NextPowerOf2(uint64_t A) { +constexpr uint64_t NextPowerOf2(uint64_t A) { A |= (A >> 1); A |= (A >> 2); A |= (A >> 4); @@ -421,7 +421,7 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew) { /// Returns the next integer (mod 2**64) that is greater than or equal to /// \p Value and is a multiple of \c Align. \c Align must be non-zero. -template <uint64_t Align> constexpr inline uint64_t alignTo(uint64_t Value) { +template <uint64_t Align> constexpr uint64_t alignTo(uint64_t Value) { static_assert(Align != 0u, "Align must be non-zero"); return (Value + Align - 1) / Align * Align; } @@ -486,7 +486,7 @@ inline uint64_t alignDown(uint64_t Value, uint64_t Align, uint64_t Skew = 0) { /// Sign-extend the number in the bottom B bits of X to a 32-bit integer. /// Requires B <= 32. -template <unsigned B> constexpr inline int32_t SignExtend32(uint32_t X) { +template <unsigned B> constexpr int32_t SignExtend32(uint32_t X) { static_assert(B <= 32, "Bit width out of range."); if constexpr (B == 0) return 0; @@ -504,7 +504,7 @@ inline int32_t SignExtend32(uint32_t X, unsigned B) { /// Sign-extend the number in the bottom B bits of X to a 64-bit integer. /// Requires B <= 64. -template <unsigned B> constexpr inline int64_t SignExtend64(uint64_t x) { +template <unsigned B> constexpr int64_t SignExtend64(uint64_t x) { static_assert(B <= 64, "Bit width out of range."); if constexpr (B == 0) return 0; |