private bool IsCaseValid(ISingleEntrySubGraph caseEntry, HashSet <ISingleEntrySubGraph> legalPredecessors)
        {
            V_0 = caseEntry.get_SameParentPredecessors().GetEnumerator();
            try
            {
                while (V_0.MoveNext())
                {
                    V_1 = (ILogicalConstruct)V_0.get_Current();
                    if (legalPredecessors.Contains(V_1))
                    {
                        continue;
                    }
                    V_2 = false;
                    goto Label1;
                }
                goto Label0;
            }
            finally
            {
                ((IDisposable)V_0).Dispose();
            }
Label1:
            return(V_2);

Label0:
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the nodes that are dominated by this subgraph construct.
        /// </summary>
        /// <param name="construct"></param>
        /// <returns></returns>
        public HashSet <ISingleEntrySubGraph> GetDominatedNodes(ISingleEntrySubGraph construct)
        {
            DTNode node;

            if (!constructToNodeMap.TryGetValue(construct, out node))
            {
                return(null);
            }

            //A node dominates all of the constructs that are in the subtree (of the dominator tree) rooted at this node.
            //So we get them via simplified bfs (no need to check if a node is traversed, since it's a tree).
            HashSet <ISingleEntrySubGraph> dominatedNodes = new HashSet <ISingleEntrySubGraph>();
            Queue <DTNode> traversalQueue = new Queue <DTNode>();

            traversalQueue.Enqueue(node);

            while (traversalQueue.Count > 0)
            {
                DTNode currnetNode = traversalQueue.Dequeue();
                dominatedNodes.Add(currnetNode.Construct);

                foreach (DTNode successor in currnetNode.TreeEdgeSuccessors)
                {
                    traversalQueue.Enqueue(successor);
                }
            }

            return(dominatedNodes);
        }
Esempio n. 3
0
 public HashSet <ISingleEntrySubGraph> GetDominatedNodes(ISingleEntrySubGraph construct)
 {
     if (!this.constructToNodeMap.TryGetValue(construct, out V_0))
     {
         return(null);
     }
     V_1 = new HashSet <ISingleEntrySubGraph>();
     V_2 = new Queue <DTNode>();
     V_2.Enqueue(V_0);
     while (V_2.get_Count() > 0)
     {
         V_3       = V_2.Dequeue();
         dummyVar0 = V_1.Add(V_3.get_Construct());
         V_4       = V_3.get_TreeEdgeSuccessors().GetEnumerator();
         try
         {
             while (V_4.MoveNext())
             {
                 V_5 = (DTNode)V_4.get_Current();
                 V_2.Enqueue(V_5);
             }
         }
         finally
         {
             ((IDisposable)V_4).Dispose();
         }
     }
     return(V_1);
 }
Esempio n. 4
0
        public static ICollection <ISingleEntrySubGraph> GetTraversablePredecessors(ISingleEntrySubGraph construct)
        {
            List <ISingleEntrySubGraph> traversablePredecessors = new List <ISingleEntrySubGraph>(construct.SameParentPredecessors);

            traversablePredecessors.Sort();
            return(traversablePredecessors);
        }
Esempio n. 5
0
 public override int CompareTo(ISingleEntrySubGraph other)
 {
     V_0 = (other as ILogicalConstruct).get_FirstBlock() as PartialCFGBlockLogicalConstruct;
     if (V_0 == null || this.get_Index() != V_0.get_Index())
     {
         return(this.CompareTo(other));
     }
     if (this == V_0)
     {
         return(0);
     }
     V_1 = this;
     while (V_1 != null && V_1.get_Index() == this.get_Index())
     {
         if (V_1 == V_0)
         {
             return(-1);
         }
         if (V_1.get_CFGSuccessors().get_Count() != 1)
         {
             break;
         }
         stackVariable30 = V_1.get_CFGSuccessors().GetEnumerator();
         dummyVar0       = stackVariable30.MoveNext();
         V_1             = stackVariable30.get_Current() as PartialCFGBlockLogicalConstruct;
     }
     return(1);
 }
 public IntervalConstruct(ISingleEntrySubGraph entry)
 {
     this.Entry = entry;
     predecesors = new HashSet<ISingleEntrySubGraph>();
     successors = new HashSet<ISingleEntrySubGraph>();
     children = new HashSet<ISingleEntrySubGraph>();
     children.Add(entry);
 }
Esempio n. 7
0
 protected TreeNode(ISingleEntrySubGraph construct)
 {
     base();
     this.set_Construct(construct);
     this.set_Predecessor(null);
     this.set_TreeEdgeSuccessors(new HashSet <TreeNode>());
     return;
 }
Esempio n. 8
0
 public ISingleEntrySubGraph GetImmediateDominator(ISingleEntrySubGraph construct)
 {
     if (!this.constructToNodeMap.TryGetValue(construct, out V_0) || V_0.get_Predecessor() == null)
     {
         return(null);
     }
     return(V_0.get_Predecessor().get_Construct());
 }
 public IntervalConstruct(ISingleEntrySubGraph entry)
 {
     this.Entry  = entry;
     predecesors = new HashSet <ISingleEntrySubGraph>();
     successors  = new HashSet <ISingleEntrySubGraph>();
     children    = new HashSet <ISingleEntrySubGraph>();
     children.Add(entry);
 }
 /// <summary>
 /// Gets the immediate dominator of the specified subgraph construct.
 /// </summary>
 /// <param name="construct"></param>
 /// <returns></returns>
 public ISingleEntrySubGraph GetImmediateDominator(ISingleEntrySubGraph construct)
 {
     DTNode node;
     if (constructToNodeMap.TryGetValue(construct, out node) && node.Predecessor != null)
     {
         return node.Predecessor.Construct;
     }
     return null;
 }
 /// <param name="graph">The graph to be analyzed by the interval builder.</param>
 /// <param name="removedEdges">The edges in the Control flow graph, that have been marked as goto-edges.</param>
 public IntervalAnalyzer(ISingleEntrySubGraph graph, Dictionary <ILogicalConstruct, HashSet <ILogicalConstruct> > removedEdges)
 {
     this.availableNodes = graph.Children;
     this.entryPoint     = graph.Entry as ILogicalConstruct;
     this.headers        = new Queue <ILogicalConstruct>();
     this.intervals      = new List <IntervalConstruct>();
     this.nodeToInterval = new Dictionary <ISingleEntrySubGraph, IntervalConstruct>();
     this.removedEdges   = removedEdges;
 }
 /// <param name="graph">The graph to be analyzed by the interval builder.</param>
 /// <param name="removedEdges">The edges in the Control flow graph, that have been marked as goto-edges.</param>
 public IntervalAnalyzer(ISingleEntrySubGraph graph, Dictionary<ILogicalConstruct, HashSet<ILogicalConstruct>> removedEdges)
 {
     this.availableNodes = graph.Children;
     this.entryPoint = graph.Entry as ILogicalConstruct;
     this.headers = new Queue<ILogicalConstruct>();
     this.intervals = new List<IntervalConstruct>();
     this.nodeToInterval = new Dictionary<ISingleEntrySubGraph, IntervalConstruct>();
     this.removedEdges = removedEdges;
 }
Esempio n. 13
0
        /// <summary>
        /// Gets the immediate dominator of the specified subgraph construct.
        /// </summary>
        /// <param name="construct"></param>
        /// <returns></returns>
        public ISingleEntrySubGraph GetImmediateDominator(ISingleEntrySubGraph construct)
        {
            DTNode node;

            if (constructToNodeMap.TryGetValue(construct, out node) && node.Predecessor != null)
            {
                return(node.Predecessor.Construct);
            }
            return(null);
        }
Esempio n. 14
0
 public DFSTNode(ISingleEntrySubGraph construct)
     : base(construct)
 {
     BackEdgeSuccessors      = new HashSet <DFSTNode>();
     ForwardEdgeSucessors    = new HashSet <DFSTNode>();
     CrossEdgeSuccessors     = new HashSet <DFSTNode>();
     BackEdgePredecessors    = new HashSet <DFSTNode>();
     ForwardEdgePredecessors = new HashSet <DFSTNode>();
     CrossEdgePredecessors   = new HashSet <DFSTNode>();
 }
Esempio n. 15
0
 private DFSTBuilder(ISingleEntrySubGraph theGraph, ISingleEntrySubGraph entry)
 {
     this.traversedNodes     = new HashSet <DFSTNode>();
     this.currentPath        = new HashSet <DFSTNode>();
     this.constructToNodeMap = new Dictionary <ISingleEntrySubGraph, DFSTNode>();
     base();
     this.theGraph = theGraph;
     this.entry    = entry;
     return;
 }
Esempio n. 16
0
 public void MergeNodes(HashSet <ISingleEntrySubGraph> constructs, ISingleEntrySubGraph originalEntry, ISingleEntrySubGraph newConstruct)
 {
     V_0            = this.constructToNodeMap.get_Item(originalEntry);
     stackVariable5 = new DTNode(newConstruct);
     stackVariable5.set_Predecessor(V_0.get_Predecessor());
     V_1 = stackVariable5;
     V_1.get_DominanceFrontier().UnionWith(V_0.get_DominanceFrontier());
     dummyVar0 = V_1.get_DominanceFrontier().Remove(V_0);
     if (V_1.get_Predecessor() != null)
     {
         dummyVar1 = V_1.get_Predecessor().get_TreeEdgeSuccessors().Remove(V_0);
         dummyVar2 = V_1.get_Predecessor().get_TreeEdgeSuccessors().Add(V_1);
     }
     V_2 = constructs.GetEnumerator();
     try
     {
         while (V_2.MoveNext())
         {
             V_3       = V_2.get_Current();
             dummyVar3 = this.constructToNodeMap.Remove(V_3);
         }
     }
     finally
     {
         ((IDisposable)V_2).Dispose();
     }
     V_4 = this.constructToNodeMap.GetEnumerator();
     try
     {
         while (V_4.MoveNext())
         {
             V_5 = V_4.get_Current();
             if (V_5.get_Value().get_Predecessor() != null && constructs.Contains(V_5.get_Value().get_Predecessor().get_Construct()))
             {
                 V_5.get_Value().set_Predecessor(V_1);
                 dummyVar4 = V_1.get_TreeEdgeSuccessors().Add(V_5.get_Value());
             }
             if (!V_5.get_Value().get_DominanceFrontier().Remove(V_0))
             {
                 continue;
             }
             dummyVar5 = V_5.get_Value().get_DominanceFrontier().Add(V_1);
         }
     }
     finally
     {
         ((IDisposable)V_4).Dispose();
     }
     if (this.get_RootConstruct() == originalEntry)
     {
         this.set_RootConstruct(newConstruct);
     }
     this.constructToNodeMap.Add(newConstruct, V_1);
     return;
 }
Esempio n. 17
0
 public DFSTNode(ISingleEntrySubGraph construct)
 {
     base(construct);
     this.set_BackEdgeSuccessors(new HashSet <DFSTNode>());
     this.set_ForwardEdgeSucessors(new HashSet <DFSTNode>());
     this.set_CrossEdgeSuccessors(new HashSet <DFSTNode>());
     this.set_BackEdgePredecessors(new HashSet <DFSTNode>());
     this.set_ForwardEdgePredecessors(new HashSet <DFSTNode>());
     this.set_CrossEdgePredecessors(new HashSet <DFSTNode>());
     return;
 }
 private bool IsCaseValid(ISingleEntrySubGraph caseEntry, HashSet <ISingleEntrySubGraph> legalPredecessors)
 {
     foreach (ILogicalConstruct predecessor in caseEntry.SameParentPredecessors)
     {
         if (!legalPredecessors.Contains(predecessor))
         {
             return(false);
         }
     }
     return(true);
 }
        /// <summary>
        /// Sets the parents of the constructs in the <paramref name="childrenCollection"/> to this construct.
        /// </summary>
        /// <remarks>
        /// All of the constructs in the <paramref name="childrenCollection"/> should have the same parent.
        /// If this construct is attached to the logical tree, then it should have the same parent as the nodes in the <paramref name="childrenCollection"/>.
        /// Otherwise if this construct is not yet attached, then its parent is the common parent of the given nodes.
        /// </remarks>
        /// <param name="childrenCollection"></param>
        private void RedirectParents(IEnumerable <ILogicalConstruct> childrenCollection)
        {
            //In order to change the parents, all the constructs in childrenCollection should have the same parent that is different from this construct
            ISingleEntrySubGraph commonParent = null;

            foreach (ILogicalConstruct childNode in childrenCollection)
            {
                if (childNode.Parent == this)
                {
                    continue;
                }

                //If the common parent is not yet set, we set it
                if (commonParent == null)
                {
                    commonParent = childNode.Parent;
                }
                else if (commonParent != childNode.Parent)
                {
                    //sanity check
                    throw new InvalidOperationException("The nodes in the child collection does not have the same parent");
                }

                //When we create the initial block all the cfg blocks have null parent, so commonParent will remain null
                if (commonParent != null)
                {
                    //If the commonParent is not null we remove the childNode from it's children collection
                    commonParent.Children.Remove(childNode);
                }

                //Finally we set the parent of the child node to this construct and we add it to the children collection
                childNode.Parent = this;
                this.Children.Add(childNode);
            }

            if (commonParent != null)
            {
                commonParent.Children.Add(this);

                //If the parent of this construct was already set and it's not the same as the common parent we throw exception, because we can add
                //a construct as a child of another construct only if they share the same parent
                if (this.parent != null && this.parent != commonParent)
                {
                    throw new InvalidOperationException("The nodes you are trying to add are not from the same logical construct");
                }
                else if (this.parent == null)
                {
                    this.parent = commonParent;
                }
            }
        }
        /// <summary>
        /// Gets the dominance frontier of the specified subgraph construct.
        /// </summary>
        /// <param name="construct"></param>
        /// <returns></returns>
        public HashSet<ISingleEntrySubGraph> GetDominanceFrontier(ISingleEntrySubGraph construct)
        {
            DTNode node;
            if (!constructToNodeMap.TryGetValue(construct, out node))
            {
                return null;
            }

            HashSet<ISingleEntrySubGraph> dominanceFrontier = new HashSet<ISingleEntrySubGraph>();
            foreach (DTNode frontierNode in node.DominanceFrontier)
            {
                dominanceFrontier.Add(frontierNode.Construct);
            }

            return dominanceFrontier;
        }
Esempio n. 21
0
        private void UpdateDominatorTree(DominatorTree dominatorTree, LoopLogicalConstruct theLoopConstruct)
        {
            HashSet <ISingleEntrySubGraph> loopNodes = new HashSet <ISingleEntrySubGraph>();

            if (theLoopConstruct.LoopCondition != null)
            {
                loopNodes.Add(theLoopConstruct.LoopCondition);
            }
            if (theLoopConstruct.LoopBodyBlock != null)
            {
                loopNodes.UnionWith(theLoopConstruct.LoopBodyBlock.Children);
            }

            ISingleEntrySubGraph loopEntry = (theLoopConstruct.LoopType == LoopType.PreTestedLoop) ? theLoopConstruct.LoopCondition : theLoopConstruct.LoopBodyBlock.Entry;

            dominatorTree.MergeNodes(loopNodes, loopEntry, theLoopConstruct);
        }
        /// <summary>
        /// Gets the dominators of the specified subgraph construct.
        /// </summary>
        /// <param name="construct"></param>
        /// <returns></returns>
        public HashSet<ISingleEntrySubGraph> GetDominators(ISingleEntrySubGraph construct)
        {
            DTNode node;
            if (!constructToNodeMap.TryGetValue(construct, out node))
            {
                return null;
            }

            HashSet<ISingleEntrySubGraph> dominatorConstructs = new HashSet<ISingleEntrySubGraph>();

            foreach (DTNode dominator in node.Dominators)
            {
                dominatorConstructs.Add(dominator.Construct);
            }

            return dominatorConstructs;
        }
Esempio n. 23
0
        /// <summary>
        /// Gets the dominators of the specified subgraph construct.
        /// </summary>
        /// <param name="construct"></param>
        /// <returns></returns>
        public HashSet <ISingleEntrySubGraph> GetDominators(ISingleEntrySubGraph construct)
        {
            DTNode node;

            if (!constructToNodeMap.TryGetValue(construct, out node))
            {
                return(null);
            }

            HashSet <ISingleEntrySubGraph> dominatorConstructs = new HashSet <ISingleEntrySubGraph>();

            foreach (DTNode dominator in node.Dominators)
            {
                dominatorConstructs.Add(dominator.Construct);
            }

            return(dominatorConstructs);
        }
Esempio n. 24
0
        /// <summary>
        /// Gets the dominance frontier of the specified subgraph construct.
        /// </summary>
        /// <param name="construct"></param>
        /// <returns></returns>
        public HashSet <ISingleEntrySubGraph> GetDominanceFrontier(ISingleEntrySubGraph construct)
        {
            DTNode node;

            if (!constructToNodeMap.TryGetValue(construct, out node))
            {
                return(null);
            }

            HashSet <ISingleEntrySubGraph> dominanceFrontier = new HashSet <ISingleEntrySubGraph>();

            foreach (DTNode frontierNode in node.DominanceFrontier)
            {
                dominanceFrontier.Add(frontierNode.Construct);
            }

            return(dominanceFrontier);
        }
Esempio n. 25
0
        public void MergeNodes(HashSet <ISingleEntrySubGraph> constructs, ISingleEntrySubGraph originalEntry, ISingleEntrySubGraph newConstruct)
        {
            DTNode oldNode = constructToNodeMap[originalEntry];
            DTNode newNode = new DTNode(newConstruct)
            {
                Predecessor = oldNode.Predecessor
            };

            newNode.DominanceFrontier.UnionWith(oldNode.DominanceFrontier);
            newNode.DominanceFrontier.Remove(oldNode);

            if (newNode.Predecessor != null)
            {
                newNode.Predecessor.TreeEdgeSuccessors.Remove(oldNode);
                newNode.Predecessor.TreeEdgeSuccessors.Add(newNode);
            }

            foreach (ISingleEntrySubGraph constructToRemove in constructs)
            {
                constructToNodeMap.Remove(constructToRemove);
            }

            foreach (KeyValuePair <ISingleEntrySubGraph, DTNode> pair in constructToNodeMap)
            {
                if (pair.Value.Predecessor != null && constructs.Contains(pair.Value.Predecessor.Construct))
                {
                    pair.Value.Predecessor = newNode;
                    newNode.TreeEdgeSuccessors.Add(pair.Value);
                }

                if (pair.Value.DominanceFrontier.Remove(oldNode))
                {
                    pair.Value.DominanceFrontier.Add(newNode);
                }
            }

            if (RootConstruct == originalEntry)
            {
                RootConstruct = newConstruct;
            }

            constructToNodeMap.Add(newConstruct, newNode);
        }
Esempio n. 26
0
 public HashSet <ISingleEntrySubGraph> GetDominators(ISingleEntrySubGraph construct)
 {
     if (!this.constructToNodeMap.TryGetValue(construct, out V_0))
     {
         return(null);
     }
     V_1 = new HashSet <ISingleEntrySubGraph>();
     V_2 = V_0.get_Dominators().GetEnumerator();
     try
     {
         while (V_2.MoveNext())
         {
             V_3       = V_2.get_Current();
             dummyVar0 = V_1.Add(V_3.get_Construct());
         }
     }
     finally
     {
         ((IDisposable)V_2).Dispose();
     }
     return(V_1);
 }
Esempio n. 27
0
        /// <summary>
        /// Retruns the first common parent of the enumeration members. This is, the logical construct that is the first one to hold all of them.
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        /// <returns></returns>
        public static ISingleEntrySubGraph FindFirstCommonParent(IEnumerable <ISingleEntrySubGraph> blocks)
        {
            Queue <ISingleEntrySubGraph>   currentCommonParentsOrdered    = new Queue <ISingleEntrySubGraph>();
            HashSet <ISingleEntrySubGraph> currentCommonParentsSearchable = new HashSet <ISingleEntrySubGraph>();

            foreach (ISingleEntrySubGraph construct in blocks)
            {
                if (currentCommonParentsOrdered.Count == 0)                 //first pass
                {
                    ISingleEntrySubGraph currentParent = construct;
                    while (currentParent != null)
                    {
                        currentCommonParentsOrdered.Enqueue(currentParent);
                        currentCommonParentsSearchable.Add(currentParent);
                        currentParent = currentParent.Parent;
                    }
                }
                else
                {
                    ISingleEntrySubGraph firstConstructsParent = construct;
                    while (!currentCommonParentsSearchable.Contains(firstConstructsParent))
                    {
                        firstConstructsParent = firstConstructsParent.Parent;
                    }

                    if (currentCommonParentsSearchable.Contains(firstConstructsParent))
                    {
                        while (currentCommonParentsOrdered.Peek() != firstConstructsParent)
                        {
                            ISingleEntrySubGraph removed = currentCommonParentsOrdered.Dequeue();
                            currentCommonParentsSearchable.Remove(removed);
                        }
                    }
                }
            }

            return(currentCommonParentsOrdered.Peek());
        }
Esempio n. 28
0
 /// <summary>
 /// Creats a DFS traversal tree for the specified graph.
 /// </summary>
 /// <param name="theGraph"></param>
 /// <returns></returns>
 public static DFSTree BuildTree(ISingleEntrySubGraph theGraph)
 {
     return(BuildTree(theGraph, theGraph.Entry));
 }
Esempio n. 29
0
 /// <summary>
 /// Creats a DFS traversal tree for the specified graph.
 /// </summary>
 /// <param name="theGraph"></param>
 /// <returns></returns>
 public static DFSTree BuildTree(ISingleEntrySubGraph theGraph)
 {
     return BuildTree(theGraph, theGraph.Entry);
 }
Esempio n. 30
0
 private DFSTBuilder(ISingleEntrySubGraph theGraph, ISingleEntrySubGraph entry)
 {
     this.theGraph = theGraph;
     this.entry    = entry;
 }
Esempio n. 31
0
 internal DominatorTree(Dictionary <ISingleEntrySubGraph, DTNode> constructToNodeMap, ISingleEntrySubGraph rootConstruct)
 {
     base();
     this.constructToNodeMap = constructToNodeMap;
     this.set_RootConstruct(rootConstruct);
     return;
 }
Esempio n. 32
0
 public static DFSTree BuildTree(ISingleEntrySubGraph theGraph, ISingleEntrySubGraph entry)
 {
     return BuildTreeInternal(new DFSTBuilder(theGraph, entry));
 }
 public static ICollection<ISingleEntrySubGraph> GetTraversablePredecessors(ISingleEntrySubGraph construct)
 {
     List<ISingleEntrySubGraph> traversablePredecessors = new List<ISingleEntrySubGraph>(construct.SameParentPredecessors);
     traversablePredecessors.Sort();
     return traversablePredecessors;
 }
        /// <summary>
        /// Builds a dominator tree for the specified graph, with its entry as root.
        /// </summary>
        /// <param name="graph"></param>
        /// <returns></returns>
		public static DominatorTree BuildTree(ISingleEntrySubGraph graph)
		{
			return BuildTreeInternal(new FastDominatorTreeBuilder(graph));
		}
        /// <summary>
        /// Gets the nodes that are dominated by this subgraph construct.
        /// </summary>
        /// <param name="construct"></param>
        /// <returns></returns>
        public HashSet<ISingleEntrySubGraph> GetDominatedNodes(ISingleEntrySubGraph construct)
        {
            DTNode node;
            if(!constructToNodeMap.TryGetValue(construct, out node))
            {
                return null;
            }

            //A node dominates all of the constructs that are in the subtree (of the dominator tree) rooted at this node.
            //So we get them via simplified bfs (no need to check if a node is traversed, since it's a tree).
            HashSet<ISingleEntrySubGraph> dominatedNodes = new HashSet<ISingleEntrySubGraph>();
            Queue<DTNode> traversalQueue = new Queue<DTNode>();
            traversalQueue.Enqueue(node);

            while(traversalQueue.Count > 0)
            {
                DTNode currnetNode = traversalQueue.Dequeue();
                dominatedNodes.Add(currnetNode.Construct);

                foreach (DTNode successor in currnetNode.TreeEdgeSuccessors)
                {
                    traversalQueue.Enqueue(successor);
                }
            }

            return dominatedNodes;
        }
 protected BaseDominatorTreeBuilder(ISingleEntrySubGraph graph)
 {
     this.originalGraph = graph;
     this.rootConstruct = graph.Entry;
 }
 public int CompareTo(ISingleEntrySubGraph other)
 {
     return this.Index.CompareTo(other.Index);
 }
Esempio n. 38
0
 public DTNode(ISingleEntrySubGraph construct)
     : base(construct)
 {
     DominanceFrontier = new HashSet<DTNode>();
 }
 private bool IsCaseValid(ISingleEntrySubGraph caseEntry, HashSet<ISingleEntrySubGraph> legalPredecessors)
 {
     foreach (ILogicalConstruct predecessor in caseEntry.SameParentPredecessors)
     {
         if (!legalPredecessors.Contains(predecessor))
         {
             return false;
         }
     }
     return true;
 }
 private FastDominatorTreeBuilder(ISingleEntrySubGraph graph)
     : base(graph)
 {
 }
Esempio n. 41
0
 internal DominatorTree(Dictionary <ISingleEntrySubGraph, DTNode> constructToNodeMap, ISingleEntrySubGraph rootConstruct)
 {
     this.constructToNodeMap = constructToNodeMap;
     RootConstruct           = rootConstruct;
 }
Esempio n. 42
0
 public static DFSTree BuildTree(ISingleEntrySubGraph theGraph, ISingleEntrySubGraph entry)
 {
     return(BuildTreeInternal(new DFSTBuilder(theGraph, entry)));
 }
 internal DominatorTree(Dictionary<ISingleEntrySubGraph, DTNode> constructToNodeMap, ISingleEntrySubGraph rootConstruct)
 {
     this.constructToNodeMap = constructToNodeMap;
     RootConstruct = rootConstruct;
 }
Esempio n. 44
0
 private DFSTBuilder(ISingleEntrySubGraph theGraph, ISingleEntrySubGraph entry)
 {
     this.theGraph = theGraph;
     this.entry = entry;
 }
        public void MergeNodes(HashSet<ISingleEntrySubGraph> constructs, ISingleEntrySubGraph originalEntry, ISingleEntrySubGraph newConstruct)
        {
            DTNode oldNode = constructToNodeMap[originalEntry];
            DTNode newNode = new DTNode(newConstruct) { Predecessor = oldNode.Predecessor };

            newNode.DominanceFrontier.UnionWith(oldNode.DominanceFrontier);
            newNode.DominanceFrontier.Remove(oldNode);

            if (newNode.Predecessor != null)
            {
                newNode.Predecessor.TreeEdgeSuccessors.Remove(oldNode);
                newNode.Predecessor.TreeEdgeSuccessors.Add(newNode);
            }

            foreach (ISingleEntrySubGraph constructToRemove in constructs)
            {
                constructToNodeMap.Remove(constructToRemove);
            }

            foreach (KeyValuePair<ISingleEntrySubGraph, DTNode> pair in constructToNodeMap)
            {
                if (pair.Value.Predecessor != null && constructs.Contains(pair.Value.Predecessor.Construct))
                {
                    pair.Value.Predecessor = newNode;
                    newNode.TreeEdgeSuccessors.Add(pair.Value);
                }

                if (pair.Value.DominanceFrontier.Remove(oldNode))
                {
                    pair.Value.DominanceFrontier.Add(newNode);
                }
            }

            if (RootConstruct == originalEntry)
            {
                RootConstruct = newConstruct;
            }

            constructToNodeMap.Add(newConstruct, newNode);
        }
Esempio n. 46
0
 public DTNode(ISingleEntrySubGraph construct)
     : base(construct)
 {
     DominanceFrontier = new HashSet <DTNode>();
 }
Esempio n. 47
0
 protected TreeNode(ISingleEntrySubGraph construct)
 {
     Construct = construct;
     Predecessor = null;
     TreeEdgeSuccessors = new HashSet<TreeNode>();
 }
 /// <summary>
 /// Builds a dominator tree for the specified graph, with its entry as root.
 /// </summary>
 /// <param name="graph"></param>
 /// <returns></returns>
 public static DominatorTree BuildTree(ISingleEntrySubGraph graph)
 {
     return(BuildTreeInternal(new FastDominatorTreeBuilder(graph)));
 }
 private FastDominatorTreeBuilder(ISingleEntrySubGraph graph)
     :base(graph)
 {
 }