1// Copyright 2018 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_CONSTANT_FOLDING_REDUCER_H_
6#define V8_COMPILER_CONSTANT_FOLDING_REDUCER_H_
7
8#include "src/compiler/graph-reducer.h"
9
10namespace v8 {
11namespace internal {
12namespace compiler {
13
14// Forward declarations.
15class JSGraph;
16
17class V8_EXPORT_PRIVATE ConstantFoldingReducer final
18    : public NON_EXPORTED_BASE(AdvancedReducer) {
19 public:
20  ConstantFoldingReducer(Editor* editor, JSGraph* jsgraph,
21                         JSHeapBroker* broker);
22  ~ConstantFoldingReducer() final;
23  ConstantFoldingReducer(const ConstantFoldingReducer&) = delete;
24  ConstantFoldingReducer& operator=(const ConstantFoldingReducer&) = delete;
25
26  const char* reducer_name() const override { return "ConstantFoldingReducer"; }
27
28  Reduction Reduce(Node* node) final;
29
30 private:
31  JSGraph* jsgraph() const { return jsgraph_; }
32  JSHeapBroker* broker() const { return broker_; }
33
34  JSGraph* const jsgraph_;
35  JSHeapBroker* const broker_;
36};
37
38}  // namespace compiler
39}  // namespace internal
40}  // namespace v8
41
42#endif  // V8_COMPILER_CONSTANT_FOLDING_REDUCER_H_
43