1 // Copyright 2011 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.
5 #ifndef V8_LITHIUM_ALLOCATOR_INL_H_
6 #define V8_LITHIUM_ALLOCATOR_INL_H_
8 #include "lithium-allocator.h"
10 #if V8_TARGET_ARCH_IA32
11 #include "ia32/lithium-ia32.h"
12 #elif V8_TARGET_ARCH_X64
13 #include "x64/lithium-x64.h"
14 #elif V8_TARGET_ARCH_ARM64
15 #include "arm64/lithium-arm64.h"
16 #elif V8_TARGET_ARCH_ARM
17 #include "arm/lithium-arm.h"
18 #elif V8_TARGET_ARCH_MIPS
19 #include "mips/lithium-mips.h"
21 #error "Unknown architecture."
27 bool LAllocator::IsGapAt(int index) { return chunk_->IsGapAt(index); }
30 LInstruction* LAllocator::InstructionAt(int index) {
31 return chunk_->instructions()->at(index);
35 LGap* LAllocator::GapAt(int index) {
36 return chunk_->GetGapAt(index);
40 TempIterator::TempIterator(LInstruction* instr)
42 limit_(instr->TempCount()),
48 bool TempIterator::Done() { return current_ >= limit_; }
51 LOperand* TempIterator::Current() {
53 return instr_->TempAt(current_);
57 void TempIterator::SkipUninteresting() {
58 while (current_ < limit_ && instr_->TempAt(current_) == NULL) ++current_;
62 void TempIterator::Advance() {
68 InputIterator::InputIterator(LInstruction* instr)
70 limit_(instr->InputCount()),
76 bool InputIterator::Done() { return current_ >= limit_; }
79 LOperand* InputIterator::Current() {
81 ASSERT(instr_->InputAt(current_) != NULL);
82 return instr_->InputAt(current_);
86 void InputIterator::Advance() {
92 void InputIterator::SkipUninteresting() {
93 while (current_ < limit_) {
94 LOperand* current = instr_->InputAt(current_);
95 if (current != NULL && !current->IsConstantOperand()) break;
101 UseIterator::UseIterator(LInstruction* instr)
102 : input_iterator_(instr), env_iterator_(instr->environment()) { }
105 bool UseIterator::Done() {
106 return input_iterator_.Done() && env_iterator_.Done();
110 LOperand* UseIterator::Current() {
112 LOperand* result = input_iterator_.Done()
113 ? env_iterator_.Current()
114 : input_iterator_.Current();
115 ASSERT(result != NULL);
120 void UseIterator::Advance() {
121 input_iterator_.Done()
122 ? env_iterator_.Advance()
123 : input_iterator_.Advance();
127 void LAllocator::SetLiveRangeAssignedRegister(LiveRange* range, int reg) {
128 if (range->Kind() == DOUBLE_REGISTERS ||
129 IsSIMD128RegisterKind(range->Kind())) {
130 assigned_double_registers_->Add(reg);
132 ASSERT(range->Kind() == GENERAL_REGISTERS);
133 assigned_registers_->Add(reg);
135 range->set_assigned_register(reg, chunk()->zone());
139 } } // namespace v8::internal
141 #endif // V8_LITHIUM_ALLOCATOR_INL_H_