本文整理汇总了C#中Mosa.Runtime.CompilerFramework.Context.ReplaceInstructionOnly方法的典型用法代码示例。如果您正苦于以下问题:C# Context.ReplaceInstructionOnly方法的具体用法?C# Context.ReplaceInstructionOnly怎么用?C# Context.ReplaceInstructionOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mosa.Runtime.CompilerFramework.Context
的用法示例。
在下文中一共展示了Context.ReplaceInstructionOnly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterOperand
/// <summary>
/// Visitation function for <see cref="IR.IIRVisitor.AddressOfInstruction"/> instruction.
/// </summary>
/// <param name="ctx">The context.</param>
void IR.IIRVisitor.AddressOfInstruction(Context ctx)
{
Operand opRes = ctx.Result;
RegisterOperand eax = new RegisterOperand (opRes.Type, GeneralPurposeRegister.EAX);
ctx.Result = eax;
ctx.ReplaceInstructionOnly (CPUx86.Instruction.LeaInstruction);
// ctx.Ignore = true;
ctx.AppendInstruction (CPUx86.Instruction.MovInstruction, opRes, eax);
}
示例2: Switch
/// <summary>
/// Visitation function for <see cref="ICILVisitor.Switch"/>.
/// </summary>
/// <param name="ctx">The context.</param>
public void Switch(Context ctx)
{
ctx.ReplaceInstructionOnly(Instruction.SwitchInstruction);
}
示例3:
/// <summary>
/// Visitation function for <see cref="ICILVisitor.Ret"/>.
/// </summary>
/// <param name="ctx">The context.</param>
void ICILVisitor.Ret(Context ctx)
{
ctx.ReplaceInstructionOnly (IR.Instruction.ReturnInstruction);
}
示例4: MakeCall
/// <summary>
/// Expands the given invoke instruction to perform the method call.
/// </summary>
/// <param name="ctx">The context.</param>
/// <returns>
/// A single instruction or an array of instructions, which appropriately represent the method call.
/// </returns>
public void MakeCall(Context ctx, ISignatureContext context, IMetadataProvider metadata)
{
/*
* Calling convention is right-to-left, pushed on the stack. Return value in EAX for integral
* types 4 bytes or less, XMM0 for floating point and EAX:EDX for 64-bit. If this is a method
* of a type, the this argument is moved to ECX right before the call.
*
*/
Operand invokeTarget = ctx.Operand1;
Operand result = ctx.Result;
Stack<Operand> operands = this.BuildOperandStack(ctx);
ctx.ReplaceInstructionOnly(CPUx86.Instruction.NopInstruction);
ctx.OperandCount = 0;
ctx.Result = null;
int stackSize = this.ReserveStackSizeForCall(ctx, metadata, context, operands);
if (stackSize != 0)
{
this.PushOperands(context, ctx, operands, stackSize, metadata);
}
ctx.AppendInstruction(CPUx86.Instruction.CallInstruction, null, invokeTarget);
if (stackSize != 0)
{
this.FreeStackAfterCall(ctx, stackSize);
}
this.CleanupReturnValue(ctx, result);
}
示例5:
/// <summary>
/// Visitation function for <see cref="CIL.ICILVisitor.Branch"/>.
/// </summary>
/// <param name="ctx">The context.</param>
void CIL.ICILVisitor.Branch(Context ctx)
{
ctx.ReplaceInstructionOnly(CPUx86.Instruction.JmpInstruction);
}
示例6:
/// <summary>
/// Visitation function for <see cref="IR.IIRVisitor.BranchInstruction"/> instructions.
/// </summary>
/// <param name="context">The context.</param>
void IR.IIRVisitor.BranchInstruction(Context context)
{
context.ReplaceInstructionOnly (CPUx86.Instruction.BranchInstruction);
}
示例7: HandleShiftOperation
/// <summary>
/// Special handling for shift operations, which require the shift amount in the ECX or as a constant register.
/// </summary>
/// <param name="ctx">The transformation context.</param>
/// <param name="instruction">The instruction to transform.</param>
private void HandleShiftOperation(Context ctx, IInstruction instruction)
{
EmitOperandConstants (ctx);
ctx.ReplaceInstructionOnly (instruction);
}
示例8:
/// <summary>
/// Visitation function for DivUInstruction.
/// </summary>
/// <param name="context">The context.</param>
void IR.IIRVisitor.DivUInstruction(Context context)
{
context.ReplaceInstructionOnly(CPUx86.Instruction.UDivInstruction);
}
示例9: HandleCommutativeOperation
/// <summary>
/// Special handling for commutative operations.
/// </summary>
/// <param name="context">The transformation context.</param>
/// <param name="instruction">The instruction.</param>
/// <remarks>
/// Commutative operations are reordered by moving the constant to the second operand,
/// which allows the instruction selection in the code generator to use a instruction
/// format with an immediate operand.
/// </remarks>
private void HandleCommutativeOperation(Context context, IInstruction instruction)
{
EmitOperandConstants(context);
context.ReplaceInstructionOnly(instruction);
}
示例10: Ldloca
/// <summary>
/// Visitation function for <see cref="ICILVisitor.Ldloca"/>.
/// </summary>
/// <param name="ctx">The context.</param>
public void Ldloca(Context ctx)
{
ctx.ReplaceInstructionOnly(Instruction.AddressOfInstruction);
}
示例11: Branch
/// <summary>
/// Visitation function for <see cref="ICILVisitor.Branch"/>.
/// </summary>
/// <param name="ctx">The context.</param>
public void Branch(Context ctx)
{
ctx.ReplaceInstructionOnly(Instruction.JmpInstruction);
}
示例12: ReplaceWithInternalCall
/// <summary>
/// Replaces the instruction with an internal call.
/// </summary>
/// <param name="ctx">The transformation context.</param>
/// <param name="internalCallTarget">The internal call target.</param>
private void ReplaceWithInternalCall(Context ctx, VmCall internalCallTarget)
{
RuntimeType rt = RuntimeBase.Instance.TypeLoader.GetType(@"Mosa.Runtime.RuntimeBase");
RuntimeMethod callTarget = FindMethod(rt, internalCallTarget.ToString());
ctx.ReplaceInstructionOnly(IR.Instruction.CallInstruction);
ctx.SetOperand(0, SymbolOperand.FromMethod(callTarget));
}
示例13: ProcessLoadInstruction
/// <summary>
/// Replaces the IL load instruction by an appropriate IR move instruction or removes it entirely, if
/// it is a native size.
/// </summary>
/// <param name="context">Provides the transformation context.</param>
private void ProcessLoadInstruction(Context context)
{
IInstruction extension = null;
SigType extendedType = null;
Operand source = context.Operand1;
Operand destination = context.Result;
// Is this a sign or zero-extending move?
if (source != null)
{
if (IsSignExtending(source))
{
extension = Instruction.SignExtendedMoveInstruction;
extendedType = BuiltInSigType.Int32;
}
else if (IsZeroExtending(source))
{
extension = Instruction.ZeroExtendedMoveInstruction;
extendedType = BuiltInSigType.UInt32;
}
}
if (extension != null)
{
Operand temp = this.MethodCompiler.CreateTemporary(extendedType);
destination.Replace(temp, context.InstructionSet);
context.SetInstruction(extension, temp, source);
}
else
{
context.ReplaceInstructionOnly(Instruction.MoveInstruction);
}
}
示例14: Replace
private static void Replace(Context context, IIRInstruction floatingPointInstruction, IIRInstruction signedInstruction, IIRInstruction unsignedInstruction)
{
if (IsFloatingPoint(context))
{
context.ReplaceInstructionOnly(floatingPointInstruction);
}
else if (IsUnsigned(context))
{
context.ReplaceInstructionOnly(unsignedInstruction);
}
else
{
context.ReplaceInstructionOnly(signedInstruction);
}
}
示例15: switch
/// <summary>
/// Visitation function for <see cref="IR.IIRVisitor.ZeroExtendedMoveInstruction"/> instructions.
/// </summary>
/// <param name="ctx">The context.</param>
void IR.IIRVisitor.ZeroExtendedMoveInstruction(Context ctx)
{
switch (ctx.Operand1.Type.Type) {
case CilElementType.I1:
ctx.ReplaceInstructionOnly (CPUx86.Instruction.MovzxInstruction);
break;
case CilElementType.I2:
goto case CilElementType.I1;
case CilElementType.I4:
goto case CilElementType.I1;
case CilElementType.I8:
throw new NotSupportedException ();
case CilElementType.U1:
goto case CilElementType.I1;
case CilElementType.U2:
goto case CilElementType.I1;
case CilElementType.U4:
goto case CilElementType.I1;
case CilElementType.U8:
goto case CilElementType.I8;
case CilElementType.Char:
goto case CilElementType.I2;
default:
throw new NotSupportedException ();
}
if ((ctx.Result is RegisterOperand))
return;
Operand result = ctx.Result;
Operand source = ctx.Operand1;
RegisterOperand ebx = new RegisterOperand (result.Type, GeneralPurposeRegister.EBX);
ctx.Result = ebx;
ctx.AppendInstruction (CPUx86.Instruction.MovInstruction, result, ebx);
}