diff --git a/CMakeLists.txt b/CMakeLists.txt index 4969868b..ec2ce4e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,11 +37,20 @@ if( VVENC_TARGET_ARCH MATCHES "ARM\|AARCH64" ) set_if_compiler_supports_arm_extensions( FLAG_sve FLAG_sve2 ) endif() +if( VVENC_TARGET_ARCH MATCHES "LOONGARCH64" ) + set( VVENC_LOONGARCH64_SIMD_DEFAULT TRUE ) + + if( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld") + endif() +endif() + # We enable x86 intrinsics for all target architectures, because they are implemented through SIMD-everywhere on non-x86. set( VVENC_ENABLE_X86_SIMD TRUE CACHE BOOL "Enable x86 intrinsics" ) set( VVENC_ENABLE_ARM_SIMD ${VVENC_ARM_SIMD_DEFAULT} CACHE BOOL "Enable Arm Neon intrinsics" ) set( VVENC_ENABLE_ARM_SIMD_SVE FALSE CACHE BOOL "Enable Arm SVE intrinsics" ) set( VVENC_ENABLE_ARM_SIMD_SVE2 FALSE CACHE BOOL "Enable Arm SVE2 intrinsics" ) +set( VVENC_ENABLE_LOONGARCH64_SIMD_LSX ${VVENC_LOONGARCH64_SIMD_DEFAULT} CACHE BOOL "Enable LoongArch64 LSX intrinsics" ) check_problematic_compiler( VVENC_PROBLEMATIC_COMPILER "MSVC" 19.38 19.39 ) if( VVENC_PROBLEMATIC_COMPILER ) @@ -119,6 +128,17 @@ if( VVENC_TARGET_ARCH STREQUAL "ARM" ) endif() endif() +if( VVENC_TARGET_ARCH STREQUAL "LOONGARCH64" ) + if( VVENC_ENABLE_LOONGARCH64_SIMD_LSX ) + set_if_compiler_supports_flag( FLAG_mlsx -mlsx ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG_mlsx}" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG_mlsx}" ) + message( STATUS "LoongArch64 LSX intrinsics enabled" ) + else() + message( STATUS "LoongArch64 LSX intrinsics disabled" ) + endif() +endif() + if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) # set exception handling if( MSVC ) diff --git a/cmake/modules/vvencCompilerSupport.cmake b/cmake/modules/vvencCompilerSupport.cmake index 141a7d99..8e59aae2 100644 --- a/cmake/modules/vvencCompilerSupport.cmake +++ b/cmake/modules/vvencCompilerSupport.cmake @@ -210,6 +210,8 @@ function( _append_cpu_type_guess output_list input_str ) list( APPEND ret "AARCH64" ) elseif( ${input_lower} MATCHES "arm") list( APPEND ret "ARM" ) + elseif( ${input_lower} MATCHES "loongarch64") + list( APPEND ret "LOONGARCH64" ) endif() set( ${output_list} ${ret} PARENT_SCOPE ) diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 160de469..5265436c 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -62,6 +62,8 @@ POSSIBILITY OF SUCH DAMAGE. # define REAL_TARGET_ARM 1 #elif defined( __wasm__ ) || defined( __wasm32__ ) # define REAL_TARGET_WASM 1 +#elif defined( __loongarch__ ) +# define REAL_TARGET_LOONGARCH 1 #endif #if defined( TARGET_SIMD_X86 ) diff --git a/source/Lib/CommonLib/x86/CommonDefX86.cpp b/source/Lib/CommonLib/x86/CommonDefX86.cpp index 777a6ff0..90956002 100644 --- a/source/Lib/CommonLib/x86/CommonDefX86.cpp +++ b/source/Lib/CommonLib/x86/CommonDefX86.cpp @@ -74,6 +74,8 @@ const static std::map vext_names{ { UNDEFINED, "" }, { SC const static std::map vext_names{ { UNDEFINED, "" }, { SCALAR, "SCALAR" }, { SIMD_EVERYWHERE_EXTENSION_LEVEL, "NEON" } }; # elif defined( REAL_TARGET_WASM ) const static std::map vext_names{ { UNDEFINED, "" }, { SCALAR, "SCALAR" }, { SIMD_EVERYWHERE_EXTENSION_LEVEL, "WASM" } }; +# elif defined( REAL_TARGET_LOONGARCH ) +const static std::map vext_names{ { UNDEFINED, "" }, { SCALAR, "SCALAR" }, { SIMD_EVERYWHERE_EXTENSION_LEVEL, "LSX" } }; # else const static std::map vext_names{ { UNDEFINED, "" }, { SCALAR, "SCALAR" }, { SIMD_EVERYWHERE_EXTENSION_LEVEL, "SIMDE" } }; # endif diff --git a/source/Lib/apputils/VVEncAppCfg.h b/source/Lib/apputils/VVEncAppCfg.h index 178d6ff4..3a793493 100644 --- a/source/Lib/apputils/VVEncAppCfg.h +++ b/source/Lib/apputils/VVEncAppCfg.h @@ -794,6 +794,8 @@ int parse( int argc, char* argv[], vvenc_config* c, std::ostream& rcOstr ) ("SIMD", ignoreParams, "SIMD extension to use (SCALAR, NEON), default: the highest supported extension") #elif defined( __wasm__ ) || defined( __wasm32__ ) ("SIMD", ignoreParams, "SIMD extension to use (SCALAR, WASM), default: the highest supported extension") +#elif defined( __loongarch__ ) + ("SIMD", ignoreParams, "SIMD extension to use (SCALAR, LSX), default: the highest supported extension") #else ("SIMD", ignoreParams, "SIMD extension to use (SCALAR, SIMDE), default: the highest supported extension") # endif