blob: 70750a854c79f0ddaded80cd92615514213b7c47 [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);
Ben Murdochc5610432016-08-08 18:44:38 +010033 Reduction ReduceTypeGuard(Node* node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040034
Ben Murdochb8a8cc12014-11-26 15:28:44 +000035 Reduction Change(Node* node, const Operator* op, Node* a);
36 Reduction ReplaceFloat64(double value);
37 Reduction ReplaceInt32(int32_t value);
38 Reduction ReplaceUint32(uint32_t value) {
39 return ReplaceInt32(bit_cast<int32_t>(value));
40 }
41 Reduction ReplaceNumber(double value);
42 Reduction ReplaceNumber(int32_t value);
43
44 Graph* graph() const;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000045 JSGraph* jsgraph() const { return jsgraph_; }
46 MachineOperatorBuilder* machine() const;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000047 SimplifiedOperatorBuilder* simplified() const;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000048
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000049 JSGraph* const jsgraph_;
Ben Murdochda12d292016-06-02 14:46:10 +010050 TypeCache const& type_cache_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000051
52 DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
53};
54
55} // namespace compiler
56} // namespace internal
57} // namespace v8
58
59#endif // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_