Line data Source code
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 RepresentationChanger;
19 : class RepresentationSelector;
20 : class SourcePositionTable;
21 : class TypeCache;
22 :
23 : class SimplifiedLowering final {
24 : public:
25 : SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
26 : SourcePositionTable* source_positions);
27 : ~SimplifiedLowering() {}
28 :
29 : void LowerAllNodes();
30 :
31 : void DoMax(Node* node, Operator const* op, MachineRepresentation rep);
32 : void DoMin(Node* node, Operator const* op, MachineRepresentation rep);
33 : void DoJSToNumberTruncatesToFloat64(Node* node,
34 : RepresentationSelector* selector);
35 : void DoJSToNumberTruncatesToWord32(Node* node,
36 : RepresentationSelector* selector);
37 : void DoShift(Node* node, Operator const* op, Type* rhs_type);
38 : void DoIntegral32ToBit(Node* node);
39 : void DoOrderedNumberToBit(Node* node);
40 : void DoNumberToBit(Node* node);
41 : void DoIntegerToUint8Clamped(Node* node);
42 : void DoNumberToUint8Clamped(Node* node);
43 : void DoSigned32ToUint8Clamped(Node* node);
44 : void DoUnsigned32ToUint8Clamped(Node* node);
45 :
46 : private:
47 : JSGraph* const jsgraph_;
48 : Zone* const zone_;
49 : TypeCache const& type_cache_;
50 : SetOncePointer<Node> to_number_code_;
51 : SetOncePointer<Operator const> to_number_operator_;
52 :
53 : // TODO(danno): SimplifiedLowering shouldn't know anything about the source
54 : // positions table, but must for now since there currently is no other way to
55 : // pass down source position information to nodes created during
56 : // lowering. Once this phase becomes a vanilla reducer, it should get source
57 : // position information via the SourcePositionWrapper like all other reducers.
58 : SourcePositionTable* source_positions_;
59 :
60 : Node* Float64Round(Node* const node);
61 : Node* Float64Sign(Node* const node);
62 : Node* Int32Abs(Node* const node);
63 : Node* Int32Div(Node* const node);
64 : Node* Int32Mod(Node* const node);
65 : Node* Int32Sign(Node* const node);
66 : Node* Uint32Div(Node* const node);
67 : Node* Uint32Mod(Node* const node);
68 :
69 : Node* ToNumberCode();
70 : Operator const* ToNumberOperator();
71 :
72 : friend class RepresentationSelector;
73 :
74 4248 : Isolate* isolate() { return jsgraph_->isolate(); }
75 : Zone* zone() { return jsgraph_->zone(); }
76 : JSGraph* jsgraph() { return jsgraph_; }
77 66751 : Graph* graph() { return jsgraph()->graph(); }
78 232921 : CommonOperatorBuilder* common() { return jsgraph()->common(); }
79 223630 : MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
80 7080 : SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); }
81 : };
82 :
83 : } // namespace compiler
84 : } // namespace internal
85 : } // namespace v8
86 :
87 : #endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_
|