int64-lowering.h 2.58 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

#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-marker.h"
12
#include "src/globals.h"
13
#include "src/zone/zone-containers.h"
14 15 16 17 18

namespace v8 {
namespace internal {
namespace compiler {

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

25
  void LowerGraph();
26

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

30 31 32 33
  // Determine whether the given type is i64 and has to be passed via two
  // parameters on the given machine.
  static bool IsI64AsTwoParameters(MachineOperatorBuilder* machine,
                                   MachineRepresentation type);
34

35
 private:
36
  enum class State : uint8_t { kUnvisited, kOnStack, kVisited };
37 38 39 40 41 42

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

43 44 45 46 47 48
  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_; }

49 50
  void PrepareReplacements(Node* node);
  void PushNode(Node* node);
51
  void LowerNode(Node* node);
52
  bool DefaultLowering(Node* node, bool low_word_only = false);
53 54
  void LowerComparison(Node* node, const Operator* signed_op,
                       const Operator* unsigned_op);
55
  void PrepareProjectionReplacements(Node* node);
56 57 58 59 60 61

  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);
62
  void PreparePhiReplacement(Node* phi);
63
  void GetIndexNodes(Node* index, Node*& index_low, Node*& index_high);
64

65 66 67 68 69
  struct NodeState {
    Node* node;
    int input_index;
  };

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

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

85
#endif  // V8_COMPILER_INT64_LOWERING_H_