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