aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support/MathExtras.h
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-05-13 00:24:22 +0000
committerDale Johannesen <dalej@apple.com>2009-05-13 00:24:22 +0000
commit8634ce3bb4fd73a5096d1fc3ed6ffa20996e214e (patch)
treeb7bfebbf35cc0ff04599b78130048ee6b8f163b9 /include/llvm/Support/MathExtras.h
parentc10915b85165887e1886179338c7d14925f95c52 (diff)
downloadexternal_llvm-8634ce3bb4fd73a5096d1fc3ed6ffa20996e214e.zip
external_llvm-8634ce3bb4fd73a5096d1fc3ed6ffa20996e214e.tar.gz
external_llvm-8634ce3bb4fd73a5096d1fc3ed6ffa20996e214e.tar.bz2
Add an int64_t variant of abs, for host environments
without one. Use it where we were using abs on int64_t objects. (I strongly suspect the casts to unsigned in the fragments in LoopStrengthReduce are not doing whatever the original intent was, but the obvious change to uint64_t doesn't work. Maybe later.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71612 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/MathExtras.h')
-rw-r--r--include/llvm/Support/MathExtras.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index 0fb2760..fd3ac91 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -425,6 +425,13 @@ inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) {
return ((Value + Align - 1) / Align) * Align;
}
+/// abs64 - absolute value of a 64-bit int. Not all environments support
+/// "abs" on whatever their name for the 64-bit int type is. The absolute
+/// value of the largest negative number is undefined, as with "abs".
+inline int64_t abs64(int64_t x) {
+ return (x < 0) ? -x : x;
+}
+
} // End llvm namespace
#endif