*** empty log message ***
[libfirm] / ir / ir / iropt_dbg.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/iropt_dbg.h
4  * Purpose:     Debug makros used in iropt.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:
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
14 /* This file contains makros that generate the calls to
15    update the debug information after a transformation. */
16
17 #define SIZ(x)    sizeof(x)/sizeof((x)[0])
18
19
20 /**
21  * Merge the debug info due to dead code elimination
22  */
23 #define DBG_OPT_DEAD(oldn, n)                                      \
24   do {                                                             \
25           ir_node *ons[2];                                         \
26           ons[0] = oldn;                                           \
27           ons[1] = get_Block_cfgpred(oldn, 0);                     \
28           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_STG);    \
29           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_dead_code); \
30         } while(0)
31
32
33 /**
34  * Merge the debug info due to a straightening optimization
35  */
36 #define DBG_OPT_STG(oldn, n)                                       \
37   do {                                                             \
38           ir_node *ons[2];                                         \
39           ons[0] = oldn;                                           \
40           ons[1] = get_Block_cfgpred(oldn, 0);                     \
41           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_STG);    \
42           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
43         } while(0)
44
45 /**
46  * Merge the debug info due to an if simplification
47  */
48 #define DBG_OPT_IFSIM(oldn, a, b, n)                                  \
49   do {                                                                \
50           ir_node *ons[4];                                            \
51           ons[0] = oldn;                                              \
52           ons[1] = a;                                                 \
53           ons[2] = b;                                                 \
54           ons[3] = get_Proj_pred(a);                                  \
55           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_IFSIM);     \
56           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
57         } while(0)
58
59 /**
60  * Merge the debug info due to an algebraic_simplification
61  */
62 #define DBG_OPT_CSTEVAL(oldn, n)                                        \
63   do {                                                                  \
64           stat_merge_nodes(&n, 1, &oldn, 1, STAT_OPT_CONST_EVAL);       \
65           __dbg_info_merge_pair(n, oldn, dbg_const_eval);               \
66   } while(0)
67
68 #define DBG_OPT_ALGSIM1(oldn, a, b, n)                                \
69   do {                                                                \
70           ir_node *ons[3];                                            \
71           ons[0] = oldn;                                              \
72           ons[1] = a;                                                 \
73           ons[2] = b;                                                 \
74           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_ALGSIM);    \
75           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
76   } while(0)
77
78 #define DBG_OPT_ALGSIM2(oldn, pred, n)                                \
79   do {                                                                \
80           ir_node *ons[3];                                            \
81           ons[0] = oldn;                                              \
82           ons[1] = pred;                                              \
83           ons[2] = n;                                                 \
84           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_ALGSIM);    \
85           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
86   } while(0)
87
88 #define DBG_OPT_ALGSIM3(oldn, a, n)                                   \
89   do {                                                                \
90           ir_node *ons[2];                                            \
91           ons[0] = oldn;                                              \
92           ons[1] = a;                                                 \
93           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_ALGSIM);    \
94           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
95   } while(0)
96
97 #define DBG_OPT_PHI(oldn, first_val, n)                               \
98   do {                                                                \
99           ir_node *ons[2];                                            \
100           ons[0] = oldn;                                              \
101           ons[1] = first_val;                                         \
102           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_PHI);       \
103           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_ssa);   \
104   } while(0)
105
106
107 /**
108  * Merge the debug info due to Write-after-Write optimization:
109  * Store oldst will be replace by a reference to Store st
110  */
111 #define DBG_OPT_WAW(oldst, st)                                        \
112   do {                                                                \
113           ir_node *ons[2];                                            \
114           ons[0] = oldst;                                             \
115           ons[1] = st;                                                \
116           stat_merge_nodes(&st, 1, ons, SIZ(ons), STAT_OPT_WAW);      \
117           __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
118   } while(0)
119
120 /**
121  * Merge the debug info due to Write-after-Read optimization:
122  * store will be replace by a reference to load
123  */
124 #define DBG_OPT_WAR(store, load)                                      \
125   do {                                                                \
126           ir_node *ons[2];                                            \
127           ons[0] = store;                                             \
128           ons[1] = load;                                              \
129           stat_merge_nodes(&load, 1, ons, SIZ(ons), STAT_OPT_WAR);    \
130           __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
131   } while(0)
132
133 /**
134  * Merge the debug info due to Read-after-Write optimization:
135  * load will be replace by a reference to store
136  */
137 #define DBG_OPT_RAW(store, load)                                      \
138   do {                                                                \
139           ir_node *ons[2];                                            \
140           ons[0] = store;                                             \
141           ons[1] = load;                                              \
142           stat_merge_nodes(&store, 1, ons, SIZ(ons), STAT_OPT_RAW);   \
143           __dbg_info_merge_sets(&store, 1, ons, SIZ(ons), dbg_read_after_write); \
144   } while(0)
145
146 /**
147  * Merge the debug info due to Read-after-Read optimization:
148  * Load oldld will be replace by a reference to Load ld
149  */
150 #define DBG_OPT_RAR(oldld, ld)                                        \
151   do {                                                                \
152           ir_node *ons[2];                                            \
153           ons[0] = oldld;                                             \
154           ons[1] = ld;                                                \
155           stat_merge_nodes(&ld, 1, ons, SIZ(ons), STAT_OPT_RAR);      \
156           __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
157   } while(0)
158
159 /**
160  * Merge the debug info due to Read-a-Const optimization:
161  * Load ld will be replace by a Constant
162  */
163 #define DBG_OPT_RC(ld, c)                                             \
164   do {                                                                \
165           ir_node *ons[2];                                            \
166           ons[0] = ld;                                                \
167           ons[1] = c;                                                 \
168           stat_merge_nodes(&c, 1, ons, SIZ(ons), STAT_OPT_RC);        \
169           __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
170         } while(0)
171
172 #define DBG_OPT_TUPLE(oldn, a, n)                                     \
173   do {                                                                \
174           ir_node *ons[3];                                            \
175           ons[0] = oldn;                                              \
176           ons[1] = a;                                                 \
177           ons[2] = n;                                                 \
178           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_TUPLE);     \
179           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode);      \
180   } while(0)
181
182 #define DBG_OPT_ID(oldn, n)                                           \
183   do {                                                                \
184           ir_node *ons[2];                                            \
185           ons[0] = oldn;                                              \
186           ons[1] = n;                                                 \
187           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_ID);        \
188           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode);      \
189   } while(0)
190
191 /**
192  * Merge the debug info due to ommon-subexpression elimination
193  */
194 #define DBG_OPT_CSE(oldn, n)                                          \
195   do {                                                                \
196           ir_node *ons[2];                                            \
197           ons[0] = oldn;                                              \
198           ons[1] = n;                                                 \
199           stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_CSE);       \
200           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse);   \
201   } while(0)
202
203 #define DBG_OPT_POLY_ALLOC(oldn, n)                                 \
204   do {                                                              \
205     ir_node *ons[3];                                                \
206     ons[0] = oldn;                                                  \
207     ons[1] = skip_Proj(get_Sel_ptr(oldn));                          \
208     ons[2] = n;                                                     \
209     stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_POLY_CALL);     \
210     __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_rem_poly_call); \
211   } while(0)
212
213 #define DBG_OPT_POLY(oldn, n)                                   \
214   do {                                                          \
215     stat_merge_nodes(&n, 1, &oldn, 1, STAT_OPT_POLY_CALL);      \
216     __dbg_info_merge_pair(n, oldn, dbg_rem_poly_call);          \
217   } while(0)