| @c Copyright (C) 1988,1989,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001, |
| @c 2002, 2003, 2004 Free Software Foundation, Inc. |
| @c This is part of the GCC manual. |
| @c For copying conditions, see the file gcc.texi. |
| |
| @node Target Macros |
| @chapter Target Description Macros and Functions |
| @cindex machine description macros |
| @cindex target description macros |
| @cindex macros, target description |
| @cindex @file{tm.h} macros |
| |
| In addition to the file @file{@var{machine}.md}, a machine description |
| includes a C header file conventionally given the name |
| @file{@var{machine}.h} and a C source file named @file{@var{machine}.c}. |
| The header file defines numerous macros that convey the information |
| about the target machine that does not fit into the scheme of the |
| @file{.md} file. The file @file{tm.h} should be a link to |
| @file{@var{machine}.h}. The header file @file{config.h} includes |
| @file{tm.h} and most compiler source files include @file{config.h}. The |
| source file defines a variable @code{targetm}, which is a structure |
| containing pointers to functions and data relating to the target |
| machine. @file{@var{machine}.c} should also contain their definitions, |
| if they are not defined elsewhere in GCC, and other functions called |
| through the macros defined in the @file{.h} file. |
| |
| @menu |
| * Target Structure:: The @code{targetm} variable. |
| * Driver:: Controlling how the driver runs the compilation passes. |
| * Run-time Target:: Defining @samp{-m} options like @option{-m68000} and @option{-m68020}. |
| * Per-Function Data:: Defining data structures for per-function information. |
| * Storage Layout:: Defining sizes and alignments of data. |
| * Type Layout:: Defining sizes and properties of basic user data types. |
| * Escape Sequences:: Defining the value of target character escape sequences |
| * Registers:: Naming and describing the hardware registers. |
| * Register Classes:: Defining the classes of hardware registers. |
| * Stack and Calling:: Defining which way the stack grows and by how much. |
| * Varargs:: Defining the varargs macros. |
| * Trampolines:: Code set up at run time to enter a nested function. |
| * Library Calls:: Controlling how library routines are implicitly called. |
| * Addressing Modes:: Defining addressing modes valid for memory operands. |
| * Condition Code:: Defining how insns update the condition code. |
| * Costs:: Defining relative costs of different operations. |
| * Scheduling:: Adjusting the behavior of the instruction scheduler. |
| * Sections:: Dividing storage into text, data, and other sections. |
| * PIC:: Macros for position independent code. |
| * Assembler Format:: Defining how to write insns and pseudo-ops to output. |
| * Debugging Info:: Defining the format of debugging output. |
| * Floating Point:: Handling floating point for cross-compilers. |
| * Mode Switching:: Insertion of mode-switching instructions. |
| * Target Attributes:: Defining target-specific uses of @code{__attribute__}. |
| * MIPS Coprocessors:: MIPS coprocessor support and how to customize it. |
| * PCH Target:: Validity checking for precompiled headers. |
| * Misc:: Everything else. |
| @end menu |
| |
| @node Target Structure |
| @section The Global @code{targetm} Variable |
| @cindex target hooks |
| @cindex target functions |
| |
| @deftypevar {struct gcc_target} targetm |
| The target @file{.c} file must define the global @code{targetm} variable |
| which contains pointers to functions and data relating to the target |
| machine. The variable is declared in @file{target.h}; |
| @file{target-def.h} defines the macro @code{TARGET_INITIALIZER} which is |
| used to initialize the variable, and macros for the default initializers |
| for elements of the structure. The @file{.c} file should override those |
| macros for which the default definition is inappropriate. For example: |
| @smallexample |
| #include "target.h" |
| #include "target-def.h" |
| |
| /* @r{Initialize the GCC target structure.} */ |
| |
| #undef TARGET_COMP_TYPE_ATTRIBUTES |
| #define TARGET_COMP_TYPE_ATTRIBUTES @var{machine}_comp_type_attributes |
| |
| struct gcc_target targetm = TARGET_INITIALIZER; |
| @end smallexample |
| @end deftypevar |
| |
| Where a macro should be defined in the @file{.c} file in this manner to |
| form part of the @code{targetm} structure, it is documented below as a |
| ``Target Hook'' with a prototype. Many macros will change in future |
| from being defined in the @file{.h} file to being part of the |
| @code{targetm} structure. |
| |
| @node Driver |
| @section Controlling the Compilation Driver, @file{gcc} |
| @cindex driver |
| @cindex controlling the compilation driver |
| |
| @c prevent bad page break with this line |
| You can control the compilation driver. |
| |
| @defmac SWITCH_TAKES_ARG (@var{char}) |
| A C expression which determines whether the option @option{-@var{char}} |
| takes arguments. The value should be the number of arguments that |
| option takes--zero, for many options. |
| |
| By default, this macro is defined as |
| @code{DEFAULT_SWITCH_TAKES_ARG}, which handles the standard options |
| properly. You need not define @code{SWITCH_TAKES_ARG} unless you |
| wish to add additional options which take arguments. Any redefinition |
| should call @code{DEFAULT_SWITCH_TAKES_ARG} and then check for |
| additional options. |
| @end defmac |
| |
| @defmac WORD_SWITCH_TAKES_ARG (@var{name}) |
| A C expression which determines whether the option @option{-@var{name}} |
| takes arguments. The value should be the number of arguments that |
| option takes--zero, for many options. This macro rather than |
| @code{SWITCH_TAKES_ARG} is used for multi-character option names. |
| |
| By default, this macro is defined as |
| @code{DEFAULT_WORD_SWITCH_TAKES_ARG}, which handles the standard options |
| properly. You need not define @code{WORD_SWITCH_TAKES_ARG} unless you |
| wish to add additional options which take arguments. Any redefinition |
| should call @code{DEFAULT_WORD_SWITCH_TAKES_ARG} and then check for |
| additional options. |
| @end defmac |
| |
| @defmac SWITCH_CURTAILS_COMPILATION (@var{char}) |
| A C expression which determines whether the option @option{-@var{char}} |
| stops compilation before the generation of an executable. The value is |
| boolean, nonzero if the option does stop an executable from being |
| generated, zero otherwise. |
| |
| By default, this macro is defined as |
| @code{DEFAULT_SWITCH_CURTAILS_COMPILATION}, which handles the standard |
| options properly. You need not define |
| @code{SWITCH_CURTAILS_COMPILATION} unless you wish to add additional |
| options which affect the generation of an executable. Any redefinition |
| should call @code{DEFAULT_SWITCH_CURTAILS_COMPILATION} and then check |
| for additional options. |
| @end defmac |
| |
| @defmac SWITCHES_NEED_SPACES |
| A string-valued C expression which enumerates the options for which |
| the linker needs a space between the option and its argument. |
| |
| If this macro is not defined, the default value is @code{""}. |
| @end defmac |
| |
| @defmac TARGET_OPTION_TRANSLATE_TABLE |
| If defined, a list of pairs of strings, the first of which is a |
| potential command line target to the @file{gcc} driver program, and the |
| second of which is a space-separated (tabs and other whitespace are not |
| supported) list of options with which to replace the first option. The |
| target defining this list is responsible for assuring that the results |
| are valid. Replacement options may not be the @code{--opt} style, they |
| must be the @code{-opt} style. It is the intention of this macro to |
| provide a mechanism for substitution that affects the multilibs chosen, |
| such as one option that enables many options, some of which select |
| multilibs. Example nonsensical definition, where @code{-malt-abi}, |
| @code{-EB}, and @code{-mspoo} cause different multilibs to be chosen: |
| |
| @smallexample |
| #define TARGET_OPTION_TRANSLATE_TABLE \ |
| @{ "-fast", "-march=fast-foo -malt-abi -I/usr/fast-foo" @}, \ |
| @{ "-compat", "-EB -malign=4 -mspoo" @} |
| @end smallexample |
| @end defmac |
| |
| @defmac DRIVER_SELF_SPECS |
| A list of specs for the driver itself. It should be a suitable |
| initializer for an array of strings, with no surrounding braces. |
| |
| The driver applies these specs to its own command line between loading |
| default @file{specs} files (but not command-line specified ones) and |
| choosing the multilib directory or running any subcommands. It |
| applies them in the order given, so each spec can depend on the |
| options added by earlier ones. It is also possible to remove options |
| using @samp{%<@var{option}} in the usual way. |
| |
| This macro can be useful when a port has several interdependent target |
| options. It provides a way of standardizing the command line so |
| that the other specs are easier to write. |
| |
| Do not define this macro if it does not need to do anything. |
| @end defmac |
| |
| @defmac OPTION_DEFAULT_SPECS |
| A list of specs used to support configure-time default options (i.e.@: |
| @option{--with} options) in the driver. It should be a suitable initializer |
| for an array of structures, each containing two strings, without the |
| outermost pair of surrounding braces. |
| |
| The first item in the pair is the name of the default. This must match |
| the code in @file{config.gcc} for the target. The second item is a spec |
| to apply if a default with this name was specified. The string |
| @samp{%(VALUE)} in the spec will be replaced by the value of the default |
| everywhere it occurs. |
| |
| The driver will apply these specs to its own command line between loading |
| default @file{specs} files and processing @code{DRIVER_SELF_SPECS}, using |
| the same mechanism as @code{DRIVER_SELF_SPECS}. |
| |
| Do not define this macro if it does not need to do anything. |
| @end defmac |
| |
| @defmac CPP_SPEC |
| A C string constant that tells the GCC driver program options to |
| pass to CPP@. It can also specify how to translate options you |
| give to GCC into options for GCC to pass to the CPP@. |
| |
| Do not define this macro if it does not need to do anything. |
| @end defmac |
| |
| @defmac CPLUSPLUS_CPP_SPEC |
| This macro is just like @code{CPP_SPEC}, but is used for C++, rather |
| than C@. If you do not define this macro, then the value of |
| @code{CPP_SPEC} (if any) will be used instead. |
| @end defmac |
| |
| @defmac CC1_SPEC |
| A C string constant that tells the GCC driver program options to |
| pass to @code{cc1}, @code{cc1plus}, @code{f771}, and the other language |
| front ends. |
| It can also specify how to translate options you give to GCC into options |
| for GCC to pass to front ends. |
| |
| Do not define this macro if it does not need to do anything. |
| @end defmac |
| |
| @defmac CC1PLUS_SPEC |
| A C string constant that tells the GCC driver program options to |
| pass to @code{cc1plus}. It can also specify how to translate options you |
| give to GCC into options for GCC to pass to the @code{cc1plus}. |
| |
| Do not define this macro if it does not need to do anything. |
| Note that everything defined in CC1_SPEC is already passed to |
| @code{cc1plus} so there is no need to duplicate the contents of |
| CC1_SPEC in CC1PLUS_SPEC@. |
| @end defmac |
| |
| @defmac ASM_SPEC |
| A C string constant that tells the GCC driver program options to |
| pass to the assembler. It can also specify how to translate options |
| you give to GCC into options for GCC to pass to the assembler. |
| See the file @file{sun3.h} for an example of this. |
| |
| Do not define this macro if it does not need to do anything. |
| @end defmac |
| |
| @defmac ASM_FINAL_SPEC |
| A C string constant that tells the GCC driver program how to |
| run any programs which cleanup after the normal assembler. |
| Normally, this is not needed. See the file @file{mips.h} for |
| an example of this. |
| |
| Do not define this macro if it does not need to do anything. |
| @end defmac |
| |
| @defmac AS_NEEDS_DASH_FOR_PIPED_INPUT |
| Define this macro, with no value, if the driver should give the assembler |
| an argument consisting of a single dash, @option{-}, to instruct it to |
| read from its standard input (which will be a pipe connected to the |
| output of the compiler proper). This argument is given after any |
| @option{-o} option specifying the name of the output file. |
| |
| If you do not define this macro, the assembler is assumed to read its |
| standard input if given no non-option arguments. If your assembler |
| cannot read standard input at all, use a @samp{%@{pipe:%e@}} construct; |
| see @file{mips.h} for instance. |
| @end defmac |
| |
| @defmac LINK_SPEC |
| A C string constant that tells the GCC driver program options to |
| pass to the linker. It can also specify how to translate options you |
| give to GCC into options for GCC to pass to the linker. |
| |
| Do not define this macro if it does not need to do anything. |
| @end defmac |
| |
| @defmac LIB_SPEC |
| Another C string constant used much like @code{LINK_SPEC}. The difference |
| between the two is that @code{LIB_SPEC} is used at the end of the |
| command given to the linker. |
| |
| If this macro is not defined, a default is provided that |
| loads the standard C library from the usual place. See @file{gcc.c}. |
| @end defmac |
| |
| @defmac LIBGCC_SPEC |
| Another C string constant that tells the GCC driver program |
| how and when to place a reference to @file{libgcc.a} into the |
| linker command line. This constant is placed both before and after |
| the value of @code{LIB_SPEC}. |
| |
| If this macro is not defined, the GCC driver provides a default that |
| passes the string @option{-lgcc} to the linker. |
| |
| By default, if @code{ENABLE_SHARED_LIBGCC} is defined, the |
| @code{LIBGCC_SPEC} is not directly used by the driver program but is |
| instead modified to refer to different versions of @file{libgcc.a} |
| depending on the values of the command line flags @option{-static}, |
| @option{-shared}, @option{-static-libgcc}, and @option{-shared-libgcc}. |
| @end defmac |
| |
| @defmac USE_LD_AS_NEEDED |
| A macro that controls the modifications to @code{LIBGCC_SPEC}. |
| If nonzero, a spec will be |
| generated that uses --as-needed and the shared libgcc in place of the |
| static exception handler library, when linking without any of |
| @code{-static}, @code{-static-libgcc}, or @code{-shared-libgcc}. |
| @end defmac |
| |
| @defmac LINK_EH_SPEC |
| If defined, this C string constant is added to @code{LINK_SPEC}. |
| When @code{USE_LD_AS_NEEDED} is zero or undefined, it also affects |
| the modifications to @code{LIBGCC_SPEC}. |
| @end defmac |
| |
| @defmac STARTFILE_SPEC |
| Another C string constant used much like @code{LINK_SPEC}. The |
| difference between the two is that @code{STARTFILE_SPEC} is used at |
| the very beginning of the command given to the linker. |
| |
| If this macro is not defined, a default is provided that loads the |
| standard C startup file from the usual place. See @file{gcc.c}. |
| @end defmac |
| |
| @defmac ENDFILE_SPEC |
| Another C string constant used much like @code{LINK_SPEC}. The |
| difference between the two is that @code{ENDFILE_SPEC} is used at |
| the very end of the command given to the linker. |
| |
| Do not define this macro if it does not need to do anything. |
| @end defmac |
| |
| @defmac THREAD_MODEL_SPEC |
| GCC @code{-v} will print the thread model GCC was configured to use. |
| However, this doesn't work on platforms that are multilibbed on thread |
| models, such as AIX 4.3. On such platforms, define |
| @code{THREAD_MODEL_SPEC} such that it evaluates to a string without |
| blanks that names one of the recognized thread models. @code{%*}, the |
| default value of this macro, will expand to the value of |
| @code{thread_file} set in @file{config.gcc}. |
| @end defmac |
| |
| @defmac SYSROOT_SUFFIX_SPEC |
| Define this macro to add a suffix to the target sysroot when GCC is |
| configured with a sysroot. This will cause GCC to search for usr/lib, |
| et al, within sysroot+suffix. |
| @end defmac |
| |
| @defmac SYSROOT_HEADERS_SUFFIX_SPEC |
| Define this macro to add a headers_suffix to the target sysroot when |
| GCC is configured with a sysroot. This will cause GCC to pass the |
| updated sysroot+headers_suffix to CPP, causing it to search for |
| usr/include, et al, within sysroot+headers_suffix. |
| @end defmac |
| |
| @defmac EXTRA_SPECS |
| Define this macro to provide additional specifications to put in the |
| @file{specs} file that can be used in various specifications like |
| @code{CC1_SPEC}. |
| |
| The definition should be an initializer for an array of structures, |
| containing a string constant, that defines the specification name, and a |
| string constant that provides the specification. |
| |
| Do not define this macro if it does not need to do anything. |
| |
| @code{EXTRA_SPECS} is useful when an architecture contains several |
| related targets, which have various @code{@dots{}_SPECS} which are similar |
| to each other, and the maintainer would like one central place to keep |
| these definitions. |
| |
| For example, the PowerPC System V.4 targets use @code{EXTRA_SPECS} to |
| define either @code{_CALL_SYSV} when the System V calling sequence is |
| used or @code{_CALL_AIX} when the older AIX-based calling sequence is |
| used. |
| |
| The @file{config/rs6000/rs6000.h} target file defines: |
| |
| @smallexample |
| #define EXTRA_SPECS \ |
| @{ "cpp_sysv_default", CPP_SYSV_DEFAULT @}, |
| |
| #define CPP_SYS_DEFAULT "" |
| @end smallexample |
| |
| The @file{config/rs6000/sysv.h} target file defines: |
| @smallexample |
| #undef CPP_SPEC |
| #define CPP_SPEC \ |
| "%@{posix: -D_POSIX_SOURCE @} \ |
| %@{mcall-sysv: -D_CALL_SYSV @} \ |
| %@{!mcall-sysv: %(cpp_sysv_default) @} \ |
| %@{msoft-float: -D_SOFT_FLOAT@} %@{mcpu=403: -D_SOFT_FLOAT@}" |
| |
| #undef CPP_SYSV_DEFAULT |
| #define CPP_SYSV_DEFAULT "-D_CALL_SYSV" |
| @end smallexample |
| |
| while the @file{config/rs6000/eabiaix.h} target file defines |
| @code{CPP_SYSV_DEFAULT} as: |
| |
| @smallexample |
| #undef CPP_SYSV_DEFAULT |
| #define CPP_SYSV_DEFAULT "-D_CALL_AIX" |
| @end smallexample |
| @end defmac |
| |
| @defmac LINK_LIBGCC_SPECIAL |
| Define this macro if the driver program should find the library |
| @file{libgcc.a} itself and should not pass @option{-L} options to the |
| linker. If you do not define this macro, the driver program will pass |
| the argument @option{-lgcc} to tell the linker to do the search and will |
| pass @option{-L} options to it. |
| @end defmac |
| |
| @defmac LINK_LIBGCC_SPECIAL_1 |
| Define this macro if the driver program should find the library |
| @file{libgcc.a}. If you do not define this macro, the driver program will pass |
| the argument @option{-lgcc} to tell the linker to do the search. |
| This macro is similar to @code{LINK_LIBGCC_SPECIAL}, except that it does |
| not affect @option{-L} options. |
| @end defmac |
| |
| @defmac LINK_GCC_C_SEQUENCE_SPEC |
| The sequence in which libgcc and libc are specified to the linker. |
| By default this is @code{%G %L %G}. |
| @end defmac |
| |
| @defmac LINK_COMMAND_SPEC |
| A C string constant giving the complete command line need to execute the |
| linker. When you do this, you will need to update your port each time a |
| change is made to the link command line within @file{gcc.c}. Therefore, |
| define this macro only if you need to completely redefine the command |
| line for invoking the linker and there is no other way to accomplish |
| the effect you need. Overriding this macro may be avoidable by overriding |
| @code{LINK_GCC_C_SEQUENCE_SPEC} instead. |
| @end defmac |
| |
| @defmac LINK_ELIMINATE_DUPLICATE_LDIRECTORIES |
| A nonzero value causes @command{collect2} to remove duplicate @option{-L@var{directory}} search |
| directories from linking commands. Do not give it a nonzero value if |
| removing duplicate search directories changes the linker's semantics. |
| @end defmac |
| |
| @defmac MULTILIB_DEFAULTS |
| Define this macro as a C expression for the initializer of an array of |
| string to tell the driver program which options are defaults for this |
| target and thus do not need to be handled specially when using |
| @code{MULTILIB_OPTIONS}. |
| |
| Do not define this macro if @code{MULTILIB_OPTIONS} is not defined in |
| the target makefile fragment or if none of the options listed in |
| @code{MULTILIB_OPTIONS} are set by default. |
| @xref{Target Fragment}. |
| @end defmac |
| |
| @defmac RELATIVE_PREFIX_NOT_LINKDIR |
| Define this macro to tell @command{gcc} that it should only translate |
| a @option{-B} prefix into a @option{-L} linker option if the prefix |
| indicates an absolute file name. |
| @end defmac |
| |
| @defmac MD_EXEC_PREFIX |
| If defined, this macro is an additional prefix to try after |
| @code{STANDARD_EXEC_PREFIX}. @code{MD_EXEC_PREFIX} is not searched |
| when the @option{-b} option is used, or the compiler is built as a cross |
| compiler. If you define @code{MD_EXEC_PREFIX}, then be sure to add it |
| to the list of directories used to find the assembler in @file{configure.in}. |
| @end defmac |
| |
| @defmac STANDARD_STARTFILE_PREFIX |
| Define this macro as a C string constant if you wish to override the |
| standard choice of @code{libdir} as the default prefix to |
| try when searching for startup files such as @file{crt0.o}. |
| @code{STANDARD_STARTFILE_PREFIX} is not searched when the compiler |
| is built as a cross compiler. |
| @end defmac |
| |
| @defmac MD_STARTFILE_PREFIX |
| If defined, this macro supplies an additional prefix to try after the |
| standard prefixes. @code{MD_EXEC_PREFIX} is not searched when the |
| @option{-b} option is used, or when the compiler is built as a cross |
| compiler. |
| @end defmac |
| |
| @defmac MD_STARTFILE_PREFIX_1 |
| If defined, this macro supplies yet another prefix to try after the |
| standard prefixes. It is not searched when the @option{-b} option is |
| used, or when the compiler is built as a cross compiler. |
| @end defmac |
| |
| @defmac INIT_ENVIRONMENT |
| Define this macro as a C string constant if you wish to set environment |
| variables for programs called by the driver, such as the assembler and |
| loader. The driver passes the value of this macro to @code{putenv} to |
| initialize the necessary environment variables. |
| @end defmac |
| |
| @defmac LOCAL_INCLUDE_DIR |
| Define this macro as a C string constant if you wish to override the |
| standard choice of @file{/usr/local/include} as the default prefix to |
| try when searching for local header files. @code{LOCAL_INCLUDE_DIR} |
| comes before @code{SYSTEM_INCLUDE_DIR} in the search order. |
| |
| Cross compilers do not search either @file{/usr/local/include} or its |
| replacement. |
| @end defmac |
| |
| @defmac MODIFY_TARGET_NAME |
| Define this macro if you wish to define command-line switches that |
| modify the default target name. |
| |
| For each switch, you can include a string to be appended to the first |
| part of the configuration name or a string to be deleted from the |
| configuration name, if present. The definition should be an initializer |
| for an array of structures. Each array element should have three |
| elements: the switch name (a string constant, including the initial |
| dash), one of the enumeration codes @code{ADD} or @code{DELETE} to |
| indicate whether the string should be inserted or deleted, and the string |
| to be inserted or deleted (a string constant). |
| |
| For example, on a machine where @samp{64} at the end of the |
| configuration name denotes a 64-bit target and you want the @option{-32} |
| and @option{-64} switches to select between 32- and 64-bit targets, you would |
| code |
| |
| @smallexample |
| #define MODIFY_TARGET_NAME \ |
| @{ @{ "-32", DELETE, "64"@}, \ |
| @{"-64", ADD, "64"@}@} |
| @end smallexample |
| @end defmac |
| |
| @defmac SYSTEM_INCLUDE_DIR |
| Define this macro as a C string constant if you wish to specify a |
| system-specific directory to search for header files before the standard |
| directory. @code{SYSTEM_INCLUDE_DIR} comes before |
| @code{STANDARD_INCLUDE_DIR} in the search order. |
| |
| Cross compilers do not use this macro and do not search the directory |
| specified. |
| @end defmac |
| |
| @defmac STANDARD_INCLUDE_DIR |
| Define this macro as a C string constant if you wish to override the |
| standard choice of @file{/usr/include} as the default prefix to |
| try when searching for header files. |
| |
| Cross compilers ignore this macro and do not search either |
| @file{/usr/include} or its replacement. |
| @end defmac |
| |
| @defmac STANDARD_INCLUDE_COMPONENT |
| The ``component'' corresponding to @code{STANDARD_INCLUDE_DIR}. |
| See @code{INCLUDE_DEFAULTS}, below, for the description of components. |
| If you do not define this macro, no component is used. |
| @end defmac |
| |
| @defmac INCLUDE_DEFAULTS |
| Define this macro if you wish to override the entire default search path |
| for include files. For a native compiler, the default search path |
| usually consists of @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR}, |
| @code{SYSTEM_INCLUDE_DIR}, @code{GPLUSPLUS_INCLUDE_DIR}, and |
| @code{STANDARD_INCLUDE_DIR}. In addition, @code{GPLUSPLUS_INCLUDE_DIR} |
| and @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile}, |
| and specify private search areas for GCC@. The directory |
| @code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs. |
| |
| The definition should be an initializer for an array of structures. |
| Each array element should have four elements: the directory name (a |
| string constant), the component name (also a string constant), a flag |
| for C++-only directories, |
| and a flag showing that the includes in the directory don't need to be |
| wrapped in @code{extern @samp{C}} when compiling C++. Mark the end of |
| the array with a null element. |
| |
| The component name denotes what GNU package the include file is part of, |
| if any, in all uppercase letters. For example, it might be @samp{GCC} |
| or @samp{BINUTILS}. If the package is part of a vendor-supplied |
| operating system, code the component name as @samp{0}. |
| |
| For example, here is the definition used for VAX/VMS: |
| |
| @smallexample |
| #define INCLUDE_DEFAULTS \ |
| @{ \ |
| @{ "GNU_GXX_INCLUDE:", "G++", 1, 1@}, \ |
| @{ "GNU_CC_INCLUDE:", "GCC", 0, 0@}, \ |
| @{ "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0@}, \ |
| @{ ".", 0, 0, 0@}, \ |
| @{ 0, 0, 0, 0@} \ |
| @} |
| @end smallexample |
| @end defmac |
| |
| Here is the order of prefixes tried for exec files: |
| |
| @enumerate |
| @item |
| Any prefixes specified by the user with @option{-B}. |
| |
| @item |
| The environment variable @code{GCC_EXEC_PREFIX}, if any. |
| |
| @item |
| The directories specified by the environment variable @code{COMPILER_PATH}. |
| |
| @item |
| The macro @code{STANDARD_EXEC_PREFIX}. |
| |
| @item |
| @file{/usr/lib/gcc/}. |
| |
| @item |
| The macro @code{MD_EXEC_PREFIX}, if any. |
| @end enumerate |
| |
| Here is the order of prefixes tried for startfiles: |
| |
| @enumerate |
| @item |
| Any prefixes specified by the user with @option{-B}. |
| |
| @item |
| The environment variable @code{GCC_EXEC_PREFIX}, if any. |
| |
| @item |
| The directories specified by the environment variable @code{LIBRARY_PATH} |
| (or port-specific name; native only, cross compilers do not use this). |
| |
| @item |
| The macro @code{STANDARD_EXEC_PREFIX}. |
| |
| @item |
| @file{/usr/lib/gcc/}. |
| |
| @item |
| The macro @code{MD_EXEC_PREFIX}, if any. |
| |
| @item |
| The macro @code{MD_STARTFILE_PREFIX}, if any. |
| |
| @item |
| The macro @code{STANDARD_STARTFILE_PREFIX}. |
| |
| @item |
| @file{/lib/}. |
| |
| @item |
| @file{/usr/lib/}. |
| @end enumerate |
| |
| @node Run-time Target |
| @section Run-time Target Specification |
| @cindex run-time target specification |
| @cindex predefined macros |
| @cindex target specifications |
| |
| @c prevent bad page break with this line |
| Here are run-time target specifications. |
| |
| @defmac TARGET_CPU_CPP_BUILTINS () |
| This function-like macro expands to a block of code that defines |
| built-in preprocessor macros and assertions for the target cpu, using |
| the functions @code{builtin_define}, @code{builtin_define_std} and |
| @code{builtin_assert}. When the front end |
| calls this macro it provides a trailing semicolon, and since it has |
| finished command line option processing your code can use those |
| results freely. |
| |
| @code{builtin_assert} takes a string in the form you pass to the |
| command-line option @option{-A}, such as @code{cpu=mips}, and creates |
| the assertion. @code{builtin_define} takes a string in the form |
| accepted by option @option{-D} and unconditionally defines the macro. |
| |
| @code{builtin_define_std} takes a string representing the name of an |
| object-like macro. If it doesn't lie in the user's namespace, |
| @code{builtin_define_std} defines it unconditionally. Otherwise, it |
| defines a version with two leading underscores, and another version |
| with two leading and trailing underscores, and defines the original |
| only if an ISO standard was not requested on the command line. For |
| example, passing @code{unix} defines @code{__unix}, @code{__unix__} |
| and possibly @code{unix}; passing @code{_mips} defines @code{__mips}, |
| @code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64} |
| defines only @code{_ABI64}. |
| |
| You can also test for the C dialect being compiled. The variable |
| @code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus} |
| or @code{clk_objective_c}. Note that if we are preprocessing |
| assembler, this variable will be @code{clk_c} but the function-like |
| macro @code{preprocessing_asm_p()} will return true, so you might want |
| to check for that first. If you need to check for strict ANSI, the |
| variable @code{flag_iso} can be used. The function-like macro |
| @code{preprocessing_trad_p()} can be used to check for traditional |
| preprocessing. |
| @end defmac |
| |
| @defmac TARGET_OS_CPP_BUILTINS () |
| Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional |
| and is used for the target operating system instead. |
| @end defmac |
| |
| @defmac TARGET_OBJFMT_CPP_BUILTINS () |
| Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional |
| and is used for the target object format. @file{elfos.h} uses this |
| macro to define @code{__ELF__}, so you probably do not need to define |
| it yourself. |
| @end defmac |
| |
| @deftypevar {extern int} target_flags |
| This declaration should be present. |
| @end deftypevar |
| |
| @cindex optional hardware or system features |
| @cindex features, optional, in system conventions |
| |
| @defmac TARGET_@var{featurename} |
| This series of macros is to allow compiler command arguments to |
| enable or disable the use of optional features of the target machine. |
| For example, one machine description serves both the 68000 and |
| the 68020; a command argument tells the compiler whether it should |
| use 68020-only instructions or not. This command argument works |
| by means of a macro @code{TARGET_68020} that tests a bit in |
| @code{target_flags}. |
| |
| Define a macro @code{TARGET_@var{featurename}} for each such option. |
| Its definition should test a bit in @code{target_flags}. It is |
| recommended that a helper macro @code{MASK_@var{featurename}} |
| is defined for each bit-value to test, and used in |
| @code{TARGET_@var{featurename}} and @code{TARGET_SWITCHES}. For |
| example: |
| |
| @smallexample |
| #define TARGET_MASK_68020 1 |
| #define TARGET_68020 (target_flags & MASK_68020) |
| @end smallexample |
| |
| One place where these macros are used is in the condition-expressions |
| of instruction patterns. Note how @code{TARGET_68020} appears |
| frequently in the 68000 machine description file, @file{m68k.md}. |
| Another place they are used is in the definitions of the other |
| macros in the @file{@var{machine}.h} file. |
| @end defmac |
| |
| @defmac TARGET_SWITCHES |
| This macro defines names of command options to set and clear |
| bits in @code{target_flags}. Its definition is an initializer |
| with a subgrouping for each command option. |
| |
| Each subgrouping contains a string constant, that defines the option |
| name, a number, which contains the bits to set in |
| @code{target_flags}, and a second string which is the description |
| displayed by @option{--help}. If the number is negative then the bits specified |
| by the number are cleared instead of being set. If the description |
| string is present but empty, then no help information will be displayed |
| for that option, but it will not count as an undocumented option. The |
| actual option name is made by appending @samp{-m} to the specified name. |
| Non-empty description strings should be marked with @code{N_(@dots{})} for |
| @command{xgettext}. Please do not mark empty strings because the empty |
| string is reserved by GNU gettext. @code{gettext("")} returns the header entry |
| of the message catalog with meta information, not the empty string. |
| |
| In addition to the description for @option{--help}, |
| more detailed documentation for each option should be added to |
| @file{invoke.texi}. |
| |
| One of the subgroupings should have a null string. The number in |
| this grouping is the default value for @code{target_flags}. Any |
| target options act starting with that value. |
| |
| Here is an example which defines @option{-m68000} and @option{-m68020} |
| with opposite meanings, and picks the latter as the default: |
| |
| @smallexample |
| #define TARGET_SWITCHES \ |
| @{ @{ "68020", MASK_68020, "" @}, \ |
| @{ "68000", -MASK_68020, \ |
| N_("Compile for the 68000") @}, \ |
| @{ "", MASK_68020, "" @}, \ |
| @} |
| @end smallexample |
| @end defmac |
| |
| @defmac TARGET_OPTIONS |
| This macro is similar to @code{TARGET_SWITCHES} but defines names of command |
| options that have values. Its definition is an initializer with a |
| subgrouping for each command option. |
| |
| Each subgrouping contains a string constant, that defines the option |
| name, the address of a variable, a description string, and a value. |
| Non-empty description strings should be marked with @code{N_(@dots{})} |
| for @command{xgettext}. Please do not mark empty strings because the |
| empty string is reserved by GNU gettext. @code{gettext("")} returns the |
| header entry of the message catalog with meta information, not the empty |
| string. |
| |
| If the value listed in the table is @code{NULL}, then the variable, type |
| @code{char *}, is set to the variable part of the given option if the |
| fixed part matches. In other words, if the first part of the option |
| matches what's in the table, the variable will be set to point to the |
| rest of the option. This allows the user to specify a value for that |
| option. The actual option name is made by appending @samp{-m} to the |
| specified name. Again, each option should also be documented in |
| @file{invoke.texi}. |
| |
| If the value listed in the table is non-@code{NULL}, then the option |
| must match the option in the table exactly (with @samp{-m}), and the |
| variable is set to point to the value listed in the table. |
| |
| Here is an example which defines @option{-mshort-data-@var{number}}. If the |
| given option is @option{-mshort-data-512}, the variable @code{m88k_short_data} |
| will be set to the string @code{"512"}. |
| |
| @smallexample |
| extern char *m88k_short_data; |
| #define TARGET_OPTIONS \ |
| @{ @{ "short-data-", &m88k_short_data, \ |
| N_("Specify the size of the short data section"), 0 @} @} |
| @end smallexample |
| |
| Here is a variant of the above that allows the user to also specify |
| just @option{-mshort-data} where a default of @code{"64"} is used. |
| |
| @smallexample |
| extern char *m88k_short_data; |
| #define TARGET_OPTIONS \ |
| @{ @{ "short-data-", &m88k_short_data, \ |
| N_("Specify the size of the short data section"), 0 @} \ |
| @{ "short-data", &m88k_short_data, "", "64" @}, |
| @} |
| @end smallexample |
| |
| Here is an example which defines @option{-mno-alu}, @option{-malu1}, and |
| @option{-malu2} as a three-state switch, along with suitable macros for |
| checking the state of the option (documentation is elided for brevity). |
| |
| @smallexample |
| [chip.c] |
| char *chip_alu = ""; /* Specify default here. */ |
| |
| [chip.h] |
| extern char *chip_alu; |
| #define TARGET_OPTIONS \ |
| @{ @{ "no-alu", &chip_alu, "", "" @}, \ |
| @{ "alu1", &chip_alu, "", "1" @}, \ |
| @{ "alu2", &chip_alu, "", "2" @}, @} |
| #define TARGET_ALU (chip_alu[0] != '\0') |
| #define TARGET_ALU1 (chip_alu[0] == '1') |
| #define TARGET_ALU2 (chip_alu[0] == '2') |
| @end smallexample |
| @end defmac |
| |
| @defmac TARGET_VERSION |
| This macro is a C statement to print on @code{stderr} a string |
| describing the particular machine description choice. Every machine |
| description should define @code{TARGET_VERSION}. For example: |
| |
| @smallexample |
| #ifdef MOTOROLA |
| #define TARGET_VERSION \ |
| fprintf (stderr, " (68k, Motorola syntax)"); |
| #else |
| #define TARGET_VERSION \ |
| fprintf (stderr, " (68k, MIT syntax)"); |
| #endif |
| @end smallexample |
| @end defmac |
| |
| @defmac OVERRIDE_OPTIONS |
| Sometimes certain combinations of command options do not make sense on |
| a particular target machine. You can define a macro |
| @code{OVERRIDE_OPTIONS} to take account of this. This macro, if |
| defined, is executed once just after all the command options have been |
| parsed. |
| |
| Don't use this macro to turn on various extra optimizations for |
| @option{-O}. That is what @code{OPTIMIZATION_OPTIONS} is for. |
| @end defmac |
| |
| @defmac OPTIMIZATION_OPTIONS (@var{level}, @var{size}) |
| Some machines may desire to change what optimizations are performed for |
| various optimization levels. This macro, if defined, is executed once |
| just after the optimization level is determined and before the remainder |
| of the command options have been parsed. Values set in this macro are |
| used as the default values for the other command line options. |
| |
| @var{level} is the optimization level specified; 2 if @option{-O2} is |
| specified, 1 if @option{-O} is specified, and 0 if neither is specified. |
| |
| @var{size} is nonzero if @option{-Os} is specified and zero otherwise. |
| |
| You should not use this macro to change options that are not |
| machine-specific. These should uniformly selected by the same |
| optimization level on all supported machines. Use this macro to enable |
| machine-specific optimizations. |
| |
| @strong{Do not examine @code{write_symbols} in |
| this macro!} The debugging options are not supposed to alter the |
| generated code. |
| @end defmac |
| |
| @defmac CAN_DEBUG_WITHOUT_FP |
| Define this macro if debugging can be performed even without a frame |
| pointer. If this macro is defined, GCC will turn on the |
| @option{-fomit-frame-pointer} option whenever @option{-O} is specified. |
| @end defmac |
| |
| @node Per-Function Data |
| @section Defining data structures for per-function information. |
| @cindex per-function data |
| @cindex data structures |
| |
| If the target needs to store information on a per-function basis, GCC |
| provides a macro and a couple of variables to allow this. Note, just |
| using statics to store the information is a bad idea, since GCC supports |
| nested functions, so you can be halfway through encoding one function |
| when another one comes along. |
| |
| GCC defines a data structure called @code{struct function} which |
| contains all of the data specific to an individual function. This |
| structure contains a field called @code{machine} whose type is |
| @code{struct machine_function *}, which can be used by targets to point |
| to their own specific data. |
| |
| If a target needs per-function specific data it should define the type |
| @code{struct machine_function} and also the macro @code{INIT_EXPANDERS}. |
| This macro should be used to initialize the function pointer |
| @code{init_machine_status}. This pointer is explained below. |
| |
| One typical use of per-function, target specific data is to create an |
| RTX to hold the register containing the function's return address. This |
| RTX can then be used to implement the @code{__builtin_return_address} |
| function, for level 0. |
| |
| Note---earlier implementations of GCC used a single data area to hold |
| all of the per-function information. Thus when processing of a nested |
| function began the old per-function data had to be pushed onto a |
| stack, and when the processing was finished, it had to be popped off the |
| stack. GCC used to provide function pointers called |
| @code{save_machine_status} and @code{restore_machine_status} to handle |
| the saving and restoring of the target specific information. Since the |
| single data area approach is no longer used, these pointers are no |
| longer supported. |
| |
| @defmac INIT_EXPANDERS |
| Macro called to initialize any target specific information. This macro |
| is called once per function, before generation of any RTL has begun. |
| The intention of this macro is to allow the initialization of the |
| function pointer @code{init_machine_status}. |
| @end defmac |
| |
| @deftypevar {void (*)(struct function *)} init_machine_status |
| If this function pointer is non-@code{NULL} it will be called once per |
| function, before function compilation starts, in order to allow the |
| target to perform any target specific initialization of the |
| @code{struct function} structure. It is intended that this would be |
| used to initialize the @code{machine} of that structure. |
| |
| @code{struct machine_function} structures are expected to be freed by GC. |
| Generally, any memory that they reference must be allocated by using |
| @code{ggc_alloc}, including the structure itself. |
| @end deftypevar |
| |
| @node Storage Layout |
| @section Storage Layout |
| @cindex storage layout |
| |
| Note that the definitions of the macros in this table which are sizes or |
| alignments measured in bits do not need to be constant. They can be C |
| expressions that refer to static variables, such as the @code{target_flags}. |
| @xref{Run-time Target}. |
| |
| @defmac BITS_BIG_ENDIAN |
| Define this macro to have the value 1 if the most significant bit in a |
| byte has the lowest number; otherwise define it to have the value zero. |
| This means that bit-field instructions count from the most significant |
| bit. If the machine has no bit-field instructions, then this must still |
| be defined, but it doesn't matter which value it is defined to. This |
| macro need not be a constant. |
| |
| This macro does not affect the way structure fields are packed into |
| bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}. |
| @end defmac |
| |
| @defmac BYTES_BIG_ENDIAN |
| Define this macro to have the value 1 if the most significant byte in a |
| word has the lowest number. This macro need not be a constant. |
| @end defmac |
| |
| @defmac WORDS_BIG_ENDIAN |
| Define this macro to have the value 1 if, in a multiword object, the |
| most significant word has the lowest number. This applies to both |
| memory locations and registers; GCC fundamentally assumes that the |
| order of words in memory is the same as the order in registers. This |
| macro need not be a constant. |
| @end defmac |
| |
| @defmac LIBGCC2_WORDS_BIG_ENDIAN |
| Define this macro if @code{WORDS_BIG_ENDIAN} is not constant. This must be a |
| constant value with the same meaning as @code{WORDS_BIG_ENDIAN}, which will be |
| used only when compiling @file{libgcc2.c}. Typically the value will be set |
| based on preprocessor defines. |
| @end defmac |
| |
| @defmac FLOAT_WORDS_BIG_ENDIAN |
| Define this macro to have the value 1 if @code{DFmode}, @code{XFmode} or |
| @code{TFmode} floating point numbers are stored in memory with the word |
| containing the sign bit at the lowest address; otherwise define it to |
| have the value 0. This macro need not be a constant. |
| |
| You need not define this macro if the ordering is the same as for |
| multi-word integers. |
| @end defmac |
| |
| @defmac BITS_PER_UNIT |
| Define this macro to be the number of bits in an addressable storage |
| unit (byte). If you do not define this macro the default is 8. |
| @end defmac |
| |
| @defmac BITS_PER_WORD |
| Number of bits in a word. If you do not define this macro, the default |
| is @code{BITS_PER_UNIT * UNITS_PER_WORD}. |
| @end defmac |
| |
| @defmac MAX_BITS_PER_WORD |
| Maximum number of bits in a word. If this is undefined, the default is |
| @code{BITS_PER_WORD}. Otherwise, it is the constant value that is the |
| largest value that @code{BITS_PER_WORD} can have at run-time. |
| @end defmac |
| |
| @defmac UNITS_PER_WORD |
| Number of storage units in a word; normally 4. |
| @end defmac |
| |
| @defmac MIN_UNITS_PER_WORD |
| Minimum number of units in a word. If this is undefined, the default is |
| @code{UNITS_PER_WORD}. Otherwise, it is the constant value that is the |
| smallest value that @code{UNITS_PER_WORD} can have at run-time. |
| @end defmac |
| |
| @defmac POINTER_SIZE |
| Width of a pointer, in bits. You must specify a value no wider than the |
| width of @code{Pmode}. If it is not equal to the width of @code{Pmode}, |
| you must define @code{POINTERS_EXTEND_UNSIGNED}. If you do not specify |
| a value the default is @code{BITS_PER_WORD}. |
| @end defmac |
| |
| @defmac POINTERS_EXTEND_UNSIGNED |
| A C expression whose value is greater than zero if pointers that need to be |
| extended from being @code{POINTER_SIZE} bits wide to @code{Pmode} are to |
| be zero-extended and zero if they are to be sign-extended. If the value |
| is less then zero then there must be an "ptr_extend" instruction that |
| extends a pointer from @code{POINTER_SIZE} to @code{Pmode}. |
| |
| You need not define this macro if the @code{POINTER_SIZE} is equal |
| to the width of @code{Pmode}. |
| @end defmac |
| |
| @defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type}) |
| A macro to update @var{m} and @var{unsignedp} when an object whose type |
| is @var{type} and which has the specified mode and signedness is to be |
| stored in a register. This macro is only called when @var{type} is a |
| scalar type. |
| |
| On most RISC machines, which only have operations that operate on a full |
| register, define this macro to set @var{m} to @code{word_mode} if |
| @var{m} is an integer mode narrower than @code{BITS_PER_WORD}. In most |
| cases, only integer modes should be widened because wider-precision |
| floating-point operations are usually more expensive than their narrower |
| counterparts. |
| |
| For most machines, the macro definition does not change @var{unsignedp}. |
| However, some machines, have instructions that preferentially handle |
| either signed or unsigned quantities of certain modes. For example, on |
| the DEC Alpha, 32-bit loads from memory and 32-bit add instructions |
| sign-extend the result to 64 bits. On such machines, set |
| @var{unsignedp} according to which kind of extension is more efficient. |
| |
| Do not define this macro if it would never modify @var{m}. |
| @end defmac |
| |
| @deftypefn {Target Hook} bool TARGET_PROMOTE_FUNCTION_ARGS (tree @var{fntype}) |
| This target hook should return @code{true} if the promotion described by |
| @code{PROMOTE_MODE} should also be done for outgoing function arguments. |
| @end deftypefn |
| |
| @deftypefn {Target Hook} bool TARGET_PROMOTE_FUNCTION_RETURN (tree @var{fntype}) |
| This target hook should return @code{true} if the promotion described by |
| @code{PROMOTE_MODE} should also be done for the return value of |
| functions. |
| |
| If this target hook returns @code{true}, @code{FUNCTION_VALUE} must |
| perform the same promotions done by @code{PROMOTE_MODE}. |
| @end deftypefn |
| |
| @defmac PROMOTE_FOR_CALL_ONLY |
| Define this macro if the promotion described by @code{PROMOTE_MODE} |
| should @emph{only} be performed for outgoing function arguments or |
| function return values, as specified by @code{TARGET_PROMOTE_FUNCTION_ARGS} |
| and @code{TARGET_PROMOTE_FUNCTION_RETURN}, respectively. |
| @end defmac |
| |
| @defmac PARM_BOUNDARY |
| Normal alignment required for function parameters on the stack, in |
| bits. All stack parameters receive at least this much alignment |
| regardless of data type. On most machines, this is the same as the |
| size of an integer. |
| @end defmac |
| |
| @defmac STACK_BOUNDARY |
| Define this macro to the minimum alignment enforced by hardware for the |
| stack pointer on this machine. The definition is a C expression for the |
| desired alignment (measured in bits). This value is used as a default |
| if @code{PREFERRED_STACK_BOUNDARY} is not defined. On most machines, |
| this should be the same as @code{PARM_BOUNDARY}. |
| @end defmac |
| |
| @defmac PREFERRED_STACK_BOUNDARY |
| Define this macro if you wish to preserve a certain alignment for the |
| stack pointer, greater than what the hardware enforces. The definition |
| is a C expression for the desired alignment (measured in bits). This |
| macro must evaluate to a value equal to or larger than |
| @code{STACK_BOUNDARY}. |
| @end defmac |
| |
| @defmac FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN |
| A C expression that evaluates true if @code{PREFERRED_STACK_BOUNDARY} is |
| not guaranteed by the runtime and we should emit code to align the stack |
| at the beginning of @code{main}. |
| |
| @cindex @code{PUSH_ROUNDING}, interaction with @code{PREFERRED_STACK_BOUNDARY} |
| If @code{PUSH_ROUNDING} is not defined, the stack will always be aligned |
| to the specified boundary. If @code{PUSH_ROUNDING} is defined and specifies |
| a less strict alignment than @code{PREFERRED_STACK_BOUNDARY}, the stack may |
| be momentarily unaligned while pushing arguments. |
| @end defmac |
| |
| @defmac FUNCTION_BOUNDARY |
| Alignment required for a function entry point, in bits. |
| @end defmac |
| |
| @defmac BIGGEST_ALIGNMENT |
| Biggest alignment that any data type can require on this machine, in bits. |
| @end defmac |
| |
| @defmac MINIMUM_ATOMIC_ALIGNMENT |
| If defined, the smallest alignment, in bits, that can be given to an |
| object that can be referenced in one operation, without disturbing any |
| nearby object. Normally, this is @code{BITS_PER_UNIT}, but may be larger |
| on machines that don't have byte or half-word store operations. |
| @end defmac |
| |
| @defmac BIGGEST_FIELD_ALIGNMENT |
| Biggest alignment that any structure or union field can require on this |
| machine, in bits. If defined, this overrides @code{BIGGEST_ALIGNMENT} for |
| structure and union fields only, unless the field alignment has been set |
| by the @code{__attribute__ ((aligned (@var{n})))} construct. |
| @end defmac |
| |
| @defmac ADJUST_FIELD_ALIGN (@var{field}, @var{computed}) |
| An expression for the alignment of a structure field @var{field} if the |
| alignment computed in the usual way (including applying of |
| @code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the |
| alignment) is @var{computed}. It overrides alignment only if the |
| field alignment has not been set by the |
| @code{__attribute__ ((aligned (@var{n})))} construct. |
| @end defmac |
| |
| @defmac MAX_OFILE_ALIGNMENT |
| Biggest alignment supported by the object file format of this machine. |
| Use this macro to limit the alignment which can be specified using the |
| @code{__attribute__ ((aligned (@var{n})))} construct. If not defined, |
| the default value is @code{BIGGEST_ALIGNMENT}. |
| @end defmac |
| |
| @defmac DATA_ALIGNMENT (@var{type}, @var{basic-align}) |
| If defined, a C expression to compute the alignment for a variable in |
| the static store. @var{type} is the data type, and @var{basic-align} is |
| the alignment that the object would ordinarily have. The value of this |
| macro is used instead of that alignment to align the object. |
| |
| If this macro is not defined, then @var{basic-align} is used. |
| |
| @findex strcpy |
| One use of this macro is to increase alignment of medium-size data to |
| make it all fit in fewer cache lines. Another is to cause character |
| arrays to be word-aligned so that @code{strcpy} calls that copy |
| constants to character arrays can be done inline. |
| @end defmac |
| |
| @defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align}) |
| If defined, a C expression to compute the alignment given to a constant |
| that is being placed in memory. @var{constant} is the constant and |
| @var{basic-align} is the alignment that the object would ordinarily |
| have. The value of this macro is used instead of that alignment to |
| align the object. |
| |
| If this macro is not defined, then @var{basic-align} is used. |
| |
| The typical use of this macro is to increase alignment for string |
| constants to be word aligned so that @code{strcpy} calls that copy |
| constants can be done inline. |
| @end defmac |
| |
| @defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align}) |
| If defined, a C expression to compute the alignment for a variable in |
| the local store. @var{type} is the data type, and @var{basic-align} is |
| the alignment that the object would ordinarily have. The value of this |
| macro is used instead of that alignment to align the object. |
| |
| If this macro is not defined, then @var{basic-align} is used. |
| |
| One use of this macro is to increase alignment of medium-size data to |
| make it all fit in fewer cache lines. |
| @end defmac |
| |
| @defmac EMPTY_FIELD_BOUNDARY |
| Alignment in bits to be given to a structure bit-field that follows an |
| empty field such as @code{int : 0;}. |
| |
| If @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro. |
| @end defmac |
| |
| @defmac STRUCTURE_SIZE_BOUNDARY |
| Number of bits which any structure or union's size must be a multiple of. |
| Each structure or union's size is rounded up to a multiple of this. |
| |
| If you do not define this macro, the default is the same as |
| @code{BITS_PER_UNIT}. |
| @end defmac |
| |
| @defmac STRICT_ALIGNMENT |
| Define this macro to be the value 1 if instructions will fail to work |
| if given data not on the nominal alignment. If instructions will merely |
| go slower in that case, define this macro as 0. |
| @end defmac |
| |
| @defmac PCC_BITFIELD_TYPE_MATTERS |
| Define this if you wish to imitate the way many other C compilers handle |
| alignment of bit-fields and the structures that contain them. |
| |
| The behavior is that the type written for a named bit-field (@code{int}, |
| @code{short}, or other integer type) imposes an alignment for the entire |
| structure, as if the structure really did contain an ordinary field of |
| that type. In addition, the bit-field is placed within the structure so |
| that it would fit within such a field, not crossing a boundary for it. |
| |
| Thus, on most machines, a named bit-field whose type is written as |
| @code{int} would not cross a four-byte boundary, and would force |
| four-byte alignment for the whole structure. (The alignment used may |
| not be four bytes; it is controlled by the other alignment parameters.) |
| |
| An unnamed bit-field will not affect the alignment of the containing |
| structure. |
| |
| If the macro is defined, its definition should be a C expression; |
| a nonzero value for the expression enables this behavior. |
| |
| Note that if this macro is not defined, or its value is zero, some |
| bit-fields may cross more than one alignment boundary. The compiler can |
| support such references if there are @samp{insv}, @samp{extv}, and |
| @samp{extzv} insns that can directly reference memory. |
| |
| The other known way of making bit-fields work is to define |
| @code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}. |
| Then every structure can be accessed with fullwords. |
| |
| Unless the machine has bit-field instructions or you define |
| @code{STRUCTURE_SIZE_BOUNDARY} that way, you must define |
| @code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value. |
| |
| If your aim is to make GCC use the same conventions for laying out |
| bit-fields as are used by another compiler, here is how to investigate |
| what the other compiler does. Compile and run this program: |
| |
| @smallexample |
| struct foo1 |
| @{ |
| char x; |
| char :0; |
| char y; |
| @}; |
| |
| struct foo2 |
| @{ |
| char x; |
| int :0; |
| char y; |
| @}; |
| |
| main () |
| @{ |
| printf ("Size of foo1 is %d\n", |
| sizeof (struct foo1)); |
| printf ("Size of foo2 is %d\n", |
| sizeof (struct foo2)); |
| exit (0); |
| @} |
| @end smallexample |
| |
| If this prints 2 and 5, then the compiler's behavior is what you would |
| get from @code{PCC_BITFIELD_TYPE_MATTERS}. |
| @end defmac |
| |
| @defmac BITFIELD_NBYTES_LIMITED |
| Like @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited |
| to aligning a bit-field within the structure. |
| @end defmac |
| |
| @defmac MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode}) |
| Return 1 if a structure or array containing @var{field} should be accessed using |
| @code{BLKMODE}. |
| |
| If @var{field} is the only field in the structure, @var{mode} is its |
| mode, otherwise @var{mode} is VOIDmode. @var{mode} is provided in the |
| case where structures of one field would require the structure's mode to |
| retain the field's mode. |
| |
| Normally, this is not needed. See the file @file{c4x.h} for an example |
| of how to use this macro to prevent a structure having a floating point |
| field from being accessed in an integer mode. |
| @end defmac |
| |
| @defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified}) |
| Define this macro as an expression for the alignment of a type (given |
| by @var{type} as a tree node) if the alignment computed in the usual |
| way is @var{computed} and the alignment explicitly specified was |
| @var{specified}. |
| |
| The default is to use @var{specified} if it is larger; otherwise, use |
| the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT} |
| @end defmac |
| |
| @defmac MAX_FIXED_MODE_SIZE |
| An integer expression for the size in bits of the largest integer |
| machine mode that should actually be used. All integer machine modes of |
| this size or smaller can be used for structures and unions with the |
| appropriate sizes. If this macro is undefined, @code{GET_MODE_BITSIZE |
| (DImode)} is assumed. |
| @end defmac |
| |
| @defmac VECTOR_MODE_SUPPORTED_P (@var{mode}) |
| Define this macro to be nonzero if the port is prepared to handle insns |
| involving vector mode @var{mode}. At the very least, it must have move |
| patterns for this mode. |
| @end defmac |
| |
| @defmac STACK_SAVEAREA_MODE (@var{save_level}) |
| If defined, an expression of type @code{enum machine_mode} that |
| specifies the mode of the save area operand of a |
| @code{save_stack_@var{level}} named pattern (@pxref{Standard Names}). |
| @var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or |
| @code{SAVE_NONLOCAL} and selects which of the three named patterns is |
| having its mode specified. |
| |
| You need not define this macro if it always returns @code{Pmode}. You |
| would most commonly define this macro if the |
| @code{save_stack_@var{level}} patterns need to support both a 32- and a |
| 64-bit mode. |
| @end defmac |
| |
| @defmac STACK_SIZE_MODE |
| If defined, an expression of type @code{enum machine_mode} that |
| specifies the mode of the size increment operand of an |
| @code{allocate_stack} named pattern (@pxref{Standard Names}). |
| |
| You need not define this macro if it always returns @code{word_mode}. |
| You would most commonly define this macro if the @code{allocate_stack} |
| pattern needs to support both a 32- and a 64-bit mode. |
| @end defmac |
| |
| @defmac TARGET_FLOAT_FORMAT |
| A code distinguishing the floating point format of the target machine. |
| There are four defined values: |
| |
| @ftable @code |
| @item IEEE_FLOAT_FORMAT |
| This code indicates IEEE floating point. It is the default; there is no |
| need to define @code{TARGET_FLOAT_FORMAT} when the format is IEEE@. |
| |
| @item VAX_FLOAT_FORMAT |
| This code indicates the ``F float'' (for @code{float}) and ``D float'' |
| or ``G float'' formats (for @code{double}) used on the VAX and PDP-11@. |
| |
| @item IBM_FLOAT_FORMAT |
| This code indicates the format used on the IBM System/370. |
| |
| @item C4X_FLOAT_FORMAT |
| This code indicates the format used on the TMS320C3x/C4x. |
| @end ftable |
| |
| If your target uses a floating point format other than these, you must |
| define a new @var{name}_FLOAT_FORMAT code for it, and add support for |
| it to @file{real.c}. |
| |
| The ordering of the component words of floating point values stored in |
| memory is controlled by @code{FLOAT_WORDS_BIG_ENDIAN}. |
| @end defmac |
| |
| @defmac MODE_HAS_NANS (@var{mode}) |
| When defined, this macro should be true if @var{mode} has a NaN |
| representation. The compiler assumes that NaNs are not equal to |
| anything (including themselves) and that addition, subtraction, |
| multiplication and division all return NaNs when one operand is |
| NaN@. |
| |
| By default, this macro is true if @var{mode} is a floating-point |
| mode and the target floating-point format is IEEE@. |
| @end defmac |
| |
| @defmac MODE_HAS_INFINITIES (@var{mode}) |
| This macro should be true if @var{mode} can represent infinity. At |
| present, the compiler uses this macro to decide whether @samp{x - x} |
| is always defined. By default, the macro is true when @var{mode} |
| is a floating-point mode and the target format is IEEE@. |
| @end defmac |
| |
| @defmac MODE_HAS_SIGNED_ZEROS (@var{mode}) |
| True if @var{mode} distinguishes between positive and negative zero. |
| The rules are expected to follow the IEEE standard: |
| |
| @itemize @bullet |
| @item |
| @samp{x + x} has the same sign as @samp{x}. |
| |
| @item |
| If the sum of two values with opposite sign is zero, the result is |
| positive for all rounding modes expect towards @minus{}infinity, for |
| which it is negative. |
| |
| @item |
| The sign of a product or quotient is negative when exactly one |
| of the operands is negative. |
| @end itemize |
| |
| The default definition is true if @var{mode} is a floating-point |
| mode and the target format is IEEE@. |
| @end defmac |
| |
| @defmac MODE_HAS_SIGN_DEPENDENT_ROUNDING (@var{mode}) |
| If defined, this macro should be true for @var{mode} if it has at |
| least one rounding mode in which @samp{x} and @samp{-x} can be |
| rounded to numbers of different magnitude. Two such modes are |
| towards @minus{}infinity and towards +infinity. |
| |
| The default definition of this macro is true if @var{mode} is |
| a floating-point mode and the target format is IEEE@. |
| @end defmac |
| |
| @defmac ROUND_TOWARDS_ZERO |
| If defined, this macro should be true if the prevailing rounding |
| mode is towards zero. A true value has the following effects: |
| |
| @itemize @bullet |
| @item |
| @code{MODE_HAS_SIGN_DEPENDENT_ROUNDING} will be false for all modes. |
| |
| @item |
| @file{libgcc.a}'s floating-point emulator will round towards zero |
| rather than towards nearest. |
| |
| @item |
| The compiler's floating-point emulator will round towards zero after |
| doing arithmetic, and when converting from the internal float format to |
| the target format. |
| @end itemize |
| |
| The macro does not affect the parsing of string literals. When the |
| primary rounding mode is towards zero, library functions like |
| @code{strtod} might still round towards nearest, and the compiler's |
| parser should behave like the target's @code{strtod} where possible. |
| |
| Not defining this macro is equivalent to returning zero. |
| @end defmac |
| |
| @defmac LARGEST_EXPONENT_IS_NORMAL (@var{size}) |
| This macro should return true if floats with @var{size} |
| bits do not have a NaN or infinity representation, but use the largest |
| exponent for normal numbers instead. |
| |
| Defining this macro to true for @var{size} causes @code{MODE_HAS_NANS} |
| and @code{MODE_HAS_INFINITIES} to be false for @var{size}-bit modes. |
| It also affects the way @file{libgcc.a} and @file{real.c} emulate |
| floating-point arithmetic. |
| |
| The default definition of this macro returns false for all sizes. |
| @end defmac |
| |
| @deftypefn {Target Hook} bool TARGET_VECTOR_OPAQUE_P (tree @var{type}) |
| This target hook should return @code{true} a vector is opaque. That |
| is, if no cast is needed when copying a vector value of type |
| @var{type} into another vector lvalue of the same size. Vector opaque |
| types cannot be initialized. The default is that there are no such |
| types. |
| @end deftypefn |
| |
| @deftypefn {Target Hook} bool TARGET_MS_BITFIELD_LAYOUT_P (tree @var{record_type}) |
| This target hook returns @code{true} if bit-fields in the given |
| @var{record_type} are to be laid out following the rules of Microsoft |
| Visual C/C++, namely: (i) a bit-field won't share the same storage |
| unit with the previous bit-field if their underlying types have |
| different sizes, and the bit-field will be aligned to the highest |
| alignment of the underlying types of itself and of the previous |
| bit-field; (ii) a zero-sized bit-field will affect the alignment of |
| the whole enclosing structure, even if it is unnamed; except that |
| (iii) a zero-sized bit-field will be disregarded unless it follows |
| another bit-field of nonzero size. If this hook returns @code{true}, |
| other macros that control bit-field layout are ignored. |
| |
| When a bit-field is inserted into a packed record, the whole size |
| of the underlying type is used by one or more same-size adjacent |
| bit-fields (that is, if its long:3, 32 bits is used in the record, |
| and any additional adjacent long bit-fields are packed into the same |
| chunk of 32 bits. However, if the size changes, a new field of that |
| size is allocated). In an unpacked record, this is the same as using |
| alignment, but not equivalent when packing. |
| |
| If both MS bit-fields and @samp{__attribute__((packed))} are used, |
| the latter will take precedence. If @samp{__attribute__((packed))} is |
| used on a single field when MS bit-fields are in use, it will take |
| precedence for that field, but the alignment of the rest of the structure |
| may affect its placement. |
| @end deftypefn |
| |
| @deftypefn {Target Hook} {const char *} TARGET_MANGLE_FUNDAMENTAL_TYPE (tree @var{type}) |
| If your target defines any fundamental types, define this hook to |
| return the appropriate encoding for these types as part of a C++ |
| mangled name. The @var{type} argument is the tree structure |
| representing the type to be mangled. The hook may be applied to trees |
| which are not target-specific fundamental types; it should return |
| @code{NULL} for all such types, as well as arguments it does not |
| recognize. If the return value is not @code{NULL}, it must point to |
| a statically-allocated string constant. |
| |
| Target-specific fundamental types might be new fundamental types or |
| qualified versions of ordinary fundamental types. Encode new |
| fundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name} |
| is the name used for the type in source code, and @var{n} is the |
| length of @var{name} in decimal. Encode qualified versions of |
| ordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where |
| @var{name} is the name used for the type qualifier in source code, |
| @var{n} is the length of @var{name} as above, and @var{code} is the |
| code used to represent the unqualified version of this type. (See |
| @code{write_builtin_type} in @file{cp/mangle.c} for the list of |
| codes.) In both cases the spaces are for clarity; do not include any |
| spaces in your string. |
| |
| The default version of this hook always returns @code{NULL}, which is |
| appropriate for a target that does not define any new fundamental |
| types. |
| @end deftypefn |
| |
| @node Type Layout |
| @section Layout of Source Language Data Types |
| |
| These macros define the sizes and other characteristics of the standard |
| basic data types used in programs being compiled. Unlike the macros in |
| the previous section, these apply to specific features of C and related |
| languages, rather than to fundamental aspects of storage layout. |
| |
| @defmac INT_TYPE_SIZE |
| A C expression for the size in bits of the type @code{int} on the |
| target machine. If you don't define this, the default is one word. |
| @end defmac |
| |
| @defmac SHORT_TYPE_SIZE |
| A C expression for the size in bits of the type @code{short} on the |
| target machine. If you don't define this, the default is half a word. |
| (If this would be less than one storage unit, it is rounded up to one |
| unit.) |
| @end defmac |
| |
| @defmac LONG_TYPE_SIZE |
| A C expression for the size in bits of the type @code{long} on the |
| target machine. If you don't define this, the default is one word. |
| @end defmac |
| |
| @defmac ADA_LONG_TYPE_SIZE |
| On some machines, the size used for the Ada equivalent of the type |
| @code{long} by a native Ada compiler differs from that used by C. In |
| that situation, define this macro to be a C expression to be used for |
| the size of that type. If you don't define this, the default is the |
| value of @code{LONG_TYPE_SIZE}. |
| @end defmac |
| |
| @defmac MAX_LONG_TYPE_SIZE |
| Maximum number for the size in bits of the type @code{long} on the |
| target machine. If this is undefined, the default is |
| @code{LONG_TYPE_SIZE}. Otherwise, it is the constant value that is the |
| largest value that @code{LONG_TYPE_SIZE} can have at run-time. This is |
| used in @code{cpp}. |
| @end defmac |
| |
| @defmac LONG_LONG_TYPE_SIZE |
| A C expression for the size in bits of the type @code{long long} on the |
| target machine. If you don't define this, the default is two |
| words. If you want to support GNU Ada on your machine, the value of this |
| macro must be at least 64. |
| @end defmac |
| |
| @defmac CHAR_TYPE_SIZE |
| A C expression for the size in bits of the type @code{char} on the |
| target machine. If you don't define this, the default is |
| @code{BITS_PER_UNIT}. |
| @end defmac |
| |
| @defmac BOOL_TYPE_SIZE |
| A C expression for the size in bits of the C++ type @code{bool} and |
| C99 type @code{_Bool} on the target machine. If you don't define |
| this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}. |
| @end defmac |
| |
| @defmac FLOAT_TYPE_SIZE |
| A C expression for the size in bits of the type @code{float} on the |
| target machine. If you don't define this, the default is one word. |
| @end defmac |
| |
| @defmac DOUBLE_TYPE_SIZE |
| A C expression for the size in bits of the type @code{double} on the |
| target machine. If you don't define this, the default is two |
| words. |
| @end defmac |
| |
| @defmac LONG_DOUBLE_TYPE_SIZE |
| A C expression for the size in bits of the type @code{long double} on |
| the target machine. If you don't define this, the default is two |
| words. |
| @end defmac |
| |
| @defmac MAX_LONG_DOUBLE_TYPE_SIZE |
| Maximum number for the size in bits of the type @code{long double} on the |
| target machine. If this is undefined, the default is |
| @code{LONG_DOUBLE_TYPE_SIZE}. Otherwise, it is the constant value that is |
| the largest value that @code{LONG_DOUBLE_TYPE_SIZE} can have at run-time. |
| This is used in @code{cpp}. |
| @end defmac |
| |
| @defmac TARGET_FLT_EVAL_METHOD |
| A C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h}, |
| assuming, if applicable, that the floating-point control word is in its |
| default state. If you do not define this macro the value of |
| @code{FLT_EVAL_METHOD} will be zero. |
| @end defmac |
| |
| @defmac WIDEST_HARDWARE_FP_SIZE |
| A C expression for the size in bits of the widest floating-point format |
| supported by the hardware. If you define this macro, you must specify a |
| value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}. |
| If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE} |
| is the default. |
| @end defmac |
| |
| @defmac DEFAULT_SIGNED_CHAR |
| An expression whose value is 1 or 0, according to whether the type |
| @code{char} should be signed or unsigned by default. The user can |
| always override this default with the options @option{-fsigned-char} |
| and @option{-funsigned-char}. |
| @end defmac |
| |
| @defmac DEFAULT_SHORT_ENUMS |
| A C expression to determine whether to give an @code{enum} type |
| only as many bytes as it takes to represent the range of possible values |
| of that type. A nonzero value means to do that; a zero value means all |
| @code{enum} types should be allocated like @code{int}. |
| |
| If you don't define the macro, the default is 0. |
| @end defmac |
| |
| @defmac SIZE_TYPE |
| A C expression for a string describing the name of the data type to use |
| for size values. The typedef name @code{size_t} is defined using the |
| contents of the string. |
| |
| The string can contain more than one keyword. If so, separate them with |
| spaces, and write first any length keyword, then @code{unsigned} if |
| appropriate, and finally @code{int}. The string must exactly match one |
| of the data type names defined in the function |
| @code{init_decl_processing} in the file @file{c-decl.c}. You may not |
| omit @code{int} or change the order---that would cause the compiler to |
| crash on startup. |
| |
| If you don't define this macro, the default is @code{"long unsigned |
| int"}. |
| @end defmac |
| |
| @defmac PTRDIFF_TYPE |
| A C expression for a string describing the name of the data type to use |
| for the result of subtracting two pointers. The typedef name |
| @code{ptrdiff_t} is defined using the contents of the string. See |
| @code{SIZE_TYPE} above for more information. |
| |
| If you don't define this macro, the default is @code{"long int"}. |
| @end defmac |
| |
| @defmac WCHAR_TYPE |
| A C expression for a string describing the name of the data type to use |
| for wide characters. The typedef name @code{wchar_t} is defined using |
| the contents of the string. See @code{SIZE_TYPE} above for more |
| information. |
| |
| If you don't define this macro, the default is @code{"int"}. |
| @end defmac |
| |
| @defmac WCHAR_TYPE_SIZE |
| A C expression for the size in bits of the data type for wide |
| characters. This is used in @code{cpp}, which cannot make use of |
| @code{WCHAR_TYPE}. |
| @end defmac |
| |
| @defmac MAX_WCHAR_TYPE_SIZE |
| Maximum number for the size in bits of the data type for wide |
| characters. If this is undefined, the default is |
| @code{WCHAR_TYPE_SIZE}. Otherwise, it is the constant value that is the |
| largest value that @code{WCHAR_TYPE_SIZE} can have at run-time. This is |
| used in @code{cpp}. |
| @end defmac |
| |
| @defmac GCOV_TYPE_SIZE |
| A C expression for the size in bits of the type used for gcov counters on the |
| target machine. If you don't define this, the default is one |
| @code{LONG_TYPE_SIZE} in case it is greater or equal to 64-bit and |
| @code{LONG_LONG_TYPE_SIZE} otherwise. You may want to re-define the type to |
| ensure atomicity for counters in multithreaded programs. |
| @end defmac |
| |
| @defmac WINT_TYPE |
| A C expression for a string describing the name of the data type to |
| use for wide characters passed to @code{printf} and returned from |
| @code{getwc}. The typedef name @code{wint_t} is defined using the |
| contents of the string. See @code{SIZE_TYPE} above for more |
| information. |
| |
| If you don't define this macro, the default is @code{"unsigned int"}. |
| @end defmac |
| |
| @defmac INTMAX_TYPE |
| A C expression for a string describing the name of the data type that |
| can represent any value of any standard or extended signed integer type. |
| The typedef name @code{intmax_t} is defined using the contents of the |
| string. See @code{SIZE_TYPE} above for more information. |
| |
| If you don't define this macro, the default is the first of |
| @code{"int"}, @code{"long int"}, or @code{"long long int"} that has as |
| much precision as @code{long long int}. |
| @end defmac |
| |
| @defmac UINTMAX_TYPE |
| A C expression for a string describing the name of the data type that |
| can represent any value of any standard or extended unsigned integer |
| type. The typedef name @code{uintmax_t} is defined using the contents |
| of the string. See @code{SIZE_TYPE} above for more information. |
| |
| If you don't define this macro, the default is the first of |
| @code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long |
| unsigned int"} that has as much precision as @code{long long unsigned |
| int}. |
| @end defmac |
| |
| @defmac TARGET_PTRMEMFUNC_VBIT_LOCATION |
| The C++ compiler represents a pointer-to-member-function with a struct |
| that looks like: |
| |
| @smallexample |
| struct @{ |
| union @{ |
| void (*fn)(); |
| ptrdiff_t vtable_index; |
| @}; |
| ptrdiff_t delta; |
| @}; |
| @end smallexample |
| |
| @noindent |
| The C++ compiler must use one bit to indicate whether the function that |
| will be called through a pointer-to-member-function is virtual. |
| Normally, we assume that the low-order bit of a function pointer must |
| always be zero. Then, by ensuring that the vtable_index is odd, we can |
| distinguish which variant of the union is in use. But, on some |
| platforms function pointers can be odd, and so this doesn't work. In |
| that case, we use the low-order bit of the @code{delta} field, and shift |
| the remainder of the @code{delta} field to the left. |
| |
| GCC will automatically make the right selection about where to store |
| this bit using the @code{FUNCTION_BOUNDARY} setting for your platform. |
| However, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY} |
| set such that functions always start at even addresses, but the lowest |
| bit of pointers to functions indicate whether the function at that |
| address is in ARM or Thumb mode. If this is the case of your |
| architecture, you should define this macro to |
| @code{ptrmemfunc_vbit_in_delta}. |
| |
| In general, you should not have to define this macro. On architectures |
| in which function addresses are always even, according to |
| @code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to |
| @code{ptrmemfunc_vbit_in_pfn}. |
| @end defmac |
| |
| @defmac TARGET_VTABLE_USES_DESCRIPTORS |
| Normally, the C++ compiler uses function pointers in vtables. This |
| macro allows the target to change to use ``function descriptors'' |
| instead. Function descriptors are found on targets for whom a |
| function pointer is actually a small data structure. Normally the |
| data structure consists of the actual code address plus a data |
| pointer to which the function's data is relative. |
| |
| If vtables are used, the value of this macro should be the number |
| of words that the function descriptor occupies. |
| @end defmac |
| |
| @defmac TARGET_VTABLE_ENTRY_ALIGN |
| By default, the vtable entries are void pointers, the so the alignment |
| is the same as pointer alignment. The value of this macro specifies |
| the alignment of the vtable entry in bits. It should be defined only |
| when special alignment is necessary. */ |
| @end defmac |
| |
| @defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE |
| There are a few non-descriptor entries in the vtable at offsets below |
| zero. If these entries must be padded (say, to preserve the alignment |
| specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number |
| of words in each data entry. |
| @end defmac |
| |
| @node Escape Sequences |
| @section Target Character Escape Sequences |
| @cindex escape sequences |
| |
| By default, GCC assumes that the C character escape sequences take on |
| their ASCII values for the target. If this is not correct, you must |
| explicitly define all of the macros below. All of them must evaluate |
| to constants; they are used in @code{case} statements. |
| |
| @findex TARGET_BELL |
| @findex TARGET_CR |
| @findex TARGET_ESC |
| @findex TARGET_FF |
| @findex TARGET_NEWLINE |
| @findex TARGET_TAB |
| @findex TARGET_VT |
| @multitable {@code{TARGET_NEWLINE}} {Escape} {ASCII character} |
| @item Macro @tab Escape @tab ASCII character |
| @item @code{TARGET_BELL} @tab @kbd{\a} @tab @code{07}, @code{BEL} |
| @item @code{TARGET_CR} @tab @kbd{\r} @tab @code{0D}, @code{CR} |
| @item @code{TARGET_ESC} @tab @kbd{\e}, @kbd{\E} @tab @code{1B}, @code{ESC} |
| @item @code{TARGET_FF} @tab @kbd{\f} @tab @code{0C}, @code{FF} |
| @item @code{TARGET_NEWLINE} @tab @kbd{\n} @tab @code{0A}, @code{LF} |
| @item @code{TARGET_TAB} @tab @kbd{\t} @tab @code{09}, @code{HT} |
| @item @code{TARGET_VT} @tab @kbd{\v} @tab @code{0B}, @code{VT} |
| @end multitable |
| |
| @noindent |
| Note that the @kbd{\e} and @kbd{\E} escapes are GNU extensions, not |
| part of the C standard. |
| |
| @node Registers |
| @section Register Usage |
| @cindex register usage |
| |
| This section explains how to describe what registers the target machine |
| has, and how (in general) they can be used. |
| |
| The description of which registers a specific instruction can use is |
| done with register classes; see @ref{Register Classes}. For information |
| on using registers to access a stack frame, see @ref{Frame Registers}. |
| For passing values in registers, see @ref{Register Arguments}. |
| For returning values in registers, see @ref{Scalar Return}. |
| |
| @menu |
| * Register Basics:: Number and kinds of registers. |
| * Allocation Order:: Order in which registers are allocated. |
| * Values in Registers:: What kinds of values each reg can hold. |
| * Leaf Functions:: Renumbering registers for leaf functions. |
| * Stack Registers:: Handling a register stack such as 80387. |
| @end menu |
| |
| @node Register Basics |
| @subsection Basic Characteristics of Registers |
| |
| @c prevent bad page break with this line |
| Registers have various characteristics. |
| |
| @defmac FIRST_PSEUDO_REGISTER |
| Number of hardware registers known to the compiler. They receive |
| numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first |
| pseudo register's number really is assigned the number |
| @code{FIRST_PSEUDO_REGISTER}. |
| @end defmac |
| |
| @defmac FIXED_REGISTERS |
| @cindex fixed register |
| An initializer that says which registers are used for fixed purposes |
| all throughout the compiled code and are therefore not available for |
| general allocation. These would include the stack pointer, the frame |
| pointer (except on machines where that can be used as a general |
| register when no frame pointer is needed), the program counter on |
| machines where that is considered one of the addressable registers, |
| and any other numbered register with a standard use. |
| |
| This information is expressed as a sequence of numbers, separated by |
| commas and surrounded by braces. The @var{n}th number is 1 if |
| register @var{n} is fixed, 0 otherwise. |
| |
| The table initialized from this macro, and the table initialized by |
| the following one, may be overridden at run time either automatically, |
| by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by |
| the user with the command options @option{-ffixed-@var{reg}}, |
| @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}. |
| @end defmac |
| |
| @defmac CALL_USED_REGISTERS |
| @cindex call-used register |
| @cindex call-clobbered register |
| @cindex call-saved register |
| Like @code{FIXED_REGISTERS} but has 1 for each register that is |
| clobbered (in general) by function calls as well as for fixed |
| registers. This macro therefore identifies the registers that are not |
| available for general allocation of values that must live across |
| function calls. |
| |
| If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler |
| automatically saves it on function entry and restores it on function |
| exit, if the register is used within the function. |
| @end defmac |
| |
| @defmac CALL_REALLY_USED_REGISTERS |
| @cindex call-used register |
| @cindex call-clobbered register |
| @cindex call-saved register |
| Like @code{CALL_USED_REGISTERS} except this macro doesn't require |
| that the entire set of @code{FIXED_REGISTERS} be included. |
| (@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}). |
| This macro is optional. If not specified, it defaults to the value |
| of @code{CALL_USED_REGISTERS}. |
| @end defmac |
| |
| @defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode}) |
| @cindex call-used register |
| @cindex call-clobbered register |
| @cindex call-saved register |
| A C expression that is nonzero if it is not permissible to store a |
| value of mode @var{mode} in hard register number @var{regno} across a |
| call without some part of it being clobbered. For most machines this |
| macro need not be defined. It is only required for machines that do not |
| preserve the entire contents of a register across a call. |
| @end defmac |
| |
| @findex fixed_regs |
| @findex call_used_regs |
| @findex global_regs |
| @findex reg_names |
| @findex reg_class_contents |
| @defmac CONDITIONAL_REGISTER_USAGE |
| Zero or more C statements that may conditionally modify five variables |
| @code{fixed_regs}, @code{call_used_regs}, @code{global_regs}, |
| @code{reg_names}, and @code{reg_class_contents}, to take into account |
| any dependence of these register sets on target flags. The first three |
| of these are of type @code{char []} (interpreted as Boolean vectors). |
| @code{global_regs} is a @code{const char *[]}, and |
| @code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is |
| called, @code{fixed_regs}, @code{call_used_regs}, |
| @code{reg_class_contents}, and @code{reg_names} have been initialized |
| from @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS}, |
| @code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively. |
| @code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}}, |
| @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}} |
| command options have been applied. |
| |
| You need not define this macro if it has no work to do. |
| |
| @cindex disabling certain registers |
| @cindex controlling register usage |
| If the usage of an entire class of registers depends on the target |
| flags, you may indicate this to GCC by using this macro to modify |
| @code{fixed_regs} and @code{call_used_regs} to 1 for each of the |
| registers in the classes which should not be used by GCC@. Also define |
| the macro @code{REG_CLASS_FROM_LETTER} / @code{REG_CLASS_FROM_CONSTRAINT} |
| to return @code{NO_REGS} if it |
| is called with a letter for a class that shouldn't be used. |
| |
| (However, if this class is not included in @code{GENERAL_REGS} and all |
| of the insn patterns whose constraints permit this class are |
| controlled by target switches, then GCC will automatically avoid using |
| these registers when the target switches are opposed to them.) |
| @end defmac |
| |
| @defmac NON_SAVING_SETJMP |
| If this macro is defined and has a nonzero value, it means that |
| @code{setjmp} and related functions fail to save the registers, or that |
| @code{longjmp} fails to restore them. To compensate, the compiler |
| avoids putting variables in registers in functions that use |
| @code{setjmp}. |
| @end defmac |
| |
| @defmac INCOMING_REGNO (@var{out}) |
| Define this macro if the target machine has register windows. This C |
| expression returns the register number as seen by the called function |
| corresponding to the register number @var{out} as seen by the calling |
| function. Return @var{out} if register number @var{out} is not an |
| outbound register. |
| @end defmac |
| |
| @defmac OUTGOING_REGNO (@var{in}) |
| Define this macro if the target machine has register windows. This C |
| expression returns the register number as seen by the calling function |
| corresponding to the register number @var{in} as seen by the called |
| function. Return @var{in} if register number @var{in} is not an inbound |
| register. |
| @end defmac |
| |
| @defmac LOCAL_REGNO (@var{regno}) |
| Define this macro if the target machine has register windows. This C |
| expression returns true if the register is call-saved but is in the |
| register window. Unlike most call-saved registers, such registers |
| need not be explicitly restored on function exit or during non-local |
| gotos. |
| @end defmac |
| |
| @defmac PC_REGNUM |
| If the program counter has a register number, define this as that |
| register number. Otherwise, do not define it. |
| @end defmac |
| |
| @node Allocation Order |
| @subsection Order of Allocation of Registers |
| @cindex order of register allocation |
| @cindex register allocation order |
| |
| @c prevent bad page break with this line |
| Registers are allocated in order. |
| |
| @defmac REG_ALLOC_ORDER |
| If defined, an initializer for a vector of integers, containing the |
| numbers of hard registers in the order in which GCC should prefer |
| to use them (from most preferred to least). |
| |
| If this macro is not defined, registers are used lowest numbered first |
| (all else being equal). |
| |
| One use of this macro is on machines where the highest numbered |
| registers must always be saved and the save-multiple-registers |
| instruction supports only sequences of consecutive registers. On such |
| machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists |
| the highest numbered allocable register first. |
| @end defmac |
| |
| @defmac ORDER_REGS_FOR_LOCAL_ALLOC |
| A C statement (sans semicolon) to choose the order in which to allocate |
| hard registers for pseudo-registers local to a basic block. |
| |
| Store the desired register order in the array @code{reg_alloc_order}. |
| Element 0 should be the register to allocate first; element 1, the next |
| register; and so on. |
| |
| The macro body should not assume anything about the contents of |
| @code{reg_alloc_order} before execution of the macro. |
| |
| On most machines, it is not necessary to define this macro. |
| @end defmac |
| |
| @node Values in Registers |
| @subsection How Values Fit in Registers |
| |
| This section discusses the macros that describe which kinds of values |
| (specifically, which machine modes) each register can hold, and how many |
| consecutive registers are needed for a given mode. |
| |
| @defmac HARD_REGNO_NREGS (@var{regno}, @var{mode}) |
| A C expression for the number of consecutive hard registers, starting |
| at register number @var{regno}, required to hold a value of mode |
| @var{mode}. |
| |
| On a machine where all registers are exactly one word, a suitable |
| definition of this macro is |
| |
| @smallexample |
| #define HARD_REGNO_NREGS(REGNO, MODE) \ |
| ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \ |
| / UNITS_PER_WORD) |
| @end smallexample |
| @end defmac |
| |
| @defmac REGMODE_NATURAL_SIZE (@var{mode}) |
| Define this macro if the natural size of registers that hold values |
| of mode @var{mode} is not the word size. It is a C expression that |
| should give the natural size in bytes for the specified mode. It is |
| used by the register allocator to try to optimize its results. This |
| happens for example on SPARC 64-bit where the natural size of |
| floating-point registers is still 32-bit. |
| @end defmac |
| |
| @defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode}) |
| A C expression that is nonzero if it is permissible to store a value |
| of mode @var{mode} in hard register number @var{regno} (or in several |
| registers starting with that one). For a machine where all registers |
| are equivalent, a suitable definition is |
| |
| @smallexample |
| #define HARD_REGNO_MODE_OK(REGNO, MODE) 1 |
| @end smallexample |
| |
| You need not include code to check for the numbers of fixed registers, |
| because the allocation mechanism considers them to be always occupied. |
| |
| @cindex register pairs |
| On some machines, double-precision values must be kept in even/odd |
| register pairs. You can implement that by defining this macro to reject |
| odd register numbers for such modes. |
| |
| The minimum requirement for a mode to be OK in a register is that the |
| @samp{mov@var{mode}} instruction pattern support moves between the |
| register and other hard register in the same class and that moving a |
| value into the register and back out not alter it. |
| |
| Since the same instruction used to move @code{word_mode} will work for |
| all narrower integer modes, it is not necessary on any machine for |
| @code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided |
| you define patterns @samp{movhi}, etc., to take advantage of this. This |
| is useful because of the interaction between @code{HARD_REGNO_MODE_OK} |
| and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes |
| to be tieable. |
| |
| Many machines have special registers for floating point arithmetic. |
| Often people assume that floating point machine modes are allowed only |
| in floating point registers. This is not true. Any registers that |
| can hold integers can safely @emph{hold} a floating point machine |
| mode, whether or not floating arithmetic can be done on it in those |
| registers. Integer move instructions can be used to move the values. |
| |
| On some machines, though, the converse is true: fixed-point machine |
| modes may not go in floating registers. This is true if the floating |
| registers normalize any value stored in them, because storing a |
| non-floating value there would garble it. In this case, |
| @code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in |
| floating registers. But if the floating registers do not automatically |
| normalize, if you can store any bit pattern in one and retrieve it |
| unchanged without a trap, then any machine mode may go in a floating |
| register, so you can define this macro to say so. |
| |
| The primary significance of special floating registers is rather that |
| they are the registers acceptable in floating point arithmetic |
| instructions. However, this is of no concern to |
| @code{HARD_REGNO_MODE_OK}. You handle it by writing the proper |
| constraints for those instructions. |
| |
| On some machines, the floating registers are especially slow to access, |
| so that it is better to store a value in a stack frame than in such a |
| register if floating point arithmetic is not being done. As long as the |
| floating registers are not in class @code{GENERAL_REGS}, they will not |
| be used unless some pattern's constraint asks for one. |
| @end defmac |
| |
| @defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2}) |
| A C expression that is nonzero if a value of mode |
| @var{mode1} is accessible in mode @var{mode2} without copying. |
| |
| If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and |
| @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for |
| any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})} |
| should be nonzero. If they differ for any @var{r}, you should define |
| this macro to return zero unless some other mechanism ensures the |
| accessibility of the value in a narrower mode. |
| |
| You should define this macro to return nonzero in as many cases as |
| possible since doing so will allow GCC to perform better register |
| allocation. |
| @end defmac |
| |
| @defmac AVOID_CCMODE_COPIES |
| Define this macro if the compiler should avoid copies to/from @code{CCmode} |
| registers. You should only define this macro if support for copying to/from |
| @code{CCmode} is incomplete. |
| @end defmac |
| |
| @node Leaf Functions |
| @subsection Handling Leaf Functions |
| |
| @cindex leaf functions |
| @cindex functions, leaf |
| On some machines, a leaf function (i.e., one which makes no calls) can run |
| more efficiently if it does not make its own register window. Often this |
| means it is required to receive its arguments in the registers where they |
| are passed by the caller, instead of the registers where they would |
| normally arrive. |
| |
| The special treatment for leaf functions generally applies only when |
| other conditions are met; for example, often they may use only those |
| registers for its own variables and temporaries. We use the term ``leaf |
| function'' to mean a function that is suitable for this special |
| handling, so that functions with no calls are not necessarily ``leaf |
| functions''. |
| |
| GCC assigns register numbers before it knows whether the function is |
| suitable for leaf function treatment. So it needs to renumber the |
| registers in order to output a leaf function. The following macros |
| accomplish this. |
| |
| @defmac LEAF_REGISTERS |
| Name of a char vector, indexed by hard register number, which |
| contains 1 for a register that is allowable in a candidate for leaf |
| function treatment. |
| |
| If leaf function treatment involves renumbering the registers, then the |
| registers marked here should be the ones before renumbering---those that |
| GCC would ordinarily allocate. The registers which will actually be |
| used in the assembler code, after renumbering, should not be marked with 1 |
| in this vector. |
| |
| Define this macro only if the target machine offers a way to optimize |
| the treatment of leaf functions. |
| @end defmac |
| |
| @defmac LEAF_REG_REMAP (@var{regno}) |
| A C expression whose value is the register number to which @var{regno} |
| should be renumbered, when a function is treated as a leaf function. |
| |
| If @var{regno} is a register number which should not appear in a leaf |
| function before renumbering, then the expression should yield @minus{}1, which |
| will cause the compiler to abort. |
| |
| Define this macro only if the target machine offers a way to optimize the |
| treatment of leaf functions, and registers need to be renumbered to do |
| this. |
| @end defmac |
| |
| @findex current_function_is_leaf |
| @findex current_function_uses_only_leaf_regs |
| @code{TARGET_ASM_FUNCTION_PROLOGUE} and |
| @code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions |
| specially. They can test the C variable @code{current_function_is_leaf} |
| which is nonzero for leaf functions. @code{current_function_is_leaf} is |
| set prior to local register allocation and is valid for the remaining |
| compiler passes. They can also test the C variable |
| @code{current_function_uses_only_leaf_regs} which is nonzero for leaf |
| functions which only use leaf registers. |
| @code{current_function_uses_only_leaf_regs} is valid after reload and is |
| only useful if @code{LEAF_REGISTERS} is defined. |
| @c changed this to fix overfull. ALSO: why the "it" at the beginning |
| @c of the next paragraph?! --mew 2feb93 |
| |
| @node Stack Registers |
| @subsection Registers That Form a Stack |
| |
| There are special features to handle computers where some of the |
| ``registers'' form a stack. Stack registers are normally written by |
| pushing onto the stack, and are numbered relative to the top of the |
| stack. |
| |
| Currently, GCC can only handle one group of stack-like registers, and |
| they must be consecutively numbered. Furthermore, the existing |
| support for stack-like registers is specific to the 80387 floating |
| point coprocessor. If you have a new architecture that uses |
| stack-like registers, you will need to do substantial work on |
| @file{reg-stack.c} and write your machine description to cooperate |
| with it, as well as defining these macros. |
| |
| @defmac STACK_REGS |
| Define this if the machine has any stack-like registers. |
| @end defmac |
| |
| @defmac FIRST_STACK_REG |
| The number of the first stack-like register. This one is the top |
| of the stack. |
| @end defmac |
| |
| @defmac LAST_STACK_REG |
| The number of the last stack-like register. This one is the bottom of |
| the stack. |
| @end defmac |
| |
| @node Register Classes |
| @section Register Classes |
| @cindex register class definitions |
| @cindex class definitions, register |
| |
| On many machines, the numbered registers are not all equivalent. |
| For example, certain registers may not be allowed for indexed addressing; |
| certain registers may not be allowed in some instructions. These machine |
| restrictions are described to the compiler using @dfn{register classes}. |
| |
| You define a number of register classes, giving each one a name and saying |
| which of the registers belong to it. Then you can specify register classes |
| that are allowed as operands to particular instruction patterns. |
| |
| @findex ALL_REGS |
| @findex NO_REGS |
| In general, each register will belong to several classes. In fact, one |
| class must be named @code{ALL_REGS} and contain all the registers. Another |
| class must be named @code{NO_REGS} and contain no registers. Often the |
| union of two classes will be another class; however, this is not required. |
| |
| @findex GENERAL_REGS |
| One of the classes must be named @code{GENERAL_REGS}. There is nothing |
| terribly special about the name, but the operand constraint letters |
| @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is |
| the same as @code{ALL_REGS}, just define it as a macro which expands |
| to @code{ALL_REGS}. |
| |
| Order the classes so that if class @var{x} is contained in class @var{y} |
| then @var{x} has a lower class number than @var{y}. |
| |
| The way classes other than @code{GENERAL_REGS} are specified in operand |
| constraints is through machine-dependent operand constraint letters. |
| You can define such letters to correspond to various classes, then use |
| them in operand constraints. |
| |
| You should define a class for the union of two classes whenever some |
| instruction allows both classes. For example, if an instruction allows |
| either a floating point (coprocessor) register or a general register for a |
| certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS} |
| which includes both of them. Otherwise you will get suboptimal code. |
| |
| You must also specify certain redundant information about the register |
| classes: for each class, which classes contain it and which ones are |
| contained in it; for each pair of classes, the largest class contained |
| in their union. |
| |
| When a value occupying several consecutive registers is expected in a |
| certain class, all the registers used must belong to that class. |
| Therefore, register classes cannot be used to enforce a requirement for |
| a register pair to start with an even-numbered register. The way to |
| specify this requirement is with @code{HARD_REGNO_MODE_OK}. |
| |
| Register classes used for input-operands of bitwise-and or shift |
| instructions have a special requirement: each such class must have, for |
| each fixed-point machine mode, a subclass whose registers can transfer that |
| mode to or from memory. For example, on some machines, the operations for |
| single-byte values (@code{QImode}) are limited to certain registers. When |
| this is so, each register class that is used in a bitwise-and or shift |
| instruction must have a subclass consisting of registers from which |
| single-byte values can be loaded or stored. This is so that |
| @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return. |
| |
| @deftp {Data type} {enum reg_class} |
| An enumerated type that must be defined with all the register class names |
| as enumerated values. @code{NO_REGS} must be first. @code{ALL_REGS} |
| must be the last register class, followed by one more enumerated value, |
| @code{LIM_REG_CLASSES}, which is not a register class but rather |
| tells how many classes there are. |
| |
| Each register class has a number, which is the value of casting |
| the class name to type @code{int}. The number serves as an index |
| in many of the tables described below. |
| @end deftp |
| |
| @defmac N_REG_CLASSES |
| The number of distinct register classes, defined as follows: |
| |
| @smallexample |
| #define N_REG_CLASSES (int) LIM_REG_CLASSES |
| @end smallexample |
| @end defmac |
| |
| @defmac REG_CLASS_NAMES |
| An initializer containing the names of the register classes as C string |
| constants. These names are used in writing some of the debugging dumps. |
| @end defmac |
| |
| @defmac REG_CLASS_CONTENTS |
| An initializer containing the contents of the register classes, as integers |
| which are bit masks. The @var{n}th integer specifies the contents of class |
| @var{n}. The way the integer @var{mask} is interpreted is that |
| register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1. |
| |
| When the machine has more than 32 registers, an integer does not suffice. |
| Then the integers are replaced by sub-initializers, braced groupings containing |
| several integers. Each sub-initializer must be suitable as an initializer |
| for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}. |
| In this situation, the first integer in each sub-initializer corresponds to |
| registers 0 through 31, the second integer to registers 32 through 63, and |
| so on. |
| @end defmac |
| |
| @defmac REGNO_REG_CLASS (@var{regno}) |
| A C expression whose value is a register class containing hard register |
| @var{regno}. In general there is more than one such class; choose a class |
| which is @dfn{minimal}, meaning that no smaller class also contains the |
| register. |
| @end defmac |
| |
| @defmac BASE_REG_CLASS |
| A macro whose definition is the name of the class to which a valid |
| base register must belong. A base register is one used in an address |
| which is the register value plus a displacement. |
| @end defmac |
| |
| @defmac MODE_BASE_REG_CLASS (@var{mode}) |
| This is a variation of the @code{BASE_REG_CLASS} macro which allows |
| the selection of a base register in a mode dependent manner. If |
| @var{mode} is VOIDmode then it should return the same value as |
| @code{BASE_REG_CLASS}. |
| @end defmac |
| |
| @defmac INDEX_REG_CLASS |
| A macro whose definition is the name of the class to which a valid |
| index register must belong. An index register is one used in an |
| address where its value is either multiplied by a scale factor or |
| added to another register (as well as added to a displacement). |
| @end defmac |
| |
| @defmac CONSTRAINT_LEN (@var{char}, @var{str}) |
| For the constraint at the start of @var{str}, which starts with the letter |
| @var{c}, return the length. This allows you to have register class / |
| constant / extra constraints that are longer than a single letter; |
| you don't need to define this macro if you can do with single-letter |
| constraints only. The definition of this macro should use |
| DEFAULT_CONSTRAINT_LEN for all the characters that you don't want |
| to handle specially. |
| There are some sanity checks in genoutput.c that check the constraint lengths |
| for the md file, so you can also use this macro to help you while you are |
| transitioning from a byzantine single-letter-constraint scheme: when you |
| return a negative length for a constraint you want to re-use, genoutput |
| will complain about every instance where it is used in the md file. |
| @end defmac |
| |
| @defmac REG_CLASS_FROM_LETTER (@var{char}) |
| A C expression which defines the machine-dependent operand constraint |
| letters for register classes. If @var{char} is such a letter, the |
| value should be the register class corresponding to it. Otherwise, |
| the value should be @code{NO_REGS}. The register letter @samp{r}, |
| corresponding to class @code{GENERAL_REGS}, will not be passed |
| to this macro; you do not need to handle it. |
| @end defmac |
| |
| @defmac REG_CLASS_FROM_CONSTRAINT (@var{char}, @var{str}) |
| Like @code{REG_CLASS_FROM_LETTER}, but you also get the constraint string |
| passed in @var{str}, so that you can use suffixes to distinguish between |
| different variants. |
| @end defmac |
| |
| @defmac REGNO_OK_FOR_BASE_P (@var{num}) |
| A C expression which is nonzero if register number @var{num} is |
| suitable for use as a base register in operand addresses. It may be |
| either a suitable hard register or a pseudo register that has been |
| allocated such a hard register. |
| @end defmac |
| |
| @defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode}) |
| A C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that |
| that expression may examine the mode of the memory reference in |
| @var{mode}. You should define this macro if the mode of the memory |
| reference affects whether a register may be used as a base register. If |
| you define this macro, the compiler will use it instead of |
| @code{REGNO_OK_FOR_BASE_P}. |
| @end defmac |
| |
| @defmac REGNO_OK_FOR_INDEX_P (@var{num}) |
| A C expression which is nonzero if register number @var{num} is |
| suitable for use as an index register in operand addresses. It may be |
| either a suitable hard register or a pseudo register that has been |
| allocated such a hard register. |
| |
| The difference between an index register and a base register is that |
| the index register may be scaled. If an address involves the sum of |
| two registers, neither one of them scaled, then either one may be |
| labeled the ``base'' and the other the ``index''; but whichever |
| labeling is used must fit the machine's constraints of which registers |
| may serve in each capacity. The compiler will try both labelings, |
| looking for one that is valid, and will reload one or both registers |
| only if neither labeling works. |
| @end defmac |
| |
| @defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class}) |
| A C expression that places additional restrictions on the register class |
| to use when it is necessary to copy value @var{x} into a register in class |
| @var{class}. The value is a register class; perhaps @var{class}, or perhaps |
| another, smaller class. On many machines, the following definition is |
| safe: |
| |
| @smallexample |
| #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS |
| @end smallexample |
| |
| Sometimes returning a more restrictive class makes better code. For |
| example, on the 68000, when @var{x} is an integer constant that is in range |
| for a @samp{moveq} instruction, the value of this macro is always |
| @code{DATA_REGS} as long as @var{class} includes the data registers. |
| Requiring a data register guarantees that a @samp{moveq} will be used. |
| |
| One case where @code{PREFERRED_RELOAD_CLASS} must not return |
| @var{class} is if @var{x} is a legitimate constant which cannot be |
| loaded into some register class. By returning @code{NO_REGS} you can |
| force @var{x} into a memory location. For example, rs6000 can load |
| immediate values into general-purpose registers, but does not have an |
| instruction for loading an immediate value into a floating-point |
| register, so @code{PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when |
| @var{x} is a floating-point constant. If the constant can't be loaded |
| into any kind of register, code generation will be better if |
| @code{LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead |
| of using @code{PREFERRED_RELOAD_CLASS}. |
| @end defmac |
| |
| @defmac PREFERRED_OUTPUT_RELOAD_CLASS (@var{x}, @var{class}) |
| Like @code{PREFERRED_RELOAD_CLASS}, but for output reloads instead of |
| input reloads. If you don't define this macro, the default is to use |
| @var{class}, unchanged. |
| @end defmac |
| |
| @defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class}) |
| A C expression that places additional restrictions on the register class |
| to use when it is necessary to be able to hold a value of mode |
| @var{mode} in a reload register for which class @var{class} would |
| ordinarily be used. |
| |
| Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when |
| there are certain modes that simply can't go in certain reload classes. |
| |
| The value is a register class; perhaps @var{class}, or perhaps another, |
| smaller class. |
| |
| Don't define this macro unless the target machine has limitations which |
| require the macro to do something nontrivial. |
| @end defmac |
| |
| @defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) |
| @defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) |
| @defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) |
| Many machines have some registers that cannot be copied directly to or |
| from memory or even from other types of registers. An example is the |
| @samp{MQ} register, which on most machines, can only be copied to or |
| from general registers, but not memory. Some machines allow copying all |
| registers to and from memory, but require a scratch register for stores |
| to some memory locations (e.g., those with symbolic address on the RT, |
| and those with certain symbolic address on the SPARC when compiling |
| PIC)@. In some cases, both an intermediate and a scratch register are |
| required. |
| |
| You should define these macros to indicate to the reload phase that it may |
| need to allocate at least one register for a reload in addition to the |
| register to contain the data. Specifically, if copying @var{x} to a |
| register @var{class} in @var{mode} requires an intermediate register, |
| you should define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the |
| largest register class all of whose registers can be used as |
| intermediate registers or scratch registers. |
| |
| If copying a register @var{class} in @var{mode} to @var{x} requires an |
| intermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS} |
| should be defined to return the largest register class required. If the |
| requirements for input and output reloads are the same, the macro |
| @code{SECONDARY_RELOAD_CLASS} should be used instead of defining both |
| macros identically. |
| |
| The values returned by these macros are often @code{GENERAL_REGS}. |
| Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x} |
| can be directly copied to or from a register of @var{class} in |
| @var{mode} without requiring a scratch register. Do not define this |
| macro if it would always return @code{NO_REGS}. |
| |
| If a scratch register is required (either with or without an |
| intermediate register), you should define patterns for |
| @samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required |
| (@pxref{Standard Names}. These patterns, which will normally be |
| implemented with a @code{define_expand}, should be similar to the |
| @samp{mov@var{m}} patterns, except that operand 2 is the scratch |
| register. |
| |
| Define constraints for the reload register and scratch register that |
| contain a single register class. If the original reload register (whose |
| class is @var{class}) can meet the constraint given in the pattern, the |
| value returned by these macros is used for the class of the scratch |
| register. Otherwise, two additional reload registers are required. |
| Their classes are obtained from the constraints in the insn pattern. |
| |
| @var{x} might be a pseudo-register or a @code{subreg} of a |
| pseudo-register, which could either be in a hard register or in memory. |
| Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is |
| in memory and the hard register number if it is in a register. |
| |
| These macros should not be used in the case where a particular class of |
| registers can only be copied to memory and not to another class of |
| registers. In that case, secondary reload registers are not needed and |
| would not be helpful. Instead, a stack location must be used to perform |
| the copy and the @code{mov@var{m}} pattern should use memory as an |
| intermediate storage. This case often occurs between floating-point and |
| general registers. |
| @end defmac |
| |
| @defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m}) |
| Certain machines have the property that some registers cannot be copied |
| to some other registers without using memory. Define this macro on |
| those machines to be a C expression that is nonzero if objects of mode |
| @var{m} in registers of @var{class1} can only be copied to registers of |
| class @var{class2} by storing a register of @var{class1} into memory |
| and loading that memory location into a register of @var{class2}. |
| |
| Do not define this macro if its value would always be zero. |
| @end defmac |
| |
| @defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode}) |
| Normally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler |
| allocates a stack slot for a memory location needed for register copies. |
| If this macro is defined, the compiler instead uses the memory location |
| defined by this macro. |
| |
| Do not define this macro if you do not define |
| @code{SECONDARY_MEMORY_NEEDED}. |
| @end defmac |
| |
| @defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode}) |
| When the compiler needs a secondary memory location to copy between two |
| registers of mode @var{mode}, it normally allocates sufficient memory to |
| hold a quantity of @code{BITS_PER_WORD} bits and performs the store and |
| load operations in a mode that many bits wide and whose class is the |
| same as that of @var{mode}. |
| |
| This is right thing to do on most machines because it ensures that all |
| bits of the register are copied and prevents accesses to the registers |
| in a narrower mode, which some machines prohibit for floating-point |
| registers. |
| |
| However, this default behavior is not correct on some machines, such as |
| the DEC Alpha, that store short integers in floating-point registers |
| differently than in integer registers. On those machines, the default |
| widening will not work correctly and you must define this macro to |
| suppress that widening in some cases. See the file @file{alpha.h} for |
| details. |
| |
| Do not define this macro if you do not define |
| @code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that |
| is @code{BITS_PER_WORD} bits wide is correct for your machine. |
| @end defmac |
| |
| @defmac SMALL_REGISTER_CLASSES |
| On some machines, it is risky to let hard registers live across arbitrary |
| insns. Typically, these machines have instructions that require values |
| to be in specific registers (like an accumulator), and reload will fail |
| if the required hard register is used for another purpose across such an |
| insn. |
| |
| Define @code{SMALL_REGISTER_CLASSES} to be an expression with a nonzero |
| value on these machines. When this macro has a nonzero value, the |
| compiler will try to minimize the lifetime of hard registers. |
| |
| It is always safe to define this macro with a nonzero value, but if you |
| unnecessarily define it, you will reduce the amount of optimizations |
| that can be performed in some cases. If you do not define this macro |
| with a nonzero value when it is required, the compiler will run out of |
| spill registers and print a fatal error message. For most machines, you |
| should not define this macro at all. |
| @end defmac |
| |
| @defmac CLASS_LIKELY_SPILLED_P (@var{class}) |
| A C expression whose value is nonzero if pseudos that have been assigned |
| to registers of class @var{class} would likely be spilled because |
| registers of @var{class} are needed for spill registers. |
| |
| The default value of this macro returns 1 if @var{class} has exactly one |
| register and zero otherwise. On most machines, this default should be |
| used. Only define this macro to some other expression if pseudos |
| allocated by @file{local-alloc.c} end up in memory because their hard |
| registers were needed for spill registers. If this macro returns nonzero |
| for those classes, those pseudos will only be allocated by |
| @file{global.c}, which knows how to reallocate the pseudo to another |
| register. If there would not be another register available for |
| reallocation, you should not change the definition of this macro since |
| the only effect of such a definition would be to slow down register |
| allocation. |
| @end defmac |
| |
| @defmac CLASS_MAX_NREGS (@var{class}, @var{mode}) |
| A C expression for the maximum number of consecutive registers |
| of class @var{class} needed to hold a value of mode @var{mode}. |
| |
| This is closely related to the macro @code{HARD_REGNO_NREGS}. In fact, |
| the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})} |
| should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno}, |
| @var{mode})} for all @var{regno} values in the class @var{class}. |
| |
| This macro helps control the handling of multiple-word values |
| in the reload pass. |
| @end defmac |
| |
| @defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class}) |
| If defined, a C expression that returns nonzero for a @var{class} for which |
| a change from mode @var{from} to mode @var{to} is invalid. |
| |
| For the example, loading 32-bit integer or floating-point objects into |
| floating-point registers on the Alpha extends them to 64 bits. |
| Therefore loading a 64-bit object and then storing it as a 32-bit object |
| does not store the low-order 32 bits, as would be the case for a normal |
| register. Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS} |
| as below: |
| |
| @smallexample |
| #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \ |
| (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \ |
| ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0) |
| @end smallexample |
| @end defmac |
| |
| Three other special macros describe which operands fit which constraint |
| letters. |
| |
| @defmac CONST_OK_FOR_LETTER_P (@var{value}, @var{c}) |
| A C expression that defines the machine-dependent operand constraint |
| letters (@samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}) that specify |
| particular ranges of integer values. If @var{c} is one of those |
| letters, the expression should check that @var{value}, an integer, is in |
| the appropriate range and return 1 if so, 0 otherwise. If @var{c} is |
| not one of those letters, the value should be 0 regardless of |
| @var{value}. |
| @end defmac |
| |
| @defmac CONST_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str}) |
| Like @code{CONST_OK_FOR_LETTER_P}, but you also get the constraint |
| string passed in @var{str}, so that you can use suffixes to distinguish |
| between different variants. |
| @end defmac |
| |
| @defmac CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c}) |
| A C expression that defines the machine-dependent operand constraint |
| letters that specify particular ranges of @code{const_double} values |
| (@samp{G} or @samp{H}). |
| |
| If @var{c} is one of those letters, the expression should check that |
| @var{value}, an RTX of code @code{const_double}, is in the appropriate |
| range and return 1 if so, 0 otherwise. If @var{c} is not one of those |
| letters, the value should be 0 regardless of @var{value}. |
| |
| @code{const_double} is used for all floating-point constants and for |
| @code{DImode} fixed-point constants. A given letter can accept either |
| or both kinds of values. It can use @code{GET_MODE} to distinguish |
| between these kinds. |
| @end defmac |
| |
| @defmac CONST_DOUBLE_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str}) |
| Like @code{CONST_DOUBLE_OK_FOR_LETTER_P}, but you also get the constraint |
| string passed in @var{str}, so that you can use suffixes to distinguish |
| between different variants. |
| @end defmac |
| |
| @defmac EXTRA_CONSTRAINT (@var{value}, @var{c}) |
| A C expression that defines the optional machine-dependent constraint |
| letters that can be used to segregate specific types of operands, usually |
| memory references, for the target machine. Any letter that is not |
| elsewhere defined and not matched by @code{REG_CLASS_FROM_LETTER} / |
| @code{REG_CLASS_FROM_CONSTRAINT} |
| may be used. Normally this macro will not be defined. |
| |
| If it is required for a particular target machine, it should return 1 |
| if @var{value} corresponds to the operand type represented by the |
| constraint letter @var{c}. If @var{c} is not defined as an extra |
| constraint, the value returned should be 0 regardless of @var{value}. |
| |
| For example, on the ROMP, load instructions cannot have their output |
| in r0 if the memory reference contains a symbolic address. Constraint |
| letter @samp{Q} is defined as representing a memory address that does |
| @emph{not} contain a symbolic address. An alternative is specified with |
| a @samp{Q} constraint on the input and @samp{r} on the output. The next |
| alternative specifies @samp{m} on the input and a register class that |
| does not include r0 on the output. |
| @end defmac |
| |
| @defmac EXTRA_CONSTRAINT_STR (@var{value}, @var{c}, @var{str}) |
| Like @code{EXTRA_CONSTRAINT}, but you also get the constraint string passed |
| in @var{str}, so that you can use suffixes to distinguish between different |
| variants. |
| @end defmac |
| |
| @defmac EXTRA_MEMORY_CONSTRAINT (@var{c}, @var{str}) |
| A C expression that defines the optional machine-dependent constraint |
| letters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should |
| be treated like memory constraints by the reload pass. |
| |
| It should return 1 if the operand type represented by the constraint |
| at the start of @var{str}, the first letter of which is the letter @var{c}, |
| comprises a subset of all memory references including |
| all those whose address is simply a base register. This allows the reload |
| pass to reload an operand, if it does not directly correspond to the operand |
| type of @var{c}, by copying its address into a base register. |
| |
| For example, on the S/390, some instructions do not accept arbitrary |
| memory references, but only those that do not make use of an index |
| register. The constraint letter @samp{Q} is defined via |
| @code{EXTRA_CONSTRAINT} as representing a memory address of this type. |
| If the letter @samp{Q} is marked as @code{EXTRA_MEMORY_CONSTRAINT}, |
| a @samp{Q} constraint can handle any memory operand, because the |
| reload pass knows it can be reloaded by copying the memory address |
| into a base register if required. This is analogous to the way |
| a @samp{o} constraint can handle any memory operand. |
| @end defmac |
| |
| @defmac EXTRA_ADDRESS_CONSTRAINT (@var{c}, @var{str}) |
| A C expression that defines the optional machine-dependent constraint |
| letters, amongst those accepted by @code{EXTRA_CONSTRAINT} / |
| @code{EXTRA_CONSTRAINT_STR}, that should |
| be treated like address constraints by the reload pass. |
| |
| It should return 1 if the operand type represented by the constraint |
| at the start of @var{str}, which starts with the letter @var{c}, comprises |
| a subset of all memory addresses including |
| all those that consist of just a base register. This allows the reload |
| pass to reload an operand, if it does not directly correspond to the operand |
| type of @var{str}, by copying it into a base register. |
| |
| Any constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only |
| be used with the @code{address_operand} predicate. It is treated |
| analogously to the @samp{p} constraint. |
| @end defmac |
| |
| @node Stack and Calling |
| @section Stack Layout and Calling Conventions |
| @cindex calling conventions |
| |
| @c prevent bad page break with this line |
| This describes the stack layout and calling conventions. |
| |
| @menu |
| * Frame Layout:: |
| * Exception Handling:: |
| * Stack Checking:: |
| * Frame Registers:: |
| * Elimination:: |
| * Stack Arguments:: |
| * Register Arguments:: |
| * Scalar Return:: |
| * Aggregate Return:: |
| * Caller Saves:: |
| * Function Entry:: |
| * Profiling:: |
| * Tail Calls:: |
| @end menu |
| |
| @node Frame Layout |
| @subsection Basic Stack Layout |
| @cindex stack frame layout |
| @cindex frame layout |
| |
| @c prevent bad page break with this line |
| Here is the basic stack layout. |
| |
| @defmac STACK_GROWS_DOWNWARD |
| Define this macro if pushing a word onto the stack moves the stack |
| pointer to a smaller address. |
| |
| When we say, ``define this macro if @dots{},'' it means that the |
| compiler checks this macro only with @code{#ifdef} so the precise |
| definition used does not matter. |
| @end defmac |
| |
| @defmac STACK_PUSH_CODE |
| This macro defines the operation used when something is pushed |
| on the stack. In RTL, a push operation will be |
| @code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})} |
| |
| The choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC}, |
| and @code{POST_INC}. Which of these is correct depends on |
| the stack direction and on whether the stack pointer points |
| to the last item on the stack or whether it points to the |
| space for the next item on the stack. |
| |
| The default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is |
| defined, which is almost always right, and @code{PRE_INC} otherwise, |
| which is often wrong. |
| @end defmac |
| |
| @defmac FRAME_GROWS_DOWNWARD |
| Define this macro if the addresses of local variable slots are at negative |
| offsets from the frame pointer. |
| @end defmac |
| |
| @defmac ARGS_GROW_DOWNWARD |
| Define this macro if successive arguments to a function occupy decreasing |
| addresses on the stack. |
| @end defmac |
| |
| @defmac STARTING_FRAME_OFFSET |
| Offset from the frame pointer to the first local variable slot to be allocated. |
| |
| If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by |
| subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}. |
| Otherwise, it is found by adding the length of the first slot to the |
| value @code{STARTING_FRAME_OFFSET}. |
| @c i'm not sure if the above is still correct.. had to change it to get |
| @c rid of an overfull. --mew 2feb93 |
| @end defmac |
| |
| @defmac STACK_ALIGNMENT_NEEDED |
| Define to zero to disable final alignment of the stack during reload. |
| The nonzero default for this macro is suitable for most ports. |
| |
| On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there |
| is a register save block following the local block that doesn't require |
| alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable |
| stack alignment and do it in the backend. |
| @end defmac |
| |
| @defmac STACK_POINTER_OFFSET |
| Offset from the stack pointer register to the first location at which |
| outgoing arguments are placed. If not specified, the default value of |
| zero is used. This is the proper value for most machines. |
| |
| If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above |
| the first location at which outgoing arguments are placed. |
| @end defmac |
| |
| @defmac FIRST_PARM_OFFSET (@var{fundecl}) |
| Offset from the argument pointer register to the first argument's |
| address. On some machines it may depend on the data type of the |
| function. |
| |
| If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above |
| the first argument's address. |
| @end defmac |
| |
| @defmac STACK_DYNAMIC_OFFSET (@var{fundecl}) |
| Offset from the stack pointer register to an item dynamically allocated |
| on the stack, e.g., by @code{alloca}. |
| |
| The default value for this macro is @code{STACK_POINTER_OFFSET} plus the |
| length of the outgoing arguments. The default is correct for most |
| machines. See @file{function.c} for details. |
| @end defmac |
| |
| @defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr}) |
| A C expression whose value is RTL representing the address in a stack |
| frame where the pointer to the caller's frame is stored. Assume that |
| @var{frameaddr} is an RTL expression for the address of the stack frame |
| itself. |
| |
| If you don't define this macro, the default is to return the value |
| of @var{frameaddr}---that is, the stack frame address is also the |
| address of the stack word that points to the previous frame. |
| @end defmac |
| |
| @defmac SETUP_FRAME_ADDRESSES |
| If defined, a C expression that produces the machine-specific code to |
| setup the stack so that arbitrary frames can be accessed. For example, |
| on the SPARC, we must flush all of the register windows to the stack |
| before we can access arbitrary stack frames. You will seldom need to |
| define this macro. |
| @end defmac |
| |
| @defmac BUILTIN_SETJMP_FRAME_VALUE |
| If defined, a C expression that contains an rtx that is used to store |
| the address of the current frame into the built in @code{setjmp} buffer. |
| The default value, @code{virtual_stack_vars_rtx}, is correct for most |
| machines. One reason you may need to define this macro is if |
| @code{hard_frame_pointer_rtx} is the appropriate value on your machine. |
| @end defmac |
| |
| @defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr}) |
| A C expression whose value is RTL representing the value of the return |
| address for the frame @var{count} steps up from the current frame, after |
| the prologue. @var{frameaddr} is the frame pointer of the @var{count} |
| frame, or the frame pointer of the @var{count} @minus{} 1 frame if |
| @code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined. |
| |
| The value of the expression must always be the correct address when |
| @var{count} is zero, but may be @code{NULL_RTX} if there is not way to |
| determine the return address of other frames. |
| @end defmac |
| |
| @defmac RETURN_ADDR_IN_PREVIOUS_FRAME |
| Define this if the return address of a particular stack frame is accessed |
| from the frame pointer of the previous stack frame. |
| @end defmac |
| |
| @defmac INCOMING_RETURN_ADDR_RTX |
| A C expression whose value is RTL representing the location of the |
| incoming return address at the beginning of any function, before the |
| prologue. This RTL is either a @code{REG}, indicating that the return |
| value is saved in @samp{REG}, or a @code{MEM} representing a location in |
| the stack. |
| |
| You only need to define this macro if you want to support call frame |
| debugging information like that provided by DWARF 2. |
| |
| If this RTL is a @code{REG}, you should also define |
| @code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}. |
| @end defmac |
| |
| @defmac DWARF_ALT_FRAME_RETURN_COLUMN |
| A C expression whose value is an integer giving a DWARF 2 column |
| number that may be used as an alternate return column. This should |
| be defined only if @code{DWARF_FRAME_RETURN_COLUMN} is set to a |
| general register, but an alternate column needs to be used for |
| signal frames. |
| @end defmac |
| |
| @defmac DWARF_ZERO_REG |
| A C expression whose value is an integer giving a DWARF 2 register |
| number that is considered to always have the value zero. This should |
| only be defined if the target has an architected zero register, and |
| someone decided it was a good idea to use that register number to |
| terminate the stack backtrace. New ports should avoid this. |
| @end defmac |
| |
| @defmac INCOMING_FRAME_SP_OFFSET |
| A C expression whose value is an integer giving the offset, in bytes, |
| from the value of the stack pointer register to the top of the stack |
| frame at the beginning of any function, before the prologue. The top of |
| the frame is defined to be the value of the stack pointer in the |
| previous frame, just before the call instruction. |
| |
| You only need to define this macro if you want to support call frame |
| debugging information like that provided by DWARF 2. |
| @end defmac |
| |
| @defmac ARG_POINTER_CFA_OFFSET (@var{fundecl}) |
| A C expression whose value is an integer giving the offset, in bytes, |
| from the argument pointer to the canonical frame address (cfa). The |
| final value should coincide with that calculated by |
| @code{INCOMING_FRAME_SP_OFFSET}. Which is unfortunately not usable |
| during virtual register instantiation. |
| |
| The default value for this macro is @code{FIRST_PARM_OFFSET (fundecl)}, |
| which is correct for most machines; in general, the arguments are found |
| immediately before the stack frame. Note that this is not the case on |
| some targets that save registers into the caller's frame, such as SPARC |
| and rs6000, and so such targets need to define this macro. |
| |
| You only need to define this macro if the default is incorrect, and you |
| want to support call frame debugging information like that provided by |
| DWARF 2. |
| @end defmac |
| |
| @node Exception Handling |
| @subsection Exception Handling Support |
| @cindex exception handling |
| |
| @defmac EH_RETURN_DATA_REGNO (@var{N}) |
| A C expression whose value is the @var{N}th register number used for |
| data by exception handlers, or @code{INVALID_REGNUM} if fewer than |
| @var{N} registers are usable. |
| |
| The exception handling library routines communicate with the exception |
| handlers via a set of agreed upon registers. Ideally these registers |
| should be call-clobbered; it is possible to use call-saved registers, |
| but may negatively impact code size. The target must support at least |
| 2 data registers, but should define 4 if there are enough free registers. |
| |
| You must define this macro if you want to support call frame exception |
| handling like that provided by DWARF 2. |
| @end defmac |
| |
| @defmac EH_RETURN_STACKADJ_RTX |
| A C expression whose value is RTL representing a location in which |
| to store a stack adjustment to be applied before function return. |
| This is used to unwind the stack to an exception handler's call frame. |
| It will be assigned zero on code paths that return normally. |
| |
| Typically this is a call-clobbered hard register that is otherwise |
| untouched by the epilogue, but could also be a stack slot. |
| |
| Do not define this macro if the stack pointer is saved and restored |
| by the regular prolog and epilog code in the call frame itself; in |
| this case, the exception handling library routines will update the |
| stack location to be restored in place. Otherwise, you must define |
| this macro if you want to support call frame exception handling like |
| that provided by DWARF 2. |
| @end defmac |
| |
| @defmac EH_RETURN_HANDLER_RTX |
| A C expression whose value is RTL representing a location in which |
| to store the address of an exception handler to which we should |
| return. It will not be assigned on code paths that return normally. |
| |
| Typically this is the location in the call frame at which the normal |
| return address is stored. For targets that return by popping an |
| address off the stack, this might be a memory address just below |
| the @emph{target} call frame rather than inside the current call |
| frame. If defined, @code{EH_RETURN_STACKADJ_RTX} will have already |
| been assigned, so it may be used to calculate the location of the |
| target call frame. |
| |
| Some targets have more complex requirements than storing to an |
| address calculable during initial code generation. In that case |
| the @code{eh_return} instruction pattern should be used instead. |
| |
| If you want to support call frame exception handling, you must |
| define either this macro or the @code{eh_return} instruction pattern. |
| @end defmac |
| |
| @defmac RETURN_ADDR_OFFSET |
| If defined, an integer-valued C expression for which rtl will be generated |
| to add it to the exception handler address before it is searched in the |
| exception handling tables, and to subtract it again from the address before |
| using it to return to the exception handler. |
| @end defmac |
| |
| @defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global}) |
| This macro chooses the encoding of pointers embedded in the exception |
| handling sections. If at all possible, this should be defined such |
| that the exception handling section will not require dynamic relocations, |
| and so may be read-only. |
| |
| @var{code} is 0 for data, 1 for code labels, 2 for function pointers. |
| @var{global} is true if the symbol may be affected by dynamic relocations. |
| The macro should return a combination of the @code{DW_EH_PE_*} defines |
| as found in @file{dwarf2.h}. |
| |
| If this macro is not defined, pointers will not be encoded but |
| represented directly. |
| @end defmac |
| |
| @defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done}) |
| This macro allows the target to emit whatever special magic is required |
| to represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}. |
| Generic code takes care of pc-relative and indirect encodings; this must |
| be defined if the target uses text-relative or data-relative encodings. |
| |
| This is a C statement that branches to @var{done} if the format was |
| handled. @var{encoding} is the format chosen, @var{size} is the number |
| of bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF} |
| to be emitted. |
| @end defmac |
| |
| @defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs}, @var{success}) |
| This macro allows the target to add cpu and operating system specific |
| code to the call-frame unwinder for use when there is no unwind data |
| available. The most common reason to implement this macro is to unwind |
| through signal frames. |
| |
| This macro is called from @code{uw_frame_state_for} in @file{unwind-dw2.c} |
| and @file{unwind-ia64.c}. @var{context} is an @code{_Unwind_Context}; |
| @var{fs} is an @code{_Unwind_FrameState}. Examine @code{context->ra} |
| for the address of the code being executed and @code{context->cfa} for |
| the stack pointer value. If the frame can be decoded, the register save |
| addresses should be updated in @var{fs} and the macro should branch to |
| @var{success}. If the frame cannot be decoded, the macro should do |
| nothing. |
| |
| For proper signal handling in Java this macro is accompanied by |
| @code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers. |
| @end defmac |
| |
| @defmac MD_HANDLE_UNWABI (@var{context}, @var{fs}) |
| This macro allows the target to add operating system specific code to the |
| call-frame unwinder to handle the IA-64 @code{.unwabi} unwinding directive, |
| usually used for signal or interrupt frames. |
| |
| This macro is called from @code{uw_update_context} in @file{unwind-ia64.c}. |
| @var{context} is an @code{_Unwind_Context}; |
| @var{fs} is an @code{_Unwind_FrameState}. Examine @code{fs->unwabi} |
| for the abi and context in the @code{.unwabi} directive. If the |
| @code{.unwabi} directive can be handled, the register save addresses should |
| be updated in @var{fs}. |
| @end defmac |
| |
| @node Stack Checking |
| @subsection Specifying How Stack Checking is Done |
| |
| GCC will check that stack references are within the boundaries of |
| the stack, if the @option{-fstack-check} is specified, in one of three ways: |
| |
| @enumerate |
| @item |
| If the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC |
| will assume that you have arranged for stack checking to be done at |
| appropriate places in the configuration files, e.g., in |
| @code{TARGET_ASM_FUNCTION_PROLOGUE}. GCC will do not other special |
| processing. |
| |
| @item |
| If @code{STACK_CHECK_BUILTIN} is zero and you defined a named pattern |
| called @code{check_stack} in your @file{md} file, GCC will call that |
| pattern with one argument which is the address to compare the stack |
| value against. You must arrange for this pattern to report an error if |
| the stack pointer is out of range. |
| |
| @item |
| If neither of the above are true, GCC will generate code to periodically |
| ``probe'' the stack pointer using the values of the macros defined below. |
| @end enumerate |
| |
| Normally, you will use the default values of these macros, so GCC |
| will use the third approach. |
| |
| @defmac STACK_CHECK_BUILTIN |
| A nonzero value if stack checking is done by the configuration files in a |
| machine-dependent manner. You should define this macro if stack checking |
| is require by the ABI of your machine or if you would like to have to stack |
| checking in some more efficient way than GCC's portable approach. |
| The default value of this macro is zero. |
| @end defmac |
| |
| @defmac STACK_CHECK_PROBE_INTERVAL |
| An integer representing the interval at which GCC must generate stack |
| probe instructions. You will normally define this macro to be no larger |
| than the size of the ``guard pages'' at the end of a stack area. The |
| default value of 4096 is suitable for most systems. |
| @end defmac |
| |
| @defmac STACK_CHECK_PROBE_LOAD |
| A integer which is nonzero if GCC should perform the stack probe |
| as a load instruction and zero if GCC should use a store instruction. |
| The default is zero, which is the most efficient choice on most systems. |
| @end defmac |
| |
| @defmac STACK_CHECK_PROTECT |
| The number of bytes of stack needed to recover from a stack overflow, |
| for languages where such a recovery is supported. The default value of |
| 75 words should be adequate for most machines. |
| @end defmac |
| |
| @defmac STACK_CHECK_MAX_FRAME_SIZE |
| The maximum size of a stack frame, in bytes. GCC will generate probe |
| instructions in non-leaf functions to ensure at least this many bytes of |
| stack are available. If a stack frame is larger than this size, stack |
| checking will not be reliable and GCC will issue a warning. The |
| default is chosen so that GCC only generates one instruction on most |
| systems. You should normally not change the default value of this macro. |
| @end defmac |
| |
| @defmac STACK_CHECK_FIXED_FRAME_SIZE |
| GCC uses this value to generate the above warning message. It |
| represents the amount of fixed frame used by a function, not including |
| space for any callee-saved registers, temporaries and user variables. |
| You need only specify an upper bound for this amount and will normally |
| use the default of four words. |
| @end defmac |
| |
| @defmac STACK_CHECK_MAX_VAR_SIZE |
| The maximum size, in bytes, of an object that GCC will place in the |
| fixed area of the stack frame when the user specifies |
| @option{-fstack-check}. |
| GCC computed the default from the values of the above macros and you will |
| normally not need to override that default. |
| @end defmac |
| |
| @need 2000 |
| @node Frame Registers |
| @subsection Registers That Address the Stack Frame |
| |
| @c prevent bad page break with this line |
| This discusses registers that address the stack frame. |
| |
| @defmac STACK_POINTER_REGNUM |
| The register number of the stack pointer register, which must also be a |
| fixed register according to @code{FIXED_REGISTERS}. On most machines, |
| the hardware determines which register this is. |
| @end defmac |
| |
| @defmac FRAME_POINTER_REGNUM |
| The register number of the frame pointer register, which is used to |
| access automatic variables in the stack frame. On some machines, the |
| hardware determines which register this is. On other machines, you can |
| choose any register you wish for this purpose. |
| @end defmac |
| |
| @defmac HARD_FRAME_POINTER_REGNUM |
| On some machines the offset between the frame pointer and starting |
| offset of the automatic variables is not known until after register |
| allocation has been done (for example, because the saved registers are |
| between these two locations). On those machines, define |
| @code{FRAME_POINTER_REGNUM} the number of a special, fixed register to |
| be used internally until the offset is known, and define |
| @code{HARD_FRAME_POINTER_REGNUM} to be the actual hard register number |
| used for the frame pointer. |
| |
| You should define this macro only in the very rare circumstances when it |
| is not possible to calculate the offset between the frame pointer and |
| the automatic variables until after register allocation has been |
| completed. When this macro is defined, you must also indicate in your |
| definition of @code{ELIMINABLE_REGS} how to eliminate |
| @code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM} |
| or @code{STACK_POINTER_REGNUM}. |
| |
| Do not define this macro if it would be the same as |
| @code{FRAME_POINTER_REGNUM}. |
| @end defmac |
| |
| @defmac ARG_POINTER_REGNUM |
| The register number of the arg pointer register, which is used to access |
| the function's argument list. On some machines, this is the same as the |
| frame pointer register. On some machines, the hardware determines which |
| register this is. On other machines, you can choose any register you |
| wish for this purpose. If this is not the same register as the frame |
| pointer register, then you must mark it as a fixed register according to |
| @code{FIXED_REGISTERS}, or arrange to be able to eliminate it |
| (@pxref{Elimination}). |
| @end defmac |
| |
| @defmac RETURN_ADDRESS_POINTER_REGNUM |
| The register number of the return address pointer register, which is used to |
| access the current function's return address from the stack. On some |
| machines, the return address is not at a fixed offset from the frame |
| pointer or stack pointer or argument pointer. This register can be defined |
| to point to the return address on the stack, and then be converted by |
| @code{ELIMINABLE_REGS} into either the frame pointer or stack pointer. |
| |
| Do not define this macro unless there is no other way to get the return |
| address from the stack. |
| @end defmac |
| |
| @defmac STATIC_CHAIN_REGNUM |
| @defmacx STATIC_CHAIN_INCOMING_REGNUM |
| Register numbers used for passing a function's static chain pointer. If |
| register windows are used, the register number as seen by the called |
| function is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register |
| number as seen by the calling function is @code{STATIC_CHAIN_REGNUM}. If |
| these registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need |
| not be defined. |
| |
| The static chain register need not be a fixed register. |
| |
| If the static chain is passed in memory, these macros should not be |
| defined; instead, the next two macros should be defined. |
| @end defmac |
| |
| @defmac STATIC_CHAIN |
| @defmacx STATIC_CHAIN_INCOMING |
| If the static chain is passed in memory, these macros provide rtx giving |
| @code{mem} expressions that denote where they are stored. |
| @code{STATIC_CHAIN} and @code{STATIC_CHAIN_INCOMING} give the locations |
| as seen by the calling and called functions, respectively. Often the former |
| will be at an offset from the stack pointer and the latter at an offset from |
| the frame pointer. |
| |
| @findex stack_pointer_rtx |
| @findex frame_pointer_rtx |
| @findex arg_pointer_rtx |
| The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and |
| @code{arg_pointer_rtx} will have been initialized prior to the use of these |
| macros and should be used to refer to those items. |
| |
| If the static chain is passed in a register, the two previous macros should |
| be defined instead. |
| @end defmac |
| |
| @defmac DWARF_FRAME_REGISTERS |
| This macro specifies the maximum number of hard registers that can be |
| saved in a call frame. This is used to size data structures used in |
| DWARF2 exception handling. |
| |
| Prior to GCC 3.0, this macro was needed in order to establish a stable |
| exception handling ABI in the face of adding new hard registers for ISA |
| extensions. In GCC 3.0 and later, the EH ABI is insulated from changes |
| in the number of hard registers. Nevertheless, this macro can still be |
| used to reduce the runtime memory requirements of the exception handling |
| routines, which can be substantial if the ISA contains a lot of |
| registers that are not call-saved. |
| |
| If this macro is not defined, it defaults to |
| @code{FIRST_PSEUDO_REGISTER}. |
| @end defmac |
| |
| @defmac PRE_GCC3_DWARF_FRAME_REGISTERS |
| |
| This macro is similar to @code{DWARF_FRAME_REGISTERS}, but is provided |
| for backward compatibility in pre GCC 3.0 compiled code. |
| |
| If this macro is not defined, it defaults to |
| @code{DWARF_FRAME_REGISTERS}. |
| @end defmac |
| |
| @defmac DWARF_REG_TO_UNWIND_COLUMN (@var{regno}) |
| |
| Define this macro if the target's representation for dwarf registers |
| is different than the internal representation for unwind column. |
| Given a dwarf register, this macro should return the internal unwind |
| column number to use instead. |
| |
| See the PowerPC's SPE target for an example. |
| @end defmac |
| |
| @defmac DWARF_FRAME_REGNUM (@var{regno}) |
| |
| Define this macro if the target's representation for dwarf registers |
| used in .eh_frame or .debug_frame is different from that used in other |
| debug info sections. Given a GCC hard register number, this macro |
| should return the .eh_frame register number. The default is |
| @code{DBX_REGISTER_NUMBER (@var{regno})}. |
| |
| @end defmac |
| |
| @defmac DWARF2_FRAME_REG_OUT (@var{regno}, @var{for_eh}) |
| |
| Define this macro to map register numbers held in the call frame info |
| that GCC has collected using @code{DWARF_FRAME_REGNUM} to those that |
| should be output in .debug_frame (@code{@var{for_eh}} is zero) and |
| .eh_frame (@code{@var{for_eh}} is nonzero). The default is to |
| return @code{@var{regno}}. |
| |
| @end defmac |
| |
| @node Elimination |
| @subsection Eliminating Frame Pointer and Arg Pointer |
| |
| @c prevent bad page break with this line |
| This is about eliminating the frame pointer and arg pointer. |
| |
| @defmac FRAME_POINTER_REQUIRED |
| A C expression which is nonzero if a function must have and use a frame |
| pointer. This expression is evaluated in the reload pass. If its value is |
| nonzero the function will have a frame pointer. |
| |
| The expression can in principle examine the current function and decide |
| according to the facts, but on most machines the constant 0 or the |
| constant 1 suffices. Use 0 when the machine allows code to be generated |
| with no frame pointer, and doing so saves some time or space. Use 1 |
| when there is no possible advantage to avoiding a frame pointer. |
| |
| In certain cases, the compiler does not know how to produce valid code |
| without a frame pointer. The compiler recognizes those cases and |
| automatically gives the function a frame pointer regardless of what |
| @code{FRAME_POINTER_REQUIRED} says. You don't need to worry about |
| them. |
| |
| In a function that does not require a frame pointer, the frame pointer |
| register can be allocated for ordinary usage, unless you mark it as a |
| fixed register. See @code{FIXED_REGISTERS} for more information. |
| @end defmac |
| |
| @findex get_frame_size |
| @defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var}) |
| A C statement to store in the variable @var{depth-var} the difference |
| between the frame pointer and the stack pointer values immediately after |
| the function prologue. The value would be computed from information |
| such as the result of @code{get_frame_size ()} and the tables of |
| registers @code{regs_ever_live} and @code{call_used_regs}. |
| |
| If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and |
| need not be defined. Otherwise, it must be defined even if |
| @code{FRAME_POINTER_REQUIRED} is defined to always be true; in that |
| case, you may set @var{depth-var} to anything. |
| @end defmac |
| |
| @defmac ELIMINABLE_REGS |
| If defined, this macro specifies a table of register pairs used to |
| eliminate unneeded registers that point into the stack frame. If it is not |
| defined, the only elimination attempted by the compiler is to replace |
| references to the frame pointer with references to the stack pointer. |
| |
| The definition of this macro is a list of structure initializations, each |
| of which specifies an original and replacement register. |
| |
| On some machines, the position of the argument pointer is not known until |
| the compilation is completed. In such a case, a separate hard register |
| must be used for the argument pointer. This register can be eliminated by |
| replacing it with either the frame pointer or the argument pointer, |
| depending on whether or not the frame pointer has been eliminated. |
| |
| In this case, you might specify: |
| @smallexample |
| #define ELIMINABLE_REGS \ |
| @{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \ |
| @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \ |
| @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@} |
| @end smallexample |
| |
| Note that the elimination of the argument pointer with the stack pointer is |
| specified first since that is the preferred elimination. |
| @end defmac |
| |
| @defmac CAN_ELIMINATE (@var{from-reg}, @var{to-reg}) |
| A C expression that returns nonzero if the compiler is allowed to try |
| to replace register number @var{from-reg} with register number |
| @var{to-reg}. This macro need only be defined if @code{ELIMINABLE_REGS} |
| is defined, and will usually be the constant 1, since most of the cases |
| preventing register elimination are things that the compiler already |
| knows about. |
| @end defmac |
| |
| @defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var}) |
| This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It |
| specifies the initial difference between the specified pair of |
| registers. This macro must be defined if @code{ELIMINABLE_REGS} is |
| defined. |
| @end defmac |
| |
| @node Stack Arguments |
| @subsection Passing Function Arguments on the Stack |
| @cindex arguments on stack |
| @cindex stack arguments |
| |
| The macros in this section control how arguments are passed |
| on the stack. See the following section for other macros that |
| control passing certain arguments in registers. |
| |
| @deftypefn {Target Hook} bool TARGET_PROMOTE_PROTOTYPES (tree @var{fntype}) |
| This target hook returns @code{true} if an argument declared in a |
| prototype as an integral type smaller than @code{int} should actually be |
| passed as an @code{int}. In addition to avoiding errors in certain |
| cases of mismatch, it also makes for better code on certain machines. |
| The default is to not promote prototypes. |
| @end deftypefn |
| |
| @defmac PUSH_ARGS |
| A C expression. If nonzero, push insns will be used to pass |
| outgoing arguments. |
| If the target machine does not have a push instruction, set it to zero. |
| That directs GCC to use an alternate strategy: to |
| allocate the entire argument block and then store the arguments into |
| it. When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too. |
| @end defmac |
| |
| @defmac PUSH_ARGS_REVERSED |
| A C expression. If nonzero, function arguments will be evaluated from |
| last to first, rather than from first to last. If this macro is not |
| defined, it defaults to @code{PUSH_ARGS} on targets where the stack |
| and args grow in opposite directions, and 0 otherwise. |
| @end defmac |
| |
| @defmac PUSH_ROUNDING (@var{npushed}) |
| A C expression that is the number of bytes actually pushed onto the |
| stack when an instruction attempts to push @var{npushed} bytes. |
| |
| On some machines, the definition |
| |
| @smallexample |
| #define PUSH_ROUNDING(BYTES) (BYTES) |
| @end smallexample |
| |
| @noindent |
| will suffice. But on other machines, instructions that appear |
| to push one byte actually push two bytes in an attempt to maintain |
| alignment. Then the definition should be |
| |
| @smallexample |
| #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) |
| @end smallexample |
| @end defmac |
| |
| @findex current_function_outgoing_args_size |
| @defmac ACCUMULATE_OUTGOING_ARGS |
| A C expression. If nonzero, the maximum amount of space required for outgoing arguments |
| will be computed and placed into the variable |
| @code{current_function_outgoing_args_size}. No space will be pushed |
| onto the stack for each call; instead, the function prologue should |
| increase the stack frame size by this amount. |
| |
| Setting both @code{PUSH_ARGS} and @code{ACCUMULATE_OUTGOING_ARGS} |
| is not proper. |
| @end defmac |
| |
| @defmac REG_PARM_STACK_SPACE (@var{fndecl}) |
| Define this macro if functions should assume that stack space has been |
| allocated for arguments even when their values are passed in |
| registers. |
| |
| The value of this macro is the size, in bytes, of the area reserved for |
| arguments passed in registers for the function represented by @var{fndecl}, |
| which can be zero if GCC is calling a library function. |
| |
| This space can be allocated by the caller, or be a part of the |
| machine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE} says |
| which. |
| @end defmac |
| @c above is overfull. not sure what to do. --mew 5feb93 did |
| @c something, not sure if it looks good. --mew 10feb93 |
| |
| @defmac MAYBE_REG_PARM_STACK_SPACE |
| @defmacx FINAL_REG_PARM_STACK_SPACE (@var{const_size}, @var{var_size}) |
| Define these macros in addition to the one above if functions might |
| allocate stack space for arguments even when their values are passed |
| in registers. These should be used when the stack space allocated |
| for arguments in registers is not a simple constant independent of the |
| function declaration. |
| |
| The value of the first macro is the size, in bytes, of the area that |
| we should initially assume would be reserved for arguments passed in registers. |
| |
| The value of the second macro is the actual size, in bytes, of the area |
| that will be reserved for arguments passed in registers. This takes two |
| arguments: an integer representing the number of bytes of fixed sized |
| arguments on the stack, and a tree representing the number of bytes of |
| variable sized arguments on the stack. |
| |
| When these macros are defined, @code{REG_PARM_STACK_SPACE} will only be |
| called for libcall functions, the current function, or for a function |
| being called when it is known that such stack space must be allocated. |
| In each case this value can be easily computed. |
| |
| When deciding whether a called function needs such stack space, and how |
| much space to reserve, GCC uses these two macros instead of |
| @code{REG_PARM_STACK_SPACE}. |
| @end defmac |
| |
| @defmac OUTGOING_REG_PARM_STACK_SPACE |
| Define this if it is the responsibility of the caller to allocate the area |
| reserved for arguments passed in registers. |
| |
| If @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls |
| whether the space for these arguments counts in the value of |
| @code{current_function_outgoing_args_size}. |
| @end defmac |
| |
| @defmac STACK_PARMS_IN_REG_PARM_AREA |
| Define this macro if @code{REG_PARM_STACK_SPACE} is defined, but the |
| stack parameters don't skip the area specified by it. |
| @c i changed this, makes more sens and it should have taken care of the |
| @c overfull.. not as specific, tho. --mew 5feb93 |
| |
| Normally, when a parameter is not passed in registers, it is placed on the |
| stack beyond the @code{REG_PARM_STACK_SPACE} area. Defining this macro |
| suppresses this behavior and causes the parameter to be passed on the |
| stack in its natural location. |
| @end defmac |
| |
| @defmac RETURN_POPS_ARGS (@var{fundecl}, @var{funtype}, @var{stack-size}) |
| A C expression that should indicate the number of bytes of its own |
| arguments that a function pops on returning, or 0 if the |
| function pops no arguments and the caller must therefore pop them all |
| after the function returns. |
| |
| @var{fundecl} is a C variable whose value is a tree node that describes |
| the function in question. Normally it is a node of type |
| @code{FUNCTION_DECL} that describes the declaration of the function. |
| From this you can obtain the @code{DECL_ATTRIBUTES} of the function. |
| |
| @var{funtype} is a C variable whose value is a tree node that |
| describes the function in question. Normally it is a node of type |
| @code{FUNCTION_TYPE} that describes the data type of the function. |
| From this it is possible to obtain the data types of the value and |
| arguments (if known). |
| |
| When a call to a library function is being considered, @var{fundecl} |
| will contain an identifier node for the library function. Thus, if |
| you need to distinguish among various library functions, you can do so |
| by their names. Note that ``library function'' in this context means |
| a function used to perform arithmetic, whose name is known specially |
| in the compiler and was not mentioned in the C code being compiled. |
| |
| @var{stack-size} is the number of bytes of arguments passed on the |
| stack. If a variable number of bytes is passed, it is zero, and |
| argument popping will always be the responsibility of the calling function. |
| |
| On the VAX, all functions always pop their arguments, so the definition |
| of this macro is @var{stack-size}. On the 68000, using the standard |
| calling convention, no functions pop their arguments, so the value of |
| the macro is always 0 in this case. But an alternative calling |
| convention is available in which functions that take a fixed number of |
| arguments pop them but other functions (such as @code{printf}) pop |
| nothing (the caller pops all). When this convention is in use, |
| @var{funtype} is examined to determine whether a function takes a fixed |
| number of arguments. |
| @end defmac |
| |
| @defmac CALL_POPS_ARGS (@var{cum}) |
| A C expression that should indicate the number of bytes a call sequence |
| pops off the stack. It is added to the value of @code{RETURN_POPS_ARGS} |
| when compiling a function call. |
| |
| @var{cum} is the variable in which all arguments to the called function |
| have been accumulated. |
| |
| On certain architectures, such as the SH5, a call trampoline is used |
| that pops certain registers off the stack, depending on the arguments |
| that have been passed to the function. Since this is a property of the |
| call site, not of the called function, @code{RETURN_POPS_ARGS} is not |
| appropriate. |
| @end defmac |
| |
| @node Register Arguments |
| @subsection Passing Arguments in Registers |
| @cindex arguments in registers |
| @cindex registers arguments |
| |
| This section describes the macros which let you control how various |
| types of arguments are passed in registers or how they are arranged in |
| the stack. |
| |
| @defmac FUNCTION_ARG (@var{cum}, @var{mode}, @var{type}, @var{named}) |
| A C expression that controls whether a function argument is passed |
| in a register, and which register. |
| |
| The arguments are @var{cum}, which summarizes all the previous |
| arguments; @var{mode}, the machine mode of the argument; @var{type}, |
| the data type of the argument as a tree node or 0 if that is not known |
| (which happens for C support library functions); and @var{named}, |
| which is 1 for an ordinary argument and 0 for nameless arguments that |
| correspond to @samp{@dots{}} in the called function's prototype. |
| @var{type} can be an incomplete type if a syntax error has previously |
| occurred. |
| |
| The value of the expression is usually either a @code{reg} RTX for the |
| hard register in which to pass the argument, or zero to pass the |
| argument on the stack. |
| |
| For machines like the VAX and 68000, where normally all arguments are |
| pushed, zero suffices as a definition. |
| |
| The value of the expression can also be a @code{parallel} RTX@. This is |
| used when an argument is passed in multiple locations. The mode of the |
| @code{parallel} should be the mode of the entire argument. The |
| @code{parallel} holds any number of @code{expr_list} pairs; each one |
| describes where part of the argument is passed. In each |
| @code{expr_list} the first operand must be a @code{reg} RTX for the hard |
| register in which to pass this part of the argument, and the mode of the |
| register RTX indicates how large this part of the argument is. The |
| second operand of the @code{expr_list} is a @code{const_int} which gives |
| the offset in bytes into the entire argument of where this part starts. |
| As a special exception the first @code{expr_list} in the @code{parallel} |
| RTX may have a first operand of zero. This indicates that the entire |
| argument is also stored on the stack. |
| |
| The last time this macro is called, it is called with @code{MODE == |
| VOIDmode}, and its result is passed to the @code{call} or @code{call_value} |
| pattern as operands 2 and 3 respectively. |
| |
| @cindex @file{stdarg.h} and register arguments |
| The usual way to make the ISO library @file{stdarg.h} work on a machine |
| where some arguments are usually passed in registers, is to cause |
| nameless arguments to be passed on the stack instead. This is done |
| by making @code{FUNCTION_ARG} return 0 whenever @var{named} is 0. |
| |
| @cindex @code{MUST_PASS_IN_STACK}, and @code{FUNCTION_ARG} |
| @cindex @code{REG_PARM_STACK_SPACE}, and @code{FUNCTION_ARG} |
| You may use the macro @code{MUST_PASS_IN_STACK (@var{mode}, @var{type})} |
| in the definition of this macro to determine if this argument is of a |
| type that must be passed in the stack. If @code{REG_PARM_STACK_SPACE} |
| is not defined and @code{FUNCTION_ARG} returns nonzero for such an |
| argument, the compiler will abort. If @code{REG_PARM_STACK_SPACE} is |
| defined, the argument will be computed in the stack and then loaded into |
| a register. |
| @end defmac |
| |
| @defmac MUST_PASS_IN_STACK (@var{mode}, @var{type}) |
| Define as a C expression that evaluates to nonzero if we do not know how |
| to pass TYPE solely in registers. The file @file{expr.h} defines a |
| definition that is usually appropriate, refer to @file{expr.h} for additional |
| documentation. |
| @end defmac |
| |
| @defmac FUNCTION_INCOMING_ARG (@var{cum}, @var{mode}, @var{type}, @var{named}) |
| Define this macro if the target machine has ``register windows'', so |
| that the register in which a function sees an arguments is not |
| necessarily the same as the one in which the caller passed the |
| argument. |
| |
| For such machines, @code{FUNCTION_ARG} computes the register in which |
| the caller passes the value, and @code{FUNCTION_INCOMING_ARG} should |
| be defined in a similar fashion to tell the function being called |
| where the arguments will arrive. |
| |
| If @code{FUNCTION_INCOMING_ARG} is not defined, @code{FUNCTION_ARG} |
| serves both purposes. |
| @end defmac |
| |
| @defmac FUNCTION_ARG_PARTIAL_NREGS (@var{cum}, @var{mode}, @var{type}, @var{named}) |
| A C expression for the number of words, at the beginning of an |
| argument, that must be put in registers. The value must be zero for |
| arguments that are passed entirely in registers or that are entirely |
| pushed on the stack. |
| |
| On some machines, certain arguments must be passed partially in |
| registers and partially in memory. On these machines, typically the |
| first @var{n} words of arguments are passed in registers, and the rest |
| on the stack. If a multi-word argument (a @code{double} or a |
| structure) crosses that boundary, its first few words must be passed |
| in registers and the rest must be pushed. This macro tells the |
| compiler when this occurs, and how many of the words should go in |
| registers. |
| |
| @code{FUNCTION_ARG} for these arguments should return the first |
| register to be used by the caller for this argument; likewise |
| @code{FUNCTION_INCOMING_ARG}, for the called function. |
| @end defmac |
| |
| @defmac FUNCTION_ARG_PASS_BY_REFERENCE (@var{cum}, @var{mode}, @var{type}, @var{named}) |
| A C expression that indicates when an argument must be passed by reference. |
| If nonzero for an argument, a copy of that argument is made in memory and a |
| pointer to the argument is passed instead of the argument itself. |
| The pointer is passed in whatever way is appropriate for passing a pointer |
| to that type. |
| |
| On machines where @code{REG_PARM_STACK_SPACE} is not defined, a suitable |
| definition of this macro might be |
| @smallexample |
| #define FUNCTION_ARG_PASS_BY_REFERENCE\ |
| (CUM, MODE, TYPE, NAMED) \ |
| MUST_PASS_IN_STACK (MODE, TYPE) |
| @end smallexample |
| @c this is *still* too long. --mew 5feb93 |
| @end defmac |
| |
| @defmac FUNCTION_ARG_CALLEE_COPIES (@var{cum}, @var{mode}, @var{type}, @var{named}) |
| If defined, a C expression that indicates when it is the called function's |
| responsibility to make a copy of arguments passed by invisible reference. |
| Normally, the caller makes a copy and passes the address of the copy to the |
| routine being called. When @code{FUNCTION_ARG_CALLEE_COPIES} is defined and is |
| nonzero, the caller does not make a copy. Instead, it passes a pointer to the |
| ``live'' value. The called function must not modify this value. If it can be |
| determined that the value won't be modified, it need not make a copy; |
| otherwise a copy must be made. |
| @end defmac |
| |
| @defmac CUMULATIVE_ARGS |
| A C type for declaring a variable that is used as the first argument of |
| @code{FUNCTION_ARG} and other related values. For some target machines, |
| the type @code{int} suffices and can hold the number of bytes of |
| argument so far. |
| |
| There is no need to record in @code{CUMULATIVE_ARGS} anything about the |
| arguments that have been passed on the stack. The compiler has other |
| variables to keep track of that. For target machines on which all |
| arguments are passed on the stack, there is no need to store anything in |
| @code{CUMULATIVE_ARGS}; however, the data structure must exist and |
| should not be empty, so use @code{int}. |
| @end defmac |
| |
| @defmac INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype}, @var{libname}, @var{fndecl}, @var{n_named_args}) |
| A C statement (sans semicolon) for initializing the variable |
| @var{cum} for the state at the beginning of the argument list. The |
| variable has type @code{CUMULATIVE_ARGS}. The value of @var{fntype} |
| is the tree node for the data type of the function which will receive |
| the args, or 0 if the args are to a compiler support library function. |
| For direct calls that are not libcalls, @var{fndecl} contain the |
| declaration node of the function. @var{fndecl} is also set when |
| @code{INIT_CUMULATIVE_ARGS} is used to find arguments for the function |
| being compiled. @var{n_named_args} is set to the number of named |
| arguments, including a structure return address if it is passed as a |
| parameter, when making a call. When processing incoming arguments, |
| @var{n_named_args} is set to -1. |
| |
| When processing a call to a compiler support library function, |
| @var{libname} identifies which one. It is a @code{symbol_ref} rtx which |
| contains the name of the function, as a string. @var{libname} is 0 when |
| an ordinary C function call is being processed. Thus, each time this |
| macro is called, either @var{libname} or @var{fntype} is nonzero, but |
| never both of them at once. |
| @end defmac |
| |
| @defmac INIT_CUMULATIVE_LIBCALL_ARGS (@var{cum}, @var{mode}, @var{libname}) |
| Like @code{INIT_CUMULATIVE_ARGS} but only used for outgoing libcalls, |
| it gets a @code{MODE} argument instead of @var{fntype}, that would be |
| @code{NULL}. @var{indirect} would always be zero, too. If this macro |
| is not defined, @code{INIT_CUMULATIVE_ARGS (cum, NULL_RTX, libname, |
| 0)} is used instead. |
| @end defmac |
| |
| @defmac INIT_CUMULATIVE_INCOMING_ARGS (@var{cum}, @var{fntype}, @var{libname}) |
| Like @code{INIT_CUMULATIVE_ARGS} but overrides it for the purposes of |
| finding the arguments for the function being compiled. If this macro is |
| undefined, @code{INIT_CUMULATIVE_ARGS} is used instead. |
| |
| The value passed for @var{libname} is always 0, since library routines |
| with special calling conventions are never compiled with GCC@. The |
| argument @var{libname} exists for symmetry with |
| @code{INIT_CUMULATIVE_ARGS}. |
| @c could use "this macro" in place of @code{INIT_CUMULATIVE_ARGS}, maybe. |
| @c --mew 5feb93 i switched the order of the sentences. --mew 10feb93 |
| @end defmac |
| |
| @defmac FUNCTION_ARG_ADVANCE (@var{cum}, @var{mode}, @var{type}, @var{named}) |
| A C statement (sans semicolon) to update the summarizer variable |
| @var{cum} to advance past an argument in the argument list. The |
| values @var{mode}, @var{type} and @var{named} describe that argument. |
| Once this is done, the variable @var{cum} is suitable for analyzing |
| the @emph{following} argument with @code{FUNCTION_ARG}, etc. |
| |
| This macro need not do anything if the argument in question was passed |
| on the stack. The compiler knows how to track the amount of stack space |
| used for arguments without any special help. |
| @end defmac |
| |
| @defmac FUNCTION_ARG_PADDING (@var{mode}, @var{type}) |
| If defined, a C expression which determines whether, and in which direction, |
| to pad out an argument with extra space. The value should be of type |
| @code{enum direction}: either @code{upward} to pad above the argument, |
| @code{downward} to pad below, or @code{none} to inhibit padding. |
| |
| The @emph{amount} of padding is always just enough to reach the next |
| multiple of @code{FUNCTION_ARG_BOUNDARY}; this macro does not control |
| it. |
| |
| This macro has a default definition which is right for most systems. |
| For little-endian machines, the default is to pad upward. For |
| big-endian machines, the default is to pad downward for an argument of |
| constant size shorter than an @code{int}, and upward otherwise. |
| @end defmac |
| |
| @defmac PAD_VARARGS_DOWN |
| If defined, a C expression which determines whether the default |
| implementation of va_arg will attempt to pad down before reading the |
| next argument, if that argument is smaller than its aligned space as |
| controlled by @code{PARM_BOUNDARY}. If this macro is not defined, all such |
| arguments are padded down if @code{BYTES_BIG_ENDIAN} is true. |
| @end defmac |
| |
| @defmac BLOCK_REG_PADDING (@var{mode}, @var{type}, @var{first}) |
| Specify padding for the last element of a block move between registers and |
| memory. @var{first} is nonzero if this is the only element. Defining this |
| macro allows better control of register function parameters on big-endian |
| machines, without using @code{PARALLEL} rtl. In particular, |
| @code{MUST_PASS_IN_STACK} need not test padding and mode of types in |
| registers, as there is no longer a "wrong" part of a register; For example, |
| a three byte aggregate may be passed in the high part of a register if so |
| required. |
| @end defmac |
| |
| @defmac FUNCTION_ARG_BOUNDARY (@var{mode}, @var{type}) |
| If defined, a C expression that gives the alignment boundary, in bits, |
| of an argument with the specified mode and type. If it is not defined, |
| @code{PARM_BOUNDARY} is used for all arguments. |
| @end defmac |
| |
| @defmac FUNCTION_ARG_REGNO_P (@var{regno}) |
| A C expression that is nonzero if @var{regno} is the number of a hard |
| register in which function arguments are sometimes passed. This does |
| @emph{not} include implicit arguments such as the static chain and |
| the structure-value address. On many machines, no registers can be |
| used for this purpose since all function arguments are pushed on the |
| stack. |
| @end defmac |
| |
| @deftypefn {Target Hook} bool TARGET_SPLIT_COMPLEX_ARG (tree @var{type}) |
| This hook should return true if parameter of type @var{type} are passed |
| as two scalar parameters. By default, GCC will attempt to pack complex |
| arguments into the target's word size. Some ABIs require complex arguments |
| to be split and treated as their individual components. For example, on |
| AIX64, complex floats should be passed in a pair of floating point |
| registers, even though a complex float would fit in one 64-bit floating |
| point register. |
| |
| The default value of this hook is @code{NULL}, which is treated as always |
| false. |
| @end deftypefn |
| |
| @node Scalar Return |
| @subsection How Scalar Function Values Are Returned |
| @cindex return values in registers |
| @cindex values, returned by functions |
| @cindex scalars, returned as values |
| |
| This section discusses the macros that control returning scalars as |
| values---values that can fit in registers. |
| |
| @defmac FUNCTION_VALUE (@var{valtype}, @var{func}) |
| A C expression to create an RTX representing the place where a |
| function returns a value of data type @var{valtype}. @var{valtype} is |
| a tree node representing a data type. Write @code{TYPE_MODE |
| (@var{valtype})} to get the machine mode used to represent that type. |
| On many machines, only the mode is relevant. (Actually, on most |
| machines, scalar values are returned in the same place regardless of |
| mode). |
| |
| The value of the expression is usually a @code{reg} RTX for the hard |
| register where the return value is stored. The value can also be a |
| @code{parallel} RTX, if the return value is in multiple places. See |
| @code{FUNCTION_ARG} for an explanation of the @code{parallel} form. |
| |
| If @code{TARGET_PROMOTE_FUNCTION_RETURN} returns true, you must apply the same |
| promotion rules specified in @code{PROMOTE_MODE} if @var{valtype} is a |
| scalar type. |
| |
| If the precise function being called is known, @var{func} is a tree |
| node (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null |
| pointer. This makes it possible to use a different value-returning |
| convention for specific functions when all their calls are |
| known. |
| |
| @code{FUNCTION_VALUE} is not used for return vales with aggregate data |
| types, because these are returned in another way. See |
| @code{TARGET_STRUCT_VALUE_RTX} and related macros, below. |
| @end defmac |
| |
| @defmac FUNCTION_OUTGOING_VALUE (@var{valtype}, @var{func}) |
| Define this macro if the target machine has ``register windows'' |
| so that the register in which a function returns its value is not |
| the same as the one in which the caller sees the value. |
| |
| For such machines, @code{FUNCTION_VALUE} computes the register in which |
| the caller will see the value. @code{FUNCTION_OUTGOING_VALUE} should be |
| defined in a similar fashion to tell the function where to put the |
| value. |
| |
| If @code{FUNCTION_OUTGOING_VALUE} is not defined, |
| @code{FUNCTION_VALUE} serves both purposes. |
| |
| @code{FUNCTION_OUTGOING_VALUE} is not used for return vales with |
| aggregate data types, because these are returned in another way. See |
| @code{TARGET_STRUCT_VALUE_RTX} and related macros, below. |
| @end defmac |
| |
| @defmac LIBCALL_VALUE (@var{mode}) |
| A C expression to create an RTX representing the place where a library |
| function returns a value of mode @var{mode}. If the precise function |
| being called is known, @var{func} is a tree node |
| (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null |
| pointer. This makes it possible to use a different value-returning |
| convention for specific functions when all their calls are |
| known. |
| |
| Note that ``library function'' in this context means a compiler |
| support routine, used to perform arithmetic, whose name is known |
| specially by the compiler and was not mentioned in the C code being |
| compiled. |
| |
| The definition of @code{LIBRARY_VALUE} need not be concerned aggregate |
| data types, because none of the library functions returns such types. |
| @end defmac |
| |
| @defmac FUNCTION_VALUE_REGNO_P (@var{regno}) |
| A C expression that is nonzero if @var{regno} is the number of a hard |
| register in which the values of called function may come back. |
| |
| A register whose use for returning values is limited to serving as the |
| second of a pair (for a value of type @code{double}, say) need not be |
| recognized by this macro. So for most machines, this definition |
| suffices: |
| |
| @smallexample |
| #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0) |
| @end smallexample |
| |
| If the machine has register windows, so that the caller and the called |
| function use different registers for the return value, this macro |
| should recognize only the caller's register numbers. |
| @end defmac |
| |
| @defmac APPLY_RESULT_SIZE |
| Define this macro if @samp{untyped_call} and @samp{untyped_return} |
| need more space than is implied by @code{FUNCTION_VALUE_REGNO_P} for |
| saving and restoring an arbitrary return value. |
| @end defmac |
| |
| @deftypefn {Target Hook} bool TARGET_RETURN_IN_MSB (tree @var{type}) |
| This hook should return true if values of type @var{type} are returned |
| at the most significant end of a register (in other words, if they are |
| padded at the least significant end). You can assume that @var{type} |
| is returned in a register; the caller is required to check this. |
| |
| Note that the register provided by @code{FUNCTION_VALUE} must be able |
| to hold the complete return value. For example, if a 1-, 2- or 3-byte |
| structure is returned at the most significant end of a 4-byte register, |
| @code{FUNCTION_VALUE} should provide an @code{SImode} rtx. |
| @end deftypefn |
| |
| @node Aggregate Return |
| @subsection How Large Values Are Returned |
| @cindex aggregates as return values |
| @cindex large return values |
| @cindex returning aggregate values |
| @cindex structure value address |
| |
| When a function value's mode is @code{BLKmode} (and in some other |
| cases), the value is not returned according to @code{FUNCTION_VALUE} |
| (@pxref{Scalar Return}). Instead, the caller passes the address of a |
| block of memory in which the value should be stored. This address |
| is called the @dfn{structure value address}. |
| |
| This section describes how to control returning structure values in |
| memory. |
| |
| @deftypefn {Target Hook} bool TARGET_RETURN_IN_MEMORY (tree @var{type}, tree @var{fntype}) |
| This target hook should return a nonzero value to say to return the |
| function value in memory, just as large structures are always returned. |
| Here @var{type} will be the data type of the value, and @var{fntype} |
| will be the type of the function doing the returning, or @code{NULL} for |
| libcalls. |
| |
| Note that values of mode @code{BLKmode} must be explicitly handled |
| by this function. Also, the option @option{-fpcc-struct-return} |
| takes effect regardless of this macro. On most systems, it is |
| possible to leave the hook undefined; this causes a default |
| definition to be used, whose value is the constant 1 for @code{BLKmode} |
| values, and 0 otherwise. |
| |
| Do not use this hook to indicate that structures and unions should always |
| be returned in memory. You should instead use @code{DEFAULT_PCC_STRUCT_RETURN} |
| to indicate this. |
| @end deftypefn |
| |
| @defmac DEFAULT_PCC_STRUCT_RETURN |
| Define this macro to be 1 if all structure and union return values must be |
| in memory. Since this results in slower code, this should be defined |
| only if needed for compatibility with other compilers or with an ABI@. |
| If you define this macro to be 0, then the conventions used for structure |
| and union return values are decided by the @code{TARGET_RETURN_IN_MEMORY} |
| target hook. |
| |
| If not defined, this defaults to the value 1. |
| @end defmac |
| |
| @deftypefn {Target Hook} rtx TARGET_STRUCT_VALUE_RTX (tree @var{fndecl}, int @var{incoming}) |
| This target hook should return the location of the structure value |
| address (normally a @code{mem} or @code{reg}), or 0 if the address is |
| passed as an ``invisible'' first argument. Note that @var{fndecl} may |
| be @code{NULL}, for libcalls. |
| |
| On some architectures the place where the structure value address |
| is found by the called function is not the same place that the |
| caller put it. This can be due to register windows, or it could |
| be because the function prologue moves it to a different place. |
| @var{incoming} is @code{true} when the location is needed in |
| the context of the called function, and @code{false} in the context of |
| the caller. |
| |
| If @var{incoming} is @code{true} and the address is to be found on the |
| stack, return a @code{mem} which refers to the frame pointer. |
| @end deftypefn |
| |
| @defmac PCC_STATIC_STRUCT_RETURN |
| Define this macro if the usual system convention on the target machine |
| for returning structures and unions is for the called function to return |
| the address of a static variable containing the value. |
| |
| Do not define this if the usual system convention is for the caller to |
| pass an address to the subroutine. |
| |
| This macro has effect in @option{-fpcc-struct-return} mode, but it does |
| nothing when you use @option{-freg-struct-return} mode. |
| @end defmac |
| |
| @node Caller Saves |
| @subsection Caller-Saves Register Allocation |
| |
| If you enable it, GCC can save registers around function calls. This |
| makes it possible to use call-clobbered registers to hold variables that |
| must live across calls. |
| |
| @defmac CALLER_SAVE_PROFITABLE (@var{refs}, @var{calls}) |
| A C expression to determine whether it is worthwhile to consider placing |
| a pseudo-register in a call-clobbered hard register and saving and |
| restoring it around each function call. The expression should be 1 when |
| this is worth doing, and 0 otherwise. |
| |
| If you don't define this macro, a default is used which is good on most |
| machines: @code{4 * @var{calls} < @var{refs}}. |
| @end defmac |
| |
| @defmac HARD_REGNO_CALLER_SAVE_MODE (@var{regno}, @var{nregs}) |
| A C expression specifying which mode is required for saving @var{nregs} |
| of a pseudo-register in call-clobbered hard register @var{regno}. If |
| @var{regno} is unsuitable for caller save, @code{VOIDmode} should be |
| returned. For most machines this macro need not be defined since GCC |
| will select the smallest suitable mode. |
| @end defmac |
| |
| @node Function Entry |
| @subsection Function Entry and Exit |
| @cindex function entry and exit |
| @cindex prologue |
| @cindex epilogue |
| |
| This section describes the macros that output function entry |
| (@dfn{prologue}) and exit (@dfn{epilogue}) code. |
| |
| @deftypefn {Target Hook} void TARGET_ASM_FUNCTION_PROLOGUE (FILE *@var{file}, HOST_WIDE_INT @var{size}) |
| If defined, a function that outputs the assembler code for entry to a |
| function. The prologue is responsible for setting up the stack frame, |
| initializing the frame pointer register, saving registers that must be |
| saved, and allocating @var{size} additional bytes of storage for the |
| local variables. @var{size} is an integer. @var{file} is a stdio |
| stream to which the assembler code should be output. |
| |
| The label for the beginning of the function need not be output by this |
| macro. That has already been done when the macro is run. |
| |
| @findex regs_ever_live |
| To determine which registers to save, the macro can refer to the array |
| @code{regs_ever_live}: element @var{r} is nonzero if hard register |
| @var{r} is used anywhere within the function. This implies the function |
| prologue should save register @var{r}, provided it is not one of the |
| call-used registers. (@code{TARGET_ASM_FUNCTION_EPILOGUE} must likewise use |
| @code{regs_ever_live}.) |
| |
| On machines that have ``register windows'', the function entry code does |
| not save on the stack the registers that are in the windows, even if |
| they are supposed to be preserved by function calls; instead it takes |
| appropriate steps to ``push'' the register stack, if any non-call-used |
| registers are used in the function. |
| |
| @findex frame_pointer_needed |
| On machines where functions may or may not have frame-pointers, the |
| function entry code must vary accordingly; it must set up the frame |
| pointer if one is wanted, and not otherwise. To determine whether a |
| frame pointer is in wanted, the macro can refer to the variable |
| @code{frame_pointer_needed}. The variable's value will be 1 at run |
| time in a function that needs a frame pointer. @xref{Elimination}. |
| |
| The function entry code is responsible f
|