target-mips: add microMIPS ASE support, v3
cover target-mips: add microMIPS ASE support, v3
This patch series adds support for the microMIPS ASE. microMIPS is a new ASE similar to MIPS16, but re-encodes the entire instruction set into 16-bit and 32-bit instructions--in contrast to MIPS16, which re-encodes only integer instructions. The mechanisms for going in and out of microMIPS mode are identical to those for MIPS16; a given chip cannot support both ASEs simultaneously.
changes from v2:
give actual name to FOP constants; assign names to FOPs for c{,abs} fix up coding style violations
fix helpers for recent ldl_*/stl_* prototype changes split out mips16-related changes into separate patch group patches more logically
changes from v1:
fix re-introduction of previously deleted code noted by rth
Nathan Froyd (8):
target-mips: define constants for magic numbers
target-mips: refactor c{,abs}.cond.fmt insns
target-mips: mips16 cleanups
target-mips: microMIPS ASE support
target-mips: add microMIPS CPUs
target-mips: add microMIPS exception handler support
linux-user: honor low bit of entry PC for MIPS
hw: honor low bit in mipssim machine
hw/mips_mipssim.c | 5 +- linux-user/main.c | 5 +- target-mips/cpu.h | 1 + target-mips/helper.c | 21 +- target-mips/helper.h | 9 + target-mips/mips-defs.h | 1 + target-mips/op_helper.c | 136 ++ target-mips/translate.c | 3015 ++++++++++++++++++++++++++++++++++++++---- target-mips/translate_init.c | 61 + 9 files changed, 3009 insertions(+), 245 deletions(-)
PATCH 7/8 linux-user: honor low bit of entry PC for MIPS
--- linux-user/main.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
linux-user/main.c +4 -1
@@ -3271,7 +3271,10 @@ int main(int argc, char **argv, char **envp)for (i =0 ; i <32 ; i++) { env->active_tc.gpr[i] = regs->regs[i]; } - env->active_tc.PC = regs->cp0_epc; + env->active_tc.PC = regs->cp0_epc & ~(target_ulong )1 ; +if (regs->cp0_epc &1 ) { + env->hflags |=MIPS_HFLAG_M16 ; + } }#elif defined(TARGET_SH4) {
Signature · 1 line
1.6.3.2
PATCH 2/8 target-mips: refactor c{, abs}.cond.fmt insns
In reply to Nathan FroydMove all knowledge about coprocessor-checking and register numbering into the gen_cmp* helper functions.
--- target-mips/translate.c | 164 +++++++++++++++++++++++------------------------ 1 files changed, 81 insertions(+), 83 deletions(-)
target-mips/translate.c +81 -83
@@ -676,39 +676,6 @@ static inline int get_fp_bit (int cc)return 23 ; } -#define FOP_CONDS (type, fmt, bits) \ -static inline void gen_cmp ## type ## _ ## fmt(int n, TCGv_i##bits a, \ - TCGv_i##bits b, int cc) \ -{ \ - switch (n) { \ - case 0: gen_helper_2i(cmp ## type ## _ ## fmt ## _f, a, b, cc); break;\ - case 1: gen_helper_2i(cmp ## type ## _ ## fmt ## _un, a, b, cc); break;\ - case 2: gen_helper_2i(cmp ## type ## _ ## fmt ## _eq, a, b, cc); break;\ - case 3: gen_helper_2i(cmp ## type ## _ ## fmt ## _ueq, a, b, cc); break;\ - case 4: gen_helper_2i(cmp ## type ## _ ## fmt ## _olt, a, b, cc); break;\ - case 5: gen_helper_2i(cmp ## type ## _ ## fmt ## _ult, a, b, cc); break;\ - case 6: gen_helper_2i(cmp ## type ## _ ## fmt ## _ole, a, b, cc); break;\ - case 7: gen_helper_2i(cmp ## type ## _ ## fmt ## _ule, a, b, cc); break;\ - case 8: gen_helper_2i(cmp ## type ## _ ## fmt ## _sf, a, b, cc); break;\ - case 9: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngle, a, b, cc); break;\ - case 10: gen_helper_2i(cmp ## type ## _ ## fmt ## _seq, a, b, cc); break;\ - case 11: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngl, a, b, cc); break;\ - case 12: gen_helper_2i(cmp ## type ## _ ## fmt ## _lt, a, b, cc); break;\ - case 13: gen_helper_2i(cmp ## type ## _ ## fmt ## _nge, a, b, cc); break;\ - case 14: gen_helper_2i(cmp ## type ## _ ## fmt ## _le, a, b, cc); break;\ - case 15: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngt, a, b, cc); break;\ - default: abort(); \ - } \ -} - -FOP_CONDS(, d, 64) -FOP_CONDS(abs, d, 64) -FOP_CONDS(, s, 32) -FOP_CONDS(abs, s, 32) -FOP_CONDS(, ps, 64) -FOP_CONDS(abs, ps, 64) -#undef FOP_CONDS -/* Tests */ static inline void gen_save_pc (target_ulong pc) {
@@ -849,6 +816,69 @@ static inline void check_mips_64(DisasContext *ctx)generate_exception (ctx,EXCP_RI ); } +/* Define small wrappers for gen_load_fpr* so that we have a uniform +calling interface for 32 and 64-bit FPRs. No sense in changing +all callers for gen_load_fpr32 when we need the CTX parameter for +this one use. */ +#define gen_ldcmp_fpr32 (ctx, x, y) gen_load_fpr32(x, y) +#define gen_ldcmp_fpr64 (ctx, x, y) gen_load_fpr64(ctx, x, y) +#define FOP_CONDS (type, abs, fmt, ifmt, bits) \ +static inline void gen_cmp ## type ## _ ## fmt(DisasContext *ctx, int n, \ + int ft, int fs, int cc) \ +{ \ + TCGv_i##bits fp0 = tcg_temp_new_i##bits (); \ + TCGv_i##bits fp1 = tcg_temp_new_i##bits (); \ + switch (ifmt) { \ + case FMT_PS: \ + check_cp1_64bitmode(ctx); \ + break; \ + case FMT_D: \ + if (abs) { \ + check_cop1x(ctx); \ + } \ + check_cp1_registers(ctx, fs | ft); \ + break; \ + case FMT_S: \ + if (abs) { \ + check_cop1x(ctx); \ + } \ + break; \ + } \ + gen_ldcmp_fpr##bits (ctx, fp0, fs); \ + gen_ldcmp_fpr##bits (ctx, fp1, ft); \ + switch (n) { \ + case 0: gen_helper_2i(cmp ## type ## _ ## fmt ## _f, fp0, fp1, cc); break;\ + case 1: gen_helper_2i(cmp ## type ## _ ## fmt ## _un, fp0, fp1, cc); break;\ + case 2: gen_helper_2i(cmp ## type ## _ ## fmt ## _eq, fp0, fp1, cc); break;\ + case 3: gen_helper_2i(cmp ## type ## _ ## fmt ## _ueq, fp0, fp1, cc); break;\ + case 4: gen_helper_2i(cmp ## type ## _ ## fmt ## _olt, fp0, fp1, cc); break;\ + case 5: gen_helper_2i(cmp ## type ## _ ## fmt ## _ult, fp0, fp1, cc); break;\ + case 6: gen_helper_2i(cmp ## type ## _ ## fmt ## _ole, fp0, fp1, cc); break;\ + case 7: gen_helper_2i(cmp ## type ## _ ## fmt ## _ule, fp0, fp1, cc); break;\ + case 8: gen_helper_2i(cmp ## type ## _ ## fmt ## _sf, fp0, fp1, cc); break;\ + case 9: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngle, fp0, fp1, cc); break;\ + case 10: gen_helper_2i(cmp ## type ## _ ## fmt ## _seq, fp0, fp1, cc); break;\ + case 11: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngl, fp0, fp1, cc); break;\ + case 12: gen_helper_2i(cmp ## type ## _ ## fmt ## _lt, fp0, fp1, cc); break;\ + case 13: gen_helper_2i(cmp ## type ## _ ## fmt ## _nge, fp0, fp1, cc); break;\ + case 14: gen_helper_2i(cmp ## type ## _ ## fmt ## _le, fp0, fp1, cc); break;\ + case 15: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngt, fp0, fp1, cc); break;\ + default: abort(); \ + } \ + tcg_temp_free_i##bits (fp0); \ + tcg_temp_free_i##bits (fp1); \ +} + +FOP_CONDS(, 0, d, FMT_D, 64) +FOP_CONDS(abs, 1, d, FMT_D, 64) +FOP_CONDS(, 0, s, FMT_S, 32) +FOP_CONDS(abs, 1, s, FMT_S, 32) +FOP_CONDS(, 0, ps, FMT_PS, 64) +FOP_CONDS(abs, 1, ps, FMT_PS, 64) +#undef FOP_CONDS +#undef gen_ldcmp_fpr32 +#undef gen_ldcmp_fpr64 +/* load/store instructions. */ #define OP_LD (insn,fname) \ static inline void op_ldst_##insn(TCGv ret, TCGv arg1, DisasContext *ctx) \
@@ -6480,22 +6510,12 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,case OPC_CMP_NGE_S :case OPC_CMP_LE_S :case OPC_CMP_NGT_S : - { -TCGv_i32 fp0 =tcg_temp_new_i32 (); -TCGv_i32 fp1 =tcg_temp_new_i32 (); - -gen_load_fpr32 (fp0, fs); -gen_load_fpr32 (fp1, ft); -if (ctx->opcode & (1 <<6 )) { -check_cop1x (ctx); -gen_cmpabs_s (func-48 , fp0, fp1, cc); - opn = condnames_abs[func-48 ]; - }else { -gen_cmp_s (func-48 , fp0, fp1, cc); - opn = condnames[func-48 ]; - } -tcg_temp_free_i32 (fp0); -tcg_temp_free_i32 (fp1); +if (ctx->opcode & (1 <<6 )) { +gen_cmpabs_s (ctx, func-48 , ft, fs, cc); + opn = condnames_abs[func-48 ]; + }else { +gen_cmp_s (ctx, func-48 , ft, fs, cc); + opn = condnames[func-48 ]; }break ;case OPC_ADD_D :
@@ -6843,24 +6863,12 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,case OPC_CMP_NGE_D :case OPC_CMP_LE_D :case OPC_CMP_NGT_D : - { -TCGv_i64 fp0 =tcg_temp_new_i64 (); -TCGv_i64 fp1 =tcg_temp_new_i64 (); - -gen_load_fpr64 (ctx, fp0, fs); -gen_load_fpr64 (ctx, fp1, ft); -if (ctx->opcode & (1 <<6 )) { -check_cop1x (ctx); -check_cp1_registers (ctx, fs | ft); -gen_cmpabs_d (func-48 , fp0, fp1, cc); - opn = condnames_abs[func-48 ]; - }else { -check_cp1_registers (ctx, fs | ft); -gen_cmp_d (func-48 , fp0, fp1, cc); - opn = condnames[func-48 ]; - } -tcg_temp_free_i64 (fp0); -tcg_temp_free_i64 (fp1); +if (ctx->opcode & (1 <<6 )) { +gen_cmpabs_d (ctx, func-48 , ft, fs, cc); + opn = condnames_abs[func-48 ]; + }else { +gen_cmp_d (ctx, func-48 , ft, fs, cc); + opn = condnames[func-48 ]; }break ;case OPC_CVT_S_D :
@@ -7280,22 +7288,12 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,case OPC_CMP_NGE_PS :case OPC_CMP_LE_PS :case OPC_CMP_NGT_PS : -check_cp1_64bitmode (ctx); - { -TCGv_i64 fp0 =tcg_temp_new_i64 (); -TCGv_i64 fp1 =tcg_temp_new_i64 (); - -gen_load_fpr64 (ctx, fp0, fs); -gen_load_fpr64 (ctx, fp1, ft); -if (ctx->opcode & (1 <<6 )) { -gen_cmpabs_ps (func-48 , fp0, fp1, cc); - opn = condnames_abs[func-48 ]; - }else { -gen_cmp_ps (func-48 , fp0, fp1, cc); - opn = condnames[func-48 ]; - } -tcg_temp_free_i64 (fp0); -tcg_temp_free_i64 (fp1); +if (ctx->opcode & (1 <<6 )) { +gen_cmpabs_ps (ctx, func-48 , ft, fs, cc); + opn = condnames_abs[func-48 ]; + }else { +gen_cmp_ps (ctx, func-48 , ft, fs, cc); + opn = condnames[func-48 ]; }break ;default :
Signature · 1 line
1.6.3.2
PATCH 8/8 hw: honor low bit in mipssim machine
In reply to Nathan Froyd--- hw/mips_mipssim.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
hw/mips_mipssim.c +4 -1
@@ -106,7 +106,10 @@ static void main_cpu_reset(void *opaque)CPUState *env = s->env;cpu_reset (env); - env->active_tc.PC = s->vector; + env->active_tc.PC = s->vector & ~(target_ulong )1 ; +if (s->vector &1 ) { + env->hflags |=MIPS_HFLAG_M16 ; + } } static void
Signature · 1 line
1.6.3.2
PATCH 3/8 target-mips: mips16 cleanups
In reply to Nathan FroydChange code handling mips16-specific branches to use ISA-neutral special opcodes. Since there are several places where the delay slot requirements for microMIPS branches differ from mips16 branches, using opcodes is easier than checking hflags, then checking mips16 vs. microMIPS.
--- target-mips/translate.c | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-)
target-mips/translate.c +17 -7
@@ -68,6 +68,7 @@ enum {/* Jump and branches */ OPC_J = (0x02 <<26 ),OPC_JAL = (0x03 <<26 ), +OPC_JALS =OPC_JAL |0x5 ,OPC_BEQ = (0x04 <<26 ),/* Unconditional if rs = rt = 0 (B) */ OPC_BEQL = (0x14 <<26 ), OPC_BNE = (0x05 << 26),
@@ -77,6 +78,7 @@ enum {OPC_BGTZ = (0x07 <<26 ),OPC_BGTZL = (0x17 <<26 ),OPC_JALX = (0x1D <<26 ),/* MIPS 16 only */ +OPC_JALXS =OPC_JALX |0x5 ,/* Load and stores */ OPC_LDL = (0x1A <<26 ), OPC_LDR = (0x1B << 26),
@@ -177,6 +179,7 @@ enum {OPC_JR =0x08 |OPC_SPECIAL ,/* Also JR.HB */ OPC_JALR =0x09 |OPC_SPECIAL ,/* Also JALR.HB */ OPC_JALRC =OPC_JALR | (0x5 <<6 ), +OPC_JALRS =0x10 |OPC_SPECIAL | (0x5 <<6 ),/* Traps */ OPC_TGE =0x30 |OPC_SPECIAL , OPC_TGEU = 0x31 | OPC_SPECIAL,
@@ -2466,12 +2469,15 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,case OPC_J :case OPC_JAL :case OPC_JALX : +case OPC_JALS : +case OPC_JALXS :/* Jump to immediate */ btgt = ((ctx->pc + insn_bytes) & (int32_t )0xF0000000 ) | (uint32_t )offset;break ;case OPC_JR :case OPC_JALR :case OPC_JALRC : +case OPC_JALRS :/* Jump to register */ if (offset !=0 && offset !=16 ) {/* Hint = 0 is JR/JALR, hint 16 is JR.HB/JALR.HB, the
@@ -2534,29 +2540,33 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, ctx->hflags |=MIPS_HFLAG_B ;MIPS_DEBUG ("j " TARGET_FMT_lx, btgt);break ; +case OPC_JALXS :case OPC_JALX : ctx->hflags |=MIPS_HFLAG_BX ;/* Fallthrough */ +case OPC_JALS :case OPC_JAL : blink =31 ; ctx->hflags |=MIPS_HFLAG_B ; - ctx->hflags |= (ctx->hflags &MIPS_HFLAG_M16 + ctx->hflags |= ((opc ==OPC_JALS || opc ==OPC_JALXS ) ?MIPS_HFLAG_BDS16 :MIPS_HFLAG_BDS32 );MIPS_DEBUG ("jal " TARGET_FMT_lx, btgt);break ;case OPC_JR : ctx->hflags |=MIPS_HFLAG_BR ; -if (ctx->hflags &MIPS_HFLAG_M16 ) - ctx->hflags |=MIPS_HFLAG_BDS16 ; +if (insn_bytes ==4 ) + ctx->hflags |=MIPS_HFLAG_BDS32 ;MIPS_DEBUG ("jr %s" , regnames[rs]);break ; +case OPC_JALRS :case OPC_JALR :case OPC_JALRC : blink = rt; ctx->hflags |=MIPS_HFLAG_BR ; -if (ctx->hflags &MIPS_HFLAG_M16 ) - ctx->hflags |=MIPS_HFLAG_BDS16 ; + ctx->hflags |= (opc ==OPC_JALRS + ?MIPS_HFLAG_BDS16 + :MIPS_HFLAG_BDS32 );MIPS_DEBUG ("jalr %s, %s" , regnames[rt], regnames[rs]);break ;default :
@@ -8487,7 +8497,7 @@ static int decode_mips16_opc (CPUState *env, DisasContext *ctx, offset = (((ctx->opcode &0x1f ) <<21 ) | ((ctx->opcode >>5 ) &0x1f ) <<16 | offset) <<2 ; - op = ((ctx->opcode >>10 ) &0x1 ) ?OPC_JALX :OPC_JAL ; + op = ((ctx->opcode >>10 ) &0x1 ) ?OPC_JALXS :OPC_JALS ;gen_compute_branch (ctx, op,4 , rx, ry, offset); n_bytes =4 ; *is_branch =1 ;
@@ -8726,7 +8736,7 @@ static int decode_mips16_opc (CPUState *env, DisasContext *ctx,int ra = (ctx->opcode >>5 ) &0x1 ;if (link) { - op = nd ?OPC_JALRC :OPC_JALR ; + op = nd ?OPC_JALRC :OPC_JALRS ; }else { op =OPC_JR ; }
Signature · 1 line
1.6.3.2
PATCH 1/8 target-mips: define constants for magic numbers
In reply to Nathan FroydAdd FMT_* constants for the floating-point format field in opcodes and tweak a few places to use them. Add enums for various invocations of FOP and tweak gen_farith and its lone caller accordingly.
--- target-mips/translate.c | 437 ++++++++++++++++++++++++++++++++--------------- 1 files changed, 295 insertions(+), 142 deletions(-)
target-mips/translate.c +295 -142
@@ -354,6 +354,19 @@ enum {/* Coprocessor 1 (rs field) */ #define MASK_CP1 (op) MASK_OP_MAJOR(op) | (op & (0x1F << 21)) +/* Values for the fmt field in FP instructions */ +enum { +/* 0 - 15 are reserved */ +FMT_S =16 , +FMT_D =17 , +FMT_E =18 , +FMT_Q =19 , +FMT_W =20 , +FMT_L =21 , +FMT_PS =22 , +/* 23 - 31 are reserved */ +}; +enum {OPC_MFC1 = (0x00 <<21 ) |OPC_CP1 ,OPC_DMFC1 = (0x01 <<21 ) |OPC_CP1 ,
@@ -366,13 +379,13 @@ enum {OPC_BC1 = (0x08 <<21 ) |OPC_CP1 ,/* bc */ OPC_BC1ANY2 = (0x09 <<21 ) |OPC_CP1 ,OPC_BC1ANY4 = (0x0A <<21 ) |OPC_CP1 , -OPC_S_FMT = (0x10 <<21 ) |OPC_CP1 ,/* 16: fmt=single fp */ -OPC_D_FMT = (0x11 <<21 ) |OPC_CP1 ,/* 17: fmt=double fp */ -OPC_E_FMT = (0x12 <<21 ) |OPC_CP1 ,/* 18: fmt=extended fp */ -OPC_Q_FMT = (0x13 <<21 ) |OPC_CP1 ,/* 19: fmt=quad fp */ -OPC_W_FMT = (0x14 <<21 ) |OPC_CP1 ,/* 20: fmt=32bit fixed */ -OPC_L_FMT = (0x15 <<21 ) |OPC_CP1 ,/* 21: fmt=64bit fixed */ - OPC_PS_FMT = (0x16 << 21) | OPC_CP1, /* 22: fmt=paired single fp */ +OPC_S_FMT = (FMT_S <<21 ) |OPC_CP1 ,/* 16: fmt=single fp */ +OPC_D_FMT = (FMT_D <<21 ) |OPC_CP1 ,/* 17: fmt=double fp */ +OPC_E_FMT = (FMT_E <<21 ) |OPC_CP1 ,/* 18: fmt=extended fp */ +OPC_Q_FMT = (FMT_Q <<21 ) |OPC_CP1 ,/* 19: fmt=quad fp */ +OPC_W_FMT = (FMT_W <<21 ) |OPC_CP1 ,/* 20: fmt=32bit fixed */ +OPC_L_FMT = (FMT_L <<21 ) |OPC_CP1 ,/* 21: fmt=64bit fixed */ + OPC_PS_FMT = (FMT_PS << 21) | OPC_CP1, /* 22: fmt=paired single fp */ };#define MASK_CP1_FUNC (op) MASK_CP1(op) | (op & 0x3F)
@@ -5714,6 +5727,146 @@ static void gen_compute_branch1 (CPUState *env, DisasContext *ctx, uint32_t op,#define FOP (func, fmt) (((fmt) << 21) | (func)) +enum fopcode { +OPC_ADD_S =FOP (0 ,FMT_S ), +OPC_SUB_S =FOP (1 ,FMT_S ), +OPC_MUL_S =FOP (2 ,FMT_S ), +OPC_DIV_S =FOP (3 ,FMT_S ), +OPC_SQRT_S =FOP (4 ,FMT_S ), +OPC_ABS_S =FOP (5 ,FMT_S ), +OPC_MOV_S =FOP (6 ,FMT_S ), +OPC_NEG_S =FOP (7 ,FMT_S ), +OPC_ROUND_L_S =FOP (8 ,FMT_S ), +OPC_TRUNC_L_S =FOP (9 ,FMT_S ), +OPC_CEIL_L_S =FOP (10 ,FMT_S ), +OPC_FLOOR_L_S =FOP (11 ,FMT_S ), +OPC_ROUND_W_S =FOP (12 ,FMT_S ), +OPC_TRUNC_W_S =FOP (13 ,FMT_S ), +OPC_CEIL_W_S =FOP (14 ,FMT_S ), +OPC_FLOOR_W_S =FOP (15 ,FMT_S ), +OPC_MOVCF_S =FOP (17 ,FMT_S ), +OPC_MOVZ_S =FOP (18 ,FMT_S ), +OPC_MOVN_S =FOP (19 ,FMT_S ), +OPC_RECIP_S =FOP (21 ,FMT_S ), +OPC_RSQRT_S =FOP (22 ,FMT_S ), +OPC_RECIP2_S =FOP (28 ,FMT_S ), +OPC_RECIP1_S =FOP (29 ,FMT_S ), +OPC_RSQRT1_S =FOP (30 ,FMT_S ), +OPC_RSQRT2_S =FOP (31 ,FMT_S ), +OPC_CVT_D_S =FOP (33 ,FMT_S ), +OPC_CVT_W_S =FOP (36 ,FMT_S ), +OPC_CVT_L_S =FOP (37 ,FMT_S ), +OPC_CVT_PS_S =FOP (38 ,FMT_S ), +OPC_CMP_F_S =FOP (48 ,FMT_S ), +OPC_CMP_UN_S =FOP (49 ,FMT_S ), +OPC_CMP_EQ_S =FOP (50 ,FMT_S ), +OPC_CMP_UEQ_S =FOP (51 ,FMT_S ), +OPC_CMP_OLT_S =FOP (52 ,FMT_S ), +OPC_CMP_ULT_S =FOP (53 ,FMT_S ), +OPC_CMP_OLE_S =FOP (54 ,FMT_S ), +OPC_CMP_ULE_S =FOP (55 ,FMT_S ), +OPC_CMP_SF_S =FOP (56 ,FMT_S ), +OPC_CMP_NGLE_S =FOP (57 ,FMT_S ), +OPC_CMP_SEQ_S =FOP (58 ,FMT_S ), +OPC_CMP_NGL_S =FOP (59 ,FMT_S ), +OPC_CMP_LT_S =FOP (60 ,FMT_S ), +OPC_CMP_NGE_S =FOP (61 ,FMT_S ), +OPC_CMP_LE_S =FOP (62 ,FMT_S ), +OPC_CMP_NGT_S =FOP (63 ,FMT_S ), + +OPC_ADD_D =FOP (0 ,FMT_D ), +OPC_SUB_D =FOP (1 ,FMT_D ), +OPC_MUL_D =FOP (2 ,FMT_D ), +OPC_DIV_D =FOP (3 ,FMT_D ), +OPC_SQRT_D =FOP (4 ,FMT_D ), +OPC_ABS_D =FOP (5 ,FMT_D ), +OPC_MOV_D =FOP (6 ,FMT_D ), +OPC_NEG_D =FOP (7 ,FMT_D ), +OPC_ROUND_L_D =FOP (8 ,FMT_D ), +OPC_TRUNC_L_D =FOP (9 ,FMT_D ), +OPC_CEIL_L_D =FOP (10 ,FMT_D ), +OPC_FLOOR_L_D =FOP (11 ,FMT_D ), +OPC_ROUND_W_D =FOP (12 ,FMT_D ), +OPC_TRUNC_W_D =FOP (13 ,FMT_D ), +OPC_CEIL_W_D =FOP (14 ,FMT_D ), +OPC_FLOOR_W_D =FOP (15 ,FMT_D ), +OPC_MOVCF_D =FOP (17 ,FMT_D ), +OPC_MOVZ_D =FOP (18 ,FMT_D ), +OPC_MOVN_D =FOP (19 ,FMT_D ), +OPC_RECIP_D =FOP (21 ,FMT_D ), +OPC_RSQRT_D =FOP (22 ,FMT_D ), +OPC_RECIP2_D =FOP (28 ,FMT_D ), +OPC_RECIP1_D =FOP (29 ,FMT_D ), +OPC_RSQRT1_D =FOP (30 ,FMT_D ), +OPC_RSQRT2_D =FOP (31 ,FMT_D ), +OPC_CVT_S_D =FOP (32 ,FMT_D ), +OPC_CVT_W_D =FOP (36 ,FMT_D ), +OPC_CVT_L_D =FOP (37 ,FMT_D ), +OPC_CMP_F_D =FOP (48 ,FMT_D ), +OPC_CMP_UN_D =FOP (49 ,FMT_D ), +OPC_CMP_EQ_D =FOP (50 ,FMT_D ), +OPC_CMP_UEQ_D =FOP (51 ,FMT_D ), +OPC_CMP_OLT_D =FOP (52 ,FMT_D ), +OPC_CMP_ULT_D =FOP (53 ,FMT_D ), +OPC_CMP_OLE_D =FOP (54 ,FMT_D ), +OPC_CMP_ULE_D =FOP (55 ,FMT_D ), +OPC_CMP_SF_D =FOP (56 ,FMT_D ), +OPC_CMP_NGLE_D =FOP (57 ,FMT_D ), +OPC_CMP_SEQ_D =FOP (58 ,FMT_D ), +OPC_CMP_NGL_D =FOP (59 ,FMT_D ), +OPC_CMP_LT_D =FOP (60 ,FMT_D ), +OPC_CMP_NGE_D =FOP (61 ,FMT_D ), +OPC_CMP_LE_D =FOP (62 ,FMT_D ), +OPC_CMP_NGT_D =FOP (63 ,FMT_D ), + +OPC_CVT_S_W =FOP (32 ,FMT_W ), +OPC_CVT_D_W =FOP (33 ,FMT_W ), +OPC_CVT_S_L =FOP (32 ,FMT_L ), +OPC_CVT_D_L =FOP (33 ,FMT_L ), +OPC_CVT_PS_PW =FOP (38 ,FMT_W ), + +OPC_ADD_PS =FOP (0 ,FMT_PS ), +OPC_SUB_PS =FOP (1 ,FMT_PS ), +OPC_MUL_PS =FOP (2 ,FMT_PS ), +OPC_DIV_PS =FOP (3 ,FMT_PS ), +OPC_ABS_PS =FOP (5 ,FMT_PS ), +OPC_MOV_PS =FOP (6 ,FMT_PS ), +OPC_NEG_PS =FOP (7 ,FMT_PS ), +OPC_MOVCF_PS =FOP (17 ,FMT_PS ), +OPC_MOVZ_PS =FOP (18 ,FMT_PS ), +OPC_MOVN_PS =FOP (19 ,FMT_PS ), +OPC_ADDR_PS =FOP (24 ,FMT_PS ), +OPC_MULR_PS =FOP (26 ,FMT_PS ), +OPC_RECIP2_PS =FOP (28 ,FMT_PS ), +OPC_RECIP1_PS =FOP (29 ,FMT_PS ), +OPC_RSQRT1_PS =FOP (30 ,FMT_PS ), +OPC_RSQRT2_PS =FOP (31 ,FMT_PS ), + +OPC_CVT_S_PU =FOP (32 ,FMT_PS ), +OPC_CVT_PW_PS =FOP (36 ,FMT_PS ), +OPC_CVT_S_PL =FOP (40 ,FMT_PS ), +OPC_PLL_PS =FOP (44 ,FMT_PS ), +OPC_PLU_PS =FOP (45 ,FMT_PS ), +OPC_PUL_PS =FOP (46 ,FMT_PS ), +OPC_PUU_PS =FOP (47 ,FMT_PS ), +OPC_CMP_F_PS =FOP (48 ,FMT_PS ), +OPC_CMP_UN_PS =FOP (49 ,FMT_PS ), +OPC_CMP_EQ_PS =FOP (50 ,FMT_PS ), +OPC_CMP_UEQ_PS =FOP (51 ,FMT_PS ), +OPC_CMP_OLT_PS =FOP (52 ,FMT_PS ), +OPC_CMP_ULT_PS =FOP (53 ,FMT_PS ), +OPC_CMP_OLE_PS =FOP (54 ,FMT_PS ), +OPC_CMP_ULE_PS =FOP (55 ,FMT_PS ), +OPC_CMP_SF_PS =FOP (56 ,FMT_PS ), +OPC_CMP_NGLE_PS =FOP (57 ,FMT_PS ), +OPC_CMP_SEQ_PS =FOP (58 ,FMT_PS ), +OPC_CMP_NGL_PS =FOP (59 ,FMT_PS ), +OPC_CMP_LT_PS =FOP (60 ,FMT_PS ), +OPC_CMP_NGE_PS =FOP (61 ,FMT_PS ), +OPC_CMP_LE_PS =FOP (62 ,FMT_PS ), +OPC_CMP_NGT_PS =FOP (63 ,FMT_PS ), +}; +static void gen_cp1 (DisasContext *ctx,uint32_t opc,int rt,int fs) {const char *opn ="cp1 move" ;
@@ -5894,7 +6047,7 @@ static inline void gen_movcf_ps (int fs, int fd, int cc, int tf) } -static void gen_farith (DisasContext *ctx,uint32_t op1, +static void gen_farith (DisasContext *ctx,enum fopcode op1,int ft,int fs,int fd,int cc) {const char *opn ="farith" ;
@@ -5937,8 +6090,8 @@ static void gen_farith (DisasContext *ctx, uint32_t op1,enum {BINOP ,CMPOP ,OTHEROP } optype =OTHEROP ;uint32_t func = ctx->opcode &0x3f ; -switch (ctx->opcode &FOP (0x3f ,0x1f )) { -case FOP (0 ,16 ): +switch (op1) { +case OPC_ADD_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();TCGv_i32 fp1 =tcg_temp_new_i32 ();
@@ -5953,7 +6106,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, opn ="add.s" ; optype =BINOP ;break ; -case FOP (1 ,16 ): +case OPC_SUB_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();TCGv_i32 fp1 =tcg_temp_new_i32 ();
@@ -5968,7 +6121,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, opn ="sub.s" ; optype =BINOP ;break ; -case FOP (2 ,16 ): +case OPC_MUL_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();TCGv_i32 fp1 =tcg_temp_new_i32 ();
@@ -5983,7 +6136,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, opn ="mul.s" ; optype =BINOP ;break ; -case FOP (3 ,16 ): +case OPC_DIV_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();TCGv_i32 fp1 =tcg_temp_new_i32 ();
@@ -5998,7 +6151,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, opn ="div.s" ; optype =BINOP ;break ; -case FOP (4 ,16 ): +case OPC_SQRT_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6009,7 +6162,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="sqrt.s" ;break ; -case FOP (5 ,16 ): +case OPC_ABS_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6020,7 +6173,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="abs.s" ;break ; -case FOP (6 ,16 ): +case OPC_MOV_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6030,7 +6183,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="mov.s" ;break ; -case FOP (7 ,16 ): +case OPC_NEG_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6041,7 +6194,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="neg.s" ;break ; -case FOP (8 ,16 ): +case OPC_ROUND_L_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6055,7 +6208,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="round.l.s" ;break ; -case FOP (9 ,16 ): +case OPC_TRUNC_L_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6069,7 +6222,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="trunc.l.s" ;break ; -case FOP (10 ,16 ): +case OPC_CEIL_L_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6083,7 +6236,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="ceil.l.s" ;break ; -case FOP (11 ,16 ): +case OPC_FLOOR_L_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6097,7 +6250,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="floor.l.s" ;break ; -case FOP (12 ,16 ): +case OPC_ROUND_W_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6108,7 +6261,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="round.w.s" ;break ; -case FOP (13 ,16 ): +case OPC_TRUNC_W_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6119,7 +6272,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="trunc.w.s" ;break ; -case FOP (14 ,16 ): +case OPC_CEIL_W_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6130,7 +6283,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="ceil.w.s" ;break ; -case FOP (15 ,16 ): +case OPC_FLOOR_W_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6141,11 +6294,11 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="floor.w.s" ;break ; -case FOP (17 ,16 ): +case OPC_MOVCF_S :gen_movcf_s (fs, fd, (ft >>2 ) &0x7 , ft &0x1 ); opn ="movcf.s" ;break ; -case FOP (18 ,16 ): +case OPC_MOVZ_S : {int l1 =gen_new_label ();TCGv_i32 fp0;
@@ -6161,7 +6314,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="movz.s" ;break ; -case FOP (19 ,16 ): +case OPC_MOVN_S : {int l1 =gen_new_label ();TCGv_i32 fp0;
@@ -6177,7 +6330,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="movn.s" ;break ; -case FOP (21 ,16 ): +case OPC_RECIP_S :check_cop1x (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6189,7 +6342,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="recip.s" ;break ; -case FOP (22 ,16 ): +case OPC_RSQRT_S :check_cop1x (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6201,7 +6354,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="rsqrt.s" ;break ; -case FOP (28 ,16 ): +case OPC_RECIP2_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6216,7 +6369,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="recip2.s" ;break ; -case FOP (29 ,16 ): +case OPC_RECIP1_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6228,7 +6381,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="recip1.s" ;break ; -case FOP (30 ,16 ): +case OPC_RSQRT1_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6240,7 +6393,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="rsqrt1.s" ;break ; -case FOP (31 ,16 ): +case OPC_RSQRT2_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6255,7 +6408,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="rsqrt2.s" ;break ; -case FOP (33 ,16 ): +case OPC_CVT_D_S :check_cp1_registers (ctx, fd); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6269,7 +6422,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.d.s" ;break ; -case FOP (36 ,16 ): +case OPC_CVT_W_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6280,7 +6433,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.w.s" ;break ; -case FOP (37 ,16 ): +case OPC_CVT_L_S :check_cp1_64bitmode (ctx); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6294,7 +6447,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.l.s" ;break ; -case FOP (38 ,16 ): +case OPC_CVT_PS_S :check_cp1_64bitmode (ctx); {TCGv_i64 fp64 =tcg_temp_new_i64 ();
@@ -6311,22 +6464,22 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.ps.s" ;break ; -case FOP (48 ,16 ): -case FOP (49 ,16 ): -case FOP (50 ,16 ): -case FOP (51 ,16 ): -case FOP (52 ,16 ): -case FOP (53 ,16 ): -case FOP (54 ,16 ): -case FOP (55 ,16 ): -case FOP (56 ,16 ): -case FOP (57 ,16 ): -case FOP (58 ,16 ): -case FOP (59 ,16 ): -case FOP (60 ,16 ): -case FOP (61 ,16 ): -case FOP (62 ,16 ): -case FOP (63 ,16 ): +case OPC_CMP_F_S : +case OPC_CMP_UN_S : +case OPC_CMP_EQ_S : +case OPC_CMP_UEQ_S : +case OPC_CMP_OLT_S : +case OPC_CMP_ULT_S : +case OPC_CMP_OLE_S : +case OPC_CMP_ULE_S : +case OPC_CMP_SF_S : +case OPC_CMP_NGLE_S : +case OPC_CMP_SEQ_S : +case OPC_CMP_NGL_S : +case OPC_CMP_LT_S : +case OPC_CMP_NGE_S : +case OPC_CMP_LE_S : +case OPC_CMP_NGT_S : {TCGv_i32 fp0 =tcg_temp_new_i32 ();TCGv_i32 fp1 =tcg_temp_new_i32 ();
@@ -6345,7 +6498,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1,tcg_temp_free_i32 (fp1); }break ; -case FOP (0 ,17 ): +case OPC_ADD_D :check_cp1_registers (ctx, fs | ft | fd); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6361,7 +6514,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, opn ="add.d" ; optype =BINOP ;break ; -case FOP (1 ,17 ): +case OPC_SUB_D :check_cp1_registers (ctx, fs | ft | fd); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6377,7 +6530,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, opn ="sub.d" ; optype =BINOP ;break ; -case FOP (2 ,17 ): +case OPC_MUL_D :check_cp1_registers (ctx, fs | ft | fd); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6393,7 +6546,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, opn ="mul.d" ; optype =BINOP ;break ; -case FOP (3 ,17 ): +case OPC_DIV_D :check_cp1_registers (ctx, fs | ft | fd); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6409,7 +6562,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, opn ="div.d" ; optype =BINOP ;break ; -case FOP (4 ,17 ): +case OPC_SQRT_D :check_cp1_registers (ctx, fs | fd); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6421,7 +6574,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="sqrt.d" ;break ; -case FOP (5 ,17 ): +case OPC_ABS_D :check_cp1_registers (ctx, fs | fd); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6433,7 +6586,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="abs.d" ;break ; -case FOP (6 ,17 ): +case OPC_MOV_D :check_cp1_registers (ctx, fs | fd); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6444,7 +6597,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="mov.d" ;break ; -case FOP (7 ,17 ): +case OPC_NEG_D :check_cp1_registers (ctx, fs | fd); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6456,7 +6609,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="neg.d" ;break ; -case FOP (8 ,17 ): +case OPC_ROUND_L_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6468,7 +6621,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="round.l.d" ;break ; -case FOP (9 ,17 ): +case OPC_TRUNC_L_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6480,7 +6633,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="trunc.l.d" ;break ; -case FOP (10 ,17 ): +case OPC_CEIL_L_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6492,7 +6645,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="ceil.l.d" ;break ; -case FOP (11 ,17 ): +case OPC_FLOOR_L_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6504,7 +6657,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="floor.l.d" ;break ; -case FOP (12 ,17 ): +case OPC_ROUND_W_D :check_cp1_registers (ctx, fs); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6518,7 +6671,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="round.w.d" ;break ; -case FOP (13 ,17 ): +case OPC_TRUNC_W_D :check_cp1_registers (ctx, fs); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6532,7 +6685,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="trunc.w.d" ;break ; -case FOP (14 ,17 ): +case OPC_CEIL_W_D :check_cp1_registers (ctx, fs); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6546,7 +6699,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="ceil.w.d" ;break ; -case FOP (15 ,17 ): +case OPC_FLOOR_W_D :check_cp1_registers (ctx, fs); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6560,11 +6713,11 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="floor.w.d" ;break ; -case FOP (17 ,17 ): +case OPC_MOVCF_D :gen_movcf_d (ctx, fs, fd, (ft >>2 ) &0x7 , ft &0x1 ); opn ="movcf.d" ;break ; -case FOP (18 ,17 ): +case OPC_MOVZ_D : {int l1 =gen_new_label ();TCGv_i64 fp0;
@@ -6580,7 +6733,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="movz.d" ;break ; -case FOP (19 ,17 ): +case OPC_MOVN_D : {int l1 =gen_new_label ();TCGv_i64 fp0;
@@ -6596,7 +6749,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="movn.d" ;break ; -case FOP (21 ,17 ): +case OPC_RECIP_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6608,7 +6761,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="recip.d" ;break ; -case FOP (22 ,17 ): +case OPC_RSQRT_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6620,7 +6773,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="rsqrt.d" ;break ; -case FOP (28 ,17 ): +case OPC_RECIP2_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6635,7 +6788,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="recip2.d" ;break ; -case FOP (29 ,17 ): +case OPC_RECIP1_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6647,7 +6800,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="recip1.d" ;break ; -case FOP (30 ,17 ): +case OPC_RSQRT1_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6659,7 +6812,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="rsqrt1.d" ;break ; -case FOP (31 ,17 ): +case OPC_RSQRT2_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6674,22 +6827,22 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="rsqrt2.d" ;break ; -case FOP (48 ,17 ): -case FOP (49 ,17 ): -case FOP (50 ,17 ): -case FOP (51 ,17 ): -case FOP (52 ,17 ): -case FOP (53 ,17 ): -case FOP (54 ,17 ): -case FOP (55 ,17 ): -case FOP (56 ,17 ): -case FOP (57 ,17 ): -case FOP (58 ,17 ): -case FOP (59 ,17 ): -case FOP (60 ,17 ): -case FOP (61 ,17 ): -case FOP (62 ,17 ): -case FOP (63 ,17 ): +case OPC_CMP_F_D : +case OPC_CMP_UN_D : +case OPC_CMP_EQ_D : +case OPC_CMP_UEQ_D : +case OPC_CMP_OLT_D : +case OPC_CMP_ULT_D : +case OPC_CMP_OLE_D : +case OPC_CMP_ULE_D : +case OPC_CMP_SF_D : +case OPC_CMP_NGLE_D : +case OPC_CMP_SEQ_D : +case OPC_CMP_NGL_D : +case OPC_CMP_LT_D : +case OPC_CMP_NGE_D : +case OPC_CMP_LE_D : +case OPC_CMP_NGT_D : {TCGv_i64 fp0 =tcg_temp_new_i64 ();TCGv_i64 fp1 =tcg_temp_new_i64 ();
@@ -6710,7 +6863,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1,tcg_temp_free_i64 (fp1); }break ; -case FOP (32 ,17 ): +case OPC_CVT_S_D :check_cp1_registers (ctx, fs); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6724,7 +6877,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.s.d" ;break ; -case FOP (36 ,17 ): +case OPC_CVT_W_D :check_cp1_registers (ctx, fs); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6738,7 +6891,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.w.d" ;break ; -case FOP (37 ,17 ): +case OPC_CVT_L_D :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6750,7 +6903,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.l.d" ;break ; -case FOP (32 ,20 ): +case OPC_CVT_S_W : {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -6761,7 +6914,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.s.w" ;break ; -case FOP (33 ,20 ): +case OPC_CVT_D_W :check_cp1_registers (ctx, fd); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6775,7 +6928,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.d.w" ;break ; -case FOP (32 ,21 ): +case OPC_CVT_S_L :check_cp1_64bitmode (ctx); {TCGv_i32 fp32 =tcg_temp_new_i32 ();
@@ -6789,7 +6942,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.s.l" ;break ; -case FOP (33 ,21 ): +case OPC_CVT_D_L :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6801,7 +6954,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.d.l" ;break ; -case FOP (38 ,20 ): +case OPC_CVT_PS_PW :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6813,7 +6966,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.ps.pw" ;break ; -case FOP (0 ,22 ): +case OPC_ADD_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6828,7 +6981,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="add.ps" ;break ; -case FOP (1 ,22 ): +case OPC_SUB_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6843,7 +6996,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="sub.ps" ;break ; -case FOP (2 ,22 ): +case OPC_MUL_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6858,7 +7011,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="mul.ps" ;break ; -case FOP (5 ,22 ): +case OPC_ABS_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6870,7 +7023,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="abs.ps" ;break ; -case FOP (6 ,22 ): +case OPC_MOV_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6881,7 +7034,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="mov.ps" ;break ; -case FOP (7 ,22 ): +case OPC_NEG_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6893,12 +7046,12 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="neg.ps" ;break ; -case FOP (17 ,22 ): +case OPC_MOVCF_PS :check_cp1_64bitmode (ctx);gen_movcf_ps (fs, fd, (ft >>2 ) &0x7 , ft &0x1 ); opn ="movcf.ps" ;break ; -case FOP (18 ,22 ): +case OPC_MOVZ_PS :check_cp1_64bitmode (ctx); {int l1 =gen_new_label ();
@@ -6914,7 +7067,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="movz.ps" ;break ; -case FOP (19 ,22 ): +case OPC_MOVN_PS :check_cp1_64bitmode (ctx); {int l1 =gen_new_label ();
@@ -6931,7 +7084,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="movn.ps" ;break ; -case FOP (24 ,22 ): +case OPC_ADDR_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6946,7 +7099,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="addr.ps" ;break ; -case FOP (26 ,22 ): +case OPC_MULR_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6961,7 +7114,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="mulr.ps" ;break ; -case FOP (28 ,22 ): +case OPC_RECIP2_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6976,7 +7129,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="recip2.ps" ;break ; -case FOP (29 ,22 ): +case OPC_RECIP1_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -6988,7 +7141,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="recip1.ps" ;break ; -case FOP (30 ,22 ): +case OPC_RSQRT1_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -7000,7 +7153,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="rsqrt1.ps" ;break ; -case FOP (31 ,22 ): +case OPC_RSQRT2_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -7015,7 +7168,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="rsqrt2.ps" ;break ; -case FOP (32 ,22 ): +case OPC_CVT_S_PU :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -7027,7 +7180,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.s.pu" ;break ; -case FOP (36 ,22 ): +case OPC_CVT_PW_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -7039,7 +7192,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.pw.ps" ;break ; -case FOP (40 ,22 ): +case OPC_CVT_S_PL :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -7051,7 +7204,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="cvt.s.pl" ;break ; -case FOP (44 ,22 ): +case OPC_PLL_PS :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -7066,7 +7219,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="pll.ps" ;break ; -case FOP (45 ,22 ): +case OPC_PLU_PS :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -7081,7 +7234,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="plu.ps" ;break ; -case FOP (46 ,22 ): +case OPC_PUL_PS :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -7096,7 +7249,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="pul.ps" ;break ; -case FOP (47 ,22 ): +case OPC_PUU_PS :check_cp1_64bitmode (ctx); {TCGv_i32 fp0 =tcg_temp_new_i32 ();
@@ -7111,22 +7264,22 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, } opn ="puu.ps" ;break ; -case FOP (48 ,22 ): -case FOP (49 ,22 ): -case FOP (50 ,22 ): -case FOP (51 ,22 ): -case FOP (52 ,22 ): -case FOP (53 ,22 ): -case FOP (54 ,22 ): -case FOP (55 ,22 ): -case FOP (56 ,22 ): -case FOP (57 ,22 ): -case FOP (58 ,22 ): -case FOP (59 ,22 ): -case FOP (60 ,22 ): -case FOP (61 ,22 ): -case FOP (62 ,22 ): -case FOP (63 ,22 ): +case OPC_CMP_F_PS : +case OPC_CMP_UN_PS : +case OPC_CMP_EQ_PS : +case OPC_CMP_UEQ_PS : +case OPC_CMP_OLT_PS : +case OPC_CMP_ULT_PS : +case OPC_CMP_OLE_PS : +case OPC_CMP_ULE_PS : +case OPC_CMP_SF_PS : +case OPC_CMP_NGLE_PS : +case OPC_CMP_SEQ_PS : +case OPC_CMP_NGL_PS : +case OPC_CMP_LT_PS : +case OPC_CMP_NGE_PS : +case OPC_CMP_LE_PS : +case OPC_CMP_NGT_PS :check_cp1_64bitmode (ctx); {TCGv_i64 fp0 =tcg_temp_new_i64 ();
@@ -9298,7 +9451,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx, int *is_branch)case OPC_W_FMT :case OPC_L_FMT :case OPC_PS_FMT : -gen_farith (ctx,MASK_CP1_FUNC (ctx->opcode), rt, rd, sa, +gen_farith (ctx, ctx->opcode &FOP (0x3f ,0x1f ), rt, rd, sa, (imm >>8 ) &0x7 );break ;default :
Signature · 1 line
1.6.3.2
PATCH 5/8 target-mips: add microMIPS CPUs
In reply to Nathan Froyd--- target-mips/translate_init.c | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 61 insertions(+), 0 deletions(-)
target-mips/translate_init.c +61 -0
@@ -141,6 +141,25 @@ static const mips_def_t mips_defs[] = .mmu_type = MMU_TYPE_FMT, }, { + .name = "4Km-micromips", + .CP0_PRid = 0x00018300, +/* Config1 implemented, fixed mapping MMU, +no virtual icache, uncached coherency. */ + .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT), + .CP0_Config1 =MIPS_CONFIG1 | + (0 <<CP0C1_IS ) | (3 <<CP0C1_IL ) | (1 <<CP0C1_IA ) | + (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3, + .SYNCI_Step = 32, + .CCRes = 2, + .CP0_Status_rw_bitmask = 0x1258FF17, + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS, + .mmu_type = MMU_TYPE_FMT, + }, + { .name = "4KEcR1", .CP0_PRid = 0x00018400, .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),
@@ -245,6 +264,25 @@ static const mips_def_t mips_defs[] = .mmu_type = MMU_TYPE_R4000, }, { + .name = "24Kc-micromips", + .CP0_PRid = 0x00019300, + .CP0_Config0 =MIPS_CONFIG0 | (0x1 <<CP0C0_AR ) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 =MIPS_CONFIG1 | (15 <<CP0C1_MMU ) | + (0 <<CP0C1_IS ) | (3 <<CP0C1_IL ) | (1 <<CP0C1_IA ) | + (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt), + .SYNCI_Step = 32, + .CCRes = 2, +/* No DSP implemented. */ + .CP0_Status_rw_bitmask = 0x1278FF1F, + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS, + .mmu_type = MMU_TYPE_R4000, + }, + { .name = "24Kf", .CP0_PRid = 0x00019300, .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
@@ -269,6 +307,29 @@ static const mips_def_t mips_defs[] = .mmu_type = MMU_TYPE_R4000, }, { + .name = "24Kf-micromips", + .CP0_PRid = 0x00019300, + .CP0_Config0 =MIPS_CONFIG0 | (0x1 <<CP0C0_AR ) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 =MIPS_CONFIG1 | (1 <<CP0C1_FP ) | (15 <<CP0C1_MMU ) | + (0 <<CP0C1_IS ) | (3 <<CP0C1_IL ) | (1 <<CP0C1_IA ) | + (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt), + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 4, + .SYNCI_Step = 32, + .CCRes = 2, +/* No DSP implemented. */ + .CP0_Status_rw_bitmask = 0x3678FF1F, + .CP1_fcr0 = (1 <<FCR0_F64 ) | (1 <<FCR0_L ) | (1 <<FCR0_W ) | + (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS, + .mmu_type = MMU_TYPE_R4000, + }, + { .name = "34Kf", .CP0_PRid = 0x00019500, .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
Signature · 1 line
1.6.3.2
PATCH 6/8 target-mips: add microMIPS exception handler support
In reply to Nathan FroydUnlike MIPS16, microMIPS lets you choose the ISA mode for your exception handlers. The ISA mode is selectable via a user-writable CP0.Config3 flag.
--- target-mips/cpu.h | 1 + target-mips/helper.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-)
target-mips/cpu.h +1 -0
@@ -363,6 +363,7 @@ struct CPUMIPSState {#define CP0C2_SA 0int32_t CP0_Config3;#define CP0C3_M 31 +#define CP0C3_ISA_ON_EXC 16#define CP0C3_DSPP 10#define CP0C3_LPA 7#define CP0C3_VEIC 6
target-mips/helper.c +15 -6
@@ -385,6 +385,18 @@ static target_ulong exception_resume_pc (CPUState *env) return bad_pc; } + +static void set_hflags_for_handler (CPUState *env) +{ +/* Exception handlers are entered in 32-bit mode. */ + env->hflags &= ~(MIPS_HFLAG_M16 ); +/* ...except that microMIPS lets you choose. */ +if (env->insn_flags &ASE_MICROMIPS ) { + env->hflags |= (!!(env->CP0_Config3 + & (1 <<CP0C3_ISA_ON_EXC )) + <<MIPS_HFLAG_M16_SHIFT ); + } +}#endif void do_interrupt (CPUState *env)
@@ -440,8 +452,7 @@ void do_interrupt (CPUState *env)if (!(env->CP0_Status & (1 << CP0St_EXL))) env->CP0_Cause &= ~(1 << CP0Ca_BD); env->active_tc.PC = (int32_t )0xBFC00480 ; -/* Exception handlers are entered in 32-bit mode. */ - env->hflags &= ~(MIPS_HFLAG_M16 ); +set_hflags_for_handler (env);break ;case EXCP_RESET :cpu_reset (env);
@@ -461,8 +472,7 @@ void do_interrupt (CPUState *env)if (!(env->CP0_Status & (1 << CP0St_EXL))) env->CP0_Cause &= ~(1 << CP0Ca_BD); env->active_tc.PC = (int32_t )0xBFC00000 ; -/* Exception handlers are entered in 32-bit mode. */ - env->hflags &= ~(MIPS_HFLAG_M16 ); +set_hflags_for_handler (env);break ;case EXCP_EXT_INTERRUPT : cause =0 ;
@@ -581,8 +591,7 @@ void do_interrupt (CPUState *env) env->active_tc.PC = (int32_t )(env->CP0_EBase & ~0x3ff ); } env->active_tc.PC += offset; -/* Exception handlers are entered in 32-bit mode. */ - env->hflags &= ~(MIPS_HFLAG_M16 ); +set_hflags_for_handler (env); env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);break ;default :
Signature · 1 line
1.6.3.2
PATCH 4/8 target-mips: microMIPS ASE support
In reply to Nathan FroydAdd instruction decoding for the microMIPS ASE. All we do is decode and then forward to the existing gen_* routines.
--- target-mips/helper.h | 9 + target-mips/mips-defs.h | 1 + target-mips/op_helper.c | 136 +++ target-mips/translate.c | 2390 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 2531 insertions(+), 5 deletions(-)
target-mips/helper.h +9 -0
@@ -160,6 +160,15 @@ DEF_HELPER_1(emt, tl, tl) DEF_HELPER_1(dvpe, tl, tl) DEF_HELPER_1(evpe, tl, tl)#endif /* !CONFIG_USER_ONLY */ + +/* microMIPS functions */ +DEF_HELPER_3 (lwm, void, tl, tl, i32); +DEF_HELPER_3 (swm, void, tl, tl, i32); +#ifdef TARGET_MIPS64 +DEF_HELPER_3 (ldm, void, tl, tl, i32); +DEF_HELPER_3 (sdm, void, tl, tl, i32); +#endif + DEF_HELPER_2(fork, void, tl, tl)DEF_HELPER_1 (yield, tl, tl)
target-mips/mips-defs.h +1 -0
@@ -38,6 +38,7 @@#define ASE_DSPR2 0x00010000#define ASE_MT 0x00020000#define ASE_SMARTMIPS 0x00040000 +#define ASE_MICROMIPS 0x00080000/* Chip specific instructions. */ #define INSN_VR54XX 0x80000000
target-mips/op_helper.c +136 -0
142 lines not on this page · raw message
target-mips/translate.c +2385 -5
2,475 lines not on this page · raw message
Signature · 1 line
1.6.3.2
Re: [Qemu-devel] [PATCH 5/8] target-mips: add microMIPS CPUs
In reply to Nathan FroydQuoted 82 lines · Nathan Froyd
Signed-off-by Nathan Froyd <[email protected]>--- target-mips/translate_init.c | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 61 insertions(+), 0 deletions(-)target-mips/translate_init.c +54
-0@@ -141,6 +141,25 @@ static const mips_def_t mips_defs[] = .mmu_type = MMU_TYPE_FMT, }, { + .name = "4Km-micromips", + .CP0_PRid = 0x00018300, +/* Config1 implemented, fixed mapping MMU, +no virtual icache, uncached coherency. */ + .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT), + .CP0_Config1 =MIPS_CONFIG1 | + (0 <<CP0C1_IS ) | (3 <<CP0C1_IL ) | (1 <<CP0C1_IA ) | + (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3, + .SYNCI_Step = 32, + .CCRes = 2, + .CP0_Status_rw_bitmask = 0x1258FF17, + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS, + .mmu_type = MMU_TYPE_FMT, + }, + { .name = "4KEcR1", .CP0_PRid = 0x00018400, .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),@@ -245,6 +264,25 @@ static const mips_def_t mips_defs[] = .mmu_type = MMU_TYPE_R4000, }, { + .name = "24Kc-micromips", + .CP0_PRid = 0x00019300, + .CP0_Config0 =MIPS_CONFIG0 | (0x1 <<CP0C0_AR ) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 =MIPS_CONFIG1 | (15 <<CP0C1_MMU ) | + (0 <<CP0C1_IS ) | (3 <<CP0C1_IL ) | (1 <<CP0C1_IA ) | + (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt), + .SYNCI_Step = 32, + .CCRes = 2, +/* No DSP implemented. */ + .CP0_Status_rw_bitmask = 0x1278FF1F, + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS, + .mmu_type = MMU_TYPE_R4000, + }, + { .name = "24Kf", .CP0_PRid = 0x00019300, .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |@@ -269,6 +307,29 @@ static const mips_def_t mips_defs[] = .mmu_type = MMU_TYPE_R4000, }, { + .name = "24Kf-micromips", + .CP0_PRid = 0x00019300, + .CP0_Config0 =MIPS_CONFIG0 | (0x1 <<CP0C0_AR ) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 =MIPS_CONFIG1 | (1 <<CP0C1_FP ) | (15 <<CP0C1_MMU ) | + (0 <<CP0C1_IS ) | (3 <<CP0C1_IL ) | (1 <<CP0C1_IA ) | + (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt), + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 4, + .SYNCI_Step = 32, + .CCRes = 2, +/* No DSP implemented. */ + .CP0_Status_rw_bitmask = 0x3678FF1F, + .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
target-mips/translate_init.c static const mips_def_t mips_defs[] = · line 335
Quoted 10 lines
target-mips/translate_init.c +7
-0+ (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS, + .mmu_type = MMU_TYPE_R4000, + }, + { .name = "34Kf", .CP0_PRid = 0x00019500, .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
None of those CPU seems to be real CPU. According to the MIPS website (which BTW has very few details about microMIPS), the microMIPS ASE is implemented in the M14K core, which seems to be a 4K core with R2 and microMIPS support. Wouldn't it be better to add this one instead?
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 4/8] target-mips: microMIPS ASE support
In reply to Nathan FroydQuoted 180 lines · Nathan Froyd
Add instruction decoding for the microMIPS ASE. All we do is decode and then forward to the existing gen_* routines.
Signed-off-by Nathan Froyd <[email protected]>--- target-mips/helper.h | 9 + target-mips/mips-defs.h | 1 + target-mips/op_helper.c | 136 +++ target-mips/translate.c | 2390 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 2531 insertions(+), 5 deletions(-)target-mips/helper.h +9
-0@@ -160,6 +160,15 @@ DEF_HELPER_1(emt, tl, tl) DEF_HELPER_1(dvpe, tl, tl) DEF_HELPER_1(evpe, tl, tl)#endif /* !CONFIG_USER_ONLY */ + +/* microMIPS functions */ +DEF_HELPER_3 (lwm, void, tl, tl, i32); +DEF_HELPER_3 (swm, void, tl, tl, i32); +#ifdef TARGET_MIPS64 +DEF_HELPER_3 (ldm, void, tl, tl, i32); +DEF_HELPER_3 (sdm, void, tl, tl, i32); +#endif + DEF_HELPER_2(fork, void, tl, tl)DEF_HELPER_1 (yield, tl, tl)target-mips/mips-defs.h +1
-0@@ -38,6 +38,7 @@#define ASE_DSPR2 0x00010000#define ASE_MT 0x00020000#define ASE_SMARTMIPS 0x00040000 +#define ASE_MICROMIPS 0x00080000/* Chip specific instructions. */ #define INSN_VR54XX 0x80000000target-mips/op_helper.c +129
-0@@ -565,6 +565,142 @@ void helper_sdr(target_ulong arg1, target_ulong arg2, int mem_idx) }#endif /* TARGET_MIPS64 */ +static const int multiple_regs[] = {16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,30 }; + +void helper_lwm (target_ulong addr,target_ulong reglist,uint32_t mem_idx) +{ +target_ulong base_reglist = reglist &0xf ; +target_ulong do_r31 = reglist &0x10 ; +#ifdef CONFIG_USER_ONLY +#undef ldfun +#define ldfun ldl_raw +#else +uint32_t (*ldfun)(target_ulong ); + +switch (mem_idx) + { +case 0 : ldfun = ldl_kernel;break ; +case 1 : ldfun = ldl_super;break ; +default : +case 2 : ldfun = ldl_user;break ; + } +#endif + +if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) { +target_ulong i; + +for (i =0 ; i < base_reglist; i++) { + env->active_tc.gpr[multiple_regs[i]] = (target_long )ldfun (addr); + addr +=4 ; + } + } + +if (do_r31) { + env->active_tc.gpr[31 ] = (target_long )ldfun (addr); + } +} + +void helper_swm (target_ulong addr,target_ulong reglist,uint32_t mem_idx) +{ +target_ulong base_reglist = reglist &0xf ; +target_ulong do_r31 = reglist &0x10 ; +#ifdef CONFIG_USER_ONLY +#undef stfun +#define stfun stl_raw +#else +void (*stfun)(target_ulong ,uint32_t ); + +switch (mem_idx) + { +case 0 : stfun = stl_kernel;break ; +case 1 : stfun = stl_super;break ; +default : +case 2 : stfun = stl_user;break ; + } +#endif + +if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) { +target_ulong i; + +for (i =0 ; i < base_reglist; i++) { +stfun (addr, env->active_tc.gpr[multiple_regs[i]]); + addr +=4 ; + } + } + +if (do_r31) { +stfun (addr, env->active_tc.gpr[31 ]); + } +} + +#if defined(TARGET_MIPS64 ) +void helper_ldm (target_ulong addr,target_ulong reglist,uint32_t mem_idx) +{ +target_ulong base_reglist = reglist &0xf ; +target_ulong do_r31 = reglist &0x10 ; +#ifdef CONFIG_USER_ONLY +#undef ldfun +#define ldfun ldq_raw +#else +uint64_t (*ldfun)(target_ulong ); + +switch (mem_idx) + { +case 0 : ldfun = ldq_kernel;break ; +case 1 : ldfun = ldq_super;break ; +default : +case 2 : ldfun = ldq_user;break ; + } +#endif + +if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) { +target_ulong i; + +for (i =0 ; i < base_reglist; i++) { + env->active_tc.gpr[multiple_regs[i]] =ldfun (addr); + addr +=8 ; + } + } + +if (do_r31) { + env->active_tc.gpr[31 ] =ldfun (addr); + } +} + +void helper_sdm (target_ulong addr,target_ulong reglist,uint32_t mem_idx) +{ +target_ulong base_reglist = reglist &0xf ; +target_ulong do_r31 = reglist &0x10 ; +#ifdef CONFIG_USER_ONLY +#undef stfun +#define stfun stq_raw +#else +void (*stfun)(target_ulong ,uint64_t ); + +switch (mem_idx) + { +case 0 : stfun = stq_kernel;break ; +case 1 : stfun = stq_super;break ; +default : +case 2 : stfun = stq_user;break ; + } +#endif + +if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) { +target_ulong i; + +for (i =0 ; i < base_reglist; i++) { +stfun (addr, env->active_tc.gpr[multiple_regs[i]]); + addr +=8 ; + } + }
target-mips/op_helper.c void helper_sdr(target_ulong arg1, target_ulong arg2, int mem_idx) · line 706
Quoted 10 lines
target-mips/op_helper.c +7
-0+ +if (do_r31) { +stfun (addr, env->active_tc.gpr[31 ]); + } +} +#endif +#ifndef CONFIG_USER_ONLY /* CP0 helpers */ target_ulong helper_mfc0_mvpcontrol (void )
As the list of registers is included in the opcode, I do wonder if it wouldn't be better to do this directly in translate.c as TCG code.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 27 lines · Nathan Froyd
This patch series adds support for the microMIPS ASE. microMIPS is a new ASE similar to MIPS16, but re-encodes the entire instruction set into 16-bit and 32-bit instructions--in contrast to MIPS16, which re-encodes only integer instructions. The mechanisms for going in and out of microMIPS mode are identical to those for MIPS16; a given chip cannot support both ASEs simultaneously.
changes from v2:
give actual name to FOP constants; assign names to FOPs for c{,abs} fix up coding style violations
fix helpers for recent ldl_*/stl_* prototype changes split out mips16-related changes into separate patch group patches more logicallychanges from v1:
fix re-introduction of previously deleted code noted by rthNathan Froyd (8):
target-mips: define constants for magic numbers
target-mips: refactor c{,abs}.cond.fmt insns
target-mips: mips16 cleanups
target-mips: microMIPS ASE support
target-mips: add microMIPS CPUs
target-mips: add microMIPS exception handler support
linux-user: honor low bit of entry PC for MIPS
hw: honor low bit in mipssim machine
Quoted 11 lines
hw/mips_mipssim.c | 5 +- linux-user/main.c | 5 +- target-mips/cpu.h | 1 + target-mips/helper.c | 21 +- target-mips/helper.h | 9 + target-mips/mips-defs.h | 1 + target-mips/op_helper.c | 136 ++ target-mips/translate.c | 3015 ++++++++++++++++++++++++++++++++++++++---- target-mips/translate_init.c | 61 + 9 files changed, 3009 insertions(+), 245 deletions(-)
I have applied all patches except the 5th one, see my comments about it.
I also have applied a complementary patch to the first one, that moves FP FMT comments to a more appropriate place. It doesn't change any code.
Finally, I have made some comments about the 4th patch, that may be a basis for future improvements.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 10 lines · Aurelien Jarno
Quoted 6 lines · Nathan Froyd
This patch series adds support for the microMIPS ASE. microMIPS is a new ASE similar to MIPS16, but re-encodes the entire instruction set into 16-bit and 32-bit instructions--in contrast to MIPS16, which re-encodes only integer instructions. The mechanisms for going in and out of microMIPS mode are identical to those for MIPS16; a given chip cannot support both ASEs simultaneously.
I have applied all patches except the 5th one, see my comments about it.
Thanks for applying these. I agree with you about the 5th one and will submit a M14K patch in the next week.
Quoted 2 lines
Finally, I have made some comments about the 4th patch, that may be a basis for future improvements.
Indeed. I will work on that one.
-Nathan