public SetInstruction2 ( |
||
instruction | The instruction. | |
result | Operand | The result. |
result2 | Operand | The result2. |
return | void |
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Operand n = context.Operand1; Operand d = context.Operand2; Operand result = context.Result; Operand result2 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.U4); Operand op0L, op0H; LongOperandTransformationStage.SplitLongOperand(methodCompiler, n, out op0L, out op0H); context.SetInstruction2(X86.Div, result2, result, op0H, op0L, d); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { // xchg bx, bx var bx = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.U2, GeneralPurposeRegister.EBX); context.SetInstruction2(X86.Xchg, bx, bx, bx, bx); }
/// <summary> /// Visitation function for <see cref="IX86Visitor.Setcc"/> instructions. /// </summary> /// <param name="context">The context.</param> void IX86Visitor.Setcc(Context context) { Debug.Assert(context.Result.IsCPURegister); // SETcc can not use ESI or EDI registers if (context.Result.IsCPURegister && (context.Result.Register == GeneralPurposeRegister.ESI || context.Result.Register == GeneralPurposeRegister.EDI)) { Operand result = context.Result; var condition = context.ConditionCode; Operand EAX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX); context.SetInstruction2(X86.Xchg, EAX, result, result, EAX); context.AppendInstruction(X86.Setcc, condition, EAX); context.AppendInstruction2(X86.Xchg, result, EAX, EAX, result); } }
/// <summary> /// Visitation function for RemSigned. /// </summary> /// <param name="context">The context.</param> void IIRVisitor.RemSigned(Context context) { EmitFloatingPointConstants(context); Operand result = context.Result; Operand operand1 = context.Operand1; Operand operand2 = context.Operand2; Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4); Operand v2 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4); Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4); // FIXME context.SetInstruction2(X86.Cdq, v1, v2, operand1); context.AppendInstruction2(X86.IDiv, result, v3, v1, v2, operand2); }
/// <summary> /// Visitation function for <see cref="IX86Visitor.Mov"/> instructions. /// </summary> /// <param name="context">The context.</param> void IX86Visitor.Mov(Context context) { // Mov can not use ESI or EDI registers with 8 or 16 bit memory or register if (context.Operand1.IsCPURegister && (context.Result.IsMemoryAddress || context.Result.IsCPURegister) && (context.Result.IsByte || context.Result.IsShort || context.Result.IsChar || context.Result.IsBoolean) && (context.Operand1.Register == GeneralPurposeRegister.ESI || context.Operand1.Register == GeneralPurposeRegister.EDI)) { Operand source = context.Operand1; Operand dest = context.Result; Operand EAX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX); context.SetInstruction2(X86.Xchg, EAX, source, source, EAX); context.AppendInstruction(X86.Mov, dest, EAX); context.AppendInstruction2(X86.Xchg, source, EAX, EAX, source); } }
/// <summary> /// Visitation function for MulSigned. /// </summary> /// <param name="context">The context.</param> void IIRVisitor.MulSigned(Context context) { Operand result = context.Result; Operand operand1 = context.Operand1; Operand operand2 = context.Operand2; Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4); context.SetInstruction2(X86.Mul, v1, result, operand1, operand2); }
/// <summary> /// Visitation function for MulUnsigned. /// </summary> /// <param name="context">The context.</param> void IIRVisitor.MulUnsigned(Context context) { EmitFloatingPointConstants(context); Operand result = context.Result; Operand operand1 = context.Operand1; Operand operand2 = context.Operand2; Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4); context.SetInstruction2(X86.Mul, v1, result, operand1, operand2); }
/// <summary> /// Visitation function for DivSigned. /// </summary> /// <param name="context">The context.</param> void IIRVisitor.DivSigned(Context context) { Operand operand1 = context.Operand1; Operand operand2 = context.Operand2; Operand result = context.Result; Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4); Operand v2 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4); Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4); context.SetInstruction2(X86.Cdq, v1, v2, operand1); context.AppendInstruction2(X86.IDiv, v3, result, v1, v2, operand2); }
/// <summary> /// Visitation function for <see cref="IX86Visitor.Mov"/> instructions. /// </summary> /// <param name="context">The context.</param> public void Mov(Context context) { if (context.Result.IsCPURegister && context.Operand1.IsCPURegister && context.Result.Register == context.Operand1.Register) { context.Empty(); return; } // Mov can not use ESI or EDI registers with 8 or 16 bit memory or register if (context.Operand1.IsCPURegister && (context.Result.IsMemoryAddress || context.Result.IsCPURegister) && (context.Result.IsByte || context.Result.IsShort || context.Result.IsChar || context.Result.IsBoolean) && (context.Operand1.Register == GeneralPurposeRegister.ESI || context.Operand1.Register == GeneralPurposeRegister.EDI)) { Operand source = context.Operand1; Operand dest = context.Result; var replace = (dest.IsMemoryAddress && dest.EffectiveOffsetBase == GeneralPurposeRegister.EAX) ? GeneralPurposeRegister.EBX : GeneralPurposeRegister.EAX; Operand reg = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, replace); context.SetInstruction2(X86.Xchg, reg, source, source, reg); context.AppendInstruction(X86.Mov, dest, reg); context.AppendInstruction2(X86.Xchg, source, reg, reg, source); } }
public void Mov(Context context) { Operand source = context.Operand1; Operand result = context.Result; Debug.Assert(result.IsCPURegister); if (source.IsCPURegister && result.Register == source.Register) { context.Empty(); return; } var size = context.Size; // Mov can not use ESI or EDI registers for 8/16bit values if (!(size == InstructionSize.Size16 || size == InstructionSize.Size8)) return; if (source.IsCPURegister && (source.Register == GeneralPurposeRegister.ESI || source.Register == GeneralPurposeRegister.EDI)) { Operand eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX); context.SetInstruction2(X86.Xchg, eax, source, source, eax); context.AppendInstruction(X86.Mov, result, eax); context.AppendInstruction2(X86.Xchg, source, eax, eax, source); } }
public void Setcc(Context context) { Debug.Assert(context.Result.IsCPURegister); Operand result = context.Result; Debug.Assert(result.IsCPURegister); // SETcc can not use with ESI or EDI registers if (result.Register == GeneralPurposeRegister.ESI || result.Register == GeneralPurposeRegister.EDI) { var condition = context.ConditionCode; Operand eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX); context.SetInstruction2(X86.Xchg, eax, result, result, eax); context.AppendInstruction(X86.Setcc, condition, eax); context.AppendInstruction2(X86.Xchg, result, eax, eax, result); } }
public void MovStore(Context context) { var size = context.Size; // Mov can not use ESI or EDI registers for 8/16bit values if (!(size == InstructionSize.Size16 || size == InstructionSize.Size8)) return; Operand value = context.Operand3; if (value.IsCPURegister && (value.Register == GeneralPurposeRegister.ESI || value.Register == GeneralPurposeRegister.EDI)) { Operand dest = context.Operand1; Operand offset = context.Operand2; Operand temporaryRegister = null; if (dest.Register != GeneralPurposeRegister.EAX && offset.Register != GeneralPurposeRegister.EAX) { temporaryRegister = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX); } else if (dest.Register != GeneralPurposeRegister.EBX && offset.Register != GeneralPurposeRegister.EBX) { temporaryRegister = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBX); } else if (dest.Register != GeneralPurposeRegister.ECX && offset.Register != GeneralPurposeRegister.ECX) { temporaryRegister = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ECX); } else { temporaryRegister = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX); } context.SetInstruction2(X86.Xchg, temporaryRegister, value, value, temporaryRegister); context.AppendInstruction(X86.MovStore, size, null, dest, offset, temporaryRegister); context.AppendInstruction2(X86.Xchg, value, temporaryRegister, temporaryRegister, value); } }