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) \
36 ons[1] = get_Block_cfgpred(oldn, 0); \
37 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_DEAD_BLOCK); \
38 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_dead_code); \
43 * Merge the debug info due to a straightening optimization.
44 * Block oldn is merged with n.
46 * @param oldn the old block
47 * @param n the new block the merges with oldn
49 #define DBG_OPT_STG(oldn, n) \
53 ons[1] = get_Block_cfgpred(oldn, 0); \
54 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG); \
55 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
59 * Merge the debug info due to an if simplification.
61 * @param oldn the old Block
62 * @param proj1 the first ProjX predecessor
63 * @param proj2 the second ProjX predecessor
64 * @param n the new Block
66 #define DBG_OPT_IFSIM1(oldn, proj1, proj2, n) \
72 ons[3] = get_Proj_pred(proj1); \
73 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM); \
74 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
78 * Merge the debug info due to an if simplification.
79 * @param oldn the old Cond
80 * @param n the new Jmp
82 #define DBG_OPT_IFSIM2(oldn, n) \
84 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_IFSIM); \
85 __dbg_info_merge_pair(n, oldn, dbg_if_simplification); \
89 * Merge the debug info due to an algebraic_simplification.
90 * A node could be avaluated into a Constant.
92 * @param oldn the node
93 * @param n the new constant holding the value
95 #define DBG_OPT_CSTEVAL(oldn, n) \
97 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
98 __dbg_info_merge_pair(n, oldn, dbg_const_eval); \
102 * Merge the debug info due to an algebraic_simplification.
104 * @param oldn the old node
105 * @param n the new node replacing oldn
106 * @param flag firm statistics option
108 #define DBG_OPT_ALGSIM0(oldn, n, flag) \
110 hook_merge_nodes(&n, 1, &oldn, 1, flag); \
111 __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
115 * Merge the debug info due to an algebraic_simplification.
117 * @param oldn the old node
118 * @param a a predecessor of oldn
119 * @param b a predecessor of oldn
120 * @param n the new node replacing oldn
121 * @param flag firm statistics option
123 #define DBG_OPT_ALGSIM1(oldn, a, b, n, flag) \
129 hook_merge_nodes(&n, 1, ons, SIZ(ons), flag); \
130 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
134 * Merge the debug info due to an algebraic_simplification.
136 #define DBG_OPT_ALGSIM2(oldn, pred, n) \
142 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
143 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
147 * Merge the debug info due to an algebraic_simplification.
149 #define DBG_OPT_ALGSIM3(oldn, a, n) \
154 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
155 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
159 * Merge the debuig info due to a Phi optimization.
160 * A Phi node was replaced by one of its input (the only meaningful)
162 * @param phi the Phi node that will be replaced
163 * @param n in Phi Input that will replace Phi
165 #define DBG_OPT_PHI(phi, n) \
167 hook_merge_nodes(&n, 1, &phi, 1, HOOK_OPT_PHI); \
168 __dbg_info_merge_sets(&n, 1, &phi, 1, dbg_opt_ssa); \
173 * Merge the debug info due to Write-after-Write optimization:
174 * Store oldst will be removed, because Store st overwrites it.
176 * @param oldst the old store that will be removed
177 * @param st the other store that overwrites oldst
179 #define DBG_OPT_WAW(oldst, st) \
184 hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW); \
185 __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
189 * Merge the debug info due to Write-after-Read optimization:
190 * A store will be removed because it rite a value just read back.
192 * @param store the store that will be removed
193 * @param load the load that produces the value that store will write back
195 #define DBG_OPT_WAR(store, load) \
200 hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR); \
201 __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
205 * Merge the debug info due to Read-after-Write optimization:
206 * A load will be replaced by a value that was just stored.
208 * @param load the load that will be replaced
209 * @param value the value that will replace the load
211 #define DBG_OPT_RAW(load, value) \
216 hook_merge_nodes(&value, 1, ons, SIZ(ons), HOOK_OPT_RAW); \
217 __dbg_info_merge_sets(&value, 1, ons, SIZ(ons), dbg_read_after_write); \
221 * Merge the debug info due to Read-after-Read optimization:
222 * Load oldld will be replace by a reference to Load ld.
224 * @param oldld the old load that can be replaced
225 * @param ld the load that produces the same values
227 #define DBG_OPT_RAR(oldld, ld) \
232 hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR); \
233 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
237 * Merge the debug info due to Read-a-Const optimization:
238 * Load ld will be replace by a Constant if the value that
239 * will be loaded is known and immutable.
242 * @param c the constant value that will replace the load's result
244 #define DBG_OPT_RC(ld, c) \
249 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC); \
250 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
254 * Merge the debug info after a tuple optimization.
255 * a Proj(Tuple) is replaced by the associated tuple value.
257 * @param oldn the Proj node
258 * @param tuple the Tuple node
259 * @param n the Proj(Tuple) value
261 #define DBG_OPT_TUPLE(proj, tuple, n) \
267 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE); \
268 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
272 * Merge the debug info after an Id optimization.
273 * An Id node was replaced by its non-Id predecessor.
275 * @param id the Id node
276 * @param n the predecessor
278 #define DBG_OPT_ID(id, n) \
283 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID); \
284 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
288 * Merge the debug info due to common-subexpression elimination.
290 * @param oldn the old node
291 * @param n the node that replaces oldn
293 #define DBG_OPT_CSE(oldn, n) \
298 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE); \
299 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse); \
303 * Merge the debug info due to polymorphic call optimization.
304 * A Sel node was replaced by a constant.
306 * @param sel the Sel node that will be replaced.
307 * @param c the constant node that replaces sel
309 #define DBG_OPT_POLY(sel, c) \
313 ons[1] = skip_Proj(get_Sel_ptr(sel)); \
315 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL); \
316 __dbg_info_merge_sets(&c, 1, ons, SIZ(ons), dbg_rem_poly_call); \
320 * A node was replaced by another node due to a Confirmation.
322 * @param oldn the old node
323 * @param n the new node
325 #define DBG_OPT_CONFIRM(oldn, n) \
327 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
328 __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
332 * A node was replaced by a constant due to a Confimation.
334 * @param oldn the old node
335 * @param c the new constnt node
337 #define DBG_OPT_CONFIRM_C(oldn, c) \
339 hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
340 __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
344 * A node could be evaluated to a value due to a Confirm.
345 * This will lead to a constant evaluation.
347 * @param n the node that could be evaluated
349 #define DBG_EVAL_CONFIRM(n) \
351 hook_merge_nodes(NULL, 0, &n, 1, HOOK_OPT_CONFIRM_E); \
354 #endif /* _IROPT_DBG_H_ */