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 "src/lithium-allocator.h"
10 #if V8_TARGET_ARCH_IA32
11 #include "src/ia32/lithium-ia32.h"
12 #elif V8_TARGET_ARCH_X64
13 #include "src/x64/lithium-x64.h"
14 #elif V8_TARGET_ARCH_ARM64
15 #include "src/arm64/lithium-arm64.h"
16 #elif V8_TARGET_ARCH_ARM
17 #include "src/arm/lithium-arm.h"
18 #elif V8_TARGET_ARCH_MIPS
19 #include "src/mips/lithium-mips.h"
20 #elif V8_TARGET_ARCH_X87
21 #include "src/x87/lithium-x87.h"
23 #error "Unknown architecture."
29 bool LAllocator::IsGapAt(int index) { return chunk_->IsGapAt(index); }
32 LInstruction* LAllocator::InstructionAt(int index) {
33 return chunk_->instructions()->at(index);
37 LGap* LAllocator::GapAt(int index) {
38 return chunk_->GetGapAt(index);
42 TempIterator::TempIterator(LInstruction* instr)
44 limit_(instr->TempCount()),
50 bool TempIterator::Done() { return current_ >= limit_; }
53 LOperand* TempIterator::Current() {
55 return instr_->TempAt(current_);
59 void TempIterator::SkipUninteresting() {
60 while (current_ < limit_ && instr_->TempAt(current_) == NULL) ++current_;
64 void TempIterator::Advance() {
70 InputIterator::InputIterator(LInstruction* instr)
72 limit_(instr->InputCount()),
78 bool InputIterator::Done() { return current_ >= limit_; }
81 LOperand* InputIterator::Current() {
83 ASSERT(instr_->InputAt(current_) != NULL);
84 return instr_->InputAt(current_);
88 void InputIterator::Advance() {
94 void InputIterator::SkipUninteresting() {
95 while (current_ < limit_) {
96 LOperand* current = instr_->InputAt(current_);
97 if (current != NULL && !current->IsConstantOperand()) break;
103 UseIterator::UseIterator(LInstruction* instr)
104 : input_iterator_(instr), env_iterator_(instr->environment()) { }
107 bool UseIterator::Done() {
108 return input_iterator_.Done() && env_iterator_.Done();
112 LOperand* UseIterator::Current() {
114 LOperand* result = input_iterator_.Done()
115 ? env_iterator_.Current()
116 : input_iterator_.Current();
117 ASSERT(result != NULL);
122 void UseIterator::Advance() {
123 input_iterator_.Done()
124 ? env_iterator_.Advance()
125 : input_iterator_.Advance();
129 void LAllocator::SetLiveRangeAssignedRegister(LiveRange* range, int reg) {
130 if (range->Kind() == DOUBLE_REGISTERS ||
131 IsSIMD128RegisterKind(range->Kind())) {
132 assigned_double_registers_->Add(reg);
134 ASSERT(range->Kind() == GENERAL_REGISTERS);
135 assigned_registers_->Add(reg);
137 range->set_assigned_register(reg, chunk()->zone());
141 } } // namespace v8::internal
143 #endif // V8_LITHIUM_ALLOCATOR_INL_H_