2009-09-07 19:23:46 +00:00
|
|
|
#include "VuBasicBlock.h"
|
|
|
|
#include "MA_VU.h"
|
|
|
|
#include "offsetof_def.h"
|
|
|
|
|
|
|
|
CVuBasicBlock::CVuBasicBlock(CMIPS& context, uint32 begin, uint32 end) :
|
|
|
|
CBasicBlock(context, begin, end)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CVuBasicBlock::~CVuBasicBlock()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-03 21:13:57 +00:00
|
|
|
void CVuBasicBlock::CompileRange(CMipsJitter* jitter)
|
2009-09-07 19:23:46 +00:00
|
|
|
{
|
|
|
|
assert((m_begin & 0x07) == 0);
|
|
|
|
assert(((m_end + 4) & 0x07) == 0);
|
2009-06-06 15:38:03 +00:00
|
|
|
CMA_VU* arch = static_cast<CMA_VU*>(m_context.m_pArch);
|
|
|
|
for(uint32 address = m_begin; address <= m_end; address += 8)
|
|
|
|
{
|
2012-03-18 01:52:44 +00:00
|
|
|
uint32 relativePipeTime = (address - m_begin) / 8;
|
|
|
|
|
2009-06-06 15:38:03 +00:00
|
|
|
uint32 addressLo = address + 0;
|
|
|
|
uint32 addressHi = address + 4;
|
|
|
|
|
|
|
|
uint32 opcodeLo = m_context.m_pMemoryMap->GetInstruction(addressLo);
|
|
|
|
uint32 opcodeHi = m_context.m_pMemoryMap->GetInstruction(addressHi);
|
|
|
|
|
|
|
|
VUShared::OPERANDSET loOps = arch->GetAffectedOperands(&m_context, addressLo, opcodeLo);
|
|
|
|
VUShared::OPERANDSET hiOps = arch->GetAffectedOperands(&m_context, addressHi, opcodeHi);
|
|
|
|
|
2011-04-03 05:25:07 +00:00
|
|
|
//No upper instruction writes to Q
|
|
|
|
assert(hiOps.syncQ == false);
|
2012-03-18 01:52:44 +00:00
|
|
|
|
|
|
|
//No lower instruction reads Q
|
|
|
|
assert(loOps.readQ == false);
|
2011-04-03 05:25:07 +00:00
|
|
|
|
2009-06-06 15:38:03 +00:00
|
|
|
if(opcodeHi & 0x80000000)
|
|
|
|
{
|
2010-09-03 21:13:57 +00:00
|
|
|
arch->CompileInstruction(addressHi, jitter, &m_context);
|
2009-06-06 15:38:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-04-03 05:25:07 +00:00
|
|
|
if(loOps.syncQ)
|
|
|
|
{
|
|
|
|
VUShared::FlushPipeline(VUShared::g_pipeInfoQ, jitter);
|
|
|
|
}
|
2012-03-18 01:52:44 +00:00
|
|
|
|
|
|
|
if(hiOps.readQ)
|
2011-04-03 05:25:07 +00:00
|
|
|
{
|
2012-03-18 01:52:44 +00:00
|
|
|
VUShared::CheckPipeline(VUShared::g_pipeInfoQ, jitter, relativePipeTime);
|
2011-04-03 05:25:07 +00:00
|
|
|
}
|
|
|
|
|
2009-06-06 15:38:03 +00:00
|
|
|
uint8 savedReg = 0;
|
|
|
|
|
|
|
|
if(hiOps.writeF != 0)
|
|
|
|
{
|
|
|
|
assert(hiOps.writeF != loOps.writeF);
|
|
|
|
if(
|
|
|
|
(hiOps.writeF == loOps.readF0) ||
|
|
|
|
(hiOps.writeF == loOps.readF1)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
savedReg = hiOps.writeF;
|
2010-09-03 21:13:57 +00:00
|
|
|
jitter->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[savedReg]));
|
|
|
|
jitter->MD_PullRel(offsetof(CMIPS, m_State.nCOP2VF_PreUp));
|
2009-06-06 15:38:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-18 01:52:44 +00:00
|
|
|
arch->SetRelativePipeTime(relativePipeTime);
|
2010-09-03 21:13:57 +00:00
|
|
|
arch->CompileInstruction(addressHi, jitter, &m_context);
|
2009-06-06 15:38:03 +00:00
|
|
|
|
|
|
|
if(savedReg != 0)
|
|
|
|
{
|
2010-09-03 21:13:57 +00:00
|
|
|
jitter->MD_PushRel(offsetof(CMIPS, m_State.nCOP2[savedReg]));
|
|
|
|
jitter->MD_PullRel(offsetof(CMIPS, m_State.nCOP2VF_UpRes));
|
2009-06-06 15:38:03 +00:00
|
|
|
|
2010-09-03 21:13:57 +00:00
|
|
|
jitter->MD_PushRel(offsetof(CMIPS, m_State.nCOP2VF_PreUp));
|
|
|
|
jitter->MD_PullRel(offsetof(CMIPS, m_State.nCOP2[savedReg]));
|
2009-06-06 15:38:03 +00:00
|
|
|
}
|
|
|
|
|
2010-09-03 21:13:57 +00:00
|
|
|
arch->CompileInstruction(addressLo, jitter, &m_context);
|
2009-06-06 15:38:03 +00:00
|
|
|
|
|
|
|
if(savedReg != 0)
|
|
|
|
{
|
2010-09-03 21:13:57 +00:00
|
|
|
jitter->MD_PushRel(offsetof(CMIPS, m_State.nCOP2VF_UpRes));
|
|
|
|
jitter->MD_PullRel(offsetof(CMIPS, m_State.nCOP2[savedReg]));
|
2009-06-06 15:38:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Sanity check
|
2010-09-03 21:13:57 +00:00
|
|
|
assert(jitter->IsStackEmpty());
|
2009-09-07 19:23:46 +00:00
|
|
|
}
|
2012-03-18 01:52:44 +00:00
|
|
|
|
|
|
|
//Increment pipeTime
|
|
|
|
{
|
|
|
|
uint32 timeInc = ((m_end - m_begin) / 8) + 1;
|
|
|
|
jitter->PushRel(offsetof(CMIPS, m_State.pipeTime));
|
|
|
|
jitter->PushCst(timeInc);
|
|
|
|
jitter->Add();
|
|
|
|
jitter->PullRel(offsetof(CMIPS, m_State.pipeTime));
|
|
|
|
}
|
2009-09-07 19:23:46 +00:00
|
|
|
}
|