added missing parentesis
[libfirm] / ir / ir / iropt_dbg.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/iropt_dbg.h
4  * Purpose:     Debug makros used in iropt.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2001-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13
14 /* This file contains makros that generate the calls to
15    update the debug information after a transformation. */
16
17 #define SIZ(x)    sizeof(x)/sizeof((x)[0])
18
19
20 /**
21  * Merge the debug info due to dead code elimination
22  */
23 #define DBG_OPT_DEAD(oldn, n)                                      \
24   do {                                                             \
25           ir_node *ons[2];                                         \
26           ons[0] = oldn;                                           \
27           ons[1] = get_Block_cfgpred(oldn, 0);                     \
28           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG);    \
29           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_dead_code); \
30         } while(0)
31
32
33 /**
34  * Merge the debug info due to a straightening optimization
35  */
36 #define DBG_OPT_STG(oldn, n)                                       \
37   do {                                                             \
38           ir_node *ons[2];                                         \
39           ons[0] = oldn;                                           \
40           ons[1] = get_Block_cfgpred(oldn, 0);                     \
41           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG);    \
42           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
43         } while(0)
44
45 /**
46  * Merge the debug info due to an if simplification
47  */
48 #define DBG_OPT_IFSIM(oldn, a, b, n)                                  \
49   do {                                                                \
50           ir_node *ons[4];                                            \
51           ons[0] = oldn;                                              \
52           ons[1] = a;                                                 \
53           ons[2] = b;                                                 \
54           ons[3] = get_Proj_pred(a);                                  \
55           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM);     \
56           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
57         } while(0)
58
59 /**
60  * Merge the debug info due to an algebraic_simplification
61  */
62 #define DBG_OPT_CSTEVAL(oldn, n)                                  \
63   do {                                                                  \
64           hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL);         \
65           __dbg_info_merge_pair(n, oldn, dbg_const_eval);               \
66   } while(0)
67
68 #define DBG_OPT_ALGSIM0(oldn, n)                                  \
69   do {                                                            \
70     hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_ALGSIM);               \
71     __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
72   } while(0)
73
74 #define DBG_OPT_ALGSIM1(oldn, a, b, n)                          \
75   do {                                                          \
76           ir_node *ons[3];                                            \
77           ons[0] = oldn;                                              \
78           ons[1] = a;                                                 \
79           ons[2] = b;                                                 \
80           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM);    \
81           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
82   } while(0)
83
84 #define DBG_OPT_ALGSIM2(oldn, pred, n)                                \
85   do {                                                                \
86           ir_node *ons[3];                                            \
87           ons[0] = oldn;                                              \
88           ons[1] = pred;                                              \
89           ons[2] = n;                                                 \
90           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM);    \
91           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
92   } while(0)
93
94 #define DBG_OPT_ALGSIM3(oldn, a, n)                                   \
95   do {                                                                \
96           ir_node *ons[2];                                            \
97           ons[0] = oldn;                                              \
98           ons[1] = a;                                                 \
99           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM);    \
100           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
101   } while(0)
102
103 #define DBG_OPT_PHI(oldn, first_val, n)                               \
104   do {                                                                \
105           ir_node *ons[2];                                            \
106           ons[0] = oldn;                                              \
107           ons[1] = first_val;                                         \
108           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_PHI);       \
109           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_ssa);   \
110   } while(0)
111
112
113 /**
114  * Merge the debug info due to Write-after-Write optimization:
115  * Store oldst will be replace by a reference to Store st
116  */
117 #define DBG_OPT_WAW(oldst, st)                                        \
118   do {                                                                \
119           ir_node *ons[2];                                            \
120           ons[0] = oldst;                                             \
121           ons[1] = st;                                                \
122           hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW);      \
123           __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
124   } while(0)
125
126 /**
127  * Merge the debug info due to Write-after-Read optimization:
128  * store will be replace by a reference to load
129  */
130 #define DBG_OPT_WAR(store, load)                                      \
131   do {                                                                \
132           ir_node *ons[2];                                            \
133           ons[0] = store;                                             \
134           ons[1] = load;                                              \
135           hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR);    \
136           __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
137   } while(0)
138
139 /**
140  * Merge the debug info due to Read-after-Write optimization:
141  * load will be replace by a reference to store
142  */
143 #define DBG_OPT_RAW(store, load)                                      \
144   do {                                                                \
145           ir_node *ons[2];                                            \
146           ons[0] = store;                                             \
147           ons[1] = load;                                              \
148           hook_merge_nodes(&store, 1, ons, SIZ(ons), HOOK_OPT_RAW);   \
149           __dbg_info_merge_sets(&store, 1, ons, SIZ(ons), dbg_read_after_write); \
150   } while(0)
151
152 /**
153  * Merge the debug info due to Read-after-Read optimization:
154  * Load oldld will be replace by a reference to Load ld
155  */
156 #define DBG_OPT_RAR(oldld, ld)                                        \
157   do {                                                                \
158           ir_node *ons[2];                                            \
159           ons[0] = oldld;                                             \
160           ons[1] = ld;                                                \
161           hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR);      \
162           __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
163   } while(0)
164
165 /**
166  * Merge the debug info due to Read-a-Const optimization:
167  * Load ld will be replace by a Constant
168  */
169 #define DBG_OPT_RC(ld, c)                                             \
170   do {                                                                \
171           ir_node *ons[2];                                            \
172           ons[0] = ld;                                                \
173           ons[1] = c;                                                 \
174           hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC);        \
175           __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
176         } while(0)
177
178 #define DBG_OPT_TUPLE(oldn, a, n)                                     \
179   do {                                                                \
180           ir_node *ons[3];                                            \
181           ons[0] = oldn;                                              \
182           ons[1] = a;                                                 \
183           ons[2] = n;                                                 \
184           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE);     \
185           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode);      \
186   } while(0)
187
188 #define DBG_OPT_ID(oldn, n)                                           \
189   do {                                                                \
190           ir_node *ons[2];                                            \
191           ons[0] = oldn;                                              \
192           ons[1] = n;                                                 \
193           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID);        \
194           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode);      \
195   } while(0)
196
197 /**
198  * Merge the debug info due to ommon-subexpression elimination
199  */
200 #define DBG_OPT_CSE(oldn, n)                                          \
201   do {                                                                \
202           ir_node *ons[2];                                            \
203           ons[0] = oldn;                                              \
204           ons[1] = n;                                                 \
205           hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE);       \
206           __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse);   \
207   } while(0)
208
209 #define DBG_OPT_POLY_ALLOC(oldn, n)                                 \
210   do {                                                              \
211     ir_node *ons[3];                                                \
212     ons[0] = oldn;                                                  \
213     ons[1] = skip_Proj(get_Sel_ptr(oldn));                          \
214     ons[2] = n;                                                     \
215     hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL);     \
216     __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_rem_poly_call); \
217   } while(0)
218
219 #define DBG_OPT_POLY(oldn, n)                                   \
220   do {                                                          \
221     hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_POLY_CALL);      \
222     __dbg_info_merge_pair(n, oldn, dbg_rem_poly_call);          \
223   } while(0)