mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader/ir: Dump the control flow graph in the GraphViz format.
This commit is contained in:
parent
da037b61ba
commit
2573d86ccf
Notes:
Alexandre Julliard
2024-02-22 23:03:31 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Conor McCarthy (@cmccarthy) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/656
@ -3106,6 +3106,43 @@ static enum vkd3d_result vsir_cfg_add_edge(struct vsir_cfg *cfg, struct vsir_blo
|
||||
return VKD3D_OK;
|
||||
}
|
||||
|
||||
static void vsir_cfg_dump_dot(struct vsir_cfg *cfg)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
TRACE("digraph cfg {\n");
|
||||
|
||||
for (i = 0; i < cfg->block_count; ++i)
|
||||
{
|
||||
struct vsir_block *block = &cfg->blocks[i];
|
||||
const char *shape;
|
||||
|
||||
if (block->label == 0)
|
||||
continue;
|
||||
|
||||
switch (block->end->handler_idx)
|
||||
{
|
||||
case VKD3DSIH_RET:
|
||||
shape = "trapezium";
|
||||
break;
|
||||
|
||||
case VKD3DSIH_BRANCH:
|
||||
shape = vsir_register_is_label(&block->end->src[0].reg) ? "ellipse" : "box";
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
TRACE(" n%u [label=\"%u\", shape=\"%s\"];\n", block->label, block->label, shape);
|
||||
|
||||
for (j = 0; j < block->successors.count; ++j)
|
||||
TRACE(" n%u -> n%u;\n", block->label, block->successors.blocks[j]->label);
|
||||
}
|
||||
|
||||
TRACE("}\n");
|
||||
}
|
||||
|
||||
static enum vkd3d_result vsir_cfg_init(struct vsir_cfg *cfg, struct vsir_program *program)
|
||||
{
|
||||
struct vsir_block *current_block = NULL;
|
||||
@ -3189,6 +3226,9 @@ static enum vkd3d_result vsir_cfg_init(struct vsir_cfg *cfg, struct vsir_program
|
||||
}
|
||||
}
|
||||
|
||||
if (TRACE_ON())
|
||||
vsir_cfg_dump_dot(cfg);
|
||||
|
||||
return VKD3D_OK;
|
||||
|
||||
fail:
|
||||
|
Loading…
Reference in New Issue
Block a user