diff --git a/build/premake/premake5.lua b/build/premake/premake5.lua index f0695e9afd..ed234df8d9 100644 --- a/build/premake/premake5.lua +++ b/build/premake/premake5.lua @@ -129,8 +129,12 @@ else arch = "aarch64" elseif string.find(machine, "e2k") == 1 then arch = "e2k" + elseif string.find(machine, "loongarch64") == 1 then + arch = "loong64" elseif string.find(machine, "ppc64") == 1 or string.find(machine, "powerpc64") == 1 then arch = "ppc64" + elseif string.find(machine, "riscv64") == 1 then + arch = "riscv64" else print("WARNING: Cannot determine architecture from GCC, assuming x86") end @@ -1003,8 +1007,12 @@ function setup_all_libs () table.insert(source_dirs, "lib/sysdep/arch/aarch64"); elseif arch == "e2k" then table.insert(source_dirs, "lib/sysdep/arch/e2k"); + elseif arch == "loong64" then + table.insert(source_dirs, "lib/sysdep/arch/loong64"); elseif arch == "ppc64" then table.insert(source_dirs, "lib/sysdep/arch/ppc64"); + elseif arch == "riscv64" then + table.insert(source_dirs, "lib/sysdep/arch/riscv64"); end -- OS-specific @@ -1214,6 +1222,11 @@ function setup_main_exe () -- Dynamic libraries (needed for linking for gold) "dl", } + + if arch == "riscv64" then + -- Needed to resolve __atomic_load_16 et al. + links { "atomic" } + end end -- Threading support @@ -1615,6 +1628,11 @@ function setup_tests() -- Dynamic libraries (needed for linking for gold) "dl", } + + if arch == "riscv64" then + -- Needed to resolve __atomic_load_16 et al. + links { "atomic" } + end end -- Threading support diff --git a/source/lib/sysdep/arch.h b/source/lib/sysdep/arch.h index 74550970ce..17110729d2 100644 --- a/source/lib/sysdep/arch.h +++ b/source/lib/sysdep/arch.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -82,9 +82,21 @@ #else # define ARCH_E2K 0 #endif +// .. LoongArch64 +#if defined(__loongarch__) && defined(__loongarch_lp64) +# define ARCH_LOONG64 1 +#else +# define ARCH_LOONG64 0 +#endif +// .. RISC-V 64 +#if defined(__riscv) && __riscv_xlen == 64 +# define ARCH_RISCV64 1 +#else +# define ARCH_RISCV64 0 +#endif // ensure exactly one architecture has been detected -#if (ARCH_IA32+ARCH_IA64+ARCH_AMD64+ARCH_ALPHA+ARCH_ARM+ARCH_AARCH64+ARCH_MIPS+ARCH_E2K+ARCH_PPC64) != 1 +#if (ARCH_IA32+ARCH_IA64+ARCH_AMD64+ARCH_ALPHA+ARCH_ARM+ARCH_AARCH64+ARCH_MIPS+ARCH_E2K+ARCH_PPC64+ARCH_LOONG64+ARCH_RISCV64) != 1 # error "architecture not correctly detected (either none or multiple ARCH_* defined)" #endif diff --git a/source/lib/sysdep/arch/loong64/loong64.cpp b/source/lib/sysdep/arch/loong64/loong64.cpp new file mode 100644 index 0000000000..913afa8d97 --- /dev/null +++ b/source/lib/sysdep/arch/loong64/loong64.cpp @@ -0,0 +1,35 @@ +/* Copyright (C) 2026 Wildfire Games. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * routines specific to LoongArch64 + */ + +#include "precompiled.h" + +#include "lib/sysdep/cpu.h" + +const char* cpu_IdentifierString() +{ + // TODO + return "LoongArch64"; +} diff --git a/source/lib/sysdep/arch/riscv64/riscv64.cpp b/source/lib/sysdep/arch/riscv64/riscv64.cpp new file mode 100644 index 0000000000..08bf1a00da --- /dev/null +++ b/source/lib/sysdep/arch/riscv64/riscv64.cpp @@ -0,0 +1,35 @@ +/* Copyright (C) 2026 Wildfire Games. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * routines specific to RISC-V 64 + */ + +#include "precompiled.h" + +#include "lib/sysdep/cpu.h" + +const char* cpu_IdentifierString() +{ + // TODO + return "RISC-V 64"; +} diff --git a/source/ps/GameSetup/HWDetect.cpp b/source/ps/GameSetup/HWDetect.cpp index 6c3197856f..3bb7e0e3ab 100644 --- a/source/ps/GameSetup/HWDetect.cpp +++ b/source/ps/GameSetup/HWDetect.cpp @@ -372,7 +372,9 @@ void RunHardwareDetection(bool writeSystemInfoBeforeDetection, Renderer::Backend Script::SetProperty(rq, settings, "arch_arm", ARCH_ARM); Script::SetProperty(rq, settings, "arch_aarch64", ARCH_AARCH64); Script::SetProperty(rq, settings, "arch_e2k", ARCH_E2K); + Script::SetProperty(rq, settings, "arch_loong64", ARCH_LOONG64); Script::SetProperty(rq, settings, "arch_ppc64", ARCH_PPC64); + Script::SetProperty(rq, settings, "arch_riscv64", ARCH_RISCV64); #ifdef NDEBUG Script::SetProperty(rq, settings, "build_debug", 0); @@ -460,7 +462,7 @@ void RunHardwareDetection(bool writeSystemInfoBeforeDetection, Renderer::Backend Script::SetProperty(rq, settings, "neon", static_cast(SDL_HasNEON())); // The version should be increased for every meaningful change. - const int reportVersion = 23; + const int reportVersion = 24; // Send the same data to the reporting system g_UserReporter.SubmitReport(