blob: 13301c2af5ce27dd6df55de25b9b33f398f3e7f4 [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"
9
10namespace v8 {
11namespace internal {
Ben Murdochda12d292016-06-02 14:46:10 +010012
13// Forward declarations.
14class TypeCache;
15
Ben Murdochb8a8cc12014-11-26 15:28:44 +000016namespace compiler {
17
18// Forward declarations.
19class JSGraph;
20class MachineOperatorBuilder;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000021class SimplifiedOperatorBuilder;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000022
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000023
24class SimplifiedOperatorReducer final : public Reducer {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000025 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040026 explicit SimplifiedOperatorReducer(JSGraph* jsgraph);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000027 ~SimplifiedOperatorReducer() final;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000028
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000029 Reduction Reduce(Node* node) final;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000030
31 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000032 Reduction ReduceReferenceEqual(Node* node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040033
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;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000044 JSGraph* jsgraph() const { return jsgraph_; }
45 MachineOperatorBuilder* machine() const;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000046 SimplifiedOperatorBuilder* simplified() const;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000047
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000048 JSGraph* const jsgraph_;
Ben Murdochda12d292016-06-02 14:46:10 +010049 TypeCache const& type_cache_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000050
51 DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
52};
53
54} // namespace compiler
55} // namespace internal
56} // namespace v8
57
58#endif // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_