common-operator-reducer.h 1.88 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_COMMON_OPERATOR_REDUCER_H_
#define V8_COMPILER_COMMON_OPERATOR_REDUCER_H_

8
#include "src/base/compiler-specific.h"
9
#include "src/compiler/graph-reducer.h"
10
#include "src/globals.h"
11 12 13 14 15

namespace v8 {
namespace internal {
namespace compiler {

16 17 18 19
// Forward declarations.
class CommonOperatorBuilder;
class Graph;
class MachineOperatorBuilder;
20
class Operator;
21 22


23
// Performs strength reduction on nodes that have common operators.
24 25
class V8_EXPORT_PRIVATE CommonOperatorReducer final
    : public NON_EXPORTED_BASE(AdvancedReducer) {
26
 public:
27 28
  CommonOperatorReducer(Editor* editor, Graph* graph,
                        CommonOperatorBuilder* common,
29
                        MachineOperatorBuilder* machine);
30
  ~CommonOperatorReducer() final {}
31

32 33
  const char* reducer_name() const override { return "CommonOperatorReducer"; }

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 41
  Reduction ReduceEffectPhi(Node* node);
  Reduction ReducePhi(Node* node);
42
  Reduction ReduceReturn(Node* node);
43 44
  Reduction ReduceSelect(Node* node);

45 46 47
  Reduction Change(Node* node, Operator const* op, Node* a);
  Reduction Change(Node* node, Operator const* op, Node* a, Node* b);

48 49 50
  Graph* graph() const { return graph_; }
  CommonOperatorBuilder* common() const { return common_; }
  MachineOperatorBuilder* machine() const { return machine_; }
51
  Node* dead() const { return dead_; }
52

53 54 55
  Graph* const graph_;
  CommonOperatorBuilder* const common_;
  MachineOperatorBuilder* const machine_;
56
  Node* const dead_;
57 58 59 60 61 62 63
};

}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_COMMON_OPERATOR_REDUCER_H_