Land the Fan (disabled)
[platform/upstream/v8.git] / src / lithium-inl.h
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_X87
21 #include "src/x87/lithium-x87.h"  // NOLINT
22 #else
23 #error "Unknown architecture."
24 #endif
25
26 namespace v8 {
27 namespace internal {
28
29 TempIterator::TempIterator(LInstruction* instr)
30     : instr_(instr), limit_(instr->TempCount()), current_(0) {
31   SkipUninteresting();
32 }
33
34
35 bool TempIterator::Done() { return current_ >= limit_; }
36
37
38 LOperand* TempIterator::Current() {
39   ASSERT(!Done());
40   return instr_->TempAt(current_);
41 }
42
43
44 void TempIterator::SkipUninteresting() {
45   while (current_ < limit_ && instr_->TempAt(current_) == NULL) ++current_;
46 }
47
48
49 void TempIterator::Advance() {
50   ++current_;
51   SkipUninteresting();
52 }
53
54
55 InputIterator::InputIterator(LInstruction* instr)
56     : instr_(instr), limit_(instr->InputCount()), current_(0) {
57   SkipUninteresting();
58 }
59
60
61 bool InputIterator::Done() { return current_ >= limit_; }
62
63
64 LOperand* InputIterator::Current() {
65   ASSERT(!Done());
66   ASSERT(instr_->InputAt(current_) != NULL);
67   return instr_->InputAt(current_);
68 }
69
70
71 void InputIterator::Advance() {
72   ++current_;
73   SkipUninteresting();
74 }
75
76
77 void InputIterator::SkipUninteresting() {
78   while (current_ < limit_) {
79     LOperand* current = instr_->InputAt(current_);
80     if (current != NULL && !current->IsConstantOperand()) break;
81     ++current_;
82   }
83 }
84
85
86 UseIterator::UseIterator(LInstruction* instr)
87     : input_iterator_(instr), env_iterator_(instr->environment()) {}
88
89
90 bool UseIterator::Done() {
91   return input_iterator_.Done() && env_iterator_.Done();
92 }
93
94
95 LOperand* UseIterator::Current() {
96   ASSERT(!Done());
97   LOperand* result = input_iterator_.Done() ? env_iterator_.Current()
98                                             : input_iterator_.Current();
99   ASSERT(result != NULL);
100   return result;
101 }
102
103
104 void UseIterator::Advance() {
105   input_iterator_.Done() ? env_iterator_.Advance() : input_iterator_.Advance();
106 }
107 }
108 }  // namespace v8::internal
109
110 #endif  // V8_LITHIUM_INL_H_