removed debug output
[libfirm] / ir / debug / dbginfo.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/debug/dbginfo.c
4  * Purpose:     Implements the Firm interface to debug information.
5  * Author:      Goetz Lindenmaier
6  * Modified by: Michael Beck
7  * Created:     2001
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2001-2006 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16
17 #include "dbginfo_t.h"
18 #include "irnode_t.h"
19 #include "type_t.h"
20 #include "entity_t.h"
21
22 void
23 default_dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info) {
24   dbg_info *old_db = get_irn_dbg_info(old);
25   if (old_db)
26     set_irn_dbg_info(nw, old_db);
27 }
28
29 void
30 default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes,
31             ir_node **old_nodes, int n_old_nodes,
32             dbg_action info) {
33 }
34
35 merge_pair_func *__dbg_info_merge_pair = default_dbg_info_merge_pair;
36
37 merge_sets_func *__dbg_info_merge_sets = default_dbg_info_merge_sets;
38
39 snprint_dbg_func *__dbg_info_snprint   = (snprint_dbg_func *)0;
40
41 void dbg_init( merge_pair_func *mpf, merge_sets_func *msf, snprint_dbg_func *snprint_dbg )
42 {
43   __dbg_info_merge_pair = mpf ? mpf : default_dbg_info_merge_pair;
44   __dbg_info_merge_sets = msf ? msf : default_dbg_info_merge_sets;
45   __dbg_info_snprint    = snprint_dbg;
46 }
47
48
49 void
50 set_irn_dbg_info(ir_node *n, struct dbg_info* db) {
51   n->dbi = db;
52 }
53
54 struct dbg_info *
55 get_irn_dbg_info(const ir_node *n) {
56   return n->dbi;
57 }
58
59
60 /* Routines to access the field of an entity containing the
61    debugging information. */
62 void set_entity_dbg_info(entity *ent, dbg_info* db) {
63   ent->dbi = db;
64 }
65
66 dbg_info *get_entity_dbg_info(entity *ent) {
67   return ent->dbi;
68 }
69
70 /* Routines to access the field of a type containing the
71    debugging information. */
72 void set_type_dbg_info(ir_type *tp, dbg_info* db) {
73   tp->dbi = db;
74 }
75
76 dbg_info *get_type_dbg_info(ir_type *tp) {
77   return tp->dbi;
78 }
79
80 /*
81  * Converts a debug_action into a string.
82  */
83 const char *dbg_action_2_str(dbg_action a) {
84 #define CASE(a) case a: return #a
85
86   switch (a) {
87   CASE(dbg_error);
88   CASE(dbg_opt_ssa);
89   CASE(dbg_opt_auxnode);
90   CASE(dbg_const_eval);
91   CASE(dbg_opt_cse);
92   CASE(dbg_straightening);
93   CASE(dbg_if_simplification);
94   CASE(dbg_algebraic_simplification);
95   CASE(dbg_write_after_write);
96   CASE(dbg_write_after_read);
97   CASE(dbg_read_after_write);
98   CASE(dbg_read_after_read);
99   CASE(dbg_read_a_const);
100   CASE(dbg_rem_poly_call);
101   CASE(dbg_dead_code);
102   CASE(dbg_opt_confirm);
103   CASE(dbg_backend);
104   default:
105     if (a <= dbg_max)
106       return "string conversion not implemented";
107     else
108       assert(0);
109     return NULL;
110   }
111 #undef CASE
112 }