EmitX64: Emit correct cycle count on cond failure

This commit is contained in:
MerryMage 2016-08-18 18:16:18 +01:00
parent 841098a0bc
commit b2de47954b
2 changed files with 9 additions and 13 deletions

View file

@ -69,7 +69,7 @@ EmitX64::BlockDescriptor EmitX64::Emit(const Arm::LocationDescriptor descriptor,
basic_blocks[descriptor].code_ptr = code_ptr; basic_blocks[descriptor].code_ptr = code_ptr;
unique_hash_to_code_ptr[descriptor.UniqueHash()] = code_ptr; unique_hash_to_code_ptr[descriptor.UniqueHash()] = code_ptr;
EmitCondPrelude(block.cond, block.cond_failed, block.location); EmitCondPrelude(block);
for (auto iter = block.instructions.begin(); iter != block.instructions.end(); ++iter) { for (auto iter = block.instructions.begin(); iter != block.instructions.end(); ++iter) {
IR::Inst* inst = &*iter; IR::Inst* inst = &*iter;
@ -1647,22 +1647,20 @@ static CCFlags EmitCond(BlockOfCode* code, Arm::Cond cond) {
return cc; return cc;
} }
void EmitX64::EmitCondPrelude(Arm::Cond cond, void EmitX64::EmitCondPrelude(const IR::Block& block) {
boost::optional<Arm::LocationDescriptor> cond_failed, if (block.cond == Arm::Cond::AL) {
Arm::LocationDescriptor initial_location) { ASSERT(!block.cond_failed.is_initialized());
if (cond == Arm::Cond::AL) {
ASSERT(!cond_failed.is_initialized());
return; return;
} }
ASSERT(cond_failed.is_initialized()); ASSERT(block.cond_failed.is_initialized());
CCFlags cc = EmitCond(code, cond); CCFlags cc = EmitCond(code, block.cond);
// TODO: Improve, maybe. // TODO: Improve, maybe.
auto fixup = code->J_CC(cc, true); auto fixup = code->J_CC(cc, true);
EmitAddCycles(1); // TODO: Proper cycle count EmitAddCycles(block.cycle_count);
EmitTerminalLinkBlock(IR::Term::LinkBlock{cond_failed.get()}, initial_location); EmitTerminalLinkBlock(IR::Term::LinkBlock{block.cond_failed.get()}, block.location);
code->SetJumpTarget(fixup); code->SetJumpTarget(fixup);
} }

View file

@ -56,9 +56,7 @@ private:
// Helpers // Helpers
void EmitAddCycles(size_t cycles); void EmitAddCycles(size_t cycles);
void EmitCondPrelude(Arm::Cond cond, void EmitCondPrelude(const IR::Block& block);
boost::optional<Arm::LocationDescriptor> cond_failed,
Arm::LocationDescriptor current_location);
// Terminal instruction emitters // Terminal instruction emitters
void EmitTerminal(IR::Terminal terminal, Arm::LocationDescriptor initial_location); void EmitTerminal(IR::Terminal terminal, Arm::LocationDescriptor initial_location);