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_OPERATOR_REDUCERS_H_ | 5 #ifndef V8_COMPILER_OPERATOR_REDUCERS_H_ |
6 #define V8_COMPILER_OPERATOR_REDUCERS_H_ | 6 #define V8_COMPILER_OPERATOR_REDUCERS_H_ |
7 | 7 |
8 #include "src/compiler/graph-reducer.h" | 8 #include "src/compiler/graph-reducer.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/lowering-builder.h" | |
11 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
12 #include "src/compiler/node.h" | 11 #include "src/compiler/node.h" |
13 #include "src/compiler/simplified-operator.h" | 12 #include "src/compiler/simplified-operator.h" |
14 | 13 |
15 namespace v8 { | 14 namespace v8 { |
16 namespace internal { | 15 namespace internal { |
17 namespace compiler { | 16 namespace compiler { |
18 | 17 |
19 // Lowers JS-level operators to simplified operators based on types. | 18 // Lowers JS-level operators to simplified operators based on types. |
20 class JSTypedLowering : public LoweringBuilder { | 19 class JSTypedLowering : public Reducer { |
21 public: | 20 public: |
22 explicit JSTypedLowering(JSGraph* jsgraph, | 21 explicit JSTypedLowering(JSGraph* jsgraph) |
23 SourcePositionTable* source_positions) | 22 : jsgraph_(jsgraph), |
24 : LoweringBuilder(jsgraph->graph(), source_positions), | |
25 jsgraph_(jsgraph), | |
26 simplified_(jsgraph->zone()), | 23 simplified_(jsgraph->zone()), |
27 machine_(jsgraph->zone()) {} | 24 machine_(jsgraph->zone()) {} |
28 virtual ~JSTypedLowering() {} | 25 virtual ~JSTypedLowering() {} |
29 | 26 |
30 Reduction Reduce(Node* node); | 27 virtual Reduction Reduce(Node* node); |
31 virtual void Lower(Node* node) { Reduce(node); } | |
32 | 28 |
33 JSGraph* jsgraph() { return jsgraph_; } | 29 JSGraph* jsgraph() { return jsgraph_; } |
34 Graph* graph() { return jsgraph_->graph(); } | 30 Graph* graph() { return jsgraph_->graph(); } |
35 | 31 |
36 private: | 32 private: |
37 friend class JSBinopReduction; | 33 friend class JSBinopReduction; |
38 JSGraph* jsgraph_; | 34 JSGraph* jsgraph_; |
39 SimplifiedOperatorBuilder simplified_; | 35 SimplifiedOperatorBuilder simplified_; |
40 MachineOperatorBuilder machine_; | 36 MachineOperatorBuilder machine_; |
41 | 37 |
42 Reduction ReplaceEagerly(Node* old, Node* node); | 38 Reduction ReplaceEagerly(Node* old, Node* node); |
43 Reduction NoChange() { return Reducer::NoChange(); } | |
44 Reduction ReplaceWith(Node* node) { return Reducer::Replace(node); } | 39 Reduction ReplaceWith(Node* node) { return Reducer::Replace(node); } |
45 Reduction Changed(Node* node) { return Reducer::Changed(node); } | |
46 Reduction ReduceJSAdd(Node* node); | 40 Reduction ReduceJSAdd(Node* node); |
47 Reduction ReduceJSComparison(Node* node); | 41 Reduction ReduceJSComparison(Node* node); |
48 Reduction ReduceJSEqual(Node* node, bool invert); | 42 Reduction ReduceJSEqual(Node* node, bool invert); |
49 Reduction ReduceJSStrictEqual(Node* node, bool invert); | 43 Reduction ReduceJSStrictEqual(Node* node, bool invert); |
50 Reduction ReduceJSToNumberInput(Node* input); | 44 Reduction ReduceJSToNumberInput(Node* input); |
51 Reduction ReduceJSToStringInput(Node* input); | 45 Reduction ReduceJSToStringInput(Node* input); |
52 Reduction ReduceJSToBooleanInput(Node* input); | 46 Reduction ReduceJSToBooleanInput(Node* input); |
53 Reduction ReduceNumberBinop(Node* node, Operator* numberOp); | 47 Reduction ReduceNumberBinop(Node* node, Operator* numberOp); |
54 Reduction ReduceI32Binop(Node* node, bool left_signed, bool right_signed, | 48 Reduction ReduceI32Binop(Node* node, bool left_signed, bool right_signed, |
55 Operator* intOp); | 49 Operator* intOp); |
56 Reduction ReduceI32Shift(Node* node, bool left_signed, Operator* shift_op); | 50 Reduction ReduceI32Shift(Node* node, bool left_signed, Operator* shift_op); |
57 | 51 |
58 JSOperatorBuilder* javascript() { return jsgraph_->javascript(); } | 52 JSOperatorBuilder* javascript() { return jsgraph_->javascript(); } |
59 CommonOperatorBuilder* common() { return jsgraph_->common(); } | 53 CommonOperatorBuilder* common() { return jsgraph_->common(); } |
60 SimplifiedOperatorBuilder* simplified() { return &simplified_; } | 54 SimplifiedOperatorBuilder* simplified() { return &simplified_; } |
61 MachineOperatorBuilder* machine() { return &machine_; } | 55 MachineOperatorBuilder* machine() { return &machine_; } |
62 }; | 56 }; |
63 } | 57 } |
64 } | 58 } |
65 } // namespace v8::internal::compiler | 59 } // namespace v8::internal::compiler |
66 | 60 |
67 #endif // V8_COMPILER_OPERATOR_REDUCERS_H_ | 61 #endif // V8_COMPILER_OPERATOR_REDUCERS_H_ |
OLD | NEW |