2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Debug macros used in iropt.
9 * @author Goetz Lindenmaier, Michael Beck
11 #ifndef FIRM_IR_IROPT_DBG_H
12 #define FIRM_IR_IROPT_DBG_H
14 #include "dbginfo_t.h"
20 * Merge the debug info due to dead block elimination.
22 * @param oldn the block that it is eliminated
23 * @param n the new node for this block, may be equal to oldn
25 #define DBG_OPT_DEAD_BLOCK(oldn, n) \
27 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_DEAD_BLOCK); \
28 __dbg_info_merge_pair(n, oldn, dbg_dead_code); \
33 * Merge the debug info due to a straightening optimization.
34 * Block oldn is merged with n.
36 * @param oldn the old block
37 * @param n the new block the merges with oldn
39 #define DBG_OPT_STG(oldn, n) \
43 ons[1] = get_Block_cfgpred(oldn, 0); \
44 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_STG); \
45 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_straightening); \
49 * Merge the debug info due to an if simplification.
51 * @param oldn the old Block
52 * @param proj1 the first ProjX predecessor
53 * @param proj2 the second ProjX predecessor
54 * @param n the new Block
56 #define DBG_OPT_IFSIM1(oldn, proj1, proj2, n) \
62 ons[3] = get_Proj_pred(proj1); \
63 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_IFSIM); \
64 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_if_simplification); \
68 * Merge the debug info due to an if simplification.
69 * @param oldn the old Cond
70 * @param n the new Jmp
72 #define DBG_OPT_IFSIM2(oldn, n) \
74 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_IFSIM); \
75 __dbg_info_merge_pair(n, oldn, dbg_if_simplification); \
79 * Merge the debug info due to an algebraic_simplification.
80 * A node could be evaluated into a Constant.
82 * @param oldn the node
83 * @param n the new constant holding the value
85 #define DBG_OPT_CSTEVAL(oldn, n) \
87 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
88 __dbg_info_merge_pair(n, oldn, dbg_const_eval); \
92 * Merge the debug info due to an algebraic_simplification.
94 * @param oldn the old node
95 * @param n the new node replacing oldn
96 * @param flag firm statistics option
98 #define DBG_OPT_ALGSIM0(oldn, n, flag) \
100 hook_merge_nodes(&n, 1, &oldn, 1, (hook_opt_kind)flag); \
101 __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
105 * Merge the debug info due to an algebraic_simplification.
107 * @param oldn the old node
108 * @param a a predecessor of oldn
109 * @param b a predecessor of oldn
110 * @param n the new node replacing oldn
111 * @param flag firm statistics option
113 #define DBG_OPT_ALGSIM1(oldn, a, b, n, flag) \
119 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), (hook_opt_kind)flag); \
120 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
124 * Merge the debug info due to an algebraic_simplification.
126 * @param oldn the old node
127 * @param pred the predecessor of oldn
128 * @param n the new node replacing oldn
129 * @param flag firm statistics option
131 #define DBG_OPT_ALGSIM2(oldn, pred, n, flag) \
137 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), (hook_opt_kind)flag); \
138 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
142 * Merge the debug info due to an algebraic_simplification.
144 #define DBG_OPT_ALGSIM3(oldn, a, n, flag) \
149 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), flag); \
150 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
154 * Merge the debug info due to a Phi optimization.
155 * A Phi node was replaced by one of its input (the only meaningful)
157 * @param phi the Phi node that will be replaced
158 * @param n in Phi Input that will replace Phi
160 #define DBG_OPT_PHI(phi, n) \
162 hook_merge_nodes(&n, 1, &phi, 1, HOOK_OPT_PHI); \
163 __dbg_info_merge_sets(&n, 1, &phi, 1, dbg_opt_ssa); \
168 * Merge the debug info due to a Sync optimization.
169 * A Sync node was replaced by one of its input (the only meaningful)
171 * @param sync the Sync node that will be replaced
172 * @param n in Sync Input that will replace Sync
174 #define DBG_OPT_SYNC(sync, n) \
176 hook_merge_nodes(&n, 1, &sync, 1, HOOK_OPT_SYNC); \
177 __dbg_info_merge_sets(&n, 1, &sync, 1, dbg_opt_ssa); \
182 * Merge the debug info due to Write-after-Write optimization:
183 * Store oldst will be removed, because Store st overwrites it.
185 * @param oldst the old store that will be removed
186 * @param st the other store that overwrites oldst
188 #define DBG_OPT_WAW(oldst, st) \
193 hook_merge_nodes(&st, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_WAW); \
194 __dbg_info_merge_sets(&st, 1, ons, ARRAY_SIZE(ons), dbg_write_after_write); \
198 * Merge the debug info due to Write-after-Read optimization:
199 * A store will be removed because it rite a value just read back.
201 * @param store the store that will be removed
202 * @param load the load that produces the value that store will write back
204 #define DBG_OPT_WAR(store, load) \
209 hook_merge_nodes(&load, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_WAR); \
210 __dbg_info_merge_sets(&load, 1, ons, ARRAY_SIZE(ons), dbg_write_after_read); \
214 * Merge the debug info due to Read-after-Write optimization:
215 * A load will be replaced by a value that was just stored.
217 * @param load the load that will be replaced
218 * @param value the value that will replace the load
220 #define DBG_OPT_RAW(load, value) \
225 hook_merge_nodes(&value, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RAW); \
226 __dbg_info_merge_sets(&value, 1, ons, ARRAY_SIZE(ons), dbg_read_after_write); \
230 * Merge the debug info due to Read-after-Read optimization:
231 * Load oldld will be replace by a reference to Load ld.
233 * @param oldld the old load that can be replaced
234 * @param ld the load that produces the same values
236 #define DBG_OPT_RAR(oldld, ld) \
241 hook_merge_nodes(&ld, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RAR); \
242 __dbg_info_merge_sets(&ld, 1, ons, ARRAY_SIZE(ons), dbg_read_after_read); \
246 * Merge the debug info due to Read-a-Const optimization:
247 * Load ld will be replace by a Constant if the value that
248 * will be loaded is known and immutable.
251 * @param c the constant value that will replace the load's result
253 #define DBG_OPT_RC(ld, c) \
258 hook_merge_nodes(&c, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RC); \
259 __dbg_info_merge_sets(&ld, 1, ons, ARRAY_SIZE(ons), dbg_read_a_const); \
263 * Merge the debug info after a tuple optimization.
264 * a Proj(Tuple) is replaced by the associated tuple value.
266 * @param proj the Proj node
267 * @param tuple the Tuple node
268 * @param n the Proj(Tuple) value
270 #define DBG_OPT_TUPLE(proj, tuple, n) \
276 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_TUPLE); \
277 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_auxnode); \
281 * Merge the debug info after an Id optimization.
282 * An Id node was replaced by its non-Id predecessor.
284 * @param id the Id node
285 * @param n the predecessor
287 #define DBG_OPT_ID(id, n) \
292 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_ID); \
293 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_auxnode); \
297 * Merge the debug info due to common-subexpression elimination.
299 * @param oldn the old node
300 * @param n the node that replaces oldn
302 #define DBG_OPT_CSE(oldn, n) \
307 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_CSE); \
308 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_cse); \
312 * Merge the debug info due to polymorphic call optimization.
313 * A Sel node was replaced by a constant.
315 * @param sel the Sel node that will be replaced.
316 * @param c the constant node that replaces sel
318 #define DBG_OPT_POLY(sel, c) \
322 ons[1] = skip_Proj(get_Sel_ptr(sel)); \
324 hook_merge_nodes(&c, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_POLY_CALL); \
325 __dbg_info_merge_sets(&c, 1, ons, ARRAY_SIZE(ons), dbg_rem_poly_call); \
329 * A node was replaced by another node due to a Confirmation.
331 * @param oldn the old node
332 * @param n the new node
334 #define DBG_OPT_CONFIRM(oldn, n) \
336 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
337 __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
341 * A node was replaced by a constant due to a Confimation.
343 * @param oldn the old node
344 * @param c the new constant node
346 #define DBG_OPT_CONFIRM_C(oldn, c) \
348 hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
349 __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
353 * A exception exdge was removed due to a Confirmation prove.
355 * @param oldn the old node
357 #define DBG_OPT_EXC_REM(oldn) \
359 hook_merge_nodes(NULL, 0, &oldn, 1, HOOK_OPT_EXC_REM); \
363 * A node could be evaluated to a value due to a Confirm.
364 * This will lead to a constant evaluation.
366 * @param n the node that could be evaluated
368 #define DBG_EVAL_CONFIRM(n) \
370 hook_merge_nodes(NULL, 0, (ir_node**)&n, 1, HOOK_OPT_CONFIRM_E); \
374 * Merge the debug info due to a GVN-PRE result.
376 * @param oldn the old node
377 * @param n the new node replacing oldn
378 * @param flag firm statistics option
380 #define DBG_OPT_GVN_PRE(oldn, n, flag) \
382 hook_merge_nodes(&n, 1, &oldn, 1, (hook_opt_kind)flag); \
383 __dbg_info_merge_pair(n, oldn, dbg_gvn_pre); \
387 * Merge the debug info due to a combo result.
389 * @param oldn the old node
390 * @param n the new node replacing oldn
391 * @param flag firm statistics option
393 #define DBG_OPT_COMBO(oldn, n, flag) \
395 hook_merge_nodes(&n, 1, &oldn, 1, (hook_opt_kind)flag); \
396 __dbg_info_merge_pair(n, oldn, dbg_combo); \
400 * Merge the debug info due to a jump threading result.
402 * @param oldn the old control flow node
403 * @param n the new control flow node replacing oldn
405 #define DBG_OPT_JUMPTHREADING(oldn, n) \
407 hook_merge_nodes(&n, 1, &oldn, 1, (hook_opt_kind)FS_OPT_JUMPTHREADING); \
408 __dbg_info_merge_pair(n, oldn, dbg_jumpthreading); \