mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
Compute dags as part of data flow analysis.
I want to use the live variable information when building the dags.
This commit is contained in:
parent
c358a0e77e
commit
2b2ea5c9b3
7 changed files with 27 additions and 10 deletions
|
@ -71,14 +71,16 @@ typedef struct dagnode_s {
|
|||
const char *daglabel_string (daglabel_t *label);
|
||||
struct dstring_s;
|
||||
void print_dag (struct dstring_s *dstr, dagnode_t *node);
|
||||
struct sblock_s;
|
||||
struct flownode_s;
|
||||
|
||||
/** Make a dag for a single basic block.
|
||||
|
||||
\param block The basic block for which the dag will be created.
|
||||
\param node The flow graph node representing the basic block for which
|
||||
the dag will be created. The node should have its live
|
||||
variable information already computed.
|
||||
\return The dag representing the basic block.
|
||||
*/
|
||||
dagnode_t *dag_create (const struct sblock_s *block);
|
||||
dagnode_t *dag_create (const struct flownode_s *node);
|
||||
|
||||
//@}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct flownode_s {
|
|||
struct set_s *out;
|
||||
} live_vars;
|
||||
struct sblock_s *sblock; ///< original statement block
|
||||
struct dagnode_s *dag; ///< dag for this node
|
||||
} flownode_t;
|
||||
|
||||
typedef struct flowgraph_s {
|
||||
|
|
|
@ -75,7 +75,6 @@ typedef struct sblock_s {
|
|||
struct sblock_s *next;
|
||||
struct reloc_s *relocs;
|
||||
struct ex_label_s *labels;
|
||||
struct dagnode_s *dag;
|
||||
int offset; ///< offset of first statement of block
|
||||
int reachable;
|
||||
int number; ///< number of this block in flow graph
|
||||
|
|
|
@ -264,8 +264,9 @@ daglabel_detatch (daglabel_t *l)
|
|||
}
|
||||
|
||||
dagnode_t *
|
||||
dag_create (const sblock_t *block)
|
||||
dag_create (const flownode_t *flownode)
|
||||
{
|
||||
sblock_t *block = flownode->sblock;
|
||||
statement_t *s;
|
||||
dagnode_t *dagnodes = 0;
|
||||
dagnode_t **dagtail = &dagnodes;
|
||||
|
|
|
@ -88,6 +88,10 @@ print_flow_node (dstring_t *dstr, flowgraph_t *graph, flownode_t *node,
|
|||
indent -= 2;
|
||||
dasprintf (dstr, "%*s}\n", indent, "");
|
||||
}
|
||||
if (node->dag) {
|
||||
dasprintf (dstr, " fn_%p -> dagnode_%p;", node, node->dag);
|
||||
print_dag (dstr, node->dag);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -73,10 +73,6 @@ flow_sblock (dstring_t *dstr, sblock_t *sblock, int blockno)
|
|||
sblock_t **target_list;
|
||||
ex_label_t *l;
|
||||
|
||||
if (sblock->dag) {
|
||||
dasprintf (dstr, " sb_%p -> dagnode_%p;", sblock, sblock->dag);
|
||||
print_dag (dstr, sblock->dag);
|
||||
}
|
||||
dasprintf (dstr, " sb_%p [shape=none,label=<\n", sblock);
|
||||
dasprintf (dstr, " <table border=\"0\" cellborder=\"1\" "
|
||||
"cellspacing=\"0\">\n");
|
||||
|
|
|
@ -250,7 +250,6 @@ flow_build_vars (function_t *func)
|
|||
for (sblock = func->sblock; sblock; sblock = sblock->next) {
|
||||
for (s = sblock->statements; s; s = s->next)
|
||||
func->statements[s->number] = s;
|
||||
sblock->dag = dag_create (sblock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,6 +322,20 @@ flow_live_vars (flowgraph_t *graph)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
flow_build_dags (flowgraph_t *graph)
|
||||
{
|
||||
int i;
|
||||
flownode_t *node;
|
||||
|
||||
for (i = 0; i < graph->num_nodes; i++) {
|
||||
node = graph->nodes[i];
|
||||
node->dag = dag_create (node);
|
||||
}
|
||||
//if (options.block_dot.dags)
|
||||
// dump_dot ("dags", graph, dump_dot_flow);
|
||||
}
|
||||
|
||||
void
|
||||
flow_data_flow (flowgraph_t *graph)
|
||||
{
|
||||
|
@ -344,6 +357,7 @@ flow_data_flow (flowgraph_t *graph)
|
|||
}
|
||||
}
|
||||
flow_live_vars (graph);
|
||||
flow_build_dags (graph);
|
||||
if (options.block_dot.flow)
|
||||
dump_dot ("flow", graph, dump_dot_flow);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue