OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
6 #define V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
11 #include "src/compiler/instruction.h" | 11 #include "src/compiler/instruction.h" |
12 #include "src/compiler/machine-operator.h" | 12 #include "src/compiler/machine-operator.h" |
13 #include "src/zone-containers.h" | 13 #include "src/zone-containers.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 namespace compiler { | 17 namespace compiler { |
18 | 18 |
19 // Forward declarations. | 19 // Forward declarations. |
20 struct CallBuffer; // TODO(bmeurer): Remove this. | 20 struct CallBuffer; // TODO(bmeurer): Remove this. |
21 class FlagsContinuation; | 21 class FlagsContinuation; |
22 class Linkage; | 22 class Linkage; |
23 | 23 |
| 24 typedef IntVector NodeToVregMap; |
| 25 |
24 class InstructionSelector FINAL { | 26 class InstructionSelector FINAL { |
25 public: | 27 public: |
| 28 static const int kNodeUnmapped = -1; |
| 29 |
26 // Forward declarations. | 30 // Forward declarations. |
27 class Features; | 31 class Features; |
28 | 32 |
29 InstructionSelector(Zone* local_zone, Linkage* linkage, | 33 // TODO(dcarney): pass in vreg mapping instead of graph. |
| 34 InstructionSelector(Zone* local_zone, Graph* graph, Linkage* linkage, |
30 InstructionSequence* sequence, Schedule* schedule, | 35 InstructionSequence* sequence, Schedule* schedule, |
31 SourcePositionTable* source_positions, | 36 SourcePositionTable* source_positions, |
32 Features features = SupportedFeatures()); | 37 Features features = SupportedFeatures()); |
33 | 38 |
34 // Visit code for the entire graph with the included schedule. | 39 // Visit code for the entire graph with the included schedule. |
35 void SelectInstructions(); | 40 void SelectInstructions(); |
36 | 41 |
37 // =========================================================================== | 42 // =========================================================================== |
38 // ============= Architecture-independent code emission methods. ============= | 43 // ============= Architecture-independent code emission methods. ============= |
39 // =========================================================================== | 44 // =========================================================================== |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // generated for it. | 108 // generated for it. |
104 bool IsDefined(Node* node) const; | 109 bool IsDefined(Node* node) const; |
105 | 110 |
106 // Checks if {node} has any uses, and therefore code has to be generated for | 111 // Checks if {node} has any uses, and therefore code has to be generated for |
107 // it. | 112 // it. |
108 bool IsUsed(Node* node) const; | 113 bool IsUsed(Node* node) const; |
109 | 114 |
110 // Checks if {node} is currently live. | 115 // Checks if {node} is currently live. |
111 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } | 116 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } |
112 | 117 |
| 118 int GetVirtualRegister(const Node* node); |
| 119 // Gets the current mapping if it exists, kNodeUnmapped otherwise. |
| 120 int GetMappedVirtualRegister(const Node* node) const; |
| 121 const NodeToVregMap& GetNodeMapForTesting() const { return node_map_; } |
| 122 |
113 private: | 123 private: |
114 friend class OperandGenerator; | 124 friend class OperandGenerator; |
115 | 125 |
116 // Checks if {block} will appear directly after {current_block_} when | 126 // Checks if {block} will appear directly after {current_block_} when |
117 // assembling code, in which case, a fall-through can be used. | 127 // assembling code, in which case, a fall-through can be used. |
118 bool IsNextInAssemblyOrder(const BasicBlock* block) const; | 128 bool IsNextInAssemblyOrder(const BasicBlock* block) const; |
119 | 129 |
120 // Inform the instruction selection that {node} was just defined. | 130 // Inform the instruction selection that {node} was just defined. |
121 void MarkAsDefined(Node* node); | 131 void MarkAsDefined(Node* node); |
122 | 132 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 Zone* zone() const { return zone_; } | 209 Zone* zone() const { return zone_; } |
200 | 210 |
201 // =========================================================================== | 211 // =========================================================================== |
202 | 212 |
203 Zone* const zone_; | 213 Zone* const zone_; |
204 Linkage* const linkage_; | 214 Linkage* const linkage_; |
205 InstructionSequence* const sequence_; | 215 InstructionSequence* const sequence_; |
206 SourcePositionTable* const source_positions_; | 216 SourcePositionTable* const source_positions_; |
207 Features features_; | 217 Features features_; |
208 Schedule* const schedule_; | 218 Schedule* const schedule_; |
| 219 NodeToVregMap node_map_; |
209 BasicBlock* current_block_; | 220 BasicBlock* current_block_; |
210 ZoneDeque<Instruction*> instructions_; | 221 ZoneDeque<Instruction*> instructions_; |
211 BoolVector defined_; | 222 BoolVector defined_; |
212 BoolVector used_; | 223 BoolVector used_; |
213 }; | 224 }; |
214 | 225 |
215 } // namespace compiler | 226 } // namespace compiler |
216 } // namespace internal | 227 } // namespace internal |
217 } // namespace v8 | 228 } // namespace v8 |
218 | 229 |
219 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 230 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
OLD | NEW |