mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 19:34:39 +01:00
Merge pull request #1367 from unknownbrackets/jit-vfpu
Initial vscl, vmmul, vmscl, and v(h)tfm in x86 jit
This commit is contained in:
commit
8615de3f1b
5 files changed
+247
-21
No files matched your search
@@ -714,4 +714,20 @@ namespace MIPSComp
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_VScl(u32 op) {
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_Vmmul(u32 op) {
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_Vmscl(u32 op) {
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_Vtfm(u32 op) {
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -193,6 +193,10 @@ public:
|
||||
void Comp_Mftv(u32 op);
|
||||
void Comp_Vmtvc(u32 op);
|
||||
void Comp_Vmmov(u32 op);
|
||||
void Comp_VScl(u32 op);
|
||||
void Comp_Vmmul(u32 op);
|
||||
void Comp_Vmscl(u32 op);
|
||||
void Comp_Vtfm(u32 op);
|
||||
|
||||
ArmJitBlockCache *GetBlockCache() { return &blocks; }
|
||||
|
||||
|
||||
+21
-21
@@ -490,7 +490,7 @@ const MIPSInstruction tableVFPU1[8] =
|
||||
{
|
||||
INSTR("vmul",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vdot",&Jit::Comp_VDot, Dis_VectorDot, Int_VDot, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vscl",&Jit::Comp_Generic, Dis_VScl, Int_VScl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vscl",&Jit::Comp_VScl, Dis_VScl, Int_VScl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
{-2},
|
||||
INSTR("vhdp",&Jit::Comp_Generic, Dis_Generic, Int_VHdp, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vcrs",&Jit::Comp_Generic, Dis_Vcrs, Int_Vcrs, IS_VFPU),
|
||||
@@ -626,30 +626,30 @@ MIPSInstruction tableVFPU5[8] = //110111 xxx
|
||||
const MIPSInstruction tableVFPU6[32] = //111100 xxx
|
||||
{
|
||||
//0
|
||||
INSTR("vmmul",&Jit::Comp_Generic, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmmul",&Jit::Comp_Generic, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmmul",&Jit::Comp_Generic, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmmul",&Jit::Comp_Generic, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmmul",&Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmmul",&Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmmul",&Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmmul",&Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX),
|
||||
|
||||
INSTR("v(h)tfm2",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm2",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm2",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm2",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm2",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm2",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm2",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm2",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
//8
|
||||
INSTR("v(h)tfm3",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm3",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm3",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm3",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm3",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm3",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm3",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm3",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
|
||||
INSTR("v(h)tfm4",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm4",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm4",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm4",&Jit::Comp_Generic, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm4",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm4",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm4",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("v(h)tfm4",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX),
|
||||
//16
|
||||
INSTR("vmscl",&Jit::Comp_Generic, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmscl",&Jit::Comp_Generic, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmscl",&Jit::Comp_Generic, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmscl",&Jit::Comp_Generic, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmscl",&Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmscl",&Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmscl",&Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmscl",&Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
|
||||
INSTR("vcrsp.t/vqmul.q",&Jit::Comp_Generic, Dis_CrossQuat, Int_CrossQuat, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vcrsp.t/vqmul.q",&Jit::Comp_Generic, Dis_CrossQuat, Int_CrossQuat, IS_VFPU|OUT_EAT_PREFIX),
|
||||
|
||||
@@ -732,4 +732,206 @@ void Jit::Comp_Vmmov(u32 op) {
|
||||
fpr.ReleaseSpillLocks();
|
||||
}
|
||||
|
||||
void Jit::Comp_VScl(u32 op) {
|
||||
CONDITIONAL_DISABLE;
|
||||
|
||||
if (js.HasUnknownPrefix())
|
||||
DISABLE;
|
||||
|
||||
VectorSize sz = GetVecSize(op);
|
||||
int n = GetNumVectorElements(sz);
|
||||
|
||||
u8 sregs[4], dregs[4], scale;
|
||||
GetVectorRegsPrefixS(sregs, sz, _VS);
|
||||
// TODO: Prefixes seem strange...
|
||||
GetVectorRegsPrefixT(&scale, V_Single, _VT);
|
||||
GetVectorRegsPrefixD(dregs, sz, _VD);
|
||||
|
||||
// Move to XMM0 early, so we don't have to worry about overlap with scale.
|
||||
MOVSS(XMM0, fpr.V(scale));
|
||||
|
||||
X64Reg tempxregs[4];
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
if (!IsOverlapSafeAllowS(dregs[i], i, n, sregs))
|
||||
{
|
||||
int reg = fpr.GetTempV();
|
||||
fpr.MapRegV(reg, MAP_NOINIT | MAP_DIRTY);
|
||||
fpr.SpillLockV(reg);
|
||||
tempxregs[i] = fpr.VX(reg);
|
||||
}
|
||||
else
|
||||
{
|
||||
fpr.MapRegV(dregs[i], (dregs[i] == sregs[i] ? 0 : MAP_NOINIT) | MAP_DIRTY);
|
||||
fpr.SpillLockV(dregs[i]);
|
||||
tempxregs[i] = fpr.VX(dregs[i]);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
if (!fpr.V(sregs[i]).IsSimpleReg(tempxregs[i]))
|
||||
MOVSS(tempxregs[i], fpr.V(sregs[i]));
|
||||
MULSS(tempxregs[i], R(XMM0));
|
||||
}
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
if (!fpr.V(dregs[i]).IsSimpleReg(tempxregs[i]))
|
||||
MOVSS(fpr.V(dregs[i]), tempxregs[i]);
|
||||
}
|
||||
ApplyPrefixD(dregs, sz);
|
||||
|
||||
fpr.ReleaseSpillLocks();
|
||||
}
|
||||
|
||||
void Jit::Comp_Vmmul(u32 op) {
|
||||
CONDITIONAL_DISABLE;
|
||||
|
||||
// TODO: This probably ignores prefixes?
|
||||
if (js.MayHavePrefix())
|
||||
DISABLE;
|
||||
|
||||
MatrixSize sz = GetMtxSize(op);
|
||||
int n = GetMatrixSide(sz);
|
||||
|
||||
u8 sregs[16], tregs[16], dregs[16];
|
||||
GetMatrixRegs(sregs, sz, _VS);
|
||||
GetMatrixRegs(tregs, sz, _VT);
|
||||
GetMatrixRegs(dregs, sz, _VD);
|
||||
|
||||
// TODO: test overlap, fix non-optimal.
|
||||
u8 tempregs[16];
|
||||
for (int a = 0; a < n; a++)
|
||||
{
|
||||
for (int b = 0; b < n; b++)
|
||||
{
|
||||
XORPS(XMM0, R(XMM0));
|
||||
for (int c = 0; c < n; c++)
|
||||
{
|
||||
MOVSS(XMM1, fpr.V(sregs[b * 4 + c]));
|
||||
MULSS(XMM1, fpr.V(tregs[a * 4 + c]));
|
||||
ADDSS(XMM0, R(XMM1));
|
||||
}
|
||||
u8 temp = (u8) fpr.GetTempV();
|
||||
fpr.MapRegV(temp, MAP_NOINIT | MAP_DIRTY);
|
||||
MOVSS(fpr.VX(temp), R(XMM0));
|
||||
fpr.StoreFromRegisterV(temp);
|
||||
tempregs[a * 4 + b] = temp;
|
||||
}
|
||||
}
|
||||
for (int a = 0; a < n; a++)
|
||||
{
|
||||
for (int b = 0; b < n; b++)
|
||||
{
|
||||
u8 temp = tempregs[a * 4 + b];
|
||||
fpr.MapRegV(temp, 0);
|
||||
MOVSS(fpr.V(dregs[a * 4 + b]), fpr.VX(temp));
|
||||
}
|
||||
}
|
||||
|
||||
fpr.ReleaseSpillLocks();
|
||||
}
|
||||
|
||||
void Jit::Comp_Vmscl(u32 op) {
|
||||
CONDITIONAL_DISABLE;
|
||||
|
||||
// TODO: This probably ignores prefixes?
|
||||
if (js.MayHavePrefix())
|
||||
DISABLE;
|
||||
|
||||
MatrixSize sz = GetMtxSize(op);
|
||||
int n = GetMatrixSide(sz);
|
||||
|
||||
u8 sregs[16], dregs[16], scale;
|
||||
GetMatrixRegs(sregs, sz, _VS);
|
||||
GetVectorRegs(&scale, V_Single, _VT);
|
||||
GetMatrixRegs(dregs, sz, _VD);
|
||||
|
||||
// Move to XMM0 early, so we don't have to worry about overlap with scale.
|
||||
MOVSS(XMM0, fpr.V(scale));
|
||||
|
||||
// TODO: test overlap, optimize.
|
||||
u8 tempregs[16];
|
||||
for (int a = 0; a < n; a++)
|
||||
{
|
||||
for (int b = 0; b < n; b++)
|
||||
{
|
||||
u8 temp = (u8) fpr.GetTempV();
|
||||
fpr.MapRegV(temp, MAP_NOINIT | MAP_DIRTY);
|
||||
MOVSS(fpr.VX(temp), fpr.V(sregs[a * 4 + b]));
|
||||
MULSS(fpr.VX(temp), R(XMM0));
|
||||
fpr.StoreFromRegisterV(temp);
|
||||
tempregs[a * 4 + b] = temp;
|
||||
}
|
||||
}
|
||||
for (int a = 0; a < n; a++)
|
||||
{
|
||||
for (int b = 0; b < n; b++)
|
||||
{
|
||||
u8 temp = tempregs[a * 4 + b];
|
||||
fpr.MapRegV(temp, 0);
|
||||
MOVSS(fpr.V(dregs[a * 4 + b]), fpr.VX(temp));
|
||||
}
|
||||
}
|
||||
|
||||
fpr.ReleaseSpillLocks();
|
||||
}
|
||||
|
||||
void Jit::Comp_Vtfm(u32 op) {
|
||||
CONDITIONAL_DISABLE;
|
||||
|
||||
// TODO: This probably ignores prefixes? Or maybe uses D?
|
||||
if (js.MayHavePrefix())
|
||||
DISABLE;
|
||||
|
||||
VectorSize sz = GetVecSize(op);
|
||||
MatrixSize msz = GetMtxSize(op);
|
||||
int n = GetNumVectorElements(sz);
|
||||
int ins = (op >> 23) & 7;
|
||||
|
||||
bool homogenous = false;
|
||||
if (n == ins)
|
||||
{
|
||||
n++;
|
||||
sz = (VectorSize)((int)(sz) + 1);
|
||||
msz = (MatrixSize)((int)(msz) + 1);
|
||||
homogenous = true;
|
||||
}
|
||||
// Otherwise, n should already be ins + 1.
|
||||
else if (n != ins + 1)
|
||||
DISABLE;
|
||||
|
||||
u8 sregs[16], dregs[4], tregs[4];
|
||||
GetMatrixRegs(sregs, msz, _VS);
|
||||
GetVectorRegs(tregs, sz, _VT);
|
||||
GetVectorRegs(dregs, sz, _VD);
|
||||
|
||||
// TODO: test overlap, optimize.
|
||||
u8 tempregs[4];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
XORPS(XMM0, R(XMM0));
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
MOVSS(XMM1, fpr.V(sregs[i * 4 + k]));
|
||||
if (!homogenous || k != n - 1)
|
||||
MULSS(XMM1, fpr.V(tregs[k]));
|
||||
ADDSS(XMM0, R(XMM1));
|
||||
}
|
||||
|
||||
u8 temp = (u8) fpr.GetTempV();
|
||||
fpr.MapRegV(temp, MAP_NOINIT | MAP_DIRTY);
|
||||
MOVSS(fpr.VX(temp), R(XMM0));
|
||||
fpr.StoreFromRegisterV(temp);
|
||||
tempregs[i] = temp;
|
||||
}
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
u8 temp = tempregs[i];
|
||||
fpr.MapRegV(temp, 0);
|
||||
MOVSS(fpr.V(dregs[i]), fpr.VX(temp));
|
||||
}
|
||||
|
||||
fpr.ReleaseSpillLocks();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -203,6 +203,10 @@ public:
|
||||
void Comp_Mftv(u32 op);
|
||||
void Comp_Vmtvc(u32 op);
|
||||
void Comp_Vmmov(u32 op);
|
||||
void Comp_VScl(u32 op);
|
||||
void Comp_Vmmul(u32 op);
|
||||
void Comp_Vmscl(u32 op);
|
||||
void Comp_Vtfm(u32 op);
|
||||
|
||||
void Comp_DoNothing(u32 op);
|
||||
|
||||
|
||||
Reference in new issue
Block a user