diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-04-03 07:51:10 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-04-03 07:51:10 +0000 |
commit | 62cc576dca6a6aa62c0424f0a1e93a0a679d4c8a (patch) | |
tree | ba3309de92b14839b2ca6ca0c6d3b39714f95d4c /include/llvm/Support/MathExtras.h | |
parent | 20e856b2a58d12231aa42d5d13888b15ac03e5a4 (diff) | |
download | FreeBSD-src-62cc576dca6a6aa62c0424f0a1e93a0a679d4c8a.zip FreeBSD-src-62cc576dca6a6aa62c0424f0a1e93a0a679d4c8a.tar.gz |
Update LLVM to r100285.
Diffstat (limited to 'include/llvm/Support/MathExtras.h')
-rw-r--r-- | include/llvm/Support/MathExtras.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index 9c5f32c..f56241c 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -457,6 +457,18 @@ inline int64_t abs64(int64_t x) { return (x < 0) ? -x : x; } +/// SignExtend32 - Sign extend B-bit number x to 32-bit int. +/// Usage int32_t r = SignExtend32<5>(x); +template <unsigned B> inline int32_t SignExtend32(int32_t x) { + return (x << (32 - B)) >> (32 - B); +} + +/// SignExtend64 - Sign extend B-bit number x to 64-bit int. +/// Usage int64_t r = SignExtend64<5>(x); +template <unsigned B> inline int64_t SignExtend64(int32_t x) { + return (x << (64 - B)) >> (64 - B); +} + } // End llvm namespace #endif |