2 * Copyright (C) 2019 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * Authors (Collabora):
24 * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
36 /* Word boundary where vectors can't cross */
39 /* Alignment for node in log2(bytes)+1. Since alignment must be
40 * non-negative power-of-two, the elements are strictly positive
41 * integers. Zero is the sentinel for a missing node */
44 /* Linear constraints imposed. Nested array sized upfront, organized as
45 * linear[node_left][node_right]. That is, calculate indices as:
47 * Each element is itself a bit field denoting whether (c_j - c_i) bias
48 * is present or not, including negative biases.
50 * Note for Midgard, there are 16 components so the bias is in range
51 * [-15, 15] so encoded by 32-bit field. */
55 /* Per node max modulus constraints */
58 /* Classes allow nodes to be partitioned with a starting register.
59 * Classes cannot interfere; that is, they are true partitions in the
60 * usual sense of the word. class_count is the number of classes.
61 * class[] is indexed by a node to get the mapped class. class_start is
62 * biased to all solutions in the class. */
66 unsigned *class_start
;
70 /* Before solving, forced registers; after solving, solutions. */
73 /* For register spilling, the costs to spill nodes (as set by the user)
74 * are in spill_cost[], negative if a node is unspillable. Internally,
75 * spill_class specifies which class to spill (whichever class failed
85 unsigned min_alignment
, unsigned max_alignment
,
86 unsigned bound
, unsigned class_count
);
89 lcra_free(struct lcra_state
*l
);
92 lcra_set_disjoint_class(struct lcra_state
*l
, unsigned c1
, unsigned c2
);
95 lcra_set_alignment(struct lcra_state
*l
, unsigned node
, unsigned align_log2
);
98 lcra_restrict_range(struct lcra_state
*l
, unsigned node
, unsigned len
);
101 lcra_add_node_interference(struct lcra_state
*l
, unsigned i
, unsigned cmask_i
, unsigned j
, unsigned cmask_j
);
104 lcra_solve(struct lcra_state
*l
);
107 lcra_set_node_spill_cost(struct lcra_state
*l
, unsigned node
, signed cost
);
110 lcra_get_best_spill_node(struct lcra_state
*l
);