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