diff --git a/ARMeilleure/CodeGen/X86/Assembler.cs b/ARMeilleure/CodeGen/X86/Assembler.cs index 848a4d3bfa..2cb7d9d0e7 100644 --- a/ARMeilleure/CodeGen/X86/Assembler.cs +++ b/ARMeilleure/CodeGen/X86/Assembler.cs @@ -380,6 +380,8 @@ namespace ARMeilleure.CodeGen.X86 { throw new ArgumentException($"Invalid shift register \"{shiftReg}\"."); } + + source = null; } WriteInstruction(dest, source, inst); diff --git a/ARMeilleure/Instructions/InstEmitAlu.cs b/ARMeilleure/Instructions/InstEmitAlu.cs index 52ddd4f8c8..eb8e0eece8 100644 --- a/ARMeilleure/Instructions/InstEmitAlu.cs +++ b/ARMeilleure/Instructions/InstEmitAlu.cs @@ -22,7 +22,14 @@ namespace ARMeilleure.Instructions Operand d = context.IAdd(n, m); - d = context.IAdd(d, GetFlag(PState.CFlag)); + Operand carry = GetFlag(PState.CFlag); + + if (context.CurrOp.RegisterSize == RegisterSize.Int64) + { + carry = context.Copy(Local(OperandType.I64), carry); + } + + d = context.IAdd(d, carry); if (setFlags) { @@ -193,6 +200,11 @@ namespace ARMeilleure.Instructions Operand borrow = context.BitwiseExclusiveOr(GetFlag(PState.CFlag), Const(1)); + if (context.CurrOp.RegisterSize == RegisterSize.Int64) + { + borrow = context.Copy(Local(OperandType.I64), borrow); + } + d = context.ISubtract(d, borrow); if (setFlags) @@ -273,6 +285,11 @@ namespace ARMeilleure.Instructions Operand m = GetIntOrZR(op, op.Rm); + if (op.RegisterSize == RegisterSize.Int64) + { + m = context.Copy(Local(OperandType.I32), m); + } + return context.BitwiseAnd(m, Const(context.CurrOp.GetBitsCount() - 1)); } diff --git a/ARMeilleure/Translation/EmitterContext.cs b/ARMeilleure/Translation/EmitterContext.cs index 0bfda56794..fd46386c83 100644 --- a/ARMeilleure/Translation/EmitterContext.cs +++ b/ARMeilleure/Translation/EmitterContext.cs @@ -91,9 +91,9 @@ namespace ARMeilleure.Translation return Add(Instruction.Copy, Local(a.Type), a); } - public void Copy(Operand d, Operand a) + public Operand Copy(Operand d, Operand a) { - Add(Instruction.Copy, d, a); + return Add(Instruction.Copy, d, a); } public Operand CountLeadingZeros(Operand a)