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

Unified Diff: src/compiler/node.h

Issue 2585713002: [turbofan] Use Node input iterators where possible (Closed)
Patch Set: Use == instead of DCHECK_EQ because of missing operator<< for iterators Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/graph-reducer.cc ('k') | src/compiler/value-numbering-reducer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/node.h
diff --git a/src/compiler/node.h b/src/compiler/node.h
index 06b6699c0beead376770d8c4426931bb12bc969b..a475fee21af8c655547790c2a16a141bf15a5534 100644
--- a/src/compiler/node.h
+++ b/src/compiler/node.h
@@ -410,6 +410,17 @@ class Node::InputEdges::iterator final {
return *this;
}
iterator operator++(int);
+ iterator& operator+=(difference_type offset) {
+ input_ptr_ += offset;
+ use_ -= offset;
+ return *this;
+ }
+ iterator operator+(difference_type offset) const {
+ return iterator(use_ - offset, input_ptr_ + offset);
+ }
+ difference_type operator-(const iterator& other) const {
+ return static_cast<difference_type>(input_ptr_ - other.input_ptr_);
+ }
private:
friend class Node;
@@ -417,6 +428,9 @@ class Node::InputEdges::iterator final {
explicit iterator(Node* from, int index = 0)
: use_(from->GetUsePtr(index)), input_ptr_(from->GetInputPtr(index)) {}
+ explicit iterator(Use* use, Node** input_ptr)
+ : use_(use), input_ptr_(input_ptr) {}
+
Use* use_;
Node** input_ptr_;
};
@@ -455,12 +469,24 @@ class Node::Inputs::const_iterator final {
return *this;
}
const_iterator operator++(int);
+ const_iterator& operator+=(difference_type offset) {
+ iter_ += offset;
+ return *this;
+ }
+ const_iterator operator+(difference_type offset) const {
+ return const_iterator(iter_ + offset);
+ }
+ difference_type operator-(const const_iterator& other) const {
+ return iter_ - other.iter_;
+ }
private:
friend class Node::Inputs;
const_iterator(Node* node, int index) : iter_(node, index) {}
+ explicit const_iterator(Node::InputEdges::iterator iter) : iter_(iter) {}
+
Node::InputEdges::iterator iter_;
};
« no previous file with comments | « src/compiler/graph-reducer.cc ('k') | src/compiler/value-numbering-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698