Lines Matching refs:block_idx
171 next_uses_per_block(spill_ctx& ctx, unsigned block_idx, uint32_t& worklist) in next_uses_per_block() argument
173 Block* block = &ctx.program->blocks[block_idx]; in next_uses_per_block()
174 ctx.next_use_distances_start[block_idx] = ctx.next_use_distances_end[block_idx]; in next_uses_per_block()
175 auto& next_use_distances_start = ctx.next_use_distances_start[block_idx]; in next_uses_per_block()
203 next_use_distances_start[op.getTemp()] = {block_idx, idx}; in next_uses_per_block()
208 assert(block_idx != 0 || next_use_distances_start.empty()); in next_uses_per_block()
214 std::pair<uint32_t, uint32_t> distance{block_idx, 0}; in next_uses_per_block()
276 unsigned block_idx = --worklist; in compute_global_next_uses() local
277 next_uses_per_block(ctx, block_idx, worklist); in compute_global_next_uses()
435 get_demand_before(spill_ctx& ctx, unsigned block_idx, unsigned idx) in get_demand_before() argument
438 RegisterDemand demand = ctx.register_demand[block_idx][idx]; in get_demand_before()
439 aco_ptr<Instruction>& instr = ctx.program->blocks[block_idx].instructions[idx]; in get_demand_before()
443 return ctx.register_demand[block_idx][idx - 1]; in get_demand_before()
448 get_live_in_demand(spill_ctx& ctx, unsigned block_idx) in get_live_in_demand() argument
452 Block& block = ctx.program->blocks[block_idx]; in get_live_in_demand()
463 !ctx.spills_entry[block_idx].count(phi->definitions[0].getTemp())) in get_live_in_demand()
467 reg_pressure += get_demand_before(ctx, block_idx, idx); in get_live_in_demand()
479 init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_idx) in init_live_in_vars() argument
484 if (block_idx == 0) in init_live_in_vars()
488 const auto& next_use_distances = ctx.next_use_distances_start[block_idx]; in init_live_in_vars()
491 if (block->loop_nest_depth > ctx.program->blocks[block_idx - 1].loop_nest_depth) { in init_live_in_vars()
492 assert(block->linear_preds[0] == block_idx - 1); in init_live_in_vars()
493 assert(block->logical_preds[0] == block_idx - 1); in init_live_in_vars()
499 RegisterDemand reg_pressure = get_live_in_demand(ctx, block_idx); in init_live_in_vars()
501 unsigned i = block_idx; in init_live_in_vars()
508 for (auto spilled : ctx.spills_exit[block_idx - 1]) { in init_live_in_vars()
517 ctx.spills_entry[block_idx][spilled.first] = spilled.second; in init_live_in_vars()
540 pair.second.second > distance && !ctx.spills_entry[block_idx].count(pair.first)) { in init_live_in_vars()
555 if (!ctx.spills_exit[block_idx - 1].count(to_spill)) { in init_live_in_vars()
558 spill_id = ctx.spills_exit[block_idx - 1][to_spill]; in init_live_in_vars()
561 ctx.spills_entry[block_idx][to_spill] = spill_id; in init_live_in_vars()
581 !ctx.spills_entry[block_idx].count(pair.first)) { in init_live_in_vars()
587 ctx.spills_entry[block_idx][to_spill] = ctx.allocate_spill_id(to_spill.regClass()); in init_live_in_vars()
605 next_use_distance_it->second.first != block_idx) { in init_live_in_vars()
606 ctx.spills_entry[block_idx].insert(pair); in init_live_in_vars()
618 next_use_distance_it->second.first != block_idx) { in init_live_in_vars()
619 ctx.spills_entry[block_idx].insert(pair); in init_live_in_vars()
631 ctx.spills_entry[block_idx].insert(pair).second) { in init_live_in_vars()
641 ctx.spills_entry[block_idx].insert(pair).second) { in init_live_in_vars()
685 ctx.spills_entry[block_idx][pair.first] = spill_id; in init_live_in_vars()
715 ctx.spills_entry[block_idx][phi->definitions[0].getTemp()] = in init_live_in_vars()
723 RegisterDemand reg_pressure = get_live_in_demand(ctx, block_idx); in init_live_in_vars()
734 assert(!ctx.spills_entry[block_idx].count(*it)); in init_live_in_vars()
744 ctx.spills_entry[block_idx][to_spill] = ctx.allocate_spill_id(to_spill.regClass()); in init_live_in_vars()
754 add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx) in add_coupling_code() argument
765 assert(ctx.register_demand[block_idx].size() == block->instructions.size()); in add_coupling_code()
768 RegisterDemand demand_before = get_demand_before(ctx, block_idx, 0); in add_coupling_code()
771 ctx.next_use_distances_start[block_idx]) { in add_coupling_code()
777 if (ctx.spills_entry[block_idx].count(live.first)) in add_coupling_code()
785 ctx.renames[block_idx].insert(*it); in add_coupling_code()
794 ctx.renames[block_idx][live.first] = new_name; in add_coupling_code()
801 reg_demand.push_back(ctx.register_demand[block_idx][insert_idx]); in add_coupling_code()
807 ctx.next_use_distances_start[block_idx]) { in add_coupling_code()
811 if (ctx.spills_entry[block_idx].count(live.first)) in add_coupling_code()
819 ctx.renames[block_idx].insert(*it); in add_coupling_code()
830 ctx.renames[block_idx][live.first] = new_name; in add_coupling_code()
839 ctx.register_demand[block_idx] = std::move(reg_demand); in add_coupling_code()
861 !ctx.spills_entry[block_idx].count(phi->definitions[0].getTemp())) { in add_coupling_code()
868 uint32_t def_spill_id = ctx.spills_entry[block_idx][phi->definitions[0].getTemp()]; in add_coupling_code()
931 for (std::pair<Temp, uint32_t> pair : ctx.spills_entry[block_idx]) { in add_coupling_code()
985 !ctx.spills_entry[block_idx].count(phi->definitions[0].getTemp())); in add_coupling_code()
1043 ctx.next_use_distances_start[block_idx]) { in add_coupling_code()
1045 if (ctx.spills_entry[block_idx].count(pair.first)) in add_coupling_code()
1112 } else if (preds[i] >= block_idx) { in add_coupling_code()
1128 ctx.renames[block_idx][pair.first] = rename; in add_coupling_code()
1137 if (!ctx.processed[block_idx]) { in add_coupling_code()
1139 RegisterDemand demand_before = get_demand_before(ctx, block_idx, idx); in add_coupling_code()
1154 process_block(spill_ctx& ctx, unsigned block_idx, Block* block, RegisterDemand spilled_registers) in process_block() argument
1156 assert(!ctx.processed[block_idx]); in process_block()
1173 auto& current_spills = ctx.spills_exit[block_idx]; in process_block()
1186 auto rename_it = ctx.renames[block_idx].find(op.getTemp()); in process_block()
1187 if (rename_it != ctx.renames[block_idx].end()) { in process_block()
1200 ctx.renames[block_idx][op.getTemp()] = new_tmp; in process_block()
1210 RegisterDemand new_demand = ctx.register_demand[block_idx][idx]; in process_block()
1211 new_demand.update(get_demand_before(ctx, block_idx, idx)); in process_block()
1250 if (ctx.renames[block_idx].count(to_spill)) { in process_block()
1251 to_spill = ctx.renames[block_idx][to_spill]; in process_block()
1277 spill_block(spill_ctx& ctx, unsigned block_idx) in spill_block() argument
1279 Block* block = &ctx.program->blocks[block_idx]; in spill_block()
1282 RegisterDemand spilled_registers = init_live_in_vars(ctx, block, block_idx); in spill_block()
1285 for (auto it = ctx.spills_entry[block_idx].begin(); it != ctx.spills_entry[block_idx].end(); in spill_block()
1287 for (auto it2 = std::next(it); it2 != ctx.spills_entry[block_idx].end(); ++it2) in spill_block()
1291 bool is_loop_header = block->loop_nest_depth && ctx.loop_header.top()->index == block_idx; in spill_block()
1294 add_coupling_code(ctx, block, block_idx); in spill_block()
1297 const auto& current_spills = ctx.spills_entry[block_idx]; in spill_block()
1301 !ctx.renames[block_idx].empty() || ctx.unused_remats.size(); in spill_block()
1304 if (ctx.next_use_distances_start[block_idx].at(it->first).first == block_idx) in spill_block()
1308 assert(ctx.spills_exit[block_idx].empty()); in spill_block()
1309 ctx.spills_exit[block_idx] = current_spills; in spill_block()
1311 process_block(ctx, block_idx, block, spilled_registers); in spill_block()
1314 ctx.processed[block_idx] = true; in spill_block()
1318 ctx.program->blocks[block_idx + 1].loop_nest_depth >= block->loop_nest_depth) in spill_block()
1332 for (unsigned idx = loop_header->index; idx <= block_idx; idx++) { in spill_block()