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