1 // Copyright 2012 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. 4 5 #ifndef V8_LITHIUM_INL_H_ 6 #define V8_LITHIUM_INL_H_ 7 8 #include "src/lithium.h" 9 10 #if V8_TARGET_ARCH_IA32 11 #include "src/ia32/lithium-ia32.h" // NOLINT 12 #elif V8_TARGET_ARCH_X64 13 #include "src/x64/lithium-x64.h" // NOLINT 14 #elif V8_TARGET_ARCH_ARM64 15 #include "src/arm64/lithium-arm64.h" // NOLINT 16 #elif V8_TARGET_ARCH_ARM 17 #include "src/arm/lithium-arm.h" // NOLINT 18 #elif V8_TARGET_ARCH_MIPS 19 #include "src/mips/lithium-mips.h" // NOLINT 20 #elif V8_TARGET_ARCH_MIPS64 21 #include "src/mips64/lithium-mips64.h" // NOLINT 22 #elif V8_TARGET_ARCH_X87 23 #include "src/x87/lithium-x87.h" // NOLINT 24 #else 25 #error "Unknown architecture." 26 #endif 27 28 namespace v8 { 29 namespace internal { 30 TempIterator(LInstruction * instr)31TempIterator::TempIterator(LInstruction* instr) 32 : instr_(instr), limit_(instr->TempCount()), current_(0) { 33 SkipUninteresting(); 34 } 35 36 Done()37bool TempIterator::Done() { return current_ >= limit_; } 38 39 Current()40LOperand* TempIterator::Current() { 41 DCHECK(!Done()); 42 return instr_->TempAt(current_); 43 } 44 45 SkipUninteresting()46void TempIterator::SkipUninteresting() { 47 while (current_ < limit_ && instr_->TempAt(current_) == NULL) ++current_; 48 } 49 50 Advance()51void TempIterator::Advance() { 52 ++current_; 53 SkipUninteresting(); 54 } 55 56 InputIterator(LInstruction * instr)57InputIterator::InputIterator(LInstruction* instr) 58 : instr_(instr), limit_(instr->InputCount()), current_(0) { 59 SkipUninteresting(); 60 } 61 62 Done()63bool InputIterator::Done() { return current_ >= limit_; } 64 65 Current()66LOperand* InputIterator::Current() { 67 DCHECK(!Done()); 68 DCHECK(instr_->InputAt(current_) != NULL); 69 return instr_->InputAt(current_); 70 } 71 72 Advance()73void InputIterator::Advance() { 74 ++current_; 75 SkipUninteresting(); 76 } 77 78 SkipUninteresting()79void InputIterator::SkipUninteresting() { 80 while (current_ < limit_) { 81 LOperand* current = instr_->InputAt(current_); 82 if (current != NULL && !current->IsConstantOperand()) break; 83 ++current_; 84 } 85 } 86 87 UseIterator(LInstruction * instr)88UseIterator::UseIterator(LInstruction* instr) 89 : input_iterator_(instr), env_iterator_(instr->environment()) {} 90 91 Done()92bool UseIterator::Done() { 93 return input_iterator_.Done() && env_iterator_.Done(); 94 } 95 96 Current()97LOperand* UseIterator::Current() { 98 DCHECK(!Done()); 99 LOperand* result = input_iterator_.Done() ? env_iterator_.Current() 100 : input_iterator_.Current(); 101 DCHECK(result != NULL); 102 return result; 103 } 104 105 Advance()106void UseIterator::Advance() { 107 input_iterator_.Done() ? env_iterator_.Advance() : input_iterator_.Advance(); 108 } 109 } 110 } // namespace v8::internal 111 112 #endif // V8_LITHIUM_INL_H_ 113