blob: baffe206ff6a9a34ef8bfa37aa1d8dd2f2354164 [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_LOWERING_H_
6#define V8_COMPILER_SIMPLIFIED_LOWERING_H_
7
8#include "src/compiler/js-graph.h"
9#include "src/compiler/machine-operator.h"
10#include "src/compiler/node.h"
11#include "src/compiler/simplified-operator.h"
12
13namespace v8 {
14namespace internal {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000015
16// Forward declarations.
17class TypeCache;
18
19
Ben Murdochb8a8cc12014-11-26 15:28:44 +000020namespace compiler {
21
Emily Bernierd0a1eb72015-03-24 16:35:39 -040022// Forward declarations.
23class RepresentationChanger;
Ben Murdochc5610432016-08-08 18:44:38 +010024class RepresentationSelector;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000025class SourcePositionTable;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040026
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000027class SimplifiedLowering final {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000028 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000029 SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
30 SourcePositionTable* source_positions);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040031 ~SimplifiedLowering() {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000032
33 void LowerAllNodes();
34
Ben Murdochc5610432016-08-08 18:44:38 +010035 void DoJSToNumberTruncatesToFloat64(Node* node,
36 RepresentationSelector* selector);
37 void DoJSToNumberTruncatesToWord32(Node* node,
38 RepresentationSelector* selector);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000039 // TODO(turbofan): The representation can be removed once the result of the
Emily Bernierd0a1eb72015-03-24 16:35:39 -040040 // representation analysis is stored in the node bounds.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000041 void DoLoadBuffer(Node* node, MachineRepresentation rep,
Emily Bernierd0a1eb72015-03-24 16:35:39 -040042 RepresentationChanger* changer);
43 void DoStoreBuffer(Node* node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000044 void DoShift(Node* node, Operator const* op, Type* rhs_type);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000045
46 private:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040047 JSGraph* const jsgraph_;
48 Zone* const zone_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000049 TypeCache const& type_cache_;
Ben Murdochc5610432016-08-08 18:44:38 +010050 SetOncePointer<Node> to_number_code_;
51 SetOncePointer<Operator const> to_number_operator_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000052
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000053 // TODO(danno): SimplifiedLowering shouldn't know anything about the source
54 // positions table, but must for now since there currently is no other way to
55 // pass down source position information to nodes created during
56 // lowering. Once this phase becomes a vanilla reducer, it should get source
57 // position information via the SourcePositionWrapper like all other reducers.
58 SourcePositionTable* source_positions_;
59
Ben Murdochda12d292016-06-02 14:46:10 +010060 Node* Float64Ceil(Node* const node);
61 Node* Float64Floor(Node* const node);
62 Node* Float64Round(Node* const node);
63 Node* Float64Trunc(Node* const node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040064 Node* Int32Div(Node* const node);
65 Node* Int32Mod(Node* const node);
66 Node* Uint32Div(Node* const node);
67 Node* Uint32Mod(Node* const node);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000068
Ben Murdochc5610432016-08-08 18:44:38 +010069 Node* ToNumberCode();
70 Operator const* ToNumberOperator();
71
Ben Murdochb8a8cc12014-11-26 15:28:44 +000072 friend class RepresentationSelector;
73
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000074 Isolate* isolate() { return jsgraph_->isolate(); }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000075 Zone* zone() { return jsgraph_->zone(); }
76 JSGraph* jsgraph() { return jsgraph_; }
77 Graph* graph() { return jsgraph()->graph(); }
78 CommonOperatorBuilder* common() { return jsgraph()->common(); }
79 MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
Ben Murdochc5610432016-08-08 18:44:38 +010080 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000081};
82
83} // namespace compiler
84} // namespace internal
85} // namespace v8
86
87#endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_