OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/locations.h" | 5 #include "vm/locations.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/il_printer.h" | 8 #include "vm/il_printer.h" |
9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 LocationSummary::ContainsCall contains_call) { | 80 LocationSummary::ContainsCall contains_call) { |
81 LocationSummary* summary = new LocationSummary(input_count, 0, contains_call); | 81 LocationSummary* summary = new LocationSummary(input_count, 0, contains_call); |
82 for (intptr_t i = 0; i < input_count; i++) { | 82 for (intptr_t i = 0; i < input_count; i++) { |
83 summary->set_in(i, Location::RequiresRegister()); | 83 summary->set_in(i, Location::RequiresRegister()); |
84 } | 84 } |
85 summary->set_out(0, out); | 85 summary->set_out(0, out); |
86 return summary; | 86 return summary; |
87 } | 87 } |
88 | 88 |
89 | 89 |
| 90 Location Location::Pair(Location first, Location second) { |
| 91 PairLocation* pair_location = new PairLocation(); |
| 92 ASSERT((reinterpret_cast<intptr_t>(pair_location) & kLocationTagMask) == 0); |
| 93 pair_location->SetAt(0, first); |
| 94 pair_location->SetAt(1, second); |
| 95 Location loc(reinterpret_cast<uword>(pair_location) | kPairLocationTag); |
| 96 return loc; |
| 97 } |
| 98 |
| 99 |
| 100 PairLocation* Location::AsPairLocation() const { |
| 101 ASSERT(IsPairLocation()); |
| 102 return reinterpret_cast<PairLocation*>(value_ & ~kLocationTagMask); |
| 103 } |
| 104 |
| 105 |
90 Location Location::RegisterOrConstant(Value* value) { | 106 Location Location::RegisterOrConstant(Value* value) { |
91 ConstantInstr* constant = value->definition()->AsConstant(); | 107 ConstantInstr* constant = value->definition()->AsConstant(); |
92 return ((constant != NULL) && Assembler::IsSafe(constant->value())) | 108 return ((constant != NULL) && Assembler::IsSafe(constant->value())) |
93 ? Location::Constant(constant->value()) | 109 ? Location::Constant(constant->value()) |
94 : Location::RequiresRegister(); | 110 : Location::RequiresRegister(); |
95 } | 111 } |
96 | 112 |
97 | 113 |
98 Location Location::RegisterOrSmiConstant(Value* value) { | 114 Location Location::RegisterOrSmiConstant(Value* value) { |
99 ConstantInstr* constant = value->definition()->AsConstant(); | 115 ConstantInstr* constant = value->definition()->AsConstant(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return "R"; | 185 return "R"; |
170 case kRequiresFpuRegister: | 186 case kRequiresFpuRegister: |
171 return "DR"; | 187 return "DR"; |
172 case kWritableRegister: | 188 case kWritableRegister: |
173 return "WR"; | 189 return "WR"; |
174 case kSameAsFirstInput: | 190 case kSameAsFirstInput: |
175 return "0"; | 191 return "0"; |
176 } | 192 } |
177 UNREACHABLE(); | 193 UNREACHABLE(); |
178 default: | 194 default: |
179 ASSERT(IsConstant()); | 195 if (IsConstant()) { |
180 return "C"; | 196 return "C"; |
| 197 } else { |
| 198 ASSERT(IsPairLocation()); |
| 199 return "2P"; |
| 200 } |
181 } | 201 } |
182 return "?"; | 202 return "?"; |
183 } | 203 } |
184 | 204 |
185 | 205 |
186 void Location::PrintTo(BufferFormatter* f) const { | 206 void Location::PrintTo(BufferFormatter* f) const { |
187 if (kind() == kStackSlot) { | 207 if (kind() == kStackSlot) { |
188 f->Print("S%+" Pd "", stack_index()); | 208 f->Print("S%+" Pd "", stack_index()); |
189 } else if (kind() == kDoubleStackSlot) { | 209 } else if (kind() == kDoubleStackSlot) { |
190 f->Print("DS%+" Pd "", stack_index()); | 210 f->Print("DS%+" Pd "", stack_index()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 246 |
227 if (!out(0).IsInvalid()) { | 247 if (!out(0).IsInvalid()) { |
228 f->Print(" => "); | 248 f->Print(" => "); |
229 out(0).PrintTo(f); | 249 out(0).PrintTo(f); |
230 } | 250 } |
231 | 251 |
232 if (always_calls()) f->Print(" C"); | 252 if (always_calls()) f->Print(" C"); |
233 } | 253 } |
234 | 254 |
235 } // namespace dart | 255 } // namespace dart |
OLD | NEW |