[llvm] r236680 - Added support for building against Android API-9 SDK

Vince Harron vince at nethacker.com
Wed May 6 17:05:27 PDT 2015


Author: vharron
Date: Wed May  6 19:05:26 2015
New Revision: 236680

URL: http://llvm.org/viewvc/llvm-project?rev=236680&view=rev
Log:
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


Modified:
    llvm/trunk/include/llvm/Support/MathExtras.h
    llvm/trunk/lib/Analysis/ConstantFolding.cpp

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=236680&r1=236679&r2=236680&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Wed May  6 19:05:26 2015
@@ -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

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=236680&r1=236679&r2=236680&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Wed May  6 19:05:26 2015
@@ -1438,7 +1438,7 @@ static Constant *ConstantFoldScalarCall(
         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:





More information about the llvm-commits mailing list