From 6ecfe106c304d1eeaa31d1b29a42c58fb70d35ca Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sun, 9 Feb 2025 17:15:43 +0800 Subject: [PATCH] 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 Reviewed-by: Mirko Bonadei --- libyuv.gyp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libyuv.gyp b/libyuv.gyp index f73a1a4b7..c2ea78c91 100644 --- a/libyuv.gyp +++ b/libyuv.gyp @@ -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',