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

Side by Side Diff: src/compiler/graph-reducer.h

Issue 479793004: [turbofan] Initial import of SimplifiedOperatorReducer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « BUILD.gn ('k') | src/compiler/node-matchers.h » ('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_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 <list> 8 #include <list>
9 9
10 #include "src/zone-allocator.h" 10 #include "src/zone-allocator.h"
(...skipping 20 matching lines...) Expand all
31 }; 31 };
32 32
33 33
34 // A reducer can reduce or simplify a given node based on its operator and 34 // A reducer can reduce or simplify a given node based on its operator and
35 // inputs. This class functions as an extension point for the graph reducer for 35 // inputs. This class functions as an extension point for the graph reducer for
36 // language-specific reductions (e.g. reduction based on types or constant 36 // language-specific reductions (e.g. reduction based on types or constant
37 // folding of low-level operators) can be integrated into the graph reduction 37 // folding of low-level operators) can be integrated into the graph reduction
38 // phase. 38 // phase.
39 class Reducer { 39 class Reducer {
40 public: 40 public:
41 Reducer() {}
41 virtual ~Reducer() {} 42 virtual ~Reducer() {}
42 43
43 // Try to reduce a node if possible. 44 // Try to reduce a node if possible.
44 virtual Reduction Reduce(Node* node) = 0; 45 virtual Reduction Reduce(Node* node) = 0;
45 46
46 // Helper functions for subclasses to produce reductions for a node. 47 // Helper functions for subclasses to produce reductions for a node.
47 static Reduction NoChange() { return Reduction(); } 48 static Reduction NoChange() { return Reduction(); }
48 static Reduction Replace(Node* node) { return Reduction(node); } 49 static Reduction Replace(Node* node) { return Reduction(node); }
49 static Reduction Changed(Node* node) { return Reduction(node); } 50 static Reduction Changed(Node* node) { return Reduction(node); }
51
52 private:
53 DISALLOW_COPY_AND_ASSIGN(Reducer);
50 }; 54 };
51 55
52 56
53 // Performs an iterative reduction of a node graph. 57 // Performs an iterative reduction of a node graph.
54 class GraphReducer V8_FINAL { 58 class GraphReducer V8_FINAL {
55 public: 59 public:
56 explicit GraphReducer(Graph* graph); 60 explicit GraphReducer(Graph* graph);
57 61
58 Graph* graph() const { return graph_; } 62 Graph* graph() const { return graph_; }
59 63
60 void AddReducer(Reducer* reducer) { reducers_.push_back(reducer); } 64 void AddReducer(Reducer* reducer) { reducers_.push_back(reducer); }
61 65
62 // Reduce a single node. 66 // Reduce a single node.
63 void ReduceNode(Node* node); 67 void ReduceNode(Node* node);
64 // Reduce the whole graph. 68 // Reduce the whole graph.
65 void ReduceGraph(); 69 void ReduceGraph();
66 70
67 private: 71 private:
68 typedef std::list<Reducer*, zone_allocator<Reducer*> > Reducers; 72 typedef std::list<Reducer*, zone_allocator<Reducer*> > Reducers;
69 73
70 Graph* graph_; 74 Graph* graph_;
71 Reducers reducers_; 75 Reducers reducers_;
76
77 DISALLOW_COPY_AND_ASSIGN(GraphReducer);
72 }; 78 };
73 } 79
74 } 80 } // namespace compiler
75 } // namespace v8::internal::compiler 81 } // namespace internal
82 } // namespace v8
76 83
77 #endif // V8_COMPILER_GRAPH_REDUCER_H_ 84 #endif // V8_COMPILER_GRAPH_REDUCER_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/compiler/node-matchers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698