[PATCH] Added support for building against Android API-9 SDK
Vince Harron
vince at nethacker.com
Wed May 6 14:50:39 PDT 2015
created an abstraction for log2
Added llvm::Log2 in Support/MathExtras.h
Hid Android problems inside of it
http://reviews.llvm.org/D9467
Files:
include/llvm/Support/MathExtras.h
lib/Analysis/ConstantFolding.cpp
Index: include/llvm/Support/MathExtras.h
===================================================================
--- include/llvm/Support/MathExtras.h
+++ 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 @@
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
Index: lib/Analysis/ConstantFolding.cpp
===================================================================
--- lib/Analysis/ConstantFolding.cpp
+++ lib/Analysis/ConstantFolding.cpp
@@ -1438,7 +1438,7 @@
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:
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9467.25091.patch
Type: text/x-patch
Size: 1461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150506/7c393770/attachment.bin>
More information about the llvm-commits
mailing list