2007-12-07 00:26:56 +00:00
|
|
|
#include "VUShared.h"
|
|
|
|
#include "MIPS.h"
|
|
|
|
#include "offsetof_def.h"
|
|
|
|
|
2008-05-02 00:55:54 +00:00
|
|
|
#define LATENCY_DIV (7)
|
|
|
|
#define LATENCY_SQRT (7)
|
|
|
|
#define LATENCY_RSQRT (13)
|
|
|
|
|
|
|
|
const VUShared::PIPEINFO g_pipeInfoQ =
|
|
|
|
{
|
|
|
|
offsetof(CMIPS, m_State.nCOP2Q),
|
|
|
|
// offsetof(CMIPS, m_State.pipeQ.heldValue),
|
|
|
|
offsetof(CMIPS, m_State.nCOP2Q),
|
|
|
|
offsetof(CMIPS, m_State.pipeQ.target)
|
|
|
|
};
|
|
|
|
|
2007-12-07 00:26:56 +00:00
|
|
|
using namespace VUShared;
|
2008-02-28 02:16:54 +00:00
|
|
|
using namespace std;
|
2007-12-07 00:26:56 +00:00
|
|
|
|
|
|
|
bool VUShared::DestinationHasElement(uint8 nDest, unsigned int nElement)
|
|
|
|
{
|
|
|
|
return (nDest & (1 << (nElement ^ 0x03))) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32* VUShared::GetVectorElement(CMIPS* pCtx, unsigned int nReg, unsigned int nElement)
|
|
|
|
{
|
|
|
|
switch(nElement)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return &pCtx->m_State.nCOP2[nReg].nV0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return &pCtx->m_State.nCOP2[nReg].nV1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return &pCtx->m_State.nCOP2[nReg].nV2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return &pCtx->m_State.nCOP2[nReg].nV3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t VUShared::GetVectorElement(unsigned int nRegister, unsigned int nElement)
|
|
|
|
{
|
|
|
|
return offsetof(CMIPS, m_State.nCOP2[nRegister].nV[nElement]);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32* VUShared::GetAccumulatorElement(CMIPS* pCtx, unsigned int nElement)
|
|
|
|
{
|
|
|
|
switch(nElement)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return &pCtx->m_State.nCOP2A.nV0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return &pCtx->m_State.nCOP2A.nV1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return &pCtx->m_State.nCOP2A.nV2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return &pCtx->m_State.nCOP2A.nV3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-02-28 02:16:54 +00:00
|
|
|
size_t VUShared::GetAccumulatorElement(unsigned int nElement)
|
|
|
|
{
|
|
|
|
return offsetof(CMIPS, m_State.nCOP2A.nV[nElement]);
|
|
|
|
}
|
|
|
|
|
2008-04-09 02:52:38 +00:00
|
|
|
void VUShared::PullVector(CCodeGen* codeGen, uint8 dest, size_t vector)
|
2008-02-27 02:23:28 +00:00
|
|
|
{
|
|
|
|
codeGen->MD_PullRel(
|
|
|
|
DestinationHasElement(dest, 0) ? vector + 0x0 : SIZE_MAX,
|
|
|
|
DestinationHasElement(dest, 1) ? vector + 0x4 : SIZE_MAX,
|
|
|
|
DestinationHasElement(dest, 2) ? vector + 0x8 : SIZE_MAX,
|
|
|
|
DestinationHasElement(dest, 3) ? vector + 0xC : SIZE_MAX);
|
|
|
|
}
|
|
|
|
|
2008-06-07 17:57:36 +00:00
|
|
|
void VUShared::ADDA_base(CCodeGen* codeGen, uint8 dest, size_t fs, size_t ft, bool expand)
|
|
|
|
{
|
|
|
|
codeGen->MD_PushRel(fs);
|
|
|
|
if(expand)
|
|
|
|
{
|
|
|
|
codeGen->MD_PushRelExpand(ft);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
codeGen->MD_PushRel(ft);
|
|
|
|
}
|
|
|
|
codeGen->MD_AddS();
|
|
|
|
PullVector(codeGen, dest, offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
}
|
|
|
|
|
|
|
|
void VUShared::MSUB_base(CCodeGen* codeGen, uint8 dest, size_t fd, size_t fs, size_t ft, bool expand)
|
|
|
|
{
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
codeGen->MD_PushRel(fs);
|
|
|
|
if(expand)
|
|
|
|
{
|
|
|
|
codeGen->MD_PushRelExpand(ft);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
codeGen->MD_PushRel(ft);
|
|
|
|
}
|
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_SubS();
|
|
|
|
PullVector(codeGen, dest, fd);
|
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::ABS(CCodeGen* codeGen, uint8 nDest, uint8 nFt, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_AbsS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFt]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 02:23:28 +00:00
|
|
|
void VUShared::ADD(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-27 02:23:28 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFt]));
|
|
|
|
codeGen->MD_AddS();
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2008-02-27 02:23:28 +00:00
|
|
|
//Get result flags
|
|
|
|
codeGen->PushTop();
|
|
|
|
codeGen->PushTop();
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2008-02-27 02:23:28 +00:00
|
|
|
codeGen->MD_IsNegative();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2SF));
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2008-02-27 02:23:28 +00:00
|
|
|
codeGen->MD_IsZero();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2ZF));
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2008-02-27 02:23:28 +00:00
|
|
|
//Save result
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 02:11:27 +00:00
|
|
|
void VUShared::ADDbc(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt, uint8 nBc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-29 02:11:27 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[nFt].nV[nBc]));
|
|
|
|
codeGen->MD_AddS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 01:09:44 +00:00
|
|
|
void VUShared::ADDi(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-18 01:09:44 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2I));
|
|
|
|
codeGen->MD_AddS();
|
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 00:55:54 +00:00
|
|
|
void VUShared::ADDq(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint32 address)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-05-02 00:55:54 +00:00
|
|
|
VerifyPipeline(g_pipeInfoQ, codeGen, address);
|
2008-02-29 02:11:27 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2Q));
|
|
|
|
codeGen->MD_AddS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-06-07 17:57:36 +00:00
|
|
|
void VUShared::ADDA(CCodeGen* codeGen, uint8 dest, uint8 fs, uint8 ft)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-06-07 17:57:36 +00:00
|
|
|
ADDA_base(codeGen, dest,
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[fs]),
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[ft]),
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VUShared::ADDAbc(CCodeGen* codeGen, uint8 dest, uint8 fs, uint8 ft, uint8 bc)
|
|
|
|
{
|
|
|
|
ADDA_base(codeGen, dest,
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[fs]),
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[ft].nV[bc]),
|
|
|
|
true);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-19 16:50:09 +00:00
|
|
|
void VUShared::CLIP(CCodeGen* codeGen, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-19 16:50:09 +00:00
|
|
|
//Create some space for the new test results
|
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2CF));
|
|
|
|
codeGen->Shl(6);
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2CF));
|
2008-04-07 00:51:28 +00:00
|
|
|
|
2008-04-19 16:50:09 +00:00
|
|
|
for(unsigned int i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
//c > +|w|
|
|
|
|
codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP2[nFt].nV[3]));
|
|
|
|
codeGen->FP_Abs();
|
|
|
|
codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP2[nFs].nV[i]));
|
|
|
|
codeGen->FP_Cmp(CCodeGen::CONDITION_AB);
|
|
|
|
|
|
|
|
codeGen->BeginIf(true);
|
|
|
|
{
|
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2CF));
|
|
|
|
codeGen->PushCst(1 << ((i * 2) + 0));
|
|
|
|
codeGen->Or();
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2CF));
|
|
|
|
}
|
|
|
|
codeGen->EndIf();
|
|
|
|
|
|
|
|
//c < -|w|
|
|
|
|
codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP2[nFt].nV[3]));
|
|
|
|
codeGen->FP_Abs();
|
|
|
|
codeGen->FP_Neg();
|
|
|
|
codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP2[nFs].nV[i]));
|
|
|
|
codeGen->FP_Cmp(CCodeGen::CONDITION_BL);
|
|
|
|
|
|
|
|
codeGen->BeginIf(true);
|
|
|
|
{
|
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2CF));
|
|
|
|
codeGen->PushCst(1 << ((i * 2) + 1));
|
|
|
|
codeGen->Or();
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2CF));
|
|
|
|
}
|
|
|
|
codeGen->EndIf();
|
|
|
|
}
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 00:55:54 +00:00
|
|
|
void VUShared::DIV(CCodeGen* codeGen, uint8 nFs, uint8 nFsf, uint8 nFt, uint8 nFtf, uint32 address, unsigned int pipeMult)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-05-02 00:55:54 +00:00
|
|
|
size_t destination = g_pipeInfoQ.heldValue;
|
|
|
|
QueueInPipeline(g_pipeInfoQ, codeGen, address + (pipeMult * 4 * LATENCY_DIV));
|
|
|
|
|
2008-02-29 02:11:27 +00:00
|
|
|
//Check for zero
|
|
|
|
codeGen->PushRel(GetVectorElement(nFt, nFtf));
|
|
|
|
codeGen->PushCst(0x7FFFFFFF);
|
|
|
|
codeGen->And();
|
|
|
|
codeGen->PushCst(0);
|
|
|
|
codeGen->Cmp(CCodeGen::CONDITION_EQ);
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2008-02-29 02:11:27 +00:00
|
|
|
codeGen->BeginIfElse(true);
|
|
|
|
{
|
|
|
|
codeGen->PushCst(0x7F7FFFFF);
|
|
|
|
codeGen->PushRel(GetVectorElement(nFs, nFsf));
|
|
|
|
codeGen->PushRel(GetVectorElement(nFt, nFtf));
|
|
|
|
codeGen->Xor();
|
|
|
|
codeGen->PushCst(0x80000000);
|
|
|
|
codeGen->And();
|
|
|
|
codeGen->Or();
|
2008-05-02 00:55:54 +00:00
|
|
|
codeGen->PullRel(destination);
|
2008-02-29 02:11:27 +00:00
|
|
|
}
|
|
|
|
codeGen->BeginIfElseAlt();
|
|
|
|
{
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, nFsf));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, nFtf));
|
|
|
|
codeGen->FP_Div();
|
2008-05-02 00:55:54 +00:00
|
|
|
codeGen->FP_PullSingle(destination);
|
2008-02-29 02:11:27 +00:00
|
|
|
}
|
|
|
|
codeGen->EndIf();
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 03:14:33 +00:00
|
|
|
void VUShared::FTOI0(CCodeGen* codeGen, uint8 nDest, uint8 nFt, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-06 03:14:33 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_ToWordTruncate();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFt]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 03:14:33 +00:00
|
|
|
void VUShared::FTOI4(CCodeGen* codeGen, uint8 nDest, uint8 nFt, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-06 03:14:33 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushCstExpand(16.0f);
|
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_ToWordTruncate();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFt]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-16 22:31:37 +00:00
|
|
|
void VUShared::ITOF0(CCodeGen* codeGen, uint8 nDest, uint8 nFt, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-16 22:31:37 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_ToSingle();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFt]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-06-09 00:06:58 +00:00
|
|
|
void VUShared::ITOF15(CCodeGen* codeGen, uint8 dest, uint8 ft, uint8 fs)
|
|
|
|
{
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[fs]));
|
|
|
|
codeGen->MD_ToSingle();
|
|
|
|
codeGen->MD_PushCstExpand(32768.0f);
|
|
|
|
codeGen->MD_DivS();
|
|
|
|
PullVector(codeGen, dest, offsetof(CMIPS, m_State.nCOP2[ft]));
|
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::MADD(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFt]));
|
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_AddS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-28 02:16:54 +00:00
|
|
|
void VUShared::MADDbc(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt, uint8 nBc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-28 02:16:54 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[nFt].nV[nBc]));
|
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_AddS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::MADDA(CCodeGen* codeGen, uint8 nDest, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFt]));
|
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_AddS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-28 02:16:54 +00:00
|
|
|
void VUShared::MADDAbc(CCodeGen* codeGen, uint8 nDest, uint8 nFs, uint8 nFt, uint8 nBc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-28 02:16:54 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[nFt].nV[nBc]));
|
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_AddS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::MADDAi(CCodeGen* codeGen, uint8 nDest, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2I));
|
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_AddS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-16 22:31:37 +00:00
|
|
|
void VUShared::MAX(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-16 22:31:37 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFt]));
|
|
|
|
codeGen->MD_MaxS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-15 16:20:36 +00:00
|
|
|
void VUShared::MAXbc(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt, uint8 nBc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-15 16:20:36 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[nFt].nV[nBc]));
|
|
|
|
codeGen->MD_MaxS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-16 22:31:37 +00:00
|
|
|
void VUShared::MINI(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-16 22:31:37 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFt]));
|
|
|
|
codeGen->MD_MinS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-15 16:20:36 +00:00
|
|
|
void VUShared::MINIbc(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt, uint8 nBc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-15 16:20:36 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[nFt].nV[nBc]));
|
|
|
|
codeGen->MD_MinS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 20:55:03 +00:00
|
|
|
void VUShared::MINIi(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-20 20:55:03 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2I));
|
|
|
|
codeGen->MD_MinS();
|
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 02:11:27 +00:00
|
|
|
void VUShared::MOVE(CCodeGen* codeGen, uint8 nDest, uint8 nFt, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-29 02:11:27 +00:00
|
|
|
for(unsigned int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if(!DestinationHasElement(nDest, i)) continue;
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2008-02-29 02:11:27 +00:00
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2[nFs].nV[i]));
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2[nFt].nV[i]));
|
|
|
|
}
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 02:23:28 +00:00
|
|
|
void VUShared::MR32(CCodeGen* codeGen, uint8 nDest, uint8 nFt, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-27 02:23:28 +00:00
|
|
|
for(unsigned int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if(!DestinationHasElement(nDest, i)) continue;
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2008-02-27 02:23:28 +00:00
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2[nFs].nV[(i + 1) & 3]));
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2[nFt].nV[i]));
|
|
|
|
}
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-06-07 17:57:36 +00:00
|
|
|
void VUShared::MSUBbc(CCodeGen* codeGen, uint8 dest, uint8 fd, uint8 fs, uint8 ft, uint8 bc)
|
|
|
|
{
|
|
|
|
MSUB_base(codeGen, dest,
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[fd]),
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[fs]),
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[ft].nV[bc]),
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::MSUBi(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs)
|
2008-06-07 17:57:36 +00:00
|
|
|
{
|
|
|
|
MSUB_base(codeGen, nDest,
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[nFd]),
|
|
|
|
offsetof(CMIPS, m_State.nCOP2[nFs]),
|
|
|
|
offsetof(CMIPS, m_State.nCOP2I),
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VUShared::MSUBAbc(CCodeGen* codeGen, uint8 dest, uint8 fs, uint8 ft, uint8 bc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2A));
|
2008-06-07 17:57:36 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[fs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[ft].nV[bc]));
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_SubS();
|
2008-06-07 17:57:36 +00:00
|
|
|
PullVector(codeGen, dest, offsetof(CMIPS, m_State.nCOP2A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::MSUBAi(CCodeGen* codeGen, uint8 nDest, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2I));
|
|
|
|
codeGen->MD_MulS();
|
|
|
|
codeGen->MD_SubS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 02:11:27 +00:00
|
|
|
void VUShared::MUL(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-29 02:11:27 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFt]));
|
|
|
|
codeGen->MD_MulS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-03 00:38:28 +00:00
|
|
|
void VUShared::MULbc(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt, uint8 nBc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-03 00:38:28 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[nFt].nV[nBc]));
|
|
|
|
codeGen->MD_MulS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-24 01:18:20 +00:00
|
|
|
void VUShared::MULi(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-24 01:18:20 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2I));
|
|
|
|
codeGen->MD_MulS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 00:55:54 +00:00
|
|
|
void VUShared::MULq(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint32 address)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-05-02 00:55:54 +00:00
|
|
|
VerifyPipeline(g_pipeInfoQ, codeGen, address);
|
2008-02-29 02:11:27 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2Q));
|
|
|
|
codeGen->MD_MulS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::MULA(CCodeGen* codeGen, uint8 nDest, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFt]));
|
|
|
|
codeGen->MD_MulS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-28 02:16:54 +00:00
|
|
|
void VUShared::MULAbc(CCodeGen* codeGen, uint8 nDest, uint8 nFs, uint8 nFt, uint8 nBc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-28 02:16:54 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[nFt].nV[nBc]));
|
|
|
|
codeGen->MD_MulS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::MULAi(CCodeGen* codeGen, uint8 nDest, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2I));
|
|
|
|
codeGen->MD_MulS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-28 02:16:54 +00:00
|
|
|
void VUShared::OPMULA(CCodeGen* codeGen, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-28 02:16:54 +00:00
|
|
|
//ACCx
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, VECTOR_COMPY));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, VECTOR_COMPZ));
|
|
|
|
codeGen->FP_Mul();
|
|
|
|
codeGen->FP_PullSingle(GetAccumulatorElement(VECTOR_COMPX));
|
|
|
|
|
|
|
|
//ACCy
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, VECTOR_COMPZ));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, VECTOR_COMPX));
|
|
|
|
codeGen->FP_Mul();
|
|
|
|
codeGen->FP_PullSingle(GetAccumulatorElement(VECTOR_COMPY));
|
|
|
|
|
|
|
|
//ACCz
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, VECTOR_COMPX));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, VECTOR_COMPY));
|
|
|
|
codeGen->FP_Mul();
|
|
|
|
codeGen->FP_PullSingle(GetAccumulatorElement(VECTOR_COMPZ));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-28 02:16:54 +00:00
|
|
|
void VUShared::OPMSUB(CCodeGen* codeGen, uint8 nFd, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
|
|
|
if(nFd == 0)
|
|
|
|
{
|
|
|
|
//Atelier Iris - OPMSUB with VF0 as FD...
|
|
|
|
//This is probably to set a flag which is tested a bit further
|
|
|
|
//The flag tested is Sz
|
2008-04-19 16:50:09 +00:00
|
|
|
codeGen->PushCst(0);
|
|
|
|
|
|
|
|
codeGen->FP_PushSingle(GetAccumulatorElement(VECTOR_COMPZ));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, VECTOR_COMPX));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, VECTOR_COMPY));
|
|
|
|
codeGen->FP_Mul();
|
|
|
|
codeGen->FP_Sub();
|
|
|
|
|
|
|
|
codeGen->FP_Cmp(CCodeGen::CONDITION_BL);
|
|
|
|
|
|
|
|
codeGen->BeginIfElse(true);
|
|
|
|
{
|
|
|
|
codeGen->PushCst(0xFFFFFFFF);
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2SF.nV[2]));
|
|
|
|
}
|
|
|
|
codeGen->BeginIfElseAlt();
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-19 16:50:09 +00:00
|
|
|
codeGen->PushCst(0);
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2SF.nV[2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
2008-04-19 16:50:09 +00:00
|
|
|
codeGen->EndIf();
|
2007-12-07 00:26:56 +00:00
|
|
|
return;
|
2008-02-28 02:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//X
|
|
|
|
codeGen->FP_PushSingle(GetAccumulatorElement(VECTOR_COMPX));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, VECTOR_COMPY));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, VECTOR_COMPZ));
|
|
|
|
codeGen->FP_Mul();
|
|
|
|
codeGen->FP_Sub();
|
|
|
|
codeGen->FP_PullSingle(GetVectorElement(nFd, VECTOR_COMPX));
|
|
|
|
|
|
|
|
//Y
|
|
|
|
codeGen->FP_PushSingle(GetAccumulatorElement(VECTOR_COMPY));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, VECTOR_COMPZ));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, VECTOR_COMPX));
|
|
|
|
codeGen->FP_Mul();
|
|
|
|
codeGen->FP_Sub();
|
|
|
|
codeGen->FP_PullSingle(GetVectorElement(nFd, VECTOR_COMPY));
|
|
|
|
|
|
|
|
//Z
|
|
|
|
codeGen->FP_PushSingle(GetAccumulatorElement(VECTOR_COMPZ));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, VECTOR_COMPX));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, VECTOR_COMPY));
|
|
|
|
codeGen->FP_Mul();
|
|
|
|
codeGen->FP_Sub();
|
|
|
|
codeGen->FP_PullSingle(GetVectorElement(nFd, VECTOR_COMPZ));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 20:55:03 +00:00
|
|
|
void VUShared::RINIT(CCodeGen* codeGen, uint8 nFs, uint8 nFsf)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-20 20:55:03 +00:00
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2[nFs].nV[nFsf]));
|
|
|
|
codeGen->PushCst(0x007FFFFF);
|
|
|
|
codeGen->And();
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2R));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-06-07 17:57:36 +00:00
|
|
|
void VUShared::RGET(CCodeGen* codeGen, uint8 dest, uint8 ft)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if(!VUShared::DestinationHasElement(dest, i)) continue;
|
|
|
|
|
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2R));
|
|
|
|
codeGen->PushCst(0x3F800000);
|
|
|
|
codeGen->Or();
|
|
|
|
codeGen->PullRel(VUShared::GetVectorElement(ft, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VUShared::RNEXT(CCodeGen* codeGen, uint8 dest, uint8 ft)
|
|
|
|
{
|
|
|
|
//Compute next R
|
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2R));
|
|
|
|
codeGen->PushCst(0xDEADBEEF);
|
|
|
|
codeGen->Xor();
|
|
|
|
codeGen->PushCst(0xDEADBEEF);
|
|
|
|
codeGen->Add();
|
|
|
|
codeGen->PushCst(0x007FFFFF);
|
|
|
|
codeGen->And();
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2R));
|
|
|
|
|
|
|
|
RGET(codeGen, dest, ft);
|
|
|
|
}
|
|
|
|
|
2008-05-02 00:55:54 +00:00
|
|
|
void VUShared::RSQRT(CCodeGen* codeGen, uint8 nFs, uint8 nFsf, uint8 nFt, uint8 nFtf, uint32 address, unsigned int pipeMult)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-05-02 00:55:54 +00:00
|
|
|
size_t destination = g_pipeInfoQ.heldValue;
|
|
|
|
QueueInPipeline(g_pipeInfoQ, codeGen, address + (pipeMult * 4 * LATENCY_RSQRT));
|
|
|
|
|
2008-03-03 00:38:28 +00:00
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFs, nFsf));
|
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, nFtf));
|
|
|
|
codeGen->FP_Rsqrt();
|
|
|
|
codeGen->FP_Mul();
|
2008-05-02 00:55:54 +00:00
|
|
|
codeGen->FP_PullSingle(destination);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-05-28 02:29:57 +00:00
|
|
|
void VUShared::RXOR(CCodeGen* codeGen, uint8 nFs, uint8 nFsf)
|
|
|
|
{
|
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2[nFs].nV[nFsf]));
|
|
|
|
codeGen->PushRel(offsetof(CMIPS, m_State.nCOP2R));
|
|
|
|
codeGen->Xor();
|
|
|
|
codeGen->PushCst(0x007FFFFF);
|
|
|
|
codeGen->And();
|
|
|
|
codeGen->PullRel(offsetof(CMIPS, m_State.nCOP2R));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 00:55:54 +00:00
|
|
|
void VUShared::SQRT(CCodeGen* codeGen, uint8 nFt, uint8 nFtf, uint32 address, unsigned int pipeMult)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-05-02 00:55:54 +00:00
|
|
|
size_t destination = g_pipeInfoQ.heldValue;
|
|
|
|
QueueInPipeline(g_pipeInfoQ, codeGen, address + (pipeMult * 4 * LATENCY_SQRT));
|
|
|
|
|
2008-02-29 02:11:27 +00:00
|
|
|
codeGen->FP_PushSingle(GetVectorElement(nFt, nFtf));
|
|
|
|
codeGen->FP_Sqrt();
|
2008-05-02 00:55:54 +00:00
|
|
|
codeGen->FP_PullSingle(destination);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 02:23:28 +00:00
|
|
|
void VUShared::SUB(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-02-27 02:23:28 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFt]));
|
|
|
|
codeGen->MD_SubS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-15 16:20:36 +00:00
|
|
|
void VUShared::SUBbc(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs, uint8 nFt, uint8 nBc)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-03-15 16:20:36 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[nFt].nV[nBc]));
|
|
|
|
codeGen->MD_SubS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-04 01:50:41 +00:00
|
|
|
void VUShared::SUBi(CCodeGen* codeGen, uint8 nDest, uint8 nFd, uint8 nFs)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-04-04 01:50:41 +00:00
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[nFs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2I));
|
|
|
|
codeGen->MD_SubS();
|
2008-04-09 02:52:38 +00:00
|
|
|
PullVector(codeGen, nDest, offsetof(CMIPS, m_State.nCOP2[nFd]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
2008-05-02 00:55:54 +00:00
|
|
|
|
2008-06-07 17:57:36 +00:00
|
|
|
void VUShared::SUBAbc(CCodeGen* codeGen, uint8 dest, uint8 fs, uint8 ft, uint8 bc)
|
|
|
|
{
|
|
|
|
codeGen->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[fs]));
|
|
|
|
codeGen->MD_PushRelExpand(offsetof(CMIPS, m_State.nCOP2[ft].nV[bc]));
|
|
|
|
codeGen->MD_SubS();
|
|
|
|
PullVector(codeGen, dest, offsetof(CMIPS, m_State.nCOP2A));
|
|
|
|
}
|
|
|
|
|
2008-05-02 00:55:54 +00:00
|
|
|
void VUShared::WAITQ(CCodeGen* codeGen)
|
|
|
|
{
|
|
|
|
FlushPipeline(g_pipeInfoQ, codeGen);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VUShared::FlushPipeline(const PIPEINFO& pipeInfo, CCodeGen* codeGen)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Dump the current value if one pending
|
|
|
|
codeGen->PushCst(MIPS_INVALID_PC);
|
|
|
|
codeGen->PushRel(pipeInfo.target);
|
|
|
|
codeGen->Cmp(CCodeGen::CONDITION_EQ);
|
|
|
|
|
|
|
|
codeGen->BeginIf(false);
|
|
|
|
{
|
|
|
|
codeGen->PushRel(pipeInfo.heldValue);
|
|
|
|
codeGen->PullRel(pipeInfo.value);
|
|
|
|
|
|
|
|
codeGen->PushCst(MIPS_INVALID_PC);
|
|
|
|
codeGen->PullRel(pipeInfo.target);
|
|
|
|
}
|
|
|
|
codeGen->EndIf();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VUShared::QueueInPipeline(const PIPEINFO& pipeInfo, CCodeGen* codeGen, uint32 targetAddress)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
|
|
|
|
FlushPipeline(pipeInfo, codeGen);
|
|
|
|
|
|
|
|
//Set target
|
|
|
|
codeGen->PushCst(targetAddress);
|
|
|
|
codeGen->PullRel(pipeInfo.target);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VUShared::VerifyPipeline(const PIPEINFO& pipeInfo, CCodeGen* codeGen, uint32 currentAddress)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Dump current value if it's ready
|
|
|
|
codeGen->PushCst(currentAddress);
|
|
|
|
codeGen->PushRel(pipeInfo.target);
|
|
|
|
codeGen->Cmp(CCodeGen::CONDITION_BL);
|
|
|
|
|
|
|
|
codeGen->BeginIf(false);
|
|
|
|
{
|
|
|
|
codeGen->PushRel(pipeInfo.heldValue);
|
|
|
|
codeGen->PullRel(pipeInfo.value);
|
|
|
|
|
|
|
|
codeGen->PushCst(MIPS_INVALID_PC);
|
|
|
|
codeGen->PullRel(pipeInfo.target);
|
|
|
|
}
|
|
|
|
codeGen->EndIf();
|
|
|
|
}
|