added CJmp statistics
[libfirm] / ir / be / ia32 / ia32_dbg_stat.h
1 /**
2  * This file contains macros to update ia32 firm statistics
3  * @author Christian Wuerdig
4  * $Id$
5  */
6 #ifndef _IA32_DBG_STAT_H_
7 #define _IA32_DBG_STAT_H_
8
9 #include "irhooks.h"
10 #include "dbginfo_t.h"
11 #include "firmstat.h"
12
13 #define SIZ(x)    sizeof(x)/sizeof((x)[0])
14
15 /**
16  * Merge the debug info due to a LEA creation.
17  *
18  * @param oldn  the node
19  * @param n     the new lea
20  */
21 #define DBG_OPT_LEA1(oldn, n)                               \
22         do {                                                    \
23                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_LEA);  \
24                 __dbg_info_merge_pair(n, oldn, dbg_backend);        \
25         } while(0)
26
27 /**
28  * Merge the debug info due to a LEA creation.
29  *
30  * @param oldn  the node
31  * @param n     the new lea
32  */
33 #define DBG_OPT_LEA1(oldn, n)                               \
34         do {                                                    \
35                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_LEA);  \
36                 __dbg_info_merge_pair(n, oldn, dbg_backend);        \
37         } while(0)
38
39 /**
40  * Merge the debug info due to a LEA creation.
41  *
42  * @param oldn1  the old node
43  * @param oldn2  an additional old node
44  * @param n      the new lea
45  */
46 #define DBG_OPT_LEA2(oldn1, oldn2, n)                              \
47         do {                                                           \
48                 ir_node *ons[2];                                           \
49                 ons[0] = oldn1;                                            \
50                 ons[1] = oldn2;                                            \
51                 hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_LEA);    \
52                 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
53         } while(0)
54
55 /**
56  * Merge the debug info due to a LEA creation.
57  *
58  * @param oldn1  the old node
59  * @param oldn2  an additional old node
60  * @param oldn3  an additional old node
61  * @param n      the new lea
62  */
63 #define DBG_OPT_LEA3(oldn1, oldn2, oldn3, n)                       \
64         do {                                                           \
65                 ir_node *ons[3];                                           \
66                 ons[0] = oldn1;                                            \
67                 ons[1] = oldn2;                                            \
68                 ons[2] = oldn3;                                            \
69                 hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_LEA);    \
70                 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
71         } while(0)
72
73 /**
74  * Merge the debug info due to a LEA creation.
75  *
76  * @param oldn1  the old node
77  * @param oldn2  an additional old node
78  * @param oldn3  an additional old node
79  * @param oldn4  an additional old node
80  * @param n      the new lea
81  */
82 #define DBG_OPT_LEA4(oldn1, oldn2, oldn3, oldn4, n)                \
83         do {                                                           \
84                 ir_node *ons[4];                                           \
85                 ons[0] = oldn1;                                            \
86                 ons[1] = oldn2;                                            \
87                 ons[2] = oldn3;                                            \
88                 ons[3] = oldn4;                                            \
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 Load with LEA creation.
95  *
96  * @param oldn  the lea
97  * @param n     the new load
98  */
99 #define DBG_OPT_LOAD_LEA(oldn, n)                                \
100         do {                                                         \
101                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_LOAD_LEA);  \
102                 __dbg_info_merge_pair(n, oldn, dbg_backend);             \
103         } while(0)
104
105 /**
106  * Merge the debug info due to a Store with LEA creation.
107  *
108  * @param oldn  the lea
109  * @param n     the new store
110  */
111 #define DBG_OPT_STORE_LEA(oldn, n)                                \
112         do {                                                          \
113                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_STORE_LEA);  \
114                 __dbg_info_merge_pair(n, oldn, dbg_backend);              \
115         } while(0)
116
117 /**
118  * Merge the debug info due to a source address mode creation.
119  *
120  * @param oldn  the old load
121  * @param n     the new op
122  */
123 #define DBG_OPT_AM_S(oldn, n)                                \
124         do {                                                     \
125                 hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_AM_S);  \
126                 __dbg_info_merge_pair(n, oldn, dbg_backend);         \
127         } while(0)
128
129 /**
130  * Merge the debug info due to a destination address mode creation.
131  *
132  * @param load   the old load
133  * @param store  yhe old store
134  * @param n      the new op
135  */
136 #define DBG_OPT_AM_D(load, store, n)                               \
137         do {                                                           \
138                 ir_node *ons[2];                                           \
139                 ons[0] = load;                                             \
140                 ons[1] = store;                                            \
141                 hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_AM_D);   \
142                 __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
143         } while(0)
144
145 /**
146  * A CJmp was created to save a cmp
147  *
148  * @param oldn  the old node
149  */
150 #define DBG_OPT_CJMP(oldn)                                    \
151         do {                                                      \
152                 hook_merge_nodes(NULL, 0, &oldn, 1, FS_BE_IA32_CJMP); \
153         } while(0)
154
155
156 #endif /* _IA32_DBG_STAT_H_ */