MIPS soft-float, part 1: Add soft-float support to interpreter.

Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
Sponsored by Cisco Systems, Inc.
This commit is contained in:
Mike Pall 2015-12-17 22:42:20 +01:00
parent 126e55d416
commit 3f5c72421e
6 changed files with 1191 additions and 226 deletions

View File

@ -304,6 +304,13 @@
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE
#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
#define LJ_ARCH_VERSION 20
#else
@ -386,9 +393,6 @@
#error "No support for PPC/e500 anymore (use LuaJIT 2.0)"
#endif
#elif LJ_TARGET_MIPS
#if defined(__mips_soft_float)
#error "No support for MIPS CPUs without FPU"
#endif
#if defined(_LP64)
#error "No support for MIPS64"
#endif

View File

@ -14,6 +14,21 @@
#if LJ_TARGET_MIPS
/* Need our own global offset table for the dreaded MIPS calling conventions. */
#if LJ_SOFTFP
extern double __adddf3(double a, double b);
extern double __subdf3(double a, double b);
extern double __muldf3(double a, double b);
extern double __divdf3(double a, double b);
extern void __ledf2(double a, double b);
extern double __floatsidf(int32_t a);
extern int32_t __fixdfsi(double a);
#define SFGOTDEF(_) \
_(lj_num2bit) _(sqrt) _(__adddf3) _(__subdf3) _(__muldf3) _(__divdf3) _(__ledf2) \
_(__floatsidf) _(__fixdfsi)
#else
#define SFGOTDEF(_)
#endif
#if LJ_HASJIT
#define JITGOTDEF(_) _(lj_trace_exit) _(lj_trace_hot)
#else
@ -39,7 +54,8 @@
_(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_setinth) _(lj_buf_putstr_reverse) _(lj_buf_putstr_lower) \
_(lj_buf_putstr_upper) _(lj_buf_tostr) JITGOTDEF(_) FFIGOTDEF(_)
_(lj_buf_putstr_upper) _(lj_buf_tostr) \
JITGOTDEF(_) FFIGOTDEF(_) SFGOTDEF(_)
enum {
#define GOTENUM(name) LJ_GOT_##name,

View File

@ -218,6 +218,7 @@ enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */
#define CFRAME_SHIFT_MULTRES 3
#endif
#elif LJ_TARGET_MIPS
#if LJ_ARCH_HASFPU
#define CFRAME_OFS_ERRF 124
#define CFRAME_OFS_NRES 120
#define CFRAME_OFS_PREV 116
@ -227,6 +228,16 @@ enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */
#define CFRAME_SIZE 112
#define CFRAME_SHIFT_MULTRES 3
#else
#define CFRAME_OFS_ERRF 100
#define CFRAME_OFS_NRES 96
#define CFRAME_OFS_PREV 92
#define CFRAME_OFS_L 88
#define CFRAME_OFS_PC 44
#define CFRAME_OFS_MULTRES 16
#define CFRAME_SIZE 88
#define CFRAME_SHIFT_MULTRES 3
#endif
#else
#error "Missing CFRAME_* definitions for this architecture"
#endif

View File

@ -270,6 +270,22 @@ LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1];
#define fp64_f2l __aeabi_f2lz
#define fp64_f2ul __aeabi_f2ulz
#endif
#elif LJ_TARGET_MIPS
#define softfp_add __adddf3
#define softfp_sub __subdf3
#define softfp_mul __muldf3
#define softfp_div __divdf3
#define softfp_cmp __ledf2
#define softfp_i2d __floatsidf
#define softfp_d2i __fixdfsi
#define softfp_ui2d __floatunsidf
#define softfp_f2d __extendsfdf2
#define softfp_d2ui __fixunsdfsi
#define softfp_d2f __truncdfsf2
#define softfp_i2f __floatsisf
#define softfp_ui2f __floatunsisf
#define softfp_f2i __fixsfsi
#define softfp_f2ui __fixunssfsi
#else
#error "Missing soft-float definitions for target architecture"
#endif

View File

@ -50,7 +50,7 @@ LJ_ASMF void lj_vm_exit_handler(void);
LJ_ASMF void lj_vm_exit_interp(void);
/* Internal math helper functions. */
#if LJ_TARGET_PPC || LJ_TARGET_ARM64
#if LJ_TARGET_PPC || LJ_TARGET_ARM64 || (LJ_TARGET_MIPS && LJ_ABI_SOFTFP)
#define lj_vm_floor floor
#define lj_vm_ceil ceil
#else

File diff suppressed because it is too large Load Diff