add dbg_dead_code case
[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:
7  * Created:     2001
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2001-2003 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   set_irn_dbg_info(nw, get_irn_dbg_info(old));
25 }
26
27 void
28 default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes,
29             ir_node **old_nodes, int n_old_nodes,
30             dbg_action info) {
31 }
32
33 merge_pair_func *__dbg_info_merge_pair = default_dbg_info_merge_pair;
34
35 merge_sets_func *__dbg_info_merge_sets = default_dbg_info_merge_sets;
36
37 snprint_dbg_func *__dbg_info_snprint   = (snprint_dbg_func *)0;
38
39 void dbg_init( merge_pair_func *mpf, merge_sets_func *msf, snprint_dbg_func *snprint_dbg )
40 {
41   __dbg_info_merge_pair = mpf ? mpf : default_dbg_info_merge_pair;
42   __dbg_info_merge_sets = msf ? msf : default_dbg_info_merge_sets;
43   __dbg_info_snprint    = snprint_dbg;
44 }
45
46
47 void
48 set_irn_dbg_info(ir_node *n, struct dbg_info* db) {
49   n->dbi = db;
50 }
51
52 struct dbg_info *
53 get_irn_dbg_info(ir_node *n) {
54   return n->dbi;
55 }
56
57
58 /* Routines to access the field of an entity containing the
59    debugging information. */
60 void set_entity_dbg_info(entity *ent, dbg_info* db) {
61   ent->dbi = db;
62 }
63
64 dbg_info *get_entity_dbg_info(entity *ent) {
65   return ent->dbi;
66 }
67
68 /* Routines to access the field of a type containing the
69    debugging information. */
70 void set_type_dbg_info(type *tp, dbg_info* db) {
71   tp->dbi = db;
72 }
73
74 dbg_info *get_type_dbg_info(type *tp) {
75   return tp->dbi;
76 }
77
78 /*
79  * Converts a debug_action into a string.
80  */
81 const char *dbg_action_2_str(dbg_action a) {
82 #define CASE(a) case a: return #a
83
84   switch (a) {
85   CASE(dbg_error);
86   CASE(dbg_opt_ssa);
87   CASE(dbg_opt_auxnode);
88   CASE(dbg_const_eval);
89   CASE(dbg_opt_cse);
90   CASE(dbg_straightening);
91   CASE(dbg_if_simplification);
92   CASE(dbg_algebraic_simplification);
93   CASE(dbg_write_after_write);
94   CASE(dbg_write_after_read);
95   CASE(dbg_read_after_write);
96   CASE(dbg_read_after_read);
97   CASE(dbg_read_a_const);
98   CASE(dbg_rem_poly_call);
99   CASE(dbg_dead_code);
100   CASE(dbg_opt_confirm);
101   default:
102     if (a <= dbg_max)
103       return "string conversion not implemented";
104     else
105       assert(0);
106     return NULL;
107   }
108 #undef CASE
109 }