CPU/Recompiler/AArch64: Use scratch for add CPU struct field

This commit is contained in:
Connor McLaughlin 2020-10-26 22:02:33 +10:00
parent 76428887b8
commit 875b0b91f1

View file

@ -1226,50 +1226,49 @@ void CodeGenerator::EmitAddCPUStructField(u32 offset, const Value& value)
const a64::MemOperand o_offset(GetCPUPtrReg(), s_offset); const a64::MemOperand o_offset(GetCPUPtrReg(), s_offset);
// Don't need to mask here because we're storing back to memory. // Don't need to mask here because we're storing back to memory.
Value temp = m_register_cache.AllocateScratch(value.size);
switch (value.size) switch (value.size)
{ {
case RegSize_8: case RegSize_8:
{ {
m_emit->Ldrb(GetHostReg8(temp), o_offset); m_emit->Ldrb(GetHostReg8(RSCRATCH), o_offset);
if (value.IsConstant()) if (value.IsConstant())
m_emit->Add(GetHostReg8(temp), GetHostReg8(temp), value.GetS64ConstantValue()); m_emit->Add(GetHostReg8(RSCRATCH), GetHostReg8(RSCRATCH), value.GetS64ConstantValue());
else else
m_emit->Add(GetHostReg8(temp), GetHostReg8(temp), GetHostReg8(value)); m_emit->Add(GetHostReg8(RSCRATCH), GetHostReg8(RSCRATCH), GetHostReg8(value));
m_emit->Strb(GetHostReg8(temp), o_offset); m_emit->Strb(GetHostReg8(RSCRATCH), o_offset);
} }
break; break;
case RegSize_16: case RegSize_16:
{ {
m_emit->Ldrh(GetHostReg16(temp), o_offset); m_emit->Ldrh(GetHostReg16(RSCRATCH), o_offset);
if (value.IsConstant()) if (value.IsConstant())
m_emit->Add(GetHostReg16(temp), GetHostReg16(temp), value.GetS64ConstantValue()); m_emit->Add(GetHostReg16(RSCRATCH), GetHostReg16(RSCRATCH), value.GetS64ConstantValue());
else else
m_emit->Add(GetHostReg16(temp), GetHostReg16(temp), GetHostReg16(value)); m_emit->Add(GetHostReg16(RSCRATCH), GetHostReg16(RSCRATCH), GetHostReg16(value));
m_emit->Strh(GetHostReg16(temp), o_offset); m_emit->Strh(GetHostReg16(RSCRATCH), o_offset);
} }
break; break;
case RegSize_32: case RegSize_32:
{ {
m_emit->Ldr(GetHostReg32(temp), o_offset); m_emit->Ldr(GetHostReg32(RSCRATCH), o_offset);
if (value.IsConstant()) if (value.IsConstant())
m_emit->Add(GetHostReg32(temp), GetHostReg32(temp), value.GetS64ConstantValue()); m_emit->Add(GetHostReg32(RSCRATCH), GetHostReg32(RSCRATCH), value.GetS64ConstantValue());
else else
m_emit->Add(GetHostReg32(temp), GetHostReg32(temp), GetHostReg32(value)); m_emit->Add(GetHostReg32(RSCRATCH), GetHostReg32(RSCRATCH), GetHostReg32(value));
m_emit->Str(GetHostReg32(temp), o_offset); m_emit->Str(GetHostReg32(RSCRATCH), o_offset);
} }
break; break;
case RegSize_64: case RegSize_64:
{ {
m_emit->Ldr(GetHostReg64(temp), o_offset); m_emit->Ldr(GetHostReg64(RSCRATCH), o_offset);
if (value.IsConstant()) if (value.IsConstant())
m_emit->Add(GetHostReg64(temp), GetHostReg64(temp), s64(value.constant_value)); m_emit->Add(GetHostReg64(RSCRATCH), GetHostReg64(RSCRATCH), s64(value.constant_value));
else else
m_emit->Add(GetHostReg64(temp), GetHostReg64(temp), GetHostReg64(value)); m_emit->Add(GetHostReg64(RSCRATCH), GetHostReg64(RSCRATCH), GetHostReg64(value));
m_emit->Str(GetHostReg64(temp), o_offset); m_emit->Str(GetHostReg64(RSCRATCH), o_offset);
} }
break; break;