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;
49 * An abstract data type containing information for
51 * This datatype is not defined in the firm library, but pointers
52 * to this type can be stored in firm nodes.
54 typedef struct dbg_info dbg_info;
55 /* Routines to access the field of an ir node containing the
56 debugging information. */
57 INLINE void set_irn_dbg_info(ir_node *n, dbg_info* db);
58 INLINE dbg_info *get_irn_dbg_info(ir_node *n);
59 /* Routines to access the field of an entity containing the
60 debugging information. */
61 INLINE void set_entity_dbg_info(entity *ent, dbg_info* db);
62 INLINE dbg_info *get_entity_dbg_info(entity *ent);
63 /* Routines to access the field of a type containing the
64 debugging information. */
65 INLINE void set_type_dbg_info(type *tp, dbg_info* db);
66 INLINE dbg_info *get_type_dbg_info(type *tp);
69 * An enumeration indicating the action performed by a transformation.
73 dbg_opt_ssa, /**< Optimization of the SSA representation, e.g., removal of superfluent phi nodes. */
74 dbg_opt_auxnode, /**< Removal of unnecessary auxilliary nodes. */
75 dbg_const_eval, /**< A Firm subgraph was evaluated to a single constant. */
76 dbg_straightening, /**< A Firm subgraph was replaced by a single, existing block. */
77 dbg_if_simplification, /**< The control flow of an if is changed as either the
78 else, the then or both blocks are empty. */
79 dbg_algebraic_simplification,
80 dbg_write_after_write,
87 * converts enum values to strings
89 static const char* dbg_action_2_str(dbg_action a) {
91 case dbg_error: return "dbg_error"; break;
92 case dbg_opt_ssa: return "dbg_opt_ssa"; break;
93 case dbg_opt_auxnode: return "dbg_opt_auxnode"; break;
94 case dbg_const_eval: return "dbg_const_eval"; break;
95 case dbg_straightening: return "dbg_straightening"; break;
96 case dbg_if_simplification: return "dbg_if_simplification"; break;
97 case dbg_algebraic_simplification:
98 return "dbg_algebraic_simplification"; break;
99 case dbg_write_after_write: return "dbg_write_after_write"; break;
100 case dbg_write_after_read: return "dbg_write_after_read"; break;
103 return "string conversion not implemented";
110 * The type of the debug info merge function.
114 typedef void merge_pair_func(ir_node *, ir_node *, dbg_action);
117 * The type of the debug info merge function.
121 typedef void merge_sets_func(ir_node **, int, ir_node **, int, dbg_action);
124 * Initializes the debug support.
126 * @param dbg_info_merge_pair see function description
127 * @param dbg_info_merge_sets see function description
129 * This function takes Pointers to two functions that merge the debug information when a
130 * transformation of a firm graph is performed.
131 * Firm transformations call one of these functions.
133 * - dbg_info_merge_pair() is called in the following situation:
134 * The optimization replaced the old node by the new one. The new node
135 * might be a recent allocated node not containing any debug information,
136 * or just another node from somewhere in the graph with the same
138 * - dbg_info_merge_sets() is called in the following situation:
139 * The optimization replaced a subgraph by another subgraph. There is no
140 * obviouse mapping between single nodes in both subgraphs. The optimization
141 * simply passes two lists to the debug module, one containing the nodes in
142 * the old subgraph, the other containing the nodes in the new subgraph.
143 * The same node can be in both lists.
145 * Further both functions pass an enumeration indicating the action
146 * performed by the transformation, e.g. the kind of optimization performed.
151 void dbg_init(merge_pair_func *dbg_info_merge_pair, merge_sets_func *dbg_info_merge_sets);
154 #endif /* _DBGINFO_H_ */