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

source code of gcc/hooks.cc