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.
732 If the target defines @code{TARGET_SWITCHES}, the null
733 @code{TARGET_SWITCHES} entry will override this value.
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 @cindex optional hardware or system features
754 @cindex features, optional, in system conventions
756 @defmac TARGET_@var{featurename}
757 This series of macros is to allow compiler command arguments to
758 enable or disable the use of optional features of the target machine.
759 For example, one machine description serves both the 68000 and
760 the 68020; a command argument tells the compiler whether it should
761 use 68020-only instructions or not. This command argument works
762 by means of a macro @code{TARGET_68020} that tests a bit in
765 Define a macro @code{TARGET_@var{featurename}} for each such option.
766 Its definition should test a bit in @code{target_flags}. It is
767 recommended that a helper macro @code{MASK_@var{featurename}}
768 is defined for each bit-value to test, and used in
769 @code{TARGET_@var{featurename}} and @code{TARGET_SWITCHES}. For
773 #define TARGET_MASK_68020 1
774 #define TARGET_68020 (target_flags & MASK_68020)
777 One place where these macros are used is in the condition-expressions
778 of instruction patterns. Note how @code{TARGET_68020} appears
779 frequently in the 68000 machine description file, @file{m68k.md}.
780 Another place they are used is in the definitions of the other
781 macros in the @file{@var{machine}.h} file.
784 @defmac TARGET_SWITCHES
785 This macro defines names of command options to set and clear
786 bits in @code{target_flags}. Its definition is an initializer
787 with a subgrouping for each command option.
789 Each subgrouping contains a string constant, that defines the option
790 name, a number, which contains the bits to set in
791 @code{target_flags}, and a second string which is the description
792 displayed by @option{--help}. If the number is negative then the bits specified
793 by the number are cleared instead of being set. If the description
794 string is present but empty, then no help information will be displayed
795 for that option, but it will not count as an undocumented option. The
796 actual option name is made by appending @samp{-m} to the specified name.
797 Non-empty description strings should be marked with @code{N_(@dots{})} for
798 @command{xgettext}. Please do not mark empty strings because the empty
799 string is reserved by GNU gettext. @code{gettext("")} returns the header entry
800 of the message catalog with meta information, not the empty string.
802 In addition to the description for @option{--help},
803 more detailed documentation for each option should be added to
806 One of the subgroupings should have a null string. The number in
807 this grouping is the default value for @code{target_flags}. Any
808 target options act starting with that value.
810 Here is an example which defines @option{-m68000} and @option{-m68020}
811 with opposite meanings, and picks the latter as the default:
814 #define TARGET_SWITCHES \
815 @{ @{ "68020", MASK_68020, "" @}, \
816 @{ "68000", -MASK_68020, \
817 N_("Compile for the 68000") @}, \
818 @{ "", MASK_68020, "" @}, \
822 This macro is being kept for compatibility with older backends.
823 New targets should use option definition files instead.
827 @defmac TARGET_OPTIONS
828 This macro is similar to @code{TARGET_SWITCHES} but defines names of command
829 options that have values. Its definition is an initializer with a
830 subgrouping for each command option.
832 Each subgrouping contains a string constant, that defines the option
833 name, the address of a variable, a description string, and a value.
834 Non-empty description strings should be marked with @code{N_(@dots{})}
835 for @command{xgettext}. Please do not mark empty strings because the
836 empty string is reserved by GNU gettext. @code{gettext("")} returns the
837 header entry of the message catalog with meta information, not the empty
840 If the value listed in the table is @code{NULL}, then the variable, type
841 @code{char *}, is set to the variable part of the given option if the
842 fixed part matches. In other words, if the first part of the option
843 matches what's in the table, the variable will be set to point to the
844 rest of the option. This allows the user to specify a value for that
845 option. The actual option name is made by appending @samp{-m} to the
846 specified name. Again, each option should also be documented in
849 If the value listed in the table is non-@code{NULL}, then the option
850 must match the option in the table exactly (with @samp{-m}), and the
851 variable is set to point to the value listed in the table.
853 Here is an example which defines @option{-mshort-data-@var{number}}. If the
854 given option is @option{-mshort-data-512}, the variable @code{m88k_short_data}
855 will be set to the string @code{"512"}.
858 extern char *m88k_short_data;
859 #define TARGET_OPTIONS \
860 @{ @{ "short-data-", &m88k_short_data, \
861 N_("Specify the size of the short data section"), 0 @} @}
864 Here is a variant of the above that allows the user to also specify
865 just @option{-mshort-data} where a default of @code{"64"} is used.
868 extern char *m88k_short_data;
869 #define TARGET_OPTIONS \
870 @{ @{ "short-data-", &m88k_short_data, \
871 N_("Specify the size of the short data section"), 0 @} \
872 @{ "short-data", &m88k_short_data, "", "64" @},
876 Here is an example which defines @option{-mno-alu}, @option{-malu1}, and
877 @option{-malu2} as a three-state switch, along with suitable macros for
878 checking the state of the option (documentation is elided for brevity).
882 char *chip_alu = ""; /* @r{Specify default here.} */
885 extern char *chip_alu;
886 #define TARGET_OPTIONS \
887 @{ @{ "no-alu", &chip_alu, "", "" @}, \
888 @{ "alu1", &chip_alu, "", "1" @}, \
889 @{ "alu2", &chip_alu, "", "2" @}, @}
890 #define TARGET_ALU (chip_alu[0] != '\0')
891 #define TARGET_ALU1 (chip_alu[0] == '1')
892 #define TARGET_ALU2 (chip_alu[0] == '2')
895 This macro is being kept for compatibility with older backends.
896 New targets should use option definition files instead.
900 @defmac TARGET_VERSION
901 This macro is a C statement to print on @code{stderr} a string
902 describing the particular machine description choice. Every machine
903 description should define @code{TARGET_VERSION}. For example:
907 #define TARGET_VERSION \
908 fprintf (stderr, " (68k, Motorola syntax)");
910 #define TARGET_VERSION \
911 fprintf (stderr, " (68k, MIT syntax)");
916 @defmac OVERRIDE_OPTIONS
917 Sometimes certain combinations of command options do not make sense on
918 a particular target machine. You can define a macro
919 @code{OVERRIDE_OPTIONS} to take account of this. This macro, if
920 defined, is executed once just after all the command options have been
923 Don't use this macro to turn on various extra optimizations for
924 @option{-O}. That is what @code{OPTIMIZATION_OPTIONS} is for.
927 @defmac OPTIMIZATION_OPTIONS (@var{level}, @var{size})
928 Some machines may desire to change what optimizations are performed for
929 various optimization levels. This macro, if defined, is executed once
930 just after the optimization level is determined and before the remainder
931 of the command options have been parsed. Values set in this macro are
932 used as the default values for the other command line options.
934 @var{level} is the optimization level specified; 2 if @option{-O2} is
935 specified, 1 if @option{-O} is specified, and 0 if neither is specified.
937 @var{size} is nonzero if @option{-Os} is specified and zero otherwise.
939 You should not use this macro to change options that are not
940 machine-specific. These should uniformly selected by the same
941 optimization level on all supported machines. Use this macro to enable
942 machine-specific optimizations.
944 @strong{Do not examine @code{write_symbols} in
945 this macro!} The debugging options are not supposed to alter the
949 @defmac CAN_DEBUG_WITHOUT_FP
950 Define this macro if debugging can be performed even without a frame
951 pointer. If this macro is defined, GCC will turn on the
952 @option{-fomit-frame-pointer} option whenever @option{-O} is specified.
955 @node Per-Function Data
956 @section Defining data structures for per-function information.
957 @cindex per-function data
958 @cindex data structures
960 If the target needs to store information on a per-function basis, GCC
961 provides a macro and a couple of variables to allow this. Note, just
962 using statics to store the information is a bad idea, since GCC supports
963 nested functions, so you can be halfway through encoding one function
964 when another one comes along.
966 GCC defines a data structure called @code{struct function} which
967 contains all of the data specific to an individual function. This
968 structure contains a field called @code{machine} whose type is
969 @code{struct machine_function *}, which can be used by targets to point
970 to their own specific data.
972 If a target needs per-function specific data it should define the type
973 @code{struct machine_function} and also the macro @code{INIT_EXPANDERS}.
974 This macro should be used to initialize the function pointer
975 @code{init_machine_status}. This pointer is explained below.
977 One typical use of per-function, target specific data is to create an
978 RTX to hold the register containing the function's return address. This
979 RTX can then be used to implement the @code{__builtin_return_address}
980 function, for level 0.
982 Note---earlier implementations of GCC used a single data area to hold
983 all of the per-function information. Thus when processing of a nested
984 function began the old per-function data had to be pushed onto a
985 stack, and when the processing was finished, it had to be popped off the
986 stack. GCC used to provide function pointers called
987 @code{save_machine_status} and @code{restore_machine_status} to handle
988 the saving and restoring of the target specific information. Since the
989 single data area approach is no longer used, these pointers are no
992 @defmac INIT_EXPANDERS
993 Macro called to initialize any target specific information. This macro
994 is called once per function, before generation of any RTL has begun.
995 The intention of this macro is to allow the initialization of the
996 function pointer @code{init_machine_status}.
999 @deftypevar {void (*)(struct function *)} init_machine_status
1000 If this function pointer is non-@code{NULL} it will be called once per
1001 function, before function compilation starts, in order to allow the
1002 target to perform any target specific initialization of the
1003 @code{struct function} structure. It is intended that this would be
1004 used to initialize the @code{machine} of that structure.
1006 @code{struct machine_function} structures are expected to be freed by GC@.
1007 Generally, any memory that they reference must be allocated by using
1008 @code{ggc_alloc}, including the structure itself.
1011 @node Storage Layout
1012 @section Storage Layout
1013 @cindex storage layout
1015 Note that the definitions of the macros in this table which are sizes or
1016 alignments measured in bits do not need to be constant. They can be C
1017 expressions that refer to static variables, such as the @code{target_flags}.
1018 @xref{Run-time Target}.
1020 @defmac BITS_BIG_ENDIAN
1021 Define this macro to have the value 1 if the most significant bit in a
1022 byte has the lowest number; otherwise define it to have the value zero.
1023 This means that bit-field instructions count from the most significant
1024 bit. If the machine has no bit-field instructions, then this must still
1025 be defined, but it doesn't matter which value it is defined to. This
1026 macro need not be a constant.
1028 This macro does not affect the way structure fields are packed into
1029 bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}.
1032 @defmac BYTES_BIG_ENDIAN
1033 Define this macro to have the value 1 if the most significant byte in a
1034 word has the lowest number. This macro need not be a constant.
1037 @defmac WORDS_BIG_ENDIAN
1038 Define this macro to have the value 1 if, in a multiword object, the
1039 most significant word has the lowest number. This applies to both
1040 memory locations and registers; GCC fundamentally assumes that the
1041 order of words in memory is the same as the order in registers. This
1042 macro need not be a constant.
1045 @defmac LIBGCC2_WORDS_BIG_ENDIAN
1046 Define this macro if @code{WORDS_BIG_ENDIAN} is not constant. This must be a
1047 constant value with the same meaning as @code{WORDS_BIG_ENDIAN}, which will be
1048 used only when compiling @file{libgcc2.c}. Typically the value will be set
1049 based on preprocessor defines.
1052 @defmac FLOAT_WORDS_BIG_ENDIAN
1053 Define this macro to have the value 1 if @code{DFmode}, @code{XFmode} or
1054 @code{TFmode} floating point numbers are stored in memory with the word
1055 containing the sign bit at the lowest address; otherwise define it to
1056 have the value 0. This macro need not be a constant.
1058 You need not define this macro if the ordering is the same as for
1059 multi-word integers.
1062 @defmac BITS_PER_UNIT
1063 Define this macro to be the number of bits in an addressable storage
1064 unit (byte). If you do not define this macro the default is 8.
1067 @defmac BITS_PER_WORD
1068 Number of bits in a word. If you do not define this macro, the default
1069 is @code{BITS_PER_UNIT * UNITS_PER_WORD}.
1072 @defmac MAX_BITS_PER_WORD
1073 Maximum number of bits in a word. If this is undefined, the default is
1074 @code{BITS_PER_WORD}. Otherwise, it is the constant value that is the
1075 largest value that @code{BITS_PER_WORD} can have at run-time.
1078 @defmac UNITS_PER_WORD
1079 Number of storage units in a word; normally 4.
1082 @defmac MIN_UNITS_PER_WORD
1083 Minimum number of units in a word. If this is undefined, the default is
1084 @code{UNITS_PER_WORD}. Otherwise, it is the constant value that is the
1085 smallest value that @code{UNITS_PER_WORD} can have at run-time.
1088 @defmac POINTER_SIZE
1089 Width of a pointer, in bits. You must specify a value no wider than the
1090 width of @code{Pmode}. If it is not equal to the width of @code{Pmode},
1091 you must define @code{POINTERS_EXTEND_UNSIGNED}. If you do not specify
1092 a value the default is @code{BITS_PER_WORD}.
1095 @defmac POINTERS_EXTEND_UNSIGNED
1096 A C expression whose value is greater than zero if pointers that need to be
1097 extended from being @code{POINTER_SIZE} bits wide to @code{Pmode} are to
1098 be zero-extended and zero if they are to be sign-extended. If the value
1099 is less then zero then there must be an "ptr_extend" instruction that
1100 extends a pointer from @code{POINTER_SIZE} to @code{Pmode}.
1102 You need not define this macro if the @code{POINTER_SIZE} is equal
1103 to the width of @code{Pmode}.
1106 @defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type})
1107 A macro to update @var{m} and @var{unsignedp} when an object whose type
1108 is @var{type} and which has the specified mode and signedness is to be
1109 stored in a register. This macro is only called when @var{type} is a
1112 On most RISC machines, which only have operations that operate on a full
1113 register, define this macro to set @var{m} to @code{word_mode} if
1114 @var{m} is an integer mode narrower than @code{BITS_PER_WORD}. In most
1115 cases, only integer modes should be widened because wider-precision
1116 floating-point operations are usually more expensive than their narrower
1119 For most machines, the macro definition does not change @var{unsignedp}.
1120 However, some machines, have instructions that preferentially handle
1121 either signed or unsigned quantities of certain modes. For example, on
1122 the DEC Alpha, 32-bit loads from memory and 32-bit add instructions
1123 sign-extend the result to 64 bits. On such machines, set
1124 @var{unsignedp} according to which kind of extension is more efficient.
1126 Do not define this macro if it would never modify @var{m}.
1129 @defmac PROMOTE_FUNCTION_MODE
1130 Like @code{PROMOTE_MODE}, but is applied to outgoing function arguments or
1131 function return values, as specified by @code{TARGET_PROMOTE_FUNCTION_ARGS}
1132 and @code{TARGET_PROMOTE_FUNCTION_RETURN}, respectively.
1134 The default is @code{PROMOTE_MODE}.
1137 @deftypefn {Target Hook} bool TARGET_PROMOTE_FUNCTION_ARGS (tree @var{fntype})
1138 This target hook should return @code{true} if the promotion described by
1139 @code{PROMOTE_FUNCTION_MODE} should be done for outgoing function
1143 @deftypefn {Target Hook} bool TARGET_PROMOTE_FUNCTION_RETURN (tree @var{fntype})
1144 This target hook should return @code{true} if the promotion described by
1145 @code{PROMOTE_FUNCTION_MODE} should be done for the return value of
1148 If this target hook returns @code{true}, @code{FUNCTION_VALUE} must
1149 perform the same promotions done by @code{PROMOTE_FUNCTION_MODE}.
1152 @defmac PARM_BOUNDARY
1153 Normal alignment required for function parameters on the stack, in
1154 bits. All stack parameters receive at least this much alignment
1155 regardless of data type. On most machines, this is the same as the
1159 @defmac STACK_BOUNDARY
1160 Define this macro to the minimum alignment enforced by hardware for the
1161 stack pointer on this machine. The definition is a C expression for the
1162 desired alignment (measured in bits). This value is used as a default
1163 if @code{PREFERRED_STACK_BOUNDARY} is not defined. On most machines,
1164 this should be the same as @code{PARM_BOUNDARY}.
1167 @defmac PREFERRED_STACK_BOUNDARY
1168 Define this macro if you wish to preserve a certain alignment for the
1169 stack pointer, greater than what the hardware enforces. The definition
1170 is a C expression for the desired alignment (measured in bits). This
1171 macro must evaluate to a value equal to or larger than
1172 @code{STACK_BOUNDARY}.
1175 @defmac FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
1176 A C expression that evaluates true if @code{PREFERRED_STACK_BOUNDARY} is
1177 not guaranteed by the runtime and we should emit code to align the stack
1178 at the beginning of @code{main}.
1180 @cindex @code{PUSH_ROUNDING}, interaction with @code{PREFERRED_STACK_BOUNDARY}
1181 If @code{PUSH_ROUNDING} is not defined, the stack will always be aligned
1182 to the specified boundary. If @code{PUSH_ROUNDING} is defined and specifies
1183 a less strict alignment than @code{PREFERRED_STACK_BOUNDARY}, the stack may
1184 be momentarily unaligned while pushing arguments.
1187 @defmac FUNCTION_BOUNDARY
1188 Alignment required for a function entry point, in bits.
1191 @defmac BIGGEST_ALIGNMENT
1192 Biggest alignment that any data type can require on this machine, in bits.
1195 @defmac MINIMUM_ATOMIC_ALIGNMENT
1196 If defined, the smallest alignment, in bits, that can be given to an
1197 object that can be referenced in one operation, without disturbing any
1198 nearby object. Normally, this is @code{BITS_PER_UNIT}, but may be larger
1199 on machines that don't have byte or half-word store operations.
1202 @defmac BIGGEST_FIELD_ALIGNMENT
1203 Biggest alignment that any structure or union field can require on this
1204 machine, in bits. If defined, this overrides @code{BIGGEST_ALIGNMENT} for
1205 structure and union fields only, unless the field alignment has been set
1206 by the @code{__attribute__ ((aligned (@var{n})))} construct.
1209 @defmac ADJUST_FIELD_ALIGN (@var{field}, @var{computed})
1210 An expression for the alignment of a structure field @var{field} if the
1211 alignment computed in the usual way (including applying of
1212 @code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the
1213 alignment) is @var{computed}. It overrides alignment only if the
1214 field alignment has not been set by the
1215 @code{__attribute__ ((aligned (@var{n})))} construct.
1218 @defmac MAX_OFILE_ALIGNMENT
1219 Biggest alignment supported by the object file format of this machine.
1220 Use this macro to limit the alignment which can be specified using the
1221 @code{__attribute__ ((aligned (@var{n})))} construct. If not defined,
1222 the default value is @code{BIGGEST_ALIGNMENT}.
1225 @defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
1226 If defined, a C expression to compute the alignment for a variable in
1227 the static store. @var{type} is the data type, and @var{basic-align} is
1228 the alignment that the object would ordinarily have. The value of this
1229 macro is used instead of that alignment to align the object.
1231 If this macro is not defined, then @var{basic-align} is used.
1234 One use of this macro is to increase alignment of medium-size data to
1235 make it all fit in fewer cache lines. Another is to cause character
1236 arrays to be word-aligned so that @code{strcpy} calls that copy
1237 constants to character arrays can be done inline.
1240 @defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
1241 If defined, a C expression to compute the alignment given to a constant
1242 that is being placed in memory. @var{constant} is the constant and
1243 @var{basic-align} is the alignment that the object would ordinarily
1244 have. The value of this macro is used instead of that alignment to
1247 If this macro is not defined, then @var{basic-align} is used.
1249 The typical use of this macro is to increase alignment for string
1250 constants to be word aligned so that @code{strcpy} calls that copy
1251 constants can be done inline.
1254 @defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
1255 If defined, a C expression to compute the alignment for a variable in
1256 the local store. @var{type} is the data type, and @var{basic-align} is
1257 the alignment that the object would ordinarily have. The value of this
1258 macro is used instead of that alignment to align the object.
1260 If this macro is not defined, then @var{basic-align} is used.
1262 One use of this macro is to increase alignment of medium-size data to
1263 make it all fit in fewer cache lines.
1266 @defmac EMPTY_FIELD_BOUNDARY
1267 Alignment in bits to be given to a structure bit-field that follows an
1268 empty field such as @code{int : 0;}.
1270 If @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro.
1273 @defmac STRUCTURE_SIZE_BOUNDARY
1274 Number of bits which any structure or union's size must be a multiple of.
1275 Each structure or union's size is rounded up to a multiple of this.
1277 If you do not define this macro, the default is the same as
1278 @code{BITS_PER_UNIT}.
1281 @defmac STRICT_ALIGNMENT
1282 Define this macro to be the value 1 if instructions will fail to work
1283 if given data not on the nominal alignment. If instructions will merely
1284 go slower in that case, define this macro as 0.
1287 @defmac PCC_BITFIELD_TYPE_MATTERS
1288 Define this if you wish to imitate the way many other C compilers handle
1289 alignment of bit-fields and the structures that contain them.
1291 The behavior is that the type written for a named bit-field (@code{int},
1292 @code{short}, or other integer type) imposes an alignment for the entire
1293 structure, as if the structure really did contain an ordinary field of
1294 that type. In addition, the bit-field is placed within the structure so
1295 that it would fit within such a field, not crossing a boundary for it.
1297 Thus, on most machines, a named bit-field whose type is written as
1298 @code{int} would not cross a four-byte boundary, and would force
1299 four-byte alignment for the whole structure. (The alignment used may
1300 not be four bytes; it is controlled by the other alignment parameters.)
1302 An unnamed bit-field will not affect the alignment of the containing
1305 If the macro is defined, its definition should be a C expression;
1306 a nonzero value for the expression enables this behavior.
1308 Note that if this macro is not defined, or its value is zero, some
1309 bit-fields may cross more than one alignment boundary. The compiler can
1310 support such references if there are @samp{insv}, @samp{extv}, and
1311 @samp{extzv} insns that can directly reference memory.
1313 The other known way of making bit-fields work is to define
1314 @code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}.
1315 Then every structure can be accessed with fullwords.
1317 Unless the machine has bit-field instructions or you define
1318 @code{STRUCTURE_SIZE_BOUNDARY} that way, you must define
1319 @code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value.
1321 If your aim is to make GCC use the same conventions for laying out
1322 bit-fields as are used by another compiler, here is how to investigate
1323 what the other compiler does. Compile and run this program:
1342 printf ("Size of foo1 is %d\n",
1343 sizeof (struct foo1));
1344 printf ("Size of foo2 is %d\n",
1345 sizeof (struct foo2));
1350 If this prints 2 and 5, then the compiler's behavior is what you would
1351 get from @code{PCC_BITFIELD_TYPE_MATTERS}.
1354 @defmac BITFIELD_NBYTES_LIMITED
1355 Like @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited
1356 to aligning a bit-field within the structure.
1359 @deftypefn {Target Hook} bool TARGET_ALIGN_ANON_BITFIELDS (void)
1360 When @code{PCC_BITFIELD_TYPE_MATTERS} is true this hook will determine
1361 whether unnamed bitfields affect the alignment of the containing
1362 structure. The hook should return true if the structure should inherit
1363 the alignment requirements of an unnamed bitfield's type.
1366 @defmac MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode})
1367 Return 1 if a structure or array containing @var{field} should be accessed using
1370 If @var{field} is the only field in the structure, @var{mode} is its
1371 mode, otherwise @var{mode} is VOIDmode. @var{mode} is provided in the
1372 case where structures of one field would require the structure's mode to
1373 retain the field's mode.
1375 Normally, this is not needed. See the file @file{c4x.h} for an example
1376 of how to use this macro to prevent a structure having a floating point
1377 field from being accessed in an integer mode.
1380 @defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified})
1381 Define this macro as an expression for the alignment of a type (given
1382 by @var{type} as a tree node) if the alignment computed in the usual
1383 way is @var{computed} and the alignment explicitly specified was
1386 The default is to use @var{specified} if it is larger; otherwise, use
1387 the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT}
1390 @defmac MAX_FIXED_MODE_SIZE
1391 An integer expression for the size in bits of the largest integer
1392 machine mode that should actually be used. All integer machine modes of
1393 this size or smaller can be used for structures and unions with the
1394 appropriate sizes. If this macro is undefined, @code{GET_MODE_BITSIZE
1395 (DImode)} is assumed.
1398 @defmac STACK_SAVEAREA_MODE (@var{save_level})
1399 If defined, an expression of type @code{enum machine_mode} that
1400 specifies the mode of the save area operand of a
1401 @code{save_stack_@var{level}} named pattern (@pxref{Standard Names}).
1402 @var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or
1403 @code{SAVE_NONLOCAL} and selects which of the three named patterns is
1404 having its mode specified.
1406 You need not define this macro if it always returns @code{Pmode}. You
1407 would most commonly define this macro if the
1408 @code{save_stack_@var{level}} patterns need to support both a 32- and a
1412 @defmac STACK_SIZE_MODE
1413 If defined, an expression of type @code{enum machine_mode} that
1414 specifies the mode of the size increment operand of an
1415 @code{allocate_stack} named pattern (@pxref{Standard Names}).
1417 You need not define this macro if it always returns @code{word_mode}.
1418 You would most commonly define this macro if the @code{allocate_stack}
1419 pattern needs to support both a 32- and a 64-bit mode.
1422 @defmac TARGET_FLOAT_FORMAT
1423 A code distinguishing the floating point format of the target machine.
1424 There are four defined values:
1427 @item IEEE_FLOAT_FORMAT
1428 This code indicates IEEE floating point. It is the default; there is no
1429 need to define @code{TARGET_FLOAT_FORMAT} when the format is IEEE@.
1431 @item VAX_FLOAT_FORMAT
1432 This code indicates the ``F float'' (for @code{float}) and ``D float''
1433 or ``G float'' formats (for @code{double}) used on the VAX and PDP-11@.
1435 @item IBM_FLOAT_FORMAT
1436 This code indicates the format used on the IBM System/370.
1438 @item C4X_FLOAT_FORMAT
1439 This code indicates the format used on the TMS320C3x/C4x.
1442 If your target uses a floating point format other than these, you must
1443 define a new @var{name}_FLOAT_FORMAT code for it, and add support for
1444 it to @file{real.c}.
1446 The ordering of the component words of floating point values stored in
1447 memory is controlled by @code{FLOAT_WORDS_BIG_ENDIAN}.
1450 @defmac MODE_HAS_NANS (@var{mode})
1451 When defined, this macro should be true if @var{mode} has a NaN
1452 representation. The compiler assumes that NaNs are not equal to
1453 anything (including themselves) and that addition, subtraction,
1454 multiplication and division all return NaNs when one operand is
1457 By default, this macro is true if @var{mode} is a floating-point
1458 mode and the target floating-point format is IEEE@.
1461 @defmac MODE_HAS_INFINITIES (@var{mode})
1462 This macro should be true if @var{mode} can represent infinity. At
1463 present, the compiler uses this macro to decide whether @samp{x - x}
1464 is always defined. By default, the macro is true when @var{mode}
1465 is a floating-point mode and the target format is IEEE@.
1468 @defmac MODE_HAS_SIGNED_ZEROS (@var{mode})
1469 True if @var{mode} distinguishes between positive and negative zero.
1470 The rules are expected to follow the IEEE standard:
1474 @samp{x + x} has the same sign as @samp{x}.
1477 If the sum of two values with opposite sign is zero, the result is
1478 positive for all rounding modes expect towards @minus{}infinity, for
1479 which it is negative.
1482 The sign of a product or quotient is negative when exactly one
1483 of the operands is negative.
1486 The default definition is true if @var{mode} is a floating-point
1487 mode and the target format is IEEE@.
1490 @defmac MODE_HAS_SIGN_DEPENDENT_ROUNDING (@var{mode})
1491 If defined, this macro should be true for @var{mode} if it has at
1492 least one rounding mode in which @samp{x} and @samp{-x} can be
1493 rounded to numbers of different magnitude. Two such modes are
1494 towards @minus{}infinity and towards +infinity.
1496 The default definition of this macro is true if @var{mode} is
1497 a floating-point mode and the target format is IEEE@.
1500 @defmac ROUND_TOWARDS_ZERO
1501 If defined, this macro should be true if the prevailing rounding
1502 mode is towards zero. A true value has the following effects:
1506 @code{MODE_HAS_SIGN_DEPENDENT_ROUNDING} will be false for all modes.
1509 @file{libgcc.a}'s floating-point emulator will round towards zero
1510 rather than towards nearest.
1513 The compiler's floating-point emulator will round towards zero after
1514 doing arithmetic, and when converting from the internal float format to
1518 The macro does not affect the parsing of string literals. When the
1519 primary rounding mode is towards zero, library functions like
1520 @code{strtod} might still round towards nearest, and the compiler's
1521 parser should behave like the target's @code{strtod} where possible.
1523 Not defining this macro is equivalent to returning zero.
1526 @defmac LARGEST_EXPONENT_IS_NORMAL (@var{size})
1527 This macro should return true if floats with @var{size}
1528 bits do not have a NaN or infinity representation, but use the largest
1529 exponent for normal numbers instead.
1531 Defining this macro to true for @var{size} causes @code{MODE_HAS_NANS}
1532 and @code{MODE_HAS_INFINITIES} to be false for @var{size}-bit modes.
1533 It also affects the way @file{libgcc.a} and @file{real.c} emulate
1534 floating-point arithmetic.
1536 The default definition of this macro returns false for all sizes.
1539 @deftypefn {Target Hook} bool TARGET_VECTOR_OPAQUE_P (tree @var{type})
1540 This target hook should return @code{true} a vector is opaque. That
1541 is, if no cast is needed when copying a vector value of type
1542 @var{type} into another vector lvalue of the same size. Vector opaque
1543 types cannot be initialized. The default is that there are no such
1547 @deftypefn {Target Hook} bool TARGET_MS_BITFIELD_LAYOUT_P (tree @var{record_type})
1548 This target hook returns @code{true} if bit-fields in the given
1549 @var{record_type} are to be laid out following the rules of Microsoft
1550 Visual C/C++, namely: (i) a bit-field won't share the same storage
1551 unit with the previous bit-field if their underlying types have
1552 different sizes, and the bit-field will be aligned to the highest
1553 alignment of the underlying types of itself and of the previous
1554 bit-field; (ii) a zero-sized bit-field will affect the alignment of
1555 the whole enclosing structure, even if it is unnamed; except that
1556 (iii) a zero-sized bit-field will be disregarded unless it follows
1557 another bit-field of nonzero size. If this hook returns @code{true},
1558 other macros that control bit-field layout are ignored.
1560 When a bit-field is inserted into a packed record, the whole size
1561 of the underlying type is used by one or more same-size adjacent
1562 bit-fields (that is, if its long:3, 32 bits is used in the record,
1563 and any additional adjacent long bit-fields are packed into the same
1564 chunk of 32 bits. However, if the size changes, a new field of that
1565 size is allocated). In an unpacked record, this is the same as using
1566 alignment, but not equivalent when packing.
1568 If both MS bit-fields and @samp{__attribute__((packed))} are used,
1569 the latter will take precedence. If @samp{__attribute__((packed))} is
1570 used on a single field when MS bit-fields are in use, it will take
1571 precedence for that field, but the alignment of the rest of the structure
1572 may affect its placement.
1575 @deftypefn {Target Hook} {const char *} TARGET_MANGLE_FUNDAMENTAL_TYPE (tree @var{type})
1576 If your target defines any fundamental types, define this hook to
1577 return the appropriate encoding for these types as part of a C++
1578 mangled name. The @var{type} argument is the tree structure
1579 representing the type to be mangled. The hook may be applied to trees
1580 which are not target-specific fundamental types; it should return
1581 @code{NULL} for all such types, as well as arguments it does not
1582 recognize. If the return value is not @code{NULL}, it must point to
1583 a statically-allocated string constant.
1585 Target-specific fundamental types might be new fundamental types or
1586 qualified versions of ordinary fundamental types. Encode new
1587 fundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name}
1588 is the name used for the type in source code, and @var{n} is the
1589 length of @var{name} in decimal. Encode qualified versions of
1590 ordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where
1591 @var{name} is the name used for the type qualifier in source code,
1592 @var{n} is the length of @var{name} as above, and @var{code} is the
1593 code used to represent the unqualified version of this type. (See
1594 @code{write_builtin_type} in @file{cp/mangle.c} for the list of
1595 codes.) In both cases the spaces are for clarity; do not include any
1596 spaces in your string.
1598 The default version of this hook always returns @code{NULL}, which is
1599 appropriate for a target that does not define any new fundamental
1604 @section Layout of Source Language Data Types
1606 These macros define the sizes and other characteristics of the standard
1607 basic data types used in programs being compiled. Unlike the macros in
1608 the previous section, these apply to specific features of C and related
1609 languages, rather than to fundamental aspects of storage layout.
1611 @defmac INT_TYPE_SIZE
1612 A C expression for the size in bits of the type @code{int} on the
1613 target machine. If you don't define this, the default is one word.
1616 @defmac SHORT_TYPE_SIZE
1617 A C expression for the size in bits of the type @code{short} on the
1618 target machine. If you don't define this, the default is half a word.
1619 (If this would be less than one storage unit, it is rounded up to one
1623 @defmac LONG_TYPE_SIZE
1624 A C expression for the size in bits of the type @code{long} on the
1625 target machine. If you don't define this, the default is one word.
1628 @defmac ADA_LONG_TYPE_SIZE
1629 On some machines, the size used for the Ada equivalent of the type
1630 @code{long} by a native Ada compiler differs from that used by C@. In
1631 that situation, define this macro to be a C expression to be used for
1632 the size of that type. If you don't define this, the default is the
1633 value of @code{LONG_TYPE_SIZE}.
1636 @defmac LONG_LONG_TYPE_SIZE
1637 A C expression for the size in bits of the type @code{long long} on the
1638 target machine. If you don't define this, the default is two
1639 words. If you want to support GNU Ada on your machine, the value of this
1640 macro must be at least 64.
1643 @defmac CHAR_TYPE_SIZE
1644 A C expression for the size in bits of the type @code{char} on the
1645 target machine. If you don't define this, the default is
1646 @code{BITS_PER_UNIT}.
1649 @defmac BOOL_TYPE_SIZE
1650 A C expression for the size in bits of the C++ type @code{bool} and
1651 C99 type @code{_Bool} on the target machine. If you don't define
1652 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
1655 @defmac FLOAT_TYPE_SIZE
1656 A C expression for the size in bits of the type @code{float} on the
1657 target machine. If you don't define this, the default is one word.
1660 @defmac DOUBLE_TYPE_SIZE
1661 A C expression for the size in bits of the type @code{double} on the
1662 target machine. If you don't define this, the default is two
1666 @defmac LONG_DOUBLE_TYPE_SIZE
1667 A C expression for the size in bits of the type @code{long double} on
1668 the target machine. If you don't define this, the default is two
1672 @defmac LIBGCC2_LONG_DOUBLE_TYPE_SIZE
1673 Define this macro if @code{LONG_DOUBLE_TYPE_SIZE} is not constant or
1674 if you want routines in @file{libgcc2.a} for a size other than
1675 @code{LONG_DOUBLE_TYPE_SIZE}. If you don't define this, the
1676 default is @code{LONG_DOUBLE_TYPE_SIZE}.
1679 @defmac LIBGCC2_HAS_DF_MODE
1680 Define this macro if neither @code{LIBGCC2_DOUBLE_TYPE_SIZE} nor
1681 @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is
1682 @code{DFmode} but you want @code{DFmode} routines in @file{libgcc2.a}
1683 anyway. If you don't define this and either @code{LIBGCC2_DOUBLE_TYPE_SIZE}
1684 or @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64 then the default is 1,
1688 @defmac LIBGCC2_HAS_XF_MODE
1689 Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1690 @code{XFmode} but you want @code{XFmode} routines in @file{libgcc2.a}
1691 anyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1692 is 80 then the default is 1, otherwise it is 0.
1695 @defmac LIBGCC2_HAS_TF_MODE
1696 Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1697 @code{TFmode} but you want @code{TFmode} routines in @file{libgcc2.a}
1698 anyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1699 is 128 then the default is 1, otherwise it is 0.
1702 @defmac TARGET_FLT_EVAL_METHOD
1703 A C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h},
1704 assuming, if applicable, that the floating-point control word is in its
1705 default state. If you do not define this macro the value of
1706 @code{FLT_EVAL_METHOD} will be zero.
1709 @defmac WIDEST_HARDWARE_FP_SIZE
1710 A C expression for the size in bits of the widest floating-point format
1711 supported by the hardware. If you define this macro, you must specify a
1712 value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
1713 If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
1717 @defmac DEFAULT_SIGNED_CHAR
1718 An expression whose value is 1 or 0, according to whether the type
1719 @code{char} should be signed or unsigned by default. The user can
1720 always override this default with the options @option{-fsigned-char}
1721 and @option{-funsigned-char}.
1724 @deftypefn {Target Hook} bool TARGET_DEFAULT_SHORT_ENUMS (void)
1725 This target hook should return true if the compiler should give an
1726 @code{enum} type only as many bytes as it takes to represent the range
1727 of possible values of that type. It should return false if all
1728 @code{enum} types should be allocated like @code{int}.
1730 The default is to return false.
1734 A C expression for a string describing the name of the data type to use
1735 for size values. The typedef name @code{size_t} is defined using the
1736 contents of the string.
1738 The string can contain more than one keyword. If so, separate them with
1739 spaces, and write first any length keyword, then @code{unsigned} if
1740 appropriate, and finally @code{int}. The string must exactly match one
1741 of the data type names defined in the function
1742 @code{init_decl_processing} in the file @file{c-decl.c}. You may not
1743 omit @code{int} or change the order---that would cause the compiler to
1746 If you don't define this macro, the default is @code{"long unsigned
1750 @defmac PTRDIFF_TYPE
1751 A C expression for a string describing the name of the data type to use
1752 for the result of subtracting two pointers. The typedef name
1753 @code{ptrdiff_t} is defined using the contents of the string. See
1754 @code{SIZE_TYPE} above for more information.
1756 If you don't define this macro, the default is @code{"long int"}.
1760 A C expression for a string describing the name of the data type to use
1761 for wide characters. The typedef name @code{wchar_t} is defined using
1762 the contents of the string. See @code{SIZE_TYPE} above for more
1765 If you don't define this macro, the default is @code{"int"}.
1768 @defmac WCHAR_TYPE_SIZE
1769 A C expression for the size in bits of the data type for wide
1770 characters. This is used in @code{cpp}, which cannot make use of
1775 A C expression for a string describing the name of the data type to
1776 use for wide characters passed to @code{printf} and returned from
1777 @code{getwc}. The typedef name @code{wint_t} is defined using the
1778 contents of the string. See @code{SIZE_TYPE} above for more
1781 If you don't define this macro, the default is @code{"unsigned int"}.
1785 A C expression for a string describing the name of the data type that
1786 can represent any value of any standard or extended signed integer type.
1787 The typedef name @code{intmax_t} is defined using the contents of the
1788 string. See @code{SIZE_TYPE} above for more information.
1790 If you don't define this macro, the default is the first of
1791 @code{"int"}, @code{"long int"}, or @code{"long long int"} that has as
1792 much precision as @code{long long int}.
1795 @defmac UINTMAX_TYPE
1796 A C expression for a string describing the name of the data type that
1797 can represent any value of any standard or extended unsigned integer
1798 type. The typedef name @code{uintmax_t} is defined using the contents
1799 of the string. See @code{SIZE_TYPE} above for more information.
1801 If you don't define this macro, the default is the first of
1802 @code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long
1803 unsigned int"} that has as much precision as @code{long long unsigned
1807 @defmac TARGET_PTRMEMFUNC_VBIT_LOCATION
1808 The C++ compiler represents a pointer-to-member-function with a struct
1815 ptrdiff_t vtable_index;
1822 The C++ compiler must use one bit to indicate whether the function that
1823 will be called through a pointer-to-member-function is virtual.
1824 Normally, we assume that the low-order bit of a function pointer must
1825 always be zero. Then, by ensuring that the vtable_index is odd, we can
1826 distinguish which variant of the union is in use. But, on some
1827 platforms function pointers can be odd, and so this doesn't work. In
1828 that case, we use the low-order bit of the @code{delta} field, and shift
1829 the remainder of the @code{delta} field to the left.
1831 GCC will automatically make the right selection about where to store
1832 this bit using the @code{FUNCTION_BOUNDARY} setting for your platform.
1833 However, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY}
1834 set such that functions always start at even addresses, but the lowest
1835 bit of pointers to functions indicate whether the function at that
1836 address is in ARM or Thumb mode. If this is the case of your
1837 architecture, you should define this macro to
1838 @code{ptrmemfunc_vbit_in_delta}.
1840 In general, you should not have to define this macro. On architectures
1841 in which function addresses are always even, according to
1842 @code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to
1843 @code{ptrmemfunc_vbit_in_pfn}.
1846 @defmac TARGET_VTABLE_USES_DESCRIPTORS
1847 Normally, the C++ compiler uses function pointers in vtables. This
1848 macro allows the target to change to use ``function descriptors''
1849 instead. Function descriptors are found on targets for whom a
1850 function pointer is actually a small data structure. Normally the
1851 data structure consists of the actual code address plus a data
1852 pointer to which the function's data is relative.
1854 If vtables are used, the value of this macro should be the number
1855 of words that the function descriptor occupies.
1858 @defmac TARGET_VTABLE_ENTRY_ALIGN
1859 By default, the vtable entries are void pointers, the so the alignment
1860 is the same as pointer alignment. The value of this macro specifies
1861 the alignment of the vtable entry in bits. It should be defined only
1862 when special alignment is necessary. */
1865 @defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE
1866 There are a few non-descriptor entries in the vtable at offsets below
1867 zero. If these entries must be padded (say, to preserve the alignment
1868 specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
1869 of words in each data entry.
1873 @section Register Usage
1874 @cindex register usage
1876 This section explains how to describe what registers the target machine
1877 has, and how (in general) they can be used.
1879 The description of which registers a specific instruction can use is
1880 done with register classes; see @ref{Register Classes}. For information
1881 on using registers to access a stack frame, see @ref{Frame Registers}.
1882 For passing values in registers, see @ref{Register Arguments}.
1883 For returning values in registers, see @ref{Scalar Return}.
1886 * Register Basics:: Number and kinds of registers.
1887 * Allocation Order:: Order in which registers are allocated.
1888 * Values in Registers:: What kinds of values each reg can hold.
1889 * Leaf Functions:: Renumbering registers for leaf functions.
1890 * Stack Registers:: Handling a register stack such as 80387.
1893 @node Register Basics
1894 @subsection Basic Characteristics of Registers
1896 @c prevent bad page break with this line
1897 Registers have various characteristics.
1899 @defmac FIRST_PSEUDO_REGISTER
1900 Number of hardware registers known to the compiler. They receive
1901 numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
1902 pseudo register's number really is assigned the number
1903 @code{FIRST_PSEUDO_REGISTER}.
1906 @defmac FIXED_REGISTERS
1907 @cindex fixed register
1908 An initializer that says which registers are used for fixed purposes
1909 all throughout the compiled code and are therefore not available for
1910 general allocation. These would include the stack pointer, the frame
1911 pointer (except on machines where that can be used as a general
1912 register when no frame pointer is needed), the program counter on
1913 machines where that is considered one of the addressable registers,
1914 and any other numbered register with a standard use.
1916 This information is expressed as a sequence of numbers, separated by
1917 commas and surrounded by braces. The @var{n}th number is 1 if
1918 register @var{n} is fixed, 0 otherwise.
1920 The table initialized from this macro, and the table initialized by
1921 the following one, may be overridden at run time either automatically,
1922 by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
1923 the user with the command options @option{-ffixed-@var{reg}},
1924 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}.
1927 @defmac CALL_USED_REGISTERS
1928 @cindex call-used register
1929 @cindex call-clobbered register
1930 @cindex call-saved register
1931 Like @code{FIXED_REGISTERS} but has 1 for each register that is
1932 clobbered (in general) by function calls as well as for fixed
1933 registers. This macro therefore identifies the registers that are not
1934 available for general allocation of values that must live across
1937 If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
1938 automatically saves it on function entry and restores it on function
1939 exit, if the register is used within the function.
1942 @defmac CALL_REALLY_USED_REGISTERS
1943 @cindex call-used register
1944 @cindex call-clobbered register
1945 @cindex call-saved register
1946 Like @code{CALL_USED_REGISTERS} except this macro doesn't require
1947 that the entire set of @code{FIXED_REGISTERS} be included.
1948 (@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}).
1949 This macro is optional. If not specified, it defaults to the value
1950 of @code{CALL_USED_REGISTERS}.
1953 @defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
1954 @cindex call-used register
1955 @cindex call-clobbered register
1956 @cindex call-saved register
1957 A C expression that is nonzero if it is not permissible to store a
1958 value of mode @var{mode} in hard register number @var{regno} across a
1959 call without some part of it being clobbered. For most machines this
1960 macro need not be defined. It is only required for machines that do not
1961 preserve the entire contents of a register across a call.
1965 @findex call_used_regs
1968 @findex reg_class_contents
1969 @defmac CONDITIONAL_REGISTER_USAGE
1970 Zero or more C statements that may conditionally modify five variables
1971 @code{fixed_regs}, @code{call_used_regs}, @code{global_regs},
1972 @code{reg_names}, and @code{reg_class_contents}, to take into account
1973 any dependence of these register sets on target flags. The first three
1974 of these are of type @code{char []} (interpreted as Boolean vectors).
1975 @code{global_regs} is a @code{const char *[]}, and
1976 @code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is
1977 called, @code{fixed_regs}, @code{call_used_regs},
1978 @code{reg_class_contents}, and @code{reg_names} have been initialized
1979 from @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS},
1980 @code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively.
1981 @code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}},
1982 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}
1983 command options have been applied.
1985 You need not define this macro if it has no work to do.
1987 @cindex disabling certain registers
1988 @cindex controlling register usage
1989 If the usage of an entire class of registers depends on the target
1990 flags, you may indicate this to GCC by using this macro to modify
1991 @code{fixed_regs} and @code{call_used_regs} to 1 for each of the
1992 registers in the classes which should not be used by GCC@. Also define
1993 the macro @code{REG_CLASS_FROM_LETTER} / @code{REG_CLASS_FROM_CONSTRAINT}
1994 to return @code{NO_REGS} if it
1995 is called with a letter for a class that shouldn't be used.
1997 (However, if this class is not included in @code{GENERAL_REGS} and all
1998 of the insn patterns whose constraints permit this class are
1999 controlled by target switches, then GCC will automatically avoid using
2000 these registers when the target switches are opposed to them.)
2003 @defmac INCOMING_REGNO (@var{out})
2004 Define this macro if the target machine has register windows. This C
2005 expression returns the register number as seen by the called function
2006 corresponding to the register number @var{out} as seen by the calling
2007 function. Return @var{out} if register number @var{out} is not an
2011 @defmac OUTGOING_REGNO (@var{in})
2012 Define this macro if the target machine has register windows. This C
2013 expression returns the register number as seen by the calling function
2014 corresponding to the register number @var{in} as seen by the called
2015 function. Return @var{in} if register number @var{in} is not an inbound
2019 @defmac LOCAL_REGNO (@var{regno})
2020 Define this macro if the target machine has register windows. This C
2021 expression returns true if the register is call-saved but is in the
2022 register window. Unlike most call-saved registers, such registers
2023 need not be explicitly restored on function exit or during non-local
2028 If the program counter has a register number, define this as that
2029 register number. Otherwise, do not define it.
2032 @node Allocation Order
2033 @subsection Order of Allocation of Registers
2034 @cindex order of register allocation
2035 @cindex register allocation order
2037 @c prevent bad page break with this line
2038 Registers are allocated in order.
2040 @defmac REG_ALLOC_ORDER
2041 If defined, an initializer for a vector of integers, containing the
2042 numbers of hard registers in the order in which GCC should prefer
2043 to use them (from most preferred to least).
2045 If this macro is not defined, registers are used lowest numbered first
2046 (all else being equal).
2048 One use of this macro is on machines where the highest numbered
2049 registers must always be saved and the save-multiple-registers
2050 instruction supports only sequences of consecutive registers. On such
2051 machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists
2052 the highest numbered allocable register first.
2055 @defmac ORDER_REGS_FOR_LOCAL_ALLOC
2056 A C statement (sans semicolon) to choose the order in which to allocate
2057 hard registers for pseudo-registers local to a basic block.
2059 Store the desired register order in the array @code{reg_alloc_order}.
2060 Element 0 should be the register to allocate first; element 1, the next
2061 register; and so on.
2063 The macro body should not assume anything about the contents of
2064 @code{reg_alloc_order} before execution of the macro.
2066 On most machines, it is not necessary to define this macro.
2069 @node Values in Registers
2070 @subsection How Values Fit in Registers
2072 This section discusses the macros that describe which kinds of values
2073 (specifically, which machine modes) each register can hold, and how many
2074 consecutive registers are needed for a given mode.
2076 @defmac HARD_REGNO_NREGS (@var{regno}, @var{mode})
2077 A C expression for the number of consecutive hard registers, starting
2078 at register number @var{regno}, required to hold a value of mode
2081 On a machine where all registers are exactly one word, a suitable
2082 definition of this macro is
2085 #define HARD_REGNO_NREGS(REGNO, MODE) \
2086 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
2091 @defmac REGMODE_NATURAL_SIZE (@var{mode})
2092 Define this macro if the natural size of registers that hold values
2093 of mode @var{mode} is not the word size. It is a C expression that
2094 should give the natural size in bytes for the specified mode. It is
2095 used by the register allocator to try to optimize its results. This
2096 happens for example on SPARC 64-bit where the natural size of
2097 floating-point registers is still 32-bit.
2100 @defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
2101 A C expression that is nonzero if it is permissible to store a value
2102 of mode @var{mode} in hard register number @var{regno} (or in several
2103 registers starting with that one). For a machine where all registers
2104 are equivalent, a suitable definition is
2107 #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
2110 You need not include code to check for the numbers of fixed registers,
2111 because the allocation mechanism considers them to be always occupied.
2113 @cindex register pairs
2114 On some machines, double-precision values must be kept in even/odd
2115 register pairs. You can implement that by defining this macro to reject
2116 odd register numbers for such modes.
2118 The minimum requirement for a mode to be OK in a register is that the
2119 @samp{mov@var{mode}} instruction pattern support moves between the
2120 register and other hard register in the same class and that moving a
2121 value into the register and back out not alter it.
2123 Since the same instruction used to move @code{word_mode} will work for
2124 all narrower integer modes, it is not necessary on any machine for
2125 @code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided
2126 you define patterns @samp{movhi}, etc., to take advantage of this. This
2127 is useful because of the interaction between @code{HARD_REGNO_MODE_OK}
2128 and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes
2131 Many machines have special registers for floating point arithmetic.
2132 Often people assume that floating point machine modes are allowed only
2133 in floating point registers. This is not true. Any registers that
2134 can hold integers can safely @emph{hold} a floating point machine
2135 mode, whether or not floating arithmetic can be done on it in those
2136 registers. Integer move instructions can be used to move the values.
2138 On some machines, though, the converse is true: fixed-point machine
2139 modes may not go in floating registers. This is true if the floating
2140 registers normalize any value stored in them, because storing a
2141 non-floating value there would garble it. In this case,
2142 @code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in
2143 floating registers. But if the floating registers do not automatically
2144 normalize, if you can store any bit pattern in one and retrieve it
2145 unchanged without a trap, then any machine mode may go in a floating
2146 register, so you can define this macro to say so.
2148 The primary significance of special floating registers is rather that
2149 they are the registers acceptable in floating point arithmetic
2150 instructions. However, this is of no concern to
2151 @code{HARD_REGNO_MODE_OK}. You handle it by writing the proper
2152 constraints for those instructions.
2154 On some machines, the floating registers are especially slow to access,
2155 so that it is better to store a value in a stack frame than in such a
2156 register if floating point arithmetic is not being done. As long as the
2157 floating registers are not in class @code{GENERAL_REGS}, they will not
2158 be used unless some pattern's constraint asks for one.
2161 @defmac HARD_REGNO_RENAME_OK (@var{from}, @var{to})
2162 A C expression that is nonzero if it is OK to rename a hard register
2163 @var{from} to another hard register @var{to}.
2165 One common use of this macro is to prevent renaming of a register to
2166 another register that is not saved by a prologue in an interrupt
2169 The default is always nonzero.
2172 @defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2})
2173 A C expression that is nonzero if a value of mode
2174 @var{mode1} is accessible in mode @var{mode2} without copying.
2176 If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
2177 @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for
2178 any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})}
2179 should be nonzero. If they differ for any @var{r}, you should define
2180 this macro to return zero unless some other mechanism ensures the
2181 accessibility of the value in a narrower mode.
2183 You should define this macro to return nonzero in as many cases as
2184 possible since doing so will allow GCC to perform better register
2188 @defmac AVOID_CCMODE_COPIES
2189 Define this macro if the compiler should avoid copies to/from @code{CCmode}
2190 registers. You should only define this macro if support for copying to/from
2191 @code{CCmode} is incomplete.
2194 @node Leaf Functions
2195 @subsection Handling Leaf Functions
2197 @cindex leaf functions
2198 @cindex functions, leaf
2199 On some machines, a leaf function (i.e., one which makes no calls) can run
2200 more efficiently if it does not make its own register window. Often this
2201 means it is required to receive its arguments in the registers where they
2202 are passed by the caller, instead of the registers where they would
2205 The special treatment for leaf functions generally applies only when
2206 other conditions are met; for example, often they may use only those
2207 registers for its own variables and temporaries. We use the term ``leaf
2208 function'' to mean a function that is suitable for this special
2209 handling, so that functions with no calls are not necessarily ``leaf
2212 GCC assigns register numbers before it knows whether the function is
2213 suitable for leaf function treatment. So it needs to renumber the
2214 registers in order to output a leaf function. The following macros
2217 @defmac LEAF_REGISTERS
2218 Name of a char vector, indexed by hard register number, which
2219 contains 1 for a register that is allowable in a candidate for leaf
2222 If leaf function treatment involves renumbering the registers, then the
2223 registers marked here should be the ones before renumbering---those that
2224 GCC would ordinarily allocate. The registers which will actually be
2225 used in the assembler code, after renumbering, should not be marked with 1
2228 Define this macro only if the target machine offers a way to optimize
2229 the treatment of leaf functions.
2232 @defmac LEAF_REG_REMAP (@var{regno})
2233 A C expression whose value is the register number to which @var{regno}
2234 should be renumbered, when a function is treated as a leaf function.
2236 If @var{regno} is a register number which should not appear in a leaf
2237 function before renumbering, then the expression should yield @minus{}1, which
2238 will cause the compiler to abort.
2240 Define this macro only if the target machine offers a way to optimize the
2241 treatment of leaf functions, and registers need to be renumbered to do
2245 @findex current_function_is_leaf
2246 @findex current_function_uses_only_leaf_regs
2247 @code{TARGET_ASM_FUNCTION_PROLOGUE} and
2248 @code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions
2249 specially. They can test the C variable @code{current_function_is_leaf}
2250 which is nonzero for leaf functions. @code{current_function_is_leaf} is
2251 set prior to local register allocation and is valid for the remaining
2252 compiler passes. They can also test the C variable
2253 @code{current_function_uses_only_leaf_regs} which is nonzero for leaf
2254 functions which only use leaf registers.
2255 @code{current_function_uses_only_leaf_regs} is valid after all passes
2256 that modify the instructions have been run and is only useful if
2257 @code{LEAF_REGISTERS} is defined.
2258 @c changed this to fix overfull. ALSO: why the "it" at the beginning
2259 @c of the next paragraph?! --mew 2feb93
2261 @node Stack Registers
2262 @subsection Registers That Form a Stack
2264 There are special features to handle computers where some of the
2265 ``registers'' form a stack. Stack registers are normally written by
2266 pushing onto the stack, and are numbered relative to the top of the
2269 Currently, GCC can only handle one group of stack-like registers, and
2270 they must be consecutively numbered. Furthermore, the existing
2271 support for stack-like registers is specific to the 80387 floating
2272 point coprocessor. If you have a new architecture that uses
2273 stack-like registers, you will need to do substantial work on
2274 @file{reg-stack.c} and write your machine description to cooperate
2275 with it, as well as defining these macros.
2278 Define this if the machine has any stack-like registers.
2281 @defmac FIRST_STACK_REG
2282 The number of the first stack-like register. This one is the top
2286 @defmac LAST_STACK_REG
2287 The number of the last stack-like register. This one is the bottom of
2291 @node Register Classes
2292 @section Register Classes
2293 @cindex register class definitions
2294 @cindex class definitions, register
2296 On many machines, the numbered registers are not all equivalent.
2297 For example, certain registers may not be allowed for indexed addressing;
2298 certain registers may not be allowed in some instructions. These machine
2299 restrictions are described to the compiler using @dfn{register classes}.
2301 You define a number of register classes, giving each one a name and saying
2302 which of the registers belong to it. Then you can specify register classes
2303 that are allowed as operands to particular instruction patterns.
2307 In general, each register will belong to several classes. In fact, one
2308 class must be named @code{ALL_REGS} and contain all the registers. Another
2309 class must be named @code{NO_REGS} and contain no registers. Often the
2310 union of two classes will be another class; however, this is not required.
2312 @findex GENERAL_REGS
2313 One of the classes must be named @code{GENERAL_REGS}. There is nothing
2314 terribly special about the name, but the operand constraint letters
2315 @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is
2316 the same as @code{ALL_REGS}, just define it as a macro which expands
2319 Order the classes so that if class @var{x} is contained in class @var{y}
2320 then @var{x} has a lower class number than @var{y}.
2322 The way classes other than @code{GENERAL_REGS} are specified in operand
2323 constraints is through machine-dependent operand constraint letters.
2324 You can define such letters to correspond to various classes, then use
2325 them in operand constraints.
2327 You should define a class for the union of two classes whenever some
2328 instruction allows both classes. For example, if an instruction allows
2329 either a floating point (coprocessor) register or a general register for a
2330 certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
2331 which includes both of them. Otherwise you will get suboptimal code.
2333 You must also specify certain redundant information about the register
2334 classes: for each class, which classes contain it and which ones are
2335 contained in it; for each pair of classes, the largest class contained
2338 When a value occupying several consecutive registers is expected in a
2339 certain class, all the registers used must belong to that class.
2340 Therefore, register classes cannot be used to enforce a requirement for
2341 a register pair to start with an even-numbered register. The way to
2342 specify this requirement is with @code{HARD_REGNO_MODE_OK}.
2344 Register classes used for input-operands of bitwise-and or shift
2345 instructions have a special requirement: each such class must have, for
2346 each fixed-point machine mode, a subclass whose registers can transfer that
2347 mode to or from memory. For example, on some machines, the operations for
2348 single-byte values (@code{QImode}) are limited to certain registers. When
2349 this is so, each register class that is used in a bitwise-and or shift
2350 instruction must have a subclass consisting of registers from which
2351 single-byte values can be loaded or stored. This is so that
2352 @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
2354 @deftp {Data type} {enum reg_class}
2355 An enumerated type that must be defined with all the register class names
2356 as enumerated values. @code{NO_REGS} must be first. @code{ALL_REGS}
2357 must be the last register class, followed by one more enumerated value,
2358 @code{LIM_REG_CLASSES}, which is not a register class but rather
2359 tells how many classes there are.
2361 Each register class has a number, which is the value of casting
2362 the class name to type @code{int}. The number serves as an index
2363 in many of the tables described below.
2366 @defmac N_REG_CLASSES
2367 The number of distinct register classes, defined as follows:
2370 #define N_REG_CLASSES (int) LIM_REG_CLASSES
2374 @defmac REG_CLASS_NAMES
2375 An initializer containing the names of the register classes as C string
2376 constants. These names are used in writing some of the debugging dumps.
2379 @defmac REG_CLASS_CONTENTS
2380 An initializer containing the contents of the register classes, as integers
2381 which are bit masks. The @var{n}th integer specifies the contents of class
2382 @var{n}. The way the integer @var{mask} is interpreted is that
2383 register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
2385 When the machine has more than 32 registers, an integer does not suffice.
2386 Then the integers are replaced by sub-initializers, braced groupings containing
2387 several integers. Each sub-initializer must be suitable as an initializer
2388 for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
2389 In this situation, the first integer in each sub-initializer corresponds to
2390 registers 0 through 31, the second integer to registers 32 through 63, and
2394 @defmac REGNO_REG_CLASS (@var{regno})
2395 A C expression whose value is a register class containing hard register
2396 @var{regno}. In general there is more than one such class; choose a class
2397 which is @dfn{minimal}, meaning that no smaller class also contains the
2401 @defmac BASE_REG_CLASS
2402 A macro whose definition is the name of the class to which a valid
2403 base register must belong. A base register is one used in an address
2404 which is the register value plus a displacement.
2407 @defmac MODE_BASE_REG_CLASS (@var{mode})
2408 This is a variation of the @code{BASE_REG_CLASS} macro which allows
2409 the selection of a base register in a mode dependent manner. If
2410 @var{mode} is VOIDmode then it should return the same value as
2411 @code{BASE_REG_CLASS}.
2414 @defmac MODE_BASE_REG_REG_CLASS (@var{mode})
2415 A C expression whose value is the register class to which a valid
2416 base register must belong in order to be used in a base plus index
2417 register address. You should define this macro if base plus index
2418 addresses have different requirements than other base register uses.
2421 @defmac INDEX_REG_CLASS
2422 A macro whose definition is the name of the class to which a valid
2423 index register must belong. An index register is one used in an
2424 address where its value is either multiplied by a scale factor or
2425 added to another register (as well as added to a displacement).
2428 @defmac CONSTRAINT_LEN (@var{char}, @var{str})
2429 For the constraint at the start of @var{str}, which starts with the letter
2430 @var{c}, return the length. This allows you to have register class /
2431 constant / extra constraints that are longer than a single letter;
2432 you don't need to define this macro if you can do with single-letter
2433 constraints only. The definition of this macro should use
2434 DEFAULT_CONSTRAINT_LEN for all the characters that you don't want
2435 to handle specially.
2436 There are some sanity checks in genoutput.c that check the constraint lengths
2437 for the md file, so you can also use this macro to help you while you are
2438 transitioning from a byzantine single-letter-constraint scheme: when you
2439 return a negative length for a constraint you want to re-use, genoutput
2440 will complain about every instance where it is used in the md file.
2443 @defmac REG_CLASS_FROM_LETTER (@var{char})
2444 A C expression which defines the machine-dependent operand constraint
2445 letters for register classes. If @var{char} is such a letter, the
2446 value should be the register class corresponding to it. Otherwise,
2447 the value should be @code{NO_REGS}. The register letter @samp{r},
2448 corresponding to class @code{GENERAL_REGS}, will not be passed
2449 to this macro; you do not need to handle it.
2452 @defmac REG_CLASS_FROM_CONSTRAINT (@var{char}, @var{str})
2453 Like @code{REG_CLASS_FROM_LETTER}, but you also get the constraint string
2454 passed in @var{str}, so that you can use suffixes to distinguish between
2458 @defmac REGNO_OK_FOR_BASE_P (@var{num})
2459 A C expression which is nonzero if register number @var{num} is
2460 suitable for use as a base register in operand addresses. It may be
2461 either a suitable hard register or a pseudo register that has been
2462 allocated such a hard register.
2465 @defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode})
2466 A C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that
2467 that expression may examine the mode of the memory reference in
2468 @var{mode}. You should define this macro if the mode of the memory
2469 reference affects whether a register may be used as a base register. If
2470 you define this macro, the compiler will use it instead of
2471 @code{REGNO_OK_FOR_BASE_P}.
2474 @defmac REGNO_MODE_OK_FOR_REG_BASE_P (@var{num}, @var{mode})
2475 A C expression which is nonzero if register number @var{num} is suitable for
2476 use as a base register in base plus index operand addresses, accessing
2477 memory in mode @var{mode}. It may be either a suitable hard register or a
2478 pseudo register that has been allocated such a hard register. You should
2479 define this macro if base plus index addresses have different requirements
2480 than other base register uses.
2483 @defmac REGNO_OK_FOR_INDEX_P (@var{num})
2484 A C expression which is nonzero if register number @var{num} is
2485 suitable for use as an index register in operand addresses. It may be
2486 either a suitable hard register or a pseudo register that has been
2487 allocated such a hard register.
2489 The difference between an index register and a base register is that
2490 the index register may be scaled. If an address involves the sum of
2491 two registers, neither one of them scaled, then either one may be
2492 labeled the ``base'' and the other the ``index''; but whichever
2493 labeling is used must fit the machine's constraints of which registers
2494 may serve in each capacity. The compiler will try both labelings,
2495 looking for one that is valid, and will reload one or both registers
2496 only if neither labeling works.
2499 @defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
2500 A C expression that places additional restrictions on the register class
2501 to use when it is necessary to copy value @var{x} into a register in class
2502 @var{class}. The value is a register class; perhaps @var{class}, or perhaps
2503 another, smaller class. On many machines, the following definition is
2507 #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
2510 Sometimes returning a more restrictive class makes better code. For
2511 example, on the 68000, when @var{x} is an integer constant that is in range
2512 for a @samp{moveq} instruction, the value of this macro is always
2513 @code{DATA_REGS} as long as @var{class} includes the data registers.
2514 Requiring a data register guarantees that a @samp{moveq} will be used.
2516 One case where @code{PREFERRED_RELOAD_CLASS} must not return
2517 @var{class} is if @var{x} is a legitimate constant which cannot be
2518 loaded into some register class. By returning @code{NO_REGS} you can
2519 force @var{x} into a memory location. For example, rs6000 can load
2520 immediate values into general-purpose registers, but does not have an
2521 instruction for loading an immediate value into a floating-point
2522 register, so @code{PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2523 @var{x} is a floating-point constant. If the constant can't be loaded
2524 into any kind of register, code generation will be better if
2525 @code{LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
2526 of using @code{PREFERRED_RELOAD_CLASS}.
2529 @defmac PREFERRED_OUTPUT_RELOAD_CLASS (@var{x}, @var{class})
2530 Like @code{PREFERRED_RELOAD_CLASS}, but for output reloads instead of
2531 input reloads. If you don't define this macro, the default is to use
2532 @var{class}, unchanged.
2535 @defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class})
2536 A C expression that places additional restrictions on the register class
2537 to use when it is necessary to be able to hold a value of mode
2538 @var{mode} in a reload register for which class @var{class} would
2541 Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when
2542 there are certain modes that simply can't go in certain reload classes.
2544 The value is a register class; perhaps @var{class}, or perhaps another,
2547 Don't define this macro unless the target machine has limitations which
2548 require the macro to do something nontrivial.
2551 @defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2552 @defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2553 @defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2554 Many machines have some registers that cannot be copied directly to or
2555 from memory or even from other types of registers. An example is the
2556 @samp{MQ} register, which on most machines, can only be copied to or
2557 from general registers, but not memory. Some machines allow copying all
2558 registers to and from memory, but require a scratch register for stores
2559 to some memory locations (e.g., those with symbolic address on the RT,
2560 and those with certain symbolic address on the SPARC when compiling
2561 PIC)@. In some cases, both an intermediate and a scratch register are
2564 You should define these macros to indicate to the reload phase that it may
2565 need to allocate at least one register for a reload in addition to the
2566 register to contain the data. Specifically, if copying @var{x} to a
2567 register @var{class} in @var{mode} requires an intermediate register,
2568 you should define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the
2569 largest register class all of whose registers can be used as
2570 intermediate registers or scratch registers.
2572 If copying a register @var{class} in @var{mode} to @var{x} requires an
2573 intermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS}
2574 should be defined to return the largest register class required. If the
2575 requirements for input and output reloads are the same, the macro
2576 @code{SECONDARY_RELOAD_CLASS} should be used instead of defining both
2579 The values returned by these macros are often @code{GENERAL_REGS}.
2580 Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x}
2581 can be directly copied to or from a register of @var{class} in
2582 @var{mode} without requiring a scratch register. Do not define this
2583 macro if it would always return @code{NO_REGS}.
2585 If a scratch register is required (either with or without an
2586 intermediate register), you should define patterns for
2587 @samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required
2588 (@pxref{Standard Names}. These patterns, which will normally be
2589 implemented with a @code{define_expand}, should be similar to the
2590 @samp{mov@var{m}} patterns, except that operand 2 is the scratch
2593 Define constraints for the reload register and scratch register that
2594 contain a single register class. If the original reload register (whose
2595 class is @var{class}) can meet the constraint given in the pattern, the
2596 value returned by these macros is used for the class of the scratch
2597 register. Otherwise, two additional reload registers are required.
2598 Their classes are obtained from the constraints in the insn pattern.
2600 @var{x} might be a pseudo-register or a @code{subreg} of a
2601 pseudo-register, which could either be in a hard register or in memory.
2602 Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2603 in memory and the hard register number if it is in a register.
2605 These macros should not be used in the case where a particular class of
2606 registers can only be copied to memory and not to another class of
2607 registers. In that case, secondary reload registers are not needed and
2608 would not be helpful. Instead, a stack location must be used to perform
2609 the copy and the @code{mov@var{m}} pattern should use memory as an
2610 intermediate storage. This case often occurs between floating-point and
2614 @defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m})
2615 Certain machines have the property that some registers cannot be copied
2616 to some other registers without using memory. Define this macro on
2617 those machines to be a C expression that is nonzero if objects of mode
2618 @var{m} in registers of @var{class1} can only be copied to registers of
2619 class @var{class2} by storing a register of @var{class1} into memory
2620 and loading that memory location into a register of @var{class2}.
2622 Do not define this macro if its value would always be zero.
2625 @defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode})
2626 Normally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler
2627 allocates a stack slot for a memory location needed for register copies.
2628 If this macro is defined, the compiler instead uses the memory location
2629 defined by this macro.
2631 Do not define this macro if you do not define
2632 @code{SECONDARY_MEMORY_NEEDED}.
2635 @defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode})
2636 When the compiler needs a secondary memory location to copy between two
2637 registers of mode @var{mode}, it normally allocates sufficient memory to
2638 hold a quantity of @code{BITS_PER_WORD} bits and performs the store and
2639 load operations in a mode that many bits wide and whose class is the
2640 same as that of @var{mode}.
2642 This is right thing to do on most machines because it ensures that all
2643 bits of the register are copied and prevents accesses to the registers
2644 in a narrower mode, which some machines prohibit for floating-point
2647 However, this default behavior is not correct on some machines, such as
2648 the DEC Alpha, that store short integers in floating-point registers
2649 differently than in integer registers. On those machines, the default
2650 widening will not work correctly and you must define this macro to
2651 suppress that widening in some cases. See the file @file{alpha.h} for
2654 Do not define this macro if you do not define
2655 @code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that
2656 is @code{BITS_PER_WORD} bits wide is correct for your machine.
2659 @defmac SMALL_REGISTER_CLASSES
2660 On some machines, it is risky to let hard registers live across arbitrary
2661 insns. Typically, these machines have instructions that require values
2662 to be in specific registers (like an accumulator), and reload will fail
2663 if the required hard register is used for another purpose across such an
2666 Define @code{SMALL_REGISTER_CLASSES} to be an expression with a nonzero
2667 value on these machines. When this macro has a nonzero value, the
2668 compiler will try to minimize the lifetime of hard registers.
2670 It is always safe to define this macro with a nonzero value, but if you
2671 unnecessarily define it, you will reduce the amount of optimizations
2672 that can be performed in some cases. If you do not define this macro
2673 with a nonzero value when it is required, the compiler will run out of
2674 spill registers and print a fatal error message. For most machines, you
2675 should not define this macro at all.
2678 @defmac CLASS_LIKELY_SPILLED_P (@var{class})
2679 A C expression whose value is nonzero if pseudos that have been assigned
2680 to registers of class @var{class} would likely be spilled because
2681 registers of @var{class} are needed for spill registers.
2683 The default value of this macro returns 1 if @var{class} has exactly one
2684 register and zero otherwise. On most machines, this default should be
2685 used. Only define this macro to some other expression if pseudos
2686 allocated by @file{local-alloc.c} end up in memory because their hard
2687 registers were needed for spill registers. If this macro returns nonzero
2688 for those classes, those pseudos will only be allocated by
2689 @file{global.c}, which knows how to reallocate the pseudo to another
2690 register. If there would not be another register available for
2691 reallocation, you should not change the definition of this macro since
2692 the only effect of such a definition would be to slow down register
2696 @defmac CLASS_MAX_NREGS (@var{class}, @var{mode})
2697 A C expression for the maximum number of consecutive registers
2698 of class @var{class} needed to hold a value of mode @var{mode}.
2700 This is closely related to the macro @code{HARD_REGNO_NREGS}. In fact,
2701 the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
2702 should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno},
2703 @var{mode})} for all @var{regno} values in the class @var{class}.
2705 This macro helps control the handling of multiple-word values
2709 @defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
2710 If defined, a C expression that returns nonzero for a @var{class} for which
2711 a change from mode @var{from} to mode @var{to} is invalid.
2713 For the example, loading 32-bit integer or floating-point objects into
2714 floating-point registers on the Alpha extends them to 64 bits.
2715 Therefore loading a 64-bit object and then storing it as a 32-bit object
2716 does not store the low-order 32 bits, as would be the case for a normal
2717 register. Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
2721 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
2722 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
2723 ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
2727 Three other special macros describe which operands fit which constraint
2730 @defmac CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
2731 A C expression that defines the machine-dependent operand constraint
2732 letters (@samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}) that specify
2733 particular ranges of integer values. If @var{c} is one of those
2734 letters, the expression should check that @var{value}, an integer, is in
2735 the appropriate range and return 1 if so, 0 otherwise. If @var{c} is
2736 not one of those letters, the value should be 0 regardless of
2740 @defmac CONST_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2741 Like @code{CONST_OK_FOR_LETTER_P}, but you also get the constraint
2742 string passed in @var{str}, so that you can use suffixes to distinguish
2743 between different variants.
2746 @defmac CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
2747 A C expression that defines the machine-dependent operand constraint
2748 letters that specify particular ranges of @code{const_double} values
2749 (@samp{G} or @samp{H}).
2751 If @var{c} is one of those letters, the expression should check that
2752 @var{value}, an RTX of code @code{const_double}, is in the appropriate
2753 range and return 1 if so, 0 otherwise. If @var{c} is not one of those
2754 letters, the value should be 0 regardless of @var{value}.
2756 @code{const_double} is used for all floating-point constants and for
2757 @code{DImode} fixed-point constants. A given letter can accept either
2758 or both kinds of values. It can use @code{GET_MODE} to distinguish
2759 between these kinds.
2762 @defmac CONST_DOUBLE_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2763 Like @code{CONST_DOUBLE_OK_FOR_LETTER_P}, but you also get the constraint
2764 string passed in @var{str}, so that you can use suffixes to distinguish
2765 between different variants.
2768 @defmac EXTRA_CONSTRAINT (@var{value}, @var{c})
2769 A C expression that defines the optional machine-dependent constraint
2770 letters that can be used to segregate specific types of operands, usually
2771 memory references, for the target machine. Any letter that is not
2772 elsewhere defined and not matched by @code{REG_CLASS_FROM_LETTER} /
2773 @code{REG_CLASS_FROM_CONSTRAINT}
2774 may be used. Normally this macro will not be defined.
2776 If it is required for a particular target machine, it should return 1
2777 if @var{value} corresponds to the operand type represented by the
2778 constraint letter @var{c}. If @var{c} is not defined as an extra
2779 constraint, the value returned should be 0 regardless of @var{value}.
2781 For example, on the ROMP, load instructions cannot have their output
2782 in r0 if the memory reference contains a symbolic address. Constraint
2783 letter @samp{Q} is defined as representing a memory address that does
2784 @emph{not} contain a symbolic address. An alternative is specified with
2785 a @samp{Q} constraint on the input and @samp{r} on the output. The next
2786 alternative specifies @samp{m} on the input and a register class that
2787 does not include r0 on the output.
2790 @defmac EXTRA_CONSTRAINT_STR (@var{value}, @var{c}, @var{str})
2791 Like @code{EXTRA_CONSTRAINT}, but you also get the constraint string passed
2792 in @var{str}, so that you can use suffixes to distinguish between different
2796 @defmac EXTRA_MEMORY_CONSTRAINT (@var{c}, @var{str})
2797 A C expression that defines the optional machine-dependent constraint
2798 letters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should
2799 be treated like memory constraints by the reload pass.
2801 It should return 1 if the operand type represented by the constraint
2802 at the start of @var{str}, the first letter of which is the letter @var{c},
2803 comprises a subset of all memory references including
2804 all those whose address is simply a base register. This allows the reload
2805 pass to reload an operand, if it does not directly correspond to the operand
2806 type of @var{c}, by copying its address into a base register.
2808 For example, on the S/390, some instructions do not accept arbitrary
2809 memory references, but only those that do not make use of an index
2810 register. The constraint letter @samp{Q} is defined via
2811 @code{EXTRA_CONSTRAINT} as representing a memory address of this type.
2812 If the letter @samp{Q} is marked as @code{EXTRA_MEMORY_CONSTRAINT},
2813 a @samp{Q} constraint can handle any memory operand, because the
2814 reload pass knows it can be reloaded by copying the memory address
2815 into a base register if required. This is analogous to the way
2816 a @samp{o} constraint can handle any memory operand.
2819 @defmac EXTRA_ADDRESS_CONSTRAINT (@var{c}, @var{str})
2820 A C expression that defines the optional machine-dependent constraint
2821 letters, amongst those accepted by @code{EXTRA_CONSTRAINT} /
2822 @code{EXTRA_CONSTRAINT_STR}, that should
2823 be treated like address constraints by the reload pass.
2825 It should return 1 if the operand type represented by the constraint
2826 at the start of @var{str}, which starts with the letter @var{c}, comprises
2827 a subset of all memory addresses including
2828 all those that consist of just a base register. This allows the reload
2829 pass to reload an operand, if it does not directly correspond to the operand
2830 type of @var{str}, by copying it into a base register.
2832 Any constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only
2833 be used with the @code{address_operand} predicate. It is treated
2834 analogously to the @samp{p} constraint.
2837 @node Stack and Calling
2838 @section Stack Layout and Calling Conventions
2839 @cindex calling conventions
2841 @c prevent bad page break with this line
2842 This describes the stack layout and calling conventions.
2846 * Exception Handling::
2851 * Register Arguments::
2853 * Aggregate Return::
2861 @subsection Basic Stack Layout
2862 @cindex stack frame layout
2863 @cindex frame layout
2865 @c prevent bad page break with this line
2866 Here is the basic stack layout.
2868 @defmac STACK_GROWS_DOWNWARD
2869 Define this macro if pushing a word onto the stack moves the stack
2870 pointer to a smaller address.
2872 When we say, ``define this macro if @dots{}'', it means that the
2873 compiler checks this macro only with @code{#ifdef} so the precise
2874 definition used does not matter.
2877 @defmac STACK_PUSH_CODE
2878 This macro defines the operation used when something is pushed
2879 on the stack. In RTL, a push operation will be
2880 @code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})}
2882 The choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC},
2883 and @code{POST_INC}. Which of these is correct depends on
2884 the stack direction and on whether the stack pointer points
2885 to the last item on the stack or whether it points to the
2886 space for the next item on the stack.
2888 The default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is
2889 defined, which is almost always right, and @code{PRE_INC} otherwise,
2890 which is often wrong.
2893 @defmac FRAME_GROWS_DOWNWARD
2894 Define this macro if the addresses of local variable slots are at negative
2895 offsets from the frame pointer.
2898 @defmac ARGS_GROW_DOWNWARD
2899 Define this macro if successive arguments to a function occupy decreasing
2900 addresses on the stack.
2903 @defmac STARTING_FRAME_OFFSET
2904 Offset from the frame pointer to the first local variable slot to be allocated.
2906 If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
2907 subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
2908 Otherwise, it is found by adding the length of the first slot to the
2909 value @code{STARTING_FRAME_OFFSET}.
2910 @c i'm not sure if the above is still correct.. had to change it to get
2911 @c rid of an overfull. --mew 2feb93
2914 @defmac STACK_ALIGNMENT_NEEDED
2915 Define to zero to disable final alignment of the stack during reload.
2916 The nonzero default for this macro is suitable for most ports.
2918 On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
2919 is a register save block following the local block that doesn't require
2920 alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
2921 stack alignment and do it in the backend.
2924 @defmac STACK_POINTER_OFFSET
2925 Offset from the stack pointer register to the first location at which
2926 outgoing arguments are placed. If not specified, the default value of
2927 zero is used. This is the proper value for most machines.
2929 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
2930 the first location at which outgoing arguments are placed.
2933 @defmac FIRST_PARM_OFFSET (@var{fundecl})
2934 Offset from the argument pointer register to the first argument's
2935 address. On some machines it may depend on the data type of the
2938 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
2939 the first argument's address.
2942 @defmac STACK_DYNAMIC_OFFSET (@var{fundecl})
2943 Offset from the stack pointer register to an item dynamically allocated
2944 on the stack, e.g., by @code{alloca}.
2946 The default value for this macro is @code{STACK_POINTER_OFFSET} plus the
2947 length of the outgoing arguments. The default is correct for most
2948 machines. See @file{function.c} for details.
2951 @defmac INITIAL_FRAME_ADDRESS_RTX
2952 A C expression whose value is RTL representing the address of the initial
2953 stack frame. This address is passed to @code{RETURN_ADDR_RTX} and
2954 @code{DYNAMIC_CHAIN_ADDRESS}.
2955 If you don't define this macro, the default is to return
2956 @code{hard_frame_pointer_rtx}.
2957 This default is usually correct unless @code{-fomit-frame-pointer} is in
2959 Define this macro in order to make @code{__builtin_frame_address (0)} and
2960 @code{__builtin_return_address (0)} work even in absence of a hard frame pointer.
2963 @defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
2964 A C expression whose value is RTL representing the address in a stack
2965 frame where the pointer to the caller's frame is stored. Assume that
2966 @var{frameaddr} is an RTL expression for the address of the stack frame
2969 If you don't define this macro, the default is to return the value
2970 of @var{frameaddr}---that is, the stack frame address is also the
2971 address of the stack word that points to the previous frame.
2974 @defmac SETUP_FRAME_ADDRESSES
2975 If defined, a C expression that produces the machine-specific code to
2976 setup the stack so that arbitrary frames can be accessed. For example,
2977 on the SPARC, we must flush all of the register windows to the stack
2978 before we can access arbitrary stack frames. You will seldom need to
2982 @deftypefn {Target Hook} bool TARGET_BUILTIN_SETJMP_FRAME_VALUE ()
2983 This target hook should return an rtx that is used to store
2984 the address of the current frame into the built in @code{setjmp} buffer.
2985 The default value, @code{virtual_stack_vars_rtx}, is correct for most
2986 machines. One reason you may need to define this target hook is if
2987 @code{hard_frame_pointer_rtx} is the appropriate value on your machine.
2990 @defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr})
2991 A C expression whose value is RTL representing the value of the return
2992 address for the frame @var{count} steps up from the current frame, after
2993 the prologue. @var{frameaddr} is the frame pointer of the @var{count}
2994 frame, or the frame pointer of the @var{count} @minus{} 1 frame if
2995 @code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined.
2997 The value of the expression must always be the correct address when
2998 @var{count} is zero, but may be @code{NULL_RTX} if there is not way to
2999 determine the return address of other frames.
3002 @defmac RETURN_ADDR_IN_PREVIOUS_FRAME
3003 Define this if the return address of a particular stack frame is accessed
3004 from the frame pointer of the previous stack frame.
3007 @defmac INCOMING_RETURN_ADDR_RTX
3008 A C expression whose value is RTL representing the location of the
3009 incoming return address at the beginning of any function, before the
3010 prologue. This RTL is either a @code{REG}, indicating that the return
3011 value is saved in @samp{REG}, or a @code{MEM} representing a location in
3014 You only need to define this macro if you want to support call frame
3015 debugging information like that provided by DWARF 2.
3017 If this RTL is a @code{REG}, you should also define
3018 @code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}.
3021 @defmac DWARF_ALT_FRAME_RETURN_COLUMN
3022 A C expression whose value is an integer giving a DWARF 2 column
3023 number that may be used as an alternate return column. This should
3024 be defined only if @code{DWARF_FRAME_RETURN_COLUMN} is set to a
3025 general register, but an alternate column needs to be used for
3029 @defmac DWARF_ZERO_REG
3030 A C expression whose value is an integer giving a DWARF 2 register
3031 number that is considered to always have the value zero. This should
3032 only be defined if the target has an architected zero register, and
3033 someone decided it was a good idea to use that register number to
3034 terminate the stack backtrace. New ports should avoid this.
3037 @deftypefn {Target Hook} void TARGET_DWARF_HANDLE_FRAME_UNSPEC (const char *@var{label}, rtx @var{pattern}, int @var{index})
3038 This target hook allows the backend to emit frame-related insns that
3039 contain UNSPECs or UNSPEC_VOLATILEs. The DWARF 2 call frame debugging
3040 info engine will invoke it on insns of the form
3042 (set (reg) (unspec [...] UNSPEC_INDEX))
3046 (set (reg) (unspec_volatile [...] UNSPECV_INDEX)).
3048 to let the backend emit the call frame instructions. @var{label} is
3049 the CFI label attached to the insn, @var{pattern} is the pattern of
3050 the insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}.
3053 @defmac INCOMING_FRAME_SP_OFFSET
3054 A C expression whose value is an integer giving the offset, in bytes,
3055 from the value of the stack pointer register to the top of the stack
3056 frame at the beginning of any function, before the prologue. The top of
3057 the frame is defined to be the value of the stack pointer in the
3058 previous frame, just before the call instruction.
3060 You only need to define this macro if you want to support call frame
3061 debugging information like that provided by DWARF 2.
3064 @defmac ARG_POINTER_CFA_OFFSET (@var{fundecl})
3065 A C expression whose value is an integer giving the offset, in bytes,
3066 from the argument pointer to the canonical frame address (cfa). The
3067 final value should coincide with that calculated by
3068 @code{INCOMING_FRAME_SP_OFFSET}. Which is unfortunately not usable
3069 during virtual register instantiation.
3071 The default value for this macro is @code{FIRST_PARM_OFFSET (fundecl)},
3072 which is correct for most machines; in general, the arguments are found
3073 immediately before the stack frame. Note that this is not the case on
3074 some targets that save registers into the caller's frame, such as SPARC
3075 and rs6000, and so such targets need to define this macro.
3077 You only need to define this macro if the default is incorrect, and you
3078 want to support call frame debugging information like that provided by
3082 @node Exception Handling
3083 @subsection Exception Handling Support
3084 @cindex exception handling
3086 @defmac EH_RETURN_DATA_REGNO (@var{N})
3087 A C expression whose value is the @var{N}th register number used for
3088 data by exception handlers, or @code{INVALID_REGNUM} if fewer than
3089 @var{N} registers are usable.
3091 The exception handling library routines communicate with the exception
3092 handlers via a set of agreed upon registers. Ideally these registers
3093 should be call-clobbered; it is possible to use call-saved registers,
3094 but may negatively impact code size. The target must support at least
3095 2 data registers, but should define 4 if there are enough free registers.
3097 You must define this macro if you want to support call frame exception
3098 handling like that provided by DWARF 2.
3101 @defmac EH_RETURN_STACKADJ_RTX
3102 A C expression whose value is RTL representing a location in which
3103 to store a stack adjustment to be applied before function return.
3104 This is used to unwind the stack to an exception handler's call frame.
3105 It will be assigned zero on code paths that return normally.
3107 Typically this is a call-clobbered hard register that is otherwise
3108 untouched by the epilogue, but could also be a stack slot.
3110 Do not define this macro if the stack pointer is saved and restored
3111 by the regular prolog and epilog code in the call frame itself; in
3112 this case, the exception handling library routines will update the
3113 stack location to be restored in place. Otherwise, you must define
3114 this macro if you want to support call frame exception handling like
3115 that provided by DWARF 2.
3118 @defmac EH_RETURN_HANDLER_RTX
3119 A C expression whose value is RTL representing a location in which
3120 to store the address of an exception handler to which we should
3121 return. It will not be assigned on code paths that return normally.
3123 Typically this is the location in the call frame at which the normal
3124 return address is stored. For targets that return by popping an
3125 address off the stack, this might be a memory address just below
3126 the @emph{target} call frame rather than inside the current call
3127 frame. If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
3128 been assigned, so it may be used to calculate the location of the
3131 Some targets have more complex requirements than storing to an
3132 address calculable during initial code generation. In that case
3133 the @code{eh_return} instruction pattern should be used instead.
3135 If you want to support call frame exception handling, you must
3136 define either this macro or the @code{eh_return} instruction pattern.
3139 @defmac RETURN_ADDR_OFFSET
3140 If defined, an integer-valued C expression for which rtl will be generated
3141 to add it to the exception handler address before it is searched in the
3142 exception handling tables, and to subtract it again from the address before
3143 using it to return to the exception handler.
3146 @defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global})
3147 This macro chooses the encoding of pointers embedded in the exception
3148 handling sections. If at all possible, this should be defined such
3149 that the exception handling section will not require dynamic relocations,
3150 and so may be read-only.
3152 @var{code} is 0 for data, 1 for code labels, 2 for function pointers.
3153 @var{global} is true if the symbol may be affected by dynamic relocations.
3154 The macro should return a combination of the @code{DW_EH_PE_*} defines
3155 as found in @file{dwarf2.h}.
3157 If this macro is not defined, pointers will not be encoded but
3158 represented directly.
3161 @defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done})
3162 This macro allows the target to emit whatever special magic is required
3163 to represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}.
3164 Generic code takes care of pc-relative and indirect encodings; this must
3165 be defined if the target uses text-relative or data-relative encodings.
3167 This is a C statement that branches to @var{done} if the format was
3168 handled. @var{encoding} is the format chosen, @var{size} is the number
3169 of bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF}
3173 @defmac MD_UNWIND_SUPPORT
3174 A string specifying a file to be #include'd in unwind-dw2.c. The file
3175 so included typically defines @code{MD_FALLBACK_FRAME_STATE_FOR}.
3178 @defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs})
3179 This macro allows the target to add cpu and operating system specific
3180 code to the call-frame unwinder for use when there is no unwind data
3181 available. The most common reason to implement this macro is to unwind
3182 through signal frames.
3184 This macro is called from @code{uw_frame_state_for} in @file{unwind-dw2.c}
3185 and @file{unwind-ia64.c}. @var{context} is an @code{_Unwind_Context};
3186 @var{fs} is an @code{_Unwind_FrameState}. Examine @code{context->ra}
3187 for the address of the code being executed and @code{context->cfa} for
3188 the stack pointer value. If the frame can be decoded, the register save
3189 addresses should be updated in @var{fs} and the macro should evaluate to
3190 @code{_URC_NO_REASON}. If the frame cannot be decoded, the macro should
3191 evaluate to @code{_URC_END_OF_STACK}.
3193 For proper signal handling in Java this macro is accompanied by
3194 @code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers.
3197 @defmac MD_HANDLE_UNWABI (@var{context}, @var{fs})
3198 This macro allows the target to add operating system specific code to the
3199 call-frame unwinder to handle the IA-64 @code{.unwabi} unwinding directive,
3200 usually used for signal or interrupt frames.
3202 This macro is called from @code{uw_update_context} in @file{unwind-ia64.c}.
3203 @var{context} is an @code{_Unwind_Context};
3204 @var{fs} is an @code{_Unwind_FrameState}. Examine @code{fs->unwabi}
3205 for the abi and context in the @code{.unwabi} directive. If the
3206 @code{.unwabi} directive can be handled, the register save addresses should
3207 be updated in @var{fs}.
3210 @defmac TARGET_USES_WEAK_UNWIND_INFO
3211 A C expression that evaluates to true if the target requires unwind
3212 info to be given comdat linkage. Define it to be @code{1} if comdat
3213 linkage is necessary. The default is @code{0}.
3216 @node Stack Checking
3217 @subsection Specifying How Stack Checking is Done
3219 GCC will check that stack references are within the boundaries of
3220 the stack, if the @option{-fstack-check} is specified, in one of three ways:
3224 If the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC
3225 will assume that you have arranged for stack checking to be done at
3226 appropriate places in the configuration files, e.g., in
3227 @code{TARGET_ASM_FUNCTION_PROLOGUE}. GCC will do not other special
3231 If @code{STACK_CHECK_BUILTIN} is zero and you defined a named pattern
3232 called @code{check_stack} in your @file{md} file, GCC will call that
3233 pattern with one argument which is the address to compare the stack
3234 value against. You must arrange for this pattern to report an error if
3235 the stack pointer is out of range.
3238 If neither of the above are true, GCC will generate code to periodically
3239 ``probe'' the stack pointer using the values of the macros defined below.
3242 Normally, you will use the default values of these macros, so GCC
3243 will use the third approach.
3245 @defmac STACK_CHECK_BUILTIN
3246 A nonzero value if stack checking is done by the configuration files in a
3247 machine-dependent manner. You should define this macro if stack checking
3248 is require by the ABI of your machine or if you would like to have to stack
3249 checking in some more efficient way than GCC's portable approach.
3250 The default value of this macro is zero.
3253 @defmac STACK_CHECK_PROBE_INTERVAL
3254 An integer representing the interval at which GCC must generate stack
3255 probe instructions. You will normally define this macro to be no larger
3256 than the size of the ``guard pages'' at the end of a stack area. The
3257 default value of 4096 is suitable for most systems.
3260 @defmac STACK_CHECK_PROBE_LOAD
3261 A integer which is nonzero if GCC should perform the stack probe
3262 as a load instruction and zero if GCC should use a store instruction.
3263 The default is zero, which is the most efficient choice on most systems.
3266 @defmac STACK_CHECK_PROTECT
3267 The number of bytes of stack needed to recover from a stack overflow,
3268 for languages where such a recovery is supported. The default value of
3269 75 words should be adequate for most machines.
3272 @defmac STACK_CHECK_MAX_FRAME_SIZE
3273 The maximum size of a stack frame, in bytes. GCC will generate probe
3274 instructions in non-leaf functions to ensure at least this many bytes of
3275 stack are available. If a stack frame is larger than this size, stack
3276 checking will not be reliable and GCC will issue a warning. The
3277 default is chosen so that GCC only generates one instruction on most
3278 systems. You should normally not change the default value of this macro.
3281 @defmac STACK_CHECK_FIXED_FRAME_SIZE
3282 GCC uses this value to generate the above warning message. It
3283 represents the amount of fixed frame used by a function, not including
3284 space for any callee-saved registers, temporaries and user variables.
3285 You need only specify an upper bound for this amount and will normally
3286 use the default of four words.
3289 @defmac STACK_CHECK_MAX_VAR_SIZE
3290 The maximum size, in bytes, of an object that GCC will place in the
3291 fixed area of the stack frame when the user specifies
3292 @option{-fstack-check}.
3293 GCC computed the default from the values of the above macros and you will
3294 normally not need to override that default.
3298 @node Frame Registers
3299 @subsection Registers That Address the Stack Frame
3301 @c prevent bad page break with this line
3302 This discusses registers that address the stack frame.
3304 @defmac STACK_POINTER_REGNUM
3305 The register number of the stack pointer register, which must also be a
3306 fixed register according to @code{FIXED_REGISTERS}. On most machines,
3307 the hardware determines which register this is.
3310 @defmac FRAME_POINTER_REGNUM
3311 The register number of the frame pointer register, which is used to
3312 access automatic variables in the stack frame. On some machines, the
3313 hardware determines which register this is. On other machines, you can
3314 choose any register you wish for this purpose.
3317 @defmac HARD_FRAME_POINTER_REGNUM
3318 On some machines the offset between the frame pointer and starting
3319 offset of the automatic variables is not known until after register
3320 allocation has been done (for example, because the saved registers are
3321 between these two locations). On those machines, define
3322 @code{FRAME_POINTER_REGNUM} the number of a special, fixed register to
3323 be used internally until the offset is known, and define
3324 @code{HARD_FRAME_POINTER_REGNUM} to be the actual hard register number
3325 used for the frame pointer.
3327 You should define this macro only in the very rare circumstances when it
3328 is not possible to calculate the offset between the frame pointer and
3329 the automatic variables until after register allocation has been
3330 completed. When this macro is defined, you must also indicate in your
3331 definition of @code{ELIMINABLE_REGS} how to eliminate
3332 @code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM}
3333 or @code{STACK_POINTER_REGNUM}.
3335 Do not define this macro if it would be the same as
3336 @code{FRAME_POINTER_REGNUM}.
3339 @defmac ARG_POINTER_REGNUM
3340 The register number of the arg pointer register, which is used to access
3341 the function's argument list. On some machines, this is the same as the
3342 frame pointer register. On some machines, the hardware determines which
3343 register this is. On other machines, you can choose any register you
3344 wish for this purpose. If this is not the same register as the frame
3345 pointer register, then you must mark it as a fixed register according to
3346 @code{FIXED_REGISTERS}, or arrange to be able to eliminate it
3347 (@pxref{Elimination}).
3350 @defmac RETURN_ADDRESS_POINTER_REGNUM
3351 The register number of the return address pointer register, which is used to
3352 access the current function's return address from the stack. On some
3353 machines, the return address is not at a fixed offset from the frame
3354 pointer or stack pointer or argument pointer. This register can be defined
3355 to point to the return address on the stack, and then be converted by
3356 @code{ELIMINABLE_REGS} into either the frame pointer or stack pointer.
3358 Do not define this macro unless there is no other way to get the return
3359 address from the stack.
3362 @defmac STATIC_CHAIN_REGNUM
3363 @defmacx STATIC_CHAIN_INCOMING_REGNUM
3364 Register numbers used for passing a function's static chain pointer. If
3365 register windows are used, the register number as seen by the called
3366 function is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register
3367 number as seen by the calling function is @code{STATIC_CHAIN_REGNUM}. If
3368 these registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need
3371 The static chain register need not be a fixed register.
3373 If the static chain is passed in memory, these macros should not be
3374 defined; instead, the next two macros should be defined.
3377 @defmac STATIC_CHAIN
3378 @defmacx STATIC_CHAIN_INCOMING
3379 If the static chain is passed in memory, these macros provide rtx giving
3380 @code{mem} expressions that denote where they are stored.
3381 @code{STATIC_CHAIN} and @code{STATIC_CHAIN_INCOMING} give the locations
3382 as seen by the calling and called functions, respectively. Often the former
3383 will be at an offset from the stack pointer and the latter at an offset from
3386 @findex stack_pointer_rtx
3387 @findex frame_pointer_rtx
3388 @findex arg_pointer_rtx
3389 The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and
3390 @code{arg_pointer_rtx} will have been initialized prior to the use of these
3391 macros and should be used to refer to those items.
3393 If the static chain is passed in a register, the two previous macros should
3397 @defmac DWARF_FRAME_REGISTERS
3398 This macro specifies the maximum number of hard registers that can be
3399 saved in a call frame. This is used to size data structures used in
3400 DWARF2 exception handling.
3402 Prior to GCC 3.0, this macro was needed in order to establish a stable
3403 exception handling ABI in the face of adding new hard registers for ISA
3404 extensions. In GCC 3.0 and later, the EH ABI is insulated from changes
3405 in the number of hard registers. Nevertheless, this macro can still be
3406 used to reduce the runtime memory requirements of the exception handling
3407 routines, which can be substantial if the ISA contains a lot of
3408 registers that are not call-saved.
3410 If this macro is not defined, it defaults to
3411 @code{FIRST_PSEUDO_REGISTER}.
3414 @defmac PRE_GCC3_DWARF_FRAME_REGISTERS
3416 This macro is similar to @code{DWARF_FRAME_REGISTERS}, but is provided
3417 for backward compatibility in pre GCC 3.0 compiled code.
3419 If this macro is not defined, it defaults to
3420 @code{DWARF_FRAME_REGISTERS}.
3423 @defmac DWARF_REG_TO_UNWIND_COLUMN (@var{regno})
3425 Define this macro if the target's representation for dwarf registers
3426 is different than the internal representation for unwind column.
3427 Given a dwarf register, this macro should return the internal unwind
3428 column number to use instead.
3430 See the PowerPC's SPE target for an example.
3433 @defmac DWARF_FRAME_REGNUM (@var{regno})
3435 Define this macro if the target's representation for dwarf registers
3436 used in .eh_frame or .debug_frame is different from that used in other
3437 debug info sections. Given a GCC hard register number, this macro
3438 should return the .eh_frame register number. The default is
3439 @code{DBX_REGISTER_NUMBER (@var{regno})}.
3443 @defmac DWARF2_FRAME_REG_OUT (@var{regno}, @var{for_eh})
3445 Define this macro to map register numbers held in the call frame info
3446 that GCC has collected using @code{DWARF_FRAME_REGNUM} to those that
3447 should be output in .debug_frame (@code{@var{for_eh}} is zero) and
3448 .eh_frame (@code{@var{for_eh}} is nonzero). The default is to
3449 return @code{@var{regno}}.
3454 @subsection Eliminating Frame Pointer and Arg Pointer
3456 @c prevent bad page break with this line
3457 This is about eliminating the frame pointer and arg pointer.
3459 @defmac FRAME_POINTER_REQUIRED
3460 A C expression which is nonzero if a function must have and use a frame
3461 pointer. This expression is evaluated in the reload pass. If its value is
3462 nonzero the function will have a frame pointer.
3464 The expression can in principle examine the current function and decide
3465 according to the facts, but on most machines the constant 0 or the
3466 constant 1 suffices. Use 0 when the machine allows code to be generated
3467 with no frame pointer, and doing so saves some time or space. Use 1
3468 when there is no possible advantage to avoiding a frame pointer.
3470 In certain cases, the compiler does not know how to produce valid code
3471 without a frame pointer. The compiler recognizes those cases and
3472 automatically gives the function a frame pointer regardless of what
3473 @code{FRAME_POINTER_REQUIRED} says. You don't need to worry about
3476 In a function that does not require a frame pointer, the frame pointer
3477 register can be allocated for ordinary usage, unless you mark it as a
3478 fixed register. See @code{FIXED_REGISTERS} for more information.
3481 @findex get_frame_size
3482 @defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var})
3483 A C statement to store in the variable @var{depth-var} the difference
3484 between the frame pointer and the stack pointer values immediately after
3485 the function prologue. The value would be computed from information
3486 such as the result of @code{get_frame_size ()} and the tables of
3487 registers @code{regs_ever_live} and @code{call_used_regs}.
3489 If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and
3490 need not be defined. Otherwise, it must be defined even if
3491 @code{FRAME_POINTER_REQUIRED} is defined to always be true; in that
3492 case, you may set @var{depth-var} to anything.
3495 @defmac ELIMINABLE_REGS
3496 If defined, this macro specifies a table of register pairs used to
3497 eliminate unneeded registers that point into the stack frame. If it is not
3498 defined, the only elimination attempted by the compiler is to replace
3499 references to the frame pointer with references to the stack pointer.
3501 The definition of this macro is a list of structure initializations, each
3502 of which specifies an original and replacement register.
3504 On some machines, the position of the argument pointer is not known until
3505 the compilation is completed. In such a case, a separate hard register
3506 must be used for the argument pointer. This register can be eliminated by
3507 replacing it with either the frame pointer or the argument pointer,
3508 depending on whether or not the frame pointer has been eliminated.
3510 In this case, you might specify:
3512 #define ELIMINABLE_REGS \
3513 @{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \
3514 @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \
3515 @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@}
3518 Note that the elimination of the argument pointer with the stack pointer is
3519 specified first since that is the preferred elimination.
3522 @defmac CAN_ELIMINATE (@var{from-reg}, @var{to-reg})
3523 A C expression that returns nonzero if the compiler is allowed to try
3524 to replace register number @var{from-reg} with register number
3525 @var{to-reg}. This macro need only be defined if @code{ELIMINABLE_REGS}
3526 is defined, and will usually be the constant 1, since most of the cases
3527 preventing register elimination are things that the compiler already
3531 @defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var})
3532 This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It
3533 specifies the initial difference between the specified pair of
3534 registers. This macro must be defined if @code{ELIMINABLE_REGS} is
3538 @node Stack Arguments
3539 @subsection Passing Function Arguments on the Stack
3540 @cindex arguments on stack
3541 @cindex stack arguments
3543 The macros in this section control how arguments are passed
3544 on the stack. See the following section for other macros that
3545 control passing certain arguments in registers.
3547 @deftypefn {Target Hook} bool TARGET_PROMOTE_PROTOTYPES (tree @var{fntype})
3548 This target hook returns @code{true} if an argument declared in a
3549 prototype as an integral type smaller than @code{int} should actually be
3550 passed as an @code{int}. In addition to avoiding errors in certain
3551 cases of mismatch, it also makes for better code on certain machines.
3552 The default is to not promote prototypes.
3556 A C expression. If nonzero, push insns will be used to pass
3558 If the target machine does not have a push instruction, set it to zero.
3559 That directs GCC to use an alternate strategy: to
3560 allocate the entire argument block and then store the arguments into
3561 it. When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too.
3564 @defmac PUSH_ARGS_REVERSED
3565 A C expression. If nonzero, function arguments will be evaluated from
3566 last to first, rather than from first to last. If this macro is not
3567 defined, it defaults to @code{PUSH_ARGS} on targets where the stack
3568 and args grow in opposite directions, and 0 otherwise.
3571 @defmac PUSH_ROUNDING (@var{npushed})
3572 A C expression that is the number of bytes actually pushed onto the
3573 stack when an instruction attempts to push @var{npushed} bytes.
3575 On some machines, the definition
3578 #define PUSH_ROUNDING(BYTES) (BYTES)
3582 will suffice. But on other machines, instructions that appear
3583 to push one byte actually push two bytes in an attempt to maintain
3584 alignment. Then the definition should be
3587 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
3591 @findex current_function_outgoing_args_size
3592 @defmac ACCUMULATE_OUTGOING_ARGS