/* Target hook definitions.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ 2011
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
-/* The following macros should be provided by the including file:
-
- DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT): Define a function-valued hook.
- DEFHOOKPOD(DOC, TYPE, NAME, INIT): Define a piece-of-data 'hook'. */
-
-/* Defaults for optional macros:
- DEFHOOKPODX(NAME, TYPE, INIT): Like DEFHOOKPOD, but share documentation
- with the previous 'hook'. */
-#ifndef DEFHOOKPODX
-#define DEFHOOKPODX(NAME, TYPE, INIT) DEFHOOKPOD (NAME, 0, TYPE, INIT)
-#endif
-
-/* HOOKSTRUCT(FRAGMENT): Declarator fragments to encapsulate all the
- members into a struct gcc_target, which in turn contains several
- sub-structs. */
-#ifndef HOOKSTRUCT
-#define HOOKSTRUCT(FRAGMENT)
-#endif
-/* HOOK_VECTOR: Start a struct declaration, which then gets its own initializer.
- HOOK_VECTOR_END: Close a struct declaration, providing a member declarator
- name for nested use. */
-#ifndef HOOK_VECTOR_1
-#define HOOK_VECTOR_1(NAME, FRAGMENT) HOOKSTRUCT(FRAGMENT)
-#endif
-#define HOOK_VECTOR(INIT_NAME, SNAME) HOOK_VECTOR_1 (INIT_NAME, struct SNAME {)
-#define HOOK_VECTOR_END(DECL_NAME) HOOK_VECTOR_1(,} DECL_NAME ;)
+/* See target-hooks-macros.h for details of macros that should be
+ provided by the including file, and how to use them here. */
+#include "target-hooks-macros.h"
-HOOK_VECTOR (TARGET_INITIALIZER, gcc_target)
+#undef HOOK_TYPE
+#define HOOK_TYPE "Target Hook"
-/* FIXME: For pre-existing hooks, we can't place the documentation in the
- documentation field here till we get permission from the FSF to include
- it in GPLed software - the target hook documentation is so far only
- available under the GFDL. */
-
-/* A hook should generally be documented by a string in the DOC parameter,
- which should contain texinfo markup. If the documentation is only available
- under the GPL, but not under the GFDL, put it in a comment above the hook
- definition. If the function declaration is available both under GPL and
- GFDL, but the documentation is only available under the GFDL, put the
- documentaton in tm.texi.in, heading with @hook <hookname> and closing
- the paragraph with @end deftypefn / deftypevr as appropriate, and marking
- the next autogenerated hook with @hook <hookname>.
- In both these cases, leave the DOC string empty, i.e. "".
- Sometimes, for some historic reason the function declaration
- has to be documented differently
- than what it is. In that case, use DEFHOOK_UNDOC to supress auto-generation
- of documentation. DEFHOOK_UNDOC takes a DOC string which it ignores, so
- you can put GPLed documentation string there if you have hopes that you
- can clear the declaration & documentation for GFDL distribution later,
- in which case you can then simply change the DEFHOOK_UNDOC to DEFHOOK
- to turn on the autogeneration of the documentation.
-
- A documentation string of "*" means not to emit any documentation at all,
- and is mainly used internally for DEFHOOK_UNDOC. It should generally not
- be used otherwise, but it has its use for exceptional cases where automatic
- documentation is not wanted, and the real documentation is elsewere, like
- for TARGET_ASM_{,UN}ALIGNED_INT_OP, which are hooks only for implementation
- purposes; they refer to structs, the components of which are documented as
- separate hooks TARGET_ASM_{,UN}ALIGNED_[HSDT]I_OP.
- A DOC string of 0 is for internal use of DEFHOOKPODX and special table
- entries only. */
+HOOK_VECTOR (TARGET_INITIALIZER, gcc_target)
/* Functions that output assembler for the target. */
#define HOOK_PREFIX "TARGET_ASM_"
section *, (tree decl, enum node_frequency freq, bool startup, bool exit),
default_function_section)
+/* Output the assembler code for function exit. */
+DEFHOOK
+(function_switched_text_sections,
+ "Used by the target to emit any assembler directives or additional\
+ labels needed when a function is partitioned between different\
+ sections. Output should be written to @var{file}. The function\
+ decl is available as @var{decl} and the new section is `cold' if\
+ @var{new_is_cold} is @code{true}.",
+ void, (FILE *file, tree decl, bool new_is_cold),
+ default_function_switched_text_sections)
+
/* Return a mask describing how relocations should be treated when
selecting sections. Bit 1 should be set if global relocations
should be placed in a read-write section; bit 0 should be set if
bool ,(unsigned char code),
default_print_operand_punct_valid_p)
+/* Given a symbol name, perform same mangling as assemble_name and
+ ASM_OUTPUT_LABELREF, returning result as an IDENTIFIER_NODE. */
+DEFHOOK
+(mangle_assembler_name,
+ "Given a symbol @var{name}, perform same mangling as @code{varasm.c}'s\
+ @code{assemble_name}, but in memory rather than to a file stream, returning\
+ result as an @code{IDENTIFIER_NODE}. Required for correct LTO symtabs. The\
+ default implementation calls the @code{TARGET_STRIP_NAME_ENCODING} hook and\
+ then prepends the @code{USER_LABEL_PREFIX}, if any.",
+ tree, (const char *name),
+ default_mangle_assembler_name)
+
HOOK_VECTOR_END (asm_out)
/* Functions relating to instruction scheduling. All of these
void, (void),
hook_void_void)
-/* Handle target switch CODE (an OPT_* value). ARG is the argument
- passed to the switch; it is NULL if no argument was. VALUE is the
- value of ARG if CODE specifies a UInteger option, otherwise it is
- 1 if the positive form of the switch was used and 0 if the negative
- form was. Return true if the switch was valid. */
+/* Handle target switch DECODED for options structures OPTS and
+ OPTS_SET, at location LOC. Return true if the switch was valid. */
DEFHOOK
(handle_option,
"",
- bool, (size_t code, const char *arg, int value),
- hook_bool_size_t_constcharptr_int_true)
+ bool, (struct gcc_options *opts, struct gcc_options *opts_set,
+ const struct cl_decoded_option *decoded,
+ unsigned int /*location_t*/ loc),
+ default_target_handle_option)
/* Display extra, target specific information in response to a
--target-help switch. */
void, (void),
hook_void_void)
+ /* Add a __gnu_ prefix to library functions rather than just __. */
+DEFHOOKPOD
+(libfunc_gnu_prefix,
+ "If false (the default), internal library routines start with two\n\
+underscores. If set to true, these routines start with @code{__gnu_}\n\
+instead. E.g., @code{__muldi3} changes to @code{__gnu_muldi3}. This\n\
+currently only affects functions defined in @file{libgcc2.c}. If this\n\
+is set to true, the @file{tm.h} file must also\n\
+@code{#define LIBGCC2_GNU_PREFIX}.",
+ bool, false)
+
/* Given a decl, a section name, and whether the decl initializer
has relocs, choose attributes for the section. */
/* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION. */
unsigned, (unsigned nunroll, struct loop *loop),
NULL)
+/* True if X is a legitimate MODE-mode immediate operand. */
+DEFHOOK
+(legitimate_constant_p,
+ "",
+ bool, (enum machine_mode mode, rtx x),
+ hook_bool_mode_rtx_true)
+
/* True if the constant X cannot be placed in the constant pool. */
DEFHOOK
(cannot_force_const_mem,
"",
- bool, (rtx x),
- hook_bool_rtx_false)
+ bool, (enum machine_mode mode, rtx x),
+ hook_bool_mode_rtx_false)
DEFHOOK_UNDOC
(cannot_copy_insn_p,
bool, (enum machine_mode mode),
default_valid_pointer_mode)
+/* Disambiguate with errno. */
+DEFHOOK
+(ref_may_alias_errno,
+ "Define this to return nonzero if the memory reference @var{ref}\
+ may alias with the system C library errno location. The default\
+ version of this hook assumes the system C library errno location\
+ is either a declaration of type int or accessed by dereferencing\
+ a pointer to int.",
+ bool, (struct ao_ref_s *ref),
+ default_ref_may_alias_errno)
+
/* Support for named address spaces. */
#undef HOOK_PREFIX
#define HOOK_PREFIX "TARGET_ADDR_SPACE_"
bool, (enum machine_mode mode),
hook_bool_mode_false)
+/* True if we should try to use a scalar mode to represent an array,
+ overriding the usual MAX_FIXED_MODE limit. */
+DEFHOOK
+(array_mode_supported_p,
+ "Return true if GCC should try to use a scalar mode to store an array\n\
+of @var{nelems} elements, given that each element has mode @var{mode}.\n\
+Returning true here overrides the usual @code{MAX_FIXED_MODE} limit\n\
+and allows GCC to use any defined integer mode.\n\
+\n\
+One use of this hook is to support vector load and store operations\n\
+that operate on several homogeneous vectors. For example, ARM NEON\n\
+has operations like:\n\
+\n\
+@smallexample\n\
+int8x8x3_t vld3_s8 (const int8_t *)\n\
+@end smallexample\n\
+\n\
+where the return type is defined as:\n\
+\n\
+@smallexample\n\
+typedef struct int8x8x3_t\n\
+@{\n\
+ int8x8_t val[3];\n\
+@} int8x8x3_t;\n\
+@end smallexample\n\
+\n\
+If this hook allows @code{val} to have a scalar mode, then\n\
+@code{int8x8x3_t} can have the same mode. GCC can then store\n\
+@code{int8x8x3_t}s in registers rather than forcing them onto the stack.",
+ bool, (enum machine_mode mode, unsigned HOST_WIDE_INT nelems),
+ hook_bool_mode_uhwi_false)
+
/* Compute cost of moving data from a register of class FROM to one of
TO, using MODE. */
DEFHOOK
bool, (enum machine_mode mode),
hook_bool_mode_false)
+/* Register number for a flags register. Only needs to be defined if the
+ target is constrainted to use post-reload comparison elimination. */
+DEFHOOKPOD
+(flags_regnum,
+ "If the target has a dedicated flags register, and it needs to use the\
+ post-reload comparison elimination pass, then this value should be set\
+ appropriately.",
+ unsigned int, INVALID_REGNUM)
+
/* Compute a (partial) cost for rtx X. Return true if the complete
cost has been computed, and false if subexpressions should be
scanned. In either case, *TOTAL contains the cost result. */
/* Update the state in CA to advance past an argument in the
argument list. The values MODE, TYPE, and NAMED describe that
argument. */
-/* ??? tm.texi still only describes the old macro. */
-DEFHOOK_UNDOC
+DEFHOOK
(function_arg_advance,
"",
void,
be placed on a stack, or a hard register in which to store the
argument. The values MODE, TYPE, and NAMED describe that
argument. */
-/* ??? tm.texi still only describes the old macro. */
-DEFHOOK_UNDOC
+DEFHOOK
(function_arg,
"",
rtx, (CUMULATIVE_ARGS *ca, enum machine_mode mode, const_tree type,
/* Likewise, but for machines with register windows. Return the
location where the argument will appear to the callee. */
-/* ??? tm.texi still only describes the old macro. */
-DEFHOOK_UNDOC
+DEFHOOK
(function_incoming_arg,
"",
rtx, (CUMULATIVE_ARGS *ca, enum machine_mode mode, const_tree type,
tree, (tree type, tree expr),
hook_tree_tree_tree_null)
-/* Return the array of IRA cover classes for the current target. */
-DEFHOOK
-(ira_cover_classes,
- "",
- const reg_class_t *, (void),
- default_ira_cover_classes)
-
/* Return the class for a secondary reload, and fill in extra information. */
DEFHOOK
(secondary_reload,
/* Leave the boolean fields at the end. */
-/* Empty macro arguments are undefined in C90, so use an empty macro. */
-#define C90_EMPTY_HACK
/* Close the 'struct gcc_target' definition. */
HOOK_VECTOR_END (C90_EMPTY_HACK)
-
-HOOK_VECTOR (TARGETCM_INITIALIZER, gcc_targetcm)
-
-/* Handle target switch CODE (an OPT_* value). ARG is the argument
- passed to the switch; it is NULL if no argument was. VALUE is the
- value of ARG if CODE specifies a UInteger option, otherwise it is
- 1 if the positive form of the switch was used and 0 if the negative
- form was. Return true if the switch was valid. */
-DEFHOOK
-(handle_c_option,
- "",
- bool, (size_t code, const char *arg, int value),
- default_handle_c_option)
-
-/* Targets may provide a string object type that can be used within
- and between C, C++, and Objective-C dialects. */
-
-DEFHOOK
-(objc_construct_string_object,
- "Targets may provide a string object type that can be used within\
- and between C, C++ and their respective Objective-C dialects.\
- A string object might, for example, embed encoding and length information.\
- These objects are considered opaque to the compiler and handled as references.\
- An ideal implementation makes the composition of the string object\
- match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\
- allowing efficient interworking between C-only and Objective-C code.\
- If a target implements string objects then this hook should return a\
- reference to such an object constructed from the normal `C' string\
- representation provided in @var{string}.\
- At present, the hook is used by Objective-C only, to obtain a\
- common-format string object when the target provides one.",
- tree, (tree string),
- NULL)
-
-DEFHOOK
-(string_object_ref_type_p,
- "If a target implements string objects then this hook should return\
- @code{true} if @var{stringref} is a valid reference to such an object.",
- bool, (const_tree stringref),
- hook_bool_const_tree_false)
-
-DEFHOOK
-(check_string_object_format_arg,
- "If a target implements string objects then this hook should should\
- provide a facility to check the function arguments in @var{args_list}\
- against the format specifiers in @var{format_arg} where the type of\
- @var{format_arg} is one recognized as a valid string reference type.",
- void, (tree format_arg, tree args_list),
- NULL)
-
-HOOK_VECTOR_END (C90_EMPTY_HACK)