public static List<Block/*!*/>/*!*/ UnrollLoops(Block start, int unrollMaxDepth, bool soundLoopUnrolling) { Contract.Requires(start != null); Contract.Requires(0 <= unrollMaxDepth); Contract.Ensures(cce.NonNullElements(Contract.Result<List<Block>>())); Dictionary<Block, GraphNode/*!*/> gd = new Dictionary<Block, GraphNode/*!*/>(); HashSet<Block> beingVisited = new HashSet<Block>(); GraphNode gStart = GraphNode.ComputeGraphInfo(null, start, gd, beingVisited); // Compute SCCs StronglyConnectedComponents<GraphNode/*!*/> sccs = new StronglyConnectedComponents<GraphNode/*!*/>(gd.Values, Preds, Succs); Contract.Assert(sccs != null); sccs.Compute(); Dictionary<GraphNode/*!*/, SCC<GraphNode/*!*/>> containingSCC = new Dictionary<GraphNode/*!*/, SCC<GraphNode/*!*/>>(); foreach (SCC<GraphNode/*!*/> scc in sccs) { foreach (GraphNode/*!*/ n in scc) { Contract.Assert(n != null); containingSCC[n] = scc; } } LoopUnroll lu = new LoopUnroll(unrollMaxDepth, soundLoopUnrolling, containingSCC, new List<Block/*!*/>()); lu.Visit(gStart); lu.newBlockSeqGlobal.Reverse(); return lu.newBlockSeqGlobal; }
public static List <Block /*!*/> /*!*/ UnrollLoops(Block start, int unrollMaxDepth, bool soundLoopUnrolling) { Contract.Requires(start != null); Contract.Requires(0 <= unrollMaxDepth); Contract.Ensures(cce.NonNullElements(Contract.Result <List <Block> >())); Dictionary <Block, GraphNode /*!*/> gd = new Dictionary <Block, GraphNode /*!*/>(); HashSet <Block> beingVisited = new HashSet <Block>(); GraphNode gStart = GraphNode.ComputeGraphInfo(null, start, gd, beingVisited); // Compute SCCs StronglyConnectedComponents <GraphNode /*!*/> sccs = new StronglyConnectedComponents <GraphNode /*!*/>(gd.Values, Preds, Succs); Contract.Assert(sccs != null); sccs.Compute(); Dictionary <GraphNode /*!*/, SCC <GraphNode /*!*/> > containingSCC = new Dictionary <GraphNode /*!*/, SCC <GraphNode /*!*/> >(); foreach (SCC <GraphNode /*!*/> scc in sccs) { foreach (GraphNode /*!*/ n in scc) { Contract.Assert(n != null); containingSCC[n] = scc; } } LoopUnroll lu = new LoopUnroll(unrollMaxDepth, soundLoopUnrolling, containingSCC, new List <Block /*!*/>()); lu.Visit(gStart); lu.newBlockSeqGlobal.Reverse(); return(lu.newBlockSeqGlobal); }
private LoopUnroll(int unrollMaxDepth, bool soundLoopUnrolling, Dictionary <GraphNode /*!*/, SCC <GraphNode /*!*/> > /*!*/ scc, List <Block /*!*/> /*!*/ newBlockSeqGlobal) : base() { Contract.Requires(cce.NonNullElements(newBlockSeqGlobal)); Contract.Requires(cce.NonNullDictionaryAndValues(scc) && Contract.ForAll(scc.Values, v => cce.NonNullElements(v))); Contract.Requires(0 <= unrollMaxDepth); this.newBlockSeqGlobal = newBlockSeqGlobal; this.c = unrollMaxDepth; this.containingSCC = scc; this.head = this; if (unrollMaxDepth != 0) { next = new LoopUnroll(unrollMaxDepth - 1, soundLoopUnrolling, scc, newBlockSeqGlobal, this); } }
private LoopUnroll(int unrollMaxDepth, bool soundLoopUnrolling, Dictionary <GraphNode /*!*/, SCC <GraphNode /*!*/> > scc, List <Block /*!*/> /*!*/ newBlockSeqGlobal, LoopUnroll head) { Contract.Requires(head != null); Contract.Requires(cce.NonNullDictionaryAndValues(scc)); Contract.Requires(cce.NonNullElements(newBlockSeqGlobal)); Contract.Requires(0 <= unrollMaxDepth); this.newBlockSeqGlobal = newBlockSeqGlobal; this.c = unrollMaxDepth; this.soundLoopUnrolling = soundLoopUnrolling; this.containingSCC = scc; this.head = head; if (unrollMaxDepth != 0) { next = new LoopUnroll(unrollMaxDepth - 1, soundLoopUnrolling, scc, newBlockSeqGlobal, head); } }
private LoopUnroll(int unrollMaxDepth, bool soundLoopUnrolling, Dictionary<GraphNode/*!*/, SCC<GraphNode/*!*/>> scc, List<Block/*!*/>/*!*/ newBlockSeqGlobal, LoopUnroll head) { Contract.Requires(head != null); Contract.Requires(cce.NonNullDictionaryAndValues(scc)); Contract.Requires(cce.NonNullElements(newBlockSeqGlobal)); Contract.Requires(0 <= unrollMaxDepth); this.newBlockSeqGlobal = newBlockSeqGlobal; this.c = unrollMaxDepth; this.soundLoopUnrolling = soundLoopUnrolling; this.containingSCC = scc; this.head = head; if (unrollMaxDepth != 0) { next = new LoopUnroll(unrollMaxDepth - 1, soundLoopUnrolling, scc, newBlockSeqGlobal, head); } }
private LoopUnroll(int unrollMaxDepth, bool soundLoopUnrolling, Dictionary<GraphNode/*!*/, SCC<GraphNode/*!*/>>/*!*/ scc, List<Block/*!*/>/*!*/ newBlockSeqGlobal) : base() { Contract.Requires(cce.NonNullElements(newBlockSeqGlobal)); Contract.Requires(cce.NonNullDictionaryAndValues(scc) && Contract.ForAll(scc.Values, v => cce.NonNullElements(v))); Contract.Requires(0 <= unrollMaxDepth); this.newBlockSeqGlobal = newBlockSeqGlobal; this.c = unrollMaxDepth; this.containingSCC = scc; this.head = this; if (unrollMaxDepth != 0) { next = new LoopUnroll(unrollMaxDepth - 1, soundLoopUnrolling, scc, newBlockSeqGlobal, this); } }