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