From 593a569b5347b593b55bbb2a86e4fa0a1fccbfe8 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Tue, 9 Jan 2018 21:21:15 +0000 Subject: [PATCH] EmitA64SetW: bug: should zero extend to entire 64-bit register --- src/backend_x64/a64_emit_x64.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/backend_x64/a64_emit_x64.cpp b/src/backend_x64/a64_emit_x64.cpp index 1703d6b5..665ac01b 100644 --- a/src/backend_x64/a64_emit_x64.cpp +++ b/src/backend_x64/a64_emit_x64.cpp @@ -165,14 +165,13 @@ void A64EmitX64::EmitA64GetSP(A64EmitContext& ctx, IR::Inst* inst) { void A64EmitX64::EmitA64SetW(A64EmitContext& ctx, IR::Inst* inst) { auto args = ctx.reg_alloc.GetArgumentInfo(inst); A64::Reg reg = inst->GetArg(0).GetA64RegRef(); - auto addr = dword[r15 + offsetof(A64JitState, reg) + sizeof(u64) * static_cast(reg)]; + auto addr = qword[r15 + offsetof(A64JitState, reg) + sizeof(u64) * static_cast(reg)]; if (args[1].IsImmediate()) { code->mov(addr, args[1].GetImmediateU32()); - } else if (args[1].IsInXmm()) { - Xbyak::Xmm to_store = ctx.reg_alloc.UseXmm(args[1]); - code->movd(addr, to_store); } else { - Xbyak::Reg32 to_store = ctx.reg_alloc.UseGpr(args[1]).cvt32(); + // TODO: zext tracking, xmm variant + Xbyak::Reg64 to_store = ctx.reg_alloc.UseScratchGpr(args[1]); + code->mov(to_store.cvt32(), to_store.cvt32()); code->mov(addr, to_store); } }