2 * Copyright (C) 2001 by Universitaet Karlsruhe
9 * This is the Firm interface to debugging support.
11 * @author Goetz Lindenmaier
14 * a debugging module fulfilling this interface, else no debugging information
15 * is passed to the backend.
16 * The interface requires a datatype representing the debugging information.
17 * Firm supports administrating a reference to the debug information
18 * in every firm node. Further Firm optimizations call routines to
19 * propagate debug information from old nodes to new nodes if the optimization
20 * replaces the old ones by the new ones.
31 #ifndef _IR_NODE_TYPEDEF_
32 #define _IR_NODE_TYPEDEF_
33 typedef struct ir_node ir_node;
36 /* to resolve recursion between entity.h and type.h */
37 #ifndef _ENTITY_TYPEDEF_
38 #define _ENTITY_TYPEDEF_
39 typedef struct entity entity;
42 #ifndef _TYPE_TYPEDEF_
43 #define _TYPE_TYPEDEF_
44 typedef struct type type;
48 * @defgroup debug The Firm interface to debugging support.
54 * An abstract data type containing information for
57 * This datatype is not defined anywere in the firm library, but pointers
58 * to this type can be stored in firm nodes.
60 typedef struct dbg_info dbg_info;
63 * Sets the debug information of a node.
65 INLINE void set_irn_dbg_info(ir_node *n, dbg_info* db);
68 * Returns the debug information of an node.
70 INLINE dbg_info *get_irn_dbg_info(ir_node *n);
73 * Sets the debug information of an entity.
75 INLINE void set_entity_dbg_info(entity *ent, dbg_info* db);
78 * Returns the debug information of an entity.
80 INLINE dbg_info *get_entity_dbg_info(entity *ent);
83 * Sets the debug information of a type.
85 INLINE void set_type_dbg_info(type *tp, dbg_info* db);
88 * Returns the debug information of a type.
90 INLINE dbg_info *get_type_dbg_info(type *tp);
93 * An enumeration indicating the action performed by a transformation.
97 dbg_opt_ssa, /**< Optimization of the SSA representation, e.g., removal of superfluent phi nodes. */
98 dbg_opt_auxnode, /**< Removal of unnecessary auxilliary nodes. */
99 dbg_const_eval, /**< A Firm subgraph was evaluated to a single constant. */
100 dbg_straightening, /**< A Firm subgraph was replaced by a single, existing block. */
101 dbg_if_simplification, /**< The control flow of an if is changed as either the
102 else, the then or both blocks are empty. */
103 dbg_algebraic_simplification, /**< A Firm subgraph was replaced because of an algebraic
105 dbg_write_after_write, /**< A Firm subgraph was replaced because of a write
106 after write optimization. */
107 dbg_write_after_read, /**< A Firm subgraph was replaced because of a write
108 after read optimization. */
109 dbg_rem_poly_call, /**< Remove polymorphic call. */
110 dbg_max /**< Maximum value. */
116 * Converts enum values to strings.
118 static const char* dbg_action_2_str(dbg_action a) {
120 case dbg_error: return "dbg_error"; break;
121 case dbg_opt_ssa: return "dbg_opt_ssa"; break;
122 case dbg_opt_auxnode: return "dbg_opt_auxnode"; break;
123 case dbg_const_eval: return "dbg_const_eval"; break;
124 case dbg_straightening: return "dbg_straightening"; break;
125 case dbg_if_simplification: return "dbg_if_simplification"; break;
126 case dbg_algebraic_simplification:
127 return "dbg_algebraic_simplification"; break;
128 case dbg_write_after_write: return "dbg_write_after_write"; break;
129 case dbg_write_after_read: return "dbg_write_after_read"; break;
130 case dbg_rem_poly_call: return "dbg_rem_poly_call"; break;
133 return "string conversion not implemented";
140 * The type of the debug info merge function.
142 * @param new_node the new ir node
143 * @param old_node the old ir node
144 * @param action the action that triggers the merge
148 typedef void merge_pair_func(ir_node *new_node, ir_node *old_node, dbg_action action);
151 * The type of the debug info merge sets function.
153 * @param new_node_array array of new nodes
154 * @param new_num_entries number of entries in new_node_array
155 * @param old_node_array array of old nodes
156 * @param old_num_entries number of entries in old_node_array
157 * @param action the action that triggers the merge
161 typedef void merge_sets_func(ir_node **new_node_array, int new_num_entries, ir_node **old_node_array, int old_num_entries, dbg_action action);
164 * Initializes the debug support.
166 * @param dbg_info_merge_pair see function description
167 * @param dbg_info_merge_sets see function description
169 * This function takes Pointers to two functions that merge the
170 * debug information when a
171 * transformation of a firm graph is performed.
172 * Firm transformations call one of these functions.
174 * - dbg_info_merge_pair() is called in the following situation:
175 * The optimization replaced the old node by the new one. The new node
176 * might be a recent allocated node not containing any debug information,
177 * or just another node from somewhere in the graph with the same
179 * - dbg_info_merge_sets() is called in the following situation:
180 * The optimization replaced a subgraph by another subgraph. There is no
181 * obviouse mapping between single nodes in both subgraphs. The optimization
182 * simply passes two lists to the debug module, one containing the nodes in
183 * the old subgraph, the other containing the nodes in the new subgraph.
184 * The same node can be in both lists.
186 * Further both functions pass an enumeration indicating the action
187 * performed by the transformation, e.g. the kind of optimization performed.
189 void dbg_init(merge_pair_func *dbg_info_merge_pair, merge_sets_func *dbg_info_merge_sets);
193 #endif /* _DBGINFO_H_ */