mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-04-19 21:43:27 +00:00
ARM64 PoC
Exception handlers not implemented, bugs present.
This commit is contained in:
parent
1b11e65813
commit
9c7dbda52a
@ -9,7 +9,7 @@
|
|||||||
#include "buildvm.h"
|
#include "buildvm.h"
|
||||||
#include "lj_bc.h"
|
#include "lj_bc.h"
|
||||||
|
|
||||||
#if LJ_TARGET_X86ORX64
|
#if LJ_TARGET_X86ORX64 || LJ_TARGET_ARM64
|
||||||
|
|
||||||
/* Context for PE object emitter. */
|
/* Context for PE object emitter. */
|
||||||
static char *strtab;
|
static char *strtab;
|
||||||
@ -93,6 +93,13 @@ typedef struct PEsymaux {
|
|||||||
#define PEOBJ_RELOC_ADDR32NB 0x03
|
#define PEOBJ_RELOC_ADDR32NB 0x03
|
||||||
#define PEOBJ_RELOC_OFS 0
|
#define PEOBJ_RELOC_OFS 0
|
||||||
#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */
|
#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */
|
||||||
|
#elif LJ_TARGET_ARM64
|
||||||
|
#define PEOBJ_ARCH_TARGET 0xaa64
|
||||||
|
#define PEOBJ_RELOC_REL32 0x11 /* MS: REL32, GNU: DISP32. */
|
||||||
|
#define PEOBJ_RELOC_DIR32 0x01
|
||||||
|
#define PEOBJ_RELOC_ADDR32NB 0x02
|
||||||
|
#define PEOBJ_RELOC_OFS 0
|
||||||
|
#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Section numbers (0-based). */
|
/* Section numbers (0-based). */
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#define LUAJIT_TARGET LUAJIT_ARCH_X64
|
#define LUAJIT_TARGET LUAJIT_ARCH_X64
|
||||||
#elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM)
|
#elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM)
|
||||||
#define LUAJIT_TARGET LUAJIT_ARCH_ARM
|
#define LUAJIT_TARGET LUAJIT_ARCH_ARM
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||||
#define LUAJIT_TARGET LUAJIT_ARCH_ARM64
|
#define LUAJIT_TARGET LUAJIT_ARCH_ARM64
|
||||||
#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
|
#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
|
||||||
#define LUAJIT_TARGET LUAJIT_ARCH_PPC
|
#define LUAJIT_TARGET LUAJIT_ARCH_PPC
|
||||||
|
@ -30,15 +30,21 @@ static uint32_t emit_isk12(int64_t n)
|
|||||||
uint64_t k = n < 0 ? ~(uint64_t)n+1u : (uint64_t)n;
|
uint64_t k = n < 0 ? ~(uint64_t)n+1u : (uint64_t)n;
|
||||||
uint32_t m = n < 0 ? 0x40000000 : 0;
|
uint32_t m = n < 0 ? 0x40000000 : 0;
|
||||||
if (k < 0x1000) {
|
if (k < 0x1000) {
|
||||||
return A64I_K12|m|A64F_U12(k);
|
return (uint32_t)(A64I_K12|m|A64F_U12(k));
|
||||||
} else if ((k & 0xfff000) == k) {
|
} else if ((k & 0xfff000) == k) {
|
||||||
return A64I_K12|m|0x400000|A64F_U12(k>>12);
|
return (uint32_t)(A64I_K12|m|0x400000|A64F_U12(k>>12));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <intrin.h>
|
||||||
|
#define emit_clz64(n) _CountLeadingZeros64(n)
|
||||||
|
#define emit_ctz64(n) _CountLeadingZeros64(neon_rbit(__uint64ToN64_v(n)).n64_u64[0])
|
||||||
|
#else
|
||||||
#define emit_clz64(n) __builtin_clzll(n)
|
#define emit_clz64(n) __builtin_clzll(n)
|
||||||
#define emit_ctz64(n) __builtin_ctzll(n)
|
#define emit_ctz64(n) __builtin_ctzll(n)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Encode constant in K13 format for logical data processing instructions. */
|
/* Encode constant in K13 format for logical data processing instructions. */
|
||||||
static uint32_t emit_isk13(uint64_t n, int is64)
|
static uint32_t emit_isk13(uint64_t n, int is64)
|
||||||
|
@ -39,7 +39,7 @@ void lj_mcode_sync(void *start, void *end)
|
|||||||
#ifdef LUAJIT_USE_VALGRIND
|
#ifdef LUAJIT_USE_VALGRIND
|
||||||
VALGRIND_DISCARD_TRANSLATIONS(start, (char *)end-(char *)start);
|
VALGRIND_DISCARD_TRANSLATIONS(start, (char *)end-(char *)start);
|
||||||
#endif
|
#endif
|
||||||
#if LJ_TARGET_X86ORX64
|
#if LJ_TARGET_X86ORX64 || _MSC_VER
|
||||||
UNUSED(start); UNUSED(end);
|
UNUSED(start); UNUSED(end);
|
||||||
#elif LJ_TARGET_IOS
|
#elif LJ_TARGET_IOS
|
||||||
sys_icache_invalidate(start, (char *)end-(char *)start);
|
sys_icache_invalidate(start, (char *)end-(char *)start);
|
||||||
|
@ -69,7 +69,7 @@ typedef uint32_t RegSet;
|
|||||||
#define rset_set(rs, r) (rs |= RID2RSET(r))
|
#define rset_set(rs, r) (rs |= RID2RSET(r))
|
||||||
#define rset_clear(rs, r) (rs &= ~RID2RSET(r))
|
#define rset_clear(rs, r) (rs &= ~RID2RSET(r))
|
||||||
#define rset_exclude(rs, r) (rs & ~RID2RSET(r))
|
#define rset_exclude(rs, r) (rs & ~RID2RSET(r))
|
||||||
#if LJ_TARGET_PPC || LJ_TARGET_MIPS || LJ_TARGET_ARM64
|
#if (LJ_TARGET_PPC || LJ_TARGET_MIPS || LJ_TARGET_ARM64) && !_MSC_VER
|
||||||
#define rset_picktop(rs) ((Reg)(__builtin_clzll(rs)^63))
|
#define rset_picktop(rs) ((Reg)(__builtin_clzll(rs)^63))
|
||||||
#define rset_pickbot(rs) ((Reg)__builtin_ctzll(rs))
|
#define rset_pickbot(rs) ((Reg)__builtin_ctzll(rs))
|
||||||
#else
|
#else
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
@setlocal
|
@setlocal
|
||||||
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK
|
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK
|
||||||
@set DEBUGCFLAGS=
|
@set DEBUGCFLAGS=
|
||||||
@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
|
@set LJCOMPILE=cl /nologo /c /O2 /Oi- /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline /Zi /Zo /DEBUG
|
||||||
@set LJLINK=link /nologo
|
@set LJLINK=link /nologo /DEBUG
|
||||||
@set LJMT=mt /nologo
|
@set LJMT=mt /nologo
|
||||||
@set LJLIB=lib /nologo /nodefaultlib
|
@set LJLIB=lib /nologo /nodefaultlib
|
||||||
@set DASMDIR=..\dynasm
|
@set DASMDIR=..\dynasm
|
||||||
@set DASM=%DASMDIR%\dynasm.lua
|
@set DASM=%DASMDIR%\dynasm.lua
|
||||||
@set DASC=vm_x64.dasc
|
@set DASC=vm_arm64.dasc
|
||||||
@set LJDLLNAME=lua51.dll
|
@set LJDLLNAME=lua51.dll
|
||||||
@set LJLIBNAME=lua51.lib
|
@set LJLIBNAME=lua51.lib
|
||||||
@set BUILDTYPE=release
|
@set BUILDTYPE=release
|
||||||
@ -35,19 +35,7 @@ if exist minilua.exe.manifest^
|
|||||||
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
|
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
|
||||||
|
|
||||||
@set DASMFLAGS=-D WIN -D JIT -D FFI -D P64
|
@set DASMFLAGS=-D WIN -D JIT -D FFI -D P64
|
||||||
@set LJARCH=x64
|
@set LJARCH=arm64
|
||||||
@minilua
|
|
||||||
@if errorlevel 8 goto :X64
|
|
||||||
@set DASC=vm_x86.dasc
|
|
||||||
@set DASMFLAGS=-D WIN -D JIT -D FFI
|
|
||||||
@set LJARCH=x86
|
|
||||||
@set LJCOMPILE=%LJCOMPILE% /arch:SSE2
|
|
||||||
:X64
|
|
||||||
@if "%1" neq "nogc64" goto :GC64
|
|
||||||
@shift
|
|
||||||
@set DASC=vm_x86.dasc
|
|
||||||
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_DISABLE_GC64
|
|
||||||
:GC64
|
|
||||||
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
|
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
|
||||||
@if errorlevel 1 goto :BAD
|
@if errorlevel 1 goto :BAD
|
||||||
|
|
||||||
@ -120,7 +108,7 @@ if exist luajit.exe.manifest^
|
|||||||
@echo.
|
@echo.
|
||||||
@echo *******************************************************
|
@echo *******************************************************
|
||||||
@echo *** Build FAILED -- Please check the error messages ***
|
@echo *** Build FAILED -- Please check the error messages ***
|
||||||
@echo *******************************************************
|
@echo *******************************************************
|
||||||
@goto :END
|
@goto :END
|
||||||
:FAIL
|
:FAIL
|
||||||
@echo You must open a "Visual Studio Command Prompt" to run this script
|
@echo You must open a "Visual Studio Command Prompt" to run this script
|
||||||
|
Loading…
Reference in New Issue
Block a user