mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Factor out the live vars magic from dag_create.
The code is messy enough as it is :P
This commit is contained in:
parent
06a62be1d5
commit
1472fec7f2
1 changed files with 27 additions and 22 deletions
|
@ -328,6 +328,31 @@ dag_sort_nodes (dag_t *dag)
|
|||
set_delete (visited);
|
||||
}
|
||||
|
||||
static void
|
||||
dag_set_live_vars (set_t *live_vars, dag_t *dag, dagnode_t *n)
|
||||
{
|
||||
if (!strncmp (n->label->opcode, "<CALL", 5)
|
||||
|| !strncmp (n->label->opcode, "<RCALL", 6)) {
|
||||
int start, end;
|
||||
|
||||
if (!strncmp (n->label->opcode, "<CALL", 5)) {
|
||||
start = 0;
|
||||
end = 0;
|
||||
if (n->label->opcode[5] != '>')
|
||||
end = n->label->opcode[5] - '0';
|
||||
} else {
|
||||
start = 2;
|
||||
end = n->label->opcode[6] - '0';
|
||||
}
|
||||
while (start < end) {
|
||||
set_add (live_vars, start + 1);
|
||||
start++;
|
||||
}
|
||||
} else if (!strncmp (n->label->opcode, "<RETURN", 7)) {
|
||||
set_union (live_vars, dag->flownode->global_vars);
|
||||
}
|
||||
}
|
||||
|
||||
dag_t *
|
||||
dag_create (flownode_t *flownode)
|
||||
{
|
||||
|
@ -407,28 +432,8 @@ dag_create (flownode_t *flownode)
|
|||
lx->expr = s->expr;
|
||||
dagnode_attach_label (n, lx);
|
||||
}
|
||||
if (n->type == st_func) {
|
||||
if (!strncmp (n->label->opcode, "<CALL", 5)
|
||||
|| !strncmp (n->label->opcode, "<RCALL", 6)) {
|
||||
int start, end;
|
||||
|
||||
if (!strncmp (n->label->opcode, "<CALL", 5)) {
|
||||
start = 0;
|
||||
end = 0;
|
||||
if (n->label->opcode[5] != '>')
|
||||
end = n->label->opcode[5] - '0';
|
||||
} else {
|
||||
start = 2;
|
||||
end = n->label->opcode[6] - '0';
|
||||
}
|
||||
while (start < end) {
|
||||
set_add (live_vars, start + 1);
|
||||
start++;
|
||||
}
|
||||
} else if (!strncmp (n->label->opcode, "<RETURN", 7)) {
|
||||
set_union (live_vars, flownode->global_vars);
|
||||
}
|
||||
}
|
||||
if (n->type == st_func)
|
||||
dag_set_live_vars (live_vars, dag, n);
|
||||
}
|
||||
|
||||
nodes = malloc (dag->num_nodes * sizeof (dagnode_t *));
|
||||
|
|
Loading…
Reference in a new issue