From ec05146ffdf93e4fc20df4fb54399f4ba5b1379b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 29 Nov 2013 09:59:59 -0800 Subject: [PATCH] Improve vfpu disasm for a few instructions. --- Core/MIPS/MIPSDisVFPU.cpp | 89 +++++++++++++++++++++++++++++++++++-- Core/MIPS/MIPSDisVFPU.h | 9 ++++ Core/MIPS/MIPSIntVFPU.cpp | 1 + Core/MIPS/MIPSTables.cpp | 51 ++++++++++----------- Core/MIPS/MIPSVFPUUtils.cpp | 11 +++++ Core/MIPS/MIPSVFPUUtils.h | 1 + 6 files changed, 133 insertions(+), 29 deletions(-) diff --git a/Core/MIPS/MIPSDisVFPU.cpp b/Core/MIPS/MIPSDisVFPU.cpp index e76f7a49e6..253858bb78 100644 --- a/Core/MIPS/MIPSDisVFPU.cpp +++ b/Core/MIPS/MIPSDisVFPU.cpp @@ -137,6 +137,14 @@ namespace MIPSDis sprintf(out, "%s%s\t%s, %s",name,vr>127?"c":"", RN(rt), VN(vr, V_Single)); } + void Dis_Vmftvc(MIPSOpcode op, char *out) + { + int vr = op & 0xFF; + int vs = _VS; + const char *name = MIPSGetName(op); + sprintf(out, "%s\t%s, %s", name, VN(vs, V_Single), VN(vr, V_Single)); + } + void Dis_VPFXST(MIPSOpcode op, char *out) { int data = op & 0xFFFFF; @@ -184,7 +192,8 @@ namespace MIPSDis strcat(out, satNames[sat]); if (mask) strcat(out, "M"); - strcat(out, " "); + if (i < 4 - 1) + strcat(out, ", "); } } @@ -202,7 +211,7 @@ namespace MIPSDis else if (type == 7) sprintf(out, "%s\t%s, %f", name, VN(vt, V_Single), Float16ToFloat32((u16)imm)); else - sprintf(out, "ARGH"); + sprintf(out, "%s\tARGH", name); } void Dis_Vcst(MIPSOpcode op, char *out) @@ -271,9 +280,20 @@ namespace MIPSDis int vs = _VS; int vt = _VT; MatrixSize sz = GetMtxSize(op); + // TODO: Xpose? sprintf(out, "%s%s\t%s, %s, %s",name,VSuff(op),MN(vd, sz),MN(Xpose(vs),sz),MN(vt,sz)); } + void Dis_Vmscl(MIPSOpcode op, char *out) + { + const char *name = MIPSGetName(op); + int vd = _VD; + int vs = _VS; + int vt = _VT; + MatrixSize sz = GetMtxSize(op); + sprintf(out, "%s%s\t%s, %s, %s", name, VSuff(op), MN(vd, sz), MN(vs, sz), VN(vt, V_Single)); + } + void Dis_VectorDot(MIPSOpcode op, char *out) { const char *name = MIPSGetName(op); @@ -351,14 +371,13 @@ namespace MIPSDis int imm3 = (op>>16)&7; if (tf > 1) { - sprintf(out, "Vcmov\tARGH%i", tf); + sprintf(out, "%s\tARGH%i", name, tf); return; } if (imm3<6) sprintf(out, "%s%s%s\t%s, %s, CC[%i]", name, tf==0?"t":"f", VSuff(op), VN(vd, sz), VN(vs,sz), imm3); else if (imm3 == 6) sprintf(out, "%s%s%s\t%s, %s, CC[...]", name, tf==0?"t":"f", VSuff(op), VN(vd, sz), VN(vs,sz)); - } void Dis_Vfad(MIPSOpcode op, char *out) @@ -505,6 +524,68 @@ namespace MIPSDis sprintf(out, "%s%s\t%s, %s",name,VSuff(op),VN(vd, dsz),VN(vs, sz)); } + void Dis_Vwbn(MIPSOpcode op, char *out) + { + VectorSize sz = GetVecSize(op); + + int vd = _VD; + int vs = _VS; + int imm = (int)((op >> 16) & 0xFF); + const char *name = MIPSGetName(op); + sprintf(out, "%s%s\t%s, %s", name, VSuff(op), VN(vd, sz), VN(vs, sz), imm); + } + + void Dis_Vf2h(MIPSOpcode op, char *out) + { + VectorSize sz = GetVecSize(op); + VectorSize dsz = GetHalfVectorSize(sz); + if (((op>>16)&3)==0) + dsz = V_Single; + + int vd = _VD; + int vs = _VS; + const char *name = MIPSGetName(op); + sprintf(out, "%s%s\t%s, %s", name, VSuff(op), VN(vd, dsz), VN(vs, sz)); + } + + void Dis_Vh2f(MIPSOpcode op, char *out) + { + VectorSize sz = GetVecSize(op); + VectorSize dsz = GetDoubleVectorSize(sz); + + int vd = _VD; + int vs = _VS; + const char *name = MIPSGetName(op); + sprintf(out, "%s%s\t%s, %s", name, VSuff(op), VN(vd, dsz), VN(vs, sz)); + } + + void Dis_ColorConv(MIPSOpcode op, char *out) + { + VectorSize sz = GetVecSize(op); + VectorSize dsz = GetHalfVectorSize(sz); + + int vd = _VD; + int vs = _VS; + const char *name = MIPSGetName(op); + sprintf(out, "%s%s\t%s, %s", name, VSuff(op), VN(vd, dsz), VN(vs, sz)); + } + + void Dis_Vrnds(MIPSOpcode op, char *out) + { + int vd = _VD; + const char *name = MIPSGetName(op); + sprintf(out, "%s%s\t%s", name, VSuff(op), VN(vd, V_Single)); + } + + void Dis_VrndX(MIPSOpcode op, char *out) + { + VectorSize sz = GetVecSize(op); + + int vd = _VD; + const char *name = MIPSGetName(op); + sprintf(out, "%s%s\t%s", name, VSuff(op), VN(vd, sz)); + } + void Dis_VBranch(MIPSOpcode op, char *out) { u32 off = disPC; diff --git a/Core/MIPS/MIPSDisVFPU.h b/Core/MIPS/MIPSDisVFPU.h index dbb1aef3f0..e5072b61aa 100644 --- a/Core/MIPS/MIPSDisVFPU.h +++ b/Core/MIPS/MIPSDisVFPU.h @@ -24,6 +24,7 @@ extern u32 disPC; namespace MIPSDis { void Dis_Mftv(MIPSOpcode op, char *out); + void Dis_Vmftvc(MIPSOpcode op, char *out); void Dis_SV(MIPSOpcode op, char *out); void Dis_SVQ(MIPSOpcode op, char *out); @@ -33,6 +34,7 @@ namespace MIPSDis void Dis_MatrixSet2(MIPSOpcode op, char *out); void Dis_MatrixSet3(MIPSOpcode op, char *out); void Dis_MatrixMult(MIPSOpcode op, char *out); + void Dis_Vmscl(MIPSOpcode op, char *out); void Dis_VectorDot(MIPSOpcode op, char *out); void Dis_Vfad(MIPSOpcode op, char *out); @@ -56,5 +58,12 @@ namespace MIPSDis void Dis_Vf2i(MIPSOpcode op, char *out); void Dis_Vi2x(MIPSOpcode op, char *out); void Dis_Vs2i(MIPSOpcode op, char *out); + void Dis_Vwbn(MIPSOpcode op, char *out); + void Dis_Vf2h(MIPSOpcode op, char *out); + void Dis_Vh2f(MIPSOpcode op, char *out); + void Dis_Vrnds(MIPSOpcode op, char *out); + void Dis_VrndX(MIPSOpcode op, char *out); + void Dis_ColorConv(MIPSOpcode op, char *out); + void Dis_VBranch(MIPSOpcode op, char *out); } diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index dc94cb5d84..af4edf4a6b 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -1193,6 +1193,7 @@ namespace MIPSInt ReadVector(s, sz, vs); ApplySwizzleS(s, sz); ReadVector(t, sz, vt); + // TODO: Does t have swizzle? d[0] = s[0] * t[1] - s[1] * t[0]; ApplyPrefixD(d, sz); WriteVector(d, V_Single, vd); diff --git a/Core/MIPS/MIPSTables.cpp b/Core/MIPS/MIPSTables.cpp index 5ea0697ec9..91667eb06b 100644 --- a/Core/MIPS/MIPSTables.cpp +++ b/Core/MIPS/MIPSTables.cpp @@ -537,9 +537,9 @@ const MIPSInstruction tableVFPU1[8] = // 011001 xxx ....... . ....... . ....... INSTR("vdot", &Jit::Comp_VDot, Dis_VectorDot, Int_VDot, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INSTR("vscl", &Jit::Comp_VScl, Dis_VScl, Int_VScl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INVALID, - INSTR("vhdp", &Jit::Comp_VHdp, Dis_Generic, Int_VHdp, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vhdp", &Jit::Comp_VHdp, Dis_VectorDot, Int_VHdp, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INSTR("vcrs", &Jit::Comp_VCrs, Dis_Vcrs, Int_Vcrs, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vdet", &Jit::Comp_VDet, Dis_Generic, Int_Vdet, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vdet", &Jit::Comp_VDet, Dis_VectorDot, Int_Vdet, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INVALID, }; @@ -578,22 +578,23 @@ const MIPSInstruction tableVFPU4Jump[32] = // 110100 xxxxx ..... . ....... . ... INVALID, //24 - 110100 11 ........ . ....... . ....... // TODO: Flags may not be correct (prefixes, etc.) - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Vwbn, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Vwbn, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Vwbn, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Vwbn, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Vwbn, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Vwbn, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Vwbn, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Vwbn, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), }; const MIPSInstruction tableVFPU7[32] = // 110100 00001 xxxxx . ....... . ....... { - INSTR("vrnds", &Jit::Comp_Generic, Dis_Generic, Int_Vrnds, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vrndi", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vrndf1", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vrndf2", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + // TODO disasm + INSTR("vrnds", &Jit::Comp_Generic, Dis_Vrnds, Int_Vrnds, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vrndi", &Jit::Comp_Generic, Dis_VrndX, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vrndf1", &Jit::Comp_Generic, Dis_VrndX, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vrndf2", &Jit::Comp_Generic, Dis_VrndX, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INVALID, INVALID, INVALID, INVALID, //8 @@ -604,8 +605,8 @@ const MIPSInstruction tableVFPU7[32] = // 110100 00001 xxxxx . ....... . ....... //16 INVALID, INVALID, - INSTR("vf2h", &Jit::Comp_Generic, Dis_Generic, Int_Vf2h, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vh2f", &Jit::Comp_Vh2f, Dis_Generic, Int_Vh2f, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vf2h", &Jit::Comp_Generic, Dis_Vf2h, Int_Vf2h, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vh2f", &Jit::Comp_Vh2f, Dis_Vh2f, Int_Vh2f, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INVALID, INVALID, @@ -691,10 +692,10 @@ const MIPSInstruction tableVFPU6[32] = // 111100 xxxxx ..... . ....... . ....... INSTR("v(h)tfm4", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INSTR("v(h)tfm4", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), //16 - INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Vmscl, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Vmscl, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Vmscl, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Vmscl, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INSTR("vcrsp.t/vqmul.q", &Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), INSTR("vcrsp.t/vqmul.q", &Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), @@ -757,9 +758,9 @@ const MIPSInstruction tableVFPU9[32] = // 110100 00010 xxxxx . ....... . ....... //16 // TODO: Flags may not be correct (prefixes, etc.) - INSTR("vmfvc", &Jit::Comp_Generic, Dis_Generic, Int_Vmfvc, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vmfvc", &Jit::Comp_Generic, Dis_Vmftvc, Int_Vmfvc, IN_OTHER|OUT_OTHER|IS_VFPU), // TODO: Flags may not be correct (prefixes, etc.) - INSTR("vmtvc", &Jit::Comp_Generic, Dis_Generic, Int_Vmtvc, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vmtvc", &Jit::Comp_Generic, Dis_Vmftvc, Int_Vmtvc, IN_OTHER|OUT_OTHER|IS_VFPU), INVALID, INVALID, @@ -767,9 +768,9 @@ const MIPSInstruction tableVFPU9[32] = // 110100 00010 xxxxx . ....... . ....... INVALID, INVALID, INVALID, INVALID, //24 INVALID, - INSTR("vt4444", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vt5551", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), - INSTR("vt5650", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vt4444", &Jit::Comp_Generic, Dis_ColorConv, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vt5551", &Jit::Comp_Generic, Dis_ColorConv, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vt5650", &Jit::Comp_Generic, Dis_ColorConv, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), //28 INVALID, INVALID, INVALID, INVALID, diff --git a/Core/MIPS/MIPSVFPUUtils.cpp b/Core/MIPS/MIPSVFPUUtils.cpp index 50b7213d59..8860c75180 100644 --- a/Core/MIPS/MIPSVFPUUtils.cpp +++ b/Core/MIPS/MIPSVFPUUtils.cpp @@ -226,6 +226,17 @@ VectorSize GetHalfVectorSize(VectorSize sz) } } +VectorSize GetDoubleVectorSize(VectorSize sz) +{ + switch (sz) + { + case V_Single: return V_Pair; + case V_Pair: return V_Quad; + default: + return V_Pair; + } +} + VectorSize GetVecSize(MIPSOpcode op) { int a = (op>>7)&1; diff --git a/Core/MIPS/MIPSVFPUUtils.h b/Core/MIPS/MIPSVFPUUtils.h index 68e4a75153..f98e76cefc 100644 --- a/Core/MIPS/MIPSVFPUUtils.h +++ b/Core/MIPS/MIPSVFPUUtils.h @@ -68,6 +68,7 @@ inline int GetMtx(int matrixReg) { VectorSize GetVecSize(MIPSOpcode op); MatrixSize GetMtxSize(MIPSOpcode op); VectorSize GetHalfVectorSize(VectorSize sz); +VectorSize GetDoubleVectorSize(VectorSize sz); int GetNumVectorElements(VectorSize sz); int GetMatrixSide(MatrixSize sz); const char *GetVectorNotation(int reg, VectorSize size);