📄 ms_inst.m4
字号:
th->stall_except = 1; UpdateStallFetch (th); return; } ms_lsq (st, Ireg(ip->r2) + ip->imm, ip->r3, 0, ST_INTEGER_W, ip - st->iwin); if (st->stall_issue) return;#ifdef BREAKPOINT if (membrk && ((Ireg(ip->r2) + ip->imm) == membrk)) ms_break (st, &st->iwin[st->iwin_curi], "MEMBRK");#endif }void opSWR (struct s_cpu_state *st, INST *ip, THREAD *th) { int inum; inum = ip - st->iwin; if (st->iwin_flags[inum] & IWIN_TLBFAULT) { st->iwin_flags[inum] |= IWIN_FAULT; CheckSquash (st,ip); th->stall_except = 1; UpdateStallFetch (th); return; } ms_lsq (st, Ireg(ip->r2) + ip->imm, ip->r3, 0, ST_INTEGER_R, ip - st->iwin); if (st->stall_issue) return;#ifdef BREAKPOINT if (membrk && ((Ireg(ip->r2) + ip->imm) == membrk)) ms_break (st, &st->iwin[st->iwin_curi], "MEMBRK");#endif }void opLWC1 (struct s_cpu_state *st, INST *ip, THREAD *th) { int inum; WorkDecls; CHECKFP() inum = ip - st->iwin; if (st->iwin_addr[inum] & 0x3) { LS_EXC(EXC_RADE) } else if (st->iwin_flags[inum] & IWIN_TLBFAULT) { st->iwin_flags[inum] |= IWIN_FAULT; } if (st->iwin_flags[inum] & IWIN_FAULT) { CheckSquash (st,ip); th->stall_except = 1; UpdateStallFetch (th); return; } ms_lsq (st, Ireg(ip->r2) + ip->imm, ip->r1, 0, LD_FLOAT, ip - st->iwin); LoadStats() }void opLDC1 (struct s_cpu_state *st, INST *ip, THREAD *th) { int inum; WorkDecls; CHECKFP() inum = ip - st->iwin; if (st->iwin_addr[inum] & 0x7) { LS_EXC(EXC_RADE) } else if (st->iwin_flags[inum] & IWIN_TLBFAULT) { st->iwin_flags[inum] |= IWIN_FAULT; } if (st->iwin_flags[inum] & IWIN_FAULT) { CheckSquash (st,ip); th->stall_except = 1; UpdateStallFetch (th); return; } ms_lsq (st, Ireg(ip->r2) + ip->imm, ip->r1, 0, LD_DOUBLE, ip - st->iwin); LoadStats() }void opSWC1 (struct s_cpu_state *st, INST *ip, THREAD *th) { int inum; CHECKFP() inum = ip - st->iwin; if (st->iwin_addr[inum] & 0x3) { LS_EXC(EXC_WADE) } else if (st->iwin_flags[inum] & IWIN_TLBFAULT) { st->iwin_flags[inum] |= IWIN_FAULT; } if (st->iwin_flags[inum] & IWIN_FAULT) { CheckSquash (st,ip); th->stall_except = 1; UpdateStallFetch (th); return; } ms_lsq (st, Ireg(ip->r2) + ip->imm, ip->r3, 0, ST_FLOAT, ip - st->iwin); if (st->stall_issue) return;#ifdef BREAKPOINT if (membrk && ((Ireg(ip->r2) + ip->imm) == membrk)) ms_break (st, &st->iwin[st->iwin_curi], "MEMBRK");#endif }void opSDC1 (struct s_cpu_state *st, INST *ip, THREAD *th) { int inum; CHECKFP() inum = ip - st->iwin; if (st->iwin_addr[inum] & 0x7) { LS_EXC(EXC_WADE) } else if (st->iwin_flags[inum] & IWIN_TLBFAULT) { st->iwin_flags[inum] |= IWIN_FAULT; } if (st->iwin_flags[inum] & IWIN_FAULT) { CheckSquash (st,ip); th->stall_except = 1; UpdateStallFetch (th); return; } ms_lsq (st, Ireg(ip->r2) + ip->imm, ip->r3, 0, ST_DOUBLE, ip - st->iwin); if (st->stall_issue) return;#ifdef BREAKPOINT if (membrk && ((Ireg(ip->r2) + ip->imm) == membrk)) ms_break (st, &st->iwin[st->iwin_curi], "MEMBRK");#endif }void opSLL (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) << ip->imm; if ((ip->r1 == 0) && (ip->r2 == 0) && (ip->imm == 0)) { IncStat(ST_NOP); } }void opSRL (struct s_cpu_state *st, INST *ip, THREAD *th) { Ureg(ip->r1) = Ureg(ip->r2) >> ip->imm; }void opSRA (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) >> ip->imm; }void opSLLV (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) << (Ireg(ip->r3) & 0x1f); }void opSRLV (struct s_cpu_state *st, INST *ip, THREAD *th) { Ureg(ip->r1) = Ureg(ip->r2) >> (Ireg(ip->r3) & 0x1f); }void opSRAV (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) >> (Ireg(ip->r3) & 0x1f); }void opJR (struct s_cpu_state *st, INST *ip, THREAD *th) { int inum, ix; BrTREE *br, *right; WorkDecls; inum = ip - st->iwin; br = &st->branch_tree [st->iwin_br_node[inum]]; right = &st->branch_tree [br->rchild]; ix = bp_pc_to_index(st->iwin_pc [inum]); th->pc = addr_to_cadr (st, Ireg(ip->r2)); st->bp_targets [ix]= th->pc; br->resolution = (right->condition == th->pc ? PRUNE_LEFT : PRUNE_RIGHT); st->iwin_branch_pc [inum] = Ireg(ip->r2);#if BRANCH_LATENCY > 1 Add_to_worklist (st, BRANCH_LATENCY, finish_branch, (void *)ip);#else th->stall_branch = 0; UpdateStallFetch (th); prune_branch (st, st->iwin_br_node[inum]);#endif th->debugpc = cadr_to_addr (st, th->pc);#ifdef BREAKPOINT if (jmpbrk && (th->pc == jmpbrk)) ms_break (st, &st->iwin[st->iwin_curi], "JMPBRK");#endif }void opJRET (struct s_cpu_state *st, INST *ip, THREAD *th) { int inum; BrTREE *br, *right; WorkDecls; inum = ip - st->iwin; br = &st->branch_tree [st->iwin_br_node[inum]]; right = &st->branch_tree [br->rchild]; th->pc = addr_to_cadr (st, Ireg(ip->r2)); br->resolution = (right->condition == th->pc ? PRUNE_LEFT : PRUNE_RIGHT); st->iwin_branch_pc [inum] = Ireg(ip->r2);#if BRANCH_LATENCY > 1 Add_to_worklist (st, BRANCH_LATENCY, finish_branch, (void *)ip);#else th->stall_branch = 0; UpdateStallFetch (th); prune_branch (st, st->iwin_br_node[inum]);#endif#ifdef PROCSTATS pop_stats (st);#endif th->debugpc = cadr_to_addr (st, th->pc);#ifdef BREAKPOINT if (jmpbrk && (th->pc == jmpbrk)) ms_break (st, &st->iwin[st->iwin_curi], "JMPBRK");#endif }void opJALR (struct s_cpu_state *st, INST *ip, THREAD *th) { int inum, ix; BrTREE *br, *right; WorkDecls; inum = ip - st->iwin; br = &st->branch_tree [st->iwin_br_node[inum]]; right = &st->branch_tree [br->rchild]; ix = bp_pc_to_index(st->iwin_pc [inum]); Ireg(ip->r1) = cadr_to_addr (st, th->returnpc); th->pc = addr_to_cadr (st, Ireg(ip->r2)); st->bp_targets [ix]= th->pc; br->resolution = (right->condition == th->pc ? PRUNE_LEFT : PRUNE_RIGHT); st->iwin_branch_pc [inum] = Ireg(ip->r2);#if BRANCH_LATENCY > 1 Add_to_worklist (st, BRANCH_LATENCY, finish_call, (void *)ip);#else th->stall_branch = 0; UpdateStallFetch (th); prune_branch (st, st->iwin_br_node[inum]);#endif#ifdef PROCSTATS push_stats (st, th->pc);#endif th->debugpc = cadr_to_addr (st, th->pc);#ifdef BREAKPOINT if (jmpbrk && (th->pc == jmpbrk)) ms_break (st, &st->iwin[st->iwin_curi], "JMPBRK");#endif }void opSYSCALL (struct s_cpu_state *st, INST *ip, THREAD *th) {#ifdef MIPSY_MXS int inum; CPUState *P = (CPUState *)st->mipsyPtr; RECORD_EXCEPTION(P, EXC_SYSCALL, E_VEC, 0, P->CP0[C0_TLBHI],P->CP0[C0_CTXT],P->CP0[C0_XCTXT]); inum = ip - st->iwin; st->iwin_except [inum] = GetLastException(st); st->iwin_flags [inum] |= IWIN_FAULT; CheckSquash (st, ip); th->stall_except = 1; UpdateStallFetch (th);#else if (!alls_quiet (st, ip, ST_SYSCALL)) return; opsysc (st, th); th->stall_sys = 0; UpdateStallFetch (th);#endif }void opBREAK (struct s_cpu_state *st, INST *ip, THREAD *th) { fprintf (stderr, "Unimplemented opcode brk\n"); CPUError("Unimplemented opcode brk\n"); exit (1); }void opADD (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) + Ireg(ip->r3); }void opADDU (struct s_cpu_state *st, INST *ip, THREAD *th) { Ureg(ip->r1) = Ureg(ip->r2) + Ureg(ip->r3); }void opSUB (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) - Ireg(ip->r3); }void opSUBU (struct s_cpu_state *st, INST *ip, THREAD *th) { Ureg(ip->r1) = Ureg(ip->r2) - Ureg(ip->r3); }void opAND (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) & Ireg(ip->r3); }void opOR (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) | Ireg(ip->r3); }void opXOR (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = Ireg(ip->r2) ^ Ireg(ip->r3); }void opNOR (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = ~(Ireg(ip->r2) | Ireg(ip->r3)); }void opSLT (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = (Ireg(ip->r2) < Ireg(ip->r3) ? 1 : 0); }void opSLTU (struct s_cpu_state *st, INST *ip, THREAD *th) { Ireg(ip->r1) = (Ureg(ip->r2) < Ureg(ip->r3) ? 1 : 0); }void opCPY (struct s_cpu_state *st, INST *ip, THREAD *th) { if (ip->op == OPCPYC1) { CHECKFP() } Ireg(ip->r1) = Ireg(ip->r2); }void opCVTSW (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() if ((ip->r1 & (~0x01)) != ip->r3) Dreg(ip->r1) = Dreg(ip->r3); Freg(ip->r1) = Ireg(ip->r2);#if FPCVTSW_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCVT; Add_to_worklist (st, FPCVTSW_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opCVTDW (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() Dreg(ip->r1) = Ireg(ip->r2);#if FPCVTDW_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCVT; Add_to_worklist (st, FPCVTDW_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opFADDS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() Freg(ip->r1) = Freg(ip->r2) + Freg(ip->r3);#if FPADD_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPADD; Add_to_worklist (st, FPADD_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opFSUBS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() Freg(ip->r1) = Freg(ip->r2) - Freg(ip->r3);#if FPADD_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPADD; Add_to_worklist (st, FPADD_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opFMULS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() Freg(ip->r1) = Freg(ip->r2) * Freg(ip->r3);#if FPMULS_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPMUL; Add_to_worklist (st, FPMULS_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opFDIVS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() if (Freg(ip->r3) == 0.0) { int inum = ip - st->iwin;#ifdef MIPSY_MXS CPUState *P = (CPUState *)st->mipsyPtr; RECORD_EXCEPTION (P, EXC_FPE, E_VEC, 0, P->CP0[C0_TLBHI],P->CP0[C0_CTXT],P->CP0[C0_XCTXT]); st->iwin_except [inum] = GetLastException(st);#else st->reg_rstat[ip->r1 >> 1].reg_status |= REG_ERROR;#endif st->iwin_flags[inum] |= IWIN_FAULT; CheckSquash (st, ip); th->stall_except = 1; UpdateStallFetch (th); return; } Freg(ip->r1) = Freg(ip->r2) / Freg(ip->r3);#if FPDIVS_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPDIV; Add_to_worklist (st, FPDIVS_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opFSQRTS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP()#ifdef MIPSY_MXS fprintf(stderr, "Hit a FSQRTS inst\n");#else Freg(ip->r1) = sqrtf (Freg(ip->r2));#endif#if FPSQRTS_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPSQRT; Add_to_worklist (st, FPSQRTS_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opFABSS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() Freg(ip->r1) = (Freg(ip->r2) >= 0 ? Freg(ip->r2) : -Freg(ip->r2) );#if FPABS_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPABS; Add_to_worklist (st, FPABS_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opFNEGS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() Freg(ip->r1) = -Freg(ip->r2);#if FPNEG_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPNEG; Add_to_worklist (st, FPNEG_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opFROUNDS (struct s_cpu_state *st, INST *ip, THREAD *th) { CHECKFP() Ireg(ip->r1) = (Freg(ip->r2) > 0.0 ? Freg(ip->r2) + 0.5 : Freg(ip->r2) - 0.5 ); }void opFTRUNCS (struct s_cpu_state *st, INST *ip, THREAD *th) { CHECKFP() Ireg(ip->r1) = Freg(ip->r2); }void opFCEILS (struct s_cpu_state *st, INST *ip, THREAD *th) { CHECKFP() Ireg(ip->r1) = (Freg(ip->r2) >= 0.0 ? Freg(ip->r2) + SP_NEAR_ONE : Freg(ip->r2) ); }void opFFLOORS (struct s_cpu_state *st, INST *ip, THREAD *th) { CHECKFP() Ireg(ip->r1) = (Freg(ip->r2) >= 0.0 ? Freg(ip->r2) : Freg(ip->r2) - SP_NEAR_ONE ); }void opCVTDS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() Dreg(ip->r1) = Freg(ip->r2);#if FPCVT_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCVT; Add_to_worklist (st, FPCVT_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opCVTWS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() if ((ip->r1 & (~0x01)) != ip->r3) Dreg(ip->r1) = Dreg(ip->r3); switch (st->round_mode) { case 0: /* RN: Round to nearest */ Ireg(ip->r1) = (Freg(ip->r2) > 0.0 ? Freg(ip->r2) + 0.5 : Freg(ip->r2) - 0.5 ); break; case 1: /* RZ: Round toward 0 */ Ireg(ip->r1) = Freg(ip->r2); break; case 2: /* RP: Round to +infinity */ Ireg(ip->r1) = (Freg(ip->r2) >= 0.0 ? Freg(ip->r2) + SP_NEAR_ONE : Freg(ip->r2) ); break; case 3: /* RM: Round to -infinity */ Ireg(ip->r1) = (Freg(ip->r2) >= 0.0 ? Freg(ip->r2) : Freg(ip->r2) - SP_NEAR_ONE ); break; }#if FPCVT_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCVT; Add_to_worklist (st, FPCVT_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opCUNS (struct s_cpu_state *st, INST *ip, THREAD *th) { CHECKFP() Ireg(ip->r1) &= ~CONDBIT; }void opCUEQS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() if (Freg(ip->r2) == Freg(ip->r3)) Ireg(ip->r1) |= CONDBIT; else Ireg(ip->r1) &= ~CONDBIT;#if FPCMP_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCMP; Add_to_worklist (st, FPCMP_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opCULTS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() if (Freg(ip->r2) < Freg(ip->r3)) Ireg(ip->r1) |= CONDBIT; else Ireg(ip->r1) &= ~CONDBIT;#if FPCMP_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCMP; Add_to_worklist (st, FPCMP_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opCULES (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() if (Freg(ip->r2) <= Freg(ip->r3)) Ireg(ip->r1) |= CONDBIT; else Ireg(ip->r1) &= ~CONDBIT;#if FPCMP_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCMP; Add_to_worklist (st, FPCMP_LATENCY, reg_writeback, (void *)(ip->r1));#endif }/* Trap if unordered, but otherwise the same as above */void opCNGLES (struct s_cpu_state *st, INST *ip, THREAD *th) { CHECKFP() Ireg(ip->r1) &= ~CONDBIT; }void opCNGLS (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() if (Freg(ip->r2) == Freg(ip->r3)) Ireg(ip->r1) |= CONDBIT; else Ireg(ip->r1) &= ~CONDBIT;#if FPCMP_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCMP; Add_to_worklist (st, FPCMP_LATENCY, reg_writeback, (void *)(ip->r1));#endif }void opCNGES (struct s_cpu_state *st, INST *ip, THREAD *th) { WorkDecls; CHECKFP() if (Freg(ip->r2) < Freg(ip->r3)) Ireg(ip->r1) |= CONDBIT; else Ireg(ip->r1) &= ~CONDBIT;#if FPCMP_LATENCY > 1 st->reg_excuse[ip->r1>>1] = ST_FPCMP; Add_to_worklist (st, FPCMP_LATENCY, reg_writeback, (void *)(ip->r1));#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -