simplified-lowering.h 2.73 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 24 25
  SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
                     SourcePositionTable* source_positions)
      : jsgraph_(jsgraph), zone_(zone), source_positions_(source_positions) {}
26
  ~SimplifiedLowering() {}
27

28 29
  void LowerAllNodes();

30
  // TODO(titzer): These are exposed for direct testing. Use a friend class.
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 DoStringAdd(Node* node);
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

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

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

67 68
  friend class RepresentationSelector;

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

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

#endif  // V8_COMPILER_SIMPLIFIED_LOWERING_H_