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/globals.h" 13 #include "src/zone/zone-containers.h" 14 15 namespace v8 { 16 namespace internal { 17 18 template <typename T> 19 class Signature; 20 21 namespace compiler { 22 23 class V8_EXPORT_PRIVATE Int64Lowering { 24 public: 25 Int64Lowering(Graph* graph, MachineOperatorBuilder* machine, 26 CommonOperatorBuilder* common, Zone* zone, 27 Signature<MachineRepresentation>* signature); 28 29 void LowerGraph(); 30 31 static int GetParameterCountAfterLowering( 32 Signature<MachineRepresentation>* signature); 33 34 private: 35 enum class State : uint8_t { kUnvisited, kOnStack, kVisited }; 36 37 struct Replacement { 38 Node* low; 39 Node* high; 40 }; 41 zone()42 Zone* zone() const { return zone_; } graph()43 Graph* graph() const { return graph_; } machine()44 MachineOperatorBuilder* machine() const { return machine_; } common()45 CommonOperatorBuilder* common() const { return common_; } signature()46 Signature<MachineRepresentation>* signature() const { return signature_; } 47 48 void PushNode(Node* node); 49 void LowerNode(Node* node); 50 bool DefaultLowering(Node* node, bool low_word_only = false); 51 void LowerComparison(Node* node, const Operator* signed_op, 52 const Operator* unsigned_op); 53 void LowerWord64AtomicBinop(Node* node, const Operator* op); 54 void LowerWord64AtomicNarrowOp(Node* node, const Operator* op); 55 56 void ReplaceNode(Node* old, Node* new_low, Node* new_high); 57 bool HasReplacementLow(Node* node); 58 Node* GetReplacementLow(Node* node); 59 bool HasReplacementHigh(Node* node); 60 Node* GetReplacementHigh(Node* node); 61 void PreparePhiReplacement(Node* phi); 62 void GetIndexNodes(Node* index, Node*& index_low, Node*& index_high); 63 void ReplaceNodeWithProjections(Node* node); 64 65 struct NodeState { 66 Node* node; 67 int input_index; 68 }; 69 70 Zone* zone_; 71 Graph* const graph_; 72 MachineOperatorBuilder* machine_; 73 CommonOperatorBuilder* common_; 74 NodeMarker<State> state_; 75 ZoneDeque<NodeState> stack_; 76 Replacement* replacements_; 77 Signature<MachineRepresentation>* signature_; 78 Node* placeholder_; 79 }; 80 81 } // namespace compiler 82 } // namespace internal 83 } // namespace v8 84 85 #endif // V8_COMPILER_INT64_LOWERING_H_ 86