Lines Matching full:loop
35 // Represents a loop in the tree of loops, including the header nodes,
37 class Loop {
39 Loop* parent() const { return parent_; } in parent()
40 const ZoneVector<Loop*>& children() const { return children_; } in children()
51 explicit Loop(Zone* zone) in Loop() function
59 Loop* parent_;
61 ZoneVector<Loop*> children_;
68 // Return the innermost nested loop, if any, that contains {node}.
69 Loop* ContainingLoop(Node* node) { in ContainingLoop()
75 // Check if the {loop} contains the {node}, either directly or by containing
76 // a nested loop that contains {node}.
77 bool Contains(Loop* loop, Node* node) { in Contains() argument
78 for (Loop* c = ContainingLoop(node); c != nullptr; c = c->parent_) { in Contains()
79 if (c == loop) return true; in Contains()
85 const ZoneVector<Loop*>& outer_loops() const { return outer_loops_; } in outer_loops()
87 // Return the unique loop number for a given loop. Loop numbers start at {1}.
88 int LoopNum(Loop* loop) const { in LoopNum() argument
89 return 1 + static_cast<int>(loop - &all_loops_[0]); in LoopNum()
92 // Return a range which can iterate over the header nodes of {loop}.
93 NodeRange HeaderNodes(Loop* loop) { in HeaderNodes() argument
94 return NodeRange(&loop_nodes_[0] + loop->header_start_, in HeaderNodes()
95 &loop_nodes_[0] + loop->body_start_); in HeaderNodes()
98 // Return the header control node for a loop.
99 Node* HeaderNode(Loop* loop);
101 // Return a range which can iterate over the body nodes of {loop}.
102 NodeRange BodyNodes(Loop* loop) { in BodyNodes() argument
103 return NodeRange(&loop_nodes_[0] + loop->body_start_, in BodyNodes()
104 &loop_nodes_[0] + loop->exits_start_); in BodyNodes()
107 // Return a range which can iterate over the body nodes of {loop}.
108 NodeRange ExitNodes(Loop* loop) { in ExitNodes() argument
109 return NodeRange(&loop_nodes_[0] + loop->exits_start_, in ExitNodes()
110 &loop_nodes_[0] + loop->exits_end_); in ExitNodes()
113 // Return a range which can iterate over the nodes of {loop}.
114 NodeRange LoopNodes(Loop* loop) { in LoopNodes() argument
115 return NodeRange(&loop_nodes_[0] + loop->header_start_, in LoopNodes()
116 &loop_nodes_[0] + loop->exits_end_); in LoopNodes()
119 // Return the node that represents the control, i.e. the loop node itself.
120 Node* GetLoopControl(Loop* loop) { in GetLoopControl() argument
121 // TODO(turbofan): make the loop control node always first? in GetLoopControl()
122 for (Node* node : HeaderNodes(loop)) { in GetLoopControl()
133 Loop* NewLoop() { in NewLoop()
134 all_loops_.push_back(Loop(zone_)); in NewLoop()
135 Loop* result = &all_loops_.back(); in NewLoop()
139 void SetParent(Loop* parent, Loop* child) { in SetParent()
150 ZoneVector<Loop*> outer_loops_;
151 ZoneVector<Loop> all_loops_;
158 // Build a loop tree for the entire graph.