CPU/Recompiler: Implement syscall/break
This commit is contained in:
parent
d2d0d5287b
commit
2f3107216a
|
@ -163,6 +163,8 @@ bool CodeGenerator::CompileInstruction(const CodeBlockInstruction& cbi)
|
||||||
|
|
||||||
case InstructionFunct::jr:
|
case InstructionFunct::jr:
|
||||||
case InstructionFunct::jalr:
|
case InstructionFunct::jalr:
|
||||||
|
case InstructionFunct::syscall:
|
||||||
|
case InstructionFunct::break_:
|
||||||
result = Compile_Branch(cbi);
|
result = Compile_Branch(cbi);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1219,14 +1221,26 @@ bool CodeGenerator::Compile_Branch(const CodeBlockInstruction& cbi)
|
||||||
|
|
||||||
case InstructionOp::funct:
|
case InstructionOp::funct:
|
||||||
{
|
{
|
||||||
Assert(cbi.instruction.r.funct == InstructionFunct::jr || cbi.instruction.r.funct == InstructionFunct::jalr);
|
if (cbi.instruction.r.funct == InstructionFunct::jr || cbi.instruction.r.funct == InstructionFunct::jalr)
|
||||||
|
{
|
||||||
// npc = rs, link to rt
|
// npc = rs, link to rt
|
||||||
Value branch_target = m_register_cache.ReadGuestRegister(cbi.instruction.r.rs);
|
Value branch_target = m_register_cache.ReadGuestRegister(cbi.instruction.r.rs);
|
||||||
EmitBranch(Condition::Always,
|
EmitBranch(Condition::Always,
|
||||||
(cbi.instruction.r.funct == InstructionFunct::jalr) ? cbi.instruction.r.rd : Reg::count, false,
|
(cbi.instruction.r.funct == InstructionFunct::jalr) ? cbi.instruction.r.rd : Reg::count, false,
|
||||||
std::move(branch_target));
|
std::move(branch_target));
|
||||||
}
|
}
|
||||||
|
else if (cbi.instruction.r.funct == InstructionFunct::syscall ||
|
||||||
|
cbi.instruction.r.funct == InstructionFunct::break_)
|
||||||
|
{
|
||||||
|
const Exception excode =
|
||||||
|
(cbi.instruction.r.funct == InstructionFunct::syscall) ? Exception::Syscall : Exception::BP;
|
||||||
|
EmitRaiseException(excode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UnreachableCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InstructionOp::beq:
|
case InstructionOp::beq:
|
||||||
|
|
Loading…
Reference in New Issue