simplified-lowering.h 3.05 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 18
// Forward declarations.
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 30
  void LowerAllNodes();

31 32
  void DoMax(Node* node, Operator const* op, MachineRepresentation rep);
  void DoMin(Node* node, Operator const* op, MachineRepresentation rep);
33 34 35 36
  void DoJSToNumberTruncatesToFloat64(Node* node,
                                      RepresentationSelector* selector);
  void DoJSToNumberTruncatesToWord32(Node* node,
                                     RepresentationSelector* selector);
37
  void DoShift(Node* node, Operator const* op, Type* rhs_type);
38
  void DoStringToNumber(Node* node);
39 40 41
  void DoIntegral32ToBit(Node* node);
  void DoOrderedNumberToBit(Node* node);
  void DoNumberToBit(Node* node);
42 43 44 45
  void DoIntegerToUint8Clamped(Node* node);
  void DoNumberToUint8Clamped(Node* node);
  void DoSigned32ToUint8Clamped(Node* node);
  void DoUnsigned32ToUint8Clamped(Node* node);
46

47
 private:
48 49
  JSGraph* const jsgraph_;
  Zone* const zone_;
50
  TypeCache const& type_cache_;
51 52
  SetOncePointer<Node> to_number_code_;
  SetOncePointer<Operator const> to_number_operator_;
53

54 55 56 57 58 59 60
  // 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_;

61
  Node* Float64Round(Node* const node);
62
  Node* Float64Sign(Node* const node);
63
  Node* Int32Abs(Node* const node);
64 65
  Node* Int32Div(Node* const node);
  Node* Int32Mod(Node* const node);
66
  Node* Int32Sign(Node* const node);
67 68
  Node* Uint32Div(Node* const node);
  Node* Uint32Mod(Node* const node);
69

70 71 72
  Node* ToNumberCode();
  Operator const* ToNumberOperator();

73 74
  friend class RepresentationSelector;

75
  Isolate* isolate() { return jsgraph_->isolate(); }
76 77 78 79
  Zone* zone() { return jsgraph_->zone(); }
  JSGraph* jsgraph() { return jsgraph_; }
  Graph* graph() { return jsgraph()->graph(); }
  CommonOperatorBuilder* common() { return jsgraph()->common(); }
80
  MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
81
  SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); }
82 83 84 85 86 87 88
};

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

#endif  // V8_COMPILER_SIMPLIFIED_LOWERING_H_