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 <map> | 8 #include <map> |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 MachineType type_; | 41 MachineType type_; |
42 }; | 42 }; |
43 | 43 |
44 // Instruction selection generates an InstructionSequence for a given Schedule. | 44 // Instruction selection generates an InstructionSequence for a given Schedule. |
45 class InstructionSelector final { | 45 class InstructionSelector final { |
46 public: | 46 public: |
47 // Forward declarations. | 47 // Forward declarations. |
48 class Features; | 48 class Features; |
49 | 49 |
50 enum SourcePositionMode { kCallSourcePositions, kAllSourcePositions }; | 50 enum SourcePositionMode { kCallSourcePositions, kAllSourcePositions }; |
| 51 enum EnableScheduling { kDisableScheduling, kEnableScheduling }; |
51 | 52 |
52 InstructionSelector( | 53 InstructionSelector( |
53 Zone* zone, size_t node_count, Linkage* linkage, | 54 Zone* zone, size_t node_count, Linkage* linkage, |
54 InstructionSequence* sequence, Schedule* schedule, | 55 InstructionSequence* sequence, Schedule* schedule, |
55 SourcePositionTable* source_positions, Frame* frame, | 56 SourcePositionTable* source_positions, Frame* frame, |
56 SourcePositionMode source_position_mode = kCallSourcePositions, | 57 SourcePositionMode source_position_mode = kCallSourcePositions, |
57 Features features = SupportedFeatures()); | 58 Features features = SupportedFeatures(), |
| 59 EnableScheduling enable_scheduling = FLAG_turbo_instruction_scheduling |
| 60 ? kEnableScheduling |
| 61 : kDisableScheduling); |
58 | 62 |
59 // Visit code for the entire graph with the included schedule. | 63 // Visit code for the entire graph with the included schedule. |
60 void SelectInstructions(); | 64 void SelectInstructions(); |
61 | 65 |
62 void StartBlock(RpoNumber rpo); | 66 void StartBlock(RpoNumber rpo); |
63 void EndBlock(RpoNumber rpo); | 67 void EndBlock(RpoNumber rpo); |
64 void AddInstruction(Instruction* instr); | 68 void AddInstruction(Instruction* instr); |
65 | 69 |
66 // =========================================================================== | 70 // =========================================================================== |
67 // ============= Architecture-independent code emission methods. ============= | 71 // ============= Architecture-independent code emission methods. ============= |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 int GetEffectLevel(Node* node) const; | 196 int GetEffectLevel(Node* node) const; |
193 | 197 |
194 int GetVirtualRegister(const Node* node); | 198 int GetVirtualRegister(const Node* node); |
195 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; | 199 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; |
196 | 200 |
197 Isolate* isolate() const { return sequence()->isolate(); } | 201 Isolate* isolate() const { return sequence()->isolate(); } |
198 | 202 |
199 private: | 203 private: |
200 friend class OperandGenerator; | 204 friend class OperandGenerator; |
201 | 205 |
| 206 bool UseInstructionScheduling() const { |
| 207 return (enable_scheduling_ == kEnableScheduling) && |
| 208 InstructionScheduler::SchedulerSupported(); |
| 209 } |
| 210 |
202 void EmitTableSwitch(const SwitchInfo& sw, InstructionOperand& index_operand); | 211 void EmitTableSwitch(const SwitchInfo& sw, InstructionOperand& index_operand); |
203 void EmitLookupSwitch(const SwitchInfo& sw, | 212 void EmitLookupSwitch(const SwitchInfo& sw, |
204 InstructionOperand& value_operand); | 213 InstructionOperand& value_operand); |
205 | 214 |
206 // Inform the instruction selection that {node} was just defined. | 215 // Inform the instruction selection that {node} was just defined. |
207 void MarkAsDefined(Node* node); | 216 void MarkAsDefined(Node* node); |
208 | 217 |
209 // Inform the instruction selection that {node} has at least one use and we | 218 // Inform the instruction selection that {node} has at least one use and we |
210 // will need to generate code for it. | 219 // will need to generate code for it. |
211 void MarkAsUsed(Node* node); | 220 void MarkAsUsed(Node* node); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 SourcePositionMode const source_position_mode_; | 335 SourcePositionMode const source_position_mode_; |
327 Features features_; | 336 Features features_; |
328 Schedule* const schedule_; | 337 Schedule* const schedule_; |
329 BasicBlock* current_block_; | 338 BasicBlock* current_block_; |
330 ZoneVector<Instruction*> instructions_; | 339 ZoneVector<Instruction*> instructions_; |
331 BoolVector defined_; | 340 BoolVector defined_; |
332 BoolVector used_; | 341 BoolVector used_; |
333 IntVector effect_level_; | 342 IntVector effect_level_; |
334 IntVector virtual_registers_; | 343 IntVector virtual_registers_; |
335 InstructionScheduler* scheduler_; | 344 InstructionScheduler* scheduler_; |
| 345 EnableScheduling enable_scheduling_; |
336 Frame* frame_; | 346 Frame* frame_; |
337 }; | 347 }; |
338 | 348 |
339 } // namespace compiler | 349 } // namespace compiler |
340 } // namespace internal | 350 } // namespace internal |
341 } // namespace v8 | 351 } // namespace v8 |
342 | 352 |
343 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 353 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
OLD | NEW |