OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/flow_graph_allocator.h" | 5 #include "vm/flow_graph_allocator.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 #include "vm/il_printer.h" | 9 #include "vm/il_printer.h" |
10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 ASSERT(pred_idx < join->PredecessorCount()); | 418 ASSERT(pred_idx < join->PredecessorCount()); |
419 | 419 |
420 // Record the corresponding phi input use for each phi. | 420 // Record the corresponding phi input use for each phi. |
421 ZoneGrowableArray<PhiInstr*>* phis = join->phis(); | 421 ZoneGrowableArray<PhiInstr*>* phis = join->phis(); |
422 intptr_t move_idx = 0; | 422 intptr_t move_idx = 0; |
423 for (intptr_t phi_idx = 0; phi_idx < phis->length(); phi_idx++) { | 423 for (intptr_t phi_idx = 0; phi_idx < phis->length(); phi_idx++) { |
424 PhiInstr* phi = (*phis)[phi_idx]; | 424 PhiInstr* phi = (*phis)[phi_idx]; |
425 if (phi == NULL) continue; | 425 if (phi == NULL) continue; |
426 | 426 |
427 Value* val = phi->InputAt(pred_idx); | 427 Value* val = phi->InputAt(pred_idx); |
428 MoveOperands move = parallel_move->moves()[move_idx]; | 428 MoveOperands* move = parallel_move->MoveOperandsAt(move_idx); |
429 if (val->IsUse()) { | 429 if (val->IsUse()) { |
430 const intptr_t virtual_register = | 430 const intptr_t virtual_register = |
431 val->AsUse()->definition()->ssa_temp_index(); | 431 val->AsUse()->definition()->ssa_temp_index(); |
432 Location* slot = move.src_slot(); | 432 move->set_src(Location::RequiresRegister()); |
433 *slot = Location::RequiresRegister(); | 433 GetLiveRange( |
434 GetLiveRange(virtual_register)->head()->AddUse(NULL, pos, slot); | 434 virtual_register)->head()->AddUse(NULL, pos, move->src_slot()); |
435 } else { | 435 } else { |
436 ASSERT(val->IsConstant()); | 436 ASSERT(val->IsConstant()); |
437 move.set_src(Location::Constant(val->AsConstant()->value())); | 437 move->set_src(Location::Constant(val->AsConstant()->value())); |
438 } | 438 } |
439 move_idx++; | 439 move_idx++; |
440 } | 440 } |
441 | 441 |
442 // Begin backward iteration with the instruction before the parallel | 442 // Begin backward iteration with the instruction before the parallel |
443 // move. | 443 // move. |
444 current = current->previous(); | 444 current = current->previous(); |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 ASSERT(virtual_register != -1); | 548 ASSERT(virtual_register != -1); |
549 | 549 |
550 LiveRange* range = GetLiveRange(virtual_register); | 550 LiveRange* range = GetLiveRange(virtual_register); |
551 range->DefineAt(NULL, pos, NULL); | 551 range->DefineAt(NULL, pos, NULL); |
552 UseInterval* interval = GetLiveRange(virtual_register)->head(); | 552 UseInterval* interval = GetLiveRange(virtual_register)->head(); |
553 | 553 |
554 for (intptr_t k = 0; k < phi->InputCount(); k++) { | 554 for (intptr_t k = 0; k < phi->InputCount(); k++) { |
555 BlockEntryInstr* pred = block->PredecessorAt(k); | 555 BlockEntryInstr* pred = block->PredecessorAt(k); |
556 ASSERT(pred->last_instruction()->IsGoto()); | 556 ASSERT(pred->last_instruction()->IsGoto()); |
557 Instruction* move_instr = pred->last_instruction()->previous(); | 557 Instruction* move_instr = pred->last_instruction()->previous(); |
558 ASSERT(move_instr->IsParallelMove()); | 558 ParallelMoveInstr* pmove = move_instr->AsParallelMove(); |
| 559 ASSERT(pmove != NULL); |
559 | 560 |
560 Location* slot = | 561 MoveOperands* move_operands = pmove->MoveOperandsAt(move_idx); |
561 move_instr->AsParallelMove()->moves()[move_idx].dest_slot(); | 562 move_operands->set_dest(Location::RequiresRegister()); |
562 *slot = Location::RequiresRegister(); | 563 interval->AddUse(NULL, pos, move_operands->dest_slot()); |
563 interval->AddUse(NULL, pos, slot); | |
564 } | 564 } |
565 | 565 |
566 // All phi resolution moves are connected. Phi's live range is | 566 // All phi resolution moves are connected. Phi's live range is |
567 // complete. | 567 // complete. |
568 AddToUnallocated(interval); | 568 AddToUnallocated(interval); |
569 | 569 |
570 move_idx++; | 570 move_idx++; |
571 } | 571 } |
572 } | 572 } |
573 } | 573 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 | 950 |
951 if (FLAG_trace_ssa_allocator) { | 951 if (FLAG_trace_ssa_allocator) { |
952 OS::Print("-- ir after allocation -------------------------\n"); | 952 OS::Print("-- ir after allocation -------------------------\n"); |
953 FlowGraphPrinter printer(Function::Handle(), block_order_, true); | 953 FlowGraphPrinter printer(Function::Handle(), block_order_, true); |
954 printer.PrintBlocks(); | 954 printer.PrintBlocks(); |
955 } | 955 } |
956 } | 956 } |
957 | 957 |
958 | 958 |
959 } // namespace dart | 959 } // namespace dart |
OLD | NEW |