blob: 6ee903ba9b99b94cd6018d3723a0d45ceedb6ab1 [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 Murdoch61f157c2016-09-16 13:49:30 +010023class SimplifiedOperatorReducer final : public AdvancedReducer {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000024 public:
Ben Murdoch61f157c2016-09-16 13:49:30 +010025 SimplifiedOperatorReducer(Editor* editor, JSGraph* jsgraph);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000026 ~SimplifiedOperatorReducer() final;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000027
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000028 Reduction Reduce(Node* node) final;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000029
30 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000031 Reduction ReduceReferenceEqual(Node* node);
Ben Murdochc5610432016-08-08 18:44:38 +010032 Reduction ReduceTypeGuard(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);
Ben Murdoch61f157c2016-09-16 13:49:30 +010035 Reduction ReplaceBoolean(bool value);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000036 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_