simplified-lowering.h 3.4 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, Zone* zone,
27
                     SourcePositionTable* source_position,
28
                     NodeOriginTable* node_origins,
29
                     PoisoningMitigationLevel poisoning_level);
30
  ~SimplifiedLowering() {}
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
  void DoShift(Node* node, Operator const* op, Type rhs_type);
41 42 43
  void DoIntegral32ToBit(Node* node);
  void DoOrderedNumberToBit(Node* node);
  void DoNumberToBit(Node* node);
44 45 46 47
  void DoIntegerToUint8Clamped(Node* node);
  void DoNumberToUint8Clamped(Node* node);
  void DoSigned32ToUint8Clamped(Node* node);
  void DoUnsigned32ToUint8Clamped(Node* node);
48

49
 private:
50 51
  JSGraph* const jsgraph_;
  Zone* const zone_;
52
  TypeCache const& type_cache_;
53
  SetOncePointer<Node> to_number_code_;
54
  SetOncePointer<Node> to_numeric_code_;
55
  SetOncePointer<Operator const> to_number_operator_;
56
  SetOncePointer<Operator const> to_numeric_operator_;
57

58 59 60 61 62 63
  // 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_;
64
  NodeOriginTable* node_origins_;
65

66 67
  PoisoningMitigationLevel poisoning_level_;

68
  Node* Float64Round(Node* const node);
69
  Node* Float64Sign(Node* const node);
70
  Node* Int32Abs(Node* const node);
71 72
  Node* Int32Div(Node* const node);
  Node* Int32Mod(Node* const node);
73
  Node* Int32Sign(Node* const node);
74 75
  Node* Uint32Div(Node* const node);
  Node* Uint32Mod(Node* const node);
76

77
  Node* ToNumberCode();
78
  Node* ToNumericCode();
79
  Operator const* ToNumberOperator();
80
  Operator const* ToNumericOperator();
81

82 83
  friend class RepresentationSelector;

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

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

#endif  // V8_COMPILER_SIMPLIFIED_LOWERING_H_