2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Implements the Firm interface to debug information.
23 * @author Goetz Lindenmaier, Michael Beck
29 #include "dbginfo_t.h"
34 merge_pair_func *__dbg_info_merge_pair = default_dbg_info_merge_pair;
36 merge_sets_func *__dbg_info_merge_sets = default_dbg_info_merge_sets;
38 snprint_dbg_func *__dbg_info_snprint = (snprint_dbg_func *)0;
40 void dbg_init( merge_pair_func *mpf, merge_sets_func *msf, snprint_dbg_func *snprint_dbg )
42 __dbg_info_merge_pair = mpf ? mpf : default_dbg_info_merge_pair;
43 __dbg_info_merge_sets = msf ? msf : default_dbg_info_merge_sets;
44 __dbg_info_snprint = snprint_dbg;
48 * Converts a debug_action into a string.
50 const char *dbg_action_2_str(dbg_action a) {
51 #define CASE(a) case a: return #a
56 CASE(dbg_opt_auxnode);
59 CASE(dbg_straightening);
60 CASE(dbg_if_simplification);
61 CASE(dbg_algebraic_simplification);
62 CASE(dbg_write_after_write);
63 CASE(dbg_write_after_read);
64 CASE(dbg_read_after_write);
65 CASE(dbg_read_after_read);
66 CASE(dbg_read_a_const);
67 CASE(dbg_rem_poly_call);
69 CASE(dbg_opt_confirm);
72 CASE(dbg_jumpthreading);
76 return "string conversion not implemented";
78 assert(!"Missing debug action in dbg_action_2_str()");
82 } /* dbg_action_2_str */
85 void default_dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info) {
86 dbg_info *new_db = get_irn_dbg_info(nw);
89 set_irn_dbg_info(nw, get_irn_dbg_info(old));
90 } /* default_dbg_info_merge_pair */
92 void default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes,
93 ir_node **old_nodes, int n_old_nodes,
96 if (n_old_nodes == 1) {
97 dbg_info *old_db = get_irn_dbg_info(old_nodes[0]);
100 for (i = 0; i < n_new_nodes; ++i)
101 if (get_irn_dbg_info(new_nodes[i]) == NULL)
102 set_irn_dbg_info(new_nodes[i], old_db);
104 } /* default_dbg_info_merge_sets */
106 /** The debug info retriever function. */
107 static retrieve_dbg_func retrieve_dbg = NULL;
109 /* Sets a debug info retriever. */
110 void ir_set_debug_retrieve(retrieve_dbg_func func) {
114 /* Retrieve the debug info. */
115 const char *ir_retrieve_dbg_info(const dbg_info *dbg, unsigned *line) {
117 return retrieve_dbg(dbg, line);