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', '-mfpu=vfpv3-d16',
], ],
'conditions': [ 'conditions': [
# "-mfpu=neon" is not requried for arm64 in GCC. # "-mfpu=neon" is not required for arm64 in GCC.
['target_arch!="arm64"', { ['target_arch!="arm64"', {
'cflags': [ 'cflags': [
'-mfpu=neon', '-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. # enable schannel on windows.
'use_legacy_ssl_defaults%': 0, 'use_legacy_ssl_defaults%': 0,
# Determines whether NEON code will be built.
'build_with_neon%': 0,
'conditions': [ 'conditions': [
['build_with_chromium==1', { ['build_with_chromium==1', {
# Exclude pulse audio on Chromium since its prerequisites don't require # Exclude pulse audio on Chromium since its prerequisites don't require
@ -152,6 +155,9 @@
['target_arch=="arm" or target_arch=="arm64"', { ['target_arch=="arm" or target_arch=="arm64"', {
'prefer_fixed_point%': 1, '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"', { ['OS!="ios" and (target_arch!="arm" or arm_version>=7) and target_arch!="mips64el"', {
'rtc_use_openmax_dl%': 1, 'rtc_use_openmax_dl%': 1,
}, { }, {

View File

@ -105,10 +105,10 @@ declare_args() {
rtc_use_openmax_dl = false rtc_use_openmax_dl = false
} }
# WebRTC builds ARM v7 Neon instruction set optimized code for both iOS and # Determines whether NEON code will be built.
# Android, which is why we currently cannot use the variables in rtc_build_with_neon = (current_cpu == "arm" &&
# //build/config/arm.gni (since it disables Neon for Android). (arm_use_neon == 1 || arm_optionally_use_neon == 1)) ||
rtc_build_armv7_neon = current_cpu == "arm" && arm_version >= 7 current_cpu == "arm64"
} }
# Make it possible to provide custom locations for some libraries (move these # 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) { if (arm_version >= 7) {
deps += [ ":common_audio_neon" ]
sources += [ "signal_processing/filter_ar_fast_q12_armv7.S" ] sources += [ "signal_processing/filter_ar_fast_q12_armv7.S" ]
} else { } else {
sources += [ "signal_processing/filter_ar_fast_q12.c" ] sources += [ "signal_processing/filter_ar_fast_q12.c" ]
} }
} }
if (current_cpu == "arm64") { if (rtc_build_with_neon) {
deps += [ ":common_audio_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") { source_set("common_audio_neon") {
sources = [ sources = [
"fir_filter_neon.cc", "fir_filter_neon.cc",
@ -221,20 +220,24 @@ if (rtc_build_armv7_neon || current_cpu == "arm64") {
"signal_processing/min_max_operations_neon.c", "signal_processing/min_max_operations_neon.c",
] ]
configs += [ "..:common_config" ] if (current_cpu != "arm64") {
public_configs = [ "..:common_inherited_config" ] # Enable compilation for the NEON instruction set. This is needed
# since //build/config/arm.gni only enables NEON for iOS, not Android.
if (!arm_use_neon) { # This provides the same functionality as webrtc/build/arm_neon.gypi.
configs -= [ "//build/config/compiler:compiler_arm_fpu" ] configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ] 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) { if (rtc_use_lto) {
cflags -= [ cflags -= [
"-flto", "-flto",
"-ffat-lto-objects", "-ffat-lto-objects",
] ]
} }
configs += [ "..:common_config" ]
public_configs = [ "..:common_inherited_config" ]
} }
} }

View File

@ -136,6 +136,9 @@
['target_arch=="ia32" or target_arch=="x64"', { ['target_arch=="ia32" or target_arch=="x64"', {
'dependencies': ['common_audio_sse2',], 'dependencies': ['common_audio_sse2',],
}], }],
['build_with_neon==1', {
'dependencies': ['common_audio_neon',],
}],
['target_arch=="arm"', { ['target_arch=="arm"', {
'sources': [ 'sources': [
'signal_processing/complex_bit_reverse_arm.S', 'signal_processing/complex_bit_reverse_arm.S',
@ -147,7 +150,6 @@
], ],
'conditions': [ 'conditions': [
['arm_version>=7', { ['arm_version>=7', {
'dependencies': ['common_audio_neon',],
'sources': [ 'sources': [
'signal_processing/filter_ar_fast_q12_armv7.S', 'signal_processing/filter_ar_fast_q12_armv7.S',
], ],
@ -157,9 +159,6 @@
}], }],
], # conditions ], # conditions
}], }],
['target_arch=="arm64"', {
'dependencies': ['common_audio_neon',],
}],
['target_arch=="mipsel" and mips_arch_variant!="r6"', { ['target_arch=="mipsel" and mips_arch_variant!="r6"', {
'sources': [ 'sources': [
'signal_processing/include/spl_inl_mips.h', 'signal_processing/include/spl_inl_mips.h',
@ -212,7 +211,7 @@
}, },
], # targets ], # targets
}], }],
['target_arch=="arm" and arm_version>=7 or target_arch=="arm64"', { ['build_with_neon==1', {
'targets': [ 'targets': [
{ {
'target_name': 'common_audio_neon', 'target_name': 'common_audio_neon',
@ -225,15 +224,6 @@
'signal_processing/downsample_fast_neon.c', 'signal_processing/downsample_fast_neon.c',
'signal_processing/min_max_operations_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 ], # targets
}], }],

View File

@ -528,6 +528,7 @@ source_set("isac_fix") {
"codecs/isac/fix/source/initialize.c", "codecs/isac/fix/source/initialize.c",
"codecs/isac/fix/source/isacfix.c", "codecs/isac/fix/source/isacfix.c",
"codecs/isac/fix/source/lattice.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.c",
"codecs/isac/fix/source/lpc_masking_model.h", "codecs/isac/fix/source/lpc_masking_model.h",
"codecs/isac/fix/source/lpc_tables.c", "codecs/isac/fix/source/lpc_tables.c",
@ -566,27 +567,19 @@ source_set("isac_fix") {
"../../system_wrappers", "../../system_wrappers",
] ]
if (current_cpu == "arm64") { if (rtc_build_with_neon) {
deps += [ ":isac_neon" ] deps += [ ":isac_neon" ]
} }
if (rtc_build_armv7_neon) { if (current_cpu == "arm" && arm_version >= 7) {
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" ]
sources += [ sources += [
"codecs/isac/fix/source/lattice_armv7.S", "codecs/isac/fix/source/lattice_armv7.S",
"codecs/isac/fix/source/pitch_filter_armv6.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") { if (current_cpu == "mipsel") {
@ -597,7 +590,10 @@ source_set("isac_fix") {
"codecs/isac/fix/source/pitch_estimator_mips.c", "codecs/isac/fix/source/pitch_estimator_mips.c",
"codecs/isac/fix/source/transform_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) { if (mips_dsp_rev > 0) {
sources += [ "codecs/isac/fix/source/filterbanks_mips.c" ] 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" ] 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") { source_set("isac_neon") {
sources = [ sources = [
"codecs/isac/fix/source/entropy_coding_neon.c", "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/lattice_neon.c",
"codecs/isac/fix/source/transform_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) { if (current_cpu != "arm64" || !is_clang) {
# Disable AllpassFilter2FixDec16Neon function due to a clang bug. # 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 # https://code.google.com/p/webrtc/issues/detail?id=4567
sources += [ "codecs/isac/fix/source/filterbanks_neon.c" ] 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) { if (rtc_use_lto) {
cflags -= [ cflags -= [
"-flto", "-flto",

View File

@ -89,13 +89,8 @@
'fix/source/lattice_c.c', 'fix/source/lattice_c.c',
'fix/source/pitch_filter_c.c', 'fix/source/pitch_filter_c.c',
], ],
'conditions': [
['arm_neon==1 or arm_neon_optional==1', {
'dependencies': [ 'isac_neon' ],
}], }],
], ['build_with_neon==1', {
}],
['target_arch=="arm64"', {
'dependencies': ['isac_neon', ], 'dependencies': ['isac_neon', ],
}], }],
['target_arch=="mipsel" and mips_arch_variant!="r6"', { ['target_arch=="mipsel" and mips_arch_variant!="r6"', {
@ -131,7 +126,7 @@
}, },
], ],
'conditions': [ 'conditions': [
['target_arch=="arm" and arm_version>=7 or target_arch=="arm64"', { ['build_with_neon==1', {
'targets': [ 'targets': [
{ {
'target_name': 'isac_neon', 'target_name': 'isac_neon',
@ -147,15 +142,8 @@
'fix/source/transform_neon.c', 'fix/source/transform_neon.c',
], ],
'conditions': [ 'conditions': [
# Disable LTO in isac_neon target due to compiler bug # Disable AllpassFilter2FixDec16Neon function due to a clang bug.
['use_lto==1', { # For more details refer to:
'cflags!': [
'-flto',
'-ffat-lto-objects',
],
}],
# Disable AllpassFilter2FixDec16Neon function due to a clang
# bug. Refer more details at:
# https://code.google.com/p/webrtc/issues/detail?id=4567 # https://code.google.com/p/webrtc/issues/detail?id=4567
['target_arch!="arm64" or clang==0', { ['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" ] deps += [ ":audio_processing_sse2" ]
} }
if (rtc_build_armv7_neon || current_cpu == "arm64") { if (rtc_build_with_neon) {
deps += [ ":audio_processing_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") { source_set("audio_processing_neon") {
sources = [ sources = [
"aec/aec_core_neon.c", "aec/aec_core_neon.c",
@ -251,32 +251,28 @@ if (rtc_build_armv7_neon || current_cpu == "arm64") {
"ns/nsx_core_neon.c", "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") { 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" ] 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) { if (rtc_use_lto) {
cflags -= [ cflags -= [
"-flto", "-flto",
"-ffat-lto-objects", "-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"', { ['target_arch=="ia32" or target_arch=="x64"', {
'dependencies': ['audio_processing_sse2',], 'dependencies': ['audio_processing_sse2',],
}], }],
['(target_arch=="arm" and arm_version>=7) or target_arch=="arm64"', { ['build_with_neon==1', {
'dependencies': ['audio_processing_neon',], 'dependencies': ['audio_processing_neon',],
}], }],
['target_arch=="mipsel" and mips_arch_variant!="r6"', { ['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': [{ 'targets': [{
'target_name': 'audio_processing_neon', 'target_name': 'audio_processing_neon',
'type': 'static_library', 'type': 'static_library',
@ -263,15 +263,6 @@
'aecm/aecm_core_neon.c', 'aecm/aecm_core_neon.c',
'ns/nsx_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',
],
}],
],
}], }],
}], }],
], ],