Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: src/compiler/loop-analysis.h

Issue 816053002: [turbofan] First version of loop peeling. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/graph-visualizer.cc ('k') | src/compiler/loop-analysis.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_LOOP_ANALYSIS_H_ 5 #ifndef V8_COMPILER_LOOP_ANALYSIS_H_
6 #define V8_COMPILER_LOOP_ANALYSIS_H_ 6 #define V8_COMPILER_LOOP_ANALYSIS_H_
7 7
8 #include "src/base/iterator.h" 8 #include "src/base/iterator.h"
9 #include "src/compiler/graph.h" 9 #include "src/compiler/graph.h"
10 #include "src/compiler/node.h" 10 #include "src/compiler/node.h"
(...skipping 19 matching lines...) Expand all
30 30
31 // Represents a loop in the tree of loops, including the header nodes, 31 // Represents a loop in the tree of loops, including the header nodes,
32 // the body, and any nested loops. 32 // the body, and any nested loops.
33 class Loop { 33 class Loop {
34 public: 34 public:
35 Loop* parent() const { return parent_; } 35 Loop* parent() const { return parent_; }
36 const ZoneVector<Loop*>& children() const { return children_; } 36 const ZoneVector<Loop*>& children() const { return children_; }
37 size_t HeaderSize() const { return body_start_ - header_start_; } 37 size_t HeaderSize() const { return body_start_ - header_start_; }
38 size_t BodySize() const { return body_end_ - body_start_; } 38 size_t BodySize() const { return body_end_ - body_start_; }
39 size_t TotalSize() const { return body_end_ - header_start_; } 39 size_t TotalSize() const { return body_end_ - header_start_; }
40 size_t depth() const { return static_cast<size_t>(depth_); }
40 41
41 private: 42 private:
42 friend class LoopTree; 43 friend class LoopTree;
43 friend class LoopFinderImpl; 44 friend class LoopFinderImpl;
44 45
45 explicit Loop(Zone* zone) 46 explicit Loop(Zone* zone)
46 : parent_(nullptr), 47 : parent_(nullptr),
47 depth_(0), 48 depth_(0),
48 children_(zone), 49 children_(zone),
49 header_start_(-1), 50 header_start_(-1),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return NodeRange(&loop_nodes_[0] + loop->header_start_, 88 return NodeRange(&loop_nodes_[0] + loop->header_start_,
88 &loop_nodes_[0] + loop->body_start_); 89 &loop_nodes_[0] + loop->body_start_);
89 } 90 }
90 91
91 // Return a range which can iterate over the body nodes of {loop}. 92 // Return a range which can iterate over the body nodes of {loop}.
92 NodeRange BodyNodes(Loop* loop) { 93 NodeRange BodyNodes(Loop* loop) {
93 return NodeRange(&loop_nodes_[0] + loop->body_start_, 94 return NodeRange(&loop_nodes_[0] + loop->body_start_,
94 &loop_nodes_[0] + loop->body_end_); 95 &loop_nodes_[0] + loop->body_end_);
95 } 96 }
96 97
98 // Return a range which can iterate over the nodes of {loop}.
99 NodeRange LoopNodes(Loop* loop) {
100 return NodeRange(&loop_nodes_[0] + loop->header_start_,
101 &loop_nodes_[0] + loop->body_end_);
102 }
103
104 // Return the node that represents the control, i.e. the loop node itself.
105 Node* GetLoopControl(Loop* loop) {
106 // TODO(turbofan): make the loop control node always first?
107 for (Node* node : HeaderNodes(loop)) {
108 if (node->opcode() == IrOpcode::kLoop) return node;
109 }
110 UNREACHABLE();
111 return NULL;
112 }
113
97 private: 114 private:
98 friend class LoopFinderImpl; 115 friend class LoopFinderImpl;
99 116
100 Loop* NewLoop() { 117 Loop* NewLoop() {
101 all_loops_.push_back(Loop(zone_)); 118 all_loops_.push_back(Loop(zone_));
102 Loop* result = &all_loops_.back(); 119 Loop* result = &all_loops_.back();
103 return result; 120 return result;
104 } 121 }
105 122
106 void SetParent(Loop* parent, Loop* child) { 123 void SetParent(Loop* parent, Loop* child) {
(...skipping 13 matching lines...) Expand all
120 ZoneVector<Node*> loop_nodes_; 137 ZoneVector<Node*> loop_nodes_;
121 }; 138 };
122 139
123 140
124 class LoopFinder { 141 class LoopFinder {
125 public: 142 public:
126 // Build a loop tree for the entire graph. 143 // Build a loop tree for the entire graph.
127 static LoopTree* BuildLoopTree(Graph* graph, Zone* temp_zone); 144 static LoopTree* BuildLoopTree(Graph* graph, Zone* temp_zone);
128 }; 145 };
129 146
147
130 } // namespace compiler 148 } // namespace compiler
131 } // namespace internal 149 } // namespace internal
132 } // namespace v8 150 } // namespace v8
133 151
134 #endif // V8_COMPILER_LOOP_ANALYSIS_H_ 152 #endif // V8_COMPILER_LOOP_ANALYSIS_H_
OLDNEW
« no previous file with comments | « src/compiler/graph-visualizer.cc ('k') | src/compiler/loop-analysis.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698