Add a [rtc_]build_with_neon variable to unify conditions.

Also consolidate ARM options for gn in an arm_neon_config.

R=jridges@masque.com, kjellander@webrtc.org, zhongwei.yao@chromium.org

Review URL: https://codereview.webrtc.org/1181373004.

Cr-Commit-Position: refs/heads/master@{#9501}
This commit is contained in:
Andrew MacDonald
2015-06-24 18:25:54 -07:00
parent 1c7075f076
commit ac4234ccfc
9 changed files with 79 additions and 108 deletions

View File

@ -24,11 +24,19 @@
'-mfpu=vfpv3-d16',
],
'conditions': [
# "-mfpu=neon" is not requried for arm64 in GCC.
# "-mfpu=neon" is not required for arm64 in GCC.
['target_arch!="arm64"', {
'cflags': [
'-mfpu=neon',
],
}],
# Disable LTO on NEON targets due to compiler bug.
# TODO(fdegans): Enable this. See crbug.com/408997.
['use_lto==1', {
'cflags!': [
'-flto',
'-ffat-lto-objects',
],
}],
],
}

View File

@ -121,6 +121,9 @@
# enable schannel on windows.
'use_legacy_ssl_defaults%': 0,
# Determines whether NEON code will be built.
'build_with_neon%': 0,
'conditions': [
['build_with_chromium==1', {
# Exclude pulse audio on Chromium since its prerequisites don't require
@ -152,6 +155,9 @@
['target_arch=="arm" or target_arch=="arm64"', {
'prefer_fixed_point%': 1,
}],
['(target_arch=="arm" and (arm_neon==1 or arm_neon_optional==1)) or target_arch=="arm64"', {
'build_with_neon%': 1,
}],
['OS!="ios" and (target_arch!="arm" or arm_version>=7) and target_arch!="mips64el"', {
'rtc_use_openmax_dl%': 1,
}, {

View File

@ -105,10 +105,10 @@ declare_args() {
rtc_use_openmax_dl = false
}
# WebRTC builds ARM v7 Neon instruction set optimized code for both iOS and
# Android, which is why we currently cannot use the variables in
# //build/config/arm.gni (since it disables Neon for Android).
rtc_build_armv7_neon = current_cpu == "arm" && arm_version >= 7
# Determines whether NEON code will be built.
rtc_build_with_neon = (current_cpu == "arm" &&
(arm_use_neon == 1 || arm_optionally_use_neon == 1)) ||
current_cpu == "arm64"
}
# Make it possible to provide custom locations for some libraries (move these

View File

@ -130,14 +130,13 @@ source_set("common_audio") {
]
if (arm_version >= 7) {
deps += [ ":common_audio_neon" ]
sources += [ "signal_processing/filter_ar_fast_q12_armv7.S" ]
} else {
sources += [ "signal_processing/filter_ar_fast_q12.c" ]
}
}
if (current_cpu == "arm64") {
if (rtc_build_with_neon) {
deps += [ ":common_audio_neon" ]
}
@ -211,7 +210,7 @@ if (current_cpu == "x86" || current_cpu == "x64") {
}
}
if (rtc_build_armv7_neon || current_cpu == "arm64") {
if (rtc_build_with_neon) {
source_set("common_audio_neon") {
sources = [
"fir_filter_neon.cc",
@ -221,20 +220,24 @@ if (rtc_build_armv7_neon || current_cpu == "arm64") {
"signal_processing/min_max_operations_neon.c",
]
configs += [ "..:common_config" ]
public_configs = [ "..:common_inherited_config" ]
if (!arm_use_neon) {
if (current_cpu != "arm64") {
# Enable compilation for the NEON instruction set. This is needed
# since //build/config/arm.gni only enables NEON for iOS, not Android.
# This provides the same functionality as webrtc/build/arm_neon.gypi.
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
# Disable LTO in audio_processing_neon target due to compiler bug.
# Disable LTO on NEON targets due to compiler bug.
# TODO(fdegans): Enable this. See crbug.com/408997.
if (rtc_use_lto) {
cflags -= [
"-flto",
"-ffat-lto-objects",
]
}
configs += [ "..:common_config" ]
public_configs = [ "..:common_inherited_config" ]
}
}

View File

@ -136,6 +136,9 @@
['target_arch=="ia32" or target_arch=="x64"', {
'dependencies': ['common_audio_sse2',],
}],
['build_with_neon==1', {
'dependencies': ['common_audio_neon',],
}],
['target_arch=="arm"', {
'sources': [
'signal_processing/complex_bit_reverse_arm.S',
@ -147,7 +150,6 @@
],
'conditions': [
['arm_version>=7', {
'dependencies': ['common_audio_neon',],
'sources': [
'signal_processing/filter_ar_fast_q12_armv7.S',
],
@ -157,9 +159,6 @@
}],
], # conditions
}],
['target_arch=="arm64"', {
'dependencies': ['common_audio_neon',],
}],
['target_arch=="mipsel" and mips_arch_variant!="r6"', {
'sources': [
'signal_processing/include/spl_inl_mips.h',
@ -212,7 +211,7 @@
},
], # targets
}],
['target_arch=="arm" and arm_version>=7 or target_arch=="arm64"', {
['build_with_neon==1', {
'targets': [
{
'target_name': 'common_audio_neon',
@ -225,15 +224,6 @@
'signal_processing/downsample_fast_neon.c',
'signal_processing/min_max_operations_neon.c',
],
'conditions': [
# Disable LTO in common_audio_neon target due to compiler bug
['use_lto==1', {
'cflags!': [
'-flto',
'-ffat-lto-objects',
],
}],
],
},
], # targets
}],

View File

@ -528,6 +528,7 @@ source_set("isac_fix") {
"codecs/isac/fix/source/initialize.c",
"codecs/isac/fix/source/isacfix.c",
"codecs/isac/fix/source/lattice.c",
"codecs/isac/fix/source/lattice_c.c",
"codecs/isac/fix/source/lpc_masking_model.c",
"codecs/isac/fix/source/lpc_masking_model.h",
"codecs/isac/fix/source/lpc_tables.c",
@ -566,27 +567,19 @@ source_set("isac_fix") {
"../../system_wrappers",
]
if (current_cpu == "arm64") {
if (rtc_build_with_neon) {
deps += [ ":isac_neon" ]
}
if (rtc_build_armv7_neon) {
deps += [ ":isac_neon" ]
# Enable compilation for the ARM v7 Neon instruction set. This is needed
# since //build/config/arm.gni only enables Neon for iOS, not Android.
# This provides the same functionality as webrtc/build/arm_neon.gypi.
# TODO(kjellander): Investigate if this can be moved into webrtc.gni or
# //build/config/arm.gni instead, to reduce code duplication.
# Remove the -mfpu=vfpv3-d16 cflag.
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
if (current_cpu == "arm" && arm_version >= 7) {
sources += [
"codecs/isac/fix/source/lattice_armv7.S",
"codecs/isac/fix/source/pitch_filter_armv6.S",
]
sources -= [ "codecs/isac/fix/source/pitch_filter_c.c" ]
sources -= [
"codecs/isac/fix/source/lattice_c.c",
"codecs/isac/fix/source/pitch_filter_c.c",
]
}
if (current_cpu == "mipsel") {
@ -597,7 +590,10 @@ source_set("isac_fix") {
"codecs/isac/fix/source/pitch_estimator_mips.c",
"codecs/isac/fix/source/transform_mips.c",
]
sources -= [ "codecs/isac/fix/source/pitch_estimator_c.c" ]
sources -= [
"codecs/isac/fix/source/lattice_c.c",
"codecs/isac/fix/source/pitch_estimator_c.c",
]
if (mips_dsp_rev > 0) {
sources += [ "codecs/isac/fix/source/filterbanks_mips.c" ]
}
@ -609,13 +605,9 @@ source_set("isac_fix") {
sources -= [ "codecs/isac/fix/source/pitch_filter_c.c" ]
}
}
if (!rtc_build_armv7_neon && current_cpu != "mipsel") {
sources += [ "codecs/isac/fix/source/lattice_c.c" ]
}
}
if (rtc_build_armv7_neon || current_cpu == "arm64") {
if (rtc_build_with_neon) {
source_set("isac_neon") {
sources = [
"codecs/isac/fix/source/entropy_coding_neon.c",
@ -623,26 +615,23 @@ if (rtc_build_armv7_neon || current_cpu == "arm64") {
"codecs/isac/fix/source/lattice_neon.c",
"codecs/isac/fix/source/transform_neon.c",
]
if (rtc_build_armv7_neon) {
# Enable compilation for the ARM v7 Neon instruction set. This is needed
# since //build/config/arm.gni only enables Neon for iOS, not Android.
# This provides the same functionality as webrtc/build/arm_neon.gypi.
# TODO(kjellander): Investigate if this can be moved into webrtc.gni or
# //build/config/arm.gni instead, to reduce code duplication.
# Remove the -mfpu=vfpv3-d16 cflag.
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
if (current_cpu != "arm64" || !is_clang) {
# Disable AllpassFilter2FixDec16Neon function due to a clang bug.
# Refer more details at:
# For more details refer to:
# https://code.google.com/p/webrtc/issues/detail?id=4567
sources += [ "codecs/isac/fix/source/filterbanks_neon.c" ]
}
# Disable LTO in audio_processing_neon target due to compiler bug.
if (current_cpu != "arm64") {
# Enable compilation for the NEON instruction set. This is needed
# since //build/config/arm.gni only enables NEON for iOS, not Android.
# This provides the same functionality as webrtc/build/arm_neon.gypi.
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
# Disable LTO on NEON targets due to compiler bug.
# TODO(fdegans): Enable this. See crbug.com/408997.
if (rtc_use_lto) {
cflags -= [
"-flto",

View File

@ -89,13 +89,8 @@
'fix/source/lattice_c.c',
'fix/source/pitch_filter_c.c',
],
'conditions': [
['arm_neon==1 or arm_neon_optional==1', {
'dependencies': [ 'isac_neon' ],
}],
],
}],
['target_arch=="arm64"', {
['build_with_neon==1', {
'dependencies': ['isac_neon', ],
}],
['target_arch=="mipsel" and mips_arch_variant!="r6"', {
@ -131,7 +126,7 @@
},
],
'conditions': [
['target_arch=="arm" and arm_version>=7 or target_arch=="arm64"', {
['build_with_neon==1', {
'targets': [
{
'target_name': 'isac_neon',
@ -147,18 +142,11 @@
'fix/source/transform_neon.c',
],
'conditions': [
# Disable LTO in isac_neon target due to compiler bug
['use_lto==1', {
'cflags!': [
'-flto',
'-ffat-lto-objects',
],
}],
# Disable AllpassFilter2FixDec16Neon function due to a clang
# bug. Refer more details at:
# Disable AllpassFilter2FixDec16Neon function due to a clang bug.
# For more details refer to:
# https://code.google.com/p/webrtc/issues/detail?id=4567
['target_arch!="arm64" or clang==0', {
'sources': ['fix/source/filterbanks_neon.c',],
'sources': ['fix/source/filterbanks_neon.c',],
}]
],
},

View File

@ -180,7 +180,7 @@ source_set("audio_processing") {
deps += [ ":audio_processing_sse2" ]
}
if (rtc_build_armv7_neon || current_cpu == "arm64") {
if (rtc_build_with_neon) {
deps += [ ":audio_processing_neon" ]
}
@ -242,7 +242,7 @@ if (current_cpu == "x86" || current_cpu == "x64") {
}
}
if (rtc_build_armv7_neon || current_cpu == "arm64") {
if (rtc_build_with_neon) {
source_set("audio_processing_neon") {
sources = [
"aec/aec_core_neon.c",
@ -251,32 +251,28 @@ if (rtc_build_armv7_neon || current_cpu == "arm64") {
"ns/nsx_core_neon.c",
]
configs += [ "../..:common_config" ]
public_configs = [ "../..:common_inherited_config" ]
deps = [
"../../common_audio",
]
# Enable compilation for the ARM v7 Neon instruction set. This is needed
# since //build/config/arm.gni only enables Neon for iOS, not Android.
# This provides the same functionality as webrtc/build/arm_neon.gypi.
# TODO(kjellander): Investigate if this can be moved into webrtc.gni or
# //build/config/arm.gni instead, to reduce code duplication.
# Remove the -mfpu=vfpv3-d16 cflag.
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
# "-mfpu=neon" is not requried for arm64 in GCC.
if (current_cpu != "arm64") {
# Enable compilation for the NEON instruction set. This is needed
# since //build/config/arm.gni only enables NEON for iOS, not Android.
# This provides the same functionality as webrtc/build/arm_neon.gypi.
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
# Disable LTO in audio_processing_neon target due to compiler bug.
# Disable LTO on NEON targets due to compiler bug.
# TODO(fdegans): Enable this. See crbug.com/408997.
if (rtc_use_lto) {
cflags -= [
"-flto",
"-ffat-lto-objects",
]
}
configs += [ "../..:common_config" ]
public_configs = [ "../..:common_inherited_config" ]
deps = [
"../../common_audio",
]
}
}

View File

@ -186,7 +186,7 @@
['target_arch=="ia32" or target_arch=="x64"', {
'dependencies': ['audio_processing_sse2',],
}],
['(target_arch=="arm" and arm_version>=7) or target_arch=="arm64"', {
['build_with_neon==1', {
'dependencies': ['audio_processing_neon',],
}],
['target_arch=="mipsel" and mips_arch_variant!="r6"', {
@ -249,7 +249,7 @@
},
],
}],
['(target_arch=="arm" and arm_version>=7) or target_arch=="arm64"', {
['build_with_neon==1', {
'targets': [{
'target_name': 'audio_processing_neon',
'type': 'static_library',
@ -263,15 +263,6 @@
'aecm/aecm_core_neon.c',
'ns/nsx_core_neon.c',
],
'conditions': [
# Disable LTO in audio_processing_neon target due to compiler bug
['use_lto==1', {
'cflags!': [
'-flto',
'-ffat-lto-objects',
],
}],
],
}],
}],
],