Enable explicit control over LoongArch LSX & LASX for GYP builds

And enable LASX by default for LoongArch builds, because LASX is
widely supported among LoongArch desktops and servers, and performance
is better than with LSX alone.

Because the LoongArch SIMD code is written to only compile if the
respective codegen option is enabled, but the defaults and availability
differ between compiler versions and target `-march` setting, the
codegen flags are explicitly added to CFLAGS for wider compatibility.

Bug: None
Change-Id: I735ceac0f6b46eea2155e58ecf3630383ef5b728
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/6241804
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
This commit is contained in:
WANG Xuerui 2025-02-09 17:15:43 +08:00 committed by Frank Barchard
parent ef9833fc70
commit 6ecfe106c3

View File

@ -26,15 +26,30 @@
'clang%': 0,
# Link-Time Optimizations.
'use_lto%': 0,
# Enable LASX on LoongArch by default.
"loong_lasx%": 1,
# Enable LSX on LoongArch by default. Has no effect if loong_lasx is
# enabled because LASX implies LSX according to the architecture specs.
"loong_lsx%": 1,
'mips_msa%': 0, # Default to msa off.
'build_neon': 0,
"build_lasx": 0,
"build_lsx": 0,
'build_msa': 0,
'conditions': [
['(target_arch == "armv7" or target_arch == "armv7s" or \
(target_arch == "arm" and arm_version >= 7) or target_arch == "arm64")\
and (arm_neon == 1 or arm_neon_optional == 1)', {
'build_neon': 1,
}],
['(target_arch == "loong64") and (loong_lasx == 1)', {
"build_lasx": 1,
"build_lsx": 1, # LASX implies LSX.
}],
['(target_arch == "loong64") and (loong_lsx == 1)', {
"build_lsx": 1,
}],
['(target_arch == "mipsel" or target_arch == "mips64el")\
and (mips_msa == 1)',
{
@ -60,6 +75,16 @@
'-Wno-unused-parameter',
],
}],
["build_lasx != 0", {
"cflags": ["-mlasx"],
}, { # build_lasx == 0
"cflags": ["-mno-lasx"],
}],
["build_lsx != 0", {
"cflags": ["-mlsx"],
}, { # build_lsx == 0
"cflags": ["-mno-lsx"],
}],
['build_neon != 0', {
'defines': [
'LIBYUV_NEON',