2 * Copyright (C) 1995-2008 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. */
37 * Merge the debug info due to dead block elimination.
39 * @param oldn the block that it is eliminated
40 * @param n the new node for this block, may be equal to oldn
42 #define DBG_OPT_DEAD_BLOCK(oldn, n) \
44 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_DEAD_BLOCK); \
45 __dbg_info_merge_pair(n, oldn, dbg_dead_code); \
50 * Merge the debug info due to a straightening optimization.
51 * Block oldn is merged with n.
53 * @param oldn the old block
54 * @param n the new block the merges with oldn
56 #define DBG_OPT_STG(oldn, n) \
60 ons[1] = get_Block_cfgpred(oldn, 0); \
61 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG); \
62 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
66 * Merge the debug info due to an if simplification.
68 * @param oldn the old Block
69 * @param proj1 the first ProjX predecessor
70 * @param proj2 the second ProjX predecessor
71 * @param n the new Block
73 #define DBG_OPT_IFSIM1(oldn, proj1, proj2, n) \
79 ons[3] = get_Proj_pred(proj1); \
80 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM); \
81 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
85 * Merge the debug info due to an if simplification.
86 * @param oldn the old Cond
87 * @param n the new Jmp
89 #define DBG_OPT_IFSIM2(oldn, n) \
91 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_IFSIM); \
92 __dbg_info_merge_pair(n, oldn, dbg_if_simplification); \
96 * Merge the debug info due to an algebraic_simplification.
97 * A node could be evaluated into a Constant.
99 * @param oldn the node
100 * @param n the new constant holding the value
102 #define DBG_OPT_CSTEVAL(oldn, n) \
104 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
105 __dbg_info_merge_pair(n, oldn, dbg_const_eval); \
109 * Merge the debug info due to an algebraic_simplification.
111 * @param oldn the old node
112 * @param n the new node replacing oldn
113 * @param flag firm statistics option
115 #define DBG_OPT_ALGSIM0(oldn, n, flag) \
117 hook_merge_nodes(&n, 1, &oldn, 1, flag); \
118 __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
122 * Merge the debug info due to an algebraic_simplification.
124 * @param oldn the old node
125 * @param a a predecessor of oldn
126 * @param b a predecessor of oldn
127 * @param n the new node replacing oldn
128 * @param flag firm statistics option
130 #define DBG_OPT_ALGSIM1(oldn, a, b, n, flag) \
136 hook_merge_nodes(&n, 1, ons, SIZ(ons), flag); \
137 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
141 * Merge the debug info due to an algebraic_simplification.
143 * @param oldn the old node
144 * @param pred the predecessor of oldn
145 * @param n the new node replacing oldn
146 * @param flag firm statistics option
148 #define DBG_OPT_ALGSIM2(oldn, pred, n, flag) \
154 hook_merge_nodes(&n, 1, ons, SIZ(ons), flag); \
155 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
159 * Merge the debug info due to an algebraic_simplification.
161 #define DBG_OPT_ALGSIM3(oldn, a, n, flag) \
166 hook_merge_nodes(&n, 1, ons, SIZ(ons), flag); \
167 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
171 * Merge the debug info due to a Phi optimization.
172 * A Phi node was replaced by one of its input (the only meaningful)
174 * @param phi the Phi node that will be replaced
175 * @param n in Phi Input that will replace Phi
177 #define DBG_OPT_PHI(phi, n) \
179 hook_merge_nodes(&n, 1, &phi, 1, HOOK_OPT_PHI); \
180 __dbg_info_merge_sets(&n, 1, &phi, 1, dbg_opt_ssa); \
185 * Merge the debug info due to a Sync optimization.
186 * A Sync node was replaced by one of its input (the only meaningful)
188 * @param sync the Sync node that will be replaced
189 * @param n in Sync Input that will replace Sync
191 #define DBG_OPT_SYNC(sync, n) \
193 hook_merge_nodes(&n, 1, &sync, 1, HOOK_OPT_SYNC); \
194 __dbg_info_merge_sets(&n, 1, &sync, 1, dbg_opt_ssa); \
199 * Merge the debug info due to Write-after-Write optimization:
200 * Store oldst will be removed, because Store st overwrites it.
202 * @param oldst the old store that will be removed
203 * @param st the other store that overwrites oldst
205 #define DBG_OPT_WAW(oldst, st) \
210 hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW); \
211 __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
215 * Merge the debug info due to Write-after-Read optimization:
216 * A store will be removed because it rite a value just read back.
218 * @param store the store that will be removed
219 * @param load the load that produces the value that store will write back
221 #define DBG_OPT_WAR(store, load) \
226 hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR); \
227 __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
231 * Merge the debug info due to Read-after-Write optimization:
232 * A load will be replaced by a value that was just stored.
234 * @param load the load that will be replaced
235 * @param value the value that will replace the load
237 #define DBG_OPT_RAW(load, value) \
242 hook_merge_nodes(&value, 1, ons, SIZ(ons), HOOK_OPT_RAW); \
243 __dbg_info_merge_sets(&value, 1, ons, SIZ(ons), dbg_read_after_write); \
247 * Merge the debug info due to Read-after-Read optimization:
248 * Load oldld will be replace by a reference to Load ld.
250 * @param oldld the old load that can be replaced
251 * @param ld the load that produces the same values
253 #define DBG_OPT_RAR(oldld, ld) \
258 hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR); \
259 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
263 * Merge the debug info due to Read-a-Const optimization:
264 * Load ld will be replace by a Constant if the value that
265 * will be loaded is known and immutable.
268 * @param c the constant value that will replace the load's result
270 #define DBG_OPT_RC(ld, c) \
275 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC); \
276 __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
280 * Merge the debug info after a tuple optimization.
281 * a Proj(Tuple) is replaced by the associated tuple value.
283 * @param proj the Proj node
284 * @param tuple the Tuple node
285 * @param n the Proj(Tuple) value
287 #define DBG_OPT_TUPLE(proj, tuple, n) \
293 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE); \
294 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
298 * Merge the debug info after an Id optimization.
299 * An Id node was replaced by its non-Id predecessor.
301 * @param id the Id node
302 * @param n the predecessor
304 #define DBG_OPT_ID(id, n) \
309 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID); \
310 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
314 * Merge the debug info due to common-subexpression elimination.
316 * @param oldn the old node
317 * @param n the node that replaces oldn
319 #define DBG_OPT_CSE(oldn, n) \
324 hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE); \
325 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse); \
329 * Merge the debug info due to polymorphic call optimization.
330 * A Sel node was replaced by a constant.
332 * @param sel the Sel node that will be replaced.
333 * @param c the constant node that replaces sel
335 #define DBG_OPT_POLY(sel, c) \
339 ons[1] = skip_Proj(get_Sel_ptr(sel)); \
341 hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL); \
342 __dbg_info_merge_sets(&c, 1, ons, SIZ(ons), dbg_rem_poly_call); \
346 * A node was replaced by another node due to a Confirmation.
348 * @param oldn the old node
349 * @param n the new node
351 #define DBG_OPT_CONFIRM(oldn, n) \
353 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
354 __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
358 * A node was replaced by a constant due to a Confimation.
360 * @param oldn the old node
361 * @param c the new constant node
363 #define DBG_OPT_CONFIRM_C(oldn, c) \
365 hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
366 __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
370 * A exception exdge was removed due to a Confirmation prove.
372 * @param oldn the old node
374 #define DBG_OPT_EXC_REM(oldn) \
376 hook_merge_nodes(NULL, 0, &oldn, 1, HOOK_OPT_EXC_REM); \
380 * A node could be evaluated to a value due to a Confirm.
381 * This will lead to a constant evaluation.
383 * @param n the node that could be evaluated
385 #define DBG_EVAL_CONFIRM(n) \
387 hook_merge_nodes(NULL, 0, &n, 1, HOOK_OPT_CONFIRM_E); \
391 * Merge the debug info due to a GVN-PRE result.
393 * @param oldn the old node
394 * @param n the new node replacing oldn
395 * @param flag firm statistics option
397 #define DBG_OPT_GVN_PRE(oldn, n, flag) \
399 hook_merge_nodes(&n, 1, &oldn, 1, flag); \
400 __dbg_info_merge_pair(n, oldn, dbg_gvn_pre); \
404 * Merge the debug info due to a combo result.
406 * @param oldn the old node
407 * @param n the new node replacing oldn
408 * @param flag firm statistics option
410 #define DBG_OPT_COMBO(oldn, n, flag) \
412 hook_merge_nodes(&n, 1, &oldn, 1, flag); \
413 __dbg_info_merge_pair(n, oldn, dbg_combo); \
417 * Merge the debug info due to a jump threading result.
419 * @param oldn the old control flow node
420 * @param n the new control flow node replacing oldn
422 #define DBG_OPT_JUMPTHREADING(oldn, n) \
424 hook_merge_nodes(&n, 1, &oldn, 1, FS_OPT_JUMPTHREADING); \
425 __dbg_info_merge_pair(n, oldn, dbg_jumpthreading); \