a64_emit_x64: bug: x64 sign-extends 32-bit immediates

This commit is contained in:
MerryMage 2018-01-27 00:38:09 +00:00
parent 6fc228f7fd
commit 54de64f5bf

View file

@ -261,8 +261,8 @@ void A64EmitX64::EmitA64SetQ(A64EmitContext& ctx, IR::Inst* inst) {
void A64EmitX64::EmitA64SetSP(A64EmitContext& ctx, IR::Inst* inst) {
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
auto addr = qword[r15 + offsetof(A64JitState, sp)];
if (args[0].FitsInImmediateU32()) {
code->mov(addr, args[0].GetImmediateU32());
if (args[0].FitsInImmediateS32()) {
code->mov(addr, args[0].GetImmediateS32());
} else if (args[0].IsInXmm()) {
Xbyak::Xmm to_store = ctx.reg_alloc.UseXmm(args[0]);
code->movq(addr, to_store);
@ -275,8 +275,8 @@ void A64EmitX64::EmitA64SetSP(A64EmitContext& ctx, IR::Inst* inst) {
void A64EmitX64::EmitA64SetPC(A64EmitContext& ctx, IR::Inst* inst) {
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
auto addr = qword[r15 + offsetof(A64JitState, pc)];
if (args[0].FitsInImmediateU32()) {
code->mov(addr, args[0].GetImmediateU32());
if (args[0].FitsInImmediateS32()) {
code->mov(addr, args[0].GetImmediateS32());
} else if (args[0].IsInXmm()) {
Xbyak::Xmm to_store = ctx.reg_alloc.UseXmm(args[0]);
code->movq(addr, to_store);