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