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
25 #ifndef FIRM_IR_IROPT_DBG_H
26 #define FIRM_IR_IROPT_DBG_H
28 #include "dbginfo_t.h"
34 * Merge the debug info due to dead block elimination.
36 * @param oldn the block that it is eliminated
37 * @param n the new node for this block, may be equal to oldn
39 #define DBG_OPT_DEAD_BLOCK(oldn, n) \
41 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_DEAD_BLOCK); \
42 __dbg_info_merge_pair(n, oldn, dbg_dead_code); \
47 * Merge the debug info due to a straightening optimization.
48 * Block oldn is merged with n.
50 * @param oldn the old block
51 * @param n the new block the merges with oldn
53 #define DBG_OPT_STG(oldn, n) \
57 ons[1] = get_Block_cfgpred(oldn, 0); \
58 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_STG); \
59 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_straightening); \
63 * Merge the debug info due to an if simplification.
65 * @param oldn the old Block
66 * @param proj1 the first ProjX predecessor
67 * @param proj2 the second ProjX predecessor
68 * @param n the new Block
70 #define DBG_OPT_IFSIM1(oldn, proj1, proj2, n) \
76 ons[3] = get_Proj_pred(proj1); \
77 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_IFSIM); \
78 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_if_simplification); \
82 * Merge the debug info due to an if simplification.
83 * @param oldn the old Cond
84 * @param n the new Jmp
86 #define DBG_OPT_IFSIM2(oldn, n) \
88 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_IFSIM); \
89 __dbg_info_merge_pair(n, oldn, dbg_if_simplification); \
93 * Merge the debug info due to an algebraic_simplification.
94 * A node could be evaluated into a Constant.
96 * @param oldn the node
97 * @param n the new constant holding the value
99 #define DBG_OPT_CSTEVAL(oldn, n) \
101 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
102 __dbg_info_merge_pair(n, oldn, dbg_const_eval); \
106 * Merge the debug info due to an algebraic_simplification.
108 * @param oldn the old node
109 * @param n the new node replacing oldn
110 * @param flag firm statistics option
112 #define DBG_OPT_ALGSIM0(oldn, n, flag) \
114 hook_merge_nodes(&n, 1, &oldn, 1, (hook_opt_kind)flag); \
115 __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
119 * Merge the debug info due to an algebraic_simplification.
121 * @param oldn the old node
122 * @param a a predecessor of oldn
123 * @param b a predecessor of oldn
124 * @param n the new node replacing oldn
125 * @param flag firm statistics option
127 #define DBG_OPT_ALGSIM1(oldn, a, b, n, flag) \
133 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), (hook_opt_kind)flag); \
134 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
138 * Merge the debug info due to an algebraic_simplification.
140 * @param oldn the old node
141 * @param pred the predecessor of oldn
142 * @param n the new node replacing oldn
143 * @param flag firm statistics option
145 #define DBG_OPT_ALGSIM2(oldn, pred, n, flag) \
151 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), (hook_opt_kind)flag); \
152 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
156 * Merge the debug info due to an algebraic_simplification.
158 #define DBG_OPT_ALGSIM3(oldn, a, n, flag) \
163 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), flag); \
164 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
168 * Merge the debug info due to a Phi optimization.
169 * A Phi node was replaced by one of its input (the only meaningful)
171 * @param phi the Phi node that will be replaced
172 * @param n in Phi Input that will replace Phi
174 #define DBG_OPT_PHI(phi, n) \
176 hook_merge_nodes(&n, 1, &phi, 1, HOOK_OPT_PHI); \
177 __dbg_info_merge_sets(&n, 1, &phi, 1, dbg_opt_ssa); \
182 * Merge the debug info due to a Sync optimization.
183 * A Sync node was replaced by one of its input (the only meaningful)
185 * @param sync the Sync node that will be replaced
186 * @param n in Sync Input that will replace Sync
188 #define DBG_OPT_SYNC(sync, n) \
190 hook_merge_nodes(&n, 1, &sync, 1, HOOK_OPT_SYNC); \
191 __dbg_info_merge_sets(&n, 1, &sync, 1, dbg_opt_ssa); \
196 * Merge the debug info due to Write-after-Write optimization:
197 * Store oldst will be removed, because Store st overwrites it.
199 * @param oldst the old store that will be removed
200 * @param st the other store that overwrites oldst
202 #define DBG_OPT_WAW(oldst, st) \
207 hook_merge_nodes(&st, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_WAW); \
208 __dbg_info_merge_sets(&st, 1, ons, ARRAY_SIZE(ons), dbg_write_after_write); \
212 * Merge the debug info due to Write-after-Read optimization:
213 * A store will be removed because it rite a value just read back.
215 * @param store the store that will be removed
216 * @param load the load that produces the value that store will write back
218 #define DBG_OPT_WAR(store, load) \
223 hook_merge_nodes(&load, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_WAR); \
224 __dbg_info_merge_sets(&load, 1, ons, ARRAY_SIZE(ons), dbg_write_after_read); \
228 * Merge the debug info due to Read-after-Write optimization:
229 * A load will be replaced by a value that was just stored.
231 * @param load the load that will be replaced
232 * @param value the value that will replace the load
234 #define DBG_OPT_RAW(load, value) \
239 hook_merge_nodes(&value, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RAW); \
240 __dbg_info_merge_sets(&value, 1, ons, ARRAY_SIZE(ons), dbg_read_after_write); \
244 * Merge the debug info due to Read-after-Read optimization:
245 * Load oldld will be replace by a reference to Load ld.
247 * @param oldld the old load that can be replaced
248 * @param ld the load that produces the same values
250 #define DBG_OPT_RAR(oldld, ld) \
255 hook_merge_nodes(&ld, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RAR); \
256 __dbg_info_merge_sets(&ld, 1, ons, ARRAY_SIZE(ons), dbg_read_after_read); \
260 * Merge the debug info due to Read-a-Const optimization:
261 * Load ld will be replace by a Constant if the value that
262 * will be loaded is known and immutable.
265 * @param c the constant value that will replace the load's result
267 #define DBG_OPT_RC(ld, c) \
272 hook_merge_nodes(&c, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RC); \
273 __dbg_info_merge_sets(&ld, 1, ons, ARRAY_SIZE(ons), dbg_read_a_const); \
277 * Merge the debug info after a tuple optimization.
278 * a Proj(Tuple) is replaced by the associated tuple value.
280 * @param proj the Proj node
281 * @param tuple the Tuple node
282 * @param n the Proj(Tuple) value
284 #define DBG_OPT_TUPLE(proj, tuple, n) \
290 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_TUPLE); \
291 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_auxnode); \
295 * Merge the debug info after an Id optimization.
296 * An Id node was replaced by its non-Id predecessor.
298 * @param id the Id node
299 * @param n the predecessor
301 #define DBG_OPT_ID(id, n) \
306 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_ID); \
307 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_auxnode); \
311 * Merge the debug info due to common-subexpression elimination.
313 * @param oldn the old node
314 * @param n the node that replaces oldn
316 #define DBG_OPT_CSE(oldn, n) \
321 hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_CSE); \
322 __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_cse); \
326 * Merge the debug info due to polymorphic call optimization.
327 * A Sel node was replaced by a constant.
329 * @param sel the Sel node that will be replaced.
330 * @param c the constant node that replaces sel
332 #define DBG_OPT_POLY(sel, c) \
336 ons[1] = skip_Proj(get_Sel_ptr(sel)); \
338 hook_merge_nodes(&c, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_POLY_CALL); \
339 __dbg_info_merge_sets(&c, 1, ons, ARRAY_SIZE(ons), dbg_rem_poly_call); \
343 * A node was replaced by another node due to a Confirmation.
345 * @param oldn the old node
346 * @param n the new node
348 #define DBG_OPT_CONFIRM(oldn, n) \
350 hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
351 __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
355 * A node was replaced by a constant due to a Confimation.
357 * @param oldn the old node
358 * @param c the new constant node
360 #define DBG_OPT_CONFIRM_C(oldn, c) \
362 hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
363 __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
367 * A exception exdge was removed due to a Confirmation prove.
369 * @param oldn the old node
371 #define DBG_OPT_EXC_REM(oldn) \
373 hook_merge_nodes(NULL, 0, &oldn, 1, HOOK_OPT_EXC_REM); \
377 * A node could be evaluated to a value due to a Confirm.
378 * This will lead to a constant evaluation.
380 * @param n the node that could be evaluated
382 #define DBG_EVAL_CONFIRM(n) \
384 hook_merge_nodes(NULL, 0, (ir_node**)&n, 1, HOOK_OPT_CONFIRM_E); \
388 * Merge the debug info due to a GVN-PRE result.
390 * @param oldn the old node
391 * @param n the new node replacing oldn
392 * @param flag firm statistics option
394 #define DBG_OPT_GVN_PRE(oldn, n, flag) \
396 hook_merge_nodes(&n, 1, &oldn, 1, (hook_opt_kind)flag); \
397 __dbg_info_merge_pair(n, oldn, dbg_gvn_pre); \
401 * Merge the debug info due to a combo result.
403 * @param oldn the old node
404 * @param n the new node replacing oldn
405 * @param flag firm statistics option
407 #define DBG_OPT_COMBO(oldn, n, flag) \
409 hook_merge_nodes(&n, 1, &oldn, 1, (hook_opt_kind)flag); \
410 __dbg_info_merge_pair(n, oldn, dbg_combo); \
414 * Merge the debug info due to a jump threading result.
416 * @param oldn the old control flow node
417 * @param n the new control flow node replacing oldn
419 #define DBG_OPT_JUMPTHREADING(oldn, n) \
421 hook_merge_nodes(&n, 1, &oldn, 1, (hook_opt_kind)FS_OPT_JUMPTHREADING); \
422 __dbg_info_merge_pair(n, oldn, dbg_jumpthreading); \