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
31 #include "dbginfo_t.h"
36 merge_pair_func *__dbg_info_merge_pair = default_dbg_info_merge_pair;
38 merge_sets_func *__dbg_info_merge_sets = default_dbg_info_merge_sets;
40 snprint_dbg_func *__dbg_info_snprint = (snprint_dbg_func *)0;
42 void dbg_init( merge_pair_func *mpf, merge_sets_func *msf, snprint_dbg_func *snprint_dbg )
44 __dbg_info_merge_pair = mpf ? mpf : default_dbg_info_merge_pair;
45 __dbg_info_merge_sets = msf ? msf : default_dbg_info_merge_sets;
46 __dbg_info_snprint = snprint_dbg;
50 * Converts a debug_action into a string.
52 const char *dbg_action_2_str(dbg_action a) {
53 #define CASE(a) case a: return #a
58 CASE(dbg_opt_auxnode);
61 CASE(dbg_straightening);
62 CASE(dbg_if_simplification);
63 CASE(dbg_algebraic_simplification);
64 CASE(dbg_write_after_write);
65 CASE(dbg_write_after_read);
66 CASE(dbg_read_after_write);
67 CASE(dbg_read_after_read);
68 CASE(dbg_read_a_const);
69 CASE(dbg_rem_poly_call);
71 CASE(dbg_opt_confirm);
77 return "string conversion not implemented";
79 assert(!"Missing debug action in dbg_action_2_str()");
83 } /* dbg_action_2_str */
86 void default_dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info) {
87 dbg_info *new_db = get_irn_dbg_info(nw);
90 set_irn_dbg_info(nw, get_irn_dbg_info(old));
91 } /* default_dbg_info_merge_pair */
93 void default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes,
94 ir_node **old_nodes, int n_old_nodes,
97 if (n_old_nodes == 1) {
98 dbg_info *old_db = get_irn_dbg_info(old_nodes[0]);
101 for (i = 0; i < n_new_nodes; ++i)
102 if (get_irn_dbg_info(new_nodes[i]) == NULL)
103 set_irn_dbg_info(new_nodes[i], old_db);
105 } /* default_dbg_info_merge_sets */
107 /** The debug info retriever function. */
108 static retrieve_dbg_func retrieve_dbg = NULL;
110 /* Sets a debug info retriever. */
111 void ir_set_debug_retrieve(retrieve_dbg_func func) {
115 /* Retrieve the debug info. */
116 const char *ir_retrieve_dbg_info(const dbg_info *dbg, unsigned *line) {
118 return retrieve_dbg(dbg, line);