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