int64-lowering.h 2.34 KB
Newer Older
1 2 3 4
// 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.

5 6
#ifndef V8_COMPILER_INT64_LOWERING_H_
#define V8_COMPILER_INT64_LOWERING_H_
7 8 9 10 11 12 13 14 15 16 17 18 19 20

#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-marker.h"
#include "src/zone-containers.h"

namespace v8 {
namespace internal {
namespace compiler {

class Int64Lowering {
 public:
  Int64Lowering(Graph* graph, MachineOperatorBuilder* machine,
21 22
                CommonOperatorBuilder* common, Zone* zone,
                Signature<MachineRepresentation>* signature);
23

24
  void LowerGraph();
25

26 27 28
  static int GetParameterCountAfterLowering(
      Signature<MachineRepresentation>* signature);

29 30 31
  static const int kLowerWordOffset;
  static const int kHigherWordOffset;

32
 private:
33
  enum class State : uint8_t { kUnvisited, kOnStack, kVisited };
34 35 36 37 38 39

  struct Replacement {
    Node* low;
    Node* high;
  };

40 41 42 43 44 45
  Zone* zone() const { return zone_; }
  Graph* graph() const { return graph_; }
  MachineOperatorBuilder* machine() const { return machine_; }
  CommonOperatorBuilder* common() const { return common_; }
  Signature<MachineRepresentation>* signature() const { return signature_; }

46 47
  void PrepareReplacements(Node* node);
  void PushNode(Node* node);
48 49
  void LowerNode(Node* node);
  bool DefaultLowering(Node* node);
50 51
  void LowerComparison(Node* node, const Operator* signed_op,
                       const Operator* unsigned_op);
52
  void PrepareProjectionReplacements(Node* node);
53 54 55 56 57 58

  void ReplaceNode(Node* old, Node* new_low, Node* new_high);
  bool HasReplacementLow(Node* node);
  Node* GetReplacementLow(Node* node);
  bool HasReplacementHigh(Node* node);
  Node* GetReplacementHigh(Node* node);
59
  void PreparePhiReplacement(Node* phi);
60
  void GetIndexNodes(Node* index, Node*& index_low, Node*& index_high);
61

62 63 64 65 66
  struct NodeState {
    Node* node;
    int input_index;
  };

67
  Zone* zone_;
68 69 70 71
  Graph* const graph_;
  MachineOperatorBuilder* machine_;
  CommonOperatorBuilder* common_;
  NodeMarker<State> state_;
72
  ZoneDeque<NodeState> stack_;
73
  Replacement* replacements_;
74
  Signature<MachineRepresentation>* signature_;
75
  Node* placeholder_;
76 77 78 79 80 81
};

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

82
#endif  // V8_COMPILER_INT64_LOWERING_H_