Lines Matching refs:ctx
110 interval_insert(struct ir3_reg_ctx *ctx, struct rb_tree *tree,
151 ctx->interval_delete(ctx, right);
163 interval_insert(ctx, &right->children, interval);
169 ctx->interval_add(ctx, interval);
175 ir3_reg_interval_insert(struct ir3_reg_ctx *ctx,
180 interval_insert(ctx, &ctx->intervals, interval);
185 ir3_reg_interval_reinsert(struct ir3_reg_ctx *ctx,
189 interval_insert(ctx, &ctx->intervals, interval);
193 ir3_reg_interval_remove(struct ir3_reg_ctx *ctx,
199 ctx->interval_delete(ctx, interval);
200 rb_tree_remove(&ctx->intervals, &interval->node);
212 ctx->interval_readd(ctx, interval, child);
213 rb_tree_insert(&ctx->intervals, &child->node,
232 ir3_reg_interval_remove_all(struct ir3_reg_ctx *ctx,
237 ctx->interval_delete(ctx, interval);
238 rb_tree_remove(&ctx->intervals, &interval->node);
246 ir3_reg_interval_remove_temp(struct ir3_reg_ctx *ctx,
251 ctx->interval_delete(ctx, interval);
252 rb_tree_remove(&ctx->intervals, &interval->node);
479 ir3_reg_ctx_to_file(struct ir3_reg_ctx *ctx)
481 return rb_node_data(struct ra_file, ctx, reg_ctx);
485 interval_add(struct ir3_reg_ctx *ctx, struct ir3_reg_interval *_interval)
488 struct ra_file *file = ir3_reg_ctx_to_file(ctx);
503 interval_delete(struct ir3_reg_ctx *ctx, struct ir3_reg_interval *_interval)
506 struct ra_file *file = ir3_reg_ctx_to_file(ctx);
517 interval_readd(struct ir3_reg_ctx *ctx, struct ir3_reg_interval *_parent,
530 interval_add(ctx, _child);
650 ra_ctx_dump(struct ra_ctx *ctx)
654 ra_file_dump(stream, &ctx->full);
656 ra_file_dump(stream, &ctx->half);
658 ra_file_dump(stream, &ctx->shared);
683 ra_pop_interval(struct ra_ctx *ctx, struct ra_file *file,
690 for (pcopy_index = 0; pcopy_index < ctx->parallel_copies_count;
692 if (ctx->parallel_copies[pcopy_index].interval == interval)
696 if (pcopy_index == ctx->parallel_copies_count) {
697 array_insert(ctx, ctx->parallel_copies,
713 ra_push_interval(struct ra_ctx *ctx, struct ra_file *file,
730 ra_move_interval(struct ra_ctx *ctx, struct ra_file *file,
733 struct ra_removed_interval temp = ra_pop_interval(ctx, file, interval);
734 ra_push_interval(ctx, file, &temp, dst);
738 ra_get_file(struct ra_ctx *ctx, struct ir3_register *reg)
741 return &ctx->shared;
742 else if (ctx->merged_regs || !(reg->flags & IR3_REG_HALF))
743 return &ctx->full;
745 return &ctx->half;
753 check_dst_overlap(struct ra_ctx *ctx, struct ra_file *file,
765 if (ra_get_file(ctx, other_dst) != file)
768 struct ra_interval *other_interval = &ctx->intervals[other_dst->name];
793 get_reg_specified(struct ra_ctx *ctx, struct ra_file *file,
804 check_dst_overlap(ctx, file, reg, physreg, physreg + reg_size(reg)))
816 try_evict_regs(struct ra_ctx *ctx, struct ra_file *file,
865 !check_dst_overlap(ctx, file, reg, avail_start, avail_start +
873 ra_move_interval(ctx, file, conflicting, avail_start);
912 if (check_dst_overlap(ctx, file, reg, killed->physreg_start,
934 ra_pop_interval(ctx, file, killed);
936 ra_pop_interval(ctx, file, conflicting);
937 ra_push_interval(ctx, file, &killed_removed, conflicting_start);
938 ra_push_interval(ctx, file, &conflicting_removed, killed_start);
1043 compress_regs_left(struct ra_ctx *ctx, struct ra_file *file,
1054 array_insert(ctx, dsts, reg);
1079 if (ra_get_file(ctx, other_dst) != file)
1084 struct ra_interval *other_interval = &ctx->intervals[other_dst->name];
1102 &ctx->intervals[other_dst->tied->def->name];
1111 array_insert(ctx, dsts, other_dst);
1162 array_insert(ctx, intervals, ra_pop_interval(ctx, file, interval));
1256 struct ra_interval *interval = &ctx->intervals[cur_reg->name];
1262 ra_push_interval(ctx, file, &intervals[live_index], physreg);
1286 struct ra_interval *tied_interval = &ctx->intervals[tied->def->name];
1290 struct ra_interval *dst_interval = &ctx->intervals[dst->name];
1319 find_best_gap(struct ra_ctx *ctx, struct ra_file *file,
1345 !check_dst_overlap(ctx, file, dst, candidate, candidate + size);
1371 get_reg(struct ra_ctx *ctx, struct ra_file *file, struct ir3_register *reg)
1379 get_reg_specified(ctx, file, reg, preferred_reg, false))
1390 physreg_t best_reg = find_best_gap(ctx, file, reg, file_size,
1409 if (ra_get_file(ctx, src) == file && reg_size(src) >= size) {
1410 struct ra_interval *src_interval = &ctx->intervals[src->def->name];
1414 get_reg_specified(ctx, file, reg, src_physreg, false))
1421 find_best_gap(ctx, file, reg, file_size, size, reg_elem_size(reg));
1433 if (try_evict_regs(ctx, file, reg, i, &eviction_count, false, true)) {
1443 ctx, file, reg, best_reg, &best_eviction_count, false, false);
1449 return compress_regs_left(ctx, file, reg);
1468 mark_src_killed(struct ra_ctx *ctx, struct ir3_register *src)
1470 struct ra_interval *interval = &ctx->intervals[src->def->name];
1477 ra_file_mark_killed(ra_get_file(ctx, src), interval);
1481 insert_dst(struct ra_ctx *ctx, struct ir3_register *dst)
1483 struct ra_file *file = ra_get_file(ctx, dst);
1484 struct ra_interval *interval = &ctx->intervals[dst->name];
1495 allocate_dst_fixed(struct ra_ctx *ctx, struct ir3_register *dst,
1498 struct ra_file *file = ra_get_file(ctx, dst);
1499 struct ra_interval *interval = &ctx->intervals[dst->name];
1517 insert_tied_dst_copy(struct ra_ctx *ctx, struct ir3_register *dst)
1524 struct ra_interval *tied_interval = &ctx->intervals[tied->def->name];
1525 struct ra_interval *dst_interval = &ctx->intervals[dst->name];
1532 array_insert(ctx, ctx->parallel_copies,
1540 allocate_dst(struct ra_ctx *ctx, struct ir3_register *dst)
1542 struct ra_file *file = ra_get_file(ctx, dst);
1546 struct ra_interval *tied_interval = &ctx->intervals[tied->def->name];
1551 allocate_dst_fixed(ctx, dst, ra_interval_get_physreg(tied_interval));
1557 physreg_t physreg = get_reg(ctx, file, dst);
1559 allocate_dst_fixed(ctx, dst, physreg);
1563 assign_src(struct ra_ctx *ctx, struct ir3_instruction *instr,
1566 struct ra_interval *interval = &ctx->intervals[src->def->name];
1567 struct ra_file *file = ra_get_file(ctx, src);
1572 struct ra_interval *tied_interval = &ctx->intervals[tied->name];
1588 insert_parallel_copy_instr(struct ra_ctx *ctx, struct ir3_instruction *instr)
1590 if (ctx->parallel_copies_count == 0)
1595 ctx->parallel_copies_count, ctx->parallel_copies_count);
1597 for (unsigned i = 0; i < ctx->parallel_copies_count; i++) {
1598 struct ra_parallel_copy *entry = &ctx->parallel_copies[i];
1608 for (unsigned i = 0; i < ctx->parallel_copies_count; i++) {
1609 struct ra_parallel_copy *entry = &ctx->parallel_copies[i];
1621 ctx->parallel_copies_count = 0;
1625 handle_normal_instr(struct ra_ctx *ctx, struct ir3_instruction *instr)
1629 mark_src_killed(ctx, src);
1634 insert_tied_dst_copy(ctx, dst);
1639 allocate_dst(ctx, dst);
1647 assign_src(ctx, instr, src);
1652 insert_dst(ctx, dst);
1655 insert_parallel_copy_instr(ctx, instr);
1659 handle_split(struct ra_ctx *ctx, struct ir3_instruction *instr)
1665 handle_normal_instr(ctx, instr);
1669 struct ra_interval *src_interval = &ctx->intervals[src->def->name];
1672 assign_src(ctx, instr, src);
1675 ctx, dst, physreg - src->def->merge_set_offset + dst->merge_set_offset);
1676 insert_dst(ctx, dst);
1680 handle_collect(struct ra_ctx *ctx, struct ir3_instruction *instr)
1686 handle_normal_instr(ctx, instr);
1709 mark_src_killed(ctx, src);
1712 struct ra_interval *interval = &ctx->intervals[src->def->name];
1729 ra_file_mark_killed(ra_get_file(ctx, src), interval);
1734 allocate_dst_fixed(ctx, instr->dsts[0], dst_fixed);
1736 allocate_dst(ctx, instr->dsts[0]);
1740 struct ra_interval *interval = &ctx->intervals[src->def->name];
1746 if (interval != &ctx->intervals[src->def->name] ||
1748 ra_file_unmark_killed(ra_get_file(ctx, src), interval);
1753 assign_src(ctx, instr, src);
1767 insert_parallel_copy_instr(ctx, instr);
1773 insert_dst(ctx, instr->dsts[0]);
1781 handle_pcopy(struct ra_ctx *ctx, struct ir3_instruction *instr)
1784 assign_src(ctx, instr, src);
1795 handle_precolored_input(struct ra_ctx *ctx, struct ir3_instruction *instr)
1800 struct ra_file *file = ra_get_file(ctx, instr->dsts[0]);
1801 struct ra_interval *interval = &ctx->intervals[instr->dsts[0]->name];
1803 allocate_dst_fixed(ctx, instr->dsts[0], physreg);
1813 handle_input(struct ra_ctx *ctx, struct ir3_instruction *instr)
1818 allocate_dst(ctx, instr->dsts[0]);
1820 struct ra_file *file = ra_get_file(ctx, instr->dsts[0]);
1821 struct ra_interval *interval = &ctx->intervals[instr->dsts[0]->name];
1826 assign_input(struct ra_ctx *ctx, struct ir3_instruction *instr)
1828 struct ra_interval *interval = &ctx->intervals[instr->dsts[0]->name];
1829 struct ra_file *file = ra_get_file(ctx, instr->dsts[0]);
1841 assign_src(ctx, instr, src);
1861 handle_precolored_source(struct ra_ctx *ctx, struct ir3_register *src)
1863 struct ra_file *file = ra_get_file(ctx, src);
1864 struct ra_interval *interval = &ctx->intervals[src->def->name];
1874 if (!get_reg_specified(ctx, file, src, physreg, true)) {
1876 if (!try_evict_regs(ctx, file, src, physreg, &eviction_count, true,
1883 ra_move_interval(ctx, file, interval, physreg);
1887 handle_chmask(struct ra_ctx *ctx, struct ir3_instruction *instr)
1896 handle_precolored_source(ctx, src);
1900 struct ra_file *file = ra_get_file(ctx, src);
1901 struct ra_interval *interval = &ctx->intervals[src->def->name];
1906 insert_parallel_copy_instr(ctx, instr);
1910 read_register(struct ra_ctx *ctx, struct ir3_block *block,
1913 struct ra_block_state *state = &ctx->blocks[block->index];
1925 handle_live_in(struct ra_ctx *ctx, struct ir3_register *def)
1928 for (unsigned i = 0; i < ctx->block->predecessors_count; i++) {
1929 struct ir3_block *pred = ctx->block->predecessors[i];
1930 struct ra_block_state *pred_state = &ctx->blocks[pred->index];
1935 physreg = read_register(ctx, pred, def);
1941 struct ra_interval *interval = &ctx->intervals[def->name];
1942 struct ra_file *file = ra_get_file(ctx, def);
1950 handle_live_out(struct ra_ctx *ctx, struct ir3_register *def)
1959 struct ra_block_state *state = &ctx->blocks[ctx->block->index];
1960 struct ra_interval *interval = &ctx->intervals[def->name];
1964 state->renames = _mesa_pointer_hash_table_create(ctx);
1970 handle_phi(struct ra_ctx *ctx, struct ir3_register *def)
1972 struct ra_file *file = ra_get_file(ctx, def);
1973 struct ra_interval *interval = &ctx->intervals[def->name];
1987 physreg = get_reg(ctx, file, def);
1990 allocate_dst_fixed(ctx, def, physreg);
1996 assign_phi(struct ra_ctx *ctx, struct ir3_instruction *phi)
1998 struct ra_file *file = ra_get_file(ctx, phi->dsts[0]);
1999 struct ra_interval *interval = &ctx->intervals[phi->dsts[0]->name];
2080 insert_live_in_move(struct ra_ctx *ctx, struct ra_interval *interval)
2086 shared ? ctx->block->physical_predecessors : ctx->block->predecessors;
2088 ? ctx->block->physical_predecessors_count
2089 : ctx->block->predecessors_count;
2093 struct ra_block_state *pred_state = &ctx->blocks[pred->index];
2098 physreg_t pred_reg = read_register(ctx, pred, interval->interval.reg);
2119 pred_state->renames = _mesa_pointer_hash_table_create(ctx);
2127 insert_file_live_in_moves(struct ra_ctx *ctx, struct ra_file *file)
2129 BITSET_WORD *live_in = ctx->live->live_in[ctx->block->index];
2137 insert_live_in_move(ctx, interval);
2152 insert_live_in_moves(struct ra_ctx *ctx)
2154 insert_file_live_in_moves(ctx, &ctx->full);
2155 insert_file_live_in_moves(ctx, &ctx->half);
2156 insert_file_live_in_moves(ctx, &ctx->shared);
2162 for (unsigned i = 0; i < ctx->block->predecessors_count; i++) {
2163 if (!ctx->blocks[ctx->block->predecessors[i]->index].visited) {
2170 struct ra_block_state *state = &ctx->blocks[ctx->block->index];
2171 state->entry_regs = _mesa_pointer_hash_table_create(ctx);
2173 insert_entry_regs(state, &ctx->full);
2174 insert_entry_regs(state, &ctx->half);
2175 insert_entry_regs(state, &ctx->shared);
2180 insert_live_out_move(struct ra_ctx *ctx, struct ra_interval *interval)
2183 if (!ctx->block->successors[i])
2186 struct ir3_block *succ = ctx->block->successors[i];
2187 struct ra_block_state *succ_state = &ctx->blocks[succ->index];
2199 insert_liveout_copy(ctx->block, new_reg, interval->physreg_start,
2206 insert_file_live_out_moves(struct ra_ctx *ctx, struct ra_file *file)
2210 insert_live_out_move(ctx, interval);
2215 insert_live_out_moves(struct ra_ctx *ctx)
2217 insert_file_live_out_moves(ctx, &ctx->full);
2218 insert_file_live_out_moves(ctx, &ctx->half);
2219 insert_file_live_out_moves(ctx, &ctx->shared);
2223 handle_block(struct ra_ctx *ctx, struct ir3_block *block)
2225 ctx->block = block;
2228 ra_file_init(&ctx->full);
2229 ra_file_init(&ctx->half);
2230 ra_file_init(&ctx->shared);
2247 handle_precolored_input(ctx, instr);
2253 BITSET_FOREACH_SET (name, ctx->live->live_in[block->index],
2254 ctx->live->definitions_count) {
2255 struct ir3_register *reg = ctx->live->definitions[name];
2256 handle_live_in(ctx, reg);
2261 handle_phi(ctx, instr->dsts[0]);
2264 handle_input(ctx, instr);
2274 ctx->parallel_copies_count = 0;
2276 insert_live_in_moves(ctx);
2280 ra_ctx_dump(ctx);
2290 assign_phi(ctx, instr);
2293 assign_input(ctx, instr);
2295 handle_split(ctx, instr);
2297 handle_collect(ctx, instr);
2299 handle_pcopy(ctx, instr);
2301 handle_chmask(ctx, instr);
2303 handle_normal_instr(ctx, instr);
2306 ra_ctx_dump(ctx);
2309 insert_live_out_moves(ctx);
2311 BITSET_FOREACH_SET (name, ctx->live->live_out[block->index],
2312 ctx->live->definitions_count) {
2313 struct ir3_register *reg = ctx->live->definitions[name];
2314 handle_live_out(ctx, reg);
2317 ctx->blocks[block->index].visited = true;
2359 dummy_interval_add(struct ir3_reg_ctx *ctx, struct ir3_reg_interval *interval)
2364 dummy_interval_delete(struct ir3_reg_ctx *ctx, struct ir3_reg_interval *interval)
2369 dummy_interval_readd(struct ir3_reg_ctx *ctx, struct ir3_reg_interval *parent,
2384 struct ir3_reg_ctx *ctx = ralloc(NULL, struct ir3_reg_ctx);
2386 rzalloc_array(ctx, struct ir3_reg_interval, live->definitions_count);
2388 ctx->interval_add = dummy_interval_add;
2389 ctx->interval_delete = dummy_interval_delete;
2390 ctx->interval_readd = dummy_interval_readd;
2423 rb_tree_init(&ctx->intervals);
2430 ir3_reg_interval_insert(ctx, &intervals[reg->name]);
2440 ir3_reg_interval_insert(ctx, &intervals[instr->dsts[0]->name]);
2468 ir3_reg_interval_remove(ctx, &intervals[src->def->name]);
2478 ir3_reg_interval_insert(ctx, &intervals[dst->name]);
2490 ralloc_free(ctx);
2548 struct ra_ctx *ctx = rzalloc(NULL, struct ra_ctx);
2550 ctx->merged_regs = v->mergedregs;
2551 ctx->compiler = v->compiler;
2552 ctx->stage = v->type;
2554 struct ir3_liveness *live = ir3_calc_liveness(ctx, v->ir);
2582 MAX2(limit_pressure.full, ctx->compiler->reg_size_vec4 / 2 * 16);
2610 ctx->live = live;
2611 ctx->intervals =
2612 rzalloc_array(ctx, struct ra_interval, live->definitions_count);
2613 ctx->blocks = rzalloc_array(ctx, struct ra_block_state, live->block_count);
2615 ctx->full.size = calc_target_full_pressure(v, max_pressure.full);
2616 d("full size: %u", ctx->full.size);
2619 ctx->half.size = RA_HALF_SIZE;
2621 ctx->shared.size = RA_SHARED_SIZE;
2623 ctx->full.start = ctx->half.start = ctx->shared.start = 0;
2626 handle_block(ctx, block);
2628 ir3_ra_validate(v, ctx->full.size, ctx->half.size, live->block_count);
2669 ralloc_free(ctx);
2673 ralloc_free(ctx);