MIPS: Switch to dual-number mode. Fix soft-float interpreter.

This commit is contained in:
Mike Pall 2016-01-29 07:03:36 +01:00
parent 2f6b2967c7
commit 60de2f3d51
7 changed files with 1442 additions and 1450 deletions

View File

@ -388,6 +388,11 @@ DASM_XFLAGS=
DASM_AFLAGS= DASM_AFLAGS=
DASM_ARCH= $(TARGET_LJARCH) DASM_ARCH= $(TARGET_LJARCH)
ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D ENDIAN_LE
else
DASM_AFLAGS+= -D ENDIAN_BE
endif
ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D P64 DASM_AFLAGS+= -D P64
endif endif

View File

@ -295,6 +295,31 @@
#define LJ_ARCH_NAME "mips" #define LJ_ARCH_NAME "mips"
#define LJ_ARCH_ENDIAN LUAJIT_BE #define LJ_ARCH_ENDIAN LUAJIT_BE
#endif #endif
#if !defined(LJ_ARCH_HASFPU)
#ifdef __mips_soft_float
#define LJ_ARCH_HASFPU 0
#else
#define LJ_ARCH_HASFPU 1
#endif
#endif
/* Temporarily disable features until the code has been merged. */
#if !LJ_ARCH_HASFPU
#define LJ_ARCH_NOJIT 1
#endif
#if !defined(LUAJIT_NO_UNWIND) && __GNU_COMPACT_EH__
#define LUAJIT_NO_UNWIND 1
#endif
#if !defined(LJ_ABI_SOFTFP)
#ifdef __mips_soft_float
#define LJ_ABI_SOFTFP 1
#else
#define LJ_ABI_SOFTFP 0
#endif
#endif
#define LJ_ARCH_BITS 32 #define LJ_ARCH_BITS 32
#define LJ_TARGET_MIPS 1 #define LJ_TARGET_MIPS 1
#define LJ_TARGET_EHRETREG 4 #define LJ_TARGET_EHRETREG 4
@ -302,14 +327,7 @@
#define LJ_TARGET_MASKSHIFT 1 #define LJ_TARGET_MASKSHIFT 1
#define LJ_TARGET_MASKROT 1 #define LJ_TARGET_MASKROT 1
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ #define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
#if !defined(LJ_ARCH_HASFPU) && defined(__mips_soft_float)
#define LJ_ARCH_HASFPU 0
#endif
#if !defined(LJ_ABI_SOFTFP) && defined(__mips_soft_float)
#define LJ_ABI_SOFTFP 1
#endif
#if _MIPS_ARCH_MIPS32R2 #if _MIPS_ARCH_MIPS32R2
#define LJ_ARCH_VERSION 20 #define LJ_ARCH_VERSION 20

View File

@ -14,18 +14,19 @@
#if LJ_TARGET_MIPS #if LJ_TARGET_MIPS
/* Need our own global offset table for the dreaded MIPS calling conventions. */ /* Need our own global offset table for the dreaded MIPS calling conventions. */
#ifndef _LJ_VM_H
LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b);
#endif
#if LJ_SOFTFP #if LJ_SOFTFP
#ifndef _LJ_IRCALL_H
extern double __adddf3(double a, double b); extern double __adddf3(double a, double b);
extern double __subdf3(double a, double b); extern double __subdf3(double a, double b);
extern double __muldf3(double a, double b); extern double __muldf3(double a, double b);
extern double __divdf3(double a, double b); extern double __divdf3(double a, double b);
extern void __ledf2(double a, double b); #endif
extern double __floatsidf(int32_t a); #define SFGOTDEF(_) _(sqrt) _(__adddf3) _(__subdf3) _(__muldf3) _(__divdf3)
extern int32_t __fixdfsi(double a);
#define SFGOTDEF(_) \
_(lj_num2bit) _(sqrt) _(__adddf3) _(__subdf3) _(__muldf3) _(__divdf3) _(__ledf2) \
_(__floatsidf) _(__fixdfsi)
#else #else
#define SFGOTDEF(_) #define SFGOTDEF(_)
#endif #endif
@ -43,14 +44,14 @@ extern int32_t __fixdfsi(double a);
#define GOTDEF(_) \ #define GOTDEF(_) \
_(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \ _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \
_(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \ _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \
_(pow) _(fmod) _(ldexp) \ _(pow) _(fmod) _(ldexp) _(lj_vm_modi) \
_(lj_dispatch_call) _(lj_dispatch_ins) _(lj_dispatch_stitch) \ _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_dispatch_stitch) \
_(lj_dispatch_profile) _(lj_err_throw) \ _(lj_dispatch_profile) _(lj_err_throw) \
_(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \ _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \
_(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \ _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \
_(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \ _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \
_(lj_meta_for) _(lj_meta_istype) _(lj_meta_len) _(lj_meta_tget) \ _(lj_meta_for) _(lj_meta_istype) _(lj_meta_len) _(lj_meta_tget) \
_(lj_meta_tset) _(lj_state_growstack) _(lj_strfmt_num) \ _(lj_meta_tset) _(lj_state_growstack) _(lj_strfmt_number) \
_(lj_str_new) _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) \ _(lj_str_new) _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) \
_(lj_tab_new) _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \ _(lj_tab_new) _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \
_(lj_tab_setinth) _(lj_buf_putstr_reverse) _(lj_buf_putstr_lower) \ _(lj_tab_setinth) _(lj_buf_putstr_reverse) _(lj_buf_putstr_lower) \

View File

@ -228,13 +228,13 @@ enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */
#define CFRAME_SIZE 112 #define CFRAME_SIZE 112
#define CFRAME_SHIFT_MULTRES 3 #define CFRAME_SHIFT_MULTRES 3
#else #else
#define CFRAME_OFS_ERRF 100 #define CFRAME_OFS_ERRF 76
#define CFRAME_OFS_NRES 96 #define CFRAME_OFS_NRES 72
#define CFRAME_OFS_PREV 92 #define CFRAME_OFS_PREV 68
#define CFRAME_OFS_L 88 #define CFRAME_OFS_L 64
#define CFRAME_OFS_PC 44 #define CFRAME_OFS_PC 20
#define CFRAME_OFS_MULTRES 16 #define CFRAME_OFS_MULTRES 16
#define CFRAME_SIZE 88 #define CFRAME_SIZE 64
#define CFRAME_SHIFT_MULTRES 3 #define CFRAME_SHIFT_MULTRES 3
#endif #endif
#else #else

View File

@ -66,6 +66,9 @@ LJ_ASMF double lj_vm_log2(double);
#else #else
#define lj_vm_log2 log2 #define lj_vm_log2 log2
#endif #endif
#if !(defined(_LJ_DISPATCH_H) && LJ_TARGET_MIPS)
LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t);
#endif
#if LJ_HASJIT #if LJ_HASJIT
#if LJ_TARGET_X86ORX64 #if LJ_TARGET_X86ORX64
@ -90,7 +93,6 @@ LJ_ASMF double lj_vm_exp2(double);
#else #else
#define lj_vm_exp2 exp2 #define lj_vm_exp2 exp2
#endif #endif
LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t);
#if LJ_HASFFI #if LJ_HASFFI
LJ_ASMF int lj_vm_errno(void); LJ_ASMF int lj_vm_errno(void);
#endif #endif

View File

@ -57,6 +57,20 @@ double lj_vm_foldarith(double x, double y, int op)
} }
} }
#if (LJ_HASJIT && !(LJ_TARGET_ARM || LJ_TARGET_ARM64 || LJ_TARGET_PPC)) || LJ_TARGET_MIPS
int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b)
{
uint32_t y, ua, ub;
lua_assert(b != 0); /* This must be checked before using this function. */
ua = a < 0 ? (uint32_t)-a : (uint32_t)a;
ub = b < 0 ? (uint32_t)-b : (uint32_t)b;
y = ua % ub;
if (y != 0 && (a^b) < 0) y = y - ub;
if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y;
return (int32_t)y;
}
#endif
#if LJ_HASJIT #if LJ_HASJIT
#ifdef LUAJIT_NO_LOG2 #ifdef LUAJIT_NO_LOG2
@ -73,20 +87,6 @@ double lj_vm_exp2(double a)
} }
#endif #endif
#if !(LJ_TARGET_ARM || LJ_TARGET_ARM64 || LJ_TARGET_PPC)
int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b)
{
uint32_t y, ua, ub;
lua_assert(b != 0); /* This must be checked before using this function. */
ua = a < 0 ? (uint32_t)-a : (uint32_t)a;
ub = b < 0 ? (uint32_t)-b : (uint32_t)b;
y = ua % ub;
if (y != 0 && (a^b) < 0) y = y - ub;
if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y;
return (int32_t)y;
}
#endif
#if !LJ_TARGET_X86ORX64 #if !LJ_TARGET_X86ORX64
/* Unsigned x^k. */ /* Unsigned x^k. */
static double lj_vm_powui(double x, uint32_t k) static double lj_vm_powui(double x, uint32_t k)

File diff suppressed because it is too large Load Diff