本文整理汇总了C#中BasicBlock类的典型用法代码示例。如果您正苦于以下问题:C# BasicBlock类的具体用法?C# BasicBlock怎么用?C# BasicBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicBlock类属于命名空间,在下文中一共展示了BasicBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildBlocks
public BuildBlocks(List<TExp> instList)
{
Dictionary<Temp.Label, BasicBlock> LabelToBlock = new Dictionary<Temp.Label, BasicBlock>();
foreach (TExp e in instList)
{
if (e is Label)
{
BasicBlock b = new BasicBlock();
Blocks.Add(b);
LabelToBlock[(e as Label).Lab] = b;
}
Blocks[Blocks.Count - 1].List.Add(e);
}
for (int i = 0; i < Blocks.Count; ++i)
{
BasicBlock b = Blocks[i];
if (b.List[b.List.Count - 1] is Jump)
{
b.AddEdge(LabelToBlock[(b.List[b.List.Count - 1] as Jump).Label.Lab]);
}
else
{
if (i + 1 < Blocks.Count)
b.AddEdge(Blocks[i + 1]);
if (b.List[b.List.Count - 1] is CJump)
b.AddEdge(LabelToBlock[(b.List[b.List.Count - 1] as CJump).Label.Lab]);
else if (b.List[b.List.Count - 1] is CJumpInt)
b.AddEdge(LabelToBlock[(b.List[b.List.Count - 1] as CJumpInt).Label.Lab]);
}
}
}
开发者ID:Nxun,项目名称:Naive-Tiger,代码行数:31,代码来源:Block.cs
示例2: Load
public override BasicBlock<MilocInstruction> Load(int target)
{
var b = new BasicBlock<MilocInstruction>();
b.Add(new LoadaiFieldInstruction(addressReg, name, target) { ContainingType = containingType, FieldIndex = fieldIndex, FieldType = this.Type });
b.Reg = target;
return b;
}
开发者ID:AustinWise,项目名称:CSC431,代码行数:7,代码来源:VarField.cs
示例3: Load
public override BasicBlock<MilocInstruction> Load(int target)
{
var b = new BasicBlock<MilocInstruction>();
b.Add(new LoadglobalInstruction(name, target) { Type = this.Type });
b.Reg = target;
return b;
}
开发者ID:AustinWise,项目名称:CSC431,代码行数:7,代码来源:VarGlobal.cs
示例4: Load
public override BasicBlock<MilocInstruction> Load(int target)
{
var b = new BasicBlock<MilocInstruction>();
b.Add(new LoadaiVarInstruction(name, target) { ArgIndex = ArgIndex });
b.Reg = target;
return b;
}
开发者ID:AustinWise,项目名称:CSC431,代码行数:7,代码来源:VarLocal.cs
示例5: Load
public override BasicBlock<MilocInstruction> Load(int target)
{
var b = new BasicBlock<MilocInstruction>();
b.Add(new MovInstruction(this.reg, target) { ArgIndex = ArgIndex, ArgReg = reg });
b.Reg = target;
return b;
}
开发者ID:AustinWise,项目名称:CSC431,代码行数:7,代码来源:VarReg.cs
示例6: AddEdge
public void AddEdge(BasicBlock target)
{
if (target == null)
return;
Next.Add(target);
target.Prev.Add(this);
}
开发者ID:Nxun,项目名称:Naive-Tiger,代码行数:7,代码来源:Block.cs
示例7: OptimizeComparisonToConstZero
/// <summary>
/// replaces comparisons where one operand has just been set to a const zero.
/// asumes that instruction is a comparison instruction with two registers.
/// </summary>
private bool OptimizeComparisonToConstZero(Instruction ins, BasicBlock bb)
{
var r1 = ins.Registers[0];
var r2 = ins.Registers[1];
bool? r1IsZero = null, r2IsZero = null;
if (r1.Category == RCategory.Argument || r1.PreventOptimization)
r1IsZero = false;
if (r2.Category == RCategory.Argument || r2.PreventOptimization)
r2IsZero = false;
for (var prev = ins.PreviousOrDefault; prev != null && prev.Index >= bb.Entry.Index; prev=prev.PreviousOrDefault)
{
if(r1IsZero.HasValue && r2IsZero.HasValue)
break;
if ((r1IsZero.HasValue && r1IsZero.Value) || (r2IsZero.HasValue && r2IsZero.Value))
break;
if (r1IsZero == null)
{
if (r1.IsDestinationIn(prev))
{
r1IsZero = prev.Code == RCode.Const && Convert.ToInt32(prev.Operand) == 0;
continue;
}
}
if (r2IsZero == null)
{
if (r2.IsDestinationIn(prev))
{
r2IsZero = prev.Code == RCode.Const && Convert.ToInt32(prev.Operand) == 0;
continue;
}
}
}
if (r2IsZero.HasValue && r2IsZero.Value)
{
ins.Code = ToComparisonWithZero(ins.Code);
ins.Registers.Clear();
ins.Registers.Add(r1);
return true;
}
if (r1IsZero.HasValue && r1IsZero.Value)
{
// swap the registers before converting to zero-comparison.
ins.Code = ToComparisonWithZero(SwapComparisonRegisters(ins.Code));
ins.Registers.Clear();
ins.Registers.Add(r2);
return true;
}
return false;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:63,代码来源:PredictableBranchOptimizer.cs
示例8: LinkBlockToClause
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public void LinkBlockToClause(Context context, BasicBlock block)
{
foreach (EhClause clause in this.Clauses)
{
if (clause.LinkBlockToClause(context, block))
return;
}
}
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:12,代码来源:ExceptionClauseHeader.cs
示例9: LinkBlocks
/// <summary>
/// Links the blocks.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="destination">The destination.</param>
protected void LinkBlocks(BasicBlock source, BasicBlock destination)
{
if (!source.NextBlocks.Contains(destination))
source.NextBlocks.Add(destination);
if (!destination.PreviousBlocks.Contains(source))
destination.PreviousBlocks.Add(source);
}
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:13,代码来源:BaseCodeTransformationStage.cs
示例10: GetSuccessors
public IEnumerable<BasicBlock> GetSuccessors(BasicBlock source)
{
foreach (XRef xref in graph.GetReferencesFrom(source.Location))
{
// TODO: change Find to ExactMatch.
yield return blocks.Find(xref.Target);
}
}
开发者ID:meloscheng,项目名称:dos-debugger,代码行数:8,代码来源:ControlFlowGraph.cs
示例11: BasicBlockEdge
public BasicBlockEdge(CFG cfg, int fromName, int toName)
{
From = cfg.CreateNode(fromName);
To = cfg.CreateNode(toName);
From.OutEdges.Add(To);
To.InEdges.Add(From);
cfg.AddEdge(this);
}
开发者ID:ZombineDev,项目名称:benchmarks,代码行数:8,代码来源:havlak.cs
示例12:
List<BasicBlock> IDominanceAnalysis.GetChildren(BasicBlock block)
{
List<BasicBlock> child;
if (children.TryGetValue(block, out child))
return child;
else
return new List<BasicBlock>(); // Empty List
}
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:9,代码来源:SimpleFastDominance.cs
示例13: BBLoop
public BBLoop(BasicBlock head, BasicBlock tail, IMSet<BasicBlock> body, JST.Identifier label)
{
Head = head;
Tail = tail;
Body = body;
Label = label;
var headEscapes = false;
var headbranchbb = head as BranchBasicBlock;
foreach (var t in head.Targets)
{
if (!body.Contains(t))
headEscapes = true;
}
var tailEscapes = false;
var tailbranchbb = tail as BranchBasicBlock;
foreach (var t in tail.Targets)
{
if (!body.Contains(t))
tailEscapes = true;
}
if (!headEscapes && tailEscapes && tailbranchbb != null)
{
if (tailbranchbb.Target.Equals(head))
Flavor = LoopFlavor.DoWhile;
else if (tailbranchbb.Fallthrough.Equals(head))
Flavor = LoopFlavor.FlippedDoWhile;
else
throw new InvalidOperationException("invalid loop");
}
else if (headEscapes && !tailEscapes && headbranchbb != null)
{
if (body.Contains(headbranchbb.Target))
Flavor = LoopFlavor.WhileDo;
else if (body.Contains(headbranchbb.Fallthrough))
Flavor = LoopFlavor.FlippedWhileDo;
else
throw new InvalidOperationException("invalid loop");
}
else if (!headEscapes && !tailEscapes)
Flavor = LoopFlavor.Loop;
else if (headEscapes && tailEscapes && headbranchbb != null && tailbranchbb != null)
{
// Could encode as do-while with a break at start, or while-do with a break at end.
if (body.Contains(headbranchbb.Target))
Flavor = LoopFlavor.WhileDo;
else if (body.Contains(headbranchbb.Fallthrough))
Flavor = LoopFlavor.FlippedWhileDo;
else
throw new InvalidOperationException("invalid loop");
}
else
Flavor = LoopFlavor.Unknown;
}
开发者ID:modulexcite,项目名称:IL2JS,代码行数:56,代码来源:BasicBlockUtils.cs
示例14: RemoveDeadBlock
protected void RemoveDeadBlock(BasicBlock block)
{
if (trace.Active) trace.Log("*** RemoveBlock: " + block.ToString());
var nextBlocks = block.NextBlocks.ToArray();
EmptyBlockOfAllInstructions(block);
UpdatePhiList(block, nextBlocks);
}
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:10,代码来源:SparseConditionalConstantPropagationStage.cs
示例15: doInvoke
private void doInvoke(string id, BasicBlock<MilocInstruction> b, List<int> regLocs)
{
var fun = CSC431.Program.Stable.Value.getType(id);
for (int i = 0; i < regLocs.Count; i++)
{
var t = fun.getArgs()[i];
b.Add(new StoreoutargumentInstruction(regLocs[i], i) { Type = t });
}
b.Add(new CallInstruction(id));
}
开发者ID:AustinWise,项目名称:CSC431,代码行数:10,代码来源:IlGenWalker.mine.cs
示例16: BasicBlockEdge
public BasicBlockEdge(CFG cfg, int fromName, int toName)
{
from = cfg.createNode(fromName);
to = cfg.createNode(toName);
from.addOutEdge(to);
to.addInEdge(from);
cfg.addEdge(this);
}
开发者ID:mattwarren,项目名称:multi-language-bench,代码行数:10,代码来源:BasicBlockEdge.cs
示例17: GetFirstContext
private Context GetFirstContext(BasicBlock block)
{
for (Context context = new Context(InstructionSet, block); !context.IsBlockEndInstruction; context.GotoNext())
{
if (context.IsBlockStartInstruction)
continue;
return context;
}
return null;
}
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:10,代码来源:UnboxValueTypeStage.cs
示例18: Redirect
private static void Redirect(List<BasicBlock> blocks, BasicBlock oldBlock, BasicBlock newBlock)
{
foreach (BasicBlock b in blocks)
{
if (b.UnconditionalTarget == oldBlock)
b.UnconditionalTarget = newBlock;
if (b.ConditionalTarget == oldBlock)
b.ConditionalTarget = newBlock;
}
}
开发者ID:ZingModelChecker,项目名称:Zing,代码行数:10,代码来源:BBOptimizer.cs
示例19: ExtendedBlock
public ExtendedBlock(BasicBlock basicBlock, int registerCount, int loopDepth)
{
this.BasicBlock = basicBlock;
this.LiveGen = new BitArray(registerCount);
this.LiveKill = new BitArray(registerCount);
this.LiveOut = new BitArray(registerCount);
this.LiveIn = new BitArray(registerCount);
this.LiveKillNot = new BitArray(registerCount);
this.LoopDepth = loopDepth;
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:10,代码来源:ExtendedBlock.cs
示例20: SplitEdge
private void SplitEdge(BasicBlock from, BasicBlock to)
{
// Create new block z
var ctx = CreateNewBlockContext();
InsertJumpInstruction(ctx, to);
ctx.Label = -1;
ReplaceBranchTargets(from, to, ctx.Block);
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:11,代码来源:BaseEdgeSplitStage.cs
注:本文中的BasicBlock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论