From 1bc4ca76e9b5c33e84992ff322d3b72f126992c6 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Fri, 28 Oct 2005 12:00:08 +0000 Subject: [PATCH] added data types for color and edge type to allow to set these for custom nodes/edges priliminary usage of this new types, not yet finished [r6824] --- ir/ir/irdump.c | 66 ++++++++++++++++++++++++++++++-------------- ir/ir/irdump.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ ir/ir/irdump_t.h | 2 +- 3 files changed, 118 insertions(+), 21 deletions(-) diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 6d587626a..180edee94 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -89,7 +89,7 @@ int dump_const_local = 0; bool opt_dump_analysed_type_info = 1; bool opt_dump_pointer_values_to_info = 0; /* default off: for test compares!! */ -static const char *overrule_nodecolor = NULL; +static dumper_colors overrule_nodecolor = ird_color_default; /** An additional edge hook. */ static DUMP_NODE_EDGE_FUNC dump_node_edge_hook = NULL; @@ -227,6 +227,25 @@ const char *get_type_name_ex(type *tp, int *bad) return ERROR_TXT; } +/** + * printf the VCG color + */ +static void print_vcg_color(FILE *F, dumper_colors color) { + static const char *color_names[32] = { + "white", "blue", "red", "green", + "yellow", "magenta", "cyan", "darkgray", + "darkblue", "darkred", "darkgreen", "darkyellow", + "darkmagenta", "darkcyan", "gold", "lightgray", + "lightblue", "lightred", "lightgreen", "lightyellow", + "lightmagenta", "lightcyan", "lilac", "turquoise", + "aquamarine", "khaki", "purple", "yellowgreen", + "pink", "orange", "orchid", "black" + }; + + if (color != ird_color_default) + fprintf(F, "color: %s", color_names[color]); +} + /** * prints the edge from a type S to a type T with additional info fmt, ... * to the file F @@ -983,7 +1002,7 @@ static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad) ir_node *n; if (bad) { - fprintf(F, "color: red"); + print_vcg_color(F, ird_color_red); return; } @@ -993,6 +1012,11 @@ static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad) n = local ? local : node; + if (overrule_nodecolor != ird_color_default) { + print_vcg_color(F, overrule_nodecolor); + return; + } + switch (get_irn_opcode(n)) { case iro_Start: case iro_EndReg: @@ -1000,28 +1024,26 @@ static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad) case iro_EndExcept: /* fall through */ case iro_End: - fprintf (F, "color: blue"); + print_vcg_color(F, ird_color_blue); break; case iro_Block: if (is_Block_dead(n)) - fprintf (F, "color: lightred"); + print_vcg_color(F, ird_color_lightred); else - fprintf (F, "color: lightyellow"); + print_vcg_color(F, ird_color_lightyellow); break; case iro_Phi: - fprintf (F, "color: green"); + print_vcg_color(F, ird_color_green); break; case iro_Const: case iro_Proj: case iro_Filter: case iro_Tuple: - fprintf (F, "color: yellow"); + print_vcg_color(F, ird_color_yellow); break; default: PRINT_DEFAULT_NODE_ATTR; } - - if (overrule_nodecolor) fprintf(F, " color: %s", overrule_nodecolor); } @@ -1450,7 +1472,7 @@ static void dump_const_expression(FILE *F, ir_node *value) { static void dump_whole_block(FILE *F, ir_node *block) { ir_node *node; - const char *color = "yellow"; + dumper_colors color = ird_color_yellow; assert(is_Block(block)); @@ -1465,11 +1487,13 @@ dump_whole_block(FILE *F, ir_node *block) { /* colorize blocks */ if (! get_Block_matured(block)) - color = "red"; + color = ird_color_red; if (is_Block_dead(block)) - color = "orange"; + color = ird_color_orange; - fprintf(F, "\" status:clustered color:%s \n", color); + fprintf(F, "\" status:clustered "); + print_vcg_color(F, color); + fprintf(F, "\n"); /* yComp can show attributes for blocks, XVCG parses but ignores them */ dump_node_info(F, block); @@ -2349,7 +2373,7 @@ void dump_ir_extblock_graph (ir_graph *irg, const char *suffix) fprintf(F, "graph: { title: \""); PRINT_IRGID(irg); - fprintf(F, "\" label: \"%s\" status:clustered color:white \n", + fprintf(F, "\" label: \"%s\" status:clustered color: white \n", get_ent_dump_name(ent)); dump_graph_info(F, irg); @@ -2793,8 +2817,8 @@ dump_class_hierarchy (bool entities, const char *suffix) /*---------------------------------------------------------------------*/ void dump_all_ir_graphs(dump_graph_func *dmp_grph, const char *suffix) { - int i, n_irgs = get_irp_n_irgs(); - for (i = 0; i < n_irgs; ++i) { + int i; + for (i = get_irp_n_irgs() - 1; i >= 0; --i) { dmp_grph(get_irp_irg(i), suffix); } } @@ -3010,9 +3034,10 @@ void dump_loop(ir_loop *l, const char *suffix) { /* dump the nodes that go into the block */ for (n = get_irn_link(b); n; n = get_irn_link(n)) { - if (eset_contains(extnodes, n)) overrule_nodecolor = "lightblue"; + if (eset_contains(extnodes, n)) + overrule_nodecolor = ird_color_lightblue; dump_node(F, n); - overrule_nodecolor = NULL; + overrule_nodecolor = ird_color_default; if (!eset_contains(extnodes, n)) dump_ir_data_edges(F, n); } @@ -3032,9 +3057,10 @@ void dump_loop(ir_loop *l, const char *suffix) { /* dump the nodes that go into the block */ for (n = get_irn_link(b); n; n = get_irn_link(n)) { - if (!eset_contains(loopnodes, n)) overrule_nodecolor = "lightblue"; + if (!eset_contains(loopnodes, n)) + overrule_nodecolor = ird_color_lightblue; dump_node(F, n); - overrule_nodecolor = NULL; + overrule_nodecolor = ird_color_default; if (eset_contains(loopnodes, n)) dump_ir_data_edges(F, n); } diff --git a/ir/ir/irdump.h b/ir/ir/irdump.h index 6721d91cb..3d8c7a265 100644 --- a/ir/ir/irdump.h +++ b/ir/ir/irdump.h @@ -37,6 +37,77 @@ # include "irgraph.h" # include "irloop.h" +/** + * Names of the 32 supported colors + */ +typedef enum { + ird_color_default = -1, + ird_color_white = 0, + ird_color_blue = 1, + ird_color_red = 2, + ird_color_green = 3, + ird_color_yellow = 4, + ird_color_magenta = 5, + ird_color_cyan = 6, + ird_color_darkgray = 7, + ird_color_darkblue = 8, + ird_color_darkred = 9, + ird_color_darkgreen = 10, + ird_color_darkyellow = 11, + ird_color_darkmagenta = 12, + ird_color_darkcyan = 13, + ird_color_gold = 14, + ird_color_lightgray = 15, + ird_color_lightblue = 16, + ird_color_lightred = 17, + ird_color_lightgreen = 18, + ird_color_lightyellow = 19, + ird_color_lightmagenta = 20, + ird_color_lightcyan = 21, + ird_color_lilac = 22, + ird_color_turquoise = 23, + ird_color_aquamarine = 24, + ird_color_khaki = 25, + ird_color_purple = 26, + ird_color_yellowgreen = 27, + ird_color_pink = 28, + ird_color_orange = 29, + ird_color_orchid = 30, + ird_color_black = 31 +} dumper_colors; + +/** + * Edge kinds + */ +typedef enum { + data_edge = 0x01, /**< a data edge between two basic blocks */ + block_edge = 0x02, /**< an edge from a node to its basic block */ + cf_edge = 0x03, /**< regularly control flow edge */ + exc_cf_edge = 0x04, /**< exceptional control flow edge */ + mem_edge = 0x05, /**< memory edge */ + dominator_edge = 0x06, /**< dominator edge */ + node2type_edge = 0x07, /**< an edge from an IR node to a type */ + + ent_type_edge = 0x11, /**< an edge from an entity to its type */ + ent_own_edge = 0x12, /**< an edge from an entity to its owner type */ + ent_overwrites_edge = 0x13, /**< an edge from an entity to the entity it overwrites */ + ent_value_edge = 0x14, /**< an edge from an entity to its value entity */ + ent_corr_edge = 0x15, /**< an edge from an entity to the member entity its initializes */ + + meth_par_edge = 0x21, /**< an edge from a method type to one of its parameter types */ + meth_res_edge = 0x22, /**< an edge from a method type to one of its result types */ + type_super_edge = 0x23, /**< an edge from a class type to its super/basis type */ + union_edge = 0x24, /**< an edge from a union type to its member types */ + ptr_pts_to_edge = 0x25, /**< an edge from a pointer type to its points-to type */ + arr_elt_type_edge = 0x26, /**< an edge from an array type to its element type */ + arr_ent_edge = 0x27, /**< an edge from a array type to its element entity */ + type_member_edge = 0x28, /**< an edge from a compound type to its member entities */ + + /* additional flags */ + intra_edge = 0, /**< intra edge flag: edge do not cross basic block boundaries */ + inter_edge = 0x40, /**< inter edge flag: edge cross basic block boundaries */ + back_edge = 0x80 /**< backwards edge flag */ +} edge_kind; /* **************************************************************************** */ /* GRAPH DUMPERS */ diff --git a/ir/ir/irdump_t.h b/ir/ir/irdump_t.h index 182f1919f..ea3e2fec7 100644 --- a/ir/ir/irdump_t.h +++ b/ir/ir/irdump_t.h @@ -45,7 +45,7 @@ #define ENT_CORR_EDGE_ATTR "label: \"value %d corresponds to \" " #define TYPE_MEMBER_EDGE_ATTR "class: 12 label: \"member\" color:blue" #define ENUM_ITEM_NODE_ATTR "color: green" -#define CALLGRAPH_EDGE_ATTR "calls" +/* #define CALLGRAPH_EDGE_ATTR "calls" */ #define PRINT_NODEID(X) fprintf(F, "n%ld", get_irn_node_nr(X)) #define PRINT_TYPEID(X) fprintf(F, "\"t%ld\"", get_type_nr(X)) -- 2.20.1