Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: src/IceUtils.h

Issue 1156713003: Subzero ARM: lower alloca instruction. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: trailing space Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | tests_lit/llvm2ice_tests/alloc.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceUtils.h
diff --git a/src/IceUtils.h b/src/IceUtils.h
index cf0be63364f2eb1052073c9c501fec60d538881e..a3b5462539a0ff347d4008cd2b94b4d924e7be7e 100644
--- a/src/IceUtils.h
+++ b/src/IceUtils.h
@@ -61,16 +61,27 @@ public:
return IsUint(N, Value);
}
+ // Return true if the addition X + Y will cause integer overflow for
+ // integers of type T.
template <typename T> static inline bool WouldOverflowAdd(T X, T Y) {
return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) ||
(X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y)));
}
+ // Return true if X is already aligned by N, where N is a power of 2.
template <typename T> static inline bool IsAligned(T X, intptr_t N) {
assert(llvm::isPowerOf2_64(N));
return (X & (N - 1)) == 0;
}
+ // Return Value adjusted to the next highest multiple of Alignment.
+ static inline uint32_t applyAlignment(uint32_t Value, uint32_t Alignment) {
+ assert(llvm::isPowerOf2_32(Alignment));
+ return (Value + Alignment - 1) & -Alignment;
+ }
+
+ // Return amount which must be added to adjust Pos to the next highest
+ // multiple of Align.
static inline uint64_t OffsetToAlignment(uint64_t Pos, uint64_t Align) {
assert(llvm::isPowerOf2_64(Align));
uint64_t Mod = Pos & (Align - 1);
@@ -79,6 +90,7 @@ public:
return Align - Mod;
}
+ // Rotate the value bit pattern to the left by shift bits.
// Precondition: 0 <= shift < 32
static inline uint32_t rotateLeft32(uint32_t value, uint32_t shift) {
if (shift == 0)
@@ -86,6 +98,7 @@ public:
return (value << shift) | (value >> (32 - shift));
}
+ // Rotate the value bit pattern to the right by shift bits.
static inline uint32_t rotateRight32(uint32_t value, uint32_t shift) {
if (shift == 0)
return value;
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | tests_lit/llvm2ice_tests/alloc.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698