simplified-lowering.h 2.74 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 SourcePositionTable;
20

21
class SimplifiedLowering final {
22
 public:
23
  SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
24
                     SourcePositionTable* source_positions);
25
  ~SimplifiedLowering() {}
26

27 28
  void LowerAllNodes();

29
  // TODO(titzer): These are exposed for direct testing. Use a friend class.
30
  void DoAllocate(Node* node);
31 32
  void DoLoadField(Node* node);
  void DoStoreField(Node* node);
33 34
  // TODO(turbofan): The output_type can be removed once the result of the
  // representation analysis is stored in the node bounds.
35 36 37 38
  void DoLoadBuffer(Node* node, MachineType output_type,
                    RepresentationChanger* changer);
  void DoStoreBuffer(Node* node);
  void DoLoadElement(Node* node);
39
  void DoStoreElement(Node* node);
40
  void DoShift(Node* node, Operator const* op);
41
  void DoStringEqual(Node* node);
42 43
  void DoStringLessThan(Node* node);
  void DoStringLessThanOrEqual(Node* node);
44

45
 private:
46 47
  JSGraph* const jsgraph_;
  Zone* const zone_;
48
  Type* const zero_thirtyone_range_;
49

50 51 52 53 54 55 56
  // 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_;

57 58 59 60
  Node* SmiTag(Node* node);
  Node* IsTagged(Node* node);
  Node* Untag(Node* node);
  Node* OffsetMinusTagConstant(int32_t offset);
61
  Node* ComputeIndex(const ElementAccess& access, Node* const key);
62
  Node* StringComparison(Node* node, bool requires_ordering);
63 64 65 66
  Node* Int32Div(Node* const node);
  Node* Int32Mod(Node* const node);
  Node* Uint32Div(Node* const node);
  Node* Uint32Mod(Node* const node);
67

68 69
  friend class RepresentationSelector;

70 71 72 73
  Zone* zone() { return jsgraph_->zone(); }
  JSGraph* jsgraph() { return jsgraph_; }
  Graph* graph() { return jsgraph()->graph(); }
  CommonOperatorBuilder* common() { return jsgraph()->common(); }
74
  MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
75 76 77 78 79 80 81
};

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

#endif  // V8_COMPILER_SIMPLIFIED_LOWERING_H_