Index: Source/wtf/CPU.h |
diff --git a/Source/wtf/CPU.h b/Source/wtf/CPU.h |
index 061d128afab82d7c4883c04f7e28a4d226e0e4a8..19ce83972f74eafb3b4a8f91741da142afd7b1c9 100644 |
--- a/Source/wtf/CPU.h |
+++ b/Source/wtf/CPU.h |
@@ -155,13 +155,33 @@ |
# endif |
#endif /* !defined(WTF_CPU_ARM_THUMB2) */ |
-#if defined(__ARM_NEON__) && !defined(WTF_CPU_ARM_NEON) |
-#define WTF_CPU_ARM_NEON 1 |
+// The isSupportedNEON() function returns true if the target device |
+// is higher than ARMv7-A and supports Neon instructions. |
+// In OPTIONAL mode, this actually probes the CPU at runtime (and caches the result). |
+#if CPU(ARM_NEON) |
+static inline bool isSupportedNEON(void) { return true; } |
+#elif CPU(ARM_NEON_OPTIONAL) |
+extern bool isSupportedNEON(void) WTF_PURE_FUNCTION; |
+#else |
+static inline bool isSupportedNEON(void) { return false; } |
#endif |
-#if CPU(ARM_NEON) && (!COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 7, 0)) |
-// All NEON intrinsics usage can be disabled by this macro. |
-#define HAVE_ARM_NEON_INTRINSICS 1 |
+// Helper macro |
+#define WTF_CPU_ARM_HAS_NEON() isSupportedNEON() |
+ |
+// Use WTF_CPU_ARM_NEON_WRAP(symbol) to map 'symbol' to a NEON-specific symbol |
+// when applicable. This will transform 'symbol' differently depending on |
+// the current NEON configuration, i.e.: |
+// |
+// NONE -> 'symbol' |
+// WTF_CPU_ARM_NEON -> 'symbolNEON' |
+// WTF_CPU_ARM_NEON_OPTIONAL -> 'symbol' or 'symbolNEON' depending on runtime check. |
+#if CPU(ARM_NEON) |
+# define WTF_CPU_ARM_NEON_WRAP(x) (x ## NEON) |
+#elif CPU(ARM_NEON_OPTIONAL) |
+# define WTF_CPU_ARM_NEON_WRAP(x) (WTF_CPU_ARM_HAS_NEON() ? x ## NEON : x) |
+#else |
+# define WTF_CPU_ARM_NEON_WRAP(x) (x) |
#endif |
#if defined(__ARM_ARCH_7S__) |