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