• Home
  • Raw
  • Download

Lines Matching refs:regs

95    struct ra_regs *regs;  in ra_alloc_reg_set()  local
97 regs = rzalloc(mem_ctx, struct ra_regs); in ra_alloc_reg_set()
98 regs->count = count; in ra_alloc_reg_set()
99 regs->regs = rzalloc_array(regs, struct ra_reg, count); in ra_alloc_reg_set()
102 regs->regs[i].conflicts = rzalloc_array(regs->regs, BITSET_WORD, in ra_alloc_reg_set()
104 BITSET_SET(regs->regs[i].conflicts, i); in ra_alloc_reg_set()
106 util_dynarray_init(&regs->regs[i].conflict_list, in ra_alloc_reg_set()
107 need_conflict_lists ? regs->regs : NULL); in ra_alloc_reg_set()
109 util_dynarray_append(&regs->regs[i].conflict_list, unsigned int, i); in ra_alloc_reg_set()
112 return regs; in ra_alloc_reg_set()
126 ra_set_allocate_round_robin(struct ra_regs *regs) in ra_set_allocate_round_robin() argument
128 regs->round_robin = true; in ra_set_allocate_round_robin()
132 ra_add_conflict_list(struct ra_regs *regs, unsigned int r1, unsigned int r2) in ra_add_conflict_list() argument
134 struct ra_reg *reg1 = &regs->regs[r1]; in ra_add_conflict_list()
143 ra_add_reg_conflict(struct ra_regs *regs, unsigned int r1, unsigned int r2) in ra_add_reg_conflict() argument
145 if (!BITSET_TEST(regs->regs[r1].conflicts, r2)) { in ra_add_reg_conflict()
146 ra_add_conflict_list(regs, r1, r2); in ra_add_reg_conflict()
147 ra_add_conflict_list(regs, r2, r1); in ra_add_reg_conflict()
160 ra_add_transitive_reg_conflict(struct ra_regs *regs, in ra_add_transitive_reg_conflict() argument
163 ra_add_reg_conflict(regs, reg, base_reg); in ra_add_transitive_reg_conflict()
165 util_dynarray_foreach(&regs->regs[base_reg].conflict_list, unsigned int, in ra_add_transitive_reg_conflict()
167 ra_add_reg_conflict(regs, reg, *r2p); in ra_add_transitive_reg_conflict()
179 ra_add_transitive_reg_pair_conflict(struct ra_regs *regs, in ra_add_transitive_reg_pair_conflict() argument
182 ra_add_reg_conflict(regs, reg0, base_reg); in ra_add_transitive_reg_pair_conflict()
183 ra_add_reg_conflict(regs, reg1, base_reg); in ra_add_transitive_reg_pair_conflict()
185 util_dynarray_foreach(&regs->regs[base_reg].conflict_list, unsigned int, i) { in ra_add_transitive_reg_pair_conflict()
188 ra_add_reg_conflict(regs, reg0, conflict); in ra_add_transitive_reg_pair_conflict()
190 ra_add_reg_conflict(regs, reg1, conflict); in ra_add_transitive_reg_pair_conflict()
204 ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int r) in ra_make_reg_conflicts_transitive() argument
206 struct ra_reg *reg = &regs->regs[r]; in ra_make_reg_conflicts_transitive()
209 BITSET_FOREACH_SET(c, reg->conflicts, regs->count) { in ra_make_reg_conflicts_transitive()
210 struct ra_reg *other = &regs->regs[c]; in ra_make_reg_conflicts_transitive()
212 for (i = 0; i < BITSET_WORDS(regs->count); i++) in ra_make_reg_conflicts_transitive()
218 ra_alloc_reg_class(struct ra_regs *regs) in ra_alloc_reg_class() argument
222 regs->classes = reralloc(regs->regs, regs->classes, struct ra_class *, in ra_alloc_reg_class()
223 regs->class_count + 1); in ra_alloc_reg_class()
225 class = rzalloc(regs, struct ra_class); in ra_alloc_reg_class()
226 class->regset = regs; in ra_alloc_reg_class()
229 class->index = regs->class_count++; in ra_alloc_reg_class()
230 regs->classes[class->index] = class; in ra_alloc_reg_class()
232 class->regs = rzalloc_array(class, BITSET_WORD, BITSET_WORDS(regs->count)); in ra_alloc_reg_class()
245 ra_alloc_contig_reg_class(struct ra_regs *regs, int contig_len) in ra_alloc_contig_reg_class() argument
247 struct ra_class *c = ra_alloc_reg_class(regs); in ra_alloc_contig_reg_class()
256 ra_get_class_from_index(struct ra_regs *regs, unsigned int class) in ra_get_class_from_index() argument
258 return regs->classes[class]; in ra_get_class_from_index()
273 BITSET_SET(class->regs, r); in ra_class_add_reg()
283 return BITSET_TEST(c->regs, r); in reg_belongs_to_class()
293 ra_set_finalize(struct ra_regs *regs, unsigned int **q_values) in ra_set_finalize() argument
297 for (b = 0; b < regs->class_count; b++) { in ra_set_finalize()
298 regs->classes[b]->q = ralloc_array(regs, unsigned int, regs->class_count); in ra_set_finalize()
302 for (b = 0; b < regs->class_count; b++) { in ra_set_finalize()
303 for (c = 0; c < regs->class_count; c++) { in ra_set_finalize()
304 regs->classes[b]->q[c] = q_values[b][c]; in ra_set_finalize()
311 for (b = 0; b < regs->class_count; b++) { in ra_set_finalize()
312 for (c = 0; c < regs->class_count; c++) { in ra_set_finalize()
313 struct ra_class *class_b = regs->classes[b]; in ra_set_finalize()
314 struct ra_class *class_c = regs->classes[c]; in ra_set_finalize()
323 for (int i = 0; i < BITSET_WORDS(regs->count); i++) { in ra_set_finalize()
324 if (class_b->regs[i] & class_c->regs[i]) { in ra_set_finalize()
334 BITSET_FOREACH_SET(rc, regs->classes[c]->regs, regs->count) { in ra_set_finalize()
336 int end = MIN2(regs->count, rc + class_c->contig_len); in ra_set_finalize()
339 if (BITSET_TEST(class_b->regs, i)) in ra_set_finalize()
361 BITSET_FOREACH_SET(rc, regs->classes[c]->regs, regs->count) { in ra_set_finalize()
364 util_dynarray_foreach(&regs->regs[rc].conflict_list, in ra_set_finalize()
367 if (reg_belongs_to_class(rb, regs->classes[b])) in ra_set_finalize()
372 regs->classes[b]->q[c] = max_conflicts; in ra_set_finalize()
378 for (b = 0; b < regs->count; b++) { in ra_set_finalize()
379 util_dynarray_fini(&regs->regs[b].conflict_list); in ra_set_finalize()
383 for (int c = 0; c < regs->class_count; c++) in ra_set_finalize()
384 all_contig &= regs->classes[c]->contig_len != 0; in ra_set_finalize()
390 for (int i = 0; i < regs->count; i++) { in ra_set_finalize()
391 ralloc_free(regs->regs[i].conflicts); in ra_set_finalize()
392 regs->regs[i].conflicts = NULL; in ra_set_finalize()
398 ra_set_serialize(const struct ra_regs *regs, struct blob *blob) in ra_set_serialize() argument
400 blob_write_uint32(blob, regs->count); in ra_set_serialize()
401 blob_write_uint32(blob, regs->class_count); in ra_set_serialize()
403 bool is_contig = regs->classes[0]->contig_len != 0; in ra_set_serialize()
407 for (unsigned int r = 0; r < regs->count; r++) { in ra_set_serialize()
408 struct ra_reg *reg = &regs->regs[r]; in ra_set_serialize()
409 blob_write_bytes(blob, reg->conflicts, BITSET_WORDS(regs->count) * in ra_set_serialize()
415 for (unsigned int c = 0; c < regs->class_count; c++) { in ra_set_serialize()
416 struct ra_class *class = regs->classes[c]; in ra_set_serialize()
417 blob_write_bytes(blob, class->regs, BITSET_WORDS(regs->count) * in ra_set_serialize()
421 blob_write_bytes(blob, class->q, regs->class_count * sizeof(*class->q)); in ra_set_serialize()
424 blob_write_uint32(blob, regs->round_robin); in ra_set_serialize()
434 struct ra_regs *regs = ra_alloc_reg_set(mem_ctx, reg_count, false); in ra_set_deserialize() local
435 assert(regs->count == reg_count); in ra_set_deserialize()
438 for (int i = 0; i < regs->count; i++) { in ra_set_deserialize()
439 ralloc_free(regs->regs[i].conflicts); in ra_set_deserialize()
440 regs->regs[i].conflicts = NULL; in ra_set_deserialize()
444 struct ra_reg *reg = &regs->regs[r]; in ra_set_deserialize()
450 assert(regs->classes == NULL); in ra_set_deserialize()
451 regs->classes = ralloc_array(regs->regs, struct ra_class *, class_count); in ra_set_deserialize()
452 regs->class_count = class_count; in ra_set_deserialize()
455 struct ra_class *class = rzalloc(regs, struct ra_class); in ra_set_deserialize()
456 regs->classes[c] = class; in ra_set_deserialize()
457 class->regset = regs; in ra_set_deserialize()
460 class->regs = ralloc_array(class, BITSET_WORD, BITSET_WORDS(reg_count)); in ra_set_deserialize()
461 blob_copy_bytes(blob, class->regs, BITSET_WORDS(reg_count) * in ra_set_deserialize()
467 class->q = ralloc_array(regs->classes[c], unsigned int, class_count); in ra_set_deserialize()
471 regs->round_robin = blob_read_uint32(blob); in ra_set_deserialize()
473 return regs; in ra_set_deserialize()
485 g->nodes[n1].q_total += g->regs->classes[n1_class]->q[n2_class]; in ra_add_node_adjacency()
499 g->nodes[n1].q_total -= g->regs->classes[n1_class]->q[n2_class]; in ra_node_remove_adjacency()
557 ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count) in ra_alloc_interference_graph() argument
562 g->regs = regs; in ra_alloc_interference_graph()
596 return g->regs->classes[g->nodes[n].class]; in ra_get_node_class()
638 if (g->nodes[n].tmp.q_total < g->regs->classes[n_class]->p) { in update_pq_info()
669 assert(g->nodes[n2].tmp.q_total >= g->regs->classes[n2_class]->q[n_class]); in add_node_to_stack()
670 g->nodes[n2].tmp.q_total -= g->regs->classes[n2_class]->q[n_class]; in add_node_to_stack()
805 return BITSET_TEST(c1->regset->regs[r1].conflicts, r2); in ra_class_allocations_conflict()
817 ra_class_allocations_conflict(g->regs->classes[g->nodes[n].class], r, in ra_find_conflicting_neighbor()
818 g->regs->classes[g->nodes[n2].class], g->nodes[n2].reg)) { in ra_find_conflicting_neighbor()
833 ra_compute_available_regs(struct ra_graph *g, unsigned int n, BITSET_WORD *regs) in ra_compute_available_regs() argument
835 struct ra_class *c = g->regs->classes[g->nodes[n].class]; in ra_compute_available_regs()
838 memcpy(regs, c->regs, BITSET_WORDS(g->regs->count) * sizeof(BITSET_WORD)); in ra_compute_available_regs()
845 struct ra_class *n2c = g->regs->classes[n2->class]; in ra_compute_available_regs()
850 int end = MIN2(g->regs->count, n2->reg + n2c->contig_len); in ra_compute_available_regs()
852 BITSET_CLEAR(regs, i); in ra_compute_available_regs()
854 for (int j = 0; j < BITSET_WORDS(g->regs->count); j++) in ra_compute_available_regs()
855 regs[j] &= ~g->regs->regs[n2->reg].conflicts[j]; in ra_compute_available_regs()
860 for (int i = 0; i < BITSET_WORDS(g->regs->count); i++) { in ra_compute_available_regs()
861 if (regs[i]) in ra_compute_available_regs()
882 select_regs = malloc(BITSET_WORDS(g->regs->count) * sizeof(BITSET_WORD)); in ra_select()
888 struct ra_class *c = g->regs->classes[g->nodes[n].class]; in ra_select()
902 assert(r < g->regs->count); in ra_select()
907 for (ri = 0; ri < g->regs->count; ri++) { in ra_select()
908 r = (start_search_reg + ri) % g->regs->count; in ra_select()
917 if (g->regs->classes[conflicting->class]->contig_len) { in ra_select()
923 g->regs->classes[conflicting->class]->contig_len - 1); in ra_select()
929 if (ri >= g->regs->count) in ra_select()
945 if (g->regs->round_robin && in ra_select()
1004 benefit += ((float)g->regs->classes[n_class]->q[n2_class] / in ra_get_spill_benefit()
1005 g->regs->classes[n_class]->p); in ra_get_spill_benefit()