blob: 1e565b8b137bb91278053fcc22778ecda1bee700 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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_SIMPLIFIED_OPERATOR_REDUCER_H_
6#define V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
7
8#include "src/compiler/graph-reducer.h"
Emily Bernierd0a1eb72015-03-24 16:35:39 -04009#include "src/compiler/simplified-operator.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000010
11namespace v8 {
12namespace internal {
13
14// Forward declarations.
15class Heap;
16
17namespace compiler {
18
19// Forward declarations.
Emily Bernierd0a1eb72015-03-24 16:35:39 -040020class CommonOperatorBuilder;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000021class JSGraph;
22class MachineOperatorBuilder;
23
24class SimplifiedOperatorReducer FINAL : public Reducer {
25 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040026 explicit SimplifiedOperatorReducer(JSGraph* jsgraph);
27 ~SimplifiedOperatorReducer() FINAL;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000028
Emily Bernierd0a1eb72015-03-24 16:35:39 -040029 Reduction Reduce(Node* node) FINAL;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000030
31 private:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040032 Reduction ReduceAnyToBoolean(Node* node);
33
Ben Murdochb8a8cc12014-11-26 15:28:44 +000034 Reduction Change(Node* node, const Operator* op, Node* a);
35 Reduction ReplaceFloat64(double value);
36 Reduction ReplaceInt32(int32_t value);
37 Reduction ReplaceUint32(uint32_t value) {
38 return ReplaceInt32(bit_cast<int32_t>(value));
39 }
40 Reduction ReplaceNumber(double value);
41 Reduction ReplaceNumber(int32_t value);
42
43 Graph* graph() const;
44 Factory* factory() const;
45 JSGraph* jsgraph() const { return jsgraph_; }
Emily Bernierd0a1eb72015-03-24 16:35:39 -040046 CommonOperatorBuilder* common() const;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000047 MachineOperatorBuilder* machine() const;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040048 SimplifiedOperatorBuilder* simplified() { return &simplified_; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000049
50 JSGraph* jsgraph_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040051 SimplifiedOperatorBuilder simplified_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000052
53 DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
54};
55
56} // namespace compiler
57} // namespace internal
58} // namespace v8
59
60#endif // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_