• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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);
~SimplifiedLowering()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   // TODO(turbofan): The representation can be removed once the result of the
38   // representation analysis is stored in the node bounds.
39   void DoLoadBuffer(Node* node, MachineRepresentation rep,
40                     RepresentationChanger* changer);
41   void DoStoreBuffer(Node* node);
42   void DoShift(Node* node, Operator const* op, Type* rhs_type);
43   void DoStringToNumber(Node* node);
44   void DoIntegral32ToBit(Node* node);
45   void DoOrderedNumberToBit(Node* node);
46   void DoNumberToBit(Node* node);
47   void DoIntegerToUint8Clamped(Node* node);
48   void DoNumberToUint8Clamped(Node* node);
49   void DoSigned32ToUint8Clamped(Node* node);
50   void DoUnsigned32ToUint8Clamped(Node* node);
51 
52  private:
53   JSGraph* const jsgraph_;
54   Zone* const zone_;
55   TypeCache const& type_cache_;
56   SetOncePointer<Node> to_number_code_;
57   SetOncePointer<Operator const> to_number_operator_;
58 
59   // TODO(danno): SimplifiedLowering shouldn't know anything about the source
60   // positions table, but must for now since there currently is no other way to
61   // pass down source position information to nodes created during
62   // lowering. Once this phase becomes a vanilla reducer, it should get source
63   // position information via the SourcePositionWrapper like all other reducers.
64   SourcePositionTable* source_positions_;
65 
66   Node* Float64Round(Node* const node);
67   Node* Float64Sign(Node* const node);
68   Node* Int32Abs(Node* const node);
69   Node* Int32Div(Node* const node);
70   Node* Int32Mod(Node* const node);
71   Node* Int32Sign(Node* const node);
72   Node* Uint32Div(Node* const node);
73   Node* Uint32Mod(Node* const node);
74 
75   Node* ToNumberCode();
76   Operator const* ToNumberOperator();
77 
78   friend class RepresentationSelector;
79 
isolate()80   Isolate* isolate() { return jsgraph_->isolate(); }
zone()81   Zone* zone() { return jsgraph_->zone(); }
jsgraph()82   JSGraph* jsgraph() { return jsgraph_; }
graph()83   Graph* graph() { return jsgraph()->graph(); }
common()84   CommonOperatorBuilder* common() { return jsgraph()->common(); }
machine()85   MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
simplified()86   SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); }
87 };
88 
89 }  // namespace compiler
90 }  // namespace internal
91 }  // namespace v8
92 
93 #endif  // V8_COMPILER_SIMPLIFIED_LOWERING_H_
94