Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1860)

Unified Diff: Source/wtf/CPU.h

Issue 715753002: [WIP] support arm_neon_optional flag in blink. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/wtf/CPU.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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__)
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/wtf/CPU.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698