2007-12-07 00:26:56 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "COP_FPU.h"
|
|
|
|
#include "MIPS.h"
|
2010-08-11 03:47:19 +00:00
|
|
|
#include "Jitter.h"
|
2007-12-11 07:05:37 +00:00
|
|
|
#include "offsetof_def.h"
|
2008-04-09 02:52:38 +00:00
|
|
|
#include "MemoryUtils.h"
|
2007-12-07 00:26:56 +00:00
|
|
|
|
|
|
|
uint32 CCOP_FPU::m_nCCMask[8] =
|
|
|
|
{
|
|
|
|
0x00800000,
|
|
|
|
0x02000000,
|
|
|
|
0x04000000,
|
|
|
|
0x08000000,
|
|
|
|
0x10000000,
|
|
|
|
0x20000000,
|
|
|
|
0x40000000,
|
|
|
|
0x80000000
|
|
|
|
};
|
|
|
|
|
|
|
|
CCOP_FPU::CCOP_FPU(MIPS_REGSIZE nRegSize) :
|
2009-03-30 04:57:52 +00:00
|
|
|
CMIPSCoprocessor(nRegSize),
|
|
|
|
m_nFT(0),
|
|
|
|
m_nFS(0),
|
|
|
|
m_nFD(0)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
|
|
|
SetupReflectionTables();
|
|
|
|
}
|
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
void CCOP_FPU::CompileInstruction(uint32 nAddress, CMipsJitter* codeGen, CMIPS* pCtx)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2009-03-30 04:57:52 +00:00
|
|
|
SetupQuickVariables(nAddress, codeGen, pCtx);
|
2007-12-07 00:26:56 +00:00
|
|
|
|
|
|
|
m_nFT = (uint8)((m_nOpcode >> 16) & 0x1F);
|
|
|
|
m_nFS = (uint8)((m_nOpcode >> 11) & 0x1F);
|
|
|
|
m_nFD = (uint8)((m_nOpcode >> 6) & 0x1F);
|
|
|
|
|
|
|
|
switch((m_nOpcode >> 26) & 0x3F)
|
|
|
|
{
|
|
|
|
case 0x11:
|
|
|
|
//COP1
|
2009-03-30 04:57:52 +00:00
|
|
|
((this)->*(m_pOpGeneral[(m_nOpcode >> 21) & 0x1F]))();
|
2007-12-07 00:26:56 +00:00
|
|
|
break;
|
|
|
|
case 0x31:
|
|
|
|
LWC1();
|
|
|
|
break;
|
|
|
|
case 0x39:
|
|
|
|
SWC1();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCOP_FPU::SetCCBit(bool nCondition, uint32 nMask)
|
|
|
|
{
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->PushCst(0);
|
|
|
|
|
|
|
|
m_codeGen->BeginIf(nCondition ? Jitter::CONDITION_NE : Jitter::CONDITION_EQ);
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2007-12-29 17:22:26 +00:00
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nFCSR));
|
|
|
|
m_codeGen->PushCst(nMask);
|
|
|
|
m_codeGen->Or();
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nFCSR));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->Else();
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2007-12-29 17:22:26 +00:00
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nFCSR));
|
|
|
|
m_codeGen->PushCst(~nMask);
|
|
|
|
m_codeGen->And();
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nFCSR));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
2007-12-29 17:22:26 +00:00
|
|
|
m_codeGen->EndIf();
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
void CCOP_FPU::PushCCBit(uint32 nMask)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2007-12-29 17:22:26 +00:00
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nFCSR));
|
|
|
|
m_codeGen->PushCst(nMask);
|
|
|
|
m_codeGen->And();
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
//General Opcodes
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//00
|
|
|
|
void CCOP_FPU::MFC1()
|
|
|
|
{
|
2007-12-11 07:05:37 +00:00
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
2010-08-11 03:47:19 +00:00
|
|
|
if(m_regSize == MIPS_REGSIZE_64)
|
|
|
|
{
|
|
|
|
m_codeGen->SignExt();
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nGPR[m_nFT].nV[1]));
|
|
|
|
}
|
2007-12-11 07:05:37 +00:00
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nGPR[m_nFT].nV[0]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2010-04-29 03:47:06 +00:00
|
|
|
//02
|
|
|
|
void CCOP_FPU::CFC1()
|
|
|
|
{
|
|
|
|
if(m_nFS == 31)
|
|
|
|
{
|
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nFCSR));
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->SignExt();
|
2010-04-29 03:47:06 +00:00
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nGPR[m_nFT].nV[1]));
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nGPR[m_nFT].nV[0]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-07 00:26:56 +00:00
|
|
|
//04
|
|
|
|
void CCOP_FPU::MTC1()
|
|
|
|
{
|
2007-12-11 07:05:37 +00:00
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nGPR[m_nFT].nV[0]));
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//06
|
|
|
|
void CCOP_FPU::CTC1()
|
|
|
|
{
|
2008-01-19 03:36:27 +00:00
|
|
|
if(m_nFS == 31)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2008-01-19 03:36:27 +00:00
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nGPR[m_nFT].nV[0]));
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nFCSR));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
2008-01-19 03:36:27 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
}
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//08
|
|
|
|
void CCOP_FPU::BC1()
|
|
|
|
{
|
|
|
|
switch((m_nOpcode >> 16) & 0x03)
|
|
|
|
{
|
|
|
|
case 0x00:
|
|
|
|
BC1F();
|
|
|
|
break;
|
|
|
|
case 0x01:
|
|
|
|
BC1T();
|
|
|
|
break;
|
|
|
|
case 0x02:
|
|
|
|
BC1FL();
|
|
|
|
break;
|
|
|
|
case 0x03:
|
|
|
|
BC1TL();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//10
|
|
|
|
void CCOP_FPU::S()
|
|
|
|
{
|
2009-03-30 04:57:52 +00:00
|
|
|
((this)->*(m_pOpSingle[(m_nOpcode & 0x3F)]))();
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//14
|
|
|
|
void CCOP_FPU::W()
|
|
|
|
{
|
2009-03-30 04:57:52 +00:00
|
|
|
((this)->*(m_pOpWord[(m_nOpcode & 0x3F)]))();
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
//Branch Opcodes
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//00
|
|
|
|
void CCOP_FPU::BC1F()
|
|
|
|
{
|
2010-08-11 03:47:19 +00:00
|
|
|
PushCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
|
|
|
|
m_codeGen->PushCst(0);
|
|
|
|
Branch(Jitter::CONDITION_EQ);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//01
|
|
|
|
void CCOP_FPU::BC1T()
|
|
|
|
{
|
2010-08-11 03:47:19 +00:00
|
|
|
PushCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
|
|
|
|
m_codeGen->PushCst(0);
|
|
|
|
Branch(Jitter::CONDITION_NE);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//02
|
|
|
|
void CCOP_FPU::BC1FL()
|
|
|
|
{
|
2010-08-11 03:47:19 +00:00
|
|
|
PushCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
|
|
|
|
m_codeGen->PushCst(0);
|
|
|
|
BranchLikely(Jitter::CONDITION_EQ);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//03
|
|
|
|
void CCOP_FPU::BC1TL()
|
|
|
|
{
|
2010-08-11 03:47:19 +00:00
|
|
|
PushCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
|
|
|
|
m_codeGen->PushCst(0);
|
|
|
|
BranchLikely(Jitter::CONDITION_NE);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
//Single Precision Floating Point Opcodes
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//00
|
|
|
|
void CCOP_FPU::ADD_S()
|
|
|
|
{
|
2007-12-14 01:41:48 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Add();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//01
|
|
|
|
void CCOP_FPU::SUB_S()
|
|
|
|
{
|
2007-12-14 01:41:48 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Sub();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//02
|
|
|
|
void CCOP_FPU::MUL_S()
|
|
|
|
{
|
2007-12-14 01:41:48 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Mul();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//03
|
|
|
|
void CCOP_FPU::DIV_S()
|
|
|
|
{
|
2007-12-11 07:05:37 +00:00
|
|
|
//Check if FT equals to 0
|
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->PushCst(0);
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->BeginIf(Jitter::CONDITION_EQ);
|
2007-12-11 07:05:37 +00:00
|
|
|
{
|
|
|
|
m_codeGen->PushCst(0x7F7FFFFF);
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->Else();
|
2007-12-11 07:05:37 +00:00
|
|
|
{
|
2007-12-14 01:41:48 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Div();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-11 07:05:37 +00:00
|
|
|
}
|
|
|
|
m_codeGen->EndIf();
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//04
|
|
|
|
void CCOP_FPU::SQRT_S()
|
|
|
|
{
|
2008-02-17 23:51:25 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Sqrt();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//05
|
|
|
|
void CCOP_FPU::ABS_S()
|
|
|
|
{
|
2008-03-06 03:14:33 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_Abs();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//06
|
|
|
|
void CCOP_FPU::MOV_S()
|
|
|
|
{
|
2008-01-02 04:03:05 +00:00
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//07
|
|
|
|
void CCOP_FPU::NEG_S()
|
|
|
|
{
|
2008-01-07 04:05:17 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_Neg();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2010-04-29 03:47:06 +00:00
|
|
|
//0D
|
|
|
|
void CCOP_FPU::TRUNC_W_S()
|
|
|
|
{
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PullWordTruncate(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
|
|
|
}
|
|
|
|
|
2007-12-07 00:26:56 +00:00
|
|
|
//18
|
|
|
|
void CCOP_FPU::ADDA_S()
|
|
|
|
{
|
2008-01-19 03:36:27 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Add();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP1A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//1A
|
|
|
|
void CCOP_FPU::MULA_S()
|
|
|
|
{
|
2008-01-21 04:09:08 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Mul();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP1A));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//1C
|
|
|
|
void CCOP_FPU::MADD_S()
|
|
|
|
{
|
2008-01-21 04:09:08 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP1A));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Mul();
|
|
|
|
m_codeGen->FP_Add();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//1D
|
|
|
|
void CCOP_FPU::MSUB_S()
|
|
|
|
{
|
2008-01-21 04:09:08 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP1A));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Mul();
|
|
|
|
m_codeGen->FP_Sub();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//24
|
|
|
|
void CCOP_FPU::CVT_W_S()
|
|
|
|
{
|
2007-12-11 07:05:37 +00:00
|
|
|
//Load the rounding mode from FCSR?
|
|
|
|
//PS2 only supports truncate rounding mode
|
2007-12-14 01:41:48 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PullWordTruncate(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2009-05-02 02:11:55 +00:00
|
|
|
//28
|
|
|
|
void CCOP_FPU::MAX_S()
|
|
|
|
{
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Max();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
|
|
|
}
|
|
|
|
|
|
|
|
//29
|
|
|
|
void CCOP_FPU::MIN_S()
|
|
|
|
{
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_Min();
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
|
|
|
}
|
|
|
|
|
2007-12-07 00:26:56 +00:00
|
|
|
//32
|
|
|
|
void CCOP_FPU::C_EQ_S()
|
|
|
|
{
|
2007-12-29 17:22:26 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->FP_Cmp(Jitter::CONDITION_EQ);
|
2007-12-29 17:22:26 +00:00
|
|
|
|
|
|
|
SetCCBit(true, m_nCCMask[((m_nOpcode >> 8) & 0x07)]);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//34
|
|
|
|
void CCOP_FPU::C_LT_S()
|
|
|
|
{
|
2008-01-03 07:42:54 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->FP_Cmp(Jitter::CONDITION_BL);
|
2008-01-03 07:42:54 +00:00
|
|
|
|
|
|
|
SetCCBit(true, m_nCCMask[((m_nOpcode >> 8) & 0x07)]);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//36
|
|
|
|
void CCOP_FPU::C_LE_S()
|
|
|
|
{
|
2008-01-15 20:27:44 +00:00
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->FP_Cmp(Jitter::CONDITION_BE);
|
2008-01-15 20:27:44 +00:00
|
|
|
|
|
|
|
SetCCBit(true, m_nCCMask[((m_nOpcode >> 8) & 0x07)]);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
//Word Sized Integer Opcodes
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//20
|
|
|
|
void CCOP_FPU::CVT_S_W()
|
|
|
|
{
|
2007-12-14 01:41:48 +00:00
|
|
|
m_codeGen->FP_PushWord(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
|
|
|
|
m_codeGen->FP_PullSingle(offsetof(CMIPS, m_State.nCOP10[m_nFD * 2]));
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
//Miscellanous Opcodes
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//31
|
|
|
|
void CCOP_FPU::LWC1()
|
|
|
|
{
|
2008-04-09 02:52:38 +00:00
|
|
|
ComputeMemAccessAddr();
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->PushCtx();
|
2007-12-11 07:05:37 +00:00
|
|
|
m_codeGen->PushIdx(1);
|
2008-04-09 02:52:38 +00:00
|
|
|
m_codeGen->Call(reinterpret_cast<void*>(&CMemoryUtils::GetWordProxy), 2, true);
|
2007-12-11 07:05:37 +00:00
|
|
|
|
|
|
|
m_codeGen->PullRel(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
|
|
|
|
m_codeGen->PullTop();
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//39
|
|
|
|
void CCOP_FPU::SWC1()
|
|
|
|
{
|
2008-04-09 02:52:38 +00:00
|
|
|
ComputeMemAccessAddr();
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
m_codeGen->PushCtx();
|
2007-12-11 07:05:37 +00:00
|
|
|
m_codeGen->PushRel(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
|
|
|
|
m_codeGen->PushIdx(2);
|
2008-04-09 02:52:38 +00:00
|
|
|
m_codeGen->Call(reinterpret_cast<void*>(&CMemoryUtils::SetWordProxy), 3, false);
|
2007-12-11 07:05:37 +00:00
|
|
|
|
|
|
|
m_codeGen->PullTop();
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
//Opcode Tables
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
2009-03-30 04:57:52 +00:00
|
|
|
CCOP_FPU::InstructionFuncConstant CCOP_FPU::m_pOpGeneral[0x20] =
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
|
|
|
//0x00
|
2010-04-29 03:47:06 +00:00
|
|
|
&CCOP_FPU::MFC1, &CCOP_FPU::Illegal, &CCOP_FPU::CFC1, &CCOP_FPU::Illegal, &CCOP_FPU::MTC1, &CCOP_FPU::Illegal, &CCOP_FPU::CTC1, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x08
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::BC1, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x10
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::S, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::W, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x18
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
};
|
|
|
|
|
2009-03-30 04:57:52 +00:00
|
|
|
CCOP_FPU::InstructionFuncConstant CCOP_FPU::m_pOpSingle[0x40] =
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
|
|
|
//0x00
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::ADD_S, &CCOP_FPU::SUB_S, &CCOP_FPU::MUL_S, &CCOP_FPU::DIV_S, &CCOP_FPU::SQRT_S, &CCOP_FPU::ABS_S, &CCOP_FPU::MOV_S, &CCOP_FPU::NEG_S,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x08
|
2010-04-29 03:47:06 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::TRUNC_W_S, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x10
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x18
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::ADDA_S, &CCOP_FPU::Illegal, &CCOP_FPU::MULA_S, &CCOP_FPU::Illegal, &CCOP_FPU::MADD_S, &CCOP_FPU::MSUB_S, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x20
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::CVT_W_S, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x28
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::MAX_S, &CCOP_FPU::MIN_S, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x30
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::C_EQ_S, &CCOP_FPU::Illegal, &CCOP_FPU::C_LT_S, &CCOP_FPU::Illegal, &CCOP_FPU::C_LE_S, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x38
|
2010-04-29 03:47:06 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::C_LT_S, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
};
|
|
|
|
|
2009-03-30 04:57:52 +00:00
|
|
|
CCOP_FPU::InstructionFuncConstant CCOP_FPU::m_pOpWord[0x40] =
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
|
|
|
//0x00
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x08
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x10
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x18
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x20
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::CVT_S_W, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x28
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x30
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
//0x38
|
2009-09-07 19:23:46 +00:00
|
|
|
&CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal, &CCOP_FPU::Illegal,
|
2007-12-07 00:26:56 +00:00
|
|
|
};
|