2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Debug macros used in iropt.
23 * @author Goetz Lindenmaier, Michael Beck
26 #ifndef FIRM_IR_IROPT_DBG_H
27 #define FIRM_IR_IROPT_DBG_H
29 #include "dbginfo_t.h"
33 /* This file contains makros that generate the calls to
34 update the debug information after a transformation. */
36 #define SIZ(x) sizeof(x)/sizeof((x)[0])
40 * Merge the debug info due to dead block elimination.
42 * @param oldn the block that it is eliminated
43 * @param n the new node for this block, may be equal to oldn
45 #define DBG_OPT_DEAD_BLOCK(oldn, n) \
47 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_DEAD_BLOCK); \
48 __dbg_info_merge_pair(n, oldn, dbg_dead_code); \
53 * Merge the debug info due to a straightening optimization.
54 * Block oldn is merged with n.
56 * @param oldn the old block
57 * @param n the new block the merges with oldn
59 #define DBG_OPT_STG(oldn, n) \
63 ons[1] = get_Block_cfgpred(oldn, 0); \
64 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG); \
65 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
69 * Merge the debug info due to an if simplification.
71 * @param oldn the old Block
72 * @param proj1 the first ProjX predecessor
73 * @param proj2 the second ProjX predecessor
74 * @param n the new Block
76 #define DBG_OPT_IFSIM1(oldn, proj1, proj2, n) \
82 ons[3] = get_Proj_pred(proj1); \
83 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM); \
84 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
88 * Merge the debug info due to an if simplification.
89 * @param oldn the old Cond
90 * @param n the new Jmp
92 #define DBG_OPT_IFSIM2(oldn, n) \
94 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_IFSIM); \
95 __dbg_info_merge_pair(n, oldn, dbg_if_simplification); \
99 * Merge the debug info due to an algebraic_simplification.
100 * A node could be avaluated into a Constant.
102 * @param oldn the node
103 * @param n the new constant holding the value
105 #define DBG_OPT_CSTEVAL(oldn, n) \
107 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
108 __dbg_info_merge_pair(n, oldn, dbg_const_eval); \
112 * Merge the debug info due to an algebraic_simplification.
114 * @param oldn the old node
115 * @param n the new node replacing oldn
116 * @param flag firm statistics option
118 #define DBG_OPT_ALGSIM0(oldn, n, flag) \
120 hook_merge_nodes(&n, 1, &oldn, 1, flag); \
121 __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
125 * Merge the debug info due to an algebraic_simplification.
127 * @param oldn the old node
128 * @param a a predecessor of oldn
129 * @param b a predecessor of oldn
130 * @param n the new node replacing oldn
131 * @param flag firm statistics option
133 #define DBG_OPT_ALGSIM1(oldn, a, b, n, flag) \
139 hook_merge_nodes(&n, 1, ons, SIZ(ons), flag); \
140 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
144 * Merge the debug info due to an algebraic_simplification.
146 * @param oldn the old node
147 * @param pred the predecessor of oldn
148 * @param n the new node replacing oldn
149 * @param flag firm statistics option
151 #define DBG_OPT_ALGSIM2(oldn, pred, n, flag) \
157 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
158 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
162 * Merge the debug info due to an algebraic_simplification.
164 #define DBG_OPT_ALGSIM3(oldn, a, n) \
169 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
170 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
174 * Merge the debug info due to a Phi optimization.
175 * A Phi node was replaced by one of its input (the only meaningful)
177 * @param phi the Phi node that will be replaced
178 * @param n in Phi Input that will replace Phi
180 #define DBG_OPT_PHI(phi, n) \
182 hook_merge_nodes(&n, 1, &phi, 1, HOOK_OPT_PHI); \
183 __dbg_info_merge_sets(&n, 1, &phi, 1, dbg_opt_ssa); \
188 * Merge the debug info due to a Sync optimization.
189 * A Sync node was replaced by one of its input (the only meaningful)
191 * @param sync the Sync node that will be replaced
192 * @param n in Sync Input that will replace Sync
194 #define DBG_OPT_SYNC(sync, n) \
196 hook_merge_nodes(&n, 1, &sync, 1, HOOK_OPT_SYNC); \
197 __dbg_info_merge_sets(&n, 1, &sync, 1, dbg_opt_ssa); \
202 * Merge the debug info due to Write-after-Write optimization:
203 * Store oldst will be removed, because Store st overwrites it.
205 * @param oldst the old store that will be removed
206 * @param st the other store that overwrites oldst
208 #define DBG_OPT_WAW(oldst, st) \
213 hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW); \
214 __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
218 * Merge the debug info due to Write-after-Read optimization:
219 * A store will be removed because it rite a value just read back.
221 * @param store the store that will be removed
222 * @param load the load that produces the value that store will write back
224 #define DBG_OPT_WAR(store, load) \
229 hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR); \
230 __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
234 * Merge the debug info due to Read-after-Write optimization:
235 * A load will be replaced by a value that was just stored.
237 * @param load the load that will be replaced
238 * @param value the value that will replace the load
240 #define DBG_OPT_RAW(load, value) \
245 hook_merge_nodes(&value, 1, ons, SIZ(ons), HOOK_OPT_RAW); \
246 __dbg_info_merge_sets(&value, 1, ons, SIZ(ons), dbg_read_after_write); \
250 * Merge the debug info due to Read-after-Read optimization:
251 * Load oldld will be replace by a reference to Load ld.
253 * @param oldld the old load that can be replaced
254 * @param ld the load that produces the same values
256 #define DBG_OPT_RAR(oldld, ld) \
261 hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR); \
262 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
266 * Merge the debug info due to Read-a-Const optimization:
267 * Load ld will be replace by a Constant if the value that
268 * will be loaded is known and immutable.
271 * @param c the constant value that will replace the load's result
273 #define DBG_OPT_RC(ld, c) \
278 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC); \
279 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
283 * Merge the debug info after a tuple optimization.
284 * a Proj(Tuple) is replaced by the associated tuple value.
286 * @param proj the Proj node
287 * @param tuple the Tuple node
288 * @param n the Proj(Tuple) value
290 #define DBG_OPT_TUPLE(proj, tuple, n) \
296 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE); \
297 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
301 * Merge the debug info after an Id optimization.
302 * An Id node was replaced by its non-Id predecessor.
304 * @param id the Id node
305 * @param n the predecessor
307 #define DBG_OPT_ID(id, n) \
312 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID); \
313 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
317 * Merge the debug info due to common-subexpression elimination.
319 * @param oldn the old node
320 * @param n the node that replaces oldn
322 #define DBG_OPT_CSE(oldn, n) \
327 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE); \
328 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse); \
332 * Merge the debug info due to polymorphic call optimization.
333 * A Sel node was replaced by a constant.
335 * @param sel the Sel node that will be replaced.
336 * @param c the constant node that replaces sel
338 #define DBG_OPT_POLY(sel, c) \
342 ons[1] = skip_Proj(get_Sel_ptr(sel)); \
344 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL); \
345 __dbg_info_merge_sets(&c, 1, ons, SIZ(ons), dbg_rem_poly_call); \
349 * A node was replaced by another node due to a Confirmation.
351 * @param oldn the old node
352 * @param n the new node
354 #define DBG_OPT_CONFIRM(oldn, n) \
356 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
357 __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
361 * A node was replaced by a constant due to a Confimation.
363 * @param oldn the old node
364 * @param c the new constant node
366 #define DBG_OPT_CONFIRM_C(oldn, c) \
368 hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
369 __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
373 * A exception exdge was removed due to a Confirmation prove.
375 * @param oldn the old node
377 #define DBG_OPT_EXC_REM(oldn) \
379 hook_merge_nodes(NULL, 0, &oldn, 1, HOOK_OPT_EXC_REM); \
383 * A node could be evaluated to a value due to a Confirm.
384 * This will lead to a constant evaluation.
386 * @param n the node that could be evaluated
388 #define DBG_EVAL_CONFIRM(n) \
390 hook_merge_nodes(NULL, 0, &n, 1, HOOK_OPT_CONFIRM_E); \