[llvm-commits] [llvm] r64691 - /llvm/trunk/include/llvm/Support/MathExtras.h

Daniel Dunbar daniel at zuster.org
Mon Feb 16 14:57:04 PST 2009


Author: ddunbar
Date: Mon Feb 16 16:57:04 2009
New Revision: 64691

URL: http://llvm.org/viewvc/llvm-project?rev=64691&view=rev
Log:
Add llvm::RoundUpToAlignment.
 - No functionality change.

Modified:
    llvm/trunk/include/llvm/Support/MathExtras.h

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=64691&r1=64690&r2=64691&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Mon Feb 16 16:57:04 2009
@@ -412,6 +412,18 @@
   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
 





More information about the llvm-commits mailing list