diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d6033eada..a8cd6ccd1d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,6 +67,8 @@ if(CMAKE_SYSTEM_PROCESSOR)
set(MIPS_DEVICE ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^riscv64")
set(RISCV64_DEVICE ON)
+ elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch64")
+ set(LOONGARCH64_DEVICE ON)
else()
message("Unknown CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
@@ -139,6 +141,7 @@ option(ARMV7 "Set to ON if targeting an ARMv7 processor" ${ARMV7_DEVICE})
option(ARM "Set to ON if targeting an ARM processor" ${ARM_DEVICE})
option(MIPS "Set to ON if targeting a MIPS processor" ${MIPS_DEVICE})
option(RISCV64 "Set to ON if targeting a RISCV64 processor" ${RISCV64_DEVICE})
+option(LOONGARCH64 "Set to ON if targeting a LOONGARCH64 processor" ${LOONGARCH64_DEVICE})
option(X86 "Set to ON if targeting an X86 processor" ${X86_DEVICE})
option(X86_64 "Set to ON if targeting an X86_64 processor" ${X86_64_DEVICE})
# :: Environments
@@ -318,6 +321,9 @@ endif()
if(RISCV64)
message("Generating for RISCV64, ${CMAKE_BUILD_TYPE}")
endif()
+if(LOONGARCH64)
+ message("Generating for LOONGARCH64, ${CMAKE_BUILD_TYPE}")
+endif()
if(X86)
message("Generating for x86, ${CMAKE_BUILD_TYPE}")
endif()
@@ -527,6 +533,14 @@ set(CommonRISCV64
)
source_group(RISCV64 FILES ${CommonRISCV64})
+set(CommonLOONGARCH64
+ ${CommonJIT}
+ Common/LoongArchCPUDetect.cpp
+ Core/MIPS/fake/FakeJit.cpp
+ Core/MIPS/fake/FakeJit.h
+)
+source_group(LOONGARCH64 FILES ${CommonLOONGARCH64})
+
if(WIN32)
set(CommonD3D
Common/GPU/D3D9/D3D9ShaderCompiler.cpp
@@ -565,6 +579,7 @@ add_library(Common STATIC
${CommonARM64}
${CommonMIPS}
${CommonRISCV64}
+ ${CommonLOONGARCH64}
${CommonD3D}
${CommonVR}
Common/Serialize/Serializer.cpp
@@ -887,6 +902,8 @@ if(USE_FFMPEG)
set(PLATFORM_ARCH "linux/mips32")
elseif(RISCV64)
set(PLATFORM_ARCH "linux/riscv64")
+ elseif(LOONGARCH64)
+ set(PLATFORM_ARCH "linux/loongarch64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATFORM_ARCH "linux/x86_64")
elseif(X86)
@@ -1478,7 +1495,7 @@ if(LINUX AND NOT ANDROID)
endif()
set(ATOMIC_LIB)
-if(ANDROID OR (LINUX AND ARM_DEVICE) OR (LINUX AND RISCV64))
+if(ANDROID OR (LINUX AND ARM_DEVICE) OR (LINUX AND RISCV64) OR (LINUX AND LOONGARCH64))
set(ATOMIC_LIB atomic)
endif()
diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj
index d6f8a1282f..e83ebfd5d3 100644
--- a/Common/Common.vcxproj
+++ b/Common/Common.vcxproj
@@ -941,6 +941,7 @@
+
diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters
index 92c8592484..288b7dc289 100644
--- a/Common/Common.vcxproj.filters
+++ b/Common/Common.vcxproj.filters
@@ -875,6 +875,7 @@
GPU\Vulkan
+
GPU\Vulkan
diff --git a/Common/FakeCPUDetect.cpp b/Common/FakeCPUDetect.cpp
index e57799950a..af0ecb9efc 100644
--- a/Common/FakeCPUDetect.cpp
+++ b/Common/FakeCPUDetect.cpp
@@ -24,6 +24,8 @@
#define REAL_CPUDETECT_AVAIL 1
#elif PPSSPP_ARCH(RISCV64)
#define REAL_CPUDETECT_AVAIL 1
+#elif PPSSPP_ARCH(LOONGARCH64)
+#define REAL_CPUDETECT_AVAIL 1
#endif
#ifndef REAL_CPUDETECT_AVAIL
diff --git a/Common/LoongArchCPUDetect.cpp b/Common/LoongArchCPUDetect.cpp
new file mode 100644
index 0000000000..4972d53e94
--- /dev/null
+++ b/Common/LoongArchCPUDetect.cpp
@@ -0,0 +1,121 @@
+// Copyright (C) 2003 Dolphin Project.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 2.0.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License 2.0 for more details.
+
+// A copy of the GPL 2.0 should have been included with the program.
+// If not, see http://www.gnu.org/licenses/
+
+// Official SVN repository and contact information can be found at
+// http://code.google.com/p/dolphin-emu/
+
+#include "ppsspp_config.h"
+#if PPSSPP_ARCH(LOONGARCH64)
+
+#include "ext/cpu_features/include/cpuinfo_loongarch.h"
+
+#if defined(CPU_FEATURES_OS_LINUX)
+#define USE_CPU_FEATURES 1
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include "Common/Common.h"
+#include "Common/CPUDetect.h"
+#include "Common/StringUtils.h"
+#include "Common/File/FileUtil.h"
+#include "Common/Data/Encoding/Utf8.h"
+
+// Only Linux platforms have /proc/cpuinfo
+#if defined(__linux__)
+const char procfile[] = "/proc/cpuinfo";
+// https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu
+const char syscpupresentfile[] = "/sys/devices/system/cpu/present";
+
+std::string GetCPUString() {
+ //TODO
+ std::string cpu_string;
+ cpu_string = "Unknown";
+ return cpu_string;
+}
+
+std::string GetCPUBrandString() {
+ //TODO
+ std::string brand_string;
+ brand_string = "Unknown";
+ return brand_string;
+}
+
+int GetCoreCount() {
+ // TODO
+ return 4;
+}
+
+#endif
+
+CPUInfo cpu_info;
+
+CPUInfo::CPUInfo() {
+ Detect();
+}
+
+// Detects the various cpu features
+void CPUInfo::Detect() {
+ // Set some defaults here
+ HTT = false;
+#if PPSSPP_ARCH(LOONGARCH64)
+ OS64bit = true;
+ CPU64bit = true;
+ Mode64bit = true;
+#else
+ OS64bit = false;
+ CPU64bit = false;
+ Mode64bit = false;
+#endif
+ vendor = VENDOR_OTHER;
+
+ truncate_cpy(brand_string, "Unknown");
+#if !defined(__linux__)
+ num_cores = 1;
+ logical_cpu_count = 1;
+ truncate_cpy(cpu_string, "Unknown");
+#else // __linux__
+ truncate_cpy(cpu_string, GetCPUString().c_str());
+ truncate_cpy(brand_string, GetCPUBrandString().c_str());
+ num_cores = GetCoreCount();
+#endif
+}
+
+std::vector CPUInfo::Features() {
+ // TODO
+ std::vector features;
+
+
+
+ return features;
+}
+
+
+// Turn the cpu info into a string we can show
+std::string CPUInfo::Summarize() {
+ std::string sum;
+ if (num_cores == 1)
+ sum = StringFromFormat("%s, %i core", cpu_string, num_cores);
+ else
+ sum = StringFromFormat("%s, %i cores", cpu_string, num_cores);
+
+ //TODO: parse /proc/cpuinfo
+
+ return sum;
+}
+
+#endif // PPSSPP_ARCH(LOONGARCH64)
\ No newline at end of file
diff --git a/ext/cmake/cpu_features/CMakeLists.txt b/ext/cmake/cpu_features/CMakeLists.txt
index e8bfdc34cf..f43b9ac8c8 100644
--- a/ext/cmake/cpu_features/CMakeLists.txt
+++ b/ext/cmake/cpu_features/CMakeLists.txt
@@ -51,6 +51,7 @@ set(PROCESSOR_IS_X86 FALSE)
set(PROCESSOR_IS_POWER FALSE)
set(PROCESSOR_IS_S390X FALSE)
set(PROCESSOR_IS_RISCV FALSE)
+set(PROCESSOR_IS_LOONGARCH64 FALSE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
set(PROCESSOR_IS_MIPS TRUE)
@@ -66,6 +67,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x)")
set(PROCESSOR_IS_S390X TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv")
set(PROCESSOR_IS_RISCV TRUE)
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64")
+ set(PROCESSOR_IS_LOONGARCH64 TRUE)
endif()
macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME)
@@ -89,6 +92,8 @@ macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/cpuinfo_s390x.h)
elseif(PROCESSOR_IS_RISCV)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/cpuinfo_riscv.h)
+ elseif(PROCESSOR_IS_LOONGARCH64)
+ # TODO
else()
message(FATAL_ERROR "Unsupported architectures ${CMAKE_SYSTEM_PROCESSOR}")
endif()
diff --git a/ext/cpu_features b/ext/cpu_features
index 75ec988188..69c9bcd942 160000
--- a/ext/cpu_features
+++ b/ext/cpu_features
@@ -1 +1 @@
-Subproject commit 75ec988188f62281efe7bf1d133338751369bb4c
+Subproject commit 69c9bcd94297ae0468c34619b1cbb351e40b3e4c
diff --git a/ppsspp_config.h b/ppsspp_config.h
index e26b1220e1..6228d2b556 100644
--- a/ppsspp_config.h
+++ b/ppsspp_config.h
@@ -75,6 +75,11 @@
#define PPSSPP_ARCH_64BIT 1
#endif
+#if defined(__loongarch64)
+ //https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/loongarch-c.cc
+ #define PPSSPP_ARCH_LOONGARCH64 1
+ #define PPSSPP_ARCH_64BIT 1
+#endif
// PLATFORM defines
#if defined(_WIN32)