OLD | NEW |
1 // Copyright 2016 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_SIMD_SCALAR_LOWERING_H_ | 5 #ifndef V8_COMPILER_SIMD_SCALAR_LOWERING_H_ |
6 #define V8_COMPILER_SIMD_SCALAR_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/js-graph.h" |
10 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
11 #include "src/compiler/node-marker.h" | 12 #include "src/compiler/node-marker.h" |
12 #include "src/zone/zone-containers.h" | 13 #include "src/zone/zone-containers.h" |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace internal { | 16 namespace internal { |
16 namespace compiler { | 17 namespace compiler { |
17 | 18 |
18 class SimdScalarLowering { | 19 class SimdScalarLowering { |
19 public: | 20 public: |
20 SimdScalarLowering(Graph* graph, MachineOperatorBuilder* machine, | 21 SimdScalarLowering(JSGraph* jsgraph, |
21 CommonOperatorBuilder* common, Zone* zone, | |
22 Signature<MachineRepresentation>* signature); | 22 Signature<MachineRepresentation>* signature); |
23 | 23 |
24 void LowerGraph(); | 24 void LowerGraph(); |
25 | 25 |
26 int GetParameterCountAfterLowering(); | 26 int GetParameterCountAfterLowering(); |
27 | 27 |
28 private: | 28 private: |
29 enum class State : uint8_t { kUnvisited, kOnStack, kVisited }; | 29 enum class State : uint8_t { kUnvisited, kOnStack, kVisited }; |
30 | 30 |
31 enum class SimdType : uint8_t { kInt32, kFloat32 }; | 31 enum class SimdType : uint8_t { kInt32, kFloat32 }; |
32 | 32 |
33 static const int kMaxLanes = 4; | 33 static const int kMaxLanes = 4; |
34 static const int kLaneWidth = 16 / kMaxLanes; | 34 static const int kLaneWidth = 16 / kMaxLanes; |
35 | 35 |
36 struct Replacement { | 36 struct Replacement { |
37 Node* node[kMaxLanes]; | 37 Node* node[kMaxLanes]; |
38 SimdType type; // represents what input type is expected | 38 SimdType type; // represents what input type is expected |
39 }; | 39 }; |
40 | 40 |
41 Zone* zone() const { return zone_; } | 41 struct NodeState { |
42 Graph* graph() const { return graph_; } | 42 Node* node; |
43 MachineOperatorBuilder* machine() const { return machine_; } | 43 int input_index; |
44 CommonOperatorBuilder* common() const { return common_; } | 44 }; |
| 45 |
| 46 Zone* zone() const { return jsgraph_->zone(); } |
| 47 Graph* graph() const { return jsgraph_->graph(); } |
| 48 MachineOperatorBuilder* machine() const { return jsgraph_->machine(); } |
| 49 CommonOperatorBuilder* common() const { return jsgraph_->common(); } |
45 Signature<MachineRepresentation>* signature() const { return signature_; } | 50 Signature<MachineRepresentation>* signature() const { return signature_; } |
46 | 51 |
47 void LowerNode(Node* node); | 52 void LowerNode(Node* node); |
48 bool DefaultLowering(Node* node); | 53 bool DefaultLowering(Node* node); |
49 | 54 |
50 void ReplaceNode(Node* old, Node** new_nodes); | 55 void ReplaceNode(Node* old, Node** new_nodes); |
51 bool HasReplacement(size_t index, Node* node); | 56 bool HasReplacement(size_t index, Node* node); |
52 Node** GetReplacements(Node* node); | 57 Node** GetReplacements(Node* node); |
53 Node** GetReplacementsWithType(Node* node, SimdType type); | 58 Node** GetReplacementsWithType(Node* node, SimdType type); |
54 SimdType ReplacementType(Node* node); | 59 SimdType ReplacementType(Node* node); |
55 void PreparePhiReplacement(Node* phi); | 60 void PreparePhiReplacement(Node* phi); |
56 void SetLoweredType(Node* node, Node* output); | 61 void SetLoweredType(Node* node, Node* output); |
57 void GetIndexNodes(Node* index, Node** new_indices); | 62 void GetIndexNodes(Node* index, Node** new_indices); |
58 void LowerLoadOp(MachineRepresentation rep, Node* node, | 63 void LowerLoadOp(MachineRepresentation rep, Node* node, |
59 const Operator* load_op); | 64 const Operator* load_op); |
60 void LowerStoreOp(MachineRepresentation rep, Node* node, | 65 void LowerStoreOp(MachineRepresentation rep, Node* node, |
61 const Operator* store_op, SimdType rep_type); | 66 const Operator* store_op, SimdType rep_type); |
62 void LowerBinaryOp(Node* node, SimdType input_rep_type, const Operator* op); | 67 void LowerBinaryOp(Node* node, SimdType input_rep_type, const Operator* op); |
63 void LowerUnaryOp(Node* node, SimdType input_rep_type, const Operator* op); | 68 void LowerUnaryOp(Node* node, SimdType input_rep_type, const Operator* op); |
| 69 void LowerIntMinMax(Node* node, const Operator* op, bool is_max); |
| 70 void LowerConvertFromFloat(Node* node, bool is_signed); |
| 71 void LowerShiftOp(Node* node, const Operator* op); |
| 72 Node* BuildF64Trunc(Node* input); |
64 | 73 |
65 struct NodeState { | 74 JSGraph* const jsgraph_; |
66 Node* node; | |
67 int input_index; | |
68 }; | |
69 | |
70 Zone* zone_; | |
71 Graph* const graph_; | |
72 MachineOperatorBuilder* machine_; | |
73 CommonOperatorBuilder* common_; | |
74 NodeMarker<State> state_; | 75 NodeMarker<State> state_; |
75 ZoneDeque<NodeState> stack_; | 76 ZoneDeque<NodeState> stack_; |
76 Replacement* replacements_; | 77 Replacement* replacements_; |
77 Signature<MachineRepresentation>* signature_; | 78 Signature<MachineRepresentation>* signature_; |
78 Node* placeholder_; | 79 Node* placeholder_; |
79 int parameter_count_after_lowering_; | 80 int parameter_count_after_lowering_; |
80 }; | 81 }; |
81 | 82 |
82 } // namespace compiler | 83 } // namespace compiler |
83 } // namespace internal | 84 } // namespace internal |
84 } // namespace v8 | 85 } // namespace v8 |
85 | 86 |
86 #endif // V8_COMPILER_SIMD_SCALAR_LOWERING_H_ | 87 #endif // V8_COMPILER_SIMD_SCALAR_LOWERING_H_ |
OLD | NEW |