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

Unified Diff: Source/wtf/CPU.h

Issue 604373003: [WIP] Supporting arm_neon_optional flag for blink platform. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months 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/graphics/gpu/WebGLImageConversion.cpp ('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..ada4d8521b5a1bfc3f44b644a086e17229978f60 100644
--- a/Source/wtf/CPU.h
+++ b/Source/wtf/CPU.h
@@ -2,7 +2,7 @@
* Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2007-2009 Torch Mobile, Inc.
* Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
- * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ * Copyright (C) 2013-2014 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -155,12 +155,39 @@
# 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 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
+
+// Helper macro
+#if CPU(ARM)
+#define WTF_CPU_ARM_HAS_NEON() isSupportedNEON()
+#endif
+
+// 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 CPU(ARM_NEON) && (!COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 7, 0))
-// All NEON intrinsics usage can be disabled by this macro.
+#if (CPU(ARM_NEON) || CPU(ARM_NEON_OPTIONAL)) && (!COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 7, 0))
+// All NEON intrinsics usage can be enabled by this macro.
#define HAVE_ARM_NEON_INTRINSICS 1
#endif
« no previous file with comments | « Source/platform/graphics/gpu/WebGLImageConversion.cpp ('k') | Source/wtf/CPU.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698