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 | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 29 | private: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 30 | enum class State : uint8_t { kUnvisited, kOnStack, kVisited }; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 31 | |
| 32 | struct Replacement { |
| 33 | Node* low; |
| 34 | Node* high; |
| 35 | }; |
| 36 | |
| 37 | Zone* zone() const { return zone_; } |
| 38 | Graph* graph() const { return graph_; } |
| 39 | MachineOperatorBuilder* machine() const { return machine_; } |
| 40 | CommonOperatorBuilder* common() const { return common_; } |
| 41 | Signature<MachineRepresentation>* signature() const { return signature_; } |
| 42 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 43 | void PrepareReplacements(Node* node); |
| 44 | void PushNode(Node* node); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 45 | void LowerNode(Node* node); |
| 46 | bool DefaultLowering(Node* node); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 47 | void LowerComparison(Node* node, const Operator* signed_op, |
| 48 | const Operator* unsigned_op); |
| 49 | void PrepareProjectionReplacements(Node* node); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 50 | |
| 51 | void ReplaceNode(Node* old, Node* new_low, Node* new_high); |
| 52 | bool HasReplacementLow(Node* node); |
| 53 | Node* GetReplacementLow(Node* node); |
| 54 | bool HasReplacementHigh(Node* node); |
| 55 | Node* GetReplacementHigh(Node* node); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 56 | void PreparePhiReplacement(Node* phi); |
| 57 | |
| 58 | struct NodeState { |
| 59 | Node* node; |
| 60 | int input_index; |
| 61 | }; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 62 | |
| 63 | Zone* zone_; |
| 64 | Graph* const graph_; |
| 65 | MachineOperatorBuilder* machine_; |
| 66 | CommonOperatorBuilder* common_; |
| 67 | NodeMarker<State> state_; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 68 | ZoneDeque<NodeState> stack_; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 69 | Replacement* replacements_; |
| 70 | Signature<MachineRepresentation>* signature_; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 71 | Node* placeholder_; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | } // namespace compiler |
| 75 | } // namespace internal |
| 76 | } // namespace v8 |
| 77 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 78 | #endif // V8_COMPILER_INT64_LOWERING_H_ |