2 * Copyright (C) 2001 by Universitaet Karlsruhe
5 * Authors: Goetz Lindenmaier
7 * dbginfo: This is the Firm interface to debugging support. Firm requires
8 * a debugging module fulfilling this interface, else no debugging information
9 * is passed to the backend.
10 * The interface requires a datatype representing the debugging information.
11 * Firm supports administrating a reference to the debug information
12 * in every firm node. Further Firm optimizations call routines to
13 * propagate debug information from old nodes to new nodes if the optimization
14 * replaces the old ones by the new ones.
25 #ifndef _IR_NODE_TYPEDEF_
26 #define _IR_NODE_TYPEDEF_
27 typedef struct ir_node ir_node;
30 /* to resolve recursion between entity.h and type.h */
31 #ifndef _ENTITY_TYPEDEF_
32 #define _ENTITY_TYPEDEF_
33 typedef struct entity entity;
36 #ifndef _TYPE_TYPEDEF_
37 #define _TYPE_TYPEDEF_
38 typedef struct type type;
43 * An abstract data type containing information for
45 * This datatype is not defined in the firm library, but pointers
46 * to this type can be stored in firm nodes.
48 typedef struct dbg_info dbg_info;
49 /* Routines to access the field of an ir node containing the
50 debugging information. */
51 INLINE void set_irn_dbg_info(ir_node *n, dbg_info* db);
52 INLINE dbg_info *get_irn_dbg_info(ir_node *n);
53 /* Routines to access the field of an entity containing the
54 debugging information. */
55 INLINE void set_entity_dbg_info(entity *ent, dbg_info* db);
56 INLINE dbg_info *get_entity_dbg_info(entity *ent);
57 /* Routines to access the field of a type containing the
58 debugging information. */
59 INLINE void set_type_dbg_info(type *tp, dbg_info* db);
60 INLINE dbg_info *get_type_dbg_info(type *tp);
63 * An enumeration indicating the action performed by a transformation.
67 dbg_opt_ssa, /**< Optimization of the SSA representation, e.g., removal of superfluent phi nodes. */
68 dbg_opt_auxnode, /**< Removal of unnecessary auxilliary nodes. */
69 dbg_const_eval, /**< A Firm subgraph was evaluated to a single constant. */
70 dbg_straightening, /**< A Firm subgraph was replaced by a single, existing block. */
71 dbg_if_simplification, /**< The control flow of an if is changed as either the
72 else, the then or both blocks are empty. */
73 dbg_algebraic_simplification,
74 dbg_write_after_write,
81 * converts enum values to strings
83 extern INLINE const char* dbg_action_2_str(dbg_action a) {
85 case dbg_error: return "dbg_error"; break;
86 case dbg_opt_ssa: return "dbg_opt_ssa"; break;
87 case dbg_opt_auxnode: return "dbg_opt_auxnode"; break;
88 case dbg_const_eval: return "dbg_const_eval"; break;
89 case dbg_straightening: return "dbg_straightening"; break;
90 case dbg_if_simplification: return "dbg_if_simplification"; break;
91 case dbg_algebraic_simplification:
92 return "dbg_algebraic_simplification"; break;
93 case dbg_write_after_write: return "dbg_write_after_write"; break;
94 case dbg_write_after_read: return "dbg_write_after_read"; break;
97 return "string conversion not implemented";
104 * The type of the debug info merge function.
108 typedef void (merge_pair_func)(ir_node *, ir_node *, dbg_action);
111 * The type of the debug info merge function.
115 typedef void (merge_sets_func)(ir_node **, int, ir_node **, int, dbg_action);
118 * Initializes the debug support.
120 * @param dbg_info_merge_pair see function description
121 * @param dbg_info_merge_sets see function description
123 * This function takes Pointers to two functions that merge the debug information when a
124 * transformation of a firm graph is performed.
125 * Firm transformations call one of these functions.
127 * - dbg_info_merge_pair() is called in the following situation:
128 * The optimization replaced the old node by the new one. The new node
129 * might be a recent allocated node not containing any debug information,
130 * or just another node from somewhere in the graph with the same
132 * - dbg_info_merge_sets() is called in the following situation:
133 * The optimization replaced a subgraph by another subgraph. There is no
134 * obviouse mapping between single nodes in both subgraphs. The optimization
135 * simply passes two lists to the debug module, one containing the nodes in
136 * the old subgraph, the other containing the nodes in the new subgraph.
137 * The same node can be in both lists.
139 * Further both functions pass an enumeration indicating the action
140 * performed by the transformation, e.g. the kind of optimization performed.
145 void dbg_init(merge_pair_func *dbg_info_merge_pair, merge_sets_func *dbg_info_merge_sets);
148 #endif /* _DBGINFO_H_ */