Index: include/llvm/Support/MathExtras.h =================================================================== --- include/llvm/Support/MathExtras.h +++ include/llvm/Support/MathExtras.h @@ -606,22 +606,26 @@ /// /// Examples: /// \code -/// RoundUpToAlignment(5, 8) = 8 -/// RoundUpToAlignment(17, 8) = 24 -/// RoundUpToAlignment(~0LL, 8) = 0 -/// RoundUpToAlignment(321, 255) = 510 +/// align(5, 8) = 8 +/// align(17, 8) = 24 +/// align(~0LL, 8) = 0 +/// align(321, 255) = 510 /// -/// RoundUpToAlignment(5, 8, 7) = 7 -/// RoundUpToAlignment(17, 8, 1) = 17 -/// RoundUpToAlignment(~0LL, 8, 3) = 3 -/// RoundUpToAlignment(321, 255, 42) = 552 +/// align(5, 8, 7) = 7 +/// align(17, 8, 1) = 17 +/// align(~0LL, 8, 3) = 3 +/// align(321, 255, 42) = 552 /// \endcode -inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align, - uint64_t Skew = 0) { +inline uint64_t align(uint64_t Value, uint64_t Align, uint64_t Skew = 0) { Skew %= Align; return (Value + Align - 1 - Skew) / Align * Align + Skew; } +inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align, + uint64_t Skew = 0) { + return align(Value, Align, Skew); +} + /// Returns the offset to the next integer (mod 2**64) that is greater than /// or equal to \p Value and is a multiple of \p Align. \p Align must be /// non-zero.