blob: dfeb409291a9ba0090dae9e662404874ccf4df2e [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_JS_BUILTIN_REDUCER_H_
6#define V8_COMPILER_JS_BUILTIN_REDUCER_H_
7
8#include "src/compiler/graph-reducer.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +00009
10namespace v8 {
11namespace internal {
Ben Murdoch097c5b22016-05-18 11:27:45 +010012
13// Forward declarations.
14class TypeCache;
15
Ben Murdochb8a8cc12014-11-26 15:28:44 +000016namespace compiler {
17
Emily Bernierd0a1eb72015-03-24 16:35:39 -040018// Forward declarations.
19class CommonOperatorBuilder;
20class JSGraph;
21class MachineOperatorBuilder;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000022class SimplifiedOperatorBuilder;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040023
24
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000025class JSBuiltinReducer final : public AdvancedReducer {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000026 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000027 explicit JSBuiltinReducer(Editor* editor, JSGraph* jsgraph);
28 ~JSBuiltinReducer() final {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000029
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000030 Reduction Reduce(Node* node) final;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000031
32 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000033 Reduction ReduceFunctionCall(Node* node);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000034 Reduction ReduceMathMax(Node* node);
35 Reduction ReduceMathImul(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010036 Reduction ReduceMathCeil(Node* node);
37 Reduction ReduceMathClz32(Node* node);
38 Reduction ReduceMathFloor(Node* node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040039 Reduction ReduceMathFround(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010040 Reduction ReduceMathRound(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010041 Reduction ReduceMathSqrt(Node* node);
42 Reduction ReduceMathTrunc(Node* node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040043
Emily Bernierd0a1eb72015-03-24 16:35:39 -040044 Graph* graph() const;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000045 JSGraph* jsgraph() const { return jsgraph_; }
46 Isolate* isolate() const;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040047 CommonOperatorBuilder* common() const;
48 MachineOperatorBuilder* machine() const;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000049 SimplifiedOperatorBuilder* simplified() const;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000050
Ben Murdoch097c5b22016-05-18 11:27:45 +010051 JSGraph* const jsgraph_;
52 TypeCache const& type_cache_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000053};
54
55} // namespace compiler
56} // namespace internal
57} // namespace v8
58
59#endif // V8_COMPILER_JS_BUILTIN_REDUCER_H_