Skip to content

Commit 32ea500

Browse files
committed
add loongarch64 build support
1 parent af5f033 commit 32ea500

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

Source/GmmLib/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ endif()
167167

168168
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
169169
set(GMMLIB_MARCH "armv8-a+fp+simd")
170+
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch")
171+
set(GMMLIB_MARCH "la464")
170172
elseif("${GMMLIB_MARCH}" STREQUAL "")
171173
set(GMMLIB_MARCH "corei7")
172174
endif()
@@ -443,6 +445,18 @@ include_directories(BEFORE ${PROJECT_SOURCE_DIR})
443445

444446
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
445447
include_directories(${GFX_DEVELOPMENT_DIR}/third_party/sse2neon)
448+
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch")
449+
find_path(SIMDE_INCLUDE_DIR
450+
NAMES simde/simde-common.h # A key SIMDE header
451+
PATHS /usr/include /usr/local/include # Default paths
452+
DOC "Path to SIMDE headers"
453+
)
454+
if(SIMDE_INCLUDE_DIR)
455+
include_directories(${SIMDE_INCLUDE_DIR})
456+
message(STATUS "Found SIMDE: ${SIMDE_INCLUDE_DIR}")
457+
else()
458+
message(FATAL_ERROR "SIMDE not found. Install it or set SIMDE_INCLUDE_DIR manually.")
459+
endif()
446460
endif()
447461

448462
set(headers

Source/GmmLib/Linux.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,43 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
5555
-fPIC
5656
-g
5757
)
58+
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch")
59+
SET (GMMLIB_COMPILER_FLAGS_COMMON
60+
#general warnings
61+
-Wall
62+
-Winit-self
63+
-Winvalid-pch
64+
-Wpointer-arith
65+
-Wno-unused
66+
-Wno-unknown-pragmas
67+
-Wno-comments
68+
-Wno-narrowing
69+
-Wno-overflow
70+
-Wno-parentheses
71+
-Wno-missing-braces
72+
-Wno-sign-compare
73+
-Wno-enum-compare
74+
-Werror=address
75+
-Werror=format-security
76+
-Werror=return-type
77+
78+
# General optimization options
79+
-march=${GMMLIB_MARCH}
80+
-Wno-attributes
81+
-finline-functions
82+
-fno-short-enums
83+
-Wa,--noexecstack
84+
-fno-strict-aliasing
85+
# Common defines
86+
# Other common flags
87+
-fstack-protector
88+
-fdata-sections
89+
-ffunction-sections
90+
-fmessage-length=0
91+
-fvisibility=hidden
92+
-fPIC
93+
-g
94+
)
5895
else()
5996
SET (GMMLIB_COMPILER_FLAGS_COMMON
6097
#general warnings
@@ -177,6 +214,9 @@ endforeach()
177214
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
178215
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
179216
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
217+
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch")
218+
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
219+
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
180220
else()
181221
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m${GMMLIB_ARCH}")
182222
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m${GMMLIB_ARCH}")

Source/GmmLib/Utility/CpuSwizzleBlt/CpuSwizzleBlt.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ extern void CpuSwizzleBlt(CPU_SWIZZLE_BLT_SURFACE *pDest, CPU_SWIZZLE_BLT_SURFAC
375375
#include <intrin.h>
376376
#elif defined(__ARM_ARCH)
377377
#include <sse2neon.h>
378+
#elif defined(__loongarch64)
379+
#define SIMDE_X86_SSE2_ENABLE_NATIVE_ALIASES
380+
#include <simde/x86/sse2.h>
378381
#elif((defined __clang__) ||(__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)))
379382
#include <cpuid.h>
380383
#include <x86intrin.h>
@@ -749,6 +752,9 @@ void CpuSwizzleBlt( // #########################################################
749752
#elif(defined(__ARM_ARCH))
750753
#define MOVNTDQA_R(Reg, Src) ((Reg) = (Reg))
751754
StreamingLoadSupported = 0;
755+
#elif(defined(__loongarch64))
756+
#define MOVNTDQA_R(Reg, Src) ((Reg) = (Reg))
757+
StreamingLoadSupported = 0;
752758
#elif((defined __clang__) || (__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
753759
#define MOVNTDQA_R(Reg, Src) ((Reg) = _mm_stream_load_si128((__m128i *)(Src)))
754760
unsigned int eax, ebx, ecx, edx;
@@ -1148,7 +1154,11 @@ void CpuSwizzleBlt( // #########################################################
11481154

11491155
} // foreach(y)
11501156

1151-
_mm_sfence(); // Flush Non-Temporal Writes
1157+
#if(defined(__loongarch64))
1158+
__sync_synchronize();
1159+
#else
1160+
_mm_sfence(); // Flush Non-Temporal Writes
1161+
#endif
11521162

11531163
#if(_MSC_VER)
11541164
#pragma warning(pop)

0 commit comments

Comments
 (0)