blob: 4ec4e821eb978f9a0dc2e8908c19745b49639962 [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 Murdoch61f157c2016-09-16 13:49:30 +010029 static const int kLowerWordOffset;
30 static const int kHigherWordOffset;
31
Ben Murdoch097c5b22016-05-18 11:27:45 +010032 private:
Ben Murdochda12d292016-06-02 14:46:10 +010033 enum class State : uint8_t { kUnvisited, kOnStack, kVisited };
Ben Murdoch097c5b22016-05-18 11:27:45 +010034
35 struct Replacement {
36 Node* low;
37 Node* high;
38 };
39
40 Zone* zone() const { return zone_; }
41 Graph* graph() const { return graph_; }
42 MachineOperatorBuilder* machine() const { return machine_; }
43 CommonOperatorBuilder* common() const { return common_; }
44 Signature<MachineRepresentation>* signature() const { return signature_; }
45
Ben Murdochda12d292016-06-02 14:46:10 +010046 void PrepareReplacements(Node* node);
47 void PushNode(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010048 void LowerNode(Node* node);
49 bool DefaultLowering(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010050 void LowerComparison(Node* node, const Operator* signed_op,
51 const Operator* unsigned_op);
52 void PrepareProjectionReplacements(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010053
54 void ReplaceNode(Node* old, Node* new_low, Node* new_high);
55 bool HasReplacementLow(Node* node);
56 Node* GetReplacementLow(Node* node);
57 bool HasReplacementHigh(Node* node);
58 Node* GetReplacementHigh(Node* node);
Ben Murdochda12d292016-06-02 14:46:10 +010059 void PreparePhiReplacement(Node* phi);
Ben Murdoch61f157c2016-09-16 13:49:30 +010060 void GetIndexNodes(Node* index, Node*& index_low, Node*& index_high);
Ben Murdochda12d292016-06-02 14:46:10 +010061
62 struct NodeState {
63 Node* node;
64 int input_index;
65 };
Ben Murdoch097c5b22016-05-18 11:27:45 +010066
67 Zone* zone_;
68 Graph* const graph_;
69 MachineOperatorBuilder* machine_;
70 CommonOperatorBuilder* common_;
71 NodeMarker<State> state_;
Ben Murdochda12d292016-06-02 14:46:10 +010072 ZoneDeque<NodeState> stack_;
Ben Murdoch097c5b22016-05-18 11:27:45 +010073 Replacement* replacements_;
74 Signature<MachineRepresentation>* signature_;
Ben Murdochda12d292016-06-02 14:46:10 +010075 Node* placeholder_;
Ben Murdoch097c5b22016-05-18 11:27:45 +010076};
77
78} // namespace compiler
79} // namespace internal
80} // namespace v8
81
Ben Murdochda12d292016-06-02 14:46:10 +010082#endif // V8_COMPILER_INT64_LOWERING_H_