From 3f537a00dc7e623f63fd5e8b1c0b430d546f7386 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Thu, 27 Jun 2024 11:33:47 +0100 Subject: MathExtras: s/constexpr inline/constexpr/ (NFC) (#96890) constexpr implies inline. --- llvm/include/llvm/Support/MathExtras.h | 40 +++++++++++++++++----------------- 1 file 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 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(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(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 constexpr inline bool isInt(int64_t x) { +template constexpr bool isInt(int64_t x) { if constexpr (N == 0) return 0 == x; if constexpr (N == 8) @@ -167,14 +167,14 @@ template constexpr inline bool isInt(int64_t x) { /// Checks if a signed integer is an N bit number shifted left by S. template -constexpr inline bool isShiftedInt(int64_t x) { +constexpr bool isShiftedInt(int64_t x) { static_assert(S < 64, "isShiftedInt with S >= 64 is too much."); static_assert(N + S <= 64, "isShiftedInt with N + S > 64 is too wide."); return isInt(x) && (x % (UINT64_C(1) << S) == 0); } /// Checks if an unsigned integer fits into the given bit width. -template constexpr inline bool isUInt(uint64_t x) { +template constexpr bool isUInt(uint64_t x) { if constexpr (N == 0) return 0 == x; if constexpr (N == 8) @@ -191,7 +191,7 @@ template constexpr inline bool isUInt(uint64_t x) { /// Checks if a unsigned integer is an N bit number shifted left by S. template -constexpr inline bool isShiftedUInt(uint64_t x) { +constexpr bool isShiftedUInt(uint64_t x) { static_assert(S < 64, "isShiftedUInt with S >= 64 is too much."); static_assert(N + S <= 64, "isShiftedUInt 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 constexpr inline size_t CTLog2() { +template constexpr size_t CTLog2() { static_assert(kValue > 0 && llvm::isPowerOf2_64(kValue), "Value is not a valid power of 2"); return 1 + CTLog2(); } -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 constexpr inline uint64_t alignTo(uint64_t Value) { +template 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 constexpr inline int32_t SignExtend32(uint32_t X) { +template 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 constexpr inline int64_t SignExtend64(uint64_t x) { +template constexpr int64_t SignExtend64(uint64_t x) { static_assert(B <= 64, "Bit width out of range."); if constexpr (B == 0) return 0; -- cgit v1.1