1 @c Copyright (C) 1988,1989,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,
2 @c 2002, 2003 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
7 @chapter Target Description Macros and Functions
8 @cindex machine description macros
9 @cindex target description macros
10 @cindex macros, target description
11 @cindex @file{tm.h} macros
13 In addition to the file @file{@var{machine}.md}, a machine description
14 includes a C header file conventionally given the name
15 @file{@var{machine}.h} and a C source file named @file{@var{machine}.c}.
16 The header file defines numerous macros that convey the information
17 about the target machine that does not fit into the scheme of the
18 @file{.md} file. The file @file{tm.h} should be a link to
19 @file{@var{machine}.h}. The header file @file{config.h} includes
20 @file{tm.h} and most compiler source files include @file{config.h}. The
21 source file defines a variable @code{targetm}, which is a structure
22 containing pointers to functions and data relating to the target
23 machine. @file{@var{machine}.c} should also contain their definitions,
24 if they are not defined elsewhere in GCC, and other functions called
25 through the macros defined in the @file{.h} file.
28 * Target Structure:: The @code{targetm} variable.
29 * Driver:: Controlling how the driver runs the compilation passes.
30 * Run-time Target:: Defining @samp{-m} options like @option{-m68000} and @option{-m68020}.
31 * Per-Function Data:: Defining data structures for per-function information.
32 * Storage Layout:: Defining sizes and alignments of data.
33 * Type Layout:: Defining sizes and properties of basic user data types.
34 * Escape Sequences:: Defining the value of target character escape sequences
35 * Registers:: Naming and describing the hardware registers.
36 * Register Classes:: Defining the classes of hardware registers.
37 * Stack and Calling:: Defining which way the stack grows and by how much.
38 * Varargs:: Defining the varargs macros.
39 * Trampolines:: Code set up at run time to enter a nested function.
40 * Library Calls:: Controlling how library routines are implicitly called.
41 * Addressing Modes:: Defining addressing modes valid for memory operands.
42 * Condition Code:: Defining how insns update the condition code.
43 * Costs:: Defining relative costs of different operations.
44 * Scheduling:: Adjusting the behavior of the instruction scheduler.
45 * Sections:: Dividing storage into text, data, and other sections.
46 * PIC:: Macros for position independent code.
47 * Assembler Format:: Defining how to write insns and pseudo-ops to output.
48 * Debugging Info:: Defining the format of debugging output.
49 * Floating Point:: Handling floating point for cross-compilers.
50 * Mode Switching:: Insertion of mode-switching instructions.
51 * Target Attributes:: Defining target-specific uses of @code{__attribute__}.
52 * MIPS Coprocessors:: MIPS coprocessor support and how to customize it.
53 * Misc:: Everything else.
56 @node Target Structure
57 @section The Global @code{targetm} Variable
59 @cindex target functions
61 @deftypevar {struct gcc_target} targetm
62 The target @file{.c} file must define the global @code{targetm} variable
63 which contains pointers to functions and data relating to the target
64 machine. The variable is declared in @file{target.h};
65 @file{target-def.h} defines the macro @code{TARGET_INITIALIZER} which is
66 used to initialize the variable, and macros for the default initializers
67 for elements of the structure. The @file{.c} file should override those
68 macros for which the default definition is inappropriate. For example:
71 #include "target-def.h"
73 /* @r{Initialize the GCC target structure.} */
75 #undef TARGET_COMP_TYPE_ATTRIBUTES
76 #define TARGET_COMP_TYPE_ATTRIBUTES @var{machine}_comp_type_attributes
78 struct gcc_target targetm = TARGET_INITIALIZER;
82 Where a macro should be defined in the @file{.c} file in this manner to
83 form part of the @code{targetm} structure, it is documented below as a
84 ``Target Hook'' with a prototype. Many macros will change in future
85 from being defined in the @file{.h} file to being part of the
86 @code{targetm} structure.
89 @section Controlling the Compilation Driver, @file{gcc}
91 @cindex controlling the compilation driver
93 @c prevent bad page break with this line
94 You can control the compilation driver.
96 @defmac SWITCH_TAKES_ARG (@var{char})
97 A C expression which determines whether the option @option{-@var{char}}
98 takes arguments. The value should be the number of arguments that
99 option takes--zero, for many options.
101 By default, this macro is defined as
102 @code{DEFAULT_SWITCH_TAKES_ARG}, which handles the standard options
103 properly. You need not define @code{SWITCH_TAKES_ARG} unless you
104 wish to add additional options which take arguments. Any redefinition
105 should call @code{DEFAULT_SWITCH_TAKES_ARG} and then check for
109 @defmac WORD_SWITCH_TAKES_ARG (@var{name})
110 A C expression which determines whether the option @option{-@var{name}}
111 takes arguments. The value should be the number of arguments that
112 option takes--zero, for many options. This macro rather than
113 @code{SWITCH_TAKES_ARG} is used for multi-character option names.
115 By default, this macro is defined as
116 @code{DEFAULT_WORD_SWITCH_TAKES_ARG}, which handles the standard options
117 properly. You need not define @code{WORD_SWITCH_TAKES_ARG} unless you
118 wish to add additional options which take arguments. Any redefinition
119 should call @code{DEFAULT_WORD_SWITCH_TAKES_ARG} and then check for
123 @defmac SWITCH_CURTAILS_COMPILATION (@var{char})
124 A C expression which determines whether the option @option{-@var{char}}
125 stops compilation before the generation of an executable. The value is
126 boolean, nonzero if the option does stop an executable from being
127 generated, zero otherwise.
129 By default, this macro is defined as
130 @code{DEFAULT_SWITCH_CURTAILS_COMPILATION}, which handles the standard
131 options properly. You need not define
132 @code{SWITCH_CURTAILS_COMPILATION} unless you wish to add additional
133 options which affect the generation of an executable. Any redefinition
134 should call @code{DEFAULT_SWITCH_CURTAILS_COMPILATION} and then check
135 for additional options.
138 @defmac SWITCHES_NEED_SPACES
139 A string-valued C expression which enumerates the options for which
140 the linker needs a space between the option and its argument.
142 If this macro is not defined, the default value is @code{""}.
145 @defmac TARGET_OPTION_TRANSLATE_TABLE
146 If defined, a list of pairs of strings, the first of which is a
147 potential command line target to the @file{gcc} driver program, and the
148 second of which is a space-separated (tabs and other whitespace are not
149 supported) list of options with which to replace the first option. The
150 target defining this list is responsible for assuring that the results
151 are valid. Replacement options may not be the @code{--opt} style, they
152 must be the @code{-opt} style. It is the intention of this macro to
153 provide a mechanism for substitution that affects the multilibs chosen,
154 such as one option that enables many options, some of which select
155 multilibs. Example nonsensical definition, where @code{-malt-abi},
156 @code{-EB}, and @code{-mspoo} cause different multilibs to be chosen:
159 #define TARGET_OPTION_TRANSLATE_TABLE \
160 @{ "-fast", "-march=fast-foo -malt-abi -I/usr/fast-foo" @}, \
161 @{ "-compat", "-EB -malign=4 -mspoo" @}
165 @defmac DRIVER_SELF_SPECS
166 A list of specs for the driver itself. It should be a suitable
167 initializer for an array of strings, with no surrounding braces.
169 The driver applies these specs to its own command line between loading
170 default @file{specs} files (but not command-line specified ones) and
171 choosing the multilib directory or running any subcommands. It
172 applies them in the order given, so each spec can depend on the
173 options added by earlier ones. It is also possible to remove options
174 using @samp{%<@var{option}} in the usual way.
176 This macro can be useful when a port has several interdependent target
177 options. It provides a way of standardizing the command line so
178 that the other specs are easier to write.
180 Do not define this macro if it does not need to do anything.
183 @defmac OPTION_DEFAULT_SPECS
184 A list of specs used to support configure-time default options (i.e.@:
185 @option{--with} options) in the driver. It should be a suitable initializer
186 for an array of structures, each containing two strings, without the
187 outermost pair of surrounding braces.
189 The first item in the pair is the name of the default. This must match
190 the code in @file{config.gcc} for the target. The second item is a spec
191 to apply if a default with this name was specified. The string
192 @samp{%(VALUE)} in the spec will be replaced by the value of the default
193 everywhere it occurs.
195 The driver will apply these specs to its own command line between loading
196 default @file{specs} files and processing @code{DRIVER_SELF_SPECS}, using
197 the same mechanism as @code{DRIVER_SELF_SPECS}.
199 Do not define this macro if it does not need to do anything.
203 A C string constant that tells the GCC driver program options to
204 pass to CPP@. It can also specify how to translate options you
205 give to GCC into options for GCC to pass to the CPP@.
207 Do not define this macro if it does not need to do anything.
210 @defmac CPLUSPLUS_CPP_SPEC
211 This macro is just like @code{CPP_SPEC}, but is used for C++, rather
212 than C@. If you do not define this macro, then the value of
213 @code{CPP_SPEC} (if any) will be used instead.
217 A C string constant that tells the GCC driver program options to
218 pass to @code{cc1}, @code{cc1plus}, @code{f771}, and the other language
220 It can also specify how to translate options you give to GCC into options
221 for GCC to pass to front ends.
223 Do not define this macro if it does not need to do anything.
227 A C string constant that tells the GCC driver program options to
228 pass to @code{cc1plus}. It can also specify how to translate options you
229 give to GCC into options for GCC to pass to the @code{cc1plus}.
231 Do not define this macro if it does not need to do anything.
232 Note that everything defined in CC1_SPEC is already passed to
233 @code{cc1plus} so there is no need to duplicate the contents of
234 CC1_SPEC in CC1PLUS_SPEC@.
238 A C string constant that tells the GCC driver program options to
239 pass to the assembler. It can also specify how to translate options
240 you give to GCC into options for GCC to pass to the assembler.
241 See the file @file{sun3.h} for an example of this.
243 Do not define this macro if it does not need to do anything.
246 @defmac ASM_FINAL_SPEC
247 A C string constant that tells the GCC driver program how to
248 run any programs which cleanup after the normal assembler.
249 Normally, this is not needed. See the file @file{mips.h} for
252 Do not define this macro if it does not need to do anything.
255 @defmac AS_NEEDS_DASH_FOR_PIPED_INPUT
256 Define this macro, with no value, if the driver should give the assembler
257 an argument consisting of a single dash, @option{-}, to instruct it to
258 read from its standard input (which will be a pipe connected to the
259 output of the compiler proper). This argument is given after any
260 @option{-o} option specifying the name of the output file.
262 If you do not define this macro, the assembler is assumed to read its
263 standard input if given no non-option arguments. If your assembler
264 cannot read standard input at all, use a @samp{%@{pipe:%e@}} construct;
265 see @file{mips.h} for instance.
269 A C string constant that tells the GCC driver program options to
270 pass to the linker. It can also specify how to translate options you
271 give to GCC into options for GCC to pass to the linker.
273 Do not define this macro if it does not need to do anything.
277 Another C string constant used much like @code{LINK_SPEC}. The difference
278 between the two is that @code{LIB_SPEC} is used at the end of the
279 command given to the linker.
281 If this macro is not defined, a default is provided that
282 loads the standard C library from the usual place. See @file{gcc.c}.
286 Another C string constant that tells the GCC driver program
287 how and when to place a reference to @file{libgcc.a} into the
288 linker command line. This constant is placed both before and after
289 the value of @code{LIB_SPEC}.
291 If this macro is not defined, the GCC driver provides a default that
292 passes the string @option{-lgcc} to the linker.
295 @defmac STARTFILE_SPEC
296 Another C string constant used much like @code{LINK_SPEC}. The
297 difference between the two is that @code{STARTFILE_SPEC} is used at
298 the very beginning of the command given to the linker.
300 If this macro is not defined, a default is provided that loads the
301 standard C startup file from the usual place. See @file{gcc.c}.
305 Another C string constant used much like @code{LINK_SPEC}. The
306 difference between the two is that @code{ENDFILE_SPEC} is used at
307 the very end of the command given to the linker.
309 Do not define this macro if it does not need to do anything.
312 @defmac THREAD_MODEL_SPEC
313 GCC @code{-v} will print the thread model GCC was configured to use.
314 However, this doesn't work on platforms that are multilibbed on thread
315 models, such as AIX 4.3. On such platforms, define
316 @code{THREAD_MODEL_SPEC} such that it evaluates to a string without
317 blanks that names one of the recognized thread models. @code{%*}, the
318 default value of this macro, will expand to the value of
319 @code{thread_file} set in @file{config.gcc}.
322 @defmac SYSROOT_SUFFIX_SPEC
323 Define this macro to add a suffix to the target sysroot when GCC is
324 configured with a sysroot. This will cause GCC to search for usr/lib,
325 et al, within sysroot+suffix.
328 @defmac SYSROOT_HEADERS_SUFFIX_SPEC
329 Define this macro to add a headers_suffix to the target sysroot when
330 GCC is configured with a sysroot. This will cause GCC to pass the
331 updated sysroot+headers_suffix to CPP@, causing it to search for
332 usr/include, et al, within sysroot+headers_suffix.
336 Define this macro to provide additional specifications to put in the
337 @file{specs} file that can be used in various specifications like
340 The definition should be an initializer for an array of structures,
341 containing a string constant, that defines the specification name, and a
342 string constant that provides the specification.
344 Do not define this macro if it does not need to do anything.
346 @code{EXTRA_SPECS} is useful when an architecture contains several
347 related targets, which have various @code{@dots{}_SPECS} which are similar
348 to each other, and the maintainer would like one central place to keep
351 For example, the PowerPC System V.4 targets use @code{EXTRA_SPECS} to
352 define either @code{_CALL_SYSV} when the System V calling sequence is
353 used or @code{_CALL_AIX} when the older AIX-based calling sequence is
356 The @file{config/rs6000/rs6000.h} target file defines:
359 #define EXTRA_SPECS \
360 @{ "cpp_sysv_default", CPP_SYSV_DEFAULT @},
362 #define CPP_SYS_DEFAULT ""
365 The @file{config/rs6000/sysv.h} target file defines:
369 "%@{posix: -D_POSIX_SOURCE @} \
370 %@{mcall-sysv: -D_CALL_SYSV @} \
371 %@{!mcall-sysv: %(cpp_sysv_default) @} \
372 %@{msoft-float: -D_SOFT_FLOAT@} %@{mcpu=403: -D_SOFT_FLOAT@}"
374 #undef CPP_SYSV_DEFAULT
375 #define CPP_SYSV_DEFAULT "-D_CALL_SYSV"
378 while the @file{config/rs6000/eabiaix.h} target file defines
379 @code{CPP_SYSV_DEFAULT} as:
382 #undef CPP_SYSV_DEFAULT
383 #define CPP_SYSV_DEFAULT "-D_CALL_AIX"
387 @defmac LINK_LIBGCC_SPECIAL
388 Define this macro if the driver program should find the library
389 @file{libgcc.a} itself and should not pass @option{-L} options to the
390 linker. If you do not define this macro, the driver program will pass
391 the argument @option{-lgcc} to tell the linker to do the search and will
392 pass @option{-L} options to it.
395 @defmac LINK_LIBGCC_SPECIAL_1
396 Define this macro if the driver program should find the library
397 @file{libgcc.a}. If you do not define this macro, the driver program will pass
398 the argument @option{-lgcc} to tell the linker to do the search.
399 This macro is similar to @code{LINK_LIBGCC_SPECIAL}, except that it does
400 not affect @option{-L} options.
403 @defmac LINK_GCC_C_SEQUENCE_SPEC
404 The sequence in which libgcc and libc are specified to the linker.
405 By default this is @code{%G %L %G}.
408 @defmac LINK_COMMAND_SPEC
409 A C string constant giving the complete command line need to execute the
410 linker. When you do this, you will need to update your port each time a
411 change is made to the link command line within @file{gcc.c}. Therefore,
412 define this macro only if you need to completely redefine the command
413 line for invoking the linker and there is no other way to accomplish
414 the effect you need. Overriding this macro may be avoidable by overriding
415 @code{LINK_GCC_C_SEQUENCE_SPEC} instead.
418 @defmac LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
419 A nonzero value causes @command{collect2} to remove duplicate @option{-L@var{directory}} search
420 directories from linking commands. Do not give it a nonzero value if
421 removing duplicate search directories changes the linker's semantics.
424 @defmac MULTILIB_DEFAULTS
425 Define this macro as a C expression for the initializer of an array of
426 string to tell the driver program which options are defaults for this
427 target and thus do not need to be handled specially when using
428 @code{MULTILIB_OPTIONS}.
430 Do not define this macro if @code{MULTILIB_OPTIONS} is not defined in
431 the target makefile fragment or if none of the options listed in
432 @code{MULTILIB_OPTIONS} are set by default.
433 @xref{Target Fragment}.
436 @defmac RELATIVE_PREFIX_NOT_LINKDIR
437 Define this macro to tell @command{gcc} that it should only translate
438 a @option{-B} prefix into a @option{-L} linker option if the prefix
439 indicates an absolute file name.
442 @defmac STANDARD_EXEC_PREFIX
443 Define this macro as a C string constant if you wish to override the
444 standard choice of @file{/usr/local/lib/gcc-lib/} as the default prefix to
445 try when searching for the executable files of the compiler.
448 @defmac MD_EXEC_PREFIX
449 If defined, this macro is an additional prefix to try after
450 @code{STANDARD_EXEC_PREFIX}. @code{MD_EXEC_PREFIX} is not searched
451 when the @option{-b} option is used, or the compiler is built as a cross
452 compiler. If you define @code{MD_EXEC_PREFIX}, then be sure to add it
453 to the list of directories used to find the assembler in @file{configure.in}.
456 @defmac STANDARD_STARTFILE_PREFIX
457 Define this macro as a C string constant if you wish to override the
458 standard choice of @file{/usr/local/lib/} as the default prefix to
459 try when searching for startup files such as @file{crt0.o}.
462 @defmac MD_STARTFILE_PREFIX
463 If defined, this macro supplies an additional prefix to try after the
464 standard prefixes. @code{MD_EXEC_PREFIX} is not searched when the
465 @option{-b} option is used, or when the compiler is built as a cross
469 @defmac MD_STARTFILE_PREFIX_1
470 If defined, this macro supplies yet another prefix to try after the
471 standard prefixes. It is not searched when the @option{-b} option is
472 used, or when the compiler is built as a cross compiler.
475 @defmac INIT_ENVIRONMENT
476 Define this macro as a C string constant if you wish to set environment
477 variables for programs called by the driver, such as the assembler and
478 loader. The driver passes the value of this macro to @code{putenv} to
479 initialize the necessary environment variables.
482 @defmac LOCAL_INCLUDE_DIR
483 Define this macro as a C string constant if you wish to override the
484 standard choice of @file{/usr/local/include} as the default prefix to
485 try when searching for local header files. @code{LOCAL_INCLUDE_DIR}
486 comes before @code{SYSTEM_INCLUDE_DIR} in the search order.
488 Cross compilers do not search either @file{/usr/local/include} or its
492 @defmac MODIFY_TARGET_NAME
493 Define this macro if you wish to define command-line switches that
494 modify the default target name.
496 For each switch, you can include a string to be appended to the first
497 part of the configuration name or a string to be deleted from the
498 configuration name, if present. The definition should be an initializer
499 for an array of structures. Each array element should have three
500 elements: the switch name (a string constant, including the initial
501 dash), one of the enumeration codes @code{ADD} or @code{DELETE} to
502 indicate whether the string should be inserted or deleted, and the string
503 to be inserted or deleted (a string constant).
505 For example, on a machine where @samp{64} at the end of the
506 configuration name denotes a 64-bit target and you want the @option{-32}
507 and @option{-64} switches to select between 32- and 64-bit targets, you would
511 #define MODIFY_TARGET_NAME \
512 @{ @{ "-32", DELETE, "64"@}, \
513 @{"-64", ADD, "64"@}@}
517 @defmac SYSTEM_INCLUDE_DIR
518 Define this macro as a C string constant if you wish to specify a
519 system-specific directory to search for header files before the standard
520 directory. @code{SYSTEM_INCLUDE_DIR} comes before
521 @code{STANDARD_INCLUDE_DIR} in the search order.
523 Cross compilers do not use this macro and do not search the directory
527 @defmac STANDARD_INCLUDE_DIR
528 Define this macro as a C string constant if you wish to override the
529 standard choice of @file{/usr/include} as the default prefix to
530 try when searching for header files.
532 Cross compilers ignore this macro and do not search either
533 @file{/usr/include} or its replacement.
536 @defmac STANDARD_INCLUDE_COMPONENT
537 The ``component'' corresponding to @code{STANDARD_INCLUDE_DIR}.
538 See @code{INCLUDE_DEFAULTS}, below, for the description of components.
539 If you do not define this macro, no component is used.
542 @defmac INCLUDE_DEFAULTS
543 Define this macro if you wish to override the entire default search path
544 for include files. For a native compiler, the default search path
545 usually consists of @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR},
546 @code{SYSTEM_INCLUDE_DIR}, @code{GPLUSPLUS_INCLUDE_DIR}, and
547 @code{STANDARD_INCLUDE_DIR}. In addition, @code{GPLUSPLUS_INCLUDE_DIR}
548 and @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile},
549 and specify private search areas for GCC@. The directory
550 @code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs.
552 The definition should be an initializer for an array of structures.
553 Each array element should have four elements: the directory name (a
554 string constant), the component name (also a string constant), a flag
555 for C++-only directories,
556 and a flag showing that the includes in the directory don't need to be
557 wrapped in @code{extern @samp{C}} when compiling C++. Mark the end of
558 the array with a null element.
560 The component name denotes what GNU package the include file is part of,
561 if any, in all upper-case letters. For example, it might be @samp{GCC}
562 or @samp{BINUTILS}. If the package is part of a vendor-supplied
563 operating system, code the component name as @samp{0}.
565 For example, here is the definition used for VAX/VMS:
568 #define INCLUDE_DEFAULTS \
570 @{ "GNU_GXX_INCLUDE:", "G++", 1, 1@}, \
571 @{ "GNU_CC_INCLUDE:", "GCC", 0, 0@}, \
572 @{ "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0@}, \
579 Here is the order of prefixes tried for exec files:
583 Any prefixes specified by the user with @option{-B}.
586 The environment variable @code{GCC_EXEC_PREFIX}, if any.
589 The directories specified by the environment variable @code{COMPILER_PATH}.
592 The macro @code{STANDARD_EXEC_PREFIX}.
595 @file{/usr/lib/gcc/}.
598 The macro @code{MD_EXEC_PREFIX}, if any.
601 Here is the order of prefixes tried for startfiles:
605 Any prefixes specified by the user with @option{-B}.
608 The environment variable @code{GCC_EXEC_PREFIX}, if any.
611 The directories specified by the environment variable @code{LIBRARY_PATH}
612 (or port-specific name; native only, cross compilers do not use this).
615 The macro @code{STANDARD_EXEC_PREFIX}.
618 @file{/usr/lib/gcc/}.
621 The macro @code{MD_EXEC_PREFIX}, if any.
624 The macro @code{MD_STARTFILE_PREFIX}, if any.
627 The macro @code{STANDARD_STARTFILE_PREFIX}.
636 @node Run-time Target
637 @section Run-time Target Specification
638 @cindex run-time target specification
639 @cindex predefined macros
640 @cindex target specifications
642 @c prevent bad page break with this line
643 Here are run-time target specifications.
645 @defmac TARGET_CPU_CPP_BUILTINS ()
646 This function-like macro expands to a block of code that defines
647 built-in preprocessor macros and assertions for the target cpu, using
648 the functions @code{builtin_define}, @code{builtin_define_std} and
649 @code{builtin_assert}. When the front end
650 calls this macro it provides a trailing semicolon, and since it has
651 finished command line option processing your code can use those
654 @code{builtin_assert} takes a string in the form you pass to the
655 command-line option @option{-A}, such as @code{cpu=mips}, and creates
656 the assertion. @code{builtin_define} takes a string in the form
657 accepted by option @option{-D} and unconditionally defines the macro.
659 @code{builtin_define_std} takes a string representing the name of an
660 object-like macro. If it doesn't lie in the user's namespace,
661 @code{builtin_define_std} defines it unconditionally. Otherwise, it
662 defines a version with two leading underscores, and another version
663 with two leading and trailing underscores, and defines the original
664 only if an ISO standard was not requested on the command line. For
665 example, passing @code{unix} defines @code{__unix}, @code{__unix__}
666 and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
667 @code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
668 defines only @code{_ABI64}.
670 You can also test for the C dialect being compiled. The variable
671 @code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus}
672 or @code{clk_objective_c}. Note that if we are preprocessing
673 assembler, this variable will be @code{clk_c} but the function-like
674 macro @code{preprocessing_asm_p()} will return true, so you might want
675 to check for that first. If you need to check for strict ANSI, the
676 variable @code{flag_iso} can be used. The function-like macro
677 @code{preprocessing_trad_p()} can be used to check for traditional
681 @defmac TARGET_OS_CPP_BUILTINS ()
682 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
683 and is used for the target operating system instead.
686 @defmac TARGET_OBJFMT_CPP_BUILTINS ()
687 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
688 and is used for the target object format. @file{elfos.h} uses this
689 macro to define @code{__ELF__}, so you probably do not need to define
693 @deftypevar {extern int} target_flags
694 This declaration should be present.
697 @cindex optional hardware or system features
698 @cindex features, optional, in system conventions
700 @defmac TARGET_@var{featurename}
701 This series of macros is to allow compiler command arguments to
702 enable or disable the use of optional features of the target machine.
703 For example, one machine description serves both the 68000 and
704 the 68020; a command argument tells the compiler whether it should
705 use 68020-only instructions or not. This command argument works
706 by means of a macro @code{TARGET_68020} that tests a bit in
709 Define a macro @code{TARGET_@var{featurename}} for each such option.
710 Its definition should test a bit in @code{target_flags}. It is
711 recommended that a helper macro @code{MASK_@var{featurename}}
712 is defined for each bit-value to test, and used in
713 @code{TARGET_@var{featurename}} and @code{TARGET_SWITCHES}. For
717 #define TARGET_MASK_68020 1
718 #define TARGET_68020 (target_flags & MASK_68020)
721 One place where these macros are used is in the condition-expressions
722 of instruction patterns. Note how @code{TARGET_68020} appears
723 frequently in the 68000 machine description file, @file{m68k.md}.
724 Another place they are used is in the definitions of the other
725 macros in the @file{@var{machine}.h} file.
728 @defmac TARGET_SWITCHES
729 This macro defines names of command options to set and clear
730 bits in @code{target_flags}. Its definition is an initializer
731 with a subgrouping for each command option.
733 Each subgrouping contains a string constant, that defines the option
734 name, a number, which contains the bits to set in
735 @code{target_flags}, and a second string which is the description
736 displayed by @option{--help}. If the number is negative then the bits specified
737 by the number are cleared instead of being set. If the description
738 string is present but empty, then no help information will be displayed
739 for that option, but it will not count as an undocumented option. The
740 actual option name is made by appending @samp{-m} to the specified name.
741 Non-empty description strings should be marked with @code{N_(@dots{})} for
742 @command{xgettext}. Please do not mark empty strings because the empty
743 string is reserved by GNU gettext. @code{gettext("")} returns the header entry
744 of the message catalog with meta information, not the empty string.
746 In addition to the description for @option{--help},
747 more detailed documentation for each option should be added to
750 One of the subgroupings should have a null string. The number in
751 this grouping is the default value for @code{target_flags}. Any
752 target options act starting with that value.
754 Here is an example which defines @option{-m68000} and @option{-m68020}
755 with opposite meanings, and picks the latter as the default:
758 #define TARGET_SWITCHES \
759 @{ @{ "68020", MASK_68020, "" @}, \
760 @{ "68000", -MASK_68020, \
761 N_("Compile for the 68000") @}, \
762 @{ "", MASK_68020, "" @}, \
767 @defmac TARGET_OPTIONS
768 This macro is similar to @code{TARGET_SWITCHES} but defines names of command
769 options that have values. Its definition is an initializer with a
770 subgrouping for each command option.
772 Each subgrouping contains a string constant, that defines the option
773 name, the address of a variable, a description string, and a value.
774 Non-empty description strings should be marked with @code{N_(@dots{})}
775 for @command{xgettext}. Please do not mark empty strings because the
776 empty string is reserved by GNU gettext. @code{gettext("")} returns the
777 header entry of the message catalog with meta information, not the empty
780 If the value listed in the table is @code{NULL}, then the variable, type
781 @code{char *}, is set to the variable part of the given option if the
782 fixed part matches. In other words, if the first part of the option
783 matches what's in the table, the variable will be set to point to the
784 rest of the option. This allows the user to specify a value for that
785 option. The actual option name is made by appending @samp{-m} to the
786 specified name. Again, each option should also be documented in
789 If the value listed in the table is non-@code{NULL}, then the option
790 must match the option in the table exactly (with @samp{-m}), and the
791 variable is set to point to the value listed in the table.
793 Here is an example which defines @option{-mshort-data-@var{number}}. If the
794 given option is @option{-mshort-data-512}, the variable @code{m88k_short_data}
795 will be set to the string @code{"512"}.
798 extern char *m88k_short_data;
799 #define TARGET_OPTIONS \
800 @{ @{ "short-data-", &m88k_short_data, \
801 N_("Specify the size of the short data section"), 0 @} @}
804 Here is a variant of the above that allows the user to also specify
805 just @option{-mshort-data} where a default of @code{"64"} is used.
808 extern char *m88k_short_data;
809 #define TARGET_OPTIONS \
810 @{ @{ "short-data-", &m88k_short_data, \
811 N_("Specify the size of the short data section"), 0 @} \
812 @{ "short-data", &m88k_short_data, "", "64" @},
816 Here is an example which defines @option{-mno-alu}, @option{-malu1}, and
817 @option{-malu2} as a three-state switch, along with suitable macros for
818 checking the state of the option (documentation is elided for brevity).
822 char *chip_alu = ""; /* Specify default here. */
825 extern char *chip_alu;
826 #define TARGET_OPTIONS \
827 @{ @{ "no-alu", &chip_alu, "", "" @}, \
828 @{ "alu1", &chip_alu, "", "1" @}, \
829 @{ "alu2", &chip_alu, "", "2" @}, @}
830 #define TARGET_ALU (chip_alu[0] != '\0')
831 #define TARGET_ALU1 (chip_alu[0] == '1')
832 #define TARGET_ALU2 (chip_alu[0] == '2')
836 @defmac TARGET_VERSION
837 This macro is a C statement to print on @code{stderr} a string
838 describing the particular machine description choice. Every machine
839 description should define @code{TARGET_VERSION}. For example:
843 #define TARGET_VERSION \
844 fprintf (stderr, " (68k, Motorola syntax)");
846 #define TARGET_VERSION \
847 fprintf (stderr, " (68k, MIT syntax)");
852 @defmac OVERRIDE_OPTIONS
853 Sometimes certain combinations of command options do not make sense on
854 a particular target machine. You can define a macro
855 @code{OVERRIDE_OPTIONS} to take account of this. This macro, if
856 defined, is executed once just after all the command options have been
859 Don't use this macro to turn on various extra optimizations for
860 @option{-O}. That is what @code{OPTIMIZATION_OPTIONS} is for.
863 @defmac OPTIMIZATION_OPTIONS (@var{level}, @var{size})
864 Some machines may desire to change what optimizations are performed for
865 various optimization levels. This macro, if defined, is executed once
866 just after the optimization level is determined and before the remainder
867 of the command options have been parsed. Values set in this macro are
868 used as the default values for the other command line options.
870 @var{level} is the optimization level specified; 2 if @option{-O2} is
871 specified, 1 if @option{-O} is specified, and 0 if neither is specified.
873 @var{size} is nonzero if @option{-Os} is specified and zero otherwise.
875 You should not use this macro to change options that are not
876 machine-specific. These should uniformly selected by the same
877 optimization level on all supported machines. Use this macro to enable
878 machine-specific optimizations.
880 @strong{Do not examine @code{write_symbols} in
881 this macro!} The debugging options are not supposed to alter the
885 @defmac CAN_DEBUG_WITHOUT_FP
886 Define this macro if debugging can be performed even without a frame
887 pointer. If this macro is defined, GCC will turn on the
888 @option{-fomit-frame-pointer} option whenever @option{-O} is specified.
891 @node Per-Function Data
892 @section Defining data structures for per-function information.
893 @cindex per-function data
894 @cindex data structures
896 If the target needs to store information on a per-function basis, GCC
897 provides a macro and a couple of variables to allow this. Note, just
898 using statics to store the information is a bad idea, since GCC supports
899 nested functions, so you can be halfway through encoding one function
900 when another one comes along.
902 GCC defines a data structure called @code{struct function} which
903 contains all of the data specific to an individual function. This
904 structure contains a field called @code{machine} whose type is
905 @code{struct machine_function *}, which can be used by targets to point
906 to their own specific data.
908 If a target needs per-function specific data it should define the type
909 @code{struct machine_function} and also the macro @code{INIT_EXPANDERS}.
910 This macro should be used to initialize the function pointer
911 @code{init_machine_status}. This pointer is explained below.
913 One typical use of per-function, target specific data is to create an
914 RTX to hold the register containing the function's return address. This
915 RTX can then be used to implement the @code{__builtin_return_address}
916 function, for level 0.
918 Note---earlier implementations of GCC used a single data area to hold
919 all of the per-function information. Thus when processing of a nested
920 function began the old per-function data had to be pushed onto a
921 stack, and when the processing was finished, it had to be popped off the
922 stack. GCC used to provide function pointers called
923 @code{save_machine_status} and @code{restore_machine_status} to handle
924 the saving and restoring of the target specific information. Since the
925 single data area approach is no longer used, these pointers are no
928 @defmac INIT_EXPANDERS
929 Macro called to initialize any target specific information. This macro
930 is called once per function, before generation of any RTL has begun.
931 The intention of this macro is to allow the initialization of the
932 function pointer @code{init_machine_status}.
935 @deftypevar {void (*)(struct function *)} init_machine_status
936 If this function pointer is non-@code{NULL} it will be called once per
937 function, before function compilation starts, in order to allow the
938 target to perform any target specific initialization of the
939 @code{struct function} structure. It is intended that this would be
940 used to initialize the @code{machine} of that structure.
942 @code{struct machine_function} structures are expected to be freed by GC.
943 Generally, any memory that they reference must be allocated by using
944 @code{ggc_alloc}, including the structure itself.
948 @section Storage Layout
949 @cindex storage layout
951 Note that the definitions of the macros in this table which are sizes or
952 alignments measured in bits do not need to be constant. They can be C
953 expressions that refer to static variables, such as the @code{target_flags}.
954 @xref{Run-time Target}.
956 @defmac BITS_BIG_ENDIAN
957 Define this macro to have the value 1 if the most significant bit in a
958 byte has the lowest number; otherwise define it to have the value zero.
959 This means that bit-field instructions count from the most significant
960 bit. If the machine has no bit-field instructions, then this must still
961 be defined, but it doesn't matter which value it is defined to. This
962 macro need not be a constant.
964 This macro does not affect the way structure fields are packed into
965 bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}.
968 @defmac BYTES_BIG_ENDIAN
969 Define this macro to have the value 1 if the most significant byte in a
970 word has the lowest number. This macro need not be a constant.
973 @defmac WORDS_BIG_ENDIAN
974 Define this macro to have the value 1 if, in a multiword object, the
975 most significant word has the lowest number. This applies to both
976 memory locations and registers; GCC fundamentally assumes that the
977 order of words in memory is the same as the order in registers. This
978 macro need not be a constant.
981 @defmac LIBGCC2_WORDS_BIG_ENDIAN
982 Define this macro if @code{WORDS_BIG_ENDIAN} is not constant. This must be a
983 constant value with the same meaning as @code{WORDS_BIG_ENDIAN}, which will be
984 used only when compiling @file{libgcc2.c}. Typically the value will be set
985 based on preprocessor defines.
988 @defmac FLOAT_WORDS_BIG_ENDIAN
989 Define this macro to have the value 1 if @code{DFmode}, @code{XFmode} or
990 @code{TFmode} floating point numbers are stored in memory with the word
991 containing the sign bit at the lowest address; otherwise define it to
992 have the value 0. This macro need not be a constant.
994 You need not define this macro if the ordering is the same as for
998 @defmac BITS_PER_UNIT
999 Define this macro to be the number of bits in an addressable storage
1000 unit (byte). If you do not define this macro the default is 8.
1003 @defmac BITS_PER_WORD
1004 Number of bits in a word. If you do not define this macro, the default
1005 is @code{BITS_PER_UNIT * UNITS_PER_WORD}.
1008 @defmac MAX_BITS_PER_WORD
1009 Maximum number of bits in a word. If this is undefined, the default is
1010 @code{BITS_PER_WORD}. Otherwise, it is the constant value that is the
1011 largest value that @code{BITS_PER_WORD} can have at run-time.
1014 @defmac UNITS_PER_WORD
1015 Number of storage units in a word; normally 4.
1018 @defmac MIN_UNITS_PER_WORD
1019 Minimum number of units in a word. If this is undefined, the default is
1020 @code{UNITS_PER_WORD}. Otherwise, it is the constant value that is the
1021 smallest value that @code{UNITS_PER_WORD} can have at run-time.
1024 @defmac POINTER_SIZE
1025 Width of a pointer, in bits. You must specify a value no wider than the
1026 width of @code{Pmode}. If it is not equal to the width of @code{Pmode},
1027 you must define @code{POINTERS_EXTEND_UNSIGNED}. If you do not specify
1028 a value the default is @code{BITS_PER_WORD}.
1031 @defmac POINTERS_EXTEND_UNSIGNED
1032 A C expression whose value is greater than zero if pointers that need to be
1033 extended from being @code{POINTER_SIZE} bits wide to @code{Pmode} are to
1034 be zero-extended and zero if they are to be sign-extended. If the value
1035 is less then zero then there must be an "ptr_extend" instruction that
1036 extends a pointer from @code{POINTER_SIZE} to @code{Pmode}.
1038 You need not define this macro if the @code{POINTER_SIZE} is equal
1039 to the width of @code{Pmode}.
1042 @defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type})
1043 A macro to update @var{m} and @var{unsignedp} when an object whose type
1044 is @var{type} and which has the specified mode and signedness is to be
1045 stored in a register. This macro is only called when @var{type} is a
1048 On most RISC machines, which only have operations that operate on a full
1049 register, define this macro to set @var{m} to @code{word_mode} if
1050 @var{m} is an integer mode narrower than @code{BITS_PER_WORD}. In most
1051 cases, only integer modes should be widened because wider-precision
1052 floating-point operations are usually more expensive than their narrower
1055 For most machines, the macro definition does not change @var{unsignedp}.
1056 However, some machines, have instructions that preferentially handle
1057 either signed or unsigned quantities of certain modes. For example, on
1058 the DEC Alpha, 32-bit loads from memory and 32-bit add instructions
1059 sign-extend the result to 64 bits. On such machines, set
1060 @var{unsignedp} according to which kind of extension is more efficient.
1062 Do not define this macro if it would never modify @var{m}.
1065 @defmac PROMOTE_FUNCTION_ARGS
1066 Define this macro if the promotion described by @code{PROMOTE_MODE}
1067 should also be done for outgoing function arguments.
1070 @defmac PROMOTE_FUNCTION_RETURN
1071 Define this macro if the promotion described by @code{PROMOTE_MODE}
1072 should also be done for the return value of functions.
1074 If this macro is defined, @code{FUNCTION_VALUE} must perform the same
1075 promotions done by @code{PROMOTE_MODE}.
1078 @defmac PROMOTE_FOR_CALL_ONLY
1079 Define this macro if the promotion described by @code{PROMOTE_MODE}
1080 should @emph{only} be performed for outgoing function arguments or
1081 function return values, as specified by @code{PROMOTE_FUNCTION_ARGS}
1082 and @code{PROMOTE_FUNCTION_RETURN}, respectively.
1085 @defmac PARM_BOUNDARY
1086 Normal alignment required for function parameters on the stack, in
1087 bits. All stack parameters receive at least this much alignment
1088 regardless of data type. On most machines, this is the same as the
1092 @defmac STACK_BOUNDARY
1093 Define this macro to the minimum alignment enforced by hardware for the
1094 stack pointer on this machine. The definition is a C expression for the
1095 desired alignment (measured in bits). This value is used as a default
1096 if @code{PREFERRED_STACK_BOUNDARY} is not defined. On most machines,
1097 this should be the same as @code{PARM_BOUNDARY}.
1100 @defmac PREFERRED_STACK_BOUNDARY
1101 Define this macro if you wish to preserve a certain alignment for the
1102 stack pointer, greater than what the hardware enforces. The definition
1103 is a C expression for the desired alignment (measured in bits). This
1104 macro must evaluate to a value equal to or larger than
1105 @code{STACK_BOUNDARY}.
1108 @defmac FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
1109 A C expression that evaluates true if @code{PREFERRED_STACK_BOUNDARY} is
1110 not guaranteed by the runtime and we should emit code to align the stack
1111 at the beginning of @code{main}.
1113 @cindex @code{PUSH_ROUNDING}, interaction with @code{PREFERRED_STACK_BOUNDARY}
1114 If @code{PUSH_ROUNDING} is not defined, the stack will always be aligned
1115 to the specified boundary. If @code{PUSH_ROUNDING} is defined and specifies
1116 a less strict alignment than @code{PREFERRED_STACK_BOUNDARY}, the stack may
1117 be momentarily unaligned while pushing arguments.
1120 @defmac FUNCTION_BOUNDARY
1121 Alignment required for a function entry point, in bits.
1124 @defmac BIGGEST_ALIGNMENT
1125 Biggest alignment that any data type can require on this machine, in bits.
1128 @defmac MINIMUM_ATOMIC_ALIGNMENT
1129 If defined, the smallest alignment, in bits, that can be given to an
1130 object that can be referenced in one operation, without disturbing any
1131 nearby object. Normally, this is @code{BITS_PER_UNIT}, but may be larger
1132 on machines that don't have byte or half-word store operations.
1135 @defmac BIGGEST_FIELD_ALIGNMENT
1136 Biggest alignment that any structure or union field can require on this
1137 machine, in bits. If defined, this overrides @code{BIGGEST_ALIGNMENT} for
1138 structure and union fields only, unless the field alignment has been set
1139 by the @code{__attribute__ ((aligned (@var{n})))} construct.
1142 @defmac ADJUST_FIELD_ALIGN (@var{field}, @var{computed})
1143 An expression for the alignment of a structure field @var{field} if the
1144 alignment computed in the usual way (including applying of
1145 @code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the
1146 alignment) is @var{computed}. It overrides alignment only if the
1147 field alignment has not been set by the
1148 @code{__attribute__ ((aligned (@var{n})))} construct.
1151 @defmac MAX_OFILE_ALIGNMENT
1152 Biggest alignment supported by the object file format of this machine.
1153 Use this macro to limit the alignment which can be specified using the
1154 @code{__attribute__ ((aligned (@var{n})))} construct. If not defined,
1155 the default value is @code{BIGGEST_ALIGNMENT}.
1158 @defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
1159 If defined, a C expression to compute the alignment for a variable in
1160 the static store. @var{type} is the data type, and @var{basic-align} is
1161 the alignment that the object would ordinarily have. The value of this
1162 macro is used instead of that alignment to align the object.
1164 If this macro is not defined, then @var{basic-align} is used.
1167 One use of this macro is to increase alignment of medium-size data to
1168 make it all fit in fewer cache lines. Another is to cause character
1169 arrays to be word-aligned so that @code{strcpy} calls that copy
1170 constants to character arrays can be done inline.
1173 @defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
1174 If defined, a C expression to compute the alignment given to a constant
1175 that is being placed in memory. @var{constant} is the constant and
1176 @var{basic-align} is the alignment that the object would ordinarily
1177 have. The value of this macro is used instead of that alignment to
1180 If this macro is not defined, then @var{basic-align} is used.
1182 The typical use of this macro is to increase alignment for string
1183 constants to be word aligned so that @code{strcpy} calls that copy
1184 constants can be done inline.
1187 @defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
1188 If defined, a C expression to compute the alignment for a variable in
1189 the local store. @var{type} is the data type, and @var{basic-align} is
1190 the alignment that the object would ordinarily have. The value of this
1191 macro is used instead of that alignment to align the object.
1193 If this macro is not defined, then @var{basic-align} is used.
1195 One use of this macro is to increase alignment of medium-size data to
1196 make it all fit in fewer cache lines.
1199 @defmac EMPTY_FIELD_BOUNDARY
1200 Alignment in bits to be given to a structure bit-field that follows an
1201 empty field such as @code{int : 0;}.
1203 If @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro.
1206 @defmac STRUCTURE_SIZE_BOUNDARY
1207 Number of bits which any structure or union's size must be a multiple of.
1208 Each structure or union's size is rounded up to a multiple of this.
1210 If you do not define this macro, the default is the same as
1211 @code{BITS_PER_UNIT}.
1214 @defmac STRICT_ALIGNMENT
1215 Define this macro to be the value 1 if instructions will fail to work
1216 if given data not on the nominal alignment. If instructions will merely
1217 go slower in that case, define this macro as 0.
1220 @defmac PCC_BITFIELD_TYPE_MATTERS
1221 Define this if you wish to imitate the way many other C compilers handle
1222 alignment of bit-fields and the structures that contain them.
1224 The behavior is that the type written for a named bit-field (@code{int},
1225 @code{short}, or other integer type) imposes an alignment for the entire
1226 structure, as if the structure really did contain an ordinary field of
1227 that type. In addition, the bit-field is placed within the structure so
1228 that it would fit within such a field, not crossing a boundary for it.
1230 Thus, on most machines, a named bit-field whose type is written as
1231 @code{int} would not cross a four-byte boundary, and would force
1232 four-byte alignment for the whole structure. (The alignment used may
1233 not be four bytes; it is controlled by the other alignment parameters.)
1235 An unnamed bit-field will not affect the alignment of the containing
1238 If the macro is defined, its definition should be a C expression;
1239 a nonzero value for the expression enables this behavior.
1241 Note that if this macro is not defined, or its value is zero, some
1242 bit-fields may cross more than one alignment boundary. The compiler can
1243 support such references if there are @samp{insv}, @samp{extv}, and
1244 @samp{extzv} insns that can directly reference memory.
1246 The other known way of making bit-fields work is to define
1247 @code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}.
1248 Then every structure can be accessed with fullwords.
1250 Unless the machine has bit-field instructions or you define
1251 @code{STRUCTURE_SIZE_BOUNDARY} that way, you must define
1252 @code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value.
1254 If your aim is to make GCC use the same conventions for laying out
1255 bit-fields as are used by another compiler, here is how to investigate
1256 what the other compiler does. Compile and run this program:
1275 printf ("Size of foo1 is %d\n",
1276 sizeof (struct foo1));
1277 printf ("Size of foo2 is %d\n",
1278 sizeof (struct foo2));
1283 If this prints 2 and 5, then the compiler's behavior is what you would
1284 get from @code{PCC_BITFIELD_TYPE_MATTERS}.
1287 @defmac BITFIELD_NBYTES_LIMITED
1288 Like @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited
1289 to aligning a bit-field within the structure.
1292 @defmac MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode})
1293 Return 1 if a structure or array containing @var{field} should be accessed using
1296 If @var{field} is the only field in the structure, @var{mode} is its
1297 mode, otherwise @var{mode} is VOIDmode. @var{mode} is provided in the
1298 case where structures of one field would require the structure's mode to
1299 retain the field's mode.
1301 Normally, this is not needed. See the file @file{c4x.h} for an example
1302 of how to use this macro to prevent a structure having a floating point
1303 field from being accessed in an integer mode.
1306 @defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified})
1307 Define this macro as an expression for the alignment of a type (given
1308 by @var{type} as a tree node) if the alignment computed in the usual
1309 way is @var{computed} and the alignment explicitly specified was
1312 The default is to use @var{specified} if it is larger; otherwise, use
1313 the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT}
1316 @defmac MAX_FIXED_MODE_SIZE
1317 An integer expression for the size in bits of the largest integer
1318 machine mode that should actually be used. All integer machine modes of
1319 this size or smaller can be used for structures and unions with the
1320 appropriate sizes. If this macro is undefined, @code{GET_MODE_BITSIZE
1321 (DImode)} is assumed.
1324 @defmac VECTOR_MODE_SUPPORTED_P (@var{mode})
1325 Define this macro to be nonzero if the port is prepared to handle insns
1326 involving vector mode @var{mode}. At the very least, it must have move
1327 patterns for this mode.
1330 @defmac STACK_SAVEAREA_MODE (@var{save_level})
1331 If defined, an expression of type @code{enum machine_mode} that
1332 specifies the mode of the save area operand of a
1333 @code{save_stack_@var{level}} named pattern (@pxref{Standard Names}).
1334 @var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or
1335 @code{SAVE_NONLOCAL} and selects which of the three named patterns is
1336 having its mode specified.
1338 You need not define this macro if it always returns @code{Pmode}. You
1339 would most commonly define this macro if the
1340 @code{save_stack_@var{level}} patterns need to support both a 32- and a
1344 @defmac STACK_SIZE_MODE
1345 If defined, an expression of type @code{enum machine_mode} that
1346 specifies the mode of the size increment operand of an
1347 @code{allocate_stack} named pattern (@pxref{Standard Names}).
1349 You need not define this macro if it always returns @code{word_mode}.
1350 You would most commonly define this macro if the @code{allocate_stack}
1351 pattern needs to support both a 32- and a 64-bit mode.
1354 @defmac TARGET_FLOAT_FORMAT
1355 A code distinguishing the floating point format of the target machine.
1356 There are four defined values:
1359 @item IEEE_FLOAT_FORMAT
1360 This code indicates IEEE floating point. It is the default; there is no
1361 need to define @code{TARGET_FLOAT_FORMAT} when the format is IEEE@.
1363 @item VAX_FLOAT_FORMAT
1364 This code indicates the ``F float'' (for @code{float}) and ``D float''
1365 or ``G float'' formats (for @code{double}) used on the VAX and PDP-11@.
1367 @item IBM_FLOAT_FORMAT
1368 This code indicates the format used on the IBM System/370.
1370 @item C4X_FLOAT_FORMAT
1371 This code indicates the format used on the TMS320C3x/C4x.
1374 If your target uses a floating point format other than these, you must
1375 define a new @var{name}_FLOAT_FORMAT code for it, and add support for
1376 it to @file{real.c}.
1378 The ordering of the component words of floating point values stored in
1379 memory is controlled by @code{FLOAT_WORDS_BIG_ENDIAN}.
1382 @defmac MODE_HAS_NANS (@var{mode})
1383 When defined, this macro should be true if @var{mode} has a NaN
1384 representation. The compiler assumes that NaNs are not equal to
1385 anything (including themselves) and that addition, subtraction,
1386 multiplication and division all return NaNs when one operand is
1389 By default, this macro is true if @var{mode} is a floating-point
1390 mode and the target floating-point format is IEEE@.
1393 @defmac MODE_HAS_INFINITIES (@var{mode})
1394 This macro should be true if @var{mode} can represent infinity. At
1395 present, the compiler uses this macro to decide whether @samp{x - x}
1396 is always defined. By default, the macro is true when @var{mode}
1397 is a floating-point mode and the target format is IEEE@.
1400 @defmac MODE_HAS_SIGNED_ZEROS (@var{mode})
1401 True if @var{mode} distinguishes between positive and negative zero.
1402 The rules are expected to follow the IEEE standard:
1406 @samp{x + x} has the same sign as @samp{x}.
1409 If the sum of two values with opposite sign is zero, the result is
1410 positive for all rounding modes expect towards @minus{}infinity, for
1411 which it is negative.
1414 The sign of a product or quotient is negative when exactly one
1415 of the operands is negative.
1418 The default definition is true if @var{mode} is a floating-point
1419 mode and the target format is IEEE@.
1422 @defmac MODE_HAS_SIGN_DEPENDENT_ROUNDING (@var{mode})
1423 If defined, this macro should be true for @var{mode} if it has at
1424 least one rounding mode in which @samp{x} and @samp{-x} can be
1425 rounded to numbers of different magnitude. Two such modes are
1426 towards @minus{}infinity and towards +infinity.
1428 The default definition of this macro is true if @var{mode} is
1429 a floating-point mode and the target format is IEEE@.
1432 @defmac ROUND_TOWARDS_ZERO
1433 If defined, this macro should be true if the prevailing rounding
1434 mode is towards zero. A true value has the following effects:
1438 @code{MODE_HAS_SIGN_DEPENDENT_ROUNDING} will be false for all modes.
1441 @file{libgcc.a}'s floating-point emulator will round towards zero
1442 rather than towards nearest.
1445 The compiler's floating-point emulator will round towards zero after
1446 doing arithmetic, and when converting from the internal float format to
1450 The macro does not affect the parsing of string literals. When the
1451 primary rounding mode is towards zero, library functions like
1452 @code{strtod} might still round towards nearest, and the compiler's
1453 parser should behave like the target's @code{strtod} where possible.
1455 Not defining this macro is equivalent to returning zero.
1458 @defmac LARGEST_EXPONENT_IS_NORMAL (@var{size})
1459 This macro should return true if floats with @var{size}
1460 bits do not have a NaN or infinity representation, but use the largest
1461 exponent for normal numbers instead.
1463 Defining this macro to true for @var{size} causes @code{MODE_HAS_NANS}
1464 and @code{MODE_HAS_INFINITIES} to be false for @var{size}-bit modes.
1465 It also affects the way @file{libgcc.a} and @file{real.c} emulate
1466 floating-point arithmetic.
1468 The default definition of this macro returns false for all sizes.
1471 @deftypefn {Target Hook} bool TARGET_VECTOR_OPAQUE_P (tree @var{type})
1472 This target hook should return @code{true} a vector is opaque. That
1473 is, if no cast is needed when copying a vector value of type
1474 @var{type} into another vector lvalue of the same size. Vector opaque
1475 types cannot be initialized. The default is that there are no such
1479 @deftypefn {Target Hook} bool TARGET_MS_BITFIELD_LAYOUT_P (tree @var{record_type})
1480 This target hook returns @code{true} if bit-fields in the given
1481 @var{record_type} are to be laid out following the rules of Microsoft
1482 Visual C/C++, namely: (i) a bit-field won't share the same storage
1483 unit with the previous bit-field if their underlying types have
1484 different sizes, and the bit-field will be aligned to the highest
1485 alignment of the underlying types of itself and of the previous
1486 bit-field; (ii) a zero-sized bit-field will affect the alignment of
1487 the whole enclosing structure, even if it is unnamed; except that
1488 (iii) a zero-sized bit-field will be disregarded unless it follows
1489 another bit-field of nonzero size. If this hook returns @code{true},
1490 other macros that control bit-field layout are ignored.
1492 When a bit-field is inserted into a packed record, the whole size
1493 of the underlying type is used by one or more same-size adjacent
1494 bit-fields (that is, if its long:3, 32 bits is used in the record,
1495 and any additional adjacent long bit-fields are packed into the same
1496 chunk of 32 bits. However, if the size changes, a new field of that
1497 size is allocated). In an unpacked record, this is the same as using
1498 alignment, but not equivalent when packing.
1500 If both MS bit-fields and @samp{__attribute__((packed))} are used,
1501 the latter will take precedence. If @samp{__attribute__((packed))} is
1502 used on a single field when MS bit-fields are in use, it will take
1503 precedence for that field, but the alignment of the rest of the structure
1504 may affect its placement.
1508 @section Layout of Source Language Data Types
1510 These macros define the sizes and other characteristics of the standard
1511 basic data types used in programs being compiled. Unlike the macros in
1512 the previous section, these apply to specific features of C and related
1513 languages, rather than to fundamental aspects of storage layout.
1515 @defmac INT_TYPE_SIZE
1516 A C expression for the size in bits of the type @code{int} on the
1517 target machine. If you don't define this, the default is one word.
1520 @defmac SHORT_TYPE_SIZE
1521 A C expression for the size in bits of the type @code{short} on the
1522 target machine. If you don't define this, the default is half a word.
1523 (If this would be less than one storage unit, it is rounded up to one
1527 @defmac LONG_TYPE_SIZE
1528 A C expression for the size in bits of the type @code{long} on the
1529 target machine. If you don't define this, the default is one word.
1532 @defmac ADA_LONG_TYPE_SIZE
1533 On some machines, the size used for the Ada equivalent of the type
1534 @code{long} by a native Ada compiler differs from that used by C. In
1535 that situation, define this macro to be a C expression to be used for
1536 the size of that type. If you don't define this, the default is the
1537 value of @code{LONG_TYPE_SIZE}.
1540 @defmac MAX_LONG_TYPE_SIZE
1541 Maximum number for the size in bits of the type @code{long} on the
1542 target machine. If this is undefined, the default is
1543 @code{LONG_TYPE_SIZE}. Otherwise, it is the constant value that is the
1544 largest value that @code{LONG_TYPE_SIZE} can have at run-time. This is
1548 @defmac LONG_LONG_TYPE_SIZE
1549 A C expression for the size in bits of the type @code{long long} on the
1550 target machine. If you don't define this, the default is two
1551 words. If you want to support GNU Ada on your machine, the value of this
1552 macro must be at least 64.
1555 @defmac CHAR_TYPE_SIZE
1556 A C expression for the size in bits of the type @code{char} on the
1557 target machine. If you don't define this, the default is
1558 @code{BITS_PER_UNIT}.
1561 @defmac BOOL_TYPE_SIZE
1562 A C expression for the size in bits of the C++ type @code{bool} and
1563 C99 type @code{_Bool} on the target machine. If you don't define
1564 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
1567 @defmac FLOAT_TYPE_SIZE
1568 A C expression for the size in bits of the type @code{float} on the
1569 target machine. If you don't define this, the default is one word.
1572 @defmac DOUBLE_TYPE_SIZE
1573 A C expression for the size in bits of the type @code{double} on the
1574 target machine. If you don't define this, the default is two
1578 @defmac LONG_DOUBLE_TYPE_SIZE
1579 A C expression for the size in bits of the type @code{long double} on
1580 the target machine. If you don't define this, the default is two
1584 @defmac MAX_LONG_DOUBLE_TYPE_SIZE
1585 Maximum number for the size in bits of the type @code{long double} on the
1586 target machine. If this is undefined, the default is
1587 @code{LONG_DOUBLE_TYPE_SIZE}. Otherwise, it is the constant value that is
1588 the largest value that @code{LONG_DOUBLE_TYPE_SIZE} can have at run-time.
1589 This is used in @code{cpp}.
1592 @defmac TARGET_FLT_EVAL_METHOD
1593 A C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h},
1594 assuming, if applicable, that the floating-point control word is in its
1595 default state. If you do not define this macro the value of
1596 @code{FLT_EVAL_METHOD} will be zero.
1599 @defmac WIDEST_HARDWARE_FP_SIZE
1600 A C expression for the size in bits of the widest floating-point format
1601 supported by the hardware. If you define this macro, you must specify a
1602 value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
1603 If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
1607 @defmac DEFAULT_SIGNED_CHAR
1608 An expression whose value is 1 or 0, according to whether the type
1609 @code{char} should be signed or unsigned by default. The user can
1610 always override this default with the options @option{-fsigned-char}
1611 and @option{-funsigned-char}.
1614 @defmac DEFAULT_SHORT_ENUMS
1615 A C expression to determine whether to give an @code{enum} type
1616 only as many bytes as it takes to represent the range of possible values
1617 of that type. A nonzero value means to do that; a zero value means all
1618 @code{enum} types should be allocated like @code{int}.
1620 If you don't define the macro, the default is 0.
1624 A C expression for a string describing the name of the data type to use
1625 for size values. The typedef name @code{size_t} is defined using the
1626 contents of the string.
1628 The string can contain more than one keyword. If so, separate them with
1629 spaces, and write first any length keyword, then @code{unsigned} if
1630 appropriate, and finally @code{int}. The string must exactly match one
1631 of the data type names defined in the function
1632 @code{init_decl_processing} in the file @file{c-decl.c}. You may not
1633 omit @code{int} or change the order---that would cause the compiler to
1636 If you don't define this macro, the default is @code{"long unsigned
1640 @defmac PTRDIFF_TYPE
1641 A C expression for a string describing the name of the data type to use
1642 for the result of subtracting two pointers. The typedef name
1643 @code{ptrdiff_t} is defined using the contents of the string. See
1644 @code{SIZE_TYPE} above for more information.
1646 If you don't define this macro, the default is @code{"long int"}.
1650 A C expression for a string describing the name of the data type to use
1651 for wide characters. The typedef name @code{wchar_t} is defined using
1652 the contents of the string. See @code{SIZE_TYPE} above for more
1655 If you don't define this macro, the default is @code{"int"}.
1658 @defmac WCHAR_TYPE_SIZE
1659 A C expression for the size in bits of the data type for wide
1660 characters. This is used in @code{cpp}, which cannot make use of
1664 @defmac MAX_WCHAR_TYPE_SIZE
1665 Maximum number for the size in bits of the data type for wide
1666 characters. If this is undefined, the default is
1667 @code{WCHAR_TYPE_SIZE}. Otherwise, it is the constant value that is the
1668 largest value that @code{WCHAR_TYPE_SIZE} can have at run-time. This is
1672 @defmac GCOV_TYPE_SIZE
1673 A C expression for the size in bits of the type used for gcov counters on the
1674 target machine. If you don't define this, the default is one
1675 @code{LONG_TYPE_SIZE} in case it is greater or equal to 64-bit and
1676 @code{LONG_LONG_TYPE_SIZE} otherwise. You may want to re-define the type to
1677 ensure atomicity for counters in multithreaded programs.
1681 A C expression for a string describing the name of the data type to
1682 use for wide characters passed to @code{printf} and returned from
1683 @code{getwc}. The typedef name @code{wint_t} is defined using the
1684 contents of the string. See @code{SIZE_TYPE} above for more
1687 If you don't define this macro, the default is @code{"unsigned int"}.
1691 A C expression for a string describing the name of the data type that
1692 can represent any value of any standard or extended signed integer type.
1693 The typedef name @code{intmax_t} is defined using the contents of the
1694 string. See @code{SIZE_TYPE} above for more information.
1696 If you don't define this macro, the default is the first of
1697 @code{"int"}, @code{"long int"}, or @code{"long long int"} that has as
1698 much precision as @code{long long int}.
1701 @defmac UINTMAX_TYPE
1702 A C expression for a string describing the name of the data type that
1703 can represent any value of any standard or extended unsigned integer
1704 type. The typedef name @code{uintmax_t} is defined using the contents
1705 of the string. See @code{SIZE_TYPE} above for more information.
1707 If you don't define this macro, the default is the first of
1708 @code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long
1709 unsigned int"} that has as much precision as @code{long long unsigned
1713 @defmac TARGET_PTRMEMFUNC_VBIT_LOCATION
1714 The C++ compiler represents a pointer-to-member-function with a struct
1721 ptrdiff_t vtable_index;
1728 The C++ compiler must use one bit to indicate whether the function that
1729 will be called through a pointer-to-member-function is virtual.
1730 Normally, we assume that the low-order bit of a function pointer must
1731 always be zero. Then, by ensuring that the vtable_index is odd, we can
1732 distinguish which variant of the union is in use. But, on some
1733 platforms function pointers can be odd, and so this doesn't work. In
1734 that case, we use the low-order bit of the @code{delta} field, and shift
1735 the remainder of the @code{delta} field to the left.
1737 GCC will automatically make the right selection about where to store
1738 this bit using the @code{FUNCTION_BOUNDARY} setting for your platform.
1739 However, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY}
1740 set such that functions always start at even addresses, but the lowest
1741 bit of pointers to functions indicate whether the function at that
1742 address is in ARM or Thumb mode. If this is the case of your
1743 architecture, you should define this macro to
1744 @code{ptrmemfunc_vbit_in_delta}.
1746 In general, you should not have to define this macro. On architectures
1747 in which function addresses are always even, according to
1748 @code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to
1749 @code{ptrmemfunc_vbit_in_pfn}.
1752 @defmac TARGET_VTABLE_USES_DESCRIPTORS
1753 Normally, the C++ compiler uses function pointers in vtables. This
1754 macro allows the target to change to use ``function descriptors''
1755 instead. Function descriptors are found on targets for whom a
1756 function pointer is actually a small data structure. Normally the
1757 data structure consists of the actual code address plus a data
1758 pointer to which the function's data is relative.
1760 If vtables are used, the value of this macro should be the number
1761 of words that the function descriptor occupies.
1764 @defmac TARGET_VTABLE_ENTRY_ALIGN
1765 By default, the vtable entries are void pointers, the so the alignment
1766 is the same as pointer alignment. The value of this macro specifies
1767 the alignment of the vtable entry in bits. It should be defined only
1768 when special alignment is necessary. */
1771 @defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE
1772 There are a few non-descriptor entries in the vtable at offsets below
1773 zero. If these entries must be padded (say, to preserve the alignment
1774 specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
1775 of words in each data entry.
1778 @node Escape Sequences
1779 @section Target Character Escape Sequences
1780 @cindex escape sequences
1782 By default, GCC assumes that the C character escape sequences take on
1783 their ASCII values for the target. If this is not correct, you must
1784 explicitly define all of the macros below. All of them must evaluate
1785 to constants; they are used in @code{case} statements.
1791 @findex TARGET_NEWLINE
1794 @multitable {@code{TARGET_NEWLINE}} {Escape} {ASCII character}
1795 @item Macro @tab Escape @tab ASCII character
1796 @item @code{TARGET_BELL} @tab @kbd{\a} @tab @code{07}, @code{BEL}
1797 @item @code{TARGET_CR} @tab @kbd{\r} @tab @code{0D}, @code{CR}
1798 @item @code{TARGET_ESC} @tab @kbd{\e}, @kbd{\E} @tab @code{1B}, @code{ESC}
1799 @item @code{TARGET_FF} @tab @kbd{\f} @tab @code{0C}, @code{FF}
1800 @item @code{TARGET_NEWLINE} @tab @kbd{\n} @tab @code{0A}, @code{LF}
1801 @item @code{TARGET_TAB} @tab @kbd{\t} @tab @code{09}, @code{HT}
1802 @item @code{TARGET_VT} @tab @kbd{\v} @tab @code{0B}, @code{VT}
1806 Note that the @kbd{\e} and @kbd{\E} escapes are GNU extensions, not
1807 part of the C standard.
1810 @section Register Usage
1811 @cindex register usage
1813 This section explains how to describe what registers the target machine
1814 has, and how (in general) they can be used.
1816 The description of which registers a specific instruction can use is
1817 done with register classes; see @ref{Register Classes}. For information
1818 on using registers to access a stack frame, see @ref{Frame Registers}.
1819 For passing values in registers, see @ref{Register Arguments}.
1820 For returning values in registers, see @ref{Scalar Return}.
1823 * Register Basics:: Number and kinds of registers.
1824 * Allocation Order:: Order in which registers are allocated.
1825 * Values in Registers:: What kinds of values each reg can hold.
1826 * Leaf Functions:: Renumbering registers for leaf functions.
1827 * Stack Registers:: Handling a register stack such as 80387.
1830 @node Register Basics
1831 @subsection Basic Characteristics of Registers
1833 @c prevent bad page break with this line
1834 Registers have various characteristics.
1836 @defmac FIRST_PSEUDO_REGISTER
1837 Number of hardware registers known to the compiler. They receive
1838 numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
1839 pseudo register's number really is assigned the number
1840 @code{FIRST_PSEUDO_REGISTER}.
1843 @defmac FIXED_REGISTERS
1844 @cindex fixed register
1845 An initializer that says which registers are used for fixed purposes
1846 all throughout the compiled code and are therefore not available for
1847 general allocation. These would include the stack pointer, the frame
1848 pointer (except on machines where that can be used as a general
1849 register when no frame pointer is needed), the program counter on
1850 machines where that is considered one of the addressable registers,
1851 and any other numbered register with a standard use.
1853 This information is expressed as a sequence of numbers, separated by
1854 commas and surrounded by braces. The @var{n}th number is 1 if
1855 register @var{n} is fixed, 0 otherwise.
1857 The table initialized from this macro, and the table initialized by
1858 the following one, may be overridden at run time either automatically,
1859 by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
1860 the user with the command options @option{-ffixed-@var{reg}},
1861 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}.
1864 @defmac CALL_USED_REGISTERS
1865 @cindex call-used register
1866 @cindex call-clobbered register
1867 @cindex call-saved register
1868 Like @code{FIXED_REGISTERS} but has 1 for each register that is
1869 clobbered (in general) by function calls as well as for fixed
1870 registers. This macro therefore identifies the registers that are not
1871 available for general allocation of values that must live across
1874 If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
1875 automatically saves it on function entry and restores it on function
1876 exit, if the register is used within the function.
1879 @defmac CALL_REALLY_USED_REGISTERS
1880 @cindex call-used register
1881 @cindex call-clobbered register
1882 @cindex call-saved register
1883 Like @code{CALL_USED_REGISTERS} except this macro doesn't require
1884 that the entire set of @code{FIXED_REGISTERS} be included.
1885 (@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}).
1886 This macro is optional. If not specified, it defaults to the value
1887 of @code{CALL_USED_REGISTERS}.
1890 @defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
1891 @cindex call-used register
1892 @cindex call-clobbered register
1893 @cindex call-saved register
1894 A C expression that is nonzero if it is not permissible to store a
1895 value of mode @var{mode} in hard register number @var{regno} across a
1896 call without some part of it being clobbered. For most machines this
1897 macro need not be defined. It is only required for machines that do not
1898 preserve the entire contents of a register across a call.
1902 @findex call_used_regs
1905 @findex reg_class_contents
1906 @defmac CONDITIONAL_REGISTER_USAGE
1907 Zero or more C statements that may conditionally modify five variables
1908 @code{fixed_regs}, @code{call_used_regs}, @code{global_regs},
1909 @code{reg_names}, and @code{reg_class_contents}, to take into account
1910 any dependence of these register sets on target flags. The first three
1911 of these are of type @code{char []} (interpreted as Boolean vectors).
1912 @code{global_regs} is a @code{const char *[]}, and
1913 @code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is
1914 called, @code{fixed_regs}, @code{call_used_regs},
1915 @code{reg_class_contents}, and @code{reg_names} have been initialized
1916 from @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS},
1917 @code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively.
1918 @code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}},
1919 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}
1920 command options have been applied.
1922 You need not define this macro if it has no work to do.
1924 @cindex disabling certain registers
1925 @cindex controlling register usage
1926 If the usage of an entire class of registers depends on the target
1927 flags, you may indicate this to GCC by using this macro to modify
1928 @code{fixed_regs} and @code{call_used_regs} to 1 for each of the
1929 registers in the classes which should not be used by GCC@. Also define
1930 the macro @code{REG_CLASS_FROM_LETTER} / @code{REG_CLASS_FROM_CONSTRAINT}
1931 to return @code{NO_REGS} if it
1932 is called with a letter for a class that shouldn't be used.
1934 (However, if this class is not included in @code{GENERAL_REGS} and all
1935 of the insn patterns whose constraints permit this class are
1936 controlled by target switches, then GCC will automatically avoid using
1937 these registers when the target switches are opposed to them.)
1940 @defmac NON_SAVING_SETJMP
1941 If this macro is defined and has a nonzero value, it means that
1942 @code{setjmp} and related functions fail to save the registers, or that
1943 @code{longjmp} fails to restore them. To compensate, the compiler
1944 avoids putting variables in registers in functions that use
1948 @defmac INCOMING_REGNO (@var{out})
1949 Define this macro if the target machine has register windows. This C
1950 expression returns the register number as seen by the called function
1951 corresponding to the register number @var{out} as seen by the calling
1952 function. Return @var{out} if register number @var{out} is not an
1956 @defmac OUTGOING_REGNO (@var{in})
1957 Define this macro if the target machine has register windows. This C
1958 expression returns the register number as seen by the calling function
1959 corresponding to the register number @var{in} as seen by the called
1960 function. Return @var{in} if register number @var{in} is not an inbound
1964 @defmac LOCAL_REGNO (@var{regno})
1965 Define this macro if the target machine has register windows. This C
1966 expression returns true if the register is call-saved but is in the
1967 register window. Unlike most call-saved registers, such registers
1968 need not be explicitly restored on function exit or during non-local
1973 If the program counter has a register number, define this as that
1974 register number. Otherwise, do not define it.
1977 @node Allocation Order
1978 @subsection Order of Allocation of Registers
1979 @cindex order of register allocation
1980 @cindex register allocation order
1982 @c prevent bad page break with this line
1983 Registers are allocated in order.
1985 @defmac REG_ALLOC_ORDER
1986 If defined, an initializer for a vector of integers, containing the
1987 numbers of hard registers in the order in which GCC should prefer
1988 to use them (from most preferred to least).
1990 If this macro is not defined, registers are used lowest numbered first
1991 (all else being equal).
1993 One use of this macro is on machines where the highest numbered
1994 registers must always be saved and the save-multiple-registers
1995 instruction supports only sequences of consecutive registers. On such
1996 machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists
1997 the highest numbered allocable register first.
2000 @defmac ORDER_REGS_FOR_LOCAL_ALLOC
2001 A C statement (sans semicolon) to choose the order in which to allocate
2002 hard registers for pseudo-registers local to a basic block.
2004 Store the desired register order in the array @code{reg_alloc_order}.
2005 Element 0 should be the register to allocate first; element 1, the next
2006 register; and so on.
2008 The macro body should not assume anything about the contents of
2009 @code{reg_alloc_order} before execution of the macro.
2011 On most machines, it is not necessary to define this macro.
2014 @node Values in Registers
2015 @subsection How Values Fit in Registers
2017 This section discusses the macros that describe which kinds of values
2018 (specifically, which machine modes) each register can hold, and how many
2019 consecutive registers are needed for a given mode.
2021 @defmac HARD_REGNO_NREGS (@var{regno}, @var{mode})
2022 A C expression for the number of consecutive hard registers, starting
2023 at register number @var{regno}, required to hold a value of mode
2026 On a machine where all registers are exactly one word, a suitable
2027 definition of this macro is
2030 #define HARD_REGNO_NREGS(REGNO, MODE) \
2031 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
2036 @defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
2037 A C expression that is nonzero if it is permissible to store a value
2038 of mode @var{mode} in hard register number @var{regno} (or in several
2039 registers starting with that one). For a machine where all registers
2040 are equivalent, a suitable definition is
2043 #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
2046 You need not include code to check for the numbers of fixed registers,
2047 because the allocation mechanism considers them to be always occupied.
2049 @cindex register pairs
2050 On some machines, double-precision values must be kept in even/odd
2051 register pairs. You can implement that by defining this macro to reject
2052 odd register numbers for such modes.
2054 The minimum requirement for a mode to be OK in a register is that the
2055 @samp{mov@var{mode}} instruction pattern support moves between the
2056 register and other hard register in the same class and that moving a
2057 value into the register and back out not alter it.
2059 Since the same instruction used to move @code{word_mode} will work for
2060 all narrower integer modes, it is not necessary on any machine for
2061 @code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided
2062 you define patterns @samp{movhi}, etc., to take advantage of this. This
2063 is useful because of the interaction between @code{HARD_REGNO_MODE_OK}
2064 and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes
2067 Many machines have special registers for floating point arithmetic.
2068 Often people assume that floating point machine modes are allowed only
2069 in floating point registers. This is not true. Any registers that
2070 can hold integers can safely @emph{hold} a floating point machine
2071 mode, whether or not floating arithmetic can be done on it in those
2072 registers. Integer move instructions can be used to move the values.
2074 On some machines, though, the converse is true: fixed-point machine
2075 modes may not go in floating registers. This is true if the floating
2076 registers normalize any value stored in them, because storing a
2077 non-floating value there would garble it. In this case,
2078 @code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in
2079 floating registers. But if the floating registers do not automatically
2080 normalize, if you can store any bit pattern in one and retrieve it
2081 unchanged without a trap, then any machine mode may go in a floating
2082 register, so you can define this macro to say so.
2084 The primary significance of special floating registers is rather that
2085 they are the registers acceptable in floating point arithmetic
2086 instructions. However, this is of no concern to
2087 @code{HARD_REGNO_MODE_OK}. You handle it by writing the proper
2088 constraints for those instructions.
2090 On some machines, the floating registers are especially slow to access,
2091 so that it is better to store a value in a stack frame than in such a
2092 register if floating point arithmetic is not being done. As long as the
2093 floating registers are not in class @code{GENERAL_REGS}, they will not
2094 be used unless some pattern's constraint asks for one.
2097 @defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2})
2098 A C expression that is nonzero if a value of mode
2099 @var{mode1} is accessible in mode @var{mode2} without copying.
2101 If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
2102 @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for
2103 any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})}
2104 should be nonzero. If they differ for any @var{r}, you should define
2105 this macro to return zero unless some other mechanism ensures the
2106 accessibility of the value in a narrower mode.
2108 You should define this macro to return nonzero in as many cases as
2109 possible since doing so will allow GCC to perform better register
2113 @defmac AVOID_CCMODE_COPIES
2114 Define this macro if the compiler should avoid copies to/from @code{CCmode}
2115 registers. You should only define this macro if support for copying to/from
2116 @code{CCmode} is incomplete.
2119 @node Leaf Functions
2120 @subsection Handling Leaf Functions
2122 @cindex leaf functions
2123 @cindex functions, leaf
2124 On some machines, a leaf function (i.e., one which makes no calls) can run
2125 more efficiently if it does not make its own register window. Often this
2126 means it is required to receive its arguments in the registers where they
2127 are passed by the caller, instead of the registers where they would
2130 The special treatment for leaf functions generally applies only when
2131 other conditions are met; for example, often they may use only those
2132 registers for its own variables and temporaries. We use the term ``leaf
2133 function'' to mean a function that is suitable for this special
2134 handling, so that functions with no calls are not necessarily ``leaf
2137 GCC assigns register numbers before it knows whether the function is
2138 suitable for leaf function treatment. So it needs to renumber the
2139 registers in order to output a leaf function. The following macros
2142 @defmac LEAF_REGISTERS
2143 Name of a char vector, indexed by hard register number, which
2144 contains 1 for a register that is allowable in a candidate for leaf
2147 If leaf function treatment involves renumbering the registers, then the
2148 registers marked here should be the ones before renumbering---those that
2149 GCC would ordinarily allocate. The registers which will actually be
2150 used in the assembler code, after renumbering, should not be marked with 1
2153 Define this macro only if the target machine offers a way to optimize
2154 the treatment of leaf functions.
2157 @defmac LEAF_REG_REMAP (@var{regno})
2158 A C expression whose value is the register number to which @var{regno}
2159 should be renumbered, when a function is treated as a leaf function.
2161 If @var{regno} is a register number which should not appear in a leaf
2162 function before renumbering, then the expression should yield @minus{}1, which
2163 will cause the compiler to abort.
2165 Define this macro only if the target machine offers a way to optimize the
2166 treatment of leaf functions, and registers need to be renumbered to do
2170 @findex current_function_is_leaf
2171 @findex current_function_uses_only_leaf_regs
2172 @code{TARGET_ASM_FUNCTION_PROLOGUE} and
2173 @code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions
2174 specially. They can test the C variable @code{current_function_is_leaf}
2175 which is nonzero for leaf functions. @code{current_function_is_leaf} is
2176 set prior to local register allocation and is valid for the remaining
2177 compiler passes. They can also test the C variable
2178 @code{current_function_uses_only_leaf_regs} which is nonzero for leaf
2179 functions which only use leaf registers.
2180 @code{current_function_uses_only_leaf_regs} is valid after reload and is
2181 only useful if @code{LEAF_REGISTERS} is defined.
2182 @c changed this to fix overfull. ALSO: why the "it" at the beginning
2183 @c of the next paragraph?! --mew 2feb93
2185 @node Stack Registers
2186 @subsection Registers That Form a Stack
2188 There are special features to handle computers where some of the
2189 ``registers'' form a stack. Stack registers are normally written by
2190 pushing onto the stack, and are numbered relative to the top of the
2193 Currently, GCC can only handle one group of stack-like registers, and
2194 they must be consecutively numbered. Furthermore, the existing
2195 support for stack-like registers is specific to the 80387 floating
2196 point coprocessor. If you have a new architecture that uses
2197 stack-like registers, you will need to do substantial work on
2198 @file{reg-stack.c} and write your machine description to cooperate
2199 with it, as well as defining these macros.
2202 Define this if the machine has any stack-like registers.
2205 @defmac FIRST_STACK_REG
2206 The number of the first stack-like register. This one is the top
2210 @defmac LAST_STACK_REG
2211 The number of the last stack-like register. This one is the bottom of
2215 @node Register Classes
2216 @section Register Classes
2217 @cindex register class definitions
2218 @cindex class definitions, register
2220 On many machines, the numbered registers are not all equivalent.
2221 For example, certain registers may not be allowed for indexed addressing;
2222 certain registers may not be allowed in some instructions. These machine
2223 restrictions are described to the compiler using @dfn{register classes}.
2225 You define a number of register classes, giving each one a name and saying
2226 which of the registers belong to it. Then you can specify register classes
2227 that are allowed as operands to particular instruction patterns.
2231 In general, each register will belong to several classes. In fact, one
2232 class must be named @code{ALL_REGS} and contain all the registers. Another
2233 class must be named @code{NO_REGS} and contain no registers. Often the
2234 union of two classes will be another class; however, this is not required.
2236 @findex GENERAL_REGS
2237 One of the classes must be named @code{GENERAL_REGS}. There is nothing
2238 terribly special about the name, but the operand constraint letters
2239 @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is
2240 the same as @code{ALL_REGS}, just define it as a macro which expands
2243 Order the classes so that if class @var{x} is contained in class @var{y}
2244 then @var{x} has a lower class number than @var{y}.
2246 The way classes other than @code{GENERAL_REGS} are specified in operand
2247 constraints is through machine-dependent operand constraint letters.
2248 You can define such letters to correspond to various classes, then use
2249 them in operand constraints.
2251 You should define a class for the union of two classes whenever some
2252 instruction allows both classes. For example, if an instruction allows
2253 either a floating point (coprocessor) register or a general register for a
2254 certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
2255 which includes both of them. Otherwise you will get suboptimal code.
2257 You must also specify certain redundant information about the register
2258 classes: for each class, which classes contain it and which ones are
2259 contained in it; for each pair of classes, the largest class contained
2262 When a value occupying several consecutive registers is expected in a
2263 certain class, all the registers used must belong to that class.
2264 Therefore, register classes cannot be used to enforce a requirement for
2265 a register pair to start with an even-numbered register. The way to
2266 specify this requirement is with @code{HARD_REGNO_MODE_OK}.
2268 Register classes used for input-operands of bitwise-and or shift
2269 instructions have a special requirement: each such class must have, for
2270 each fixed-point machine mode, a subclass whose registers can transfer that
2271 mode to or from memory. For example, on some machines, the operations for
2272 single-byte values (@code{QImode}) are limited to certain registers. When
2273 this is so, each register class that is used in a bitwise-and or shift
2274 instruction must have a subclass consisting of registers from which
2275 single-byte values can be loaded or stored. This is so that
2276 @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
2278 @deftp {Data type} {enum reg_class}
2279 An enumeral type that must be defined with all the register class names
2280 as enumeral values. @code{NO_REGS} must be first. @code{ALL_REGS}
2281 must be the last register class, followed by one more enumeral value,
2282 @code{LIM_REG_CLASSES}, which is not a register class but rather
2283 tells how many classes there are.
2285 Each register class has a number, which is the value of casting
2286 the class name to type @code{int}. The number serves as an index
2287 in many of the tables described below.
2290 @defmac N_REG_CLASSES
2291 The number of distinct register classes, defined as follows:
2294 #define N_REG_CLASSES (int) LIM_REG_CLASSES
2298 @defmac REG_CLASS_NAMES
2299 An initializer containing the names of the register classes as C string
2300 constants. These names are used in writing some of the debugging dumps.
2303 @defmac REG_CLASS_CONTENTS
2304 An initializer containing the contents of the register classes, as integers
2305 which are bit masks. The @var{n}th integer specifies the contents of class
2306 @var{n}. The way the integer @var{mask} is interpreted is that
2307 register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
2309 When the machine has more than 32 registers, an integer does not suffice.
2310 Then the integers are replaced by sub-initializers, braced groupings containing
2311 several integers. Each sub-initializer must be suitable as an initializer
2312 for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
2313 In this situation, the first integer in each sub-initializer corresponds to
2314 registers 0 through 31, the second integer to registers 32 through 63, and
2318 @defmac REGNO_REG_CLASS (@var{regno})
2319 A C expression whose value is a register class containing hard register
2320 @var{regno}. In general there is more than one such class; choose a class
2321 which is @dfn{minimal}, meaning that no smaller class also contains the
2325 @defmac BASE_REG_CLASS
2326 A macro whose definition is the name of the class to which a valid
2327 base register must belong. A base register is one used in an address
2328 which is the register value plus a displacement.
2331 @defmac MODE_BASE_REG_CLASS (@var{mode})
2332 This is a variation of the @code{BASE_REG_CLASS} macro which allows
2333 the selection of a base register in a mode dependent manner. If
2334 @var{mode} is VOIDmode then it should return the same value as
2335 @code{BASE_REG_CLASS}.
2338 @defmac INDEX_REG_CLASS
2339 A macro whose definition is the name of the class to which a valid
2340 index register must belong. An index register is one used in an
2341 address where its value is either multiplied by a scale factor or
2342 added to another register (as well as added to a displacement).
2345 @defmac CONSTRAINT_LEN (@var{char}, @var{str})
2346 For the constraint at the start of @var{str}, which starts with the letter
2347 @var{c}, return the length. This allows you to have register class /
2348 constant / extra constraints that are longer than a single letter;
2349 you don't need to define this macro if you can do with single-letter
2350 constraints only. The definition of this macro should use
2351 DEFAULT_CONSTRAINT_LEN for all the characters that you don't want
2352 to handle specially.
2353 There are some sanity checks in genoutput.c that check the constraint lengths
2354 for the md file, so you can also use this macro to help you while you are
2355 transitioning from a byzantine single-letter-constraint scheme: when you
2356 return a negative length for a constraint you want to re-use, genoutput
2357 will complain about every instance where it is used in the md file.
2360 @defmac REG_CLASS_FROM_LETTER (@var{char})
2361 A C expression which defines the machine-dependent operand constraint
2362 letters for register classes. If @var{char} is such a letter, the
2363 value should be the register class corresponding to it. Otherwise,
2364 the value should be @code{NO_REGS}. The register letter @samp{r},
2365 corresponding to class @code{GENERAL_REGS}, will not be passed
2366 to this macro; you do not need to handle it.
2369 @defmac REG_CLASS_FROM_CONSTRAINT (@var{char}, @var{str})
2370 Like @code{REG_CLASS_FROM_LETTER}, but you also get the constraint string
2371 passed in @var{str}, so that you can use suffixes to distinguish between
2375 @defmac REGNO_OK_FOR_BASE_P (@var{num})
2376 A C expression which is nonzero if register number @var{num} is
2377 suitable for use as a base register in operand addresses. It may be
2378 either a suitable hard register or a pseudo register that has been
2379 allocated such a hard register.
2382 @defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode})
2383 A C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that
2384 that expression may examine the mode of the memory reference in
2385 @var{mode}. You should define this macro if the mode of the memory
2386 reference affects whether a register may be used as a base register. If
2387 you define this macro, the compiler will use it instead of
2388 @code{REGNO_OK_FOR_BASE_P}.
2391 @defmac REGNO_OK_FOR_INDEX_P (@var{num})
2392 A C expression which is nonzero if register number @var{num} is
2393 suitable for use as an index register in operand addresses. It may be
2394 either a suitable hard register or a pseudo register that has been
2395 allocated such a hard register.
2397 The difference between an index register and a base register is that
2398 the index register may be scaled. If an address involves the sum of
2399 two registers, neither one of them scaled, then either one may be
2400 labeled the ``base'' and the other the ``index''; but whichever
2401 labeling is used must fit the machine's constraints of which registers
2402 may serve in each capacity. The compiler will try both labelings,
2403 looking for one that is valid, and will reload one or both registers
2404 only if neither labeling works.
2407 @defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
2408 A C expression that places additional restrictions on the register class
2409 to use when it is necessary to copy value @var{x} into a register in class
2410 @var{class}. The value is a register class; perhaps @var{class}, or perhaps
2411 another, smaller class. On many machines, the following definition is
2415 #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
2418 Sometimes returning a more restrictive class makes better code. For
2419 example, on the 68000, when @var{x} is an integer constant that is in range
2420 for a @samp{moveq} instruction, the value of this macro is always
2421 @code{DATA_REGS} as long as @var{class} includes the data registers.
2422 Requiring a data register guarantees that a @samp{moveq} will be used.
2424 If @var{x} is a @code{const_double}, by returning @code{NO_REGS}
2425 you can force @var{x} into a memory constant. This is useful on
2426 certain machines where immediate floating values cannot be loaded into
2427 certain kinds of registers.
2430 @defmac PREFERRED_OUTPUT_RELOAD_CLASS (@var{x}, @var{class})
2431 Like @code{PREFERRED_RELOAD_CLASS}, but for output reloads instead of
2432 input reloads. If you don't define this macro, the default is to use
2433 @var{class}, unchanged.
2436 @defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class})
2437 A C expression that places additional restrictions on the register class
2438 to use when it is necessary to be able to hold a value of mode
2439 @var{mode} in a reload register for which class @var{class} would
2442 Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when
2443 there are certain modes that simply can't go in certain reload classes.
2445 The value is a register class; perhaps @var{class}, or perhaps another,
2448 Don't define this macro unless the target machine has limitations which
2449 require the macro to do something nontrivial.
2452 @defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2453 @defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2454 @defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2455 Many machines have some registers that cannot be copied directly to or
2456 from memory or even from other types of registers. An example is the
2457 @samp{MQ} register, which on most machines, can only be copied to or
2458 from general registers, but not memory. Some machines allow copying all
2459 registers to and from memory, but require a scratch register for stores
2460 to some memory locations (e.g., those with symbolic address on the RT,
2461 and those with certain symbolic address on the SPARC when compiling
2462 PIC)@. In some cases, both an intermediate and a scratch register are
2465 You should define these macros to indicate to the reload phase that it may
2466 need to allocate at least one register for a reload in addition to the
2467 register to contain the data. Specifically, if copying @var{x} to a
2468 register @var{class} in @var{mode} requires an intermediate register,
2469 you should define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the
2470 largest register class all of whose registers can be used as
2471 intermediate registers or scratch registers.
2473 If copying a register @var{class} in @var{mode} to @var{x} requires an
2474 intermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS}
2475 should be defined to return the largest register class required. If the
2476 requirements for input and output reloads are the same, the macro
2477 @code{SECONDARY_RELOAD_CLASS} should be used instead of defining both
2480 The values returned by these macros are often @code{GENERAL_REGS}.
2481 Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x}
2482 can be directly copied to or from a register of @var{class} in
2483 @var{mode} without requiring a scratch register. Do not define this
2484 macro if it would always return @code{NO_REGS}.
2486 If a scratch register is required (either with or without an
2487 intermediate register), you should define patterns for
2488 @samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required
2489 (@pxref{Standard Names}. These patterns, which will normally be
2490 implemented with a @code{define_expand}, should be similar to the
2491 @samp{mov@var{m}} patterns, except that operand 2 is the scratch
2494 Define constraints for the reload register and scratch register that
2495 contain a single register class. If the original reload register (whose
2496 class is @var{class}) can meet the constraint given in the pattern, the
2497 value returned by these macros is used for the class of the scratch
2498 register. Otherwise, two additional reload registers are required.
2499 Their classes are obtained from the constraints in the insn pattern.
2501 @var{x} might be a pseudo-register or a @code{subreg} of a
2502 pseudo-register, which could either be in a hard register or in memory.
2503 Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2504 in memory and the hard register number if it is in a register.
2506 These macros should not be used in the case where a particular class of
2507 registers can only be copied to memory and not to another class of
2508 registers. In that case, secondary reload registers are not needed and
2509 would not be helpful. Instead, a stack location must be used to perform
2510 the copy and the @code{mov@var{m}} pattern should use memory as an
2511 intermediate storage. This case often occurs between floating-point and
2515 @defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m})
2516 Certain machines have the property that some registers cannot be copied
2517 to some other registers without using memory. Define this macro on
2518 those machines to be a C expression that is nonzero if objects of mode
2519 @var{m} in registers of @var{class1} can only be copied to registers of
2520 class @var{class2} by storing a register of @var{class1} into memory
2521 and loading that memory location into a register of @var{class2}.
2523 Do not define this macro if its value would always be zero.
2526 @defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode})
2527 Normally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler
2528 allocates a stack slot for a memory location needed for register copies.
2529 If this macro is defined, the compiler instead uses the memory location
2530 defined by this macro.
2532 Do not define this macro if you do not define
2533 @code{SECONDARY_MEMORY_NEEDED}.
2536 @defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode})
2537 When the compiler needs a secondary memory location to copy between two
2538 registers of mode @var{mode}, it normally allocates sufficient memory to
2539 hold a quantity of @code{BITS_PER_WORD} bits and performs the store and
2540 load operations in a mode that many bits wide and whose class is the
2541 same as that of @var{mode}.
2543 This is right thing to do on most machines because it ensures that all
2544 bits of the register are copied and prevents accesses to the registers
2545 in a narrower mode, which some machines prohibit for floating-point
2548 However, this default behavior is not correct on some machines, such as
2549 the DEC Alpha, that store short integers in floating-point registers
2550 differently than in integer registers. On those machines, the default
2551 widening will not work correctly and you must define this macro to
2552 suppress that widening in some cases. See the file @file{alpha.h} for
2555 Do not define this macro if you do not define
2556 @code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that
2557 is @code{BITS_PER_WORD} bits wide is correct for your machine.
2560 @defmac SMALL_REGISTER_CLASSES
2561 On some machines, it is risky to let hard registers live across arbitrary
2562 insns. Typically, these machines have instructions that require values
2563 to be in specific registers (like an accumulator), and reload will fail
2564 if the required hard register is used for another purpose across such an
2567 Define @code{SMALL_REGISTER_CLASSES} to be an expression with a nonzero
2568 value on these machines. When this macro has a nonzero value, the
2569 compiler will try to minimize the lifetime of hard registers.
2571 It is always safe to define this macro with a nonzero value, but if you
2572 unnecessarily define it, you will reduce the amount of optimizations
2573 that can be performed in some cases. If you do not define this macro
2574 with a nonzero value when it is required, the compiler will run out of
2575 spill registers and print a fatal error message. For most machines, you
2576 should not define this macro at all.
2579 @defmac CLASS_LIKELY_SPILLED_P (@var{class})
2580 A C expression whose value is nonzero if pseudos that have been assigned
2581 to registers of class @var{class} would likely be spilled because
2582 registers of @var{class} are needed for spill registers.
2584 The default value of this macro returns 1 if @var{class} has exactly one
2585 register and zero otherwise. On most machines, this default should be
2586 used. Only define this macro to some other expression if pseudos
2587 allocated by @file{local-alloc.c} end up in memory because their hard
2588 registers were needed for spill registers. If this macro returns nonzero
2589 for those classes, those pseudos will only be allocated by
2590 @file{global.c}, which knows how to reallocate the pseudo to another
2591 register. If there would not be another register available for
2592 reallocation, you should not change the definition of this macro since
2593 the only effect of such a definition would be to slow down register
2597 @defmac CLASS_MAX_NREGS (@var{class}, @var{mode})
2598 A C expression for the maximum number of consecutive registers
2599 of class @var{class} needed to hold a value of mode @var{mode}.
2601 This is closely related to the macro @code{HARD_REGNO_NREGS}. In fact,
2602 the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
2603 should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno},
2604 @var{mode})} for all @var{regno} values in the class @var{class}.
2606 This macro helps control the handling of multiple-word values
2610 @defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
2611 If defined, a C expression that returns nonzero for a @var{class} for which
2612 a change from mode @var{from} to mode @var{to} is invalid.
2614 For the example, loading 32-bit integer or floating-point objects into
2615 floating-point registers on the Alpha extends them to 64 bits.
2616 Therefore loading a 64-bit object and then storing it as a 32-bit object
2617 does not store the low-order 32 bits, as would be the case for a normal
2618 register. Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
2622 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
2623 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
2624 ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
2628 Three other special macros describe which operands fit which constraint
2631 @defmac CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
2632 A C expression that defines the machine-dependent operand constraint
2633 letters (@samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}) that specify
2634 particular ranges of integer values. If @var{c} is one of those
2635 letters, the expression should check that @var{value}, an integer, is in
2636 the appropriate range and return 1 if so, 0 otherwise. If @var{c} is
2637 not one of those letters, the value should be 0 regardless of
2641 @defmac CONST_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2642 Like @code{CONST_OK_FOR_LETTER_P}, but you also get the constraint
2643 string passed in @var{str}, so that you can use suffixes to distinguish
2644 between different variants.
2647 @defmac CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
2648 A C expression that defines the machine-dependent operand constraint
2649 letters that specify particular ranges of @code{const_double} values
2650 (@samp{G} or @samp{H}).
2652 If @var{c} is one of those letters, the expression should check that
2653 @var{value}, an RTX of code @code{const_double}, is in the appropriate
2654 range and return 1 if so, 0 otherwise. If @var{c} is not one of those
2655 letters, the value should be 0 regardless of @var{value}.
2657 @code{const_double} is used for all floating-point constants and for
2658 @code{DImode} fixed-point constants. A given letter can accept either
2659 or both kinds of values. It can use @code{GET_MODE} to distinguish
2660 between these kinds.
2663 @defmac CONST_DOUBLE_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2664 Like @code{CONST_DOUBLE_OK_FOR_LETTER_P}, but you also get the constraint
2665 string passed in @var{str}, so that you can use suffixes to distinguish
2666 between different variants.
2669 @defmac EXTRA_CONSTRAINT (@var{value}, @var{c})
2670 A C expression that defines the optional machine-dependent constraint
2671 letters that can be used to segregate specific types of operands, usually
2672 memory references, for the target machine. Any letter that is not
2673 elsewhere defined and not matched by @code{REG_CLASS_FROM_LETTER} /
2674 @code{REG_CLASS_FROM_CONSTRAINT}
2675 may be used. Normally this macro will not be defined.
2677 If it is required for a particular target machine, it should return 1
2678 if @var{value} corresponds to the operand type represented by the
2679 constraint letter @var{c}. If @var{c} is not defined as an extra
2680 constraint, the value returned should be 0 regardless of @var{value}.
2682 For example, on the ROMP, load instructions cannot have their output
2683 in r0 if the memory reference contains a symbolic address. Constraint
2684 letter @samp{Q} is defined as representing a memory address that does
2685 @emph{not} contain a symbolic address. An alternative is specified with
2686 a @samp{Q} constraint on the input and @samp{r} on the output. The next
2687 alternative specifies @samp{m} on the input and a register class that
2688 does not include r0 on the output.
2691 @defmac EXTRA_CONSTRAINT_STR (@var{value}, @var{c}, @var{str})
2692 Like @code{EXTRA_CONSTRAINT}, but you also get the constraint string passed
2693 in @var{str}, so that you can use suffixes to distinguish between different
2697 @defmac EXTRA_MEMORY_CONSTRAINT (@var{c}, @var{str})
2698 A C expression that defines the optional machine-dependent constraint
2699 letters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should
2700 be treated like memory constraints by the reload pass.
2702 It should return 1 if the operand type represented by the constraint
2703 at the start of @var{str}, the first letter of which is the letter @var{c},
2704 comprises a subset of all memory references including
2705 all those whose address is simply a base register. This allows the reload
2706 pass to reload an operand, if it does not directly correspond to the operand
2707 type of @var{c}, by copying its address into a base register.
2709 For example, on the S/390, some instructions do not accept arbitrary
2710 memory references, but only those that do not make use of an index
2711 register. The constraint letter @samp{Q} is defined via
2712 @code{EXTRA_CONSTRAINT} as representing a memory address of this type.
2713 If the letter @samp{Q} is marked as @code{EXTRA_MEMORY_CONSTRAINT},
2714 a @samp{Q} constraint can handle any memory operand, because the
2715 reload pass knows it can be reloaded by copying the memory address
2716 into a base register if required. This is analogous to the way
2717 a @samp{o} constraint can handle any memory operand.
2720 @defmac EXTRA_ADDRESS_CONSTRAINT (@var{c}, @var{str})
2721 A C expression that defines the optional machine-dependent constraint
2722 letters, amongst those accepted by @code{EXTRA_CONSTRAINT} /
2723 @code{EXTRA_CONSTRAINT_STR}, that should
2724 be treated like address constraints by the reload pass.
2726 It should return 1 if the operand type represented by the constraint
2727 at the start of @var{str}, which starts with the letter @var{c}, comprises
2728 a subset of all memory addresses including
2729 all those that consist of just a base register. This allows the reload
2730 pass to reload an operand, if it does not directly correspond to the operand
2731 type of @var{str}, by copying it into a base register.
2733 Any constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only
2734 be used with the @code{address_operand} predicate. It is treated
2735 analogously to the @samp{p} constraint.
2738 @node Stack and Calling
2739 @section Stack Layout and Calling Conventions
2740 @cindex calling conventions
2742 @c prevent bad page break with this line
2743 This describes the stack layout and calling conventions.
2747 * Exception Handling::
2752 * Register Arguments::
2754 * Aggregate Return::
2762 @subsection Basic Stack Layout
2763 @cindex stack frame layout
2764 @cindex frame layout
2766 @c prevent bad page break with this line
2767 Here is the basic stack layout.
2769 @defmac STACK_GROWS_DOWNWARD
2770 Define this macro if pushing a word onto the stack moves the stack
2771 pointer to a smaller address.
2773 When we say, ``define this macro if @dots{},'' it means that the
2774 compiler checks this macro only with @code{#ifdef} so the precise
2775 definition used does not matter.
2778 @defmac STACK_PUSH_CODE
2779 This macro defines the operation used when something is pushed
2780 on the stack. In RTL, a push operation will be
2781 @code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})}
2783 The choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC},
2784 and @code{POST_INC}. Which of these is correct depends on
2785 the stack direction and on whether the stack pointer points
2786 to the last item on the stack or whether it points to the
2787 space for the next item on the stack.
2789 The default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is
2790 defined, which is almost always right, and @code{PRE_INC} otherwise,
2791 which is often wrong.
2794 @defmac FRAME_GROWS_DOWNWARD
2795 Define this macro if the addresses of local variable slots are at negative
2796 offsets from the frame pointer.
2799 @defmac ARGS_GROW_DOWNWARD
2800 Define this macro if successive arguments to a function occupy decreasing
2801 addresses on the stack.
2804 @defmac STARTING_FRAME_OFFSET
2805 Offset from the frame pointer to the first local variable slot to be allocated.
2807 If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
2808 subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
2809 Otherwise, it is found by adding the length of the first slot to the
2810 value @code{STARTING_FRAME_OFFSET}.
2811 @c i'm not sure if the above is still correct.. had to change it to get
2812 @c rid of an overfull. --mew 2feb93
2815 @defmac STACK_ALIGNMENT_NEEDED
2816 Define to zero to disable final alignment of the stack during reload.
2817 The nonzero default for this macro is suitable for most ports.
2819 On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
2820 is a register save block following the local block that doesn't require
2821 alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
2822 stack alignment and do it in the backend.
2825 @defmac STACK_POINTER_OFFSET
2826 Offset from the stack pointer register to the first location at which
2827 outgoing arguments are placed. If not specified, the default value of
2828 zero is used. This is the proper value for most machines.
2830 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
2831 the first location at which outgoing arguments are placed.
2834 @defmac FIRST_PARM_OFFSET (@var{fundecl})
2835 Offset from the argument pointer register to the first argument's
2836 address. On some machines it may depend on the data type of the
2839 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
2840 the first argument's address.
2843 @defmac STACK_DYNAMIC_OFFSET (@var{fundecl})
2844 Offset from the stack pointer register to an item dynamically allocated
2845 on the stack, e.g., by @code{alloca}.
2847 The default value for this macro is @code{STACK_POINTER_OFFSET} plus the
2848 length of the outgoing arguments. The default is correct for most
2849 machines. See @file{function.c} for details.
2852 @defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
2853 A C expression whose value is RTL representing the address in a stack
2854 frame where the pointer to the caller's frame is stored. Assume that
2855 @var{frameaddr} is an RTL expression for the address of the stack frame
2858 If you don't define this macro, the default is to return the value
2859 of @var{frameaddr}---that is, the stack frame address is also the
2860 address of the stack word that points to the previous frame.
2863 @defmac SETUP_FRAME_ADDRESSES
2864 If defined, a C expression that produces the machine-specific code to
2865 setup the stack so that arbitrary frames can be accessed. For example,
2866 on the SPARC, we must flush all of the register windows to the stack
2867 before we can access arbitrary stack frames. You will seldom need to
2871 @defmac BUILTIN_SETJMP_FRAME_VALUE
2872 If defined, a C expression that contains an rtx that is used to store
2873 the address of the current frame into the built in @code{setjmp} buffer.
2874 The default value, @code{virtual_stack_vars_rtx}, is correct for most
2875 machines. One reason you may need to define this macro is if
2876 @code{hard_frame_pointer_rtx} is the appropriate value on your machine.
2879 @defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr})
2880 A C expression whose value is RTL representing the value of the return
2881 address for the frame @var{count} steps up from the current frame, after
2882 the prologue. @var{frameaddr} is the frame pointer of the @var{count}
2883 frame, or the frame pointer of the @var{count} @minus{} 1 frame if
2884 @code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined.
2886 The value of the expression must always be the correct address when
2887 @var{count} is zero, but may be @code{NULL_RTX} if there is not way to
2888 determine the return address of other frames.
2891 @defmac RETURN_ADDR_IN_PREVIOUS_FRAME
2892 Define this if the return address of a particular stack frame is accessed
2893 from the frame pointer of the previous stack frame.
2896 @defmac INCOMING_RETURN_ADDR_RTX
2897 A C expression whose value is RTL representing the location of the
2898 incoming return address at the beginning of any function, before the
2899 prologue. This RTL is either a @code{REG}, indicating that the return
2900 value is saved in @samp{REG}, or a @code{MEM} representing a location in
2903 You only need to define this macro if you want to support call frame
2904 debugging information like that provided by DWARF 2.
2906 If this RTL is a @code{REG}, you should also define
2907 @code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}.
2910 @defmac INCOMING_FRAME_SP_OFFSET
2911 A C expression whose value is an integer giving the offset, in bytes,
2912 from the value of the stack pointer register to the top of the stack
2913 frame at the beginning of any function, before the prologue. The top of
2914 the frame is defined to be the value of the stack pointer in the
2915 previous frame, just before the call instruction.
2917 You only need to define this macro if you want to support call frame
2918 debugging information like that provided by DWARF 2.
2921 @defmac ARG_POINTER_CFA_OFFSET (@var{fundecl})
2922 A C expression whose value is an integer giving the offset, in bytes,
2923 from the argument pointer to the canonical frame address (cfa). The
2924 final value should coincide with that calculated by
2925 @code{INCOMING_FRAME_SP_OFFSET}. Which is unfortunately not usable
2926 during virtual register instantiation.
2928 The default value for this macro is @code{FIRST_PARM_OFFSET (fundecl)},
2929 which is correct for most machines; in general, the arguments are found
2930 immediately before the stack frame. Note that this is not the case on
2931 some targets that save registers into the caller's frame, such as SPARC
2932 and rs6000, and so such targets need to define this macro.
2934 You only need to define this macro if the default is incorrect, and you
2935 want to support call frame debugging information like that provided by
2940 Define this macro if the stack size for the target is very small. This
2941 has the effect of disabling gcc's built-in @samp{alloca}, though
2942 @samp{__builtin_alloca} is not affected.
2945 @node Exception Handling
2946 @subsection Exception Handling Support
2947 @cindex exception handling
2949 @defmac EH_RETURN_DATA_REGNO (@var{N})
2950 A C expression whose value is the @var{N}th register number used for
2951 data by exception handlers, or @code{INVALID_REGNUM} if fewer than
2952 @var{N} registers are usable.
2954 The exception handling library routines communicate with the exception
2955 handlers via a set of agreed upon registers. Ideally these registers
2956 should be call-clobbered; it is possible to use call-saved registers,
2957 but may negatively impact code size. The target must support at least
2958 2 data registers, but should define 4 if there are enough free registers.
2960 You must define this macro if you want to support call frame exception
2961 handling like that provided by DWARF 2.
2964 @defmac EH_RETURN_STACKADJ_RTX
2965 A C expression whose value is RTL representing a location in which
2966 to store a stack adjustment to be applied before function return.
2967 This is used to unwind the stack to an exception handler's call frame.
2968 It will be assigned zero on code paths that return normally.
2970 Typically this is a call-clobbered hard register that is otherwise
2971 untouched by the epilogue, but could also be a stack slot.
2973 Do not define this macro if the stack pointer is saved and restored
2974 by the regular prolog and epilog code in the call frame itself; in
2975 this case, the exception handling library routines will update the
2976 stack location to be restored in place. Otherwise, you must define
2977 this macro if you want to support call frame exception handling like
2978 that provided by DWARF 2.
2981 @defmac EH_RETURN_HANDLER_RTX
2982 A C expression whose value is RTL representing a location in which
2983 to store the address of an exception handler to which we should
2984 return. It will not be assigned on code paths that return normally.
2986 Typically this is the location in the call frame at which the normal
2987 return address is stored. For targets that return by popping an
2988 address off the stack, this might be a memory address just below
2989 the @emph{target} call frame rather than inside the current call
2990 frame. If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
2991 been assigned, so it may be used to calculate the location of the
2994 Some targets have more complex requirements than storing to an
2995 address calculable during initial code generation. In that case
2996 the @code{eh_return} instruction pattern should be used instead.
2998 If you want to support call frame exception handling, you must
2999 define either this macro or the @code{eh_return} instruction pattern.
3002 @defmac RETURN_ADDR_OFFSET
3003 If defined, an integer-valued C expression for which rtl will be generated
3004 to add it to the exception handler address before it is searched in the
3005 exception handling tables, and to subtract it again from the address before
3006 using it to return to the exception handler.
3009 @defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global})
3010 This macro chooses the encoding of pointers embedded in the exception
3011 handling sections. If at all possible, this should be defined such
3012 that the exception handling section will not require dynamic relocations,
3013 and so may be read-only.
3015 @var{code} is 0 for data, 1 for code labels, 2 for function pointers.
3016 @var{global} is true if the symbol may be affected by dynamic relocations.
3017 The macro should return a combination of the @code{DW_EH_PE_*} defines
3018 as found in @file{dwarf2.h}.
3020 If this macro is not defined, pointers will not be encoded but
3021 represented directly.
3024 @defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done})
3025 This macro allows the target to emit whatever special magic is required
3026 to represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}.
3027 Generic code takes care of pc-relative and indirect encodings; this must
3028 be defined if the target uses text-relative or data-relative encodings.
3030 This is a C statement that branches to @var{done} if the format was
3031 handled. @var{encoding} is the format chosen, @var{size} is the number
3032 of bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF}
3036 @defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs}, @var{success})
3037 This macro allows the target to add cpu and operating system specific
3038 code to the call-frame unwinder for use when there is no unwind data
3039 available. The most common reason to implement this macro is to unwind
3040 through signal frames.
3042 This macro is called from @code{uw_frame_state_for} in @file{unwind-dw2.c}
3043 and @file{unwind-ia64.c}. @var{context} is an @code{_Unwind_Context};
3044 @var{fs} is an @code{_Unwind_FrameState}. Examine @code{context->ra}
3045 for the address of the code being executed and @code{context->cfa} for
3046 the stack pointer value. If the frame can be decoded, the register save
3047 addresses should be updated in @var{fs} and the macro should branch to
3048 @var{success}. If the frame cannot be decoded, the macro should do
3051 For proper signal handling in Java this macro is accompanied by
3052 @code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers.
3055 @node Stack Checking
3056 @subsection Specifying How Stack Checking is Done
3058 GCC will check that stack references are within the boundaries of
3059 the stack, if the @option{-fstack-check} is specified, in one of three ways:
3063 If the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC
3064 will assume that you have arranged for stack checking to be done at
3065 appropriate places in the configuration files, e.g., in
3066 @code{TARGET_ASM_FUNCTION_PROLOGUE}. GCC will do not other special
3070 If @code{STACK_CHECK_BUILTIN} is zero and you defined a named pattern
3071 called @code{check_stack} in your @file{md} file, GCC will call that
3072 pattern with one argument which is the address to compare the stack
3073 value against. You must arrange for this pattern to report an error if
3074 the stack pointer is out of range.
3077 If neither of the above are true, GCC will generate code to periodically
3078 ``probe'' the stack pointer using the values of the macros defined below.
3081 Normally, you will use the default values of these macros, so GCC
3082 will use the third approach.
3084 @defmac STACK_CHECK_BUILTIN
3085 A nonzero value if stack checking is done by the configuration files in a
3086 machine-dependent manner. You should define this macro if stack checking
3087 is require by the ABI of your machine or if you would like to have to stack
3088 checking in some more efficient way than GCC's portable approach.
3089 The default value of this macro is zero.
3092 @defmac STACK_CHECK_PROBE_INTERVAL
3093 An integer representing the interval at which GCC must generate stack
3094 probe instructions. You will normally define this macro to be no larger
3095 than the size of the ``guard pages'' at the end of a stack area. The
3096 default value of 4096 is suitable for most systems.
3099 @defmac STACK_CHECK_PROBE_LOAD
3100 A integer which is nonzero if GCC should perform the stack probe
3101 as a load instruction and zero if GCC should use a store instruction.
3102 The default is zero, which is the most efficient choice on most systems.
3105 @defmac STACK_CHECK_PROTECT
3106 The number of bytes of stack needed to recover from a stack overflow,
3107 for languages where such a recovery is supported. The default value of
3108 75 words should be adequate for most machines.
3111 @defmac STACK_CHECK_MAX_FRAME_SIZE
3112 The maximum size of a stack frame, in bytes. GCC will generate probe
3113 instructions in non-leaf functions to ensure at least this many bytes of
3114 stack are available. If a stack frame is larger than this size, stack
3115 checking will not be reliable and GCC will issue a warning. The
3116 default is chosen so that GCC only generates one instruction on most
3117 systems. You should normally not change the default value of this macro.
3120 @defmac STACK_CHECK_FIXED_FRAME_SIZE
3121 GCC uses this value to generate the above warning message. It
3122 represents the amount of fixed frame used by a function, not including
3123 space for any callee-saved registers, temporaries and user variables.
3124 You need only specify an upper bound for this amount and will normally
3125 use the default of four words.
3128 @defmac STACK_CHECK_MAX_VAR_SIZE
3129 The maximum size, in bytes, of an object that GCC will place in the
3130 fixed area of the stack frame when the user specifies
3131 @option{-fstack-check}.
3132 GCC computed the default from the values of the above macros and you will
3133 normally not need to override that default.
3137 @node Frame Registers
3138 @subsection Registers That Address the Stack Frame
3140 @c prevent bad page break with this line
3141 This discusses registers that address the stack frame.
3143 @defmac STACK_POINTER_REGNUM
3144 The register number of the stack pointer register, which must also be a
3145 fixed register according to @code{FIXED_REGISTERS}. On most machines,
3146 the hardware determines which register this is.
3149 @defmac FRAME_POINTER_REGNUM
3150 The register number of the frame pointer register, which is used to
3151 access automatic variables in the stack frame. On some machines, the
3152 hardware determines which register this is. On other machines, you can
3153 choose any register you wish for this purpose.
3156 @defmac HARD_FRAME_POINTER_REGNUM
3157 On some machines the offset between the frame pointer and starting
3158 offset of the automatic variables is not known until after register
3159 allocation has been done (for example, because the saved registers are
3160 between these two locations). On those machines, define
3161 @code{FRAME_POINTER_REGNUM} the number of a special, fixed register to
3162 be used internally until the offset is known, and define
3163 @code{HARD_FRAME_POINTER_REGNUM} to be the actual hard register number
3164 used for the frame pointer.
3166 You should define this macro only in the very rare circumstances when it
3167 is not possible to calculate the offset between the frame pointer and
3168 the automatic variables until after register allocation has been
3169 completed. When this macro is defined, you must also indicate in your
3170 definition of @code{ELIMINABLE_REGS} how to eliminate
3171 @code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM}
3172 or @code{STACK_POINTER_REGNUM}.
3174 Do not define this macro if it would be the same as
3175 @code{FRAME_POINTER_REGNUM}.
3178 @defmac ARG_POINTER_REGNUM
3179 The register number of the arg pointer register, which is used to access
3180 the function's argument list. On some machines, this is the same as the
3181 frame pointer register. On some machines, the hardware determines which
3182 register this is. On other machines, you can choose any register you
3183 wish for this purpose. If this is not the same register as the frame
3184 pointer register, then you must mark it as a fixed register according to
3185 @code{FIXED_REGISTERS}, or arrange to be able to eliminate it
3186 (@pxref{Elimination}).
3189 @defmac RETURN_ADDRESS_POINTER_REGNUM
3190 The register number of the return address pointer register, which is used to
3191 access the current function's return address from the stack. On some
3192 machines, the return address is not at a fixed offset from the frame
3193 pointer or stack pointer or argument pointer. This register can be defined
3194 to point to the return address on the stack, and then be converted by
3195 @code{ELIMINABLE_REGS} into either the frame pointer or stack pointer.
3197 Do not define this macro unless there is no other way to get the return
3198 address from the stack.
3201 @defmac STATIC_CHAIN_REGNUM
3202 @defmacx STATIC_CHAIN_INCOMING_REGNUM
3203 Register numbers used for passing a function's static chain pointer. If
3204 register windows are used, the register number as seen by the called
3205 function is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register
3206 number as seen by the calling function is @code{STATIC_CHAIN_REGNUM}. If
3207 these registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need
3210 The static chain register need not be a fixed register.
3212 If the static chain is passed in memory, these macros should not be
3213 defined; instead, the next two macros should be defined.
3216 @defmac STATIC_CHAIN
3217 @defmacx STATIC_CHAIN_INCOMING
3218 If the static chain is passed in memory, these macros provide rtx giving
3219 @code{mem} expressions that denote where they are stored.
3220 @code{STATIC_CHAIN} and @code{STATIC_CHAIN_INCOMING} give the locations
3221 as seen by the calling and called functions, respectively. Often the former
3222 will be at an offset from the stack pointer and the latter at an offset from
3225 @findex stack_pointer_rtx
3226 @findex frame_pointer_rtx
3227 @findex arg_pointer_rtx
3228 The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and
3229 @code{arg_pointer_rtx} will have been initialized prior to the use of these
3230 macros and should be used to refer to those items.
3232 If the static chain is passed in a register, the two previous macros should
3236 @defmac DWARF_FRAME_REGISTERS
3237 This macro specifies the maximum number of hard registers that can be
3238 saved in a call frame. This is used to size data structures used in
3239 DWARF2 exception handling.
3241 Prior to GCC 3.0, this macro was needed in order to establish a stable
3242 exception handling ABI in the face of adding new hard registers for ISA
3243 extensions. In GCC 3.0 and later, the EH ABI is insulated from changes
3244 in the number of hard registers. Nevertheless, this macro can still be
3245 used to reduce the runtime memory requirements of the exception handling
3246 routines, which can be substantial if the ISA contains a lot of
3247 registers that are not call-saved.
3249 If this macro is not defined, it defaults to
3250 @code{FIRST_PSEUDO_REGISTER}.
3253 @defmac PRE_GCC3_DWARF_FRAME_REGISTERS
3255 This macro is similar to @code{DWARF_FRAME_REGISTERS}, but is provided
3256 for backward compatibility in pre GCC 3.0 compiled code.
3258 If this macro is not defined, it defaults to
3259 @code{DWARF_FRAME_REGISTERS}.
3262 @defmac DWARF_REG_TO_UNWIND_COLUMN (@var{regno})
3264 Define this macro if the target's representation for dwarf registers
3265 is different than the internal representation for unwind column.
3266 Given a dwarf register, this macro should return the internal unwind
3267 column number to use instead.
3269 See the PowerPC's SPE target for an example.
3273 @subsection Eliminating Frame Pointer and Arg Pointer
3275 @c prevent bad page break with this line
3276 This is about eliminating the frame pointer and arg pointer.
3278 @defmac FRAME_POINTER_REQUIRED
3279 A C expression which is nonzero if a function must have and use a frame
3280 pointer. This expression is evaluated in the reload pass. If its value is
3281 nonzero the function will have a frame pointer.
3283 The expression can in principle examine the current function and decide
3284 according to the facts, but on most machines the constant 0 or the
3285 constant 1 suffices. Use 0 when the machine allows code to be generated
3286 with no frame pointer, and doing so saves some time or space. Use 1
3287 when there is no possible advantage to avoiding a frame pointer.
3289 In certain cases, the compiler does not know how to produce valid code
3290 without a frame pointer. The compiler recognizes those cases and
3291 automatically gives the function a frame pointer regardless of what
3292 @code{FRAME_POINTER_REQUIRED} says. You don't need to worry about
3295 In a function that does not require a frame pointer, the frame pointer
3296 register can be allocated for ordinary usage, unless you mark it as a
3297 fixed register. See @code{FIXED_REGISTERS} for more information.
3300 @findex get_frame_size
3301 @defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var})
3302 A C statement to store in the variable @var{depth-var} the difference
3303 between the frame pointer and the stack pointer values immediately after
3304 the function prologue. The value would be computed from information
3305 such as the result of @code{get_frame_size ()} and the tables of
3306 registers @code{regs_ever_live} and @code{call_used_regs}.
3308 If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and
3309 need not be defined. Otherwise, it must be defined even if
3310 @code{FRAME_POINTER_REQUIRED} is defined to always be true; in that
3311 case, you may set @var{depth-var} to anything.
3314 @defmac ELIMINABLE_REGS
3315 If defined, this macro specifies a table of register pairs used to
3316 eliminate unneeded registers that point into the stack frame. If it is not
3317 defined, the only elimination attempted by the compiler is to replace
3318 references to the frame pointer with references to the stack pointer.
3320 The definition of this macro is a list of structure initializations, each
3321 of which specifies an original and replacement register.
3323 On some machines, the position of the argument pointer is not known until
3324 the compilation is completed. In such a case, a separate hard register
3325 must be used for the argument pointer. This register can be eliminated by
3326 replacing it with either the frame pointer or the argument pointer,
3327 depending on whether or not the frame pointer has been eliminated.
3329 In this case, you might specify:
3331 #define ELIMINABLE_REGS \
3332 @{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \
3333 @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \
3334 @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@}
3337 Note that the elimination of the argument pointer with the stack pointer is
3338 specified first since that is the preferred elimination.
3341 @defmac CAN_ELIMINATE (@var{from-reg}, @var{to-reg})
3342 A C expression that returns nonzero if the compiler is allowed to try
3343 to replace register number @var{from-reg} with register number
3344 @var{to-reg}. This macro need only be defined if @code{ELIMINABLE_REGS}
3345 is defined, and will usually be the constant 1, since most of the cases
3346 preventing register elimination are things that the compiler already
3350 @defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var})
3351 This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It
3352 specifies the initial difference between the specified pair of
3353 registers. This macro must be defined if @code{ELIMINABLE_REGS} is
3357 @node Stack Arguments
3358 @subsection Passing Function Arguments on the Stack
3359 @cindex arguments on stack
3360 @cindex stack arguments
3362 The macros in this section control how arguments are passed
3363 on the stack. See the following section for other macros that
3364 control passing certain arguments in registers.
3366 @defmac PROMOTE_PROTOTYPES
3367 A C expression whose value is nonzero if an argument declared in
3368 a prototype as an integral type smaller than @code{int} should
3369 actually be passed as an @code{int}. In addition to avoiding
3370 errors in certain cases of mismatch, it also makes for better
3371 code on certain machines. If the macro is not defined in target
3372 header files, it defaults to 0.
3376 A C expression. If nonzero, push insns will be used to pass
3378 If the target machine does not have a push instruction, set it to zero.
3379 That directs GCC to use an alternate strategy: to
3380 allocate the entire argument block and then store the arguments into
3381 it. When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too.
3384 @defmac PUSH_ARGS_REVERSED
3385 A C expression. If nonzero, function arguments will be evaluated from
3386 last to first, rather than from first to last. If this macro is not
3387 defined, it defaults to @code{PUSH_ARGS} on targets where the stack
3388 and args grow in opposite directions, and 0 otherwise.
3391 @defmac PUSH_ROUNDING (@var{npushed})
3392 A C expression that is the number of bytes actually pushed onto the
3393 stack when an instruction attempts to push @var{npushed} bytes.
3395 On some machines, the definition
3398 #define PUSH_ROUNDING(BYTES) (BYTES)
3402 will suffice. But on other machines, instructions that appear
3403 to push one byte actually push two bytes in an attempt to maintain
3404 alignment. Then the definition should be
3407 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
3411 @findex current_function_outgoing_args_size
3412 @defmac ACCUMULATE_OUTGOING_ARGS
3413 A C expression. If nonzero, the maximum amount of space required for outgoing arguments
3414 will be computed and placed into the variable
3415 @code{current_function_outgoing_args_size}. No space will be pushed
3416 onto the stack for each call; instead, the function prologue should
3417 increase the stack frame size by this amount.
3419 Setting both @code{PUSH_ARGS} and @code{ACCUMULATE_OUTGOING_ARGS}
3423 @defmac REG_PARM_STACK_SPACE (@var{fndecl})
3424 Define this macro if functions should assume that stack space has been
3425 allocated for arguments even when their values are passed in
3428 The value of this macro is the size, in bytes, of the area reserved for
3429 arguments passed in registers for the function represented by @var{fndecl},
3430 which can be zero if GCC is calling a library function.
3432 This space can be allocated by the caller, or be a part of the
3433 machine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE} says
3436 @c above is overfull. not sure what to do. --mew 5feb93 did
3437 @c something, not sure if it looks good. --mew 10feb93
3439 @defmac MAYBE_REG_PARM_STACK_SPACE
3440 @defmacx FINAL_REG_PARM_STACK_SPACE (@var{const_size}, @var{var_size})
3441 Define these macros in addition to the one above if functions might
3442 allocate stack space for arguments even when their values are passed
3443 in registers. These should be used when the stack space allocated
3444 for arguments in registers is not a simple constant independent of the
3445 function declaration.
3447 The value of the first macro is the size, in bytes, of the area that
3448 we should initially assume would be reserved for arguments passed in registers.
3450 The value of the second macro is the actual size, in bytes, of the area
3451 that will be reserved for arguments passed in registers. This takes two
3452 arguments: an integer representing the number of bytes of fixed sized
3453 arguments on the stack, and a tree representing the number of bytes of
3454 variable sized arguments on the stack.
3456 When these macros are defined, @code{REG_PARM_STACK_SPACE} will only be
3457 called for libcall functions, the current function, or for a function
3458 being called when it is known that such stack space must be allocated.
3459 In each case this value can be easily computed.
3461 When deciding whether a called function needs such stack space, and how
3462 much space to reserve, GCC uses these two macros instead of
3463 @code{REG_PARM_STACK_SPACE}.
3466 @defmac OUTGOING_REG_PARM_STACK_SPACE
3467 Define this if it is the responsibility of the caller to allocate the area
3468 reserved for arguments passed in registers.
3470 If @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls
3471 whether the space for these arguments counts in the value of
3472 @code{current_function_outgoing_args_size}.
3475 @defmac STACK_PARMS_IN_REG_PARM_AREA
3476 Define this macro if @code{REG_PARM_STACK_SPACE} is defined, but the
3477 stack parameters don't skip the area specified by it.
3478 @c i changed this, makes more sens and it should have taken care of the
3479 @c overfull.. not as specific, tho. --mew 5feb93
3481 Normally, when a parameter is not passed in registers, it is placed on the
3482 stack beyond the @code{REG_PARM_STACK_SPACE} area. Defining this macro
3483 suppresses this behavior and causes the parameter to be passed on the
3484 stack in its natural location.
3487 @defmac RETURN_POPS_ARGS (@var{fundecl}, @var{funtype}, @var{stack-size})
3488 A C expression that should indicate the number of bytes of its own
3489 arguments that a function pops on returning, or 0 if the
3490 function pops no arguments and the caller must therefore pop them all
3491 after the function returns.
3493 @var{fundecl} is a C variable whose value is a tree node that describes
3494 the function in question. Normally it is a node of type
3495 @code{FUNCTION_DECL} that describes the declaration of the function.
3496 From this you can obtain the @code{DECL_ATTRIBUTES} of the function.
3498 @var{funtype} is a C variable whose value is a tree node that
3499 describes the function in question. Normally it is a node of type
3500 @code{FUNCTION_TYPE} that describes the data type of the function.
3501 From this it is possible to obtain the data types of the value and
3502 arguments (if known).
3504 When a call to a library function is being considered, @var{fundecl}
3505 will contain an identifier node for the library function. Thus, if
3506 you need to distinguish among various library functions, you can do so
3507 by their names. Note that ``library function'' in this context means
3508 a function used to perform arithmetic, whose name is known specially
3509 in the compiler and was not mentioned in the C code being compiled.
3511 @var{stack-size} is the number of bytes of arguments passed on the
3512 stack. If a variable number of bytes is passed, it is zero, and
3513 argument popping will always be the responsibility of the calling function.
3515 On the VAX, all functions always pop their arguments, so the definition
3516 of this macro is @var{stack-size}. On the 68000, using the standard
3517 calling convention, no functions pop their arguments, so the value of
3518 the macro is always 0 in this case. But an alternative calling
3519 convention is available in which functions that take a fixed number of
3520 arguments pop them but other functions (such as @code{printf}) pop
3521 nothing (the caller pops all). When this convention is in use,
3522 @var{funtype} is examined to determine whether a function takes a fixed
3523 number of arguments.
3526 @defmac CALL_POPS_ARGS (@var{cum})
3527 A C expression that should indicate the number of bytes a call sequence
3528 pops off the stack. It is added to the value of @code{RETURN_POPS_ARGS}
3529 when compiling a function call.
3531 @var{cum} is the variable in which all arguments to the called function
3532 have been accumulated.
3534 On certain architectures, such as the SH5, a call trampoline is used
3535 that pops certain registers off the stack, depending on the arguments
3536 that have been passed to the function. Since this is a property of the
3537 call site, not of the called function, @code{RETURN_POPS_ARGS} is not
3541 @node Register Arguments
3542 @subsection Passing Arguments in Registers
3543 @cindex arguments in registers
3544 @cindex registers arguments
3546 This section describes the macros which let you control how various
3547 types of arguments are passed in registers or how they are arranged in
3550 @defmac FUNCTION_ARG (@var{cum}, @var{mode}, @var{type}, @var{named})
3551 A C expression that controls whether a function argument is passed
3552 in a register, and which register.
3554 The arguments are @var{cum}, which summarizes all the previous
3555 arguments; @var{mode}, the machine mode of the argument; @var{type},
3556 the data type of the argument as a tree node or 0 if that is not known
3557 (which happens for C support library functions); and @var{named},
3558 which is 1 for an ordinary argument and 0 for nameless arguments that
3559 correspond to @samp{@dots{}} in the called function's prototype.
3560 @var{type} can be an incomplete type if a syntax error has previously
3563 The value of the expression is usually either a @code{reg} RTX for the
3564 hard register in which to pass the argument, or zero to pass the
3565 argument on the stack.
3567 For machines like the VAX and 68000, where normally all arguments are
3568 pushed, zero suffices as a definition.
3570 The value of the expression can also be a @code{parallel} RTX@. This is
3571 used when an argument is passed in multiple locations. The mode of the
3572 @code{parallel} should be the mode of the entire argument. The
3573 @code{parallel} holds any number of @code{expr_list} pairs; each one
3574 describes where part of the argument is passed. In each
3575 @code{expr_list} the first operand must be a @code{reg} RTX for the hard
3576 register in which to pass this part of the argument, and the mode of the
3577 register RTX indicates how large this part of the argument is. The
3578 second operand of the @code{expr_list} is a @code{const_int} which gives
3579 the offset in bytes into the entire argument of where this part starts.
3580 As a special exception the first @code{expr_list} in the @code{parallel}
3581 RTX may have a first operand of zero. This indicates that the entire
3582 argument is also stored on the stack.
3584 The last time this macro is called, it is called with @code{MODE ==
3585 VOIDmode}, and its result is passed to the @code{call} or @code{call_value}
3586 pattern as operands 2 and 3 respectively.
3588 @cindex @file{stdarg.h} and register arguments
3589 The usual way to make the ISO library @file{stdarg.h} work on a machine
3590 where some arguments are usually pass