From 9752e3725eb983a735721c79a11812da6ab37361 Mon Sep 17 00:00:00 2001 From: Gernot Veit Batz Date: Mon, 10 Oct 2005 13:42:30 +0000 Subject: [PATCH] added two more hooks to the ir graph dumper [r6668] --- ir/ir/irdump.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++-- ir/ir/irdump.h | 14 ++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index d53a9c710..722b91c0b 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -105,13 +105,25 @@ DUMP_NODE_EDGE_FUNC get_dump_node_edge_hook(void) } -/** The vcg attribute hook. */ +/** The vcg node attribute hook. */ +static DUMP_IR_GRAPH_FUNC dump_ir_graph_hook = NULL; +/** The vcg node attribute hook. */ static DUMP_NODE_VCGATTR_FUNC dump_node_vcgattr_hook = NULL; +/** The vcg edge attribute hook. */ +static DUMP_EDGE_VCGATTR_FUNC dump_edge_vcgattr_hook = NULL; -/* set the hook */ +/* set the ir graph hook */ +void set_dump_ir_graph_hook(DUMP_IR_GRAPH_FUNC hook) { + dump_ir_graph_hook = hook; +} +/* set the node attribute hook */ void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook) { dump_node_vcgattr_hook = hook; } +/* set the edge attribute hook */ +void set_dump_edge_vcgattr_hook(DUMP_EDGE_VCGATTR_FUNC hook) { + dump_edge_vcgattr_hook = hook; +} INLINE bool get_opt_dump_const_local(void) { if (!dump_out_edge_flag && !dump_loop_information_flag) @@ -1073,6 +1085,19 @@ static void dump_const_block_local(FILE *F, ir_node *n) { fprintf (F, "edge: { sourcename: \""); PRINT_NODEID(n); fprintf (F, "\" targetname: \""); PRINT_CONSTBLKID(n,blk); + + if (dump_edge_vcgattr_hook) { + fprintf (F, "\" "); + if (dump_edge_vcgattr_hook(F, n, -1)) { + fprintf (F, "}\n"); + return; + } + else { + fprintf (F, " " BLOCK_EDGE_ATTR "}\n"); + return; + } + } + fprintf (F, "\" " BLOCK_EDGE_ATTR "}\n"); } } @@ -1151,6 +1176,19 @@ dump_ir_block_edge(FILE *F, ir_node *n) { PRINT_NODEID(n); fprintf (F, "\" targetname: "); fprintf(F, "\""); PRINT_NODEID(block); fprintf(F, "\""); + + if (dump_edge_vcgattr_hook) { + fprintf (F, " "); + if (dump_edge_vcgattr_hook(F, n, -1)) { + fprintf (F, "}\n"); + return; + } + else { + fprintf (F, " " BLOCK_EDGE_ATTR "}\n"); + return; + } + } + fprintf (F, " " BLOCK_EDGE_ATTR "}\n"); } } @@ -1184,6 +1222,10 @@ static void print_edge_vcgattr(FILE *F, ir_node *from, int to) { assert(from); + if (dump_edge_vcgattr_hook) + if (dump_edge_vcgattr_hook(F, from, to)) + return; + if (dump_backedge_information_flag && is_backedge(from, to)) fprintf (F, BACK_EDGE_ATTR); @@ -2197,6 +2239,11 @@ dump_ir_graph (ir_graph *irg, const char *suffix ) f = vcg_open(irg, suffix, suffix1); dump_vcg_header(f, get_irg_dump_name(irg), NULL); + /* call the dump graph hook */ + if (dump_ir_graph_hook) + if (dump_ir_graph_hook(f, irg)) + return; + /* walk over the graph */ /* dump_whole_node must be called in post visiting predecessors */ irg_walk(get_irg_end(irg), NULL, dump_whole_node, f); diff --git a/ir/ir/irdump.h b/ir/ir/irdump.h index be72fbd2c..2e03d27f1 100644 --- a/ir/ir/irdump.h +++ b/ir/ir/irdump.h @@ -42,15 +42,29 @@ /* GRAPH DUMPERS */ /* **************************************************************************** */ +/** + * This hook is called to insert some special nodes into dumped graph + */ +typedef int (*DUMP_IR_GRAPH_FUNC)(FILE *F, ir_graph *irg); /** * This hook is called to dump the vcg attributes of a node to a file. * If this function returns zero, the default attributes are added, else * removed. */ typedef int (*DUMP_NODE_VCGATTR_FUNC)(FILE *F, ir_node *node, ir_node *local); +/** + * This hook is called to dump the vcg attributes of an edge to a file. + * If this function returns zero, the default attributes are added, else + * removed. + */ +typedef int (*DUMP_EDGE_VCGATTR_FUNC)(FILE *F, ir_node *node, int to); +/** Set the ir graph dump hook. */ +void set_dump_ir_graph_hook(DUMP_IR_GRAPH_FUNC hook); /** Set the node_vcgattr hook. */ void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook); +/** Set the edge_vcgattr hook. */ +void set_dump_edge_vcgattr_hook(DUMP_EDGE_VCGATTR_FUNC hook); typedef int (*DUMP_NODE_EDGE_FUNC)(FILE *f, ir_node *node); -- 2.20.1