3 * File name: ir/ir/iropt_dbg.h
4 * Purpose: Debug makros used in iropt.
5 * Author: Goetz Lindenmaier
9 * Copyright: (c) 2001-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
16 #include "dbginfo_t.h"
20 /* This file contains makros that generate the calls to
21 update the debug information after a transformation. */
23 #define SIZ(x) sizeof(x)/sizeof((x)[0])
27 * Merge the debug info due to dead block elimination.
29 * @param oldn the block that it is eliminated
30 * @param n the new node for this block, may be equal to oldn
32 #define DBG_OPT_DEAD_BLOCK(oldn, n) \
34 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_DEAD_BLOCK); \
35 __dbg_info_merge_pair(n, oldn, dbg_dead_code); \
40 * Merge the debug info due to a straightening optimization.
41 * Block oldn is merged with n.
43 * @param oldn the old block
44 * @param n the new block the merges with oldn
46 #define DBG_OPT_STG(oldn, n) \
50 ons[1] = get_Block_cfgpred(oldn, 0); \
51 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG); \
52 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
56 * Merge the debug info due to an if simplification.
58 * @param oldn the old Block
59 * @param proj1 the first ProjX predecessor
60 * @param proj2 the second ProjX predecessor
61 * @param n the new Block
63 #define DBG_OPT_IFSIM1(oldn, proj1, proj2, n) \
69 ons[3] = get_Proj_pred(proj1); \
70 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM); \
71 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
75 * Merge the debug info due to an if simplification.
76 * @param oldn the old Cond
77 * @param n the new Jmp
79 #define DBG_OPT_IFSIM2(oldn, n) \
81 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_IFSIM); \
82 __dbg_info_merge_pair(n, oldn, dbg_if_simplification); \
86 * Merge the debug info due to an algebraic_simplification.
87 * A node could be avaluated into a Constant.
89 * @param oldn the node
90 * @param n the new constant holding the value
92 #define DBG_OPT_CSTEVAL(oldn, n) \
94 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
95 __dbg_info_merge_pair(n, oldn, dbg_const_eval); \
99 * Merge the debug info due to an algebraic_simplification.
101 * @param oldn the old node
102 * @param n the new node replacing oldn
103 * @param flag firm statistics option
105 #define DBG_OPT_ALGSIM0(oldn, n, flag) \
107 hook_merge_nodes(&n, 1, &oldn, 1, flag); \
108 __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
112 * Merge the debug info due to an algebraic_simplification.
114 * @param oldn the old node
115 * @param a a predecessor of oldn
116 * @param b a predecessor of oldn
117 * @param n the new node replacing oldn
118 * @param flag firm statistics option
120 #define DBG_OPT_ALGSIM1(oldn, a, b, n, flag) \
126 hook_merge_nodes(&n, 1, ons, SIZ(ons), flag); \
127 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
131 * Merge the debug info due to an algebraic_simplification.
133 #define DBG_OPT_ALGSIM2(oldn, pred, n) \
139 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
140 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
144 * Merge the debug info due to an algebraic_simplification.
146 #define DBG_OPT_ALGSIM3(oldn, a, n) \
151 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
152 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
156 * Merge the debuig info due to a Phi optimization.
157 * A Phi node was replaced by one of its input (the only meaningful)
159 * @param phi the Phi node that will be replaced
160 * @param n in Phi Input that will replace Phi
162 #define DBG_OPT_PHI(phi, n) \
164 hook_merge_nodes(&n, 1, &phi, 1, HOOK_OPT_PHI); \
165 __dbg_info_merge_sets(&n, 1, &phi, 1, dbg_opt_ssa); \
170 * Merge the debug info due to Write-after-Write optimization:
171 * Store oldst will be removed, because Store st overwrites it.
173 * @param oldst the old store that will be removed
174 * @param st the other store that overwrites oldst
176 #define DBG_OPT_WAW(oldst, st) \
181 hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW); \
182 __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
186 * Merge the debug info due to Write-after-Read optimization:
187 * A store will be removed because it rite a value just read back.
189 * @param store the store that will be removed
190 * @param load the load that produces the value that store will write back
192 #define DBG_OPT_WAR(store, load) \
197 hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR); \
198 __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
202 * Merge the debug info due to Read-after-Write optimization:
203 * A load will be replaced by a value that was just stored.
205 * @param load the load that will be replaced
206 * @param value the value that will replace the load
208 #define DBG_OPT_RAW(load, value) \
213 hook_merge_nodes(&value, 1, ons, SIZ(ons), HOOK_OPT_RAW); \
214 __dbg_info_merge_sets(&value, 1, ons, SIZ(ons), dbg_read_after_write); \
218 * Merge the debug info due to Read-after-Read optimization:
219 * Load oldld will be replace by a reference to Load ld.
221 * @param oldld the old load that can be replaced
222 * @param ld the load that produces the same values
224 #define DBG_OPT_RAR(oldld, ld) \
229 hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR); \
230 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
234 * Merge the debug info due to Read-a-Const optimization:
235 * Load ld will be replace by a Constant if the value that
236 * will be loaded is known and immutable.
239 * @param c the constant value that will replace the load's result
241 #define DBG_OPT_RC(ld, c) \
246 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC); \
247 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
251 * Merge the debug info after a tuple optimization.
252 * a Proj(Tuple) is replaced by the associated tuple value.
254 * @param oldn the Proj node
255 * @param tuple the Tuple node
256 * @param n the Proj(Tuple) value
258 #define DBG_OPT_TUPLE(proj, tuple, n) \
264 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE); \
265 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
269 * Merge the debug info after an Id optimization.
270 * An Id node was replaced by its non-Id predecessor.
272 * @param id the Id node
273 * @param n the predecessor
275 #define DBG_OPT_ID(id, n) \
280 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID); \
281 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
285 * Merge the debug info due to common-subexpression elimination.
287 * @param oldn the old node
288 * @param n the node that replaces oldn
290 #define DBG_OPT_CSE(oldn, n) \
295 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE); \
296 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse); \
300 * Merge the debug info due to polymorphic call optimization.
301 * A Sel node was replaced by a constant.
303 * @param sel the Sel node that will be replaced.
304 * @param c the constant node that replaces sel
306 #define DBG_OPT_POLY(sel, c) \
310 ons[1] = skip_Proj(get_Sel_ptr(sel)); \
312 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL); \
313 __dbg_info_merge_sets(&c, 1, ons, SIZ(ons), dbg_rem_poly_call); \
317 * A node was replaced by another node due to a Confirmation.
319 * @param oldn the old node
320 * @param n the new node
322 #define DBG_OPT_CONFIRM(oldn, n) \
324 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
325 __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
329 * A node was replaced by a constant due to a Confimation.
331 * @param oldn the old node
332 * @param c the new constnt node
334 #define DBG_OPT_CONFIRM_C(oldn, c) \
336 hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
337 __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
341 * A node could be evaluated to a value due to a Confirm.
342 * This will lead to a constant evaluation.
344 * @param n the node that could be evaluated
346 #define DBG_EVAL_CONFIRM(n) \
348 hook_merge_nodes(NULL, 0, &n, 1, HOOK_OPT_CONFIRM_E); \
351 #endif /* _IROPT_DBG_H_ */