SPU: Use named constants for MFC tag updates

This commit is contained in:
Eladash 2020-06-27 10:47:13 +03:00 committed by Ani
parent 20fcc6530f
commit 2c93fecd8b
3 changed files with 20 additions and 27 deletions

View File

@ -2477,7 +2477,7 @@ void spu_recompiler::WRCH(spu_opcode_t op)
Label ret = c->newLabel();
c->mov(qw0->r32(), SPU_OFF_32(gpr, op.rt, &v128::_u32, 3));
c->mov(SPU_OFF_32(ch_tag_mask), qw0->r32());
c->cmp(SPU_OFF_32(ch_tag_upd), 0);
c->cmp(SPU_OFF_32(ch_tag_upd), MFC_TAG_UPDATE_IMMEDIATE);
c->jnz(upd);
after.emplace_back([=, this, pos = m_pos]

View File

@ -5715,23 +5715,16 @@ public:
const auto stat_ptr = spu_ptr<u64>(&spu_thread::ch_tag_stat);
const auto stat_val = m_ir->CreateOr(m_ir->CreateZExt(completed, get_type<u64>()), INT64_MIN);
if (upd == 0)
if (upd == MFC_TAG_UPDATE_IMMEDIATE)
{
m_ir->CreateStore(m_ir->getInt32(0), upd_ptr);
m_ir->CreateStore(m_ir->getInt32(MFC_TAG_UPDATE_IMMEDIATE), upd_ptr);
m_ir->CreateStore(stat_val, stat_ptr);
return;
}
else if (upd == 1)
else if (upd <= MFC_TAG_UPDATE_ALL)
{
const auto cond = m_ir->CreateICmpNE(completed, m_ir->getInt32(0));
m_ir->CreateStore(m_ir->CreateSelect(cond, m_ir->getInt32(0), m_ir->getInt32(1)), upd_ptr);
m_ir->CreateStore(m_ir->CreateSelect(cond, stat_val, m_ir->getInt64(0)), stat_ptr);
return;
}
else if (upd == 2)
{
const auto cond = m_ir->CreateICmpEQ(completed, tag_mask);
m_ir->CreateStore(m_ir->CreateSelect(cond, m_ir->getInt32(0), m_ir->getInt32(2)), upd_ptr);
const auto cond = upd == MFC_TAG_UPDATE_ANY ? m_ir->CreateICmpNE(completed, m_ir->getInt32(0)) : m_ir->CreateICmpEQ(completed, tag_mask);
m_ir->CreateStore(m_ir->CreateSelect(cond, m_ir->getInt32(MFC_TAG_UPDATE_IMMEDIATE), m_ir->getInt32(static_cast<u32>(upd))), upd_ptr);
m_ir->CreateStore(m_ir->CreateSelect(cond, stat_val, m_ir->getInt64(0)), stat_ptr);
return;
}

View File

@ -1889,15 +1889,15 @@ void spu_thread::do_mfc(bool wait)
{
const u32 completed = get_mfc_completed();
if (completed && ch_tag_upd == 1)
if (completed && ch_tag_upd == MFC_TAG_UPDATE_ANY)
{
ch_tag_stat.set_value(completed);
ch_tag_upd = 0;
ch_tag_upd = MFC_TAG_UPDATE_IMMEDIATE;
}
else if (completed == ch_tag_mask && ch_tag_upd == 2)
else if (completed == ch_tag_mask && ch_tag_upd == MFC_TAG_UPDATE_ALL)
{
ch_tag_stat.set_value(completed);
ch_tag_upd = 0;
ch_tag_upd = MFC_TAG_UPDATE_IMMEDIATE;
}
}
@ -2769,15 +2769,15 @@ bool spu_thread::set_ch_value(u32 ch, u32 value)
{
const u32 completed = get_mfc_completed();
if (completed && ch_tag_upd == 1)
if (completed && ch_tag_upd == MFC_TAG_UPDATE_ANY)
{
ch_tag_stat.set_value(completed);
ch_tag_upd = 0;
ch_tag_upd = MFC_TAG_UPDATE_IMMEDIATE;
}
else if (completed == value && ch_tag_upd == 2)
else if (completed == value && ch_tag_upd == MFC_TAG_UPDATE_ALL)
{
ch_tag_stat.set_value(completed);
ch_tag_upd = 0;
ch_tag_upd = MFC_TAG_UPDATE_IMMEDIATE;
}
}
@ -2786,7 +2786,7 @@ bool spu_thread::set_ch_value(u32 ch, u32 value)
case MFC_WrTagUpdate:
{
if (value > 2)
if (value > MFC_TAG_UPDATE_ALL)
{
break;
}
@ -2795,17 +2795,17 @@ bool spu_thread::set_ch_value(u32 ch, u32 value)
if (!value)
{
ch_tag_upd = 0;
ch_tag_upd = MFC_TAG_UPDATE_IMMEDIATE;
ch_tag_stat.set_value(completed);
}
else if (completed && value == 1)
else if (completed && value == MFC_TAG_UPDATE_ANY)
{
ch_tag_upd = 0;
ch_tag_upd = MFC_TAG_UPDATE_IMMEDIATE;
ch_tag_stat.set_value(completed);
}
else if (completed == ch_tag_mask && value == 2)
else if (completed == ch_tag_mask && value == MFC_TAG_UPDATE_ALL)
{
ch_tag_upd = 0;
ch_tag_upd = MFC_TAG_UPDATE_IMMEDIATE;
ch_tag_stat.set_value(completed);
}
else