1 // Copyright 2014 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_INT64_LOWERING_H_ 6 #define V8_COMPILER_INT64_LOWERING_H_ 7 8 #include "src/compiler/common-operator.h" 9 #include "src/compiler/graph.h" 10 #include "src/compiler/machine-operator.h" 11 #include "src/compiler/node-marker.h" 12 #include "src/zone-containers.h" 13 14 namespace v8 { 15 namespace internal { 16 namespace compiler { 17 18 class Int64Lowering { 19 public: 20 Int64Lowering(Graph* graph, MachineOperatorBuilder* machine, 21 CommonOperatorBuilder* common, Zone* zone, 22 Signature<MachineRepresentation>* signature); 23 24 void LowerGraph(); 25 26 static int GetParameterCountAfterLowering( 27 Signature<MachineRepresentation>* signature); 28 29 static const int kLowerWordOffset; 30 static const int kHigherWordOffset; 31 32 private: 33 enum class State : uint8_t { kUnvisited, kOnStack, kVisited }; 34 35 struct Replacement { 36 Node* low; 37 Node* high; 38 }; 39 zone()40 Zone* zone() const { return zone_; } graph()41 Graph* graph() const { return graph_; } machine()42 MachineOperatorBuilder* machine() const { return machine_; } common()43 CommonOperatorBuilder* common() const { return common_; } signature()44 Signature<MachineRepresentation>* signature() const { return signature_; } 45 46 void PrepareReplacements(Node* node); 47 void PushNode(Node* node); 48 void LowerNode(Node* node); 49 bool DefaultLowering(Node* node); 50 void LowerComparison(Node* node, const Operator* signed_op, 51 const Operator* unsigned_op); 52 void PrepareProjectionReplacements(Node* node); 53 54 void ReplaceNode(Node* old, Node* new_low, Node* new_high); 55 bool HasReplacementLow(Node* node); 56 Node* GetReplacementLow(Node* node); 57 bool HasReplacementHigh(Node* node); 58 Node* GetReplacementHigh(Node* node); 59 void PreparePhiReplacement(Node* phi); 60 void GetIndexNodes(Node* index, Node*& index_low, Node*& index_high); 61 62 struct NodeState { 63 Node* node; 64 int input_index; 65 }; 66 67 Zone* zone_; 68 Graph* const graph_; 69 MachineOperatorBuilder* machine_; 70 CommonOperatorBuilder* common_; 71 NodeMarker<State> state_; 72 ZoneDeque<NodeState> stack_; 73 Replacement* replacements_; 74 Signature<MachineRepresentation>* signature_; 75 Node* placeholder_; 76 }; 77 78 } // namespace compiler 79 } // namespace internal 80 } // namespace v8 81 82 #endif // V8_COMPILER_INT64_LOWERING_H_ 83