1 /* Target hook definitions.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
4 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>.
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding! */
24 /* See target-hooks-macros.h for details of macros that should be
25 provided by the including file, and how to use them here. */
26 #include "target-hooks-macros.h"
29 #define HOOK_TYPE "Target Hook"
31 HOOK_VECTOR (TARGET_INITIALIZER, gcc_target)
33 /* Functions that output assembler for the target. */
34 #define HOOK_PREFIX "TARGET_ASM_"
35 HOOK_VECTOR (TARGET_ASM_OUT, asm_out)
37 /* Opening and closing parentheses for asm expression grouping. */
42 DEFHOOKPODX (close_paren, const char *, ")")
44 /* Assembler instructions for creating various kinds of integer object. */
48 const char *, "\t.byte\t")
49 DEFHOOKPOD (aligned_op, "*", struct asm_int_op, TARGET_ASM_ALIGNED_INT_OP)
50 DEFHOOKPOD (unaligned_op, "*", struct asm_int_op, TARGET_ASM_UNALIGNED_INT_OP)
52 /* The maximum number of bytes to skip when applying
53 LABEL_ALIGN_AFTER_BARRIER. */
55 (label_align_after_barrier_max_skip,
58 default_label_align_after_barrier_max_skip)
60 /* The maximum number of bytes to skip when applying
66 default_loop_align_max_skip)
68 /* The maximum number of bytes to skip when applying
71 (label_align_max_skip,
74 default_label_align_max_skip)
76 /* The maximum number of bytes to skip when applying
82 default_jump_align_max_skip)
84 /* Try to output the assembler code for an integer object whose
85 value is given by X. SIZE is the size of the object in bytes and
86 ALIGNED_P indicates whether it is aligned. Return true if
87 successful. Only handles cases for which BYTE_OP, ALIGNED_OP
88 and UNALIGNED_OP are NULL. */
92 /* Only handles cases for which BYTE_OP, ALIGNED_OP and UNALIGNED_OP are
94 bool, (rtx x, unsigned int size, int aligned_p),
95 default_assemble_integer)
97 /* Output code that will globalize a label. */
101 void, (FILE *stream, const char *name),
102 default_globalize_label)
104 /* Output code that will globalize a declaration. */
106 (globalize_decl_name,
108 void, (FILE *stream, tree decl), default_globalize_decl_name)
110 /* Output code that will emit a label for unwind info, if this
111 target requires such labels. Second argument is the decl the
112 unwind info is associated with, third is a boolean: true if
113 this is for exception handling, fourth is a boolean: true if
114 this is only a placeholder for an omitted FDE. */
118 void, (FILE *stream, tree decl, int for_eh, int empty),
119 default_emit_unwind_label)
121 /* Output code that will emit a label to divide up the exception table. */
123 (emit_except_table_label,
125 void, (FILE *stream),
126 default_emit_except_table_label)
128 /* Emit a directive for setting the personality for the function. */
130 (emit_except_personality,
131 "If the target implements @code{TARGET_ASM_UNWIND_EMIT}, this hook may be\
132 used to emit a directive to install a personality hook into the unwind\
133 info. This hook should not be used if dwarf2 unwind info is used.",
134 void, (rtx personality),
137 /* Emit any directives required to unwind this instruction. */
141 void, (FILE *stream, rtx insn),
145 (unwind_emit_before_insn,
146 "True if the @code{TARGET_ASM_UNWIND_EMIT} hook should be called before\
147 the assembly for @var{insn} has been emitted, false if the hook should\
148 be called afterward.",
151 /* Generate an internal label.
152 For now this is just a wrapper for ASM_GENERATE_INTERNAL_LABEL. */
154 (generate_internal_label,
156 void, (char *buf, const char *prefix, unsigned long labelno),
157 default_generate_internal_label)
159 /* Output an internal label. */
163 void, (FILE *stream, const char *prefix, unsigned long labelno),
164 default_internal_label)
166 /* Output label for the constant. */
168 (declare_constant_name,
170 void, (FILE *file, const char *name, const_tree expr, HOST_WIDE_INT size),
171 default_asm_declare_constant_name)
173 /* Emit a ttype table reference to a typeinfo object. */
180 /* Emit an assembler directive to set visibility for the symbol
181 associated with the tree decl. */
183 (assemble_visibility,
185 void, (tree decl, int visibility),
186 default_assemble_visibility)
188 /* Output the assembler code for entry to a function. */
192 void, (FILE *file, HOST_WIDE_INT size),
193 default_function_pro_epilogue)
195 /* Output the assembler code for end of prologue. */
197 (function_end_prologue,
202 /* Output the assembler code for start of epilogue. */
204 (function_begin_epilogue,
209 /* Output the assembler code for function exit. */
213 void, (FILE *file, HOST_WIDE_INT size),
214 default_function_pro_epilogue)
216 /* Initialize target-specific sections. */
223 /* Tell assembler to change to section NAME with attributes FLAGS.
224 If DECL is non-NULL, it is the VAR_DECL or FUNCTION_DECL with
225 which this section is associated. */
229 void, (const char *name, unsigned int flags, tree decl),
230 default_no_named_section)
232 /* Return preferred text (sub)section for function DECL.
233 Main purpose of this function is to separate cold, normal and hot
234 functions. STARTUP is true when function is known to be used only
235 at startup (from static constructors or it is main()).
236 EXIT is true when function is known to be used only at exit
237 (from static destructors).
238 Return NULL if function should go to default text section. */
242 section *, (tree decl, enum node_frequency freq, bool startup, bool exit),
243 default_function_section)
245 /* Output the assembler code for function exit. */
247 (function_switched_text_sections,
248 "Used by the target to emit any assembler directives or additional\
249 labels needed when a function is partitioned between different\
250 sections. Output should be written to @var{file}. The function\
251 decl is available as @var{decl} and the new section is `cold' if\
252 @var{new_is_cold} is @code{true}.",
253 void, (FILE *file, tree decl, bool new_is_cold),
254 default_function_switched_text_sections)
256 /* Return a mask describing how relocations should be treated when
257 selecting sections. Bit 1 should be set if global relocations
258 should be placed in a read-write section; bit 0 should be set if
259 local relocations should be placed in a read-write section. */
264 default_reloc_rw_mask)
266 /* Return a section for EXP. It may be a DECL or a constant. RELOC
267 is nonzero if runtime relocations must be applied; bit 1 will be
268 set if the runtime relocations require non-local name resolution.
269 ALIGN is the required alignment of the data. */
273 section *, (tree exp, int reloc, unsigned HOST_WIDE_INT align),
274 default_select_section)
276 /* Return a section for X. MODE is X's mode and ALIGN is its
277 alignment in bits. */
281 section *, (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align),
282 default_select_rtx_section)
284 /* Select a unique section name for DECL. RELOC is the same as
285 for SELECT_SECTION. */
289 void, (tree decl, int reloc),
290 default_unique_section)
292 /* Return the readonly data section associated with function DECL. */
294 (function_rodata_section,
296 section *, (tree decl),
297 default_function_rodata_section)
299 /* Nonnull if the target wants to override the default ".rodata" prefix
300 for mergeable data sections. */
302 (mergeable_rodata_prefix,
303 "Usually, the compiler uses the prefix @code{\".rodata\"} to construct\n\
304 section names for mergeable constant data. Define this macro to override\n\
305 the string if a different section name should be used.",
306 const char *, ".rodata")
308 /* Output a constructor for a symbol with a given priority. */
312 void, (rtx symbol, int priority), NULL)
314 /* Output a destructor for a symbol with a given priority. */
318 void, (rtx symbol, int priority), NULL)
320 /* Output the assembler code for a thunk function. THUNK_DECL is the
321 declaration for the thunk function itself, FUNCTION is the decl for
322 the target function. DELTA is an immediate constant offset to be
323 added to THIS. If VCALL_OFFSET is nonzero, the word at
324 *(*this + vcall_offset) should be added to THIS. */
328 void, (FILE *file, tree thunk_fndecl, HOST_WIDE_INT delta,
329 HOST_WIDE_INT vcall_offset, tree function),
332 /* Determine whether output_mi_thunk would succeed. */
333 /* ??? Ideally, this hook would not exist, and success or failure
334 would be returned from output_mi_thunk directly. But there's
335 too much undo-able setup involved in invoking output_mi_thunk.
336 Could be fixed by making output_mi_thunk emit rtl instead of
337 text to the output file. */
339 (can_output_mi_thunk,
341 bool, (const_tree thunk_fndecl, HOST_WIDE_INT delta,
342 HOST_WIDE_INT vcall_offset, const_tree function),
343 hook_bool_const_tree_hwi_hwi_const_tree_false)
345 /* Output any boilerplate text needed at the beginning of a
353 /* Output any boilerplate text needed at the end of a translation unit. */
360 /* Output any boilerplate text needed at the beginning of an
361 LTO output stream. */
368 /* Output any boilerplate text needed at the end of an
369 LTO output stream. */
376 /* Output any boilerplace text needed at the end of a
377 translation unit before debug and unwind info is emitted. */
384 /* Output an assembler pseudo-op to declare a library function name
390 default_external_libcall)
392 /* Output an assembler directive to mark decl live. This instructs
393 linker to not dead code strip this symbol. */
395 (mark_decl_preserved,
397 void, (const char *symbol),
398 hook_void_constcharptr)
400 /* Output a record of the command line switches that have been passed. */
402 (record_gcc_switches,
404 int, (print_switch_type type, const char *text),
407 /* The name of the section that the example ELF implementation of
408 record_gcc_switches will use to store the information. Target
409 specific versions of record_gcc_switches may or may not use
412 (record_gcc_switches_section,
414 const char *, ".GCC.command.line")
416 /* Output the definition of a section anchor. */
421 default_asm_output_anchor)
423 /* Output a DTP-relative reference to a TLS symbol. */
425 (output_dwarf_dtprel,
427 void, (FILE *file, int size, rtx x),
430 /* Some target machines need to postscan each insn after it is output. */
432 (final_postscan_insn,
434 void, (FILE *file, rtx insn, rtx *opvec, int noperands),
437 /* Emit the trampoline template. This hook may be NULL. */
439 (trampoline_template,
445 (output_source_filename,
446 "Output COFF information or DWARF debugging information which indicates\
447 that filename @var{name} is the current source file to the stdio\
448 stream @var{file}.\n\
450 This target hook need not be defined if the standard form of output\
451 for the file format in use is appropriate.",
452 void ,(FILE *file, const char *name),
453 default_asm_output_source_filename)
456 (output_addr_const_extra,
458 bool, (FILE *file, rtx x),
459 hook_bool_FILEptr_rtx_false)
461 /* ??? The TARGET_PRINT_OPERAND* hooks are part of the asm_out struct,
462 even though that is not reflected in the macro name to override their
465 #define HOOK_PREFIX "TARGET_"
467 /* Emit a machine-specific insn operand. */
468 /* ??? tm.texi only documents the old macro PRINT_OPERAND,
469 not this hook, and uses a different name for the argument FILE. */
473 void, (FILE *file, rtx x, int code),
474 default_print_operand)
476 /* Emit a machine-specific memory address. */
477 /* ??? tm.texi only documents the old macro PRINT_OPERAND_ADDRESS,
478 not this hook, and uses different argument names. */
480 (print_operand_address,
482 void, (FILE *file, rtx addr),
483 default_print_operand_address)
485 /* Determine whether CODE is a valid punctuation character for the
486 `print_operand' hook. */
487 /* ??? tm.texi only documents the old macro PRINT_OPERAND_PUNCT_VALID_P,
490 (print_operand_punct_valid_p,
492 bool ,(unsigned char code),
493 default_print_operand_punct_valid_p)
495 /* Given a symbol name, perform same mangling as assemble_name and
496 ASM_OUTPUT_LABELREF, returning result as an IDENTIFIER_NODE. */
498 (mangle_assembler_name,
499 "Given a symbol @var{name}, perform same mangling as @code{varasm.c}'s\
500 @code{assemble_name}, but in memory rather than to a file stream, returning\
501 result as an @code{IDENTIFIER_NODE}. Required for correct LTO symtabs. The\
502 default implementation calls the @code{TARGET_STRIP_NAME_ENCODING} hook and\
503 then prepends the @code{USER_LABEL_PREFIX}, if any.",
504 tree, (const char *name),
505 default_mangle_assembler_name)
507 HOOK_VECTOR_END (asm_out)
509 /* Functions relating to instruction scheduling. All of these
510 default to null pointers, which haifa-sched.c looks for and handles. */
512 #define HOOK_PREFIX "TARGET_SCHED_"
513 HOOK_VECTOR (TARGET_SCHED, sched)
515 /* Given the current cost, COST, of an insn, INSN, calculate and
516 return a new cost based on its relationship to DEP_INSN through
517 the dependence LINK. The default is to make no adjustment. */
521 int, (rtx insn, rtx link, rtx dep_insn, int cost), NULL)
523 /* Adjust the priority of an insn as you see fit. Returns the new priority. */
527 int, (rtx insn, int priority), NULL)
529 /* Function which returns the maximum number of insns that can be
530 scheduled in the same machine cycle. This must be constant
531 over an entire compilation. The default is 1. */
537 /* Calculate how much this insn affects how many more insns we
538 can emit this cycle. Default is they all cost the same. */
542 int, (FILE *file, int verbose, rtx insn, int more), NULL)
544 /* Initialize machine-dependent scheduling code. */
548 void, (FILE *file, int verbose, int max_ready), NULL)
550 /* Finalize machine-dependent scheduling code. */
554 void, (FILE *file, int verbose), NULL)
556 /* Initialize machine-dependent function wide scheduling code. */
560 void, (FILE *file, int verbose, int old_max_uid), NULL)
562 /* Finalize machine-dependent function wide scheduling code. */
566 void, (FILE *file, int verbose), NULL)
568 /* Reorder insns in a machine-dependent fashion, in two different
569 places. Default does nothing. */
573 int, (FILE *file, int verbose, rtx *ready, int *n_readyp, int clock), NULL)
578 int, (FILE *file, int verbose, rtx *ready, int *n_readyp, int clock), NULL)
580 /* The following member value is a pointer to a function called
581 after evaluation forward dependencies of insns in chain given
582 by two parameter values (head and tail correspondingly). */
584 (dependencies_evaluation_hook,
586 void, (rtx head, rtx tail), NULL)
588 /* The values of the following four members are pointers to functions
589 used to simplify the automaton descriptions. dfa_pre_cycle_insn and
590 dfa_post_cycle_insn give functions returning insns which are used to
591 change the pipeline hazard recognizer state when the new simulated
592 processor cycle correspondingly starts and finishes. The function
593 defined by init_dfa_pre_cycle_insn and init_dfa_post_cycle_insn are
594 used to initialize the corresponding insns. The default values of
595 the members result in not changing the automaton state when the
596 new simulated processor cycle correspondingly starts and finishes. */
599 (init_dfa_pre_cycle_insn,
609 (init_dfa_post_cycle_insn,
614 (dfa_post_cycle_insn,
618 /* The values of the following two members are pointers to
619 functions used to simplify the automaton descriptions.
620 dfa_pre_advance_cycle and dfa_post_advance_cycle are getting called
621 immediately before and after cycle is advanced. */
624 (dfa_pre_advance_cycle,
629 (dfa_post_advance_cycle,
633 /* The following member value is a pointer to a function returning value
634 which defines how many insns in queue `ready' will we try for
635 multi-pass scheduling. If the member value is nonzero and the
636 function returns positive value, the DFA based scheduler will make
637 multi-pass scheduling for the first cycle. In other words, we will
638 try to choose ready insn which permits to start maximum number of
639 insns on the same cycle. */
641 (first_cycle_multipass_dfa_lookahead,
645 /* The following member value is pointer to a function controlling
646 what insns from the ready insn queue will be considered for the
647 multipass insn scheduling. If the hook returns zero for insn
648 passed as the parameter, the insn will be not chosen to be issued. */
650 (first_cycle_multipass_dfa_lookahead_guard,
652 int, (rtx insn), NULL)
654 /* This hook prepares the target for a new round of multipass
656 DATA is a pointer to target-specific data used for multipass scheduling.
657 READY_TRY and N_READY represent the current state of search in the
658 optimization space. The target can filter out instructions that
659 should not be tried during current round by setting corresponding
660 elements in READY_TRY to non-zero.
661 FIRST_CYCLE_INSN_P is true if this is the first round of multipass
662 scheduling on current cycle. */
664 (first_cycle_multipass_begin,
666 void, (void *data, char *ready_try, int n_ready, bool first_cycle_insn_p),
669 /* This hook is called when multipass scheduling evaluates instruction INSN.
670 DATA is a pointer to target-specific data that can be used to record effects
671 of INSN on CPU that are not described in DFA.
672 READY_TRY and N_READY represent the current state of search in the
673 optimization space. The target can filter out instructions that
674 should not be tried after issueing INSN by setting corresponding
675 elements in READY_TRY to non-zero.
676 INSN is the instruction being evaluated.
677 PREV_DATA is a pointer to target-specific data corresponding
678 to a state before issueing INSN. */
680 (first_cycle_multipass_issue,
682 void, (void *data, char *ready_try, int n_ready, rtx insn,
683 const void *prev_data), NULL)
685 /* This hook is called when multipass scheduling backtracks from evaluation of
686 instruction corresponding to DATA.
687 DATA is a pointer to target-specific data that stores the effects
688 of instruction from which the algorithm backtracks on CPU that are not
690 READY_TRY and N_READY represent the current state of search in the
691 optimization space. The target can filter out instructions that
692 should not be tried after issueing INSN by setting corresponding
693 elements in READY_TRY to non-zero. */
695 (first_cycle_multipass_backtrack,
697 void, (const void *data, char *ready_try, int n_ready), NULL)
699 /* This hook notifies the target about the result of the concluded current
700 round of multipass scheduling.
702 If DATA is non-NULL it points to target-specific data used for multipass
703 scheduling which corresponds to instruction at the start of the chain of
704 the winning solution. DATA is NULL when multipass scheduling cannot find
705 a good enough solution on current cycle and decides to retry later,
706 usually after advancing the cycle count. */
708 (first_cycle_multipass_end,
710 void, (const void *data), NULL)
712 /* This hook is called to initialize target-specific data for multipass
713 scheduling after it has been allocated.
714 DATA is a pointer to target-specific data that stores the effects
715 of instruction from which the algorithm backtracks on CPU that are not
718 (first_cycle_multipass_init,
720 void, (void *data), NULL)
722 /* This hook is called to finalize target-specific data for multipass
723 scheduling before it is deallocated.
724 DATA is a pointer to target-specific data that stores the effects
725 of instruction from which the algorithm backtracks on CPU that are not
728 (first_cycle_multipass_fini,
730 void, (void *data), NULL)
732 /* The following member value is pointer to a function called by
733 the insn scheduler before issuing insn passed as the third
734 parameter on given cycle. If the hook returns nonzero, the
735 insn is not issued on given processors cycle. Instead of that,
736 the processor cycle is advanced. If the value passed through
737 the last parameter is zero, the insn ready queue is not sorted
738 on the new cycle start as usually. The first parameter passes
739 file for debugging output. The second one passes the scheduler
740 verbose level of the debugging output. The forth and the fifth
741 parameter values are correspondingly processor cycle on which
742 the previous insn has been issued and the current processor cycle. */
746 int, (FILE *dump, int verbose, rtx insn, int last_clock,
747 int clock, int *sort_p),
750 /* The following member value is a pointer to a function called by the
751 insn scheduler. It should return true if there exists a dependence
752 which is considered costly by the target, between the insn
753 DEP_PRO (&_DEP), and the insn DEP_CON (&_DEP). The first parameter is
754 the dep that represents the dependence between the two insns. The
755 second argument is the cost of the dependence as estimated by
756 the scheduler. The last argument is the distance in cycles
757 between the already scheduled insn (first parameter) and the
758 second insn (second parameter). */
760 (is_costly_dependence,
762 bool, (struct _dep *_dep, int cost, int distance), NULL)
766 "Given the current cost, @var{cost}, of an insn, @var{insn}, calculate and\
767 return a new cost based on its relationship to @var{dep_insn} through the\
768 dependence of weakness @var{dw}. The default is to make no adjustment.",
769 int, (rtx insn, int dep_type1, rtx dep_insn, int cost, int dw), NULL)
771 /* The following member value is a pointer to a function called
772 by the insn scheduler. This hook is called to notify the backend
773 that new instructions were emitted. */
779 /* Next 5 functions are for multi-point scheduling. */
781 /* Allocate memory for scheduler context. */
783 (alloc_sched_context,
785 void *, (void), NULL)
787 /* Fills the context from the local machine scheduler context. */
791 void, (void *tc, bool clean_p), NULL)
793 /* Sets local machine scheduler context to a saved value. */
797 void, (void *tc), NULL)
799 /* Clears a scheduler context so it becomes like after init. */
801 (clear_sched_context,
803 void, (void *tc), NULL)
805 /* Frees the scheduler context. */
809 void, (void *tc), NULL)
811 /* The following member value is a pointer to a function called
812 by the insn scheduler.
813 The first parameter is an instruction, the second parameter is the type
814 of the requested speculation, and the third parameter is a pointer to the
815 speculative pattern of the corresponding type (set if return value == 1).
817 -1, if there is no pattern, that will satisfy the requested speculation type,
818 0, if current pattern satisfies the requested speculation type,
819 1, if pattern of the instruction should be changed to the newly
824 int, (rtx insn, int request, rtx *new_pat), NULL)
826 /* The following member value is a pointer to a function called
827 by the insn scheduler. It should return true if the check instruction
828 passed as the parameter needs a recovery block. */
832 bool, (int dep_status), NULL)
834 /* The following member value is a pointer to a function called
835 by the insn scheduler. It should return a pattern for the check
837 The first parameter is a speculative instruction, the second parameter
838 is the label of the corresponding recovery block (or null, if it is a
839 simple check). If the mutation of the check is requested (e.g. from
840 ld.c to chk.a), the third parameter is true - in this case the first
841 parameter is the previous check. */
845 rtx, (rtx insn, rtx label, int mutate_p), NULL)
847 /* The following member value is a pointer to a function controlling
848 what insns from the ready insn queue will be considered for the
849 multipass insn scheduling. If the hook returns zero for the insn
850 passed as the parameter, the insn will not be chosen to be
851 issued. This hook is used to discard speculative instructions,
852 that stand at the first position of the ready list. */
854 (first_cycle_multipass_dfa_lookahead_guard_spec,
856 bool, (const_rtx insn), NULL)
858 /* The following member value is a pointer to a function that provides
859 information about the speculation capabilities of the target.
860 The parameter is a pointer to spec_info variable. */
864 void, (struct spec_info_def *spec_info), NULL)
868 "Return speculation types of instruction @var{insn}.",
869 int, (rtx insn), NULL)
872 (get_insn_checked_ds,
873 "Return speculation types that are checked for instruction @var{insn}",
874 int, (rtx insn), NULL)
878 "Return bool if rtx scanning should just skip current layer and\
879 advance to the inner rtxes.",
880 bool, (const_rtx x), NULL)
882 /* The following member value is a pointer to a function that provides
883 information about the target resource-based lower bound which is
884 used by the swing modulo scheduler. The parameter is a pointer
889 int, (struct ddg *g), NULL)
891 /* The following member value is a function that initializes dispatch
892 schedling and adds instructions to dispatch window according to its
897 void, (rtx insn, int x),
900 /* The following member value is a a function that returns true is
901 dispatch schedling is supported in hardware and condition passed
902 as the second parameter is true. */
906 bool, (rtx insn, int x),
907 hook_bool_rtx_int_false)
911 "True if the processor has an exposed pipeline, which means that not just\n\
912 the order of instructions is important for correctness when scheduling, but\n\
913 also the latencies of operations.",
916 /* The following member value is a function that returns number
917 of operations reassociator should try to put in parallel for
918 statements of the given type. By default 1 is used. */
920 (reassociation_width,
921 "This hook is called by tree reassociator to determine a level of\n\
922 parallelism required in output calculations chain.",
923 int, (unsigned int opc, enum machine_mode mode),
924 hook_int_uint_mode_1)
926 HOOK_VECTOR_END (sched)
928 /* Functions relating to vectorization. */
930 #define HOOK_PREFIX "TARGET_VECTORIZE_"
931 HOOK_VECTOR (TARGET_VECTORIZE, vectorize)
933 /* The following member value is a pointer to a function called
934 by the vectorizer, and return the decl of the target builtin
937 (builtin_mask_for_load,
941 /* Returns a code for builtin that realizes vectorized version of
942 function, or NULL_TREE if not available. */
944 (builtin_vectorized_function,
946 tree, (tree fndecl, tree vec_type_out, tree vec_type_in),
947 default_builtin_vectorized_function)
949 /* Returns a function declaration for a builtin that realizes the
950 vector conversion, or NULL_TREE if not available. */
954 tree, (unsigned code, tree dest_type, tree src_type),
955 default_builtin_vectorized_conversion)
957 /* Target builtin that implements vector widening multiplication.
958 builtin_mul_widen_eve computes the element-by-element products
959 for the even elements, and builtin_mul_widen_odd computes the
960 element-by-element products for the odd elements. */
962 (builtin_mul_widen_even,
964 tree, (tree x), NULL)
967 (builtin_mul_widen_odd,
969 tree, (tree x), NULL)
971 /* Cost of different vector/scalar statements in vectorization cost
972 model. In case of misaligned vector loads and stores the cost depends
973 on the data type and misalignment value. */
975 (builtin_vectorization_cost,
977 int, (enum vect_cost_for_stmt type_of_cost, tree vectype, int misalign),
978 default_builtin_vectorization_cost)
980 /* Return true if vector alignment is reachable (by peeling N
981 iterations) for the given type. */
983 (vector_alignment_reachable,
985 bool, (const_tree type, bool is_packed),
986 default_builtin_vector_alignment_reachable)
988 /* Return true if a vector created for vec_perm_const is valid.
989 A NULL indicates that all constants are valid permutations. */
993 bool, (enum machine_mode, const unsigned char *sel),
996 /* Return true if the target supports misaligned store/load of a
997 specific factor denoted in the third parameter. The last parameter
998 is true if the access is defined in a packed struct. */
1000 (support_vector_misalignment,
1003 (enum machine_mode mode, const_tree type, int misalignment, bool is_packed),
1004 default_builtin_support_vector_misalignment)
1006 /* Returns the preferred mode for SIMD operations for the specified
1009 (preferred_simd_mode,
1012 (enum machine_mode mode),
1013 default_preferred_simd_mode)
1015 /* Returns a mask of vector sizes to iterate over when auto-vectorizing
1016 after processing the preferred one derived from preferred_simd_mode. */
1018 (autovectorize_vector_sizes,
1022 default_autovectorize_vector_sizes)
1024 /* Target builtin that implements vector gather operation. */
1029 (const_tree mem_vectype, const_tree index_type, int scale),
1032 HOOK_VECTOR_END (vectorize)
1035 #define HOOK_PREFIX "TARGET_"
1037 /* Allow target specific overriding of option settings after options have
1038 been changed by an attribute or pragma or when it is reset at the
1039 end of the code affected by an attribute or pragma. */
1041 (override_options_after_change,
1047 (eh_return_filter_mode,
1048 "Return machine mode for filter value.",
1049 enum machine_mode, (void),
1050 default_eh_return_filter_mode)
1052 /* Return machine mode for libgcc expanded cmp instructions. */
1054 (libgcc_cmp_return_mode,
1056 enum machine_mode, (void),
1057 default_libgcc_cmp_return_mode)
1059 /* Return machine mode for libgcc expanded shift instructions. */
1061 (libgcc_shift_count_mode,
1063 enum machine_mode, (void),
1064 default_libgcc_shift_count_mode)
1066 /* Return machine mode to be used for _Unwind_Word type. */
1070 enum machine_mode, (void),
1071 default_unwind_word_mode)
1073 /* Given two decls, merge their attributes and return the result. */
1075 (merge_decl_attributes,
1077 tree, (tree olddecl, tree newdecl),
1078 merge_decl_attributes)
1080 /* Given two types, merge their attributes and return the result. */
1082 (merge_type_attributes,
1084 tree, (tree type1, tree type2),
1085 merge_type_attributes)
1087 /* Table of machine attributes and functions to handle them.
1092 const struct attribute_spec *, NULL)
1094 /* Return true iff attribute NAME expects a plain identifier as its first
1097 (attribute_takes_identifier_p,
1099 bool, (const_tree name),
1100 hook_bool_const_tree_false)
1102 /* Return zero if the attributes on TYPE1 and TYPE2 are incompatible,
1103 one if they are compatible and two if they are nearly compatible
1104 (which causes a warning to be generated). */
1106 (comp_type_attributes,
1108 int, (const_tree type1, const_tree type2),
1109 hook_int_const_tree_const_tree_1)
1111 /* Assign default attributes to the newly defined TYPE. */
1113 (set_default_type_attributes,
1118 /* Insert attributes on the newly created DECL. */
1122 void, (tree node, tree *attr_ptr),
1123 hook_void_tree_treeptr)
1125 /* Return true if FNDECL (which has at least one machine attribute)
1126 can be inlined despite its machine attributes, false otherwise. */
1128 (function_attribute_inlinable_p,
1130 bool, (const_tree fndecl),
1131 hook_bool_const_tree_false)
1133 /* Return true if bitfields in RECORD_TYPE should follow the
1134 Microsoft Visual C++ bitfield layout rules. */
1136 (ms_bitfield_layout_p,
1138 bool, (const_tree record_type),
1139 hook_bool_const_tree_false)
1141 /* For now this is only an interface to WORDS_BIG_ENDIAN for
1142 target-independent code like the front ends, need performance testing
1143 before switching completely to the target hook. */
1148 targhook_words_big_endian)
1150 /* Likewise for FLOAT_WORDS_BIG_ENDIAN. */
1152 (float_words_big_endian,
1155 targhook_float_words_big_endian)
1157 /* True if the target supports decimal floating point. */
1159 (decimal_float_supported_p,
1162 default_decimal_float_supported_p)
1164 /* True if the target supports fixed-point. */
1166 (fixed_point_supported_p,
1169 default_fixed_point_supported_p)
1171 /* Return true if anonymous bitfields affect structure alignment. */
1173 (align_anon_bitfield,
1176 hook_bool_void_false)
1178 /* Return true if volatile bitfields should use the narrowest type possible.
1179 Return false if they should use the container type. */
1181 (narrow_volatile_bitfield,
1184 hook_bool_void_false)
1186 /* Set up target-specific built-in functions. */
1193 /* Initialize (if INITIALIZE_P is true) and return the target-specific
1194 built-in function decl for CODE.
1195 Return NULL if that is not possible. Return error_mark_node if CODE
1196 is outside of the range of valid target builtin function codes. */
1200 tree, (unsigned code, bool initialize_p), NULL)
1202 /* Expand a target-specific builtin. */
1207 (tree exp, rtx target, rtx subtarget, enum machine_mode mode, int ignore),
1208 default_expand_builtin)
1210 /* Select a replacement for a target-specific builtin. This is done
1211 *before* regular type checking, and so allows the target to
1212 implement a crude form of function overloading. The result is a
1213 complete expression that implements the operation. PARAMS really
1214 has type VEC(tree,gc)*, but we don't want to include tree.h here. */
1216 (resolve_overloaded_builtin,
1218 tree, (unsigned int /*location_t*/ loc, tree fndecl, void *arglist), NULL)
1220 /* Fold a target-specific builtin. */
1224 tree, (tree fndecl, int n_args, tree *argp, bool ignore),
1225 hook_tree_tree_int_treep_bool_null)
1227 /* Returns a code for a target-specific builtin that implements
1228 reciprocal of the function, or NULL_TREE if not available. */
1230 (builtin_reciprocal,
1232 tree, (unsigned fn, bool md_fn, bool sqrt),
1233 default_builtin_reciprocal)
1235 /* For a vendor-specific TYPE, return a pointer to a statically-allocated
1236 string containing the C++ mangling for TYPE. In all other cases, return
1241 const char *, (const_tree type),
1242 hook_constcharptr_const_tree_null)
1244 /* Make any adjustments to libfunc names needed for this target. */
1251 /* Add a __gnu_ prefix to library functions rather than just __. */
1253 (libfunc_gnu_prefix,
1254 "If false (the default), internal library routines start with two\n\
1255 underscores. If set to true, these routines start with @code{__gnu_}\n\
1256 instead. E.g., @code{__muldi3} changes to @code{__gnu_muldi3}. This\n\
1257 currently only affects functions defined in @file{libgcc2.c}. If this\n\
1258 is set to true, the @file{tm.h} file must also\n\
1259 @code{#define LIBGCC2_GNU_PREFIX}.",
1262 /* Given a decl, a section name, and whether the decl initializer
1263 has relocs, choose attributes for the section. */
1264 /* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION. */
1266 (section_type_flags,
1268 unsigned int, (tree decl, const char *name, int reloc),
1269 default_section_type_flags)
1271 /* True if new jumps cannot be created, to replace existing ones or
1272 not, at the current point in the compilation. */
1274 (cannot_modify_jumps_p,
1277 hook_bool_void_false)
1279 /* Return a register class for which branch target register
1280 optimizations should be applied. */
1282 (branch_target_register_class,
1284 reg_class_t, (void),
1285 default_branch_target_register_class)
1287 /* Return true if branch target register optimizations should include
1288 callee-saved registers that are not already live during the current
1289 function. AFTER_PE_GEN is true if prologues and epilogues have
1290 already been generated. */
1292 (branch_target_register_callee_saved,
1294 bool, (bool after_prologue_epilogue_gen),
1295 hook_bool_bool_false)
1297 /* Return true if the target supports conditional execution. */
1299 (have_conditional_execution,
1302 default_have_conditional_execution)
1304 /* Return a new value for loop unroll size. */
1306 (loop_unroll_adjust,
1308 unsigned, (unsigned nunroll, struct loop *loop),
1311 /* True if X is a legitimate MODE-mode immediate operand. */
1313 (legitimate_constant_p,
1315 bool, (enum machine_mode mode, rtx x),
1316 hook_bool_mode_rtx_true)
1318 /* True if the constant X cannot be placed in the constant pool. */
1320 (cannot_force_const_mem,
1322 bool, (enum machine_mode mode, rtx x),
1323 hook_bool_mode_rtx_false)
1326 (cannot_copy_insn_p,
1327 "True if the insn @var{x} cannot be duplicated.",
1330 /* True if X is considered to be commutative. */
1334 bool, (const_rtx x, int outer_code),
1335 hook_bool_const_rtx_commutative_p)
1337 /* True if ADDR is an address-expression whose effect depends
1338 on the mode of the memory reference it is used in. */
1340 (mode_dependent_address_p,
1342 bool, (const_rtx addr),
1343 default_mode_dependent_address_p)
1345 /* Given an invalid address X for a given machine mode, try machine-specific
1346 ways to make it legitimate. Return X or an invalid address on failure. */
1348 (legitimize_address,
1350 rtx, (rtx x, rtx oldx, enum machine_mode mode),
1351 default_legitimize_address)
1353 /* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */
1355 (delegitimize_address,
1358 delegitimize_mem_from_attrs)
1360 /* Given an address RTX, say whether it is valid. */
1362 (legitimate_address_p,
1364 bool, (enum machine_mode mode, rtx x, bool strict),
1365 default_legitimate_address_p)
1367 /* True if the given constant can be put into an object_block. */
1369 (use_blocks_for_constant_p,
1371 bool, (enum machine_mode mode, const_rtx x),
1372 hook_bool_mode_const_rtx_false)
1374 /* The minimum and maximum byte offsets for anchored addresses. */
1385 /* True if section anchors can be used to access the given symbol. */
1387 (use_anchors_for_symbol_p,
1389 bool, (const_rtx x),
1390 default_use_anchors_for_symbol_p)
1392 /* True if it is OK to do sibling call optimization for the specified
1393 call expression EXP. DECL will be the called function, or NULL if
1394 this is an indirect call. */
1396 (function_ok_for_sibcall,
1398 bool, (tree decl, tree exp),
1399 hook_bool_tree_tree_false)
1401 /* Establish appropriate back-end context for processing the function
1402 FNDECL. The argument might be NULL to indicate processing at top
1403 level, outside of any function scope. */
1405 (set_current_function,
1407 void, (tree decl), hook_void_tree)
1409 /* True if EXP should be placed in a "small data" section. */
1413 bool, (const_tree exp),
1414 hook_bool_const_tree_false)
1416 /* True if EXP names an object for which name resolution must resolve
1417 to the current executable or shared library. */
1421 bool, (const_tree exp),
1422 default_binds_local_p)
1424 /* Check if profiling code is before or after prologue. */
1426 (profile_before_prologue,
1427 "It returns true if target wants profile code emitted before prologue.\n\n\
1428 The default version of this hook use the target macro\n\
1429 @code{PROFILE_BEFORE_PROLOGUE}.",
1431 default_profile_before_prologue)
1433 /* Modify and return the identifier of a DECL's external name,
1434 originally identified by ID, as required by the target,
1435 (eg, append @nn to windows32 stdcall function names).
1436 The default is to return ID without modification. */
1438 (mangle_decl_assembler_name,
1440 tree, (tree decl, tree id),
1441 default_mangle_decl_assembler_name)
1443 /* Do something target-specific to record properties of the DECL into
1444 the associated SYMBOL_REF. */
1446 (encode_section_info,
1448 void, (tree decl, rtx rtl, int new_decl_p),
1449 default_encode_section_info)
1451 /* Undo the effects of encode_section_info on the symbol string. */
1453 (strip_name_encoding,
1455 const char *, (const char *name),
1456 default_strip_name_encoding)
1458 /* If shift optabs for MODE are known to always truncate the shift count,
1459 return the mask that they apply. Return 0 otherwise. */
1461 (shift_truncation_mask,
1463 unsigned HOST_WIDE_INT, (enum machine_mode mode),
1464 default_shift_truncation_mask)
1466 /* Return the number of divisions in the given MODE that should be present,
1467 so that it is profitable to turn the division into a multiplication by
1470 (min_divisions_for_recip_mul,
1472 unsigned int, (enum machine_mode mode),
1473 default_min_divisions_for_recip_mul)
1475 /* If the representation of integral MODE is such that values are
1476 always sign-extended to a wider mode MODE_REP then return
1477 SIGN_EXTEND. Return UNKNOWN otherwise. */
1478 /* Note that the return type ought to be RTX_CODE, but that's not
1479 necessarily defined at this point. */
1483 int, (enum machine_mode mode, enum machine_mode rep_mode),
1484 default_mode_rep_extended)
1486 /* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */
1488 (valid_pointer_mode,
1490 bool, (enum machine_mode mode),
1491 default_valid_pointer_mode)
1493 /* Disambiguate with errno. */
1495 (ref_may_alias_errno,
1496 "Define this to return nonzero if the memory reference @var{ref}\
1497 may alias with the system C library errno location. The default\
1498 version of this hook assumes the system C library errno location\
1499 is either a declaration of type int or accessed by dereferencing\
1501 bool, (struct ao_ref_s *ref),
1502 default_ref_may_alias_errno)
1504 /* Support for named address spaces. */
1506 #define HOOK_PREFIX "TARGET_ADDR_SPACE_"
1507 HOOK_VECTOR (TARGET_ADDR_SPACE_HOOKS, addr_space)
1509 /* MODE to use for a pointer into another address space. */
1513 enum machine_mode, (addr_space_t address_space),
1514 default_addr_space_pointer_mode)
1516 /* MODE to use for an address in another address space. */
1520 enum machine_mode, (addr_space_t address_space),
1521 default_addr_space_address_mode)
1523 /* True if MODE is valid for a pointer in __attribute__((mode("MODE")))
1524 in another address space. */
1526 (valid_pointer_mode,
1528 bool, (enum machine_mode mode, addr_space_t as),
1529 default_addr_space_valid_pointer_mode)
1531 /* True if an address is a valid memory address to a given named address
1532 space for a given mode. */
1534 (legitimate_address_p,
1536 bool, (enum machine_mode mode, rtx exp, bool strict, addr_space_t as),
1537 default_addr_space_legitimate_address_p)
1539 /* Return an updated address to convert an invalid pointer to a named
1540 address space to a valid one. If NULL_RTX is returned use machine
1541 independent methods to make the address valid. */
1543 (legitimize_address,
1545 rtx, (rtx x, rtx oldx, enum machine_mode mode, addr_space_t as),
1546 default_addr_space_legitimize_address)
1548 /* True if one named address space is a subset of another named address. */
1552 bool, (addr_space_t subset, addr_space_t superset),
1553 default_addr_space_subset_p)
1555 /* Function to convert an rtl expression from one address space to another. */
1559 rtx, (rtx op, tree from_type, tree to_type),
1560 default_addr_space_convert)
1562 HOOK_VECTOR_END (addr_space)
1565 #define HOOK_PREFIX "TARGET_"
1567 /* True if MODE is valid for the target. By "valid", we mean able to
1568 be manipulated in non-trivial ways. In particular, this means all
1569 the arithmetic is supported. */
1571 (scalar_mode_supported_p,
1573 bool, (enum machine_mode mode),
1574 default_scalar_mode_supported_p)
1576 /* Similarly for vector modes. "Supported" here is less strict. At
1577 least some operations are supported; need to check optabs or builtins
1578 for further details. */
1580 (vector_mode_supported_p,
1582 bool, (enum machine_mode mode),
1583 hook_bool_mode_false)
1585 /* True if we should try to use a scalar mode to represent an array,
1586 overriding the usual MAX_FIXED_MODE limit. */
1588 (array_mode_supported_p,
1589 "Return true if GCC should try to use a scalar mode to store an array\n\
1590 of @var{nelems} elements, given that each element has mode @var{mode}.\n\
1591 Returning true here overrides the usual @code{MAX_FIXED_MODE} limit\n\
1592 and allows GCC to use any defined integer mode.\n\
1594 One use of this hook is to support vector load and store operations\n\
1595 that operate on several homogeneous vectors. For example, ARM NEON\n\
1596 has operations like:\n\
1599 int8x8x3_t vld3_s8 (const int8_t *)\n\
1600 @end smallexample\n\
1602 where the return type is defined as:\n\
1605 typedef struct int8x8x3_t\n\
1609 @end smallexample\n\
1611 If this hook allows @code{val} to have a scalar mode, then\n\
1612 @code{int8x8x3_t} can have the same mode. GCC can then store\n\
1613 @code{int8x8x3_t}s in registers rather than forcing them onto the stack.",
1614 bool, (enum machine_mode mode, unsigned HOST_WIDE_INT nelems),
1615 hook_bool_mode_uhwi_false)
1617 /* Compute cost of moving data from a register of class FROM to one of
1620 (register_move_cost,
1622 int, (enum machine_mode mode, reg_class_t from, reg_class_t to),
1623 default_register_move_cost)
1625 /* Compute cost of moving registers to/from memory. */
1626 /* ??? Documenting the argument types for this hook requires a GFDL
1627 license grant. Also, the documentation uses a different name for RCLASS. */
1631 int, (enum machine_mode mode, reg_class_t rclass, bool in),
1632 default_memory_move_cost)
1634 /* True for MODE if the target expects that registers in this mode will
1635 be allocated to registers in a small register class. The compiler is
1636 allowed to use registers explicitly used in the rtl as spill registers
1637 but it should prevent extending the lifetime of these registers. */
1639 (small_register_classes_for_mode_p,
1641 bool, (enum machine_mode mode),
1642 hook_bool_mode_false)
1644 /* Register number for a flags register. Only needs to be defined if the
1645 target is constrainted to use post-reload comparison elimination. */
1648 "If the target has a dedicated flags register, and it needs to use the\
1649 post-reload comparison elimination pass, then this value should be set\
1651 unsigned int, INVALID_REGNUM)
1653 /* Compute a (partial) cost for rtx X. Return true if the complete
1654 cost has been computed, and false if subexpressions should be
1655 scanned. In either case, *TOTAL contains the cost result. */
1656 /* Note that CODE and OUTER_CODE ought to be RTX_CODE, but that's
1657 not necessarily defined at this point. */
1661 bool, (rtx x, int code, int outer_code, int opno, int *total, bool speed),
1662 hook_bool_rtx_int_int_int_intp_bool_false)
1664 /* Compute the cost of X, used as an address. Never called with
1665 invalid addresses. */
1669 int, (rtx address, bool speed),
1670 default_address_cost)
1672 /* Return where to allocate pseudo for a given hard register initial value. */
1674 (allocate_initial_value,
1676 rtx, (rtx hard_reg), NULL)
1678 /* Return nonzero if evaluating UNSPEC[_VOLATILE] X might cause a trap.
1679 FLAGS has the same meaning as in rtlanal.c: may_trap_p_1. */
1683 int, (const_rtx x, unsigned flags),
1684 default_unspec_may_trap_p)
1686 /* Given a register, this hook should return a parallel of registers
1687 to represent where to find the register pieces. Define this hook
1688 if the register and its mode are represented in Dwarf in
1689 non-contiguous locations, or if the register should be
1690 represented in more than one register in Dwarf. Otherwise, this
1691 hook should return NULL_RTX. */
1693 (dwarf_register_span,
1698 /* If expand_builtin_init_dwarf_reg_sizes needs to fill in table
1699 entries not corresponding directly to registers below
1700 FIRST_PSEUDO_REGISTER, this hook should generate the necessary
1701 code, given the address of the table. */
1703 (init_dwarf_reg_sizes_extra,
1705 void, (tree address),
1708 /* Fetch the fixed register(s) which hold condition codes, for
1709 targets where it makes sense to look for duplicate assignments to
1710 the condition codes. This should return true if there is such a
1711 register, false otherwise. The arguments should be set to the
1712 fixed register numbers. Up to two condition code registers are
1713 supported. If there is only one for this target, the int pointed
1714 at by the second argument should be set to -1. */
1716 (fixed_condition_code_regs,
1718 bool, (unsigned int *p1, unsigned int *p2),
1719 hook_bool_uintp_uintp_false)
1721 /* If two condition code modes are compatible, return a condition
1722 code mode which is compatible with both, such that a comparison
1723 done in the returned mode will work for both of the original
1724 modes. If the condition code modes are not compatible, return
1727 (cc_modes_compatible,
1729 enum machine_mode, (enum machine_mode m1, enum machine_mode m2),
1730 default_cc_modes_compatible)
1732 /* Do machine-dependent code transformations. Called just before
1733 delayed-branch scheduling. */
1735 (machine_dependent_reorg,
1739 /* Create the __builtin_va_list type. */
1741 (build_builtin_va_list,
1744 std_build_builtin_va_list)
1746 /* Enumerate the va list variants. */
1750 int, (int idx, const char **pname, tree *ptree),
1753 /* Get the cfun/fndecl calling abi __builtin_va_list type. */
1757 tree, (tree fndecl),
1760 /* Get the __builtin_va_list type dependent on input type. */
1762 (canonical_va_list_type,
1765 std_canonical_va_list_type)
1767 /* ??? Documenting this hook requires a GFDL license grant. */
1769 (expand_builtin_va_start,
1770 "Expand the @code{__builtin_va_start} builtin.",
1771 void, (tree valist, rtx nextarg), NULL)
1773 /* Gimplifies a VA_ARG_EXPR. */
1775 (gimplify_va_arg_expr,
1777 tree, (tree valist, tree type, gimple_seq *pre_p, gimple_seq *post_p),
1778 std_gimplify_va_arg_expr)
1780 /* Validity-checking routines for PCH files, target-specific.
1781 get_pch_validity returns a pointer to the data to be stored,
1782 and stores the size in its argument. pch_valid_p gets the same
1783 information back and returns NULL if the PCH is valid,
1784 or an error message if not. */
1788 void *, (size_t *sz),
1789 default_get_pch_validity)
1794 const char *, (const void *data, size_t sz),
1795 default_pch_valid_p)
1797 /* If nonnull, this function checks whether a PCH file with the
1798 given set of target flags can be used. It returns NULL if so,
1799 otherwise it returns an error message. */
1801 (check_pch_target_flags,
1803 const char *, (int pch_flags), NULL)
1805 /* True if the compiler should give an enum type only as many
1806 bytes as it takes to represent the range of possible values of
1809 (default_short_enums,
1812 hook_bool_void_false)
1814 /* This target hook returns an rtx that is used to store the address
1815 of the current frame into the built-in setjmp buffer. */
1817 (builtin_setjmp_frame_value,
1820 default_builtin_setjmp_frame_value)
1822 /* This target hook should add STRING_CST trees for any hard regs
1823 the port wishes to automatically clobber for an asm. */
1827 tree, (tree outputs, tree inputs, tree clobbers),
1828 hook_tree_tree_tree_tree_3rd_identity)
1830 /* This target hook allows the backend to specify a calling convention
1831 in the debug information. This function actually returns an
1832 enum dwarf_calling_convention, but because of forward declarations
1833 and not wanting to include dwarf2.h everywhere target.h is included
1834 the function is being declared as an int. */
1836 (dwarf_calling_convention,
1838 int, (const_tree function),
1839 hook_int_const_tree_0)
1841 /* This target hook allows the backend to emit frame-related insns that
1842 contain UNSPECs or UNSPEC_VOLATILEs. The call frame debugging info
1843 engine will invoke it on insns of the form
1844 (set (reg) (unspec [...] UNSPEC_INDEX))
1846 (set (reg) (unspec_volatile [...] UNSPECV_INDEX))
1847 to let the backend emit the call frame instructions. */
1849 (dwarf_handle_frame_unspec,
1851 void, (const char *label, rtx pattern, int index), NULL)
1853 /* ??? Documenting this hook requires a GFDL license grant. */
1855 (stdarg_optimize_hook,
1856 "Perform architecture specific checking of statements gimplified\
1857 from @code{VA_ARG_EXPR}. @var{stmt} is the statement. Returns true if\
1858 the statement doesn't need to be checked for @code{va_list} references.",
1859 bool, (struct stdarg_info *ai, const_gimple stmt), NULL)
1861 /* This target hook allows the operating system to override the DECL
1862 that represents the external variable that contains the stack
1863 protection guard variable. The type of this DECL is ptr_type_node. */
1865 (stack_protect_guard,
1868 default_stack_protect_guard)
1870 /* This target hook allows the operating system to override the CALL_EXPR
1871 that is invoked when a check vs the guard variable fails. */
1873 (stack_protect_fail,
1876 default_external_stack_protect_fail)
1878 /* Returns NULL if target supports the insn within a doloop block,
1879 otherwise it returns an error message. */
1881 (invalid_within_doloop,
1883 const char *, (const_rtx insn),
1884 default_invalid_within_doloop)
1887 (valid_dllimport_attribute_p,
1888 "@var{decl} is a variable or function with @code{__attribute__((dllimport))}\
1889 specified. Use this hook if the target needs to add extra validation\
1890 checks to @code{handle_dll_attribute}.",
1891 bool, (const_tree decl),
1892 hook_bool_const_tree_true)
1894 /* If non-zero, align constant anchors in CSE to a multiple of this
1899 unsigned HOST_WIDE_INT, 0)
1901 /* Functions relating to calls - argument passing, returns, etc. */
1902 /* Members of struct call have no special macro prefix. */
1903 HOOK_VECTOR (TARGET_CALLS, calls)
1906 (promote_function_mode,
1908 enum machine_mode, (const_tree type, enum machine_mode mode, int *punsignedp,
1909 const_tree funtype, int for_return),
1910 default_promote_function_mode)
1913 (promote_prototypes,
1915 bool, (const_tree fntype),
1916 hook_bool_const_tree_false)
1921 rtx, (tree fndecl, int incoming),
1922 hook_rtx_tree_int_null)
1926 bool, (const_tree type, const_tree fntype),
1927 default_return_in_memory)
1932 bool, (const_tree type),
1933 hook_bool_const_tree_false)
1935 /* Return true if a parameter must be passed by reference. TYPE may
1936 be null if this is a libcall. CA may be null if this query is
1937 from __builtin_va_arg. */
1942 (cumulative_args_t cum, enum machine_mode mode, const_tree type, bool named),
1943 hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false)
1946 (expand_builtin_saveregs,
1949 default_expand_builtin_saveregs)
1951 /* Returns pretend_argument_size. */
1953 (setup_incoming_varargs,
1955 void, (cumulative_args_t args_so_far, enum machine_mode mode, tree type,
1956 int *pretend_args_size, int second_time),
1957 default_setup_incoming_varargs)
1960 (strict_argument_naming,
1962 bool, (cumulative_args_t ca),
1963 hook_bool_CUMULATIVE_ARGS_false)
1965 /* Returns true if we should use
1966 targetm.calls.setup_incoming_varargs() and/or
1967 targetm.calls.strict_argument_naming(). */
1969 (pretend_outgoing_varargs_named,
1971 bool, (cumulative_args_t ca),
1972 default_pretend_outgoing_varargs_named)
1974 /* Given a complex type T, return true if a parameter of type T
1975 should be passed as two scalars. */
1979 bool, (const_tree type), NULL)
1981 /* Return true if type T, mode MODE, may not be passed in registers,
1982 but must be passed on the stack. */
1983 /* ??? This predicate should be applied strictly after pass-by-reference.
1984 Need audit to verify that this is the case. */
1986 (must_pass_in_stack,
1988 bool, (enum machine_mode mode, const_tree type),
1989 must_pass_in_stack_var_size_or_pad)
1991 /* Return true if type TYPE, mode MODE, which is passed by reference,
1992 should have the object copy generated by the callee rather than
1993 the caller. It is never called for TYPE requiring constructors. */
1998 (cumulative_args_t cum, enum machine_mode mode, const_tree type, bool named),
1999 hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false)
2001 /* Return zero for arguments passed entirely on the stack or entirely
2002 in registers. If passed in both, return the number of bytes passed
2003 in registers; the balance is therefore passed on the stack. */
2007 int, (cumulative_args_t cum, enum machine_mode mode, tree type, bool named),
2008 hook_int_CUMULATIVE_ARGS_mode_tree_bool_0)
2010 /* Update the state in CA to advance past an argument in the
2011 argument list. The values MODE, TYPE, and NAMED describe that
2014 (function_arg_advance,
2017 (cumulative_args_t ca, enum machine_mode mode, const_tree type, bool named),
2018 default_function_arg_advance)
2020 /* Return zero if the argument described by the state of CA should
2021 be placed on a stack, or a hard register in which to store the
2022 argument. The values MODE, TYPE, and NAMED describe that
2027 rtx, (cumulative_args_t ca, enum machine_mode mode, const_tree type,
2029 default_function_arg)
2031 /* Likewise, but for machines with register windows. Return the
2032 location where the argument will appear to the callee. */
2034 (function_incoming_arg,
2036 rtx, (cumulative_args_t ca, enum machine_mode mode, const_tree type,
2038 default_function_incoming_arg)
2041 (function_arg_boundary,
2043 unsigned int, (enum machine_mode mode, const_tree type),
2044 default_function_arg_boundary)
2047 (function_arg_round_boundary,
2048 "Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY},\n\
2049 which is the default value for this hook. You can define this hook to\n\
2050 return a different value if an argument size must be rounded to a larger\n\
2052 unsigned int, (enum machine_mode mode, const_tree type),
2053 default_function_arg_round_boundary)
2055 /* Return the diagnostic message string if function without a prototype
2056 is not allowed for this 'val' argument; NULL otherwise. */
2058 (invalid_arg_for_unprototyped_fn,
2060 const char *, (const_tree typelist, const_tree funcdecl, const_tree val),
2061 hook_invalid_arg_for_unprototyped_fn)
2063 /* Return an rtx for the return value location of the function
2064 specified by FN_DECL_OR_TYPE with a return type of RET_TYPE. */
2068 rtx, (const_tree ret_type, const_tree fn_decl_or_type, bool outgoing),
2069 default_function_value)
2071 /* Return the rtx for the result of a libcall of mode MODE,
2072 calling the function FN_NAME. */
2076 rtx, (enum machine_mode mode, const_rtx fun),
2077 default_libcall_value)
2079 /* Return true if REGNO is a possible register number for
2080 a function value as seen by the caller. */
2082 (function_value_regno_p,
2084 bool, (const unsigned int regno),
2085 default_function_value_regno_p)
2087 /* ??? Documenting this hook requires a GFDL license grant. */
2089 (internal_arg_pointer,
2090 "Return an rtx for the argument pointer incoming to the\
2093 default_internal_arg_pointer)
2095 /* Update the current function stack boundary if needed. */
2097 (update_stack_boundary,
2101 /* Handle stack alignment and return an rtx for Dynamic Realign
2102 Argument Pointer if necessary. */
2108 /* Return true if all function parameters should be spilled to the
2111 (allocate_stack_slots_for_args,
2114 hook_bool_void_true)
2116 /* Return an rtx for the static chain for FNDECL. If INCOMING_P is true,
2117 then it should be for the callee; otherwise for the caller. */
2121 rtx, (const_tree fndecl, bool incoming_p),
2122 default_static_chain)
2124 /* Fill in the trampoline at MEM with a call to FNDECL and a
2125 static chain value of CHAIN. */
2129 void, (rtx m_tramp, tree fndecl, rtx static_chain),
2130 default_trampoline_init)
2132 /* Adjust the address of the trampoline in a target-specific way. */
2134 (trampoline_adjust_address,
2136 rtx, (rtx addr), NULL)
2138 /* Return the number of bytes of its own arguments that a function
2139 pops on returning, or 0 if the function pops no arguments and the
2140 caller must therefore pop them all after the function returns. */
2141 /* ??? tm.texi has no types for the parameters. */
2145 int, (tree fundecl, tree funtype, int size),
2146 default_return_pops_args)
2148 /* Return a mode wide enough to copy any function value that might be
2151 (get_raw_result_mode,
2152 "This target hook returns the mode to be used when accessing raw return\
2153 registers in @code{__builtin_return}. Define this macro if the value\
2154 in @var{reg_raw_mode} is not correct.",
2155 enum machine_mode, (int regno),
2156 default_get_reg_raw_mode)
2158 /* Return a mode wide enough to copy any argument value that might be
2162 "This target hook returns the mode to be used when accessing raw argument\
2163 registers in @code{__builtin_apply_args}. Define this macro if the value\
2164 in @var{reg_raw_mode} is not correct.",
2165 enum machine_mode, (int regno),
2166 default_get_reg_raw_mode)
2168 HOOK_VECTOR_END (calls)
2170 /* Return the diagnostic message string if conversion from FROMTYPE
2171 to TOTYPE is not allowed, NULL otherwise. */
2173 (invalid_conversion,
2175 const char *, (const_tree fromtype, const_tree totype),
2176 hook_constcharptr_const_tree_const_tree_null)
2178 /* Return the diagnostic message string if the unary operation OP is
2179 not permitted on TYPE, NULL otherwise. */
2183 const char *, (int op, const_tree type),
2184 hook_constcharptr_int_const_tree_null)
2186 /* Return the diagnostic message string if the binary operation OP
2187 is not permitted on TYPE1 and TYPE2, NULL otherwise. */
2191 const char *, (int op, const_tree type1, const_tree type2),
2192 hook_constcharptr_int_const_tree_const_tree_null)
2194 /* Return the diagnostic message string if TYPE is not valid as a
2195 function parameter type, NULL otherwise. */
2197 (invalid_parameter_type,
2199 const char *, (const_tree type),
2200 hook_constcharptr_const_tree_null)
2202 /* Return the diagnostic message string if TYPE is not valid as a
2203 function return type, NULL otherwise. */
2205 (invalid_return_type,
2207 const char *, (const_tree type),
2208 hook_constcharptr_const_tree_null)
2210 /* If values of TYPE are promoted to some other type when used in
2211 expressions (analogous to the integer promotions), return that type,
2212 or NULL_TREE otherwise. */
2216 tree, (const_tree type),
2217 hook_tree_const_tree_null)
2219 /* Convert EXPR to TYPE, if target-specific types with special conversion
2220 rules are involved. Return the converted expression, or NULL to apply
2221 the standard conversion rules. */
2225 tree, (tree type, tree expr),
2226 hook_tree_tree_tree_null)
2228 /* Return the class for a secondary reload, and fill in extra information. */
2233 (bool in_p, rtx x, reg_class_t reload_class, enum machine_mode reload_mode,
2234 secondary_reload_info *sri),
2235 default_secondary_reload)
2237 /* Given an rtx X being reloaded into a reg required to be in class CLASS,
2238 return the class of reg to actually use. */
2240 (preferred_reload_class,
2243 (rtx x, reg_class_t rclass),
2244 default_preferred_reload_class)
2246 /* Like TARGET_PREFERRED_RELOAD_CLASS, but for output reloads instead of
2249 (preferred_output_reload_class,
2252 (rtx x, reg_class_t rclass),
2253 default_preferred_output_reload_class)
2256 (class_likely_spilled_p,
2258 bool, (reg_class_t rclass),
2259 default_class_likely_spilled_p)
2261 /* Return the maximum number of consecutive registers
2262 needed to represent mode MODE in a register of class RCLASS. */
2266 unsigned char, (reg_class_t rclass, enum machine_mode mode),
2267 default_class_max_nregs)
2270 (preferred_rename_class,
2271 "A target hook that places additional preference on the register\
2272 class to use when it is necessary to rename a register in class\
2273 @var{rclass} to another class, or perhaps @var{NO_REGS}, if no\
2274 preferred register class is found or hook @code{preferred_rename_class}\
2275 is not implemented.\
2276 Sometimes returning a more restrictive class makes better code. For\
2277 example, on ARM, thumb-2 instructions using @code{LO_REGS} may be\
2278 smaller than instructions using @code{GENERIC_REGS}. By returning\
2279 @code{LO_REGS} from @code{preferred_rename_class}, code size can\
2281 reg_class_t, (reg_class_t rclass),
2282 default_preferred_rename_class)
2284 /* This target hook allows the backend to perform additional
2285 processing while initializing for variable expansion. */
2287 (expand_to_rtl_hook,
2292 /* This target hook allows the backend to perform additional
2293 instantiations on rtx that are not actually in insns yet,
2294 but will be later. */
2301 /* Return true if is OK to use a hard register REGNO as scratch register
2304 (hard_regno_scratch_ok,
2306 bool, (unsigned int regno),
2307 default_hard_regno_scratch_ok)
2309 /* Return the smallest number of different values for which it is best to
2310 use a jump-table instead of a tree of conditional branches. */
2312 (case_values_threshold,
2314 unsigned int, (void),
2315 default_case_values_threshold)
2317 /* Retutn true if a function must have and use a frame pointer. */
2319 (frame_pointer_required,
2322 hook_bool_void_false)
2324 /* Returns true if the compiler is allowed to try to replace register number
2325 from-reg with register number to-reg. */
2329 bool, (const int from_reg, const int to_reg),
2330 hook_bool_const_int_const_int_true)
2332 /* Modify any or all of fixed_regs, call_used_regs, global_regs,
2333 reg_names, and reg_class_contents to account of the vagaries of the
2336 (conditional_register_usage,
2341 /* Functions specific to the C family of frontends. */
2343 #define HOOK_PREFIX "TARGET_C_"
2344 HOOK_VECTOR (TARGET_C, c)
2346 /* ??? Documenting this hook requires a GFDL license grant. */
2349 "Return machine mode for non-standard constant literal suffix @var{c},\
2350 or VOIDmode if non-standard suffixes are unsupported.",
2351 enum machine_mode, (char c),
2352 default_mode_for_suffix)
2356 /* Functions specific to the C++ frontend. */
2358 #define HOOK_PREFIX "TARGET_CXX_"
2359 HOOK_VECTOR (TARGET_CXX, cxx)
2361 /* Return the integer type used for guard variables. */
2366 default_cxx_guard_type)
2368 /* Return true if only the low bit of the guard should be tested. */
2373 hook_bool_void_false)
2375 /* Returns the size of the array cookie for an array of type. */
2380 default_cxx_get_cookie_size)
2382 /* Returns true if the element size should be stored in the array cookie. */
2387 hook_bool_void_false)
2389 /* Allows backends to perform additional processing when
2390 deciding if a class should be exported or imported. */
2392 (import_export_class,
2394 int, (tree type, int import_export), NULL)
2396 /* Returns true if constructors and destructors return "this". */
2398 (cdtor_returns_this,
2401 hook_bool_void_false)
2403 /* Returns true if the key method for a class can be an inline
2404 function, so long as it is not declared inline in the class
2405 itself. Returning true is the behavior required by the Itanium C++ ABI. */
2407 (key_method_may_be_inline,
2410 hook_bool_void_true)
2413 (determine_class_data_visibility,
2414 "@var{decl} is a virtual table, virtual table table, typeinfo object,\
2415 or other similar implicit class data object that will be emitted with\
2416 external linkage in this translation unit. No ELF visibility has been\
2417 explicitly specified. If the target needs to specify a visibility\
2418 other than that of the containing class, use this hook to set\
2419 @code{DECL_VISIBILITY} and @code{DECL_VISIBILITY_SPECIFIED}.",
2423 /* Returns true (the default) if virtual tables and other
2424 similar implicit class data objects are always COMDAT if they
2425 have external linkage. If this hook returns false, then
2426 class data for classes whose virtual table will be emitted in
2427 only one translation unit will not be COMDAT. */
2429 (class_data_always_comdat,
2432 hook_bool_void_true)
2434 /* Returns true (the default) if the RTTI for the basic types,
2435 which is always defined in the C++ runtime, should be COMDAT;
2436 false if it should not be COMDAT. */
2438 (library_rtti_comdat,
2441 hook_bool_void_true)
2443 /* Returns true if __aeabi_atexit should be used to register static
2449 hook_bool_void_false)
2451 /* Returns true if target may use atexit in the same manner as
2452 __cxa_atexit to register static destructors. */
2454 (use_atexit_for_cxa_atexit,
2457 hook_bool_void_false)
2460 (adjust_class_at_definition,
2461 "@var{type} is a C++ class (i.e., RECORD_TYPE or UNION_TYPE) that has just\
2462 been defined. Use this hook to make adjustments to the class (eg, tweak\
2463 visibility or perform any other required target modifications).",
2468 (decl_mangling_context,
2469 "Return target-specific mangling context of @var{decl} or @code{NULL_TREE}.",
2470 tree, (const_tree decl),
2471 hook_tree_const_tree_null)
2473 HOOK_VECTOR_END (cxx)
2475 /* Functions and data for emulated TLS support. */
2477 #define HOOK_PREFIX "TARGET_EMUTLS_"
2478 HOOK_VECTOR (TARGET_EMUTLS, emutls)
2480 /* Name of the address and common functions. */
2484 const char *, "__builtin___emutls_get_address")
2489 const char *, "__builtin___emutls_register_common")
2491 /* Prefixes for proxy variable and template. */
2502 /* Prefixes for proxy variable and template. */
2513 /* Function to generate field definitions of the proxy variable. */
2517 tree, (tree type, tree *name),
2518 default_emutls_var_fields)
2520 /* Function to initialize a proxy variable. */
2524 tree, (tree var, tree decl, tree tmpl_addr),
2525 default_emutls_var_init)
2527 /* Whether we are allowed to alter the usual alignment of the
2534 /* Whether we can emit debug information for TLS vars. */
2536 (debug_form_tls_address,
2540 HOOK_VECTOR_END (emutls)
2543 #define HOOK_PREFIX "TARGET_OPTION_"
2544 HOOK_VECTOR (TARGET_OPTION_HOOKS, target_option_hooks)
2546 /* Function to validate the attribute((option(...))) strings or NULL. If
2547 the option is validated, it is assumed that DECL_FUNCTION_SPECIFIC will
2548 be filled in in the function decl node. */
2552 bool, (tree fndecl, tree name, tree args, int flags),
2553 default_target_option_valid_attribute_p)
2555 /* Function to save any extra target state in the target options structure. */
2559 void, (struct cl_target_option *ptr), NULL)
2561 /* Function to restore any extra target state from the target options
2566 void, (struct cl_target_option *ptr), NULL)
2568 /* Function to print any extra target state from the target options
2573 void, (FILE *file, int indent, struct cl_target_option *ptr), NULL)
2575 /* Function to parse arguments to be validated for #pragma option, and to
2576 change the state if the options are valid. If the first argument is
2577 NULL, the second argument specifies the default options to use. Return
2578 true if the options are valid, and set the current state. */
2579 /* ??? The documentation in tm.texi is incomplete. */
2583 bool, (tree args, tree pop_target),
2584 default_target_option_pragma_parse)
2586 /* Do option overrides for the target. */
2593 /* Function to determine if one function can inline another function. */
2595 #define HOOK_PREFIX "TARGET_"
2599 bool, (tree caller, tree callee),
2600 default_target_can_inline_p)
2602 HOOK_VECTOR_END (target_option)
2604 /* For targets that need to mark extra registers as live on entry to
2605 the function, they should define this target hook and set their
2606 bits in the bitmap passed in. */
2608 (extra_live_on_entry,
2610 void, (bitmap regs),
2613 /* Determine the type of unwind info to emit for debugging. */
2617 enum unwind_info_type, (void),
2618 default_debug_unwind_info)
2620 /* Leave the boolean fields at the end. */
2622 /* True if we can create zeroed data by switching to a BSS section
2623 and then using ASM_OUTPUT_SKIP to allocate the space. */
2625 (have_switchable_bss_sections,
2629 /* True if "native" constructors and destructors are supported,
2630 false if we're using collect2 for the job. */
2636 /* True if thread-local storage is supported. */
2642 /* True if a small readonly data section is supported. */
2644 (have_srodata_section,
2648 /* True if EH frame info sections should be zero-terminated. */
2650 (terminate_dw2_eh_frame_info,
2654 /* True if #NO_APP should be emitted at the beginning of assembly output. */
2656 (asm_file_start_app_off,
2660 /* True if output_file_directive should be called for main_input_filename
2661 at the beginning of assembly output. */
2663 (asm_file_start_file_directive,
2668 (handle_pragma_extern_prefix,
2669 "True if @code{#pragma extern_prefix} is to be supported.",
2672 /* True if the target is allowed to reorder memory accesses unless
2673 synchronization is explicitly requested. */
2679 /* Returns true if we should generate exception tables for use with the
2680 ARM EABI. The effects the encoding of function exception specifications. */
2687 (want_debug_pub_sections,
2688 "True if the @code{.debug_pubtypes} and @code{.debug_pubnames} sections\
2689 should be emitted. These sections are not used on most platforms, and\
2690 in particular GDB does not use them.",
2694 (delay_sched2, "True if sched2 is not to be run at its normal place. \
2695 This usually means it will be run as part of machine-specific reorg.",
2699 (delay_vartrack, "True if vartrack is not to be run at its normal place. \
2700 This usually means it will be run as part of machine-specific reorg.",
2703 /* Leave the boolean fields at the end. */
2705 /* Close the 'struct gcc_target' definition. */
2706 HOOK_VECTOR_END (C90_EMPTY_HACK)