emit_arm64_a64: Implement A64GetCNTPCT

This commit is contained in:
Merry 2022-11-28 21:50:35 +00:00 committed by Liam
parent 59ccccdc26
commit 167ba85ce8
4 changed files with 11 additions and 1 deletions

View file

@ -311,6 +311,7 @@ EmittedBlockInfo A32AddressSpace::Emit(IR::Block block) {
.is_a64 = false, .is_a64 = false,
.hook_isb = conf.hook_isb, .hook_isb = conf.hook_isb,
.enable_cycle_counting = conf.enable_cycle_counting, .enable_cycle_counting = conf.enable_cycle_counting,
.wall_clock_cntpct = conf.wall_clock_cntpct,
.always_little_endian = conf.always_little_endian, .always_little_endian = conf.always_little_endian,
.descriptor_to_fpcr = [](const IR::LocationDescriptor& location) { return FP::FPCR{A32::LocationDescriptor{location}.FPSCR().Value()}; }, .descriptor_to_fpcr = [](const IR::LocationDescriptor& location) { return FP::FPCR{A32::LocationDescriptor{location}.FPSCR().Value()}; },
.state_nzcv_offset = offsetof(A32JitState, cpsr_nzcv), .state_nzcv_offset = offsetof(A32JitState, cpsr_nzcv),

View file

@ -441,6 +441,7 @@ EmittedBlockInfo A64AddressSpace::Emit(IR::Block block) {
.is_a64 = true, .is_a64 = true,
.hook_isb = conf.hook_isb, .hook_isb = conf.hook_isb,
.enable_cycle_counting = conf.enable_cycle_counting, .enable_cycle_counting = conf.enable_cycle_counting,
.wall_clock_cntpct = conf.wall_clock_cntpct,
.always_little_endian = true, .always_little_endian = true,
.descriptor_to_fpcr = [](const IR::LocationDescriptor& location) { return A64::LocationDescriptor{location}.FPCR(); }, .descriptor_to_fpcr = [](const IR::LocationDescriptor& location) { return A64::LocationDescriptor{location}.FPCR(); },
.state_nzcv_offset = offsetof(A64JitState, cpsr_nzcv), .state_nzcv_offset = offsetof(A64JitState, cpsr_nzcv),

View file

@ -98,6 +98,7 @@ struct EmitConfig {
bool is_a64; bool is_a64;
bool hook_isb; bool hook_isb;
bool enable_cycle_counting; bool enable_cycle_counting;
bool wall_clock_cntpct;
bool always_little_endian; bool always_little_endian;
FP::FPCR (*descriptor_to_fpcr)(const IR::LocationDescriptor& descriptor); FP::FPCR (*descriptor_to_fpcr)(const IR::LocationDescriptor& descriptor);

View file

@ -425,8 +425,15 @@ void EmitIR<IR::Opcode::A64GetCNTFRQ>(oaknut::CodeGenerator& code, EmitContext&
template<> template<>
void EmitIR<IR::Opcode::A64GetCNTPCT>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) { void EmitIR<IR::Opcode::A64GetCNTPCT>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
// FIXME: AddTicks / GetTicksRemaining
auto Xresult = ctx.reg_alloc.PrepareForCallReg(inst); auto Xresult = ctx.reg_alloc.PrepareForCallReg(inst);
if (!ctx.conf.wall_clock_cntpct && ctx.conf.enable_cycle_counting) {
code.LDR(X1, SP, offsetof(StackLayout, cycles_to_run));
code.SUB(X1, X1, Xticks);
EmitRelocation(code, ctx, LinkTarget::AddTicks);
EmitRelocation(code, ctx, LinkTarget::GetTicksRemaining);
code.STR(X0, SP, offsetof(StackLayout, cycles_to_run));
code.MOV(Xticks, X0);
}
EmitRelocation(code, ctx, LinkTarget::GetCNTPCT); EmitRelocation(code, ctx, LinkTarget::GetCNTPCT);
code.MOV(Xresult, X0); code.MOV(Xresult, X0);
} }