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 debug 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 a Sync optimization.
171 * A Sync node was replaced by one of its input (the only meaningful)
173 * @param sync the Sync node that will be replaced
174 * @param n in Sync Input that will replace Sync
176 #define DBG_OPT_SYNC(sync, n) \
178 hook_merge_nodes(&n, 1, &sync, 1, HOOK_OPT_SYNC); \
179 __dbg_info_merge_sets(&n, 1, &sync, 1, dbg_opt_ssa); \
184 * Merge the debug info due to Write-after-Write optimization:
185 * Store oldst will be removed, because Store st overwrites it.
187 * @param oldst the old store that will be removed
188 * @param st the other store that overwrites oldst
190 #define DBG_OPT_WAW(oldst, st) \
195 hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW); \
196 __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
200 * Merge the debug info due to Write-after-Read optimization:
201 * A store will be removed because it rite a value just read back.
203 * @param store the store that will be removed
204 * @param load the load that produces the value that store will write back
206 #define DBG_OPT_WAR(store, load) \
211 hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR); \
212 __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
216 * Merge the debug info due to Read-after-Write optimization:
217 * A load will be replaced by a value that was just stored.
219 * @param load the load that will be replaced
220 * @param value the value that will replace the load
222 #define DBG_OPT_RAW(load, value) \
227 hook_merge_nodes(&value, 1, ons, SIZ(ons), HOOK_OPT_RAW); \
228 __dbg_info_merge_sets(&value, 1, ons, SIZ(ons), dbg_read_after_write); \
232 * Merge the debug info due to Read-after-Read optimization:
233 * Load oldld will be replace by a reference to Load ld.
235 * @param oldld the old load that can be replaced
236 * @param ld the load that produces the same values
238 #define DBG_OPT_RAR(oldld, ld) \
243 hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR); \
244 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
248 * Merge the debug info due to Read-a-Const optimization:
249 * Load ld will be replace by a Constant if the value that
250 * will be loaded is known and immutable.
253 * @param c the constant value that will replace the load's result
255 #define DBG_OPT_RC(ld, c) \
260 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC); \
261 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
265 * Merge the debug info after a tuple optimization.
266 * a Proj(Tuple) is replaced by the associated tuple value.
268 * @param proj the Proj node
269 * @param tuple the Tuple node
270 * @param n the Proj(Tuple) value
272 #define DBG_OPT_TUPLE(proj, tuple, n) \
278 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE); \
279 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
283 * Merge the debug info after an Id optimization.
284 * An Id node was replaced by its non-Id predecessor.
286 * @param id the Id node
287 * @param n the predecessor
289 #define DBG_OPT_ID(id, n) \
294 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID); \
295 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
299 * Merge the debug info due to common-subexpression elimination.
301 * @param oldn the old node
302 * @param n the node that replaces oldn
304 #define DBG_OPT_CSE(oldn, n) \
309 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE); \
310 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse); \
314 * Merge the debug info due to polymorphic call optimization.
315 * A Sel node was replaced by a constant.
317 * @param sel the Sel node that will be replaced.
318 * @param c the constant node that replaces sel
320 #define DBG_OPT_POLY(sel, c) \
324 ons[1] = skip_Proj(get_Sel_ptr(sel)); \
326 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL); \
327 __dbg_info_merge_sets(&c, 1, ons, SIZ(ons), dbg_rem_poly_call); \
331 * A node was replaced by another node due to a Confirmation.
333 * @param oldn the old node
334 * @param n the new node
336 #define DBG_OPT_CONFIRM(oldn, n) \
338 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
339 __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
343 * A node was replaced by a constant due to a Confimation.
345 * @param oldn the old node
346 * @param c the new constant node
348 #define DBG_OPT_CONFIRM_C(oldn, c) \
350 hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
351 __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
355 * A exception exdge was removed due to a Confirmation prove.
357 * @param oldn the old node
359 #define DBG_OPT_EXC_REM(oldn) \
361 hook_merge_nodes(NULL, 0, &oldn, 1, HOOK_OPT_EXC_REM); \
365 * A node could be evaluated to a value due to a Confirm.
366 * This will lead to a constant evaluation.
368 * @param n the node that could be evaluated
370 #define DBG_EVAL_CONFIRM(n) \
372 hook_merge_nodes(NULL, 0, &n, 1, HOOK_OPT_CONFIRM_E); \
375 #endif /* _IROPT_DBG_H_ */