1 /* General-purpose hooks. 2 Copyright (C) 2002-2017 Free Software Foundation, Inc. 3 4 This program is free software; you can redistribute it and/or modify it 5 under the terms of the GNU General Public License as published by the 6 Free Software Foundation; either version 3, or (at your option) any 7 later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; see the file COPYING3. If not see 16 <http://www.gnu.org/licenses/>. 17 18 In other words, you are welcome to use, share and improve this program. 19 You are forbidden to forbid anyone else to use, share and improve 20 what you give them. Help stamp out software-hoarding! */ 21 22 /* This file contains generic hooks that can be used as defaults for 23 target or language-dependent hook initializers. */ 24 25 #include "config.h" 26 #include "system.h" 27 #include "coretypes.h" 28 #include "tm.h" 29 #include "hooks.h" 30 31 /* Generic hook that does absolutely zappo. */ 32 void 33 hook_void_void (void) 34 { 35 } 36 37 /* Generic hook that takes no arguments and returns false. */ 38 bool 39 hook_bool_void_false (void) 40 { 41 return false; 42 } 43 44 /* Generic hook that takes no arguments and returns true. */ 45 bool 46 hook_bool_void_true (void) 47 { 48 return true; 49 } 50 51 /* Generic hook that takes (bool) and returns false. */ 52 bool 53 hook_bool_bool_false (bool) 54 { 55 return false; 56 } 57 58 /* Generic hook that takes (bool, struct gcc_options *) and returns false. */ 59 bool 60 hook_bool_bool_gcc_optionsp_false (bool, struct gcc_options *) 61 { 62 return false; 63 } 64 65 /* Generic hook that takes const int, const int) and returns true. */ 66 bool hook_bool_const_int_const_int_true (const int, const int) 67 { 68 return true; 69 } 70 71 /* Generic hook that takes (machine_mode) and returns false. */ 72 bool 73 hook_bool_mode_false (machine_mode) 74 { 75 return false; 76 } 77 78 /* Generic hook that takes (machine_mode) and returns true. */ 79 bool 80 hook_bool_mode_true (machine_mode) 81 { 82 return true; 83 } 84 85 /* Generic hook that takes (machine_mode, const_rtx) and returns false. */ 86 bool 87 hook_bool_mode_const_rtx_false (machine_mode, const_rtx) 88 { 89 return false; 90 } 91 92 /* Generic hook that takes (machine_mode, const_rtx) and returns true. */ 93 bool 94 hook_bool_mode_const_rtx_true (machine_mode, const_rtx) 95 { 96 return true; 97 } 98 99 /* Generic hook that takes (machine_mode, rtx) and returns false. */ 100 bool 101 hook_bool_mode_rtx_false (machine_mode, rtx) 102 { 103 return false; 104 } 105 106 /* Generic hook that takes (machine_mode, rtx) and returns true. */ 107 bool 108 hook_bool_mode_rtx_true (machine_mode, rtx) 109 { 110 return true; 111 } 112 113 /* Generic hook that takes (const rtx_insn *, const rtx_insn *) and returns true. */ 114 bool 115 hook_bool_const_rtx_insn_const_rtx_insn_true (const rtx_insn *, 116 const rtx_insn *) 117 { 118 return true; 119 } 120 121 /* Generic hook that takes (machine_mode, unsigned HOST_WIDE_INT) 122 and returns false. */ 123 bool 124 hook_bool_mode_uhwi_false (machine_mode, unsigned HOST_WIDE_INT) 125 { 126 return false; 127 } 128 129 /* Generic hook that takes (FILE *, const char *) and does nothing. */ 130 void 131 hook_void_FILEptr_constcharptr (FILE *, const char *) 132 { 133 } 134 135 /* Generic hook that takes (FILE *, const char *, constr_tree *) and does 136 nothing. */ 137 void 138 hook_void_FILEptr_constcharptr_const_tree (FILE *, const char *, const_tree) 139 { 140 } 141 142 /* Generic hook that takes (FILE *, rtx) and returns false. */ 143 bool 144 hook_bool_FILEptr_rtx_false (FILE *, rtx) 145 { 146 return false; 147 } 148 149 /* Generic hook that takes (gimple_stmt_iterator *) and returns 150 false. */ 151 bool 152 hook_bool_gsiptr_false (gimple_stmt_iterator *) 153 { 154 return false; 155 } 156 157 /* Used for the TARGET_ASM_CAN_OUTPUT_MI_THUNK hook. */ 158 bool 159 hook_bool_const_tree_hwi_hwi_const_tree_false (const_tree, HOST_WIDE_INT, 160 HOST_WIDE_INT, const_tree) 161 { 162 return false; 163 } 164 165 bool 166 hook_bool_const_tree_hwi_hwi_const_tree_true (const_tree, HOST_WIDE_INT, 167 HOST_WIDE_INT, const_tree) 168 { 169 return true; 170 } 171 172 bool 173 default_can_output_mi_thunk_no_vcall (const_tree, HOST_WIDE_INT, 174 HOST_WIDE_INT c, const_tree) 175 { 176 return c == 0; 177 } 178 179 int 180 hook_int_uint_mode_1 (unsigned int, machine_mode) 181 { 182 return 1; 183 } 184 185 int 186 hook_int_const_tree_0 (const_tree) 187 { 188 return 0; 189 } 190 191 /* ??? Used for comp_type_attributes, which ought to return bool. */ 192 int 193 hook_int_const_tree_const_tree_1 (const_tree, const_tree) 194 { 195 return 1; 196 } 197 198 int 199 hook_int_rtx_0 (rtx) 200 { 201 return 0; 202 } 203 204 int 205 hook_int_rtx_1 (rtx) 206 { 207 return 1; 208 } 209 210 int 211 hook_int_rtx_insn_unreachable (rtx_insn *) 212 { 213 gcc_unreachable (); 214 } 215 216 int 217 hook_int_rtx_bool_0 (rtx, bool) 218 { 219 return 0; 220 } 221 222 int 223 hook_int_rtx_mode_as_bool_0 (rtx, machine_mode, addr_space_t, bool) 224 { 225 return 0; 226 } 227 228 unsigned int 229 hook_uint_void_0 (void) 230 { 231 return 0; 232 } 233 234 void 235 hook_void_tree (tree) 236 { 237 } 238 239 void 240 hook_void_rtx_tree (rtx, tree) 241 { 242 } 243 244 void 245 hook_void_constcharptr (const char *) 246 { 247 } 248 249 void 250 hook_void_tree_treeptr (tree, tree *) 251 { 252 } 253 254 void 255 hook_void_int_int (int, int) 256 { 257 } 258 259 bool 260 hook_bool_tree_false (tree) 261 { 262 return false; 263 } 264 265 bool 266 hook_bool_const_tree_false (const_tree) 267 { 268 return false; 269 } 270 271 bool 272 hook_bool_tree_true (tree) 273 { 274 return true; 275 } 276 277 bool 278 hook_bool_const_tree_true (const_tree) 279 { 280 return true; 281 } 282 283 bool 284 hook_bool_tree_tree_false (tree, tree) 285 { 286 return false; 287 } 288 289 bool 290 hook_bool_tree_tree_true (tree, tree) 291 { 292 return true; 293 } 294 295 bool 296 hook_bool_tree_bool_false (tree, bool) 297 { 298 return false; 299 } 300 301 bool 302 hook_bool_rtx_insn_true (rtx_insn *) 303 { 304 return true; 305 } 306 307 bool 308 hook_bool_rtx_false (rtx) 309 { 310 return false; 311 } 312 313 bool 314 hook_bool_uintp_uintp_false (unsigned int *, unsigned int *) 315 { 316 return false; 317 } 318 319 bool 320 hook_bool_rtx_mode_int_int_intp_bool_false (rtx, machine_mode, int, int, 321 int *, bool) 322 { 323 return false; 324 } 325 326 bool 327 hook_bool_wint_wint_uint_bool_true (const widest_int &, const widest_int &, 328 unsigned int, bool) 329 { 330 return true; 331 } 332 333 /* Generic hook that takes an rtx and returns it. */ 334 rtx 335 hook_rtx_rtx_identity (rtx x) 336 { 337 return x; 338 } 339 340 /* Generic hook that takes an rtx and returns NULL_RTX. */ 341 rtx 342 hook_rtx_rtx_null (rtx) 343 { 344 return NULL; 345 } 346 347 /* Generic hook that takes a tree and an int and returns NULL_RTX. */ 348 rtx 349 hook_rtx_tree_int_null (tree, int) 350 { 351 return NULL; 352 } 353 354 /* Generic hook that takes a machine mode and returns an unsigned int 0. */ 355 unsigned int 356 hook_uint_mode_0 (machine_mode) 357 { 358 return 0; 359 } 360 361 /* Generic hook that takes no arguments and returns a NULL const string. */ 362 const char * 363 hook_constcharptr_void_null (void) 364 { 365 return NULL; 366 } 367 368 /* Generic hook that takes no arguments and returns a NULL string. */ 369 char * 370 hook_charptr_void_null (void) 371 { 372 return NULL; 373 } 374 375 /* Generic hook that takes a tree and returns a NULL string. */ 376 const char * 377 hook_constcharptr_const_tree_null (const_tree) 378 { 379 return NULL; 380 } 381 382 tree 383 hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool) 384 { 385 return NULL; 386 } 387 388 tree 389 hook_tree_tree_tree_null (tree, tree) 390 { 391 return NULL; 392 } 393 394 tree 395 hook_tree_tree_tree_tree_null (tree, tree, tree) 396 { 397 return NULL; 398 } 399 400 /* Generic hook that takes an rtx_insn *and returns a NULL string. */ 401 const char * 402 hook_constcharptr_const_rtx_insn_null (const rtx_insn *) 403 { 404 return NULL; 405 } 406 407 const char * 408 hook_constcharptr_const_tree_const_tree_null (const_tree, const_tree) 409 { 410 return NULL; 411 } 412 413 const char * 414 hook_constcharptr_int_const_tree_null (int, const_tree) 415 { 416 return NULL; 417 } 418 419 const char * 420 hook_constcharptr_int_const_tree_const_tree_null (int, const_tree, const_tree) 421 { 422 return NULL; 423 } 424 425 /* Generic hook that takes a const_tree and returns NULL_TREE. */ 426 tree 427 hook_tree_const_tree_null (const_tree) 428 { 429 return NULL; 430 } 431 432 /* Generic hook that takes no arguments and returns a NULL_TREE. */ 433 tree 434 hook_tree_void_null (void) 435 { 436 return NULL; 437 } 438 439 /* Generic hook that takes a rtx_insn * and an int and returns a bool. */ 440 441 bool 442 hook_bool_rtx_insn_int_false (rtx_insn *, int) 443 { 444 return false; 445 } 446 447 /* Generic hook that takes a rtx_insn * and an int and returns void. */ 448 449 void 450 hook_void_rtx_insn_int (rtx_insn *, int) 451 { 452 } 453 454 /* Generic hook that takes a struct gcc_options * and returns void. */ 455 456 void 457 hook_void_gcc_optionsp (struct gcc_options *) 458 { 459 } 460 461 /* Generic hook that takes an unsigned int, an unsigned int pointer and 462 returns false. */ 463 464 bool 465 hook_bool_uint_uintp_false (unsigned int, unsigned int *) 466 { 467 return false; 468 } 469 470 /* Generic hook that takes a register class and returns false. */ 471 bool 472 hook_bool_reg_class_t_false (reg_class_t regclass ATTRIBUTE_UNUSED) 473 { 474 return false; 475 } 476 477