Debian Codegraph @

gcc/hooks.cc

raw
1 /* General-purpose hooks.
2 Copyright (C) 2002-2025 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 (dwarf_call_frame_info, dw_cfi_oprnd_type &) and
66 return false. */
67 bool hook_bool_dwcfi_dwcfioprndtyperef_false (dwarf_call_frame_info,
68 dw_cfi_oprnd_type &)
69 {
70 return false;
71 }
72
73 /* Generic hook that takes (FILE *, dw_cfi_ref) and return false. */
74 bool hook_bool_FILEptr_dwcfiptr_false (FILE *, dw_cfi_ref)
75 {
76 return false;
77 }
78
79 /* Generic hook that takes const int, const int) and returns true. */
80 bool hook_bool_const_int_const_int_true (const int, const int)
81 {
82 return true;
83 }
84
85 /* Generic hook that takes (machine_mode) and returns false. */
86 bool
87 hook_bool_mode_false (machine_mode)
88 {
89 return false;
90 }
91
92 /* Generic hook that takes (machine_mode) and returns true. */
93 bool
94 hook_bool_mode_true (machine_mode)
95 {
96 return true;
97 }
98
99 /* Generic hook that takes (machine_mode, machine_mode) and returns true. */
100 bool
101 hook_bool_mode_mode_true (machine_mode, machine_mode)
102 {
103 return true;
104 }
105
106 /* Generic hook that takes (machine_mode, const_rtx) and returns false. */
107 bool
108 hook_bool_mode_const_rtx_false (machine_mode, const_rtx)
109 {
110 return false;
111 }
112
113 /* Generic hook that takes (machine_mode, const_rtx) and returns true. */
114 bool
115 hook_bool_mode_const_rtx_true (machine_mode, const_rtx)
116 {
117 return true;
118 }
119
120 /* Generic hook that takes (machine_mode, rtx) and returns false. */
121 bool
122 hook_bool_mode_rtx_false (machine_mode, rtx)
123 {
124 return false;
125 }
126
127 /* Generic hook that takes (machine_mode, rtx) and returns true. */
128 bool
129 hook_bool_mode_rtx_true (machine_mode, rtx)
130 {
131 return true;
132 }
133
134 /* Generic hook that takes (const rtx_insn *, const rtx_insn *) and returns true. */
135 bool
136 hook_bool_const_rtx_insn_const_rtx_insn_true (const rtx_insn *,
137 const rtx_insn *)
138 {
139 return true;
140 }
141
142 /* Generic hook that takes (machine_mode, unsigned HOST_WIDE_INT)
143 and returns false. */
144 bool
145 hook_bool_mode_uhwi_false (machine_mode, unsigned HOST_WIDE_INT)
146 {
147 return false;
148 }
149
150 /* Generic hook that takes (poly_uint64, poly_uint64) and returns true. */
151 bool
152 hook_bool_puint64_puint64_true (poly_uint64, poly_uint64)
153 {
154 return true;
155 }
156
157 bool
158 hook_bool_uint_uint_mode_false (unsigned int, unsigned int, machine_mode)
159 {
160 return false;
161 }
162
163 /* Generic hook that takes (unsigned int, machine_mode) and returns true. */
164 bool
165 hook_bool_uint_mode_true (unsigned int, machine_mode)
166 {
167 return true;
168 }
169
170 /* Generic hook that takes (FILE *, const char *) and does nothing. */
171 void
172 hook_void_FILEptr_constcharptr (FILE *, const char *)
173 {
174 }
175
176 /* Generic hook that takes (FILE *, const char *, constr_tree *) and does
177 nothing. */
178 void
179 hook_void_FILEptr_constcharptr_const_tree (FILE *, const char *, const_tree)
180 {
181 }
182
183 /* Generic hook that takes (FILE *, rtx) and returns false. */
184 bool
185 hook_bool_FILEptr_rtx_false (FILE *, rtx)
186 {
187 return false;
188 }
189
190 /* Generic hook that takes (gimple_stmt_iterator *) and returns
191 false. */
192 bool
193 hook_bool_gsiptr_false (gimple_stmt_iterator *)
194 {
195 return false;
196 }
197
198 /* Used for the TARGET_ASM_CAN_OUTPUT_MI_THUNK hook. */
199 bool
200 hook_bool_const_tree_hwi_hwi_const_tree_false (const_tree, HOST_WIDE_INT,
201 HOST_WIDE_INT, const_tree)
202 {
203 return false;
204 }
205
206 bool
207 hook_bool_const_tree_hwi_hwi_const_tree_true (const_tree, HOST_WIDE_INT,
208 HOST_WIDE_INT, const_tree)
209 {
210 return true;
211 }
212
213 bool
214 default_can_output_mi_thunk_no_vcall (const_tree, HOST_WIDE_INT,
215 HOST_WIDE_INT c, const_tree)
216 {
217 return c == 0;
218 }
219
220 int
221 hook_int_uint_mode_1 (unsigned int, machine_mode)
222 {
223 return 1;
224 }
225
226 int
227 hook_int_const_tree_0 (const_tree)
228 {
229 return 0;
230 }
231
232 /* ??? Used for comp_type_attributes, which ought to return bool. */
233 int
234 hook_int_const_tree_const_tree_1 (const_tree, const_tree)
235 {
236 return 1;
237 }
238
239 int
240 hook_int_rtx_0 (rtx)
241 {
242 return 0;
243 }
244
245 int
246 hook_int_rtx_1 (rtx)
247 {
248 return 1;
249 }
250
251 int
252 hook_int_rtx_insn_0 (rtx_insn *)
253 {
254 return 0;
255 }
256
257 int
258 hook_int_rtx_insn_unreachable (rtx_insn *)
259 {
260 gcc_unreachable ();
261 }
262
263 int
264 hook_int_rtx_bool_0 (rtx, bool)
265 {
266 return 0;
267 }
268
269 int
270 hook_int_rtx_mode_as_bool_0 (rtx, machine_mode, addr_space_t, bool)
271 {
272 return 0;
273 }
274
275 unsigned int
276 hook_uint_void_0 (void)
277 {
278 return 0;
279 }
280
281 HOST_WIDE_INT
282 hook_hwi_void_0 (void)
283 {
284 return 0;
285 }
286
287 void
288 hook_void_tree (tree)
289 {
290 }
291
292 void
293 hook_void_FILEptr_tree (FILE *, tree)
294 {
295 }
296
297 void
298 hook_void_constcharptr (const char *)
299 {
300 }
301
302 void
303 hook_void_tree_treeptr (tree, tree *)
304 {
305 }
306
307 void
308 hook_void_int_int (int, int)
309 {
310 }
311
312 bool
313 hook_bool_tree_false (tree)
314 {
315 return false;
316 }
317
318 bool
319 hook_bool_const_tree_false (const_tree)
320 {
321 return false;
322 }
323
324 bool
325 hook_bool_const_tree_const_tree_true (const_tree, const_tree)
326 {
327 return true;
328 }
329
330 bool
331 hook_bool_tree_true (tree)
332 {
333 return true;
334 }
335
336 bool
337 hook_bool_const_tree_true (const_tree)
338 {
339 return true;
340 }
341
342 bool
343 hook_bool_tree_tree_false (tree, tree)
344 {
345 return false;
346 }
347
348 bool
349 hook_bool_tree_tree_true (tree, tree)
350 {
351 return true;
352 }
353
354 bool
355 hook_bool_tree_bool_false (tree, bool)
356 {
357 return false;
358 }
359
360 bool
361 hook_bool_rtx_insn_true (rtx_insn *)
362 {
363 return true;
364 }
365
366 bool
367 hook_bool_rtx_false (rtx)
368 {
369 return false;
370 }
371
372 bool
373 hook_bool_uintp_uintp_false (unsigned int *, unsigned int *)
374 {
375 return false;
376 }
377
378 bool
379 hook_bool_rtx_mode_int_int_intp_bool_false (rtx, machine_mode, int, int,
380 int *, bool)
381 {
382 return false;
383 }
384
385 bool
386 hook_bool_wint_wint_uint_bool_true (const widest_int &, const widest_int &,
387 unsigned int, bool)
388 {
389 return true;
390 }
391
392 /* Generic hook that takes an rtx and returns it. */
393 rtx
394 hook_rtx_rtx_identity (rtx x)
395 {
396 return x;
397 }
398
399 /* Generic hook that takes an rtx and returns NULL_RTX. */
400 rtx
401 hook_rtx_rtx_null (rtx)
402 {
403 return NULL;
404 }
405
406 /* Generic hook that takes a tree and an int and returns NULL_RTX. */
407 rtx
408 hook_rtx_tree_int_null (tree, int)
409 {
410 return NULL;
411 }
412
413 /* Generic hook that takes a machine mode and returns an unsigned int 0. */
414 unsigned int
415 hook_uint_mode_0 (machine_mode)
416 {
417 return 0;
418 }
419
420 /* Generic hook that takes no arguments and returns a NULL const string. */
421 const char *
422 hook_constcharptr_void_null (void)
423 {
424 return NULL;
425 }
426
427 /* Generic hook that takes no arguments and returns a NULL string. */
428 char *
429 hook_charptr_void_null (void)
430 {
431 return NULL;
432 }
433
434 /* Generic hook that takes a tree and returns a NULL string. */
435 const char *
436 hook_constcharptr_const_tree_null (const_tree)
437 {
438 return NULL;
439 }
440
441 tree
442 hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool)
443 {
444 return NULL;
445 }
446
447 tree
448 hook_tree_tree_bool_null (tree, bool)
449 {
450 return NULL;
451 }
452
453 tree
454 hook_tree_tree_tree_null (tree, tree)
455 {
456 return NULL;
457 }
458
459 tree
460 hook_tree_tree_tree_tree_null (tree, tree, tree)
461 {
462 return NULL;
463 }
464
465 tree
466 hook_tree_treeptr_tree_tree_int_boolptr_null (tree *, tree, tree, int, bool *)
467 {
468 return NULL;
469 }
470
471 /* Generic hook that takes an rtx_insn *and returns a NULL string. */
472 const char *
473 hook_constcharptr_const_rtx_insn_null (const rtx_insn *)
474 {
475 return NULL;
476 }
477
478 const char *
479 hook_constcharptr_const_tree_const_tree_null (const_tree, const_tree)
480 {
481 return NULL;
482 }
483
484 const char *
485 hook_constcharptr_int_const_tree_null (int, const_tree)
486 {
487 return NULL;
488 }
489
490 const char *
491 hook_constcharptr_int_const_tree_const_tree_null (int, const_tree, const_tree)
492 {
493 return NULL;
494 }
495
496 /* Generic hook that takes a const_tree and returns NULL_TREE. */
497 tree
498 hook_tree_const_tree_null (const_tree)
499 {
500 return NULL;
501 }
502
503 /* Generic hook that takes no arguments and returns a NULL_TREE. */
504 tree
505 hook_tree_void_null (void)
506 {
507 return NULL;
508 }
509
510 /* Generic hook that takes a rtx_insn * and an int and returns a bool. */
511
512 bool
513 hook_bool_rtx_insn_int_false (rtx_insn *, int)
514 {
515 return false;
516 }
517
518 /* Generic hook that takes a rtx_insn * and an int and returns void. */
519
520 void
521 hook_void_rtx_insn_int (rtx_insn *, int)
522 {
523 }
524
525 /* Generic hook that takes a struct gcc_options * and returns void. */
526
527 void
528 hook_void_gcc_optionsp (struct gcc_options *)
529 {
530 }
531
532 /* Generic hook that takes an unsigned int and returns true. */
533
534 bool
535 hook_bool_uint_true (unsigned int)
536 {
537 return true;
538 }
539
540 /* Generic hook that takes an unsigned int, an unsigned int pointer and
541 returns false. */
542
543 bool
544 hook_bool_uint_uintp_false (unsigned int, unsigned int *)
545 {
546 return false;
547 }
548
549 /* Generic hook that takes a register class and returns false. */
550 bool
551 hook_bool_reg_class_t_false (reg_class_t regclass ATTRIBUTE_UNUSED)
552 {
553 return false;
554 }
555
556 /* Generic hook that takes 2 machine_modes and a register class and
557 returns true. */
558 bool
559 hook_bool_mode_mode_reg_class_t_true (machine_mode, machine_mode, reg_class_t)
560 {
561 return true;
562 }
563
564 /* Generic hook that takes a machine_mode and 2 register classes
565 and returns false. */
566 bool
567 hook_bool_mode_reg_class_t_reg_class_t_false (machine_mode, reg_class_t,
568 reg_class_t)
569 {
570 return false;
571 }
572
573 /* Generic hook that takes a mode and an unsigned HOST_WIDE_INT and
574 returns no mode. */
575
576 opt_machine_mode
577 hook_optmode_mode_uhwi_none (machine_mode, unsigned HOST_WIDE_INT)
578 {
579 return opt_machine_mode ();
580 }