]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/target.def
Change references of .c files to .cc files
[thirdparty/gcc.git] / gcc / target.def
CommitLineData
38f8b050 1/* Target hook definitions.
7adcbafe 2 Copyright (C) 2001-2022 Free Software Foundation, Inc.
38f8b050
JR
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
acce4e77
JM
22/* See target-hooks-macros.h for details of macros that should be
23 provided by the including file, and how to use them here. */
24#include "target-hooks-macros.h"
38f8b050 25
acce4e77
JM
26#undef HOOK_TYPE
27#define HOOK_TYPE "Target Hook"
38f8b050 28
acce4e77 29HOOK_VECTOR (TARGET_INITIALIZER, gcc_target)
38f8b050
JR
30
31/* Functions that output assembler for the target. */
32#define HOOK_PREFIX "TARGET_ASM_"
33HOOK_VECTOR (TARGET_ASM_OUT, asm_out)
34
35/* Opening and closing parentheses for asm expression grouping. */
36DEFHOOKPOD
37(open_paren,
673c2f63
JM
38 "These target hooks are C string constants, describing the syntax in the\n\
39assembler for grouping arithmetic expressions. If not overridden, they\n\
40default to normal parentheses, which is correct for most assemblers.",
38f8b050
JR
41 const char *, "(")
42DEFHOOKPODX (close_paren, const char *, ")")
43
44/* Assembler instructions for creating various kinds of integer object. */
45DEFHOOKPOD
46(byte_op,
673c2f63 47 "@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_HI_OP\n\
cac6691c 48@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PSI_OP\n\
673c2f63 49@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_SI_OP\n\
cac6691c 50@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PDI_OP\n\
673c2f63 51@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_DI_OP\n\
cac6691c 52@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PTI_OP\n\
673c2f63
JM
53@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_TI_OP\n\
54@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_HI_OP\n\
cac6691c 55@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PSI_OP\n\
673c2f63 56@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_SI_OP\n\
cac6691c 57@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PDI_OP\n\
673c2f63 58@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_DI_OP\n\
cac6691c 59@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PTI_OP\n\
673c2f63
JM
60@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_TI_OP\n\
61These hooks specify assembly directives for creating certain kinds\n\
62of integer object. The @code{TARGET_ASM_BYTE_OP} directive creates a\n\
63byte-sized object, the @code{TARGET_ASM_ALIGNED_HI_OP} one creates an\n\
64aligned two-byte object, and so on. Any of the hooks may be\n\
65@code{NULL}, indicating that no suitable directive is available.\n\
66\n\
67The compiler will print these strings at the start of a new line,\n\
68followed immediately by the object's initial value. In most cases,\n\
69the string should contain a tab, a pseudo-op, and then another tab.",
38f8b050
JR
70 const char *, "\t.byte\t")
71DEFHOOKPOD (aligned_op, "*", struct asm_int_op, TARGET_ASM_ALIGNED_INT_OP)
72DEFHOOKPOD (unaligned_op, "*", struct asm_int_op, TARGET_ASM_UNALIGNED_INT_OP)
73
74/* Try to output the assembler code for an integer object whose
75 value is given by X. SIZE is the size of the object in bytes and
76 ALIGNED_P indicates whether it is aligned. Return true if
77 successful. Only handles cases for which BYTE_OP, ALIGNED_OP
78 and UNALIGNED_OP are NULL. */
79DEFHOOK
80(integer,
673c2f63
JM
81 "The @code{assemble_integer} function uses this hook to output an\n\
82integer object. @var{x} is the object's value, @var{size} is its size\n\
83in bytes and @var{aligned_p} indicates whether it is aligned. The\n\
84function should return @code{true} if it was able to output the\n\
85object. If it returns false, @code{assemble_integer} will try to\n\
86split the object into smaller parts.\n\
87\n\
88The default implementation of this hook will use the\n\
89@code{TARGET_ASM_BYTE_OP} family of strings, returning @code{false}\n\
90when the relevant string is @code{NULL}.",
38f8b050
JR
91 /* Only handles cases for which BYTE_OP, ALIGNED_OP and UNALIGNED_OP are
92 NULL. */
93 bool, (rtx x, unsigned int size, int aligned_p),
94 default_assemble_integer)
95
dddb7af4
ST
96/* Assembly strings required after the .cfi_startproc label. */
97DEFHOOK
98(post_cfi_startproc,
99 "This target hook is used to emit assembly strings required by the target\n\
100after the .cfi_startproc directive. The first argument is the file stream to\n\
7e1f39b6
JL
101write the strings to and the second argument is the function\'s declaration. The\n\
102expected use is to add more .cfi_* directives.\n\
dddb7af4
ST
103\n\
104The default is to not output any assembly strings.",
105 void, (FILE *, tree),
106 hook_void_FILEptr_tree)
107
dc2af904
BS
108/* Notify the backend that we have completed emitting the data for a
109 decl. */
110DEFHOOK
111(decl_end,
112 "Define this hook if the target assembler requires a special marker to\n\
113terminate an initialized variable declaration.",
114 void, (void),
115 hook_void_void)
116
38f8b050
JR
117/* Output code that will globalize a label. */
118DEFHOOK
119(globalize_label,
673c2f63
JM
120 "This target hook is a function to output to the stdio stream\n\
121@var{stream} some commands that will make the label @var{name} global;\n\
122that is, available for reference from other files.\n\
123\n\
124The default implementation relies on a proper definition of\n\
125@code{GLOBAL_ASM_OP}.",
38f8b050
JR
126 void, (FILE *stream, const char *name),
127 default_globalize_label)
128
129/* Output code that will globalize a declaration. */
130DEFHOOK
131(globalize_decl_name,
673c2f63
JM
132 "This target hook is a function to output to the stdio stream\n\
133@var{stream} some commands that will make the name associated with @var{decl}\n\
134global; that is, available for reference from other files.\n\
135\n\
136The default implementation uses the TARGET_ASM_GLOBALIZE_LABEL target hook.",
38f8b050
JR
137 void, (FILE *stream, tree decl), default_globalize_decl_name)
138
0d4b5b86
BS
139/* Output code that will declare an external variable. */
140DEFHOOK
141(assemble_undefined_decl,
142 "This target hook is a function to output to the stdio stream\n\
143@var{stream} some commands that will declare the name associated with\n\
144@var{decl} which is not defined in the current translation unit. Most\n\
145assemblers do not require anything to be output in this case.",
146 void, (FILE *stream, const char *name, const_tree decl),
147 hook_void_FILEptr_constcharptr_const_tree)
148
38f8b050
JR
149/* Output code that will emit a label for unwind info, if this
150 target requires such labels. Second argument is the decl the
151 unwind info is associated with, third is a boolean: true if
152 this is for exception handling, fourth is a boolean: true if
153 this is only a placeholder for an omitted FDE. */
154DEFHOOK
155(emit_unwind_label,
673c2f63
JM
156 "This target hook emits a label at the beginning of each FDE@. It\n\
157should be defined on targets where FDEs need special labels, and it\n\
158should write the appropriate label, for the FDE associated with the\n\
159function declaration @var{decl}, to the stdio stream @var{stream}.\n\
160The third argument, @var{for_eh}, is a boolean: true if this is for an\n\
161exception table. The fourth argument, @var{empty}, is a boolean:\n\
162true if this is a placeholder label for an omitted FDE@.\n\
163\n\
164The default is that FDEs are not given nonlocal labels.",
38f8b050
JR
165 void, (FILE *stream, tree decl, int for_eh, int empty),
166 default_emit_unwind_label)
167
168/* Output code that will emit a label to divide up the exception table. */
169DEFHOOK
170(emit_except_table_label,
673c2f63
JM
171 "This target hook emits a label at the beginning of the exception table.\n\
172It should be defined on targets where it is desirable for the table\n\
173to be broken up according to function.\n\
174\n\
175The default is that no label is emitted.",
38f8b050
JR
176 void, (FILE *stream),
177 default_emit_except_table_label)
178
a68b5e52
RH
179/* Emit a directive for setting the personality for the function. */
180DEFHOOK
181(emit_except_personality,
4d3907c2
ML
182 "If the target implements @code{TARGET_ASM_UNWIND_EMIT}, this hook may be\n\
183used to emit a directive to install a personality hook into the unwind\n\
184info. This hook should not be used if dwarf2 unwind info is used.",
a68b5e52
RH
185 void, (rtx personality),
186 NULL)
187
5d46ec3d
IS
188/* If necessary, modify personality and LSDA references to handle
189 indirection. This is used when the assembler supports CFI directives. */
190DEFHOOK
191(make_eh_symbol_indirect,
4d3907c2
ML
192 "If necessary, modify personality and LSDA references to handle indirection.\n\
193The original symbol is in @code{origsymbol} and if @code{pubvis} is true\n\
194the symbol is visible outside the TU.",
5d46ec3d
IS
195 rtx, (rtx origsymbol, bool pubvis),
196 NULL)
197
38f8b050
JR
198/* Emit any directives required to unwind this instruction. */
199DEFHOOK
200(unwind_emit,
673c2f63
JM
201 "This target hook emits assembly directives required to unwind the\n\
202given instruction. This is only used when @code{TARGET_EXCEPT_UNWIND_INFO}\n\
203returns @code{UI_TARGET}.",
ac44248e 204 void, (FILE *stream, rtx_insn *insn),
2784ed9c 205 NULL)
38f8b050 206
3bc6b3e6
RH
207DEFHOOKPOD
208(unwind_emit_before_insn,
4d3907c2
ML
209 "True if the @code{TARGET_ASM_UNWIND_EMIT} hook should be called before\n\
210the assembly for @var{insn} has been emitted, false if the hook should\n\
211be called afterward.",
3bc6b3e6
RH
212 bool, true)
213
491d5b3c
IS
214/* Return true if the target needs extra instructions to restore the current
215 frame address after a DW_CFA_restore_state opcode. */
216DEFHOOK
217(should_restore_cfa_state,
4d3907c2
ML
218 "For DWARF-based unwind frames, two CFI instructions provide for save and\n\
219restore of register state. GCC maintains the current frame address (CFA)\n\
220separately from the register bank but the unwinder in libgcc preserves this\n\
221state along with the registers (and this is expected by the code that writes\n\
222the unwind frames). This hook allows the target to specify that the CFA data\n\
223is not saved/restored along with the registers by the target unwinder so that\n\
224suitable additional instructions should be emitted to restore it.",
491d5b3c
IS
225 bool, (void),
226 hook_bool_void_false)
227
4ee3b013
JR
228/* Generate an internal label.
229 For now this is just a wrapper for ASM_GENERATE_INTERNAL_LABEL. */
230DEFHOOK_UNDOC
231(generate_internal_label,
232 "",
233 void, (char *buf, const char *prefix, unsigned long labelno),
234 default_generate_internal_label)
235
38f8b050
JR
236/* Output an internal label. */
237DEFHOOK
238(internal_label,
673c2f63
JM
239 "A function to output to the stdio stream @var{stream} a label whose\n\
240name is made from the string @var{prefix} and the number @var{labelno}.\n\
241\n\
242It is absolutely essential that these labels be distinct from the labels\n\
243used for user-level functions and variables. Otherwise, certain programs\n\
244will have name conflicts with internal labels.\n\
245\n\
246It is desirable to exclude internal labels from the symbol table of the\n\
247object file. Most assemblers have a naming convention for labels that\n\
248should be excluded; on many systems, the letter @samp{L} at the\n\
249beginning of a label has this effect. You should find out what\n\
250convention your system uses, and follow it.\n\
251\n\
252The default version of this function utilizes @code{ASM_GENERATE_INTERNAL_LABEL}.",
38f8b050
JR
253 void, (FILE *stream, const char *prefix, unsigned long labelno),
254 default_internal_label)
255
256/* Output label for the constant. */
ad78130c 257DEFHOOK
38f8b050 258(declare_constant_name,
673c2f63
JM
259 "A target hook to output to the stdio stream @var{file} any text necessary\n\
260for declaring the name @var{name} of a constant which is being defined. This\n\
261target hook is responsible for outputting the label definition (perhaps using\n\
262@code{assemble_label}). The argument @var{exp} is the value of the constant,\n\
263and @var{size} is the size of the constant in bytes. The @var{name}\n\
264will be an internal label.\n\
265\n\
266The default version of this target hook, define the @var{name} in the\n\
267usual manner as a label (by means of @code{assemble_label}).\n\
268\n\
269You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in this target hook.",
ad78130c 270 void, (FILE *file, const char *name, const_tree expr, HOST_WIDE_INT size),
38f8b050
JR
271 default_asm_declare_constant_name)
272
273/* Emit a ttype table reference to a typeinfo object. */
274DEFHOOK
275(ttype,
673c2f63
JM
276 "This hook is used to output a reference from a frame unwinding table to\n\
277the type_info object identified by @var{sym}. It should return @code{true}\n\
278if the reference was output. Returning @code{false} will cause the\n\
279reference to be output using the normal Dwarf2 routines.",
38f8b050
JR
280 bool, (rtx sym),
281 hook_bool_rtx_false)
282
283/* Emit an assembler directive to set visibility for the symbol
284 associated with the tree decl. */
285DEFHOOK
286(assemble_visibility,
673c2f63
JM
287 "This target hook is a function to output to @var{asm_out_file} some\n\
288commands that will make the symbol(s) associated with @var{decl} have\n\
289hidden, protected or internal visibility as specified by @var{visibility}.",
38f8b050
JR
290 void, (tree decl, int visibility),
291 default_assemble_visibility)
292
417ca011
TD
293DEFHOOK
294(print_patchable_function_entry,
295 "Generate a patchable area at the function start, consisting of\n\
296@var{patch_area_size} NOP instructions. If the target supports named\n\
297sections and if @var{record_p} is true, insert a pointer to the current\n\
298location in the table of patchable functions. The default implementation\n\
299of the hook places the table of pointers in the special section named\n\
300@code{__patchable_function_entries}.",
301 void, (FILE *file, unsigned HOST_WIDE_INT patch_area_size, bool record_p),
302 default_print_patchable_function_entry)
303
38f8b050
JR
304/* Output the assembler code for entry to a function. */
305DEFHOOK
306(function_prologue,
673c2f63
JM
307 "If defined, a function that outputs the assembler code for entry to a\n\
308function. The prologue is responsible for setting up the stack frame,\n\
309initializing the frame pointer register, saving registers that must be\n\
310saved, and allocating @var{size} additional bytes of storage for the\n\
42776416
RS
311local variables. @var{file} is a stdio stream to which the assembler\n\
312code should be output.\n\
673c2f63
JM
313\n\
314The label for the beginning of the function need not be output by this\n\
315macro. That has already been done when the macro is run.\n\
316\n\
317@findex regs_ever_live\n\
318To determine which registers to save, the macro can refer to the array\n\
319@code{regs_ever_live}: element @var{r} is nonzero if hard register\n\
320@var{r} is used anywhere within the function. This implies the function\n\
321prologue should save register @var{r}, provided it is not one of the\n\
322call-used registers. (@code{TARGET_ASM_FUNCTION_EPILOGUE} must likewise use\n\
323@code{regs_ever_live}.)\n\
324\n\
325On machines that have ``register windows'', the function entry code does\n\
326not save on the stack the registers that are in the windows, even if\n\
327they are supposed to be preserved by function calls; instead it takes\n\
328appropriate steps to ``push'' the register stack, if any non-call-used\n\
329registers are used in the function.\n\
330\n\
331@findex frame_pointer_needed\n\
332On machines where functions may or may not have frame-pointers, the\n\
333function entry code must vary accordingly; it must set up the frame\n\
334pointer if one is wanted, and not otherwise. To determine whether a\n\
335frame pointer is in wanted, the macro can refer to the variable\n\
336@code{frame_pointer_needed}. The variable's value will be 1 at run\n\
337time in a function that needs a frame pointer. @xref{Elimination}.\n\
338\n\
339The function entry code is responsible for allocating any stack space\n\
340required for the function. This stack space consists of the regions\n\
341listed below. In most cases, these regions are allocated in the\n\
342order listed, with the last listed region closest to the top of the\n\
343stack (the lowest address if @code{STACK_GROWS_DOWNWARD} is defined, and\n\
344the highest address if it is not defined). You can use a different order\n\
345for a machine if doing so is more convenient or required for\n\
346compatibility reasons. Except in cases where required by standard\n\
347or by a debugger, there is no reason why the stack layout used by GCC\n\
348need agree with that used by other compilers for a machine.",
42776416 349 void, (FILE *file),
38f8b050
JR
350 default_function_pro_epilogue)
351
352/* Output the assembler code for end of prologue. */
353DEFHOOK
354(function_end_prologue,
673c2f63
JM
355 "If defined, a function that outputs assembler code at the end of a\n\
356prologue. This should be used when the function prologue is being\n\
357emitted as RTL, and you have some extra assembler that needs to be\n\
358emitted. @xref{prologue instruction pattern}.",
38f8b050
JR
359 void, (FILE *file),
360 no_asm_to_stream)
361
362/* Output the assembler code for start of epilogue. */
363DEFHOOK
364(function_begin_epilogue,
673c2f63
JM
365 "If defined, a function that outputs assembler code at the start of an\n\
366epilogue. This should be used when the function epilogue is being\n\
367emitted as RTL, and you have some extra assembler that needs to be\n\
368emitted. @xref{epilogue instruction pattern}.",
38f8b050
JR
369 void, (FILE *file),
370 no_asm_to_stream)
371
372/* Output the assembler code for function exit. */
373DEFHOOK
374(function_epilogue,
673c2f63
JM
375 "If defined, a function that outputs the assembler code for exit from a\n\
376function. The epilogue is responsible for restoring the saved\n\
377registers and stack pointer to their values when the function was\n\
378called, and returning control to the caller. This macro takes the\n\
42776416 379same argument as the macro @code{TARGET_ASM_FUNCTION_PROLOGUE}, and the\n\
673c2f63
JM
380registers to restore are determined from @code{regs_ever_live} and\n\
381@code{CALL_USED_REGISTERS} in the same way.\n\
382\n\
383On some machines, there is a single instruction that does all the work\n\
384of returning from the function. On these machines, give that\n\
385instruction the name @samp{return} and do not define the macro\n\
386@code{TARGET_ASM_FUNCTION_EPILOGUE} at all.\n\
387\n\
388Do not define a pattern named @samp{return} if you want the\n\
389@code{TARGET_ASM_FUNCTION_EPILOGUE} to be used. If you want the target\n\
390switches to control whether return instructions or epilogues are used,\n\
391define a @samp{return} pattern with a validity condition that tests the\n\
392target switches appropriately. If the @samp{return} pattern's validity\n\
393condition is false, epilogues will be used.\n\
394\n\
395On machines where functions may or may not have frame-pointers, the\n\
396function exit code must vary accordingly. Sometimes the code for these\n\
397two cases is completely different. To determine whether a frame pointer\n\
398is wanted, the macro can refer to the variable\n\
399@code{frame_pointer_needed}. The variable's value will be 1 when compiling\n\
400a function that needs a frame pointer.\n\
401\n\
402Normally, @code{TARGET_ASM_FUNCTION_PROLOGUE} and\n\
403@code{TARGET_ASM_FUNCTION_EPILOGUE} must treat leaf functions specially.\n\
404The C variable @code{current_function_is_leaf} is nonzero for such a\n\
405function. @xref{Leaf Functions}.\n\
406\n\
407On some machines, some functions pop their arguments on exit while\n\
408others leave that for the caller to do. For example, the 68020 when\n\
409given @option{-mrtd} pops arguments in functions that take a fixed\n\
410number of arguments.\n\
411\n\
412@findex pops_args\n\
413@findex crtl->args.pops_args\n\
414Your definition of the macro @code{RETURN_POPS_ARGS} decides which\n\
415functions pop their own arguments. @code{TARGET_ASM_FUNCTION_EPILOGUE}\n\
416needs to know what was decided. The number of bytes of the current\n\
417function's arguments that this function should pop is available in\n\
418@code{crtl->args.pops_args}. @xref{Scalar Return}.",
42776416 419 void, (FILE *file),
38f8b050
JR
420 default_function_pro_epilogue)
421
422/* Initialize target-specific sections. */
423DEFHOOK
424(init_sections,
673c2f63 425 "Define this hook if you need to do something special to set up the\n\
e53b6e56 426@file{varasm.cc} sections, or if your target has some special sections\n\
673c2f63
JM
427of its own that you need to create.\n\
428\n\
429GCC calls this hook after processing the command line, but before writing\n\
430any assembly code, and before calling any of the section-returning hooks\n\
431described below.",
38f8b050
JR
432 void, (void),
433 hook_void_void)
434
435/* Tell assembler to change to section NAME with attributes FLAGS.
436 If DECL is non-NULL, it is the VAR_DECL or FUNCTION_DECL with
437 which this section is associated. */
438DEFHOOK
439(named_section,
673c2f63
JM
440 "Output assembly directives to switch to section @var{name}. The section\n\
441should have attributes as specified by @var{flags}, which is a bit mask\n\
442of the @code{SECTION_*} flags defined in @file{output.h}. If @var{decl}\n\
443is non-NULL, it is the @code{VAR_DECL} or @code{FUNCTION_DECL} with which\n\
444this section is associated.",
38f8b050
JR
445 void, (const char *name, unsigned int flags, tree decl),
446 default_no_named_section)
447
0ee70cc0
AV
448/* Tell assembler what section attributes to assign this elf section
449 declaration, using their numerical value. */
450DEFHOOK
451(elf_flags_numeric,
452 "This hook can be used to encode ELF section flags for which no letter\n\
453code has been defined in the assembler. It is called by\n\
454@code{default_asm_named_section} whenever the section flags need to be\n\
455emitted in the assembler output. If the hook returns true, then the\n\
456numerical value for ELF section flags should be calculated from\n\
759a6472
AV
457@var{flags} and saved in @var{*num}; the value is printed out instead of the\n\
458normal sequence of letter codes. If the hook is not defined, or if it\n\
459returns false, then @var{num} is ignored and the traditional letter sequence\n\
460is emitted.",
0ee70cc0 461 bool, (unsigned int flags, unsigned int *num),
bf072854 462 hook_bool_uint_uintp_false)
0ee70cc0 463
f16d3f39
JH
464/* Return preferred text (sub)section for function DECL.
465 Main purpose of this function is to separate cold, normal and hot
466 functions. STARTUP is true when function is known to be used only
467 at startup (from static constructors or it is main()).
468 EXIT is true when function is known to be used only at exit
469 (from static destructors).
470 Return NULL if function should go to default text section. */
471DEFHOOK
472(function_section,
673c2f63
JM
473 "Return preferred text (sub)section for function @var{decl}.\n\
474Main purpose of this function is to separate cold, normal and hot\n\
475functions. @var{startup} is true when function is known to be used only\n\
476at startup (from static constructors or it is @code{main()}).\n\
477@var{exit} is true when function is known to be used only at exit\n\
478(from static destructors).\n\
479Return NULL if function should go to default text section.",
f16d3f39
JH
480 section *, (tree decl, enum node_frequency freq, bool startup, bool exit),
481 default_function_section)
482
14d11d40
IS
483/* Output the assembler code for function exit. */
484DEFHOOK
485(function_switched_text_sections,
4d3907c2
ML
486 "Used by the target to emit any assembler directives or additional\n\
487labels needed when a function is partitioned between different\n\
488sections. Output should be written to @var{file}. The function\n\
489decl is available as @var{decl} and the new section is `cold' if\n\
490@var{new_is_cold} is @code{true}.",
14d11d40
IS
491 void, (FILE *file, tree decl, bool new_is_cold),
492 default_function_switched_text_sections)
493
38f8b050
JR
494/* Return a mask describing how relocations should be treated when
495 selecting sections. Bit 1 should be set if global relocations
496 should be placed in a read-write section; bit 0 should be set if
497 local relocations should be placed in a read-write section. */
498DEFHOOK
499(reloc_rw_mask,
673c2f63
JM
500 "Return a mask describing how relocations should be treated when\n\
501selecting sections. Bit 1 should be set if global relocations\n\
502should be placed in a read-write section; bit 0 should be set if\n\
503local relocations should be placed in a read-write section.\n\
504\n\
505The default version of this function returns 3 when @option{-fpic}\n\
506is in effect, and 0 otherwise. The hook is typically redefined\n\
507when the target cannot support (some kinds of) dynamic relocations\n\
508in read-only sections even in executables.",
38f8b050
JR
509 int, (void),
510 default_reloc_rw_mask)
511
af1682fc
AS
512 /* Return a flag for either generating ADDR_DIF_VEC table
513 or ADDR_VEC table for jumps in case of -fPIC/-fPIE. */
514DEFHOOK
515(generate_pic_addr_diff_vec,
516"Return true to generate ADDR_DIF_VEC table\n\
517or false to generate ADDR_VEC table for jumps in case of -fPIC.\n\
518\n\
519The default version of this function returns true if flag_pic\n\
520equals true and false otherwise",
521 bool, (void),
522 default_generate_pic_addr_diff_vec)
523
38f8b050
JR
524 /* Return a section for EXP. It may be a DECL or a constant. RELOC
525 is nonzero if runtime relocations must be applied; bit 1 will be
526 set if the runtime relocations require non-local name resolution.
527 ALIGN is the required alignment of the data. */
528DEFHOOK
529(select_section,
673c2f63
JM
530 "Return the section into which @var{exp} should be placed. You can\n\
531assume that @var{exp} is either a @code{VAR_DECL} node or a constant of\n\
532some sort. @var{reloc} indicates whether the initial value of @var{exp}\n\
533requires link-time relocations. Bit 0 is set when variable contains\n\
534local relocations only, while bit 1 is set for global relocations.\n\
535@var{align} is the constant alignment in bits.\n\
536\n\
537The default version of this function takes care of putting read-only\n\
538variables in @code{readonly_data_section}.\n\
539\n\
540See also @var{USE_SELECT_SECTION_FOR_FUNCTIONS}.",
38f8b050
JR
541 section *, (tree exp, int reloc, unsigned HOST_WIDE_INT align),
542 default_select_section)
543
544/* Return a section for X. MODE is X's mode and ALIGN is its
545 alignment in bits. */
546DEFHOOK
547(select_rtx_section,
673c2f63
JM
548 "Return the section into which a constant @var{x}, of mode @var{mode},\n\
549should be placed. You can assume that @var{x} is some kind of\n\
550constant in RTL@. The argument @var{mode} is redundant except in the\n\
551case of a @code{const_int} rtx. @var{align} is the constant alignment\n\
552in bits.\n\
553\n\
554The default version of this function takes care of putting symbolic\n\
555constants in @code{flag_pic} mode in @code{data_section} and everything\n\
556else in @code{readonly_data_section}.",
ef4bddc2 557 section *, (machine_mode mode, rtx x, unsigned HOST_WIDE_INT align),
38f8b050
JR
558 default_select_rtx_section)
559
560/* Select a unique section name for DECL. RELOC is the same as
561 for SELECT_SECTION. */
562DEFHOOK
563(unique_section,
673c2f63
JM
564 "Build up a unique section name, expressed as a @code{STRING_CST} node,\n\
565and assign it to @samp{DECL_SECTION_NAME (@var{decl})}.\n\
566As with @code{TARGET_ASM_SELECT_SECTION}, @var{reloc} indicates whether\n\
567the initial value of @var{exp} requires link-time relocations.\n\
568\n\
569The default version of this function appends the symbol name to the\n\
570ELF section name that would normally be used for the symbol. For\n\
571example, the function @code{foo} would be placed in @code{.text.foo}.\n\
572Whatever the actual target object format, this is often good enough.",
38f8b050
JR
573 void, (tree decl, int reloc),
574 default_unique_section)
575
d5ac0401
HG
576/* Return the readonly data or relocated readonly data section
577 associated with function DECL. */
38f8b050
JR
578DEFHOOK
579(function_rodata_section,
d5ac0401
HG
580 "Return the readonly data or reloc readonly data section associated with\n\
581@samp{DECL_SECTION_NAME (@var{decl})}. @var{relocatable} selects the latter\n\
582over the former.\n\
673c2f63
JM
583The default version of this function selects @code{.gnu.linkonce.r.name} if\n\
584the function's section is @code{.gnu.linkonce.t.name}, @code{.rodata.name}\n\
d5ac0401
HG
585or @code{.data.rel.ro.name} if function is in @code{.text.name}, and\n\
586the normal readonly-data or reloc readonly data section otherwise.",
587 section *, (tree decl, bool relocatable),
38f8b050
JR
588 default_function_rodata_section)
589
727a65e6
BS
590/* Nonnull if the target wants to override the default ".rodata" prefix
591 for mergeable data sections. */
592DEFHOOKPOD
593(mergeable_rodata_prefix,
594 "Usually, the compiler uses the prefix @code{\".rodata\"} to construct\n\
595section names for mergeable constant data. Define this macro to override\n\
596the string if a different section name should be used.",
597 const char *, ".rodata")
598
50b0b78a
IS
599/* Return the section to be used for transactional memory clone tables. */
600DEFHOOK
601(tm_clone_table_section,
4d3907c2
ML
602 "Return the section that should be used for transactional memory clone\n\
603tables.",
50b0b78a
IS
604 section *, (void), default_clone_table_section)
605
38f8b050
JR
606/* Output a constructor for a symbol with a given priority. */
607DEFHOOK
608(constructor,
673c2f63
JM
609 "If defined, a function that outputs assembler code to arrange to call\n\
610the function referenced by @var{symbol} at initialization time.\n\
611\n\
612Assume that @var{symbol} is a @code{SYMBOL_REF} for a function taking\n\
613no arguments and with no return value. If the target supports initialization\n\
614priorities, @var{priority} is a value between 0 and @code{MAX_INIT_PRIORITY};\n\
615otherwise it must be @code{DEFAULT_INIT_PRIORITY}.\n\
616\n\
617If this macro is not defined by the target, a suitable default will\n\
618be chosen if (1) the target supports arbitrary section names, (2) the\n\
619target defines @code{CTORS_SECTION_ASM_OP}, or (3) @code{USE_COLLECT2}\n\
620is not defined.",
38f8b050
JR
621 void, (rtx symbol, int priority), NULL)
622
623/* Output a destructor for a symbol with a given priority. */
624DEFHOOK
625(destructor,
673c2f63
JM
626 "This is like @code{TARGET_ASM_CONSTRUCTOR} but used for termination\n\
627functions rather than initialization functions.",
38f8b050
JR
628 void, (rtx symbol, int priority), NULL)
629
630/* Output the assembler code for a thunk function. THUNK_DECL is the
631 declaration for the thunk function itself, FUNCTION is the decl for
632 the target function. DELTA is an immediate constant offset to be
633 added to THIS. If VCALL_OFFSET is nonzero, the word at
634 *(*this + vcall_offset) should be added to THIS. */
635DEFHOOK
636(output_mi_thunk,
673c2f63
JM
637 "A function that outputs the assembler code for a thunk\n\
638function, used to implement C++ virtual function calls with multiple\n\
639inheritance. The thunk acts as a wrapper around a virtual function,\n\
640adjusting the implicit object parameter before handing control off to\n\
641the real function.\n\
642\n\
643First, emit code to add the integer @var{delta} to the location that\n\
644contains the incoming first argument. Assume that this argument\n\
645contains a pointer, and is the one used to pass the @code{this} pointer\n\
646in C++. This is the incoming argument @emph{before} the function prologue,\n\
647e.g.@: @samp{%o0} on a sparc. The addition must preserve the values of\n\
648all other incoming arguments.\n\
649\n\
650Then, if @var{vcall_offset} is nonzero, an additional adjustment should be\n\
651made after adding @code{delta}. In particular, if @var{p} is the\n\
652adjusted pointer, the following adjustment should be made:\n\
653\n\
654@smallexample\n\
655p += (*((ptrdiff_t **)p))[vcall_offset/sizeof(ptrdiff_t)]\n\
656@end smallexample\n\
657\n\
658After the additions, emit code to jump to @var{function}, which is a\n\
659@code{FUNCTION_DECL}. This is a direct pure jump, not a call, and does\n\
660not touch the return address. Hence returning from @var{FUNCTION} will\n\
661return to whoever called the current @samp{thunk}.\n\
662\n\
663The effect must be as if @var{function} had been called directly with\n\
664the adjusted first argument. This macro is responsible for emitting all\n\
665of the code for a thunk function; @code{TARGET_ASM_FUNCTION_PROLOGUE}\n\
666and @code{TARGET_ASM_FUNCTION_EPILOGUE} are not invoked.\n\
667\n\
668The @var{thunk_fndecl} is redundant. (@var{delta} and @var{function}\n\
669have already been extracted from it.) It might possibly be useful on\n\
670some targets, but probably not.\n\
671\n\
672If you do not define this macro, the target-independent code in the C++\n\
673front end will generate a less efficient heavyweight thunk that calls\n\
674@var{function} instead of jumping to it. The generic approach does\n\
675not support varargs.",
38f8b050
JR
676 void, (FILE *file, tree thunk_fndecl, HOST_WIDE_INT delta,
677 HOST_WIDE_INT vcall_offset, tree function),
678 NULL)
679
680/* Determine whether output_mi_thunk would succeed. */
681/* ??? Ideally, this hook would not exist, and success or failure
682 would be returned from output_mi_thunk directly. But there's
683 too much undo-able setup involved in invoking output_mi_thunk.
684 Could be fixed by making output_mi_thunk emit rtl instead of
685 text to the output file. */
686DEFHOOK
687(can_output_mi_thunk,
673c2f63
JM
688 "A function that returns true if TARGET_ASM_OUTPUT_MI_THUNK would be able\n\
689to output the assembler code for the thunk function specified by the\n\
690arguments it is passed, and false otherwise. In the latter case, the\n\
691generic approach will be used by the C++ front end, with the limitations\n\
692previously exposed.",
38f8b050
JR
693 bool, (const_tree thunk_fndecl, HOST_WIDE_INT delta,
694 HOST_WIDE_INT vcall_offset, const_tree function),
695 hook_bool_const_tree_hwi_hwi_const_tree_false)
696
697/* Output any boilerplate text needed at the beginning of a
698 translation unit. */
699DEFHOOK
700(file_start,
673c2f63
JM
701 "Output to @code{asm_out_file} any text which the assembler expects to\n\
702find at the beginning of a file. The default behavior is controlled\n\
703by two flags, documented below. Unless your target's assembler is\n\
704quite unusual, if you override the default, you should call\n\
705@code{default_file_start} at some point in your target hook. This\n\
706lets other target files rely on these variables.",
38f8b050
JR
707 void, (void),
708 default_file_start)
709
710/* Output any boilerplate text needed at the end of a translation unit. */
711DEFHOOK
712(file_end,
673c2f63
JM
713 "Output to @code{asm_out_file} any text which the assembler expects\n\
714to find at the end of a file. The default is to output nothing.",
38f8b050
JR
715 void, (void),
716 hook_void_void)
717
718/* Output any boilerplate text needed at the beginning of an
719 LTO output stream. */
720DEFHOOK
721(lto_start,
673c2f63
JM
722 "Output to @code{asm_out_file} any text which the assembler expects\n\
723to find at the start of an LTO section. The default is to output\n\
724nothing.",
38f8b050
JR
725 void, (void),
726 hook_void_void)
727
728/* Output any boilerplate text needed at the end of an
729 LTO output stream. */
730DEFHOOK
731(lto_end,
673c2f63
JM
732 "Output to @code{asm_out_file} any text which the assembler expects\n\
733to find at the end of an LTO section. The default is to output\n\
734nothing.",
38f8b050
JR
735 void, (void),
736 hook_void_void)
737
738/* Output any boilerplace text needed at the end of a
739 translation unit before debug and unwind info is emitted. */
740DEFHOOK
741(code_end,
673c2f63
JM
742 "Output to @code{asm_out_file} any text which is needed before emitting\n\
743unwind info and debug info at the end of a file. Some targets emit\n\
744here PIC setup thunks that cannot be emitted at the end of file,\n\
745because they couldn't have unwind info then. The default is to output\n\
746nothing.",
38f8b050
JR
747 void, (void),
748 hook_void_void)
749
750/* Output an assembler pseudo-op to declare a library function name
751 external. */
752DEFHOOK
753(external_libcall,
673c2f63
JM
754 "This target hook is a function to output to @var{asm_out_file} an assembler\n\
755pseudo-op to declare a library function name external. The name of the\n\
756library function is given by @var{symref}, which is a @code{symbol_ref}.",
38f8b050
JR
757 void, (rtx symref),
758 default_external_libcall)
759
760/* Output an assembler directive to mark decl live. This instructs
761 linker to not dead code strip this symbol. */
762DEFHOOK
763(mark_decl_preserved,
673c2f63
JM
764 "This target hook is a function to output to @var{asm_out_file} an assembler\n\
765directive to annotate @var{symbol} as used. The Darwin target uses the\n\
766.no_dead_code_strip directive.",
38f8b050
JR
767 void, (const char *symbol),
768 hook_void_constcharptr)
769
770/* Output a record of the command line switches that have been passed. */
771DEFHOOK
772(record_gcc_switches,
673c2f63 773 "Provides the target with the ability to record the gcc command line\n\
7caa4970 774switches provided as argument.\n\
673c2f63
JM
775\n\
776By default this hook is set to NULL, but an example implementation is\n\
777provided for ELF based targets. Called @var{elf_record_gcc_switches},\n\
778it records the switches as ASCII text inside a new, string mergeable\n\
779section in the assembler output file. The name of the new section is\n\
780provided by the @code{TARGET_ASM_RECORD_GCC_SWITCHES_SECTION} target\n\
781hook.",
7caa4970 782 void, (const char *),
38f8b050
JR
783 NULL)
784
785/* The name of the section that the example ELF implementation of
786 record_gcc_switches will use to store the information. Target
787 specific versions of record_gcc_switches may or may not use
788 this information. */
789DEFHOOKPOD
790(record_gcc_switches_section,
673c2f63
JM
791 "This is the name of the section that will be created by the example\n\
792ELF implementation of the @code{TARGET_ASM_RECORD_GCC_SWITCHES} target\n\
793hook.",
38f8b050
JR
794 const char *, ".GCC.command.line")
795
796/* Output the definition of a section anchor. */
797DEFHOOK
798(output_anchor,
673c2f63
JM
799 "Write the assembly code to define section anchor @var{x}, which is a\n\
800@code{SYMBOL_REF} for which @samp{SYMBOL_REF_ANCHOR_P (@var{x})} is true.\n\
801The hook is called with the assembly output position set to the beginning\n\
802of @code{SYMBOL_REF_BLOCK (@var{x})}.\n\
803\n\
804If @code{ASM_OUTPUT_DEF} is available, the hook's default definition uses\n\
805it to define the symbol as @samp{. + SYMBOL_REF_BLOCK_OFFSET (@var{x})}.\n\
806If @code{ASM_OUTPUT_DEF} is not available, the hook's default definition\n\
807is @code{NULL}, which disables the use of section anchors altogether.",
38f8b050
JR
808 void, (rtx x),
809 default_asm_output_anchor)
810
a8781821
SB
811DEFHOOK
812(output_ident,
4d3907c2
ML
813 "Output a string based on @var{name}, suitable for the @samp{#ident}\n\
814directive, or the equivalent directive or pragma in non-C-family languages.\n\
815If this hook is not defined, nothing is output for the @samp{#ident}\n\
816directive.",
a8781821
SB
817 void, (const char *name),
818 hook_void_constcharptr)
819
38f8b050
JR
820/* Output a DTP-relative reference to a TLS symbol. */
821DEFHOOK
822(output_dwarf_dtprel,
673c2f63
JM
823 "If defined, this target hook is a function which outputs a DTP-relative\n\
824reference to the given TLS symbol of the specified size.",
38f8b050
JR
825 void, (FILE *file, int size, rtx x),
826 NULL)
827
828/* Some target machines need to postscan each insn after it is output. */
829DEFHOOK
830(final_postscan_insn,
673c2f63
JM
831 "If defined, this target hook is a function which is executed just after the\n\
832output of assembler code for @var{insn}, to change the mode of the assembler\n\
833if necessary.\n\
834\n\
835Here the argument @var{opvec} is the vector containing the operands\n\
836extracted from @var{insn}, and @var{noperands} is the number of\n\
837elements of the vector which contain meaningful data for this insn.\n\
838The contents of this vector are what was used to convert the insn\n\
839template into assembler code, so you can change the assembler mode\n\
840by checking the contents of the vector.",
ac44248e 841 void, (FILE *file, rtx_insn *insn, rtx *opvec, int noperands),
38f8b050
JR
842 NULL)
843
844/* Emit the trampoline template. This hook may be NULL. */
845DEFHOOK
846(trampoline_template,
673c2f63
JM
847 "This hook is called by @code{assemble_trampoline_template} to output,\n\
848on the stream @var{f}, assembler code for a block of data that contains\n\
849the constant parts of a trampoline. This code should not include a\n\
850label---the label is taken care of automatically.\n\
851\n\
852If you do not define this hook, it means no template is needed\n\
853for the target. Do not define this hook on systems where the block move\n\
854code to copy the trampoline into place would be larger than the code\n\
855to generate it on the spot.",
38f8b050
JR
856 void, (FILE *f),
857 NULL)
858
b5f5d41d
AS
859DEFHOOK
860(output_source_filename,
4d3907c2
ML
861 "Output DWARF debugging information which indicates that filename\n\
862@var{name} is the current source file to the stdio stream @var{file}.\n\
863\n\
864This target hook need not be defined if the standard form of output\n\
865for the file format in use is appropriate.",
b5f5d41d
AS
866 void ,(FILE *file, const char *name),
867 default_asm_output_source_filename)
868
6cbd8875
AS
869DEFHOOK
870(output_addr_const_extra,
673c2f63
JM
871 "A target hook to recognize @var{rtx} patterns that @code{output_addr_const}\n\
872can't deal with, and output assembly code to @var{file} corresponding to\n\
873the pattern @var{x}. This may be used to allow machine-dependent\n\
874@code{UNSPEC}s to appear within constants.\n\
875\n\
876If target hook fails to recognize a pattern, it must return @code{false},\n\
877so that a standard error message is printed. If it prints an error message\n\
878itself, by calling, for example, @code{output_operand_lossage}, it may just\n\
879return @code{true}.",
6cbd8875 880 bool, (FILE *file, rtx x),
e1267133 881 hook_bool_FILEptr_rtx_false)
6cbd8875 882
38f8b050
JR
883/* ??? The TARGET_PRINT_OPERAND* hooks are part of the asm_out struct,
884 even though that is not reflected in the macro name to override their
885 initializers. */
886#undef HOOK_PREFIX
887#define HOOK_PREFIX "TARGET_"
888
889/* Emit a machine-specific insn operand. */
4d00d5dd
JR
890/* ??? tm.texi only documents the old macro PRINT_OPERAND,
891 not this hook, and uses a different name for the argument FILE. */
38f8b050
JR
892DEFHOOK_UNDOC
893(print_operand,
894 "",
895 void, (FILE *file, rtx x, int code),
896 default_print_operand)
897
898/* Emit a machine-specific memory address. */
4d00d5dd
JR
899/* ??? tm.texi only documents the old macro PRINT_OPERAND_ADDRESS,
900 not this hook, and uses different argument names. */
38f8b050
JR
901DEFHOOK_UNDOC
902(print_operand_address,
903 "",
cc8ca59e 904 void, (FILE *file, machine_mode mode, rtx addr),
38f8b050
JR
905 default_print_operand_address)
906
907/* Determine whether CODE is a valid punctuation character for the
908 `print_operand' hook. */
4d00d5dd
JR
909/* ??? tm.texi only documents the old macro PRINT_OPERAND_PUNCT_VALID_P,
910 not this hook. */
38f8b050
JR
911DEFHOOK_UNDOC
912(print_operand_punct_valid_p,
913 "",
914 bool ,(unsigned char code),
915 default_print_operand_punct_valid_p)
916
77754180
DK
917/* Given a symbol name, perform same mangling as assemble_name and
918 ASM_OUTPUT_LABELREF, returning result as an IDENTIFIER_NODE. */
919DEFHOOK
920(mangle_assembler_name,
e53b6e56 921 "Given a symbol @var{name}, perform same mangling as @code{varasm.cc}'s\n\
4d3907c2
ML
922@code{assemble_name}, but in memory rather than to a file stream, returning\n\
923result as an @code{IDENTIFIER_NODE}. Required for correct LTO symtabs. The\n\
924default implementation calls the @code{TARGET_STRIP_NAME_ENCODING} hook and\n\
925then prepends the @code{USER_LABEL_PREFIX}, if any.",
77754180
DK
926 tree, (const char *name),
927 default_mangle_assembler_name)
928
38f8b050
JR
929HOOK_VECTOR_END (asm_out)
930
931/* Functions relating to instruction scheduling. All of these
e53b6e56 932 default to null pointers, which haifa-sched.cc looks for and handles. */
38f8b050
JR
933#undef HOOK_PREFIX
934#define HOOK_PREFIX "TARGET_SCHED_"
935HOOK_VECTOR (TARGET_SCHED, sched)
936
937/* Given the current cost, COST, of an insn, INSN, calculate and
938 return a new cost based on its relationship to DEP_INSN through
939 the dependence LINK. The default is to make no adjustment. */
940DEFHOOK
941(adjust_cost,
673c2f63 942 "This function corrects the value of @var{cost} based on the\n\
b505225b
TS
943relationship between @var{insn} and @var{dep_insn} through a\n\
944dependence of type dep_type, and strength @var{dw}. It should return the new\n\
945value. The default is to make no adjustment to @var{cost}. This can be\n\
946used for example to specify to the scheduler using the traditional pipeline\n\
947description that an output- or anti-dependence does not incur the same cost\n\
948as a data-dependence. If the scheduler using the automaton based pipeline\n\
673c2f63
JM
949description, the cost of anti-dependence is zero and the cost of\n\
950output-dependence is maximum of one and the difference of latency\n\
951times of the first and the second insns. If these values are not\n\
952acceptable, you could use the hook to modify them too. See also\n\
953@pxref{Processor pipeline description}.",
b505225b
TS
954 int, (rtx_insn *insn, int dep_type1, rtx_insn *dep_insn, int cost,
955 unsigned int dw),
956 NULL)
38f8b050
JR
957
958/* Adjust the priority of an insn as you see fit. Returns the new priority. */
959DEFHOOK
960(adjust_priority,
673c2f63
JM
961 "This hook adjusts the integer scheduling priority @var{priority} of\n\
962@var{insn}. It should return the new priority. Increase the priority to\n\
963execute @var{insn} earlier, reduce the priority to execute @var{insn}\n\
964later. Do not define this hook if you do not need to adjust the\n\
965scheduling priorities of insns.",
ac44248e 966 int, (rtx_insn *insn, int priority), NULL)
38f8b050
JR
967
968/* Function which returns the maximum number of insns that can be
969 scheduled in the same machine cycle. This must be constant
970 over an entire compilation. The default is 1. */
971DEFHOOK
972(issue_rate,
673c2f63
JM
973 "This hook returns the maximum number of instructions that can ever\n\
974issue at the same time on the target machine. The default is one.\n\
975Although the insn scheduler can define itself the possibility of issue\n\
976an insn on the same cycle, the value can serve as an additional\n\
977constraint to issue insns on the same simulated processor cycle (see\n\
978hooks @samp{TARGET_SCHED_REORDER} and @samp{TARGET_SCHED_REORDER2}).\n\
979This value must be constant over the entire compilation. If you need\n\
980it to vary depending on what the instructions are, you must use\n\
981@samp{TARGET_SCHED_VARIABLE_ISSUE}.",
38f8b050
JR
982 int, (void), NULL)
983
984/* Calculate how much this insn affects how many more insns we
985 can emit this cycle. Default is they all cost the same. */
986DEFHOOK
987(variable_issue,
673c2f63
JM
988 "This hook is executed by the scheduler after it has scheduled an insn\n\
989from the ready list. It should return the number of insns which can\n\
990still be issued in the current cycle. The default is\n\
991@samp{@w{@var{more} - 1}} for insns other than @code{CLOBBER} and\n\
992@code{USE}, which normally are not counted against the issue rate.\n\
993You should define this hook if some insns take more machine resources\n\
994than others, so that fewer insns can follow them in the same cycle.\n\
995@var{file} is either a null pointer, or a stdio stream to write any\n\
996debug output to. @var{verbose} is the verbose level provided by\n\
997@option{-fsched-verbose-@var{n}}. @var{insn} is the instruction that\n\
998was scheduled.",
ac44248e 999 int, (FILE *file, int verbose, rtx_insn *insn, int more), NULL)
38f8b050
JR
1000
1001/* Initialize machine-dependent scheduling code. */
1002DEFHOOK
1003(init,
673c2f63
JM
1004 "This hook is executed by the scheduler at the beginning of each block of\n\
1005instructions that are to be scheduled. @var{file} is either a null\n\
1006pointer, or a stdio stream to write any debug output to. @var{verbose}\n\
1007is the verbose level provided by @option{-fsched-verbose-@var{n}}.\n\
1008@var{max_ready} is the maximum number of insns in the current scheduling\n\
1009region that can be live at the same time. This can be used to allocate\n\
1010scratch space if it is needed, e.g.@: by @samp{TARGET_SCHED_REORDER}.",
38f8b050
JR
1011 void, (FILE *file, int verbose, int max_ready), NULL)
1012
1013/* Finalize machine-dependent scheduling code. */
1014DEFHOOK
1015(finish,
673c2f63
JM
1016 "This hook is executed by the scheduler at the end of each block of\n\
1017instructions that are to be scheduled. It can be used to perform\n\
1018cleanup of any actions done by the other scheduling hooks. @var{file}\n\
1019is either a null pointer, or a stdio stream to write any debug output\n\
1020to. @var{verbose} is the verbose level provided by\n\
1021@option{-fsched-verbose-@var{n}}.",
38f8b050
JR
1022 void, (FILE *file, int verbose), NULL)
1023
1024 /* Initialize machine-dependent function wide scheduling code. */
1025DEFHOOK
1026(init_global,
673c2f63
JM
1027 "This hook is executed by the scheduler after function level initializations.\n\
1028@var{file} is either a null pointer, or a stdio stream to write any debug output to.\n\
1029@var{verbose} is the verbose level provided by @option{-fsched-verbose-@var{n}}.\n\
1030@var{old_max_uid} is the maximum insn uid when scheduling begins.",
38f8b050
JR
1031 void, (FILE *file, int verbose, int old_max_uid), NULL)
1032
1033/* Finalize machine-dependent function wide scheduling code. */
1034DEFHOOK
1035(finish_global,
673c2f63
JM
1036 "This is the cleanup hook corresponding to @code{TARGET_SCHED_INIT_GLOBAL}.\n\
1037@var{file} is either a null pointer, or a stdio stream to write any debug output to.\n\
1038@var{verbose} is the verbose level provided by @option{-fsched-verbose-@var{n}}.",
38f8b050
JR
1039 void, (FILE *file, int verbose), NULL)
1040
1041/* Reorder insns in a machine-dependent fashion, in two different
1042 places. Default does nothing. */
1043DEFHOOK
1044(reorder,
673c2f63
JM
1045 "This hook is executed by the scheduler after it has scheduled the ready\n\
1046list, to allow the machine description to reorder it (for example to\n\
1047combine two small instructions together on @samp{VLIW} machines).\n\
1048@var{file} is either a null pointer, or a stdio stream to write any\n\
1049debug output to. @var{verbose} is the verbose level provided by\n\
1050@option{-fsched-verbose-@var{n}}. @var{ready} is a pointer to the ready\n\
1051list of instructions that are ready to be scheduled. @var{n_readyp} is\n\
1052a pointer to the number of elements in the ready list. The scheduler\n\
1053reads the ready list in reverse order, starting with\n\
1054@var{ready}[@var{*n_readyp} @minus{} 1] and going to @var{ready}[0]. @var{clock}\n\
1055is the timer tick of the scheduler. You may modify the ready list and\n\
1056the number of ready insns. The return value is the number of insns that\n\
1057can issue this cycle; normally this is just @code{issue_rate}. See also\n\
1058@samp{TARGET_SCHED_REORDER2}.",
ce1ce33a 1059 int, (FILE *file, int verbose, rtx_insn **ready, int *n_readyp, int clock), NULL)
38f8b050
JR
1060
1061DEFHOOK
1062(reorder2,
673c2f63
JM
1063 "Like @samp{TARGET_SCHED_REORDER}, but called at a different time. That\n\
1064function is called whenever the scheduler starts a new cycle. This one\n\
1065is called once per iteration over a cycle, immediately after\n\
1066@samp{TARGET_SCHED_VARIABLE_ISSUE}; it can reorder the ready list and\n\
1067return the number of insns to be scheduled in the same cycle. Defining\n\
1068this hook can be useful if there are frequent situations where\n\
1069scheduling one insn causes other insns to become ready in the same\n\
1070cycle. These other insns can then be taken into account properly.",
ce1ce33a 1071 int, (FILE *file, int verbose, rtx_insn **ready, int *n_readyp, int clock), NULL)
38f8b050 1072
0dc41f28
WM
1073DEFHOOK
1074(macro_fusion_p,
1075 "This hook is used to check whether target platform supports macro fusion.",
1076 bool, (void), NULL)
1077
1078DEFHOOK
1079(macro_fusion_pair_p,
892d9879
KT
1080 "This hook is used to check whether two insns should be macro fused for\n\
1081a target microarchitecture. If this hook returns true for the given insn pair\n\
1082(@var{prev} and @var{curr}), the scheduler will put them into a sched\n\
1083group, and they will not be scheduled apart. The two insns will be either\n\
1084two SET insns or a compare and a conditional jump and this hook should\n\
1085validate any dependencies needed to fuse the two insns together.",
1086 bool, (rtx_insn *prev, rtx_insn *curr), NULL)
0dc41f28 1087
38f8b050
JR
1088/* The following member value is a pointer to a function called
1089 after evaluation forward dependencies of insns in chain given
1090 by two parameter values (head and tail correspondingly). */
1091DEFHOOK
1092(dependencies_evaluation_hook,
673c2f63
JM
1093 "This hook is called after evaluation forward dependencies of insns in\n\
1094chain given by two parameter values (@var{head} and @var{tail}\n\
1095correspondingly) but before insns scheduling of the insn chain. For\n\
1096example, it can be used for better insn classification if it requires\n\
1097analysis of dependencies. This hook can use backward and forward\n\
1098dependencies of the insn scheduler because they are already\n\
1099calculated.",
ce1ce33a 1100 void, (rtx_insn *head, rtx_insn *tail), NULL)
38f8b050
JR
1101
1102/* The values of the following four members are pointers to functions
1103 used to simplify the automaton descriptions. dfa_pre_cycle_insn and
1104 dfa_post_cycle_insn give functions returning insns which are used to
1105 change the pipeline hazard recognizer state when the new simulated
1106 processor cycle correspondingly starts and finishes. The function
1107 defined by init_dfa_pre_cycle_insn and init_dfa_post_cycle_insn are
1108 used to initialize the corresponding insns. The default values of
1109 the members result in not changing the automaton state when the
1110 new simulated processor cycle correspondingly starts and finishes. */
1111
1112DEFHOOK
1113(init_dfa_pre_cycle_insn,
673c2f63 1114 "The hook can be used to initialize data used by the previous hook.",
38f8b050
JR
1115 void, (void), NULL)
1116
1117DEFHOOK
1118(dfa_pre_cycle_insn,
673c2f63
JM
1119 "The hook returns an RTL insn. The automaton state used in the\n\
1120pipeline hazard recognizer is changed as if the insn were scheduled\n\
1121when the new simulated processor cycle starts. Usage of the hook may\n\
1122simplify the automaton pipeline description for some @acronym{VLIW}\n\
1123processors. If the hook is defined, it is used only for the automaton\n\
1124based pipeline description. The default is not to change the state\n\
1125when the new simulated processor cycle starts.",
38f8b050
JR
1126 rtx, (void), NULL)
1127
1128DEFHOOK
1129(init_dfa_post_cycle_insn,
673c2f63
JM
1130 "The hook is analogous to @samp{TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN} but\n\
1131used to initialize data used by the previous hook.",
38f8b050
JR
1132 void, (void), NULL)
1133
1134DEFHOOK
1135(dfa_post_cycle_insn,
673c2f63
JM
1136 "The hook is analogous to @samp{TARGET_SCHED_DFA_PRE_CYCLE_INSN} but used\n\
1137to changed the state as if the insn were scheduled when the new\n\
1138simulated processor cycle finishes.",
ac44248e 1139 rtx_insn *, (void), NULL)
38f8b050
JR
1140
1141/* The values of the following two members are pointers to
1142 functions used to simplify the automaton descriptions.
1143 dfa_pre_advance_cycle and dfa_post_advance_cycle are getting called
1144 immediately before and after cycle is advanced. */
1145
1146DEFHOOK
1147(dfa_pre_advance_cycle,
673c2f63
JM
1148 "The hook to notify target that the current simulated cycle is about to finish.\n\
1149The hook is analogous to @samp{TARGET_SCHED_DFA_PRE_CYCLE_INSN} but used\n\
1150to change the state in more complicated situations - e.g., when advancing\n\
1151state on a single insn is not enough.",
38f8b050
JR
1152 void, (void), NULL)
1153
1154DEFHOOK
1155(dfa_post_advance_cycle,
673c2f63
JM
1156 "The hook to notify target that new simulated cycle has just started.\n\
1157The hook is analogous to @samp{TARGET_SCHED_DFA_POST_CYCLE_INSN} but used\n\
1158to change the state in more complicated situations - e.g., when advancing\n\
1159state on a single insn is not enough.",
38f8b050
JR
1160 void, (void), NULL)
1161
1162/* The following member value is a pointer to a function returning value
1163 which defines how many insns in queue `ready' will we try for
1164 multi-pass scheduling. If the member value is nonzero and the
1165 function returns positive value, the DFA based scheduler will make
1166 multi-pass scheduling for the first cycle. In other words, we will
1167 try to choose ready insn which permits to start maximum number of
1168 insns on the same cycle. */
1169DEFHOOK
1170(first_cycle_multipass_dfa_lookahead,
673c2f63
JM
1171 "This hook controls better choosing an insn from the ready insn queue\n\
1172for the @acronym{DFA}-based insn scheduler. Usually the scheduler\n\
1173chooses the first insn from the queue. If the hook returns a positive\n\
1174value, an additional scheduler code tries all permutations of\n\
1175@samp{TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD ()}\n\
1176subsequent ready insns to choose an insn whose issue will result in\n\
1177maximal number of issued insns on the same cycle. For the\n\
1178@acronym{VLIW} processor, the code could actually solve the problem of\n\
1179packing simple insns into the @acronym{VLIW} insn. Of course, if the\n\
1180rules of @acronym{VLIW} packing are described in the automaton.\n\
1181\n\
1182This code also could be used for superscalar @acronym{RISC}\n\
1183processors. Let us consider a superscalar @acronym{RISC} processor\n\
1184with 3 pipelines. Some insns can be executed in pipelines @var{A} or\n\
1185@var{B}, some insns can be executed only in pipelines @var{B} or\n\
1186@var{C}, and one insn can be executed in pipeline @var{B}. The\n\
1187processor may issue the 1st insn into @var{A} and the 2nd one into\n\
1188@var{B}. In this case, the 3rd insn will wait for freeing @var{B}\n\
1189until the next cycle. If the scheduler issues the 3rd insn the first,\n\
1190the processor could issue all 3 insns per cycle.\n\
1191\n\
1192Actually this code demonstrates advantages of the automaton based\n\
1193pipeline hazard recognizer. We try quickly and easy many insn\n\
1194schedules to choose the best one.\n\
1195\n\
1196The default is no multipass scheduling.",
38f8b050
JR
1197 int, (void), NULL)
1198
1199/* The following member value is pointer to a function controlling
1200 what insns from the ready insn queue will be considered for the
1201 multipass insn scheduling. If the hook returns zero for insn
1202 passed as the parameter, the insn will be not chosen to be issued. */
1203DEFHOOK
1204(first_cycle_multipass_dfa_lookahead_guard,
673c2f63
JM
1205 "\n\
1206This hook controls what insns from the ready insn queue will be\n\
1207considered for the multipass insn scheduling. If the hook returns\n\
4960a0cb
MK
1208zero for @var{insn}, the insn will be considered in multipass scheduling.\n\
1209Positive return values will remove @var{insn} from consideration on\n\
1210the current round of multipass scheduling.\n\
1211Negative return values will remove @var{insn} from consideration for given\n\
1212number of cycles.\n\
1213Backends should be careful about returning non-zero for highest priority\n\
1214instruction at position 0 in the ready list. @var{ready_index} is passed\n\
1215to allow backends make correct judgements.\n\
673c2f63
JM
1216\n\
1217The default is that any ready insns can be chosen to be issued.",
ac44248e 1218 int, (rtx_insn *insn, int ready_index), NULL)
38f8b050 1219
894fd6f2
MK
1220/* This hook prepares the target for a new round of multipass
1221 scheduling.
1222 DATA is a pointer to target-specific data used for multipass scheduling.
1223 READY_TRY and N_READY represent the current state of search in the
1224 optimization space. The target can filter out instructions that
1225 should not be tried during current round by setting corresponding
1226 elements in READY_TRY to non-zero.
1227 FIRST_CYCLE_INSN_P is true if this is the first round of multipass
1228 scheduling on current cycle. */
1229DEFHOOK
1230(first_cycle_multipass_begin,
673c2f63
JM
1231 "This hook prepares the target backend for a new round of multipass\n\
1232scheduling.",
4960a0cb 1233 void, (void *data, signed char *ready_try, int n_ready, bool first_cycle_insn_p),
894fd6f2
MK
1234 NULL)
1235
1236/* This hook is called when multipass scheduling evaluates instruction INSN.
1237 DATA is a pointer to target-specific data that can be used to record effects
1238 of INSN on CPU that are not described in DFA.
1239 READY_TRY and N_READY represent the current state of search in the
1240 optimization space. The target can filter out instructions that
073a8998 1241 should not be tried after issuing INSN by setting corresponding
894fd6f2
MK
1242 elements in READY_TRY to non-zero.
1243 INSN is the instruction being evaluated.
1244 PREV_DATA is a pointer to target-specific data corresponding
073a8998 1245 to a state before issuing INSN. */
894fd6f2
MK
1246DEFHOOK
1247(first_cycle_multipass_issue,
673c2f63 1248 "This hook is called when multipass scheduling evaluates instruction INSN.",
ac44248e 1249 void, (void *data, signed char *ready_try, int n_ready, rtx_insn *insn,
894fd6f2
MK
1250 const void *prev_data), NULL)
1251
1252/* This hook is called when multipass scheduling backtracks from evaluation of
1253 instruction corresponding to DATA.
1254 DATA is a pointer to target-specific data that stores the effects
1255 of instruction from which the algorithm backtracks on CPU that are not
1256 described in DFA.
1257 READY_TRY and N_READY represent the current state of search in the
1258 optimization space. The target can filter out instructions that
073a8998 1259 should not be tried after issuing INSN by setting corresponding
894fd6f2
MK
1260 elements in READY_TRY to non-zero. */
1261DEFHOOK
1262(first_cycle_multipass_backtrack,
673c2f63
JM
1263 "This is called when multipass scheduling backtracks from evaluation of\n\
1264an instruction.",
4960a0cb 1265 void, (const void *data, signed char *ready_try, int n_ready), NULL)
894fd6f2
MK
1266
1267/* This hook notifies the target about the result of the concluded current
1268 round of multipass scheduling.
1269 DATA is a pointer.
1270 If DATA is non-NULL it points to target-specific data used for multipass
1271 scheduling which corresponds to instruction at the start of the chain of
1272 the winning solution. DATA is NULL when multipass scheduling cannot find
1273 a good enough solution on current cycle and decides to retry later,
1274 usually after advancing the cycle count. */
1275DEFHOOK
1276(first_cycle_multipass_end,
673c2f63
JM
1277 "This hook notifies the target about the result of the concluded current\n\
1278round of multipass scheduling.",
894fd6f2
MK
1279 void, (const void *data), NULL)
1280
1281/* This hook is called to initialize target-specific data for multipass
1282 scheduling after it has been allocated.
1283 DATA is a pointer to target-specific data that stores the effects
1284 of instruction from which the algorithm backtracks on CPU that are not
1285 described in DFA. */
1286DEFHOOK
1287(first_cycle_multipass_init,
673c2f63 1288 "This hook initializes target-specific data used in multipass scheduling.",
894fd6f2
MK
1289 void, (void *data), NULL)
1290
1291/* This hook is called to finalize target-specific data for multipass
1292 scheduling before it is deallocated.
1293 DATA is a pointer to target-specific data that stores the effects
1294 of instruction from which the algorithm backtracks on CPU that are not
1295 described in DFA. */
1296DEFHOOK
1297(first_cycle_multipass_fini,
673c2f63 1298 "This hook finalizes target-specific data used in multipass scheduling.",
894fd6f2
MK
1299 void, (void *data), NULL)
1300
38f8b050
JR
1301/* The following member value is pointer to a function called by
1302 the insn scheduler before issuing insn passed as the third
1303 parameter on given cycle. If the hook returns nonzero, the
1304 insn is not issued on given processors cycle. Instead of that,
1305 the processor cycle is advanced. If the value passed through
1306 the last parameter is zero, the insn ready queue is not sorted
1307 on the new cycle start as usually. The first parameter passes
1308 file for debugging output. The second one passes the scheduler
1309 verbose level of the debugging output. The forth and the fifth
1310 parameter values are correspondingly processor cycle on which
1311 the previous insn has been issued and the current processor cycle. */
c06bbdf7 1312DEFHOOK
38f8b050 1313(dfa_new_cycle,
673c2f63
JM
1314 "This hook is called by the insn scheduler before issuing @var{insn}\n\
1315on cycle @var{clock}. If the hook returns nonzero,\n\
1316@var{insn} is not issued on this processor cycle. Instead,\n\
1317the processor cycle is advanced. If *@var{sort_p}\n\
1318is zero, the insn ready queue is not sorted on the new cycle\n\
1319start as usually. @var{dump} and @var{verbose} specify the file and\n\
1320verbosity level to use for debugging output.\n\
1321@var{last_clock} and @var{clock} are, respectively, the\n\
1322processor cycle on which the previous insn has been issued,\n\
1323and the current processor cycle.",
ac44248e 1324 int, (FILE *dump, int verbose, rtx_insn *insn, int last_clock,
c06bbdf7 1325 int clock, int *sort_p),
38f8b050
JR
1326 NULL)
1327
1328/* The following member value is a pointer to a function called by the
1329 insn scheduler. It should return true if there exists a dependence
1330 which is considered costly by the target, between the insn
1331 DEP_PRO (&_DEP), and the insn DEP_CON (&_DEP). The first parameter is
1332 the dep that represents the dependence between the two insns. The
1333 second argument is the cost of the dependence as estimated by
1334 the scheduler. The last argument is the distance in cycles
1335 between the already scheduled insn (first parameter) and the
1336 second insn (second parameter). */
1337DEFHOOK
1338(is_costly_dependence,
673c2f63
JM
1339 "This hook is used to define which dependences are considered costly by\n\
1340the target, so costly that it is not advisable to schedule the insns that\n\
1341are involved in the dependence too close to one another. The parameters\n\
1342to this hook are as follows: The first parameter @var{_dep} is the dependence\n\
1343being evaluated. The second parameter @var{cost} is the cost of the\n\
1344dependence as estimated by the scheduler, and the third\n\
1345parameter @var{distance} is the distance in cycles between the two insns.\n\
1346The hook returns @code{true} if considering the distance between the two\n\
1347insns the dependence between them is considered costly by the target,\n\
1348and @code{false} otherwise.\n\
1349\n\
1350Defining this hook can be useful in multiple-issue out-of-order machines,\n\
1351where (a) it's practically hopeless to predict the actual data/resource\n\
1352delays, however: (b) there's a better chance to predict the actual grouping\n\
1353that will be formed, and (c) correctly emulating the grouping can be very\n\
1354important. In such targets one may want to allow issuing dependent insns\n\
1355closer to one another---i.e., closer than the dependence distance; however,\n\
1356not in cases of ``costly dependences'', which this hooks allows to define.",
38f8b050
JR
1357 bool, (struct _dep *_dep, int cost, int distance), NULL)
1358
38f8b050
JR
1359/* The following member value is a pointer to a function called
1360 by the insn scheduler. This hook is called to notify the backend
1361 that new instructions were emitted. */
1362DEFHOOK
1363(h_i_d_extended,
673c2f63
JM
1364 "This hook is called by the insn scheduler after emitting a new instruction to\n\
1365the instruction stream. The hook notifies a target backend to extend its\n\
1366per instruction data structures.",
38f8b050
JR
1367 void, (void), NULL)
1368
1369/* Next 5 functions are for multi-point scheduling. */
1370
1371/* Allocate memory for scheduler context. */
1372DEFHOOK
1373(alloc_sched_context,
673c2f63 1374 "Return a pointer to a store large enough to hold target scheduling context.",
38f8b050
JR
1375 void *, (void), NULL)
1376
1377/* Fills the context from the local machine scheduler context. */
1378DEFHOOK
1379(init_sched_context,
673c2f63
JM
1380 "Initialize store pointed to by @var{tc} to hold target scheduling context.\n\
1381It @var{clean_p} is true then initialize @var{tc} as if scheduler is at the\n\
1382beginning of the block. Otherwise, copy the current context into @var{tc}.",
38f8b050
JR
1383 void, (void *tc, bool clean_p), NULL)
1384
1385/* Sets local machine scheduler context to a saved value. */
1386DEFHOOK
1387(set_sched_context,
673c2f63 1388 "Copy target scheduling context pointed to by @var{tc} to the current context.",
38f8b050
JR
1389 void, (void *tc), NULL)
1390
1391/* Clears a scheduler context so it becomes like after init. */
1392DEFHOOK
1393(clear_sched_context,
673c2f63 1394 "Deallocate internal data in target scheduling context pointed to by @var{tc}.",
38f8b050
JR
1395 void, (void *tc), NULL)
1396
1397/* Frees the scheduler context. */
1398DEFHOOK
1399(free_sched_context,
673c2f63 1400 "Deallocate a store for target scheduling context pointed to by @var{tc}.",
38f8b050
JR
1401 void, (void *tc), NULL)
1402
1403/* The following member value is a pointer to a function called
1404 by the insn scheduler.
1405 The first parameter is an instruction, the second parameter is the type
1406 of the requested speculation, and the third parameter is a pointer to the
1407 speculative pattern of the corresponding type (set if return value == 1).
1408 It should return
1409 -1, if there is no pattern, that will satisfy the requested speculation type,
1410 0, if current pattern satisfies the requested speculation type,
1411 1, if pattern of the instruction should be changed to the newly
1412 generated one. */
1413DEFHOOK
1414(speculate_insn,
673c2f63
JM
1415 "This hook is called by the insn scheduler when @var{insn} has only\n\
1416speculative dependencies and therefore can be scheduled speculatively.\n\
1417The hook is used to check if the pattern of @var{insn} has a speculative\n\
1418version and, in case of successful check, to generate that speculative\n\
1419pattern. The hook should return 1, if the instruction has a speculative form,\n\
1420or @minus{}1, if it doesn't. @var{request} describes the type of requested\n\
1421speculation. If the return value equals 1 then @var{new_pat} is assigned\n\
1422the generated speculative pattern.",
ac44248e 1423 int, (rtx_insn *insn, unsigned int dep_status, rtx *new_pat), NULL)
38f8b050
JR
1424
1425/* The following member value is a pointer to a function called
1426 by the insn scheduler. It should return true if the check instruction
1427 passed as the parameter needs a recovery block. */
1428DEFHOOK
1429(needs_block_p,
673c2f63
JM
1430 "This hook is called by the insn scheduler during generation of recovery code\n\
1431for @var{insn}. It should return @code{true}, if the corresponding check\n\
1432instruction should branch to recovery code, or @code{false} otherwise.",
8e90de43 1433 bool, (unsigned int dep_status), NULL)
38f8b050
JR
1434
1435/* The following member value is a pointer to a function called
1436 by the insn scheduler. It should return a pattern for the check
1437 instruction.
1438 The first parameter is a speculative instruction, the second parameter
1439 is the label of the corresponding recovery block (or null, if it is a
8e90de43
SB
1440 simple check). The third parameter is the kind of speculation that
1441 is being performed. */
38f8b050
JR
1442DEFHOOK
1443(gen_spec_check,
673c2f63
JM
1444 "This hook is called by the insn scheduler to generate a pattern for recovery\n\
1445check instruction. If @var{mutate_p} is zero, then @var{insn} is a\n\
1446speculative instruction for which the check should be generated.\n\
1447@var{label} is either a label of a basic block, where recovery code should\n\
1448be emitted, or a null pointer, when requested check doesn't branch to\n\
1449recovery code (a simple check). If @var{mutate_p} is nonzero, then\n\
1450a pattern for a branchy check corresponding to a simple check denoted by\n\
1451@var{insn} should be generated. In this case @var{label} can't be null.",
ac44248e 1452 rtx, (rtx_insn *insn, rtx_insn *label, unsigned int ds), NULL)
38f8b050 1453
38f8b050
JR
1454/* The following member value is a pointer to a function that provides
1455 information about the speculation capabilities of the target.
1456 The parameter is a pointer to spec_info variable. */
1457DEFHOOK
1458(set_sched_flags,
673c2f63
JM
1459 "This hook is used by the insn scheduler to find out what features should be\n\
1460enabled/used.\n\
1461The structure *@var{spec_info} should be filled in by the target.\n\
1462The structure describes speculation types that can be used in the scheduler.",
38f8b050
JR
1463 void, (struct spec_info_def *spec_info), NULL)
1464
1465DEFHOOK_UNDOC
1466(get_insn_spec_ds,
1467 "Return speculation types of instruction @var{insn}.",
ac44248e 1468 unsigned int, (rtx_insn *insn), NULL)
38f8b050
JR
1469
1470DEFHOOK_UNDOC
1471(get_insn_checked_ds,
1472 "Return speculation types that are checked for instruction @var{insn}",
ac44248e 1473 unsigned int, (rtx_insn *insn), NULL)
38f8b050 1474
176274c9
SB
1475DEFHOOK
1476(can_speculate_insn,
1477 "Some instructions should never be speculated by the schedulers, usually\n\
1478 because the instruction is too expensive to get this wrong. Often such\n\
1479 instructions have long latency, and often they are not fully modeled in the\n\
1480 pipeline descriptions. This hook should return @code{false} if @var{insn}\n\
1481 should not be speculated.",
1482 bool, (rtx_insn *insn), hook_bool_rtx_insn_true)
1483
38f8b050
JR
1484DEFHOOK_UNDOC
1485(skip_rtx_p,
1486 "Return bool if rtx scanning should just skip current layer and\
1487 advance to the inner rtxes.",
1488 bool, (const_rtx x), NULL)
1489
1490/* The following member value is a pointer to a function that provides
1491 information about the target resource-based lower bound which is
1492 used by the swing modulo scheduler. The parameter is a pointer
1493 to ddg variable. */
1494DEFHOOK
1495(sms_res_mii,
673c2f63
JM
1496 "This hook is called by the swing modulo scheduler to calculate a\n\
1497resource-based lower bound which is based on the resources available in\n\
1498the machine and the resources required by each instruction. The target\n\
1499backend can use @var{g} to calculate such bound. A very simple lower\n\
1500bound will be used in case this hook is not implemented: the total number\n\
1501of instructions divided by the issue rate.",
38f8b050
JR
1502 int, (struct ddg *g), NULL)
1503
7942e47e
RY
1504/* The following member value is a function that initializes dispatch
1505 schedling and adds instructions to dispatch window according to its
1506 parameters. */
1507DEFHOOK
1508(dispatch_do,
673c2f63
JM
1509"This hook is called by Haifa Scheduler. It performs the operation specified\n\
1510in its second parameter.",
ac44248e
DM
1511void, (rtx_insn *insn, int x),
1512hook_void_rtx_insn_int)
7942e47e 1513
700d4cb0 1514/* The following member value is a function that returns true is
7942e47e
RY
1515 dispatch schedling is supported in hardware and condition passed
1516 as the second parameter is true. */
1517DEFHOOK
1518(dispatch,
673c2f63
JM
1519"This hook is called by Haifa Scheduler. It returns true if dispatch scheduling\n\
1520is supported in hardware and the condition specified in the parameter is true.",
ac44248e
DM
1521bool, (rtx_insn *insn, int x),
1522hook_bool_rtx_insn_int_false)
7942e47e 1523
b0bd15f7
BS
1524DEFHOOKPOD
1525(exposed_pipeline,
1526"True if the processor has an exposed pipeline, which means that not just\n\
1527the order of instructions is important for correctness when scheduling, but\n\
1528also the latencies of operations.",
1529bool, false)
1530
df7b0cc4
EI
1531/* The following member value is a function that returns number
1532 of operations reassociator should try to put in parallel for
1533 statements of the given type. By default 1 is used. */
1534DEFHOOK
1535(reassociation_width,
1536"This hook is called by tree reassociator to determine a level of\n\
1537parallelism required in output calculations chain.",
ef4bddc2 1538int, (unsigned int opc, machine_mode mode),
df7b0cc4
EI
1539hook_int_uint_mode_1)
1540
b16abbcb
BC
1541/* The following member value is a function that returns priority for
1542 fusion of each instruction via pointer parameters. */
1543DEFHOOK
1544(fusion_priority,
1545"This hook is called by scheduling fusion pass. It calculates fusion\n\
1546priorities for each instruction passed in by parameter. The priorities\n\
1547are returned via pointer parameters.\n\
1548\n\
1549@var{insn} is the instruction whose priorities need to be calculated.\n\
1550@var{max_pri} is the maximum priority can be returned in any cases.\n\
1551@var{fusion_pri} is the pointer parameter through which @var{insn}'s\n\
1552fusion priority should be calculated and returned.\n\
1553@var{pri} is the pointer parameter through which @var{insn}'s priority\n\
1554should be calculated and returned.\n\
1555\n\
1556Same @var{fusion_pri} should be returned for instructions which should\n\
1557be scheduled together. Different @var{pri} should be returned for\n\
1558instructions with same @var{fusion_pri}. @var{fusion_pri} is the major\n\
1559sort key, @var{pri} is the minor sort key. All instructions will be\n\
1560scheduled according to the two priorities. All priorities calculated\n\
1561should be between 0 (exclusive) and @var{max_pri} (inclusive). To avoid\n\
1562false dependencies, @var{fusion_pri} of instructions which need to be\n\
1563scheduled together should be smaller than @var{fusion_pri} of irrelevant\n\
1564instructions.\n\
1565\n\
1566Given below example:\n\
1567\n\
51be4977 1568@smallexample\n\
b16abbcb
BC
1569 ldr r10, [r1, 4]\n\
1570 add r4, r4, r10\n\
1571 ldr r15, [r2, 8]\n\
1572 sub r5, r5, r15\n\
1573 ldr r11, [r1, 0]\n\
1574 add r4, r4, r11\n\
1575 ldr r16, [r2, 12]\n\
1576 sub r5, r5, r16\n\
51be4977 1577@end smallexample\n\
b16abbcb
BC
1578\n\
1579On targets like ARM/AArch64, the two pairs of consecutive loads should be\n\
1580merged. Since peephole2 pass can't help in this case unless consecutive\n\
1581loads are actually next to each other in instruction flow. That's where\n\
1582this scheduling fusion pass works. This hook calculates priority for each\n\
1583instruction based on its fustion type, like:\n\
1584\n\
51be4977
BC
1585@smallexample\n\
1586 ldr r10, [r1, 4] ; fusion_pri=99, pri=96\n\
1587 add r4, r4, r10 ; fusion_pri=100, pri=100\n\
1588 ldr r15, [r2, 8] ; fusion_pri=98, pri=92\n\
1589 sub r5, r5, r15 ; fusion_pri=100, pri=100\n\
1590 ldr r11, [r1, 0] ; fusion_pri=99, pri=100\n\
1591 add r4, r4, r11 ; fusion_pri=100, pri=100\n\
1592 ldr r16, [r2, 12] ; fusion_pri=98, pri=88\n\
1593 sub r5, r5, r16 ; fusion_pri=100, pri=100\n\
1594@end smallexample\n\
b16abbcb
BC
1595\n\
1596Scheduling fusion pass then sorts all ready to issue instructions according\n\
1597to the priorities. As a result, instructions of same fusion type will be\n\
1598pushed together in instruction flow, like:\n\
1599\n\
51be4977 1600@smallexample\n\
b16abbcb
BC
1601 ldr r11, [r1, 0]\n\
1602 ldr r10, [r1, 4]\n\
1603 ldr r15, [r2, 8]\n\
1604 ldr r16, [r2, 12]\n\
1605 add r4, r4, r10\n\
1606 sub r5, r5, r15\n\
1607 add r4, r4, r11\n\
1608 sub r5, r5, r16\n\
51be4977 1609@end smallexample\n\
b16abbcb
BC
1610\n\
1611Now peephole2 pass can simply merge the two pairs of loads.\n\
1612\n\
1613Since scheduling fusion pass relies on peephole2 to do real fusion\n\
1614work, it is only enabled by default when peephole2 is in effect.\n\
1615\n\
1616This is firstly introduced on ARM/AArch64 targets, please refer to\n\
1617the hook implementation for how different fusion types are supported.",
1618void, (rtx_insn *insn, int max_pri, int *fusion_pri, int *pri), NULL)
1619
38f8b050
JR
1620HOOK_VECTOR_END (sched)
1621
e76c7157 1622/* Functions relating to OpenMP SIMD and __attribute__((simd)) clones. */
0136f8f0
AH
1623#undef HOOK_PREFIX
1624#define HOOK_PREFIX "TARGET_SIMD_CLONE_"
1625HOOK_VECTOR (TARGET_SIMD_CLONE, simd_clone)
1626
1627DEFHOOK
1628(compute_vecsize_and_simdlen,
1629"This hook should set @var{vecsize_mangle}, @var{vecsize_int}, @var{vecsize_float}\n\
1630fields in @var{simd_clone} structure pointed by @var{clone_info} argument and also\n\
1631@var{simdlen} field if it was previously 0.\n\
1632The hook should return 0 if SIMD clones shouldn't be emitted,\n\
1633or number of @var{vecsize_mangle} variants that should be emitted.",
1634int, (struct cgraph_node *, struct cgraph_simd_clone *, tree, int), NULL)
1635
1636DEFHOOK
1637(adjust,
1638"This hook should add implicit @code{attribute(target(\"...\"))} attribute\n\
1639to SIMD clone @var{node} if needed.",
1640void, (struct cgraph_node *), NULL)
1641
1642DEFHOOK
1643(usable,
1644"This hook should return -1 if SIMD clone @var{node} shouldn't be used\n\
1645in vectorized loops in current function, or non-negative number if it is\n\
1646usable. In that case, the smaller the number is, the more desirable it is\n\
1647to use it.",
1648int, (struct cgraph_node *), NULL)
1649
1650HOOK_VECTOR_END (simd_clone)
1651
5012919d
AM
1652/* Functions relating to OpenMP SIMT vectorization transform. */
1653#undef HOOK_PREFIX
1654#define HOOK_PREFIX "TARGET_SIMT_"
1655HOOK_VECTOR (TARGET_SIMT, simt)
1656
1657DEFHOOK
1658(vf,
1659"Return number of threads in SIMT thread group on the target.",
1660int, (void), NULL)
1661
1662HOOK_VECTOR_END (simt)
1663
9ba66bf5
JJ
1664/* Functions relating to OpenMP. */
1665#undef HOOK_PREFIX
1666#define HOOK_PREFIX "TARGET_OMP_"
1667HOOK_VECTOR (TARGET_OMP, omp)
1668
1669DEFHOOK
1670(device_kind_arch_isa,
1671"Return 1 if @var{trait} @var{name} is present in the OpenMP context's\n\
1672device trait set, return 0 if not present in any OpenMP context in the\n\
1673whole translation unit, or -1 if not present in the current OpenMP context\n\
1674but might be present in another OpenMP context in the same TU.",
1675int, (enum omp_device_kind_arch_isa trait, const char *name), NULL)
1676
1677HOOK_VECTOR_END (omp)
1678
94829f87
NS
1679/* Functions relating to openacc. */
1680#undef HOOK_PREFIX
1681#define HOOK_PREFIX "TARGET_GOACC_"
1682HOOK_VECTOR (TARGET_GOACC, goacc)
1683
1684DEFHOOK
1685(validate_dims,
1686"This hook should check the launch dimensions provided for an OpenACC\n\
1687compute region, or routine. Defaulted values are represented as -1\n\
b6adbb9f 1688and non-constant values as 0. The @var{fn_level} is negative for the\n\
700d4cb0 1689function corresponding to the compute region. For a routine it is the\n\
b6adbb9f
NS
1690outermost level at which partitioned execution may be spawned. The hook\n\
1691should verify non-default values. If DECL is NULL, global defaults\n\
1692are being validated and unspecified defaults should be filled in.\n\
1693Diagnostics should be issued as appropriate. Return\n\
94829f87
NS
1694true, if changes have been made. You must override this hook to\n\
1695provide dimensions larger than 1.",
46dedae6 1696bool, (tree decl, int *dims, int fn_level, unsigned used),
94829f87
NS
1697default_goacc_validate_dims)
1698
bd751975
NS
1699DEFHOOK
1700(dim_limit,
1701"This hook should return the maximum size of a particular dimension,\n\
1702or zero if unbounded.",
1703int, (int axis),
1704default_goacc_dim_limit)
1705
6e91acf8
NS
1706DEFHOOK
1707(fork_join,
9bd46bc9
NS
1708"This hook can be used to convert IFN_GOACC_FORK and IFN_GOACC_JOIN\n\
1709function calls to target-specific gimple, or indicate whether they\n\
1710should be retained. It is executed during the oacc_device_lower pass.\n\
1711It should return true, if the call should be retained. It should\n\
1712return false, if it is to be deleted (either because target-specific\n\
1713gimple has been inserted before it, or there is no need for it).\n\
1714The default hook returns false, if there are no RTL expanders for them.",
6e91acf8
NS
1715bool, (gcall *call, const int *dims, bool is_fork),
1716default_goacc_fork_join)
1717
e5014671
NS
1718DEFHOOK
1719(reduction,
1720"This hook is used by the oacc_transform pass to expand calls to the\n\
1721@var{GOACC_REDUCTION} internal function, into a sequence of gimple\n\
1722instructions. @var{call} is gimple statement containing the call to\n\
1723the function. This hook removes statement @var{call} after the\n\
1724expanded sequence has been inserted. This hook is also responsible\n\
1725for allocating any storage for reductions when necessary.",
1726void, (gcall *call),
1727default_goacc_reduction)
1728
29a2f518
JB
1729DEFHOOK
1730(adjust_private_decl,
1731"This hook, if defined, is used by accelerator target back-ends to adjust\n\
1732OpenACC variable declarations that should be made private to the given\n\
1733parallelism level (i.e. @code{GOMP_DIM_GANG}, @code{GOMP_DIM_WORKER} or\n\
1734@code{GOMP_DIM_VECTOR}). A typical use for this hook is to force variable\n\
1735declarations at the @code{gang} level to reside in GPU shared memory.\n\
11b8286a 1736@var{loc} may be used for diagnostic purposes.\n\
29a2f518
JB
1737\n\
1738You may also use the @code{TARGET_GOACC_EXPAND_VAR_DECL} hook if the\n\
1739adjusted variable declaration needs to be expanded to RTL in a non-standard\n\
1740way.",
11b8286a 1741tree, (location_t loc, tree var, int level),
29a2f518
JB
1742NULL)
1743
1744DEFHOOK
1745(expand_var_decl,
1746"This hook, if defined, is used by accelerator target back-ends to expand\n\
1747specially handled kinds of @code{VAR_DECL} expressions. A particular use is\n\
1748to place variables with specific attributes inside special accelarator\n\
1749memories. A return value of @code{NULL} indicates that the target does not\n\
1750handle this @code{VAR_DECL}, and normal RTL expanding is resumed.\n\
1751\n\
1752Only define this hook if your accelerator target needs to expand certain\n\
1753@code{VAR_DECL} nodes in a way that differs from the default. You can also adjust\n\
1754private variables at OpenACC device-lowering time using the\n\
1755@code{TARGET_GOACC_ADJUST_PRIVATE_DECL} target hook.",
1756rtx, (tree var),
1757NULL)
1758
e2a58ed6
JB
1759DEFHOOK
1760(create_worker_broadcast_record,
1761"Create a record used to propagate local-variable state from an active\n\
1762worker to other workers. A possible implementation might adjust the type\n\
1763of REC to place the new variable in shared GPU memory.\n\
1764\n\
1765Presence of this target hook indicates that middle end neutering/broadcasting\n\
1766be used.",
2a3f9f65
JB
1767tree, (tree rec, bool sender, const char *name, unsigned HOST_WIDE_INT offset),
1768NULL)
1769
1770DEFHOOK
1771(shared_mem_layout,
1772"Lay out a fixed shared-memory region on the target. The LO and HI\n\
1773arguments should be set to a range of addresses that can be used for worker\n\
1774broadcasting. The dimensions, reduction size and gang-private size\n\
1775arguments are for the current offload region.",
1776void, (unsigned HOST_WIDE_INT *, unsigned HOST_WIDE_INT *, int[],
1777 unsigned HOST_WIDE_INT[], unsigned HOST_WIDE_INT[]),
e2a58ed6
JB
1778NULL)
1779
94829f87
NS
1780HOOK_VECTOR_END (goacc)
1781
38f8b050
JR
1782/* Functions relating to vectorization. */
1783#undef HOOK_PREFIX
1784#define HOOK_PREFIX "TARGET_VECTORIZE_"
1785HOOK_VECTOR (TARGET_VECTORIZE, vectorize)
1786
1787/* The following member value is a pointer to a function called
1788 by the vectorizer, and return the decl of the target builtin
1789 function. */
1790DEFHOOK
1791(builtin_mask_for_load,
673c2f63
JM
1792 "This hook should return the DECL of a function @var{f} that given an\n\
1793address @var{addr} as an argument returns a mask @var{m} that can be\n\
1794used to extract from two vectors the relevant data that resides in\n\
1795@var{addr} in case @var{addr} is not properly aligned.\n\
1796\n\
1797The autovectorizer, when vectorizing a load operation from an address\n\
1798@var{addr} that may be unaligned, will generate two vector loads from\n\
1799the two aligned addresses around @var{addr}. It then generates a\n\
1800@code{REALIGN_LOAD} operation to extract the relevant data from the\n\
1801two loaded vectors. The first two arguments to @code{REALIGN_LOAD},\n\
1802@var{v1} and @var{v2}, are the two vectors, each of size @var{VS}, and\n\
1803the third argument, @var{OFF}, defines how the data will be extracted\n\
1804from these two vectors: if @var{OFF} is 0, then the returned vector is\n\
1805@var{v2}; otherwise, the returned vector is composed from the last\n\
1806@var{VS}-@var{OFF} elements of @var{v1} concatenated to the first\n\
1807@var{OFF} elements of @var{v2}.\n\
1808\n\
1809If this hook is defined, the autovectorizer will generate a call\n\
1810to @var{f} (using the DECL tree that this hook returns) and will\n\
1811use the return value of @var{f} as the argument @var{OFF} to\n\
1812@code{REALIGN_LOAD}. Therefore, the mask @var{m} returned by @var{f}\n\
1813should comply with the semantics expected by @code{REALIGN_LOAD}\n\
1814described above.\n\
1815If this hook is not defined, then @var{addr} will be used as\n\
1816the argument @var{OFF} to @code{REALIGN_LOAD}, in which case the low\n\
1817log2(@var{VS}) @minus{} 1 bits of @var{addr} will be considered.",
38f8b050
JR
1818 tree, (void), NULL)
1819
10766209
RS
1820/* Returns a built-in function that realizes the vectorized version of
1821 a target-independent function, or NULL_TREE if not available. */
38f8b050
JR
1822DEFHOOK
1823(builtin_vectorized_function,
673c2f63 1824 "This hook should return the decl of a function that implements the\n\
10766209 1825vectorized variant of the function with the @code{combined_fn} code\n\
673c2f63 1826@var{code} or @code{NULL_TREE} if such a function is not available.\n\
10766209
RS
1827The return type of the vectorized function shall be of vector type\n\
1828@var{vec_type_out} and the argument types should be @var{vec_type_in}.",
1829 tree, (unsigned code, tree vec_type_out, tree vec_type_in),
1830 default_builtin_vectorized_function)
1831
1832/* Returns a built-in function that realizes the vectorized version of
1833 a target-specific function, or NULL_TREE if not available. */
1834DEFHOOK
1835(builtin_md_vectorized_function,
1836 "This hook should return the decl of a function that implements the\n\
1837vectorized variant of target built-in function @code{fndecl}. The\n\
673c2f63
JM
1838return type of the vectorized function shall be of vector type\n\
1839@var{vec_type_out} and the argument types should be @var{vec_type_in}.",
38f8b050 1840 tree, (tree fndecl, tree vec_type_out, tree vec_type_in),
10766209 1841 default_builtin_md_vectorized_function)
38f8b050 1842
720f5239
IR
1843/* Cost of different vector/scalar statements in vectorization cost
1844 model. In case of misaligned vector loads and stores the cost depends
1845 on the data type and misalignment value. */
38f8b050
JR
1846DEFHOOK
1847(builtin_vectorization_cost,
673c2f63
JM
1848 "Returns cost of different scalar or vector statements for vectorization cost model.\n\
1849For vector memory operations the cost may depend on type (@var{vectype}) and\n\
1850misalignment value (@var{misalign}).",
720f5239 1851 int, (enum vect_cost_for_stmt type_of_cost, tree vectype, int misalign),
38f8b050
JR
1852 default_builtin_vectorization_cost)
1853
f702e7d4
RS
1854DEFHOOK
1855(preferred_vector_alignment,
1856 "This hook returns the preferred alignment in bits for accesses to\n\
1857vectors of type @var{type} in vectorized code. This might be less than\n\
1858or greater than the ABI-defined value returned by\n\
1859@code{TARGET_VECTOR_ALIGNMENT}. It can be equal to the alignment of\n\
1860a single element, in which case the vectorizer will not try to optimize\n\
1861for alignment.\n\
1862\n\
1863The default hook returns @code{TYPE_ALIGN (@var{type})}, which is\n\
1864correct for most targets.",
ca31798e 1865 poly_uint64, (const_tree type),
f702e7d4
RS
1866 default_preferred_vector_alignment)
1867
38f8b050 1868/* Return true if vector alignment is reachable (by peeling N
c2873892 1869 iterations) for the given scalar type. */
38f8b050
JR
1870DEFHOOK
1871(vector_alignment_reachable,
4d3907c2
ML
1872 "Return true if vector alignment is reachable (by peeling N iterations)\n\
1873for the given scalar type @var{type}. @var{is_packed} is false if the scalar\n\
1874access using @var{type} is known to be naturally aligned.",
38f8b050
JR
1875 bool, (const_tree type, bool is_packed),
1876 default_builtin_vector_alignment_reachable)
1877
38f8b050 1878DEFHOOK
f151c9e1
RS
1879(vec_perm_const,
1880 "This hook is used to test whether the target can permute up to two\n\
1881vectors of mode @var{mode} using the permutation vector @code{sel}, and\n\
1882also to emit such a permutation. In the former case @var{in0}, @var{in1}\n\
1883and @var{out} are all null. In the latter case @var{in0} and @var{in1} are\n\
1884the source vectors and @var{out} is the destination vector; all three are\n\
841548f0 1885operands of mode @var{mode}. @var{in1} is the same as @var{in0} if\n\
f151c9e1
RS
1886@var{sel} describes a permutation on one vector instead of two.\n\
1887\n\
1888Return true if the operation is possible, emitting instructions for it\n\
1889if rtxes are provided.\n\
1890\n\
1891@cindex @code{vec_perm@var{m}} instruction pattern\n\
1892If the hook returns false for a mode with multibyte elements, GCC will\n\
1893try the equivalent byte operation. If that also fails, it will try forcing\n\
1894the selector into a register and using the @var{vec_perm@var{mode}}\n\
1895instruction pattern. There is no need for the hook to handle these two\n\
1896implementation approaches itself.",
1897 bool, (machine_mode mode, rtx output, rtx in0, rtx in1,
1898 const vec_perm_indices &sel),
22e4dee7 1899 NULL)
38f8b050
JR
1900
1901/* Return true if the target supports misaligned store/load of a
1902 specific factor denoted in the third parameter. The last parameter
1903 is true if the access is defined in a packed struct. */
1904DEFHOOK
1905(support_vector_misalignment,
673c2f63
JM
1906 "This hook should return true if the target supports misaligned vector\n\
1907store/load of a specific factor denoted in the @var{misalignment}\n\
1908parameter. The vector store/load should be of machine mode @var{mode} and\n\
1909the elements in the vectors should be of type @var{type}. @var{is_packed}\n\
1910parameter is true if the memory access is defined in a packed struct.",
38f8b050 1911 bool,
ef4bddc2 1912 (machine_mode mode, const_tree type, int misalignment, bool is_packed),
38f8b050
JR
1913 default_builtin_support_vector_misalignment)
1914
cc4b5170
RG
1915/* Returns the preferred mode for SIMD operations for the specified
1916 scalar mode. */
26983c22 1917DEFHOOK
cc4b5170 1918(preferred_simd_mode,
673c2f63
JM
1919 "This hook should return the preferred mode for vectorizing scalar\n\
1920mode @var{mode}. The default is\n\
1921equal to @code{word_mode}, because the vectorizer can do some\n\
1922transformations even in absence of specialized @acronym{SIMD} hardware.",
ef4bddc2 1923 machine_mode,
005ba29c 1924 (scalar_mode mode),
cc4b5170 1925 default_preferred_simd_mode)
26983c22 1926
c803b2a9
RB
1927/* Returns the preferred mode for splitting SIMD reductions to. */
1928DEFHOOK
1929(split_reduction,
1930 "This hook should return the preferred mode to split the final reduction\n\
1931step on @var{mode} to. The reduction is then carried out reducing upper\n\
1932against lower halves of vectors recursively until the specified mode is\n\
1933reached. The default is @var{mode} which means no splitting.",
1934 machine_mode,
1935 (machine_mode),
1936 default_split_reduction)
1937
767f865f
RG
1938/* Returns a mask of vector sizes to iterate over when auto-vectorizing
1939 after processing the preferred one derived from preferred_simd_mode. */
1940DEFHOOK
e021fb86
RS
1941(autovectorize_vector_modes,
1942 "If using the mode returned by @code{TARGET_VECTORIZE_PREFERRED_SIMD_MODE}\n\
1943is not the only approach worth considering, this hook should add one mode to\n\
1944@var{modes} for each useful alternative approach. These modes are then\n\
1945passed to @code{TARGET_VECTORIZE_RELATED_MODE} to obtain the vector mode\n\
1946for a given element mode.\n\
1947\n\
1948The modes returned in @var{modes} should use the smallest element mode\n\
1949possible for the vectorization approach that they represent, preferring\n\
1950integer modes over floating-poing modes in the event of a tie. The first\n\
1951mode should be the @code{TARGET_VECTORIZE_PREFERRED_SIMD_MODE} for its\n\
1952element mode.\n\
1953\n\
1954If @var{all} is true, add suitable vector modes even when they are generally\n\
f63445e5 1955not expected to be worthwhile.\n\
86e36728 1956\n\
bcc7e346
RS
1957The hook returns a bitmask of flags that control how the modes in\n\
1958@var{modes} are used. The flags are:\n\
1959@table @code\n\
1960@item VECT_COMPARE_COSTS\n\
1961Tells the loop vectorizer to try all the provided modes and pick the one\n\
1962with the lowest cost. By default the vectorizer will choose the first\n\
1963mode that works.\n\
1964@end table\n\
1965\n\
86e36728
RS
1966The hook does not need to do anything if the vector returned by\n\
1967@code{TARGET_VECTORIZE_PREFERRED_SIMD_MODE} is the only one relevant\n\
bcc7e346
RS
1968for autovectorization. The default implementation adds no modes and\n\
1969returns 0.",
1970 unsigned int,
e021fb86
RS
1971 (vector_modes *modes, bool all),
1972 default_autovectorize_vector_modes)
767f865f 1973
f0955233
RS
1974DEFHOOK
1975(related_mode,
1976 "If a piece of code is using vector mode @var{vector_mode} and also wants\n\
1977to operate on elements of mode @var{element_mode}, return the vector mode\n\
1978it should use for those elements. If @var{nunits} is nonzero, ensure that\n\
1979the mode has exactly @var{nunits} elements, otherwise pick whichever vector\n\
1980size pairs the most naturally with @var{vector_mode}. Return an empty\n\
1981@code{opt_machine_mode} if there is no supported vector mode with the\n\
1982required properties.\n\
1983\n\
1984There is no prescribed way of handling the case in which @var{nunits}\n\
1985is zero. One common choice is to pick a vector mode with the same size\n\
1986as @var{vector_mode}; this is the natural choice if the target has a\n\
1987fixed vector size. Another option is to choose a vector mode with the\n\
1988same number of elements as @var{vector_mode}; this is the natural choice\n\
1989if the target has a fixed number of elements. Alternatively, the hook\n\
1990might choose a middle ground, such as trying to keep the number of\n\
1991elements as similar as possible while applying maximum and minimum\n\
1992vector sizes.\n\
1993\n\
1994The default implementation uses @code{mode_for_vector} to find the\n\
1995requested mode, returning a mode with the same size as @var{vector_mode}\n\
1996when @var{nunits} is zero. This is the correct behavior for most targets.",
1997 opt_machine_mode,
1998 (machine_mode vector_mode, scalar_mode element_mode, poly_uint64 nunits),
1999 default_vectorize_related_mode)
2000
9f47c7e5
IE
2001/* Function to get a target mode for a vector mask. */
2002DEFHOOK
2003(get_mask_mode,
10116ec1
RS
2004 "Return the mode to use for a vector mask that holds one boolean\n\
2005result for each element of vector mode @var{mode}. The returned mask mode\n\
2006can be a vector of integers (class @code{MODE_VECTOR_INT}), a vector of\n\
2007booleans (class @code{MODE_VECTOR_BOOL}) or a scalar integer (class\n\
2008@code{MODE_INT}). Return an empty @code{opt_machine_mode} if no such\n\
2009mask mode exists.\n\
2010\n\
2011The default implementation returns a @code{MODE_VECTOR_INT} with the\n\
2012same size and number of elements as @var{mode}, if such a mode exists.",
3981fbb6 2013 opt_machine_mode,
10116ec1 2014 (machine_mode mode),
9f47c7e5
IE
2015 default_get_mask_mode)
2016
76a34e3f
RS
2017/* Function to say whether a masked operation is expensive when the
2018 mask is all zeros. */
2019DEFHOOK
2020(empty_mask_is_expensive,
2021 "This hook returns true if masked internal function @var{ifn} (really of\n\
2022type @code{internal_fn}) should be considered expensive when the mask is\n\
2023all zeros. GCC can then try to branch around the instruction instead.",
2024 bool,
2025 (unsigned ifn),
2026 default_empty_mask_is_expensive)
2027
aec7ae7d
JJ
2028/* Target builtin that implements vector gather operation. */
2029DEFHOOK
2030(builtin_gather,
673c2f63
JM
2031 "Target builtin that implements vector gather operation. @var{mem_vectype}\n\
2032is the vector type of the load and @var{index_type} is scalar type of\n\
2033the index, scaled by @var{scale}.\n\
2034The default is @code{NULL_TREE} which means to not vectorize gather\n\
2035loads.",
aec7ae7d
JJ
2036 tree,
2037 (const_tree mem_vectype, const_tree index_type, int scale),
2038 NULL)
2039
3bab6342
AT
2040/* Target builtin that implements vector scatter operation. */
2041DEFHOOK
2042(builtin_scatter,
2043"Target builtin that implements vector scatter operation. @var{vectype}\n\
2044is the vector type of the store and @var{index_type} is scalar type of\n\
2045the index, scaled by @var{scale}.\n\
2046The default is @code{NULL_TREE} which means to not vectorize scatter\n\
2047stores.",
2048 tree,
2049 (const_tree vectype, const_tree index_type, int scale),
2050 NULL)
2051
c3e7ee41
BS
2052/* Target function to initialize the cost model for a loop or block. */
2053DEFHOOK
6239dd05 2054(create_costs,
4d3907c2
ML
2055 "This hook should initialize target-specific data structures in preparation\n\
2056for modeling the costs of vectorizing a loop or basic block. The default\n\
2057allocates three unsigned integers for accumulating costs for the prologue,\n\
2058body, and epilogue of the loop or basic block. If @var{loop_info} is\n\
2059non-NULL, it identifies the loop being vectorized; otherwise a single block\n\
2060is being vectorized. If @var{costing_for_scalar} is true, it indicates the\n\
2061current cost model is for the scalar version of a loop or block; otherwise\n\
2062it is for the vector version.",
6239dd05
RS
2063 class vector_costs *,
2064 (vec_info *vinfo, bool costing_for_scalar),
2065 default_vectorize_create_costs)
c3e7ee41 2066
38f8b050
JR
2067HOOK_VECTOR_END (vectorize)
2068
2069#undef HOOK_PREFIX
2070#define HOOK_PREFIX "TARGET_"
2071
6a86928d
RS
2072DEFHOOK
2073(preferred_else_value,
2074 "This hook returns the target's preferred final argument for a call\n\
2075to conditional internal function @var{ifn} (really of type\n\
2076@code{internal_fn}). @var{type} specifies the return type of the\n\
2077function and @var{ops} are the operands to the conditional operation,\n\
2078of which there are @var{nops}.\n\
2079\n\
2080For example, if @var{ifn} is @code{IFN_COND_ADD}, the hook returns\n\
2081a value of type @var{type} that should be used when @samp{@var{ops}[0]}\n\
2082and @samp{@var{ops}[1]} are conditionally added together.\n\
2083\n\
2084This hook is only relevant if the target supports conditional patterns\n\
2085like @code{cond_add@var{m}}. The default implementation returns a zero\n\
2086constant of type @var{type}.",
2087 tree,
2088 (unsigned ifn, tree type, unsigned nops, tree *ops),
2089 default_preferred_else_value)
2090
ec6fe917
IV
2091DEFHOOK
2092(record_offload_symbol,
2093 "Used when offloaded functions are seen in the compilation unit and no named\n\
2094sections are available. It is called once for each symbol that must be\n\
2095recorded in the offload function and variable table.",
2096 void, (tree),
2097 hook_void_tree)
2098
6d2b7199
BS
2099DEFHOOKPOD
2100(absolute_biggest_alignment,
2101 "If defined, this target hook specifies the absolute biggest alignment\n\
2102that a type or variable can have on this machine, otherwise,\n\
2103@code{BIGGEST_ALIGNMENT} is used.",
2104 HOST_WIDE_INT, BIGGEST_ALIGNMENT)
2105
38f8b050
JR
2106/* Allow target specific overriding of option settings after options have
2107 been changed by an attribute or pragma or when it is reset at the
2108 end of the code affected by an attribute or pragma. */
2109DEFHOOK
2110(override_options_after_change,
673c2f63
JM
2111 "This target function is similar to the hook @code{TARGET_OPTION_OVERRIDE}\n\
2112but is called when the optimize level is changed via an attribute or\n\
2113pragma or when it is reset at the end of the code affected by the\n\
2114attribute or pragma. It is not called at the beginning of compilation\n\
2115when @code{TARGET_OPTION_OVERRIDE} is called so if you want to perform these\n\
2116actions then, you should have @code{TARGET_OPTION_OVERRIDE} call\n\
2117@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}.",
38f8b050
JR
2118 void, (void),
2119 hook_void_void)
2120
c713ddc0
BS
2121DEFHOOK
2122(offload_options,
2123 "Used when writing out the list of options into an LTO file. It should\n\
2124translate any relevant target-specific options (such as the ABI in use)\n\
2125into one of the @option{-foffload} options that exist as a common interface\n\
2126to express such options. It should return a string containing these options,\n\
2127separated by spaces, which the caller will free.\n",
2128char *, (void), hook_charptr_void_null)
2129
38f8b050
JR
2130DEFHOOK_UNDOC
2131(eh_return_filter_mode,
2132 "Return machine mode for filter value.",
095a2d76 2133 scalar_int_mode, (void),
38f8b050
JR
2134 default_eh_return_filter_mode)
2135
2136/* Return machine mode for libgcc expanded cmp instructions. */
2137DEFHOOK
2138(libgcc_cmp_return_mode,
673c2f63
JM
2139 "This target hook should return the mode to be used for the return value\n\
2140of compare instructions expanded to libgcc calls. If not defined\n\
2141@code{word_mode} is returned which is the right choice for a majority of\n\
2142targets.",
095a2d76 2143 scalar_int_mode, (void),
38f8b050
JR
2144 default_libgcc_cmp_return_mode)
2145
2146/* Return machine mode for libgcc expanded shift instructions. */
2147DEFHOOK
2148(libgcc_shift_count_mode,
673c2f63
JM
2149 "This target hook should return the mode to be used for the shift count operand\n\
2150of shift instructions expanded to libgcc calls. If not defined\n\
2151@code{word_mode} is returned which is the right choice for a majority of\n\
2152targets.",
095a2d76 2153 scalar_int_mode, (void),
38f8b050
JR
2154 default_libgcc_shift_count_mode)
2155
2156/* Return machine mode to be used for _Unwind_Word type. */
2157DEFHOOK
2158(unwind_word_mode,
673c2f63
JM
2159 "Return machine mode to be used for @code{_Unwind_Word} type.\n\
2160The default is to use @code{word_mode}.",
095a2d76 2161 scalar_int_mode, (void),
38f8b050
JR
2162 default_unwind_word_mode)
2163
2164/* Given two decls, merge their attributes and return the result. */
2165DEFHOOK
2166(merge_decl_attributes,
673c2f63
JM
2167 "Define this target hook if the merging of decl attributes needs special\n\
2168handling. If defined, the result is a list of the combined\n\
2169@code{DECL_ATTRIBUTES} of @var{olddecl} and @var{newdecl}.\n\
2170@var{newdecl} is a duplicate declaration of @var{olddecl}. Examples of\n\
2171when this is needed are when one attribute overrides another, or when an\n\
2172attribute is nullified by a subsequent definition. This function may\n\
2173call @code{merge_attributes} to handle machine-independent merging.\n\
2174\n\
2175@findex TARGET_DLLIMPORT_DECL_ATTRIBUTES\n\
2176If the only target-specific handling you require is @samp{dllimport}\n\
2177for Microsoft Windows targets, you should define the macro\n\
2178@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES} to @code{1}. The compiler\n\
2179will then define a function called\n\
2180@code{merge_dllimport_decl_attributes} which can then be defined as\n\
2181the expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}. You can also\n\
2182add @code{handle_dll_attribute} in the attribute table for your port\n\
2183to perform initial processing of the @samp{dllimport} and\n\
2184@samp{dllexport} attributes. This is done in @file{i386/cygwin.h} and\n\
e53b6e56 2185@file{i386/i386.cc}, for example.",
38f8b050
JR
2186 tree, (tree olddecl, tree newdecl),
2187 merge_decl_attributes)
2188
2189/* Given two types, merge their attributes and return the result. */
2190DEFHOOK
2191(merge_type_attributes,
673c2f63
JM
2192 "Define this target hook if the merging of type attributes needs special\n\
2193handling. If defined, the result is a list of the combined\n\
2194@code{TYPE_ATTRIBUTES} of @var{type1} and @var{type2}. It is assumed\n\
2195that @code{comptypes} has already been called and returned 1. This\n\
2196function may call @code{merge_attributes} to handle machine-independent\n\
2197merging.",
38f8b050
JR
2198 tree, (tree type1, tree type2),
2199 merge_type_attributes)
2200
2201/* Table of machine attributes and functions to handle them.
2202 Ignored if NULL. */
2203DEFHOOKPOD
2204(attribute_table,
673c2f63 2205 "If defined, this target hook points to an array of @samp{struct\n\
15ab4e1e 2206attribute_spec} (defined in @file{tree-core.h}) specifying the machine\n\
673c2f63
JM
2207specific attributes for this target and some of the restrictions on the\n\
2208entities to which these attributes are applied and the arguments they\n\
2209take.",
38f8b050
JR
2210 const struct attribute_spec *, NULL)
2211
2212/* Return true iff attribute NAME expects a plain identifier as its first
2213 argument. */
2214DEFHOOK
2215(attribute_takes_identifier_p,
673c2f63
JM
2216 "If defined, this target hook is a function which returns true if the\n\
2217machine-specific attribute named @var{name} expects an identifier\n\
2218given as its first argument to be passed on as a plain identifier, not\n\
2219subjected to name lookup. If this is not defined, the default is\n\
2220false for all machine-specific attributes.",
38f8b050
JR
2221 bool, (const_tree name),
2222 hook_bool_const_tree_false)
2223
2224/* Return zero if the attributes on TYPE1 and TYPE2 are incompatible,
2225 one if they are compatible and two if they are nearly compatible
2226 (which causes a warning to be generated). */
2227DEFHOOK
2228(comp_type_attributes,
673c2f63
JM
2229 "If defined, this target hook is a function which returns zero if the attributes on\n\
2230@var{type1} and @var{type2} are incompatible, one if they are compatible,\n\
2231and two if they are nearly compatible (which causes a warning to be\n\
2232generated). If this is not defined, machine-specific attributes are\n\
2233supposed always to be compatible.",
38f8b050
JR
2234 int, (const_tree type1, const_tree type2),
2235 hook_int_const_tree_const_tree_1)
2236
2237/* Assign default attributes to the newly defined TYPE. */
2238DEFHOOK
2239(set_default_type_attributes,
673c2f63
JM
2240 "If defined, this target hook is a function which assigns default attributes to\n\
2241the newly defined @var{type}.",
38f8b050
JR
2242 void, (tree type),
2243 hook_void_tree)
2244
2245/* Insert attributes on the newly created DECL. */
2246DEFHOOK
2247(insert_attributes,
673c2f63
JM
2248 "Define this target hook if you want to be able to add attributes to a decl\n\
2249when it is being created. This is normally useful for back ends which\n\
2250wish to implement a pragma by using the attributes which correspond to\n\
2251the pragma's effect. The @var{node} argument is the decl which is being\n\
2252created. The @var{attr_ptr} argument is a pointer to the attribute list\n\
2253for this decl. The list itself should not be modified, since it may be\n\
2254shared with other decls, but attributes may be chained on the head of\n\
2255the list and @code{*@var{attr_ptr}} modified to point to the new\n\
2256attributes, or a copy of the list may be made if further changes are\n\
2257needed.",
38f8b050
JR
2258 void, (tree node, tree *attr_ptr),
2259 hook_void_tree_treeptr)
2260
7a4418a5
JL
2261/* Perform additional target-specific processing of generic attributes. */
2262DEFHOOK
2263(handle_generic_attribute,
2264 "Define this target hook if you want to be able to perform additional\n\
2265target-specific processing of an attribute which is handled generically\n\
2266by a front end. The arguments are the same as those which are passed to\n\
2267attribute handlers. So far this only affects the @var{noinit} and\n\
2268@var{section} attribute.",
2269 tree, (tree *node, tree name, tree args, int flags, bool *no_add_attrs),
2270 hook_tree_treeptr_tree_tree_int_boolptr_null)
2271
38f8b050
JR
2272/* Return true if FNDECL (which has at least one machine attribute)
2273 can be inlined despite its machine attributes, false otherwise. */
2274DEFHOOK
2275(function_attribute_inlinable_p,
673c2f63 2276 "@cindex inlining\n\
5bd40ade 2277This target hook returns @code{true} if it is OK to inline @var{fndecl}\n\
673c2f63
JM
2278into the current function, despite its having target-specific\n\
2279attributes, @code{false} otherwise. By default, if a function has a\n\
2280target specific attribute attached to it, it will not be inlined.",
38f8b050
JR
2281 bool, (const_tree fndecl),
2282 hook_bool_const_tree_false)
2283
2284/* Return true if bitfields in RECORD_TYPE should follow the
2285 Microsoft Visual C++ bitfield layout rules. */
2286DEFHOOK
2287(ms_bitfield_layout_p,
673c2f63
JM
2288 "This target hook returns @code{true} if bit-fields in the given\n\
2289@var{record_type} are to be laid out following the rules of Microsoft\n\
2290Visual C/C++, namely: (i) a bit-field won't share the same storage\n\
2291unit with the previous bit-field if their underlying types have\n\
2292different sizes, and the bit-field will be aligned to the highest\n\
2293alignment of the underlying types of itself and of the previous\n\
2294bit-field; (ii) a zero-sized bit-field will affect the alignment of\n\
2295the whole enclosing structure, even if it is unnamed; except that\n\
2296(iii) a zero-sized bit-field will be disregarded unless it follows\n\
2297another bit-field of nonzero size. If this hook returns @code{true},\n\
2298other macros that control bit-field layout are ignored.\n\
2299\n\
2300When a bit-field is inserted into a packed record, the whole size\n\
2301of the underlying type is used by one or more same-size adjacent\n\
2302bit-fields (that is, if its long:3, 32 bits is used in the record,\n\
2303and any additional adjacent long bit-fields are packed into the same\n\
2304chunk of 32 bits. However, if the size changes, a new field of that\n\
2305size is allocated). In an unpacked record, this is the same as using\n\
2306alignment, but not equivalent when packing.\n\
2307\n\
2308If both MS bit-fields and @samp{__attribute__((packed))} are used,\n\
2309the latter will take precedence. If @samp{__attribute__((packed))} is\n\
2310used on a single field when MS bit-fields are in use, it will take\n\
2311precedence for that field, but the alignment of the rest of the structure\n\
2312may affect its placement.",
38f8b050
JR
2313 bool, (const_tree record_type),
2314 hook_bool_const_tree_false)
2315
2e681adf
JR
2316/* For now this is only an interface to WORDS_BIG_ENDIAN for
2317 target-independent code like the front ends, need performance testing
2318 before switching completely to the target hook. */
2319DEFHOOK_UNDOC
2320(words_big_endian,
2321 "",
2322 bool, (void),
2323 targhook_words_big_endian)
2324
2325/* Likewise for FLOAT_WORDS_BIG_ENDIAN. */
2326DEFHOOK_UNDOC
2327(float_words_big_endian,
2328 "",
2329 bool, (void),
2330 targhook_float_words_big_endian)
2331
9193fb05
JM
2332DEFHOOK
2333(float_exceptions_rounding_supported_p,
4d3907c2
ML
2334 "Returns true if the target supports IEEE 754 floating-point exceptions\n\
2335and rounding modes, false otherwise. This is intended to relate to the\n\
2336@code{float} and @code{double} types, but not necessarily @code{long double}.\n\
2337By default, returns true if the @code{adddf3} instruction pattern is\n\
2338available and false otherwise, on the assumption that hardware floating\n\
2339point supports exceptions and rounding modes but software floating point\n\
2340does not.",
9193fb05
JM
2341 bool, (void),
2342 default_float_exceptions_rounding_supported_p)
2343
38f8b050
JR
2344/* True if the target supports decimal floating point. */
2345DEFHOOK
2346(decimal_float_supported_p,
673c2f63 2347 "Returns true if the target supports decimal floating point.",
38f8b050
JR
2348 bool, (void),
2349 default_decimal_float_supported_p)
2350
2351/* True if the target supports fixed-point. */
2352DEFHOOK
2353(fixed_point_supported_p,
673c2f63 2354 "Returns true if the target supports fixed-point arithmetic.",
38f8b050
JR
2355 bool, (void),
2356 default_fixed_point_supported_p)
2357
2358/* Return true if anonymous bitfields affect structure alignment. */
2359DEFHOOK
2360(align_anon_bitfield,
673c2f63
JM
2361 "When @code{PCC_BITFIELD_TYPE_MATTERS} is true this hook will determine\n\
2362whether unnamed bitfields affect the alignment of the containing\n\
2363structure. The hook should return true if the structure should inherit\n\
2364the alignment requirements of an unnamed bitfield's type.",
38f8b050
JR
2365 bool, (void),
2366 hook_bool_void_false)
2367
2368/* Return true if volatile bitfields should use the narrowest type possible.
2369 Return false if they should use the container type. */
2370DEFHOOK
2371(narrow_volatile_bitfield,
673c2f63
JM
2372 "This target hook should return @code{true} if accesses to volatile bitfields\n\
2373should use the narrowest mode possible. It should return @code{false} if\n\
2374these accesses should use the bitfield container type.\n\
2375\n\
7d0b9a9c 2376The default is @code{false}.",
38f8b050
JR
2377 bool, (void),
2378 hook_bool_void_false)
2379
2380/* Set up target-specific built-in functions. */
2381DEFHOOK
2382(init_builtins,
673c2f63
JM
2383 "Define this hook if you have any machine-specific built-in functions\n\
2384that need to be defined. It should be a function that performs the\n\
2385necessary setup.\n\
2386\n\
2387Machine specific built-in functions can be useful to expand special machine\n\
2388instructions that would otherwise not normally be generated because\n\
2389they have no equivalent in the source language (for example, SIMD vector\n\
2390instructions or prefetch instructions).\n\
2391\n\
2392To create a built-in function, call the function\n\
2393@code{lang_hooks.builtin_function}\n\
2394which is defined by the language front end. You can use any type nodes set\n\
2395up by @code{build_common_tree_nodes};\n\
2396only language front ends that use those two functions will call\n\
2397@samp{TARGET_INIT_BUILTINS}.",
38f8b050
JR
2398 void, (void),
2399 hook_void_void)
2400
2401/* Initialize (if INITIALIZE_P is true) and return the target-specific
2402 built-in function decl for CODE.
2403 Return NULL if that is not possible. Return error_mark_node if CODE
2404 is outside of the range of valid target builtin function codes. */
2405DEFHOOK
2406(builtin_decl,
673c2f63
JM
2407 "Define this hook if you have any machine-specific built-in functions\n\
2408that need to be defined. It should be a function that returns the\n\
2409builtin function declaration for the builtin function code @var{code}.\n\
2410If there is no such builtin and it cannot be initialized at this time\n\
2411if @var{initialize_p} is true the function should return @code{NULL_TREE}.\n\
2412If @var{code} is out of range the function should return\n\
2413@code{error_mark_node}.",
38f8b050
JR
2414 tree, (unsigned code, bool initialize_p), NULL)
2415
2416/* Expand a target-specific builtin. */
2417DEFHOOK
2418(expand_builtin,
673c2f63
JM
2419 "\n\
2420Expand a call to a machine specific built-in function that was set up by\n\
2421@samp{TARGET_INIT_BUILTINS}. @var{exp} is the expression for the\n\
2422function call; the result should go to @var{target} if that is\n\
2423convenient, and have mode @var{mode} if that is convenient.\n\
2424@var{subtarget} may be used as the target for computing one of\n\
2425@var{exp}'s operands. @var{ignore} is nonzero if the value is to be\n\
2426ignored. This function should return the result of the call to the\n\
2427built-in function.",
38f8b050 2428 rtx,
ef4bddc2 2429 (tree exp, rtx target, rtx subtarget, machine_mode mode, int ignore),
38f8b050
JR
2430 default_expand_builtin)
2431
2432/* Select a replacement for a target-specific builtin. This is done
2433 *before* regular type checking, and so allows the target to
2434 implement a crude form of function overloading. The result is a
2435 complete expression that implements the operation. PARAMS really
2436 has type VEC(tree,gc)*, but we don't want to include tree.h here. */
d66f5459 2437DEFHOOK
38f8b050 2438(resolve_overloaded_builtin,
673c2f63
JM
2439 "Select a replacement for a machine specific built-in function that\n\
2440was set up by @samp{TARGET_INIT_BUILTINS}. This is done\n\
2441@emph{before} regular type checking, and so allows the target to\n\
2442implement a crude form of function overloading. @var{fndecl} is the\n\
2443declaration of the built-in function. @var{arglist} is the list of\n\
2444arguments passed to the built-in function. The result is a\n\
2445complete expression that implements the operation, usually\n\
2446another @code{CALL_EXPR}.\n\
2447@var{arglist} really has type @samp{VEC(tree,gc)*}",
d66f5459 2448 tree, (unsigned int /*location_t*/ loc, tree fndecl, void *arglist), NULL)
38f8b050 2449
c6447c20
RS
2450DEFHOOK
2451(check_builtin_call,
2452 "Perform semantic checking on a call to a machine-specific built-in\n\
2453function after its arguments have been constrained to the function\n\
2454signature. Return true if the call is valid, otherwise report an error\n\
2455and return false.\n\
2456\n\
2457This hook is called after @code{TARGET_RESOLVE_OVERLOADED_BUILTIN}.\n\
2458The call was originally to built-in function @var{orig_fndecl},\n\
2459but after the optional @code{TARGET_RESOLVE_OVERLOADED_BUILTIN}\n\
2460step is now to built-in function @var{fndecl}. @var{loc} is the\n\
2461location of the call and @var{args} is an array of function arguments,\n\
2462of which there are @var{nargs}. @var{arg_loc} specifies the location\n\
2463of each argument.",
2464 bool, (location_t loc, vec<location_t> arg_loc, tree fndecl,
2465 tree orig_fndecl, unsigned int nargs, tree *args),
2466 NULL)
2467
ea679d55
JG
2468/* Fold a target-specific builtin to a tree valid for both GIMPLE
2469 and GENERIC. */
08914aaa 2470DEFHOOK
38f8b050 2471(fold_builtin,
673c2f63
JM
2472 "Fold a call to a machine specific built-in function that was set up by\n\
2473@samp{TARGET_INIT_BUILTINS}. @var{fndecl} is the declaration of the\n\
2474built-in function. @var{n_args} is the number of arguments passed to\n\
2475the function; the arguments themselves are pointed to by @var{argp}.\n\
2476The result is another tree, valid for both GIMPLE and GENERIC,\n\
2477containing a simplified expression for the call's result. If\n\
2478@var{ignore} is true the value will be ignored.",
08914aaa 2479 tree, (tree fndecl, int n_args, tree *argp, bool ignore),
38f8b050
JR
2480 hook_tree_tree_int_treep_bool_null)
2481
ea679d55
JG
2482/* Fold a target-specific builtin to a valid GIMPLE tree. */
2483DEFHOOK
2484(gimple_fold_builtin,
2485 "Fold a call to a machine specific built-in function that was set up\n\
2486by @samp{TARGET_INIT_BUILTINS}. @var{gsi} points to the gimple\n\
2487statement holding the function call. Returns true if any change\n\
2488was made to the GIMPLE stream.",
2489 bool, (gimple_stmt_iterator *gsi),
2490 hook_bool_gsiptr_false)
2491
3649b9b7
ST
2492/* Target hook is used to compare the target attributes in two functions to
2493 determine which function's features get higher priority. This is used
2494 during function multi-versioning to figure out the order in which two
2495 versions must be dispatched. A function version with a higher priority
2496 is checked for dispatching earlier. DECL1 and DECL2 are
2497 the two function decls that will be compared. It returns positive value
2498 if DECL1 is higher priority, negative value if DECL2 is higher priority
2499 and 0 if they are the same. */
2500DEFHOOK
2501(compare_version_priority,
673c2f63
JM
2502 "This hook is used to compare the target attributes in two functions to\n\
2503determine which function's features get higher priority. This is used\n\
2504during function multi-versioning to figure out the order in which two\n\
2505versions must be dispatched. A function version with a higher priority\n\
2506is checked for dispatching earlier. @var{decl1} and @var{decl2} are\n\
2507 the two function decls that will be compared.",
3649b9b7
ST
2508 int, (tree decl1, tree decl2), NULL)
2509
2510/* Target hook is used to generate the dispatcher logic to invoke the right
2511 function version at run-time for a given set of function versions.
2512 ARG points to the callgraph node of the dispatcher function whose body
2513 must be generated. */
2514DEFHOOK
2515(generate_version_dispatcher_body,
673c2f63
JM
2516 "This hook is used to generate the dispatcher logic to invoke the right\n\
2517function version at run-time for a given set of function versions.\n\
2518@var{arg} points to the callgraph node of the dispatcher function whose\n\
2519body must be generated.",
3649b9b7
ST
2520 tree, (void *arg), NULL)
2521
2522/* Target hook is used to get the dispatcher function for a set of function
2523 versions. The dispatcher function is called to invoke the right function
2524 version at run-time. DECL is one version from a set of semantically
2525 identical versions. */
2526DEFHOOK
2527(get_function_versions_dispatcher,
673c2f63
JM
2528 "This hook is used to get the dispatcher function for a set of function\n\
2529versions. The dispatcher function is called to invoke the right function\n\
2530version at run-time. @var{decl} is one version from a set of semantically\n\
2531identical versions.",
3649b9b7
ST
2532 tree, (void *decl), NULL)
2533
38f8b050 2534/* Returns a code for a target-specific builtin that implements
ee62a5a6 2535 reciprocal of a target-specific function, or NULL_TREE if not available. */
89356d17 2536DEFHOOK
38f8b050 2537(builtin_reciprocal,
ee62a5a6
RS
2538 "This hook should return the DECL of a function that implements the\n\
2539reciprocal of the machine-specific builtin function @var{fndecl}, or\n\
7b90c63a 2540@code{NULL_TREE} if such a function is not available.",
ee62a5a6 2541 tree, (tree fndecl),
38f8b050
JR
2542 default_builtin_reciprocal)
2543
2544/* For a vendor-specific TYPE, return a pointer to a statically-allocated
2545 string containing the C++ mangling for TYPE. In all other cases, return
2546 NULL. */
2547DEFHOOK
2548(mangle_type,
673c2f63
JM
2549 "If your target defines any fundamental types, or any types your target\n\
2550uses should be mangled differently from the default, define this hook\n\
2551to return the appropriate encoding for these types as part of a C++\n\
2552mangled name. The @var{type} argument is the tree structure representing\n\
2553the type to be mangled. The hook may be applied to trees which are\n\
2554not target-specific fundamental types; it should return @code{NULL}\n\
2555for all such types, as well as arguments it does not recognize. If the\n\
2556return value is not @code{NULL}, it must point to a statically-allocated\n\
2557string constant.\n\
2558\n\
2559Target-specific fundamental types might be new fundamental types or\n\
2560qualified versions of ordinary fundamental types. Encode new\n\
2561fundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name}\n\
2562is the name used for the type in source code, and @var{n} is the\n\
2563length of @var{name} in decimal. Encode qualified versions of\n\
2564ordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where\n\
2565@var{name} is the name used for the type qualifier in source code,\n\
2566@var{n} is the length of @var{name} as above, and @var{code} is the\n\
2567code used to represent the unqualified version of this type. (See\n\
e53b6e56 2568@code{write_builtin_type} in @file{cp/mangle.cc} for the list of\n\
673c2f63
JM
2569codes.) In both cases the spaces are for clarity; do not include any\n\
2570spaces in your string.\n\
2571\n\
2572This hook is applied to types prior to typedef resolution. If the mangled\n\
2573name for a particular type depends only on that type's main variant, you\n\
2574can perform typedef resolution yourself using @code{TYPE_MAIN_VARIANT}\n\
2575before mangling.\n\
2576\n\
2577The default version of this hook always returns @code{NULL}, which is\n\
2578appropriate for a target that does not define any new fundamental\n\
2579types.",
38f8b050
JR
2580 const char *, (const_tree type),
2581 hook_constcharptr_const_tree_null)
2582
2583/* Make any adjustments to libfunc names needed for this target. */
2584DEFHOOK
2585(init_libfuncs,
673c2f63
JM
2586 "This hook should declare additional library routines or rename\n\
2587existing ones, using the functions @code{set_optab_libfunc} and\n\
e53b6e56 2588@code{init_one_libfunc} defined in @file{optabs.cc}.\n\
673c2f63
JM
2589@code{init_optabs} calls this macro after initializing all the normal\n\
2590library routines.\n\
2591\n\
2592The default is to do nothing. Most ports don't need to define this hook.",
38f8b050
JR
2593 void, (void),
2594 hook_void_void)
2595
cdbf4541
BS
2596 /* Add a __gnu_ prefix to library functions rather than just __. */
2597DEFHOOKPOD
2598(libfunc_gnu_prefix,
2599 "If false (the default), internal library routines start with two\n\
2600underscores. If set to true, these routines start with @code{__gnu_}\n\
2601instead. E.g., @code{__muldi3} changes to @code{__gnu_muldi3}. This\n\
2602currently only affects functions defined in @file{libgcc2.c}. If this\n\
2603is set to true, the @file{tm.h} file must also\n\
2604@code{#define LIBGCC2_GNU_PREFIX}.",
2605 bool, false)
2606
38f8b050
JR
2607/* Given a decl, a section name, and whether the decl initializer
2608 has relocs, choose attributes for the section. */
2609/* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION. */
2610DEFHOOK
2611(section_type_flags,
673c2f63
JM
2612 "Choose a set of section attributes for use by @code{TARGET_ASM_NAMED_SECTION}\n\
2613based on a variable or function decl, a section name, and whether or not the\n\
2614declaration's initializer may contain runtime relocations. @var{decl} may be\n\
2615null, in which case read-write data should be assumed.\n\
2616\n\
2617The default version of this function handles choosing code vs data,\n\
2618read-only vs read-write data, and @code{flag_pic}. You should only\n\
2619need to override this if your target has special flags that might be\n\
2620set via @code{__attribute__}.",
38f8b050
JR
2621 unsigned int, (tree decl, const char *name, int reloc),
2622 default_section_type_flags)
2623
d33d9e47
AI
2624DEFHOOK
2625(libc_has_function,
2626 "This hook determines whether a function from a class of functions\n\
bae974e6
TV
2627@var{fn_class} is present in the target C library. If @var{type} is NULL,\n\
2628the caller asks for support for all standard (float, double, long double)\n\
2629types. If @var{type} is non-NULL, the caller asks for support for a\n\
2630specific type.",
2631 bool, (enum function_class fn_class, tree type),
d33d9e47
AI
2632 default_libc_has_function)
2633
db91c7cf
ML
2634DEFHOOK
2635(libc_has_fast_function,
2636 "This hook determines whether a function from a class of functions\n\
c53bb876 2637@code{(enum function_class)}@var{fcode} has a fast implementation.",
db91c7cf
ML
2638 bool, (int fcode),
2639 default_libc_has_fast_function)
2640
38f8b050
JR
2641/* True if new jumps cannot be created, to replace existing ones or
2642 not, at the current point in the compilation. */
2643DEFHOOK
2644(cannot_modify_jumps_p,
673c2f63
JM
2645 "This target hook returns @code{true} past the point in which new jump\n\
2646instructions could be created. On machines that require a register for\n\
2647every jump such as the SHmedia ISA of SH5, this point would typically be\n\
2648reload, so this target hook should be defined to a function such as:\n\
2649\n\
2650@smallexample\n\
2651static bool\n\
2652cannot_modify_jumps_past_reload_p ()\n\
2653@{\n\
2654 return (reload_completed || reload_in_progress);\n\
2655@}\n\
2656@end smallexample",
38f8b050
JR
2657 bool, (void),
2658 hook_bool_void_false)
2659
4b4de898
JR
2660/* True if FOLLOWER may be modified to follow FOLLOWEE. */
2661DEFHOOK
2662(can_follow_jump,
4d3907c2
ML
2663 "FOLLOWER and FOLLOWEE are JUMP_INSN instructions;\n\
2664return true if FOLLOWER may be modified to follow FOLLOWEE;\n\
2665false, if it can't.\n\
2666For example, on some targets, certain kinds of branches can't be made to\n\
2667follow through a hot/cold partitioning.",
c1ce59ab
DM
2668 bool, (const rtx_insn *follower, const rtx_insn *followee),
2669 hook_bool_const_rtx_insn_const_rtx_insn_true)
4b4de898 2670
38f8b050
JR
2671/* Return true if the target supports conditional execution. */
2672DEFHOOK
2673(have_conditional_execution,
673c2f63
JM
2674 "This target hook returns true if the target supports conditional execution.\n\
2675This target hook is required only when the target has several different\n\
2676modes and they have different conditional execution capability, such as ARM.",
38f8b050
JR
2677 bool, (void),
2678 default_have_conditional_execution)
2679
2e0f1341
ZC
2680DEFHOOK
2681(gen_ccmp_first,
5f3bc026 2682 "This function prepares to emit a comparison insn for the first compare in a\n\
c8012fbc
WD
2683 sequence of conditional comparisions. It returns an appropriate comparison\n\
2684 with @code{CC} for passing to @code{gen_ccmp_next} or @code{cbranch_optab}.\n\
2685 The insns to prepare the compare are saved in @var{prep_seq} and the compare\n\
2686 insns are saved in @var{gen_seq}. They will be emitted when all the\n\
700d4cb0 2687 compares in the conditional comparision are generated without error.\n\
c8012fbc 2688 @var{code} is the @code{rtx_code} of the compare for @var{op0} and @var{op1}.",
cb4347e8 2689 rtx, (rtx_insn **prep_seq, rtx_insn **gen_seq, int code, tree op0, tree op1),
2e0f1341
ZC
2690 NULL)
2691
2692DEFHOOK
2693(gen_ccmp_next,
c8012fbc
WD
2694 "This function prepares to emit a conditional comparison within a sequence\n\
2695 of conditional comparisons. It returns an appropriate comparison with\n\
2696 @code{CC} for passing to @code{gen_ccmp_next} or @code{cbranch_optab}.\n\
2697 The insns to prepare the compare are saved in @var{prep_seq} and the compare\n\
2698 insns are saved in @var{gen_seq}. They will be emitted when all the\n\
2699 compares in the conditional comparision are generated without error. The\n\
2700 @var{prev} expression is the result of a prior call to @code{gen_ccmp_first}\n\
2701 or @code{gen_ccmp_next}. It may return @code{NULL} if the combination of\n\
2702 @var{prev} and this comparison is not supported, otherwise the result must\n\
2703 be appropriate for passing to @code{gen_ccmp_next} or @code{cbranch_optab}.\n\
2704 @var{code} is the @code{rtx_code} of the compare for @var{op0} and @var{op1}.\n\
2705 @var{bit_code} is @code{AND} or @code{IOR}, which is the op on the compares.",
cb4347e8 2706 rtx, (rtx_insn **prep_seq, rtx_insn **gen_seq, rtx prev, int cmp_code, tree op0, tree op1, int bit_code),
2e0f1341
ZC
2707 NULL)
2708
e5e164ef
L
2709DEFHOOK
2710(gen_memset_scratch_rtx,
2711 "This hook should return an rtx for a scratch register in @var{mode} to\n\
2712be used when expanding memset calls. The backend can use a hard scratch\n\
2713register to avoid stack realignment when expanding memset. The default\n\
2714is @code{gen_reg_rtx}.",
2715 rtx, (machine_mode mode),
2716 gen_reg_rtx)
2717
38f8b050
JR
2718/* Return a new value for loop unroll size. */
2719DEFHOOK
2720(loop_unroll_adjust,
673c2f63
JM
2721 "This target hook returns a new value for the number of times @var{loop}\n\
2722should be unrolled. The parameter @var{nunroll} is the number of times\n\
2723the loop is to be unrolled. The parameter @var{loop} is a pointer to\n\
2724the loop, which is going to be checked for unrolling. This target hook\n\
2725is required only when the target has special constraints like maximum\n\
2726number of memory accesses.",
99b1c316 2727 unsigned, (unsigned nunroll, class loop *loop),
38f8b050
JR
2728 NULL)
2729
1a627b35
RS
2730/* True if X is a legitimate MODE-mode immediate operand. */
2731DEFHOOK
2732(legitimate_constant_p,
673c2f63
JM
2733 "This hook returns true if @var{x} is a legitimate constant for a\n\
2734@var{mode}-mode immediate operand on the target machine. You can assume that\n\
2735@var{x} satisfies @code{CONSTANT_P}, so you need not check this.\n\
2736\n\
2737The default definition returns true.",
ef4bddc2 2738 bool, (machine_mode mode, rtx x),
1a627b35
RS
2739 hook_bool_mode_rtx_true)
2740
a21b3997
DE
2741/* True if X is a TLS operand whose value should be pre-computed. */
2742DEFHOOK
2743(precompute_tls_p,
2744 "This hook returns true if @var{x} is a TLS operand on the target\n\
2745machine that should be pre-computed when used as the argument in a call.\n\
2746You can assume that @var{x} satisfies @code{CONSTANT_P}, so you need not \n\
2747check this.\n\
2748\n\
2749The default definition returns false.",
2750 bool, (machine_mode mode, rtx x),
2751 hook_bool_mode_rtx_false)
2752
38f8b050
JR
2753/* True if the constant X cannot be placed in the constant pool. */
2754DEFHOOK
2755(cannot_force_const_mem,
673c2f63
JM
2756 "This hook should return true if @var{x} is of a form that cannot (or\n\
2757should not) be spilled to the constant pool. @var{mode} is the mode\n\
2758of @var{x}.\n\
2759\n\
2760The default version of this hook returns false.\n\
2761\n\
2762The primary reason to define this hook is to prevent reload from\n\
2763deciding that a non-legitimate constant would be better reloaded\n\
2764from the constant pool instead of spilling and reloading a register\n\
2765holding the constant. This restriction is often true of addresses\n\
2766of TLS symbols for various targets.",
ef4bddc2 2767 bool, (machine_mode mode, rtx x),
fbbf66e7 2768 hook_bool_mode_rtx_false)
38f8b050
JR
2769
2770DEFHOOK_UNDOC
2771(cannot_copy_insn_p,
2772 "True if the insn @var{x} cannot be duplicated.",
ac44248e 2773 bool, (rtx_insn *), NULL)
38f8b050
JR
2774
2775/* True if X is considered to be commutative. */
2776DEFHOOK
2777(commutative_p,
673c2f63
JM
2778 "This target hook returns @code{true} if @var{x} is considered to be commutative.\n\
2779Usually, this is just COMMUTATIVE_P (@var{x}), but the HP PA doesn't consider\n\
2780PLUS to be commutative inside a MEM@. @var{outer_code} is the rtx code\n\
2781of the enclosing rtl, if known, otherwise it is UNKNOWN.",
38f8b050
JR
2782 bool, (const_rtx x, int outer_code),
2783 hook_bool_const_rtx_commutative_p)
2784
2785/* True if ADDR is an address-expression whose effect depends
2786 on the mode of the memory reference it is used in. */
2787DEFHOOK
2788(mode_dependent_address_p,
673c2f63
JM
2789 "This hook returns @code{true} if memory address @var{addr} in address\n\
2790space @var{addrspace} can have\n\
2791different meanings depending on the machine mode of the memory\n\
2792reference it is used for or if the address is valid for some modes\n\
2793but not others.\n\
2794\n\
2795Autoincrement and autodecrement addresses typically have mode-dependent\n\
2796effects because the amount of the increment or decrement is the size\n\
2797of the operand being addressed. Some machines have other mode-dependent\n\
2798addresses. Many RISC machines have no mode-dependent addresses.\n\
2799\n\
2800You may assume that @var{addr} is a valid address for the machine.\n\
2801\n\
2802The default version of this hook returns @code{false}.",
5bfed9a9 2803 bool, (const_rtx addr, addr_space_t addrspace),
38f8b050
JR
2804 default_mode_dependent_address_p)
2805
2806/* Given an invalid address X for a given machine mode, try machine-specific
2807 ways to make it legitimate. Return X or an invalid address on failure. */
2808DEFHOOK
2809(legitimize_address,
673c2f63
JM
2810 "This hook is given an invalid memory address @var{x} for an\n\
2811operand of mode @var{mode} and should try to return a valid memory\n\
2812address.\n\
2813\n\
2814@findex break_out_memory_refs\n\
2815@var{x} will always be the result of a call to @code{break_out_memory_refs},\n\
2816and @var{oldx} will be the operand that was given to that function to produce\n\
2817@var{x}.\n\
2818\n\
2819The code of the hook should not alter the substructure of\n\
2820@var{x}. If it transforms @var{x} into a more legitimate form, it\n\
2821should return the new @var{x}.\n\
2822\n\
2823It is not necessary for this hook to come up with a legitimate address,\n\
2824with the exception of native TLS addresses (@pxref{Emulated TLS}).\n\
2825The compiler has standard ways of doing so in all cases. In fact, if\n\
2826the target supports only emulated TLS, it\n\
2827is safe to omit this hook or make it return @var{x} if it cannot find\n\
2828a valid way to legitimize the address. But often a machine-dependent\n\
2829strategy can generate better code.",
ef4bddc2 2830 rtx, (rtx x, rtx oldx, machine_mode mode),
38f8b050
JR
2831 default_legitimize_address)
2832
2833/* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */
2834DEFHOOK
2835(delegitimize_address,
673c2f63
JM
2836 "This hook is used to undo the possibly obfuscating effects of the\n\
2837@code{LEGITIMIZE_ADDRESS} and @code{LEGITIMIZE_RELOAD_ADDRESS} target\n\
2838macros. Some backend implementations of these macros wrap symbol\n\
2839references inside an @code{UNSPEC} rtx to represent PIC or similar\n\
2840addressing modes. This target hook allows GCC's optimizers to understand\n\
2841the semantics of these opaque @code{UNSPEC}s by converting them back\n\
2842into their original form.",
38f8b050
JR
2843 rtx, (rtx x),
2844 delegitimize_mem_from_attrs)
2845
93bcc8c9
JJ
2846/* Given an RTX, return true if it is not ok to emit it into debug info
2847 section. */
2848DEFHOOK
2849(const_not_ok_for_debug_p,
673c2f63
JM
2850 "This hook should return true if @var{x} should not be emitted into\n\
2851debug sections.",
93bcc8c9 2852 bool, (rtx x),
6b10f174 2853 default_const_not_ok_for_debug_p)
93bcc8c9 2854
38f8b050
JR
2855/* Given an address RTX, say whether it is valid. */
2856DEFHOOK
2857(legitimate_address_p,
673c2f63
JM
2858 "A function that returns whether @var{x} (an RTX) is a legitimate memory\n\
2859address on the target machine for a memory operand of mode @var{mode}.\n\
2860\n\
2861Legitimate addresses are defined in two variants: a strict variant and a\n\
2862non-strict one. The @var{strict} parameter chooses which variant is\n\
2863desired by the caller.\n\
2864\n\
2865The strict variant is used in the reload pass. It must be defined so\n\
2866that any pseudo-register that has not been allocated a hard register is\n\
2867considered a memory reference. This is because in contexts where some\n\
2868kind of register is required, a pseudo-register with no hard register\n\
2869must be rejected. For non-hard registers, the strict variant should look\n\
2870up the @code{reg_renumber} array; it should then proceed using the hard\n\
2871register number in the array, or treat the pseudo as a memory reference\n\
2872if the array holds @code{-1}.\n\
2873\n\
2874The non-strict variant is used in other passes. It must be defined to\n\
2875accept all pseudo-registers in every context where some kind of\n\
2876register is required.\n\
2877\n\
2878Normally, constant addresses which are the sum of a @code{symbol_ref}\n\
2879and an integer are stored inside a @code{const} RTX to mark them as\n\
2880constant. Therefore, there is no need to recognize such sums\n\
2881specifically as legitimate addresses. Normally you would simply\n\
2882recognize any @code{const} as legitimate.\n\
2883\n\
2884Usually @code{PRINT_OPERAND_ADDRESS} is not prepared to handle constant\n\
2885sums that are not marked with @code{const}. It assumes that a naked\n\
2886@code{plus} indicates indexing. If so, then you @emph{must} reject such\n\
2887naked constant sums as illegitimate addresses, so that none of them will\n\
2888be given to @code{PRINT_OPERAND_ADDRESS}.\n\
2889\n\
2890@cindex @code{TARGET_ENCODE_SECTION_INFO} and address validation\n\
2891On some machines, whether a symbolic address is legitimate depends on\n\
2892the section that the address refers to. On these machines, define the\n\
2893target hook @code{TARGET_ENCODE_SECTION_INFO} to store the information\n\
2894into the @code{symbol_ref}, and then check for it here. When you see a\n\
2895@code{const}, you will have to look inside it to find the\n\
2896@code{symbol_ref} in order to determine the section. @xref{Assembler\n\
2897Format}.\n\
2898\n\
2899@cindex @code{GO_IF_LEGITIMATE_ADDRESS}\n\
2900Some ports are still using a deprecated legacy substitute for\n\
2901this hook, the @code{GO_IF_LEGITIMATE_ADDRESS} macro. This macro\n\
2902has this syntax:\n\
2903\n\
2904@example\n\
2905#define GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label})\n\
2906@end example\n\
2907\n\
2908@noindent\n\
2909and should @code{goto @var{label}} if the address @var{x} is a valid\n\
2910address on the target machine for a memory operand of mode @var{mode}.\n\
2911\n\
2912@findex REG_OK_STRICT\n\
2913Compiler source files that want to use the strict variant of this\n\
2914macro define the macro @code{REG_OK_STRICT}. You should use an\n\
2915@code{#ifdef REG_OK_STRICT} conditional to define the strict variant in\n\
2916that case and the non-strict variant otherwise.\n\
2917\n\
2918Using the hook is usually simpler because it limits the number of\n\
2919files that are recompiled when changes are made.",
ef4bddc2 2920 bool, (machine_mode mode, rtx x, bool strict),
38f8b050
JR
2921 default_legitimate_address_p)
2922
2923/* True if the given constant can be put into an object_block. */
2924DEFHOOK
2925(use_blocks_for_constant_p,
673c2f63
JM
2926 "This hook should return true if pool entries for constant @var{x} can\n\
2927be placed in an @code{object_block} structure. @var{mode} is the mode\n\
2928of @var{x}.\n\
2929\n\
2930The default version returns false for all constants.",
ef4bddc2 2931 bool, (machine_mode mode, const_rtx x),
38f8b050
JR
2932 hook_bool_mode_const_rtx_false)
2933
361a58da
DE
2934/* True if the given decl can be put into an object_block. */
2935DEFHOOK
2936(use_blocks_for_decl_p,
673c2f63
JM
2937 "This hook should return true if pool entries for @var{decl} should\n\
2938be placed in an @code{object_block} structure.\n\
2939\n\
2940The default version returns true for all decls.",
361a58da
DE
2941 bool, (const_tree decl),
2942 hook_bool_const_tree_true)
2943
38f8b050
JR
2944/* The minimum and maximum byte offsets for anchored addresses. */
2945DEFHOOKPOD
2946(min_anchor_offset,
673c2f63
JM
2947 "The minimum offset that should be applied to a section anchor.\n\
2948On most targets, it should be the smallest offset that can be\n\
2949applied to a base register while still giving a legitimate address\n\
2950for every mode. The default value is 0.",
38f8b050
JR
2951 HOST_WIDE_INT, 0)
2952
2953DEFHOOKPOD
2954(max_anchor_offset,
673c2f63
JM
2955 "Like @code{TARGET_MIN_ANCHOR_OFFSET}, but the maximum (inclusive)\n\
2956offset that should be applied to section anchors. The default\n\
2957value is 0.",
38f8b050
JR
2958 HOST_WIDE_INT, 0)
2959
2960/* True if section anchors can be used to access the given symbol. */
2961DEFHOOK
2962(use_anchors_for_symbol_p,
673c2f63
JM
2963 "Return true if GCC should attempt to use anchors to access @code{SYMBOL_REF}\n\
2964@var{x}. You can assume @samp{SYMBOL_REF_HAS_BLOCK_INFO_P (@var{x})} and\n\
2965@samp{!SYMBOL_REF_ANCHOR_P (@var{x})}.\n\
2966\n\
2967The default version is correct for most targets, but you might need to\n\
2968intercept this hook to handle things like target-specific attributes\n\
2969or target-specific sections.",
38f8b050
JR
2970 bool, (const_rtx x),
2971 default_use_anchors_for_symbol_p)
2972
2f251a05
AI
2973/* True if target supports indirect functions. */
2974DEFHOOK
2975(has_ifunc_p,
2976 "It returns true if the target supports GNU indirect functions.\n\
2977The support includes the assembler, linker and dynamic linker.\n\
2978The default value of this hook is based on target's libc.",
2979 bool, (void),
2980 default_has_ifunc_p)
2981
f7854b90
L
2982/* True if it is OK to reference indirect function resolvers locally. */
2983DEFHOOK
2984(ifunc_ref_local_ok,
2985 "Return true if it is OK to reference indirect function resolvers\n\
2986locally. The default is to return false.",
2987 bool, (void),
2988 hook_bool_void_false)
2989
38f8b050
JR
2990/* True if it is OK to do sibling call optimization for the specified
2991 call expression EXP. DECL will be the called function, or NULL if
2992 this is an indirect call. */
2993DEFHOOK
2994(function_ok_for_sibcall,
5bd40ade 2995 "True if it is OK to do sibling call optimization for the specified\n\
673c2f63
JM
2996call expression @var{exp}. @var{decl} will be the called function,\n\
2997or @code{NULL} if this is an indirect call.\n\
2998\n\
2999It is not uncommon for limitations of calling conventions to prevent\n\
3000tail calls to functions outside the current unit of translation, or\n\
3001during PIC compilation. The hook is used to enforce these restrictions,\n\
67914693 3002as the @code{sibcall} md pattern cannot fail, or fall over to a\n\
673c2f63
JM
3003``normal'' call. The criteria for successful sibling call optimization\n\
3004may vary greatly between different architectures.",
38f8b050
JR
3005 bool, (tree decl, tree exp),
3006 hook_bool_tree_tree_false)
3007
3008/* Establish appropriate back-end context for processing the function
3009 FNDECL. The argument might be NULL to indicate processing at top
3010 level, outside of any function scope. */
3011DEFHOOK
3012(set_current_function,
673c2f63
JM
3013 "The compiler invokes this hook whenever it changes its current function\n\
3014context (@code{cfun}). You can define this function if\n\
3015the back end needs to perform any initialization or reset actions on a\n\
3016per-function basis. For example, it may be used to implement function\n\
3017attributes that affect register usage or code generation patterns.\n\
3018The argument @var{decl} is the declaration for the new function context,\n\
3019and may be null to indicate that the compiler has left a function context\n\
3020and is returning to processing at the top level.\n\
3021The default hook function does nothing.\n\
3022\n\
3023GCC sets @code{cfun} to a dummy function context during initialization of\n\
3024some parts of the back end. The hook function is not invoked in this\n\
3025situation; you need not worry about the hook being invoked recursively,\n\
3026or when the back end is in a partially-initialized state.\n\
3027@code{cfun} might be @code{NULL} to indicate processing at top level,\n\
3028outside of any function scope.",
38f8b050
JR
3029 void, (tree decl), hook_void_tree)
3030
3031/* True if EXP should be placed in a "small data" section. */
3032DEFHOOK
3033(in_small_data_p,
673c2f63
JM
3034 "Returns true if @var{exp} should be placed into a ``small data'' section.\n\
3035The default version of this hook always returns false.",
38f8b050
JR
3036 bool, (const_tree exp),
3037 hook_bool_const_tree_false)
3038
3039/* True if EXP names an object for which name resolution must resolve
3040 to the current executable or shared library. */
3041DEFHOOK
3042(binds_local_p,
673c2f63
JM
3043 "Returns true if @var{exp} names an object for which name resolution\n\
3044rules must resolve to the current ``module'' (dynamic shared library\n\
3045or executable image).\n\
3046\n\
3047The default version of this hook implements the name resolution rules\n\
3048for ELF, which has a looser model of global name binding than other\n\
3049currently supported object file formats.",
38f8b050
JR
3050 bool, (const_tree exp),
3051 default_binds_local_p)
3052
3c5273a9
KT
3053/* Check if profiling code is before or after prologue. */
3054DEFHOOK
3055(profile_before_prologue,
3056 "It returns true if target wants profile code emitted before prologue.\n\n\
3057The default version of this hook use the target macro\n\
3058@code{PROFILE_BEFORE_PROLOGUE}.",
3059 bool, (void),
3060 default_profile_before_prologue)
3061
d56a43a0
AK
3062/* Return true if a leaf function should stay leaf even with profiling
3063 enabled. */
3064DEFHOOK
3065(keep_leaf_when_profiled,
4d3907c2
ML
3066 "This target hook returns true if the target wants the leaf flag for\n\
3067the current function to stay true even if it calls mcount. This might\n\
3068make sense for targets using the leaf flag only to determine whether a\n\
3069stack frame needs to be generated or not and for which the call to\n\
3070mcount is generated before the function prologue.",
d56a43a0
AK
3071 bool, (void),
3072 default_keep_leaf_when_profiled)
3073
38f8b050
JR
3074/* Modify and return the identifier of a DECL's external name,
3075 originally identified by ID, as required by the target,
3076 (eg, append @nn to windows32 stdcall function names).
3077 The default is to return ID without modification. */
3078DEFHOOK
3079(mangle_decl_assembler_name,
673c2f63
JM
3080 "Define this hook if you need to postprocess the assembler name generated\n\
3081by target-independent code. The @var{id} provided to this hook will be\n\
3082the computed name (e.g., the macro @code{DECL_NAME} of the @var{decl} in C,\n\
3083or the mangled name of the @var{decl} in C++). The return value of the\n\
3084hook is an @code{IDENTIFIER_NODE} for the appropriate mangled name on\n\
3085your target system. The default implementation of this hook just\n\
3086returns the @var{id} provided.",
38f8b050
JR
3087 tree, (tree decl, tree id),
3088 default_mangle_decl_assembler_name)
3089
3090/* Do something target-specific to record properties of the DECL into
3091 the associated SYMBOL_REF. */
3092DEFHOOK
3093(encode_section_info,
673c2f63
JM
3094 "Define this hook if references to a symbol or a constant must be\n\
3095treated differently depending on something about the variable or\n\
3096function named by the symbol (such as what section it is in).\n\
3097\n\
3098The hook is executed immediately after rtl has been created for\n\
3099@var{decl}, which may be a variable or function declaration or\n\
3100an entry in the constant pool. In either case, @var{rtl} is the\n\
3101rtl in question. Do @emph{not} use @code{DECL_RTL (@var{decl})}\n\
3102in this hook; that field may not have been initialized yet.\n\
3103\n\
3104In the case of a constant, it is safe to assume that the rtl is\n\
3105a @code{mem} whose address is a @code{symbol_ref}. Most decls\n\
3106will also have this form, but that is not guaranteed. Global\n\
3107register variables, for instance, will have a @code{reg} for their\n\
3108rtl. (Normally the right thing to do with such unusual rtl is\n\
3109leave it alone.)\n\
3110\n\
3111The @var{new_decl_p} argument will be true if this is the first time\n\
3112that @code{TARGET_ENCODE_SECTION_INFO} has been invoked on this decl. It will\n\
3113be false for subsequent invocations, which will happen for duplicate\n\
3114declarations. Whether or not anything must be done for the duplicate\n\
3115declaration depends on whether the hook examines @code{DECL_ATTRIBUTES}.\n\
3116@var{new_decl_p} is always true when the hook is called for a constant.\n\
3117\n\
3118@cindex @code{SYMBOL_REF_FLAG}, in @code{TARGET_ENCODE_SECTION_INFO}\n\
3119The usual thing for this hook to do is to record flags in the\n\
3120@code{symbol_ref}, using @code{SYMBOL_REF_FLAG} or @code{SYMBOL_REF_FLAGS}.\n\
3121Historically, the name string was modified if it was necessary to\n\
3122encode more than one bit of information, but this practice is now\n\
3123discouraged; use @code{SYMBOL_REF_FLAGS}.\n\
3124\n\
3125The default definition of this hook, @code{default_encode_section_info}\n\
e53b6e56 3126in @file{varasm.cc}, sets a number of commonly-useful bits in\n\
673c2f63
JM
3127@code{SYMBOL_REF_FLAGS}. Check whether the default does what you need\n\
3128before overriding it.",
38f8b050
JR
3129 void, (tree decl, rtx rtl, int new_decl_p),
3130 default_encode_section_info)
3131
3132/* Undo the effects of encode_section_info on the symbol string. */
3133DEFHOOK
3134(strip_name_encoding,
673c2f63
JM
3135 "Decode @var{name} and return the real name part, sans\n\
3136the characters that @code{TARGET_ENCODE_SECTION_INFO}\n\
3137may have added.",
38f8b050
JR
3138 const char *, (const char *name),
3139 default_strip_name_encoding)
3140
3141/* If shift optabs for MODE are known to always truncate the shift count,
3142 return the mask that they apply. Return 0 otherwise. */
3143DEFHOOK
3144(shift_truncation_mask,
673c2f63
JM
3145 "This function describes how the standard shift patterns for @var{mode}\n\
3146deal with shifts by negative amounts or by more than the width of the mode.\n\
3147@xref{shift patterns}.\n\
3148\n\
3149On many machines, the shift patterns will apply a mask @var{m} to the\n\
3150shift count, meaning that a fixed-width shift of @var{x} by @var{y} is\n\
3151equivalent to an arbitrary-width shift of @var{x} by @var{y & m}. If\n\
3152this is true for mode @var{mode}, the function should return @var{m},\n\
3153otherwise it should return 0. A return value of 0 indicates that no\n\
3154particular behavior is guaranteed.\n\
3155\n\
3156Note that, unlike @code{SHIFT_COUNT_TRUNCATED}, this function does\n\
3157@emph{not} apply to general shift rtxes; it applies only to instructions\n\
3158that are generated by the named shift patterns.\n\
3159\n\
3160The default implementation of this function returns\n\
3161@code{GET_MODE_BITSIZE (@var{mode}) - 1} if @code{SHIFT_COUNT_TRUNCATED}\n\
3162and 0 otherwise. This definition is always safe, but if\n\
3163@code{SHIFT_COUNT_TRUNCATED} is false, and some shift patterns\n\
3164nevertheless truncate the shift count, you may get better code\n\
3165by overriding it.",
ef4bddc2 3166 unsigned HOST_WIDE_INT, (machine_mode mode),
38f8b050
JR
3167 default_shift_truncation_mask)
3168
3169/* Return the number of divisions in the given MODE that should be present,
3170 so that it is profitable to turn the division into a multiplication by
3171 the reciprocal. */
3172DEFHOOK
3173(min_divisions_for_recip_mul,
673c2f63
JM
3174 "When @option{-ffast-math} is in effect, GCC tries to optimize\n\
3175divisions by the same divisor, by turning them into multiplications by\n\
3176the reciprocal. This target hook specifies the minimum number of divisions\n\
3177that should be there for GCC to perform the optimization for a variable\n\
3178of mode @var{mode}. The default implementation returns 3 if the machine\n\
3179has an instruction for the division, and 2 if it does not.",
ef4bddc2 3180 unsigned int, (machine_mode mode),
38f8b050
JR
3181 default_min_divisions_for_recip_mul)
3182
bb149ca2
RS
3183DEFHOOK
3184(truly_noop_truncation,
3185 "This hook returns true if it is safe to ``convert'' a value of\n\
3186@var{inprec} bits to one of @var{outprec} bits (where @var{outprec} is\n\
3187smaller than @var{inprec}) by merely operating on it as if it had only\n\
3188@var{outprec} bits. The default returns true unconditionally, which\n\
5abe0d81
RS
3189is correct for most machines. When @code{TARGET_TRULY_NOOP_TRUNCATION}\n\
3190returns false, the machine description should provide a @code{trunc}\n\
3191optab to specify the RTL that performs the required truncation.\n\
bb149ca2
RS
3192\n\
3193If @code{TARGET_MODES_TIEABLE_P} returns false for a pair of modes,\n\
3194suboptimal code can result if this hook returns true for the corresponding\n\
3195mode sizes. Making this hook return false in such cases may improve things.",
37b2b8f9
RS
3196 bool, (poly_uint64 outprec, poly_uint64 inprec),
3197 hook_bool_puint64_puint64_true)
bb149ca2 3198
38f8b050
JR
3199/* If the representation of integral MODE is such that values are
3200 always sign-extended to a wider mode MODE_REP then return
3201 SIGN_EXTEND. Return UNKNOWN otherwise. */
3202/* Note that the return type ought to be RTX_CODE, but that's not
3203 necessarily defined at this point. */
3204DEFHOOK
3205(mode_rep_extended,
673c2f63
JM
3206 "The representation of an integral mode can be such that the values\n\
3207are always extended to a wider integral mode. Return\n\
3208@code{SIGN_EXTEND} if values of @var{mode} are represented in\n\
3209sign-extended form to @var{rep_mode}. Return @code{UNKNOWN}\n\
3210otherwise. (Currently, none of the targets use zero-extended\n\
3211representation this way so unlike @code{LOAD_EXTEND_OP},\n\
3212@code{TARGET_MODE_REP_EXTENDED} is expected to return either\n\
3213@code{SIGN_EXTEND} or @code{UNKNOWN}. Also no target extends\n\
3214@var{mode} to @var{rep_mode} so that @var{rep_mode} is not the next\n\
3215widest integral mode and currently we take advantage of this fact.)\n\
3216\n\
3217Similarly to @code{LOAD_EXTEND_OP} you may return a non-@code{UNKNOWN}\n\
3218value even if the extension is not performed on certain hard registers\n\
3219as long as for the @code{REGNO_REG_CLASS} of these hard registers\n\
0d803030 3220@code{TARGET_CAN_CHANGE_MODE_CLASS} returns false.\n\
673c2f63
JM
3221\n\
3222Note that @code{TARGET_MODE_REP_EXTENDED} and @code{LOAD_EXTEND_OP}\n\
3223describe two related properties. If you define\n\
3224@code{TARGET_MODE_REP_EXTENDED (mode, word_mode)} you probably also want\n\
3225to define @code{LOAD_EXTEND_OP (mode)} to return the same type of\n\
3226extension.\n\
3227\n\
3228In order to enforce the representation of @code{mode},\n\
bb149ca2 3229@code{TARGET_TRULY_NOOP_TRUNCATION} should return false when truncating to\n\
673c2f63 3230@code{mode}.",
095a2d76 3231 int, (scalar_int_mode mode, scalar_int_mode rep_mode),
38f8b050
JR
3232 default_mode_rep_extended)
3233
4d3907c2 3234DEFHOOK
82957a73
PB
3235(setjmp_preserves_nonvolatile_regs_p,
3236 "On some targets, it is assumed that the compiler will spill all pseudos\n\
3237 that are live across a call to @code{setjmp}, while other targets treat\n\
3238 @code{setjmp} calls as normal function calls.\n\
3239 \n\
3240 This hook returns false if @code{setjmp} calls do not preserve all\n\
3241 non-volatile registers so that gcc that must spill all pseudos that are\n\
3242 live across @code{setjmp} calls. Define this to return true if the\n\
3243 target does not need to spill all pseudos live across @code{setjmp} calls.\n\
3244 The default implementation conservatively assumes all pseudos must be\n\
3245 spilled across @code{setjmp} calls.",
3246 bool, (void),
3247 hook_bool_void_false)
3248
38f8b050
JR
3249/* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */
3250DEFHOOK
3251(valid_pointer_mode,
673c2f63
JM
3252 "Define this to return nonzero if the port can handle pointers\n\
3253with machine mode @var{mode}. The default version of this\n\
3254hook returns true for both @code{ptr_mode} and @code{Pmode}.",
095a2d76 3255 bool, (scalar_int_mode mode),
38f8b050
JR
3256 default_valid_pointer_mode)
3257
7352c013
RG
3258/* Disambiguate with errno. */
3259DEFHOOK
3260(ref_may_alias_errno,
4d3907c2
ML
3261 "Define this to return nonzero if the memory reference @var{ref}\n\
3262may alias with the system C library errno location. The default\n\
3263version of this hook assumes the system C library errno location\n\
3264is either a declaration of type int or accessed by dereferencing\n\
3265a pointer to int.",
99b1c316 3266 bool, (ao_ref *ref),
7352c013
RG
3267 default_ref_may_alias_errno)
3268
38f8b050
JR
3269/* Support for named address spaces. */
3270#undef HOOK_PREFIX
3271#define HOOK_PREFIX "TARGET_ADDR_SPACE_"
3272HOOK_VECTOR (TARGET_ADDR_SPACE_HOOKS, addr_space)
3273
3274/* MODE to use for a pointer into another address space. */
3275DEFHOOK
3276(pointer_mode,
673c2f63
JM
3277 "Define this to return the machine mode to use for pointers to\n\
3278@var{address_space} if the target supports named address spaces.\n\
0a798c16 3279The default version of this hook returns @code{ptr_mode}.",
095a2d76 3280 scalar_int_mode, (addr_space_t address_space),
38f8b050
JR
3281 default_addr_space_pointer_mode)
3282
3283/* MODE to use for an address in another address space. */
3284DEFHOOK
3285(address_mode,
673c2f63
JM
3286 "Define this to return the machine mode to use for addresses in\n\
3287@var{address_space} if the target supports named address spaces.\n\
0a798c16 3288The default version of this hook returns @code{Pmode}.",
095a2d76 3289 scalar_int_mode, (addr_space_t address_space),
38f8b050
JR
3290 default_addr_space_address_mode)
3291
3292/* True if MODE is valid for a pointer in __attribute__((mode("MODE")))
3293 in another address space. */
3294DEFHOOK
3295(valid_pointer_mode,
673c2f63
JM
3296 "Define this to return nonzero if the port can handle pointers\n\
3297with machine mode @var{mode} to address space @var{as}. This target\n\
3298hook is the same as the @code{TARGET_VALID_POINTER_MODE} target hook,\n\
3299except that it includes explicit named address space support. The default\n\
3300version of this hook returns true for the modes returned by either the\n\
3301@code{TARGET_ADDR_SPACE_POINTER_MODE} or @code{TARGET_ADDR_SPACE_ADDRESS_MODE}\n\
3302target hooks for the given address space.",
095a2d76 3303 bool, (scalar_int_mode mode, addr_space_t as),
38f8b050
JR
3304 default_addr_space_valid_pointer_mode)
3305
3306/* True if an address is a valid memory address to a given named address
3307 space for a given mode. */
3308DEFHOOK
3309(legitimate_address_p,
673c2f63
JM
3310 "Define this to return true if @var{exp} is a valid address for mode\n\
3311@var{mode} in the named address space @var{as}. The @var{strict}\n\
3312parameter says whether strict addressing is in effect after reload has\n\
3313finished. This target hook is the same as the\n\
3314@code{TARGET_LEGITIMATE_ADDRESS_P} target hook, except that it includes\n\
3315explicit named address space support.",
ef4bddc2 3316 bool, (machine_mode mode, rtx exp, bool strict, addr_space_t as),
38f8b050
JR
3317 default_addr_space_legitimate_address_p)
3318
3319/* Return an updated address to convert an invalid pointer to a named
3320 address space to a valid one. If NULL_RTX is returned use machine
3321 independent methods to make the address valid. */
3322DEFHOOK
3323(legitimize_address,
673c2f63
JM
3324 "Define this to modify an invalid address @var{x} to be a valid address\n\
3325with mode @var{mode} in the named address space @var{as}. This target\n\
3326hook is the same as the @code{TARGET_LEGITIMIZE_ADDRESS} target hook,\n\
3327except that it includes explicit named address space support.",
ef4bddc2 3328 rtx, (rtx x, rtx oldx, machine_mode mode, addr_space_t as),
38f8b050
JR
3329 default_addr_space_legitimize_address)
3330
3331/* True if one named address space is a subset of another named address. */
3332DEFHOOK
3333(subset_p,
673c2f63
JM
3334 "Define this to return whether the @var{subset} named address space is\n\
3335contained within the @var{superset} named address space. Pointers to\n\
3336a named address space that is a subset of another named address space\n\
3337will be converted automatically without a cast if used together in\n\
3338arithmetic operations. Pointers to a superset address space can be\n\
3339converted to pointers to a subset address space via explicit casts.",
b5bcaa4a 3340 bool, (addr_space_t subset, addr_space_t superset),
38f8b050
JR
3341 default_addr_space_subset_p)
3342
6626f970
RH
3343/* True if 0 is a valid address in the address space, or false if
3344 0 is a NULL in the address space. */
3345DEFHOOK
3346(zero_address_valid,
3347 "Define this to modify the default handling of address 0 for the\n\
3348address space. Return true if 0 should be considered a valid address.",
3349 bool, (addr_space_t as),
3350 default_addr_space_zero_address_valid)
3351
38f8b050
JR
3352/* Function to convert an rtl expression from one address space to another. */
3353DEFHOOK
3354(convert,
673c2f63
JM
3355 "Define this to convert the pointer expression represented by the RTL\n\
3356@var{op} with type @var{from_type} that points to a named address\n\
3357space to a new pointer expression with type @var{to_type} that points\n\
3358to a different named address space. When this hook it called, it is\n\
3359guaranteed that one of the two address spaces is a subset of the other,\n\
3360as determined by the @code{TARGET_ADDR_SPACE_SUBSET_P} target hook.",
38f8b050
JR
3361 rtx, (rtx op, tree from_type, tree to_type),
3362 default_addr_space_convert)
3363
f736b911
RH
3364/* Function to encode an address space into dwarf. */
3365DEFHOOK
3366(debug,
3367 "Define this to define how the address space is encoded in dwarf.\n\
3368The result is the value to be used with @code{DW_AT_address_class}.",
3369 int, (addr_space_t as),
3370 default_addr_space_debug)
3371
ffc22840
GJL
3372/* Function to emit custom diagnostic if an address space is used. */
3373DEFHOOK
3374(diagnose_usage,
3375 "Define this hook if the availability of an address space depends on\n\
3376command line options and some diagnostics should be printed when the\n\
3377address space is used. This hook is called during parsing and allows\n\
3378to emit a better diagnostic compared to the case where the address space\n\
3379was not registered with @code{c_register_addr_space}. @var{as} is\n\
3380the address space as registered with @code{c_register_addr_space}.\n\
3381@var{loc} is the location of the address space qualifier token.\n\
3382The default implementation does nothing.",
3383 void, (addr_space_t as, location_t loc),
3384 default_addr_space_diagnose_usage)
3385
38f8b050
JR
3386HOOK_VECTOR_END (addr_space)
3387
3388#undef HOOK_PREFIX
3389#define HOOK_PREFIX "TARGET_"
3390
0a9d711d
SP
3391DEFHOOK
3392(lower_local_decl_alignment,
3393 "Define this hook to lower alignment of local, parm or result\n\
3394decl @samp{(@var{decl})}.",
3395 void, (tree decl),
3396 hook_void_tree)
3397
f073de07
RS
3398DEFHOOK
3399(static_rtx_alignment,
3400 "This hook returns the preferred alignment in bits for a\n\
3401statically-allocated rtx, such as a constant pool entry. @var{mode}\n\
3402is the mode of the rtx. The default implementation returns\n\
3403@samp{GET_MODE_ALIGNMENT (@var{mode})}.",
3404 HOST_WIDE_INT, (machine_mode mode),
3405 default_static_rtx_alignment)
3406
58e17cf8
RS
3407DEFHOOK
3408(constant_alignment,
3409 "This hook returns the alignment in bits of a constant that is being\n\
3410placed in memory. @var{constant} is the constant and @var{basic_align}\n\
3411is the alignment that the object would ordinarily have.\n\
3412\n\
3413The default definition just returns @var{basic_align}.\n\
3414\n\
3415The typical use of this hook is to increase alignment for string\n\
3416constants to be word aligned so that @code{strcpy} calls that copy\n\
3417constants can be done inline. The function\n\
3418@code{constant_alignment_word_strings} provides such a definition.",
3419 HOST_WIDE_INT, (const_tree constant, HOST_WIDE_INT basic_align),
3420 default_constant_alignment)
3421
8de583fc
PB
3422DEFHOOK
3423(translate_mode_attribute,
3424 "Define this hook if during mode attribute processing, the port should\n\
3425translate machine_mode @var{mode} to another mode. For example, rs6000's\n\
3426@code{KFmode}, when it is the same as @code{TFmode}.\n\
3427\n\
3428The default version of the hook returns that mode that was passed in.",
3429 machine_mode, (machine_mode mode),
3430 default_translate_mode_attribute)
3431
38f8b050
JR
3432/* True if MODE is valid for the target. By "valid", we mean able to
3433 be manipulated in non-trivial ways. In particular, this means all
3434 the arithmetic is supported. */
3435DEFHOOK
3436(scalar_mode_supported_p,
673c2f63
JM
3437 "Define this to return nonzero if the port is prepared to handle\n\
3438insns involving scalar mode @var{mode}. For a scalar mode to be\n\
3439considered supported, all the basic arithmetic and comparisons\n\
3440must work.\n\
3441\n\
3442The default version of this hook returns true for any mode\n\
3443required to handle the basic C types (as defined by the port).\n\
3444Included here are the double-word arithmetic supported by the\n\
e53b6e56 3445code in @file{optabs.cc}.",
18e2a8b8 3446 bool, (scalar_mode mode),
38f8b050
JR
3447 default_scalar_mode_supported_p)
3448
3449/* Similarly for vector modes. "Supported" here is less strict. At
3450 least some operations are supported; need to check optabs or builtins
3451 for further details. */
3452DEFHOOK
3453(vector_mode_supported_p,
673c2f63
JM
3454 "Define this to return nonzero if the port is prepared to handle\n\
3455insns involving vector mode @var{mode}. At the very least, it\n\
3456must have move patterns for this mode.",
ef4bddc2 3457 bool, (machine_mode mode),
38f8b050
JR
3458 hook_bool_mode_false)
3459
482b2b43
RS
3460DEFHOOK
3461(compatible_vector_types_p,
3462 "Return true if there is no target-specific reason for treating\n\
3463vector types @var{type1} and @var{type2} as distinct types. The caller\n\
3464has already checked for target-independent reasons, meaning that the\n\
3465types are known to have the same mode, to have the same number of elements,\n\
3466and to have what the caller considers to be compatible element types.\n\
3467\n\
3468The main reason for defining this hook is to reject pairs of types\n\
3469that are handled differently by the target's calling convention.\n\
3470For example, when a new @var{N}-bit vector architecture is added\n\
3471to a target, the target may want to handle normal @var{N}-bit\n\
3472@code{VECTOR_TYPE} arguments and return values in the same way as\n\
3473before, to maintain backwards compatibility. However, it may also\n\
3474provide new, architecture-specific @code{VECTOR_TYPE}s that are passed\n\
3475and returned in a more efficient way. It is then important to maintain\n\
3476a distinction between the ``normal'' @code{VECTOR_TYPE}s and the new\n\
3477architecture-specific ones.\n\
3478\n\
3479The default implementation returns true, which is correct for most targets.",
3480 bool, (const_tree type1, const_tree type2),
3481 hook_bool_const_tree_const_tree_true)
3482
5aea1e76
UW
3483DEFHOOK
3484(vector_alignment,
3485 "This hook can be used to define the alignment for a vector of type\n\
3486@var{type}, in order to comply with a platform ABI. The default is to\n\
3487require natural alignment for vector types. The alignment returned by\n\
3488this hook must be a power-of-two multiple of the default alignment of\n\
3489the vector element type.",
3490 HOST_WIDE_INT, (const_tree type),
3491 default_vector_alignment)
3492
695da534
RS
3493DEFHOOK
3494(array_mode,
3495 "Return the mode that GCC should use for an array that has\n\
3496@var{nelems} elements, with each element having mode @var{mode}.\n\
3497Return no mode if the target has no special requirements. In the\n\
3498latter case, GCC looks for an integer mode of the appropriate size\n\
3499if available and uses BLKmode otherwise. Usually the search for the\n\
3500integer mode is limited to @code{MAX_FIXED_MODE_SIZE}, but the\n\
3501@code{TARGET_ARRAY_MODE_SUPPORTED_P} hook allows a larger mode to be\n\
3502used in specific cases.\n\
3503\n\
3504The main use of this hook is to specify that an array of vectors should\n\
3505also have a vector mode. The default implementation returns no mode.",
3506 opt_machine_mode, (machine_mode mode, unsigned HOST_WIDE_INT nelems),
3507 hook_optmode_mode_uhwi_none)
3508
0f6d54f7
RS
3509/* True if we should try to use a scalar mode to represent an array,
3510 overriding the usual MAX_FIXED_MODE limit. */
3511DEFHOOK
3512(array_mode_supported_p,
3513 "Return true if GCC should try to use a scalar mode to store an array\n\
3514of @var{nelems} elements, given that each element has mode @var{mode}.\n\
3515Returning true here overrides the usual @code{MAX_FIXED_MODE} limit\n\
3516and allows GCC to use any defined integer mode.\n\
3517\n\
3518One use of this hook is to support vector load and store operations\n\
3519that operate on several homogeneous vectors. For example, ARM NEON\n\
3520has operations like:\n\
3521\n\
3522@smallexample\n\
3523int8x8x3_t vld3_s8 (const int8_t *)\n\
3524@end smallexample\n\
3525\n\
3526where the return type is defined as:\n\
3527\n\
3528@smallexample\n\
3529typedef struct int8x8x3_t\n\
3530@{\n\
3531 int8x8_t val[3];\n\
3532@} int8x8x3_t;\n\
3533@end smallexample\n\
3534\n\
3535If this hook allows @code{val} to have a scalar mode, then\n\
3536@code{int8x8x3_t} can have the same mode. GCC can then store\n\
3537@code{int8x8x3_t}s in registers rather than forcing them onto the stack.",
ef4bddc2 3538 bool, (machine_mode mode, unsigned HOST_WIDE_INT nelems),
0f6d54f7
RS
3539 hook_bool_mode_uhwi_false)
3540
8cc4b7a2
JM
3541DEFHOOK
3542(libgcc_floating_mode_supported_p,
3543 "Define this to return nonzero if libgcc provides support for the \n\
3544floating-point mode @var{mode}, which is known to pass \n\
3545@code{TARGET_SCALAR_MODE_SUPPORTED_P}. The default version of this \n\
3546hook returns true for all of @code{SFmode}, @code{DFmode}, \n\
3547@code{XFmode} and @code{TFmode}, if such modes exist.",
7c5bd57a 3548 bool, (scalar_float_mode mode),
8cc4b7a2
JM
3549 default_libgcc_floating_mode_supported_p)
3550
c65699ef
JM
3551DEFHOOK
3552(floatn_mode,
3553 "Define this to return the machine mode to use for the type \n\
3554@code{_Float@var{n}}, if @var{extended} is false, or the type \n\
1ce87609
RS
3555@code{_Float@var{n}x}, if @var{extended} is true. If such a type is not\n\
3556supported, return @code{opt_scalar_float_mode ()}. The default version of\n\
3557this hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for\n\
c65699ef
JM
3558@code{_Float64} and @code{_Float32x} and @code{TFmode} for \n\
3559@code{_Float128}, if those modes exist and satisfy the requirements for \n\
3560those types and pass @code{TARGET_SCALAR_MODE_SUPPORTED_P} and \n\
3561@code{TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P}; for @code{_Float64x}, it \n\
3562returns the first of @code{XFmode} and @code{TFmode} that exists and \n\
3563satisfies the same requirements; for other types, it returns \n\
1ce87609
RS
3564@code{opt_scalar_float_mode ()}. The hook is only called for values\n\
3565of @var{n} and @var{extended} that are valid according to\n\
3566ISO/IEC TS 18661-3:2015; that is, @var{n} is one of 32, 64, 128, or,\n\
3567if @var{extended} is false, 16 or greater than 128 and a multiple of 32.",
3568 opt_scalar_float_mode, (int n, bool extended),
c65699ef
JM
3569 default_floatn_mode)
3570
c6762423
MM
3571DEFHOOK
3572(floatn_builtin_p,
3573 "Define this to return true if the @code{_Float@var{n}} and\n\
3574@code{_Float@var{n}x} built-in functions should implicitly enable the\n\
3575built-in function without the @code{__builtin_} prefix in addition to the\n\
3576normal built-in function with the @code{__builtin_} prefix. The default is\n\
3577to only enable built-in functions without the @code{__builtin_} prefix for\n\
3578the GNU C langauge. In strict ANSI/ISO mode, the built-in function without\n\
3579the @code{__builtin_} prefix is not enabled. The argument @code{FUNC} is the\n\
3580@code{enum built_in_function} id of the function to be enabled.",
3581 bool, (int func),
3582 default_floatn_builtin_p)
3583
38f8b050
JR
3584/* Compute cost of moving data from a register of class FROM to one of
3585 TO, using MODE. */
3586DEFHOOK
3587(register_move_cost,
673c2f63
JM
3588 "This target hook should return the cost of moving data of mode @var{mode}\n\
3589from a register in class @var{from} to one in class @var{to}. The classes\n\
3590are expressed using the enumeration values such as @code{GENERAL_REGS}.\n\
3591A value of 2 is the default; other values are interpreted relative to\n\
3592that.\n\
3593\n\
3594It is not required that the cost always equal 2 when @var{from} is the\n\
3595same as @var{to}; on some machines it is expensive to move between\n\
3596registers if they are not general registers.\n\
3597\n\
3598If reload sees an insn consisting of a single @code{set} between two\n\
3599hard registers, and if @code{TARGET_REGISTER_MOVE_COST} applied to their\n\
3600classes returns a value of 2, reload does not check to ensure that the\n\
3601constraints of the insn are met. Setting a cost of other than 2 will\n\
3602allow reload to verify that the constraints are met. You should do this\n\
3603if the @samp{mov@var{m}} pattern's constraints do not allow such copying.\n\
3604\n\
3605The default version of this function returns 2.",
ef4bddc2 3606 int, (machine_mode mode, reg_class_t from, reg_class_t to),
38f8b050
JR
3607 default_register_move_cost)
3608
3609/* Compute cost of moving registers to/from memory. */
3610/* ??? Documenting the argument types for this hook requires a GFDL
3611 license grant. Also, the documentation uses a different name for RCLASS. */
911852ff 3612DEFHOOK
38f8b050 3613(memory_move_cost,
673c2f63
JM
3614 "This target hook should return the cost of moving data of mode @var{mode}\n\
3615between a register of class @var{rclass} and memory; @var{in} is @code{false}\n\
3616if the value is to be written to memory, @code{true} if it is to be read in.\n\
3617This cost is relative to those in @code{TARGET_REGISTER_MOVE_COST}.\n\
3618If moving between registers and memory is more expensive than between two\n\
3619registers, you should add this target hook to express the relative cost.\n\
3620\n\
3621If you do not add this target hook, GCC uses a default cost of 4 plus\n\
3622the cost of copying via a secondary reload register, if one is\n\
3623needed. If your machine requires a secondary reload register to copy\n\
3624between memory and a register of @var{rclass} but the reload mechanism is\n\
3625more complex than copying via an intermediate, use this target hook to\n\
3626reflect the actual cost of the move.\n\
3627\n\
3628GCC defines the function @code{memory_move_secondary_cost} if\n\
3629secondary reloads are needed. It computes the costs due to copying via\n\
3630a secondary register. If your machine copies from memory using a\n\
3631secondary register in the conventional way but the default base value of\n\
36324 is not correct for your machine, use this target hook to add some other\n\
3633value to the result of that function. The arguments to that function\n\
3634are the same as to this target hook.",
ef4bddc2 3635 int, (machine_mode mode, reg_class_t rclass, bool in),
38f8b050
JR
3636 default_memory_move_cost)
3637
7cbed008
JG
3638DEFHOOK
3639(use_by_pieces_infrastructure_p,
3640 "GCC will attempt several strategies when asked to copy between\n\
3641two areas of memory, or to set, clear or store to memory, for example\n\
3642when copying a @code{struct}. The @code{by_pieces} infrastructure\n\
3643implements such memory operations as a sequence of load, store or move\n\
3644insns. Alternate strategies are to expand the\n\
76715c32 3645@code{cpymem} or @code{setmem} optabs, to emit a library call, or to emit\n\
7cbed008
JG
3646unit-by-unit, loop-based operations.\n\
3647\n\
3648This target hook should return true if, for a memory operation with a\n\
3649given @var{size} and @var{alignment}, using the @code{by_pieces}\n\
3650infrastructure is expected to result in better code generation.\n\
3651Both @var{size} and @var{alignment} are measured in terms of storage\n\
3652units.\n\
3653\n\
3654The parameter @var{op} is one of: @code{CLEAR_BY_PIECES},\n\
36b85e43
BS
3655@code{MOVE_BY_PIECES}, @code{SET_BY_PIECES}, @code{STORE_BY_PIECES} or\n\
3656@code{COMPARE_BY_PIECES}. These describe the type of memory operation\n\
3657under consideration.\n\
7cbed008
JG
3658\n\
3659The parameter @var{speed_p} is true if the code is currently being\n\
3660optimized for speed rather than size.\n\
3661\n\
3662Returning true for higher values of @var{size} can improve code generation\n\
3663for speed if the target does not provide an implementation of the\n\
76715c32 3664@code{cpymem} or @code{setmem} standard names, if the @code{cpymem} or\n\
7cbed008
JG
3665@code{setmem} implementation would be more expensive than a sequence of\n\
3666insns, or if the overhead of a library call would dominate that of\n\
3667the body of the memory operation.\n\
3668\n\
3669Returning true for higher values of @code{size} may also cause an increase\n\
3670in code size, for example where the number of insns emitted to perform a\n\
3671move would be greater than that of a library call.",
445d7826 3672 bool, (unsigned HOST_WIDE_INT size, unsigned int alignment,
7cbed008
JG
3673 enum by_pieces_operation op, bool speed_p),
3674 default_use_by_pieces_infrastructure_p)
3675
985b3a68
L
3676DEFHOOK
3677(overlap_op_by_pieces_p,
3678 "This target hook should return true if when the @code{by_pieces}\n\
3679infrastructure is used, an offset adjusted unaligned memory operation\n\
3680in the smallest integer mode for the last piece operation of a memory\n\
3681region can be generated to avoid doing more than one smaller operations.",
3682 bool, (void),
3683 hook_bool_void_false)
3684
36b85e43
BS
3685DEFHOOK
3686(compare_by_pieces_branch_ratio,
3687 "When expanding a block comparison in MODE, gcc can try to reduce the\n\
3688number of branches at the expense of more memory operations. This hook\n\
3689allows the target to override the default choice. It should return the\n\
3690factor by which branches should be reduced over the plain expansion with\n\
3691one comparison per @var{mode}-sized piece. A port can also prevent a\n\
3692particular mode from being used for block comparisons by returning a\n\
3693negative number from this hook.",
3694 int, (machine_mode mode),
3695 default_compare_by_pieces_branch_ratio)
3696
e0bd6c9f
RS
3697DEFHOOK
3698(slow_unaligned_access,
3699 "This hook returns true if memory accesses described by the\n\
3700@var{mode} and @var{alignment} parameters have a cost many times greater\n\
3701than aligned accesses, for example if they are emulated in a trap handler.\n\
630ba2fd 3702This hook is invoked only for unaligned accesses, i.e.@: when\n\
e0bd6c9f
RS
3703@code{@var{alignment} < GET_MODE_ALIGNMENT (@var{mode})}.\n\
3704\n\
3705When this hook returns true, the compiler will act as if\n\
3706@code{STRICT_ALIGNMENT} were true when generating code for block\n\
3707moves. This can cause significantly more instructions to be produced.\n\
3708Therefore, do not make this hook return true if unaligned accesses only\n\
3709add a cycle or two to the time for a memory access.\n\
3710\n\
3711The hook must return true whenever @code{STRICT_ALIGNMENT} is true.\n\
3712The default implementation returns @code{STRICT_ALIGNMENT}.",
3713 bool, (machine_mode mode, unsigned int align),
3714 default_slow_unaligned_access)
3715
d95ab70a
RS
3716DEFHOOK
3717(optab_supported_p,
3718 "Return true if the optimizers should use optab @var{op} with\n\
3719modes @var{mode1} and @var{mode2} for optimization type @var{opt_type}.\n\
3720The optab is known to have an associated @file{.md} instruction\n\
3721whose C condition is true. @var{mode2} is only meaningful for conversion\n\
3722optabs; for direct optabs it is a copy of @var{mode1}.\n\
3723\n\
3724For example, when called with @var{op} equal to @code{rint_optab} and\n\
3725@var{mode1} equal to @code{DFmode}, the hook should say whether the\n\
3726optimizers should use optab @code{rintdf2}.\n\
3727\n\
3728The default hook returns true for all inputs.",
3729 bool, (int op, machine_mode mode1, machine_mode mode2,
3730 optimization_type opt_type),
3731 default_optab_supported_p)
3732
38f8b050
JR
3733/* True for MODE if the target expects that registers in this mode will
3734 be allocated to registers in a small register class. The compiler is
3735 allowed to use registers explicitly used in the rtl as spill registers
3736 but it should prevent extending the lifetime of these registers. */
3737DEFHOOK
3738(small_register_classes_for_mode_p,
673c2f63
JM
3739 "Define this to return nonzero for machine modes for which the port has\n\
3740small register classes. If this target hook returns nonzero for a given\n\
3741@var{mode}, the compiler will try to minimize the lifetime of registers\n\
3742in @var{mode}. The hook may be called with @code{VOIDmode} as argument.\n\
3743In this case, the hook is expected to return nonzero if it returns nonzero\n\
3744for any mode.\n\
3745\n\
3746On some machines, it is risky to let hard registers live across arbitrary\n\
3747insns. Typically, these machines have instructions that require values\n\
3748to be in specific registers (like an accumulator), and reload will fail\n\
3749if the required hard register is used for another purpose across such an\n\
3750insn.\n\
3751\n\
3752Passes before reload do not know which hard registers will be used\n\
3753in an instruction, but the machine modes of the registers set or used in\n\
3754the instruction are already known. And for some machines, register\n\
3755classes are small for, say, integer registers but not for floating point\n\
3756registers. For example, the AMD x86-64 architecture requires specific\n\
3757registers for the legacy x86 integer instructions, but there are many\n\
3758SSE registers for floating point operations. On such targets, a good\n\
3759strategy may be to return nonzero from this hook for @code{INTEGRAL_MODE_P}\n\
3760machine modes but zero for the SSE register classes.\n\
3761\n\
3762The default version of this hook returns false for any mode. It is always\n\
3763safe to redefine this hook to return with a nonzero value. But if you\n\
3764unnecessarily define it, you will reduce the amount of optimizations\n\
3765that can be performed in some cases. If you do not define this hook\n\
3766to return a nonzero value when it is required, the compiler will run out\n\
3767of spill registers and print a fatal error message.",
ef4bddc2 3768 bool, (machine_mode mode),
38f8b050
JR
3769 hook_bool_mode_false)
3770
e692f276
RH
3771/* Register number for a flags register. Only needs to be defined if the
3772 target is constrainted to use post-reload comparison elimination. */
3773DEFHOOKPOD
3774(flags_regnum,
9adea939
HPN
3775 "If the target has a dedicated flags register, and it needs to use the\n\
3776post-reload comparison elimination pass, or the delay slot filler pass,\n\
3777then this value should be set appropriately.",
3778unsigned int, INVALID_REGNUM)
e692f276 3779
38f8b050
JR
3780/* Compute a (partial) cost for rtx X. Return true if the complete
3781 cost has been computed, and false if subexpressions should be
3782 scanned. In either case, *TOTAL contains the cost result. */
e548c9df 3783/* Note that OUTER_CODE ought to be RTX_CODE, but that's
38f8b050
JR
3784 not necessarily defined at this point. */
3785DEFHOOK
3786(rtx_costs,
673c2f63
JM
3787 "This target hook describes the relative costs of RTL expressions.\n\
3788\n\
3789The cost may depend on the precise form of the expression, which is\n\
3790available for examination in @var{x}, and the fact that @var{x} appears\n\
3791as operand @var{opno} of an expression with rtx code @var{outer_code}.\n\
3792That is, the hook can assume that there is some rtx @var{y} such\n\
3793that @samp{GET_CODE (@var{y}) == @var{outer_code}} and such that\n\
3794either (a) @samp{XEXP (@var{y}, @var{opno}) == @var{x}} or\n\
3795(b) @samp{XVEC (@var{y}, @var{opno})} contains @var{x}.\n\
3796\n\
e548c9df
AM
3797@var{mode} is @var{x}'s machine mode, or for cases like @code{const_int} that\n\
3798do not have a mode, the mode in which @var{x} is used.\n\
673c2f63
JM
3799\n\
3800In implementing this hook, you can use the construct\n\
3801@code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast\n\
3802instructions.\n\
3803\n\
3804On entry to the hook, @code{*@var{total}} contains a default estimate\n\
3805for the cost of the expression. The hook should modify this value as\n\
3806necessary. Traditionally, the default costs are @code{COSTS_N_INSNS (5)}\n\
3807for multiplications, @code{COSTS_N_INSNS (7)} for division and modulus\n\
3808operations, and @code{COSTS_N_INSNS (1)} for all other operations.\n\
3809\n\
3810When optimizing for code size, i.e.@: when @code{speed} is\n\
3811false, this target hook should be used to estimate the relative\n\
3812size cost of an expression, again relative to @code{COSTS_N_INSNS}.\n\
3813\n\
3814The hook returns true when all subexpressions of @var{x} have been\n\
3815processed, and false when @code{rtx_cost} should recurse.",
e548c9df
AM
3816 bool, (rtx x, machine_mode mode, int outer_code, int opno, int *total, bool speed),
3817 hook_bool_rtx_mode_int_int_intp_bool_false)
38f8b050
JR
3818
3819/* Compute the cost of X, used as an address. Never called with
3820 invalid addresses. */
3821DEFHOOK
3822(address_cost,
673c2f63
JM
3823 "This hook computes the cost of an addressing mode that contains\n\
3824@var{address}. If not defined, the cost is computed from\n\
3825the @var{address} expression and the @code{TARGET_RTX_COST} hook.\n\
3826\n\
3827For most CISC machines, the default cost is a good approximation of the\n\
3828true cost of the addressing mode. However, on RISC machines, all\n\
3829instructions normally have the same length and execution time. Hence\n\
3830all addresses will have equal costs.\n\
3831\n\
3832In cases where more than one form of an address is known, the form with\n\
3833the lowest cost will be used. If multiple forms have the same, lowest,\n\
3834cost, the one that is the most complex will be used.\n\
3835\n\
3836For example, suppose an address that is equal to the sum of a register\n\
3837and a constant is used twice in the same basic block. When this macro\n\
3838is not defined, the address will be computed in a register and memory\n\
3839references will be indirect through that register. On machines where\n\
3840the cost of the addressing mode containing the sum is no higher than\n\
3841that of a simple indirect reference, this will produce an additional\n\
3842instruction and possibly require an additional register. Proper\n\
3843specification of this macro eliminates this overhead for such machines.\n\
3844\n\
3845This hook is never called with an invalid address.\n\
3846\n\
3847On machines where an address involving more than one register is as\n\
3848cheap as an address computation involving only one register, defining\n\
3849@code{TARGET_ADDRESS_COST} to reflect this can cause two registers to\n\
3850be live over a region of code where only one would have been if\n\
3851@code{TARGET_ADDRESS_COST} were not defined in that manner. This effect\n\
3852should be considered in the definition of this macro. Equivalent costs\n\
3853should probably only be given to addresses with different numbers of\n\
3854registers on machines with lots of registers.",
ef4bddc2 3855 int, (rtx address, machine_mode mode, addr_space_t as, bool speed),
38f8b050
JR
3856 default_address_cost)
3857
94105f5c
SB
3858/* Compute a cost for INSN. */
3859DEFHOOK
3860(insn_cost,
3861 "This target hook describes the relative costs of RTL instructions.\n\
3862\n\
3863In implementing this hook, you can use the construct\n\
3864@code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast\n\
3865instructions.\n\
3866\n\
3867When optimizing for code size, i.e.@: when @code{speed} is\n\
3868false, this target hook should be used to estimate the relative\n\
3869size cost of an expression, again relative to @code{COSTS_N_INSNS}.",
3870 int, (rtx_insn *insn, bool speed), NULL)
3871
e914c11a
JG
3872/* Give a cost, in RTX Costs units, for an edge. Like BRANCH_COST, but with
3873 well defined units. */
3874DEFHOOK
3875(max_noce_ifcvt_seq_cost,
3876 "This hook returns a value in the same units as @code{TARGET_RTX_COSTS},\n\
3877giving the maximum acceptable cost for a sequence generated by the RTL\n\
3878if-conversion pass when conditional execution is not available.\n\
3879The RTL if-conversion pass attempts to convert conditional operations\n\
3880that would require a branch to a series of unconditional operations and\n\
3881@code{mov@var{mode}cc} insns. This hook returns the maximum cost of the\n\
3882unconditional instructions and the @code{mov@var{mode}cc} insns.\n\
3883RTL if-conversion is cancelled if the cost of the converted sequence\n\
3884is greater than the value returned by this hook.\n\
3885\n\
3886@code{e} is the edge between the basic block containing the conditional\n\
3887branch to the basic block which would be executed if the condition\n\
3888were true.\n\
3889\n\
3890The default implementation of this hook uses the\n\
3891@code{max-rtl-if-conversion-[un]predictable} parameters if they are set,\n\
3892and uses a multiple of @code{BRANCH_COST} otherwise.",
3893unsigned int, (edge e),
3894default_max_noce_ifcvt_seq_cost)
3895
d16e2ddd
JJ
3896/* Return true if the given instruction sequence is a good candidate
3897 as a replacement for the if-convertible sequence. */
3898DEFHOOK
3899(noce_conversion_profitable_p,
3900 "This hook returns true if the instruction sequence @code{seq} is a good\n\
3901candidate as a replacement for the if-convertible sequence described in\n\
3902@code{if_info}.",
3903bool, (rtx_insn *seq, struct noce_if_info *if_info),
3904default_noce_conversion_profitable_p)
3905
de6320a8
CB
3906/* Return true if new_addr should be preferred over the existing address used by
3907 memref in insn. */
3908DEFHOOK
3909(new_address_profitable_p,
3910 "Return @code{true} if it is profitable to replace the address in\n\
3911@var{memref} with @var{new_addr}. This allows targets to prevent the\n\
3912scheduler from undoing address optimizations. The instruction containing the\n\
3913memref is @var{insn}. The default implementation returns @code{true}.",
3914bool, (rtx memref, rtx_insn * insn, rtx new_addr),
3915default_new_address_profitable_p)
3916
e535b963
RS
3917DEFHOOK
3918(estimated_poly_value,
3919 "Return an estimate of the runtime value of @var{val}, for use in\n\
64432b68
KT
3920things like cost calculations or profiling frequencies. @var{kind} is used\n\
3921to ask for the minimum, maximum, and likely estimates of the value through\n\
3922the @code{POLY_VALUE_MIN}, @code{POLY_VALUE_MAX} and\n\
3923@code{POLY_VALUE_LIKELY} values. The default\n\
e535b963 3924implementation returns the lowest possible value of @var{val}.",
64432b68 3925 HOST_WIDE_INT, (poly_int64 val, poly_value_estimate_kind kind),
e535b963
RS
3926 default_estimated_poly_value)
3927
f52a73a4
SD
3928/* Permit speculative instructions in delay slots during delayed-branch
3929 scheduling. */
3930DEFHOOK
3931(no_speculation_in_delay_slots_p,
3932 "This predicate controls the use of the eager delay slot filler to disallow\n\
3933speculatively executed instructions being placed in delay slots. Targets\n\
3934such as certain MIPS architectures possess both branches with and without\n\
3935delay slots. As the eager delay slot filler can decrease performance,\n\
3936disabling it is beneficial when ordinary branches are available. Use of\n\
3937delay slot branches filled using the basic filler is often still desirable\n\
4d3907c2
ML
3938as the delay slot can hide a pipeline bubble.",
3939 bool, (void),
f52a73a4
SD
3940 hook_bool_void_false)
3941
38f8b050
JR
3942/* Return where to allocate pseudo for a given hard register initial value. */
3943DEFHOOK
3944(allocate_initial_value,
673c2f63
JM
3945 "\n\
3946When the initial value of a hard register has been copied in a pseudo\n\
3947register, it is often not necessary to actually allocate another register\n\
3948to this pseudo register, because the original hard register or a stack slot\n\
3949it has been saved into can be used. @code{TARGET_ALLOCATE_INITIAL_VALUE}\n\
3950is called at the start of register allocation once for each hard register\n\
3951that had its initial value copied by using\n\
3952@code{get_func_hard_reg_initial_val} or @code{get_hard_reg_initial_val}.\n\
3953Possible values are @code{NULL_RTX}, if you don't want\n\
3954to do any special allocation, a @code{REG} rtx---that would typically be\n\
3955the hard register itself, if it is known not to be clobbered---or a\n\
3956@code{MEM}.\n\
3957If you are returning a @code{MEM}, this is only a hint for the allocator;\n\
3958it might decide to use another register anyways.\n\
3959You may use @code{current_function_is_leaf} or \n\
3960@code{REG_N_SETS} in the hook to determine if the hard\n\
3961register in question will not be clobbered.\n\
3962The default value of this hook is @code{NULL}, which disables any special\n\
3963allocation.",
38f8b050
JR
3964 rtx, (rtx hard_reg), NULL)
3965
c84a808e 3966/* Return nonzero if evaluating UNSPEC X might cause a trap.
e53b6e56 3967 FLAGS has the same meaning as in rtlanal.cc: may_trap_p_1. */
38f8b050
JR
3968DEFHOOK
3969(unspec_may_trap_p,
673c2f63
JM
3970 "This target hook returns nonzero if @var{x}, an @code{unspec} or\n\
3971@code{unspec_volatile} operation, might cause a trap. Targets can use\n\
3972this hook to enhance precision of analysis for @code{unspec} and\n\
3973@code{unspec_volatile} operations. You may call @code{may_trap_p_1}\n\
3974to analyze inner elements of @var{x} in which case @var{flags} should be\n\
3975passed along.",
38f8b050
JR
3976 int, (const_rtx x, unsigned flags),
3977 default_unspec_may_trap_p)
3978
3979/* Given a register, this hook should return a parallel of registers
3980 to represent where to find the register pieces. Define this hook
3981 if the register and its mode are represented in Dwarf in
3982 non-contiguous locations, or if the register should be
3983 represented in more than one register in Dwarf. Otherwise, this
3984 hook should return NULL_RTX. */
3985DEFHOOK
3986(dwarf_register_span,
673c2f63
JM
3987 "Given a register, this hook should return a parallel of registers to\n\
3988represent where to find the register pieces. Define this hook if the\n\
3989register and its mode are represented in Dwarf in non-contiguous\n\
3990locations, or if the register should be represented in more than one\n\
3991register in Dwarf. Otherwise, this hook should return @code{NULL_RTX}.\n\
3992If not defined, the default is to return @code{NULL_RTX}.",
38f8b050
JR
3993 rtx, (rtx reg),
3994 hook_rtx_rtx_null)
3995
ff050c66
MF
3996/* Given a register return the mode of the corresponding DWARF frame
3997 register. */
3998DEFHOOK
3999(dwarf_frame_reg_mode,
4000 "Given a register, this hook should return the mode which the\n\
4001corresponding Dwarf frame register should have. This is normally\n\
4002used to return a smaller mode than the raw mode to prevent call\n\
4003clobbered parts of a register altering the frame register size",
ef4bddc2 4004 machine_mode, (int regno),
ff050c66
MF
4005 default_dwarf_frame_reg_mode)
4006
38f8b050
JR
4007/* If expand_builtin_init_dwarf_reg_sizes needs to fill in table
4008 entries not corresponding directly to registers below
4009 FIRST_PSEUDO_REGISTER, this hook should generate the necessary
4010 code, given the address of the table. */
4011DEFHOOK
4012(init_dwarf_reg_sizes_extra,
673c2f63
JM
4013 "If some registers are represented in Dwarf-2 unwind information in\n\
4014multiple pieces, define this hook to fill in information about the\n\
4015sizes of those pieces in the table used by the unwinder at runtime.\n\
4016It will be called by @code{expand_builtin_init_dwarf_reg_sizes} after\n\
4017filling in a single size corresponding to each hard register;\n\
4018@var{address} is the address of the table.",
38f8b050
JR
4019 void, (tree address),
4020 hook_void_tree)
4021
4022/* Fetch the fixed register(s) which hold condition codes, for
4023 targets where it makes sense to look for duplicate assignments to
4024 the condition codes. This should return true if there is such a
4025 register, false otherwise. The arguments should be set to the
4026 fixed register numbers. Up to two condition code registers are
4027 supported. If there is only one for this target, the int pointed
4028 at by the second argument should be set to -1. */
4029DEFHOOK
4030(fixed_condition_code_regs,
bd1cd0d0 4031 "On targets which use a hard\n\
673c2f63
JM
4032register rather than a pseudo-register to hold condition codes, the\n\
4033regular CSE passes are often not able to identify cases in which the\n\
4034hard register is set to a common value. Use this hook to enable a\n\
4035small pass which optimizes such cases. This hook should return true\n\
4036to enable this pass, and it should set the integers to which its\n\
4037arguments point to the hard register numbers used for condition codes.\n\
4038When there is only one such register, as is true on most systems, the\n\
4039integer pointed to by @var{p2} should be set to\n\
4040@code{INVALID_REGNUM}.\n\
4041\n\
4042The default version of this hook returns false.",
38f8b050
JR
4043 bool, (unsigned int *p1, unsigned int *p2),
4044 hook_bool_uintp_uintp_false)
4045
4046/* If two condition code modes are compatible, return a condition
4047 code mode which is compatible with both, such that a comparison
4048 done in the returned mode will work for both of the original
4049 modes. If the condition code modes are not compatible, return
4050 VOIDmode. */
4051DEFHOOK
4052(cc_modes_compatible,
673c2f63
JM
4053 "On targets which use multiple condition code modes in class\n\
4054@code{MODE_CC}, it is sometimes the case that a comparison can be\n\
4055validly done in more than one mode. On such a system, define this\n\
4056target hook to take two mode arguments and to return a mode in which\n\
4057both comparisons may be validly done. If there is no such mode,\n\
4058return @code{VOIDmode}.\n\
4059\n\
4060The default version of this hook checks whether the modes are the\n\
4061same. If they are, it returns that mode. If they are different, it\n\
4062returns @code{VOIDmode}.",
ef4bddc2 4063 machine_mode, (machine_mode m1, machine_mode m2),
38f8b050
JR
4064 default_cc_modes_compatible)
4065
4066/* Do machine-dependent code transformations. Called just before
4067 delayed-branch scheduling. */
4068DEFHOOK
4069(machine_dependent_reorg,
673c2f63
JM
4070 "If non-null, this hook performs a target-specific pass over the\n\
4071instruction stream. The compiler will run it at all optimization levels,\n\
4072just before the point at which it normally does delayed-branch scheduling.\n\
4073\n\
4074The exact purpose of the hook varies from target to target. Some use\n\
4075it to do transformations that are necessary for correctness, such as\n\
4076laying out in-function constant pools or avoiding hardware hazards.\n\
4077Others use it as an opportunity to do some machine-dependent optimizations.\n\
4078\n\
4079You need not implement the hook if it has nothing to do. The default\n\
4080definition is null.",
38f8b050
JR
4081 void, (void), NULL)
4082
4083/* Create the __builtin_va_list type. */
4084DEFHOOK
4085(build_builtin_va_list,
673c2f63
JM
4086 "This hook returns a type node for @code{va_list} for the target.\n\
4087The default version of the hook returns @code{void*}.",
38f8b050
JR
4088 tree, (void),
4089 std_build_builtin_va_list)
4090
4091/* Enumerate the va list variants. */
07a5b2bc 4092DEFHOOK
38f8b050 4093(enum_va_list_p,
673c2f63
JM
4094 "This target hook is used in function @code{c_common_nodes_and_builtins}\n\
4095to iterate through the target specific builtin types for va_list. The\n\
4096variable @var{idx} is used as iterator. @var{pname} has to be a pointer\n\
4097to a @code{const char *} and @var{ptree} a pointer to a @code{tree} typed\n\
4098variable.\n\
4099The arguments @var{pname} and @var{ptree} are used to store the result of\n\
4100this macro and are set to the name of the va_list builtin type and its\n\
4101internal type.\n\
4102If the return value of this macro is zero, then there is no more element.\n\
4103Otherwise the @var{IDX} should be increased for the next call of this\n\
4104macro to iterate through all types.",
38f8b050
JR
4105 int, (int idx, const char **pname, tree *ptree),
4106 NULL)
4107
4108/* Get the cfun/fndecl calling abi __builtin_va_list type. */
4109DEFHOOK
4110(fn_abi_va_list,
673c2f63
JM
4111 "This hook returns the va_list type of the calling convention specified by\n\
4112@var{fndecl}.\n\
4113The default version of this hook returns @code{va_list_type_node}.",
38f8b050
JR
4114 tree, (tree fndecl),
4115 std_fn_abi_va_list)
4116
4117/* Get the __builtin_va_list type dependent on input type. */
4118DEFHOOK
4119(canonical_va_list_type,
673c2f63
JM
4120 "This hook returns the va_list type of the calling convention specified by the\n\
4121type of @var{type}. If @var{type} is not a valid va_list type, it returns\n\
4122@code{NULL_TREE}.",
38f8b050
JR
4123 tree, (tree type),
4124 std_canonical_va_list_type)
4125
4126/* ??? Documenting this hook requires a GFDL license grant. */
4127DEFHOOK_UNDOC
4128(expand_builtin_va_start,
4129"Expand the @code{__builtin_va_start} builtin.",
4130 void, (tree valist, rtx nextarg), NULL)
4131
4132/* Gimplifies a VA_ARG_EXPR. */
4133DEFHOOK
4134(gimplify_va_arg_expr,
673c2f63
JM
4135 "This hook performs target-specific gimplification of\n\
4136@code{VA_ARG_EXPR}. The first two parameters correspond to the\n\
4137arguments to @code{va_arg}; the latter two are as in\n\
e53b6e56 4138@code{gimplify.cc:gimplify_expr}.",
38f8b050
JR
4139 tree, (tree valist, tree type, gimple_seq *pre_p, gimple_seq *post_p),
4140 std_gimplify_va_arg_expr)
4141
4142/* Validity-checking routines for PCH files, target-specific.
4143 get_pch_validity returns a pointer to the data to be stored,
4144 and stores the size in its argument. pch_valid_p gets the same
4145 information back and returns NULL if the PCH is valid,
4146 or an error message if not. */
4147DEFHOOK
4148(get_pch_validity,
673c2f63
JM
4149 "This hook returns a pointer to the data needed by\n\
4150@code{TARGET_PCH_VALID_P} and sets\n\
4151@samp{*@var{sz}} to the size of the data in bytes.",
38f8b050
JR
4152 void *, (size_t *sz),
4153 default_get_pch_validity)
4154
4155DEFHOOK
4156(pch_valid_p,
673c2f63
JM
4157 "This hook checks whether the options used to create a PCH file are\n\
4158compatible with the current settings. It returns @code{NULL}\n\
4159if so and a suitable error message if not. Error messages will\n\
4160be presented to the user and must be localized using @samp{_(@var{msg})}.\n\
4161\n\
4162@var{data} is the data that was returned by @code{TARGET_GET_PCH_VALIDITY}\n\
4163when the PCH file was created and @var{sz} is the size of that data in bytes.\n\
4164It's safe to assume that the data was created by the same version of the\n\
4165compiler, so no format checking is needed.\n\
4166\n\
4167The default definition of @code{default_pch_valid_p} should be\n\
4168suitable for most targets.",
38f8b050
JR
4169 const char *, (const void *data, size_t sz),
4170 default_pch_valid_p)
4171
e32ea2d1
RS
4172DEFHOOK
4173(prepare_pch_save,
4174 "Called before writing out a PCH file. If the target has some\n\
4175garbage-collected data that needs to be in a particular state on PCH loads,\n\
4176it can use this hook to enforce that state. Very few targets need\n\
4177to do anything here.",
4178 void, (void),
4179 hook_void_void)
4180
38f8b050
JR
4181/* If nonnull, this function checks whether a PCH file with the
4182 given set of target flags can be used. It returns NULL if so,
4183 otherwise it returns an error message. */
4184DEFHOOK
4185(check_pch_target_flags,
673c2f63
JM
4186 "If this hook is nonnull, the default implementation of\n\
4187@code{TARGET_PCH_VALID_P} will use it to check for compatible values\n\
4188of @code{target_flags}. @var{pch_flags} specifies the value that\n\
4189@code{target_flags} had when the PCH file was created. The return\n\
4190value is the same as for @code{TARGET_PCH_VALID_P}.",
38f8b050
JR
4191 const char *, (int pch_flags), NULL)
4192
4193/* True if the compiler should give an enum type only as many
4194 bytes as it takes to represent the range of possible values of
4195 that type. */
4196DEFHOOK
4197(default_short_enums,
673c2f63
JM
4198 "This target hook should return true if the compiler should give an\n\
4199@code{enum} type only as many bytes as it takes to represent the range\n\
4200of possible values of that type. It should return false if all\n\
4201@code{enum} types should be allocated like @code{int}.\n\
4202\n\
4203The default is to return false.",
38f8b050
JR
4204 bool, (void),
4205 hook_bool_void_false)
4206
4207/* This target hook returns an rtx that is used to store the address
4208 of the current frame into the built-in setjmp buffer. */
4209DEFHOOK
4210(builtin_setjmp_frame_value,
673c2f63
JM
4211 "This target hook should return an rtx that is used to store\n\
4212the address of the current frame into the built in @code{setjmp} buffer.\n\
4213The default value, @code{virtual_stack_vars_rtx}, is correct for most\n\
4214machines. One reason you may need to define this target hook is if\n\
4215@code{hard_frame_pointer_rtx} is the appropriate value on your machine.",
38f8b050
JR
4216 rtx, (void),
4217 default_builtin_setjmp_frame_value)
4218
7ca35180
RH
4219/* This target hook should manipulate the outputs, inputs, constraints,
4220 and clobbers the port wishes for pre-processing the asm. */
4221DEFHOOK
4222(md_asm_adjust,
4223 "This target hook may add @dfn{clobbers} to @var{clobbers} and\n\
4224@var{clobbered_regs} for any hard regs the port wishes to automatically\n\
4225clobber for an asm. The @var{outputs} and @var{inputs} may be inspected\n\
8d76ff99
TS
4226to avoid clobbering a register that is already used by the asm. @var{loc}\n\
4227is the source location of the asm.\n\
7ca35180 4228\n\
e52ef6e6
IL
4229It may modify the @var{outputs}, @var{inputs}, @var{input_modes}, and\n\
4230@var{constraints} as necessary for other pre-processing. In this case the\n\
4231return value is a sequence of insns to emit after the asm. Note that\n\
4232changes to @var{inputs} must be accompanied by the corresponding changes\n\
4233to @var{input_modes}.",
7ca35180 4234 rtx_insn *,
e52ef6e6
IL
4235 (vec<rtx>& outputs, vec<rtx>& inputs, vec<machine_mode>& input_modes,
4236 vec<const char *>& constraints, vec<rtx>& clobbers,
8d76ff99 4237 HARD_REG_SET& clobbered_regs, location_t loc),
7ca35180 4238 NULL)
38f8b050
JR
4239
4240/* This target hook allows the backend to specify a calling convention
4241 in the debug information. This function actually returns an
4242 enum dwarf_calling_convention, but because of forward declarations
4243 and not wanting to include dwarf2.h everywhere target.h is included
4244 the function is being declared as an int. */
4245DEFHOOK
4246(dwarf_calling_convention,
673c2f63
JM
4247 "Define this to enable the dwarf attribute @code{DW_AT_calling_convention} to\n\
4248be emitted for each function. Instead of an integer return the enum\n\
4249value for the @code{DW_CC_} tag.",
38f8b050
JR
4250 int, (const_tree function),
4251 hook_int_const_tree_0)
4252
4253/* This target hook allows the backend to emit frame-related insns that
4254 contain UNSPECs or UNSPEC_VOLATILEs. The call frame debugging info
4255 engine will invoke it on insns of the form
4256 (set (reg) (unspec [...] UNSPEC_INDEX))
4257 and
4258 (set (reg) (unspec_volatile [...] UNSPECV_INDEX))
4259 to let the backend emit the call frame instructions. */
4260DEFHOOK
4261(dwarf_handle_frame_unspec,
673c2f63
JM
4262 "This target hook allows the backend to emit frame-related insns that\n\
4263contain UNSPECs or UNSPEC_VOLATILEs. The DWARF 2 call frame debugging\n\
4264info engine will invoke it on insns of the form\n\
4265@smallexample\n\
4266(set (reg) (unspec [@dots{}] UNSPEC_INDEX))\n\
4267@end smallexample\n\
4268and\n\
4269@smallexample\n\
4270(set (reg) (unspec_volatile [@dots{}] UNSPECV_INDEX)).\n\
4271@end smallexample\n\
4272to let the backend emit the call frame instructions. @var{label} is\n\
4273the CFI label attached to the insn, @var{pattern} is the pattern of\n\
4274the insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}.",
38f8b050
JR
4275 void, (const char *label, rtx pattern, int index), NULL)
4276
74c74aa0
RS
4277DEFHOOK
4278(dwarf_poly_indeterminate_value,
4279 "Express the value of @code{poly_int} indeterminate @var{i} as a DWARF\n\
4280expression, with @var{i} counting from 1. Return the number of a DWARF\n\
4281register @var{R} and set @samp{*@var{factor}} and @samp{*@var{offset}} such\n\
4282that the value of the indeterminate is:\n\
4283@smallexample\n\
4284value_of(@var{R}) / @var{factor} - @var{offset}\n\
4285@end smallexample\n\
4286\n\
4287A target only needs to define this hook if it sets\n\
4288@samp{NUM_POLY_INT_COEFFS} to a value greater than 1.",
4289 unsigned int, (unsigned int i, unsigned int *factor, int *offset),
4290 default_dwarf_poly_indeterminate_value)
4291
38f8b050
JR
4292/* ??? Documenting this hook requires a GFDL license grant. */
4293DEFHOOK_UNDOC
4294(stdarg_optimize_hook,
4295"Perform architecture specific checking of statements gimplified\
4296 from @code{VA_ARG_EXPR}. @var{stmt} is the statement. Returns true if\
4297 the statement doesn't need to be checked for @code{va_list} references.",
355fe088 4298 bool, (struct stdarg_info *ai, const gimple *stmt), NULL)
38f8b050
JR
4299
4300/* This target hook allows the operating system to override the DECL
4301 that represents the external variable that contains the stack
4302 protection guard variable. The type of this DECL is ptr_type_node. */
4303DEFHOOK
4304(stack_protect_guard,
673c2f63
JM
4305 "This hook returns a @code{DECL} node for the external variable to use\n\
4306for the stack protection guard. This variable is initialized by the\n\
4307runtime to some random value and is used to initialize the guard value\n\
4308that is placed at the top of the local stack frame. The type of this\n\
4309variable must be @code{ptr_type_node}.\n\
4310\n\
4311The default version of this hook creates a variable called\n\
4312@samp{__stack_chk_guard}, which is normally defined in @file{libgcc2.c}.",
38f8b050
JR
4313 tree, (void),
4314 default_stack_protect_guard)
4315
4316/* This target hook allows the operating system to override the CALL_EXPR
4317 that is invoked when a check vs the guard variable fails. */
4318DEFHOOK
4319(stack_protect_fail,
673c2f63
JM
4320 "This hook returns a @code{CALL_EXPR} that alerts the runtime that the\n\
4321stack protect guard variable has been modified. This expression should\n\
4322involve a call to a @code{noreturn} function.\n\
4323\n\
4324The default version of this hook invokes a function called\n\
4325@samp{__stack_chk_fail}, taking no arguments. This function is\n\
4326normally defined in @file{libgcc2.c}.",
38f8b050
JR
4327 tree, (void),
4328 default_external_stack_protect_fail)
4329
87a5dc2d
JW
4330/* This target hook allows the operating system to disable the default stack
4331 protector runtime support. */
4332DEFHOOK
4333(stack_protect_runtime_enabled_p,
4d3907c2
ML
4334 "Returns true if the target wants GCC's default stack protect runtime support,\n\
4335otherwise return false. The default implementation always returns true.",
87a5dc2d
JW
4336 bool, (void),
4337 hook_bool_void_true)
4338
425fc685
RE
4339DEFHOOK
4340(have_speculation_safe_value,
4341"This hook is used to determine the level of target support for\n\
4342 @code{__builtin_speculation_safe_value}. If called with an argument\n\
4343 of false, it returns true if the target has been modified to support\n\
4344 this builtin. If called with an argument of true, it returns true\n\
4345 if the target requires active mitigation execution might be speculative.\n\
4346 \n\
4347 The default implementation returns false if the target does not define\n\
4348 a pattern named @code{speculation_barrier}. Else it returns true\n\
4349 for the first case and whether the pattern is enabled for the current\n\
f3debef3
RE
4350 compilation for the second case.\n\
4351 \n\
4352 For targets that have no processors that can execute instructions\n\
4353 speculatively an alternative implemenation of this hook is available:\n\
4354 simply redefine this hook to @code{speculation_safe_value_not_needed}\n\
4355 along with your other target hooks.",
425fc685
RE
4356bool, (bool active), default_have_speculation_safe_value)
4357
4358DEFHOOK
4359(speculation_safe_value,
4360"This target hook can be used to generate a target-specific code\n\
4361 sequence that implements the @code{__builtin_speculation_safe_value}\n\
4362 built-in function. The function must always return @var{val} in\n\
4363 @var{result} in mode @var{mode} when the cpu is not executing\n\
4364 speculatively, but must never return that when speculating until it\n\
4365 is known that the speculation will not be unwound. The hook supports\n\
4366 two primary mechanisms for implementing the requirements. The first\n\
4367 is to emit a speculation barrier which forces the processor to wait\n\
4368 until all prior speculative operations have been resolved; the second\n\
4369 is to use a target-specific mechanism that can track the speculation\n\
4370 state and to return @var{failval} if it can determine that\n\
4371 speculation must be unwound at a later time.\n\
4372 \n\
4373 The default implementation simply copies @var{val} to @var{result} and\n\
4374 emits a @code{speculation_barrier} instruction if that is defined.",
4375rtx, (machine_mode mode, rtx result, rtx val, rtx failval),
4376 default_speculation_safe_value)
4377
74b5fcf7
KL
4378DEFHOOK
4379(predict_doloop_p,
4380 "Return true if we can predict it is possible to use a low-overhead loop\n\
4381for a particular loop. The parameter @var{loop} is a pointer to the loop.\n\
4382This target hook is required only when the target supports low-overhead\n\
4383loops, and will help ivopts to make some decisions.\n\
4384The default version of this hook returns false.",
99b1c316 4385 bool, (class loop *loop),
74b5fcf7 4386 default_predict_doloop_p)
425fc685 4387
603a4ad4
KL
4388DEFHOOKPOD
4389(have_count_reg_decr_p,
4390 "Return true if the target supports hardware count register for decrement\n\
4391and branch.\n\
4392The default value is false.",
4393 bool, false)
4394
4395DEFHOOKPOD
4396(doloop_cost_for_generic,
4397 "One IV candidate dedicated for doloop is introduced in IVOPTs, we can\n\
4398calculate the computation cost of adopting it to any generic IV use by\n\
4399function get_computation_cost as before. But for targets which have\n\
4400hardware count register support for decrement and branch, it may have to\n\
4401move IV value from hardware count register to general purpose register\n\
4402while doloop IV candidate is used for generic IV uses. It probably takes\n\
4403expensive penalty. This hook allows target owners to define the cost for\n\
4404this especially for generic IV uses.\n\
4405The default value is zero.",
4406 int64_t, 0)
4407
4408DEFHOOKPOD
4409(doloop_cost_for_address,
4410 "One IV candidate dedicated for doloop is introduced in IVOPTs, we can\n\
4411calculate the computation cost of adopting it to any address IV use by\n\
4412function get_computation_cost as before. But for targets which have\n\
4413hardware count register support for decrement and branch, it may have to\n\
4414move IV value from hardware count register to general purpose register\n\
4415while doloop IV candidate is used for address IV uses. It probably takes\n\
4416expensive penalty. This hook allows target owners to define the cost for\n\
4417this escpecially for address IV uses.\n\
4418The default value is zero.",
4419 int64_t, 0)
4420
1d0216c8
RS
4421DEFHOOK
4422(can_use_doloop_p,
4423 "Return true if it is possible to use low-overhead loops (@code{doloop_end}\n\
4424and @code{doloop_begin}) for a particular loop. @var{iterations} gives the\n\
4425exact number of iterations, or 0 if not known. @var{iterations_max} gives\n\
4426the maximum number of iterations, or 0 if not known. @var{loop_depth} is\n\
4427the nesting depth of the loop, with 1 for innermost loops, 2 for loops that\n\
4428contain innermost loops, and so on. @var{entered_at_top} is true if the\n\
4429loop is only entered from the top.\n\
4430\n\
4431This hook is only used if @code{doloop_end} is available. The default\n\
4432implementation returns true. You can use @code{can_use_doloop_if_innermost}\n\
4433if the loop must be the innermost, and if there are no other restrictions.",
807e902e 4434 bool, (const widest_int &iterations, const widest_int &iterations_max,
1d0216c8 4435 unsigned int loop_depth, bool entered_at_top),
807e902e 4436 hook_bool_wint_wint_uint_bool_true)
1d0216c8 4437
38f8b050
JR
4438/* Returns NULL if target supports the insn within a doloop block,
4439 otherwise it returns an error message. */
4440DEFHOOK
4441(invalid_within_doloop,
673c2f63
JM
4442 "\n\
4443Take an instruction in @var{insn} and return NULL if it is valid within a\n\
4444low-overhead loop, otherwise return a string explaining why doloop\n\
4445could not be applied.\n\
4446\n\
4447Many targets use special registers for low-overhead looping. For any\n\
4448instruction that clobbers these this function should return a string indicating\n\
4449the reason why the doloop could not be applied.\n\
4450By default, the RTL loop optimizer does not use a present doloop pattern for\n\
4451loops containing function calls or branch on table instructions.",
ac44248e 4452 const char *, (const rtx_insn *insn),
38f8b050
JR
4453 default_invalid_within_doloop)
4454
aafa38b5
JG
4455/* Returns the machine mode which the target prefers for doloop IV. */
4456DEFHOOK
4457(preferred_doloop_mode,
4458"This hook takes a @var{mode} for a doloop IV, where @code{mode} is the\n\
4459original mode for the operation. If the target prefers an alternate\n\
4460@code{mode} for the operation, then this hook should return that mode;\n\
4461otherwise the original @code{mode} should be returned. For example, on a\n\
446264-bit target, @code{DImode} might be preferred over @code{SImode}. Both the\n\
4463original and the returned modes should be @code{MODE_INT}.",
4464 machine_mode,
4465 (machine_mode mode),
4466 default_preferred_doloop_mode)
4467
78e4f1ad
UB
4468/* Returns true for a legitimate combined insn. */
4469DEFHOOK
4470(legitimate_combined_insn,
4d3907c2
ML
4471"Take an instruction in @var{insn} and return @code{false} if the instruction\n\
4472is not appropriate as a combination of two or more instructions. The\n\
4473default is to accept all instructions.",
ac44248e
DM
4474 bool, (rtx_insn *insn),
4475 hook_bool_rtx_insn_true)
78e4f1ad 4476
38f8b050
JR
4477DEFHOOK
4478(valid_dllimport_attribute_p,
4d3907c2
ML
4479"@var{decl} is a variable or function with @code{__attribute__((dllimport))}\n\
4480specified. Use this hook if the target needs to add extra validation\n\
4481checks to @code{handle_dll_attribute}.",
38f8b050
JR
4482 bool, (const_tree decl),
4483 hook_bool_const_tree_true)
4484
4485/* If non-zero, align constant anchors in CSE to a multiple of this
4486 value. */
4487DEFHOOKPOD
4488(const_anchor,
673c2f63
JM
4489 "On some architectures it can take multiple instructions to synthesize\n\
4490a constant. If there is another constant already in a register that\n\
4491is close enough in value then it is preferable that the new constant\n\
4492is computed from this register using immediate addition or\n\
4493subtraction. We accomplish this through CSE. Besides the value of\n\
4494the constant we also add a lower and an upper constant anchor to the\n\
4495available expressions. These are then queried when encountering new\n\
4496constants. The anchors are computed by rounding the constant up and\n\
4497down to a multiple of the value of @code{TARGET_CONST_ANCHOR}.\n\
4498@code{TARGET_CONST_ANCHOR} should be the maximum positive value\n\
4499accepted by immediate-add plus one. We currently assume that the\n\
4500value of @code{TARGET_CONST_ANCHOR} is a power of 2. For example, on\n\
4501MIPS, where add-immediate takes a 16-bit signed value,\n\
4502@code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}. The default value\n\
4503is zero, which disables this optimization.",
38f8b050
JR
4504 unsigned HOST_WIDE_INT, 0)
4505
5dcfdccd
KY
4506/* Defines, which target-dependent bits (upper 16) are used by port */
4507DEFHOOK
4508(memmodel_check,
673c2f63
JM
4509 "Validate target specific memory model mask bits. When NULL no target specific\n\
4510memory model bits are allowed.",
5dcfdccd
KY
4511 unsigned HOST_WIDE_INT, (unsigned HOST_WIDE_INT val), NULL)
4512
dfe06d3e
JJ
4513/* Defines an offset bitwise ored into shifted address to get corresponding
4514 Address Sanitizer shadow address, or -1 if Address Sanitizer is not
4515 supported by the target. */
4516DEFHOOK
4517(asan_shadow_offset,
4518 "Return the offset bitwise ored into shifted address to get corresponding\n\
4519Address Sanitizer shadow memory address. NULL if Address Sanitizer is not\n\
dcf0dde4
JW
4520supported by the target. May return 0 if Address Sanitizer is not supported\n\
4521by a subtarget.",
dfe06d3e
JJ
4522 unsigned HOST_WIDE_INT, (void),
4523 NULL)
4524
38f8b050
JR
4525/* Functions relating to calls - argument passing, returns, etc. */
4526/* Members of struct call have no special macro prefix. */
4527HOOK_VECTOR (TARGET_CALLS, calls)
4528
4529DEFHOOK
4530(promote_function_mode,
673c2f63
JM
4531 "Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or\n\
4532function return values. The target hook should return the new mode\n\
4533and possibly change @code{*@var{punsignedp}} if the promotion should\n\
4534change signedness. This function is called only for scalar @emph{or\n\
4535pointer} types.\n\
4536\n\
4537@var{for_return} allows to distinguish the promotion of arguments and\n\
4538return values. If it is @code{1}, a return value is being promoted and\n\
4539@code{TARGET_FUNCTION_VALUE} must perform the same promotions done here.\n\
4540If it is @code{2}, the returned mode should be that of the register in\n\
4541which an incoming parameter is copied, or the outgoing result is computed;\n\
4542then the hook should return the same mode as @code{promote_mode}, though\n\
4543the signedness may be different.\n\
4544\n\
4545@var{type} can be NULL when promoting function arguments of libcalls.\n\
4546\n\
4547The default is to not promote arguments and return values. You can\n\
4548also define the hook to @code{default_promote_function_mode_always_promote}\n\
4549if you would like to apply the same rules given by @code{PROMOTE_MODE}.",
ef4bddc2 4550 machine_mode, (const_tree type, machine_mode mode, int *punsignedp,
38f8b050
JR
4551 const_tree funtype, int for_return),
4552 default_promote_function_mode)
4553
4554DEFHOOK
4555(promote_prototypes,
673c2f63
JM
4556 "This target hook returns @code{true} if an argument declared in a\n\
4557prototype as an integral type smaller than @code{int} should actually be\n\
4558passed as an @code{int}. In addition to avoiding errors in certain\n\
4559cases of mismatch, it also makes for better code on certain machines.\n\
4560The default is to not promote prototypes.",
38f8b050
JR
4561 bool, (const_tree fntype),
4562 hook_bool_const_tree_false)
4563
4564DEFHOOK
4565(struct_value_rtx,
673c2f63
JM
4566 "This target hook should return the location of the structure value\n\
4567address (normally a @code{mem} or @code{reg}), or 0 if the address is\n\
4568passed as an ``invisible'' first argument. Note that @var{fndecl} may\n\
4569be @code{NULL}, for libcalls. You do not need to define this target\n\
4570hook if the address is always passed as an ``invisible'' first\n\
4571argument.\n\
4572\n\
4573On some architectures the place where the structure value address\n\
4574is found by the called function is not the same place that the\n\
4575caller put it. This can be due to register windows, or it could\n\
4576be because the function prologue moves it to a different place.\n\
4577@var{incoming} is @code{1} or @code{2} when the location is needed in\n\
4578the context of the called function, and @code{0} in the context of\n\
4579the caller.\n\
4580\n\
4581If @var{incoming} is nonzero and the address is to be found on the\n\
4582stack, return a @code{mem} which refers to the frame pointer. If\n\
4583@var{incoming} is @code{2}, the result is being used to fetch the\n\
4584structure value address at the beginning of a function. If you need\n\
4585to emit adjusting code, you should do it at this point.",
38f8b050
JR
4586 rtx, (tree fndecl, int incoming),
4587 hook_rtx_tree_int_null)
e0d14c39
BS
4588
4589DEFHOOKPOD
4590(omit_struct_return_reg,
4591 "Normally, when a function returns a structure by memory, the address\n\
4592is passed as an invisible pointer argument, but the compiler also\n\
4593arranges to return the address from the function like it would a normal\n\
9c582551 4594pointer return value. Define this to true if that behavior is\n\
e0d14c39
BS
4595undesirable on your target.",
4596 bool, false)
4597
38f8b050
JR
4598DEFHOOK
4599(return_in_memory,
673c2f63
JM
4600 "This target hook should return a nonzero value to say to return the\n\
4601function value in memory, just as large structures are always returned.\n\
4602Here @var{type} will be the data type of the value, and @var{fntype}\n\
4603will be the type of the function doing the returning, or @code{NULL} for\n\
4604libcalls.\n\
4605\n\
4606Note that values of mode @code{BLKmode} must be explicitly handled\n\
4607by this function. Also, the option @option{-fpcc-struct-return}\n\
4608takes effect regardless of this macro. On most systems, it is\n\
4609possible to leave the hook undefined; this causes a default\n\
4610definition to be used, whose value is the constant 1 for @code{BLKmode}\n\
4611values, and 0 otherwise.\n\
4612\n\
4613Do not use this hook to indicate that structures and unions should always\n\
4614be returned in memory. You should instead use @code{DEFAULT_PCC_STRUCT_RETURN}\n\
4615to indicate this.",
38f8b050
JR
4616 bool, (const_tree type, const_tree fntype),
4617 default_return_in_memory)
4618
4619DEFHOOK
4620(return_in_msb,
673c2f63
JM
4621 "This hook should return true if values of type @var{type} are returned\n\
4622at the most significant end of a register (in other words, if they are\n\
4623padded at the least significant end). You can assume that @var{type}\n\
4624is returned in a register; the caller is required to check this.\n\
4625\n\
4626Note that the register provided by @code{TARGET_FUNCTION_VALUE} must\n\
4627be able to hold the complete return value. For example, if a 1-, 2-\n\
4628or 3-byte structure is returned at the most significant end of a\n\
46294-byte register, @code{TARGET_FUNCTION_VALUE} should provide an\n\
4630@code{SImode} rtx.",
38f8b050
JR
4631 bool, (const_tree type),
4632 hook_bool_const_tree_false)
4633
4634/* Return true if a parameter must be passed by reference. TYPE may
4635 be null if this is a libcall. CA may be null if this query is
4636 from __builtin_va_arg. */
ec9f85e5 4637DEFHOOK
38f8b050 4638(pass_by_reference,
52090e4d 4639 "This target hook should return @code{true} if argument @var{arg} at the\n\
673c2f63
JM
4640position indicated by @var{cum} should be passed by reference. This\n\
4641predicate is queried after target independent reasons for being\n\
52090e4d 4642passed by reference, such as @code{TREE_ADDRESSABLE (@var{arg}.type)}.\n\
673c2f63
JM
4643\n\
4644If the hook returns true, a copy of that argument is made in memory and a\n\
4645pointer to the argument is passed instead of the argument itself.\n\
4646The pointer is passed in whatever way is appropriate for passing a pointer\n\
4647to that type.",
38f8b050 4648 bool,
52090e4d
RS
4649 (cumulative_args_t cum, const function_arg_info &arg),
4650 hook_bool_CUMULATIVE_ARGS_arg_info_false)
38f8b050
JR
4651
4652DEFHOOK
4653(expand_builtin_saveregs,
673c2f63
JM
4654 "If defined, this hook produces the machine-specific code for a call to\n\
4655@code{__builtin_saveregs}. This code will be moved to the very\n\
4656beginning of the function, before any parameter access are made. The\n\
4657return value of this function should be an RTX that contains the value\n\
4658to use as the return of @code{__builtin_saveregs}.",
38f8b050
JR
4659 rtx, (void),
4660 default_expand_builtin_saveregs)
4661
4662/* Returns pretend_argument_size. */
4663DEFHOOK
4664(setup_incoming_varargs,
673c2f63
JM
4665 "This target hook offers an alternative to using\n\
4666@code{__builtin_saveregs} and defining the hook\n\
4667@code{TARGET_EXPAND_BUILTIN_SAVEREGS}. Use it to store the anonymous\n\
4668register arguments into the stack so that all the arguments appear to\n\
4669have been passed consecutively on the stack. Once this is done, you can\n\
4670use the standard implementation of varargs that works for machines that\n\
4671pass all their arguments on the stack.\n\
4672\n\
4673The argument @var{args_so_far} points to the @code{CUMULATIVE_ARGS} data\n\
4674structure, containing the values that are obtained after processing the\n\
e7056ca4
RS
4675named arguments. The argument @var{arg} describes the last of these named\n\
4676arguments.\n\
673c2f63
JM
4677\n\
4678The target hook should do two things: first, push onto the stack all the\n\
4679argument registers @emph{not} used for the named arguments, and second,\n\
4680store the size of the data thus pushed into the @code{int}-valued\n\
4681variable pointed to by @var{pretend_args_size}. The value that you\n\
4682store here will serve as additional offset for setting up the stack\n\
4683frame.\n\
4684\n\
4685Because you must generate code to push the anonymous arguments at\n\
4686compile time without knowing their data types,\n\
4687@code{TARGET_SETUP_INCOMING_VARARGS} is only useful on machines that\n\
4688have just a single category of argument register and use it uniformly\n\
4689for all data types.\n\
4690\n\
4691If the argument @var{second_time} is nonzero, it means that the\n\
4692arguments of the function are being analyzed for the second time. This\n\
4693happens for an inline function, which is not actually compiled until the\n\
4694end of the source file. The hook @code{TARGET_SETUP_INCOMING_VARARGS} should\n\
4695not generate any instructions in this case.",
e7056ca4 4696 void, (cumulative_args_t args_so_far, const function_arg_info &arg,
38f8b050
JR
4697 int *pretend_args_size, int second_time),
4698 default_setup_incoming_varargs)
4699
2f21e1ba
BS
4700DEFHOOK
4701(call_args,
4702 "While generating RTL for a function call, this target hook is invoked once\n\
4703for each argument passed to the function, either a register returned by\n\
4704@code{TARGET_FUNCTION_ARG} or a memory location. It is called just\n\
4705before the point where argument registers are stored. The type of the\n\
4706function to be called is also passed as the second argument; it is\n\
4707@code{NULL_TREE} for libcalls. The @code{TARGET_END_CALL_ARGS} hook is\n\
4708invoked just after the code to copy the return reg has been emitted.\n\
4709This functionality can be used to perform special setup of call argument\n\
4710registers if a target needs it.\n\
4711For functions without arguments, the hook is called once with @code{pc_rtx}\n\
4712passed instead of an argument register.\n\
4713Most ports do not need to implement anything for this hook.",
4714 void, (rtx, tree),
4715 hook_void_rtx_tree)
4716
4717DEFHOOK
4718(end_call_args,
4719 "This target hook is invoked while generating RTL for a function call,\n\
4720just after the point where the return reg is copied into a pseudo. It\n\
4721signals that all the call argument and return registers for the just\n\
4722emitted call are now no longer in use.\n\
4723Most ports do not need to implement anything for this hook.",
4724 void, (void),
4725 hook_void_void)
4726
967b4653
L
4727DEFHOOK
4728(push_argument,
4729 "This target hook returns @code{true} if push instructions will be\n\
4730used to pass outgoing arguments. When the push instruction usage is\n\
4731optional, @var{npush} is nonzero to indicate the number of bytes to\n\
4732push. Otherwise, @var{npush} is zero. If the target machine does not\n\
4733have a push instruction or push instruction should be avoided,\n\
4734@code{false} should be returned. That directs GCC to use an alternate\n\
4735strategy: to allocate the entire argument block and then store the\n\
4736arguments into it. If this target hook may return @code{true},\n\
4737@code{PUSH_ROUNDING} must be defined.",
4738 bool, (unsigned int npush),
4739 default_push_argument)
4740
38f8b050
JR
4741DEFHOOK
4742(strict_argument_naming,
673c2f63
JM
4743 "Define this hook to return @code{true} if the location where a function\n\
4744argument is passed depends on whether or not it is a named argument.\n\
4745\n\
4746This hook controls how the @var{named} argument to @code{TARGET_FUNCTION_ARG}\n\
4747is set for varargs and stdarg functions. If this hook returns\n\
4748@code{true}, the @var{named} argument is always true for named\n\
4749arguments, and false for unnamed arguments. If it returns @code{false},\n\
4750but @code{TARGET_PRETEND_OUTGOING_VARARGS_NAMED} returns @code{true},\n\
4751then all arguments are treated as named. Otherwise, all named arguments\n\
4752except the last are treated as named.\n\
4753\n\
4754You need not define this hook if it always returns @code{false}.",
d5cc9181 4755 bool, (cumulative_args_t ca),
38f8b050
JR
4756 hook_bool_CUMULATIVE_ARGS_false)
4757
4758/* Returns true if we should use
4759 targetm.calls.setup_incoming_varargs() and/or
4760 targetm.calls.strict_argument_naming(). */
4761DEFHOOK
4762(pretend_outgoing_varargs_named,
673c2f63
JM
4763 "If you need to conditionally change ABIs so that one works with\n\
4764@code{TARGET_SETUP_INCOMING_VARARGS}, but the other works like neither\n\
4765@code{TARGET_SETUP_INCOMING_VARARGS} nor @code{TARGET_STRICT_ARGUMENT_NAMING} was\n\
4766defined, then define this hook to return @code{true} if\n\
4767@code{TARGET_SETUP_INCOMING_VARARGS} is used, @code{false} otherwise.\n\
4768Otherwise, you should not define this hook.",
d5cc9181 4769 bool, (cumulative_args_t ca),
38f8b050
JR
4770 default_pretend_outgoing_varargs_named)
4771
4772/* Given a complex type T, return true if a parameter of type T
4773 should be passed as two scalars. */
4774DEFHOOK
4775(split_complex_arg,
673c2f63
JM
4776 "This hook should return true if parameter of type @var{type} are passed\n\
4777as two scalar parameters. By default, GCC will attempt to pack complex\n\
4778arguments into the target's word size. Some ABIs require complex arguments\n\
4779to be split and treated as their individual components. For example, on\n\
4780AIX64, complex floats should be passed in a pair of floating point\n\
4781registers, even though a complex float would fit in one 64-bit floating\n\
4782point register.\n\
4783\n\
4784The default value of this hook is @code{NULL}, which is treated as always\n\
4785false.",
38f8b050
JR
4786 bool, (const_tree type), NULL)
4787
4788/* Return true if type T, mode MODE, may not be passed in registers,
4789 but must be passed on the stack. */
4790/* ??? This predicate should be applied strictly after pass-by-reference.
4791 Need audit to verify that this is the case. */
4792DEFHOOK
4793(must_pass_in_stack,
0ffef200 4794 "This target hook should return @code{true} if we should not pass @var{arg}\n\
673c2f63
JM
4795solely in registers. The file @file{expr.h} defines a\n\
4796definition that is usually appropriate, refer to @file{expr.h} for additional\n\
4797documentation.",
0ffef200 4798 bool, (const function_arg_info &arg),
38f8b050
JR
4799 must_pass_in_stack_var_size_or_pad)
4800
4801/* Return true if type TYPE, mode MODE, which is passed by reference,
4802 should have the object copy generated by the callee rather than
4803 the caller. It is never called for TYPE requiring constructors. */
4804DEFHOOK
4805(callee_copies,
673c2f63
JM
4806 "The function argument described by the parameters to this hook is\n\
4807known to be passed by reference. The hook should return true if the\n\
4808function argument should be copied by the callee instead of copied\n\
4809by the caller.\n\
4810\n\
4811For any argument for which the hook returns true, if it can be\n\
4812determined that the argument is not modified, then a copy need\n\
4813not be generated.\n\
4814\n\
4815The default version of this hook always returns false.",
38f8b050 4816 bool,
7256c719
RS
4817 (cumulative_args_t cum, const function_arg_info &arg),
4818 hook_bool_CUMULATIVE_ARGS_arg_info_false)
38f8b050
JR
4819
4820/* Return zero for arguments passed entirely on the stack or entirely
4821 in registers. If passed in both, return the number of bytes passed
4822 in registers; the balance is therefore passed on the stack. */
4823DEFHOOK
4824(arg_partial_bytes,
673c2f63
JM
4825 "This target hook returns the number of bytes at the beginning of an\n\
4826argument that must be put in registers. The value must be zero for\n\
4827arguments that are passed entirely in registers or that are entirely\n\
4828pushed on the stack.\n\
4829\n\
4830On some machines, certain arguments must be passed partially in\n\
4831registers and partially in memory. On these machines, typically the\n\
4832first few words of arguments are passed in registers, and the rest\n\
4833on the stack. If a multi-word argument (a @code{double} or a\n\
4834structure) crosses that boundary, its first few words must be passed\n\
4835in registers and the rest must be pushed. This macro tells the\n\
4836compiler when this occurs, and how many bytes should go in registers.\n\
4837\n\
4838@code{TARGET_FUNCTION_ARG} for these arguments should return the first\n\
4839register to be used by the caller for this argument; likewise\n\
4840@code{TARGET_FUNCTION_INCOMING_ARG}, for the called function.",
a7c81bc1
RS
4841 int, (cumulative_args_t cum, const function_arg_info &arg),
4842 hook_int_CUMULATIVE_ARGS_arg_info_0)
38f8b050
JR
4843
4844/* Update the state in CA to advance past an argument in the
4845 argument list. The values MODE, TYPE, and NAMED describe that
4846 argument. */
b25b9e8f 4847DEFHOOK
38f8b050 4848(function_arg_advance,
673c2f63 4849 "This hook updates the summarizer variable pointed to by @var{ca} to\n\
6930c98c 4850advance past argument @var{arg} in the argument list. Once this is done,\n\
673c2f63
JM
4851the variable @var{cum} is suitable for analyzing the @emph{following}\n\
4852argument with @code{TARGET_FUNCTION_ARG}, etc.\n\
4853\n\
4854This hook need not do anything if the argument in question was passed\n\
4855on the stack. The compiler knows how to track the amount of stack space\n\
4856used for arguments without any special help.",
38f8b050 4857 void,
6930c98c 4858 (cumulative_args_t ca, const function_arg_info &arg),
38f8b050
JR
4859 default_function_arg_advance)
4860
870118b7
RS
4861DEFHOOK
4862(function_arg_offset,
4863 "This hook returns the number of bytes to add to the offset of an\n\
4864argument of type @var{type} and mode @var{mode} when passed in memory.\n\
4865This is needed for the SPU, which passes @code{char} and @code{short}\n\
4866arguments in the preferred slot that is in the middle of the quad word\n\
4867instead of starting at the top. The default implementation returns 0.",
4868 HOST_WIDE_INT, (machine_mode mode, const_tree type),
4869 default_function_arg_offset)
4870
76b0cbf8
RS
4871DEFHOOK
4872(function_arg_padding,
4873 "This hook determines whether, and in which direction, to pad out\n\
4874an argument of mode @var{mode} and type @var{type}. It returns\n\
4875@code{PAD_UPWARD} to insert padding above the argument, @code{PAD_DOWNWARD}\n\
4876to insert padding below the argument, or @code{PAD_NONE} to inhibit padding.\n\
4877\n\
4878The @emph{amount} of padding is not controlled by this hook, but by\n\
4879@code{TARGET_FUNCTION_ARG_ROUND_BOUNDARY}. It is always just enough\n\
4880to reach the next multiple of that boundary.\n\
4881\n\
4882This hook has a default definition that is right for most systems.\n\
4883For little-endian machines, the default is to pad upward. For\n\
4884big-endian machines, the default is to pad downward for an argument of\n\
4885constant size shorter than an @code{int}, and upward otherwise.",
4886 pad_direction, (machine_mode mode, const_tree type),
4887 default_function_arg_padding)
4888
38f8b050
JR
4889/* Return zero if the argument described by the state of CA should
4890 be placed on a stack, or a hard register in which to store the
4891 argument. The values MODE, TYPE, and NAMED describe that
4892 argument. */
b25b9e8f 4893DEFHOOK
38f8b050 4894(function_arg,
6783fdb7
RS
4895 "Return an RTX indicating whether function argument @var{arg} is passed\n\
4896in a register and if so, which register. Argument @var{ca} summarizes all\n\
4897the previous arguments.\n\
673c2f63
JM
4898\n\
4899The return value is usually either a @code{reg} RTX for the hard\n\
4900register in which to pass the argument, or zero to pass the argument\n\
4901on the stack.\n\
4902\n\
4903The value of the expression can also be a @code{parallel} RTX@. This is\n\
4904used when an argument is passed in multiple locations. The mode of the\n\
4905@code{parallel} should be the mode of the entire argument. The\n\
4906@code{parallel} holds any number of @code{expr_list} pairs; each one\n\
4907describes where part of the argument is passed. In each\n\
4908@code{expr_list} the first operand must be a @code{reg} RTX for the hard\n\
4909register in which to pass this part of the argument, and the mode of the\n\
4910register RTX indicates how large this part of the argument is. The\n\
4911second operand of the @code{expr_list} is a @code{const_int} which gives\n\
4912the offset in bytes into the entire argument of where this part starts.\n\
4913As a special exception the first @code{expr_list} in the @code{parallel}\n\
4914RTX may have a first operand of zero. This indicates that the entire\n\
4915argument is also stored on the stack.\n\
4916\n\
4917The last time this hook is called, it is called with @code{MODE ==\n\
4918VOIDmode}, and its result is passed to the @code{call} or @code{call_value}\n\
4919pattern as operands 2 and 3 respectively.\n\
4920\n\
4921@cindex @file{stdarg.h} and register arguments\n\
4922The usual way to make the ISO library @file{stdarg.h} work on a\n\
4923machine where some arguments are usually passed in registers, is to\n\
4924cause nameless arguments to be passed on the stack instead. This is\n\
4925done by making @code{TARGET_FUNCTION_ARG} return 0 whenever\n\
4926@var{named} is @code{false}.\n\
4927\n\
4928@cindex @code{TARGET_MUST_PASS_IN_STACK}, and @code{TARGET_FUNCTION_ARG}\n\
4929@cindex @code{REG_PARM_STACK_SPACE}, and @code{TARGET_FUNCTION_ARG}\n\
4930You may use the hook @code{targetm.calls.must_pass_in_stack}\n\
4931in the definition of this macro to determine if this argument is of a\n\
4932type that must be passed in the stack. If @code{REG_PARM_STACK_SPACE}\n\
4933is not defined and @code{TARGET_FUNCTION_ARG} returns nonzero for such an\n\
4934argument, the compiler will abort. If @code{REG_PARM_STACK_SPACE} is\n\
4935defined, the argument will be computed in the stack and then loaded into\n\
4936a register.",
6783fdb7 4937 rtx, (cumulative_args_t ca, const function_arg_info &arg),
38f8b050
JR
4938 default_function_arg)
4939
b25b9e8f 4940DEFHOOK
38f8b050 4941(function_incoming_arg,
4a235312
L
4942 "Define this hook if the caller and callee on the target have different\n\
4943views of where arguments are passed. Also define this hook if there are\n\
4944functions that are never directly called, but are invoked by the hardware\n\
4945and which have nonstandard calling conventions.\n\
673c2f63 4946\n\
4a235312 4947In this case @code{TARGET_FUNCTION_ARG} computes the register in\n\
673c2f63
JM
4948which the caller passes the value, and\n\
4949@code{TARGET_FUNCTION_INCOMING_ARG} should be defined in a similar\n\
4950fashion to tell the function being called where the arguments will\n\
4951arrive.\n\
4952\n\
4a235312
L
4953@code{TARGET_FUNCTION_INCOMING_ARG} can also return arbitrary address\n\
4954computation using hard register, which can be forced into a register,\n\
4955so that it can be used to pass special arguments.\n\
4956\n\
673c2f63
JM
4957If @code{TARGET_FUNCTION_INCOMING_ARG} is not defined,\n\
4958@code{TARGET_FUNCTION_ARG} serves both purposes.",
6783fdb7 4959 rtx, (cumulative_args_t ca, const function_arg_info &arg),
38f8b050
JR
4960 default_function_incoming_arg)
4961
c2ed6cf8
NF
4962DEFHOOK
4963(function_arg_boundary,
673c2f63
JM
4964 "This hook returns the alignment boundary, in bits, of an argument\n\
4965with the specified mode and type. The default hook returns\n\
4966@code{PARM_BOUNDARY} for all arguments.",
ef4bddc2 4967 unsigned int, (machine_mode mode, const_tree type),
c2ed6cf8
NF
4968 default_function_arg_boundary)
4969
123148b5
BS
4970DEFHOOK
4971(function_arg_round_boundary,
4972 "Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY},\n\
4973which is the default value for this hook. You can define this hook to\n\
4974return a different value if an argument size must be rounded to a larger\n\
4975value.",
ef4bddc2 4976 unsigned int, (machine_mode mode, const_tree type),
123148b5
BS
4977 default_function_arg_round_boundary)
4978
38f8b050
JR
4979/* Return the diagnostic message string if function without a prototype
4980 is not allowed for this 'val' argument; NULL otherwise. */
4981DEFHOOK
4982(invalid_arg_for_unprototyped_fn,
673c2f63
JM
4983 "If defined, this macro returns the diagnostic message when it is\n\
4984illegal to pass argument @var{val} to function @var{funcdecl}\n\
4985with prototype @var{typelist}.",
38f8b050
JR
4986 const char *, (const_tree typelist, const_tree funcdecl, const_tree val),
4987 hook_invalid_arg_for_unprototyped_fn)
4988
4989/* Return an rtx for the return value location of the function
4990 specified by FN_DECL_OR_TYPE with a return type of RET_TYPE. */
4991DEFHOOK
4992(function_value,
673c2f63
JM
4993 "\n\
4994Define this to return an RTX representing the place where a function\n\
4995returns or receives a value of data type @var{ret_type}, a tree node\n\
4996representing a data type. @var{fn_decl_or_type} is a tree node\n\
4997representing @code{FUNCTION_DECL} or @code{FUNCTION_TYPE} of a\n\
4998function being called. If @var{outgoing} is false, the hook should\n\
4999compute the register in which the caller will see the return value.\n\
5000Otherwise, the hook should return an RTX representing the place where\n\
5001a function returns a value.\n\
5002\n\
5003On many machines, only @code{TYPE_MODE (@var{ret_type})} is relevant.\n\
5004(Actually, on most machines, scalar values are returned in the same\n\
5005place regardless of mode.) The value of the expression is usually a\n\
5006@code{reg} RTX for the hard register where the return value is stored.\n\
5007The value can also be a @code{parallel} RTX, if the return value is in\n\
5008multiple places. See @code{TARGET_FUNCTION_ARG} for an explanation of the\n\
5009@code{parallel} form. Note that the callee will populate every\n\
5010location specified in the @code{parallel}, but if the first element of\n\
5011the @code{parallel} contains the whole return value, callers will use\n\
5012that element as the canonical location and ignore the others. The m68k\n\
5013port uses this type of @code{parallel} to return pointers in both\n\
5014@samp{%a0} (the canonical location) and @samp{%d0}.\n\
5015\n\
5016If @code{TARGET_PROMOTE_FUNCTION_RETURN} returns true, you must apply\n\
5017the same promotion rules specified in @code{PROMOTE_MODE} if\n\
5018@var{valtype} is a scalar type.\n\
5019\n\
5020If the precise function being called is known, @var{func} is a tree\n\
5021node (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null\n\
5022pointer. This makes it possible to use a different value-returning\n\
5023convention for specific functions when all their calls are\n\
5024known.\n\
5025\n\
5026Some target machines have ``register windows'' so that the register in\n\
5027which a function returns its value is not the same as the one in which\n\
5028the caller sees the value. For such machines, you should return\n\
5029different RTX depending on @var{outgoing}.\n\
5030\n\
5031@code{TARGET_FUNCTION_VALUE} is not used for return values with\n\
5032aggregate data types, because these are returned in another way. See\n\
5033@code{TARGET_STRUCT_VALUE_RTX} and related macros, below.",
38f8b050
JR
5034 rtx, (const_tree ret_type, const_tree fn_decl_or_type, bool outgoing),
5035 default_function_value)
5036
5037/* Return the rtx for the result of a libcall of mode MODE,
5038 calling the function FN_NAME. */
5039DEFHOOK
5040(libcall_value,
673c2f63
JM
5041 "Define this hook if the back-end needs to know the name of the libcall\n\
5042function in order to determine where the result should be returned.\n\
5043\n\
5044The mode of the result is given by @var{mode} and the name of the called\n\
5045library function is given by @var{fun}. The hook should return an RTX\n\
5046representing the place where the library function result will be returned.\n\
5047\n\
5048If this hook is not defined, then LIBCALL_VALUE will be used.",
ef4bddc2 5049 rtx, (machine_mode mode, const_rtx fun),
38f8b050
JR
5050 default_libcall_value)
5051
5052/* Return true if REGNO is a possible register number for
5053 a function value as seen by the caller. */
5054DEFHOOK
5055(function_value_regno_p,
673c2f63
JM
5056 "A target hook that return @code{true} if @var{regno} is the number of a hard\n\
5057register in which the values of called function may come back.\n\
5058\n\
5059A register whose use for returning values is limited to serving as the\n\
5060second of a pair (for a value of type @code{double}, say) need not be\n\
5061recognized by this target hook.\n\
5062\n\
5063If the machine has register windows, so that the caller and the called\n\
5064function use different registers for the return value, this target hook\n\
5065should recognize only the caller's register numbers.\n\
5066\n\
5067If this hook is not defined, then FUNCTION_VALUE_REGNO_P will be used.",
38f8b050
JR
5068 bool, (const unsigned int regno),
5069 default_function_value_regno_p)
5070
002ffd3c
RS
5071DEFHOOK
5072(fntype_abi,
5073 "Return the ABI used by a function with type @var{type}; see the\n\
5074definition of @code{predefined_function_abi} for details of the ABI\n\
5075descriptor. Targets only need to define this hook if they support\n\
5076interoperability between several ABIs in the same translation unit.",
5077 const predefined_function_abi &, (const_tree type),
5078 NULL)
5079
5a5a3bc5
RS
5080DEFHOOK
5081(insn_callee_abi,
5082 "This hook returns a description of the ABI used by the target of\n\
5083call instruction @var{insn}; see the definition of\n\
5084@code{predefined_function_abi} for details of the ABI descriptor.\n\
5085Only the global function @code{insn_callee_abi} should call this hook\n\
5086directly.\n\
5087\n\
5088Targets only need to define this hook if they support\n\
5089interoperability between several ABIs in the same translation unit.",
5090 const predefined_function_abi &, (const rtx_insn *insn),
5091 NULL)
5092
38f8b050
JR
5093/* ??? Documenting this hook requires a GFDL license grant. */
5094DEFHOOK_UNDOC
5095(internal_arg_pointer,
5096"Return an rtx for the argument pointer incoming to the\
5097 current function.",
5098 rtx, (void),
5099 default_internal_arg_pointer)
5100
5101/* Update the current function stack boundary if needed. */
5102DEFHOOK
5103(update_stack_boundary,
673c2f63
JM
5104 "Define this macro to update the current function stack boundary if\n\
5105necessary.",
38f8b050
JR
5106 void, (void), NULL)
5107
5108/* Handle stack alignment and return an rtx for Dynamic Realign
5109 Argument Pointer if necessary. */
5110DEFHOOK
5111(get_drap_rtx,
673c2f63
JM
5112 "This hook should return an rtx for Dynamic Realign Argument Pointer (DRAP) if a\n\
5113different argument pointer register is needed to access the function's\n\
5114argument list due to stack realignment. Return @code{NULL} if no DRAP\n\
5115is needed.",
38f8b050
JR
5116 rtx, (void), NULL)
5117
d10f3e90 5118/* Generate instruction sequence to zero call used registers. */
5119DEFHOOK
5120(zero_call_used_regs,
5121 "This target hook emits instructions to zero the subset of @var{selected_regs}\n\
5122that could conceivably contain values that are useful to an attacker.\n\
5123Return the set of registers that were actually cleared.\n\
5124\n\
5125The default implementation uses normal move instructions to zero\n\
5126all the registers in @var{selected_regs}. Define this hook if the\n\
5127target has more efficient ways of zeroing certain registers,\n\
5128or if you believe that certain registers would never contain\n\
5129values that are useful to an attacker.",
5130 HARD_REG_SET, (HARD_REG_SET selected_regs),
5131default_zero_call_used_regs)
5132
38f8b050
JR
5133/* Return true if all function parameters should be spilled to the
5134 stack. */
5135DEFHOOK
5136(allocate_stack_slots_for_args,
673c2f63
JM
5137 "When optimization is disabled, this hook indicates whether or not\n\
5138arguments should be allocated to stack slots. Normally, GCC allocates\n\
5139stacks slots for arguments when not optimizing in order to make\n\
5140debugging easier. However, when a function is declared with\n\
5141@code{__attribute__((naked))}, there is no stack frame, and the compiler\n\
5142cannot safely move arguments from the registers in which they are passed\n\
5143to the stack. Therefore, this hook should return true in general, but\n\
5144false for naked functions. The default implementation always returns true.",
38f8b050
JR
5145 bool, (void),
5146 hook_bool_void_true)
5147
c21df29b
RH
5148/* Return an rtx for the static chain for FNDECL_OR_TYPE. If INCOMING_P
5149 is true, then it should be for the callee; otherwise for the caller. */
38f8b050
JR
5150DEFHOOK
5151(static_chain,
673c2f63
JM
5152 "This hook replaces the use of @code{STATIC_CHAIN_REGNUM} et al for\n\
5153targets that may use different static chain locations for different\n\
5154nested functions. This may be required if the target has function\n\
5155attributes that affect the calling conventions of the function and\n\
5156those calling conventions use different static chain locations.\n\
5157\n\
5158The default version of this hook uses @code{STATIC_CHAIN_REGNUM} et al.\n\
5159\n\
5160If the static chain is passed in memory, this hook should be used to\n\
5161provide rtx giving @code{mem} expressions that denote where they are stored.\n\
5162Often the @code{mem} expression as seen by the caller will be at an offset\n\
5163from the stack pointer and the @code{mem} expression as seen by the callee\n\
5164will be at an offset from the frame pointer.\n\
5165@findex stack_pointer_rtx\n\
5166@findex frame_pointer_rtx\n\
5167@findex arg_pointer_rtx\n\
5168The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and\n\
5169@code{arg_pointer_rtx} will have been initialized and should be used\n\
5170to refer to those items.",
c21df29b 5171 rtx, (const_tree fndecl_or_type, bool incoming_p),
38f8b050
JR
5172 default_static_chain)
5173
5174/* Fill in the trampoline at MEM with a call to FNDECL and a
5175 static chain value of CHAIN. */
5176DEFHOOK
5177(trampoline_init,
673c2f63
JM
5178 "This hook is called to initialize a trampoline.\n\
5179@var{m_tramp} is an RTX for the memory block for the trampoline; @var{fndecl}\n\
5180is the @code{FUNCTION_DECL} for the nested function; @var{static_chain} is an\n\
5181RTX for the static chain value that should be passed to the function\n\
5182when it is called.\n\
5183\n\
5184If the target defines @code{TARGET_ASM_TRAMPOLINE_TEMPLATE}, then the\n\
5185first thing this hook should do is emit a block move into @var{m_tramp}\n\
5186from the memory block returned by @code{assemble_trampoline_template}.\n\
5187Note that the block move need only cover the constant parts of the\n\
5188trampoline. If the target isolates the variable parts of the trampoline\n\
5189to the end, not all @code{TRAMPOLINE_SIZE} bytes need be copied.\n\
5190\n\
c05ece92
AO
5191If the target requires any other actions, such as flushing caches\n\
5192(possibly calling function maybe_emit_call_builtin___clear_cache) or\n\
673c2f63
JM
5193enabling stack execution, these actions should be performed after\n\
5194initializing the trampoline proper.",
38f8b050
JR
5195 void, (rtx m_tramp, tree fndecl, rtx static_chain),
5196 default_trampoline_init)
5197
c05ece92
AO
5198/* Emit a call to a function to clear the instruction cache. */
5199DEFHOOK
5200(emit_call_builtin___clear_cache,
5201 "On targets that do not define a @code{clear_cache} insn expander,\n\
5202but that define the @code{CLEAR_CACHE_INSN} macro,\n\
5203maybe_emit_call_builtin___clear_cache relies on this target hook\n\
5204to clear an address range in the instruction cache.\n\
5205\n\
5206The default implementation calls the @code{__clear_cache} builtin,\n\
5207taking the assembler name from the builtin declaration. Overriding\n\
5208definitions may call alternate functions, with alternate calling\n\
5209conventions, or emit alternate RTX to perform the job.",
5210 void, (rtx begin, rtx end),
5211 default_emit_call_builtin___clear_cache)
5212
38f8b050
JR
5213/* Adjust the address of the trampoline in a target-specific way. */
5214DEFHOOK
5215(trampoline_adjust_address,
673c2f63
JM
5216 "This hook should perform any machine-specific adjustment in\n\
5217the address of the trampoline. Its argument contains the address of the\n\
5218memory block that was passed to @code{TARGET_TRAMPOLINE_INIT}. In case\n\
5219the address to be used for a function call should be different from the\n\
5220address at which the template was stored, the different address should\n\
5221be returned; otherwise @var{addr} should be returned unchanged.\n\
5222If this hook is not defined, @var{addr} will be used for function calls.",
38f8b050
JR
5223 rtx, (rtx addr), NULL)
5224
4c640e26
EB
5225DEFHOOKPOD
5226(custom_function_descriptors,
92b6df43
SL
5227 "If the target can use GCC's generic descriptor mechanism for nested\n\
5228functions, define this hook to a power of 2 representing an unused bit\n\
5229in function pointers which can be used to differentiate descriptors at\n\
5230run time. This value gives the number of bytes by which descriptor\n\
5231pointers are misaligned compared to function pointers. For example, on\n\
5232targets that require functions to be aligned to a 4-byte boundary, a\n\
5233value of either 1 or 2 is appropriate unless the architecture already\n\
5234reserves the bit for another purpose, such as on ARM.\n\
5235\n\
5236Define this hook to 0 if the target implements ABI support for\n\
5237function descriptors in its standard calling sequence, like for example\n\
5238HPPA or IA-64.\n\
5239\n\
5240Using descriptors for nested functions\n\
4c640e26 5241eliminates the need for trampolines that reside on the stack and require\n\
4d3907c2 5242it to be made executable.",
4c640e26
EB
5243 int, -1)
5244
38f8b050
JR
5245/* Return the number of bytes of its own arguments that a function
5246 pops on returning, or 0 if the function pops no arguments and the
5247 caller must therefore pop them all after the function returns. */
5248/* ??? tm.texi has no types for the parameters. */
893d13d5 5249DEFHOOK
38f8b050 5250(return_pops_args,
673c2f63
JM
5251 "This target hook returns the number of bytes of its own arguments that\n\
5252a function pops on returning, or 0 if the function pops no arguments\n\
5253and the caller must therefore pop them all after the function returns.\n\
5254\n\
5255@var{fundecl} is a C variable whose value is a tree node that describes\n\
5256the function in question. Normally it is a node of type\n\
5257@code{FUNCTION_DECL} that describes the declaration of the function.\n\
5258From this you can obtain the @code{DECL_ATTRIBUTES} of the function.\n\
5259\n\
5260@var{funtype} is a C variable whose value is a tree node that\n\
5261describes the function in question. Normally it is a node of type\n\
5262@code{FUNCTION_TYPE} that describes the data type of the function.\n\
5263From this it is possible to obtain the data types of the value and\n\
5264arguments (if known).\n\
5265\n\
5266When a call to a library function is being considered, @var{fundecl}\n\
5267will contain an identifier node for the library function. Thus, if\n\
5268you need to distinguish among various library functions, you can do so\n\
5269by their names. Note that ``library function'' in this context means\n\
5270a function used to perform arithmetic, whose name is known specially\n\
5271in the compiler and was not mentioned in the C code being compiled.\n\
5272\n\
5273@var{size} is the number of bytes of arguments passed on the\n\
5274stack. If a variable number of bytes is passed, it is zero, and\n\
5275argument popping will always be the responsibility of the calling function.\n\
5276\n\
5277On the VAX, all functions always pop their arguments, so the definition\n\
5278of this macro is @var{size}. On the 68000, using the standard\n\
5279calling convention, no functions pop their arguments, so the value of\n\
5280the macro is always 0 in this case. But an alternative calling\n\
5281convention is available in which functions that take a fixed number of\n\
5282arguments pop them but other functions (such as @code{printf}) pop\n\
5283nothing (the caller pops all). When this convention is in use,\n\
5284@var{funtype} is examined to determine whether a function takes a fixed\n\
5285number of arguments.",
a20c5714 5286 poly_int64, (tree fundecl, tree funtype, poly_int64 size),
38f8b050
JR
5287 default_return_pops_args)
5288
ffa88471
SE
5289/* Return a mode wide enough to copy any function value that might be
5290 returned. */
5291DEFHOOK
5292(get_raw_result_mode,
4d3907c2
ML
5293 "This target hook returns the mode to be used when accessing raw return\n\
5294registers in @code{__builtin_return}. Define this macro if the value\n\
5295in @var{reg_raw_mode} is not correct.",
ef1d3b57 5296 fixed_size_mode, (int regno),
ffa88471
SE
5297 default_get_reg_raw_mode)
5298
5299/* Return a mode wide enough to copy any argument value that might be
5300 passed. */
5301DEFHOOK
5302(get_raw_arg_mode,
4d3907c2
ML
5303 "This target hook returns the mode to be used when accessing raw argument\n\
5304registers in @code{__builtin_apply_args}. Define this macro if the value\n\
5305in @var{reg_raw_mode} is not correct.",
ef1d3b57 5306 fixed_size_mode, (int regno),
ffa88471
SE
5307 default_get_reg_raw_mode)
5308
974aedcc
MP
5309/* Return true if a type is an empty record. */
5310DEFHOOK
5311(empty_record_p,
5312 "This target hook returns true if the type is an empty record. The default\n\
5313is to return @code{false}.",
5314 bool, (const_tree type),
5315 hook_bool_const_tree_false)
5316
5317/* Warn about the change in empty class parameter passing ABI. */
5318DEFHOOK
5319(warn_parameter_passing_abi,
5320 "This target hook warns about the change in empty class parameter passing\n\
5321ABI.",
5322 void, (cumulative_args_t ca, tree type),
5323 hook_void_CUMULATIVE_ARGS_tree)
5324
38f8b050
JR
5325HOOK_VECTOR_END (calls)
5326
bcb21886
KY
5327DEFHOOK
5328(use_pseudo_pic_reg,
5329 "This hook should return 1 in case pseudo register should be created\n\
5330for pic_offset_table_rtx during function expand.",
5331 bool, (void),
5332 hook_bool_void_false)
5333
5334DEFHOOK
5335(init_pic_reg,
5336 "Perform a target dependent initialization of pic_offset_table_rtx.\n\
5337This hook is called at the start of register allocation.",
5338 void, (void),
5339 hook_void_void)
5340
38f8b050
JR
5341/* Return the diagnostic message string if conversion from FROMTYPE
5342 to TOTYPE is not allowed, NULL otherwise. */
5343DEFHOOK
5344(invalid_conversion,
673c2f63
JM
5345 "If defined, this macro returns the diagnostic message when it is\n\
5346invalid to convert from @var{fromtype} to @var{totype}, or @code{NULL}\n\
5347if validity should be determined by the front end.",
38f8b050
JR
5348 const char *, (const_tree fromtype, const_tree totype),
5349 hook_constcharptr_const_tree_const_tree_null)
5350
5351/* Return the diagnostic message string if the unary operation OP is
5352 not permitted on TYPE, NULL otherwise. */
5353DEFHOOK
5354(invalid_unary_op,
673c2f63
JM
5355 "If defined, this macro returns the diagnostic message when it is\n\
5356invalid to apply operation @var{op} (where unary plus is denoted by\n\
5357@code{CONVERT_EXPR}) to an operand of type @var{type}, or @code{NULL}\n\
5358if validity should be determined by the front end.",
38f8b050
JR
5359 const char *, (int op, const_tree type),
5360 hook_constcharptr_int_const_tree_null)
5361
5362/* Return the diagnostic message string if the binary operation OP
5363 is not permitted on TYPE1 and TYPE2, NULL otherwise. */
5364DEFHOOK
5365(invalid_binary_op,
673c2f63
JM
5366 "If defined, this macro returns the diagnostic message when it is\n\
5367invalid to apply operation @var{op} to operands of types @var{type1}\n\
5368and @var{type2}, or @code{NULL} if validity should be determined by\n\
5369the front end.",
38f8b050
JR
5370 const char *, (int op, const_tree type1, const_tree type2),
5371 hook_constcharptr_int_const_tree_const_tree_null)
5372
38f8b050
JR
5373/* If values of TYPE are promoted to some other type when used in
5374 expressions (analogous to the integer promotions), return that type,
5375 or NULL_TREE otherwise. */
5376DEFHOOK
5377(promoted_type,
673c2f63
JM
5378 "If defined, this target hook returns the type to which values of\n\
5379@var{type} should be promoted when they appear in expressions,\n\
5380analogous to the integer promotions, or @code{NULL_TREE} to use the\n\
5381front end's normal promotion rules. This hook is useful when there are\n\
5382target-specific types with special promotion rules.\n\
5383This is currently used only by the C and C++ front ends.",
38f8b050
JR
5384 tree, (const_tree type),
5385 hook_tree_const_tree_null)
5386
5387/* Convert EXPR to TYPE, if target-specific types with special conversion
5388 rules are involved. Return the converted expression, or NULL to apply
5389 the standard conversion rules. */
5390DEFHOOK
5391(convert_to_type,
673c2f63
JM
5392 "If defined, this hook returns the result of converting @var{expr} to\n\
5393@var{type}. It should return the converted expression,\n\
5394or @code{NULL_TREE} to apply the front end's normal conversion rules.\n\
5395This hook is useful when there are target-specific types with special\n\
5396conversion rules.\n\
5397This is currently used only by the C and C++ front ends.",
38f8b050
JR
5398 tree, (tree type, tree expr),
5399 hook_tree_tree_tree_null)
5400
65ef05d0
RS
5401DEFHOOK
5402(verify_type_context,
5403 "If defined, this hook returns false if there is a target-specific reason\n\
5404why type @var{type} cannot be used in the source language context described\n\
5405by @var{context}. When @var{silent_p} is false, the hook also reports an\n\
5406error against @var{loc} for invalid uses of @var{type}.\n\
5407\n\
5408Calls to this hook should be made through the global function\n\
5409@code{verify_type_context}, which makes the @var{silent_p} parameter\n\
5410default to false and also handles @code{error_mark_node}.\n\
5411\n\
5412The default implementation always returns true.",
5413 bool, (location_t loc, type_context_kind context, const_tree type,
5414 bool silent_p),
5415 NULL)
5416
0d803030
RS
5417DEFHOOK
5418(can_change_mode_class,
5419 "This hook returns true if it is possible to bitcast values held in\n\
5420registers of class @var{rclass} from mode @var{from} to mode @var{to}\n\
5421and if doing so preserves the low-order bits that are common to both modes.\n\
5422The result is only meaningful if @var{rclass} has registers that can hold\n\
5423both @code{from} and @code{to}. The default implementation returns true.\n\
5424\n\
5425As an example of when such bitcasting is invalid, loading 32-bit integer or\n\
5426floating-point objects into floating-point registers on Alpha extends them\n\
5427to 64 bits. Therefore loading a 64-bit object and then storing it as a\n\
542832-bit object does not store the low-order 32 bits, as would be the case\n\
5429for a normal register. Therefore, @file{alpha.h} defines\n\
5430@code{TARGET_CAN_CHANGE_MODE_CLASS} to return:\n\
5431\n\
5432@smallexample\n\
5433(GET_MODE_SIZE (from) == GET_MODE_SIZE (to)\n\
5434 || !reg_classes_intersect_p (FLOAT_REGS, rclass))\n\
5435@end smallexample\n\
5436\n\
5437Even if storing from a register in mode @var{to} would be valid,\n\
5438if both @var{from} and @code{raw_reg_mode} for @var{rclass} are wider\n\
5439than @code{word_mode}, then we must prevent @var{to} narrowing the\n\
5440mode. This happens when the middle-end assumes that it can load\n\
5441or store pieces of an @var{N}-word pseudo, and that the pseudo will\n\
5442eventually be allocated to @var{N} @code{word_mode} hard registers.\n\
5443Failure to prevent this kind of mode change will result in the\n\
5444entire @code{raw_reg_mode} being modified instead of the partial\n\
5445value that the middle-end intended.",
5446 bool, (machine_mode from, machine_mode to, reg_class_t rclass),
5447 hook_bool_mode_mode_reg_class_t_true)
5448
5074a1f8
VM
5449/* Change pseudo allocno class calculated by IRA. */
5450DEFHOOK
5451(ira_change_pseudo_allocno_class,
5452 "A target hook which can change allocno class for given pseudo from\n\
31e2b5a3 5453 allocno and best class calculated by IRA.\n\
5074a1f8
VM
5454 \n\
5455 The default version of this target hook always returns given class.",
31e2b5a3 5456 reg_class_t, (int, reg_class_t, reg_class_t),
5074a1f8
VM
5457 default_ira_change_pseudo_allocno_class)
5458
55a2c322
VM
5459/* Return true if we use LRA instead of reload. */
5460DEFHOOK
5461(lra_p,
4d3907c2
ML
5462 "A target hook which returns true if we use LRA instead of reload pass.\n\
5463\n\
5464The default version of this target hook returns true. New ports\n\
5465should use LRA, and existing ports are encouraged to convert.",
55a2c322
VM
5466 bool, (void),
5467 default_lra_p)
5468
5469/* Return register priority of given hard regno for the current target. */
5470DEFHOOK
5471(register_priority,
4d3907c2
ML
5472 "A target hook which returns the register priority number to which the\n\
5473register @var{hard_regno} belongs to. The bigger the number, the\n\
5474more preferable the hard register usage (when all other conditions are\n\
5475the same). This hook can be used to prefer some hard register over\n\
5476others in LRA. For example, some x86-64 register usage needs\n\
5477additional prefix which makes instructions longer. The hook can\n\
5478return lower priority number for such registers make them less favorable\n\
5479and as result making the generated code smaller.\n\
5480\n\
5481The default version of this target hook returns always zero.",
55a2c322
VM
5482 int, (int),
5483 default_register_priority)
5484
3b9ceb4b
VM
5485/* Return true if we need register usage leveling. */
5486DEFHOOK
5487(register_usage_leveling_p,
4d3907c2
ML
5488 "A target hook which returns true if we need register usage leveling.\n\
5489That means if a few hard registers are equally good for the\n\
5490assignment, we choose the least used hard register. The register\n\
5491usage leveling may be profitable for some targets. Don't use the\n\
5492usage leveling for targets with conditional execution or targets\n\
5493with big register files as it hurts if-conversion and cross-jumping\n\
5494optimizations.\n\
5495\n\
5496The default version of this target hook returns always false.",
3b9ceb4b
VM
5497 bool, (void),
5498 default_register_usage_leveling_p)
5499
55a2c322
VM
5500/* Return true if maximal address displacement can be different. */
5501DEFHOOK
5502(different_addr_displacement_p,
4d3907c2
ML
5503 "A target hook which returns true if an address with the same structure\n\
5504can have different maximal legitimate displacement. For example, the\n\
5505displacement can depend on memory mode or on operand combinations in\n\
5506the insn.\n\
5507\n\
5508The default version of this target hook returns always false.",
55a2c322
VM
5509 bool, (void),
5510 default_different_addr_displacement_p)
5511
5512/* Determine class for spilling pseudos of given mode into registers
5513 instead of memory. */
5514DEFHOOK
5515(spill_class,
4d3907c2
ML
5516 "This hook defines a class of registers which could be used for spilling\n\
5517pseudos of the given mode and class, or @code{NO_REGS} if only memory\n\
5518should be used. Not defining this hook is equivalent to returning\n\
5519@code{NO_REGS} for all inputs.",
ef4bddc2 5520 reg_class_t, (reg_class_t, machine_mode),
55a2c322
VM
5521 NULL)
5522
e93f30a6
VM
5523/* Determine an additional allocno class. */
5524DEFHOOK
5525(additional_allocno_class_p,
4d3907c2
ML
5526 "This hook should return @code{true} if given class of registers should\n\
5527be an allocno class in any way. Usually RA uses only one register\n\
5528class from all classes containing the same register set. In some\n\
5529complicated cases, you need to have two or more such classes as\n\
5530allocno ones for RA correct work. Not defining this hook is\n\
5531equivalent to returning @code{false} for all inputs.",
e93f30a6
VM
5532 bool, (reg_class_t),
5533 hook_bool_reg_class_t_false)
5534
42e37616
DM
5535DEFHOOK
5536(cstore_mode,
4d3907c2
ML
5537 "This hook defines the machine mode to use for the boolean result of\n\
5538conditional store patterns. The ICODE argument is the instruction code\n\
5539for the cstore being performed. Not definiting this hook is the same\n\
5540as accepting the mode encoded into operand 0 of the cstore expander\n\
5541patterns.",
7cc237a6 5542 scalar_int_mode, (enum insn_code icode),
42e37616
DM
5543 default_cstore_mode)
5544
b4ff394c
PH
5545/* This target hook allows the backend to compute the register pressure
5546 classes to use. */
5547DEFHOOK
5548(compute_pressure_classes,
4d3907c2
ML
5549 "A target hook which lets a backend compute the set of pressure classes to\n\
5550be used by those optimization passes which take register pressure into\n\
5551account, as opposed to letting IRA compute them. It returns the number of\n\
5552register classes stored in the array @var{pressure_classes}.",
b4ff394c
PH
5553 int, (enum reg_class *pressure_classes), NULL)
5554
d9886a9e
L
5555/* True if a structure, union or array with MODE containing FIELD should
5556 be accessed using BLKmode. */
5557DEFHOOK
5558(member_type_forces_blk,
673c2f63
JM
5559 "Return true if a structure, union or array containing @var{field} should\n\
5560be accessed using @code{BLKMODE}.\n\
5561\n\
5562If @var{field} is the only field in the structure, @var{mode} is its\n\
5563mode, otherwise @var{mode} is VOIDmode. @var{mode} is provided in the\n\
5564case where structures of one field would require the structure's mode to\n\
5565retain the field's mode.\n\
5566\n\
5567Normally, this is not needed.",
ef4bddc2 5568 bool, (const_tree field, machine_mode mode),
d9886a9e
L
5569 default_member_type_forces_blk)
5570
e53b6e56 5571/* See tree-ssa-math-opts.cc:divmod_candidate_p for conditions
e72531b9
PK
5572 that gate the divod transform. */
5573DEFHOOK
5574(expand_divmod_libfunc,
5575 "Define this hook for enabling divmod transform if the port does not have\n\
4d3907c2 5576hardware divmod insn but defines target-specific divmod libfuncs.",
e72531b9
PK
5577 void, (rtx libfunc, machine_mode mode, rtx op0, rtx op1, rtx *quot, rtx *rem),
5578 NULL)
5579
38f8b050
JR
5580/* Return the class for a secondary reload, and fill in extra information. */
5581DEFHOOK
5582(secondary_reload,
673c2f63
JM
5583 "Many machines have some registers that cannot be copied directly to or\n\
5584from memory or even from other types of registers. An example is the\n\
5585@samp{MQ} register, which on most machines, can only be copied to or\n\
5586from general registers, but not memory. Below, we shall be using the\n\
5587term 'intermediate register' when a move operation cannot be performed\n\
5588directly, but has to be done by copying the source into the intermediate\n\
5589register first, and then copying the intermediate register to the\n\
5590destination. An intermediate register always has the same mode as\n\
5591source and destination. Since it holds the actual value being copied,\n\
5592reload might apply optimizations to re-use an intermediate register\n\
5593and eliding the copy from the source when it can determine that the\n\
5594intermediate register still holds the required value.\n\
5595\n\
5596Another kind of secondary reload is required on some machines which\n\
5597allow copying all registers to and from memory, but require a scratch\n\
5598register for stores to some memory locations (e.g., those with symbolic\n\
5599address on the RT, and those with certain symbolic address on the SPARC\n\
5600when compiling PIC)@. Scratch registers need not have the same mode\n\
5601as the value being copied, and usually hold a different value than\n\
5602that being copied. Special patterns in the md file are needed to\n\
5603describe how the copy is performed with the help of the scratch register;\n\
5604these patterns also describe the number, register class(es) and mode(s)\n\
5605of the scratch register(s).\n\
5606\n\
5607In some cases, both an intermediate and a scratch register are required.\n\
5608\n\
5609For input reloads, this target hook is called with nonzero @var{in_p},\n\
5610and @var{x} is an rtx that needs to be copied to a register of class\n\
5611@var{reload_class} in @var{reload_mode}. For output reloads, this target\n\
5612hook is called with zero @var{in_p}, and a register of class @var{reload_class}\n\
5613needs to be copied to rtx @var{x} in @var{reload_mode}.\n\
5614\n\
5615If copying a register of @var{reload_class} from/to @var{x} requires\n\
5616an intermediate register, the hook @code{secondary_reload} should\n\
5617return the register class required for this intermediate register.\n\
5618If no intermediate register is required, it should return NO_REGS.\n\
5619If more than one intermediate register is required, describe the one\n\
5620that is closest in the copy chain to the reload register.\n\
5621\n\
5622If scratch registers are needed, you also have to describe how to\n\
5623perform the copy from/to the reload register to/from this\n\
5624closest intermediate register. Or if no intermediate register is\n\
5625required, but still a scratch register is needed, describe the\n\
5626copy from/to the reload register to/from the reload operand @var{x}.\n\
5627\n\
5628You do this by setting @code{sri->icode} to the instruction code of a pattern\n\
5629in the md file which performs the move. Operands 0 and 1 are the output\n\
5630and input of this copy, respectively. Operands from operand 2 onward are\n\
5631for scratch operands. These scratch operands must have a mode, and a\n\
5632single-register-class\n\
5633@c [later: or memory]\n\
5634output constraint.\n\
5635\n\
5636When an intermediate register is used, the @code{secondary_reload}\n\
5637hook will be called again to determine how to copy the intermediate\n\
5638register to/from the reload operand @var{x}, so your hook must also\n\
5639have code to handle the register class of the intermediate operand.\n\
5640\n\
5641@c [For later: maybe we'll allow multi-alternative reload patterns -\n\
5642@c the port maintainer could name a mov<mode> pattern that has clobbers -\n\
5643@c and match the constraints of input and output to determine the required\n\
5644@c alternative. A restriction would be that constraints used to match\n\
5645@c against reloads registers would have to be written as register class\n\
5646@c constraints, or we need a new target macro / hook that tells us if an\n\
5647@c arbitrary constraint can match an unknown register of a given class.\n\
5648@c Such a macro / hook would also be useful in other places.]\n\
5649\n\
5650\n\
5651@var{x} might be a pseudo-register or a @code{subreg} of a\n\
5652pseudo-register, which could either be in a hard register or in memory.\n\
5653Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is\n\
5654in memory and the hard register number if it is in a register.\n\
5655\n\
5656Scratch operands in memory (constraint @code{\"=m\"} / @code{\"=&m\"}) are\n\
5657currently not supported. For the time being, you will have to continue\n\
f15643d4 5658to use @code{TARGET_SECONDARY_MEMORY_NEEDED} for that purpose.\n\
673c2f63
JM
5659\n\
5660@code{copy_cost} also uses this target hook to find out how values are\n\
5661copied. If you want it to include some extra cost for the need to allocate\n\
5662(a) scratch register(s), set @code{sri->extra_cost} to the additional cost.\n\
5663Or if two dependent moves are supposed to have a lower cost than the sum\n\
5664of the individual moves due to expected fortuitous scheduling and/or special\n\
5665forwarding logic, you can set @code{sri->extra_cost} to a negative amount.",
a87cf97e 5666 reg_class_t,
ef4bddc2 5667 (bool in_p, rtx x, reg_class_t reload_class, machine_mode reload_mode,
38f8b050
JR
5668 secondary_reload_info *sri),
5669 default_secondary_reload)
5670
f15643d4
RS
5671DEFHOOK
5672(secondary_memory_needed,
5673 "Certain machines have the property that some registers cannot be copied\n\
5674to some other registers without using memory. Define this hook on\n\
5675those machines to return true if objects of mode @var{m} in registers\n\
5676of @var{class1} can only be copied to registers of class @var{class2} by\n\
5677 storing a register of @var{class1} into memory and loading that memory\n\
5678location into a register of @var{class2}. The default definition returns\n\
5679false for all inputs.",
5680 bool, (machine_mode mode, reg_class_t class1, reg_class_t class2),
5681 hook_bool_mode_reg_class_t_reg_class_t_false)
5682
94e23f53
RS
5683DEFHOOK
5684(secondary_memory_needed_mode,
f15643d4 5685 "If @code{TARGET_SECONDARY_MEMORY_NEEDED} tells the compiler to use memory\n\
94e23f53
RS
5686when moving between two particular registers of mode @var{mode},\n\
5687this hook specifies the mode that the memory should have.\n\
5688\n\
5689The default depends on @code{TARGET_LRA_P}. Without LRA, the default\n\
5690is to use a word-sized mode for integral modes that are smaller than a\n\
5691a word. This is right thing to do on most machines because it ensures\n\
5692that all bits of the register are copied and prevents accesses to the\n\
5693registers in a narrower mode, which some machines prohibit for\n\
5694floating-point registers.\n\
5695\n\
5696However, this default behavior is not correct on some machines, such as\n\
5697the DEC Alpha, that store short integers in floating-point registers\n\
5698differently than in integer registers. On those machines, the default\n\
5699widening will not work correctly and you must define this hook to\n\
e53b6e56 5700suppress that widening in some cases. See the file @file{alpha.cc} for\n\
94e23f53
RS
5701details.\n\
5702\n\
5703With LRA, the default is to use @var{mode} unmodified.",
5704 machine_mode, (machine_mode mode),
5705 default_secondary_memory_needed_mode)
5706
fba42e24
AS
5707/* Given an rtx X being reloaded into a reg required to be in class CLASS,
5708 return the class of reg to actually use. */
5709DEFHOOK
5710(preferred_reload_class,
673c2f63
JM
5711 "A target hook that places additional restrictions on the register class\n\
5712to use when it is necessary to copy value @var{x} into a register in class\n\
5713@var{rclass}. The value is a register class; perhaps @var{rclass}, or perhaps\n\
5714another, smaller class.\n\
5715\n\
5716The default version of this hook always returns value of @code{rclass} argument.\n\
5717\n\
5718Sometimes returning a more restrictive class makes better code. For\n\
5719example, on the 68000, when @var{x} is an integer constant that is in range\n\
5720for a @samp{moveq} instruction, the value of this macro is always\n\
5721@code{DATA_REGS} as long as @var{rclass} includes the data registers.\n\
5722Requiring a data register guarantees that a @samp{moveq} will be used.\n\
5723\n\
5724One case where @code{TARGET_PREFERRED_RELOAD_CLASS} must not return\n\
5725@var{rclass} is if @var{x} is a legitimate constant which cannot be\n\
5726loaded into some register class. By returning @code{NO_REGS} you can\n\
5727force @var{x} into a memory location. For example, rs6000 can load\n\
5728immediate values into general-purpose registers, but does not have an\n\
5729instruction for loading an immediate value into a floating-point\n\
5730register, so @code{TARGET_PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when\n\
5731@var{x} is a floating-point constant. If the constant can't be loaded\n\
5732into any kind of register, code generation will be better if\n\
5733@code{TARGET_LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead\n\
5734of using @code{TARGET_PREFERRED_RELOAD_CLASS}.\n\
5735\n\
5736If an insn has pseudos in it after register allocation, reload will go\n\
5737through the alternatives and call repeatedly @code{TARGET_PREFERRED_RELOAD_CLASS}\n\
5738to find the best one. Returning @code{NO_REGS}, in this case, makes\n\
5739reload add a @code{!} in front of the constraint: the x86 back-end uses\n\
5740this feature to discourage usage of 387 registers when math is done in\n\
5741the SSE registers (and vice versa).",
fba42e24
AS
5742 reg_class_t,
5743 (rtx x, reg_class_t rclass),
5744 default_preferred_reload_class)
5745
abd26bfb
AS
5746/* Like TARGET_PREFERRED_RELOAD_CLASS, but for output reloads instead of
5747 input reloads. */
5748DEFHOOK
5749(preferred_output_reload_class,
673c2f63
JM
5750 "Like @code{TARGET_PREFERRED_RELOAD_CLASS}, but for output reloads instead of\n\
5751input reloads.\n\
5752\n\
5753The default version of this hook always returns value of @code{rclass}\n\
5754argument.\n\
5755\n\
5756You can also use @code{TARGET_PREFERRED_OUTPUT_RELOAD_CLASS} to discourage\n\
5757reload from using some alternatives, like @code{TARGET_PREFERRED_RELOAD_CLASS}.",
abd26bfb
AS
5758 reg_class_t,
5759 (rtx x, reg_class_t rclass),
5760 default_preferred_output_reload_class)
5761
5cce8171
RS
5762DEFHOOK
5763(select_early_remat_modes,
5764 "On some targets, certain modes cannot be held in registers around a\n\
5765standard ABI call and are relatively expensive to spill to the stack.\n\
5766The early rematerialization pass can help in such cases by aggressively\n\
5767recomputing values after calls, so that they don't need to be spilled.\n\
5768\n\
5769This hook returns the set of such modes by setting the associated bits\n\
5770in @var{modes}. The default implementation selects no modes, which has\n\
5771the effect of disabling the early rematerialization pass.",
5772 void, (sbitmap modes),
5773 default_select_early_remat_modes)
5774
07b8f0a8
AS
5775DEFHOOK
5776(class_likely_spilled_p,
673c2f63
JM
5777 "A target hook which returns @code{true} if pseudos that have been assigned\n\
5778to registers of class @var{rclass} would likely be spilled because\n\
5779registers of @var{rclass} are needed for spill registers.\n\
5780\n\
5781The default version of this target hook returns @code{true} if @var{rclass}\n\
5782has exactly one register and @code{false} otherwise. On most machines, this\n\
5783default should be used. For generally register-starved machines, such as\n\
5784i386, or machines with right register constraints, such as SH, this hook\n\
5785can be used to avoid excessive spilling.\n\
5786\n\
5787This hook is also used by some of the global intra-procedural code\n\
5788transformations to throtle code motion, to avoid increasing register\n\
5789pressure.",
07b8f0a8
AS
5790 bool, (reg_class_t rclass),
5791 default_class_likely_spilled_p)
5792
a8c44c52
AS
5793/* Return the maximum number of consecutive registers
5794 needed to represent mode MODE in a register of class RCLASS. */
5795DEFHOOK
5796(class_max_nregs,
673c2f63
JM
5797 "A target hook returns the maximum number of consecutive registers\n\
5798of class @var{rclass} needed to hold a value of mode @var{mode}.\n\
5799\n\
c43f4279
RS
5800This is closely related to the macro @code{TARGET_HARD_REGNO_NREGS}.\n\
5801In fact, the value returned by @code{TARGET_CLASS_MAX_NREGS (@var{rclass},\n\
673c2f63 5802@var{mode})} target hook should be the maximum value of\n\
c43f4279 5803@code{TARGET_HARD_REGNO_NREGS (@var{regno}, @var{mode})} for all @var{regno}\n\
673c2f63
JM
5804values in the class @var{rclass}.\n\
5805\n\
5806This target hook helps control the handling of multiple-word values\n\
5807in the reload pass.\n\
5808\n\
5809The default version of this target hook returns the size of @var{mode}\n\
5810in words.",
ef4bddc2 5811 unsigned char, (reg_class_t rclass, machine_mode mode),
a8c44c52
AS
5812 default_class_max_nregs)
5813
5f286f4a
YQ
5814DEFHOOK
5815(preferred_rename_class,
4d3907c2
ML
5816 "A target hook that places additional preference on the register\n\
5817class to use when it is necessary to rename a register in class\n\
5818@var{rclass} to another class, or perhaps @var{NO_REGS}, if no\n\
5819preferred register class is found or hook @code{preferred_rename_class}\n\
5820is not implemented.\n\
5821Sometimes returning a more restrictive class makes better code. For\n\
5822example, on ARM, thumb-2 instructions using @code{LO_REGS} may be\n\
5823smaller than instructions using @code{GENERIC_REGS}. By returning\n\
5824@code{LO_REGS} from @code{preferred_rename_class}, code size can\n\
5825be reduced.",
5f286f4a
YQ
5826 reg_class_t, (reg_class_t rclass),
5827 default_preferred_rename_class)
5828
d6220b11
KK
5829/* This target hook allows the backend to avoid unsafe substitution
5830 during register allocation. */
5831DEFHOOK
5832(cannot_substitute_mem_equiv_p,
5833 "A target hook which returns @code{true} if @var{subst} can't\n\
5834substitute safely pseudos with equivalent memory values during\n\
5835register allocation.\n\
5836The default version of this target hook returns @code{false}.\n\
5837On most machines, this default should be used. For generally\n\
5838machines with non orthogonal register usage for addressing, such\n\
5839as SH, this hook can be used to avoid excessive spilling.",
5840 bool, (rtx subst),
5841 hook_bool_rtx_false)
5842
14133a4d
KK
5843/* This target hook allows the backend to legitimize base plus
5844 displacement addressing. */
5845DEFHOOK
5846(legitimize_address_displacement,
9005477f
RS
5847 "This hook tries to split address offset @var{orig_offset} into\n\
5848two parts: one that should be added to the base address to create\n\
5849a local anchor point, and an additional offset that can be applied\n\
5850to the anchor to address a value of mode @var{mode}. The idea is that\n\
5851the local anchor could be shared by other accesses to nearby locations.\n\
5852\n\
5853The hook returns true if it succeeds, storing the offset of the\n\
5854anchor from the base in @var{offset1} and the offset of the final address\n\
5855from the anchor in @var{offset2}. The default implementation returns false.",
5856 bool, (rtx *offset1, rtx *offset2, poly_int64 orig_offset, machine_mode mode),
14133a4d
KK
5857 default_legitimize_address_displacement)
5858
38f8b050
JR
5859/* This target hook allows the backend to perform additional
5860 processing while initializing for variable expansion. */
5861DEFHOOK
5862(expand_to_rtl_hook,
673c2f63
JM
5863 "This hook is called just before expansion into rtl, allowing the target\n\
5864to perform additional initializations or analysis before the expansion.\n\
5865For example, the rs6000 port uses it to allocate a scratch stack slot\n\
5866for use in copying SDmode values between memory and floating point\n\
5867registers whenever the function being expanded has any SDmode\n\
5868usage.",
38f8b050
JR
5869 void, (void),
5870 hook_void_void)
5871
5872/* This target hook allows the backend to perform additional
5873 instantiations on rtx that are not actually in insns yet,
5874 but will be later. */
5875DEFHOOK
5876(instantiate_decls,
673c2f63
JM
5877 "This hook allows the backend to perform additional instantiations on rtl\n\
5878that are not actually in any insns yet, but will be later.",
38f8b050
JR
5879 void, (void),
5880 hook_void_void)
5881
c43f4279
RS
5882DEFHOOK
5883(hard_regno_nregs,
5884 "This hook returns the number of consecutive hard registers, starting\n\
5885at register number @var{regno}, required to hold a value of mode\n\
5886@var{mode}. This hook must never return zero, even if a register\n\
5887cannot hold the requested mode - indicate that with\n\
0d803030
RS
5888@code{TARGET_HARD_REGNO_MODE_OK} and/or\n\
5889@code{TARGET_CAN_CHANGE_MODE_CLASS} instead.\n\
c43f4279
RS
5890\n\
5891The default definition returns the number of words in @var{mode}.",
5892 unsigned int, (unsigned int regno, machine_mode mode),
5893 default_hard_regno_nregs)
5894
f939c3e6
RS
5895DEFHOOK
5896(hard_regno_mode_ok,
5897 "This hook returns true if it is permissible to store a value\n\
5898of mode @var{mode} in hard register number @var{regno} (or in several\n\
5899registers starting with that one). The default definition returns true\n\
5900unconditionally.\n\
5901\n\
5902You need not include code to check for the numbers of fixed registers,\n\
5903because the allocation mechanism considers them to be always occupied.\n\
5904\n\
5905@cindex register pairs\n\
5906On some machines, double-precision values must be kept in even/odd\n\
5907register pairs. You can implement that by defining this hook to reject\n\
5908odd register numbers for such modes.\n\
5909\n\
5910The minimum requirement for a mode to be OK in a register is that the\n\
5911@samp{mov@var{mode}} instruction pattern support moves between the\n\
5912register and other hard register in the same class and that moving a\n\
5913value into the register and back out not alter it.\n\
5914\n\
5915Since the same instruction used to move @code{word_mode} will work for\n\
5916all narrower integer modes, it is not necessary on any machine for\n\
5917this hook to distinguish between these modes, provided you define\n\
5918patterns @samp{movhi}, etc., to take advantage of this. This is\n\
5919useful because of the interaction between @code{TARGET_HARD_REGNO_MODE_OK}\n\
99e1629f
RS
5920and @code{TARGET_MODES_TIEABLE_P}; it is very desirable for all integer\n\
5921modes to be tieable.\n\
f939c3e6
RS
5922\n\
5923Many machines have special registers for floating point arithmetic.\n\
5924Often people assume that floating point machine modes are allowed only\n\
5925in floating point registers. This is not true. Any registers that\n\
5926can hold integers can safely @emph{hold} a floating point machine\n\
5927mode, whether or not floating arithmetic can be done on it in those\n\
5928registers. Integer move instructions can be used to move the values.\n\
5929\n\
5930On some machines, though, the converse is true: fixed-point machine\n\
5931modes may not go in floating registers. This is true if the floating\n\
5932registers normalize any value stored in them, because storing a\n\
5933non-floating value there would garble it. In this case,\n\
5934@code{TARGET_HARD_REGNO_MODE_OK} should reject fixed-point machine modes in\n\
5935floating registers. But if the floating registers do not automatically\n\
5936normalize, if you can store any bit pattern in one and retrieve it\n\
5937unchanged without a trap, then any machine mode may go in a floating\n\
5938register, so you can define this hook to say so.\n\
5939\n\
5940The primary significance of special floating registers is rather that\n\
5941they are the registers acceptable in floating point arithmetic\n\
5942instructions. However, this is of no concern to\n\
5943@code{TARGET_HARD_REGNO_MODE_OK}. You handle it by writing the proper\n\
5944constraints for those instructions.\n\
5945\n\
5946On some machines, the floating registers are especially slow to access,\n\
5947so that it is better to store a value in a stack frame than in such a\n\
5948register if floating point arithmetic is not being done. As long as the\n\
5949floating registers are not in class @code{GENERAL_REGS}, they will not\n\
5950be used unless some pattern's constraint asks for one.",
5951 bool, (unsigned int regno, machine_mode mode),
5952 hook_bool_uint_mode_true)
5953
99e1629f
RS
5954DEFHOOK
5955(modes_tieable_p,
5956 "This hook returns true if a value of mode @var{mode1} is accessible\n\
5957in mode @var{mode2} without copying.\n\
5958\n\
5959If @code{TARGET_HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and\n\
5960@code{TARGET_HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always\n\
5961the same for any @var{r}, then\n\
5962@code{TARGET_MODES_TIEABLE_P (@var{mode1}, @var{mode2})}\n\
5963should be true. If they differ for any @var{r}, you should define\n\
5964this hook to return false unless some other mechanism ensures the\n\
5965accessibility of the value in a narrower mode.\n\
5966\n\
5967You should define this hook to return true in as many cases as\n\
5968possible since doing so will allow GCC to perform better register\n\
5969allocation. The default definition returns true unconditionally.",
5970 bool, (machine_mode mode1, machine_mode mode2),
5971 hook_bool_mode_mode_true)
5972
38f8b050
JR
5973/* Return true if is OK to use a hard register REGNO as scratch register
5974 in peephole2. */
5975DEFHOOK
5976(hard_regno_scratch_ok,
673c2f63
JM
5977 "This target hook should return @code{true} if it is OK to use a hard register\n\
5978@var{regno} as scratch reg in peephole2.\n\
5979\n\
5980One common use of this macro is to prevent using of a register that\n\
5981is not saved by a prologue in an interrupt handler.\n\
5982\n\
5983The default version of this hook always returns @code{true}.",
38f8b050
JR
5984 bool, (unsigned int regno),
5985 default_hard_regno_scratch_ok)
5986
80ec73f4
RS
5987DEFHOOK
5988(hard_regno_call_part_clobbered,
6ee2cc70
RS
5989 "ABIs usually specify that calls must preserve the full contents\n\
5990of a particular register, or that calls can alter any part of a\n\
5991particular register. This information is captured by the target macro\n\
5992@code{CALL_REALLY_USED_REGISTERS}. However, some ABIs specify that calls\n\
5993must preserve certain bits of a particular register but can alter others.\n\
5994This hook should return true if this applies to at least one of the\n\
5995registers in @samp{(reg:@var{mode} @var{regno})}, and if as a result the\n\
5996call would alter part of the @var{mode} value. For example, if a call\n\
5997preserves the low 32 bits of a 64-bit hard register @var{regno} but can\n\
5998clobber the upper 32 bits, this hook should return true for a 64-bit mode\n\
5999but false for a 32-bit mode.\n\
6000\n\
6001The value of @var{abi_id} comes from the @code{predefined_function_abi}\n\
6002structure that describes the ABI of the call; see the definition of the\n\
6003structure for more details. If (as is usual) the target uses the same ABI\n\
6004for all functions in a translation unit, @var{abi_id} is always 0.\n\
80ec73f4
RS
6005\n\
6006The default implementation returns false, which is correct\n\
6007for targets that don't have partly call-clobbered registers.",
6ee2cc70
RS
6008 bool, (unsigned int abi_id, unsigned int regno, machine_mode mode),
6009 hook_bool_uint_uint_mode_false)
473574ee 6010
e8cecccc
ML
6011DEFHOOK
6012(get_multilib_abi_name,
6013 "This hook returns name of multilib ABI name.",
6014 const char *, (void),
6015 hook_constcharptr_void_null)
6016
38f8b050
JR
6017/* Return the smallest number of different values for which it is best to
6018 use a jump-table instead of a tree of conditional branches. */
6019DEFHOOK
6020(case_values_threshold,
673c2f63
JM
6021 "This function return the smallest number of different values for which it\n\
6022is best to use a jump-table instead of a tree of conditional branches.\n\
6023The default is four for machines with a @code{casesi} instruction and\n\
6024five otherwise. This is best for most machines.",
38f8b050
JR
6025 unsigned int, (void),
6026 default_case_values_threshold)
6027
2a31c321
RS
6028DEFHOOK
6029(starting_frame_offset,
6030 "This hook returns the offset from the frame pointer to the first local\n\
6031variable slot to be allocated. If @code{FRAME_GROWS_DOWNWARD}, it is the\n\
6032offset to @emph{end} of the first slot allocated, otherwise it is the\n\
6033offset to @emph{beginning} of the first slot allocated. The default\n\
6034implementation returns 0.",
6035 HOST_WIDE_INT, (void),
6036 hook_hwi_void_0)
6037
29eb9a44
BE
6038/* Optional callback to advise the target to compute the frame layout. */
6039DEFHOOK
6040(compute_frame_layout,
6041 "This target hook is called once each time the frame layout needs to be\n\
6042recalculated. The calculations can be cached by the target and can then\n\
6043be used by @code{INITIAL_ELIMINATION_OFFSET} instead of re-computing the\n\
6044layout on every invocation of that hook. This is particularly useful\n\
6045for targets that have an expensive frame layout function. Implementing\n\
6046this callback is optional.",
6047 void, (void),
6048 hook_void_void)
6049
53680238 6050/* Return true if a function must have and use a frame pointer. */
38f8b050
JR
6051DEFHOOK
6052(frame_pointer_required,
673c2f63
JM
6053 "This target hook should return @code{true} if a function must have and use\n\
6054a frame pointer. This target hook is called in the reload pass. If its return\n\
6055value is @code{true} the function will have a frame pointer.\n\
6056\n\
6057This target hook can in principle examine the current function and decide\n\
6058according to the facts, but on most machines the constant @code{false} or the\n\
6059constant @code{true} suffices. Use @code{false} when the machine allows code\n\
6060to be generated with no frame pointer, and doing so saves some time or space.\n\
6061Use @code{true} when there is no possible advantage to avoiding a frame\n\
6062pointer.\n\
6063\n\
6064In certain cases, the compiler does not know how to produce valid code\n\
6065without a frame pointer. The compiler recognizes those cases and\n\
6066automatically gives the function a frame pointer regardless of what\n\
53680238 6067@code{targetm.frame_pointer_required} returns. You don't need to worry about\n\
673c2f63
JM
6068them.\n\
6069\n\
6070In a function that does not require a frame pointer, the frame pointer\n\
6071register can be allocated for ordinary usage, unless you mark it as a\n\
6072fixed register. See @code{FIXED_REGISTERS} for more information.\n\
6073\n\
6074Default return value is @code{false}.",
38f8b050
JR
6075 bool, (void),
6076 hook_bool_void_false)
6077
6078/* Returns true if the compiler is allowed to try to replace register number
6079 from-reg with register number to-reg. */
6080DEFHOOK
6081(can_eliminate,
53680238 6082 "This target hook should return @code{true} if the compiler is allowed to\n\
673c2f63 6083try to replace register number @var{from_reg} with register number\n\
53680238
BE
6084@var{to_reg}. This target hook will usually be @code{true}, since most of the\n\
6085cases preventing register elimination are things that the compiler already\n\
673c2f63
JM
6086knows about.\n\
6087\n\
6088Default return value is @code{true}.",
38f8b050
JR
6089 bool, (const int from_reg, const int to_reg),
6090 hook_bool_const_int_const_int_true)
6091
5efd84c5
NF
6092/* Modify any or all of fixed_regs, call_used_regs, global_regs,
6093 reg_names, and reg_class_contents to account of the vagaries of the
6094 target. */
6095DEFHOOK
6096(conditional_register_usage,
673c2f63
JM
6097 "This hook may conditionally modify five variables\n\
6098@code{fixed_regs}, @code{call_used_regs}, @code{global_regs},\n\
6099@code{reg_names}, and @code{reg_class_contents}, to take into account\n\
6100any dependence of these register sets on target flags. The first three\n\
527a3750 6101of these are of type @code{char []} (interpreted as boolean vectors).\n\
673c2f63
JM
6102@code{global_regs} is a @code{const char *[]}, and\n\
6103@code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is\n\
6104called, @code{fixed_regs}, @code{call_used_regs},\n\
6105@code{reg_class_contents}, and @code{reg_names} have been initialized\n\
6106from @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS},\n\
6107@code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively.\n\
6108@code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}},\n\
6109@option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}\n\
6110command options have been applied.\n\
6111\n\
6112@cindex disabling certain registers\n\
6113@cindex controlling register usage\n\
6114If the usage of an entire class of registers depends on the target\n\
6115flags, you may indicate this to GCC by using this macro to modify\n\
6116@code{fixed_regs} and @code{call_used_regs} to 1 for each of the\n\
b48e9677
RS
6117registers in the classes which should not be used by GCC@. Also make\n\
6118@code{define_register_constraint}s return @code{NO_REGS} for constraints\n\
6119that shouldn't be used.\n\
673c2f63
JM
6120\n\
6121(However, if this class is not included in @code{GENERAL_REGS} and all\n\
6122of the insn patterns whose constraints permit this class are\n\
6123controlled by target switches, then GCC will automatically avoid using\n\
6124these registers when the target switches are opposed to them.)",
5efd84c5
NF
6125 void, (void),
6126 hook_void_void)
6127
8c1dd970 6128DEFHOOK
2c25083e
TC
6129(stack_clash_protection_alloca_probe_range,
6130 "Some targets have an ABI defined interval for which no probing needs to be done.\n\
4d3907c2 6131When a probe does need to be done this same interval is used as the probe distance\n\
2c25083e
TC
6132up when doing stack clash protection for alloca.\n\
6133On such targets this value can be set to override the default probing up interval.\n\
4d3907c2
ML
6134Define this variable to return nonzero if such a probe range is required or zero otherwise.\n\
6135Defining this hook also requires your functions which make use of alloca to have at least 8 byes\n\
2c25083e
TC
6136of outgoing arguments. If this is not the case the stack will be corrupted.\n\
6137You need not define this macro if it would always have the value zero.",
6138 HOST_WIDE_INT, (void),
6139 default_stack_clash_protection_alloca_probe_range)
8c1dd970
JL
6140
6141
38f8b050
JR
6142/* Functions specific to the C family of frontends. */
6143#undef HOOK_PREFIX
6144#define HOOK_PREFIX "TARGET_C_"
6145HOOK_VECTOR (TARGET_C, c)
6146
6147/* ??? Documenting this hook requires a GFDL license grant. */
6148DEFHOOK_UNDOC
6149(mode_for_suffix,
6150"Return machine mode for non-standard constant literal suffix @var{c},\
6151 or VOIDmode if non-standard suffixes are unsupported.",
ef4bddc2 6152 machine_mode, (char c),
38f8b050
JR
6153 default_mode_for_suffix)
6154
42e02b20
JG
6155DEFHOOK
6156(excess_precision,
4d3907c2
ML
6157 "Return a value, with the same meaning as the C99 macro\n\
6158@code{FLT_EVAL_METHOD} that describes which excess precision should be\n\
6159applied. @var{type} is either @code{EXCESS_PRECISION_TYPE_IMPLICIT},\n\
f19a3270 6160@code{EXCESS_PRECISION_TYPE_FAST},\n\
6161@code{EXCESS_PRECISION_TYPE_STANDARD}, or\n\
6162@code{EXCESS_PRECISION_TYPE_FLOAT16}. For\n\
4d3907c2
ML
6163@code{EXCESS_PRECISION_TYPE_IMPLICIT}, the target should return which\n\
6164precision and range operations will be implictly evaluated in regardless\n\
6165of the excess precision explicitly added. For\n\
f19a3270 6166@code{EXCESS_PRECISION_TYPE_STANDARD}, \n\
6167@code{EXCESS_PRECISION_TYPE_FLOAT16}, and\n\
4d3907c2
ML
6168@code{EXCESS_PRECISION_TYPE_FAST}, the target should return the\n\
6169explicit excess precision that should be added depending on the\n\
6170value set for @option{-fexcess-precision=@r{[}standard@r{|}fast@r{]}}.\n\
6171Note that unpredictable explicit excess precision does not make sense,\n\
6172so a target should never return @code{FLT_EVAL_METHOD_UNPREDICTABLE}\n\
f19a3270 6173when @var{type} is @code{EXCESS_PRECISION_TYPE_STANDARD},\n\
6174@code{EXCESS_PRECISION_TYPE_FLOAT16} or\n\
4d3907c2 6175@code{EXCESS_PRECISION_TYPE_FAST}.",
42e02b20
JG
6176 enum flt_eval_method, (enum excess_precision_type type),
6177 default_excess_precision)
6178
38f8b050
JR
6179HOOK_VECTOR_END (c)
6180
6181/* Functions specific to the C++ frontend. */
6182#undef HOOK_PREFIX
6183#define HOOK_PREFIX "TARGET_CXX_"
6184HOOK_VECTOR (TARGET_CXX, cxx)
6185
6186/* Return the integer type used for guard variables. */
6187DEFHOOK
6188(guard_type,
673c2f63
JM
6189 "Define this hook to override the integer type used for guard variables.\n\
6190These are used to implement one-time construction of static objects. The\n\
6191default is long_long_integer_type_node.",
38f8b050
JR
6192 tree, (void),
6193 default_cxx_guard_type)
6194
6195/* Return true if only the low bit of the guard should be tested. */
6196DEFHOOK
6197(guard_mask_bit,
673c2f63
JM
6198 "This hook determines how guard variables are used. It should return\n\
6199@code{false} (the default) if the first byte should be used. A return value of\n\
6200@code{true} indicates that only the least significant bit should be used.",
38f8b050
JR
6201 bool, (void),
6202 hook_bool_void_false)
6203
6204/* Returns the size of the array cookie for an array of type. */
6205DEFHOOK
6206(get_cookie_size,
673c2f63
JM
6207 "This hook returns the size of the cookie to use when allocating an array\n\
6208whose elements have the indicated @var{type}. Assumes that it is already\n\
6209known that a cookie is needed. The default is\n\
6210@code{max(sizeof (size_t), alignof(type))}, as defined in section 2.7 of the\n\
6211IA64/Generic C++ ABI@.",
38f8b050
JR
6212 tree, (tree type),
6213 default_cxx_get_cookie_size)
6214
6215/* Returns true if the element size should be stored in the array cookie. */
6216DEFHOOK
6217(cookie_has_size,
673c2f63
JM
6218 "This hook should return @code{true} if the element size should be stored in\n\
6219array cookies. The default is to return @code{false}.",
38f8b050
JR
6220 bool, (void),
6221 hook_bool_void_false)
6222
6223/* Allows backends to perform additional processing when
6224 deciding if a class should be exported or imported. */
6225DEFHOOK
6226(import_export_class,
673c2f63
JM
6227 "If defined by a backend this hook allows the decision made to export\n\
6228class @var{type} to be overruled. Upon entry @var{import_export}\n\
6229will contain 1 if the class is going to be exported, @minus{}1 if it is going\n\
6230to be imported and 0 otherwise. This function should return the\n\
6231modified value and perform any other actions necessary to support the\n\
6232backend's targeted operating system.",
38f8b050
JR
6233 int, (tree type, int import_export), NULL)
6234
6235/* Returns true if constructors and destructors return "this". */
6236DEFHOOK
6237(cdtor_returns_this,
673c2f63
JM
6238 "This hook should return @code{true} if constructors and destructors return\n\
6239the address of the object created/destroyed. The default is to return\n\
6240@code{false}.",
38f8b050
JR
6241 bool, (void),
6242 hook_bool_void_false)
6243
6244/* Returns true if the key method for a class can be an inline
6245 function, so long as it is not declared inline in the class
6246 itself. Returning true is the behavior required by the Itanium C++ ABI. */
6247DEFHOOK
6248(key_method_may_be_inline,
673c2f63
JM
6249 "This hook returns true if the key method for a class (i.e., the method\n\
6250which, if defined in the current translation unit, causes the virtual\n\
6251table to be emitted) may be an inline function. Under the standard\n\
6252Itanium C++ ABI the key method may be an inline function so long as\n\
6253the function is not declared inline in the class definition. Under\n\
6254some variants of the ABI, an inline function can never be the key\n\
6255method. The default is to return @code{true}.",
38f8b050
JR
6256 bool, (void),
6257 hook_bool_void_true)
6258
6259DEFHOOK
6260(determine_class_data_visibility,
4d3907c2
ML
6261"@var{decl} is a virtual table, virtual table table, typeinfo object,\n\
6262or other similar implicit class data object that will be emitted with\n\
6263external linkage in this translation unit. No ELF visibility has been\n\
6264explicitly specified. If the target needs to specify a visibility\n\
6265other than that of the containing class, use this hook to set\n\
6266@code{DECL_VISIBILITY} and @code{DECL_VISIBILITY_SPECIFIED}.",
38f8b050
JR
6267 void, (tree decl),
6268 hook_void_tree)
6269
6270/* Returns true (the default) if virtual tables and other
6271 similar implicit class data objects are always COMDAT if they
6272 have external linkage. If this hook returns false, then
6273 class data for classes whose virtual table will be emitted in
6274 only one translation unit will not be COMDAT. */
6275DEFHOOK
6276(class_data_always_comdat,
673c2f63
JM
6277 "This hook returns true (the default) if virtual tables and other\n\
6278similar implicit class data objects are always COMDAT if they have\n\
6279external linkage. If this hook returns false, then class data for\n\
6280classes whose virtual table will be emitted in only one translation\n\
6281unit will not be COMDAT.",
38f8b050
JR
6282 bool, (void),
6283 hook_bool_void_true)
6284
6285/* Returns true (the default) if the RTTI for the basic types,
6286 which is always defined in the C++ runtime, should be COMDAT;
6287 false if it should not be COMDAT. */
6288DEFHOOK
6289(library_rtti_comdat,
673c2f63
JM
6290 "This hook returns true (the default) if the RTTI information for\n\
6291the basic types which is defined in the C++ runtime should always\n\
6292be COMDAT, false if it should not be COMDAT.",
38f8b050
JR
6293 bool, (void),
6294 hook_bool_void_true)
6295
6296/* Returns true if __aeabi_atexit should be used to register static
6297 destructors. */
6298DEFHOOK
6299(use_aeabi_atexit,
673c2f63
JM
6300 "This hook returns true if @code{__aeabi_atexit} (as defined by the ARM EABI)\n\
6301should be used to register static destructors when @option{-fuse-cxa-atexit}\n\
6302is in effect. The default is to return false to use @code{__cxa_atexit}.",
38f8b050
JR
6303 bool, (void),
6304 hook_bool_void_false)
6305
6306/* Returns true if target may use atexit in the same manner as
6307 __cxa_atexit to register static destructors. */
6308DEFHOOK
6309(use_atexit_for_cxa_atexit,
673c2f63
JM
6310 "This hook returns true if the target @code{atexit} function can be used\n\
6311in the same manner as @code{__cxa_atexit} to register C++ static\n\
6312destructors. This requires that @code{atexit}-registered functions in\n\
6313shared libraries are run in the correct order when the libraries are\n\
6314unloaded. The default is to return false.",
38f8b050
JR
6315 bool, (void),
6316 hook_bool_void_false)
6317
6318DEFHOOK
6319(adjust_class_at_definition,
4d3907c2
ML
6320"@var{type} is a C++ class (i.e., RECORD_TYPE or UNION_TYPE) that has just\n\
6321been defined. Use this hook to make adjustments to the class (eg, tweak\n\
6322visibility or perform any other required target modifications).",
38f8b050
JR
6323 void, (tree type),
6324 hook_void_tree)
6325
5b880ea6
RO
6326DEFHOOK
6327(decl_mangling_context,
6328 "Return target-specific mangling context of @var{decl} or @code{NULL_TREE}.",
6329 tree, (const_tree decl),
6330 hook_tree_const_tree_null)
6331
38f8b050
JR
6332HOOK_VECTOR_END (cxx)
6333
6334/* Functions and data for emulated TLS support. */
6335#undef HOOK_PREFIX
6336#define HOOK_PREFIX "TARGET_EMUTLS_"
6337HOOK_VECTOR (TARGET_EMUTLS, emutls)
6338
6339/* Name of the address and common functions. */
6340DEFHOOKPOD
6341(get_address,
673c2f63
JM
6342 "Contains the name of the helper function that uses a TLS control\n\
6343object to locate a TLS instance. The default causes libgcc's\n\
6344emulated TLS helper function to be used.",
38f8b050
JR
6345 const char *, "__builtin___emutls_get_address")
6346
6347DEFHOOKPOD
6348(register_common,
673c2f63
JM
6349 "Contains the name of the helper function that should be used at\n\
6350program startup to register TLS objects that are implicitly\n\
6351initialized to zero. If this is @code{NULL}, all TLS objects will\n\
6352have explicit initializers. The default causes libgcc's emulated TLS\n\
6353registration function to be used.",
38f8b050
JR
6354 const char *, "__builtin___emutls_register_common")
6355
6356/* Prefixes for proxy variable and template. */
6357DEFHOOKPOD
6358(var_section,
673c2f63
JM
6359 "Contains the name of the section in which TLS control variables should\n\
6360be placed. The default of @code{NULL} allows these to be placed in\n\
6361any section.",
38f8b050
JR
6362 const char *, NULL)
6363
6364DEFHOOKPOD
6365(tmpl_section,
673c2f63
JM
6366 "Contains the name of the section in which TLS initializers should be\n\
6367placed. The default of @code{NULL} allows these to be placed in any\n\
6368section.",
38f8b050
JR
6369 const char *, NULL)
6370
6371/* Prefixes for proxy variable and template. */
6372DEFHOOKPOD
6373(var_prefix,
673c2f63
JM
6374 "Contains the prefix to be prepended to TLS control variable names.\n\
6375The default of @code{NULL} uses a target-specific prefix.",
38f8b050
JR
6376 const char *, NULL)
6377
6378DEFHOOKPOD
6379(tmpl_prefix,
673c2f63
JM
6380 "Contains the prefix to be prepended to TLS initializer objects. The\n\
6381default of @code{NULL} uses a target-specific prefix.",
38f8b050
JR
6382 const char *, NULL)
6383
6384/* Function to generate field definitions of the proxy variable. */
6385DEFHOOK
6386(var_fields,
673c2f63
JM
6387 "Specifies a function that generates the FIELD_DECLs for a TLS control\n\
6388object type. @var{type} is the RECORD_TYPE the fields are for and\n\
6389@var{name} should be filled with the structure tag, if the default of\n\
6390@code{__emutls_object} is unsuitable. The default creates a type suitable\n\
6391for libgcc's emulated TLS function.",
38f8b050
JR
6392 tree, (tree type, tree *name),
6393 default_emutls_var_fields)
6394
6395/* Function to initialize a proxy variable. */
6396DEFHOOK
6397(var_init,
673c2f63
JM
6398 "Specifies a function that generates the CONSTRUCTOR to initialize a\n\
6399TLS control object. @var{var} is the TLS control object, @var{decl}\n\
6400is the TLS object and @var{tmpl_addr} is the address of the\n\
6401initializer. The default initializes libgcc's emulated TLS control object.",
38f8b050
JR
6402 tree, (tree var, tree decl, tree tmpl_addr),
6403 default_emutls_var_init)
6404
6405/* Whether we are allowed to alter the usual alignment of the
6406 proxy variable. */
6407DEFHOOKPOD
6408(var_align_fixed,
673c2f63
JM
6409 "Specifies whether the alignment of TLS control variable objects is\n\
6410fixed and should not be increased as some backends may do to optimize\n\
6411single objects. The default is false.",
38f8b050
JR
6412 bool, false)
6413
6414/* Whether we can emit debug information for TLS vars. */
6415DEFHOOKPOD
6416(debug_form_tls_address,
673c2f63
JM
6417 "Specifies whether a DWARF @code{DW_OP_form_tls_address} location descriptor\n\
6418may be used to describe emulated TLS control objects.",
38f8b050
JR
6419 bool, false)
6420
6421HOOK_VECTOR_END (emutls)
6422
6423#undef HOOK_PREFIX
6424#define HOOK_PREFIX "TARGET_OPTION_"
6425HOOK_VECTOR (TARGET_OPTION_HOOKS, target_option_hooks)
6426
7aa7f2e3
SL
6427/* Function to validate the attribute((target(...))) strings. If
6428 the option is validated, the hook should also fill in
6429 DECL_FUNCTION_SPECIFIC_TARGET in the function decl node. */
38f8b050
JR
6430DEFHOOK
6431(valid_attribute_p,
673c2f63
JM
6432 "This hook is called to parse @code{attribute(target(\"...\"))}, which\n\
6433allows setting target-specific options on individual functions.\n\
6434These function-specific options may differ\n\
6435from the options specified on the command line. The hook should return\n\
6436@code{true} if the options are valid.\n\
6437\n\
6438The hook should set the @code{DECL_FUNCTION_SPECIFIC_TARGET} field in\n\
6439the function declaration to hold a pointer to a target-specific\n\
6440@code{struct cl_target_option} structure.",
38f8b050
JR
6441 bool, (tree fndecl, tree name, tree args, int flags),
6442 default_target_option_valid_attribute_p)
6443
6444/* Function to save any extra target state in the target options structure. */
6445DEFHOOK
6446(save,
673c2f63
JM
6447 "This hook is called to save any additional target-specific information\n\
6448in the @code{struct cl_target_option} structure for function-specific\n\
bf7b5747 6449options from the @code{struct gcc_options} structure.\n\
673c2f63 6450@xref{Option file format}.",
ba948b37
JJ
6451 void, (struct cl_target_option *ptr, struct gcc_options *opts,
6452 struct gcc_options *opts_set), NULL)
38f8b050
JR
6453
6454/* Function to restore any extra target state from the target options
6455 structure. */
6456DEFHOOK
6457(restore,
673c2f63
JM
6458 "This hook is called to restore any additional target-specific\n\
6459information in the @code{struct cl_target_option} structure for\n\
bf7b5747 6460function-specific options to the @code{struct gcc_options} structure.",
ba948b37
JJ
6461 void, (struct gcc_options *opts, struct gcc_options *opts_set,
6462 struct cl_target_option *ptr), NULL)
38f8b050 6463
59913123
JJ
6464/* Function to update target-specific option information after being
6465 streamed in. */
6466DEFHOOK
6467(post_stream_in,
6468 "This hook is called to update target-specific information in the\n\
6469@code{struct cl_target_option} structure after it is streamed in from\n\
6470LTO bytecode.",
6471 void, (struct cl_target_option *ptr), NULL)
6472
38f8b050
JR
6473/* Function to print any extra target state from the target options
6474 structure. */
6475DEFHOOK
6476(print,
673c2f63
JM
6477 "This hook is called to print any additional target-specific\n\
6478information in the @code{struct cl_target_option} structure for\n\
6479function-specific options.",
38f8b050
JR
6480 void, (FILE *file, int indent, struct cl_target_option *ptr), NULL)
6481
7aa7f2e3 6482/* Function to parse arguments to be validated for #pragma target, and to
38f8b050
JR
6483 change the state if the options are valid. If the first argument is
6484 NULL, the second argument specifies the default options to use. Return
6485 true if the options are valid, and set the current state. */
56cb42ea 6486DEFHOOK
38f8b050 6487(pragma_parse,
673c2f63
JM
6488 "This target hook parses the options for @code{#pragma GCC target}, which\n\
6489sets the target-specific options for functions that occur later in the\n\
6490input stream. The options accepted should be the same as those handled by the\n\
6491@code{TARGET_OPTION_VALID_ATTRIBUTE_P} hook.",
38f8b050
JR
6492 bool, (tree args, tree pop_target),
6493 default_target_option_pragma_parse)
6494
6495/* Do option overrides for the target. */
6496DEFHOOK
6497(override,
673c2f63
JM
6498 "Sometimes certain combinations of command options do not make sense on\n\
6499a particular target machine. You can override the hook\n\
6500@code{TARGET_OPTION_OVERRIDE} to take account of this. This hooks is called\n\
6501once just after all the command options have been parsed.\n\
6502\n\
6503Don't use this hook to turn on various extra optimizations for\n\
6504@option{-O}. That is what @code{TARGET_OPTION_OPTIMIZATION} is for.\n\
6505\n\
6506If you need to do something whenever the optimization level is\n\
6507changed via the optimize attribute or pragma, see\n\
6508@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}",
38f8b050 6509 void, (void),
c5387660 6510 hook_void_void)
38f8b050 6511
3649b9b7
ST
6512/* This function returns true if DECL1 and DECL2 are versions of the same
6513 function. DECL1 and DECL2 are function versions if and only if they
6514 have the same function signature and different target specific attributes,
6515 that is, they are compiled for different target machines. */
6516DEFHOOK
6517(function_versions,
673c2f63
JM
6518 "This target hook returns @code{true} if @var{DECL1} and @var{DECL2} are\n\
6519versions of the same function. @var{DECL1} and @var{DECL2} are function\n\
6520versions if and only if they have the same function signature and\n\
6521different target specific attributes, that is, they are compiled for\n\
6522different target machines.",
3649b9b7
ST
6523 bool, (tree decl1, tree decl2),
6524 hook_bool_tree_tree_false)
6525
38f8b050
JR
6526/* Function to determine if one function can inline another function. */
6527#undef HOOK_PREFIX
6528#define HOOK_PREFIX "TARGET_"
6529DEFHOOK
6530(can_inline_p,
673c2f63
JM
6531 "This target hook returns @code{false} if the @var{caller} function\n\
6532cannot inline @var{callee}, based on target specific information. By\n\
6533default, inlining is not allowed if the callee function has function\n\
6534specific target options and the caller does not use the same options.",
38f8b050
JR
6535 bool, (tree caller, tree callee),
6536 default_target_can_inline_p)
6537
0fc60c18
KL
6538DEFHOOK
6539(update_ipa_fn_target_info,
6540 "Allow target to analyze all gimple statements for the given function to\n\
6541record and update some target specific information for inlining. A typical\n\
6542example is that a caller with one isa feature disabled is normally not\n\
6543allowed to inline a callee with that same isa feature enabled even which is\n\
6544attributed by always_inline, but with the conservative analysis on all\n\
6545statements of the callee if we are able to guarantee the callee does not\n\
6546exploit any instructions from the mismatch isa feature, it would be safe to\n\
6547allow the caller to inline the callee.\n\
6548@var{info} is one @code{unsigned int} value to record information in which\n\
6549one set bit indicates one corresponding feature is detected in the analysis,\n\
6550@var{stmt} is the statement being analyzed. Return true if target still\n\
6551need to analyze the subsequent statements, otherwise return false to stop\n\
6552subsequent analysis.\n\
6553The default version of this hook returns false.",
6554 bool, (unsigned int& info, const gimple* stmt),
6555 default_update_ipa_fn_target_info)
6556
6557DEFHOOK
6558(need_ipa_fn_target_info,
6559 "Allow target to check early whether it is necessary to analyze all gimple\n\
6560statements in the given function to update target specific information for\n\
6561inlining. See hook @code{update_ipa_fn_target_info} for usage example of\n\
6562target specific information. This hook is expected to be invoked ahead of\n\
6563the iterating with hook @code{update_ipa_fn_target_info}.\n\
6564@var{decl} is the function being analyzed, @var{info} is the same as what\n\
6565in hook @code{update_ipa_fn_target_info}, target can do one time update\n\
6566into @var{info} without iterating for some case. Return true if target\n\
6567decides to analyze all gimple statements to collect information, otherwise\n\
6568return false.\n\
6569The default version of this hook returns false.",
6570 bool, (const_tree decl, unsigned int& info),
6571 default_need_ipa_fn_target_info)
6572
63b0cb04
CB
6573DEFHOOK
6574(relayout_function,
4d3907c2
ML
6575"This target hook fixes function @var{fndecl} after attributes are processed.\n\
6576Default does nothing. On ARM, the default function's alignment is updated\n\
6577with the attribute target.",
63b0cb04
CB
6578 void, (tree fndecl),
6579 hook_void_tree)
6580
38f8b050
JR
6581HOOK_VECTOR_END (target_option)
6582
6583/* For targets that need to mark extra registers as live on entry to
6584 the function, they should define this target hook and set their
6585 bits in the bitmap passed in. */
6586DEFHOOK
6587(extra_live_on_entry,
673c2f63
JM
6588 "Add any hard registers to @var{regs} that are live on entry to the\n\
6589function. This hook only needs to be defined to provide registers that\n\
6590cannot be found by examination of FUNCTION_ARG_REGNO_P, the callee saved\n\
6591registers, STATIC_CHAIN_INCOMING_REGNUM, STATIC_CHAIN_REGNUM,\n\
6592TARGET_STRUCT_VALUE_RTX, FRAME_POINTER_REGNUM, EH_USES,\n\
6593FRAME_POINTER_REGNUM, ARG_POINTER_REGNUM, and the PIC_OFFSET_TABLE_REGNUM.",
38f8b050
JR
6594 void, (bitmap regs),
6595 hook_void_bitmap)
6596
aaeaa9a9 6597/* Targets should define this target hook to mark that non-callee clobbers are
73b3e61b
TV
6598 present in CALL_INSN_FUNCTION_USAGE for all the calls that bind to a local
6599 definition. */
aaeaa9a9
RO
6600DEFHOOKPOD
6601(call_fusage_contains_non_callee_clobbers,
73b3e61b
TV
6602 "Set to true if each call that binds to a local definition explicitly\n\
6603clobbers or sets all non-fixed registers modified by performing the call.\n\
6604That is, by the call pattern itself, or by code that might be inserted by the\n\
630ba2fd 6605linker (e.g.@: stubs, veneers, branch islands), but not including those\n\
73b3e61b
TV
6606modifiable by the callee. The affected registers may be mentioned explicitly\n\
6607in the call pattern, or included as clobbers in CALL_INSN_FUNCTION_USAGE.\n\
6608The default version of this hook is set to false. The purpose of this hook\n\
1e288103 6609is to enable the fipa-ra optimization.",
aaeaa9a9
RO
6610 bool,
6611 false)
6612
ee3d2ecd
JJ
6613/* Fill in additional registers set up by prologue into a regset. */
6614DEFHOOK
6615(set_up_by_prologue,
4d3907c2
ML
6616 "This hook should add additional registers that are computed by the prologue\n\
6617to the hard regset for shrink-wrapping optimization purposes.",
ee3d2ecd
JJ
6618 void, (struct hard_reg_set_container *),
6619 NULL)
6620
d45eae79
SL
6621/* For targets that have attributes that can affect whether a
6622 function's return statements need checking. For instance a 'naked'
6623 function attribute. */
6624DEFHOOK
6625(warn_func_return,
4d3907c2
ML
6626 "True if a function's return statements should be checked for matching\n\
6627the function's return type. This includes checking for falling off the end\n\
6628of a non-void function. Return false if no such check should be made.",
d45eae79
SL
6629 bool, (tree),
6630 hook_bool_tree_true)
6631
20a6ece0
SB
6632#undef HOOK_PREFIX
6633#define HOOK_PREFIX "TARGET_SHRINK_WRAP_"
6634HOOK_VECTOR (TARGET_SHRINK_WRAP_HOOKS, shrink_wrap)
6635
6636DEFHOOK
6637(get_separate_components,
6638 "This hook should return an @code{sbitmap} with the bits set for those\n\
6639components that can be separately shrink-wrapped in the current function.\n\
6640Return @code{NULL} if the current function should not get any separate\n\
6641shrink-wrapping.\n\
6642Don't define this hook if it would always return @code{NULL}.\n\
6643If it is defined, the other hooks in this group have to be defined as well.",
6644 sbitmap, (void),
6645 NULL)
6646
6647DEFHOOK
6648(components_for_bb,
6649 "This hook should return an @code{sbitmap} with the bits set for those\n\
6650components where either the prologue component has to be executed before\n\
6651the @code{basic_block}, or the epilogue component after it, or both.",
6652 sbitmap, (basic_block),
6653 NULL)
6654
6655DEFHOOK
6656(disqualify_components,
6657 "This hook should clear the bits in the @var{components} bitmap for those\n\
6658components in @var{edge_components} that the target cannot handle on edge\n\
6659@var{e}, where @var{is_prologue} says if this is for a prologue or an\n\
6660epilogue instead.",
6661 void, (sbitmap components, edge e, sbitmap edge_components, bool is_prologue),
6662 NULL)
6663
6664DEFHOOK
6665(emit_prologue_components,
6666 "Emit prologue insns for the components indicated by the parameter.",
6667 void, (sbitmap),
6668 NULL)
6669
6670DEFHOOK
6671(emit_epilogue_components,
6672 "Emit epilogue insns for the components indicated by the parameter.",
6673 void, (sbitmap),
6674 NULL)
6675
6676DEFHOOK
6677(set_handled_components,
6678 "Mark the components in the parameter as handled, so that the\n\
6679@code{prologue} and @code{epilogue} named patterns know to ignore those\n\
6680components. The target code should not hang on to the @code{sbitmap}, it\n\
6681will be deleted after this call.",
6682 void, (sbitmap),
6683 NULL)
6684
6685HOOK_VECTOR_END (shrink_wrap)
6686#undef HOOK_PREFIX
6687#define HOOK_PREFIX "TARGET_"
6688
f0a0390e
RH
6689/* Determine the type of unwind info to emit for debugging. */
6690DEFHOOK
6691(debug_unwind_info,
673c2f63
JM
6692 "This hook defines the mechanism that will be used for describing frame\n\
6693unwind information to the debugger. Normally the hook will return\n\
6694@code{UI_DWARF2} if DWARF 2 debug information is enabled, and\n\
6695return @code{UI_NONE} otherwise.\n\
6696\n\
6697A target may return @code{UI_DWARF2} even when DWARF 2 debug information\n\
6698is disabled in order to always output DWARF 2 frame information.\n\
6699\n\
6700A target may return @code{UI_TARGET} if it has ABI specified unwind tables.\n\
6701This will suppress generation of the normal debug frame unwind information.",
f0a0390e
RH
6702 enum unwind_info_type, (void),
6703 default_debug_unwind_info)
6704
924c9e3e 6705DEFHOOK
4d3907c2
ML
6706(reset_location_view,
6707 "This hook, if defined, enables -ginternal-reset-location-views, and\n\
924c9e3e
AO
6708uses its result to override cases in which the estimated min insn\n\
6709length might be nonzero even when a PC advance (i.e., a view reset)\n\
6710cannot be taken for granted.\n\
6711\n\
6712If the hook is defined, it must return a positive value to indicate\n\
6713the insn definitely advances the PC, and so the view number can be\n\
6714safely assumed to be reset; a negative value to mean the insn\n\
6715definitely does not advance the PC, and os the view number must not\n\
6716be reset; or zero to decide based on the estimated insn length.\n\
6717\n\
6718If insn length is to be regarded as reliable, set the hook to\n\
6719@code{hook_int_rtx_insn_0}.",
6720 int, (rtx_insn *), NULL)
6721
c354951b
AK
6722/* The code parameter should be of type enum rtx_code but this is not
6723 defined at this time. */
6724DEFHOOK
6725(canonicalize_comparison,
673c2f63
JM
6726 "On some machines not all possible comparisons are defined, but you can\n\
6727convert an invalid comparison into a valid one. For example, the Alpha\n\
6728does not have a @code{GT} comparison, but you can use an @code{LT}\n\
6729comparison instead and swap the order of the operands.\n\
6730\n\
6731On such machines, implement this hook to do any required conversions.\n\
6732@var{code} is the initial comparison code and @var{op0} and @var{op1}\n\
6733are the left and right operands of the comparison, respectively. If\n\
6734@var{op0_preserve_value} is @code{true} the implementation is not\n\
6735allowed to change the value of @var{op0} since the value might be used\n\
6736in RTXs which aren't comparisons. E.g. the implementation is not\n\
6737allowed to swap operands in that case.\n\
6738\n\
6739GCC will not assume that the comparison resulting from this macro is\n\
6740valid but will see if the resulting insn matches a pattern in the\n\
6741@file{md} file.\n\
6742\n\
6743You need not to implement this hook if it would never change the\n\
6744comparison code or operands.",
c354951b
AK
6745 void, (int *code, rtx *op0, rtx *op1, bool op0_preserve_value),
6746 default_canonicalize_comparison)
6747
894d8b41
EB
6748DEFHOOK
6749(min_arithmetic_precision,
6750 "On some RISC architectures with 64-bit registers, the processor also\n\
6751maintains 32-bit condition codes that make it possible to do real 32-bit\n\
6752arithmetic, although the operations are performed on the full registers.\n\
6753\n\
6754On such architectures, defining this hook to 32 tells the compiler to try\n\
6755using 32-bit arithmetical operations setting the condition codes instead\n\
6756of doing full 64-bit arithmetic.\n\
6757\n\
6758More generally, define this hook on RISC architectures if you want the\n\
6759compiler to try using arithmetical operations setting the condition codes\n\
6760with a precision lower than the word precision.\n\
6761\n\
6762You need not define this hook if @code{WORD_REGISTER_OPERATIONS} is not\n\
6763defined to 1.",
6764 unsigned int, (void), default_min_arithmetic_precision)
6765
57c5ab1b
RH
6766DEFHOOKPOD
6767(atomic_test_and_set_trueval,
4d3907c2
ML
6768 "This value should be set if the result written by\n\
6769@code{atomic_test_and_set} is not exactly 1, i.e.@: the\n\
6770@code{bool} @code{true}.",
57c5ab1b 6771 unsigned char, 1)
267bac10 6772
fceec4d3
AM
6773/* Return an unsigned int representing the alignment (in bits) of the atomic
6774 type which maps to machine MODE. This allows alignment to be overridden
6775 as needed. */
6776DEFHOOK
6777(atomic_align_for_mode,
4d3907c2
ML
6778"If defined, this function returns an appropriate alignment in bits for an\n\
6779atomic object of machine_mode @var{mode}. If 0 is returned then the\n\
6780default alignment for the specified mode is used.",
ef4bddc2 6781 unsigned int, (machine_mode mode),
fceec4d3
AM
6782 hook_uint_mode_0)
6783
267bac10
JM
6784DEFHOOK
6785(atomic_assign_expand_fenv,
4d3907c2
ML
6786"ISO C11 requires atomic compound assignments that may raise floating-point\n\
6787exceptions to raise exceptions corresponding to the arithmetic operation\n\
6788whose result was successfully stored in a compare-and-exchange sequence.\n\
6789This requires code equivalent to calls to @code{feholdexcept},\n\
6790@code{feclearexcept} and @code{feupdateenv} to be generated at\n\
6791appropriate points in the compare-and-exchange sequence. This hook should\n\
6792set @code{*@var{hold}} to an expression equivalent to the call to\n\
6793@code{feholdexcept}, @code{*@var{clear}} to an expression equivalent to\n\
6794the call to @code{feclearexcept} and @code{*@var{update}} to an expression\n\
6795equivalent to the call to @code{feupdateenv}. The three expressions are\n\
6796@code{NULL_TREE} on entry to the hook and may be left as @code{NULL_TREE}\n\
6797if no code is required in a particular place. The default implementation\n\
6798leaves all three expressions as @code{NULL_TREE}. The\n\
6799@code{__atomic_feraiseexcept} function from @code{libatomic} may be of use\n\
6800as part of the code generated in @code{*@var{update}}.",
267bac10
JM
6801 void, (tree *hold, tree *clear, tree *update),
6802 default_atomic_assign_expand_fenv)
6803
38f8b050
JR
6804/* Leave the boolean fields at the end. */
6805
38f8b050
JR
6806/* True if we can create zeroed data by switching to a BSS section
6807 and then using ASM_OUTPUT_SKIP to allocate the space. */
6808DEFHOOKPOD
6809(have_switchable_bss_sections,
673c2f63
JM
6810 "This flag is true if we can create zeroed data by switching to a BSS\n\
6811section and then using @code{ASM_OUTPUT_SKIP} to allocate the space.\n\
6812This is true on most ELF targets.",
38f8b050
JR
6813 bool, false)
6814
6815/* True if "native" constructors and destructors are supported,
6816 false if we're using collect2 for the job. */
6817DEFHOOKPOD
6818(have_ctors_dtors,
673c2f63
JM
6819 "This value is true if the target supports some ``native'' method of\n\
6820collecting constructors and destructors to be run at startup and exit.\n\
6821It is false if we must use @command{collect2}.",
38f8b050
JR
6822 bool, false)
6823
fabe8cc4
IS
6824/* True if the target wants DTORs to be run from cxa_atexit. */
6825DEFHOOKPOD
6826(dtors_from_cxa_atexit,
6827 "This value is true if the target wants destructors to be queued to be\n\
6828run from __cxa_atexit. If this is the case then, for each priority level,\n\
6829a new constructor will be entered that registers the destructors for that\n\
6830level with __cxa_atexit (and there will be no destructors emitted).\n\
6831It is false the method implied by @code{have_ctors_dtors} is used.",
6832 bool, false)
6833
38f8b050
JR
6834/* True if thread-local storage is supported. */
6835DEFHOOKPOD
6836(have_tls,
673c2f63
JM
6837 "Contains the value true if the target supports thread-local storage.\n\
6838The default value is false.",
38f8b050
JR
6839 bool, false)
6840
6841/* True if a small readonly data section is supported. */
6842DEFHOOKPOD
6843(have_srodata_section,
673c2f63
JM
6844 "Contains the value true if the target places read-only\n\
6845``small data'' into a separate section. The default value is false.",
38f8b050
JR
6846 bool, false)
6847
6848/* True if EH frame info sections should be zero-terminated. */
6849DEFHOOKPOD
6850(terminate_dw2_eh_frame_info,
673c2f63
JM
6851 "Contains the value true if the target should add a zero word onto the\n\
6852end of a Dwarf-2 frame info section when used for exception handling.\n\
6853Default value is false if @code{EH_FRAME_SECTION_NAME} is defined, and\n\
6854true otherwise.",
38f8b050
JR
6855 bool, true)
6856
6857/* True if #NO_APP should be emitted at the beginning of assembly output. */
6858DEFHOOKPOD
6859(asm_file_start_app_off,
673c2f63
JM
6860 "If this flag is true, the text of the macro @code{ASM_APP_OFF} will be\n\
6861printed as the very first line in the assembly file, unless\n\
6862@option{-fverbose-asm} is in effect. (If that macro has been defined\n\
6863to the empty string, this variable has no effect.) With the normal\n\
6864definition of @code{ASM_APP_OFF}, the effect is to notify the GNU\n\
6865assembler that it need not bother stripping comments or extra\n\
6866whitespace from its input. This allows it to work a bit faster.\n\
6867\n\
6868The default is false. You should not set it to true unless you have\n\
6869verified that your port does not generate any extra whitespace or\n\
6870comments that will cause GAS to issue errors in NO_APP mode.",
38f8b050
JR
6871 bool, false)
6872
6873/* True if output_file_directive should be called for main_input_filename
6874 at the beginning of assembly output. */
6875DEFHOOKPOD
6876(asm_file_start_file_directive,
673c2f63
JM
6877 "If this flag is true, @code{output_file_directive} will be called\n\
6878for the primary source file, immediately after printing\n\
6879@code{ASM_APP_OFF} (if that is enabled). Most ELF assemblers expect\n\
6880this to be done. The default is false.",
38f8b050 6881 bool, false)
38f8b050
JR
6882
6883/* Returns true if we should generate exception tables for use with the
6884 ARM EABI. The effects the encoding of function exception specifications. */
6885DEFHOOKPOD
6886(arm_eabi_unwinder,
673c2f63
JM
6887 "This flag should be set to @code{true} on targets that use an ARM EABI\n\
6888based unwinding library, and @code{false} on other targets. This effects\n\
6889the format of unwinding tables, and how the unwinder in entered after\n\
6890running a cleanup. The default is @code{false}.",
38f8b050
JR
6891 bool, false)
6892
9730bc27
TT
6893DEFHOOKPOD
6894(want_debug_pub_sections,
4d3907c2
ML
6895 "True if the @code{.debug_pubtypes} and @code{.debug_pubnames} sections\n\
6896should be emitted. These sections are not used on most platforms, and\n\
6897in particular GDB does not use them.",
9730bc27
TT
6898 bool, false)
6899
2ba42841 6900DEFHOOKPOD
4d3907c2
ML
6901(delay_sched2,
6902 "True if sched2 is not to be run at its normal place.\n\
2ba42841
AO
6903This usually means it will be run as part of machine-specific reorg.",
6904bool, false)
6905
6906DEFHOOKPOD
4d3907c2
ML
6907(delay_vartrack,
6908 "True if vartrack is not to be run at its normal place.\n\
2ba42841
AO
6909This usually means it will be run as part of machine-specific reorg.",
6910bool, false)
6911
a50fa76a 6912DEFHOOKPOD
4d3907c2
ML
6913(no_register_allocation,
6914 "True if register allocation and the passes\n\
a50fa76a
BS
6915following it should not be run. Usually true only for virtual assembler\n\
6916targets.",
6917bool, false)
6918
38f8b050
JR
6919/* Leave the boolean fields at the end. */
6920
06b90602
CB
6921/* Functions related to mode switching. */
6922#undef HOOK_PREFIX
6923#define HOOK_PREFIX "TARGET_MODE_"
6924HOOK_VECTOR (TARGET_TOGGLE_, mode_switching)
6925
6926DEFHOOK
6927(emit,
4d3907c2
ML
6928 "Generate one or more insns to set @var{entity} to @var{mode}.\n\
6929@var{hard_reg_live} is the set of hard registers live at the point where\n\
6930the insn(s) are to be inserted. @var{prev_moxde} indicates the mode\n\
6931to switch from. Sets of a lower numbered entity will be emitted before\n\
6932sets of a higher numbered entity to a mode of the same or lower priority.",
cbb1e3d9 6933 void, (int entity, int mode, int prev_mode, HARD_REG_SET regs_live), NULL)
06b90602
CB
6934
6935DEFHOOK
6936(needed,
4d3907c2
ML
6937 "@var{entity} is an integer specifying a mode-switched entity.\n\
6938If @code{OPTIMIZE_MODE_SWITCHING} is defined, you must define this macro\n\
6939to return an integer value not larger than the corresponding element\n\
6940in @code{NUM_MODES_FOR_MODE_SWITCHING}, to denote the mode that @var{entity}\n\
6941must be switched into prior to the execution of @var{insn}.",
ac44248e 6942 int, (int entity, rtx_insn *insn), NULL)
06b90602
CB
6943
6944DEFHOOK
6945(after,
4d3907c2
ML
6946 "@var{entity} is an integer specifying a mode-switched entity.\n\
6947If this macro is defined, it is evaluated for every @var{insn} during mode\n\
6948switching. It determines the mode that an insn results\n\
6949in (if different from the incoming mode).",
ac44248e 6950 int, (int entity, int mode, rtx_insn *insn), NULL)
06b90602
CB
6951
6952DEFHOOK
6953(entry,
4d3907c2
ML
6954 "If this macro is defined, it is evaluated for every @var{entity} that\n\
6955needs mode switching. It should evaluate to an integer, which is a mode\n\
6956that @var{entity} is assumed to be switched to at function entry.\n\
6957If @code{TARGET_MODE_ENTRY} is defined then @code{TARGET_MODE_EXIT}\n\
6958must be defined.",
06b90602
CB
6959 int, (int entity), NULL)
6960
6961DEFHOOK
6962(exit,
4d3907c2
ML
6963 "If this macro is defined, it is evaluated for every @var{entity} that\n\
6964needs mode switching. It should evaluate to an integer, which is a mode\n\
6965that @var{entity} is assumed to be switched to at function exit.\n\
6966If @code{TARGET_MODE_EXIT} is defined then @code{TARGET_MODE_ENTRY}\n\
6967must be defined.",
06b90602
CB
6968 int, (int entity), NULL)
6969
6970DEFHOOK
6971(priority,
4d3907c2
ML
6972 "This macro specifies the order in which modes for @var{entity}\n\
6973are processed. 0 is the highest priority,\n\
6974@code{NUM_MODES_FOR_MODE_SWITCHING[@var{entity}] - 1} the lowest.\n\
6975The value of the macro should be an integer designating a mode\n\
6976for @var{entity}. For any fixed @var{entity}, @code{mode_priority}\n\
6977(@var{entity}, @var{n}) shall be a bijection in 0 @dots{}\n\
6978@code{num_modes_for_mode_switching[@var{entity}] - 1}.",
06b90602
CB
6979 int, (int entity, int n), NULL)
6980
6981HOOK_VECTOR_END (mode_switching)
6982
3bd87832
MM
6983#undef HOOK_PREFIX
6984#define HOOK_PREFIX "TARGET_MEMTAG_"
6985HOOK_VECTOR (TARGET_MEMTAG_, memtag)
6986
6987DEFHOOK
6988(can_tag_addresses,
6989 "True if the backend architecture naturally supports ignoring some region\n\
6990of pointers. This feature means that @option{-fsanitize=hwaddress} can\n\
6991work.\n\
6992\n\
6993At preset, this feature does not support address spaces. It also requires\n\
6994@code{Pmode} to be the same as @code{ptr_mode}.",
6995 bool, (), default_memtag_can_tag_addresses)
6996
0854b584
MM
6997DEFHOOK
6998(tag_size,
6999 "Return the size of a tag (in bits) for this platform.\n\
7000\n\
7001The default returns 8.",
7002 uint8_t, (), default_memtag_tag_size)
7003
7004DEFHOOK
7005(granule_size,
7006 "Return the size in real memory that each byte in shadow memory refers to.\n\
7007I.e. if a variable is @var{X} bytes long in memory, then this hook should\n\
7008return the value @var{Y} such that the tag in shadow memory spans\n\
7009@var{X}/@var{Y} bytes.\n\
7010\n\
7011Most variables will need to be aligned to this amount since two variables\n\
7012that are neighbors in memory and share a tag granule would need to share\n\
7013the same tag.\n\
7014\n\
7015The default returns 16.",
7016 uint8_t, (), default_memtag_granule_size)
7017
7018DEFHOOK
7019(insert_random_tag,
7020 "Return an RTX representing the value of @var{untagged} but with a\n\
7021(possibly) random tag in it.\n\
7022Put that value into @var{target} if it is convenient to do so.\n\
7023This function is used to generate a tagged base for the current stack frame.",
7024 rtx, (rtx untagged, rtx target), default_memtag_insert_random_tag)
7025
7026DEFHOOK
7027(add_tag,
7028 "Return an RTX that represents the result of adding @var{addr_offset} to\n\
7029the address in pointer @var{base} and @var{tag_offset} to the tag in pointer\n\
7030@var{base}.\n\
7031The resulting RTX must either be a valid memory address or be able to get\n\
7032put into an operand with @code{force_operand}.\n\
7033\n\
7034Unlike other memtag hooks, this must return an expression and not emit any\n\
7035RTL.",
7036 rtx, (rtx base, poly_int64 addr_offset, uint8_t tag_offset),
7037 default_memtag_add_tag)
7038
7039DEFHOOK
7040(set_tag,
7041 "Return an RTX representing @var{untagged_base} but with the tag @var{tag}.\n\
7042Try and store this in @var{target} if convenient.\n\
7043@var{untagged_base} is required to have a zero tag when this hook is called.\n\
7044The default of this hook is to set the top byte of @var{untagged_base} to\n\
7045@var{tag}.",
7046 rtx, (rtx untagged_base, rtx tag, rtx target), default_memtag_set_tag)
7047
7048DEFHOOK
7049(extract_tag,
7050 "Return an RTX representing the tag stored in @var{tagged_pointer}.\n\
7051Store the result in @var{target} if it is convenient.\n\
7052The default represents the top byte of the original pointer.",
7053 rtx, (rtx tagged_pointer, rtx target), default_memtag_extract_tag)
7054
7055DEFHOOK
7056(untagged_pointer,
7057 "Return an RTX representing @var{tagged_pointer} with its tag set to zero.\n\
7058Store the result in @var{target} if convenient.\n\
7059The default clears the top byte of the original pointer.",
7060 rtx, (rtx tagged_pointer, rtx target), default_memtag_untagged_pointer)
7061
3bd87832 7062HOOK_VECTOR_END (memtag)
4bccb39e
RS
7063#undef HOOK_PREFIX
7064#define HOOK_PREFIX "TARGET_"
7065
7066#define DEF_TARGET_INSN(NAME, PROTO) \
7067 DEFHOOK_UNDOC (have_##NAME, "", bool, (void), false)
7068#include "target-insns.def"
7069#undef DEF_TARGET_INSN
7070
7071#define DEF_TARGET_INSN(NAME, PROTO) \
7072 DEFHOOK_UNDOC (gen_##NAME, "", rtx_insn *, PROTO, NULL)
7073#include "target-insns.def"
7074#undef DEF_TARGET_INSN
7075
8684d89d
RS
7076#define DEF_TARGET_INSN(NAME, PROTO) \
7077 DEFHOOKPOD (code_for_##NAME, "*", enum insn_code, CODE_FOR_nothing)
7078#include "target-insns.def"
7079#undef DEF_TARGET_INSN
7080
40af5894
DM
7081DEFHOOK
7082(run_target_selftests,
7083 "If selftests are enabled, run any selftests for this target.",
7084 void, (void),
7085 NULL)
7086
8cdcea51
SH
7087DEFHOOK
7088(gcov_type_size,
7089 "Returns the gcov type size in bits. This type is used for example for\n\
7090counters incremented by profiling and code-coverage events. The default\n\
7091value is 64, if the type size of long long is greater than 32, otherwise the\n\
7092default value is 32. A 64-bit type is recommended to avoid overflows of the\n\
7093counters. If the @option{-fprofile-update=atomic} is used, then the\n\
7094counters are incremented using atomic operations. Targets not supporting\n\
709564-bit atomic operations may override the default value and request a 32-bit\n\
7096type.",
7097 HOST_WIDE_INT, (void), default_gcov_type_size)
7098
38f8b050
JR
7099/* Close the 'struct gcc_target' definition. */
7100HOOK_VECTOR_END (C90_EMPTY_HACK)
06b90602 7101