Skip to content

Commit 3f537a0

Browse files
authored
MathExtras: s/constexpr inline/constexpr/ (NFC) (#96890)
constexpr implies inline.
1 parent 253a294 commit 3f537a0

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

llvm/include/llvm/Support/MathExtras.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,22 @@ template <typename T> T reverseBits(T Val) {
135135
// ambiguity.
136136

137137
/// Return the high 32 bits of a 64 bit value.
138-
constexpr inline uint32_t Hi_32(uint64_t Value) {
138+
constexpr uint32_t Hi_32(uint64_t Value) {
139139
return static_cast<uint32_t>(Value >> 32);
140140
}
141141

142142
/// Return the low 32 bits of a 64 bit value.
143-
constexpr inline uint32_t Lo_32(uint64_t Value) {
143+
constexpr uint32_t Lo_32(uint64_t Value) {
144144
return static_cast<uint32_t>(Value);
145145
}
146146

147147
/// Make a 64-bit integer from a high / low pair of 32-bit integers.
148-
constexpr inline uint64_t Make_64(uint32_t High, uint32_t Low) {
148+
constexpr uint64_t Make_64(uint32_t High, uint32_t Low) {
149149
return ((uint64_t)High << 32) | (uint64_t)Low;
150150
}
151151

152152
/// Checks if an integer fits into the given bit width.
153-
template <unsigned N> constexpr inline bool isInt(int64_t x) {
153+
template <unsigned N> constexpr bool isInt(int64_t x) {
154154
if constexpr (N == 0)
155155
return 0 == x;
156156
if constexpr (N == 8)
@@ -167,14 +167,14 @@ template <unsigned N> constexpr inline bool isInt(int64_t x) {
167167

168168
/// Checks if a signed integer is an N bit number shifted left by S.
169169
template <unsigned N, unsigned S>
170-
constexpr inline bool isShiftedInt(int64_t x) {
170+
constexpr bool isShiftedInt(int64_t x) {
171171
static_assert(S < 64, "isShiftedInt<N, S> with S >= 64 is too much.");
172172
static_assert(N + S <= 64, "isShiftedInt<N, S> with N + S > 64 is too wide.");
173173
return isInt<N + S>(x) && (x % (UINT64_C(1) << S) == 0);
174174
}
175175

176176
/// Checks if an unsigned integer fits into the given bit width.
177-
template <unsigned N> constexpr inline bool isUInt(uint64_t x) {
177+
template <unsigned N> constexpr bool isUInt(uint64_t x) {
178178
if constexpr (N == 0)
179179
return 0 == x;
180180
if constexpr (N == 8)
@@ -191,7 +191,7 @@ template <unsigned N> constexpr inline bool isUInt(uint64_t x) {
191191

192192
/// Checks if a unsigned integer is an N bit number shifted left by S.
193193
template <unsigned N, unsigned S>
194-
constexpr inline bool isShiftedUInt(uint64_t x) {
194+
constexpr bool isShiftedUInt(uint64_t x) {
195195
static_assert(S < 64, "isShiftedUInt<N, S> with S >= 64 is too much.");
196196
static_assert(N + S <= 64,
197197
"isShiftedUInt<N, S> with N + S > 64 is too wide.");
@@ -248,36 +248,36 @@ inline bool isIntN(unsigned N, int64_t x) {
248248
/// Return true if the argument is a non-empty sequence of ones starting at the
249249
/// least significant bit with the remainder zero (32 bit version).
250250
/// Ex. isMask_32(0x0000FFFFU) == true.
251-
constexpr inline bool isMask_32(uint32_t Value) {
251+
constexpr bool isMask_32(uint32_t Value) {
252252
return Value && ((Value + 1) & Value) == 0;
253253
}
254254

255255
/// Return true if the argument is a non-empty sequence of ones starting at the
256256
/// least significant bit with the remainder zero (64 bit version).
257-
constexpr inline bool isMask_64(uint64_t Value) {
257+
constexpr bool isMask_64(uint64_t Value) {
258258
return Value && ((Value + 1) & Value) == 0;
259259
}
260260

261261
/// Return true if the argument contains a non-empty sequence of ones with the
262262
/// remainder zero (32 bit version.) Ex. isShiftedMask_32(0x0000FF00U) == true.
263-
constexpr inline bool isShiftedMask_32(uint32_t Value) {
263+
constexpr bool isShiftedMask_32(uint32_t Value) {
264264
return Value && isMask_32((Value - 1) | Value);
265265
}
266266

267267
/// Return true if the argument contains a non-empty sequence of ones with the
268268
/// remainder zero (64 bit version.)
269-
constexpr inline bool isShiftedMask_64(uint64_t Value) {
269+
constexpr bool isShiftedMask_64(uint64_t Value) {
270270
return Value && isMask_64((Value - 1) | Value);
271271
}
272272

273273
/// Return true if the argument is a power of two > 0.
274274
/// Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.)
275-
constexpr inline bool isPowerOf2_32(uint32_t Value) {
275+
constexpr bool isPowerOf2_32(uint32_t Value) {
276276
return llvm::has_single_bit(Value);
277277
}
278278

279279
/// Return true if the argument is a power of two > 0 (64 bit edition.)
280-
constexpr inline bool isPowerOf2_64(uint64_t Value) {
280+
constexpr bool isPowerOf2_64(uint64_t Value) {
281281
return llvm::has_single_bit(Value);
282282
}
283283

@@ -310,13 +310,13 @@ inline bool isShiftedMask_64(uint64_t Value, unsigned &MaskIdx,
310310

311311
/// Compile time Log2.
312312
/// Valid only for positive powers of two.
313-
template <size_t kValue> constexpr inline size_t CTLog2() {
313+
template <size_t kValue> constexpr size_t CTLog2() {
314314
static_assert(kValue > 0 && llvm::isPowerOf2_64(kValue),
315315
"Value is not a valid power of 2");
316316
return 1 + CTLog2<kValue / 2>();
317317
}
318318

319-
template <> constexpr inline size_t CTLog2<1>() { return 0; }
319+
template <> constexpr size_t CTLog2<1>() { return 0; }
320320

321321
/// Return the floor log base 2 of the specified value, -1 if the value is zero.
322322
/// (32 bit edition.)
@@ -346,7 +346,7 @@ inline unsigned Log2_64_Ceil(uint64_t Value) {
346346

347347
/// A and B are either alignments or offsets. Return the minimum alignment that
348348
/// may be assumed after adding the two together.
349-
constexpr inline uint64_t MinAlign(uint64_t A, uint64_t B) {
349+
constexpr uint64_t MinAlign(uint64_t A, uint64_t B) {
350350
// The largest power of 2 that divides both A and B.
351351
//
352352
// 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) {
357357

358358
/// Returns the next power of two (in 64-bits) that is strictly greater than A.
359359
/// Returns zero on overflow.
360-
constexpr inline uint64_t NextPowerOf2(uint64_t A) {
360+
constexpr uint64_t NextPowerOf2(uint64_t A) {
361361
A |= (A >> 1);
362362
A |= (A >> 2);
363363
A |= (A >> 4);
@@ -421,7 +421,7 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew) {
421421

422422
/// Returns the next integer (mod 2**64) that is greater than or equal to
423423
/// \p Value and is a multiple of \c Align. \c Align must be non-zero.
424-
template <uint64_t Align> constexpr inline uint64_t alignTo(uint64_t Value) {
424+
template <uint64_t Align> constexpr uint64_t alignTo(uint64_t Value) {
425425
static_assert(Align != 0u, "Align must be non-zero");
426426
return (Value + Align - 1) / Align * Align;
427427
}
@@ -486,7 +486,7 @@ inline uint64_t alignDown(uint64_t Value, uint64_t Align, uint64_t Skew = 0) {
486486

487487
/// Sign-extend the number in the bottom B bits of X to a 32-bit integer.
488488
/// Requires B <= 32.
489-
template <unsigned B> constexpr inline int32_t SignExtend32(uint32_t X) {
489+
template <unsigned B> constexpr int32_t SignExtend32(uint32_t X) {
490490
static_assert(B <= 32, "Bit width out of range.");
491491
if constexpr (B == 0)
492492
return 0;
@@ -504,7 +504,7 @@ inline int32_t SignExtend32(uint32_t X, unsigned B) {
504504

505505
/// Sign-extend the number in the bottom B bits of X to a 64-bit integer.
506506
/// Requires B <= 64.
507-
template <unsigned B> constexpr inline int64_t SignExtend64(uint64_t x) {
507+
template <unsigned B> constexpr int64_t SignExtend64(uint64_t x) {
508508
static_assert(B <= 64, "Bit width out of range.");
509509
if constexpr (B == 0)
510510
return 0;

0 commit comments

Comments
 (0)