blob: 8b711a96599fd4a0bccaa302b04e3111ab7f8aad [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 Murdoch4a90d5f2016-03-22 12:00:34 +000024class SourcePositionTable;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040025
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000026class SimplifiedLowering final {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000027 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000028 SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
29 SourcePositionTable* source_positions);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040030 ~SimplifiedLowering() {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000031
32 void LowerAllNodes();
33
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000034 // TODO(turbofan): The representation can be removed once the result of the
Emily Bernierd0a1eb72015-03-24 16:35:39 -040035 // representation analysis is stored in the node bounds.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000036 void DoLoadBuffer(Node* node, MachineRepresentation rep,
Emily Bernierd0a1eb72015-03-24 16:35:39 -040037 RepresentationChanger* changer);
38 void DoStoreBuffer(Node* node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000039 void DoShift(Node* node, Operator const* op, Type* rhs_type);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000040
Ben Murdoch097c5b22016-05-18 11:27:45 +010041 // TODO(bmeurer): This is a gigantic hack to support the gigantic LoadBuffer
42 // typing hack to support the gigantic "asm.js should be fast without proper
43 // verifier"-hack, ... Kill this! Soon! Really soon! I'm serious!
44 bool abort_compilation_ = false;
45
Ben Murdochb8a8cc12014-11-26 15:28:44 +000046 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 Murdochb8a8cc12014-11-26 15:28:44 +000050
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000051 // TODO(danno): SimplifiedLowering shouldn't know anything about the source
52 // positions table, but must for now since there currently is no other way to
53 // pass down source position information to nodes created during
54 // lowering. Once this phase becomes a vanilla reducer, it should get source
55 // position information via the SourcePositionWrapper like all other reducers.
56 SourcePositionTable* source_positions_;
57
Ben Murdochda12d292016-06-02 14:46:10 +010058 Node* Float64Ceil(Node* const node);
59 Node* Float64Floor(Node* const node);
60 Node* Float64Round(Node* const node);
61 Node* Float64Trunc(Node* const node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040062 Node* Int32Div(Node* const node);
63 Node* Int32Mod(Node* const node);
64 Node* Uint32Div(Node* const node);
65 Node* Uint32Mod(Node* const node);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000066
67 friend class RepresentationSelector;
68
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000069 Isolate* isolate() { return jsgraph_->isolate(); }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000070 Zone* zone() { return jsgraph_->zone(); }
71 JSGraph* jsgraph() { return jsgraph_; }
72 Graph* graph() { return jsgraph()->graph(); }
73 CommonOperatorBuilder* common() { return jsgraph()->common(); }
74 MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
75};
76
77} // namespace compiler
78} // namespace internal
79} // namespace v8
80
81#endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_