LoongArch64: Add target architecture selection

Co-developed-by: Qiqi Huang <huangqiqi@loongson.cn>
This commit is contained in:
Xiaolin Zhao 2022-07-27 15:47:31 +08:00
parent e1339aed3d
commit 016f8b583c

View File

@ -31,6 +31,8 @@
#define LUAJIT_ARCH_mips32 6 #define LUAJIT_ARCH_mips32 6
#define LUAJIT_ARCH_MIPS64 7 #define LUAJIT_ARCH_MIPS64 7
#define LUAJIT_ARCH_mips64 7 #define LUAJIT_ARCH_mips64 7
#define LUAJIT_ARCH_LOONGARCH64 8
#define LUAJIT_ARCH_loongarch64 8
/* Target OS. */ /* Target OS. */
#define LUAJIT_OS_OTHER 0 #define LUAJIT_OS_OTHER 0
@ -65,6 +67,8 @@
#define LUAJIT_TARGET LUAJIT_ARCH_MIPS64 #define LUAJIT_TARGET LUAJIT_ARCH_MIPS64
#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS) #elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS)
#define LUAJIT_TARGET LUAJIT_ARCH_MIPS32 #define LUAJIT_TARGET LUAJIT_ARCH_MIPS32
#elif defined(__loongarch64)
#define LUAJIT_TARGET LUAJIT_ARCH_LOONGARCH64
#else #else
#error "No support for this architecture (yet)" #error "No support for this architecture (yet)"
#endif #endif
@ -432,6 +436,20 @@
#define LJ_ARCH_VERSION 10 #define LJ_ARCH_VERSION 10
#endif #endif
#elif LUAJIT_TARGET == LUAJIT_ARCH_LOONGARCH64
#define LJ_ARCH_NAME "loongarch64"
#define LJ_ARCH_BITS 64
#define LJ_ARCH_ENDIAN LUAJIT_LE
#define LJ_TARGET_LOONGARCH64 1
#define LJ_TARGET_GC64 1
#define LJ_TARGET_EHRETREG 4
#define LJ_TARGET_EHRAREG 1
#define LJ_TARGET_JUMPRANGE 27 /* +-2^27 = +-128MB */
#define LJ_TARGET_MASKSHIFT 1
#define LJ_TARGET_MASKROT 1
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
#else #else
#error "No target architecture defined" #error "No target architecture defined"
#endif #endif
@ -462,6 +480,16 @@
#error "Need at least GCC 4.8 or newer" #error "Need at least GCC 4.8 or newer"
#endif #endif
#endif #endif
#elif LJ_TARGET_LOONGARCH64
#if __clang__
#if ((__clang_major__ < 8) || ((__clang_major__ == 8) && __clang_minor__ < 0)) && !defined(__NX_TOOLCHAIN_MAJOR__)
#error "Need at least Clang 8.0 or newer"
#endif
#else
#if (__GNUC__ < 8) || ((__GNUC__ == 8) && __GNUC_MINOR__ < 3)
#error "Need at least GCC 8.3 or newer"
#endif
#endif
#elif !LJ_TARGET_PS3 #elif !LJ_TARGET_PS3
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
#error "Need at least GCC 4.3 or newer" #error "Need at least GCC 4.3 or newer"
@ -509,6 +537,10 @@
/* MIPS32ON64 aka n32 ABI support might be desirable, but difficult. */ /* MIPS32ON64 aka n32 ABI support might be desirable, but difficult. */
#error "Only n64 ABI supported for MIPS64" #error "Only n64 ABI supported for MIPS64"
#endif #endif
#elif LJ_TARGET_LOONGARCH64
#if !(defined(_ABILP64) && _LOONGARCH_SIM == _ABILP64)
#error "Only LOONGARCH lp64d ABI is supported"
#endif
#endif #endif
#endif #endif