blob: c91579236f7c038699fb4031b6fa0400860c6864 [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;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000021class SimplifiedOperatorBuilder;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040022
23
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000024class JSBuiltinReducer final : public AdvancedReducer {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000025 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000026 explicit JSBuiltinReducer(Editor* editor, JSGraph* jsgraph);
27 ~JSBuiltinReducer() 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 Murdoch61f157c2016-09-16 13:49:30 +010032 Reduction ReduceMathAbs(Node* node);
33 Reduction ReduceMathAtan(Node* node);
34 Reduction ReduceMathAtan2(Node* node);
35 Reduction ReduceMathAtanh(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010036 Reduction ReduceMathCeil(Node* node);
37 Reduction ReduceMathClz32(Node* node);
Ben Murdoch61f157c2016-09-16 13:49:30 +010038 Reduction ReduceMathCos(Node* node);
39 Reduction ReduceMathExp(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010040 Reduction ReduceMathFloor(Node* node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040041 Reduction ReduceMathFround(Node* node);
Ben Murdoch61f157c2016-09-16 13:49:30 +010042 Reduction ReduceMathImul(Node* node);
43 Reduction ReduceMathLog(Node* node);
44 Reduction ReduceMathLog1p(Node* node);
45 Reduction ReduceMathLog10(Node* node);
46 Reduction ReduceMathLog2(Node* node);
47 Reduction ReduceMathMax(Node* node);
48 Reduction ReduceMathMin(Node* node);
49 Reduction ReduceMathCbrt(Node* node);
50 Reduction ReduceMathExpm1(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010051 Reduction ReduceMathRound(Node* node);
Ben Murdoch61f157c2016-09-16 13:49:30 +010052 Reduction ReduceMathSin(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010053 Reduction ReduceMathSqrt(Node* node);
Ben Murdoch61f157c2016-09-16 13:49:30 +010054 Reduction ReduceMathTan(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010055 Reduction ReduceMathTrunc(Node* node);
Ben Murdoch61f157c2016-09-16 13:49:30 +010056 Reduction ReduceStringFromCharCode(Node* node);
57
58 Node* ToNumber(Node* value);
59 Node* ToUint32(Node* value);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040060
Emily Bernierd0a1eb72015-03-24 16:35:39 -040061 Graph* graph() const;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000062 JSGraph* jsgraph() const { return jsgraph_; }
63 Isolate* isolate() const;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040064 CommonOperatorBuilder* common() const;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000065 SimplifiedOperatorBuilder* simplified() const;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000066
Ben Murdoch097c5b22016-05-18 11:27:45 +010067 JSGraph* const jsgraph_;
68 TypeCache const& type_cache_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000069};
70
71} // namespace compiler
72} // namespace internal
73} // namespace v8
74
75#endif // V8_COMPILER_JS_BUILTIN_REDUCER_H_