From 7b9486ad4355a010d22e0737cee9cd7c7b747ece Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Wed, 13 May 2009 00:24:22 +0000 Subject: 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 --- include/llvm/Support/MathExtras.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/llvm/Support/MathExtras.h') diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index 0fb2760b12..fd3ac9157b 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 -- cgit v1.2.3