fixed wrong variable usage
[libfirm] / ir / be / ia32 / ia32_dbg_stat.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       This file contains macros to update ia32 firm statistics.
23  * @author      Christian Wuerdig
24  * @version     $Id$
25  */
26 #ifndef FIRM_BE_IA32_IA32_DBG_STAT_H
27 #define FIRM_BE_IA32_IA32_DBG_STAT_H
28
29 #include "irhooks.h"
30 #include "dbginfo_t.h"
31 #include "firmstat.h"
32
33 #define SIZ(x)    sizeof(x)/sizeof((x)[0])
34
35 /**
36  * Merge the debug info due to a LEA creation.
37  *
38  * @param oldn  the node
39  * @param n     the new lea
40  */
41 #define DBG_OPT_LEA1(oldn, n)                               \
42         do {                                                    \
43                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_LEA);  \
44                 __dbg_info_merge_pair(n, oldn, dbg_backend);        \
45         } while(0)
46
47 /**
48  * Merge the debug info due to a LEA creation.
49  *
50  * @param oldn  the node
51  * @param n     the new lea
52  */
53 #define DBG_OPT_LEA1(oldn, n)                               \
54         do {                                                    \
55                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_LEA);  \
56                 __dbg_info_merge_pair(n, oldn, dbg_backend);        \
57         } while(0)
58
59 /**
60  * Merge the debug info due to a LEA creation.
61  *
62  * @param oldn1  the old node
63  * @param oldn2  an additional old node
64  * @param n      the new lea
65  */
66 #define DBG_OPT_LEA2(oldn1, oldn2, n)                              \
67         do {                                                           \
68                 ir_node *ons[2];                                           \
69                 ons[0] = oldn1;                                            \
70                 ons[1] = oldn2;                                            \
71                 hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_LEA);    \
72                 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
73         } while(0)
74
75 /**
76  * Merge the debug info due to a LEA creation.
77  *
78  * @param oldn1  the old node
79  * @param oldn2  an additional old node
80  * @param oldn3  an additional old node
81  * @param n      the new lea
82  */
83 #define DBG_OPT_LEA3(oldn1, oldn2, oldn3, n)                       \
84         do {                                                           \
85                 ir_node *ons[3];                                           \
86                 ons[0] = oldn1;                                            \
87                 ons[1] = oldn2;                                            \
88                 ons[2] = oldn3;                                            \
89                 hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_LEA);    \
90                 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
91         } while(0)
92
93 /**
94  * Merge the debug info due to a LEA creation.
95  *
96  * @param oldn1  the old node
97  * @param oldn2  an additional old node
98  * @param oldn3  an additional old node
99  * @param oldn4  an additional old node
100  * @param n      the new lea
101  */
102 #define DBG_OPT_LEA4(oldn1, oldn2, oldn3, oldn4, n)                \
103         do {                                                           \
104                 ir_node *ons[4];                                           \
105                 ons[0] = oldn1;                                            \
106                 ons[1] = oldn2;                                            \
107                 ons[2] = oldn3;                                            \
108                 ons[3] = oldn4;                                            \
109                 hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_LEA);    \
110                 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
111         } while(0)
112
113 /**
114  * Merge the debug info due to a Load with LEA creation.
115  *
116  * @param oldn  the lea
117  * @param n     the new load
118  */
119 #define DBG_OPT_LOAD_LEA(oldn, n)                                \
120         do {                                                         \
121                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_LOAD_LEA);  \
122                 __dbg_info_merge_pair(n, oldn, dbg_backend);             \
123         } while(0)
124
125 /**
126  * Merge the debug info due to a Store with LEA creation.
127  *
128  * @param oldn  the lea
129  * @param n     the new store
130  */
131 #define DBG_OPT_STORE_LEA(oldn, n)                                \
132         do {                                                          \
133                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_STORE_LEA);  \
134                 __dbg_info_merge_pair(n, oldn, dbg_backend);              \
135         } while(0)
136
137 /**
138  * Merge the debug info due to a source address mode creation.
139  *
140  * @param oldn  the old load
141  * @param n     the new op
142  */
143 #define DBG_OPT_AM_S(oldn, n)                                \
144         do {                                                     \
145                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_AM_S);  \
146                 __dbg_info_merge_pair(n, oldn, dbg_backend);         \
147         } while(0)
148
149 /**
150  * Merge the debug info due to a destination address mode creation.
151  *
152  * @param load   the old load
153  * @param store  the old store
154  * @param n      the new op
155  */
156 #define DBG_OPT_AM_D(load, store, n)                               \
157         do {                                                           \
158                 ir_node *ons[2];                                           \
159                 ons[0] = load;                                             \
160                 ons[1] = store;                                            \
161                 hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_AM_D);   \
162                 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
163         } while(0)
164
165 /**
166  * A CJmp was created to save a cmp
167  *
168  * @param oldn  the old node
169  */
170 #define DBG_OPT_CJMP(oldn)                                    \
171         do {                                                      \
172                 hook_merge_nodes(NULL, 0, &oldn, 1, FS_BE_IA32_CJMP); \
173         } while(0)
174
175 /**
176  * A Copy was created to fulfill two address code constraints
177  *
178  * @param cpy  the copy
179  */
180 #define DBG_OPT_2ADDRCPY(cpy)                                    \
181         do {                                                         \
182                 hook_merge_nodes(NULL, 0, &cpy, 1, FS_BE_IA32_2ADDRCPY); \
183         } while(0)
184
185 /**
186  * A Store was created for a Spill
187  *
188  * @param spill  the Spill
189  * @param store  the Store
190  */
191 #define DBG_OPT_SPILL2ST(spill, store)                               \
192         do {                                                             \
193                 hook_merge_nodes(&store, 1, &spill, 1, FS_BE_IA32_SPILL2ST); \
194                 __dbg_info_merge_pair(store, spill, dbg_backend);            \
195         } while(0)
196
197 /**
198  * A Load was created for a Reload
199  *
200  * @param rload  the Reload
201  * @param load   the Load
202  */
203 #define DBG_OPT_RELOAD2LD(rload, load)                               \
204         do {                                                             \
205                 hook_merge_nodes(&load, 1, &rload, 1, FS_BE_IA32_RELOAD2LD); \
206                 __dbg_info_merge_pair(load, rload, dbg_backend);             \
207         } while(0)
208
209 /**
210  * A Sub was transformed into Neg-Add due to 2 address code limitations
211  *
212  * @param sub   the old Sub
213  * @param nadd  the new Add
214  */
215 #define DBG_OPT_SUB2NEGADD(sub, nadd)                               \
216         do {                                                            \
217                 hook_merge_nodes(&nadd, 1, &sub, 1, FS_BE_IA32_SUB2NEGADD); \
218                 __dbg_info_merge_pair(nadd, sub, dbg_backend);              \
219         } while(0)
220
221 /**
222  * A Lea was transformed back into an Add
223  *
224  * @param lea   the old Lea
225  * @param nadd  the new Add
226  */
227 #define DBG_OPT_LEA2ADD(lea, nadd)                               \
228         do {                                                         \
229                 hook_merge_nodes(&nadd, 1, &lea, 1, FS_BE_IA32_LEA2ADD); \
230                 __dbg_info_merge_pair(nadd, lea, dbg_backend);           \
231         } while(0)
232
233 #endif /* FIRM_BE_IA32_IA32_DBG_STAT_H */