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_COMMON_OPERATOR_REDUCER_H_ 6 #define V8_COMPILER_COMMON_OPERATOR_REDUCER_H_ 7 8 #include "src/base/compiler-specific.h" 9 #include "src/compiler/graph-reducer.h" 10 #include "src/globals.h" 11 12 namespace v8 { 13 namespace internal { 14 namespace compiler { 15 16 // Forward declarations. 17 class CommonOperatorBuilder; 18 class Graph; 19 class MachineOperatorBuilder; 20 class Operator; 21 22 23 // Performs strength reduction on nodes that have common operators. 24 class V8_EXPORT_PRIVATE CommonOperatorReducer final NON_EXPORTED_BASE(AdvancedReducer)25 : public NON_EXPORTED_BASE(AdvancedReducer) { 26 public: 27 CommonOperatorReducer(Editor* editor, Graph* graph, 28 JSHeapBroker* js_heap_broker, 29 CommonOperatorBuilder* common, 30 MachineOperatorBuilder* machine, Zone* temp_zone); 31 ~CommonOperatorReducer() final {} 32 33 const char* reducer_name() const override { return "CommonOperatorReducer"; } 34 35 Reduction Reduce(Node* node) final; 36 37 private: 38 Reduction ReduceBranch(Node* node); 39 Reduction ReduceDeoptimizeConditional(Node* node); 40 Reduction ReduceMerge(Node* node); 41 Reduction ReduceEffectPhi(Node* node); 42 Reduction ReducePhi(Node* node); 43 Reduction ReduceReturn(Node* node); 44 Reduction ReduceSelect(Node* node); 45 Reduction ReduceSwitch(Node* node); 46 47 Reduction Change(Node* node, Operator const* op, Node* a); 48 Reduction Change(Node* node, Operator const* op, Node* a, Node* b); 49 50 Graph* graph() const { return graph_; } 51 JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } 52 CommonOperatorBuilder* common() const { return common_; } 53 MachineOperatorBuilder* machine() const { return machine_; } 54 Node* dead() const { return dead_; } 55 56 Graph* const graph_; 57 JSHeapBroker* const js_heap_broker_; 58 CommonOperatorBuilder* const common_; 59 MachineOperatorBuilder* const machine_; 60 Node* const dead_; 61 Zone* zone_; 62 }; 63 64 } // namespace compiler 65 } // namespace internal 66 } // namespace v8 67 68 #endif // V8_COMPILER_COMMON_OPERATOR_REDUCER_H_ 69