| OLD | NEW |
| 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_GRAPH_REDUCER_H_ | 5 #ifndef V8_COMPILER_GRAPH_REDUCER_H_ |
| 6 #define V8_COMPILER_GRAPH_REDUCER_H_ | 6 #define V8_COMPILER_GRAPH_REDUCER_H_ |
| 7 | 7 |
| 8 #include "src/compiler/node-marker.h" | 8 #include "src/compiler/node-marker.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // language-specific reductions (e.g. reduction based on types or constant | 40 // language-specific reductions (e.g. reduction based on types or constant |
| 41 // folding of low-level operators) can be integrated into the graph reduction | 41 // folding of low-level operators) can be integrated into the graph reduction |
| 42 // phase. | 42 // phase. |
| 43 class Reducer { | 43 class Reducer { |
| 44 public: | 44 public: |
| 45 virtual ~Reducer() {} | 45 virtual ~Reducer() {} |
| 46 | 46 |
| 47 // Try to reduce a node if possible. | 47 // Try to reduce a node if possible. |
| 48 virtual Reduction Reduce(Node* node) = 0; | 48 virtual Reduction Reduce(Node* node) = 0; |
| 49 | 49 |
| 50 // Invoked by the {GraphReducer} when all nodes are done. Can be used to |
| 51 // do additional reductions at the end, which in turn can cause a new round |
| 52 // of reductions. |
| 53 virtual void Finalize(); |
| 54 |
| 50 // Helper functions for subclasses to produce reductions for a node. | 55 // Helper functions for subclasses to produce reductions for a node. |
| 51 static Reduction NoChange() { return Reduction(); } | 56 static Reduction NoChange() { return Reduction(); } |
| 52 static Reduction Replace(Node* node) { return Reduction(node); } | 57 static Reduction Replace(Node* node) { return Reduction(node); } |
| 53 static Reduction Changed(Node* node) { return Reduction(node); } | 58 static Reduction Changed(Node* node) { return Reduction(node); } |
| 54 }; | 59 }; |
| 55 | 60 |
| 56 | 61 |
| 57 // An advanced reducer can also edit the graphs by changing and replacing nodes | 62 // An advanced reducer can also edit the graphs by changing and replacing nodes |
| 58 // other than the one currently being reduced. | 63 // other than the one currently being reduced. |
| 59 class AdvancedReducer : public Reducer { | 64 class AdvancedReducer : public Reducer { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 ZoneStack<NodeState> stack_; | 175 ZoneStack<NodeState> stack_; |
| 171 | 176 |
| 172 DISALLOW_COPY_AND_ASSIGN(GraphReducer); | 177 DISALLOW_COPY_AND_ASSIGN(GraphReducer); |
| 173 }; | 178 }; |
| 174 | 179 |
| 175 } // namespace compiler | 180 } // namespace compiler |
| 176 } // namespace internal | 181 } // namespace internal |
| 177 } // namespace v8 | 182 } // namespace v8 |
| 178 | 183 |
| 179 #endif // V8_COMPILER_GRAPH_REDUCER_H_ | 184 #endif // V8_COMPILER_GRAPH_REDUCER_H_ |
| OLD | NEW |