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_REGISTER_ALLOCATOR_H_ | 5 #ifndef V8_REGISTER_ALLOCATOR_H_ |
6 #define V8_REGISTER_ALLOCATOR_H_ | 6 #define V8_REGISTER_ALLOCATOR_H_ |
7 | 7 |
8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
10 | 10 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 }; | 208 }; |
209 | 209 |
210 class SpillRange; | 210 class SpillRange; |
211 | 211 |
212 | 212 |
213 // TODO(dcarney): remove this cache. | 213 // TODO(dcarney): remove this cache. |
214 class InstructionOperandCache FINAL : public ZoneObject { | 214 class InstructionOperandCache FINAL : public ZoneObject { |
215 public: | 215 public: |
216 InstructionOperandCache(); | 216 InstructionOperandCache(); |
217 | 217 |
218 InstructionOperand* RegisterOperand(int index) { | 218 RegisterOperand* GetRegisterOperand(int index) { |
219 DCHECK(index >= 0 && | 219 DCHECK(index >= 0 && |
220 index < static_cast<int>(arraysize(general_register_operands_))); | 220 index < static_cast<int>(arraysize(general_register_operands_))); |
221 return &general_register_operands_[index]; | 221 return RegisterOperand::cast(&general_register_operands_[index]); |
222 } | 222 } |
223 InstructionOperand* DoubleRegisterOperand(int index) { | 223 DoubleRegisterOperand* GetDoubleRegisterOperand(int index) { |
224 DCHECK(index >= 0 && | 224 DCHECK(index >= 0 && |
225 index < static_cast<int>(arraysize(double_register_operands_))); | 225 index < static_cast<int>(arraysize(double_register_operands_))); |
226 return &double_register_operands_[index]; | 226 return DoubleRegisterOperand::cast(&double_register_operands_[index]); |
227 } | 227 } |
228 | 228 |
229 private: | 229 private: |
230 InstructionOperand | 230 InstructionOperand |
231 general_register_operands_[RegisterConfiguration::kMaxGeneralRegisters]; | 231 general_register_operands_[RegisterConfiguration::kMaxGeneralRegisters]; |
232 InstructionOperand | 232 InstructionOperand |
233 double_register_operands_[RegisterConfiguration::kMaxDoubleRegisters]; | 233 double_register_operands_[RegisterConfiguration::kMaxDoubleRegisters]; |
234 | 234 |
235 DISALLOW_COPY_AND_ASSIGN(InstructionOperandCache); | 235 DISALLOW_COPY_AND_ASSIGN(InstructionOperandCache); |
236 }; | 236 }; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 bool HasNoSpillType() const { return spill_type_ == SpillType::kNoSpillType; } | 338 bool HasNoSpillType() const { return spill_type_ == SpillType::kNoSpillType; } |
339 bool HasSpillOperand() const { | 339 bool HasSpillOperand() const { |
340 return spill_type_ == SpillType::kSpillOperand; | 340 return spill_type_ == SpillType::kSpillOperand; |
341 } | 341 } |
342 bool HasSpillRange() const { return spill_type_ == SpillType::kSpillRange; } | 342 bool HasSpillRange() const { return spill_type_ == SpillType::kSpillRange; } |
343 | 343 |
344 void SpillAtDefinition(Zone* zone, int gap_index, | 344 void SpillAtDefinition(Zone* zone, int gap_index, |
345 InstructionOperand* operand); | 345 InstructionOperand* operand); |
346 void SetSpillOperand(InstructionOperand* operand); | 346 void SetSpillOperand(InstructionOperand* operand); |
347 void SetSpillRange(SpillRange* spill_range); | 347 void SetSpillRange(SpillRange* spill_range); |
348 void CommitSpillOperand(InstructionOperand* operand); | 348 void CommitSpillOperand(AllocatedOperand* operand); |
349 void CommitSpillsAtDefinition(InstructionSequence* sequence, | 349 void CommitSpillsAtDefinition(InstructionSequence* sequence, |
350 InstructionOperand* operand, | 350 InstructionOperand* operand, |
351 bool might_be_duplicated); | 351 bool might_be_duplicated); |
352 | 352 |
353 void SetSpillStartIndex(int start) { | 353 void SetSpillStartIndex(int start) { |
354 spill_start_index_ = Min(start, spill_start_index_); | 354 spill_start_index_ = Min(start, spill_start_index_); |
355 } | 355 } |
356 | 356 |
357 bool ShouldBeAllocatedBefore(const LiveRange* other) const; | 357 bool ShouldBeAllocatedBefore(const LiveRange* other) const; |
358 bool CanCover(LifetimePosition position) const; | 358 bool CanCover(LifetimePosition position) const; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 416 |
417 | 417 |
418 class SpillRange FINAL : public ZoneObject { | 418 class SpillRange FINAL : public ZoneObject { |
419 public: | 419 public: |
420 SpillRange(LiveRange* range, Zone* zone); | 420 SpillRange(LiveRange* range, Zone* zone); |
421 | 421 |
422 UseInterval* interval() const { return use_interval_; } | 422 UseInterval* interval() const { return use_interval_; } |
423 RegisterKind Kind() const { return live_ranges_[0]->Kind(); } | 423 RegisterKind Kind() const { return live_ranges_[0]->Kind(); } |
424 bool IsEmpty() const { return live_ranges_.empty(); } | 424 bool IsEmpty() const { return live_ranges_.empty(); } |
425 bool TryMerge(SpillRange* other); | 425 bool TryMerge(SpillRange* other); |
426 void SetOperand(InstructionOperand* op); | 426 void SetOperand(AllocatedOperand* op); |
427 | 427 |
428 private: | 428 private: |
429 LifetimePosition End() const { return end_position_; } | 429 LifetimePosition End() const { return end_position_; } |
430 ZoneVector<LiveRange*>& live_ranges() { return live_ranges_; } | 430 ZoneVector<LiveRange*>& live_ranges() { return live_ranges_; } |
431 bool IsIntersectingWith(SpillRange* other) const; | 431 bool IsIntersectingWith(SpillRange* other) const; |
432 // Merge intervals, making sure the use intervals are sorted | 432 // Merge intervals, making sure the use intervals are sorted |
433 void MergeDisjointIntervals(UseInterval* other); | 433 void MergeDisjointIntervals(UseInterval* other); |
434 | 434 |
435 ZoneVector<LiveRange*> live_ranges_; | 435 ZoneVector<LiveRange*> live_ranges_; |
436 UseInterval* use_interval_; | 436 UseInterval* use_interval_; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 #endif | 685 #endif |
686 | 686 |
687 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); | 687 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); |
688 }; | 688 }; |
689 | 689 |
690 } // namespace compiler | 690 } // namespace compiler |
691 } // namespace internal | 691 } // namespace internal |
692 } // namespace v8 | 692 } // namespace v8 |
693 | 693 |
694 #endif // V8_REGISTER_ALLOCATOR_H_ | 694 #endif // V8_REGISTER_ALLOCATOR_H_ |
OLD | NEW |