/// <summary>
/// Visitation function for <see cref="IX86Visitor.Cmp"/> instructions.
/// </summary>
/// <param name="context">The context.</param>
public override void Cmp(Context context)
{
Operand left = context.Operand1;
Operand right = context.Operand2;
if (left.IsConstant)
{
Operand ecx = AllocateVirtualRegister(left.Type);
Context before = context.InsertBefore();
before.AppendInstruction(X86.Mov, ecx, left);
context.Operand1 = ecx;
}
if (right.IsConstant && (left.IsChar || left.IsShort || left.IsByte))
{
Operand edx = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
Context before = context.InsertBefore();
if (left.IsSigned)
{
before.AppendInstruction(X86.Movsx, edx, left);
}
else
{
before.AppendInstruction(X86.Movzx, edx, left);
}
context.Operand1 = edx;
}
}