vc4->reg_class_any = ra_alloc_reg_class(vc4->regs);
for (uint32_t i = 0; i < ARRAY_SIZE(vc4_regs); i++) {
- /* Reserve rb31 for spilling fixup_raddr_conflict() in
+ /* Reserve ra31/rb31 for spilling fixup_raddr_conflict() in
* vc4_qpu_emit.c
*/
- if (vc4_regs[i].mux == QPU_MUX_B && vc4_regs[i].addr == 31)
+ if (vc4_regs[i].addr == 31)
continue;
/* R4 can't be written as a general purpose register. (it's
struct qpu_reg *
vc4_register_allocate(struct vc4_context *vc4, struct vc4_compile *c)
{
- struct simple_node *node;
struct node_to_temp_map map[c->num_temps];
uint32_t temp_to_node[c->num_temps];
uint32_t def[c->num_temps];
/* Compute the live ranges so we can figure out interference.
*/
uint32_t ip = 0;
- foreach(node, &c->instructions) {
- struct qinst *inst = (struct qinst *)node;
-
+ list_for_each_entry(struct qinst, inst, &c->instructions, link) {
if (inst->dst.file == QFILE_TEMP) {
def[inst->dst.index] = ip;
use[inst->dst.index] = ip;
}
/* Figure out our register classes and preallocated registers*/
- foreach(node, &c->instructions) {
- struct qinst *inst = (struct qinst *)node;
-
+ list_for_each_entry(struct qinst, inst, &c->instructions, link) {
switch (inst->op) {
case QOP_FRAG_Z:
ra_set_node_reg(g, temp_to_node[inst->dst.index],
vc4->reg_class_a);
break;
- case QOP_UNPACK_8A_F:
- case QOP_UNPACK_8B_F:
- case QOP_UNPACK_8C_F:
- case QOP_UNPACK_8D_F:
- case QOP_UNPACK_8A_I:
- case QOP_UNPACK_8B_I:
- case QOP_UNPACK_8C_I:
- case QOP_UNPACK_8D_I:
- /* The unpack flags require an A-file src register. */
- ra_set_node_class(g, temp_to_node[inst->src[0].index],
- vc4->reg_class_a);
- break;
-
default:
break;
}
+
+ if (qir_src_needs_a_file(inst)) {
+ ra_set_node_class(g, temp_to_node[inst->src[0].index],
+ vc4->reg_class_a);
+ }
}
for (uint32_t i = 0; i < c->num_temps; i++) {
}
bool ok = ra_allocate(g);
- assert(ok);
+ if (!ok) {
+ fprintf(stderr, "Failed to register allocate:\n");
+ qir_dump(c);
+ abort();
+ }
for (uint32_t i = 0; i < c->num_temps; i++) {
temp_registers[i] = vc4_regs[ra_get_node_reg(g, temp_to_node[i])];