aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-08-17 19:17:10 +0000
committerChris Lattner <sabre@nondot.org>2004-08-17 19:17:10 +0000
commite265504e82310266271fa2329b6ef8115bbe8244 (patch)
tree2ecc0bab69831cf1b4c3b8208251119326936886 /include
parentbfddc2030a7e67b9e0c42276525d6932375ff261 (diff)
downloadexternal_llvm-e265504e82310266271fa2329b6ef8115bbe8244.zip
external_llvm-e265504e82310266271fa2329b6ef8115bbe8244.tar.gz
external_llvm-e265504e82310266271fa2329b6ef8115bbe8244.tar.bz2
Add an overload
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/Support/MathExtras.h7
-rw-r--r--include/llvm/Support/MathExtras.h7
2 files changed, 14 insertions, 0 deletions
diff --git a/include/Support/MathExtras.h b/include/Support/MathExtras.h
index d520985..c1384d3 100644
--- a/include/Support/MathExtras.h
+++ b/include/Support/MathExtras.h
@@ -29,6 +29,13 @@ inline unsigned log2(uint64_t C) {
return getPow;
}
+inline unsigned log2(unsigned C) {
+ unsigned getPow;
+ for (getPow = 0; C > 1; ++getPow)
+ C >>= 1;
+ return getPow;
+}
+
inline bool isPowerOf2(int64_t C, unsigned &getPow) {
if (C < 0) C = -C;
if (C > 0 && C == (C & ~(C - 1))) {
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index d520985..c1384d3 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -29,6 +29,13 @@ inline unsigned log2(uint64_t C) {
return getPow;
}
+inline unsigned log2(unsigned C) {
+ unsigned getPow;
+ for (getPow = 0; C > 1; ++getPow)
+ C >>= 1;
+ return getPow;
+}
+
inline bool isPowerOf2(int64_t C, unsigned &getPow) {
if (C < 0) C = -C;
if (C > 0 && C == (C & ~(C - 1))) {