Lines Matching refs:allocator

35 // Note: the register allocator tests rely on the fact that constants have live
40 ArenaAllocator allocator(&pool);
41 HGraph* graph = CreateGraph(&allocator);
51 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
57 * Unit testing of RegisterAllocator::ValidateIntervals. Register allocator
62 ArenaAllocator allocator(&pool);
63 HGraph* graph = CreateGraph(&allocator);
67 GrowableArray<LiveInterval*> intervals(&allocator, 0);
72 intervals.Add(BuildInterval(ranges, arraysize(ranges), &allocator, 0));
73 intervals.Add(BuildInterval(ranges, arraysize(ranges), &allocator, 1));
75 intervals, 0, 0, codegen, &allocator, true, false));
79 intervals, 0, 0, codegen, &allocator, true, false));
86 intervals.Add(BuildInterval(ranges1, arraysize(ranges1), &allocator, 0));
88 intervals.Add(BuildInterval(ranges2, arraysize(ranges2), &allocator, 1));
90 intervals, 0, 0, codegen, &allocator, true, false));
94 intervals, 0, 0, codegen, &allocator, true, false));
101 intervals.Add(BuildInterval(ranges1, arraysize(ranges1), &allocator, 0));
103 intervals.Add(BuildInterval(ranges2, arraysize(ranges2), &allocator, 1));
105 intervals, 0, 0, codegen, &allocator, true, false));
109 intervals, 0, 0, codegen, &allocator, true, false));
116 intervals.Add(BuildInterval(ranges1, arraysize(ranges1), &allocator, 0));
118 intervals.Add(BuildInterval(ranges2, arraysize(ranges2), &allocator, 1));
120 intervals, 0, 0, codegen, &allocator, true, false));
124 intervals, 0, 0, codegen, &allocator, true, false));
131 intervals.Add(BuildInterval(ranges1, arraysize(ranges1), &allocator, 0));
134 intervals.Add(BuildInterval(ranges2, arraysize(ranges2), &allocator, 1));
136 intervals, 0, 0, codegen, &allocator, true, false));
141 intervals, 0, 0, codegen, &allocator, true, false));
145 intervals, 0, 0, codegen, &allocator, true, false));
257 static HGraph* BuildSSAGraph(const uint16_t* data, ArenaAllocator* allocator) {
258 HGraph* graph = CreateGraph(allocator);
304 ArenaAllocator allocator(&pool);
305 HGraph* graph = BuildSSAGraph(data, &allocator);
311 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
338 ArenaAllocator allocator(&pool);
339 HGraph* graph = BuildSSAGraph(data, &allocator);
392 ArenaAllocator allocator(&pool);
393 HGraph* graph = BuildSSAGraph(data, &allocator);
400 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
416 ArenaAllocator allocator(&pool);
417 HGraph* graph = BuildSSAGraph(data, &allocator);
424 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
436 LiveInterval* interval = LiveInterval::MakeFixedInterval(&allocator, 0, Primitive::kPrimInt);
440 interval = LiveInterval::MakeFixedInterval(&allocator, 0, Primitive::kPrimInt);
444 interval = LiveInterval::MakeFixedInterval(&allocator, 0, Primitive::kPrimInt);
449 register_allocator.registers_array_ = allocator.AllocArray<size_t>(1);
462 static HGraph* BuildIfElseWithPhi(ArenaAllocator* allocator,
466 HGraph* graph = CreateGraph(allocator);
467 HBasicBlock* entry = new (allocator) HBasicBlock(graph);
470 HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimNot);
473 HBasicBlock* block = new (allocator) HBasicBlock(graph);
477 HInstruction* test = new (allocator) HInstanceFieldGet(
480 block->AddInstruction(new (allocator) HIf(test));
481 HBasicBlock* then = new (allocator) HBasicBlock(graph);
482 HBasicBlock* else_ = new (allocator) HBasicBlock(graph);
483 HBasicBlock* join = new (allocator) HBasicBlock(graph);
492 then->AddInstruction(new (allocator) HGoto());
493 else_->AddInstruction(new (allocator) HGoto());
495 *phi = new (allocator) HPhi(allocator, 0, 0, Primitive::kPrimInt);
497 *input1 = new (allocator) HInstanceFieldGet(parameter, Primitive::kPrimInt,
499 *input2 = new (allocator) HInstanceFieldGet(parameter, Primitive::kPrimInt,
503 join->AddInstruction(new (allocator) HExit());
514 ArenaAllocator allocator(&pool);
519 HGraph* graph = BuildIfElseWithPhi(&allocator, &phi, &input1, &input2);
526 // Check that the register allocator is deterministic.
527 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
536 HGraph* graph = BuildIfElseWithPhi(&allocator, &phi, &input1, &input2);
546 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
555 HGraph* graph = BuildIfElseWithPhi(&allocator, &phi, &input1, &input2);
565 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
574 HGraph* graph = BuildIfElseWithPhi(&allocator, &phi, &input1, &input2);
584 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
593 static HGraph* BuildFieldReturn(ArenaAllocator* allocator,
596 HGraph* graph = CreateGraph(allocator);
597 HBasicBlock* entry = new (allocator) HBasicBlock(graph);
600 HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimNot);
603 HBasicBlock* block = new (allocator) HBasicBlock(graph);
607 *field = new (allocator) HInstanceFieldGet(parameter, Primitive::kPrimInt,
610 *ret = new (allocator) HReturn(*field);
613 HBasicBlock* exit = new (allocator) HBasicBlock(graph);
616 exit->AddInstruction(new (allocator) HExit());
624 ArenaAllocator allocator(&pool);
628 HGraph* graph = BuildFieldReturn(&allocator, &field, &ret);
635 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
643 HGraph* graph = BuildFieldReturn(&allocator, &field, &ret);
654 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
661 static HGraph* BuildTwoSubs(ArenaAllocator* allocator,
664 HGraph* graph = CreateGraph(allocator);
665 HBasicBlock* entry = new (allocator) HBasicBlock(graph);
668 HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimInt);
674 HBasicBlock* block = new (allocator) HBasicBlock(graph);
678 *first_sub = new (allocator) HSub(Primitive::kPrimInt, parameter, constant1);
680 *second_sub = new (allocator) HSub(Primitive::kPrimInt, *first_sub, constant2);
683 block->AddInstruction(new (allocator) HExit());
691 ArenaAllocator allocator(&pool);
695 HGraph* graph = BuildTwoSubs(&allocator, &first_sub, &second_sub);
702 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
711 HGraph* graph = BuildTwoSubs(&allocator, &first_sub, &second_sub);
724 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
732 static HGraph* BuildDiv(ArenaAllocator* allocator,
734 HGraph* graph = CreateGraph(allocator);
735 HBasicBlock* entry = new (allocator) HBasicBlock(graph);
738 HInstruction* first = new (allocator) HParameterValue(0, Primitive::kPrimInt);
739 HInstruction* second = new (allocator) HParameterValue(0, Primitive::kPrimInt);
743 HBasicBlock* block = new (allocator) HBasicBlock(graph);
747 *div = new (allocator) HDiv(Primitive::kPrimInt, first, second, 0); // don't care about dex_pc.
750 block->AddInstruction(new (allocator) HExit());
758 ArenaAllocator allocator(&pool);
762 HGraph* graph = BuildDiv(&allocator, &div);
769 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
777 // Test a bug in the register allocator, where allocating a blocked
785 ArenaAllocator allocator(&pool);
786 HGraph* graph = CreateGraph(&allocator);
787 HBasicBlock* entry = new (&allocator) HBasicBlock(graph);
790 HInstruction* one = new (&allocator) HParameterValue(0, Primitive::kPrimInt);
791 HInstruction* two = new (&allocator) HParameterValue(0, Primitive::kPrimInt);
792 HInstruction* three = new (&allocator) HParameterValue(0, Primitive::kPrimInt);
793 HInstruction* four = new (&allocator) HParameterValue(0, Primitive::kPrimInt);
799 HBasicBlock* block = new (&allocator) HBasicBlock(graph);
802 block->AddInstruction(new (&allocator) HExit());
806 HPhi* user = new (&allocator) HPhi(&allocator, 0, 1, Primitive::kPrimInt);
809 LocationSummary* locations = new (&allocator) LocationSummary(user, LocationSummary::kNoCall);
812 BuildInterval(phi_ranges, arraysize(phi_ranges), &allocator, -1, user);
816 LiveInterval* first = BuildInterval(ranges1, arraysize(ranges1), &allocator, -1, one);
817 first->first_use_ = new(&allocator) UsePosition(user, 0, false, 8, first->first_use_);
818 first->first_use_ = new(&allocator) UsePosition(user, 0, false, 7, first->first_use_);
819 first->first_use_ = new(&allocator) UsePosition(user, 0, false, 6, first->first_use_);
821 locations = new (&allocator) LocationSummary(first->GetDefinedBy(), LocationSummary::kNoCall);
828 LiveInterval* second = BuildInterval(ranges2, arraysize(ranges2), &allocator, -1, two);
829 locations = new (&allocator) LocationSummary(second->GetDefinedBy(), LocationSummary::kNoCall);
838 LiveInterval* third = BuildInterval(ranges3, arraysize(ranges3), &allocator, -1, three);
839 third->first_use_ = new(&allocator) UsePosition(user, 0, false, 8, third->first_use_);
840 third->first_use_ = new(&allocator) UsePosition(user, 0, false, 4, third->first_use_);
841 third->first_use_ = new(&allocator) UsePosition(user, 0, false, 3, third->first_use_);
842 locations = new (&allocator) LocationSummary(third->GetDefinedBy(), LocationSummary::kNoCall);
849 LiveInterval* fourth = BuildInterval(ranges4, arraysize(ranges4), &allocator, -1, four);
850 locations = new (&allocator) LocationSummary(fourth->GetDefinedBy(), LocationSummary::kNoCall);
857 // Populate the instructions in the liveness object, to please the register allocator.
862 RegisterAllocator register_allocator(&allocator, &codegen, liveness);
870 register_allocator.registers_array_ = allocator.AllocArray<size_t>(1);
876 GrowableArray<LiveInterval*> intervals(&allocator, 0);
882 intervals, 0, 0, codegen, &allocator, true, false));