blob: b21cf21ffdfe4cc94ea3050867bb8ad1dd4f3370 [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 {
15namespace compiler {
16
Emily Bernierd0a1eb72015-03-24 16:35:39 -040017// Forward declarations.
18class RepresentationChanger;
19
20
21class SimplifiedLowering FINAL {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000022 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040023 SimplifiedLowering(JSGraph* jsgraph, Zone* zone)
24 : jsgraph_(jsgraph), zone_(zone) {}
25 ~SimplifiedLowering() {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000026
27 void LowerAllNodes();
28
29 // TODO(titzer): These are exposed for direct testing. Use a friend class.
30 void DoLoadField(Node* node);
31 void DoStoreField(Node* node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040032 // TODO(turbofan): The output_type can be removed once the result of the
33 // representation analysis is stored in the node bounds.
34 void DoLoadBuffer(Node* node, MachineType output_type,
35 RepresentationChanger* changer);
36 void DoStoreBuffer(Node* node);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000037 void DoLoadElement(Node* node);
38 void DoStoreElement(Node* node);
39 void DoStringAdd(Node* node);
40 void DoStringEqual(Node* node);
41 void DoStringLessThan(Node* node);
42 void DoStringLessThanOrEqual(Node* node);
43
44 private:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040045 JSGraph* const jsgraph_;
46 Zone* const zone_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000047
48 Node* SmiTag(Node* node);
49 Node* IsTagged(Node* node);
50 Node* Untag(Node* node);
51 Node* OffsetMinusTagConstant(int32_t offset);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040052 Node* ComputeIndex(const ElementAccess& access, Node* const key);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000053 Node* StringComparison(Node* node, bool requires_ordering);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040054 Node* Int32Div(Node* const node);
55 Node* Int32Mod(Node* const node);
56 Node* Uint32Div(Node* const node);
57 Node* Uint32Mod(Node* const node);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000058
59 friend class RepresentationSelector;
60
61 Zone* zone() { return jsgraph_->zone(); }
62 JSGraph* jsgraph() { return jsgraph_; }
63 Graph* graph() { return jsgraph()->graph(); }
64 CommonOperatorBuilder* common() { return jsgraph()->common(); }
65 MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
66};
67
68} // namespace compiler
69} // namespace internal
70} // namespace v8
71
72#endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_