1 @c Copyright (C) 1988,1989,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,
2 @c 2002, 2003, 2004, 2005 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 * Registers:: Naming and describing the hardware registers.
35 * Register Classes:: Defining the classes of hardware registers.
36 * Stack and Calling:: Defining which way the stack grows and by how much.
37 * Varargs:: Defining the varargs macros.
38 * Trampolines:: Code set up at run time to enter a nested function.
39 * Library Calls:: Controlling how library routines are implicitly called.
40 * Addressing Modes:: Defining addressing modes valid for memory operands.
41 * Condition Code:: Defining how insns update the condition code.
42 * Costs:: Defining relative costs of different operations.
43 * Scheduling:: Adjusting the behavior of the instruction scheduler.
44 * Sections:: Dividing storage into text, data, and other sections.
45 * PIC:: Macros for position independent code.
46 * Assembler Format:: Defining how to write insns and pseudo-ops to output.
47 * Debugging Info:: Defining the format of debugging output.
48 * Floating Point:: Handling floating point for cross-compilers.
49 * Mode Switching:: Insertion of mode-switching instructions.
50 * Target Attributes:: Defining target-specific uses of @code{__attribute__}.
51 * MIPS Coprocessors:: MIPS coprocessor support and how to customize it.
52 * PCH Target:: Validity checking for precompiled headers.
53 * C++ ABI:: Controlling C++ ABI changes.
54 * Misc:: Everything else.
57 @node Target Structure
58 @section The Global @code{targetm} Variable
60 @cindex target functions
62 @deftypevar {struct gcc_target} targetm
63 The target @file{.c} file must define the global @code{targetm} variable
64 which contains pointers to functions and data relating to the target
65 machine. The variable is declared in @file{target.h};
66 @file{target-def.h} defines the macro @code{TARGET_INITIALIZER} which is
67 used to initialize the variable, and macros for the default initializers
68 for elements of the structure. The @file{.c} file should override those
69 macros for which the default definition is inappropriate. For example:
72 #include "target-def.h"
74 /* @r{Initialize the GCC target structure.} */
76 #undef TARGET_COMP_TYPE_ATTRIBUTES
77 #define TARGET_COMP_TYPE_ATTRIBUTES @var{machine}_comp_type_attributes
79 struct gcc_target targetm = TARGET_INITIALIZER;
83 Where a macro should be defined in the @file{.c} file in this manner to
84 form part of the @code{targetm} structure, it is documented below as a
85 ``Target Hook'' with a prototype. Many macros will change in future
86 from being defined in the @file{.h} file to being part of the
87 @code{targetm} structure.
90 @section Controlling the Compilation Driver, @file{gcc}
92 @cindex controlling the compilation driver
94 @c prevent bad page break with this line
95 You can control the compilation driver.
97 @defmac SWITCH_TAKES_ARG (@var{char})
98 A C expression which determines whether the option @option{-@var{char}}
99 takes arguments. The value should be the number of arguments that
100 option takes--zero, for many options.
102 By default, this macro is defined as
103 @code{DEFAULT_SWITCH_TAKES_ARG}, which handles the standard options
104 properly. You need not define @code{SWITCH_TAKES_ARG} unless you
105 wish to add additional options which take arguments. Any redefinition
106 should call @code{DEFAULT_SWITCH_TAKES_ARG} and then check for
110 @defmac WORD_SWITCH_TAKES_ARG (@var{name})
111 A C expression which determines whether the option @option{-@var{name}}
112 takes arguments. The value should be the number of arguments that
113 option takes--zero, for many options. This macro rather than
114 @code{SWITCH_TAKES_ARG} is used for multi-character option names.
116 By default, this macro is defined as
117 @code{DEFAULT_WORD_SWITCH_TAKES_ARG}, which handles the standard options
118 properly. You need not define @code{WORD_SWITCH_TAKES_ARG} unless you
119 wish to add additional options which take arguments. Any redefinition
120 should call @code{DEFAULT_WORD_SWITCH_TAKES_ARG} and then check for
124 @defmac SWITCH_CURTAILS_COMPILATION (@var{char})
125 A C expression which determines whether the option @option{-@var{char}}
126 stops compilation before the generation of an executable. The value is
127 boolean, nonzero if the option does stop an executable from being
128 generated, zero otherwise.
130 By default, this macro is defined as
131 @code{DEFAULT_SWITCH_CURTAILS_COMPILATION}, which handles the standard
132 options properly. You need not define
133 @code{SWITCH_CURTAILS_COMPILATION} unless you wish to add additional
134 options which affect the generation of an executable. Any redefinition
135 should call @code{DEFAULT_SWITCH_CURTAILS_COMPILATION} and then check
136 for additional options.
139 @defmac SWITCHES_NEED_SPACES
140 A string-valued C expression which enumerates the options for which
141 the linker needs a space between the option and its argument.
143 If this macro is not defined, the default value is @code{""}.
146 @defmac TARGET_OPTION_TRANSLATE_TABLE
147 If defined, a list of pairs of strings, the first of which is a
148 potential command line target to the @file{gcc} driver program, and the
149 second of which is a space-separated (tabs and other whitespace are not
150 supported) list of options with which to replace the first option. The
151 target defining this list is responsible for assuring that the results
152 are valid. Replacement options may not be the @code{--opt} style, they
153 must be the @code{-opt} style. It is the intention of this macro to
154 provide a mechanism for substitution that affects the multilibs chosen,
155 such as one option that enables many options, some of which select
156 multilibs. Example nonsensical definition, where @option{-malt-abi},
157 @option{-EB}, and @option{-mspoo} cause different multilibs to be chosen:
160 #define TARGET_OPTION_TRANSLATE_TABLE \
161 @{ "-fast", "-march=fast-foo -malt-abi -I/usr/fast-foo" @}, \
162 @{ "-compat", "-EB -malign=4 -mspoo" @}
166 @defmac DRIVER_SELF_SPECS
167 A list of specs for the driver itself. It should be a suitable
168 initializer for an array of strings, with no surrounding braces.
170 The driver applies these specs to its own command line between loading
171 default @file{specs} files (but not command-line specified ones) and
172 choosing the multilib directory or running any subcommands. It
173 applies them in the order given, so each spec can depend on the
174 options added by earlier ones. It is also possible to remove options
175 using @samp{%<@var{option}} in the usual way.
177 This macro can be useful when a port has several interdependent target
178 options. It provides a way of standardizing the command line so
179 that the other specs are easier to write.
181 Do not define this macro if it does not need to do anything.
184 @defmac OPTION_DEFAULT_SPECS
185 A list of specs used to support configure-time default options (i.e.@:
186 @option{--with} options) in the driver. It should be a suitable initializer
187 for an array of structures, each containing two strings, without the
188 outermost pair of surrounding braces.
190 The first item in the pair is the name of the default. This must match
191 the code in @file{config.gcc} for the target. The second item is a spec
192 to apply if a default with this name was specified. The string
193 @samp{%(VALUE)} in the spec will be replaced by the value of the default
194 everywhere it occurs.
196 The driver will apply these specs to its own command line between loading
197 default @file{specs} files and processing @code{DRIVER_SELF_SPECS}, using
198 the same mechanism as @code{DRIVER_SELF_SPECS}.
200 Do not define this macro if it does not need to do anything.
204 A C string constant that tells the GCC driver program options to
205 pass to CPP@. It can also specify how to translate options you
206 give to GCC into options for GCC to pass to the CPP@.
208 Do not define this macro if it does not need to do anything.
211 @defmac CPLUSPLUS_CPP_SPEC
212 This macro is just like @code{CPP_SPEC}, but is used for C++, rather
213 than C@. If you do not define this macro, then the value of
214 @code{CPP_SPEC} (if any) will be used instead.
218 A C string constant that tells the GCC driver program options to
219 pass to @code{cc1}, @code{cc1plus}, @code{f771}, and the other language
221 It can also specify how to translate options you give to GCC into options
222 for GCC to pass to front ends.
224 Do not define this macro if it does not need to do anything.
228 A C string constant that tells the GCC driver program options to
229 pass to @code{cc1plus}. It can also specify how to translate options you
230 give to GCC into options for GCC to pass to the @code{cc1plus}.
232 Do not define this macro if it does not need to do anything.
233 Note that everything defined in CC1_SPEC is already passed to
234 @code{cc1plus} so there is no need to duplicate the contents of
235 CC1_SPEC in CC1PLUS_SPEC@.
239 A C string constant that tells the GCC driver program options to
240 pass to the assembler. It can also specify how to translate options
241 you give to GCC into options for GCC to pass to the assembler.
242 See the file @file{sun3.h} for an example of this.
244 Do not define this macro if it does not need to do anything.
247 @defmac ASM_FINAL_SPEC
248 A C string constant that tells the GCC driver program how to
249 run any programs which cleanup after the normal assembler.
250 Normally, this is not needed. See the file @file{mips.h} for
253 Do not define this macro if it does not need to do anything.
256 @defmac AS_NEEDS_DASH_FOR_PIPED_INPUT
257 Define this macro, with no value, if the driver should give the assembler
258 an argument consisting of a single dash, @option{-}, to instruct it to
259 read from its standard input (which will be a pipe connected to the
260 output of the compiler proper). This argument is given after any
261 @option{-o} option specifying the name of the output file.
263 If you do not define this macro, the assembler is assumed to read its
264 standard input if given no non-option arguments. If your assembler
265 cannot read standard input at all, use a @samp{%@{pipe:%e@}} construct;
266 see @file{mips.h} for instance.
270 A C string constant that tells the GCC driver program options to
271 pass to the linker. It can also specify how to translate options you
272 give to GCC into options for GCC to pass to the linker.
274 Do not define this macro if it does not need to do anything.
278 Another C string constant used much like @code{LINK_SPEC}. The difference
279 between the two is that @code{LIB_SPEC} is used at the end of the
280 command given to the linker.
282 If this macro is not defined, a default is provided that
283 loads the standard C library from the usual place. See @file{gcc.c}.
287 Another C string constant that tells the GCC driver program
288 how and when to place a reference to @file{libgcc.a} into the
289 linker command line. This constant is placed both before and after
290 the value of @code{LIB_SPEC}.
292 If this macro is not defined, the GCC driver provides a default that
293 passes the string @option{-lgcc} to the linker.
296 @defmac REAL_LIBGCC_SPEC
297 By default, if @code{ENABLE_SHARED_LIBGCC} is defined, the
298 @code{LIBGCC_SPEC} is not directly used by the driver program but is
299 instead modified to refer to different versions of @file{libgcc.a}
300 depending on the values of the command line flags @option{-static},
301 @option{-shared}, @option{-static-libgcc}, and @option{-shared-libgcc}. On
302 targets where these modifications are inappropriate, define
303 @code{REAL_LIBGCC_SPEC} instead. @code{REAL_LIBGCC_SPEC} tells the
304 driver how to place a reference to @file{libgcc} on the link command
305 line, but, unlike @code{LIBGCC_SPEC}, it is used unmodified.
308 @defmac USE_LD_AS_NEEDED
309 A macro that controls the modifications to @code{LIBGCC_SPEC}
310 mentioned in @code{REAL_LIBGCC_SPEC}. If nonzero, a spec will be
311 generated that uses --as-needed and the shared libgcc in place of the
312 static exception handler library, when linking without any of
313 @code{-static}, @code{-static-libgcc}, or @code{-shared-libgcc}.
317 If defined, this C string constant is added to @code{LINK_SPEC}.
318 When @code{USE_LD_AS_NEEDED} is zero or undefined, it also affects
319 the modifications to @code{LIBGCC_SPEC} mentioned in
320 @code{REAL_LIBGCC_SPEC}.
323 @defmac STARTFILE_SPEC
324 Another C string constant used much like @code{LINK_SPEC}. The
325 difference between the two is that @code{STARTFILE_SPEC} is used at
326 the very beginning of the command given to the linker.
328 If this macro is not defined, a default is provided that loads the
329 standard C startup file from the usual place. See @file{gcc.c}.
333 Another C string constant used much like @code{LINK_SPEC}. The
334 difference between the two is that @code{ENDFILE_SPEC} is used at
335 the very end of the command given to the linker.
337 Do not define this macro if it does not need to do anything.
340 @defmac THREAD_MODEL_SPEC
341 GCC @code{-v} will print the thread model GCC was configured to use.
342 However, this doesn't work on platforms that are multilibbed on thread
343 models, such as AIX 4.3. On such platforms, define
344 @code{THREAD_MODEL_SPEC} such that it evaluates to a string without
345 blanks that names one of the recognized thread models. @code{%*}, the
346 default value of this macro, will expand to the value of
347 @code{thread_file} set in @file{config.gcc}.
350 @defmac SYSROOT_SUFFIX_SPEC
351 Define this macro to add a suffix to the target sysroot when GCC is
352 configured with a sysroot. This will cause GCC to search for usr/lib,
353 et al, within sysroot+suffix.
356 @defmac SYSROOT_HEADERS_SUFFIX_SPEC
357 Define this macro to add a headers_suffix to the target sysroot when
358 GCC is configured with a sysroot. This will cause GCC to pass the
359 updated sysroot+headers_suffix to CPP, causing it to search for
360 usr/include, et al, within sysroot+headers_suffix.
364 Define this macro to provide additional specifications to put in the
365 @file{specs} file that can be used in various specifications like
368 The definition should be an initializer for an array of structures,
369 containing a string constant, that defines the specification name, and a
370 string constant that provides the specification.
372 Do not define this macro if it does not need to do anything.
374 @code{EXTRA_SPECS} is useful when an architecture contains several
375 related targets, which have various @code{@dots{}_SPECS} which are similar
376 to each other, and the maintainer would like one central place to keep
379 For example, the PowerPC System V.4 targets use @code{EXTRA_SPECS} to
380 define either @code{_CALL_SYSV} when the System V calling sequence is
381 used or @code{_CALL_AIX} when the older AIX-based calling sequence is
384 The @file{config/rs6000/rs6000.h} target file defines:
387 #define EXTRA_SPECS \
388 @{ "cpp_sysv_default", CPP_SYSV_DEFAULT @},
390 #define CPP_SYS_DEFAULT ""
393 The @file{config/rs6000/sysv.h} target file defines:
397 "%@{posix: -D_POSIX_SOURCE @} \
398 %@{mcall-sysv: -D_CALL_SYSV @} \
399 %@{!mcall-sysv: %(cpp_sysv_default) @} \
400 %@{msoft-float: -D_SOFT_FLOAT@} %@{mcpu=403: -D_SOFT_FLOAT@}"
402 #undef CPP_SYSV_DEFAULT
403 #define CPP_SYSV_DEFAULT "-D_CALL_SYSV"
406 while the @file{config/rs6000/eabiaix.h} target file defines
407 @code{CPP_SYSV_DEFAULT} as:
410 #undef CPP_SYSV_DEFAULT
411 #define CPP_SYSV_DEFAULT "-D_CALL_AIX"
415 @defmac LINK_LIBGCC_SPECIAL_1
416 Define this macro if the driver program should find the library
417 @file{libgcc.a}. If you do not define this macro, the driver program will pass
418 the argument @option{-lgcc} to tell the linker to do the search.
421 @defmac LINK_GCC_C_SEQUENCE_SPEC
422 The sequence in which libgcc and libc are specified to the linker.
423 By default this is @code{%G %L %G}.
426 @defmac LINK_COMMAND_SPEC
427 A C string constant giving the complete command line need to execute the
428 linker. When you do this, you will need to update your port each time a
429 change is made to the link command line within @file{gcc.c}. Therefore,
430 define this macro only if you need to completely redefine the command
431 line for invoking the linker and there is no other way to accomplish
432 the effect you need. Overriding this macro may be avoidable by overriding
433 @code{LINK_GCC_C_SEQUENCE_SPEC} instead.
436 @defmac LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
437 A nonzero value causes @command{collect2} to remove duplicate @option{-L@var{directory}} search
438 directories from linking commands. Do not give it a nonzero value if
439 removing duplicate search directories changes the linker's semantics.
442 @defmac MULTILIB_DEFAULTS
443 Define this macro as a C expression for the initializer of an array of
444 string to tell the driver program which options are defaults for this
445 target and thus do not need to be handled specially when using
446 @code{MULTILIB_OPTIONS}.
448 Do not define this macro if @code{MULTILIB_OPTIONS} is not defined in
449 the target makefile fragment or if none of the options listed in
450 @code{MULTILIB_OPTIONS} are set by default.
451 @xref{Target Fragment}.
454 @defmac RELATIVE_PREFIX_NOT_LINKDIR
455 Define this macro to tell @command{gcc} that it should only translate
456 a @option{-B} prefix into a @option{-L} linker option if the prefix
457 indicates an absolute file name.
460 @defmac MD_EXEC_PREFIX
461 If defined, this macro is an additional prefix to try after
462 @code{STANDARD_EXEC_PREFIX}. @code{MD_EXEC_PREFIX} is not searched
463 when the @option{-b} option is used, or the compiler is built as a cross
464 compiler. If you define @code{MD_EXEC_PREFIX}, then be sure to add it
465 to the list of directories used to find the assembler in @file{configure.in}.
468 @defmac STANDARD_STARTFILE_PREFIX
469 Define this macro as a C string constant if you wish to override the
470 standard choice of @code{libdir} as the default prefix to
471 try when searching for startup files such as @file{crt0.o}.
472 @code{STANDARD_STARTFILE_PREFIX} is not searched when the compiler
473 is built as a cross compiler.
476 @defmac STANDARD_STARTFILE_PREFIX_1
477 Define this macro as a C string constant if you wish to override the
478 standard choice of @code{/lib} as a prefix to try after the default prefix
479 when searching for startup files such as @file{crt0.o}.
480 @code{STANDARD_STARTFILE_PREFIX_1} is not searched when the compiler
481 is built as a cross compiler.
484 @defmac STANDARD_STARTFILE_PREFIX_2
485 Define this macro as a C string constant if you wish to override the
486 standard choice of @code{/lib} as yet another prefix to try after the
487 default prefix when searching for startup files such as @file{crt0.o}.
488 @code{STANDARD_STARTFILE_PREFIX_2} is not searched when the compiler
489 is built as a cross compiler.
492 @defmac MD_STARTFILE_PREFIX
493 If defined, this macro supplies an additional prefix to try after the
494 standard prefixes. @code{MD_EXEC_PREFIX} is not searched when the
495 @option{-b} option is used, or when the compiler is built as a cross
499 @defmac MD_STARTFILE_PREFIX_1
500 If defined, this macro supplies yet another prefix to try after the
501 standard prefixes. It is not searched when the @option{-b} option is
502 used, or when the compiler is built as a cross compiler.
505 @defmac INIT_ENVIRONMENT
506 Define this macro as a C string constant if you wish to set environment
507 variables for programs called by the driver, such as the assembler and
508 loader. The driver passes the value of this macro to @code{putenv} to
509 initialize the necessary environment variables.
512 @defmac LOCAL_INCLUDE_DIR
513 Define this macro as a C string constant if you wish to override the
514 standard choice of @file{/usr/local/include} as the default prefix to
515 try when searching for local header files. @code{LOCAL_INCLUDE_DIR}
516 comes before @code{SYSTEM_INCLUDE_DIR} in the search order.
518 Cross compilers do not search either @file{/usr/local/include} or its
522 @defmac MODIFY_TARGET_NAME
523 Define this macro if you wish to define command-line switches that
524 modify the default target name.
526 For each switch, you can include a string to be appended to the first
527 part of the configuration name or a string to be deleted from the
528 configuration name, if present. The definition should be an initializer
529 for an array of structures. Each array element should have three
530 elements: the switch name (a string constant, including the initial
531 dash), one of the enumeration codes @code{ADD} or @code{DELETE} to
532 indicate whether the string should be inserted or deleted, and the string
533 to be inserted or deleted (a string constant).
535 For example, on a machine where @samp{64} at the end of the
536 configuration name denotes a 64-bit target and you want the @option{-32}
537 and @option{-64} switches to select between 32- and 64-bit targets, you would
541 #define MODIFY_TARGET_NAME \
542 @{ @{ "-32", DELETE, "64"@}, \
543 @{"-64", ADD, "64"@}@}
547 @defmac SYSTEM_INCLUDE_DIR
548 Define this macro as a C string constant if you wish to specify a
549 system-specific directory to search for header files before the standard
550 directory. @code{SYSTEM_INCLUDE_DIR} comes before
551 @code{STANDARD_INCLUDE_DIR} in the search order.
553 Cross compilers do not use this macro and do not search the directory
557 @defmac STANDARD_INCLUDE_DIR
558 Define this macro as a C string constant if you wish to override the
559 standard choice of @file{/usr/include} as the default prefix to
560 try when searching for header files.
562 Cross compilers ignore this macro and do not search either
563 @file{/usr/include} or its replacement.
566 @defmac STANDARD_INCLUDE_COMPONENT
567 The ``component'' corresponding to @code{STANDARD_INCLUDE_DIR}.
568 See @code{INCLUDE_DEFAULTS}, below, for the description of components.
569 If you do not define this macro, no component is used.
572 @defmac INCLUDE_DEFAULTS
573 Define this macro if you wish to override the entire default search path
574 for include files. For a native compiler, the default search path
575 usually consists of @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR},
576 @code{SYSTEM_INCLUDE_DIR}, @code{GPLUSPLUS_INCLUDE_DIR}, and
577 @code{STANDARD_INCLUDE_DIR}. In addition, @code{GPLUSPLUS_INCLUDE_DIR}
578 and @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile},
579 and specify private search areas for GCC@. The directory
580 @code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs.
582 The definition should be an initializer for an array of structures.
583 Each array element should have four elements: the directory name (a
584 string constant), the component name (also a string constant), a flag
585 for C++-only directories,
586 and a flag showing that the includes in the directory don't need to be
587 wrapped in @code{extern @samp{C}} when compiling C++. Mark the end of
588 the array with a null element.
590 The component name denotes what GNU package the include file is part of,
591 if any, in all uppercase letters. For example, it might be @samp{GCC}
592 or @samp{BINUTILS}. If the package is part of a vendor-supplied
593 operating system, code the component name as @samp{0}.
595 For example, here is the definition used for VAX/VMS:
598 #define INCLUDE_DEFAULTS \
600 @{ "GNU_GXX_INCLUDE:", "G++", 1, 1@}, \
601 @{ "GNU_CC_INCLUDE:", "GCC", 0, 0@}, \
602 @{ "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0@}, \
609 Here is the order of prefixes tried for exec files:
613 Any prefixes specified by the user with @option{-B}.
616 The environment variable @code{GCC_EXEC_PREFIX}, if any.
619 The directories specified by the environment variable @code{COMPILER_PATH}.
622 The macro @code{STANDARD_EXEC_PREFIX}.
625 @file{/usr/lib/gcc/}.
628 The macro @code{MD_EXEC_PREFIX}, if any.
631 Here is the order of prefixes tried for startfiles:
635 Any prefixes specified by the user with @option{-B}.
638 The environment variable @code{GCC_EXEC_PREFIX}, if any.
641 The directories specified by the environment variable @code{LIBRARY_PATH}
642 (or port-specific name; native only, cross compilers do not use this).
645 The macro @code{STANDARD_EXEC_PREFIX}.
648 @file{/usr/lib/gcc/}.
651 The macro @code{MD_EXEC_PREFIX}, if any.
654 The macro @code{MD_STARTFILE_PREFIX}, if any.
657 The macro @code{STANDARD_STARTFILE_PREFIX}.
666 @node Run-time Target
667 @section Run-time Target Specification
668 @cindex run-time target specification
669 @cindex predefined macros
670 @cindex target specifications
672 @c prevent bad page break with this line
673 Here are run-time target specifications.
675 @defmac TARGET_CPU_CPP_BUILTINS ()
676 This function-like macro expands to a block of code that defines
677 built-in preprocessor macros and assertions for the target cpu, using
678 the functions @code{builtin_define}, @code{builtin_define_std} and
679 @code{builtin_assert}. When the front end
680 calls this macro it provides a trailing semicolon, and since it has
681 finished command line option processing your code can use those
684 @code{builtin_assert} takes a string in the form you pass to the
685 command-line option @option{-A}, such as @code{cpu=mips}, and creates
686 the assertion. @code{builtin_define} takes a string in the form
687 accepted by option @option{-D} and unconditionally defines the macro.
689 @code{builtin_define_std} takes a string representing the name of an
690 object-like macro. If it doesn't lie in the user's namespace,
691 @code{builtin_define_std} defines it unconditionally. Otherwise, it
692 defines a version with two leading underscores, and another version
693 with two leading and trailing underscores, and defines the original
694 only if an ISO standard was not requested on the command line. For
695 example, passing @code{unix} defines @code{__unix}, @code{__unix__}
696 and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
697 @code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
698 defines only @code{_ABI64}.
700 You can also test for the C dialect being compiled. The variable
701 @code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus}
702 or @code{clk_objective_c}. Note that if we are preprocessing
703 assembler, this variable will be @code{clk_c} but the function-like
704 macro @code{preprocessing_asm_p()} will return true, so you might want
705 to check for that first. If you need to check for strict ANSI, the
706 variable @code{flag_iso} can be used. The function-like macro
707 @code{preprocessing_trad_p()} can be used to check for traditional
711 @defmac TARGET_OS_CPP_BUILTINS ()
712 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
713 and is used for the target operating system instead.
716 @defmac TARGET_OBJFMT_CPP_BUILTINS ()
717 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
718 and is used for the target object format. @file{elfos.h} uses this
719 macro to define @code{__ELF__}, so you probably do not need to define
723 @deftypevar {extern int} target_flags
724 This variable is declared in @file{options.h}, which is included before
725 any target-specific headers.
728 @deftypevar {Target Hook} int TARGET_DEFAULT_TARGET_FLAGS
729 This variable specifies the initial value of @code{target_flags}.
730 Its default setting is 0.
733 @cindex optional hardware or system features
734 @cindex features, optional, in system conventions
736 @deftypefn {Target Hook} bool TARGET_HANDLE_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value})
737 This hook is called whenever the user specifies one of the
738 target-specific options described by the @file{.opt} definition files
739 (@pxref{Options}). It has the opportunity to do some option-specific
740 processing and should return true if the option is valid. The default
741 definition does nothing but return true.
743 @var{code} specifies the @code{OPT_@var{name}} enumeration value
744 associated with the selected option; @var{name} is just a rendering of
745 the option name in which non-alphanumeric characters are replaced by
746 underscores. @var{arg} specifies the string argument and is null if
747 no argument was given. If the option is flagged as a @code{UInteger}
748 (@pxref{Option properties}), @var{value} is the numeric value of the
749 argument. Otherwise @var{value} is 1 if the positive form of the
750 option was used and 0 if the ``no-'' form was.
753 @defmac TARGET_VERSION
754 This macro is a C statement to print on @code{stderr} a string
755 describing the particular machine description choice. Every machine
756 description should define @code{TARGET_VERSION}. For example:
760 #define TARGET_VERSION \
761 fprintf (stderr, " (68k, Motorola syntax)");
763 #define TARGET_VERSION \
764 fprintf (stderr, " (68k, MIT syntax)");
769 @defmac OVERRIDE_OPTIONS
770 Sometimes certain combinations of command options do not make sense on
771 a particular target machine. You can define a macro
772 @code{OVERRIDE_OPTIONS} to take account of this. This macro, if
773 defined, is executed once just after all the command options have been
776 Don't use this macro to turn on various extra optimizations for
777 @option{-O}. That is what @code{OPTIMIZATION_OPTIONS} is for.
780 @defmac OPTIMIZATION_OPTIONS (@var{level}, @var{size})
781 Some machines may desire to change what optimizations are performed for
782 various optimization levels. This macro, if defined, is executed once
783 just after the optimization level is determined and before the remainder
784 of the command options have been parsed. Values set in this macro are
785 used as the default values for the other command line options.
787 @var{level} is the optimization level specified; 2 if @option{-O2} is
788 specified, 1 if @option{-O} is specified, and 0 if neither is specified.
790 @var{size} is nonzero if @option{-Os} is specified and zero otherwise.
792 You should not use this macro to change options that are not
793 machine-specific. These should uniformly selected by the same
794 optimization level on all supported machines. Use this macro to enable
795 machine-specific optimizations.
797 @strong{Do not examine @code{write_symbols} in
798 this macro!} The debugging options are not supposed to alter the
802 @defmac CAN_DEBUG_WITHOUT_FP
803 Define this macro if debugging can be performed even without a frame
804 pointer. If this macro is defined, GCC will turn on the
805 @option{-fomit-frame-pointer} option whenever @option{-O} is specified.
808 @node Per-Function Data
809 @section Defining data structures for per-function information.
810 @cindex per-function data
811 @cindex data structures
813 If the target needs to store information on a per-function basis, GCC
814 provides a macro and a couple of variables to allow this. Note, just
815 using statics to store the information is a bad idea, since GCC supports
816 nested functions, so you can be halfway through encoding one function
817 when another one comes along.
819 GCC defines a data structure called @code{struct function} which
820 contains all of the data specific to an individual function. This
821 structure contains a field called @code{machine} whose type is
822 @code{struct machine_function *}, which can be used by targets to point
823 to their own specific data.
825 If a target needs per-function specific data it should define the type
826 @code{struct machine_function} and also the macro @code{INIT_EXPANDERS}.
827 This macro should be used to initialize the function pointer
828 @code{init_machine_status}. This pointer is explained below.
830 One typical use of per-function, target specific data is to create an
831 RTX to hold the register containing the function's return address. This
832 RTX can then be used to implement the @code{__builtin_return_address}
833 function, for level 0.
835 Note---earlier implementations of GCC used a single data area to hold
836 all of the per-function information. Thus when processing of a nested
837 function began the old per-function data had to be pushed onto a
838 stack, and when the processing was finished, it had to be popped off the
839 stack. GCC used to provide function pointers called
840 @code{save_machine_status} and @code{restore_machine_status} to handle
841 the saving and restoring of the target specific information. Since the
842 single data area approach is no longer used, these pointers are no
845 @defmac INIT_EXPANDERS
846 Macro called to initialize any target specific information. This macro
847 is called once per function, before generation of any RTL has begun.
848 The intention of this macro is to allow the initialization of the
849 function pointer @code{init_machine_status}.
852 @deftypevar {void (*)(struct function *)} init_machine_status
853 If this function pointer is non-@code{NULL} it will be called once per
854 function, before function compilation starts, in order to allow the
855 target to perform any target specific initialization of the
856 @code{struct function} structure. It is intended that this would be
857 used to initialize the @code{machine} of that structure.
859 @code{struct machine_function} structures are expected to be freed by GC@.
860 Generally, any memory that they reference must be allocated by using
861 @code{ggc_alloc}, including the structure itself.
865 @section Storage Layout
866 @cindex storage layout
868 Note that the definitions of the macros in this table which are sizes or
869 alignments measured in bits do not need to be constant. They can be C
870 expressions that refer to static variables, such as the @code{target_flags}.
871 @xref{Run-time Target}.
873 @defmac BITS_BIG_ENDIAN
874 Define this macro to have the value 1 if the most significant bit in a
875 byte has the lowest number; otherwise define it to have the value zero.
876 This means that bit-field instructions count from the most significant
877 bit. If the machine has no bit-field instructions, then this must still
878 be defined, but it doesn't matter which value it is defined to. This
879 macro need not be a constant.
881 This macro does not affect the way structure fields are packed into
882 bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}.
885 @defmac BYTES_BIG_ENDIAN
886 Define this macro to have the value 1 if the most significant byte in a
887 word has the lowest number. This macro need not be a constant.
890 @defmac WORDS_BIG_ENDIAN
891 Define this macro to have the value 1 if, in a multiword object, the
892 most significant word has the lowest number. This applies to both
893 memory locations and registers; GCC fundamentally assumes that the
894 order of words in memory is the same as the order in registers. This
895 macro need not be a constant.
898 @defmac LIBGCC2_WORDS_BIG_ENDIAN
899 Define this macro if @code{WORDS_BIG_ENDIAN} is not constant. This must be a
900 constant value with the same meaning as @code{WORDS_BIG_ENDIAN}, which will be
901 used only when compiling @file{libgcc2.c}. Typically the value will be set
902 based on preprocessor defines.
905 @defmac FLOAT_WORDS_BIG_ENDIAN
906 Define this macro to have the value 1 if @code{DFmode}, @code{XFmode} or
907 @code{TFmode} floating point numbers are stored in memory with the word
908 containing the sign bit at the lowest address; otherwise define it to
909 have the value 0. This macro need not be a constant.
911 You need not define this macro if the ordering is the same as for
915 @defmac BITS_PER_UNIT
916 Define this macro to be the number of bits in an addressable storage
917 unit (byte). If you do not define this macro the default is 8.
920 @defmac BITS_PER_WORD
921 Number of bits in a word. If you do not define this macro, the default
922 is @code{BITS_PER_UNIT * UNITS_PER_WORD}.
925 @defmac MAX_BITS_PER_WORD
926 Maximum number of bits in a word. If this is undefined, the default is
927 @code{BITS_PER_WORD}. Otherwise, it is the constant value that is the
928 largest value that @code{BITS_PER_WORD} can have at run-time.
931 @defmac UNITS_PER_WORD
932 Number of storage units in a word; normally the size of a general-purpose
933 register, a power of two from 1 or 8.
936 @defmac MIN_UNITS_PER_WORD
937 Minimum number of units in a word. If this is undefined, the default is
938 @code{UNITS_PER_WORD}. Otherwise, it is the constant value that is the
939 smallest value that @code{UNITS_PER_WORD} can have at run-time.
942 @defmac UNITS_PER_SIMD_WORD
943 Number of units in the vectors that the vectorizer can produce.
944 The default is equal to @code{UNITS_PER_WORD}, because the vectorizer
945 can do some transformations even in absence of specialized @acronym{SIMD}
950 Width of a pointer, in bits. You must specify a value no wider than the
951 width of @code{Pmode}. If it is not equal to the width of @code{Pmode},
952 you must define @code{POINTERS_EXTEND_UNSIGNED}. If you do not specify
953 a value the default is @code{BITS_PER_WORD}.
956 @defmac POINTERS_EXTEND_UNSIGNED
957 A C expression whose value is greater than zero if pointers that need to be
958 extended from being @code{POINTER_SIZE} bits wide to @code{Pmode} are to
959 be zero-extended and zero if they are to be sign-extended. If the value
960 is less then zero then there must be an "ptr_extend" instruction that
961 extends a pointer from @code{POINTER_SIZE} to @code{Pmode}.
963 You need not define this macro if the @code{POINTER_SIZE} is equal
964 to the width of @code{Pmode}.
967 @defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type})
968 A macro to update @var{m} and @var{unsignedp} when an object whose type
969 is @var{type} and which has the specified mode and signedness is to be
970 stored in a register. This macro is only called when @var{type} is a
973 On most RISC machines, which only have operations that operate on a full
974 register, define this macro to set @var{m} to @code{word_mode} if
975 @var{m} is an integer mode narrower than @code{BITS_PER_WORD}. In most
976 cases, only integer modes should be widened because wider-precision
977 floating-point operations are usually more expensive than their narrower
980 For most machines, the macro definition does not change @var{unsignedp}.
981 However, some machines, have instructions that preferentially handle
982 either signed or unsigned quantities of certain modes. For example, on
983 the DEC Alpha, 32-bit loads from memory and 32-bit add instructions
984 sign-extend the result to 64 bits. On such machines, set
985 @var{unsignedp} according to which kind of extension is more efficient.
987 Do not define this macro if it would never modify @var{m}.
990 @defmac PROMOTE_FUNCTION_MODE
991 Like @code{PROMOTE_MODE}, but is applied to outgoing function arguments or
992 function return values, as specified by @code{TARGET_PROMOTE_FUNCTION_ARGS}
993 and @code{TARGET_PROMOTE_FUNCTION_RETURN}, respectively.
995 The default is @code{PROMOTE_MODE}.
998 @deftypefn {Target Hook} bool TARGET_PROMOTE_FUNCTION_ARGS (tree @var{fntype})
999 This target hook should return @code{true} if the promotion described by
1000 @code{PROMOTE_FUNCTION_MODE} should be done for outgoing function
1004 @deftypefn {Target Hook} bool TARGET_PROMOTE_FUNCTION_RETURN (tree @var{fntype})
1005 This target hook should return @code{true} if the promotion described by
1006 @code{PROMOTE_FUNCTION_MODE} should be done for the return value of
1009 If this target hook returns @code{true}, @code{FUNCTION_VALUE} must
1010 perform the same promotions done by @code{PROMOTE_FUNCTION_MODE}.
1013 @defmac PARM_BOUNDARY
1014 Normal alignment required for function parameters on the stack, in
1015 bits. All stack parameters receive at least this much alignment
1016 regardless of data type. On most machines, this is the same as the
1020 @defmac STACK_BOUNDARY
1021 Define this macro to the minimum alignment enforced by hardware for the
1022 stack pointer on this machine. The definition is a C expression for the
1023 desired alignment (measured in bits). This value is used as a default
1024 if @code{PREFERRED_STACK_BOUNDARY} is not defined. On most machines,
1025 this should be the same as @code{PARM_BOUNDARY}.
1028 @defmac PREFERRED_STACK_BOUNDARY
1029 Define this macro if you wish to preserve a certain alignment for the
1030 stack pointer, greater than what the hardware enforces. The definition
1031 is a C expression for the desired alignment (measured in bits). This
1032 macro must evaluate to a value equal to or larger than
1033 @code{STACK_BOUNDARY}.
1036 @defmac FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
1037 A C expression that evaluates true if @code{PREFERRED_STACK_BOUNDARY} is
1038 not guaranteed by the runtime and we should emit code to align the stack
1039 at the beginning of @code{main}.
1041 @cindex @code{PUSH_ROUNDING}, interaction with @code{PREFERRED_STACK_BOUNDARY}
1042 If @code{PUSH_ROUNDING} is not defined, the stack will always be aligned
1043 to the specified boundary. If @code{PUSH_ROUNDING} is defined and specifies
1044 a less strict alignment than @code{PREFERRED_STACK_BOUNDARY}, the stack may
1045 be momentarily unaligned while pushing arguments.
1048 @defmac FUNCTION_BOUNDARY
1049 Alignment required for a function entry point, in bits.
1052 @defmac BIGGEST_ALIGNMENT
1053 Biggest alignment that any data type can require on this machine, in bits.
1056 @defmac MINIMUM_ATOMIC_ALIGNMENT
1057 If defined, the smallest alignment, in bits, that can be given to an
1058 object that can be referenced in one operation, without disturbing any
1059 nearby object. Normally, this is @code{BITS_PER_UNIT}, but may be larger
1060 on machines that don't have byte or half-word store operations.
1063 @defmac BIGGEST_FIELD_ALIGNMENT
1064 Biggest alignment that any structure or union field can require on this
1065 machine, in bits. If defined, this overrides @code{BIGGEST_ALIGNMENT} for
1066 structure and union fields only, unless the field alignment has been set
1067 by the @code{__attribute__ ((aligned (@var{n})))} construct.
1070 @defmac ADJUST_FIELD_ALIGN (@var{field}, @var{computed})
1071 An expression for the alignment of a structure field @var{field} if the
1072 alignment computed in the usual way (including applying of
1073 @code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the
1074 alignment) is @var{computed}. It overrides alignment only if the
1075 field alignment has not been set by the
1076 @code{__attribute__ ((aligned (@var{n})))} construct.
1079 @defmac MAX_OFILE_ALIGNMENT
1080 Biggest alignment supported by the object file format of this machine.
1081 Use this macro to limit the alignment which can be specified using the
1082 @code{__attribute__ ((aligned (@var{n})))} construct. If not defined,
1083 the default value is @code{BIGGEST_ALIGNMENT}.
1086 @defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
1087 If defined, a C expression to compute the alignment for a variable in
1088 the static store. @var{type} is the data type, and @var{basic-align} is
1089 the alignment that the object would ordinarily have. The value of this
1090 macro is used instead of that alignment to align the object.
1092 If this macro is not defined, then @var{basic-align} is used.
1095 One use of this macro is to increase alignment of medium-size data to
1096 make it all fit in fewer cache lines. Another is to cause character
1097 arrays to be word-aligned so that @code{strcpy} calls that copy
1098 constants to character arrays can be done inline.
1101 @defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
1102 If defined, a C expression to compute the alignment given to a constant
1103 that is being placed in memory. @var{constant} is the constant and
1104 @var{basic-align} is the alignment that the object would ordinarily
1105 have. The value of this macro is used instead of that alignment to
1108 If this macro is not defined, then @var{basic-align} is used.
1110 The typical use of this macro is to increase alignment for string
1111 constants to be word aligned so that @code{strcpy} calls that copy
1112 constants can be done inline.
1115 @defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
1116 If defined, a C expression to compute the alignment for a variable in
1117 the local store. @var{type} is the data type, and @var{basic-align} is
1118 the alignment that the object would ordinarily have. The value of this
1119 macro is used instead of that alignment to align the object.
1121 If this macro is not defined, then @var{basic-align} is used.
1123 One use of this macro is to increase alignment of medium-size data to
1124 make it all fit in fewer cache lines.
1127 @defmac EMPTY_FIELD_BOUNDARY
1128 Alignment in bits to be given to a structure bit-field that follows an
1129 empty field such as @code{int : 0;}.
1131 If @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro.
1134 @defmac STRUCTURE_SIZE_BOUNDARY
1135 Number of bits which any structure or union's size must be a multiple of.
1136 Each structure or union's size is rounded up to a multiple of this.
1138 If you do not define this macro, the default is the same as
1139 @code{BITS_PER_UNIT}.
1142 @defmac STRICT_ALIGNMENT
1143 Define this macro to be the value 1 if instructions will fail to work
1144 if given data not on the nominal alignment. If instructions will merely
1145 go slower in that case, define this macro as 0.
1148 @defmac PCC_BITFIELD_TYPE_MATTERS
1149 Define this if you wish to imitate the way many other C compilers handle
1150 alignment of bit-fields and the structures that contain them.
1152 The behavior is that the type written for a named bit-field (@code{int},
1153 @code{short}, or other integer type) imposes an alignment for the entire
1154 structure, as if the structure really did contain an ordinary field of
1155 that type. In addition, the bit-field is placed within the structure so
1156 that it would fit within such a field, not crossing a boundary for it.
1158 Thus, on most machines, a named bit-field whose type is written as
1159 @code{int} would not cross a four-byte boundary, and would force
1160 four-byte alignment for the whole structure. (The alignment used may
1161 not be four bytes; it is controlled by the other alignment parameters.)
1163 An unnamed bit-field will not affect the alignment of the containing
1166 If the macro is defined, its definition should be a C expression;
1167 a nonzero value for the expression enables this behavior.
1169 Note that if this macro is not defined, or its value is zero, some
1170 bit-fields may cross more than one alignment boundary. The compiler can
1171 support such references if there are @samp{insv}, @samp{extv}, and
1172 @samp{extzv} insns that can directly reference memory.
1174 The other known way of making bit-fields work is to define
1175 @code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}.
1176 Then every structure can be accessed with fullwords.
1178 Unless the machine has bit-field instructions or you define
1179 @code{STRUCTURE_SIZE_BOUNDARY} that way, you must define
1180 @code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value.
1182 If your aim is to make GCC use the same conventions for laying out
1183 bit-fields as are used by another compiler, here is how to investigate
1184 what the other compiler does. Compile and run this program:
1203 printf ("Size of foo1 is %d\n",
1204 sizeof (struct foo1));
1205 printf ("Size of foo2 is %d\n",
1206 sizeof (struct foo2));
1211 If this prints 2 and 5, then the compiler's behavior is what you would
1212 get from @code{PCC_BITFIELD_TYPE_MATTERS}.
1215 @defmac BITFIELD_NBYTES_LIMITED
1216 Like @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited
1217 to aligning a bit-field within the structure.
1220 @deftypefn {Target Hook} bool TARGET_ALIGN_ANON_BITFIELDS (void)
1221 When @code{PCC_BITFIELD_TYPE_MATTERS} is true this hook will determine
1222 whether unnamed bitfields affect the alignment of the containing
1223 structure. The hook should return true if the structure should inherit
1224 the alignment requirements of an unnamed bitfield's type.
1227 @defmac MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode})
1228 Return 1 if a structure or array containing @var{field} should be accessed using
1231 If @var{field} is the only field in the structure, @var{mode} is its
1232 mode, otherwise @var{mode} is VOIDmode. @var{mode} is provided in the
1233 case where structures of one field would require the structure's mode to
1234 retain the field's mode.
1236 Normally, this is not needed. See the file @file{c4x.h} for an example
1237 of how to use this macro to prevent a structure having a floating point
1238 field from being accessed in an integer mode.
1241 @defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified})
1242 Define this macro as an expression for the alignment of a type (given
1243 by @var{type} as a tree node) if the alignment computed in the usual
1244 way is @var{computed} and the alignment explicitly specified was
1247 The default is to use @var{specified} if it is larger; otherwise, use
1248 the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT}
1251 @defmac MAX_FIXED_MODE_SIZE
1252 An integer expression for the size in bits of the largest integer
1253 machine mode that should actually be used. All integer machine modes of
1254 this size or smaller can be used for structures and unions with the
1255 appropriate sizes. If this macro is undefined, @code{GET_MODE_BITSIZE
1256 (DImode)} is assumed.
1259 @defmac STACK_SAVEAREA_MODE (@var{save_level})
1260 If defined, an expression of type @code{enum machine_mode} that
1261 specifies the mode of the save area operand of a
1262 @code{save_stack_@var{level}} named pattern (@pxref{Standard Names}).
1263 @var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or
1264 @code{SAVE_NONLOCAL} and selects which of the three named patterns is
1265 having its mode specified.
1267 You need not define this macro if it always returns @code{Pmode}. You
1268 would most commonly define this macro if the
1269 @code{save_stack_@var{level}} patterns need to support both a 32- and a
1273 @defmac STACK_SIZE_MODE
1274 If defined, an expression of type @code{enum machine_mode} that
1275 specifies the mode of the size increment operand of an
1276 @code{allocate_stack} named pattern (@pxref{Standard Names}).
1278 You need not define this macro if it always returns @code{word_mode}.
1279 You would most commonly define this macro if the @code{allocate_stack}
1280 pattern needs to support both a 32- and a 64-bit mode.
1283 @defmac TARGET_FLOAT_FORMAT
1284 A code distinguishing the floating point format of the target machine.
1285 There are four defined values:
1288 @item IEEE_FLOAT_FORMAT
1289 This code indicates IEEE floating point. It is the default; there is no
1290 need to define @code{TARGET_FLOAT_FORMAT} when the format is IEEE@.
1292 @item VAX_FLOAT_FORMAT
1293 This code indicates the ``F float'' (for @code{float}) and ``D float''
1294 or ``G float'' formats (for @code{double}) used on the VAX and PDP-11@.
1296 @item IBM_FLOAT_FORMAT
1297 This code indicates the format used on the IBM System/370.
1299 @item C4X_FLOAT_FORMAT
1300 This code indicates the format used on the TMS320C3x/C4x.
1303 If your target uses a floating point format other than these, you must
1304 define a new @var{name}_FLOAT_FORMAT code for it, and add support for
1305 it to @file{real.c}.
1307 The ordering of the component words of floating point values stored in
1308 memory is controlled by @code{FLOAT_WORDS_BIG_ENDIAN}.
1311 @defmac MODE_HAS_NANS (@var{mode})
1312 When defined, this macro should be true if @var{mode} has a NaN
1313 representation. The compiler assumes that NaNs are not equal to
1314 anything (including themselves) and that addition, subtraction,
1315 multiplication and division all return NaNs when one operand is
1318 By default, this macro is true if @var{mode} is a floating-point
1319 mode and the target floating-point format is IEEE@.
1322 @defmac MODE_HAS_INFINITIES (@var{mode})
1323 This macro should be true if @var{mode} can represent infinity. At
1324 present, the compiler uses this macro to decide whether @samp{x - x}
1325 is always defined. By default, the macro is true when @var{mode}
1326 is a floating-point mode and the target format is IEEE@.
1329 @defmac MODE_HAS_SIGNED_ZEROS (@var{mode})
1330 True if @var{mode} distinguishes between positive and negative zero.
1331 The rules are expected to follow the IEEE standard:
1335 @samp{x + x} has the same sign as @samp{x}.
1338 If the sum of two values with opposite sign is zero, the result is
1339 positive for all rounding modes expect towards @minus{}infinity, for
1340 which it is negative.
1343 The sign of a product or quotient is negative when exactly one
1344 of the operands is negative.
1347 The default definition is true if @var{mode} is a floating-point
1348 mode and the target format is IEEE@.
1351 @defmac MODE_HAS_SIGN_DEPENDENT_ROUNDING (@var{mode})
1352 If defined, this macro should be true for @var{mode} if it has at
1353 least one rounding mode in which @samp{x} and @samp{-x} can be
1354 rounded to numbers of different magnitude. Two such modes are
1355 towards @minus{}infinity and towards +infinity.
1357 The default definition of this macro is true if @var{mode} is
1358 a floating-point mode and the target format is IEEE@.
1361 @defmac ROUND_TOWARDS_ZERO
1362 If defined, this macro should be true if the prevailing rounding
1363 mode is towards zero. A true value has the following effects:
1367 @code{MODE_HAS_SIGN_DEPENDENT_ROUNDING} will be false for all modes.
1370 @file{libgcc.a}'s floating-point emulator will round towards zero
1371 rather than towards nearest.
1374 The compiler's floating-point emulator will round towards zero after
1375 doing arithmetic, and when converting from the internal float format to
1379 The macro does not affect the parsing of string literals. When the
1380 primary rounding mode is towards zero, library functions like
1381 @code{strtod} might still round towards nearest, and the compiler's
1382 parser should behave like the target's @code{strtod} where possible.
1384 Not defining this macro is equivalent to returning zero.
1387 @defmac LARGEST_EXPONENT_IS_NORMAL (@var{size})
1388 This macro should return true if floats with @var{size}
1389 bits do not have a NaN or infinity representation, but use the largest
1390 exponent for normal numbers instead.
1392 Defining this macro to true for @var{size} causes @code{MODE_HAS_NANS}
1393 and @code{MODE_HAS_INFINITIES} to be false for @var{size}-bit modes.
1394 It also affects the way @file{libgcc.a} and @file{real.c} emulate
1395 floating-point arithmetic.
1397 The default definition of this macro returns false for all sizes.
1400 @deftypefn {Target Hook} bool TARGET_VECTOR_OPAQUE_P (tree @var{type})
1401 This target hook should return @code{true} a vector is opaque. That
1402 is, if no cast is needed when copying a vector value of type
1403 @var{type} into another vector lvalue of the same size. Vector opaque
1404 types cannot be initialized. The default is that there are no such
1408 @deftypefn {Target Hook} bool TARGET_MS_BITFIELD_LAYOUT_P (tree @var{record_type})
1409 This target hook returns @code{true} if bit-fields in the given
1410 @var{record_type} are to be laid out following the rules of Microsoft
1411 Visual C/C++, namely: (i) a bit-field won't share the same storage
1412 unit with the previous bit-field if their underlying types have
1413 different sizes, and the bit-field will be aligned to the highest
1414 alignment of the underlying types of itself and of the previous
1415 bit-field; (ii) a zero-sized bit-field will affect the alignment of
1416 the whole enclosing structure, even if it is unnamed; except that
1417 (iii) a zero-sized bit-field will be disregarded unless it follows
1418 another bit-field of nonzero size. If this hook returns @code{true},
1419 other macros that control bit-field layout are ignored.
1421 When a bit-field is inserted into a packed record, the whole size
1422 of the underlying type is used by one or more same-size adjacent
1423 bit-fields (that is, if its long:3, 32 bits is used in the record,
1424 and any additional adjacent long bit-fields are packed into the same
1425 chunk of 32 bits. However, if the size changes, a new field of that
1426 size is allocated). In an unpacked record, this is the same as using
1427 alignment, but not equivalent when packing.
1429 If both MS bit-fields and @samp{__attribute__((packed))} are used,
1430 the latter will take precedence. If @samp{__attribute__((packed))} is
1431 used on a single field when MS bit-fields are in use, it will take
1432 precedence for that field, but the alignment of the rest of the structure
1433 may affect its placement.
1436 @deftypefn {Target Hook} {const char *} TARGET_MANGLE_FUNDAMENTAL_TYPE (tree @var{type})
1437 If your target defines any fundamental types, define this hook to
1438 return the appropriate encoding for these types as part of a C++
1439 mangled name. The @var{type} argument is the tree structure
1440 representing the type to be mangled. The hook may be applied to trees
1441 which are not target-specific fundamental types; it should return
1442 @code{NULL} for all such types, as well as arguments it does not
1443 recognize. If the return value is not @code{NULL}, it must point to
1444 a statically-allocated string constant.
1446 Target-specific fundamental types might be new fundamental types or
1447 qualified versions of ordinary fundamental types. Encode new
1448 fundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name}
1449 is the name used for the type in source code, and @var{n} is the
1450 length of @var{name} in decimal. Encode qualified versions of
1451 ordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where
1452 @var{name} is the name used for the type qualifier in source code,
1453 @var{n} is the length of @var{name} as above, and @var{code} is the
1454 code used to represent the unqualified version of this type. (See
1455 @code{write_builtin_type} in @file{cp/mangle.c} for the list of
1456 codes.) In both cases the spaces are for clarity; do not include any
1457 spaces in your string.
1459 The default version of this hook always returns @code{NULL}, which is
1460 appropriate for a target that does not define any new fundamental
1465 @section Layout of Source Language Data Types
1467 These macros define the sizes and other characteristics of the standard
1468 basic data types used in programs being compiled. Unlike the macros in
1469 the previous section, these apply to specific features of C and related
1470 languages, rather than to fundamental aspects of storage layout.
1472 @defmac INT_TYPE_SIZE
1473 A C expression for the size in bits of the type @code{int} on the
1474 target machine. If you don't define this, the default is one word.
1477 @defmac SHORT_TYPE_SIZE
1478 A C expression for the size in bits of the type @code{short} on the
1479 target machine. If you don't define this, the default is half a word.
1480 (If this would be less than one storage unit, it is rounded up to one
1484 @defmac LONG_TYPE_SIZE
1485 A C expression for the size in bits of the type @code{long} on the
1486 target machine. If you don't define this, the default is one word.
1489 @defmac ADA_LONG_TYPE_SIZE
1490 On some machines, the size used for the Ada equivalent of the type
1491 @code{long} by a native Ada compiler differs from that used by C@. In
1492 that situation, define this macro to be a C expression to be used for
1493 the size of that type. If you don't define this, the default is the
1494 value of @code{LONG_TYPE_SIZE}.
1497 @defmac LONG_LONG_TYPE_SIZE
1498 A C expression for the size in bits of the type @code{long long} on the
1499 target machine. If you don't define this, the default is two
1500 words. If you want to support GNU Ada on your machine, the value of this
1501 macro must be at least 64.
1504 @defmac CHAR_TYPE_SIZE
1505 A C expression for the size in bits of the type @code{char} on the
1506 target machine. If you don't define this, the default is
1507 @code{BITS_PER_UNIT}.
1510 @defmac BOOL_TYPE_SIZE
1511 A C expression for the size in bits of the C++ type @code{bool} and
1512 C99 type @code{_Bool} on the target machine. If you don't define
1513 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
1516 @defmac FLOAT_TYPE_SIZE
1517 A C expression for the size in bits of the type @code{float} on the
1518 target machine. If you don't define this, the default is one word.
1521 @defmac DOUBLE_TYPE_SIZE
1522 A C expression for the size in bits of the type @code{double} on the
1523 target machine. If you don't define this, the default is two
1527 @defmac LONG_DOUBLE_TYPE_SIZE
1528 A C expression for the size in bits of the type @code{long double} on
1529 the target machine. If you don't define this, the default is two
1533 @defmac LIBGCC2_LONG_DOUBLE_TYPE_SIZE
1534 Define this macro if @code{LONG_DOUBLE_TYPE_SIZE} is not constant or
1535 if you want routines in @file{libgcc2.a} for a size other than
1536 @code{LONG_DOUBLE_TYPE_SIZE}. If you don't define this, the
1537 default is @code{LONG_DOUBLE_TYPE_SIZE}.
1540 @defmac LIBGCC2_HAS_DF_MODE
1541 Define this macro if neither @code{LIBGCC2_DOUBLE_TYPE_SIZE} nor
1542 @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is
1543 @code{DFmode} but you want @code{DFmode} routines in @file{libgcc2.a}
1544 anyway. If you don't define this and either @code{LIBGCC2_DOUBLE_TYPE_SIZE}
1545 or @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64 then the default is 1,
1549 @defmac LIBGCC2_HAS_XF_MODE
1550 Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1551 @code{XFmode} but you want @code{XFmode} routines in @file{libgcc2.a}
1552 anyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1553 is 80 then the default is 1, otherwise it is 0.
1556 @defmac LIBGCC2_HAS_TF_MODE
1557 Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1558 @code{TFmode} but you want @code{TFmode} routines in @file{libgcc2.a}
1559 anyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1560 is 128 then the default is 1, otherwise it is 0.
1563 @defmac TARGET_FLT_EVAL_METHOD
1564 A C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h},
1565 assuming, if applicable, that the floating-point control word is in its
1566 default state. If you do not define this macro the value of
1567 @code{FLT_EVAL_METHOD} will be zero.
1570 @defmac WIDEST_HARDWARE_FP_SIZE
1571 A C expression for the size in bits of the widest floating-point format
1572 supported by the hardware. If you define this macro, you must specify a
1573 value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
1574 If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
1578 @defmac DEFAULT_SIGNED_CHAR
1579 An expression whose value is 1 or 0, according to whether the type
1580 @code{char} should be signed or unsigned by default. The user can
1581 always override this default with the options @option{-fsigned-char}
1582 and @option{-funsigned-char}.
1585 @deftypefn {Target Hook} bool TARGET_DEFAULT_SHORT_ENUMS (void)
1586 This target hook should return true if the compiler should give an
1587 @code{enum} type only as many bytes as it takes to represent the range
1588 of possible values of that type. It should return false if all
1589 @code{enum} types should be allocated like @code{int}.
1591 The default is to return false.
1595 A C expression for a string describing the name of the data type to use
1596 for size values. The typedef name @code{size_t} is defined using the
1597 contents of the string.
1599 The string can contain more than one keyword. If so, separate them with
1600 spaces, and write first any length keyword, then @code{unsigned} if
1601 appropriate, and finally @code{int}. The string must exactly match one
1602 of the data type names defined in the function
1603 @code{init_decl_processing} in the file @file{c-decl.c}. You may not
1604 omit @code{int} or change the order---that would cause the compiler to
1607 If you don't define this macro, the default is @code{"long unsigned
1611 @defmac PTRDIFF_TYPE
1612 A C expression for a string describing the name of the data type to use
1613 for the result of subtracting two pointers. The typedef name
1614 @code{ptrdiff_t} is defined using the contents of the string. See
1615 @code{SIZE_TYPE} above for more information.
1617 If you don't define this macro, the default is @code{"long int"}.
1621 A C expression for a string describing the name of the data type to use
1622 for wide characters. The typedef name @code{wchar_t} is defined using
1623 the contents of the string. See @code{SIZE_TYPE} above for more
1626 If you don't define this macro, the default is @code{"int"}.
1629 @defmac WCHAR_TYPE_SIZE
1630 A C expression for the size in bits of the data type for wide
1631 characters. This is used in @code{cpp}, which cannot make use of
1636 A C expression for a string describing the name of the data type to
1637 use for wide characters passed to @code{printf} and returned from
1638 @code{getwc}. The typedef name @code{wint_t} is defined using the
1639 contents of the string. See @code{SIZE_TYPE} above for more
1642 If you don't define this macro, the default is @code{"unsigned int"}.
1646 A C expression for a string describing the name of the data type that
1647 can represent any value of any standard or extended signed integer type.
1648 The typedef name @code{intmax_t} is defined using the contents of the
1649 string. See @code{SIZE_TYPE} above for more information.
1651 If you don't define this macro, the default is the first of
1652 @code{"int"}, @code{"long int"}, or @code{"long long int"} that has as
1653 much precision as @code{long long int}.
1656 @defmac UINTMAX_TYPE
1657 A C expression for a string describing the name of the data type that
1658 can represent any value of any standard or extended unsigned integer
1659 type. The typedef name @code{uintmax_t} is defined using the contents
1660 of the string. See @code{SIZE_TYPE} above for more information.
1662 If you don't define this macro, the default is the first of
1663 @code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long
1664 unsigned int"} that has as much precision as @code{long long unsigned
1668 @defmac TARGET_PTRMEMFUNC_VBIT_LOCATION
1669 The C++ compiler represents a pointer-to-member-function with a struct
1676 ptrdiff_t vtable_index;
1683 The C++ compiler must use one bit to indicate whether the function that
1684 will be called through a pointer-to-member-function is virtual.
1685 Normally, we assume that the low-order bit of a function pointer must
1686 always be zero. Then, by ensuring that the vtable_index is odd, we can
1687 distinguish which variant of the union is in use. But, on some
1688 platforms function pointers can be odd, and so this doesn't work. In
1689 that case, we use the low-order bit of the @code{delta} field, and shift
1690 the remainder of the @code{delta} field to the left.
1692 GCC will automatically make the right selection about where to store
1693 this bit using the @code{FUNCTION_BOUNDARY} setting for your platform.
1694 However, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY}
1695 set such that functions always start at even addresses, but the lowest
1696 bit of pointers to functions indicate whether the function at that
1697 address is in ARM or Thumb mode. If this is the case of your
1698 architecture, you should define this macro to
1699 @code{ptrmemfunc_vbit_in_delta}.
1701 In general, you should not have to define this macro. On architectures
1702 in which function addresses are always even, according to
1703 @code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to
1704 @code{ptrmemfunc_vbit_in_pfn}.
1707 @defmac TARGET_VTABLE_USES_DESCRIPTORS
1708 Normally, the C++ compiler uses function pointers in vtables. This
1709 macro allows the target to change to use ``function descriptors''
1710 instead. Function descriptors are found on targets for whom a
1711 function pointer is actually a small data structure. Normally the
1712 data structure consists of the actual code address plus a data
1713 pointer to which the function's data is relative.
1715 If vtables are used, the value of this macro should be the number
1716 of words that the function descriptor occupies.
1719 @defmac TARGET_VTABLE_ENTRY_ALIGN
1720 By default, the vtable entries are void pointers, the so the alignment
1721 is the same as pointer alignment. The value of this macro specifies
1722 the alignment of the vtable entry in bits. It should be defined only
1723 when special alignment is necessary. */
1726 @defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE
1727 There are a few non-descriptor entries in the vtable at offsets below
1728 zero. If these entries must be padded (say, to preserve the alignment
1729 specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
1730 of words in each data entry.
1734 @section Register Usage
1735 @cindex register usage
1737 This section explains how to describe what registers the target machine
1738 has, and how (in general) they can be used.
1740 The description of which registers a specific instruction can use is
1741 done with register classes; see @ref{Register Classes}. For information
1742 on using registers to access a stack frame, see @ref{Frame Registers}.
1743 For passing values in registers, see @ref{Register Arguments}.
1744 For returning values in registers, see @ref{Scalar Return}.
1747 * Register Basics:: Number and kinds of registers.
1748 * Allocation Order:: Order in which registers are allocated.
1749 * Values in Registers:: What kinds of values each reg can hold.
1750 * Leaf Functions:: Renumbering registers for leaf functions.
1751 * Stack Registers:: Handling a register stack such as 80387.
1754 @node Register Basics
1755 @subsection Basic Characteristics of Registers
1757 @c prevent bad page break with this line
1758 Registers have various characteristics.
1760 @defmac FIRST_PSEUDO_REGISTER
1761 Number of hardware registers known to the compiler. They receive
1762 numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
1763 pseudo register's number really is assigned the number
1764 @code{FIRST_PSEUDO_REGISTER}.
1767 @defmac FIXED_REGISTERS
1768 @cindex fixed register
1769 An initializer that says which registers are used for fixed purposes
1770 all throughout the compiled code and are therefore not available for
1771 general allocation. These would include the stack pointer, the frame
1772 pointer (except on machines where that can be used as a general
1773 register when no frame pointer is needed), the program counter on
1774 machines where that is considered one of the addressable registers,
1775 and any other numbered register with a standard use.
1777 This information is expressed as a sequence of numbers, separated by
1778 commas and surrounded by braces. The @var{n}th number is 1 if
1779 register @var{n} is fixed, 0 otherwise.
1781 The table initialized from this macro, and the table initialized by
1782 the following one, may be overridden at run time either automatically,
1783 by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
1784 the user with the command options @option{-ffixed-@var{reg}},
1785 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}.
1788 @defmac CALL_USED_REGISTERS
1789 @cindex call-used register
1790 @cindex call-clobbered register
1791 @cindex call-saved register
1792 Like @code{FIXED_REGISTERS} but has 1 for each register that is
1793 clobbered (in general) by function calls as well as for fixed
1794 registers. This macro therefore identifies the registers that are not
1795 available for general allocation of values that must live across
1798 If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
1799 automatically saves it on function entry and restores it on function
1800 exit, if the register is used within the function.
1803 @defmac CALL_REALLY_USED_REGISTERS
1804 @cindex call-used register
1805 @cindex call-clobbered register
1806 @cindex call-saved register
1807 Like @code{CALL_USED_REGISTERS} except this macro doesn't require
1808 that the entire set of @code{FIXED_REGISTERS} be included.
1809 (@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}).
1810 This macro is optional. If not specified, it defaults to the value
1811 of @code{CALL_USED_REGISTERS}.
1814 @defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
1815 @cindex call-used register
1816 @cindex call-clobbered register
1817 @cindex call-saved register
1818 A C expression that is nonzero if it is not permissible to store a
1819 value of mode @var{mode} in hard register number @var{regno} across a
1820 call without some part of it being clobbered. For most machines this
1821 macro need not be defined. It is only required for machines that do not
1822 preserve the entire contents of a register across a call.
1826 @findex call_used_regs
1829 @findex reg_class_contents
1830 @defmac CONDITIONAL_REGISTER_USAGE
1831 Zero or more C statements that may conditionally modify five variables
1832 @code{fixed_regs}, @code{call_used_regs}, @code{global_regs},
1833 @code{reg_names}, and @code{reg_class_contents}, to take into account
1834 any dependence of these register sets on target flags. The first three
1835 of these are of type @code{char []} (interpreted as Boolean vectors).
1836 @code{global_regs} is a @code{const char *[]}, and
1837 @code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is
1838 called, @code{fixed_regs}, @code{call_used_regs},
1839 @code{reg_class_contents}, and @code{reg_names} have been initialized
1840 from @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS},
1841 @code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively.
1842 @code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}},
1843 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}
1844 command options have been applied.
1846 You need not define this macro if it has no work to do.
1848 @cindex disabling certain registers
1849 @cindex controlling register usage
1850 If the usage of an entire class of registers depends on the target
1851 flags, you may indicate this to GCC by using this macro to modify
1852 @code{fixed_regs} and @code{call_used_regs} to 1 for each of the
1853 registers in the classes which should not be used by GCC@. Also define
1854 the macro @code{REG_CLASS_FROM_LETTER} / @code{REG_CLASS_FROM_CONSTRAINT}
1855 to return @code{NO_REGS} if it
1856 is called with a letter for a class that shouldn't be used.
1858 (However, if this class is not included in @code{GENERAL_REGS} and all
1859 of the insn patterns whose constraints permit this class are
1860 controlled by target switches, then GCC will automatically avoid using
1861 these registers when the target switches are opposed to them.)
1864 @defmac INCOMING_REGNO (@var{out})
1865 Define this macro if the target machine has register windows. This C
1866 expression returns the register number as seen by the called function
1867 corresponding to the register number @var{out} as seen by the calling
1868 function. Return @var{out} if register number @var{out} is not an
1872 @defmac OUTGOING_REGNO (@var{in})
1873 Define this macro if the target machine has register windows. This C
1874 expression returns the register number as seen by the calling function
1875 corresponding to the register number @var{in} as seen by the called
1876 function. Return @var{in} if register number @var{in} is not an inbound
1880 @defmac LOCAL_REGNO (@var{regno})
1881 Define this macro if the target machine has register windows. This C
1882 expression returns true if the register is call-saved but is in the
1883 register window. Unlike most call-saved registers, such registers
1884 need not be explicitly restored on function exit or during non-local
1889 If the program counter has a register number, define this as that
1890 register number. Otherwise, do not define it.
1893 @node Allocation Order
1894 @subsection Order of Allocation of Registers
1895 @cindex order of register allocation
1896 @cindex register allocation order
1898 @c prevent bad page break with this line
1899 Registers are allocated in order.
1901 @defmac REG_ALLOC_ORDER
1902 If defined, an initializer for a vector of integers, containing the
1903 numbers of hard registers in the order in which GCC should prefer
1904 to use them (from most preferred to least).
1906 If this macro is not defined, registers are used lowest numbered first
1907 (all else being equal).
1909 One use of this macro is on machines where the highest numbered
1910 registers must always be saved and the save-multiple-registers
1911 instruction supports only sequences of consecutive registers. On such
1912 machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists
1913 the highest numbered allocable register first.
1916 @defmac ORDER_REGS_FOR_LOCAL_ALLOC
1917 A C statement (sans semicolon) to choose the order in which to allocate
1918 hard registers for pseudo-registers local to a basic block.
1920 Store the desired register order in the array @code{reg_alloc_order}.
1921 Element 0 should be the register to allocate first; element 1, the next
1922 register; and so on.
1924 The macro body should not assume anything about the contents of
1925 @code{reg_alloc_order} before execution of the macro.
1927 On most machines, it is not necessary to define this macro.
1930 @node Values in Registers
1931 @subsection How Values Fit in Registers
1933 This section discusses the macros that describe which kinds of values
1934 (specifically, which machine modes) each register can hold, and how many
1935 consecutive registers are needed for a given mode.
1937 @defmac HARD_REGNO_NREGS (@var{regno}, @var{mode})
1938 A C expression for the number of consecutive hard registers, starting
1939 at register number @var{regno}, required to hold a value of mode
1942 On a machine where all registers are exactly one word, a suitable
1943 definition of this macro is
1946 #define HARD_REGNO_NREGS(REGNO, MODE) \
1947 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
1952 @defmac REGMODE_NATURAL_SIZE (@var{mode})
1953 Define this macro if the natural size of registers that hold values
1954 of mode @var{mode} is not the word size. It is a C expression that
1955 should give the natural size in bytes for the specified mode. It is
1956 used by the register allocator to try to optimize its results. This
1957 happens for example on SPARC 64-bit where the natural size of
1958 floating-point registers is still 32-bit.
1961 @defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
1962 A C expression that is nonzero if it is permissible to store a value
1963 of mode @var{mode} in hard register number @var{regno} (or in several
1964 registers starting with that one). For a machine where all registers
1965 are equivalent, a suitable definition is
1968 #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
1971 You need not include code to check for the numbers of fixed registers,
1972 because the allocation mechanism considers them to be always occupied.
1974 @cindex register pairs
1975 On some machines, double-precision values must be kept in even/odd
1976 register pairs. You can implement that by defining this macro to reject
1977 odd register numbers for such modes.
1979 The minimum requirement for a mode to be OK in a register is that the
1980 @samp{mov@var{mode}} instruction pattern support moves between the
1981 register and other hard register in the same class and that moving a
1982 value into the register and back out not alter it.
1984 Since the same instruction used to move @code{word_mode} will work for
1985 all narrower integer modes, it is not necessary on any machine for
1986 @code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided
1987 you define patterns @samp{movhi}, etc., to take advantage of this. This
1988 is useful because of the interaction between @code{HARD_REGNO_MODE_OK}
1989 and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes
1992 Many machines have special registers for floating point arithmetic.
1993 Often people assume that floating point machine modes are allowed only
1994 in floating point registers. This is not true. Any registers that
1995 can hold integers can safely @emph{hold} a floating point machine
1996 mode, whether or not floating arithmetic can be done on it in those
1997 registers. Integer move instructions can be used to move the values.
1999 On some machines, though, the converse is true: fixed-point machine
2000 modes may not go in floating registers. This is true if the floating
2001 registers normalize any value stored in them, because storing a
2002 non-floating value there would garble it. In this case,
2003 @code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in
2004 floating registers. But if the floating registers do not automatically
2005 normalize, if you can store any bit pattern in one and retrieve it
2006 unchanged without a trap, then any machine mode may go in a floating
2007 register, so you can define this macro to say so.
2009 The primary significance of special floating registers is rather that
2010 they are the registers acceptable in floating point arithmetic
2011 instructions. However, this is of no concern to
2012 @code{HARD_REGNO_MODE_OK}. You handle it by writing the proper
2013 constraints for those instructions.
2015 On some machines, the floating registers are especially slow to access,
2016 so that it is better to store a value in a stack frame than in such a
2017 register if floating point arithmetic is not being done. As long as the
2018 floating registers are not in class @code{GENERAL_REGS}, they will not
2019 be used unless some pattern's constraint asks for one.
2022 @defmac HARD_REGNO_RENAME_OK (@var{from}, @var{to})
2023 A C expression that is nonzero if it is OK to rename a hard register
2024 @var{from} to another hard register @var{to}.
2026 One common use of this macro is to prevent renaming of a register to
2027 another register that is not saved by a prologue in an interrupt
2030 The default is always nonzero.
2033 @defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2})
2034 A C expression that is nonzero if a value of mode
2035 @var{mode1} is accessible in mode @var{mode2} without copying.
2037 If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
2038 @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for
2039 any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})}
2040 should be nonzero. If they differ for any @var{r}, you should define
2041 this macro to return zero unless some other mechanism ensures the
2042 accessibility of the value in a narrower mode.
2044 You should define this macro to return nonzero in as many cases as
2045 possible since doing so will allow GCC to perform better register
2049 @defmac AVOID_CCMODE_COPIES
2050 Define this macro if the compiler should avoid copies to/from @code{CCmode}
2051 registers. You should only define this macro if support for copying to/from
2052 @code{CCmode} is incomplete.
2055 @node Leaf Functions
2056 @subsection Handling Leaf Functions
2058 @cindex leaf functions
2059 @cindex functions, leaf
2060 On some machines, a leaf function (i.e., one which makes no calls) can run
2061 more efficiently if it does not make its own register window. Often this
2062 means it is required to receive its arguments in the registers where they
2063 are passed by the caller, instead of the registers where they would
2066 The special treatment for leaf functions generally applies only when
2067 other conditions are met; for example, often they may use only those
2068 registers for its own variables and temporaries. We use the term ``leaf
2069 function'' to mean a function that is suitable for this special
2070 handling, so that functions with no calls are not necessarily ``leaf
2073 GCC assigns register numbers before it knows whether the function is
2074 suitable for leaf function treatment. So it needs to renumber the
2075 registers in order to output a leaf function. The following macros
2078 @defmac LEAF_REGISTERS
2079 Name of a char vector, indexed by hard register number, which
2080 contains 1 for a register that is allowable in a candidate for leaf
2083 If leaf function treatment involves renumbering the registers, then the
2084 registers marked here should be the ones before renumbering---those that
2085 GCC would ordinarily allocate. The registers which will actually be
2086 used in the assembler code, after renumbering, should not be marked with 1
2089 Define this macro only if the target machine offers a way to optimize
2090 the treatment of leaf functions.
2093 @defmac LEAF_REG_REMAP (@var{regno})
2094 A C expression whose value is the register number to which @var{regno}
2095 should be renumbered, when a function is treated as a leaf function.
2097 If @var{regno} is a register number which should not appear in a leaf
2098 function before renumbering, then the expression should yield @minus{}1, which
2099 will cause the compiler to abort.
2101 Define this macro only if the target machine offers a way to optimize the
2102 treatment of leaf functions, and registers need to be renumbered to do
2106 @findex current_function_is_leaf
2107 @findex current_function_uses_only_leaf_regs
2108 @code{TARGET_ASM_FUNCTION_PROLOGUE} and
2109 @code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions
2110 specially. They can test the C variable @code{current_function_is_leaf}
2111 which is nonzero for leaf functions. @code{current_function_is_leaf} is
2112 set prior to local register allocation and is valid for the remaining
2113 compiler passes. They can also test the C variable
2114 @code{current_function_uses_only_leaf_regs} which is nonzero for leaf
2115 functions which only use leaf registers.
2116 @code{current_function_uses_only_leaf_regs} is valid after all passes
2117 that modify the instructions have been run and is only useful if
2118 @code{LEAF_REGISTERS} is defined.
2119 @c changed this to fix overfull. ALSO: why the "it" at the beginning
2120 @c of the next paragraph?! --mew 2feb93
2122 @node Stack Registers
2123 @subsection Registers That Form a Stack
2125 There are special features to handle computers where some of the
2126 ``registers'' form a stack. Stack registers are normally written by
2127 pushing onto the stack, and are numbered relative to the top of the
2130 Currently, GCC can only handle one group of stack-like registers, and
2131 they must be consecutively numbered. Furthermore, the existing
2132 support for stack-like registers is specific to the 80387 floating
2133 point coprocessor. If you have a new architecture that uses
2134 stack-like registers, you will need to do substantial work on
2135 @file{reg-stack.c} and write your machine description to cooperate
2136 with it, as well as defining these macros.
2139 Define this if the machine has any stack-like registers.
2142 @defmac FIRST_STACK_REG
2143 The number of the first stack-like register. This one is the top
2147 @defmac LAST_STACK_REG
2148 The number of the last stack-like register. This one is the bottom of
2152 @node Register Classes
2153 @section Register Classes
2154 @cindex register class definitions
2155 @cindex class definitions, register
2157 On many machines, the numbered registers are not all equivalent.
2158 For example, certain registers may not be allowed for indexed addressing;
2159 certain registers may not be allowed in some instructions. These machine
2160 restrictions are described to the compiler using @dfn{register classes}.
2162 You define a number of register classes, giving each one a name and saying
2163 which of the registers belong to it. Then you can specify register classes
2164 that are allowed as operands to particular instruction patterns.
2168 In general, each register will belong to several classes. In fact, one
2169 class must be named @code{ALL_REGS} and contain all the registers. Another
2170 class must be named @code{NO_REGS} and contain no registers. Often the
2171 union of two classes will be another class; however, this is not required.
2173 @findex GENERAL_REGS
2174 One of the classes must be named @code{GENERAL_REGS}. There is nothing
2175 terribly special about the name, but the operand constraint letters
2176 @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is
2177 the same as @code{ALL_REGS}, just define it as a macro which expands
2180 Order the classes so that if class @var{x} is contained in class @var{y}
2181 then @var{x} has a lower class number than @var{y}.
2183 The way classes other than @code{GENERAL_REGS} are specified in operand
2184 constraints is through machine-dependent operand constraint letters.
2185 You can define such letters to correspond to various classes, then use
2186 them in operand constraints.
2188 You should define a class for the union of two classes whenever some
2189 instruction allows both classes. For example, if an instruction allows
2190 either a floating point (coprocessor) register or a general register for a
2191 certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
2192 which includes both of them. Otherwise you will get suboptimal code.
2194 You must also specify certain redundant information about the register
2195 classes: for each class, which classes contain it and which ones are
2196 contained in it; for each pair of classes, the largest class contained
2199 When a value occupying several consecutive registers is expected in a
2200 certain class, all the registers used must belong to that class.
2201 Therefore, register classes cannot be used to enforce a requirement for
2202 a register pair to start with an even-numbered register. The way to
2203 specify this requirement is with @code{HARD_REGNO_MODE_OK}.
2205 Register classes used for input-operands of bitwise-and or shift
2206 instructions have a special requirement: each such class must have, for
2207 each fixed-point machine mode, a subclass whose registers can transfer that
2208 mode to or from memory. For example, on some machines, the operations for
2209 single-byte values (@code{QImode}) are limited to certain registers. When
2210 this is so, each register class that is used in a bitwise-and or shift
2211 instruction must have a subclass consisting of registers from which
2212 single-byte values can be loaded or stored. This is so that
2213 @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
2215 @deftp {Data type} {enum reg_class}
2216 An enumerated type that must be defined with all the register class names
2217 as enumerated values. @code{NO_REGS} must be first. @code{ALL_REGS}
2218 must be the last register class, followed by one more enumerated value,
2219 @code{LIM_REG_CLASSES}, which is not a register class but rather
2220 tells how many classes there are.
2222 Each register class has a number, which is the value of casting
2223 the class name to type @code{int}. The number serves as an index
2224 in many of the tables described below.
2227 @defmac N_REG_CLASSES
2228 The number of distinct register classes, defined as follows:
2231 #define N_REG_CLASSES (int) LIM_REG_CLASSES
2235 @defmac REG_CLASS_NAMES
2236 An initializer containing the names of the register classes as C string
2237 constants. These names are used in writing some of the debugging dumps.
2240 @defmac REG_CLASS_CONTENTS
2241 An initializer containing the contents of the register classes, as integers
2242 which are bit masks. The @var{n}th integer specifies the contents of class
2243 @var{n}. The way the integer @var{mask} is interpreted is that
2244 register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
2246 When the machine has more than 32 registers, an integer does not suffice.
2247 Then the integers are replaced by sub-initializers, braced groupings containing
2248 several integers. Each sub-initializer must be suitable as an initializer
2249 for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
2250 In this situation, the first integer in each sub-initializer corresponds to
2251 registers 0 through 31, the second integer to registers 32 through 63, and
2255 @defmac REGNO_REG_CLASS (@var{regno})
2256 A C expression whose value is a register class containing hard register
2257 @var{regno}. In general there is more than one such class; choose a class
2258 which is @dfn{minimal}, meaning that no smaller class also contains the
2262 @defmac BASE_REG_CLASS
2263 A macro whose definition is the name of the class to which a valid
2264 base register must belong. A base register is one used in an address
2265 which is the register value plus a displacement.
2268 @defmac MODE_BASE_REG_CLASS (@var{mode})
2269 This is a variation of the @code{BASE_REG_CLASS} macro which allows
2270 the selection of a base register in a mode dependent manner. If
2271 @var{mode} is VOIDmode then it should return the same value as
2272 @code{BASE_REG_CLASS}.
2275 @defmac MODE_BASE_REG_REG_CLASS (@var{mode})
2276 A C expression whose value is the register class to which a valid
2277 base register must belong in order to be used in a base plus index
2278 register address. You should define this macro if base plus index
2279 addresses have different requirements than other base register uses.
2282 @defmac INDEX_REG_CLASS
2283 A macro whose definition is the name of the class to which a valid
2284 index register must belong. An index register is one used in an
2285 address where its value is either multiplied by a scale factor or
2286 added to another register (as well as added to a displacement).
2289 @defmac CONSTRAINT_LEN (@var{char}, @var{str})
2290 For the constraint at the start of @var{str}, which starts with the letter
2291 @var{c}, return the length. This allows you to have register class /
2292 constant / extra constraints that are longer than a single letter;
2293 you don't need to define this macro if you can do with single-letter
2294 constraints only. The definition of this macro should use
2295 DEFAULT_CONSTRAINT_LEN for all the characters that you don't want
2296 to handle specially.
2297 There are some sanity checks in genoutput.c that check the constraint lengths
2298 for the md file, so you can also use this macro to help you while you are
2299 transitioning from a byzantine single-letter-constraint scheme: when you
2300 return a negative length for a constraint you want to re-use, genoutput
2301 will complain about every instance where it is used in the md file.
2304 @defmac REG_CLASS_FROM_LETTER (@var{char})
2305 A C expression which defines the machine-dependent operand constraint
2306 letters for register classes. If @var{char} is such a letter, the
2307 value should be the register class corresponding to it. Otherwise,
2308 the value should be @code{NO_REGS}. The register letter @samp{r},
2309 corresponding to class @code{GENERAL_REGS}, will not be passed
2310 to this macro; you do not need to handle it.
2313 @defmac REG_CLASS_FROM_CONSTRAINT (@var{char}, @var{str})
2314 Like @code{REG_CLASS_FROM_LETTER}, but you also get the constraint string
2315 passed in @var{str}, so that you can use suffixes to distinguish between
2319 @defmac REGNO_OK_FOR_BASE_P (@var{num})
2320 A C expression which is nonzero if register number @var{num} is
2321 suitable for use as a base register in operand addresses. It may be
2322 either a suitable hard register or a pseudo register that has been
2323 allocated such a hard register.
2326 @defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode})
2327 A C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that
2328 that expression may examine the mode of the memory reference in
2329 @var{mode}. You should define this macro if the mode of the memory
2330 reference affects whether a register may be used as a base register. If
2331 you define this macro, the compiler will use it instead of
2332 @code{REGNO_OK_FOR_BASE_P}.
2335 @defmac REGNO_MODE_OK_FOR_REG_BASE_P (@var{num}, @var{mode})
2336 A C expression which is nonzero if register number @var{num} is suitable for
2337 use as a base register in base plus index operand addresses, accessing
2338 memory in mode @var{mode}. It may be either a suitable hard register or a
2339 pseudo register that has been allocated such a hard register. You should
2340 define this macro if base plus index addresses have different requirements
2341 than other base register uses.
2344 @defmac REGNO_OK_FOR_INDEX_P (@var{num})
2345 A C expression which is nonzero if register number @var{num} is
2346 suitable for use as an index register in operand addresses. It may be
2347 either a suitable hard register or a pseudo register that has been
2348 allocated such a hard register.
2350 The difference between an index register and a base register is that
2351 the index register may be scaled. If an address involves the sum of
2352 two registers, neither one of them scaled, then either one may be
2353 labeled the ``base'' and the other the ``index''; but whichever
2354 labeling is used must fit the machine's constraints of which registers
2355 may serve in each capacity. The compiler will try both labelings,
2356 looking for one that is valid, and will reload one or both registers
2357 only if neither labeling works.
2360 @defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
2361 A C expression that places additional restrictions on the register class
2362 to use when it is necessary to copy value @var{x} into a register in class
2363 @var{class}. The value is a register class; perhaps @var{class}, or perhaps
2364 another, smaller class. On many machines, the following definition is
2368 #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
2371 Sometimes returning a more restrictive class makes better code. For
2372 example, on the 68000, when @var{x} is an integer constant that is in range
2373 for a @samp{moveq} instruction, the value of this macro is always
2374 @code{DATA_REGS} as long as @var{class} includes the data registers.
2375 Requiring a data register guarantees that a @samp{moveq} will be used.
2377 One case where @code{PREFERRED_RELOAD_CLASS} must not return
2378 @var{class} is if @var{x} is a legitimate constant which cannot be
2379 loaded into some register class. By returning @code{NO_REGS} you can
2380 force @var{x} into a memory location. For example, rs6000 can load
2381 immediate values into general-purpose registers, but does not have an
2382 instruction for loading an immediate value into a floating-point
2383 register, so @code{PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2384 @var{x} is a floating-point constant. If the constant can't be loaded
2385 into any kind of register, code generation will be better if
2386 @code{LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
2387 of using @code{PREFERRED_RELOAD_CLASS}.
2390 @defmac PREFERRED_OUTPUT_RELOAD_CLASS (@var{x}, @var{class})
2391 Like @code{PREFERRED_RELOAD_CLASS}, but for output reloads instead of
2392 input reloads. If you don't define this macro, the default is to use
2393 @var{class}, unchanged.
2396 @defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class})
2397 A C expression that places additional restrictions on the register class
2398 to use when it is necessary to be able to hold a value of mode
2399 @var{mode} in a reload register for which class @var{class} would
2402 Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when
2403 there are certain modes that simply can't go in certain reload classes.
2405 The value is a register class; perhaps @var{class}, or perhaps another,
2408 Don't define this macro unless the target machine has limitations which
2409 require the macro to do something nontrivial.
2412 @defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2413 @defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2414 @defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2415 Many machines have some registers that cannot be copied directly to or
2416 from memory or even from other types of registers. An example is the
2417 @samp{MQ} register, which on most machines, can only be copied to or
2418 from general registers, but not memory. Some machines allow copying all
2419 registers to and from memory, but require a scratch register for stores
2420 to some memory locations (e.g., those with symbolic address on the RT,
2421 and those with certain symbolic address on the SPARC when compiling
2422 PIC)@. In some cases, both an intermediate and a scratch register are
2425 You should define these macros to indicate to the reload phase that it may
2426 need to allocate at least one register for a reload in addition to the
2427 register to contain the data. Specifically, if copying @var{x} to a
2428 register @var{class} in @var{mode} requires an intermediate register,
2429 you should define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the
2430 largest register class all of whose registers can be used as
2431 intermediate registers or scratch registers.
2433 If copying a register @var{class} in @var{mode} to @var{x} requires an
2434 intermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS}
2435 should be defined to return the largest register class required. If the
2436 requirements for input and output reloads are the same, the macro
2437 @code{SECONDARY_RELOAD_CLASS} should be used instead of defining both
2440 The values returned by these macros are often @code{GENERAL_REGS}.
2441 Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x}
2442 can be directly copied to or from a register of @var{class} in
2443 @var{mode} without requiring a scratch register. Do not define this
2444 macro if it would always return @code{NO_REGS}.
2446 If a scratch register is required (either with or without an
2447 intermediate register), you should define patterns for
2448 @samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required
2449 (@pxref{Standard Names}. These patterns, which will normally be
2450 implemented with a @code{define_expand}, should be similar to the
2451 @samp{mov@var{m}} patterns, except that operand 2 is the scratch
2454 Define constraints for the reload register and scratch register that
2455 contain a single register class. If the original reload register (whose
2456 class is @var{class}) can meet the constraint given in the pattern, the
2457 value returned by these macros is used for the class of the scratch
2458 register. Otherwise, two additional reload registers are required.
2459 Their classes are obtained from the constraints in the insn pattern.
2461 @var{x} might be a pseudo-register or a @code{subreg} of a
2462 pseudo-register, which could either be in a hard register or in memory.
2463 Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2464 in memory and the hard register number if it is in a register.
2466 These macros should not be used in the case where a particular class of
2467 registers can only be copied to memory and not to another class of
2468 registers. In that case, secondary reload registers are not needed and
2469 would not be helpful. Instead, a stack location must be used to perform
2470 the copy and the @code{mov@var{m}} pattern should use memory as an
2471 intermediate storage. This case often occurs between floating-point and
2475 @defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m})
2476 Certain machines have the property that some registers cannot be copied
2477 to some other registers without using memory. Define this macro on
2478 those machines to be a C expression that is nonzero if objects of mode
2479 @var{m} in registers of @var{class1} can only be copied to registers of
2480 class @var{class2} by storing a register of @var{class1} into memory
2481 and loading that memory location into a register of @var{class2}.
2483 Do not define this macro if its value would always be zero.
2486 @defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode})
2487 Normally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler
2488 allocates a stack slot for a memory location needed for register copies.
2489 If this macro is defined, the compiler instead uses the memory location
2490 defined by this macro.
2492 Do not define this macro if you do not define
2493 @code{SECONDARY_MEMORY_NEEDED}.
2496 @defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode})
2497 When the compiler needs a secondary memory location to copy between two
2498 registers of mode @var{mode}, it normally allocates sufficient memory to
2499 hold a quantity of @code{BITS_PER_WORD} bits and performs the store and
2500 load operations in a mode that many bits wide and whose class is the
2501 same as that of @var{mode}.
2503 This is right thing to do on most machines because it ensures that all
2504 bits of the register are copied and prevents accesses to the registers
2505 in a narrower mode, which some machines prohibit for floating-point
2508 However, this default behavior is not correct on some machines, such as
2509 the DEC Alpha, that store short integers in floating-point registers
2510 differently than in integer registers. On those machines, the default
2511 widening will not work correctly and you must define this macro to
2512 suppress that widening in some cases. See the file @file{alpha.h} for
2515 Do not define this macro if you do not define
2516 @code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that
2517 is @code{BITS_PER_WORD} bits wide is correct for your machine.
2520 @defmac SMALL_REGISTER_CLASSES
2521 On some machines, it is risky to let hard registers live across arbitrary
2522 insns. Typically, these machines have instructions that require values
2523 to be in specific registers (like an accumulator), and reload will fail
2524 if the required hard register is used for another purpose across such an
2527 Define @code{SMALL_REGISTER_CLASSES} to be an expression with a nonzero
2528 value on these machines. When this macro has a nonzero value, the
2529 compiler will try to minimize the lifetime of hard registers.
2531 It is always safe to define this macro with a nonzero value, but if you
2532 unnecessarily define it, you will reduce the amount of optimizations
2533 that can be performed in some cases. If you do not define this macro
2534 with a nonzero value when it is required, the compiler will run out of
2535 spill registers and print a fatal error message. For most machines, you
2536 should not define this macro at all.
2539 @defmac CLASS_LIKELY_SPILLED_P (@var{class})
2540 A C expression whose value is nonzero if pseudos that have been assigned
2541 to registers of class @var{class} would likely be spilled because
2542 registers of @var{class} are needed for spill registers.
2544 The default value of this macro returns 1 if @var{class} has exactly one
2545 register and zero otherwise. On most machines, this default should be
2546 used. Only define this macro to some other expression if pseudos
2547 allocated by @file{local-alloc.c} end up in memory because their hard
2548 registers were needed for spill registers. If this macro returns nonzero
2549 for those classes, those pseudos will only be allocated by
2550 @file{global.c}, which knows how to reallocate the pseudo to another
2551 register. If there would not be another register available for
2552 reallocation, you should not change the definition of this macro since
2553 the only effect of such a definition would be to slow down register
2557 @defmac CLASS_MAX_NREGS (@var{class}, @var{mode})
2558 A C expression for the maximum number of consecutive registers
2559 of class @var{class} needed to hold a value of mode @var{mode}.
2561 This is closely related to the macro @code{HARD_REGNO_NREGS}. In fact,
2562 the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
2563 should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno},
2564 @var{mode})} for all @var{regno} values in the class @var{class}.
2566 This macro helps control the handling of multiple-word values
2570 @defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
2571 If defined, a C expression that returns nonzero for a @var{class} for which
2572 a change from mode @var{from} to mode @var{to} is invalid.
2574 For the example, loading 32-bit integer or floating-point objects into
2575 floating-point registers on the Alpha extends them to 64 bits.
2576 Therefore loading a 64-bit object and then storing it as a 32-bit object
2577 does not store the low-order 32 bits, as would be the case for a normal
2578 register. Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
2582 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
2583 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
2584 ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
2588 Three other special macros describe which operands fit which constraint
2591 @defmac CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
2592 A C expression that defines the machine-dependent operand constraint
2593 letters (@samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}) that specify
2594 particular ranges of integer values. If @var{c} is one of those
2595 letters, the expression should check that @var{value}, an integer, is in
2596 the appropriate range and return 1 if so, 0 otherwise. If @var{c} is
2597 not one of those letters, the value should be 0 regardless of
2601 @defmac CONST_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2602 Like @code{CONST_OK_FOR_LETTER_P}, but you also get the constraint
2603 string passed in @var{str}, so that you can use suffixes to distinguish
2604 between different variants.
2607 @defmac CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
2608 A C expression that defines the machine-dependent operand constraint
2609 letters that specify particular ranges of @code{const_double} values
2610 (@samp{G} or @samp{H}).
2612 If @var{c} is one of those letters, the expression should check that
2613 @var{value}, an RTX of code @code{const_double}, is in the appropriate
2614 range and return 1 if so, 0 otherwise. If @var{c} is not one of those
2615 letters, the value should be 0 regardless of @var{value}.
2617 @code{const_double} is used for all floating-point constants and for
2618 @code{DImode} fixed-point constants. A given letter can accept either
2619 or both kinds of values. It can use @code{GET_MODE} to distinguish
2620 between these kinds.
2623 @defmac CONST_DOUBLE_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2624 Like @code{CONST_DOUBLE_OK_FOR_LETTER_P}, but you also get the constraint
2625 string passed in @var{str}, so that you can use suffixes to distinguish
2626 between different variants.
2629 @defmac EXTRA_CONSTRAINT (@var{value}, @var{c})
2630 A C expression that defines the optional machine-dependent constraint
2631 letters that can be used to segregate specific types of operands, usually
2632 memory references, for the target machine. Any letter that is not
2633 elsewhere defined and not matched by @code{REG_CLASS_FROM_LETTER} /
2634 @code{REG_CLASS_FROM_CONSTRAINT}
2635 may be used. Normally this macro will not be defined.
2637 If it is required for a particular target machine, it should return 1
2638 if @var{value} corresponds to the operand type represented by the
2639 constraint letter @var{c}. If @var{c} is not defined as an extra
2640 constraint, the value returned should be 0 regardless of @var{value}.
2642 For example, on the ROMP, load instructions cannot have their output
2643 in r0 if the memory reference contains a symbolic address. Constraint
2644 letter @samp{Q} is defined as representing a memory address that does
2645 @emph{not} contain a symbolic address. An alternative is specified with
2646 a @samp{Q} constraint on the input and @samp{r} on the output. The next
2647 alternative specifies @samp{m} on the input and a register class that
2648 does not include r0 on the output.
2651 @defmac EXTRA_CONSTRAINT_STR (@var{value}, @var{c}, @var{str})
2652 Like @code{EXTRA_CONSTRAINT}, but you also get the constraint string passed
2653 in @var{str}, so that you can use suffixes to distinguish between different
2657 @defmac EXTRA_MEMORY_CONSTRAINT (@var{c}, @var{str})
2658 A C expression that defines the optional machine-dependent constraint
2659 letters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should
2660 be treated like memory constraints by the reload pass.
2662 It should return 1 if the operand type represented by the constraint
2663 at the start of @var{str}, the first letter of which is the letter @var{c},
2664 comprises a subset of all memory references including
2665 all those whose address is simply a base register. This allows the reload
2666 pass to reload an operand, if it does not directly correspond to the operand
2667 type of @var{c}, by copying its address into a base register.
2669 For example, on the S/390, some instructions do not accept arbitrary
2670 memory references, but only those that do not make use of an index
2671 register. The constraint letter @samp{Q} is defined via
2672 @code{EXTRA_CONSTRAINT} as representing a memory address of this type.
2673 If the letter @samp{Q} is marked as @code{EXTRA_MEMORY_CONSTRAINT},
2674 a @samp{Q} constraint can handle any memory operand, because the
2675 reload pass knows it can be reloaded by copying the memory address
2676 into a base register if required. This is analogous to the way
2677 a @samp{o} constraint can handle any memory operand.
2680 @defmac EXTRA_ADDRESS_CONSTRAINT (@var{c}, @var{str})
2681 A C expression that defines the optional machine-dependent constraint
2682 letters, amongst those accepted by @code{EXTRA_CONSTRAINT} /
2683 @code{EXTRA_CONSTRAINT_STR}, that should
2684 be treated like address constraints by the reload pass.
2686 It should return 1 if the operand type represented by the constraint
2687 at the start of @var{str}, which starts with the letter @var{c}, comprises
2688 a subset of all memory addresses including
2689 all those that consist of just a base register. This allows the reload
2690 pass to reload an operand, if it does not directly correspond to the operand
2691 type of @var{str}, by copying it into a base register.
2693 Any constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only
2694 be used with the @code{address_operand} predicate. It is treated
2695 analogously to the @samp{p} constraint.
2698 @node Stack and Calling
2699 @section Stack Layout and Calling Conventions
2700 @cindex calling conventions
2702 @c prevent bad page break with this line
2703 This describes the stack layout and calling conventions.
2707 * Exception Handling::
2712 * Register Arguments::
2714 * Aggregate Return::
2719 * Stack Smashing Protection::
2723 @subsection Basic Stack Layout
2724 @cindex stack frame layout
2725 @cindex frame layout
2727 @c prevent bad page break with this line
2728 Here is the basic stack layout.
2730 @defmac STACK_GROWS_DOWNWARD
2731 Define this macro if pushing a word onto the stack moves the stack
2732 pointer to a smaller address.
2734 When we say, ``define this macro if @dots{}'', it means that the
2735 compiler checks this macro only with @code{#ifdef} so the precise
2736 definition used does not matter.
2739 @defmac STACK_PUSH_CODE
2740 This macro defines the operation used when something is pushed
2741 on the stack. In RTL, a push operation will be
2742 @code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})}
2744 The choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC},
2745 and @code{POST_INC}. Which of these is correct depends on
2746 the stack direction and on whether the stack pointer points
2747 to the last item on the stack or whether it points to the
2748 space for the next item on the stack.
2750 The default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is
2751 defined, which is almost always right, and @code{PRE_INC} otherwise,
2752 which is often wrong.
2755 @defmac FRAME_GROWS_DOWNWARD
2756 Define this macro to non-zero value if the addresses of local variable slots
2757 are at negative offsets from the frame pointer.
2760 @defmac ARGS_GROW_DOWNWARD
2761 Define this macro if successive arguments to a function occupy decreasing
2762 addresses on the stack.
2765 @defmac STARTING_FRAME_OFFSET
2766 Offset from the frame pointer to the first local variable slot to be allocated.
2768 If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
2769 subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
2770 Otherwise, it is found by adding the length of the first slot to the
2771 value @code{STARTING_FRAME_OFFSET}.
2772 @c i'm not sure if the above is still correct.. had to change it to get
2773 @c rid of an overfull. --mew 2feb93
2776 @defmac STACK_ALIGNMENT_NEEDED
2777 Define to zero to disable final alignment of the stack during reload.
2778 The nonzero default for this macro is suitable for most ports.
2780 On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
2781 is a register save block following the local block that doesn't require
2782 alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
2783 stack alignment and do it in the backend.
2786 @defmac STACK_POINTER_OFFSET
2787 Offset from the stack pointer register to the first location at which
2788 outgoing arguments are placed. If not specified, the default value of
2789 zero is used. This is the proper value for most machines.
2791 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
2792 the first location at which outgoing arguments are placed.
2795 @defmac FIRST_PARM_OFFSET (@var{fundecl})
2796 Offset from the argument pointer register to the first argument's
2797 address. On some machines it may depend on the data type of the
2800 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
2801 the first argument's address.
2804 @defmac STACK_DYNAMIC_OFFSET (@var{fundecl})
2805 Offset from the stack pointer register to an item dynamically allocated
2806 on the stack, e.g., by @code{alloca}.
2808 The default value for this macro is @code{STACK_POINTER_OFFSET} plus the
2809 length of the outgoing arguments. The default is correct for most
2810 machines. See @file{function.c} for details.
2813 @defmac INITIAL_FRAME_ADDRESS_RTX
2814 A C expression whose value is RTL representing the address of the initial
2815 stack frame. This address is passed to @code{RETURN_ADDR_RTX} and
2816 @code{DYNAMIC_CHAIN_ADDRESS}.
2817 If you don't define this macro, the default is to return
2818 @code{hard_frame_pointer_rtx}.
2819 This default is usually correct unless @code{-fomit-frame-pointer} is in
2821 Define this macro in order to make @code{__builtin_frame_address (0)} and
2822 @code{__builtin_return_address (0)} work even in absence of a hard frame pointer.
2825 @defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
2826 A C expression whose value is RTL representing the address in a stack
2827 frame where the pointer to the caller's frame is stored. Assume that
2828 @var{frameaddr} is an RTL expression for the address of the stack frame
2831 If you don't define this macro, the default is to return the value
2832 of @var{frameaddr}---that is, the stack frame address is also the
2833 address of the stack word that points to the previous frame.
2836 @defmac SETUP_FRAME_ADDRESSES
2837 If defined, a C expression that produces the machine-specific code to
2838 setup the stack so that arbitrary frames can be accessed. For example,
2839 on the SPARC, we must flush all of the register windows to the stack
2840 before we can access arbitrary stack frames. You will seldom need to
2844 @deftypefn {Target Hook} bool TARGET_BUILTIN_SETJMP_FRAME_VALUE ()
2845 This target hook should return an rtx that is used to store
2846 the address of the current frame into the built in @code{setjmp} buffer.
2847 The default value, @code{virtual_stack_vars_rtx}, is correct for most
2848 machines. One reason you may need to define this target hook is if
2849 @code{hard_frame_pointer_rtx} is the appropriate value on your machine.
2852 @defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr})
2853 A C expression whose value is RTL representing the value of the return
2854 address for the frame @var{count} steps up from the current frame, after
2855 the prologue. @var{frameaddr} is the frame pointer of the @var{count}
2856 frame, or the frame pointer of the @var{count} @minus{} 1 frame if
2857 @code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined.
2859 The value of the expression must always be the correct address when
2860 @var{count} is zero, but may be @code{NULL_RTX} if there is not way to
2861 determine the return address of other frames.
2864 @defmac RETURN_ADDR_IN_PREVIOUS_FRAME
2865 Define this if the return address of a particular stack frame is accessed
2866 from the frame pointer of the previous stack frame.
2869 @defmac INCOMING_RETURN_ADDR_RTX
2870 A C expression whose value is RTL representing the location of the
2871 incoming return address at the beginning of any function, before the
2872 prologue. This RTL is either a @code{REG}, indicating that the return
2873 value is saved in @samp{REG}, or a @code{MEM} representing a location in
2876 You only need to define this macro if you want to support call frame
2877 debugging information like that provided by DWARF 2.
2879 If this RTL is a @code{REG}, you should also define
2880 @code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}.
2883 @defmac DWARF_ALT_FRAME_RETURN_COLUMN
2884 A C expression whose value is an integer giving a DWARF 2 column
2885 number that may be used as an alternate return column. This should
2886 be defined only if @code{DWARF_FRAME_RETURN_COLUMN} is set to a
2887 general register, but an alternate column needs to be used for
2891 @defmac DWARF_ZERO_REG
2892 A C expression whose value is an integer giving a DWARF 2 register
2893 number that is considered to always have the value zero. This should
2894 only be defined if the target has an architected zero register, and
2895 someone decided it was a good idea to use that register number to
2896 terminate the stack backtrace. New ports should avoid this.
2899 @deftypefn {Target Hook} void TARGET_DWARF_HANDLE_FRAME_UNSPEC (const char *@var{label}, rtx @var{pattern}, int @var{index})
2900 This target hook allows the backend to emit frame-related insns that
2901 contain UNSPECs or UNSPEC_VOLATILEs. The DWARF 2 call frame debugging
2902 info engine will invoke it on insns of the form
2904 (set (reg) (unspec [...] UNSPEC_INDEX))
2908 (set (reg) (unspec_volatile [...] UNSPECV_INDEX)).
2910 to let the backend emit the call frame instructions. @var{label} is
2911 the CFI label attached to the insn, @var{pattern} is the pattern of
2912 the insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}.
2915 @defmac INCOMING_FRAME_SP_OFFSET
2916 A C expression whose value is an integer giving the offset, in bytes,
2917 from the value of the stack pointer register to the top of the stack
2918 frame at the beginning of any function, before the prologue. The top of
2919 the frame is defined to be the value of the stack pointer in the
2920 previous frame, just before the call instruction.
2922 You only need to define this macro if you want to support call frame
2923 debugging information like that provided by DWARF 2.
2926 @defmac ARG_POINTER_CFA_OFFSET (@var{fundecl})
2927 A C expression whose value is an integer giving the offset, in bytes,
2928 from the argument pointer to the canonical frame address (cfa). The
2929 final value should coincide with that calculated by
2930 @code{INCOMING_FRAME_SP_OFFSET}. Which is unfortunately not usable
2931 during virtual register instantiation.
2933 The default value for this macro is @code{FIRST_PARM_OFFSET (fundecl)},
2934 which is correct for most machines; in general, the arguments are found
2935 immediately before the stack frame. Note that this is not the case on
2936 some targets that save registers into the caller's frame, such as SPARC
2937 and rs6000, and so such targets need to define this macro.
2939 You only need to define this macro if the default is incorrect, and you
2940 want to support call frame debugging information like that provided by
2944 @node Exception Handling
2945 @subsection Exception Handling Support
2946 @cindex exception handling
2948 @defmac EH_RETURN_DATA_REGNO (@var{N})
2949 A C expression whose value is the @var{N}th register number used for
2950 data by exception handlers, or @code{INVALID_REGNUM} if fewer than
2951 @var{N} registers are usable.
2953 The exception handling library routines communicate with the exception
2954 handlers via a set of agreed upon registers. Ideally these registers
2955 should be call-clobbered; it is possible to use call-saved registers,
2956 but may negatively impact code size. The target must support at least
2957 2 data registers, but should define 4 if there are enough free registers.
2959 You must define this macro if you want to support call frame exception
2960 handling like that provided by DWARF 2.
2963 @defmac EH_RETURN_STACKADJ_RTX
2964 A C expression whose value is RTL representing a location in which
2965 to store a stack adjustment to be applied before function return.
2966 This is used to unwind the stack to an exception handler's call frame.
2967 It will be assigned zero on code paths that return normally.
2969 Typically this is a call-clobbered hard register that is otherwise
2970 untouched by the epilogue, but could also be a stack slot.
2972 Do not define this macro if the stack pointer is saved and restored
2973 by the regular prolog and epilog code in the call frame itself; in
2974 this case, the exception handling library routines will update the
2975 stack location to be restored in place. Otherwise, you must define
2976 this macro if you want to support call frame exception handling like
2977 that provided by DWARF 2.
2980 @defmac EH_RETURN_HANDLER_RTX
2981 A C expression whose value is RTL representing a location in which
2982 to store the address of an exception handler to which we should
2983 return. It will not be assigned on code paths that return normally.
2985 Typically this is the location in the call frame at which the normal
2986 return address is stored. For targets that return by popping an
2987 address off the stack, this might be a memory address just below
2988 the @emph{target} call frame rather than inside the current call
2989 frame. If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
2990 been assigned, so it may be used to calculate the location of the
2993 Some targets have more complex requirements than storing to an
2994 address calculable during initial code generation. In that case
2995 the @code{eh_return} instruction pattern should be used instead.
2997 If you want to support call frame exception handling, you must
2998 define either this macro or the @code{eh_return} instruction pattern.
3001 @defmac RETURN_ADDR_OFFSET
3002 If defined, an integer-valued C expression for which rtl will be generated
3003 to add it to the exception handler address before it is searched in the
3004 exception handling tables, and to subtract it again from the address before
3005 using it to return to the exception handler.
3008 @defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global})
3009 This macro chooses the encoding of pointers embedded in the exception
3010 handling sections. If at all possible, this should be defined such
3011 that the exception handling section will not require dynamic relocations,
3012 and so may be read-only.
3014 @var{code} is 0 for data, 1 for code labels, 2 for function pointers.
3015 @var{global} is true if the symbol may be affected by dynamic relocations.
3016 The macro should return a combination of the @code{DW_EH_PE_*} defines
3017 as found in @file{dwarf2.h}.
3019 If this macro is not defined, pointers will not be encoded but
3020 represented directly.
3023 @defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done})
3024 This macro allows the target to emit whatever special magic is required
3025 to represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}.
3026 Generic code takes care of pc-relative and indirect encodings; this must
3027 be defined if the target uses text-relative or data-relative encodings.
3029 This is a C statement that branches to @var{done} if the format was
3030 handled. @var{encoding} is the format chosen, @var{size} is the number
3031 of bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF}
3035 @defmac MD_UNWIND_SUPPORT
3036 A string specifying a file to be #include'd in unwind-dw2.c. The file
3037 so included typically defines @code{MD_FALLBACK_FRAME_STATE_FOR}.
3040 @defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs})
3041 This macro allows the target to add cpu and operating system specific
3042 code to the call-frame unwinder for use when there is no unwind data
3043 available. The most common reason to implement this macro is to unwind
3044 through signal frames.
3046 This macro is called from @code{uw_frame_state_for} in @file{unwind-dw2.c}
3047 and @file{unwind-ia64.c}. @var{context} is an @code{_Unwind_Context};
3048 @var{fs} is an @code{_Unwind_FrameState}. Examine @code{context->ra}
3049 for the address of the code being executed and @code{context->cfa} for
3050 the stack pointer value. If the frame can be decoded, the register save
3051 addresses should be updated in @var{fs} and the macro should evaluate to
3052 @code{_URC_NO_REASON}. If the frame cannot be decoded, the macro should
3053 evaluate to @code{_URC_END_OF_STACK}.
3055 For proper signal handling in Java this macro is accompanied by
3056 @code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers.
3059 @defmac MD_HANDLE_UNWABI (@var{context}, @var{fs})
3060 This macro allows the target to add operating system specific code to the
3061 call-frame unwinder to handle the IA-64 @code{.unwabi} unwinding directive,
3062 usually used for signal or interrupt frames.
3064 This macro is called from @code{uw_update_context} in @file{unwind-ia64.c}.
3065 @var{context} is an @code{_Unwind_Context};
3066 @var{fs} is an @code{_Unwind_FrameState}. Examine @code{fs->unwabi}
3067 for the abi and context in the @code{.unwabi} directive. If the
3068 @code{.unwabi} directive can be handled, the register save addresses should
3069 be updated in @var{fs}.
3072 @defmac TARGET_USES_WEAK_UNWIND_INFO
3073 A C expression that evaluates to true if the target requires unwind
3074 info to be given comdat linkage. Define it to be @code{1} if comdat
3075 linkage is necessary. The default is @code{0}.
3078 @node Stack Checking
3079 @subsection Specifying How Stack Checking is Done
3081 GCC will check that stack references are within the boundaries of
3082 the stack, if the @option{-fstack-check} is specified, in one of three ways:
3086 If the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC
3087 will assume that you have arranged for stack checking to be done at
3088 appropriate places in the configuration files, e.g., in
3089 @code{TARGET_ASM_FUNCTION_PROLOGUE}. GCC will do not other special
3093 If @code{STACK_CHECK_BUILTIN} is zero and you defined a named pattern
3094 called @code{check_stack} in your @file{md} file, GCC will call that
3095 pattern with one argument which is the address to compare the stack
3096 value against. You must arrange for this pattern to report an error if
3097 the stack pointer is out of range.
3100 If neither of the above are true, GCC will generate code to periodically
3101 ``probe'' the stack pointer using the values of the macros defined below.
3104 Normally, you will use the default values of these macros, so GCC
3105 will use the third approach.
3107 @defmac STACK_CHECK_BUILTIN
3108 A nonzero value if stack checking is done by the configuration files in a
3109 machine-dependent manner. You should define this macro if stack checking
3110 is require by the ABI of your machine or if you would like to have to stack
3111 checking in some more efficient way than GCC's portable approach.
3112 The default value of this macro is zero.
3115 @defmac STACK_CHECK_PROBE_INTERVAL
3116 An integer representing the interval at which GCC must generate stack
3117 probe instructions. You will normally define this macro to be no larger
3118 than the size of the ``guard pages'' at the end of a stack area. The
3119 default value of 4096 is suitable for most systems.
3122 @defmac STACK_CHECK_PROBE_LOAD
3123 A integer which is nonzero if GCC should perform the stack probe
3124 as a load instruction and zero if GCC should use a store instruction.
3125 The default is zero, which is the most efficient choice on most systems.
3128 @defmac STACK_CHECK_PROTECT
3129 The number of bytes of stack needed to recover from a stack overflow,
3130 for languages where such a recovery is supported. The default value of
3131 75 words should be adequate for most machines.
3134 @defmac STACK_CHECK_MAX_FRAME_SIZE
3135 The maximum size of a stack frame, in bytes. GCC will generate probe
3136 instructions in non-leaf functions to ensure at least this many bytes of
3137 stack are available. If a stack frame is larger than this size, stack
3138 checking will not be reliable and GCC will issue a warning. The
3139 default is chosen so that GCC only generates one instruction on most
3140 systems. You should normally not change the default value of this macro.
3143 @defmac STACK_CHECK_FIXED_FRAME_SIZE
3144 GCC uses this value to generate the above warning message. It
3145 represents the amount of fixed frame used by a function, not including
3146 space for any callee-saved registers, temporaries and user variables.
3147 You need only specify an upper bound for this amount and will normally
3148 use the default of four words.
3151 @defmac STACK_CHECK_MAX_VAR_SIZE
3152 The maximum size, in bytes, of an object that GCC will place in the
3153 fixed area of the stack frame when the user specifies
3154 @option{-fstack-check}.
3155 GCC computed the default from the values of the above macros and you will
3156 normally not need to override that default.
3160 @node Frame Registers
3161 @subsection Registers That Address the Stack Frame
3163 @c prevent bad page break with this line
3164 This discusses registers that address the stack frame.
3166 @defmac STACK_POINTER_REGNUM
3167 The register number of the stack pointer register, which must also be a
3168 fixed register according to @code{FIXED_REGISTERS}. On most machines,
3169 the hardware determines which register this is.
3172 @defmac FRAME_POINTER_REGNUM
3173 The register number of the frame pointer register, which is used to
3174 access automatic variables in the stack frame. On some machines, the
3175 hardware determines which register this is. On other machines, you can
3176 choose any register you wish for this purpose.
3179 @defmac HARD_FRAME_POINTER_REGNUM
3180 On some machines the offset between the frame pointer and starting
3181 offset of the automatic variables is not known until after register
3182 allocation has been done (for example, because the saved registers are
3183 between these two locations). On those machines, define
3184 @code{FRAME_POINTER_REGNUM} the number of a special, fixed register to
3185 be used internally until the offset is known, and define
3186 @code{HARD_FRAME_POINTER_REGNUM} to be the actual hard register number
3187 used for the frame pointer.
3189 You should define this macro only in the very rare circumstances when it
3190 is not possible to calculate the offset between the frame pointer and
3191 the automatic variables until after register allocation has been
3192 completed. When this macro is defined, you must also indicate in your
3193 definition of @code{ELIMINABLE_REGS} how to eliminate
3194 @code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM}
3195 or @code{STACK_POINTER_REGNUM}.
3197 Do not define this macro if it would be the same as
3198 @code{FRAME_POINTER_REGNUM}.
3201 @defmac ARG_POINTER_REGNUM
3202 The register number of the arg pointer register, which is used to access
3203 the function's argument list. On some machines, this is the same as the
3204 frame pointer register. On some machines, the hardware determines which
3205 register this is. On other machines, you can choose any register you
3206 wish for this purpose. If this is not the same register as the frame
3207 pointer register, then you must mark it as a fixed register according to
3208 @code{FIXED_REGISTERS}, or arrange to be able to eliminate it
3209 (@pxref{Elimination}).
3212 @defmac RETURN_ADDRESS_POINTER_REGNUM
3213 The register number of the return address pointer register, which is used to
3214 access the current function's return address from the stack. On some
3215 machines, the return address is not at a fixed offset from the frame
3216 pointer or stack pointer or argument pointer. This register can be defined
3217 to point to the return address on the stack, and then be converted by
3218 @code{ELIMINABLE_REGS} into either the frame pointer or stack pointer.
3220 Do not define this macro unless there is no other way to get the return
3221 address from the stack.
3224 @defmac STATIC_CHAIN_REGNUM
3225 @defmacx STATIC_CHAIN_INCOMING_REGNUM
3226 Register numbers used for passing a function's static chain pointer. If
3227 register windows are used, the register number as seen by the called
3228 function is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register
3229 number as seen by the calling function is @code{STATIC_CHAIN_REGNUM}. If
3230 these registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need
3233 The static chain register need not be a fixed register.
3235 If the static chain is passed in memory, these macros should not be
3236 defined; instead, the next two macros should be defined.
3239 @defmac STATIC_CHAIN
3240 @defmacx STATIC_CHAIN_INCOMING
3241 If the static chain is passed in memory, these macros provide rtx giving
3242 @code{mem} expressions that denote where they are stored.
3243 @code{STATIC_CHAIN} and @code{STATIC_CHAIN_INCOMING} give the locations
3244 as seen by the calling and called functions, respectively. Often the former
3245 will be at an offset from the stack pointer and the latter at an offset from
3248 @findex stack_pointer_rtx
3249 @findex frame_pointer_rtx
3250 @findex arg_pointer_rtx
3251 The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and
3252 @code{arg_pointer_rtx} will have been initialized prior to the use of these
3253 macros and should be used to refer to those items.
3255 If the static chain is passed in a register, the two previous macros should
3259 @defmac DWARF_FRAME_REGISTERS
3260 This macro specifies the maximum number of hard registers that can be
3261 saved in a call frame. This is used to size data structures used in
3262 DWARF2 exception handling.
3264 Prior to GCC 3.0, this macro was needed in order to establish a stable
3265 exception handling ABI in the face of adding new hard registers for ISA
3266 extensions. In GCC 3.0 and later, the EH ABI is insulated from changes
3267 in the number of hard registers. Nevertheless, this macro can still be
3268 used to reduce the runtime memory requirements of the exception handling
3269 routines, which can be substantial if the ISA contains a lot of
3270 registers that are not call-saved.
3272 If this macro is not defined, it defaults to
3273 @code{FIRST_PSEUDO_REGISTER}.
3276 @defmac PRE_GCC3_DWARF_FRAME_REGISTERS
3278 This macro is similar to @code{DWARF_FRAME_REGISTERS}, but is provided
3279 for backward compatibility in pre GCC 3.0 compiled code.
3281 If this macro is not defined, it defaults to
3282 @code{DWARF_FRAME_REGISTERS}.
3285 @defmac DWARF_REG_TO_UNWIND_COLUMN (@var{regno})
3287 Define this macro if the target's representation for dwarf registers
3288 is different than the internal representation for unwind column.
3289 Given a dwarf register, this macro should return the internal unwind
3290 column number to use instead.
3292 See the PowerPC's SPE target for an example.
3295 @defmac DWARF_FRAME_REGNUM (@var{regno})
3297 Define this macro if the target's representation for dwarf registers
3298 used in .eh_frame or .debug_frame is different from that used in other
3299 debug info sections. Given a GCC hard register number, this macro
3300 should return the .eh_frame register number. The default is
3301 @code{DBX_REGISTER_NUMBER (@var{regno})}.
3305 @defmac DWARF2_FRAME_REG_OUT (@var{regno}, @var{for_eh})
3307 Define this macro to map register numbers held in the call frame info
3308 that GCC has collected using @code{DWARF_FRAME_REGNUM} to those that
3309 should be output in .debug_frame (@code{@var{for_eh}} is zero) and
3310 .eh_frame (@code{@var{for_eh}} is nonzero). The default is to
3311 return @code{@var{regno}}.
3316 @subsection Eliminating Frame Pointer and Arg Pointer
3318 @c prevent bad page break with this line
3319 This is about eliminating the frame pointer and arg pointer.
3321 @defmac FRAME_POINTER_REQUIRED
3322 A C expression which is nonzero if a function must have and use a frame
3323 pointer. This expression is evaluated in the reload pass. If its value is
3324 nonzero the function will have a frame pointer.
3326 The expression can in principle examine the current function and decide
3327 according to the facts, but on most machines the constant 0 or the
3328 constant 1 suffices. Use 0 when the machine allows code to be generated
3329 with no frame pointer, and doing so saves some time or space. Use 1
3330 when there is no possible advantage to avoiding a frame pointer.
3332 In certain cases, the compiler does not know how to produce valid code
3333 without a frame pointer. The compiler recognizes those cases and
3334 automatically gives the function a frame pointer regardless of what
3335 @code{FRAME_POINTER_REQUIRED} says. You don't need to worry about
3338 In a function that does not require a frame pointer, the frame pointer
3339 register can be allocated for ordinary usage, unless you mark it as a
3340 fixed register. See @code{FIXED_REGISTERS} for more information.
3343 @findex get_frame_size
3344 @defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var})
3345 A C statement to store in the variable @var{depth-var} the difference
3346 between the frame pointer and the stack pointer values immediately after
3347 the function prologue. The value would be computed from information
3348 such as the result of @code{get_frame_size ()} and the tables of
3349 registers @code{regs_ever_live} and @code{call_used_regs}.
3351 If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and
3352 need not be defined. Otherwise, it must be defined even if
3353 @code{FRAME_POINTER_REQUIRED} is defined to always be true; in that
3354 case, you may set @var{depth-var} to anything.
3357 @defmac ELIMINABLE_REGS
3358 If defined, this macro specifies a table of register pairs used to
3359 eliminate unneeded registers that point into the stack frame. If it is not
3360 defined, the only elimination attempted by the compiler is to replace
3361 references to the frame pointer with references to the stack pointer.
3363 The definition of this macro is a list of structure initializations, each
3364 of which specifies an original and replacement register.
3366 On some machines, the position of the argument pointer is not known until
3367 the compilation is completed. In such a case, a separate hard register
3368 must be used for the argument pointer. This register can be eliminated by
3369 replacing it with either the frame pointer or the argument pointer,
3370 depending on whether or not the frame pointer has been eliminated.
3372 In this case, you might specify:
3374 #define ELIMINABLE_REGS \
3375 @{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \
3376 @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \
3377 @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@}
3380 Note that the elimination of the argument pointer with the stack pointer is
3381 specified first since that is the preferred elimination.
3384 @defmac CAN_ELIMINATE (@var{from-reg}, @var{to-reg})
3385 A C expression that returns nonzero if the compiler is allowed to try
3386 to replace register number @var{from-reg} with register number
3387 @var{to-reg}. This macro need only be defined if @code{ELIMINABLE_REGS}
3388 is defined, and will usually be the constant 1, since most of the cases
3389 preventing register elimination are things that the compiler already
3393 @defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var})
3394 This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It
3395 specifies the initial difference between the specified pair of
3396 registers. This macro must be defined if @code{ELIMINABLE_REGS} is
3400 @node Stack Arguments
3401 @subsection Passing Function Arguments on the Stack
3402 @cindex arguments on stack
3403 @cindex stack arguments
3405 The macros in this section control how arguments are passed
3406 on the stack. See the following section for other macros that
3407 control passing certain arguments in registers.
3409 @deftypefn {Target Hook} bool TARGET_PROMOTE_PROTOTYPES (tree @var{fntype})
3410 This target hook returns @code{true} if an argument declared in a
3411 prototype as an integral type smaller than @code{int} should actually be
3412 passed as an @code{int}. In addition to avoiding errors in certain
3413 cases of mismatch, it also makes for better code on certain machines.
3414 The default is to not promote prototypes.
3418 A C expression. If nonzero, push insns will be used to pass
3420 If the target machine does not have a push instruction, set it to zero.
3421 That directs GCC to use an alternate strategy: to
3422 allocate the entire argument block and then store the arguments into
3423 it. When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too.
3426 @defmac PUSH_ARGS_REVERSED
3427 A C expression. If nonzero, function arguments will be evaluated from
3428 last to first, rather than from first to last. If this macro is not
3429 defined, it defaults to @code{PUSH_ARGS} on targets where the stack
3430 and args grow in opposite directions, and 0 otherwise.
3433 @defmac PUSH_ROUNDING (@var{npushed})
3434 A C expression that is the number of bytes actually pushed onto the
3435 stack when an instruction attempts to push @var{npushed} bytes.
3437 On some machines, the definition
3440 #define PUSH_ROUNDING(BYTES) (BYTES)
3444 will suffice. But on other machines, instructions that appear
3445 to push one byte actually push two bytes in an attempt to maintain
3446 alignment. Then the definition should be
3449 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
3453 @findex current_function_outgoing_args_size
3454 @defmac ACCUMULATE_OUTGOING_ARGS
3455 A C expression. If nonzero, the maximum amount of space required for outgoing arguments
3456 will be computed and placed into the variable
3457 @code{current_function_outgoing_args_size}. No space will be pushed
3458 onto the stack for each call; instead, the function prologue should
3459 increase the stack frame size by this amount.
3461 Setting both @code{PUSH_ARGS} and @code{ACCUMULATE_OUTGOING_ARGS}
3465 @defmac REG_PARM_STACK_SPACE (@var{fndecl})
3466 Define this macro if functions should assume that stack space has been
3467 allocated for arguments even when their values are passed in
3470 The value of this macro is the size, in bytes, of the area reserved for
3471 arguments passed in registers for the function represented by @var{fndecl},
3472 which can be zero if GCC is calling a library function.
3474 This space can be allocated by the caller, or be a part of the
3475 machine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE} says
3478 @c above is overfull. not sure what to do. --mew 5feb93 did
3479 @c something, not sure if it looks good. --mew 10feb93
3481 @defmac OUTGOING_REG_PARM_STACK_SPACE
3482 Define this if it is the responsibility of the caller to allocate the area
3483 reserved for arguments passed in registers.
3485 If @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls
3486 whether the space for these arguments counts in the value of
3487 @code{current_function_outgoing_args_size}.
3490 @defmac STACK_PARMS_IN_REG_PARM_AREA
3491 Define this macro if @code{REG_PARM_STACK_SPACE} is defined, but the
3492 stack parameters don't skip the area specified by it.
3493 @c i changed this, makes more sens and it should have taken care of the
3494 @c overfull.. not as specific, tho. --mew 5feb93
3496 Normally, when a parameter is not passed in registers, it is placed on the
3497 stack beyond the @code{REG_PARM_STACK_SPACE} area. Defining this macro
3498 suppresses this behavior and causes the parameter to be passed on the
3499 stack in its natural location.
3502 @defmac RETURN_POPS_ARGS (@var{fundecl}, @var{funtype}, @var{stack-size})
3503 A C expression that should indicate the number of bytes of its own
3504 arguments that a function pops on returning, or 0 if the
3505 function pops no arguments and the caller must therefore pop them all
3506 after the function returns.
3508 @var{fundecl} is a C variable whose value is a tree node that describes
3509 the function in question. Normally it is a node of type
3510 @code{FUNCTION_DECL} that describes the declaration of the function.
3511 From this you can obtain the @code{DECL_ATTRIBUTES} of the function.
3513 @var{funtype} is a C variable whose value is a tree node that
3514 describes the function in question. Normally it is a node of type
3515 @code{FUNCTION_TYPE} that describes the data type of the function.
3516 From this it is possible to obtain the data types of the value and
3517 arguments (if known).
3519 When a call to a library function is being considered, @var{fundecl}
3520 will contain an identifier node for the library function. Thus, if
3521 you need to distinguish among various library functions, you can do so
3522 by their names. Note that ``library function'' in this context means
3523 a function used to perform arithmetic, whose name is known specially
3524 in the compiler and was not mentioned in the C code being compiled.
3526 @var{stack-size} is the number of bytes of arguments passed on the
3527 stack. If a variable number of bytes is passed, it is zero, and
3528 argument popping will always be the responsibility of the calling function.
3530 On the VAX, all functions always pop their arguments, so the definition
3531 of this macro is @var{stack-size}. On the 68000, using the standard
3532 calling convention, no functions pop their arguments, so the value of
3533 the macro is always 0 in this case. But an alternative calling
3534 convention is available in which functions that take a fixed number of
3535 arguments pop them but other functions (such as @code{printf}) pop
3536 nothing (the caller pops all). When this convention is in use,
3537 @var{funtype} is examined to determine whether a function takes a fixed
3538 number of arguments.
3541 @defmac CALL_POPS_ARGS (@var{cum})
3542 A C expression that should indicate the number of bytes a call sequence
3543 pops off the stack. It is added to the value of @code{RETURN_POPS_ARGS}
3544 when compiling a function call.
3546 @var{cum} is the variable in which all arguments to the called function
3547 have been accumulated.
3549 On certain architectures, such as the SH5, a call trampoline is used
3550 that pops certain registers off the stack, depending on the arguments
3551 that have been passed to the function. Since this is a property of the
3552 call site, not of the called function, @code{RETURN_POPS_ARGS} is not
3556 @node Register Arguments
3557 @subsection Passing Arguments in Registers
3558 @cindex arguments in registers
3559 @cindex registers arguments
3561 This section describes the macros which let you control how various
3562 types of arguments are passed in registers or how they are arranged in
3565 @defmac FUNCTION_ARG (@var{cum}, @var{mode}, @var{type}, @var{named})
3566 A C expression that controls whether a function argument is passed
3567 in a register, and which register.
3569 The arguments are @var{cum}, which summarizes all the previous
3570 arguments; @var{mode}, the machine mode of the argument; @var{type},
3571 the data type of the argument as a tree node or 0 if that is not known
3572 (which happens for C support library functions); and @var{named},
3573 which is 1 for an ordinary argument and 0 for nameless arguments that
3574 correspond to @samp{@dots{}} in the called function's prototype.
3575 @var{type} can be an incomplete type if a syntax error has previously
3578 The value of the expression is usually either a @code{reg} RTX for the
3579 hard register in which to pass the argument, or zero to pass the
3580 argument on the stack.
3582 For machines like the VAX and 68000, where normally all arguments are
3583 pushed, zero suffices as a definition.
3585 The value of the expression can also be a @code{parallel} RTX@. This is
3586 used when an argument is passed in multiple locations. The mode of the
3587 @code{parallel} should be the mode of the entire argument. The
3588 @code{parallel} holds any number of @code{expr_list} pairs; each one
3589 describes where part of the argument is passed. In each
3590 @code{expr_list} the first operand must be a @code{reg} RTX for the hard