arm: First step towards dynamic NEON support.
This patch adds minimal support for dynamic ARM NEON support,
i.e. the ability to probe the CPU at runtime for NEON and
provide alternate code paths when it is available.
- Add include/core/SkUtilsArm.h, which declares a few helper
macros (e.g. SK_NEON_ARM_IS_DYNAMIC), plus the handy
function 'sk_cpu_arm_has_neon()' which returns true if
the target CPU supports the ARM NEON instruction set.
Note that the header is in include/core/ because it will
have to be included from NEON-specific code under src/code/
It would probably be more logical to put it under include/opts/
instead, but this would require moving all the NEON-specific
stuff under src/code/ into src/opts/, which is not trivial
due to the way the code is currently architected.
- Add src/core/SkUtilsArm.cpp which implements
'sk_cpu_arm_has_neon' for ARM-based Linux systems, only
when SK_NEON_ARM_IS_DYNAMIC is true.
(For other cases, 'sk_cpu_arm_has_neon' is an inline function
that returns a constant 'true' or 'false' value).
There is no user-level accessible CPUID instruction on ARM,
so do all CPU feature probing by parsing /proc/cpuinfo.
This is Linux-specific.
For Debug build types, the CPU probing result is printed
to the Android log (or Linux command-line) for easier
debugging.
- Create a new 'opts_neon' target (static library) which shall
contain all the NEON-specific code paths for the library.
This is necessary because -mfpu=neon impacts also non-scalar
code. Just like with -mssse3 on x86, we can't build the rest
of the library with this flag.
Note that for now, we only include memset16_neon and
memset32_neon in this library.
- Modify opts_check_arm.cpp to implement SK_ARM_NEON_IS_DYNAMIC
properly.
Compared to a 'xoom' build, the only difference is the use of
NEON-optimized memset16/32 functions. Later patches will move
more NEON-specific code paths to 'opts_neon'.
Review URL: https://codereview.appspot.com/6247058
git-svn-id: http://skia.googlecode.com/svn/trunk@4069 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gyp/opts.gyp b/gyp/opts.gyp
index cf8e6dd..41cb0ed 100644
--- a/gyp/opts.gyp
+++ b/gyp/opts.gyp
@@ -56,14 +56,22 @@
'cflags': [
'-fomit-frame-pointer',
],
+ 'variables': {
+ 'arm_neon_optional%': '<(arm_neon_optional>',
+ },
'sources': [
'../src/opts/opts_check_arm.cpp',
'../src/opts/memset.arm.S',
- '../src/opts/memset16_neon.S',
- '../src/opts/memset32_neon.S',
'../src/opts/SkBitmapProcState_opts_arm.cpp',
'../src/opts/SkBlitRow_opts_arm.cpp',
],
+ 'conditions': [
+ [ 'arm_neon == 1 or arm_neon_optional == 1', {
+ 'dependencies': [
+ 'opts_neon',
+ ]
+ }]
+ ],
}],
[ 'skia_target_arch == "arm" and armv7 != 1', {
'sources': [
@@ -107,6 +115,33 @@
}],
],
},
+ # NEON code must be compiled with -mfpu=neon which also affects scalar
+ # code. To support dynamic NEON code paths, we need to build all
+ # NEON-specific sources in a separate static library. The situation
+ # is very similar to the SSSE3 one.
+ {
+ 'target_name': 'opts_neon',
+ 'type': 'static_library',
+ 'include_dirs': [
+ '../include/config',
+ '../include/core',
+ '../src/core',
+ ],
+ 'cflags!': [
+ '-fno-omit-frame-pointer',
+ '-mfpu=vfp', # remove them all, just in case.
+ '-mfpu=vfpv3',
+ '-mfpu=vfpv3-d16',
+ ],
+ 'cflags': [
+ '-fomit-frame-pointer',
+ '-mfpu=neon',
+ ],
+ 'sources': [
+ '../src/opts/memset16_neon.S',
+ '../src/opts/memset32_neon.S',
+ ],
+ },
],
}