MIPS64, part 2: Add MIPS64 hard-float JIT compiler backend.

Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
Sponsored by Cisco Systems, Inc.
This commit is contained in:
Mike Pall
2017-02-20 03:43:10 +01:00
parent 4416e885d2
commit a25c0b99b8
14 changed files with 1024 additions and 199 deletions

View File

@@ -81,7 +81,7 @@ enum {
RID2RSET(RID_SYS1)|RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)|RID2RSET(RID_GP))
#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED)
#if LJ_SOFTFP
#define RSET_FPR 0
#define RSET_FPR 0
#else
#if LJ_32
#define RSET_FPR \
@@ -90,11 +90,11 @@ enum {
RID2RSET(RID_F16)|RID2RSET(RID_F18)|RID2RSET(RID_F20)|RID2RSET(RID_F22)|\
RID2RSET(RID_F24)|RID2RSET(RID_F26)|RID2RSET(RID_F28)|RID2RSET(RID_F30))
#else
#define RSET_FPR RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)
#define RSET_FPR RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)
#endif
#endif
#define RSET_ALL (RSET_GPR|RSET_FPR)
#define RSET_INIT RSET_ALL
#define RSET_ALL (RSET_GPR|RSET_FPR)
#define RSET_INIT RSET_ALL
#define RSET_SCRATCH_GPR \
(RSET_RANGE(RID_R1, RID_R15+1)|\
@@ -192,8 +192,12 @@ static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p)
#define MIPSF_F(r) ((r) << 6)
#define MIPSF_A(n) ((n) << 6)
#define MIPSF_M(n) ((n) << 11)
#define MIPSF_L(n) ((n) << 6)
typedef enum MIPSIns {
MIPSI_D = 0x38,
MIPSI_DV = 0x10,
MIPSI_D32 = 0x3c,
/* Integer instructions. */
MIPSI_MOVE = 0x00000025,
MIPSI_NOP = 0x00000000,
@@ -202,22 +206,27 @@ typedef enum MIPSIns {
MIPSI_LU = 0x34000000,
MIPSI_LUI = 0x3c000000,
MIPSI_ADDIU = 0x24000000,
MIPSI_AND = 0x00000024,
MIPSI_ANDI = 0x30000000,
MIPSI_OR = 0x00000025,
MIPSI_ORI = 0x34000000,
MIPSI_XOR = 0x00000026,
MIPSI_XORI = 0x38000000,
MIPSI_NOR = 0x00000027,
MIPSI_SLT = 0x0000002a,
MIPSI_SLTU = 0x0000002b,
MIPSI_SLTI = 0x28000000,
MIPSI_SLTIU = 0x2c000000,
MIPSI_ADDU = 0x00000021,
MIPSI_ADDIU = 0x24000000,
MIPSI_SUB = 0x00000022,
MIPSI_SUBU = 0x00000023,
MIPSI_MUL = 0x70000002,
MIPSI_AND = 0x00000024,
MIPSI_OR = 0x00000025,
MIPSI_XOR = 0x00000026,
MIPSI_NOR = 0x00000027,
MIPSI_SLT = 0x0000002a,
MIPSI_SLTU = 0x0000002b,
MIPSI_DIV = 0x0000001a,
MIPSI_DIVU = 0x0000001b,
MIPSI_MOVZ = 0x0000000a,
MIPSI_MOVN = 0x0000000b,
MIPSI_MFHI = 0x00000010,
@@ -228,14 +237,18 @@ typedef enum MIPSIns {
MIPSI_SRL = 0x00000002,
MIPSI_SRA = 0x00000003,
MIPSI_ROTR = 0x00200002, /* MIPSXXR2 */
MIPSI_DROTR = 0x0020003a,
MIPSI_DROTR32 = 0x0020003e,
MIPSI_SLLV = 0x00000004,
MIPSI_SRLV = 0x00000006,
MIPSI_SRAV = 0x00000007,
MIPSI_ROTRV = 0x00000046, /* MIPSXXR2 */
MIPSI_DROTRV = 0x00000056,
MIPSI_SEB = 0x7c000420, /* MIPSXXR2 */
MIPSI_SEH = 0x7c000620, /* MIPSXXR2 */
MIPSI_WSBH = 0x7c0000a0, /* MIPSXXR2 */
MIPSI_DSBH = 0x7c0000a4,
MIPSI_B = 0x10000000,
MIPSI_J = 0x08000000,
@@ -253,7 +266,9 @@ typedef enum MIPSIns {
/* Load/store instructions. */
MIPSI_LW = 0x8c000000,
MIPSI_LD = 0xdc000000,
MIPSI_SW = 0xac000000,
MIPSI_SD = 0xfc000000,
MIPSI_LB = 0x80000000,
MIPSI_SB = 0xa0000000,
MIPSI_LH = 0x84000000,
@@ -266,13 +281,48 @@ typedef enum MIPSIns {
MIPSI_SDC1 = 0xf4000000,
/* MIPS64 instructions. */
MIPSI_DSLL = 0x00000038,
MIPSI_LD = 0xdc000000,
MIPSI_DADD = 0x0000002c,
MIPSI_DADDI = 0x60000000,
MIPSI_DADDU = 0x0000002d,
MIPSI_DADDIU = 0x64000000,
MIPSI_SD = 0xfc000000,
MIPSI_DMFC1 = 0x44200000,
MIPSI_DSUB = 0x0000002e,
MIPSI_DSUBU = 0x0000002f,
MIPSI_DDIV = 0x0000001e,
MIPSI_DDIVU = 0x0000001f,
MIPSI_DMULT = 0x0000001c,
MIPSI_DMULTU = 0x0000001d,
MIPSI_DSLL = 0x00000038,
MIPSI_DSRL = 0x0000003a,
MIPSI_DSLLV = 0x00000014,
MIPSI_DSRLV = 0x00000016,
MIPSI_DSRA = 0x0000003b,
MIPSI_DSRAV = 0x00000017,
MIPSI_DSRA32 = 0x0000003f,
MIPSI_MFHC1 = 0x44600000,
MIPSI_DSLL32 = 0x0000003c,
MIPSI_DSRL32 = 0x0000003e,
MIPSI_DSHD = 0x7c000164,
MIPSI_AADDU = LJ_32 ? MIPSI_ADDU : MIPSI_DADDU,
MIPSI_AADDIU = LJ_32 ? MIPSI_ADDIU : MIPSI_DADDIU,
MIPSI_ASUBU = LJ_32 ? MIPSI_SUBU : MIPSI_DSUBU,
MIPSI_AL = LJ_32 ? MIPSI_LW : MIPSI_LD,
MIPSI_AS = LJ_32 ? MIPSI_SW : MIPSI_SD,
/* Extract/insert instructions. */
MIPSI_DEXTM = 0x7c000001,
MIPSI_DEXTU = 0x7c000002,
MIPSI_DEXT = 0x7c000003,
MIPSI_DINSM = 0x7c000005,
MIPSI_DINSU = 0x7c000006,
MIPSI_DINS = 0x7c000007,
MIPSI_RINT_D = 0x4620001a,
MIPSI_RINT_S = 0x4600001a,
MIPSI_RINT = 0x4400001a,
MIPSI_FLOOR_D = 0x4620000b,
MIPSI_CEIL_D = 0x4620000a,
MIPSI_ROUND_D = 0x46200008,
/* FP instructions. */
MIPSI_MOV_S = 0x46000006,
@@ -298,24 +348,30 @@ typedef enum MIPSIns {
MIPSI_CVT_W_D = 0x46200024,
MIPSI_CVT_S_W = 0x46800020,
MIPSI_CVT_D_W = 0x46800021,
MIPSI_CVT_S_L = 0x46a00020,
MIPSI_CVT_D_L = 0x46a00021,
MIPSI_TRUNC_W_S = 0x4600000d,
MIPSI_TRUNC_W_D = 0x4620000d,
MIPSI_TRUNC_L_S = 0x46000009,
MIPSI_TRUNC_L_D = 0x46200009,
MIPSI_FLOOR_W_S = 0x4600000f,
MIPSI_FLOOR_W_D = 0x4620000f,
MIPSI_MFC1 = 0x44000000,
MIPSI_MTC1 = 0x44800000,
MIPSI_DMTC1 = 0x44a00000,
MIPSI_DMFC1 = 0x44200000,
MIPSI_BC1F = 0x45000000,
MIPSI_BC1T = 0x45010000,
MIPSI_C_EQ_D = 0x46200032,
MIPSI_C_OLT_S = 0x46000034,
MIPSI_C_OLT_D = 0x46200034,
MIPSI_C_ULT_D = 0x46200035,
MIPSI_C_OLE_D = 0x46200036,
MIPSI_C_ULE_D = 0x46200037,
} MIPSIns;
#endif