• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/common/globals.h"
10 #include "src/compiler/graph-reducer.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, JSHeapBroker* broker,
28                         CommonOperatorBuilder* common,
29                         MachineOperatorBuilder* machine, Zone* temp_zone);
30   ~CommonOperatorReducer() final = default;
31 
32   const char* reducer_name() const override { return "CommonOperatorReducer"; }
33 
34   Reduction Reduce(Node* node) final;
35 
36  private:
37   Reduction ReduceBranch(Node* node);
38   Reduction ReduceDeoptimizeConditional(Node* node);
39   Reduction ReduceMerge(Node* node);
40   Reduction ReduceEffectPhi(Node* node);
41   Reduction ReducePhi(Node* node);
42   Reduction ReduceReturn(Node* node);
43   Reduction ReduceSelect(Node* node);
44   Reduction ReduceSwitch(Node* node);
45   Reduction ReduceStaticAssert(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* broker() const { return 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 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