Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 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 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 5 | #ifndef V8_COMPILER_INT64_LOWERING_H_ |
| 6 | #define V8_COMPILER_INT64_LOWERING_H_ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 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 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 26 | static int GetParameterCountAfterLowering( |
| 27 | Signature<MachineRepresentation>* signature); |
| 28 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 29 | static const int kLowerWordOffset; |
| 30 | static const int kHigherWordOffset; |
| 31 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 32 | private: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 33 | enum class State : uint8_t { kUnvisited, kOnStack, kVisited }; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 34 | |
| 35 | struct Replacement { |
| 36 | Node* low; |
| 37 | Node* high; |
| 38 | }; |
| 39 | |
| 40 | Zone* zone() const { return zone_; } |
| 41 | Graph* graph() const { return graph_; } |
| 42 | MachineOperatorBuilder* machine() const { return machine_; } |
| 43 | CommonOperatorBuilder* common() const { return common_; } |
| 44 | Signature<MachineRepresentation>* signature() const { return signature_; } |
| 45 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 46 | void PrepareReplacements(Node* node); |
| 47 | void PushNode(Node* node); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 48 | void LowerNode(Node* node); |
| 49 | bool DefaultLowering(Node* node); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 50 | void LowerComparison(Node* node, const Operator* signed_op, |
| 51 | const Operator* unsigned_op); |
| 52 | void PrepareProjectionReplacements(Node* node); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 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); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 59 | void PreparePhiReplacement(Node* phi); |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 60 | void GetIndexNodes(Node* index, Node*& index_low, Node*& index_high); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 61 | |
| 62 | struct NodeState { |
| 63 | Node* node; |
| 64 | int input_index; |
| 65 | }; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 66 | |
| 67 | Zone* zone_; |
| 68 | Graph* const graph_; |
| 69 | MachineOperatorBuilder* machine_; |
| 70 | CommonOperatorBuilder* common_; |
| 71 | NodeMarker<State> state_; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 72 | ZoneDeque<NodeState> stack_; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 73 | Replacement* replacements_; |
| 74 | Signature<MachineRepresentation>* signature_; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 75 | Node* placeholder_; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace compiler |
| 79 | } // namespace internal |
| 80 | } // namespace v8 |
| 81 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 82 | #endif // V8_COMPILER_INT64_LOWERING_H_ |