From aa341b7eea81f54b9832fce3eae6c054beaeb076 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Tue, 16 Jun 2020 12:58:18 +0100 Subject: [PATCH] a32_emit_x64: Make ExclusiveWrite a member function of A32EmitX64 --- src/backend/x64/a32_emit_x64.cpp | 26 ++++++++++++++------------ src/backend/x64/a32_emit_x64.h | 2 ++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/backend/x64/a32_emit_x64.cpp b/src/backend/x64/a32_emit_x64.cpp index 89ed4f0d..2e329ef7 100644 --- a/src/backend/x64/a32_emit_x64.cpp +++ b/src/backend/x64/a32_emit_x64.cpp @@ -1061,15 +1061,17 @@ void A32EmitX64::EmitA32WriteMemory64(A32EmitContext& ctx, IR::Inst* inst) { WriteMemory<64, &A32::UserCallbacks::MemoryWrite64>(ctx, inst); } -template -static void ExclusiveWrite(BlockOfCode& code, RegAlloc& reg_alloc, IR::Inst* inst, const A32::UserConfig& config, bool prepend_high_word) { - auto args = reg_alloc.GetArgumentInfo(inst); +template +void A32EmitX64::ExclusiveWriteMemory(A32EmitContext& ctx, IR::Inst* inst) { + const bool prepend_high_word = bitsize == 64; + + auto args = ctx.reg_alloc.GetArgumentInfo(inst); if (prepend_high_word) { - reg_alloc.HostCall(nullptr, {}, args[0], args[1], args[2]); + ctx.reg_alloc.HostCall(nullptr, {}, args[0], args[1], args[2]); } else { - reg_alloc.HostCall(nullptr, {}, args[0], args[1]); + ctx.reg_alloc.HostCall(nullptr, {}, args[0], args[1]); } - const Xbyak::Reg32 passed = reg_alloc.ScratchGpr().cvt32(); + const Xbyak::Reg32 passed = ctx.reg_alloc.ScratchGpr().cvt32(); const Xbyak::Reg32 tmp = code.ABI_RETURN.cvt32(); // Use one of the unused HostCall registers. Xbyak::Label end; @@ -1087,27 +1089,27 @@ static void ExclusiveWrite(BlockOfCode& code, RegAlloc& reg_alloc, IR::Inst* ins code.shl(code.ABI_PARAM4, 32); code.or_(code.ABI_PARAM3, code.ABI_PARAM4); } - Devirtualize(config.callbacks).EmitCall(code); + Devirtualize(config.callbacks).EmitCall(code); code.xor_(passed, passed); code.L(end); - reg_alloc.DefineValue(inst, passed); + ctx.reg_alloc.DefineValue(inst, passed); } void A32EmitX64::EmitA32ExclusiveWriteMemory8(A32EmitContext& ctx, IR::Inst* inst) { - ExclusiveWrite(code, ctx.reg_alloc, inst, config, false); + ExclusiveWriteMemory<8, &A32::UserCallbacks::MemoryWrite8>(ctx, inst); } void A32EmitX64::EmitA32ExclusiveWriteMemory16(A32EmitContext& ctx, IR::Inst* inst) { - ExclusiveWrite(code, ctx.reg_alloc, inst, config, false); + ExclusiveWriteMemory<16, &A32::UserCallbacks::MemoryWrite16>(ctx, inst); } void A32EmitX64::EmitA32ExclusiveWriteMemory32(A32EmitContext& ctx, IR::Inst* inst) { - ExclusiveWrite(code, ctx.reg_alloc, inst, config, false); + ExclusiveWriteMemory<32, &A32::UserCallbacks::MemoryWrite32>(ctx, inst); } void A32EmitX64::EmitA32ExclusiveWriteMemory64(A32EmitContext& ctx, IR::Inst* inst) { - ExclusiveWrite(code, ctx.reg_alloc, inst, config, true); + ExclusiveWriteMemory<64, &A32::UserCallbacks::MemoryWrite64>(ctx, inst); } static void EmitCoprocessorException() { diff --git a/src/backend/x64/a32_emit_x64.h b/src/backend/x64/a32_emit_x64.h index 3f3633e0..2f451d49 100644 --- a/src/backend/x64/a32_emit_x64.h +++ b/src/backend/x64/a32_emit_x64.h @@ -102,6 +102,8 @@ protected: void ReadMemory(A32EmitContext& ctx, IR::Inst* inst); template void WriteMemory(A32EmitContext& ctx, IR::Inst* inst); + template + void ExclusiveWriteMemory(A32EmitContext& ctx, IR::Inst* inst); // Terminal instruction emitters void EmitSetUpperLocationDescriptor(IR::LocationDescriptor new_location, IR::LocationDescriptor old_location);