From feabc807177d71086dd49b1811b1656849f18975 Mon Sep 17 00:00:00 2001 From: Dandan Zhang Date: Thu, 28 Dec 2023 03:18:26 +0000 Subject: [PATCH] nall: add support for LoongArch architecture --- nall/GNUmakefile | 2 ++ nall/intrinsics.hpp | 21 +++++++++++++++++++++ nall/recompiler/generic/generic.hpp | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/nall/GNUmakefile b/nall/GNUmakefile index 25b7159853..2eee27b3a7 100644 --- a/nall/GNUmakefile +++ b/nall/GNUmakefile @@ -99,6 +99,8 @@ else machine := arm64 else ifneq ($(filter arm-% armv7-%,$(machine_str)),) machine := arm32 + else ifneq ($(filter loong64-% loongarch64-%,$(machine_str)),) + machine := loong64 else ifneq ($(filter powerpc64-% powerpc64le-%,$(machine_str)),) machine := ppc64 else ifneq ($(filter riscv64-%,$(machine_str)),) diff --git a/nall/intrinsics.hpp b/nall/intrinsics.hpp index 370151d3c2..d300f14537 100644 --- a/nall/intrinsics.hpp +++ b/nall/intrinsics.hpp @@ -190,6 +190,7 @@ namespace nall { static constexpr bool amd64 = 0; static constexpr bool arm64 = 0; static constexpr bool arm32 = 0; + static constexpr bool loong64 = 0; static constexpr bool ppc64 = 0; static constexpr bool ppc32 = 0; static constexpr bool rv64 = 0; @@ -205,6 +206,7 @@ namespace nall { static constexpr bool amd64 = 1; static constexpr bool arm64 = 0; static constexpr bool arm32 = 0; + static constexpr bool loong64 = 0; static constexpr bool ppc64 = 0; static constexpr bool ppc32 = 0; static constexpr bool rv64 = 0; @@ -220,6 +222,7 @@ namespace nall { static constexpr bool amd64 = 0; static constexpr bool arm64 = 1; static constexpr bool arm32 = 0; + static constexpr bool loong64 = 0; static constexpr bool ppc64 = 0; static constexpr bool ppc32 = 0; static constexpr bool rv64 = 0; @@ -232,6 +235,20 @@ namespace nall { static constexpr bool amd64 = 0; static constexpr bool arm64 = 0; static constexpr bool arm32 = 1; + static constexpr bool loong64 = 0; + static constexpr bool ppc64 = 0; + static constexpr bool ppc32 = 0; + static constexpr bool rv64 = 0; + static constexpr bool rv32 = 0; + }; +#elif defined(__loongarch64) + #define ARCHITECTURE_LOONG64 + struct Architecture { + static constexpr bool x86 = 0; + static constexpr bool amd64 = 0; + static constexpr bool arm64 = 0; + static constexpr bool arm32 = 0; + static constexpr bool loong64 = 1; static constexpr bool ppc64 = 0; static constexpr bool ppc32 = 0; static constexpr bool rv64 = 0; @@ -244,6 +261,7 @@ namespace nall { static constexpr bool amd64 = 0; static constexpr bool arm64 = 0; static constexpr bool arm32 = 0; + static constexpr bool loong64 = 0; static constexpr bool ppc64 = 1; static constexpr bool ppc32 = 0; static constexpr bool rv64 = 0; @@ -256,6 +274,7 @@ namespace nall { static constexpr bool amd64 = 0; static constexpr bool arm64 = 0; static constexpr bool arm32 = 0; + static constexpr bool loong64 = 0; static constexpr bool ppc64 = 0; static constexpr bool ppc32 = 1; static constexpr bool rv64 = 0; @@ -268,6 +287,7 @@ namespace nall { static constexpr bool amd64 = 0; static constexpr bool arm64 = 0; static constexpr bool arm32 = 0; + static constexpr bool loong64 = 0; static constexpr bool ppc64 = 0; static constexpr bool ppc32 = 0; static constexpr bool rv64 = 1; @@ -280,6 +300,7 @@ namespace nall { static constexpr bool amd64 = 0; static constexpr bool arm64 = 0; static constexpr bool arm32 = 0; + static constexpr bool loong64 = 0; static constexpr bool ppc64 = 0; static constexpr bool ppc32 = 0; static constexpr bool rv64 = 0; diff --git a/nall/recompiler/generic/generic.hpp b/nall/recompiler/generic/generic.hpp index dd102be37e..6bee885236 100644 --- a/nall/recompiler/generic/generic.hpp +++ b/nall/recompiler/generic/generic.hpp @@ -3,7 +3,7 @@ #if defined(SLJIT) namespace nall::recompiler { struct generic { - static constexpr bool supported = Architecture::amd64 | Architecture::arm64 | Architecture::ppc64 | Architecture::rv64; + static constexpr bool supported = Architecture::amd64 | Architecture::arm64 | Architecture::loong64 | Architecture::ppc64 | Architecture::rv64; bump_allocator& allocator; sljit_compiler* compiler = nullptr;