OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_INT64_LOWERING_H_ | 5 #ifndef V8_COMPILER_SIMD_SCALAR_LOWERING_H_ |
6 #define V8_COMPILER_INT64_LOWERING_H_ | 6 #define V8_COMPILER_SIMD_SCALAR_LOWERING_H_ |
7 | 7 |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
11 #include "src/compiler/node-marker.h" | 11 #include "src/compiler/node-marker.h" |
12 #include "src/globals.h" | |
13 #include "src/zone/zone-containers.h" | 12 #include "src/zone/zone-containers.h" |
14 | 13 |
15 namespace v8 { | 14 namespace v8 { |
16 namespace internal { | 15 namespace internal { |
17 namespace compiler { | 16 namespace compiler { |
18 | 17 |
19 class V8_EXPORT_PRIVATE Int64Lowering { | 18 class SimdScalarLowering { |
20 public: | 19 public: |
21 Int64Lowering(Graph* graph, MachineOperatorBuilder* machine, | 20 SimdScalarLowering(Graph* graph, MachineOperatorBuilder* machine, |
22 CommonOperatorBuilder* common, Zone* zone, | 21 CommonOperatorBuilder* common, Zone* zone, |
23 Signature<MachineRepresentation>* signature); | 22 Signature<MachineRepresentation>* signature); |
24 | 23 |
25 void LowerGraph(); | 24 void LowerGraph(); |
26 | 25 |
27 static int GetParameterCountAfterLowering( | 26 int GetParameterCountAfterLowering(); |
28 Signature<MachineRepresentation>* signature); | |
29 | |
30 static const int kLowerWordOffset; | |
31 static const int kHigherWordOffset; | |
32 | 27 |
33 private: | 28 private: |
34 enum class State : uint8_t { kUnvisited, kOnStack, kVisited }; | 29 enum class State : uint8_t { kUnvisited, kOnStack, kVisited }; |
35 | 30 |
| 31 enum class SimdType : uint8_t { kInt32, kFloat32 }; |
| 32 |
| 33 static const size_t kMaxLanes = 4; |
| 34 |
36 struct Replacement { | 35 struct Replacement { |
37 Node* low; | 36 Node* node[kMaxLanes]; |
38 Node* high; | 37 SimdType type; // represents what input type is expected |
39 }; | 38 }; |
40 | 39 |
41 Zone* zone() const { return zone_; } | 40 Zone* zone() const { return zone_; } |
42 Graph* graph() const { return graph_; } | 41 Graph* graph() const { return graph_; } |
43 MachineOperatorBuilder* machine() const { return machine_; } | 42 MachineOperatorBuilder* machine() const { return machine_; } |
44 CommonOperatorBuilder* common() const { return common_; } | 43 CommonOperatorBuilder* common() const { return common_; } |
45 Signature<MachineRepresentation>* signature() const { return signature_; } | 44 Signature<MachineRepresentation>* signature() const { return signature_; } |
46 | 45 |
47 void PrepareReplacements(Node* node); | |
48 void PushNode(Node* node); | |
49 void LowerNode(Node* node); | 46 void LowerNode(Node* node); |
50 bool DefaultLowering(Node* node); | 47 bool DefaultLowering(Node* node); |
51 void LowerComparison(Node* node, const Operator* signed_op, | |
52 const Operator* unsigned_op); | |
53 void PrepareProjectionReplacements(Node* node); | |
54 | 48 |
55 void ReplaceNode(Node* old, Node* new_low, Node* new_high); | 49 void ReplaceNode(Node* old, Node** new_nodes); |
56 bool HasReplacementLow(Node* node); | 50 bool HasReplacement(size_t index, Node* node); |
57 Node* GetReplacementLow(Node* node); | 51 Node** GetReplacements(Node* node); |
58 bool HasReplacementHigh(Node* node); | 52 Node** GetReplacementsWithType(Node* node, SimdType type); |
59 Node* GetReplacementHigh(Node* node); | 53 SimdType ReplacementType(Node* node); |
60 void PreparePhiReplacement(Node* phi); | 54 void PreparePhiReplacement(Node* phi); |
61 void GetIndexNodes(Node* index, Node*& index_low, Node*& index_high); | 55 void SetLoweredType(Node* node, Node* output); |
62 | 56 |
63 struct NodeState { | 57 struct NodeState { |
64 Node* node; | 58 Node* node; |
65 int input_index; | 59 int input_index; |
66 }; | 60 }; |
67 | 61 |
68 Zone* zone_; | 62 Zone* zone_; |
69 Graph* const graph_; | 63 Graph* const graph_; |
70 MachineOperatorBuilder* machine_; | 64 MachineOperatorBuilder* machine_; |
71 CommonOperatorBuilder* common_; | 65 CommonOperatorBuilder* common_; |
72 NodeMarker<State> state_; | 66 NodeMarker<State> state_; |
73 ZoneDeque<NodeState> stack_; | 67 ZoneDeque<NodeState> stack_; |
74 Replacement* replacements_; | 68 Replacement* replacements_; |
75 Signature<MachineRepresentation>* signature_; | 69 Signature<MachineRepresentation>* signature_; |
76 Node* placeholder_; | 70 Node* placeholder_; |
| 71 int parameter_count_after_lowering_; |
77 }; | 72 }; |
78 | 73 |
79 } // namespace compiler | 74 } // namespace compiler |
80 } // namespace internal | 75 } // namespace internal |
81 } // namespace v8 | 76 } // namespace v8 |
82 | 77 |
83 #endif // V8_COMPILER_INT64_LOWERING_H_ | 78 #endif // V8_COMPILER_SIMD_SCALAR_LOWERING_H_ |
OLD | NEW |