Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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 |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 24 | #elif V8_TARGET_ARCH_S390 |
| 25 | #include "src/crankshaft/s390/lithium-s390.h" // NOLINT |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 26 | #elif V8_TARGET_ARCH_X87 |
| 27 | #include "src/crankshaft/x87/lithium-x87.h" // NOLINT |
| 28 | #else |
| 29 | #error "Unknown architecture." |
| 30 | #endif |
| 31 | |
| 32 | namespace v8 { |
| 33 | namespace internal { |
| 34 | |
| 35 | TempIterator::TempIterator(LInstruction* instr) |
| 36 | : instr_(instr), limit_(instr->TempCount()), current_(0) { |
| 37 | SkipUninteresting(); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | bool TempIterator::Done() { return current_ >= limit_; } |
| 42 | |
| 43 | |
| 44 | LOperand* TempIterator::Current() { |
| 45 | DCHECK(!Done()); |
| 46 | return instr_->TempAt(current_); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | void TempIterator::SkipUninteresting() { |
| 51 | while (current_ < limit_ && instr_->TempAt(current_) == NULL) ++current_; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | void TempIterator::Advance() { |
| 56 | ++current_; |
| 57 | SkipUninteresting(); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | InputIterator::InputIterator(LInstruction* instr) |
| 62 | : instr_(instr), limit_(instr->InputCount()), current_(0) { |
| 63 | SkipUninteresting(); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | bool InputIterator::Done() { return current_ >= limit_; } |
| 68 | |
| 69 | |
| 70 | LOperand* InputIterator::Current() { |
| 71 | DCHECK(!Done()); |
| 72 | DCHECK(instr_->InputAt(current_) != NULL); |
| 73 | return instr_->InputAt(current_); |
| 74 | } |
| 75 | |
| 76 | |
| 77 | void InputIterator::Advance() { |
| 78 | ++current_; |
| 79 | SkipUninteresting(); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | void InputIterator::SkipUninteresting() { |
| 84 | while (current_ < limit_) { |
| 85 | LOperand* current = instr_->InputAt(current_); |
| 86 | if (current != NULL && !current->IsConstantOperand()) break; |
| 87 | ++current_; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | |
| 92 | UseIterator::UseIterator(LInstruction* instr) |
| 93 | : input_iterator_(instr), env_iterator_(instr->environment()) {} |
| 94 | |
| 95 | |
| 96 | bool UseIterator::Done() { |
| 97 | return input_iterator_.Done() && env_iterator_.Done(); |
| 98 | } |
| 99 | |
| 100 | |
| 101 | LOperand* UseIterator::Current() { |
| 102 | DCHECK(!Done()); |
| 103 | LOperand* result = input_iterator_.Done() ? env_iterator_.Current() |
| 104 | : input_iterator_.Current(); |
| 105 | DCHECK(result != NULL); |
| 106 | return result; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | void UseIterator::Advance() { |
| 111 | input_iterator_.Done() ? env_iterator_.Advance() : input_iterator_.Advance(); |
| 112 | } |
| 113 | } // namespace internal |
| 114 | } // namespace v8 |
| 115 | |
| 116 | #endif // V8_CRANKSHAFT_LITHIUM_INL_H_ |