diff options
| author | Vince Harron <vince@nethacker.com> | 2015-05-07 00:05:26 +0000 |
|---|---|---|
| committer | Vince Harron <vince@nethacker.com> | 2015-05-07 00:05:26 +0000 |
| commit | d528112b41449afaa8e53dda633d335ac09e1425 (patch) | |
| tree | 74feb9da2227c472fa758e43d99fbfb7d18b3a43 | |
| parent | 13c03581acd95fed099359b6be08924bd0ca01b0 (diff) | |
| download | bcm5719-llvm-d528112b41449afaa8e53dda633d335ac09e1425.tar.gz bcm5719-llvm-d528112b41449afaa8e53dda633d335ac09e1425.zip | |
Added support for building against Android API-9 SDK
Created an abstraction for log2, llvm::Log2 in Support/MathExtras.h
Hid Android problems inside of it
Differential Revision: http://reviews.llvm.org/D9467
llvm-svn: 236680
| -rw-r--r-- | llvm/include/llvm/Support/MathExtras.h | 13 | ||||
| -rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h index 7edc2ac2e7a..340dc934934 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -24,6 +24,10 @@ #include <intrin.h> #endif +#ifdef __ANDROID_NDK__ +#include <android/api-level.h> +#endif + namespace llvm { /// \brief The behavior an operation has on an input of 0. enum ZeroBehavior { @@ -449,6 +453,15 @@ inline unsigned countPopulation(T Value) { return detail::PopulationCounter<T, sizeof(T)>::count(Value); } +/// Log2 - This function returns the log base 2 of the specified value +inline double Log2(double Value) { +#if defined(__ANDROID_API__) && __ANDROID_API__ < 18 + return (double)__builtin_log2l(Value); +#else + return log2(Value); +#endif +} + /// Log2_32 - This function returns the floor log base 2 of the specified value, /// -1 if the value is zero. (32 bit edition.) /// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2 diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index a85e8136de5..6a37f951942 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1438,7 +1438,7 @@ static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, case Intrinsic::fabs: return ConstantFoldFP(fabs, V, Ty); case Intrinsic::log2: - return ConstantFoldFP(log2, V, Ty); + return ConstantFoldFP(Log2, V, Ty); case Intrinsic::log: return ConstantFoldFP(log, V, Ty); case Intrinsic::log10: |

