blob: 7f6ef9a297c1b3f21e6563ddbf10170c61d89572 [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
26 private:
Ben Murdochda12d292016-06-02 14:46:10 +010027 enum class State : uint8_t { kUnvisited, kOnStack, kVisited };
Ben Murdoch097c5b22016-05-18 11:27:45 +010028
29 struct Replacement {
30 Node* low;
31 Node* high;
32 };
33
34 Zone* zone() const { return zone_; }
35 Graph* graph() const { return graph_; }
36 MachineOperatorBuilder* machine() const { return machine_; }
37 CommonOperatorBuilder* common() const { return common_; }
38 Signature<MachineRepresentation>* signature() const { return signature_; }
39
Ben Murdochda12d292016-06-02 14:46:10 +010040 void PrepareReplacements(Node* node);
41 void PushNode(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010042 void LowerNode(Node* node);
43 bool DefaultLowering(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010044 void LowerComparison(Node* node, const Operator* signed_op,
45 const Operator* unsigned_op);
46 void PrepareProjectionReplacements(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010047
48 void ReplaceNode(Node* old, Node* new_low, Node* new_high);
49 bool HasReplacementLow(Node* node);
50 Node* GetReplacementLow(Node* node);
51 bool HasReplacementHigh(Node* node);
52 Node* GetReplacementHigh(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010053 void PreparePhiReplacement(Node* phi);
54
55 struct NodeState {
56 Node* node;
57 int input_index;
58 };
Ben Murdoch097c5b22016-05-18 11:27:45 +010059
60 Zone* zone_;
61 Graph* const graph_;
62 MachineOperatorBuilder* machine_;
63 CommonOperatorBuilder* common_;
64 NodeMarker<State> state_;
Ben Murdochda12d292016-06-02 14:46:10 +010065 ZoneDeque<NodeState> stack_;
Ben Murdoch097c5b22016-05-18 11:27:45 +010066 Replacement* replacements_;
67 Signature<MachineRepresentation>* signature_;
Ben Murdochda12d292016-06-02 14:46:10 +010068 Node* placeholder_;
Ben Murdoch097c5b22016-05-18 11:27:45 +010069};
70
71} // namespace compiler
72} // namespace internal
73} // namespace v8
74
Ben Murdochda12d292016-06-02 14:46:10 +010075#endif // V8_COMPILER_INT64_LOWERING_H_