1/* General-purpose hooks.
2 Copyright (C) 2002-2023 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_rtx_tree (rtx, tree)
285{
286}
287
288void
289hook_void_constcharptr (const char *)
290{
291}
292
293void
294hook_void_tree_treeptr (tree, tree *)
295{
296}
297
298void
299hook_void_int_int (int, int)
300{
301}
302
303bool
304hook_bool_tree_false (tree)
305{
306 return false;
307}
308
309bool
310hook_bool_const_tree_false (const_tree)
311{
312 return false;
313}
314
315bool
316hook_bool_const_tree_const_tree_true (const_tree, const_tree)
317{
318 return true;
319}
320
321bool
322hook_bool_tree_true (tree)
323{
324 return true;
325}
326
327bool
328hook_bool_const_tree_true (const_tree)
329{
330 return true;
331}
332
333bool
334hook_bool_tree_tree_false (tree, tree)
335{
336 return false;
337}
338
339bool
340hook_bool_tree_tree_true (tree, tree)
341{
342 return true;
343}
344
345bool
346hook_bool_tree_bool_false (tree, bool)
347{
348 return false;
349}
350
351bool
352hook_bool_rtx_insn_true (rtx_insn *)
353{
354 return true;
355}
356
357bool
358hook_bool_rtx_false (rtx)
359{
360 return false;
361}
362
363bool
364hook_bool_uintp_uintp_false (unsigned int *, unsigned int *)
365{
366 return false;
367}
368
369bool
370hook_bool_rtx_mode_int_int_intp_bool_false (rtx, machine_mode, int, int,
371 int *, bool)
372{
373 return false;
374}
375
376bool
377hook_bool_wint_wint_uint_bool_true (const widest_int &, const widest_int &,
378 unsigned int, bool)
379{
380 return true;
381}
382
383/* Generic hook that takes an rtx and returns it. */
384rtx
385hook_rtx_rtx_identity (rtx x)
386{
387 return x;
388}
389
390/* Generic hook that takes an rtx and returns NULL_RTX. */
391rtx
392hook_rtx_rtx_null (rtx)
393{
394 return NULL;
395}
396
397/* Generic hook that takes a tree and an int and returns NULL_RTX. */
398rtx
399hook_rtx_tree_int_null (tree, int)
400{
401 return NULL;
402}
403
404/* Generic hook that takes a machine mode and returns an unsigned int 0. */
405unsigned int
406hook_uint_mode_0 (machine_mode)
407{
408 return 0;
409}
410
411/* Generic hook that takes no arguments and returns a NULL const string. */
412const char *
413hook_constcharptr_void_null (void)
414{
415 return NULL;
416}
417
418/* Generic hook that takes no arguments and returns a NULL string. */
419char *
420hook_charptr_void_null (void)
421{
422 return NULL;
423}
424
425/* Generic hook that takes a tree and returns a NULL string. */
426const char *
427hook_constcharptr_const_tree_null (const_tree)
428{
429 return NULL;
430}
431
432tree
433hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool)
434{
435 return NULL;
436}
437
438tree
439hook_tree_tree_bool_null (tree, bool)
440{
441 return NULL;
442}
443
444tree
445hook_tree_tree_tree_null (tree, tree)
446{
447 return NULL;
448}
449
450tree
451hook_tree_tree_tree_tree_null (tree, tree, tree)
452{
453 return NULL;
454}
455
456tree
457hook_tree_treeptr_tree_tree_int_boolptr_null (tree *, tree, tree, int, bool *)
458{
459 return NULL;
460}
461
462/* Generic hook that takes an rtx_insn *and returns a NULL string. */
463const char *
464hook_constcharptr_const_rtx_insn_null (const rtx_insn *)
465{
466 return NULL;
467}
468
469const char *
470hook_constcharptr_const_tree_const_tree_null (const_tree, const_tree)
471{
472 return NULL;
473}
474
475const char *
476hook_constcharptr_int_const_tree_null (int, const_tree)
477{
478 return NULL;
479}
480
481const char *
482hook_constcharptr_int_const_tree_const_tree_null (int, const_tree, const_tree)
483{
484 return NULL;
485}
486
487/* Generic hook that takes a const_tree and returns NULL_TREE. */
488tree
489hook_tree_const_tree_null (const_tree)
490{
491 return NULL;
492}
493
494/* Generic hook that takes no arguments and returns a NULL_TREE. */
495tree
496hook_tree_void_null (void)
497{
498 return NULL;
499}
500
501/* Generic hook that takes a rtx_insn * and an int and returns a bool. */
502
503bool
504hook_bool_rtx_insn_int_false (rtx_insn *, int)
505{
506 return false;
507}
508
509/* Generic hook that takes a rtx_insn * and an int and returns void. */
510
511void
512hook_void_rtx_insn_int (rtx_insn *, int)
513{
514}
515
516/* Generic hook that takes a struct gcc_options * and returns void. */
517
518void
519hook_void_gcc_optionsp (struct gcc_options *)
520{
521}
522
523/* Generic hook that takes an unsigned int and returns true. */
524
525bool
526hook_bool_uint_true (unsigned int)
527{
528 return true;
529}
530
531/* Generic hook that takes an unsigned int, an unsigned int pointer and
532 returns false. */
533
534bool
535hook_bool_uint_uintp_false (unsigned int, unsigned int *)
536{
537 return false;
538}
539
540/* Generic hook that takes a register class and returns false. */
541bool
542hook_bool_reg_class_t_false (reg_class_t regclass ATTRIBUTE_UNUSED)
543{
544 return false;
545}
546
547/* Generic hook that takes 2 machine_modes and a register class and
548 returns true. */
549bool
550hook_bool_mode_mode_reg_class_t_true (machine_mode, machine_mode, reg_class_t)
551{
552 return true;
553}
554
555/* Generic hook that takes a machine_mode and 2 register classes
556 and returns false. */
557bool
558hook_bool_mode_reg_class_t_reg_class_t_false (machine_mode, reg_class_t,
559 reg_class_t)
560{
561 return false;
562}
563
564/* Generic hook that takes a mode and an unsigned HOST_WIDE_INT and
565 returns no mode. */
566
567opt_machine_mode
568hook_optmode_mode_uhwi_none (machine_mode, unsigned HOST_WIDE_INT)
569{
570 return opt_machine_mode ();
571}
572

source code of gcc/hooks.cc