Lines Matching refs:l
46 struct lcra_state *l = calloc(1, sizeof(*l)); in lcra_alloc_equations() local
48 l->node_count = node_count; in lcra_alloc_equations()
49 l->class_count = class_count; in lcra_alloc_equations()
51 l->alignment = calloc(sizeof(l->alignment[0]), node_count); in lcra_alloc_equations()
52 l->linear = calloc(sizeof(l->linear[0]), node_count * node_count); in lcra_alloc_equations()
53 l->modulus = calloc(sizeof(l->modulus[0]), node_count); in lcra_alloc_equations()
54 l->class = calloc(sizeof(l->class[0]), node_count); in lcra_alloc_equations()
55 l->class_start = calloc(sizeof(l->class_start[0]), class_count); in lcra_alloc_equations()
56 l->class_disjoint = calloc(sizeof(l->class_disjoint[0]), class_count * class_count); in lcra_alloc_equations()
57 l->class_size = calloc(sizeof(l->class_size[0]), class_count); in lcra_alloc_equations()
58 l->spill_cost = calloc(sizeof(l->spill_cost[0]), node_count); in lcra_alloc_equations()
59 l->solutions = calloc(sizeof(l->solutions[0]), node_count); in lcra_alloc_equations()
61 memset(l->solutions, ~0, sizeof(l->solutions[0]) * node_count); in lcra_alloc_equations()
63 return l; in lcra_alloc_equations()
67 lcra_free(struct lcra_state *l) in lcra_free() argument
69 if (!l) in lcra_free()
72 free(l->alignment); in lcra_free()
73 free(l->linear); in lcra_free()
74 free(l->modulus); in lcra_free()
75 free(l->class); in lcra_free()
76 free(l->class_start); in lcra_free()
77 free(l->class_disjoint); in lcra_free()
78 free(l->class_size); in lcra_free()
79 free(l->spill_cost); in lcra_free()
80 free(l->solutions); in lcra_free()
82 free(l); in lcra_free()
86 lcra_set_alignment(struct lcra_state *l, unsigned node, unsigned align_log2, unsigned bound) in lcra_set_alignment() argument
88 l->alignment[node] = (align_log2 + 1) | (bound << 16); in lcra_set_alignment()
92 lcra_set_disjoint_class(struct lcra_state *l, unsigned c1, unsigned c2) in lcra_set_disjoint_class() argument
94 l->class_disjoint[(c1 * l->class_count) + c2] = true; in lcra_set_disjoint_class()
95 l->class_disjoint[(c2 * l->class_count) + c1] = true; in lcra_set_disjoint_class()
99 lcra_restrict_range(struct lcra_state *l, unsigned node, unsigned len) in lcra_restrict_range() argument
101 if (node < l->node_count && l->alignment[node]) { in lcra_restrict_range()
102 unsigned BA = l->alignment[node]; in lcra_restrict_range()
105 l->modulus[node] = DIV_ROUND_UP(bound - len + 1, 1 << alignment); in lcra_restrict_range()
110 lcra_add_node_interference(struct lcra_state *l, unsigned i, unsigned cmask_i, unsigned j, unsigned… in lcra_add_node_interference() argument
115 if (l->class_disjoint[(l->class[i] * l->class_count) + l->class[j]]) in lcra_add_node_interference()
133 l->linear[j * l->node_count + i] |= constraint_fw; in lcra_add_node_interference()
134 l->linear[i * l->node_count + j] |= constraint_bw; in lcra_add_node_interference()
138 lcra_test_linear(struct lcra_state *l, unsigned *solutions, unsigned i) in lcra_test_linear() argument
140 unsigned *row = &l->linear[i * l->node_count]; in lcra_test_linear()
143 for (unsigned j = 0; j < l->node_count; ++j) { in lcra_test_linear()
159 lcra_solve(struct lcra_state *l) in lcra_solve() argument
161 for (unsigned step = 0; step < l->node_count; ++step) { in lcra_solve()
162 if (l->solutions[step] != ~0) continue; in lcra_solve()
163 if (l->alignment[step] == 0) continue; in lcra_solve()
165 unsigned _class = l->class[step]; in lcra_solve()
166 unsigned class_start = l->class_start[_class]; in lcra_solve()
168 unsigned BA = l->alignment[step]; in lcra_solve()
173 unsigned Q = l->modulus[step]; in lcra_solve()
174 unsigned r_max = l->class_size[_class]; in lcra_solve()
181 l->solutions[step] = ((m * P + n) << shift) + class_start; in lcra_solve()
182 succ = lcra_test_linear(l, l->solutions, step); in lcra_solve()
192 l->spill_class = l->class[step]; in lcra_solve()
204 lcra_set_node_spill_cost(struct lcra_state *l, unsigned node, signed cost) in lcra_set_node_spill_cost() argument
206 if (node < l->node_count) in lcra_set_node_spill_cost()
207 l->spill_cost[node] = cost; in lcra_set_node_spill_cost()
213 lcra_count_constraints(struct lcra_state *l, unsigned i) in lcra_count_constraints() argument
216 unsigned *constraints = &l->linear[i * l->node_count]; in lcra_count_constraints()
225 lcra_get_best_spill_node(struct lcra_state *l) in lcra_get_best_spill_node() argument
230 for (unsigned i = 0; i < l->node_count; ++i) { in lcra_get_best_spill_node()
232 if (l->class[i] != l->spill_class) continue; in lcra_get_best_spill_node()
233 if (l->spill_cost[i] < 0) continue; in lcra_get_best_spill_node()
236 float constraints = lcra_count_constraints(l, i); in lcra_get_best_spill_node()
237 float cost = (l->spill_cost[i] + 1); in lcra_get_best_spill_node()