EmitTwoOpFallbackWithoutRegAlloc: Simplify

This commit is contained in:
Merry 2022-11-29 14:14:00 +00:00 committed by Liam
parent 6965095cb9
commit cf704a460d
2 changed files with 7 additions and 18 deletions

View file

@ -20,7 +20,7 @@ struct A64JitState {
u32 cpsr_nzcv = 0; u32 cpsr_nzcv = 0;
alignas(16) std::array<u64, 64> vec{}; // Extension registers. alignas(16) std::array<u64, 64> vec{};
u32 exclusive_state = 0; u32 exclusive_state = 0;

View file

@ -263,30 +263,20 @@ static void EmitTwoOpFallbackWithoutRegAlloc(oaknut::CodeGenerator& code, EmitCo
const auto fn = static_cast<mcl::equivalent_function_type<Lambda>*>(lambda); const auto fn = static_cast<mcl::equivalent_function_type<Lambda>*>(lambda);
const u32 fpcr = ctx.FPCR(fpcr_controlled).Value(); const u32 fpcr = ctx.FPCR(fpcr_controlled).Value();
constexpr u64 stack_size = sizeof(u64) * 4; // sizeof(u128)*2 constexpr u64 stack_size = sizeof(u64) * 4; // sizeof(u128) * 2
oaknut::Label fn_ptr, end;
ABI_PushRegisters(code, ABI_CALLER_SAVE & ~(1ull << Qresult.index()), stack_size); ABI_PushRegisters(code, ABI_CALLER_SAVE & ~(1ull << Qresult.index()), stack_size);
code.MOV(Xscratch0, SP);
code.LDR(Xscratch1, fn_ptr);
// Call lambda(Vec&, Vec&, fpcr, fpsr&) code.MOV(Xscratch0, mcl::bit_cast<u64>(fn));
code.ADD(X0, Xscratch0, 0 * 16); code.ADD(X0, SP, 0 * 16);
code.ADD(X1, Xscratch0, 1 * 16); code.ADD(X1, SP, 1 * 16);
code.MOV(X2, fpcr); code.MOV(X2, fpcr);
code.ADD(X3, Xstate, ctx.conf.state_fpsr_offset); code.ADD(X3, Xstate, ctx.conf.state_fpsr_offset);
code.STR(Qarg1, X1); code.STR(Qarg1, X1);
code.BLR(Xscratch1); code.BLR(Xscratch0);
// Reload result
code.LDR(Qresult, SP); code.LDR(Qresult, SP);
ABI_PopRegisters(code, ABI_CALLER_SAVE & ~(1ull << Qresult.index()), stack_size);
code.B(end); ABI_PopRegisters(code, ABI_CALLER_SAVE & ~(1ull << Qresult.index()), stack_size);
code.align(8);
code.l(fn_ptr);
code.dx(mcl::bit_cast<u64>(fn));
code.l(end);
} }
template<size_t fpcr_controlled_arg_index = 1, typename Lambda> template<size_t fpcr_controlled_arg_index = 1, typename Lambda>
@ -295,7 +285,6 @@ static void EmitTwoOpFallback(oaknut::CodeGenerator& code, EmitContext& ctx, IR:
auto Qarg1 = ctx.reg_alloc.ReadQ(args[0]); auto Qarg1 = ctx.reg_alloc.ReadQ(args[0]);
auto Qresult = ctx.reg_alloc.WriteQ(inst); auto Qresult = ctx.reg_alloc.WriteQ(inst);
RegAlloc::Realize(Qarg1, Qresult); RegAlloc::Realize(Qarg1, Qresult);
ctx.reg_alloc.SpillFlags(); ctx.reg_alloc.SpillFlags();
ctx.fpsr.Spill(); ctx.fpsr.Spill();