/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { if (node.Operand3.IsConstant) { emitter.Emit(C, node.Operand2, node.Result, node.Operand3); } else { emitter.Emit(RM, node.Operand2, node.Result); } }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { var opCode = ComputeOpCode(node.Size, node.Operand1, node.Operand2); if (node.Operand1.IsConstant) { emitter.Emit(opCode, node.Operand1); } else { emitter.Emit(opCode); } }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { LegacyOpCode opCode = ComputeOpCode(node.Result, node.Operand1, null); if (node.Result.Register is ControlRegister) { emitter.Emit(opCode, node.Result, node.Operand1); } else { emitter.Emit(opCode, node.Operand1, node.Result); } }
internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { System.Diagnostics.Debug.Assert(node.ResultCount == 1); System.Diagnostics.Debug.Assert(node.OperandCount == 1); emitter.Emit(LegacyOpcode, node.Result, node.Operand1); }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { Debug.Assert(node.Result == node.Operand1); LegacyOpCode opCode = ComputeOpCode(node.Result, node.Operand1, node.Operand2); emitter.Emit(opCode, node.Result, node.Operand2); }
internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { System.Diagnostics.Debug.Assert(node.ResultCount == 2); System.Diagnostics.Debug.Assert(node.OperandCount == 3); System.Diagnostics.Debug.Assert(node.Result.IsCPURegister); System.Diagnostics.Debug.Assert(node.Operand1.IsCPURegister); System.Diagnostics.Debug.Assert(node.Result.Register == node.Operand1.Register); emitter.Emit(LegacyOpcode, node.Operand3); }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> /// <exception cref="System.InvalidOperationException">@unable to emit opcode for segment register</exception> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { if (node.Operand1.IsConstant) { if (node.Operand1.IsByte) { emitter.Emit(CONST8, node.Operand1); } else if (node.Operand1.IsShort || node.Operand1.IsChar) { emitter.Emit(CONST16, node.Operand1); } else if (node.Operand1.IsInt) { emitter.Emit(CONST32, node.Operand1); } return; } if (node.Operand1.IsCPURegister) { if (node.Operand1.Register is SegmentRegister) { switch ((node.Operand1.Register as SegmentRegister).Segment) { case SegmentRegister.SegmentType.CS: emitter.Emit(PUSH_CS); return; case SegmentRegister.SegmentType.SS: emitter.Emit(PUSH_SS); return; case SegmentRegister.SegmentType.DS: emitter.Emit(PUSH_DS); return; case SegmentRegister.SegmentType.ES: emitter.Emit(PUSH_ES); return; case SegmentRegister.SegmentType.FS: emitter.Emit(PUSH_FS); return; case SegmentRegister.SegmentType.GS: emitter.Emit(PUSH_GS); return; default: throw new InvalidOperationException(@"unable to emit opcode for segment register"); } } } emitter.Emit(PUSH, node.Operand1); }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> /// <exception cref="System.InvalidOperationException">@unable to emit opcode for segment register</exception> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { if (node.Result.IsCPURegister) { if (node.Result.Register is SegmentRegister) { switch ((node.Result.Register as SegmentRegister).Segment) { case SegmentRegister.SegmentType.DS: emitter.Emit(POP_DS); return; case SegmentRegister.SegmentType.ES: emitter.Emit(POP_ES); return; case SegmentRegister.SegmentType.FS: emitter.Emit(POP_FS); return; case SegmentRegister.SegmentType.GS: emitter.Emit(POP_GS); return; case SegmentRegister.SegmentType.SS: emitter.Emit(POP_SS); return; default: throw new InvalidOperationException(@"unable to emit opcode for segment register"); } } else { emitter.WriteByte((byte)(0x58 + node.Result.Register.RegisterCode)); } } else { emitter.Emit(POP, node.Result); } }
private static readonly LegacyOpCode CMOVG = new LegacyOpCode(new byte[] { 0x0F, 0x4F }); // GreaterThan (ZF = 0 and SF = OF) #endregion Data Members #region Methods /// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> /// <exception cref="System.NotSupportedException"></exception> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { LegacyOpCode opcode = null; switch (node.ConditionCode) { case ConditionCode.Equal: opcode = CMOVO; break; case ConditionCode.NotEqual: opcode = CMOVNE; break; case ConditionCode.Zero: opcode = CMOVZ; break; case ConditionCode.NotZero: opcode = CMOVNZ; break; case ConditionCode.GreaterOrEqual: opcode = CMOVGE; break; case ConditionCode.GreaterThan: opcode = CMOVG; break; case ConditionCode.LessOrEqual: opcode = CMOVLE; break; case ConditionCode.LessThan: opcode = CMOVL; break; case ConditionCode.UnsignedGreaterOrEqual: opcode = CMOVNB; break; case ConditionCode.UnsignedGreaterThan: opcode = CMOVA; break; case ConditionCode.UnsignedLessOrEqual: opcode = CMOVBE; break; case ConditionCode.UnsignedLessThan: opcode = CMOVB; break; case ConditionCode.Signed: opcode = CMOVS; break; case ConditionCode.NotSigned: opcode = CMOVNS; break; case ConditionCode.Carry: opcode = CMOVC; break; case ConditionCode.NoCarry: opcode = CMOVNC; break; case ConditionCode.Overflow: opcode = CMOVO; break; case ConditionCode.NoOverflow: opcode = CMOVNO; break; case ConditionCode.Parity: opcode = CMOVP; break; case ConditionCode.NoParity: opcode = CMOVNP; break; default: throw new NotSupportedException(); } emitter.Emit(opcode, node.Result, node.Operand1); }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { if (node.OperandCount == 0) { emitter.EmitRelativeBranch(CALL, node.BranchTargets[0].Label); return; } if (node.Operand1.IsSymbol) { emitter.WriteByte(0xE8); emitter.EmitCallSite(node.Operand1); } else { emitter.Emit(RegCall, node.Operand1); } }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { if (node.Operand1 == null) { emitter.EmitRelativeBranch(JMP, node.BranchTargets[0].Label); } else { if (node.Operand1.IsSymbol) { emitter.WriteByte(0xE9); emitter.EmitCallSite(node.Operand1); } else if (node.Operand1.IsCPURegister) { emitter.Emit(JMP_R, node.Operand1); } } }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> /// <exception cref="System.NotSupportedException"></exception> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { LegacyOpCode opcode; switch (node.ConditionCode) { case ConditionCode.Equal: opcode = E; break; case ConditionCode.LessThan: opcode = LT; break; case ConditionCode.LessOrEqual: opcode = LE; break; case ConditionCode.GreaterOrEqual: opcode = GE; break; case ConditionCode.GreaterThan: opcode = GT; break; case ConditionCode.NotEqual: opcode = NE; break; case ConditionCode.UnsignedGreaterOrEqual: opcode = UGE; break; case ConditionCode.UnsignedGreaterThan: opcode = UGT; break; case ConditionCode.UnsignedLessOrEqual: opcode = ULE; break; case ConditionCode.UnsignedLessThan: opcode = ULT; break; case ConditionCode.Parity: opcode = P; break; case ConditionCode.NoParity: opcode = NP; break; case ConditionCode.NoCarry: opcode = NC; break; case ConditionCode.Carry: opcode = C; break; case ConditionCode.Zero: opcode = Z; break; case ConditionCode.NotZero: opcode = NZ; break; default: throw new NotSupportedException(); } emitter.Emit(opcode, node.Result); }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { LegacyOpCode opCode = ComputeOpCode(node.Result, null, null); emitter.Emit(opCode, node.Result); }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { emitter.Emit(opcode, node.Operand3); }
/// <summary> /// Emits the specified platform instruction. /// </summary> /// <param name="node">The node.</param> /// <param name="emitter">The emitter.</param> internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter) { LegacyOpCode opCode = ComputeOpCode(null, node.Operand1, node.Operand2); emitter.Emit(opCode, node.Operand1, node.Operand2); }