simplified-lowering.h 3.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_SIMPLIFIED_LOWERING_H_
#define V8_COMPILER_SIMPLIFIED_LOWERING_H_

#include "src/compiler/js-graph.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node.h"
#include "src/compiler/simplified-operator.h"

namespace v8 {
namespace internal {
namespace compiler {

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 33
  void LowerAllNodes();

34 35
  void DoMax(Node* node, Operator const* op, MachineRepresentation rep);
  void DoMin(Node* node, Operator const* op, MachineRepresentation rep);
36 37 38 39
  void DoJSToNumberOrNumericTruncatesToFloat64(
      Node* node, RepresentationSelector* selector);
  void DoJSToNumberOrNumericTruncatesToWord32(Node* node,
                                              RepresentationSelector* selector);
40 41 42
  void DoIntegral32ToBit(Node* node);
  void DoOrderedNumberToBit(Node* node);
  void DoNumberToBit(Node* node);
43 44 45 46
  void DoIntegerToUint8Clamped(Node* node);
  void DoNumberToUint8Clamped(Node* node);
  void DoSigned32ToUint8Clamped(Node* node);
  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 61 62 63 64 65
  // TODO(danno): SimplifiedLowering shouldn't know anything about the source
  // positions table, but must for now since there currently is no other way to
  // pass down source position information to nodes created during
  // lowering. Once this phase becomes a vanilla reducer, it should get source
  // position information via the SourcePositionWrapper like all other reducers.
  SourcePositionTable* source_positions_;
66
  NodeOriginTable* node_origins_;
67

68 69
  PoisoningMitigationLevel poisoning_level_;

70
  Node* Float64Round(Node* const node);
71
  Node* Float64Sign(Node* const node);
72
  Node* Int32Abs(Node* const node);
73 74
  Node* Int32Div(Node* const node);
  Node* Int32Mod(Node* const node);
75
  Node* Int32Sign(Node* const node);
76 77
  Node* Uint32Div(Node* const node);
  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 87
  friend class RepresentationSelector;

88
  Isolate* isolate() { return jsgraph_->isolate(); }
89 90 91 92
  Zone* zone() { return jsgraph_->zone(); }
  JSGraph* jsgraph() { return jsgraph_; }
  Graph* graph() { return jsgraph()->graph(); }
  CommonOperatorBuilder* common() { return jsgraph()->common(); }
93
  MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
94
  SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); }
95 96 97 98 99 100 101
};

}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_SIMPLIFIED_LOWERING_H_