Skip to content

Commit ce7eaeb

Browse files
authoredJan 9, 2025
Merge pull request #225 from HecaiYuan/master
loongarch: add loongarch support
2 parents 6408623 + b5c8221 commit ce7eaeb

File tree

7 files changed

+30
-1
lines changed

7 files changed

+30
-1
lines changed
 

‎CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ if( VVDEC_TARGET_ARCH STREQUAL "ARM" )
3131
set( VVDEC_ARM_SIMD_DEFAULT TRUE )
3232
endif()
3333

34+
if( VVDEC_TARGET_ARCH MATCHES "LOONGARCH64" )
35+
set( VVDEC_LOONGARCH64_SIMD_DEFAULT TRUE )
36+
endif()
37+
3438
# we enable x86 intrinsics for all target architectures, because they are implemented through simd-everywhere on non-x86
3539
set( VVDEC_ENABLE_X86_SIMD TRUE CACHE BOOL "enable x86 intrinsics" )
3640
set( VVDEC_ENABLE_ARM_SIMD ${VVDEC_ARM_SIMD_DEFAULT} CACHE BOOL "enable ARM intrinsics" )
41+
set( VVDEC_ENABLE_LOONGARCH64_LSX_SIMD ${VVDEC_LOONGARCH64_SIMD_DEFAULT} CACHE BOOL "enable loongarch64 LSX intrinsics" )
3742

3843
set( VVDEC_ENABLE_TRACING FALSE CACHE BOOL "Compile in tracing functionality" )
3944

@@ -63,6 +68,17 @@ if( VVDEC_ENABLE_X86_SIMD )
6368
set_if_compiler_supports_flag( FLAG_mfloat_abi_hard -mfloat-abi=hard )
6469
add_compile_options( ${FLAG_mfpu_neon} ${FLAG_mfloat_abi_hard} )
6570
endif()
71+
72+
if( VVDEC_TARGET_ARCH STREQUAL "LOONGARCH64" )
73+
if( VVDEC_ENABLE_LOONGARCH64_LSX_SIMD )
74+
set_if_compiler_supports_flag( FLAG_mlsx -mlsx )
75+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG_mlsx}")
76+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG_mlsx}")
77+
message( STATUS "LoongArch64 lsx intrinsics enabled" )
78+
else()
79+
message( STATUS "LoongArch64 lsx intrinsics disabled" )
80+
endif()
81+
endif()
6682
endif()
6783

6884
if( VVDEC_ENABLE_ARM_SIMD )

‎cmake/modules/vvdecCompilerSupport.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ function( _append_cpu_type_guess output_list input_str )
112112
list( APPEND ret "X86" )
113113
elseif( ${input_lower} MATCHES "aarch64\|arm")
114114
list( APPEND ret "ARM" )
115+
elseif( ${input_lower} MATCHES "loongarch64")
116+
list( APPEND ret "LOONGARCH64" )
115117
endif()
116118

117119
set( ${output_list} ${ret} PARENT_SCOPE )

‎include/vvdec/vvdec.h

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ VVDEC_NAMESPACE_BEGIN
6464
# define VVDEC_ARCH_ARM 1
6565
#elif defined( __wasm__ ) || defined( __wasm32__ )
6666
# define VVDEC_ARCH_WASM 1
67+
#elif defined( __loongarch__ )
68+
# define VVDEC_ARCH_LOONGARCH 1
6769
#endif
6870

6971
/* vvdecDecoder:
@@ -149,6 +151,9 @@ typedef enum
149151
#elif defined( VVDEC_ARCH_WASM )
150152
VVDEC_SIMD_WASM = 3,
151153
VVDEC_SIMD_MAX = VVDEC_SIMD_WASM
154+
#elif defined( VVDEC_ARCH_LOONGARCH )
155+
VVDEC_SIMD_LSX = 3,
156+
VVDEC_SIMD_MAX = VVDEC_SIMD_LSX
152157
#else
153158
VVDEC_SIMD_SIMDE_ANY= 3,
154159
VVDEC_SIMD_MAX = VVDEC_SIMD_SIMDE_ANY

‎source/App/vvdecapp/CmdLineParser.h

+2
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ class CmdLineParser
400400
case VVDEC_SIMD_NEON: cll = "NEON"; break;
401401
#elif defined (VVDEC_ARCH_WASM)
402402
case VVDEC_SIMD_WASM: cll = "WASM-SIMD"; break;
403+
#elif defined (VVDEC_ARCH_LOONGARCH)
404+
case VVDEC_SIMD_LSX: cll = "LSX"; break;
403405
#else
404406
case VVDEC_SIMD_SIMDE_ANY: cll = "SIMDE-ANY"; break;
405407
#endif

‎source/Lib/CommonLib/CommonDef.h

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ POSSIBILITY OF SUCH DAMAGE.
6161
# define REAL_TARGET_ARM 1
6262
#elif defined( __wasm__ ) || defined( __wasm32__ )
6363
# define REAL_TARGET_WASM 1
64+
#elif defined( __loongarch__ )
65+
# define REAL_TARGET_LOONGARCH 1
6466
#endif
6567

6668
#ifdef _WIN32

‎source/Lib/CommonLib/x86/CommonDefX86.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ std::string read_x86_extension_name()
270270
return std::string( "NEON/SIMDE(" ) + vext_names[vext] + ")";
271271
# elif defined( REAL_TARGET_WASM )
272272
return std::string( "WASM/Emscripten(" ) + vext_names[vext] + ")";
273+
# elif defined( REAL_TARGET_LOONGARCH )
274+
return std::string( "LSX/SIMDE(" ) + vext_names[vext] + ")";
273275
# else
274276
return std::string( "SIMDE(" ) + vext_names[vext] + ")" ;
275277
# endif

‎source/Lib/vvdec/vvdecimpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int VVDecImpl::init( const vvdecParams& params, vvdecCreateBufferCallback create
9292
case VVDEC_SIMD_SSE42 : read_x86_extension_flags( x86_simd::SSE42 ); break;
9393
case VVDEC_SIMD_AVX : read_x86_extension_flags( x86_simd::AVX ); break;
9494
case VVDEC_SIMD_AVX2 : read_x86_extension_flags( x86_simd::AVX2 ); break;
95-
# elif defined( VVDEC_ARCH_ARM ) || defined( VVDEC_ARCH_WASM )
95+
# elif defined( VVDEC_ARCH_ARM ) || defined( VVDEC_ARCH_WASM ) || defined( VVDEC_ARCH_LOONGARCH )
9696
case VVDEC_SIMD_MAX : read_x86_extension_flags( SIMD_EVERYWHERE_EXTENSION_LEVEL ); break;
9797
# endif
9898
case VVDEC_SIMD_DEFAULT:

0 commit comments

Comments
 (0)