Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: src/compiler/register-allocator-verifier.cc

Issue 1087793002: [turbofan] add MachineType to AllocatedOperand (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: no flag Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | test/cctest/compiler/test-gap-resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bit-vector.h" 5 #include "src/bit-vector.h"
6 #include "src/compiler/instruction.h" 6 #include "src/compiler/instruction.h"
7 #include "src/compiler/register-allocator-verifier.h" 7 #include "src/compiler/register-allocator-verifier.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 constraint->virtual_register_ = vreg; 156 constraint->virtual_register_ = vreg;
157 if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) { 157 if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) {
158 constraint->type_ = kFixedSlot; 158 constraint->type_ = kFixedSlot;
159 constraint->value_ = unallocated->fixed_slot_index(); 159 constraint->value_ = unallocated->fixed_slot_index();
160 } else { 160 } else {
161 switch (unallocated->extended_policy()) { 161 switch (unallocated->extended_policy()) {
162 case UnallocatedOperand::ANY: 162 case UnallocatedOperand::ANY:
163 CHECK(false); 163 CHECK(false);
164 break; 164 break;
165 case UnallocatedOperand::NONE: 165 case UnallocatedOperand::NONE:
166 if (sequence()->IsDouble(vreg)) { 166 if (sequence()->IsFloat(vreg)) {
167 constraint->type_ = kNoneDouble; 167 constraint->type_ = kNoneDouble;
168 } else { 168 } else {
169 constraint->type_ = kNone; 169 constraint->type_ = kNone;
170 } 170 }
171 break; 171 break;
172 case UnallocatedOperand::FIXED_REGISTER: 172 case UnallocatedOperand::FIXED_REGISTER:
173 constraint->type_ = kFixedRegister; 173 constraint->type_ = kFixedRegister;
174 constraint->value_ = unallocated->fixed_register_index(); 174 constraint->value_ = unallocated->fixed_register_index();
175 break; 175 break;
176 case UnallocatedOperand::FIXED_DOUBLE_REGISTER: 176 case UnallocatedOperand::FIXED_DOUBLE_REGISTER:
177 constraint->type_ = kFixedDoubleRegister; 177 constraint->type_ = kFixedDoubleRegister;
178 constraint->value_ = unallocated->fixed_register_index(); 178 constraint->value_ = unallocated->fixed_register_index();
179 break; 179 break;
180 case UnallocatedOperand::MUST_HAVE_REGISTER: 180 case UnallocatedOperand::MUST_HAVE_REGISTER:
181 if (sequence()->IsDouble(vreg)) { 181 if (sequence()->IsFloat(vreg)) {
182 constraint->type_ = kDoubleRegister; 182 constraint->type_ = kDoubleRegister;
183 } else { 183 } else {
184 constraint->type_ = kRegister; 184 constraint->type_ = kRegister;
185 } 185 }
186 break; 186 break;
187 case UnallocatedOperand::MUST_HAVE_SLOT: 187 case UnallocatedOperand::MUST_HAVE_SLOT:
188 if (sequence()->IsDouble(vreg)) { 188 if (sequence()->IsFloat(vreg)) {
189 constraint->type_ = kDoubleSlot; 189 constraint->type_ = kDoubleSlot;
190 } else { 190 } else {
191 constraint->type_ = kSlot; 191 constraint->type_ = kSlot;
192 } 192 }
193 break; 193 break;
194 case UnallocatedOperand::SAME_AS_FIRST_INPUT: 194 case UnallocatedOperand::SAME_AS_FIRST_INPUT:
195 constraint->type_ = kSameAsFirst; 195 constraint->type_ = kSameAsFirst;
196 break; 196 break;
197 } 197 }
198 } 198 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 }; 279 };
280 280
281 class PhiMap : public ZoneMap<int, PhiData*>, public ZoneObject { 281 class PhiMap : public ZoneMap<int, PhiData*>, public ZoneObject {
282 public: 282 public:
283 explicit PhiMap(Zone* zone) : ZoneMap<int, PhiData*>(zone) {} 283 explicit PhiMap(Zone* zone) : ZoneMap<int, PhiData*>(zone) {}
284 }; 284 };
285 285
286 struct OperandLess { 286 struct OperandLess {
287 bool operator()(const InstructionOperand* a, 287 bool operator()(const InstructionOperand* a,
288 const InstructionOperand* b) const { 288 const InstructionOperand* b) const {
289 return *a < *b; 289 return a->CompareModuloType(*b);
290 } 290 }
291 }; 291 };
292 292
293 class OperandMap : public ZoneObject { 293 class OperandMap : public ZoneObject {
294 public: 294 public:
295 struct MapValue : public ZoneObject { 295 struct MapValue : public ZoneObject {
296 MapValue() 296 MapValue()
297 : incoming(nullptr), 297 : incoming(nullptr),
298 define_vreg(kInvalidVreg), 298 define_vreg(kInvalidVreg),
299 use_vreg(kInvalidVreg), 299 use_vreg(kInvalidVreg),
(...skipping 13 matching lines...) Expand all
313 // Remove all entries with keys not in other. 313 // Remove all entries with keys not in other.
314 void Intersect(const Map& other) { 314 void Intersect(const Map& other) {
315 if (this->empty()) return; 315 if (this->empty()) return;
316 auto it = this->begin(); 316 auto it = this->begin();
317 OperandLess less; 317 OperandLess less;
318 for (const auto& o : other) { 318 for (const auto& o : other) {
319 while (less(it->first, o.first)) { 319 while (less(it->first, o.first)) {
320 this->erase(it++); 320 this->erase(it++);
321 if (it == this->end()) return; 321 if (it == this->end()) return;
322 } 322 }
323 if (*it->first == *o.first) { 323 if (it->first->EqualsModuloType(*o.first)) {
324 ++it; 324 ++it;
325 if (it == this->end()) return; 325 if (it == this->end()) return;
326 } else { 326 } else {
327 CHECK(less(o.first, it->first)); 327 CHECK(less(o.first, it->first));
328 } 328 }
329 } 329 }
330 } 330 }
331 }; 331 };
332 332
333 explicit OperandMap(Zone* zone) : map_(zone) {} 333 explicit OperandMap(Zone* zone) : map_(zone) {}
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 RunParallelMoves(zone, move); 365 RunParallelMoves(zone, move);
366 } 366 }
367 } 367 }
368 368
369 void Drop(const InstructionOperand* op) { 369 void Drop(const InstructionOperand* op) {
370 auto it = map().find(op); 370 auto it = map().find(op);
371 if (it != map().end()) map().erase(it); 371 if (it != map().end()) map().erase(it);
372 } 372 }
373 373
374 void DropRegisters(const RegisterConfiguration* config) { 374 void DropRegisters(const RegisterConfiguration* config) {
375 for (int i = 0; i < config->num_general_registers(); ++i) { 375 // TODO(dcarney): sort map by kind and drop range.
376 RegisterOperand op(i); 376 for (auto it = map().begin(); it != map().end();) {
377 Drop(&op); 377 auto op = it->first;
378 } 378 if (op->IsRegister() || op->IsDoubleRegister()) {
379 for (int i = 0; i < config->num_double_registers(); ++i) { 379 map().erase(it++);
380 DoubleRegisterOperand op(i); 380 } else {
381 Drop(&op); 381 ++it;
382 }
382 } 383 }
383 } 384 }
384 385
385 void Define(Zone* zone, const InstructionOperand* op, int virtual_register) { 386 void Define(Zone* zone, const InstructionOperand* op, int virtual_register) {
386 auto value = new (zone) MapValue(); 387 auto value = new (zone) MapValue();
387 value->define_vreg = virtual_register; 388 value->define_vreg = virtual_register;
388 auto res = map().insert(std::make_pair(op, value)); 389 auto res = map().insert(std::make_pair(op, value));
389 if (!res.second) res.first->second = value; 390 if (!res.second) res.first->second = value;
390 } 391 }
391 392
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 int virtual_register = op_constraints[count].virtual_register_; 700 int virtual_register = op_constraints[count].virtual_register_;
700 current->Define(zone(), instr->OutputAt(i), virtual_register); 701 current->Define(zone(), instr->OutputAt(i), virtual_register);
701 } 702 }
702 } 703 }
703 } 704 }
704 } 705 }
705 706
706 } // namespace compiler 707 } // namespace compiler
707 } // namespace internal 708 } // namespace internal
708 } // namespace v8 709 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | test/cctest/compiler/test-gap-resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698