CPU/Recompiler: Add EmitBindLabel and EmitBranchIfBitClear

This commit is contained in:
Connor McLaughlin 2019-12-25 01:04:08 +10:00
parent 03a36645a2
commit 4f2c1e1a6b
4 changed files with 55 additions and 0 deletions

View File

@ -80,6 +80,8 @@ public:
// Branching, generates two paths.
void EmitBranch(Condition condition, Reg lr_reg, Value&& branch_target);
void EmitBranchIfBitClear(HostReg reg, RegSize size, u8 bit, LabelType* label);
void EmitBindLabel(LabelType* label);
// Raising exception if condition is true.
void EmitRaiseException(Exception excode, Condition condition = Condition::Always);

View File

@ -1541,6 +1541,27 @@ void CodeGenerator::EmitBranch(Condition condition, Reg lr_reg, Value&& branch_t
m_register_cache.InvalidateGuestRegister(lr_reg);
}
void CodeGenerator::EmitBranchIfBitClear(HostReg reg, RegSize size, u8 bit, LabelType* label)
{
switch (size)
{
case RegSize_8:
case RegSize_16:
case RegSize_32:
m_emit->tbz(GetHostReg32(reg), bit, label);
break;
default:
UnreachableCode();
break;
}
}
void CodeGenerator::EmitBindLabel(LabelType* label)
{
m_emit->Bind(label);
}
void CodeGenerator::EmitRaiseException(Exception excode, Condition condition /* = Condition::Always */)
{
if (condition == Condition::Always)

View File

@ -1937,6 +1937,36 @@ void CodeGenerator::EmitBranch(Condition condition, Reg lr_reg, Value&& branch_t
m_register_cache.InvalidateGuestRegister(lr_reg);
}
void CodeGenerator::EmitBranchIfBitClear(HostReg reg, RegSize size, u8 bit, LabelType* label)
{
switch (size)
{
case RegSize_8:
m_emit->bt(GetHostReg8(reg), bit);
m_emit->jnc(*label);
break;
case RegSize_16:
m_emit->bt(GetHostReg16(reg), bit);
m_emit->jnc(*label);
break;
case RegSize_32:
m_emit->bt(GetHostReg32(reg), bit);
m_emit->jnc(*label);
break;
default:
UnreachableCode();
break;
}
}
void CodeGenerator::EmitBindLabel(LabelType* label)
{
m_emit->L(*label);
}
void CodeGenerator::EmitRaiseException(Exception excode, Condition condition /* = Condition::Always */)
{
if (condition == Condition::Always)

View File

@ -52,6 +52,7 @@ enum class Condition : u8
using HostReg = Xbyak::Operand::Code;
using CodeEmitter = Xbyak::CodeGenerator;
using LabelType = Xbyak::Label;
enum : u32
{
HostReg_Count = 16
@ -70,6 +71,7 @@ constexpr bool SHIFTS_ARE_IMPLICITLY_MASKED = true;
using HostReg = unsigned;
using CodeEmitter = vixl::aarch64::MacroAssembler;
using LabelType = vixl::aarch64::Label;
enum : u32
{
HostReg_Count = vixl::aarch64::kNumberOfRegisters