blob: 054c4219948bb640fc4bc43adb89f655046c4987 [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001// 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
Ben Murdochda12d292016-06-02 14:46:10 +01005#ifndef V8_COMPILER_INT64_LOWERING_H_
6#define V8_COMPILER_INT64_LOWERING_H_
Ben Murdoch097c5b22016-05-18 11:27:45 +01007
8#include "src/compiler/common-operator.h"
9#include "src/compiler/graph.h"
10#include "src/compiler/machine-operator.h"
11#include "src/compiler/node-marker.h"
12#include "src/zone-containers.h"
13
14namespace v8 {
15namespace internal {
16namespace compiler {
17
18class Int64Lowering {
19 public:
20 Int64Lowering(Graph* graph, MachineOperatorBuilder* machine,
21 CommonOperatorBuilder* common, Zone* zone,
22 Signature<MachineRepresentation>* signature);
23
24 void LowerGraph();
25
Ben Murdochc5610432016-08-08 18:44:38 +010026 static int GetParameterCountAfterLowering(
27 Signature<MachineRepresentation>* signature);
28
Ben Murdoch097c5b22016-05-18 11:27:45 +010029 private:
Ben Murdochda12d292016-06-02 14:46:10 +010030 enum class State : uint8_t { kUnvisited, kOnStack, kVisited };
Ben Murdoch097c5b22016-05-18 11:27:45 +010031
32 struct Replacement {
33 Node* low;
34 Node* high;
35 };
36
37 Zone* zone() const { return zone_; }
38 Graph* graph() const { return graph_; }
39 MachineOperatorBuilder* machine() const { return machine_; }
40 CommonOperatorBuilder* common() const { return common_; }
41 Signature<MachineRepresentation>* signature() const { return signature_; }
42
Ben Murdochda12d292016-06-02 14:46:10 +010043 void PrepareReplacements(Node* node);
44 void PushNode(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010045 void LowerNode(Node* node);
46 bool DefaultLowering(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010047 void LowerComparison(Node* node, const Operator* signed_op,
48 const Operator* unsigned_op);
49 void PrepareProjectionReplacements(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010050
51 void ReplaceNode(Node* old, Node* new_low, Node* new_high);
52 bool HasReplacementLow(Node* node);
53 Node* GetReplacementLow(Node* node);
54 bool HasReplacementHigh(Node* node);
55 Node* GetReplacementHigh(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010056 void PreparePhiReplacement(Node* phi);
57
58 struct NodeState {
59 Node* node;
60 int input_index;
61 };
Ben Murdoch097c5b22016-05-18 11:27:45 +010062
63 Zone* zone_;
64 Graph* const graph_;
65 MachineOperatorBuilder* machine_;
66 CommonOperatorBuilder* common_;
67 NodeMarker<State> state_;
Ben Murdochda12d292016-06-02 14:46:10 +010068 ZoneDeque<NodeState> stack_;
Ben Murdoch097c5b22016-05-18 11:27:45 +010069 Replacement* replacements_;
70 Signature<MachineRepresentation>* signature_;
Ben Murdochda12d292016-06-02 14:46:10 +010071 Node* placeholder_;
Ben Murdoch097c5b22016-05-18 11:27:45 +010072};
73
74} // namespace compiler
75} // namespace internal
76} // namespace v8
77
Ben Murdochda12d292016-06-02 14:46:10 +010078#endif // V8_COMPILER_INT64_LOWERING_H_