Chromium Code Reviews| 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 <map> |
| 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 | |
| 26 class InstructionSelector FINAL { | 24 class InstructionSelector FINAL { |
| 27 public: | 25 public: |
| 28 static const int kNodeUnmapped = -1; | |
| 29 | |
| 30 // Forward declarations. | 26 // Forward declarations. |
| 31 class Features; | 27 class Features; |
| 32 | 28 |
| 33 // TODO(dcarney): pass in vreg mapping instead of graph. | 29 InstructionSelector(Zone* zone, size_t node_count, Linkage* linkage, |
| 34 InstructionSelector(Zone* local_zone, Graph* graph, Linkage* linkage, | |
| 35 InstructionSequence* sequence, Schedule* schedule, | 30 InstructionSequence* sequence, Schedule* schedule, |
| 36 SourcePositionTable* source_positions, | 31 SourcePositionTable* source_positions, |
| 37 Features features = SupportedFeatures()); | 32 Features features = SupportedFeatures()); |
| 38 | 33 |
| 39 // Visit code for the entire graph with the included schedule. | 34 // Visit code for the entire graph with the included schedule. |
| 40 void SelectInstructions(); | 35 void SelectInstructions(); |
| 41 | 36 |
| 42 // =========================================================================== | 37 // =========================================================================== |
| 43 // ============= Architecture-independent code emission methods. ============= | 38 // ============= Architecture-independent code emission methods. ============= |
| 44 // =========================================================================== | 39 // =========================================================================== |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 bool IsDefined(Node* node) const; | 114 bool IsDefined(Node* node) const; |
| 120 | 115 |
| 121 // Checks if {node} has any uses, and therefore code has to be generated for | 116 // Checks if {node} has any uses, and therefore code has to be generated for |
| 122 // it. | 117 // it. |
| 123 bool IsUsed(Node* node) const; | 118 bool IsUsed(Node* node) const; |
| 124 | 119 |
| 125 // Checks if {node} is currently live. | 120 // Checks if {node} is currently live. |
| 126 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } | 121 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } |
| 127 | 122 |
| 128 int GetVirtualRegister(const Node* node); | 123 int GetVirtualRegister(const Node* node); |
| 129 // Gets the current mapping if it exists, kNodeUnmapped otherwise. | 124 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; |
| 130 int GetMappedVirtualRegister(const Node* node) const; | |
| 131 const NodeToVregMap& GetNodeMapForTesting() const { return node_map_; } | |
| 132 | 125 |
| 133 private: | 126 private: |
| 134 friend class OperandGenerator; | 127 friend class OperandGenerator; |
| 135 | 128 |
| 136 // Inform the instruction selection that {node} was just defined. | 129 // Inform the instruction selection that {node} was just defined. |
| 137 void MarkAsDefined(Node* node); | 130 void MarkAsDefined(Node* node); |
| 138 | 131 |
| 139 // Inform the instruction selection that {node} has at least one use and we | 132 // Inform the instruction selection that {node} has at least one use and we |
| 140 // will need to generate code for it. | 133 // will need to generate code for it. |
| 141 void MarkAsUsed(Node* node); | 134 void MarkAsUsed(Node* node); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 // =========================================================================== | 202 // =========================================================================== |
| 210 | 203 |
| 211 Schedule* schedule() const { return schedule_; } | 204 Schedule* schedule() const { return schedule_; } |
| 212 Linkage* linkage() const { return linkage_; } | 205 Linkage* linkage() const { return linkage_; } |
| 213 InstructionSequence* sequence() const { return sequence_; } | 206 InstructionSequence* sequence() const { return sequence_; } |
| 214 Zone* instruction_zone() const { return sequence()->zone(); } | 207 Zone* instruction_zone() const { return sequence()->zone(); } |
| 215 Zone* zone() const { return zone_; } | 208 Zone* zone() const { return zone_; } |
| 216 | 209 |
| 217 // =========================================================================== | 210 // =========================================================================== |
| 218 | 211 |
| 212 enum { kNoVirtualRegister = -1 }; | |
|
dcarney
2015/01/08 12:54:09
this should be UnallocatedOperand::kInvalidVirtual
Benedikt Meurer
2015/01/08 13:23:06
Done.
| |
| 213 | |
| 219 Zone* const zone_; | 214 Zone* const zone_; |
| 220 Linkage* const linkage_; | 215 Linkage* const linkage_; |
| 221 InstructionSequence* const sequence_; | 216 InstructionSequence* const sequence_; |
| 222 SourcePositionTable* const source_positions_; | 217 SourcePositionTable* const source_positions_; |
| 223 Features features_; | 218 Features features_; |
| 224 Schedule* const schedule_; | 219 Schedule* const schedule_; |
| 225 NodeToVregMap node_map_; | |
| 226 BasicBlock* current_block_; | 220 BasicBlock* current_block_; |
| 227 ZoneDeque<Instruction*> instructions_; | 221 ZoneVector<Instruction*> instructions_; |
| 228 BoolVector defined_; | 222 BoolVector defined_; |
| 229 BoolVector used_; | 223 BoolVector used_; |
| 224 IntVector virtual_registers_; | |
| 230 }; | 225 }; |
| 231 | 226 |
| 232 } // namespace compiler | 227 } // namespace compiler |
| 233 } // namespace internal | 228 } // namespace internal |
| 234 } // namespace v8 | 229 } // namespace v8 |
| 235 | 230 |
| 236 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 231 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
| OLD | NEW |