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