riscv(support): add RISC-V 64 arch base definition

This commit is contained in:
gns 2024-03-05 17:09:31 +08:00 committed by gns
parent a4f56a459a
commit 459094e899

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_riscv64 8
#define LUAJIT_ARCH_RISCV64 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(__riscv) || defined(__riscv__)) && __riscv_xlen == 64
#define LUAJIT_TARGET LUAJIT_ARCH_RISCV64
#else #else
#error "Architecture not supported (in this version), see: https://luajit.org/status.html#architectures" #error "Architecture not supported (in this version), see: https://luajit.org/status.html#architectures"
#endif #endif
@ -439,6 +443,21 @@
#define LJ_ARCH_VERSION 10 #define LJ_ARCH_VERSION 10
#endif #endif
#elif LUAJIT_TARGET == LUAJIT_ARCH_RISCV64
#define LJ_ARCH_NAME "riscv64"
#define LJ_ARCH_BITS 64
#define LJ_ARCH_ENDIAN LUAJIT_LE /* Forget about BE for now */
#define LJ_TARGET_RISCV64 1
#define LJ_TARGET_GC64 1
#define LJ_TARGET_EHRETREG 10
#define LJ_TARGET_EHRAREG 1
#define LJ_TARGET_JUMPRANGE 30 /* JAL +-2^20 = +-1MB,\
AUIPC+JALR +-2^31 = +-2GB, leave 1 bit to avoid AUIPC corner case */
#define LJ_TARGET_MASKSHIFT 1
#define LJ_TARGET_MASKROT 1
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
#else #else
#error "No target architecture defined" #error "No target architecture defined"
#endif #endif
@ -531,6 +550,10 @@
#error "Only n64 ABI supported for MIPS64" #error "Only n64 ABI supported for MIPS64"
#undef LJ_TARGET_MIPS #undef LJ_TARGET_MIPS
#endif #endif
#elif LJ_TARGET_RISCV64
#if !defined(__riscv_float_abi_double)
#error "Only RISC-V 64 double float supported for now"
#endif
#endif #endif
#endif #endif