1 /* 2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. 3 * 4 * This file is part of libFirm. 5 * 6 * This file may be distributed and/or modified under the terms of the 7 * GNU General Public License version 2 as published by the Free Software 8 * Foundation and appearing in the file LICENSE.GPL included in the 9 * packaging of this file. 10 * 11 * Licensees holding valid libFirm Professional Edition licenses may use 12 * this file in accordance with the libFirm Commercial License. 13 * Agreement provided with the Software. 14 * 15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * PURPOSE. 18 */ 19 20 /** 21 * @file 22 * @brief Private header for irdump 23 */ 24 #ifndef FIRM_IR_IRDUMPT_T_H 25 #define FIRM_IR_IRDUMPT_T_H 26 27 #include "irdump.h" 28 #include "irgraph_t.h" 29 30 /** 31 * Symbolic names for the different dumping colors. 32 */ 33 typedef enum ird_color_t { 34 ird_color_none = -1, 35 ird_color_prog_background, 36 ird_color_block_background, 37 ird_color_dead_block_background, 38 ird_color_block_inout, 39 ird_color_default_node, 40 ird_color_phi, 41 ird_color_memory, 42 ird_color_controlflow, 43 ird_color_const, 44 ird_color_anchor, 45 ird_color_proj, 46 ird_color_uses_memory, 47 ird_color_error, 48 ird_color_entity, 49 ird_color_count 50 } ird_color_t; 51 52 /** 53 * Edge kinds. 54 */ 55 typedef enum { 56 data_edge = 0x01, /**< A data edge between two basic blocks. */ 57 block_edge = 0x02, /**< An edge from a node to its basic block. */ 58 cf_edge = 0x03, /**< A regularly control flow edge. */ 59 exc_cf_edge = 0x04, /**< An exceptional control flow edge. */ 60 mem_edge = 0x05, /**< A memory edge. */ 61 dominator_edge = 0x06, /**< A dominator edge from a block to its immediate dominator. */ 62 node2type_edge = 0x07, /**< An edge from an IR node to a type. */ 63 64 ent_type_edge = 0x11, /**< An edge from an entity to its type. */ 65 ent_own_edge = 0x12, /**< An edge from an entity to its owner type. */ 66 ent_overwrites_edge = 0x13, /**< An edge from an entity to the entity it overwrites. */ 67 ent_value_edge = 0x14, /**< An edge from an entity to its value entity. */ 68 ent_corr_edge = 0x15, /**< An edge from an entity to the member entity its initializes. */ 69 70 meth_par_edge = 0x21, /**< An edge from a method type to one of its parameter types. */ 71 meth_res_edge = 0x22, /**< An edge from a method type to one of its result types. */ 72 type_super_edge = 0x23, /**< An edge from a class type to its super/basis type. */ 73 union_edge = 0x24, /**< An edge from a union type to its member types. */ 74 ptr_pts_to_edge = 0x25, /**< An edge from a pointer type to its points-to type. */ 75 arr_elt_type_edge = 0x26, /**< An edge from an array type to its element type. */ 76 arr_ent_edge = 0x27, /**< An edge from a array type to its element entity. */ 77 type_member_edge = 0x28, /**< An edge from a compound type to its member entities. */ 78 79 /* additional flags */ 80 intra_edge = 0, /**< Intra edge flag: edge do not cross basic block boundaries */ 81 inter_edge = 0x40, /**< Inter edge flag: edge cross basic block boundaries */ 82 back_edge = 0x80 /**< Backwards edge flag. */ 83 } edge_kind; 84 85 /* Attributes of nodes */ 86 #define PRINT_DEFAULT_NODE_ATTR 87 #define DEFAULT_NODE_ATTR " " 88 #define DEFAULT_TYPE_ATTRIBUTE " " 89 #define DEFAULT_ENUM_ITEM_ATTRIBUTE " " 90 91 /* Attributes of edges between Firm nodes */ 92 #define INTRA_DATA_EDGE_ATTR "class:1 priority:50" 93 #define INTER_DATA_EDGE_ATTR "class:16 priority:10" 94 #define BLOCK_EDGE_ATTR "class:2 priority:50 linestyle:dotted" 95 #define CF_EDGE_ATTR "class:13 priority:60 color:red" 96 #define EXC_CF_EDGE_ATTR "class:18 priority:60 color:blue" 97 #define INTRA_MEM_EDGE_ATTR "class:14 priority:50 color:blue" 98 #define INTER_MEM_EDGE_ATTR "class:17 priority:10 color:blue" 99 #define DOMINATOR_EDGE_ATTR "class:15 color:red" 100 #define POSTDOMINATOR_EDGE_ATTR "class:19 color:red linestyle:dotted" 101 #define KEEP_ALIVE_EDGE_ATTR "class:20 priority:10 color:purple" 102 #define KEEP_ALIVE_CF_EDGE_ATTR "class:20 priority:60 color:purple" 103 #define KEEP_ALIVE_DF_EDGE_ATTR "class:20 priority:10 color:purple" 104 #define ANCHOR_EDGE_ATTR "class:20 priority:60 color:purple linestyle:dotted" 105 #define OUT_EDGE_ATTR "class:21 priority:10 color:gold linestyle:dashed" 106 107 #define BACK_EDGE_ATTR "linestyle:dashed " 108 109 /* Attributes of edges between Firm nodes and type/entity nodes */ 110 #define NODE2TYPE_EDGE_ATTR "class:2 priority:2 linestyle:dotted" 111 112 /* Attributes of edges in type/entity graphs. */ 113 #define TYPE_METH_NODE_ATTR "color: lightyellow" 114 #define TYPE_CLASS_NODE_ATTR "color: green" 115 #define TYPE_DESCRIPTION_NODE_ATTR "color: lightgreen" 116 #define ENTITY_NODE_ATTR "color: yellow" 117 #define ENUM_ITEM_NODE_ATTR "color: green" 118 #define ENT_TYPE_EDGE_ATTR "class: 3 label: \"type\" color: red" 119 #define ENT_OWN_EDGE_ATTR "class: 4 label: \"owner\" color: black" 120 #define METH_PAR_EDGE_ATTR "class: 5 label: \"param %zu\" color: green" 121 #define METH_RES_EDGE_ATTR "class: 6 label: \"res %zu\" color: green" 122 #define TYPE_SUPER_EDGE_ATTR "class: 7 label: \"supertype\" color: red" 123 #define UNION_EDGE_ATTR "class: 8 label: \"component\" color: blue" 124 #define PTR_PTS_TO_EDGE_ATTR "class: 9 label: \"points to\" color:green" 125 #define ARR_ELT_TYPE_EDGE_ATTR "class: 10 label: \"arr elt tp\" color:green" 126 #define ARR_ENT_EDGE_ATTR "class: 10 label: \"arr ent\" color: green" 127 #define ENT_OVERWRITES_EDGE_ATTR "class: 11 label: \"overwrites\" color:red" 128 #define ENT_VALUE_EDGE_ATTR "label: \"value %d\"" 129 #define ENT_CORR_EDGE_ATTR "label: \"value %zu corresponds to \" " 130 #define TYPE_MEMBER_EDGE_ATTR "class: 12 label: \"member\" color:blue" 131 /* #define CALLGRAPH_EDGE_ATTR "calls" */ 132 133 void print_nodeid(FILE *F, const ir_node *node); 134 void print_irgid(FILE *F, const ir_graph *irg); 135 void print_typeid(FILE *F, const ir_type *type); 136 void print_entityid(FILE *F, const ir_entity *entity); 137 void print_loopid(FILE *F, const ir_loop *loop); 138 139 const char *get_irg_dump_name(const ir_graph *irg); 140 141 const char *get_ent_dump_name(const ir_entity *ent); 142 143 /** 144 * returns the name of a mode or "<ERROR>" if mode is NOT a mode object. 145 * in the later case, sets bad. 146 */ 147 const char *get_mode_name_ex(const ir_mode *mode, int *bad); 148 /** dump the name of a node n to the File F. */ 149 void dump_node_opcode(FILE *out, const ir_node *n); 150 151 void dump_node_label(FILE *out, const ir_node *n); 152 153 /** Writes vcg representation with title "PRINT_TYPEID(tp)" to file F. */ 154 void dump_type_node(FILE *out, ir_type *tp); 155 156 void dump_vcg_header(FILE *out, const char *name, const char *layout, const char *orientation); 157 void dump_vcg_footer(FILE *out); 158 void dump_vcg_header_colors(FILE *out); 159 void dump_vcg_infonames(FILE *out); 160 void dump_node(FILE *out, const ir_node *node); 161 162 /** Write the irnode and all its attributes to the file passed. 163 * (plain text format) */ 164 void dump_irnode_to_file(FILE *out, const ir_node *node); 165 166 #endif 167