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_SIMPLIFIED_LOWERING_H_ |
6 | #define V8_COMPILER_SIMPLIFIED_LOWERING_H_ |
7 | |
8 | #include "src/compiler/js-graph.h" |
9 | #include "src/compiler/machine-operator.h" |
10 | #include "src/compiler/node.h" |
11 | #include "src/compiler/simplified-operator.h" |
12 | |
13 | namespace v8 { |
14 | namespace internal { |
15 | namespace compiler { |
16 | |
17 | // Forward declarations. |
18 | class NodeOriginTable; |
19 | class RepresentationChanger; |
20 | class RepresentationSelector; |
21 | class SourcePositionTable; |
22 | class TypeCache; |
23 | |
24 | class V8_EXPORT_PRIVATE SimplifiedLowering final { |
25 | public: |
26 | SimplifiedLowering(JSGraph* jsgraph, JSHeapBroker* broker, Zone* zone, |
27 | SourcePositionTable* source_position, |
28 | NodeOriginTable* node_origins, |
29 | PoisoningMitigationLevel poisoning_level); |
30 | ~SimplifiedLowering() = default; |
31 | |
32 | void LowerAllNodes(); |
33 | |
34 | void DoMax(Node* node, Operator const* op, MachineRepresentation rep); |
35 | void DoMin(Node* node, Operator const* op, MachineRepresentation rep); |
36 | void DoJSToNumberOrNumericTruncatesToFloat64( |
37 | Node* node, RepresentationSelector* selector); |
38 | void DoJSToNumberOrNumericTruncatesToWord32(Node* node, |
39 | RepresentationSelector* selector); |
40 | void DoIntegral32ToBit(Node* node); |
41 | void DoOrderedNumberToBit(Node* node); |
42 | void DoNumberToBit(Node* node); |
43 | void DoIntegerToUint8Clamped(Node* node); |
44 | void DoNumberToUint8Clamped(Node* node); |
45 | void DoSigned32ToUint8Clamped(Node* node); |
46 | void DoUnsigned32ToUint8Clamped(Node* node); |
47 | |
48 | private: |
49 | JSGraph* const jsgraph_; |
50 | JSHeapBroker* broker_; |
51 | Zone* const zone_; |
52 | TypeCache const* type_cache_; |
53 | SetOncePointer<Node> to_number_code_; |
54 | SetOncePointer<Node> to_number_convert_big_int_code_; |
55 | SetOncePointer<Node> to_numeric_code_; |
56 | SetOncePointer<Operator const> to_number_operator_; |
57 | SetOncePointer<Operator const> to_number_convert_big_int_operator_; |
58 | SetOncePointer<Operator const> to_numeric_operator_; |
59 | |
60 | // TODO(danno): SimplifiedLowering shouldn't know anything about the source |
61 | // positions table, but must for now since there currently is no other way to |
62 | // pass down source position information to nodes created during |
63 | // lowering. Once this phase becomes a vanilla reducer, it should get source |
64 | // position information via the SourcePositionWrapper like all other reducers. |
65 | SourcePositionTable* source_positions_; |
66 | NodeOriginTable* node_origins_; |
67 | |
68 | PoisoningMitigationLevel poisoning_level_; |
69 | |
70 | Node* Float64Round(Node* const node); |
71 | Node* Float64Sign(Node* const node); |
72 | Node* Int32Abs(Node* const node); |
73 | Node* Int32Div(Node* const node); |
74 | Node* Int32Mod(Node* const node); |
75 | Node* Int32Sign(Node* const node); |
76 | Node* Uint32Div(Node* const node); |
77 | Node* Uint32Mod(Node* const node); |
78 | |
79 | Node* ToNumberCode(); |
80 | Node* ToNumberConvertBigIntCode(); |
81 | Node* ToNumericCode(); |
82 | Operator const* ToNumberOperator(); |
83 | Operator const* ToNumberConvertBigIntOperator(); |
84 | Operator const* ToNumericOperator(); |
85 | |
86 | friend class RepresentationSelector; |
87 | |
88 | Isolate* isolate() { return jsgraph_->isolate(); } |
89 | Zone* zone() { return jsgraph_->zone(); } |
90 | JSGraph* jsgraph() { return jsgraph_; } |
91 | Graph* graph() { return jsgraph()->graph(); } |
92 | CommonOperatorBuilder* common() { return jsgraph()->common(); } |
93 | MachineOperatorBuilder* machine() { return jsgraph()->machine(); } |
94 | SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } |
95 | }; |
96 | |
97 | } // namespace compiler |
98 | } // namespace internal |
99 | } // namespace v8 |
100 | |
101 | #endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_ |
102 | |