本文整理汇总了C#中Mosa.Runtime.CompilerFramework.Context.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Remove方法的具体用法?C# Context.Remove怎么用?C# Context.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mosa.Runtime.CompilerFramework.Context
的用法示例。
在下文中一共展示了Context.Remove方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <summary>
/// Performs stage specific processing on the compiler context.
/// </summary>
public void Run()
{
bool remove = false;
foreach (BasicBlock block in BasicBlocks) {
for (Context ctx = new Context(InstructionSet, block); !ctx.EndOfInstruction; ctx.GotoNext()) {
if (ctx.Instruction is IR.MoveInstruction || ctx.Instruction is CIL.StlocInstruction) {
if (ctx.Operand1 is ConstantOperand) {
// HACK: We can't track a constant through a register, so we keep those moves
if (ctx.Result is StackOperand) {
Debug.Assert(ctx.Result.Definitions.Count == 1, @"Operand defined multiple times. Instruction stream not in SSA form!");
ctx.Result.Replace(ctx.Operand1, InstructionSet);
remove = true;
}
}
}
else if (ctx.Instruction is IR.PhiInstruction) {
IR.PhiInstruction phi = (IR.PhiInstruction)ctx.Instruction;
ConstantOperand co = ctx.Operand2 as ConstantOperand;
List<BasicBlock> blocks = ctx.Other as List<BasicBlock>; // FIXME PG / ctx has moved
if (co != null && blocks.Count == 1) {
// We can remove the phi, as it is only defined once
// HACK: We can't track a constant through a register, so we keep those moves
if (!ctx.Result.IsRegister) {
Debug.Assert(ctx.Result.Definitions.Count == 1, @"Operand defined multiple times. Instruction stream not in SSA form!");
ctx.Result.Replace(co, InstructionSet);
remove = true;
}
}
}
// Shall we remove this instruction?
if (remove) {
ctx.Remove();
remove = false;
}
}
}
}
示例2: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
// TODO
context.Remove();
}
示例3:
/// <summary>
/// Visitation function for <see cref="ICILVisitor.Pop"/>.
/// </summary>
/// <param name="ctx">The context.</param>
void ICILVisitor.Pop(Context ctx)
{
ctx.Remove ();
}
示例4: 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="ctx">Provides the transformation context.</param>
private void ProcessLoadInstruction(Context ctx)
{
// We don't need to rewire the source/destination yet, its already there. :(
//Remove(ctx);
ctx.Remove ();
}
示例5: ConstantOperand
/// <summary>
/// Visitation function for <see cref="CIL.ICILVisitor.Switch"/>.
/// </summary>
/// <param name="ctx">The context.</param>
void CIL.ICILVisitor.Switch(Context ctx)
{
IBranch branch = ctx.Branch;
Operand operand = ctx.Operand1;
ctx.Remove();
for (int i = 0; i < branch.Targets.Length - 1; ++i) {
ctx.AppendInstruction(CPUx86.Instruction.CmpInstruction, operand, new ConstantOperand(new SigType(CilElementType.I), i));
ctx.AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.Equal);
ctx.SetBranch(branch.Targets[i]);
}
}
示例6: 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="ctx">Provides the transformation context.</param>
private void ProcessLoadInstruction(Context ctx)
{
// We don't need to rewire the source/destination yet, its already there. :(
//Remove(ctx);
ctx.Remove();
/* FIXME: This is only valid with reg alloc!
Type type = null;
load = load as LoadInstruction;
// Is this a sign or zero-extending move?
if (IsSignExtending(load.Source))
{
type = typeof(IR.SignExtendedMoveInstruction);
}
else if (IsZeroExtending(load.Source))
{
type = typeof(IR.ZeroExtendedMoveInstruction);
}
// Do we have a move replacement?
if (null == type)
{
// No, we can safely drop the load instruction and can rewire the operands.
/*if (1 == load.Destination.Definitions.Count && 1 == load.Destination.Uses.Count)
{
load.Destination.Replace(load.Source);
Remove(ctx);
}
return;
}
else
{
Replace(ctx, Architecture.CreateInstruction(type, load.Destination, load.Source));
}*/
}
示例7:
/// <summary>
/// Visitation function for <see cref="ICILVisitor.Call"/>.
/// </summary>
/// <param name="ctx">The context.</param>
void ICILVisitor.Call(Context ctx)
{
if (this.CanSkipDueToRecursiveSystemObjectCtorCall(ctx) == true)
{
ctx.Remove();
return;
}
if (this.ProcessIntrinsicCall(ctx) == false)
{
// Create a symbol operand for the invocation target
RuntimeMethod invokeTarget = ctx.InvokeTarget;
SymbolOperand symbolOperand = SymbolOperand.FromMethod(invokeTarget);
this.ProcessInvokeInstruction(ctx, symbolOperand, ctx.Result, new List<Operand>(ctx.Operands));
}
}
示例8: Ldloc
/// <summary>
/// Visitation function for <see cref="ICILVisitor.Ldloc"/>.
/// </summary>
/// <param name="ctx">The context.</param>
public void Ldloc(Context ctx)
{
if (ctx.Ignore == true)
{
ctx.Remove();
}
else
{
this.ProcessLoadInstruction(ctx);
}
}
示例9: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
public void ReplaceIntrinsicCall(Context context)
{
// context.SetInstruction(IR.Instruction.JmpInstruction, );
context.Remove();
}
示例10: Ldloc
/// <summary>
/// Visitation function for Ldloc instruction.
/// </summary>
/// <param name="context">The context.</param>
public void Ldloc(Context context)
{
if (context.Ignore)
{
context.Remove();
}
else
{
this.ProcessLoadInstruction(context);
}
}
示例11:
/// <summary>
/// Visitation function for Pop instruction.
/// </summary>
/// <param name="context">The context.</param>
void CIL.ICILVisitor.Pop(Context context)
{
context.Remove();
}
示例12: ProcessInvokeInstruction
/// <summary>
/// Visitation function for Call instruction.
/// </summary>
/// <param name="context">The context.</param>
void CIL.ICILVisitor.Call(Context context)
{
if (this.CanSkipDueToRecursiveSystemObjectCtorCall(context))
{
context.Remove();
return;
}
//if (ProcessVmCall(context))
// return;
if (ProcessExternalCall(context))
return;
// Create a symbol operand for the invocation target
RuntimeMethod invokeTarget = context.InvokeTarget;
SymbolOperand symbolOperand = SymbolOperand.FromMethod(invokeTarget);
ProcessInvokeInstruction(context, symbolOperand, context.Result, new List<Operand>(context.Operands));
}
示例13: SwitchInstruction
public void SwitchInstruction(Context context)
{
IBranch branch = context.Branch;
Operand operand = context.Operand1;
context.Remove();
for (int i = 0; i < branch.Targets.Length - 1; ++i)
{
context.AppendInstruction(CPUx86.Instruction.CmpInstruction, operand, new ConstantOperand(new SigType(CilElementType.I), i));
context.AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.Equal);
context.SetBranch(branch.Targets[i]);
}
}