system: Ensure value of CNTPCT_EL0 is accurate

Since we currently only update the host's tick count at the end of a
block, we force an end-of-block before executing a MRS %, CNTPCT_ELO
instruction.
This commit is contained in:
MerryMage 2018-07-19 01:40:51 +01:00
parent 84affdb260
commit 3f602129f4

View file

@ -105,6 +105,11 @@ bool TranslatorVisitor::MRS(Imm<1> o0, Imm<3> op1, Imm<4> CRn, Imm<4> CRm, Imm<3
X(32, Rt, ir.GetCTR());
return true;
case SystemRegisterEncoding::CNTPCT_EL0:
// HACK: Ensure that this is the first instruction in the block it's emitted in, so the cycle count is most up-to-date.
if (!ir.block.empty()) {
ir.SetTerm(IR::Term::LinkBlock{*ir.current_location});
return false;
}
X(64, Rt, ir.GetCNTPCT());
return true;
case SystemRegisterEncoding::FPCR: