aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support/MathExtras.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-16 22:57:04 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-16 22:57:04 +0000
commit305a1bf30995859188bf274d442b3a756c6e65ca (patch)
tree50b506522bbcf76c29a6ede3d5174a4ef299fe8d /include/llvm/Support/MathExtras.h
parentf22bdca2722add4bac21f91c05cd9bccf65ed45f (diff)
downloadexternal_llvm-305a1bf30995859188bf274d442b3a756c6e65ca.zip
external_llvm-305a1bf30995859188bf274d442b3a756c6e65ca.tar.gz
external_llvm-305a1bf30995859188bf274d442b3a756c6e65ca.tar.bz2
Add llvm::RoundUpToAlignment.
- No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64691 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/MathExtras.h')
-rw-r--r--include/llvm/Support/MathExtras.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index d55fb80..c314e0e 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -412,6 +412,18 @@ static inline uint64_t NextPowerOf2(uint64_t A) {
A |= (A >> 32);
return A + 1;
}
+
+/// RoundUpToAlignment - Returns the next integer (mod 2**64) that is
+/// greater than or equal to \arg Value and is a multiple of \arg
+/// Align. Align must be non-zero.
+///
+/// Examples:
+/// RoundUpToAlignment(5, 8) = 8
+/// RoundUpToAlignment(17, 8) = 24
+/// RoundUpToAlignment(~0LL, 8) = 0
+inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) {
+ return ((Value + Align - 1) / Align) * Align;
+}
} // End llvm namespace