From a4a27c08f5adf7bc002a98071e3f13eeadc84399 Mon Sep 17 00:00:00 2001 From: donmor Date: Sun, 10 Mar 2024 14:17:01 +0800 Subject: [PATCH 1/8] Update configure.ac Add proper loongarch64 support --- configure.ac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index fcc57637d62..14dc65bf40f 100644 --- a/configure.ac +++ b/configure.ac @@ -630,6 +630,12 @@ case "$host_cpu" in c_targetcpu="m68k" c_unalignedmemory=yes ;; + loongarch64*) + AC_DEFINE(C_TARGETCPU,LOONGARCH64) + AC_MSG_RESULT(Loongson 3A5000+) + c_targetcpu="loongarch64" + c_unalignedmemory=yes + ;; armv7*) AC_DEFINE(C_TARGETCPU,ARMV7LE) AC_MSG_RESULT(ARMv7 Little Endian) @@ -871,6 +877,10 @@ if test x$enable_mt32 = xyes ; then AC_MSG_RESULT(yes) AC_DEFINE(C_MT32,1) ;; + loongarch64) + AC_MSG_RESULT(yes) + AC_DEFINE(C_MT32,1) + ;; *) enable_mt32=no AC_MSG_RESULT(no) From 893c45707dbeb7de31fe50c389e73d3429626db6 Mon Sep 17 00:00:00 2001 From: donmor Date: Sun, 10 Mar 2024 14:19:40 +0800 Subject: [PATCH 2/8] Update version_string.h Recognize loongarch64 as 64-bit --- include/version_string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/version_string.h b/include/version_string.h index 73c17881a3b..70a17fa91e8 100644 --- a/include/version_string.h +++ b/include/version_string.h @@ -57,7 +57,7 @@ #define OS_PLATFORM_LONG "" #endif -#if defined(_M_X64) || defined (_M_AMD64) || defined (_M_ARM64) || defined (_M_IA64) || defined(__ia64__) || defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) +#if defined(_M_X64) || defined (_M_AMD64) || defined (_M_ARM64) || defined (_M_IA64) || defined(__ia64__) || defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || defined(__loongarch64__) #define OS_BIT "64" #define OS_BIT_INT 64 #else From 1c3c9bbeddedc7b737216ff6bfc3a463ddd15dfb Mon Sep 17 00:00:00 2001 From: donmor Date: Sun, 10 Mar 2024 14:28:45 +0800 Subject: [PATCH 3/8] Update savestates.cpp loongarch64 is 64-bit --- src/misc/savestates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/savestates.cpp b/src/misc/savestates.cpp index 90c57d035d4..226297e15b6 100644 --- a/src/misc/savestates.cpp +++ b/src/misc/savestates.cpp @@ -277,7 +277,7 @@ std::string GetPlatform(bool save) { #endif ); if (!save) strcat(platform, (std::string(SDL_STRING)+", ").c_str()); -#if defined(_M_X64) || defined (_M_AMD64) || defined (_M_ARM64) || defined (_M_IA64) || defined(__ia64__) || defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) +#if defined(_M_X64) || defined (_M_AMD64) || defined (_M_ARM64) || defined (_M_IA64) || defined(__ia64__) || defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || defined(__loongarch64__) strcat(platform, "64"); #else strcat(platform, "32"); From 1c1b7c37b9bcaece14b208f97379b7aae3175504 Mon Sep 17 00:00:00 2001 From: donmor Date: Sun, 10 Mar 2024 14:45:18 +0800 Subject: [PATCH 4/8] Update CpuArch.h --- src/libs/libchdr/lzma/CpuArch.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libs/libchdr/lzma/CpuArch.h b/src/libs/libchdr/lzma/CpuArch.h index bd429388024..c8729ae7244 100644 --- a/src/libs/libchdr/lzma/CpuArch.h +++ b/src/libs/libchdr/lzma/CpuArch.h @@ -83,6 +83,14 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem #endif +#if defined(__loongarch64) \ + || defined(__loongarch64__) + #define MY_CPU_LOONGARCH64 + #define MY_CPU_NAME "loongarch64" + #define MY_CPU_64BIT +#endif + + #if defined(__ppc64__) \ || defined(__powerpc64__) #ifdef __ILP32__ @@ -140,6 +148,7 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem || defined(__MIPSEL__) \ || defined(__MIPSEL) \ || defined(_MIPSEL) \ + || defined(MY_CPU_LOONGARCH64) \ || defined(__BFIN__) \ || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) #define MY_CPU_LE From 0b6e7f3147088e4353ecff99088e53daeb853330 Mon Sep 17 00:00:00 2001 From: donmor Date: Mon, 11 Mar 2024 13:39:56 +0800 Subject: [PATCH 5/8] Update version_string.h Revert --- include/version_string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/version_string.h b/include/version_string.h index 70a17fa91e8..73c17881a3b 100644 --- a/include/version_string.h +++ b/include/version_string.h @@ -57,7 +57,7 @@ #define OS_PLATFORM_LONG "" #endif -#if defined(_M_X64) || defined (_M_AMD64) || defined (_M_ARM64) || defined (_M_IA64) || defined(__ia64__) || defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || defined(__loongarch64__) +#if defined(_M_X64) || defined (_M_AMD64) || defined (_M_ARM64) || defined (_M_IA64) || defined(__ia64__) || defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) #define OS_BIT "64" #define OS_BIT_INT 64 #else From 1dad7914607b85c287c37c34198995a462e23b90 Mon Sep 17 00:00:00 2001 From: donmor Date: Mon, 11 Mar 2024 13:42:09 +0800 Subject: [PATCH 6/8] Update CpuArch.h --- src/libs/libchdr/lzma/CpuArch.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/libchdr/lzma/CpuArch.h b/src/libs/libchdr/lzma/CpuArch.h index c8729ae7244..e322bc9ff3c 100644 --- a/src/libs/libchdr/lzma/CpuArch.h +++ b/src/libs/libchdr/lzma/CpuArch.h @@ -83,9 +83,7 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem #endif -#if defined(__loongarch64) \ - || defined(__loongarch64__) - #define MY_CPU_LOONGARCH64 +#if defined(__loongarch_lp64) #define MY_CPU_NAME "loongarch64" #define MY_CPU_64BIT #endif @@ -148,7 +146,6 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem || defined(__MIPSEL__) \ || defined(__MIPSEL) \ || defined(_MIPSEL) \ - || defined(MY_CPU_LOONGARCH64) \ || defined(__BFIN__) \ || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) #define MY_CPU_LE From 98a648c989f45d782bea9d5784cea3f631df89f6 Mon Sep 17 00:00:00 2001 From: donmor Date: Mon, 11 Mar 2024 13:43:11 +0800 Subject: [PATCH 7/8] Update savestates.cpp Revert --- src/misc/savestates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/savestates.cpp b/src/misc/savestates.cpp index 226297e15b6..90c57d035d4 100644 --- a/src/misc/savestates.cpp +++ b/src/misc/savestates.cpp @@ -277,7 +277,7 @@ std::string GetPlatform(bool save) { #endif ); if (!save) strcat(platform, (std::string(SDL_STRING)+", ").c_str()); -#if defined(_M_X64) || defined (_M_AMD64) || defined (_M_ARM64) || defined (_M_IA64) || defined(__ia64__) || defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || defined(__loongarch64__) +#if defined(_M_X64) || defined (_M_AMD64) || defined (_M_ARM64) || defined (_M_IA64) || defined(__ia64__) || defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) strcat(platform, "64"); #else strcat(platform, "32"); From 4fc85e79cf480818f9d3e9e10d0784f724442d96 Mon Sep 17 00:00:00 2001 From: donmor Date: Mon, 11 Mar 2024 13:44:13 +0800 Subject: [PATCH 8/8] Update configure.ac --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 14dc65bf40f..9493b0142ca 100644 --- a/configure.ac +++ b/configure.ac @@ -632,7 +632,7 @@ case "$host_cpu" in ;; loongarch64*) AC_DEFINE(C_TARGETCPU,LOONGARCH64) - AC_MSG_RESULT(Loongson 3A5000+) + AC_MSG_RESULT(LoongArch) c_targetcpu="loongarch64" c_unalignedmemory=yes ;;