arm64/emit_context: Add deferred_emits

This commit is contained in:
Merry 2022-12-06 21:52:53 +00:00
parent ac0a20795a
commit d6b58b268b
2 changed files with 21 additions and 1 deletions

View file

@ -180,7 +180,7 @@ EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block, const E
FpsrManager fpsr_manager{code, conf.state_fpsr_offset};
RegAlloc reg_alloc{code, fpsr_manager, GPR_ORDER, FPR_ORDER};
EmitContext ctx{block, reg_alloc, conf, ebi, fpsr_manager};
EmitContext ctx{block, reg_alloc, conf, ebi, fpsr_manager, {}};
ebi.entry_point = code.ptr<CodePtr>();
@ -232,6 +232,12 @@ EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block, const E
EmitAddCycles(code, ctx, block.CycleCount());
conf.emit_terminal(code, ctx);
code.BRK(0);
for (const auto& deferred_emit : ctx.deferred_emits) {
deferred_emit();
}
code.BRK(0);
ebi.size = code.ptr<CodePtr>() - ebi.entry_point;
return ebi;

View file

@ -5,6 +5,12 @@
#pragma once
#include <functional>
#include <memory>
#include <vector>
#include <oaknut/oaknut.hpp>
#include "dynarmic/backend/arm64/emit_arm64.h"
#include "dynarmic/backend/arm64/reg_alloc.h"
#include "dynarmic/common/fp/fpcr.h"
@ -19,6 +25,12 @@ namespace Dynarmic::Backend::Arm64 {
struct EmitConfig;
class FpsrManager;
using SharedLabel = std::shared_ptr<oaknut::Label>;
inline SharedLabel GenSharedLabel() {
return std::make_shared<oaknut::Label>();
}
struct EmitContext {
IR::Block& block;
RegAlloc& reg_alloc;
@ -26,6 +38,8 @@ struct EmitContext {
EmittedBlockInfo& ebi;
FpsrManager& fpsr;
std::vector<std::function<void()>> deferred_emits;
FP::FPCR FPCR(bool fpcr_controlled = true) const {
const FP::FPCR fpcr = conf.descriptor_to_fpcr(block.Location());
return fpcr_controlled ? fpcr : fpcr.ASIMDStandardValue();