Line data Source code
1 : // 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_INT64_LOWERING_H_
6 : #define V8_COMPILER_INT64_LOWERING_H_
7 :
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/globals.h"
13 : #include "src/zone/zone-containers.h"
14 :
15 : namespace v8 {
16 : namespace internal {
17 :
18 : template <typename T>
19 : class Signature;
20 :
21 : namespace compiler {
22 :
23 47 : class V8_EXPORT_PRIVATE Int64Lowering {
24 : public:
25 : Int64Lowering(Graph* graph, MachineOperatorBuilder* machine,
26 : CommonOperatorBuilder* common, Zone* zone,
27 : Signature<MachineRepresentation>* signature);
28 :
29 : void LowerGraph();
30 :
31 : static int GetParameterCountAfterLowering(
32 : Signature<MachineRepresentation>* signature);
33 :
34 : private:
35 : enum class State : uint8_t { kUnvisited, kOnStack, kVisited };
36 :
37 : struct Replacement {
38 : Node* low;
39 : Node* high;
40 : };
41 :
42 : Zone* zone() const { return zone_; }
43 : Graph* graph() const { return graph_; }
44 : MachineOperatorBuilder* machine() const { return machine_; }
45 : CommonOperatorBuilder* common() const { return common_; }
46 : Signature<MachineRepresentation>* signature() const { return signature_; }
47 :
48 : void PushNode(Node* node);
49 : void LowerNode(Node* node);
50 : bool DefaultLowering(Node* node, bool low_word_only = false);
51 : void LowerComparison(Node* node, const Operator* signed_op,
52 : const Operator* unsigned_op);
53 : void LowerWord64AtomicBinop(Node* node, const Operator* op);
54 : void LowerWord64AtomicNarrowOp(Node* node, const Operator* op);
55 :
56 : void ReplaceNode(Node* old, Node* new_low, Node* new_high);
57 : bool HasReplacementLow(Node* node);
58 : Node* GetReplacementLow(Node* node);
59 : bool HasReplacementHigh(Node* node);
60 : Node* GetReplacementHigh(Node* node);
61 : void PreparePhiReplacement(Node* phi);
62 : void GetIndexNodes(Node* index, Node*& index_low, Node*& index_high);
63 : void ReplaceNodeWithProjections(Node* node);
64 : void LowerMemoryBaseAndIndex(Node* node);
65 :
66 : struct NodeState {
67 : Node* node;
68 : int input_index;
69 : };
70 :
71 : Zone* zone_;
72 : Graph* const graph_;
73 : MachineOperatorBuilder* machine_;
74 : CommonOperatorBuilder* common_;
75 : NodeMarker<State> state_;
76 : ZoneDeque<NodeState> stack_;
77 : Replacement* replacements_;
78 : Signature<MachineRepresentation>* signature_;
79 : Node* placeholder_;
80 : };
81 :
82 : } // namespace compiler
83 : } // namespace internal
84 : } // namespace v8
85 :
86 : #endif // V8_COMPILER_INT64_LOWERING_H_
|