Merge pull request #4680 from unknownbrackets/debugger

Improve vfpu disasm for a few instructions
This commit is contained in:
Henrik Rydgård 2013-11-29 10:47:33 -08:00
commit 120cbf05e1
7 changed files with 159 additions and 31 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -65,6 +65,7 @@ enum CmdFormatType {
CMD_FMT_LOGICOP,
CMD_FMT_TEXWRAP,
CMD_FMT_TEXFILTER,
CMD_FMT_TEXMAPMODE,
};
struct TabStateRow {
@ -157,8 +158,7 @@ static const TabStateRow stateTextureRows[] = {
{ L"Tex V scale", GE_CMD_TEXSCALEV, CMD_FMT_FLOAT24, GE_CMD_TEXTUREMAPENABLE },
{ L"Tex U offset", GE_CMD_TEXOFFSETU, CMD_FMT_FLOAT24, GE_CMD_TEXTUREMAPENABLE },
{ L"Tex V offset", GE_CMD_TEXOFFSETV, CMD_FMT_FLOAT24, GE_CMD_TEXTUREMAPENABLE },
// TODO: Format.
{ L"Tex mapping mode", GE_CMD_TEXMAPMODE, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE },
{ L"Tex mapping mode", GE_CMD_TEXMAPMODE, CMD_FMT_TEXMAPMODE, GE_CMD_TEXTUREMAPENABLE },
// TODO: Format.
{ L"Tex shade srcs", GE_CMD_TEXSHADELS, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE },
{ L"Tex mode", GE_CMD_TEXMODE, CMD_FMT_TEXMODE, GE_CMD_TEXTUREMAPENABLE },
@ -636,6 +636,30 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab
}
break;
case CMD_FMT_TEXMAPMODE:
{
const char *uvGenModes[] = {
"tex coords",
"tex matrix",
"tex env map",
"unknown (tex coords?)",
};
const char *uvProjModes[] = {
"pos",
"uv",
"normalized normal",
"normal",
};
if ((value & ~0x0303) == 0) {
const int uvGen = (value & 0x0003) >> 0;
const int uvProj = (value & 0x0300) >> 8;
swprintf(dest, L"gen: %S, proj: %S", uvGenModes[uvGen], uvProjModes[uvProj]);
} else {
swprintf(dest, L"%06x", value);
}
}
break;
case CMD_FMT_FLAG:
if ((value & ~1) == 0) {
swprintf(dest, L"%d", value);