Small ChangeLog tweak.
[official-gcc.git] / gcc / doc / tm.texi.in
blobdff6cf8e038701215ab81d0ac153231a68554adb
1 @c Copyright (C) 1988-2017 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
5 @node Target Macros
6 @chapter Target Description Macros and Functions
7 @cindex machine description macros
8 @cindex target description macros
9 @cindex macros, target description
10 @cindex @file{tm.h} macros
12 In addition to the file @file{@var{machine}.md}, a machine description
13 includes a C header file conventionally given the name
14 @file{@var{machine}.h} and a C source file named @file{@var{machine}.c}.
15 The header file defines numerous macros that convey the information
16 about the target machine that does not fit into the scheme of the
17 @file{.md} file.  The file @file{tm.h} should be a link to
18 @file{@var{machine}.h}.  The header file @file{config.h} includes
19 @file{tm.h} and most compiler source files include @file{config.h}.  The
20 source file defines a variable @code{targetm}, which is a structure
21 containing pointers to functions and data relating to the target
22 machine.  @file{@var{machine}.c} should also contain their definitions,
23 if they are not defined elsewhere in GCC, and other functions called
24 through the macros defined in the @file{.h} file.
26 @menu
27 * Target Structure::    The @code{targetm} variable.
28 * Driver::              Controlling how the driver runs the compilation passes.
29 * Run-time Target::     Defining @samp{-m} options like @option{-m68000} and @option{-m68020}.
30 * Per-Function Data::   Defining data structures for per-function information.
31 * Storage Layout::      Defining sizes and alignments of data.
32 * Type Layout::         Defining sizes and properties of basic user data types.
33 * Registers::           Naming and describing the hardware registers.
34 * Register Classes::    Defining the classes of hardware registers.
35 * Stack and Calling::   Defining which way the stack grows and by how much.
36 * Varargs::             Defining the varargs macros.
37 * Trampolines::         Code set up at run time to enter a nested function.
38 * Library Calls::       Controlling how library routines are implicitly called.
39 * Addressing Modes::    Defining addressing modes valid for memory operands.
40 * Anchored Addresses::  Defining how @option{-fsection-anchors} should work.
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 * Emulated TLS::        Emulated TLS support.
52 * MIPS Coprocessors::   MIPS coprocessor support and how to customize it.
53 * PCH Target::          Validity checking for precompiled headers.
54 * C++ ABI::             Controlling C++ ABI changes.
55 * Named Address Spaces:: Adding support for named address spaces
56 * Misc::                Everything else.
57 @end menu
59 @node Target Structure
60 @section The Global @code{targetm} Variable
61 @cindex target hooks
62 @cindex target functions
64 @deftypevar {struct gcc_target} targetm
65 The target @file{.c} file must define the global @code{targetm} variable
66 which contains pointers to functions and data relating to the target
67 machine.  The variable is declared in @file{target.h};
68 @file{target-def.h} defines the macro @code{TARGET_INITIALIZER} which is
69 used to initialize the variable, and macros for the default initializers
70 for elements of the structure.  The @file{.c} file should override those
71 macros for which the default definition is inappropriate.  For example:
72 @smallexample
73 #include "target.h"
74 #include "target-def.h"
76 /* @r{Initialize the GCC target structure.}  */
78 #undef TARGET_COMP_TYPE_ATTRIBUTES
79 #define TARGET_COMP_TYPE_ATTRIBUTES @var{machine}_comp_type_attributes
81 struct gcc_target targetm = TARGET_INITIALIZER;
82 @end smallexample
83 @end deftypevar
85 Where a macro should be defined in the @file{.c} file in this manner to
86 form part of the @code{targetm} structure, it is documented below as a
87 ``Target Hook'' with a prototype.  Many macros will change in future
88 from being defined in the @file{.h} file to being part of the
89 @code{targetm} structure.
91 Similarly, there is a @code{targetcm} variable for hooks that are
92 specific to front ends for C-family languages, documented as ``C
93 Target Hook''.  This is declared in @file{c-family/c-target.h}, the
94 initializer @code{TARGETCM_INITIALIZER} in
95 @file{c-family/c-target-def.h}.  If targets initialize @code{targetcm}
96 themselves, they should set @code{target_has_targetcm=yes} in
97 @file{config.gcc}; otherwise a default definition is used.
99 Similarly, there is a @code{targetm_common} variable for hooks that
100 are shared between the compiler driver and the compilers proper,
101 documented as ``Common Target Hook''.  This is declared in
102 @file{common/common-target.h}, the initializer
103 @code{TARGETM_COMMON_INITIALIZER} in
104 @file{common/common-target-def.h}.  If targets initialize
105 @code{targetm_common} themselves, they should set
106 @code{target_has_targetm_common=yes} in @file{config.gcc}; otherwise a
107 default definition is used.
109 @node Driver
110 @section Controlling the Compilation Driver, @file{gcc}
111 @cindex driver
112 @cindex controlling the compilation driver
114 @c prevent bad page break with this line
115 You can control the compilation driver.
117 @defmac DRIVER_SELF_SPECS
118 A list of specs for the driver itself.  It should be a suitable
119 initializer for an array of strings, with no surrounding braces.
121 The driver applies these specs to its own command line between loading
122 default @file{specs} files (but not command-line specified ones) and
123 choosing the multilib directory or running any subcommands.  It
124 applies them in the order given, so each spec can depend on the
125 options added by earlier ones.  It is also possible to remove options
126 using @samp{%<@var{option}} in the usual way.
128 This macro can be useful when a port has several interdependent target
129 options.  It provides a way of standardizing the command line so
130 that the other specs are easier to write.
132 Do not define this macro if it does not need to do anything.
133 @end defmac
135 @defmac OPTION_DEFAULT_SPECS
136 A list of specs used to support configure-time default options (i.e.@:
137 @option{--with} options) in the driver.  It should be a suitable initializer
138 for an array of structures, each containing two strings, without the
139 outermost pair of surrounding braces.
141 The first item in the pair is the name of the default.  This must match
142 the code in @file{config.gcc} for the target.  The second item is a spec
143 to apply if a default with this name was specified.  The string
144 @samp{%(VALUE)} in the spec will be replaced by the value of the default
145 everywhere it occurs.
147 The driver will apply these specs to its own command line between loading
148 default @file{specs} files and processing @code{DRIVER_SELF_SPECS}, using
149 the same mechanism as @code{DRIVER_SELF_SPECS}.
151 Do not define this macro if it does not need to do anything.
152 @end defmac
154 @defmac CPP_SPEC
155 A C string constant that tells the GCC driver program options to
156 pass to CPP@.  It can also specify how to translate options you
157 give to GCC into options for GCC to pass to the CPP@.
159 Do not define this macro if it does not need to do anything.
160 @end defmac
162 @defmac CPLUSPLUS_CPP_SPEC
163 This macro is just like @code{CPP_SPEC}, but is used for C++, rather
164 than C@.  If you do not define this macro, then the value of
165 @code{CPP_SPEC} (if any) will be used instead.
166 @end defmac
168 @defmac CC1_SPEC
169 A C string constant that tells the GCC driver program options to
170 pass to @code{cc1}, @code{cc1plus}, @code{f771}, and the other language
171 front ends.
172 It can also specify how to translate options you give to GCC into options
173 for GCC to pass to front ends.
175 Do not define this macro if it does not need to do anything.
176 @end defmac
178 @defmac CC1PLUS_SPEC
179 A C string constant that tells the GCC driver program options to
180 pass to @code{cc1plus}.  It can also specify how to translate options you
181 give to GCC into options for GCC to pass to the @code{cc1plus}.
183 Do not define this macro if it does not need to do anything.
184 Note that everything defined in CC1_SPEC is already passed to
185 @code{cc1plus} so there is no need to duplicate the contents of
186 CC1_SPEC in CC1PLUS_SPEC@.
187 @end defmac
189 @defmac ASM_SPEC
190 A C string constant that tells the GCC driver program options to
191 pass to the assembler.  It can also specify how to translate options
192 you give to GCC into options for GCC to pass to the assembler.
193 See the file @file{sun3.h} for an example of this.
195 Do not define this macro if it does not need to do anything.
196 @end defmac
198 @defmac ASM_FINAL_SPEC
199 A C string constant that tells the GCC driver program how to
200 run any programs which cleanup after the normal assembler.
201 Normally, this is not needed.  See the file @file{mips.h} for
202 an example of this.
204 Do not define this macro if it does not need to do anything.
205 @end defmac
207 @defmac AS_NEEDS_DASH_FOR_PIPED_INPUT
208 Define this macro, with no value, if the driver should give the assembler
209 an argument consisting of a single dash, @option{-}, to instruct it to
210 read from its standard input (which will be a pipe connected to the
211 output of the compiler proper).  This argument is given after any
212 @option{-o} option specifying the name of the output file.
214 If you do not define this macro, the assembler is assumed to read its
215 standard input if given no non-option arguments.  If your assembler
216 cannot read standard input at all, use a @samp{%@{pipe:%e@}} construct;
217 see @file{mips.h} for instance.
218 @end defmac
220 @defmac LINK_SPEC
221 A C string constant that tells the GCC driver program options to
222 pass to the linker.  It can also specify how to translate options you
223 give to GCC into options for GCC to pass to the linker.
225 Do not define this macro if it does not need to do anything.
226 @end defmac
228 @defmac LIB_SPEC
229 Another C string constant used much like @code{LINK_SPEC}.  The difference
230 between the two is that @code{LIB_SPEC} is used at the end of the
231 command given to the linker.
233 If this macro is not defined, a default is provided that
234 loads the standard C library from the usual place.  See @file{gcc.c}.
235 @end defmac
237 @defmac LIBGCC_SPEC
238 Another C string constant that tells the GCC driver program
239 how and when to place a reference to @file{libgcc.a} into the
240 linker command line.  This constant is placed both before and after
241 the value of @code{LIB_SPEC}.
243 If this macro is not defined, the GCC driver provides a default that
244 passes the string @option{-lgcc} to the linker.
245 @end defmac
247 @defmac REAL_LIBGCC_SPEC
248 By default, if @code{ENABLE_SHARED_LIBGCC} is defined, the
249 @code{LIBGCC_SPEC} is not directly used by the driver program but is
250 instead modified to refer to different versions of @file{libgcc.a}
251 depending on the values of the command line flags @option{-static},
252 @option{-shared}, @option{-static-libgcc}, and @option{-shared-libgcc}.  On
253 targets where these modifications are inappropriate, define
254 @code{REAL_LIBGCC_SPEC} instead.  @code{REAL_LIBGCC_SPEC} tells the
255 driver how to place a reference to @file{libgcc} on the link command
256 line, but, unlike @code{LIBGCC_SPEC}, it is used unmodified.
257 @end defmac
259 @defmac USE_LD_AS_NEEDED
260 A macro that controls the modifications to @code{LIBGCC_SPEC}
261 mentioned in @code{REAL_LIBGCC_SPEC}.  If nonzero, a spec will be
262 generated that uses @option{--as-needed} or equivalent options and the
263 shared @file{libgcc} in place of the
264 static exception handler library, when linking without any of
265 @code{-static}, @code{-static-libgcc}, or @code{-shared-libgcc}.
266 @end defmac
268 @defmac LINK_EH_SPEC
269 If defined, this C string constant is added to @code{LINK_SPEC}.
270 When @code{USE_LD_AS_NEEDED} is zero or undefined, it also affects
271 the modifications to @code{LIBGCC_SPEC} mentioned in
272 @code{REAL_LIBGCC_SPEC}.
273 @end defmac
275 @defmac STARTFILE_SPEC
276 Another C string constant used much like @code{LINK_SPEC}.  The
277 difference between the two is that @code{STARTFILE_SPEC} is used at
278 the very beginning of the command given to the linker.
280 If this macro is not defined, a default is provided that loads the
281 standard C startup file from the usual place.  See @file{gcc.c}.
282 @end defmac
284 @defmac ENDFILE_SPEC
285 Another C string constant used much like @code{LINK_SPEC}.  The
286 difference between the two is that @code{ENDFILE_SPEC} is used at
287 the very end of the command given to the linker.
289 Do not define this macro if it does not need to do anything.
290 @end defmac
292 @defmac THREAD_MODEL_SPEC
293 GCC @code{-v} will print the thread model GCC was configured to use.
294 However, this doesn't work on platforms that are multilibbed on thread
295 models, such as AIX 4.3.  On such platforms, define
296 @code{THREAD_MODEL_SPEC} such that it evaluates to a string without
297 blanks that names one of the recognized thread models.  @code{%*}, the
298 default value of this macro, will expand to the value of
299 @code{thread_file} set in @file{config.gcc}.
300 @end defmac
302 @defmac SYSROOT_SUFFIX_SPEC
303 Define this macro to add a suffix to the target sysroot when GCC is
304 configured with a sysroot.  This will cause GCC to search for usr/lib,
305 et al, within sysroot+suffix.
306 @end defmac
308 @defmac SYSROOT_HEADERS_SUFFIX_SPEC
309 Define this macro to add a headers_suffix to the target sysroot when
310 GCC is configured with a sysroot.  This will cause GCC to pass the
311 updated sysroot+headers_suffix to CPP, causing it to search for
312 usr/include, et al, within sysroot+headers_suffix.
313 @end defmac
315 @defmac EXTRA_SPECS
316 Define this macro to provide additional specifications to put in the
317 @file{specs} file that can be used in various specifications like
318 @code{CC1_SPEC}.
320 The definition should be an initializer for an array of structures,
321 containing a string constant, that defines the specification name, and a
322 string constant that provides the specification.
324 Do not define this macro if it does not need to do anything.
326 @code{EXTRA_SPECS} is useful when an architecture contains several
327 related targets, which have various @code{@dots{}_SPECS} which are similar
328 to each other, and the maintainer would like one central place to keep
329 these definitions.
331 For example, the PowerPC System V.4 targets use @code{EXTRA_SPECS} to
332 define either @code{_CALL_SYSV} when the System V calling sequence is
333 used or @code{_CALL_AIX} when the older AIX-based calling sequence is
334 used.
336 The @file{config/rs6000/rs6000.h} target file defines:
338 @smallexample
339 #define EXTRA_SPECS \
340   @{ "cpp_sysv_default", CPP_SYSV_DEFAULT @},
342 #define CPP_SYS_DEFAULT ""
343 @end smallexample
345 The @file{config/rs6000/sysv.h} target file defines:
346 @smallexample
347 #undef CPP_SPEC
348 #define CPP_SPEC \
349 "%@{posix: -D_POSIX_SOURCE @} \
350 %@{mcall-sysv: -D_CALL_SYSV @} \
351 %@{!mcall-sysv: %(cpp_sysv_default) @} \
352 %@{msoft-float: -D_SOFT_FLOAT@} %@{mcpu=403: -D_SOFT_FLOAT@}"
354 #undef CPP_SYSV_DEFAULT
355 #define CPP_SYSV_DEFAULT "-D_CALL_SYSV"
356 @end smallexample
358 while the @file{config/rs6000/eabiaix.h} target file defines
359 @code{CPP_SYSV_DEFAULT} as:
361 @smallexample
362 #undef CPP_SYSV_DEFAULT
363 #define CPP_SYSV_DEFAULT "-D_CALL_AIX"
364 @end smallexample
365 @end defmac
367 @defmac LINK_LIBGCC_SPECIAL_1
368 Define this macro if the driver program should find the library
369 @file{libgcc.a}.  If you do not define this macro, the driver program will pass
370 the argument @option{-lgcc} to tell the linker to do the search.
371 @end defmac
373 @defmac LINK_GCC_C_SEQUENCE_SPEC
374 The sequence in which libgcc and libc are specified to the linker.
375 By default this is @code{%G %L %G}.
376 @end defmac
378 @defmac POST_LINK_SPEC
379 Define this macro to add additional steps to be executed after linker.
380 The default value of this macro is empty string.
381 @end defmac
383 @defmac LINK_COMMAND_SPEC
384 A C string constant giving the complete command line need to execute the
385 linker.  When you do this, you will need to update your port each time a
386 change is made to the link command line within @file{gcc.c}.  Therefore,
387 define this macro only if you need to completely redefine the command
388 line for invoking the linker and there is no other way to accomplish
389 the effect you need.  Overriding this macro may be avoidable by overriding
390 @code{LINK_GCC_C_SEQUENCE_SPEC} instead.
391 @end defmac
393 @hook TARGET_ALWAYS_STRIP_DOTDOT
395 @defmac MULTILIB_DEFAULTS
396 Define this macro as a C expression for the initializer of an array of
397 string to tell the driver program which options are defaults for this
398 target and thus do not need to be handled specially when using
399 @code{MULTILIB_OPTIONS}.
401 Do not define this macro if @code{MULTILIB_OPTIONS} is not defined in
402 the target makefile fragment or if none of the options listed in
403 @code{MULTILIB_OPTIONS} are set by default.
404 @xref{Target Fragment}.
405 @end defmac
407 @defmac RELATIVE_PREFIX_NOT_LINKDIR
408 Define this macro to tell @command{gcc} that it should only translate
409 a @option{-B} prefix into a @option{-L} linker option if the prefix
410 indicates an absolute file name.
411 @end defmac
413 @defmac MD_EXEC_PREFIX
414 If defined, this macro is an additional prefix to try after
415 @code{STANDARD_EXEC_PREFIX}.  @code{MD_EXEC_PREFIX} is not searched
416 when the compiler is built as a cross
417 compiler.  If you define @code{MD_EXEC_PREFIX}, then be sure to add it
418 to the list of directories used to find the assembler in @file{configure.ac}.
419 @end defmac
421 @defmac STANDARD_STARTFILE_PREFIX
422 Define this macro as a C string constant if you wish to override the
423 standard choice of @code{libdir} as the default prefix to
424 try when searching for startup files such as @file{crt0.o}.
425 @code{STANDARD_STARTFILE_PREFIX} is not searched when the compiler
426 is built as a cross compiler.
427 @end defmac
429 @defmac STANDARD_STARTFILE_PREFIX_1
430 Define this macro as a C string constant if you wish to override the
431 standard choice of @code{/lib} as a prefix to try after the default prefix
432 when searching for startup files such as @file{crt0.o}.
433 @code{STANDARD_STARTFILE_PREFIX_1} is not searched when the compiler
434 is built as a cross compiler.
435 @end defmac
437 @defmac STANDARD_STARTFILE_PREFIX_2
438 Define this macro as a C string constant if you wish to override the
439 standard choice of @code{/lib} as yet another prefix to try after the
440 default prefix when searching for startup files such as @file{crt0.o}.
441 @code{STANDARD_STARTFILE_PREFIX_2} is not searched when the compiler
442 is built as a cross compiler.
443 @end defmac
445 @defmac MD_STARTFILE_PREFIX
446 If defined, this macro supplies an additional prefix to try after the
447 standard prefixes.  @code{MD_EXEC_PREFIX} is not searched when the
448 compiler is built as a cross compiler.
449 @end defmac
451 @defmac MD_STARTFILE_PREFIX_1
452 If defined, this macro supplies yet another prefix to try after the
453 standard prefixes.  It is not searched when the compiler is built as a
454 cross compiler.
455 @end defmac
457 @defmac INIT_ENVIRONMENT
458 Define this macro as a C string constant if you wish to set environment
459 variables for programs called by the driver, such as the assembler and
460 loader.  The driver passes the value of this macro to @code{putenv} to
461 initialize the necessary environment variables.
462 @end defmac
464 @defmac LOCAL_INCLUDE_DIR
465 Define this macro as a C string constant if you wish to override the
466 standard choice of @file{/usr/local/include} as the default prefix to
467 try when searching for local header files.  @code{LOCAL_INCLUDE_DIR}
468 comes before @code{NATIVE_SYSTEM_HEADER_DIR} (set in
469 @file{config.gcc}, normally @file{/usr/include}) in the search order.
471 Cross compilers do not search either @file{/usr/local/include} or its
472 replacement.
473 @end defmac
475 @defmac NATIVE_SYSTEM_HEADER_COMPONENT
476 The ``component'' corresponding to @code{NATIVE_SYSTEM_HEADER_DIR}.
477 See @code{INCLUDE_DEFAULTS}, below, for the description of components.
478 If you do not define this macro, no component is used.
479 @end defmac
481 @defmac INCLUDE_DEFAULTS
482 Define this macro if you wish to override the entire default search path
483 for include files.  For a native compiler, the default search path
484 usually consists of @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR},
485 @code{GPLUSPLUS_INCLUDE_DIR}, and
486 @code{NATIVE_SYSTEM_HEADER_DIR}.  In addition, @code{GPLUSPLUS_INCLUDE_DIR}
487 and @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile},
488 and specify private search areas for GCC@.  The directory
489 @code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs.
491 The definition should be an initializer for an array of structures.
492 Each array element should have four elements: the directory name (a
493 string constant), the component name (also a string constant), a flag
494 for C++-only directories,
495 and a flag showing that the includes in the directory don't need to be
496 wrapped in @code{extern @samp{C}} when compiling C++.  Mark the end of
497 the array with a null element.
499 The component name denotes what GNU package the include file is part of,
500 if any, in all uppercase letters.  For example, it might be @samp{GCC}
501 or @samp{BINUTILS}.  If the package is part of a vendor-supplied
502 operating system, code the component name as @samp{0}.
504 For example, here is the definition used for VAX/VMS:
506 @smallexample
507 #define INCLUDE_DEFAULTS \
508 @{                                       \
509   @{ "GNU_GXX_INCLUDE:", "G++", 1, 1@},   \
510   @{ "GNU_CC_INCLUDE:", "GCC", 0, 0@},    \
511   @{ "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0@},  \
512   @{ ".", 0, 0, 0@},                      \
513   @{ 0, 0, 0, 0@}                         \
515 @end smallexample
516 @end defmac
518 Here is the order of prefixes tried for exec files:
520 @enumerate
521 @item
522 Any prefixes specified by the user with @option{-B}.
524 @item
525 The environment variable @code{GCC_EXEC_PREFIX} or, if @code{GCC_EXEC_PREFIX}
526 is not set and the compiler has not been installed in the configure-time
527 @var{prefix}, the location in which the compiler has actually been installed.
529 @item
530 The directories specified by the environment variable @code{COMPILER_PATH}.
532 @item
533 The macro @code{STANDARD_EXEC_PREFIX}, if the compiler has been installed
534 in the configured-time @var{prefix}.
536 @item
537 The location @file{/usr/libexec/gcc/}, but only if this is a native compiler.
539 @item
540 The location @file{/usr/lib/gcc/}, but only if this is a native compiler.
542 @item
543 The macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native
544 compiler.
545 @end enumerate
547 Here is the order of prefixes tried for startfiles:
549 @enumerate
550 @item
551 Any prefixes specified by the user with @option{-B}.
553 @item
554 The environment variable @code{GCC_EXEC_PREFIX} or its automatically determined
555 value based on the installed toolchain location.
557 @item
558 The directories specified by the environment variable @code{LIBRARY_PATH}
559 (or port-specific name; native only, cross compilers do not use this).
561 @item
562 The macro @code{STANDARD_EXEC_PREFIX}, but only if the toolchain is installed
563 in the configured @var{prefix} or this is a native compiler.
565 @item
566 The location @file{/usr/lib/gcc/}, but only if this is a native compiler.
568 @item
569 The macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native
570 compiler.
572 @item
573 The macro @code{MD_STARTFILE_PREFIX}, if defined, but only if this is a
574 native compiler, or we have a target system root.
576 @item
577 The macro @code{MD_STARTFILE_PREFIX_1}, if defined, but only if this is a
578 native compiler, or we have a target system root.
580 @item
581 The macro @code{STANDARD_STARTFILE_PREFIX}, with any sysroot modifications.
582 If this path is relative it will be prefixed by @code{GCC_EXEC_PREFIX} and
583 the machine suffix or @code{STANDARD_EXEC_PREFIX} and the machine suffix.
585 @item
586 The macro @code{STANDARD_STARTFILE_PREFIX_1}, but only if this is a native
587 compiler, or we have a target system root. The default for this macro is
588 @file{/lib/}.
590 @item
591 The macro @code{STANDARD_STARTFILE_PREFIX_2}, but only if this is a native
592 compiler, or we have a target system root. The default for this macro is
593 @file{/usr/lib/}.
594 @end enumerate
596 @node Run-time Target
597 @section Run-time Target Specification
598 @cindex run-time target specification
599 @cindex predefined macros
600 @cindex target specifications
602 @c prevent bad page break with this line
603 Here are run-time target specifications.
605 @defmac TARGET_CPU_CPP_BUILTINS ()
606 This function-like macro expands to a block of code that defines
607 built-in preprocessor macros and assertions for the target CPU, using
608 the functions @code{builtin_define}, @code{builtin_define_std} and
609 @code{builtin_assert}.  When the front end
610 calls this macro it provides a trailing semicolon, and since it has
611 finished command line option processing your code can use those
612 results freely.
614 @code{builtin_assert} takes a string in the form you pass to the
615 command-line option @option{-A}, such as @code{cpu=mips}, and creates
616 the assertion.  @code{builtin_define} takes a string in the form
617 accepted by option @option{-D} and unconditionally defines the macro.
619 @code{builtin_define_std} takes a string representing the name of an
620 object-like macro.  If it doesn't lie in the user's namespace,
621 @code{builtin_define_std} defines it unconditionally.  Otherwise, it
622 defines a version with two leading underscores, and another version
623 with two leading and trailing underscores, and defines the original
624 only if an ISO standard was not requested on the command line.  For
625 example, passing @code{unix} defines @code{__unix}, @code{__unix__}
626 and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
627 @code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
628 defines only @code{_ABI64}.
630 You can also test for the C dialect being compiled.  The variable
631 @code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus}
632 or @code{clk_objective_c}.  Note that if we are preprocessing
633 assembler, this variable will be @code{clk_c} but the function-like
634 macro @code{preprocessing_asm_p()} will return true, so you might want
635 to check for that first.  If you need to check for strict ANSI, the
636 variable @code{flag_iso} can be used.  The function-like macro
637 @code{preprocessing_trad_p()} can be used to check for traditional
638 preprocessing.
639 @end defmac
641 @defmac TARGET_OS_CPP_BUILTINS ()
642 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
643 and is used for the target operating system instead.
644 @end defmac
646 @defmac TARGET_OBJFMT_CPP_BUILTINS ()
647 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
648 and is used for the target object format.  @file{elfos.h} uses this
649 macro to define @code{__ELF__}, so you probably do not need to define
650 it yourself.
651 @end defmac
653 @deftypevar {extern int} target_flags
654 This variable is declared in @file{options.h}, which is included before
655 any target-specific headers.
656 @end deftypevar
658 @hook TARGET_DEFAULT_TARGET_FLAGS
659 This variable specifies the initial value of @code{target_flags}.
660 Its default setting is 0.
661 @end deftypevr
663 @cindex optional hardware or system features
664 @cindex features, optional, in system conventions
666 @hook TARGET_HANDLE_OPTION
667 This hook is called whenever the user specifies one of the
668 target-specific options described by the @file{.opt} definition files
669 (@pxref{Options}).  It has the opportunity to do some option-specific
670 processing and should return true if the option is valid.  The default
671 definition does nothing but return true.
673 @var{decoded} specifies the option and its arguments.  @var{opts} and
674 @var{opts_set} are the @code{gcc_options} structures to be used for
675 storing option state, and @var{loc} is the location at which the
676 option was passed (@code{UNKNOWN_LOCATION} except for options passed
677 via attributes).
678 @end deftypefn
680 @hook TARGET_HANDLE_C_OPTION
681 This target hook is called whenever the user specifies one of the
682 target-specific C language family options described by the @file{.opt}
683 definition files(@pxref{Options}).  It has the opportunity to do some
684 option-specific processing and should return true if the option is
685 valid.  The arguments are like for @code{TARGET_HANDLE_OPTION}.  The
686 default definition does nothing but return false.
688 In general, you should use @code{TARGET_HANDLE_OPTION} to handle
689 options.  However, if processing an option requires routines that are
690 only available in the C (and related language) front ends, then you
691 should use @code{TARGET_HANDLE_C_OPTION} instead.
692 @end deftypefn
694 @hook TARGET_OBJC_CONSTRUCT_STRING_OBJECT
696 @hook TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE
698 @hook TARGET_OBJC_DECLARE_CLASS_DEFINITION
700 @hook TARGET_STRING_OBJECT_REF_TYPE_P
702 @hook TARGET_CHECK_STRING_OBJECT_FORMAT_ARG
704 @hook TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
706 @defmac C_COMMON_OVERRIDE_OPTIONS
707 This is similar to the @code{TARGET_OPTION_OVERRIDE} hook
708 but is only used in the C
709 language frontends (C, Objective-C, C++, Objective-C++) and so can be
710 used to alter option flag variables which only exist in those
711 frontends.
712 @end defmac
714 @hook TARGET_OPTION_OPTIMIZATION_TABLE
715 Some machines may desire to change what optimizations are performed for
716 various optimization levels.   This variable, if defined, describes
717 options to enable at particular sets of optimization levels.  These
718 options are processed once
719 just after the optimization level is determined and before the remainder
720 of the command options have been parsed, so may be overridden by other
721 options passed explicitly.
723 This processing is run once at program startup and when the optimization
724 options are changed via @code{#pragma GCC optimize} or by using the
725 @code{optimize} attribute.
726 @end deftypevr
728 @hook TARGET_OPTION_INIT_STRUCT
730 @hook TARGET_OPTION_DEFAULT_PARAMS
732 @defmac SWITCHABLE_TARGET
733 Some targets need to switch between substantially different subtargets
734 during compilation.  For example, the MIPS target has one subtarget for
735 the traditional MIPS architecture and another for MIPS16.  Source code
736 can switch between these two subarchitectures using the @code{mips16}
737 and @code{nomips16} attributes.
739 Such subtargets can differ in things like the set of available
740 registers, the set of available instructions, the costs of various
741 operations, and so on.  GCC caches a lot of this type of information
742 in global variables, and recomputing them for each subtarget takes a
743 significant amount of time.  The compiler therefore provides a facility
744 for maintaining several versions of the global variables and quickly
745 switching between them; see @file{target-globals.h} for details.
747 Define this macro to 1 if your target needs this facility.  The default
748 is 0.
749 @end defmac
751 @hook TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P
753 @node Per-Function Data
754 @section Defining data structures for per-function information.
755 @cindex per-function data
756 @cindex data structures
758 If the target needs to store information on a per-function basis, GCC
759 provides a macro and a couple of variables to allow this.  Note, just
760 using statics to store the information is a bad idea, since GCC supports
761 nested functions, so you can be halfway through encoding one function
762 when another one comes along.
764 GCC defines a data structure called @code{struct function} which
765 contains all of the data specific to an individual function.  This
766 structure contains a field called @code{machine} whose type is
767 @code{struct machine_function *}, which can be used by targets to point
768 to their own specific data.
770 If a target needs per-function specific data it should define the type
771 @code{struct machine_function} and also the macro @code{INIT_EXPANDERS}.
772 This macro should be used to initialize the function pointer
773 @code{init_machine_status}.  This pointer is explained below.
775 One typical use of per-function, target specific data is to create an
776 RTX to hold the register containing the function's return address.  This
777 RTX can then be used to implement the @code{__builtin_return_address}
778 function, for level 0.
780 Note---earlier implementations of GCC used a single data area to hold
781 all of the per-function information.  Thus when processing of a nested
782 function began the old per-function data had to be pushed onto a
783 stack, and when the processing was finished, it had to be popped off the
784 stack.  GCC used to provide function pointers called
785 @code{save_machine_status} and @code{restore_machine_status} to handle
786 the saving and restoring of the target specific information.  Since the
787 single data area approach is no longer used, these pointers are no
788 longer supported.
790 @defmac INIT_EXPANDERS
791 Macro called to initialize any target specific information.  This macro
792 is called once per function, before generation of any RTL has begun.
793 The intention of this macro is to allow the initialization of the
794 function pointer @code{init_machine_status}.
795 @end defmac
797 @deftypevar {void (*)(struct function *)} init_machine_status
798 If this function pointer is non-@code{NULL} it will be called once per
799 function, before function compilation starts, in order to allow the
800 target to perform any target specific initialization of the
801 @code{struct function} structure.  It is intended that this would be
802 used to initialize the @code{machine} of that structure.
804 @code{struct machine_function} structures are expected to be freed by GC@.
805 Generally, any memory that they reference must be allocated by using
806 GC allocation, including the structure itself.
807 @end deftypevar
809 @node Storage Layout
810 @section Storage Layout
811 @cindex storage layout
813 Note that the definitions of the macros in this table which are sizes or
814 alignments measured in bits do not need to be constant.  They can be C
815 expressions that refer to static variables, such as the @code{target_flags}.
816 @xref{Run-time Target}.
818 @defmac BITS_BIG_ENDIAN
819 Define this macro to have the value 1 if the most significant bit in a
820 byte has the lowest number; otherwise define it to have the value zero.
821 This means that bit-field instructions count from the most significant
822 bit.  If the machine has no bit-field instructions, then this must still
823 be defined, but it doesn't matter which value it is defined to.  This
824 macro need not be a constant.
826 This macro does not affect the way structure fields are packed into
827 bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}.
828 @end defmac
830 @defmac BYTES_BIG_ENDIAN
831 Define this macro to have the value 1 if the most significant byte in a
832 word has the lowest number.  This macro need not be a constant.
833 @end defmac
835 @defmac WORDS_BIG_ENDIAN
836 Define this macro to have the value 1 if, in a multiword object, the
837 most significant word has the lowest number.  This applies to both
838 memory locations and registers; see @code{REG_WORDS_BIG_ENDIAN} if the
839 order of words in memory is not the same as the order in registers.  This
840 macro need not be a constant.
841 @end defmac
843 @defmac REG_WORDS_BIG_ENDIAN
844 On some machines, the order of words in a multiword object differs between
845 registers in memory.  In such a situation, define this macro to describe
846 the order of words in a register.  The macro @code{WORDS_BIG_ENDIAN} controls
847 the order of words in memory.
848 @end defmac
850 @defmac FLOAT_WORDS_BIG_ENDIAN
851 Define this macro to have the value 1 if @code{DFmode}, @code{XFmode} or
852 @code{TFmode} floating point numbers are stored in memory with the word
853 containing the sign bit at the lowest address; otherwise define it to
854 have the value 0.  This macro need not be a constant.
856 You need not define this macro if the ordering is the same as for
857 multi-word integers.
858 @end defmac
860 @defmac BITS_PER_WORD
861 Number of bits in a word.  If you do not define this macro, the default
862 is @code{BITS_PER_UNIT * UNITS_PER_WORD}.
863 @end defmac
865 @defmac MAX_BITS_PER_WORD
866 Maximum number of bits in a word.  If this is undefined, the default is
867 @code{BITS_PER_WORD}.  Otherwise, it is the constant value that is the
868 largest value that @code{BITS_PER_WORD} can have at run-time.
869 @end defmac
871 @defmac UNITS_PER_WORD
872 Number of storage units in a word; normally the size of a general-purpose
873 register, a power of two from 1 or 8.
874 @end defmac
876 @defmac MIN_UNITS_PER_WORD
877 Minimum number of units in a word.  If this is undefined, the default is
878 @code{UNITS_PER_WORD}.  Otherwise, it is the constant value that is the
879 smallest value that @code{UNITS_PER_WORD} can have at run-time.
880 @end defmac
882 @defmac POINTER_SIZE
883 Width of a pointer, in bits.  You must specify a value no wider than the
884 width of @code{Pmode}.  If it is not equal to the width of @code{Pmode},
885 you must define @code{POINTERS_EXTEND_UNSIGNED}.  If you do not specify
886 a value the default is @code{BITS_PER_WORD}.
887 @end defmac
889 @defmac POINTERS_EXTEND_UNSIGNED
890 A C expression that determines how pointers should be extended from
891 @code{ptr_mode} to either @code{Pmode} or @code{word_mode}.  It is
892 greater than zero if pointers should be zero-extended, zero if they
893 should be sign-extended, and negative if some other sort of conversion
894 is needed.  In the last case, the extension is done by the target's
895 @code{ptr_extend} instruction.
897 You need not define this macro if the @code{ptr_mode}, @code{Pmode}
898 and @code{word_mode} are all the same width.
899 @end defmac
901 @defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type})
902 A macro to update @var{m} and @var{unsignedp} when an object whose type
903 is @var{type} and which has the specified mode and signedness is to be
904 stored in a register.  This macro is only called when @var{type} is a
905 scalar type.
907 On most RISC machines, which only have operations that operate on a full
908 register, define this macro to set @var{m} to @code{word_mode} if
909 @var{m} is an integer mode narrower than @code{BITS_PER_WORD}.  In most
910 cases, only integer modes should be widened because wider-precision
911 floating-point operations are usually more expensive than their narrower
912 counterparts.
914 For most machines, the macro definition does not change @var{unsignedp}.
915 However, some machines, have instructions that preferentially handle
916 either signed or unsigned quantities of certain modes.  For example, on
917 the DEC Alpha, 32-bit loads from memory and 32-bit add instructions
918 sign-extend the result to 64 bits.  On such machines, set
919 @var{unsignedp} according to which kind of extension is more efficient.
921 Do not define this macro if it would never modify @var{m}.
922 @end defmac
924 @hook TARGET_C_EXCESS_PRECISION
926 @hook TARGET_PROMOTE_FUNCTION_MODE
928 @defmac PARM_BOUNDARY
929 Normal alignment required for function parameters on the stack, in
930 bits.  All stack parameters receive at least this much alignment
931 regardless of data type.  On most machines, this is the same as the
932 size of an integer.
933 @end defmac
935 @defmac STACK_BOUNDARY
936 Define this macro to the minimum alignment enforced by hardware for the
937 stack pointer on this machine.  The definition is a C expression for the
938 desired alignment (measured in bits).  This value is used as a default
939 if @code{PREFERRED_STACK_BOUNDARY} is not defined.  On most machines,
940 this should be the same as @code{PARM_BOUNDARY}.
941 @end defmac
943 @defmac PREFERRED_STACK_BOUNDARY
944 Define this macro if you wish to preserve a certain alignment for the
945 stack pointer, greater than what the hardware enforces.  The definition
946 is a C expression for the desired alignment (measured in bits).  This
947 macro must evaluate to a value equal to or larger than
948 @code{STACK_BOUNDARY}.
949 @end defmac
951 @defmac INCOMING_STACK_BOUNDARY
952 Define this macro if the incoming stack boundary may be different
953 from @code{PREFERRED_STACK_BOUNDARY}.  This macro must evaluate
954 to a value equal to or larger than @code{STACK_BOUNDARY}.
955 @end defmac
957 @defmac FUNCTION_BOUNDARY
958 Alignment required for a function entry point, in bits.
959 @end defmac
961 @defmac BIGGEST_ALIGNMENT
962 Biggest alignment that any data type can require on this machine, in
963 bits.  Note that this is not the biggest alignment that is supported,
964 just the biggest alignment that, when violated, may cause a fault.
965 @end defmac
967 @hook TARGET_ABSOLUTE_BIGGEST_ALIGNMENT
969 @defmac MALLOC_ABI_ALIGNMENT
970 Alignment, in bits, a C conformant malloc implementation has to
971 provide.  If not defined, the default value is @code{BITS_PER_WORD}.
972 @end defmac
974 @defmac ATTRIBUTE_ALIGNED_VALUE
975 Alignment used by the @code{__attribute__ ((aligned))} construct.  If
976 not defined, the default value is @code{BIGGEST_ALIGNMENT}.
977 @end defmac
979 @defmac MINIMUM_ATOMIC_ALIGNMENT
980 If defined, the smallest alignment, in bits, that can be given to an
981 object that can be referenced in one operation, without disturbing any
982 nearby object.  Normally, this is @code{BITS_PER_UNIT}, but may be larger
983 on machines that don't have byte or half-word store operations.
984 @end defmac
986 @defmac BIGGEST_FIELD_ALIGNMENT
987 Biggest alignment that any structure or union field can require on this
988 machine, in bits.  If defined, this overrides @code{BIGGEST_ALIGNMENT} for
989 structure and union fields only, unless the field alignment has been set
990 by the @code{__attribute__ ((aligned (@var{n})))} construct.
991 @end defmac
993 @defmac ADJUST_FIELD_ALIGN (@var{field}, @var{type}, @var{computed})
994 An expression for the alignment of a structure field @var{field} of
995 type @var{type} if the alignment computed in the usual way (including
996 applying of @code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the
997 alignment) is @var{computed}.  It overrides alignment only if the
998 field alignment has not been set by the
999 @code{__attribute__ ((aligned (@var{n})))} construct.  Note that @var{field}
1000 may be @code{NULL_TREE} in case we just query for the minimum alignment
1001 of a field of type @var{type} in structure context.
1002 @end defmac
1004 @defmac MAX_STACK_ALIGNMENT
1005 Biggest stack alignment guaranteed by the backend.  Use this macro
1006 to specify the maximum alignment of a variable on stack.
1008 If not defined, the default value is @code{STACK_BOUNDARY}.
1010 @c FIXME: The default should be @code{PREFERRED_STACK_BOUNDARY}.
1011 @c But the fix for PR 32893 indicates that we can only guarantee
1012 @c maximum stack alignment on stack up to @code{STACK_BOUNDARY}, not
1013 @c @code{PREFERRED_STACK_BOUNDARY}, if stack alignment isn't supported.
1014 @end defmac
1016 @defmac MAX_OFILE_ALIGNMENT
1017 Biggest alignment supported by the object file format of this machine.
1018 Use this macro to limit the alignment which can be specified using the
1019 @code{__attribute__ ((aligned (@var{n})))} construct.  If not defined,
1020 the default value is @code{BIGGEST_ALIGNMENT}.
1022 On systems that use ELF, the default (in @file{config/elfos.h}) is
1023 the largest supported 32-bit ELF section alignment representable on
1024 a 32-bit host e.g. @samp{(((uint64_t) 1 << 28) * 8)}.
1025 On 32-bit ELF the largest supported section alignment in bits is
1026 @samp{(0x80000000 * 8)}, but this is not representable on 32-bit hosts.
1027 @end defmac
1029 @defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
1030 If defined, a C expression to compute the alignment for a variable in
1031 the static store.  @var{type} is the data type, and @var{basic-align} is
1032 the alignment that the object would ordinarily have.  The value of this
1033 macro is used instead of that alignment to align the object.
1035 If this macro is not defined, then @var{basic-align} is used.
1037 @findex strcpy
1038 One use of this macro is to increase alignment of medium-size data to
1039 make it all fit in fewer cache lines.  Another is to cause character
1040 arrays to be word-aligned so that @code{strcpy} calls that copy
1041 constants to character arrays can be done inline.
1042 @end defmac
1044 @defmac DATA_ABI_ALIGNMENT (@var{type}, @var{basic-align})
1045 Similar to @code{DATA_ALIGNMENT}, but for the cases where the ABI mandates
1046 some alignment increase, instead of optimization only purposes.  E.g.@
1047 AMD x86-64 psABI says that variables with array type larger than 15 bytes
1048 must be aligned to 16 byte boundaries.
1050 If this macro is not defined, then @var{basic-align} is used.
1051 @end defmac
1053 @defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
1054 If defined, a C expression to compute the alignment given to a constant
1055 that is being placed in memory.  @var{constant} is the constant and
1056 @var{basic-align} is the alignment that the object would ordinarily
1057 have.  The value of this macro is used instead of that alignment to
1058 align the object.
1060 The default definition just returns @var{basic-align}.
1062 The typical use of this macro is to increase alignment for string
1063 constants to be word aligned so that @code{strcpy} calls that copy
1064 constants can be done inline.
1065 @end defmac
1067 @defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
1068 If defined, a C expression to compute the alignment for a variable in
1069 the local store.  @var{type} is the data type, and @var{basic-align} is
1070 the alignment that the object would ordinarily have.  The value of this
1071 macro is used instead of that alignment to align the object.
1073 If this macro is not defined, then @var{basic-align} is used.
1075 One use of this macro is to increase alignment of medium-size data to
1076 make it all fit in fewer cache lines.
1078 If the value of this macro has a type, it should be an unsigned type.
1079 @end defmac
1081 @hook TARGET_VECTOR_ALIGNMENT
1083 @defmac STACK_SLOT_ALIGNMENT (@var{type}, @var{mode}, @var{basic-align})
1084 If defined, a C expression to compute the alignment for stack slot.
1085 @var{type} is the data type, @var{mode} is the widest mode available,
1086 and @var{basic-align} is the alignment that the slot would ordinarily
1087 have.  The value of this macro is used instead of that alignment to
1088 align the slot.
1090 If this macro is not defined, then @var{basic-align} is used when
1091 @var{type} is @code{NULL}.  Otherwise, @code{LOCAL_ALIGNMENT} will
1092 be used.
1094 This macro is to set alignment of stack slot to the maximum alignment
1095 of all possible modes which the slot may have.
1097 If the value of this macro has a type, it should be an unsigned type.
1098 @end defmac
1100 @defmac LOCAL_DECL_ALIGNMENT (@var{decl})
1101 If defined, a C expression to compute the alignment for a local
1102 variable @var{decl}.
1104 If this macro is not defined, then
1105 @code{LOCAL_ALIGNMENT (TREE_TYPE (@var{decl}), DECL_ALIGN (@var{decl}))}
1106 is used.
1108 One use of this macro is to increase alignment of medium-size data to
1109 make it all fit in fewer cache lines.
1111 If the value of this macro has a type, it should be an unsigned type.
1112 @end defmac
1114 @defmac MINIMUM_ALIGNMENT (@var{exp}, @var{mode}, @var{align})
1115 If defined, a C expression to compute the minimum required alignment
1116 for dynamic stack realignment purposes for @var{exp} (a type or decl),
1117 @var{mode}, assuming normal alignment @var{align}.
1119 If this macro is not defined, then @var{align} will be used.
1120 @end defmac
1122 @defmac EMPTY_FIELD_BOUNDARY
1123 Alignment in bits to be given to a structure bit-field that follows an
1124 empty field such as @code{int : 0;}.
1126 If @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro.
1127 @end defmac
1129 @defmac STRUCTURE_SIZE_BOUNDARY
1130 Number of bits which any structure or union's size must be a multiple of.
1131 Each structure or union's size is rounded up to a multiple of this.
1133 If you do not define this macro, the default is the same as
1134 @code{BITS_PER_UNIT}.
1135 @end defmac
1137 @defmac STRICT_ALIGNMENT
1138 Define this macro to be the value 1 if instructions will fail to work
1139 if given data not on the nominal alignment.  If instructions will merely
1140 go slower in that case, define this macro as 0.
1141 @end defmac
1143 @defmac PCC_BITFIELD_TYPE_MATTERS
1144 Define this if you wish to imitate the way many other C compilers handle
1145 alignment of bit-fields and the structures that contain them.
1147 The behavior is that the type written for a named bit-field (@code{int},
1148 @code{short}, or other integer type) imposes an alignment for the entire
1149 structure, as if the structure really did contain an ordinary field of
1150 that type.  In addition, the bit-field is placed within the structure so
1151 that it would fit within such a field, not crossing a boundary for it.
1153 Thus, on most machines, a named bit-field whose type is written as
1154 @code{int} would not cross a four-byte boundary, and would force
1155 four-byte alignment for the whole structure.  (The alignment used may
1156 not be four bytes; it is controlled by the other alignment parameters.)
1158 An unnamed bit-field will not affect the alignment of the containing
1159 structure.
1161 If the macro is defined, its definition should be a C expression;
1162 a nonzero value for the expression enables this behavior.
1164 Note that if this macro is not defined, or its value is zero, some
1165 bit-fields may cross more than one alignment boundary.  The compiler can
1166 support such references if there are @samp{insv}, @samp{extv}, and
1167 @samp{extzv} insns that can directly reference memory.
1169 The other known way of making bit-fields work is to define
1170 @code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}.
1171 Then every structure can be accessed with fullwords.
1173 Unless the machine has bit-field instructions or you define
1174 @code{STRUCTURE_SIZE_BOUNDARY} that way, you must define
1175 @code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value.
1177 If your aim is to make GCC use the same conventions for laying out
1178 bit-fields as are used by another compiler, here is how to investigate
1179 what the other compiler does.  Compile and run this program:
1181 @smallexample
1182 struct foo1
1184   char x;
1185   char :0;
1186   char y;
1189 struct foo2
1191   char x;
1192   int :0;
1193   char y;
1196 main ()
1198   printf ("Size of foo1 is %d\n",
1199           sizeof (struct foo1));
1200   printf ("Size of foo2 is %d\n",
1201           sizeof (struct foo2));
1202   exit (0);
1204 @end smallexample
1206 If this prints 2 and 5, then the compiler's behavior is what you would
1207 get from @code{PCC_BITFIELD_TYPE_MATTERS}.
1208 @end defmac
1210 @defmac BITFIELD_NBYTES_LIMITED
1211 Like @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited
1212 to aligning a bit-field within the structure.
1213 @end defmac
1215 @hook TARGET_ALIGN_ANON_BITFIELD
1217 @hook TARGET_NARROW_VOLATILE_BITFIELD
1219 @hook TARGET_MEMBER_TYPE_FORCES_BLK
1221 @defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified})
1222 Define this macro as an expression for the alignment of a type (given
1223 by @var{type} as a tree node) if the alignment computed in the usual
1224 way is @var{computed} and the alignment explicitly specified was
1225 @var{specified}.
1227 The default is to use @var{specified} if it is larger; otherwise, use
1228 the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT}
1229 @end defmac
1231 @defmac MAX_FIXED_MODE_SIZE
1232 An integer expression for the size in bits of the largest integer
1233 machine mode that should actually be used.  All integer machine modes of
1234 this size or smaller can be used for structures and unions with the
1235 appropriate sizes.  If this macro is undefined, @code{GET_MODE_BITSIZE
1236 (DImode)} is assumed.
1237 @end defmac
1239 @defmac STACK_SAVEAREA_MODE (@var{save_level})
1240 If defined, an expression of type @code{machine_mode} that
1241 specifies the mode of the save area operand of a
1242 @code{save_stack_@var{level}} named pattern (@pxref{Standard Names}).
1243 @var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or
1244 @code{SAVE_NONLOCAL} and selects which of the three named patterns is
1245 having its mode specified.
1247 You need not define this macro if it always returns @code{Pmode}.  You
1248 would most commonly define this macro if the
1249 @code{save_stack_@var{level}} patterns need to support both a 32- and a
1250 64-bit mode.
1251 @end defmac
1253 @defmac STACK_SIZE_MODE
1254 If defined, an expression of type @code{machine_mode} that
1255 specifies the mode of the size increment operand of an
1256 @code{allocate_stack} named pattern (@pxref{Standard Names}).
1258 You need not define this macro if it always returns @code{word_mode}.
1259 You would most commonly define this macro if the @code{allocate_stack}
1260 pattern needs to support both a 32- and a 64-bit mode.
1261 @end defmac
1263 @hook TARGET_LIBGCC_CMP_RETURN_MODE
1265 @hook TARGET_LIBGCC_SHIFT_COUNT_MODE
1267 @hook TARGET_UNWIND_WORD_MODE
1269 @hook TARGET_MS_BITFIELD_LAYOUT_P
1271 @hook TARGET_DECIMAL_FLOAT_SUPPORTED_P
1273 @hook TARGET_FIXED_POINT_SUPPORTED_P
1275 @hook TARGET_EXPAND_TO_RTL_HOOK
1277 @hook TARGET_INSTANTIATE_DECLS
1279 @hook TARGET_MANGLE_TYPE
1281 @node Type Layout
1282 @section Layout of Source Language Data Types
1284 These macros define the sizes and other characteristics of the standard
1285 basic data types used in programs being compiled.  Unlike the macros in
1286 the previous section, these apply to specific features of C and related
1287 languages, rather than to fundamental aspects of storage layout.
1289 @defmac INT_TYPE_SIZE
1290 A C expression for the size in bits of the type @code{int} on the
1291 target machine.  If you don't define this, the default is one word.
1292 @end defmac
1294 @defmac SHORT_TYPE_SIZE
1295 A C expression for the size in bits of the type @code{short} on the
1296 target machine.  If you don't define this, the default is half a word.
1297 (If this would be less than one storage unit, it is rounded up to one
1298 unit.)
1299 @end defmac
1301 @defmac LONG_TYPE_SIZE
1302 A C expression for the size in bits of the type @code{long} on the
1303 target machine.  If you don't define this, the default is one word.
1304 @end defmac
1306 @defmac ADA_LONG_TYPE_SIZE
1307 On some machines, the size used for the Ada equivalent of the type
1308 @code{long} by a native Ada compiler differs from that used by C@.  In
1309 that situation, define this macro to be a C expression to be used for
1310 the size of that type.  If you don't define this, the default is the
1311 value of @code{LONG_TYPE_SIZE}.
1312 @end defmac
1314 @defmac LONG_LONG_TYPE_SIZE
1315 A C expression for the size in bits of the type @code{long long} on the
1316 target machine.  If you don't define this, the default is two
1317 words.  If you want to support GNU Ada on your machine, the value of this
1318 macro must be at least 64.
1319 @end defmac
1321 @defmac CHAR_TYPE_SIZE
1322 A C expression for the size in bits of the type @code{char} on the
1323 target machine.  If you don't define this, the default is
1324 @code{BITS_PER_UNIT}.
1325 @end defmac
1327 @defmac BOOL_TYPE_SIZE
1328 A C expression for the size in bits of the C++ type @code{bool} and
1329 C99 type @code{_Bool} on the target machine.  If you don't define
1330 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
1331 @end defmac
1333 @defmac FLOAT_TYPE_SIZE
1334 A C expression for the size in bits of the type @code{float} on the
1335 target machine.  If you don't define this, the default is one word.
1336 @end defmac
1338 @defmac DOUBLE_TYPE_SIZE
1339 A C expression for the size in bits of the type @code{double} on the
1340 target machine.  If you don't define this, the default is two
1341 words.
1342 @end defmac
1344 @defmac LONG_DOUBLE_TYPE_SIZE
1345 A C expression for the size in bits of the type @code{long double} on
1346 the target machine.  If you don't define this, the default is two
1347 words.
1348 @end defmac
1350 @defmac SHORT_FRACT_TYPE_SIZE
1351 A C expression for the size in bits of the type @code{short _Fract} on
1352 the target machine.  If you don't define this, the default is
1353 @code{BITS_PER_UNIT}.
1354 @end defmac
1356 @defmac FRACT_TYPE_SIZE
1357 A C expression for the size in bits of the type @code{_Fract} on
1358 the target machine.  If you don't define this, the default is
1359 @code{BITS_PER_UNIT * 2}.
1360 @end defmac
1362 @defmac LONG_FRACT_TYPE_SIZE
1363 A C expression for the size in bits of the type @code{long _Fract} on
1364 the target machine.  If you don't define this, the default is
1365 @code{BITS_PER_UNIT * 4}.
1366 @end defmac
1368 @defmac LONG_LONG_FRACT_TYPE_SIZE
1369 A C expression for the size in bits of the type @code{long long _Fract} on
1370 the target machine.  If you don't define this, the default is
1371 @code{BITS_PER_UNIT * 8}.
1372 @end defmac
1374 @defmac SHORT_ACCUM_TYPE_SIZE
1375 A C expression for the size in bits of the type @code{short _Accum} on
1376 the target machine.  If you don't define this, the default is
1377 @code{BITS_PER_UNIT * 2}.
1378 @end defmac
1380 @defmac ACCUM_TYPE_SIZE
1381 A C expression for the size in bits of the type @code{_Accum} on
1382 the target machine.  If you don't define this, the default is
1383 @code{BITS_PER_UNIT * 4}.
1384 @end defmac
1386 @defmac LONG_ACCUM_TYPE_SIZE
1387 A C expression for the size in bits of the type @code{long _Accum} on
1388 the target machine.  If you don't define this, the default is
1389 @code{BITS_PER_UNIT * 8}.
1390 @end defmac
1392 @defmac LONG_LONG_ACCUM_TYPE_SIZE
1393 A C expression for the size in bits of the type @code{long long _Accum} on
1394 the target machine.  If you don't define this, the default is
1395 @code{BITS_PER_UNIT * 16}.
1396 @end defmac
1398 @defmac LIBGCC2_GNU_PREFIX
1399 This macro corresponds to the @code{TARGET_LIBFUNC_GNU_PREFIX} target
1400 hook and should be defined if that hook is overriden to be true.  It
1401 causes function names in libgcc to be changed to use a @code{__gnu_}
1402 prefix for their name rather than the default @code{__}.  A port which
1403 uses this macro should also arrange to use @file{t-gnu-prefix} in
1404 the libgcc @file{config.host}.
1405 @end defmac
1407 @defmac WIDEST_HARDWARE_FP_SIZE
1408 A C expression for the size in bits of the widest floating-point format
1409 supported by the hardware.  If you define this macro, you must specify a
1410 value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
1411 If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
1412 is the default.
1413 @end defmac
1415 @defmac DEFAULT_SIGNED_CHAR
1416 An expression whose value is 1 or 0, according to whether the type
1417 @code{char} should be signed or unsigned by default.  The user can
1418 always override this default with the options @option{-fsigned-char}
1419 and @option{-funsigned-char}.
1420 @end defmac
1422 @hook TARGET_DEFAULT_SHORT_ENUMS
1424 @defmac SIZE_TYPE
1425 A C expression for a string describing the name of the data type to use
1426 for size values.  The typedef name @code{size_t} is defined using the
1427 contents of the string.
1429 The string can contain more than one keyword.  If so, separate them with
1430 spaces, and write first any length keyword, then @code{unsigned} if
1431 appropriate, and finally @code{int}.  The string must exactly match one
1432 of the data type names defined in the function
1433 @code{c_common_nodes_and_builtins} in the file @file{c-family/c-common.c}.
1434 You may not omit @code{int} or change the order---that would cause the
1435 compiler to crash on startup.
1437 If you don't define this macro, the default is @code{"long unsigned
1438 int"}.
1439 @end defmac
1441 @defmac SIZETYPE
1442 GCC defines internal types (@code{sizetype}, @code{ssizetype},
1443 @code{bitsizetype} and @code{sbitsizetype}) for expressions
1444 dealing with size.  This macro is a C expression for a string describing
1445 the name of the data type from which the precision of @code{sizetype}
1446 is extracted.
1448 The string has the same restrictions as @code{SIZE_TYPE} string.
1450 If you don't define this macro, the default is @code{SIZE_TYPE}.
1451 @end defmac
1453 @defmac PTRDIFF_TYPE
1454 A C expression for a string describing the name of the data type to use
1455 for the result of subtracting two pointers.  The typedef name
1456 @code{ptrdiff_t} is defined using the contents of the string.  See
1457 @code{SIZE_TYPE} above for more information.
1459 If you don't define this macro, the default is @code{"long int"}.
1460 @end defmac
1462 @defmac WCHAR_TYPE
1463 A C expression for a string describing the name of the data type to use
1464 for wide characters.  The typedef name @code{wchar_t} is defined using
1465 the contents of the string.  See @code{SIZE_TYPE} above for more
1466 information.
1468 If you don't define this macro, the default is @code{"int"}.
1469 @end defmac
1471 @defmac WCHAR_TYPE_SIZE
1472 A C expression for the size in bits of the data type for wide
1473 characters.  This is used in @code{cpp}, which cannot make use of
1474 @code{WCHAR_TYPE}.
1475 @end defmac
1477 @defmac WINT_TYPE
1478 A C expression for a string describing the name of the data type to
1479 use for wide characters passed to @code{printf} and returned from
1480 @code{getwc}.  The typedef name @code{wint_t} is defined using the
1481 contents of the string.  See @code{SIZE_TYPE} above for more
1482 information.
1484 If you don't define this macro, the default is @code{"unsigned int"}.
1485 @end defmac
1487 @defmac INTMAX_TYPE
1488 A C expression for a string describing the name of the data type that
1489 can represent any value of any standard or extended signed integer type.
1490 The typedef name @code{intmax_t} is defined using the contents of the
1491 string.  See @code{SIZE_TYPE} above for more information.
1493 If you don't define this macro, the default is the first of
1494 @code{"int"}, @code{"long int"}, or @code{"long long int"} that has as
1495 much precision as @code{long long int}.
1496 @end defmac
1498 @defmac UINTMAX_TYPE
1499 A C expression for a string describing the name of the data type that
1500 can represent any value of any standard or extended unsigned integer
1501 type.  The typedef name @code{uintmax_t} is defined using the contents
1502 of the string.  See @code{SIZE_TYPE} above for more information.
1504 If you don't define this macro, the default is the first of
1505 @code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long
1506 unsigned int"} that has as much precision as @code{long long unsigned
1507 int}.
1508 @end defmac
1510 @defmac SIG_ATOMIC_TYPE
1511 @defmacx INT8_TYPE
1512 @defmacx INT16_TYPE
1513 @defmacx INT32_TYPE
1514 @defmacx INT64_TYPE
1515 @defmacx UINT8_TYPE
1516 @defmacx UINT16_TYPE
1517 @defmacx UINT32_TYPE
1518 @defmacx UINT64_TYPE
1519 @defmacx INT_LEAST8_TYPE
1520 @defmacx INT_LEAST16_TYPE
1521 @defmacx INT_LEAST32_TYPE
1522 @defmacx INT_LEAST64_TYPE
1523 @defmacx UINT_LEAST8_TYPE
1524 @defmacx UINT_LEAST16_TYPE
1525 @defmacx UINT_LEAST32_TYPE
1526 @defmacx UINT_LEAST64_TYPE
1527 @defmacx INT_FAST8_TYPE
1528 @defmacx INT_FAST16_TYPE
1529 @defmacx INT_FAST32_TYPE
1530 @defmacx INT_FAST64_TYPE
1531 @defmacx UINT_FAST8_TYPE
1532 @defmacx UINT_FAST16_TYPE
1533 @defmacx UINT_FAST32_TYPE
1534 @defmacx UINT_FAST64_TYPE
1535 @defmacx INTPTR_TYPE
1536 @defmacx UINTPTR_TYPE
1537 C expressions for the standard types @code{sig_atomic_t},
1538 @code{int8_t}, @code{int16_t}, @code{int32_t}, @code{int64_t},
1539 @code{uint8_t}, @code{uint16_t}, @code{uint32_t}, @code{uint64_t},
1540 @code{int_least8_t}, @code{int_least16_t}, @code{int_least32_t},
1541 @code{int_least64_t}, @code{uint_least8_t}, @code{uint_least16_t},
1542 @code{uint_least32_t}, @code{uint_least64_t}, @code{int_fast8_t},
1543 @code{int_fast16_t}, @code{int_fast32_t}, @code{int_fast64_t},
1544 @code{uint_fast8_t}, @code{uint_fast16_t}, @code{uint_fast32_t},
1545 @code{uint_fast64_t}, @code{intptr_t}, and @code{uintptr_t}.  See
1546 @code{SIZE_TYPE} above for more information.
1548 If any of these macros evaluates to a null pointer, the corresponding
1549 type is not supported; if GCC is configured to provide
1550 @code{<stdint.h>} in such a case, the header provided may not conform
1551 to C99, depending on the type in question.  The defaults for all of
1552 these macros are null pointers.
1553 @end defmac
1555 @defmac TARGET_PTRMEMFUNC_VBIT_LOCATION
1556 The C++ compiler represents a pointer-to-member-function with a struct
1557 that looks like:
1559 @smallexample
1560   struct @{
1561     union @{
1562       void (*fn)();
1563       ptrdiff_t vtable_index;
1564     @};
1565     ptrdiff_t delta;
1566   @};
1567 @end smallexample
1569 @noindent
1570 The C++ compiler must use one bit to indicate whether the function that
1571 will be called through a pointer-to-member-function is virtual.
1572 Normally, we assume that the low-order bit of a function pointer must
1573 always be zero.  Then, by ensuring that the vtable_index is odd, we can
1574 distinguish which variant of the union is in use.  But, on some
1575 platforms function pointers can be odd, and so this doesn't work.  In
1576 that case, we use the low-order bit of the @code{delta} field, and shift
1577 the remainder of the @code{delta} field to the left.
1579 GCC will automatically make the right selection about where to store
1580 this bit using the @code{FUNCTION_BOUNDARY} setting for your platform.
1581 However, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY}
1582 set such that functions always start at even addresses, but the lowest
1583 bit of pointers to functions indicate whether the function at that
1584 address is in ARM or Thumb mode.  If this is the case of your
1585 architecture, you should define this macro to
1586 @code{ptrmemfunc_vbit_in_delta}.
1588 In general, you should not have to define this macro.  On architectures
1589 in which function addresses are always even, according to
1590 @code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to
1591 @code{ptrmemfunc_vbit_in_pfn}.
1592 @end defmac
1594 @defmac TARGET_VTABLE_USES_DESCRIPTORS
1595 Normally, the C++ compiler uses function pointers in vtables.  This
1596 macro allows the target to change to use ``function descriptors''
1597 instead.  Function descriptors are found on targets for whom a
1598 function pointer is actually a small data structure.  Normally the
1599 data structure consists of the actual code address plus a data
1600 pointer to which the function's data is relative.
1602 If vtables are used, the value of this macro should be the number
1603 of words that the function descriptor occupies.
1604 @end defmac
1606 @defmac TARGET_VTABLE_ENTRY_ALIGN
1607 By default, the vtable entries are void pointers, the so the alignment
1608 is the same as pointer alignment.  The value of this macro specifies
1609 the alignment of the vtable entry in bits.  It should be defined only
1610 when special alignment is necessary. */
1611 @end defmac
1613 @defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE
1614 There are a few non-descriptor entries in the vtable at offsets below
1615 zero.  If these entries must be padded (say, to preserve the alignment
1616 specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
1617 of words in each data entry.
1618 @end defmac
1620 @node Registers
1621 @section Register Usage
1622 @cindex register usage
1624 This section explains how to describe what registers the target machine
1625 has, and how (in general) they can be used.
1627 The description of which registers a specific instruction can use is
1628 done with register classes; see @ref{Register Classes}.  For information
1629 on using registers to access a stack frame, see @ref{Frame Registers}.
1630 For passing values in registers, see @ref{Register Arguments}.
1631 For returning values in registers, see @ref{Scalar Return}.
1633 @menu
1634 * Register Basics::             Number and kinds of registers.
1635 * Allocation Order::            Order in which registers are allocated.
1636 * Values in Registers::         What kinds of values each reg can hold.
1637 * Leaf Functions::              Renumbering registers for leaf functions.
1638 * Stack Registers::             Handling a register stack such as 80387.
1639 @end menu
1641 @node Register Basics
1642 @subsection Basic Characteristics of Registers
1644 @c prevent bad page break with this line
1645 Registers have various characteristics.
1647 @defmac FIRST_PSEUDO_REGISTER
1648 Number of hardware registers known to the compiler.  They receive
1649 numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
1650 pseudo register's number really is assigned the number
1651 @code{FIRST_PSEUDO_REGISTER}.
1652 @end defmac
1654 @defmac FIXED_REGISTERS
1655 @cindex fixed register
1656 An initializer that says which registers are used for fixed purposes
1657 all throughout the compiled code and are therefore not available for
1658 general allocation.  These would include the stack pointer, the frame
1659 pointer (except on machines where that can be used as a general
1660 register when no frame pointer is needed), the program counter on
1661 machines where that is considered one of the addressable registers,
1662 and any other numbered register with a standard use.
1664 This information is expressed as a sequence of numbers, separated by
1665 commas and surrounded by braces.  The @var{n}th number is 1 if
1666 register @var{n} is fixed, 0 otherwise.
1668 The table initialized from this macro, and the table initialized by
1669 the following one, may be overridden at run time either automatically,
1670 by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
1671 the user with the command options @option{-ffixed-@var{reg}},
1672 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}.
1673 @end defmac
1675 @defmac CALL_USED_REGISTERS
1676 @cindex call-used register
1677 @cindex call-clobbered register
1678 @cindex call-saved register
1679 Like @code{FIXED_REGISTERS} but has 1 for each register that is
1680 clobbered (in general) by function calls as well as for fixed
1681 registers.  This macro therefore identifies the registers that are not
1682 available for general allocation of values that must live across
1683 function calls.
1685 If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
1686 automatically saves it on function entry and restores it on function
1687 exit, if the register is used within the function.
1688 @end defmac
1690 @defmac CALL_REALLY_USED_REGISTERS
1691 @cindex call-used register
1692 @cindex call-clobbered register
1693 @cindex call-saved register
1694 Like @code{CALL_USED_REGISTERS} except this macro doesn't require
1695 that the entire set of @code{FIXED_REGISTERS} be included.
1696 (@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}).
1697 This macro is optional.  If not specified, it defaults to the value
1698 of @code{CALL_USED_REGISTERS}.
1699 @end defmac
1701 @defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
1702 @cindex call-used register
1703 @cindex call-clobbered register
1704 @cindex call-saved register
1705 A C expression that is nonzero if it is not permissible to store a
1706 value of mode @var{mode} in hard register number @var{regno} across a
1707 call without some part of it being clobbered.  For most machines this
1708 macro need not be defined.  It is only required for machines that do not
1709 preserve the entire contents of a register across a call.
1710 @end defmac
1712 @findex fixed_regs
1713 @findex call_used_regs
1714 @findex global_regs
1715 @findex reg_names
1716 @findex reg_class_contents
1717 @hook TARGET_CONDITIONAL_REGISTER_USAGE
1719 @defmac INCOMING_REGNO (@var{out})
1720 Define this macro if the target machine has register windows.  This C
1721 expression returns the register number as seen by the called function
1722 corresponding to the register number @var{out} as seen by the calling
1723 function.  Return @var{out} if register number @var{out} is not an
1724 outbound register.
1725 @end defmac
1727 @defmac OUTGOING_REGNO (@var{in})
1728 Define this macro if the target machine has register windows.  This C
1729 expression returns the register number as seen by the calling function
1730 corresponding to the register number @var{in} as seen by the called
1731 function.  Return @var{in} if register number @var{in} is not an inbound
1732 register.
1733 @end defmac
1735 @defmac LOCAL_REGNO (@var{regno})
1736 Define this macro if the target machine has register windows.  This C
1737 expression returns true if the register is call-saved but is in the
1738 register window.  Unlike most call-saved registers, such registers
1739 need not be explicitly restored on function exit or during non-local
1740 gotos.
1741 @end defmac
1743 @defmac PC_REGNUM
1744 If the program counter has a register number, define this as that
1745 register number.  Otherwise, do not define it.
1746 @end defmac
1748 @node Allocation Order
1749 @subsection Order of Allocation of Registers
1750 @cindex order of register allocation
1751 @cindex register allocation order
1753 @c prevent bad page break with this line
1754 Registers are allocated in order.
1756 @defmac REG_ALLOC_ORDER
1757 If defined, an initializer for a vector of integers, containing the
1758 numbers of hard registers in the order in which GCC should prefer
1759 to use them (from most preferred to least).
1761 If this macro is not defined, registers are used lowest numbered first
1762 (all else being equal).
1764 One use of this macro is on machines where the highest numbered
1765 registers must always be saved and the save-multiple-registers
1766 instruction supports only sequences of consecutive registers.  On such
1767 machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists
1768 the highest numbered allocable register first.
1769 @end defmac
1771 @defmac ADJUST_REG_ALLOC_ORDER
1772 A C statement (sans semicolon) to choose the order in which to allocate
1773 hard registers for pseudo-registers local to a basic block.
1775 Store the desired register order in the array @code{reg_alloc_order}.
1776 Element 0 should be the register to allocate first; element 1, the next
1777 register; and so on.
1779 The macro body should not assume anything about the contents of
1780 @code{reg_alloc_order} before execution of the macro.
1782 On most machines, it is not necessary to define this macro.
1783 @end defmac
1785 @defmac HONOR_REG_ALLOC_ORDER
1786 Normally, IRA tries to estimate the costs for saving a register in the
1787 prologue and restoring it in the epilogue.  This discourages it from
1788 using call-saved registers.  If a machine wants to ensure that IRA
1789 allocates registers in the order given by REG_ALLOC_ORDER even if some
1790 call-saved registers appear earlier than call-used ones, then define this
1791 macro as a C expression to nonzero. Default is 0.
1792 @end defmac
1794 @defmac IRA_HARD_REGNO_ADD_COST_MULTIPLIER (@var{regno})
1795 In some case register allocation order is not enough for the
1796 Integrated Register Allocator (@acronym{IRA}) to generate a good code.
1797 If this macro is defined, it should return a floating point value
1798 based on @var{regno}.  The cost of using @var{regno} for a pseudo will
1799 be increased by approximately the pseudo's usage frequency times the
1800 value returned by this macro.  Not defining this macro is equivalent
1801 to having it always return @code{0.0}.
1803 On most machines, it is not necessary to define this macro.
1804 @end defmac
1806 @node Values in Registers
1807 @subsection How Values Fit in Registers
1809 This section discusses the macros that describe which kinds of values
1810 (specifically, which machine modes) each register can hold, and how many
1811 consecutive registers are needed for a given mode.
1813 @defmac HARD_REGNO_NREGS (@var{regno}, @var{mode})
1814 A C expression for the number of consecutive hard registers, starting
1815 at register number @var{regno}, required to hold a value of mode
1816 @var{mode}.  This macro must never return zero, even if a register
1817 cannot hold the requested mode - indicate that with HARD_REGNO_MODE_OK
1818 and/or CANNOT_CHANGE_MODE_CLASS instead.
1820 On a machine where all registers are exactly one word, a suitable
1821 definition of this macro is
1823 @smallexample
1824 #define HARD_REGNO_NREGS(REGNO, MODE)            \
1825    ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1)  \
1826     / UNITS_PER_WORD)
1827 @end smallexample
1828 @end defmac
1830 @defmac HARD_REGNO_NREGS_HAS_PADDING (@var{regno}, @var{mode})
1831 A C expression that is nonzero if a value of mode @var{mode}, stored
1832 in memory, ends with padding that causes it to take up more space than
1833 in registers starting at register number @var{regno} (as determined by
1834 multiplying GCC's notion of the size of the register when containing
1835 this mode by the number of registers returned by
1836 @code{HARD_REGNO_NREGS}).  By default this is zero.
1838 For example, if a floating-point value is stored in three 32-bit
1839 registers but takes up 128 bits in memory, then this would be
1840 nonzero.
1842 This macros only needs to be defined if there are cases where
1843 @code{subreg_get_info}
1844 would otherwise wrongly determine that a @code{subreg} can be
1845 represented by an offset to the register number, when in fact such a
1846 @code{subreg} would contain some of the padding not stored in
1847 registers and so not be representable.
1848 @end defmac
1850 @defmac HARD_REGNO_NREGS_WITH_PADDING (@var{regno}, @var{mode})
1851 For values of @var{regno} and @var{mode} for which
1852 @code{HARD_REGNO_NREGS_HAS_PADDING} returns nonzero, a C expression
1853 returning the greater number of registers required to hold the value
1854 including any padding.  In the example above, the value would be four.
1855 @end defmac
1857 @defmac REGMODE_NATURAL_SIZE (@var{mode})
1858 Define this macro if the natural size of registers that hold values
1859 of mode @var{mode} is not the word size.  It is a C expression that
1860 should give the natural size in bytes for the specified mode.  It is
1861 used by the register allocator to try to optimize its results.  This
1862 happens for example on SPARC 64-bit where the natural size of
1863 floating-point registers is still 32-bit.
1864 @end defmac
1866 @defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
1867 A C expression that is nonzero if it is permissible to store a value
1868 of mode @var{mode} in hard register number @var{regno} (or in several
1869 registers starting with that one).  For a machine where all registers
1870 are equivalent, a suitable definition is
1872 @smallexample
1873 #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
1874 @end smallexample
1876 You need not include code to check for the numbers of fixed registers,
1877 because the allocation mechanism considers them to be always occupied.
1879 @cindex register pairs
1880 On some machines, double-precision values must be kept in even/odd
1881 register pairs.  You can implement that by defining this macro to reject
1882 odd register numbers for such modes.
1884 The minimum requirement for a mode to be OK in a register is that the
1885 @samp{mov@var{mode}} instruction pattern support moves between the
1886 register and other hard register in the same class and that moving a
1887 value into the register and back out not alter it.
1889 Since the same instruction used to move @code{word_mode} will work for
1890 all narrower integer modes, it is not necessary on any machine for
1891 @code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided
1892 you define patterns @samp{movhi}, etc., to take advantage of this.  This
1893 is useful because of the interaction between @code{HARD_REGNO_MODE_OK}
1894 and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes
1895 to be tieable.
1897 Many machines have special registers for floating point arithmetic.
1898 Often people assume that floating point machine modes are allowed only
1899 in floating point registers.  This is not true.  Any registers that
1900 can hold integers can safely @emph{hold} a floating point machine
1901 mode, whether or not floating arithmetic can be done on it in those
1902 registers.  Integer move instructions can be used to move the values.
1904 On some machines, though, the converse is true: fixed-point machine
1905 modes may not go in floating registers.  This is true if the floating
1906 registers normalize any value stored in them, because storing a
1907 non-floating value there would garble it.  In this case,
1908 @code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in
1909 floating registers.  But if the floating registers do not automatically
1910 normalize, if you can store any bit pattern in one and retrieve it
1911 unchanged without a trap, then any machine mode may go in a floating
1912 register, so you can define this macro to say so.
1914 The primary significance of special floating registers is rather that
1915 they are the registers acceptable in floating point arithmetic
1916 instructions.  However, this is of no concern to
1917 @code{HARD_REGNO_MODE_OK}.  You handle it by writing the proper
1918 constraints for those instructions.
1920 On some machines, the floating registers are especially slow to access,
1921 so that it is better to store a value in a stack frame than in such a
1922 register if floating point arithmetic is not being done.  As long as the
1923 floating registers are not in class @code{GENERAL_REGS}, they will not
1924 be used unless some pattern's constraint asks for one.
1925 @end defmac
1927 @defmac HARD_REGNO_RENAME_OK (@var{from}, @var{to})
1928 A C expression that is nonzero if it is OK to rename a hard register
1929 @var{from} to another hard register @var{to}.
1931 One common use of this macro is to prevent renaming of a register to
1932 another register that is not saved by a prologue in an interrupt
1933 handler.
1935 The default is always nonzero.
1936 @end defmac
1938 @defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2})
1939 A C expression that is nonzero if a value of mode
1940 @var{mode1} is accessible in mode @var{mode2} without copying.
1942 If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
1943 @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for
1944 any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})}
1945 should be nonzero.  If they differ for any @var{r}, you should define
1946 this macro to return zero unless some other mechanism ensures the
1947 accessibility of the value in a narrower mode.
1949 You should define this macro to return nonzero in as many cases as
1950 possible since doing so will allow GCC to perform better register
1951 allocation.
1952 @end defmac
1954 @hook TARGET_HARD_REGNO_SCRATCH_OK
1956 @defmac AVOID_CCMODE_COPIES
1957 Define this macro if the compiler should avoid copies to/from @code{CCmode}
1958 registers.  You should only define this macro if support for copying to/from
1959 @code{CCmode} is incomplete.
1960 @end defmac
1962 @node Leaf Functions
1963 @subsection Handling Leaf Functions
1965 @cindex leaf functions
1966 @cindex functions, leaf
1967 On some machines, a leaf function (i.e., one which makes no calls) can run
1968 more efficiently if it does not make its own register window.  Often this
1969 means it is required to receive its arguments in the registers where they
1970 are passed by the caller, instead of the registers where they would
1971 normally arrive.
1973 The special treatment for leaf functions generally applies only when
1974 other conditions are met; for example, often they may use only those
1975 registers for its own variables and temporaries.  We use the term ``leaf
1976 function'' to mean a function that is suitable for this special
1977 handling, so that functions with no calls are not necessarily ``leaf
1978 functions''.
1980 GCC assigns register numbers before it knows whether the function is
1981 suitable for leaf function treatment.  So it needs to renumber the
1982 registers in order to output a leaf function.  The following macros
1983 accomplish this.
1985 @defmac LEAF_REGISTERS
1986 Name of a char vector, indexed by hard register number, which
1987 contains 1 for a register that is allowable in a candidate for leaf
1988 function treatment.
1990 If leaf function treatment involves renumbering the registers, then the
1991 registers marked here should be the ones before renumbering---those that
1992 GCC would ordinarily allocate.  The registers which will actually be
1993 used in the assembler code, after renumbering, should not be marked with 1
1994 in this vector.
1996 Define this macro only if the target machine offers a way to optimize
1997 the treatment of leaf functions.
1998 @end defmac
2000 @defmac LEAF_REG_REMAP (@var{regno})
2001 A C expression whose value is the register number to which @var{regno}
2002 should be renumbered, when a function is treated as a leaf function.
2004 If @var{regno} is a register number which should not appear in a leaf
2005 function before renumbering, then the expression should yield @minus{}1, which
2006 will cause the compiler to abort.
2008 Define this macro only if the target machine offers a way to optimize the
2009 treatment of leaf functions, and registers need to be renumbered to do
2010 this.
2011 @end defmac
2013 @findex current_function_is_leaf
2014 @findex current_function_uses_only_leaf_regs
2015 @code{TARGET_ASM_FUNCTION_PROLOGUE} and
2016 @code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions
2017 specially.  They can test the C variable @code{current_function_is_leaf}
2018 which is nonzero for leaf functions.  @code{current_function_is_leaf} is
2019 set prior to local register allocation and is valid for the remaining
2020 compiler passes.  They can also test the C variable
2021 @code{current_function_uses_only_leaf_regs} which is nonzero for leaf
2022 functions which only use leaf registers.
2023 @code{current_function_uses_only_leaf_regs} is valid after all passes
2024 that modify the instructions have been run and is only useful if
2025 @code{LEAF_REGISTERS} is defined.
2026 @c changed this to fix overfull.  ALSO:  why the "it" at the beginning
2027 @c of the next paragraph?!  --mew 2feb93
2029 @node Stack Registers
2030 @subsection Registers That Form a Stack
2032 There are special features to handle computers where some of the
2033 ``registers'' form a stack.  Stack registers are normally written by
2034 pushing onto the stack, and are numbered relative to the top of the
2035 stack.
2037 Currently, GCC can only handle one group of stack-like registers, and
2038 they must be consecutively numbered.  Furthermore, the existing
2039 support for stack-like registers is specific to the 80387 floating
2040 point coprocessor.  If you have a new architecture that uses
2041 stack-like registers, you will need to do substantial work on
2042 @file{reg-stack.c} and write your machine description to cooperate
2043 with it, as well as defining these macros.
2045 @defmac STACK_REGS
2046 Define this if the machine has any stack-like registers.
2047 @end defmac
2049 @defmac STACK_REG_COVER_CLASS
2050 This is a cover class containing the stack registers.  Define this if
2051 the machine has any stack-like registers.
2052 @end defmac
2054 @defmac FIRST_STACK_REG
2055 The number of the first stack-like register.  This one is the top
2056 of the stack.
2057 @end defmac
2059 @defmac LAST_STACK_REG
2060 The number of the last stack-like register.  This one is the bottom of
2061 the stack.
2062 @end defmac
2064 @node Register Classes
2065 @section Register Classes
2066 @cindex register class definitions
2067 @cindex class definitions, register
2069 On many machines, the numbered registers are not all equivalent.
2070 For example, certain registers may not be allowed for indexed addressing;
2071 certain registers may not be allowed in some instructions.  These machine
2072 restrictions are described to the compiler using @dfn{register classes}.
2074 You define a number of register classes, giving each one a name and saying
2075 which of the registers belong to it.  Then you can specify register classes
2076 that are allowed as operands to particular instruction patterns.
2078 @findex ALL_REGS
2079 @findex NO_REGS
2080 In general, each register will belong to several classes.  In fact, one
2081 class must be named @code{ALL_REGS} and contain all the registers.  Another
2082 class must be named @code{NO_REGS} and contain no registers.  Often the
2083 union of two classes will be another class; however, this is not required.
2085 @findex GENERAL_REGS
2086 One of the classes must be named @code{GENERAL_REGS}.  There is nothing
2087 terribly special about the name, but the operand constraint letters
2088 @samp{r} and @samp{g} specify this class.  If @code{GENERAL_REGS} is
2089 the same as @code{ALL_REGS}, just define it as a macro which expands
2090 to @code{ALL_REGS}.
2092 Order the classes so that if class @var{x} is contained in class @var{y}
2093 then @var{x} has a lower class number than @var{y}.
2095 The way classes other than @code{GENERAL_REGS} are specified in operand
2096 constraints is through machine-dependent operand constraint letters.
2097 You can define such letters to correspond to various classes, then use
2098 them in operand constraints.
2100 You must define the narrowest register classes for allocatable
2101 registers, so that each class either has no subclasses, or that for
2102 some mode, the move cost between registers within the class is
2103 cheaper than moving a register in the class to or from memory
2104 (@pxref{Costs}).
2106 You should define a class for the union of two classes whenever some
2107 instruction allows both classes.  For example, if an instruction allows
2108 either a floating point (coprocessor) register or a general register for a
2109 certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
2110 which includes both of them.  Otherwise you will get suboptimal code,
2111 or even internal compiler errors when reload cannot find a register in the
2112 class computed via @code{reg_class_subunion}.
2114 You must also specify certain redundant information about the register
2115 classes: for each class, which classes contain it and which ones are
2116 contained in it; for each pair of classes, the largest class contained
2117 in their union.
2119 When a value occupying several consecutive registers is expected in a
2120 certain class, all the registers used must belong to that class.
2121 Therefore, register classes cannot be used to enforce a requirement for
2122 a register pair to start with an even-numbered register.  The way to
2123 specify this requirement is with @code{HARD_REGNO_MODE_OK}.
2125 Register classes used for input-operands of bitwise-and or shift
2126 instructions have a special requirement: each such class must have, for
2127 each fixed-point machine mode, a subclass whose registers can transfer that
2128 mode to or from memory.  For example, on some machines, the operations for
2129 single-byte values (@code{QImode}) are limited to certain registers.  When
2130 this is so, each register class that is used in a bitwise-and or shift
2131 instruction must have a subclass consisting of registers from which
2132 single-byte values can be loaded or stored.  This is so that
2133 @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
2135 @deftp {Data type} {enum reg_class}
2136 An enumerated type that must be defined with all the register class names
2137 as enumerated values.  @code{NO_REGS} must be first.  @code{ALL_REGS}
2138 must be the last register class, followed by one more enumerated value,
2139 @code{LIM_REG_CLASSES}, which is not a register class but rather
2140 tells how many classes there are.
2142 Each register class has a number, which is the value of casting
2143 the class name to type @code{int}.  The number serves as an index
2144 in many of the tables described below.
2145 @end deftp
2147 @defmac N_REG_CLASSES
2148 The number of distinct register classes, defined as follows:
2150 @smallexample
2151 #define N_REG_CLASSES (int) LIM_REG_CLASSES
2152 @end smallexample
2153 @end defmac
2155 @defmac REG_CLASS_NAMES
2156 An initializer containing the names of the register classes as C string
2157 constants.  These names are used in writing some of the debugging dumps.
2158 @end defmac
2160 @defmac REG_CLASS_CONTENTS
2161 An initializer containing the contents of the register classes, as integers
2162 which are bit masks.  The @var{n}th integer specifies the contents of class
2163 @var{n}.  The way the integer @var{mask} is interpreted is that
2164 register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
2166 When the machine has more than 32 registers, an integer does not suffice.
2167 Then the integers are replaced by sub-initializers, braced groupings containing
2168 several integers.  Each sub-initializer must be suitable as an initializer
2169 for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
2170 In this situation, the first integer in each sub-initializer corresponds to
2171 registers 0 through 31, the second integer to registers 32 through 63, and
2172 so on.
2173 @end defmac
2175 @defmac REGNO_REG_CLASS (@var{regno})
2176 A C expression whose value is a register class containing hard register
2177 @var{regno}.  In general there is more than one such class; choose a class
2178 which is @dfn{minimal}, meaning that no smaller class also contains the
2179 register.
2180 @end defmac
2182 @defmac BASE_REG_CLASS
2183 A macro whose definition is the name of the class to which a valid
2184 base register must belong.  A base register is one used in an address
2185 which is the register value plus a displacement.
2186 @end defmac
2188 @defmac MODE_BASE_REG_CLASS (@var{mode})
2189 This is a variation of the @code{BASE_REG_CLASS} macro which allows
2190 the selection of a base register in a mode dependent manner.  If
2191 @var{mode} is VOIDmode then it should return the same value as
2192 @code{BASE_REG_CLASS}.
2193 @end defmac
2195 @defmac MODE_BASE_REG_REG_CLASS (@var{mode})
2196 A C expression whose value is the register class to which a valid
2197 base register must belong in order to be used in a base plus index
2198 register address.  You should define this macro if base plus index
2199 addresses have different requirements than other base register uses.
2200 @end defmac
2202 @defmac MODE_CODE_BASE_REG_CLASS (@var{mode}, @var{address_space}, @var{outer_code}, @var{index_code})
2203 A C expression whose value is the register class to which a valid
2204 base register for a memory reference in mode @var{mode} to address
2205 space @var{address_space} must belong.  @var{outer_code} and @var{index_code}
2206 define the context in which the base register occurs.  @var{outer_code} is
2207 the code of the immediately enclosing expression (@code{MEM} for the top level
2208 of an address, @code{ADDRESS} for something that occurs in an
2209 @code{address_operand}).  @var{index_code} is the code of the corresponding
2210 index expression if @var{outer_code} is @code{PLUS}; @code{SCRATCH} otherwise.
2211 @end defmac
2213 @defmac INDEX_REG_CLASS
2214 A macro whose definition is the name of the class to which a valid
2215 index register must belong.  An index register is one used in an
2216 address where its value is either multiplied by a scale factor or
2217 added to another register (as well as added to a displacement).
2218 @end defmac
2220 @defmac REGNO_OK_FOR_BASE_P (@var{num})
2221 A C expression which is nonzero if register number @var{num} is
2222 suitable for use as a base register in operand addresses.
2223 @end defmac
2225 @defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode})
2226 A C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that
2227 that expression may examine the mode of the memory reference in
2228 @var{mode}.  You should define this macro if the mode of the memory
2229 reference affects whether a register may be used as a base register.  If
2230 you define this macro, the compiler will use it instead of
2231 @code{REGNO_OK_FOR_BASE_P}.  The mode may be @code{VOIDmode} for
2232 addresses that appear outside a @code{MEM}, i.e., as an
2233 @code{address_operand}.
2234 @end defmac
2236 @defmac REGNO_MODE_OK_FOR_REG_BASE_P (@var{num}, @var{mode})
2237 A C expression which is nonzero if register number @var{num} is suitable for
2238 use as a base register in base plus index operand addresses, accessing
2239 memory in mode @var{mode}.  It may be either a suitable hard register or a
2240 pseudo register that has been allocated such a hard register.  You should
2241 define this macro if base plus index addresses have different requirements
2242 than other base register uses.
2244 Use of this macro is deprecated; please use the more general
2245 @code{REGNO_MODE_CODE_OK_FOR_BASE_P}.
2246 @end defmac
2248 @defmac REGNO_MODE_CODE_OK_FOR_BASE_P (@var{num}, @var{mode}, @var{address_space}, @var{outer_code}, @var{index_code})
2249 A C expression which is nonzero if register number @var{num} is
2250 suitable for use as a base register in operand addresses, accessing
2251 memory in mode @var{mode} in address space @var{address_space}.
2252 This is similar to @code{REGNO_MODE_OK_FOR_BASE_P}, except
2253 that that expression may examine the context in which the register
2254 appears in the memory reference.  @var{outer_code} is the code of the
2255 immediately enclosing expression (@code{MEM} if at the top level of the
2256 address, @code{ADDRESS} for something that occurs in an
2257 @code{address_operand}).  @var{index_code} is the code of the
2258 corresponding index expression if @var{outer_code} is @code{PLUS};
2259 @code{SCRATCH} otherwise.  The mode may be @code{VOIDmode} for addresses
2260 that appear outside a @code{MEM}, i.e., as an @code{address_operand}.
2261 @end defmac
2263 @defmac REGNO_OK_FOR_INDEX_P (@var{num})
2264 A C expression which is nonzero if register number @var{num} is
2265 suitable for use as an index register in operand addresses.  It may be
2266 either a suitable hard register or a pseudo register that has been
2267 allocated such a hard register.
2269 The difference between an index register and a base register is that
2270 the index register may be scaled.  If an address involves the sum of
2271 two registers, neither one of them scaled, then either one may be
2272 labeled the ``base'' and the other the ``index''; but whichever
2273 labeling is used must fit the machine's constraints of which registers
2274 may serve in each capacity.  The compiler will try both labelings,
2275 looking for one that is valid, and will reload one or both registers
2276 only if neither labeling works.
2277 @end defmac
2279 @hook TARGET_PREFERRED_RENAME_CLASS
2281 @hook TARGET_PREFERRED_RELOAD_CLASS
2283 @defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
2284 A C expression that places additional restrictions on the register class
2285 to use when it is necessary to copy value @var{x} into a register in class
2286 @var{class}.  The value is a register class; perhaps @var{class}, or perhaps
2287 another, smaller class.  On many machines, the following definition is
2288 safe:
2290 @smallexample
2291 #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
2292 @end smallexample
2294 Sometimes returning a more restrictive class makes better code.  For
2295 example, on the 68000, when @var{x} is an integer constant that is in range
2296 for a @samp{moveq} instruction, the value of this macro is always
2297 @code{DATA_REGS} as long as @var{class} includes the data registers.
2298 Requiring a data register guarantees that a @samp{moveq} will be used.
2300 One case where @code{PREFERRED_RELOAD_CLASS} must not return
2301 @var{class} is if @var{x} is a legitimate constant which cannot be
2302 loaded into some register class.  By returning @code{NO_REGS} you can
2303 force @var{x} into a memory location.  For example, rs6000 can load
2304 immediate values into general-purpose registers, but does not have an
2305 instruction for loading an immediate value into a floating-point
2306 register, so @code{PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2307 @var{x} is a floating-point constant.  If the constant cannot be loaded
2308 into any kind of register, code generation will be better if
2309 @code{TARGET_LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
2310 of using @code{TARGET_PREFERRED_RELOAD_CLASS}.
2312 If an insn has pseudos in it after register allocation, reload will go
2313 through the alternatives and call repeatedly @code{PREFERRED_RELOAD_CLASS}
2314 to find the best one.  Returning @code{NO_REGS}, in this case, makes
2315 reload add a @code{!} in front of the constraint: the x86 back-end uses
2316 this feature to discourage usage of 387 registers when math is done in
2317 the SSE registers (and vice versa).
2318 @end defmac
2320 @hook TARGET_PREFERRED_OUTPUT_RELOAD_CLASS
2322 @defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class})
2323 A C expression that places additional restrictions on the register class
2324 to use when it is necessary to be able to hold a value of mode
2325 @var{mode} in a reload register for which class @var{class} would
2326 ordinarily be used.
2328 Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when
2329 there are certain modes that simply cannot go in certain reload classes.
2331 The value is a register class; perhaps @var{class}, or perhaps another,
2332 smaller class.
2334 Don't define this macro unless the target machine has limitations which
2335 require the macro to do something nontrivial.
2336 @end defmac
2338 @hook TARGET_SECONDARY_RELOAD
2340 @defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2341 @defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2342 @defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2343 These macros are obsolete, new ports should use the target hook
2344 @code{TARGET_SECONDARY_RELOAD} instead.
2346 These are obsolete macros, replaced by the @code{TARGET_SECONDARY_RELOAD}
2347 target hook.  Older ports still define these macros to indicate to the
2348 reload phase that it may
2349 need to allocate at least one register for a reload in addition to the
2350 register to contain the data.  Specifically, if copying @var{x} to a
2351 register @var{class} in @var{mode} requires an intermediate register,
2352 you were supposed to define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the
2353 largest register class all of whose registers can be used as
2354 intermediate registers or scratch registers.
2356 If copying a register @var{class} in @var{mode} to @var{x} requires an
2357 intermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS}
2358 was supposed to be defined be defined to return the largest register
2359 class required.  If the
2360 requirements for input and output reloads were the same, the macro
2361 @code{SECONDARY_RELOAD_CLASS} should have been used instead of defining both
2362 macros identically.
2364 The values returned by these macros are often @code{GENERAL_REGS}.
2365 Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x}
2366 can be directly copied to or from a register of @var{class} in
2367 @var{mode} without requiring a scratch register.  Do not define this
2368 macro if it would always return @code{NO_REGS}.
2370 If a scratch register is required (either with or without an
2371 intermediate register), you were supposed to define patterns for
2372 @samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required
2373 (@pxref{Standard Names}.  These patterns, which were normally
2374 implemented with a @code{define_expand}, should be similar to the
2375 @samp{mov@var{m}} patterns, except that operand 2 is the scratch
2376 register.
2378 These patterns need constraints for the reload register and scratch
2379 register that
2380 contain a single register class.  If the original reload register (whose
2381 class is @var{class}) can meet the constraint given in the pattern, the
2382 value returned by these macros is used for the class of the scratch
2383 register.  Otherwise, two additional reload registers are required.
2384 Their classes are obtained from the constraints in the insn pattern.
2386 @var{x} might be a pseudo-register or a @code{subreg} of a
2387 pseudo-register, which could either be in a hard register or in memory.
2388 Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2389 in memory and the hard register number if it is in a register.
2391 These macros should not be used in the case where a particular class of
2392 registers can only be copied to memory and not to another class of
2393 registers.  In that case, secondary reload registers are not needed and
2394 would not be helpful.  Instead, a stack location must be used to perform
2395 the copy and the @code{mov@var{m}} pattern should use memory as an
2396 intermediate storage.  This case often occurs between floating-point and
2397 general registers.
2398 @end defmac
2400 @defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m})
2401 Certain machines have the property that some registers cannot be copied
2402 to some other registers without using memory.  Define this macro on
2403 those machines to be a C expression that is nonzero if objects of mode
2404 @var{m} in registers of @var{class1} can only be copied to registers of
2405 class @var{class2} by storing a register of @var{class1} into memory
2406 and loading that memory location into a register of @var{class2}.
2408 Do not define this macro if its value would always be zero.
2409 @end defmac
2411 @defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode})
2412 Normally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler
2413 allocates a stack slot for a memory location needed for register copies.
2414 If this macro is defined, the compiler instead uses the memory location
2415 defined by this macro.
2417 Do not define this macro if you do not define
2418 @code{SECONDARY_MEMORY_NEEDED}.
2419 @end defmac
2421 @defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode})
2422 When the compiler needs a secondary memory location to copy between two
2423 registers of mode @var{mode}, it normally allocates sufficient memory to
2424 hold a quantity of @code{BITS_PER_WORD} bits and performs the store and
2425 load operations in a mode that many bits wide and whose class is the
2426 same as that of @var{mode}.
2428 This is right thing to do on most machines because it ensures that all
2429 bits of the register are copied and prevents accesses to the registers
2430 in a narrower mode, which some machines prohibit for floating-point
2431 registers.
2433 However, this default behavior is not correct on some machines, such as
2434 the DEC Alpha, that store short integers in floating-point registers
2435 differently than in integer registers.  On those machines, the default
2436 widening will not work correctly and you must define this macro to
2437 suppress that widening in some cases.  See the file @file{alpha.h} for
2438 details.
2440 Do not define this macro if you do not define
2441 @code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that
2442 is @code{BITS_PER_WORD} bits wide is correct for your machine.
2443 @end defmac
2445 @hook TARGET_CLASS_LIKELY_SPILLED_P
2447 @hook TARGET_CLASS_MAX_NREGS
2449 @defmac CLASS_MAX_NREGS (@var{class}, @var{mode})
2450 A C expression for the maximum number of consecutive registers
2451 of class @var{class} needed to hold a value of mode @var{mode}.
2453 This is closely related to the macro @code{HARD_REGNO_NREGS}.  In fact,
2454 the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
2455 should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno},
2456 @var{mode})} for all @var{regno} values in the class @var{class}.
2458 This macro helps control the handling of multiple-word values
2459 in the reload pass.
2460 @end defmac
2462 @defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
2463 If defined, a C expression that returns nonzero for a @var{class} for which
2464 a change from mode @var{from} to mode @var{to} is invalid.
2466 For example, loading 32-bit integer or floating-point objects into
2467 floating-point registers on Alpha extends them to 64 bits.
2468 Therefore loading a 64-bit object and then storing it as a 32-bit object
2469 does not store the low-order 32 bits, as would be the case for a normal
2470 register.  Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
2471 as below:
2473 @smallexample
2474 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
2475   (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
2476    ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
2477 @end smallexample
2479 Even if storing from a register in mode @var{to} would be valid,
2480 if both @var{from} and @code{raw_reg_mode} for @var{class} are wider
2481 than @code{word_mode}, then we must prevent @var{to} narrowing the
2482 mode.  This happens when the middle-end assumes that it can load
2483 or store pieces of an @var{N}-word pseudo, and that the pseudo will
2484 eventually be allocated to @var{N} @code{word_mode} hard registers.
2485 Failure to prevent this kind of mode change will result in the
2486 entire @code{raw_reg_mode} being modified instead of the partial
2487 value that the middle-end intended.
2489 @end defmac
2491 @hook TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS
2493 @hook TARGET_LRA_P
2495 @hook TARGET_REGISTER_PRIORITY
2497 @hook TARGET_REGISTER_USAGE_LEVELING_P
2499 @hook TARGET_DIFFERENT_ADDR_DISPLACEMENT_P
2501 @hook TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P
2503 @hook TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT
2505 @hook TARGET_SPILL_CLASS
2507 @hook TARGET_ADDITIONAL_ALLOCNO_CLASS_P
2509 @hook TARGET_CSTORE_MODE
2511 @hook TARGET_COMPUTE_PRESSURE_CLASSES
2513 @node Stack and Calling
2514 @section Stack Layout and Calling Conventions
2515 @cindex calling conventions
2517 @c prevent bad page break with this line
2518 This describes the stack layout and calling conventions.
2520 @menu
2521 * Frame Layout::
2522 * Exception Handling::
2523 * Stack Checking::
2524 * Frame Registers::
2525 * Elimination::
2526 * Stack Arguments::
2527 * Register Arguments::
2528 * Scalar Return::
2529 * Aggregate Return::
2530 * Caller Saves::
2531 * Function Entry::
2532 * Profiling::
2533 * Tail Calls::
2534 * Shrink-wrapping separate components::
2535 * Stack Smashing Protection::
2536 * Miscellaneous Register Hooks::
2537 @end menu
2539 @node Frame Layout
2540 @subsection Basic Stack Layout
2541 @cindex stack frame layout
2542 @cindex frame layout
2544 @c prevent bad page break with this line
2545 Here is the basic stack layout.
2547 @defmac STACK_GROWS_DOWNWARD
2548 Define this macro to be true if pushing a word onto the stack moves the stack
2549 pointer to a smaller address, and false otherwise.
2550 @end defmac
2552 @defmac STACK_PUSH_CODE
2553 This macro defines the operation used when something is pushed
2554 on the stack.  In RTL, a push operation will be
2555 @code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})}
2557 The choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC},
2558 and @code{POST_INC}.  Which of these is correct depends on
2559 the stack direction and on whether the stack pointer points
2560 to the last item on the stack or whether it points to the
2561 space for the next item on the stack.
2563 The default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is
2564 true, which is almost always right, and @code{PRE_INC} otherwise,
2565 which is often wrong.
2566 @end defmac
2568 @defmac FRAME_GROWS_DOWNWARD
2569 Define this macro to nonzero value if the addresses of local variable slots
2570 are at negative offsets from the frame pointer.
2571 @end defmac
2573 @defmac ARGS_GROW_DOWNWARD
2574 Define this macro if successive arguments to a function occupy decreasing
2575 addresses on the stack.
2576 @end defmac
2578 @defmac STARTING_FRAME_OFFSET
2579 Offset from the frame pointer to the first local variable slot to be allocated.
2581 If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
2582 subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
2583 Otherwise, it is found by adding the length of the first slot to the
2584 value @code{STARTING_FRAME_OFFSET}.
2585 @c i'm not sure if the above is still correct.. had to change it to get
2586 @c rid of an overfull.  --mew 2feb93
2587 @end defmac
2589 @defmac STACK_ALIGNMENT_NEEDED
2590 Define to zero to disable final alignment of the stack during reload.
2591 The nonzero default for this macro is suitable for most ports.
2593 On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
2594 is a register save block following the local block that doesn't require
2595 alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
2596 stack alignment and do it in the backend.
2597 @end defmac
2599 @defmac STACK_POINTER_OFFSET
2600 Offset from the stack pointer register to the first location at which
2601 outgoing arguments are placed.  If not specified, the default value of
2602 zero is used.  This is the proper value for most machines.
2604 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
2605 the first location at which outgoing arguments are placed.
2606 @end defmac
2608 @defmac FIRST_PARM_OFFSET (@var{fundecl})
2609 Offset from the argument pointer register to the first argument's
2610 address.  On some machines it may depend on the data type of the
2611 function.
2613 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
2614 the first argument's address.
2615 @end defmac
2617 @defmac STACK_DYNAMIC_OFFSET (@var{fundecl})
2618 Offset from the stack pointer register to an item dynamically allocated
2619 on the stack, e.g., by @code{alloca}.
2621 The default value for this macro is @code{STACK_POINTER_OFFSET} plus the
2622 length of the outgoing arguments.  The default is correct for most
2623 machines.  See @file{function.c} for details.
2624 @end defmac
2626 @defmac INITIAL_FRAME_ADDRESS_RTX
2627 A C expression whose value is RTL representing the address of the initial
2628 stack frame. This address is passed to @code{RETURN_ADDR_RTX} and
2629 @code{DYNAMIC_CHAIN_ADDRESS}.  If you don't define this macro, a reasonable
2630 default value will be used.  Define this macro in order to make frame pointer
2631 elimination work in the presence of @code{__builtin_frame_address (count)} and
2632 @code{__builtin_return_address (count)} for @code{count} not equal to zero.
2633 @end defmac
2635 @defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
2636 A C expression whose value is RTL representing the address in a stack
2637 frame where the pointer to the caller's frame is stored.  Assume that
2638 @var{frameaddr} is an RTL expression for the address of the stack frame
2639 itself.
2641 If you don't define this macro, the default is to return the value
2642 of @var{frameaddr}---that is, the stack frame address is also the
2643 address of the stack word that points to the previous frame.
2644 @end defmac
2646 @defmac SETUP_FRAME_ADDRESSES
2647 A C expression that produces the machine-specific code to
2648 setup the stack so that arbitrary frames can be accessed.  For example,
2649 on the SPARC, we must flush all of the register windows to the stack
2650 before we can access arbitrary stack frames.  You will seldom need to
2651 define this macro.  The default is to do nothing.
2652 @end defmac
2654 @hook TARGET_BUILTIN_SETJMP_FRAME_VALUE
2656 @defmac FRAME_ADDR_RTX (@var{frameaddr})
2657 A C expression whose value is RTL representing the value of the frame
2658 address for the current frame.  @var{frameaddr} is the frame pointer
2659 of the current frame.  This is used for __builtin_frame_address.
2660 You need only define this macro if the frame address is not the same
2661 as the frame pointer.  Most machines do not need to define it.
2662 @end defmac
2664 @defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr})
2665 A C expression whose value is RTL representing the value of the return
2666 address for the frame @var{count} steps up from the current frame, after
2667 the prologue.  @var{frameaddr} is the frame pointer of the @var{count}
2668 frame, or the frame pointer of the @var{count} @minus{} 1 frame if
2669 @code{RETURN_ADDR_IN_PREVIOUS_FRAME} is nonzero.
2671 The value of the expression must always be the correct address when
2672 @var{count} is zero, but may be @code{NULL_RTX} if there is no way to
2673 determine the return address of other frames.
2674 @end defmac
2676 @defmac RETURN_ADDR_IN_PREVIOUS_FRAME
2677 Define this macro to nonzero value if the return address of a particular
2678 stack frame is accessed from the frame pointer of the previous stack
2679 frame.  The zero default for this macro is suitable for most ports.
2680 @end defmac
2682 @defmac INCOMING_RETURN_ADDR_RTX
2683 A C expression whose value is RTL representing the location of the
2684 incoming return address at the beginning of any function, before the
2685 prologue.  This RTL is either a @code{REG}, indicating that the return
2686 value is saved in @samp{REG}, or a @code{MEM} representing a location in
2687 the stack.
2689 You only need to define this macro if you want to support call frame
2690 debugging information like that provided by DWARF 2.
2692 If this RTL is a @code{REG}, you should also define
2693 @code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}.
2694 @end defmac
2696 @defmac DWARF_ALT_FRAME_RETURN_COLUMN
2697 A C expression whose value is an integer giving a DWARF 2 column
2698 number that may be used as an alternative return column.  The column
2699 must not correspond to any gcc hard register (that is, it must not
2700 be in the range of @code{DWARF_FRAME_REGNUM}).
2702 This macro can be useful if @code{DWARF_FRAME_RETURN_COLUMN} is set to a
2703 general register, but an alternative column needs to be used for signal
2704 frames.  Some targets have also used different frame return columns
2705 over time.
2706 @end defmac
2708 @defmac DWARF_ZERO_REG
2709 A C expression whose value is an integer giving a DWARF 2 register
2710 number that is considered to always have the value zero.  This should
2711 only be defined if the target has an architected zero register, and
2712 someone decided it was a good idea to use that register number to
2713 terminate the stack backtrace.  New ports should avoid this.
2714 @end defmac
2716 @hook TARGET_DWARF_HANDLE_FRAME_UNSPEC
2718 @defmac INCOMING_FRAME_SP_OFFSET
2719 A C expression whose value is an integer giving the offset, in bytes,
2720 from the value of the stack pointer register to the top of the stack
2721 frame at the beginning of any function, before the prologue.  The top of
2722 the frame is defined to be the value of the stack pointer in the
2723 previous frame, just before the call instruction.
2725 You only need to define this macro if you want to support call frame
2726 debugging information like that provided by DWARF 2.
2727 @end defmac
2729 @defmac ARG_POINTER_CFA_OFFSET (@var{fundecl})
2730 A C expression whose value is an integer giving the offset, in bytes,
2731 from the argument pointer to the canonical frame address (cfa).  The
2732 final value should coincide with that calculated by
2733 @code{INCOMING_FRAME_SP_OFFSET}.  Which is unfortunately not usable
2734 during virtual register instantiation.
2736 The default value for this macro is
2737 @code{FIRST_PARM_OFFSET (fundecl) + crtl->args.pretend_args_size},
2738 which is correct for most machines; in general, the arguments are found
2739 immediately before the stack frame.  Note that this is not the case on
2740 some targets that save registers into the caller's frame, such as SPARC
2741 and rs6000, and so such targets need to define this macro.
2743 You only need to define this macro if the default is incorrect, and you
2744 want to support call frame debugging information like that provided by
2745 DWARF 2.
2746 @end defmac
2748 @defmac FRAME_POINTER_CFA_OFFSET (@var{fundecl})
2749 If defined, a C expression whose value is an integer giving the offset
2750 in bytes from the frame pointer to the canonical frame address (cfa).
2751 The final value should coincide with that calculated by
2752 @code{INCOMING_FRAME_SP_OFFSET}.
2754 Normally the CFA is calculated as an offset from the argument pointer,
2755 via @code{ARG_POINTER_CFA_OFFSET}, but if the argument pointer is
2756 variable due to the ABI, this may not be possible.  If this macro is
2757 defined, it implies that the virtual register instantiation should be
2758 based on the frame pointer instead of the argument pointer.  Only one
2759 of @code{FRAME_POINTER_CFA_OFFSET} and @code{ARG_POINTER_CFA_OFFSET}
2760 should be defined.
2761 @end defmac
2763 @defmac CFA_FRAME_BASE_OFFSET (@var{fundecl})
2764 If defined, a C expression whose value is an integer giving the offset
2765 in bytes from the canonical frame address (cfa) to the frame base used
2766 in DWARF 2 debug information.  The default is zero.  A different value
2767 may reduce the size of debug information on some ports.
2768 @end defmac
2770 @node Exception Handling
2771 @subsection Exception Handling Support
2772 @cindex exception handling
2774 @defmac EH_RETURN_DATA_REGNO (@var{N})
2775 A C expression whose value is the @var{N}th register number used for
2776 data by exception handlers, or @code{INVALID_REGNUM} if fewer than
2777 @var{N} registers are usable.
2779 The exception handling library routines communicate with the exception
2780 handlers via a set of agreed upon registers.  Ideally these registers
2781 should be call-clobbered; it is possible to use call-saved registers,
2782 but may negatively impact code size.  The target must support at least
2783 2 data registers, but should define 4 if there are enough free registers.
2785 You must define this macro if you want to support call frame exception
2786 handling like that provided by DWARF 2.
2787 @end defmac
2789 @defmac EH_RETURN_STACKADJ_RTX
2790 A C expression whose value is RTL representing a location in which
2791 to store a stack adjustment to be applied before function return.
2792 This is used to unwind the stack to an exception handler's call frame.
2793 It will be assigned zero on code paths that return normally.
2795 Typically this is a call-clobbered hard register that is otherwise
2796 untouched by the epilogue, but could also be a stack slot.
2798 Do not define this macro if the stack pointer is saved and restored
2799 by the regular prolog and epilog code in the call frame itself; in
2800 this case, the exception handling library routines will update the
2801 stack location to be restored in place.  Otherwise, you must define
2802 this macro if you want to support call frame exception handling like
2803 that provided by DWARF 2.
2804 @end defmac
2806 @defmac EH_RETURN_HANDLER_RTX
2807 A C expression whose value is RTL representing a location in which
2808 to store the address of an exception handler to which we should
2809 return.  It will not be assigned on code paths that return normally.
2811 Typically this is the location in the call frame at which the normal
2812 return address is stored.  For targets that return by popping an
2813 address off the stack, this might be a memory address just below
2814 the @emph{target} call frame rather than inside the current call
2815 frame.  If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
2816 been assigned, so it may be used to calculate the location of the
2817 target call frame.
2819 Some targets have more complex requirements than storing to an
2820 address calculable during initial code generation.  In that case
2821 the @code{eh_return} instruction pattern should be used instead.
2823 If you want to support call frame exception handling, you must
2824 define either this macro or the @code{eh_return} instruction pattern.
2825 @end defmac
2827 @defmac RETURN_ADDR_OFFSET
2828 If defined, an integer-valued C expression for which rtl will be generated
2829 to add it to the exception handler address before it is searched in the
2830 exception handling tables, and to subtract it again from the address before
2831 using it to return to the exception handler.
2832 @end defmac
2834 @defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global})
2835 This macro chooses the encoding of pointers embedded in the exception
2836 handling sections.  If at all possible, this should be defined such
2837 that the exception handling section will not require dynamic relocations,
2838 and so may be read-only.
2840 @var{code} is 0 for data, 1 for code labels, 2 for function pointers.
2841 @var{global} is true if the symbol may be affected by dynamic relocations.
2842 The macro should return a combination of the @code{DW_EH_PE_*} defines
2843 as found in @file{dwarf2.h}.
2845 If this macro is not defined, pointers will not be encoded but
2846 represented directly.
2847 @end defmac
2849 @defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done})
2850 This macro allows the target to emit whatever special magic is required
2851 to represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}.
2852 Generic code takes care of pc-relative and indirect encodings; this must
2853 be defined if the target uses text-relative or data-relative encodings.
2855 This is a C statement that branches to @var{done} if the format was
2856 handled.  @var{encoding} is the format chosen, @var{size} is the number
2857 of bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF}
2858 to be emitted.
2859 @end defmac
2861 @defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs})
2862 This macro allows the target to add CPU and operating system specific
2863 code to the call-frame unwinder for use when there is no unwind data
2864 available.  The most common reason to implement this macro is to unwind
2865 through signal frames.
2867 This macro is called from @code{uw_frame_state_for} in
2868 @file{unwind-dw2.c}, @file{unwind-dw2-xtensa.c} and
2869 @file{unwind-ia64.c}.  @var{context} is an @code{_Unwind_Context};
2870 @var{fs} is an @code{_Unwind_FrameState}.  Examine @code{context->ra}
2871 for the address of the code being executed and @code{context->cfa} for
2872 the stack pointer value.  If the frame can be decoded, the register
2873 save addresses should be updated in @var{fs} and the macro should
2874 evaluate to @code{_URC_NO_REASON}.  If the frame cannot be decoded,
2875 the macro should evaluate to @code{_URC_END_OF_STACK}.
2877 For proper signal handling in Java this macro is accompanied by
2878 @code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers.
2879 @end defmac
2881 @defmac MD_HANDLE_UNWABI (@var{context}, @var{fs})
2882 This macro allows the target to add operating system specific code to the
2883 call-frame unwinder to handle the IA-64 @code{.unwabi} unwinding directive,
2884 usually used for signal or interrupt frames.
2886 This macro is called from @code{uw_update_context} in libgcc's
2887 @file{unwind-ia64.c}.  @var{context} is an @code{_Unwind_Context};
2888 @var{fs} is an @code{_Unwind_FrameState}.  Examine @code{fs->unwabi}
2889 for the abi and context in the @code{.unwabi} directive.  If the
2890 @code{.unwabi} directive can be handled, the register save addresses should
2891 be updated in @var{fs}.
2892 @end defmac
2894 @defmac TARGET_USES_WEAK_UNWIND_INFO
2895 A C expression that evaluates to true if the target requires unwind
2896 info to be given comdat linkage.  Define it to be @code{1} if comdat
2897 linkage is necessary.  The default is @code{0}.
2898 @end defmac
2900 @node Stack Checking
2901 @subsection Specifying How Stack Checking is Done
2903 GCC will check that stack references are within the boundaries of the
2904 stack, if the option @option{-fstack-check} is specified, in one of
2905 three ways:
2907 @enumerate
2908 @item
2909 If the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC
2910 will assume that you have arranged for full stack checking to be done
2911 at appropriate places in the configuration files.  GCC will not do
2912 other special processing.
2914 @item
2915 If @code{STACK_CHECK_BUILTIN} is zero and the value of the
2916 @code{STACK_CHECK_STATIC_BUILTIN} macro is nonzero, GCC will assume
2917 that you have arranged for static stack checking (checking of the
2918 static stack frame of functions) to be done at appropriate places
2919 in the configuration files.  GCC will only emit code to do dynamic
2920 stack checking (checking on dynamic stack allocations) using the third
2921 approach below.
2923 @item
2924 If neither of the above are true, GCC will generate code to periodically
2925 ``probe'' the stack pointer using the values of the macros defined below.
2926 @end enumerate
2928 If neither STACK_CHECK_BUILTIN nor STACK_CHECK_STATIC_BUILTIN is defined,
2929 GCC will change its allocation strategy for large objects if the option
2930 @option{-fstack-check} is specified: they will always be allocated
2931 dynamically if their size exceeds @code{STACK_CHECK_MAX_VAR_SIZE} bytes.
2933 @defmac STACK_CHECK_BUILTIN
2934 A nonzero value if stack checking is done by the configuration files in a
2935 machine-dependent manner.  You should define this macro if stack checking
2936 is required by the ABI of your machine or if you would like to do stack
2937 checking in some more efficient way than the generic approach.  The default
2938 value of this macro is zero.
2939 @end defmac
2941 @defmac STACK_CHECK_STATIC_BUILTIN
2942 A nonzero value if static stack checking is done by the configuration files
2943 in a machine-dependent manner.  You should define this macro if you would
2944 like to do static stack checking in some more efficient way than the generic
2945 approach.  The default value of this macro is zero.
2946 @end defmac
2948 @defmac STACK_CHECK_PROBE_INTERVAL_EXP
2949 An integer specifying the interval at which GCC must generate stack probe
2950 instructions, defined as 2 raised to this integer.  You will normally
2951 define this macro so that the interval be no larger than the size of
2952 the ``guard pages'' at the end of a stack area.  The default value
2953 of 12 (4096-byte interval) is suitable for most systems.
2954 @end defmac
2956 @defmac STACK_CHECK_MOVING_SP
2957 An integer which is nonzero if GCC should move the stack pointer page by page
2958 when doing probes.  This can be necessary on systems where the stack pointer
2959 contains the bottom address of the memory area accessible to the executing
2960 thread at any point in time.  In this situation an alternate signal stack
2961 is required in order to be able to recover from a stack overflow.  The
2962 default value of this macro is zero.
2963 @end defmac
2965 @defmac STACK_CHECK_PROTECT
2966 The number of bytes of stack needed to recover from a stack overflow, for
2967 languages where such a recovery is supported.  The default value of 4KB/8KB
2968 with the @code{setjmp}/@code{longjmp}-based exception handling mechanism and
2969 8KB/12KB with other exception handling mechanisms should be adequate for most
2970 architectures and operating systems.
2971 @end defmac
2973 The following macros are relevant only if neither STACK_CHECK_BUILTIN
2974 nor STACK_CHECK_STATIC_BUILTIN is defined; you can omit them altogether
2975 in the opposite case.
2977 @defmac STACK_CHECK_MAX_FRAME_SIZE
2978 The maximum size of a stack frame, in bytes.  GCC will generate probe
2979 instructions in non-leaf functions to ensure at least this many bytes of
2980 stack are available.  If a stack frame is larger than this size, stack
2981 checking will not be reliable and GCC will issue a warning.  The
2982 default is chosen so that GCC only generates one instruction on most
2983 systems.  You should normally not change the default value of this macro.
2984 @end defmac
2986 @defmac STACK_CHECK_FIXED_FRAME_SIZE
2987 GCC uses this value to generate the above warning message.  It
2988 represents the amount of fixed frame used by a function, not including
2989 space for any callee-saved registers, temporaries and user variables.
2990 You need only specify an upper bound for this amount and will normally
2991 use the default of four words.
2992 @end defmac
2994 @defmac STACK_CHECK_MAX_VAR_SIZE
2995 The maximum size, in bytes, of an object that GCC will place in the
2996 fixed area of the stack frame when the user specifies
2997 @option{-fstack-check}.
2998 GCC computed the default from the values of the above macros and you will
2999 normally not need to override that default.
3000 @end defmac
3002 @need 2000
3003 @node Frame Registers
3004 @subsection Registers That Address the Stack Frame
3006 @c prevent bad page break with this line
3007 This discusses registers that address the stack frame.
3009 @defmac STACK_POINTER_REGNUM
3010 The register number of the stack pointer register, which must also be a
3011 fixed register according to @code{FIXED_REGISTERS}.  On most machines,
3012 the hardware determines which register this is.
3013 @end defmac
3015 @defmac FRAME_POINTER_REGNUM
3016 The register number of the frame pointer register, which is used to
3017 access automatic variables in the stack frame.  On some machines, the
3018 hardware determines which register this is.  On other machines, you can
3019 choose any register you wish for this purpose.
3020 @end defmac
3022 @defmac HARD_FRAME_POINTER_REGNUM
3023 On some machines the offset between the frame pointer and starting
3024 offset of the automatic variables is not known until after register
3025 allocation has been done (for example, because the saved registers are
3026 between these two locations).  On those machines, define
3027 @code{FRAME_POINTER_REGNUM} the number of a special, fixed register to
3028 be used internally until the offset is known, and define
3029 @code{HARD_FRAME_POINTER_REGNUM} to be the actual hard register number
3030 used for the frame pointer.
3032 You should define this macro only in the very rare circumstances when it
3033 is not possible to calculate the offset between the frame pointer and
3034 the automatic variables until after register allocation has been
3035 completed.  When this macro is defined, you must also indicate in your
3036 definition of @code{ELIMINABLE_REGS} how to eliminate
3037 @code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM}
3038 or @code{STACK_POINTER_REGNUM}.
3040 Do not define this macro if it would be the same as
3041 @code{FRAME_POINTER_REGNUM}.
3042 @end defmac
3044 @defmac ARG_POINTER_REGNUM
3045 The register number of the arg pointer register, which is used to access
3046 the function's argument list.  On some machines, this is the same as the
3047 frame pointer register.  On some machines, the hardware determines which
3048 register this is.  On other machines, you can choose any register you
3049 wish for this purpose.  If this is not the same register as the frame
3050 pointer register, then you must mark it as a fixed register according to
3051 @code{FIXED_REGISTERS}, or arrange to be able to eliminate it
3052 (@pxref{Elimination}).
3053 @end defmac
3055 @defmac HARD_FRAME_POINTER_IS_FRAME_POINTER
3056 Define this to a preprocessor constant that is nonzero if
3057 @code{hard_frame_pointer_rtx} and @code{frame_pointer_rtx} should be
3058 the same.  The default definition is @samp{(HARD_FRAME_POINTER_REGNUM
3059 == FRAME_POINTER_REGNUM)}; you only need to define this macro if that
3060 definition is not suitable for use in preprocessor conditionals.
3061 @end defmac
3063 @defmac HARD_FRAME_POINTER_IS_ARG_POINTER
3064 Define this to a preprocessor constant that is nonzero if
3065 @code{hard_frame_pointer_rtx} and @code{arg_pointer_rtx} should be the
3066 same.  The default definition is @samp{(HARD_FRAME_POINTER_REGNUM ==
3067 ARG_POINTER_REGNUM)}; you only need to define this macro if that
3068 definition is not suitable for use in preprocessor conditionals.
3069 @end defmac
3071 @defmac RETURN_ADDRESS_POINTER_REGNUM
3072 The register number of the return address pointer register, which is used to
3073 access the current function's return address from the stack.  On some
3074 machines, the return address is not at a fixed offset from the frame
3075 pointer or stack pointer or argument pointer.  This register can be defined
3076 to point to the return address on the stack, and then be converted by
3077 @code{ELIMINABLE_REGS} into either the frame pointer or stack pointer.
3079 Do not define this macro unless there is no other way to get the return
3080 address from the stack.
3081 @end defmac
3083 @defmac STATIC_CHAIN_REGNUM
3084 @defmacx STATIC_CHAIN_INCOMING_REGNUM
3085 Register numbers used for passing a function's static chain pointer.  If
3086 register windows are used, the register number as seen by the called
3087 function is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register
3088 number as seen by the calling function is @code{STATIC_CHAIN_REGNUM}.  If
3089 these registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need
3090 not be defined.
3092 The static chain register need not be a fixed register.
3094 If the static chain is passed in memory, these macros should not be
3095 defined; instead, the @code{TARGET_STATIC_CHAIN} hook should be used.
3096 @end defmac
3098 @hook TARGET_STATIC_CHAIN
3100 @defmac DWARF_FRAME_REGISTERS
3101 This macro specifies the maximum number of hard registers that can be
3102 saved in a call frame.  This is used to size data structures used in
3103 DWARF2 exception handling.
3105 Prior to GCC 3.0, this macro was needed in order to establish a stable
3106 exception handling ABI in the face of adding new hard registers for ISA
3107 extensions.  In GCC 3.0 and later, the EH ABI is insulated from changes
3108 in the number of hard registers.  Nevertheless, this macro can still be
3109 used to reduce the runtime memory requirements of the exception handling
3110 routines, which can be substantial if the ISA contains a lot of
3111 registers that are not call-saved.
3113 If this macro is not defined, it defaults to
3114 @code{FIRST_PSEUDO_REGISTER}.
3115 @end defmac
3117 @defmac PRE_GCC3_DWARF_FRAME_REGISTERS
3119 This macro is similar to @code{DWARF_FRAME_REGISTERS}, but is provided
3120 for backward compatibility in pre GCC 3.0 compiled code.
3122 If this macro is not defined, it defaults to
3123 @code{DWARF_FRAME_REGISTERS}.
3124 @end defmac
3126 @defmac DWARF_REG_TO_UNWIND_COLUMN (@var{regno})
3128 Define this macro if the target's representation for dwarf registers
3129 is different than the internal representation for unwind column.
3130 Given a dwarf register, this macro should return the internal unwind
3131 column number to use instead.
3133 See the PowerPC's SPE target for an example.
3134 @end defmac
3136 @defmac DWARF_FRAME_REGNUM (@var{regno})
3138 Define this macro if the target's representation for dwarf registers
3139 used in .eh_frame or .debug_frame is different from that used in other
3140 debug info sections.  Given a GCC hard register number, this macro
3141 should return the .eh_frame register number.  The default is
3142 @code{DBX_REGISTER_NUMBER (@var{regno})}.
3144 @end defmac
3146 @defmac DWARF2_FRAME_REG_OUT (@var{regno}, @var{for_eh})
3148 Define this macro to map register numbers held in the call frame info
3149 that GCC has collected using @code{DWARF_FRAME_REGNUM} to those that
3150 should be output in .debug_frame (@code{@var{for_eh}} is zero) and
3151 .eh_frame (@code{@var{for_eh}} is nonzero).  The default is to
3152 return @code{@var{regno}}.
3154 @end defmac
3156 @defmac REG_VALUE_IN_UNWIND_CONTEXT
3158 Define this macro if the target stores register values as
3159 @code{_Unwind_Word} type in unwind context.  It should be defined if
3160 target register size is larger than the size of @code{void *}.  The
3161 default is to store register values as @code{void *} type.
3163 @end defmac
3165 @defmac ASSUME_EXTENDED_UNWIND_CONTEXT
3167 Define this macro to be 1 if the target always uses extended unwind
3168 context with version, args_size and by_value fields.  If it is undefined,
3169 it will be defined to 1 when @code{REG_VALUE_IN_UNWIND_CONTEXT} is
3170 defined and 0 otherwise.
3172 @end defmac
3174 @node Elimination
3175 @subsection Eliminating Frame Pointer and Arg Pointer
3177 @c prevent bad page break with this line
3178 This is about eliminating the frame pointer and arg pointer.
3180 @hook TARGET_FRAME_POINTER_REQUIRED
3182 @defmac ELIMINABLE_REGS
3183 This macro specifies a table of register pairs used to eliminate
3184 unneeded registers that point into the stack frame.
3186 The definition of this macro is a list of structure initializations, each
3187 of which specifies an original and replacement register.
3189 On some machines, the position of the argument pointer is not known until
3190 the compilation is completed.  In such a case, a separate hard register
3191 must be used for the argument pointer.  This register can be eliminated by
3192 replacing it with either the frame pointer or the argument pointer,
3193 depending on whether or not the frame pointer has been eliminated.
3195 In this case, you might specify:
3196 @smallexample
3197 #define ELIMINABLE_REGS  \
3198 @{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \
3199  @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \
3200  @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@}
3201 @end smallexample
3203 Note that the elimination of the argument pointer with the stack pointer is
3204 specified first since that is the preferred elimination.
3205 @end defmac
3207 @hook TARGET_CAN_ELIMINATE
3209 @defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var})
3210 This macro returns the initial difference between the specified pair
3211 of registers.  The value would be computed from information
3212 such as the result of @code{get_frame_size ()} and the tables of
3213 registers @code{df_regs_ever_live_p} and @code{call_used_regs}.
3214 @end defmac
3216 @hook TARGET_COMPUTE_FRAME_LAYOUT
3218 @node Stack Arguments
3219 @subsection Passing Function Arguments on the Stack
3220 @cindex arguments on stack
3221 @cindex stack arguments
3223 The macros in this section control how arguments are passed
3224 on the stack.  See the following section for other macros that
3225 control passing certain arguments in registers.
3227 @hook TARGET_PROMOTE_PROTOTYPES
3229 @defmac PUSH_ARGS
3230 A C expression.  If nonzero, push insns will be used to pass
3231 outgoing arguments.
3232 If the target machine does not have a push instruction, set it to zero.
3233 That directs GCC to use an alternate strategy: to
3234 allocate the entire argument block and then store the arguments into
3235 it.  When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too.
3236 @end defmac
3238 @defmac PUSH_ARGS_REVERSED
3239 A C expression.  If nonzero, function arguments will be evaluated from
3240 last to first, rather than from first to last.  If this macro is not
3241 defined, it defaults to @code{PUSH_ARGS} on targets where the stack
3242 and args grow in opposite directions, and 0 otherwise.
3243 @end defmac
3245 @defmac PUSH_ROUNDING (@var{npushed})
3246 A C expression that is the number of bytes actually pushed onto the
3247 stack when an instruction attempts to push @var{npushed} bytes.
3249 On some machines, the definition
3251 @smallexample
3252 #define PUSH_ROUNDING(BYTES) (BYTES)
3253 @end smallexample
3255 @noindent
3256 will suffice.  But on other machines, instructions that appear
3257 to push one byte actually push two bytes in an attempt to maintain
3258 alignment.  Then the definition should be
3260 @smallexample
3261 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
3262 @end smallexample
3264 If the value of this macro has a type, it should be an unsigned type.
3265 @end defmac
3267 @findex outgoing_args_size
3268 @findex crtl->outgoing_args_size
3269 @defmac ACCUMULATE_OUTGOING_ARGS
3270 A C expression.  If nonzero, the maximum amount of space required for outgoing arguments
3271 will be computed and placed into
3272 @code{crtl->outgoing_args_size}.  No space will be pushed
3273 onto the stack for each call; instead, the function prologue should
3274 increase the stack frame size by this amount.
3276 Setting both @code{PUSH_ARGS} and @code{ACCUMULATE_OUTGOING_ARGS}
3277 is not proper.
3278 @end defmac
3280 @defmac REG_PARM_STACK_SPACE (@var{fndecl})
3281 Define this macro if functions should assume that stack space has been
3282 allocated for arguments even when their values are passed in
3283 registers.
3285 The value of this macro is the size, in bytes, of the area reserved for
3286 arguments passed in registers for the function represented by @var{fndecl},
3287 which can be zero if GCC is calling a library function.
3288 The argument @var{fndecl} can be the FUNCTION_DECL, or the type itself
3289 of the function.
3291 This space can be allocated by the caller, or be a part of the
3292 machine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE} says
3293 which.
3294 @end defmac
3295 @c above is overfull.  not sure what to do.  --mew 5feb93  did
3296 @c something, not sure if it looks good.  --mew 10feb93
3298 @defmac INCOMING_REG_PARM_STACK_SPACE (@var{fndecl})
3299 Like @code{REG_PARM_STACK_SPACE}, but for incoming register arguments.
3300 Define this macro if space guaranteed when compiling a function body
3301 is different to space required when making a call, a situation that
3302 can arise with K&R style function definitions.
3303 @end defmac
3305 @defmac OUTGOING_REG_PARM_STACK_SPACE (@var{fntype})
3306 Define this to a nonzero value if it is the responsibility of the
3307 caller to allocate the area reserved for arguments passed in registers
3308 when calling a function of @var{fntype}.  @var{fntype} may be NULL
3309 if the function called is a library function.
3311 If @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls
3312 whether the space for these arguments counts in the value of
3313 @code{crtl->outgoing_args_size}.
3314 @end defmac
3316 @defmac STACK_PARMS_IN_REG_PARM_AREA
3317 Define this macro if @code{REG_PARM_STACK_SPACE} is defined, but the
3318 stack parameters don't skip the area specified by it.
3319 @c i changed this, makes more sens and it should have taken care of the
3320 @c overfull.. not as specific, tho.  --mew 5feb93
3322 Normally, when a parameter is not passed in registers, it is placed on the
3323 stack beyond the @code{REG_PARM_STACK_SPACE} area.  Defining this macro
3324 suppresses this behavior and causes the parameter to be passed on the
3325 stack in its natural location.
3326 @end defmac
3328 @hook TARGET_RETURN_POPS_ARGS
3330 @defmac CALL_POPS_ARGS (@var{cum})
3331 A C expression that should indicate the number of bytes a call sequence
3332 pops off the stack.  It is added to the value of @code{RETURN_POPS_ARGS}
3333 when compiling a function call.
3335 @var{cum} is the variable in which all arguments to the called function
3336 have been accumulated.
3338 On certain architectures, such as the SH5, a call trampoline is used
3339 that pops certain registers off the stack, depending on the arguments
3340 that have been passed to the function.  Since this is a property of the
3341 call site, not of the called function, @code{RETURN_POPS_ARGS} is not
3342 appropriate.
3343 @end defmac
3345 @node Register Arguments
3346 @subsection Passing Arguments in Registers
3347 @cindex arguments in registers
3348 @cindex registers arguments
3350 This section describes the macros which let you control how various
3351 types of arguments are passed in registers or how they are arranged in
3352 the stack.
3354 @hook TARGET_FUNCTION_ARG
3356 @hook TARGET_MUST_PASS_IN_STACK
3358 @hook TARGET_FUNCTION_INCOMING_ARG
3360 @hook TARGET_USE_PSEUDO_PIC_REG
3362 @hook TARGET_INIT_PIC_REG
3364 @hook TARGET_ARG_PARTIAL_BYTES
3366 @hook TARGET_PASS_BY_REFERENCE
3368 @hook TARGET_CALLEE_COPIES
3370 @defmac CUMULATIVE_ARGS
3371 A C type for declaring a variable that is used as the first argument
3372 of @code{TARGET_FUNCTION_ARG} and other related values.  For some
3373 target machines, the type @code{int} suffices and can hold the number
3374 of bytes of argument so far.
3376 There is no need to record in @code{CUMULATIVE_ARGS} anything about the
3377 arguments that have been passed on the stack.  The compiler has other
3378 variables to keep track of that.  For target machines on which all
3379 arguments are passed on the stack, there is no need to store anything in
3380 @code{CUMULATIVE_ARGS}; however, the data structure must exist and
3381 should not be empty, so use @code{int}.
3382 @end defmac
3384 @defmac OVERRIDE_ABI_FORMAT (@var{fndecl})
3385 If defined, this macro is called before generating any code for a
3386 function, but after the @var{cfun} descriptor for the function has been
3387 created.  The back end may use this macro to update @var{cfun} to
3388 reflect an ABI other than that which would normally be used by default.
3389 If the compiler is generating code for a compiler-generated function,
3390 @var{fndecl} may be @code{NULL}.
3391 @end defmac
3393 @defmac INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype}, @var{libname}, @var{fndecl}, @var{n_named_args})
3394 A C statement (sans semicolon) for initializing the variable
3395 @var{cum} for the state at the beginning of the argument list.  The
3396 variable has type @code{CUMULATIVE_ARGS}.  The value of @var{fntype}
3397 is the tree node for the data type of the function which will receive
3398 the args, or 0 if the args are to a compiler support library function.
3399 For direct calls that are not libcalls, @var{fndecl} contain the
3400 declaration node of the function.  @var{fndecl} is also set when
3401 @code{INIT_CUMULATIVE_ARGS} is used to find arguments for the function
3402 being compiled.  @var{n_named_args} is set to the number of named
3403 arguments, including a structure return address if it is passed as a
3404 parameter, when making a call.  When processing incoming arguments,
3405 @var{n_named_args} is set to @minus{}1.
3407 When processing a call to a compiler support library function,
3408 @var{libname} identifies which one.  It is a @code{symbol_ref} rtx which
3409 contains the name of the function, as a string.  @var{libname} is 0 when
3410 an ordinary C function call is being processed.  Thus, each time this
3411 macro is called, either @var{libname} or @var{fntype} is nonzero, but
3412 never both of them at once.
3413 @end defmac
3415 @defmac INIT_CUMULATIVE_LIBCALL_ARGS (@var{cum}, @var{mode}, @var{libname})
3416 Like @code{INIT_CUMULATIVE_ARGS} but only used for outgoing libcalls,
3417 it gets a @code{MODE} argument instead of @var{fntype}, that would be
3418 @code{NULL}.  @var{indirect} would always be zero, too.  If this macro
3419 is not defined, @code{INIT_CUMULATIVE_ARGS (cum, NULL_RTX, libname,
3420 0)} is used instead.
3421 @end defmac
3423 @defmac INIT_CUMULATIVE_INCOMING_ARGS (@var{cum}, @var{fntype}, @var{libname})
3424 Like @code{INIT_CUMULATIVE_ARGS} but overrides it for the purposes of
3425 finding the arguments for the function being compiled.  If this macro is
3426 undefined, @code{INIT_CUMULATIVE_ARGS} is used instead.
3428 The value passed for @var{libname} is always 0, since library routines
3429 with special calling conventions are never compiled with GCC@.  The
3430 argument @var{libname} exists for symmetry with
3431 @code{INIT_CUMULATIVE_ARGS}.
3432 @c could use "this macro" in place of @code{INIT_CUMULATIVE_ARGS}, maybe.
3433 @c --mew 5feb93   i switched the order of the sentences.  --mew 10feb93
3434 @end defmac
3436 @hook TARGET_FUNCTION_ARG_ADVANCE
3438 @defmac FUNCTION_ARG_OFFSET (@var{mode}, @var{type})
3439 If defined, a C expression that is the number of bytes to add to the
3440 offset of the argument passed in memory.  This is needed for the SPU,
3441 which passes @code{char} and @code{short} arguments in the preferred
3442 slot that is in the middle of the quad word instead of starting at the
3443 top.
3444 @end defmac
3446 @defmac FUNCTION_ARG_PADDING (@var{mode}, @var{type})
3447 If defined, a C expression which determines whether, and in which direction,
3448 to pad out an argument with extra space.  The value should be of type
3449 @code{enum direction}: either @code{upward} to pad above the argument,
3450 @code{downward} to pad below, or @code{none} to inhibit padding.
3452 The @emph{amount} of padding is not controlled by this macro, but by the
3453 target hook @code{TARGET_FUNCTION_ARG_ROUND_BOUNDARY}.  It is
3454 always just enough to reach the next multiple of that boundary. 
3456 This macro has a default definition which is right for most systems.
3457 For little-endian machines, the default is to pad upward.  For
3458 big-endian machines, the default is to pad downward for an argument of
3459 constant size shorter than an @code{int}, and upward otherwise.
3460 @end defmac
3462 @defmac PAD_VARARGS_DOWN
3463 If defined, a C expression which determines whether the default
3464 implementation of va_arg will attempt to pad down before reading the
3465 next argument, if that argument is smaller than its aligned space as
3466 controlled by @code{PARM_BOUNDARY}.  If this macro is not defined, all such
3467 arguments are padded down if @code{BYTES_BIG_ENDIAN} is true.
3468 @end defmac
3470 @defmac BLOCK_REG_PADDING (@var{mode}, @var{type}, @var{first})
3471 Specify padding for the last element of a block move between registers and
3472 memory.  @var{first} is nonzero if this is the only element.  Defining this
3473 macro allows better control of register function parameters on big-endian
3474 machines, without using @code{PARALLEL} rtl.  In particular,
3475 @code{MUST_PASS_IN_STACK} need not test padding and mode of types in
3476 registers, as there is no longer a "wrong" part of a register;  For example,
3477 a three byte aggregate may be passed in the high part of a register if so
3478 required.
3479 @end defmac
3481 @hook TARGET_FUNCTION_ARG_BOUNDARY
3483 @hook TARGET_FUNCTION_ARG_ROUND_BOUNDARY
3485 @defmac FUNCTION_ARG_REGNO_P (@var{regno})
3486 A C expression that is nonzero if @var{regno} is the number of a hard
3487 register in which function arguments are sometimes passed.  This does
3488 @emph{not} include implicit arguments such as the static chain and
3489 the structure-value address.  On many machines, no registers can be
3490 used for this purpose since all function arguments are pushed on the
3491 stack.
3492 @end defmac
3494 @hook TARGET_SPLIT_COMPLEX_ARG
3496 @hook TARGET_BUILD_BUILTIN_VA_LIST
3498 @hook TARGET_ENUM_VA_LIST_P
3500 @hook TARGET_FN_ABI_VA_LIST
3502 @hook TARGET_CANONICAL_VA_LIST_TYPE
3504 @hook TARGET_GIMPLIFY_VA_ARG_EXPR
3506 @hook TARGET_VALID_POINTER_MODE
3508 @hook TARGET_REF_MAY_ALIAS_ERRNO
3510 @hook TARGET_SCALAR_MODE_SUPPORTED_P
3512 @hook TARGET_VECTOR_MODE_SUPPORTED_P
3514 @hook TARGET_ARRAY_MODE_SUPPORTED_P
3516 @hook TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P
3518 @hook TARGET_FLOATN_MODE
3520 @hook TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P
3522 @node Scalar Return
3523 @subsection How Scalar Function Values Are Returned
3524 @cindex return values in registers
3525 @cindex values, returned by functions
3526 @cindex scalars, returned as values
3528 This section discusses the macros that control returning scalars as
3529 values---values that can fit in registers.
3531 @hook TARGET_FUNCTION_VALUE
3533 @defmac FUNCTION_VALUE (@var{valtype}, @var{func})
3534 This macro has been deprecated.  Use @code{TARGET_FUNCTION_VALUE} for
3535 a new target instead.
3536 @end defmac
3538 @defmac LIBCALL_VALUE (@var{mode})
3539 A C expression to create an RTX representing the place where a library
3540 function returns a value of mode @var{mode}.
3542 Note that ``library function'' in this context means a compiler
3543 support routine, used to perform arithmetic, whose name is known
3544 specially by the compiler and was not mentioned in the C code being
3545 compiled.
3546 @end defmac
3548 @hook TARGET_LIBCALL_VALUE
3550 @defmac FUNCTION_VALUE_REGNO_P (@var{regno})
3551 A C expression that is nonzero if @var{regno} is the number of a hard
3552 register in which the values of called function may come back.
3554 A register whose use for returning values is limited to serving as the
3555 second of a pair (for a value of type @code{double}, say) need not be
3556 recognized by this macro.  So for most machines, this definition
3557 suffices:
3559 @smallexample
3560 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
3561 @end smallexample
3563 If the machine has register windows, so that the caller and the called
3564 function use different registers for the return value, this macro
3565 should recognize only the caller's register numbers.
3567 This macro has been deprecated.  Use @code{TARGET_FUNCTION_VALUE_REGNO_P}
3568 for a new target instead.
3569 @end defmac
3571 @hook TARGET_FUNCTION_VALUE_REGNO_P
3573 @defmac APPLY_RESULT_SIZE
3574 Define this macro if @samp{untyped_call} and @samp{untyped_return}
3575 need more space than is implied by @code{FUNCTION_VALUE_REGNO_P} for
3576 saving and restoring an arbitrary return value.
3577 @end defmac
3579 @hook TARGET_OMIT_STRUCT_RETURN_REG
3581 @hook TARGET_RETURN_IN_MSB
3583 @node Aggregate Return
3584 @subsection How Large Values Are Returned
3585 @cindex aggregates as return values
3586 @cindex large return values
3587 @cindex returning aggregate values
3588 @cindex structure value address
3590 When a function value's mode is @code{BLKmode} (and in some other
3591 cases), the value is not returned according to
3592 @code{TARGET_FUNCTION_VALUE} (@pxref{Scalar Return}).  Instead, the
3593 caller passes the address of a block of memory in which the value
3594 should be stored.  This address is called the @dfn{structure value
3595 address}.
3597 This section describes how to control returning structure values in
3598 memory.
3600 @hook TARGET_RETURN_IN_MEMORY
3602 @defmac DEFAULT_PCC_STRUCT_RETURN
3603 Define this macro to be 1 if all structure and union return values must be
3604 in memory.  Since this results in slower code, this should be defined
3605 only if needed for compatibility with other compilers or with an ABI@.
3606 If you define this macro to be 0, then the conventions used for structure
3607 and union return values are decided by the @code{TARGET_RETURN_IN_MEMORY}
3608 target hook.
3610 If not defined, this defaults to the value 1.
3611 @end defmac
3613 @hook TARGET_STRUCT_VALUE_RTX
3615 @defmac PCC_STATIC_STRUCT_RETURN
3616 Define this macro if the usual system convention on the target machine
3617 for returning structures and unions is for the called function to return
3618 the address of a static variable containing the value.
3620 Do not define this if the usual system convention is for the caller to
3621 pass an address to the subroutine.
3623 This macro has effect in @option{-fpcc-struct-return} mode, but it does
3624 nothing when you use @option{-freg-struct-return} mode.
3625 @end defmac
3627 @hook TARGET_GET_RAW_RESULT_MODE
3629 @hook TARGET_GET_RAW_ARG_MODE
3631 @node Caller Saves
3632 @subsection Caller-Saves Register Allocation
3634 If you enable it, GCC can save registers around function calls.  This
3635 makes it possible to use call-clobbered registers to hold variables that
3636 must live across calls.
3638 @defmac HARD_REGNO_CALLER_SAVE_MODE (@var{regno}, @var{nregs})
3639 A C expression specifying which mode is required for saving @var{nregs}
3640 of a pseudo-register in call-clobbered hard register @var{regno}.  If
3641 @var{regno} is unsuitable for caller save, @code{VOIDmode} should be
3642 returned.  For most machines this macro need not be defined since GCC
3643 will select the smallest suitable mode.
3644 @end defmac
3646 @node Function Entry
3647 @subsection Function Entry and Exit
3648 @cindex function entry and exit
3649 @cindex prologue
3650 @cindex epilogue
3652 This section describes the macros that output function entry
3653 (@dfn{prologue}) and exit (@dfn{epilogue}) code.
3655 @hook TARGET_ASM_FUNCTION_PROLOGUE
3657 @hook TARGET_ASM_FUNCTION_END_PROLOGUE
3659 @hook TARGET_ASM_FUNCTION_BEGIN_EPILOGUE
3661 @hook TARGET_ASM_FUNCTION_EPILOGUE
3663 @itemize @bullet
3664 @item
3665 @findex pretend_args_size
3666 @findex crtl->args.pretend_args_size
3667 A region of @code{crtl->args.pretend_args_size} bytes of
3668 uninitialized space just underneath the first argument arriving on the
3669 stack.  (This may not be at the very start of the allocated stack region
3670 if the calling sequence has pushed anything else since pushing the stack
3671 arguments.  But usually, on such machines, nothing else has been pushed
3672 yet, because the function prologue itself does all the pushing.)  This
3673 region is used on machines where an argument may be passed partly in
3674 registers and partly in memory, and, in some cases to support the
3675 features in @code{<stdarg.h>}.
3677 @item
3678 An area of memory used to save certain registers used by the function.
3679 The size of this area, which may also include space for such things as
3680 the return address and pointers to previous stack frames, is
3681 machine-specific and usually depends on which registers have been used
3682 in the function.  Machines with register windows often do not require
3683 a save area.
3685 @item
3686 A region of at least @var{size} bytes, possibly rounded up to an allocation
3687 boundary, to contain the local variables of the function.  On some machines,
3688 this region and the save area may occur in the opposite order, with the
3689 save area closer to the top of the stack.
3691 @item
3692 @cindex @code{ACCUMULATE_OUTGOING_ARGS} and stack frames
3693 Optionally, when @code{ACCUMULATE_OUTGOING_ARGS} is defined, a region of
3694 @code{crtl->outgoing_args_size} bytes to be used for outgoing
3695 argument lists of the function.  @xref{Stack Arguments}.
3696 @end itemize
3698 @defmac EXIT_IGNORE_STACK
3699 Define this macro as a C expression that is nonzero if the return
3700 instruction or the function epilogue ignores the value of the stack
3701 pointer; in other words, if it is safe to delete an instruction to
3702 adjust the stack pointer before a return from the function.  The
3703 default is 0.
3705 Note that this macro's value is relevant only for functions for which
3706 frame pointers are maintained.  It is never safe to delete a final
3707 stack adjustment in a function that has no frame pointer, and the
3708 compiler knows this regardless of @code{EXIT_IGNORE_STACK}.
3709 @end defmac
3711 @defmac EPILOGUE_USES (@var{regno})
3712 Define this macro as a C expression that is nonzero for registers that are
3713 used by the epilogue or the @samp{return} pattern.  The stack and frame
3714 pointer registers are already assumed to be used as needed.
3715 @end defmac
3717 @defmac EH_USES (@var{regno})
3718 Define this macro as a C expression that is nonzero for registers that are
3719 used by the exception handling mechanism, and so should be considered live
3720 on entry to an exception edge.
3721 @end defmac
3723 @hook TARGET_ASM_OUTPUT_MI_THUNK
3725 @hook TARGET_ASM_CAN_OUTPUT_MI_THUNK
3727 @node Profiling
3728 @subsection Generating Code for Profiling
3729 @cindex profiling, code generation
3731 These macros will help you generate code for profiling.
3733 @defmac FUNCTION_PROFILER (@var{file}, @var{labelno})
3734 A C statement or compound statement to output to @var{file} some
3735 assembler code to call the profiling subroutine @code{mcount}.
3737 @findex mcount
3738 The details of how @code{mcount} expects to be called are determined by
3739 your operating system environment, not by GCC@.  To figure them out,
3740 compile a small program for profiling using the system's installed C
3741 compiler and look at the assembler code that results.
3743 Older implementations of @code{mcount} expect the address of a counter
3744 variable to be loaded into some register.  The name of this variable is
3745 @samp{LP} followed by the number @var{labelno}, so you would generate
3746 the name using @samp{LP%d} in a @code{fprintf}.
3747 @end defmac
3749 @defmac PROFILE_HOOK
3750 A C statement or compound statement to output to @var{file} some assembly
3751 code to call the profiling subroutine @code{mcount} even the target does
3752 not support profiling.
3753 @end defmac
3755 @defmac NO_PROFILE_COUNTERS
3756 Define this macro to be an expression with a nonzero value if the
3757 @code{mcount} subroutine on your system does not need a counter variable
3758 allocated for each function.  This is true for almost all modern
3759 implementations.  If you define this macro, you must not use the
3760 @var{labelno} argument to @code{FUNCTION_PROFILER}.
3761 @end defmac
3763 @defmac PROFILE_BEFORE_PROLOGUE
3764 Define this macro if the code for function profiling should come before
3765 the function prologue.  Normally, the profiling code comes after.
3766 @end defmac
3768 @hook TARGET_KEEP_LEAF_WHEN_PROFILED
3770 @node Tail Calls
3771 @subsection Permitting tail calls
3772 @cindex tail calls
3774 @hook TARGET_FUNCTION_OK_FOR_SIBCALL
3776 @hook TARGET_EXTRA_LIVE_ON_ENTRY
3778 @hook TARGET_SET_UP_BY_PROLOGUE
3780 @hook TARGET_WARN_FUNC_RETURN
3782 @node Shrink-wrapping separate components
3783 @subsection Shrink-wrapping separate components
3784 @cindex shrink-wrapping separate components
3786 The prologue may perform a variety of target dependent tasks such as
3787 saving callee-saved registers, saving the return address, aligning the
3788 stack, creating a stack frame, initializing the PIC register, setting
3789 up the static chain, etc.
3791 On some targets some of these tasks may be independent of others and
3792 thus may be shrink-wrapped separately.  These independent tasks are
3793 referred to as components and are handled generically by the target
3794 independent parts of GCC.
3796 Using the following hooks those prologue or epilogue components can be
3797 shrink-wrapped separately, so that the initialization (and possibly
3798 teardown) those components do is not done as frequently on execution
3799 paths where this would unnecessary.
3801 What exactly those components are is up to the target code; the generic
3802 code treats them abstractly, as a bit in an @code{sbitmap}.  These
3803 @code{sbitmap}s are allocated by the @code{shrink_wrap.get_separate_components}
3804 and @code{shrink_wrap.components_for_bb} hooks, and deallocated by the
3805 generic code.
3807 @hook TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS
3809 @hook TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB
3811 @hook TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS
3813 @hook TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS
3815 @hook TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS
3817 @hook TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS
3819 @node Stack Smashing Protection
3820 @subsection Stack smashing protection
3821 @cindex stack smashing protection
3823 @hook TARGET_STACK_PROTECT_GUARD
3825 @hook TARGET_STACK_PROTECT_FAIL
3827 @hook TARGET_STACK_PROTECT_RUNTIME_ENABLED_P
3829 @hook TARGET_SUPPORTS_SPLIT_STACK
3831 @node Miscellaneous Register Hooks
3832 @subsection Miscellaneous register hooks
3833 @cindex miscellaneous register hooks
3835 @hook TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS
3837 @node Varargs
3838 @section Implementing the Varargs Macros
3839 @cindex varargs implementation
3841 GCC comes with an implementation of @code{<varargs.h>} and
3842 @code{<stdarg.h>} that work without change on machines that pass arguments
3843 on the stack.  Other machines require their own implementations of
3844 varargs, and the two machine independent header files must have
3845 conditionals to include it.
3847 ISO @code{<stdarg.h>} differs from traditional @code{<varargs.h>} mainly in
3848 the calling convention for @code{va_start}.  The traditional
3849 implementation takes just one argument, which is the variable in which
3850 to store the argument pointer.  The ISO implementation of
3851 @code{va_start} takes an additional second argument.  The user is
3852 supposed to write the last named argument of the function here.
3854 However, @code{va_start} should not use this argument.  The way to find
3855 the end of the named arguments is with the built-in functions described
3856 below.
3858 @defmac __builtin_saveregs ()
3859 Use this built-in function to save the argument registers in memory so
3860 that the varargs mechanism can access them.  Both ISO and traditional
3861 versions of @code{va_start} must use @code{__builtin_saveregs}, unless
3862 you use @code{TARGET_SETUP_INCOMING_VARARGS} (see below) instead.
3864 On some machines, @code{__builtin_saveregs} is open-coded under the
3865 control of the target hook @code{TARGET_EXPAND_BUILTIN_SAVEREGS}.  On
3866 other machines, it calls a routine written in assembler language,
3867 found in @file{libgcc2.c}.
3869 Code generated for the call to @code{__builtin_saveregs} appears at the
3870 beginning of the function, as opposed to where the call to
3871 @code{__builtin_saveregs} is written, regardless of what the code is.
3872 This is because the registers must be saved before the function starts
3873 to use them for its own purposes.
3874 @c i rewrote the first sentence above to fix an overfull hbox. --mew
3875 @c 10feb93
3876 @end defmac
3878 @defmac __builtin_next_arg (@var{lastarg})
3879 This builtin returns the address of the first anonymous stack
3880 argument, as type @code{void *}.  If @code{ARGS_GROW_DOWNWARD}, it
3881 returns the address of the location above the first anonymous stack
3882 argument.  Use it in @code{va_start} to initialize the pointer for
3883 fetching arguments from the stack.  Also use it in @code{va_start} to
3884 verify that the second parameter @var{lastarg} is the last named argument
3885 of the current function.
3886 @end defmac
3888 @defmac __builtin_classify_type (@var{object})
3889 Since each machine has its own conventions for which data types are
3890 passed in which kind of register, your implementation of @code{va_arg}
3891 has to embody these conventions.  The easiest way to categorize the
3892 specified data type is to use @code{__builtin_classify_type} together
3893 with @code{sizeof} and @code{__alignof__}.
3895 @code{__builtin_classify_type} ignores the value of @var{object},
3896 considering only its data type.  It returns an integer describing what
3897 kind of type that is---integer, floating, pointer, structure, and so on.
3899 The file @file{typeclass.h} defines an enumeration that you can use to
3900 interpret the values of @code{__builtin_classify_type}.
3901 @end defmac
3903 These machine description macros help implement varargs:
3905 @hook TARGET_EXPAND_BUILTIN_SAVEREGS
3907 @hook TARGET_SETUP_INCOMING_VARARGS
3909 @hook TARGET_STRICT_ARGUMENT_NAMING
3911 @hook TARGET_CALL_ARGS
3913 @hook TARGET_END_CALL_ARGS
3915 @hook TARGET_PRETEND_OUTGOING_VARARGS_NAMED
3917 @hook TARGET_LOAD_BOUNDS_FOR_ARG
3919 @hook TARGET_STORE_BOUNDS_FOR_ARG
3921 @hook TARGET_LOAD_RETURNED_BOUNDS
3923 @hook TARGET_STORE_RETURNED_BOUNDS
3925 @hook TARGET_CHKP_FUNCTION_VALUE_BOUNDS
3927 @hook TARGET_SETUP_INCOMING_VARARG_BOUNDS
3929 @node Trampolines
3930 @section Trampolines for Nested Functions
3931 @cindex trampolines for nested functions
3932 @cindex nested functions, trampolines for
3934 A @dfn{trampoline} is a small piece of code that is created at run time
3935 when the address of a nested function is taken.  It normally resides on
3936 the stack, in the stack frame of the containing function.  These macros
3937 tell GCC how to generate code to allocate and initialize a
3938 trampoline.
3940 The instructions in the trampoline must do two things: load a constant
3941 address into the static chain register, and jump to the real address of
3942 the nested function.  On CISC machines such as the m68k, this requires
3943 two instructions, a move immediate and a jump.  Then the two addresses
3944 exist in the trampoline as word-long immediate operands.  On RISC
3945 machines, it is often necessary to load each address into a register in
3946 two parts.  Then pieces of each address form separate immediate
3947 operands.
3949 The code generated to initialize the trampoline must store the variable
3950 parts---the static chain value and the function address---into the
3951 immediate operands of the instructions.  On a CISC machine, this is
3952 simply a matter of copying each address to a memory reference at the
3953 proper offset from the start of the trampoline.  On a RISC machine, it
3954 may be necessary to take out pieces of the address and store them
3955 separately.
3957 @hook TARGET_ASM_TRAMPOLINE_TEMPLATE
3959 @defmac TRAMPOLINE_SECTION
3960 Return the section into which the trampoline template is to be placed
3961 (@pxref{Sections}).  The default value is @code{readonly_data_section}.
3962 @end defmac
3964 @defmac TRAMPOLINE_SIZE
3965 A C expression for the size in bytes of the trampoline, as an integer.
3966 @end defmac
3968 @defmac TRAMPOLINE_ALIGNMENT
3969 Alignment required for trampolines, in bits.
3971 If you don't define this macro, the value of @code{FUNCTION_ALIGNMENT}
3972 is used for aligning trampolines.
3973 @end defmac
3975 @hook TARGET_TRAMPOLINE_INIT
3977 @hook TARGET_TRAMPOLINE_ADJUST_ADDRESS
3979 @hook TARGET_CUSTOM_FUNCTION_DESCRIPTORS
3981 Implementing trampolines is difficult on many machines because they have
3982 separate instruction and data caches.  Writing into a stack location
3983 fails to clear the memory in the instruction cache, so when the program
3984 jumps to that location, it executes the old contents.
3986 Here are two possible solutions.  One is to clear the relevant parts of
3987 the instruction cache whenever a trampoline is set up.  The other is to
3988 make all trampolines identical, by having them jump to a standard
3989 subroutine.  The former technique makes trampoline execution faster; the
3990 latter makes initialization faster.
3992 To clear the instruction cache when a trampoline is initialized, define
3993 the following macro.
3995 @defmac CLEAR_INSN_CACHE (@var{beg}, @var{end})
3996 If defined, expands to a C expression clearing the @emph{instruction
3997 cache} in the specified interval.  The definition of this macro would
3998 typically be a series of @code{asm} statements.  Both @var{beg} and
3999 @var{end} are both pointer expressions.
4000 @end defmac
4002 To use a standard subroutine, define the following macro.  In addition,
4003 you must make sure that the instructions in a trampoline fill an entire
4004 cache line with identical instructions, or else ensure that the
4005 beginning of the trampoline code is always aligned at the same point in
4006 its cache line.  Look in @file{m68k.h} as a guide.
4008 @defmac TRANSFER_FROM_TRAMPOLINE
4009 Define this macro if trampolines need a special subroutine to do their
4010 work.  The macro should expand to a series of @code{asm} statements
4011 which will be compiled with GCC@.  They go in a library function named
4012 @code{__transfer_from_trampoline}.
4014 If you need to avoid executing the ordinary prologue code of a compiled
4015 C function when you jump to the subroutine, you can do so by placing a
4016 special label of your own in the assembler code.  Use one @code{asm}
4017 statement to generate an assembler label, and another to make the label
4018 global.  Then trampolines can use that label to jump directly to your
4019 special assembler code.
4020 @end defmac
4022 @node Library Calls
4023 @section Implicit Calls to Library Routines
4024 @cindex library subroutine names
4025 @cindex @file{libgcc.a}
4027 @c prevent bad page break with this line
4028 Here is an explanation of implicit calls to library routines.
4030 @defmac DECLARE_LIBRARY_RENAMES
4031 This macro, if defined, should expand to a piece of C code that will get
4032 expanded when compiling functions for libgcc.a.  It can be used to
4033 provide alternate names for GCC's internal library functions if there
4034 are ABI-mandated names that the compiler should provide.
4035 @end defmac
4037 @findex set_optab_libfunc
4038 @findex init_one_libfunc
4039 @hook TARGET_INIT_LIBFUNCS
4041 @hook TARGET_LIBFUNC_GNU_PREFIX
4043 @defmac FLOAT_LIB_COMPARE_RETURNS_BOOL (@var{mode}, @var{comparison})
4044 This macro should return @code{true} if the library routine that
4045 implements the floating point comparison operator @var{comparison} in
4046 mode @var{mode} will return a boolean, and @var{false} if it will
4047 return a tristate.
4049 GCC's own floating point libraries return tristates from the
4050 comparison operators, so the default returns false always.  Most ports
4051 don't need to define this macro.
4052 @end defmac
4054 @defmac TARGET_LIB_INT_CMP_BIASED
4055 This macro should evaluate to @code{true} if the integer comparison
4056 functions (like @code{__cmpdi2}) return 0 to indicate that the first
4057 operand is smaller than the second, 1 to indicate that they are equal,
4058 and 2 to indicate that the first operand is greater than the second.
4059 If this macro evaluates to @code{false} the comparison functions return
4060 @minus{}1, 0, and 1 instead of 0, 1, and 2.  If the target uses the routines
4061 in @file{libgcc.a}, you do not need to define this macro.
4062 @end defmac
4064 @defmac TARGET_HAS_NO_HW_DIVIDE
4065 This macro should be defined if the target has no hardware divide
4066 instructions.  If this macro is defined, GCC will use an algorithm which
4067 make use of simple logical and arithmetic operations for 64-bit
4068 division.  If the macro is not defined, GCC will use an algorithm which
4069 make use of a 64-bit by 32-bit divide primitive.
4070 @end defmac
4072 @cindex @code{EDOM}, implicit usage
4073 @findex matherr
4074 @defmac TARGET_EDOM
4075 The value of @code{EDOM} on the target machine, as a C integer constant
4076 expression.  If you don't define this macro, GCC does not attempt to
4077 deposit the value of @code{EDOM} into @code{errno} directly.  Look in
4078 @file{/usr/include/errno.h} to find the value of @code{EDOM} on your
4079 system.
4081 If you do not define @code{TARGET_EDOM}, then compiled code reports
4082 domain errors by calling the library function and letting it report the
4083 error.  If mathematical functions on your system use @code{matherr} when
4084 there is an error, then you should leave @code{TARGET_EDOM} undefined so
4085 that @code{matherr} is used normally.
4086 @end defmac
4088 @cindex @code{errno}, implicit usage
4089 @defmac GEN_ERRNO_RTX
4090 Define this macro as a C expression to create an rtl expression that
4091 refers to the global ``variable'' @code{errno}.  (On certain systems,
4092 @code{errno} may not actually be a variable.)  If you don't define this
4093 macro, a reasonable default is used.
4094 @end defmac
4096 @hook TARGET_LIBC_HAS_FUNCTION
4098 @defmac NEXT_OBJC_RUNTIME
4099 Set this macro to 1 to use the "NeXT" Objective-C message sending conventions
4100 by default.  This calling convention involves passing the object, the selector
4101 and the method arguments all at once to the method-lookup library function.
4102 This is the usual setting when targeting Darwin/Mac OS X systems, which have
4103 the NeXT runtime installed.
4105 If the macro is set to 0, the "GNU" Objective-C message sending convention
4106 will be used by default.  This convention passes just the object and the
4107 selector to the method-lookup function, which returns a pointer to the method.
4109 In either case, it remains possible to select code-generation for the alternate
4110 scheme, by means of compiler command line switches.
4111 @end defmac
4113 @node Addressing Modes
4114 @section Addressing Modes
4115 @cindex addressing modes
4117 @c prevent bad page break with this line
4118 This is about addressing modes.
4120 @defmac HAVE_PRE_INCREMENT
4121 @defmacx HAVE_PRE_DECREMENT
4122 @defmacx HAVE_POST_INCREMENT
4123 @defmacx HAVE_POST_DECREMENT
4124 A C expression that is nonzero if the machine supports pre-increment,
4125 pre-decrement, post-increment, or post-decrement addressing respectively.
4126 @end defmac
4128 @defmac HAVE_PRE_MODIFY_DISP
4129 @defmacx HAVE_POST_MODIFY_DISP
4130 A C expression that is nonzero if the machine supports pre- or
4131 post-address side-effect generation involving constants other than
4132 the size of the memory operand.
4133 @end defmac
4135 @defmac HAVE_PRE_MODIFY_REG
4136 @defmacx HAVE_POST_MODIFY_REG
4137 A C expression that is nonzero if the machine supports pre- or
4138 post-address side-effect generation involving a register displacement.
4139 @end defmac
4141 @defmac CONSTANT_ADDRESS_P (@var{x})
4142 A C expression that is 1 if the RTX @var{x} is a constant which
4143 is a valid address.  On most machines the default definition of
4144 @code{(CONSTANT_P (@var{x}) && GET_CODE (@var{x}) != CONST_DOUBLE)}
4145 is acceptable, but a few machines are more restrictive as to which
4146 constant addresses are supported.
4147 @end defmac
4149 @defmac CONSTANT_P (@var{x})
4150 @code{CONSTANT_P}, which is defined by target-independent code,
4151 accepts integer-values expressions whose values are not explicitly
4152 known, such as @code{symbol_ref}, @code{label_ref}, and @code{high}
4153 expressions and @code{const} arithmetic expressions, in addition to
4154 @code{const_int} and @code{const_double} expressions.
4155 @end defmac
4157 @defmac MAX_REGS_PER_ADDRESS
4158 A number, the maximum number of registers that can appear in a valid
4159 memory address.  Note that it is up to you to specify a value equal to
4160 the maximum number that @code{TARGET_LEGITIMATE_ADDRESS_P} would ever
4161 accept.
4162 @end defmac
4164 @hook TARGET_LEGITIMATE_ADDRESS_P
4166 @defmac TARGET_MEM_CONSTRAINT
4167 A single character to be used instead of the default @code{'m'}
4168 character for general memory addresses.  This defines the constraint
4169 letter which matches the memory addresses accepted by
4170 @code{TARGET_LEGITIMATE_ADDRESS_P}.  Define this macro if you want to
4171 support new address formats in your back end without changing the
4172 semantics of the @code{'m'} constraint.  This is necessary in order to
4173 preserve functionality of inline assembly constructs using the
4174 @code{'m'} constraint.
4175 @end defmac
4177 @defmac FIND_BASE_TERM (@var{x})
4178 A C expression to determine the base term of address @var{x},
4179 or to provide a simplified version of @var{x} from which @file{alias.c}
4180 can easily find the base term.  This macro is used in only two places:
4181 @code{find_base_value} and @code{find_base_term} in @file{alias.c}.
4183 It is always safe for this macro to not be defined.  It exists so
4184 that alias analysis can understand machine-dependent addresses.
4186 The typical use of this macro is to handle addresses containing
4187 a label_ref or symbol_ref within an UNSPEC@.
4188 @end defmac
4190 @hook TARGET_LEGITIMIZE_ADDRESS
4192 @defmac LEGITIMIZE_RELOAD_ADDRESS (@var{x}, @var{mode}, @var{opnum}, @var{type}, @var{ind_levels}, @var{win})
4193 A C compound statement that attempts to replace @var{x}, which is an address
4194 that needs reloading, with a valid memory address for an operand of mode
4195 @var{mode}.  @var{win} will be a C statement label elsewhere in the code.
4196 It is not necessary to define this macro, but it might be useful for
4197 performance reasons.
4199 For example, on the i386, it is sometimes possible to use a single
4200 reload register instead of two by reloading a sum of two pseudo
4201 registers into a register.  On the other hand, for number of RISC
4202 processors offsets are limited so that often an intermediate address
4203 needs to be generated in order to address a stack slot.  By defining
4204 @code{LEGITIMIZE_RELOAD_ADDRESS} appropriately, the intermediate addresses
4205 generated for adjacent some stack slots can be made identical, and thus
4206 be shared.
4208 @emph{Note}: This macro should be used with caution.  It is necessary
4209 to know something of how reload works in order to effectively use this,
4210 and it is quite easy to produce macros that build in too much knowledge
4211 of reload internals.
4213 @emph{Note}: This macro must be able to reload an address created by a
4214 previous invocation of this macro.  If it fails to handle such addresses
4215 then the compiler may generate incorrect code or abort.
4217 @findex push_reload
4218 The macro definition should use @code{push_reload} to indicate parts that
4219 need reloading; @var{opnum}, @var{type} and @var{ind_levels} are usually
4220 suitable to be passed unaltered to @code{push_reload}.
4222 The code generated by this macro must not alter the substructure of
4223 @var{x}.  If it transforms @var{x} into a more legitimate form, it
4224 should assign @var{x} (which will always be a C variable) a new value.
4225 This also applies to parts that you change indirectly by calling
4226 @code{push_reload}.
4228 @findex strict_memory_address_p
4229 The macro definition may use @code{strict_memory_address_p} to test if
4230 the address has become legitimate.
4232 @findex copy_rtx
4233 If you want to change only a part of @var{x}, one standard way of doing
4234 this is to use @code{copy_rtx}.  Note, however, that it unshares only a
4235 single level of rtl.  Thus, if the part to be changed is not at the
4236 top level, you'll need to replace first the top level.
4237 It is not necessary for this macro to come up with a legitimate
4238 address;  but often a machine-dependent strategy can generate better code.
4239 @end defmac
4241 @hook TARGET_MODE_DEPENDENT_ADDRESS_P
4243 @hook TARGET_LEGITIMATE_CONSTANT_P
4245 @hook TARGET_DELEGITIMIZE_ADDRESS
4247 @hook TARGET_CONST_NOT_OK_FOR_DEBUG_P
4249 @hook TARGET_CANNOT_FORCE_CONST_MEM
4251 @hook TARGET_USE_BLOCKS_FOR_CONSTANT_P
4253 @hook TARGET_USE_BLOCKS_FOR_DECL_P
4255 @hook TARGET_BUILTIN_RECIPROCAL
4257 @hook TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
4259 @hook TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
4261 @hook TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE
4263 @hook TARGET_VECTORIZE_VEC_PERM_CONST_OK
4265 @hook TARGET_VECTORIZE_BUILTIN_CONVERSION
4267 @hook TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
4269 @hook TARGET_VECTORIZE_BUILTIN_MD_VECTORIZED_FUNCTION
4271 @hook TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT
4273 @hook TARGET_VECTORIZE_PREFERRED_SIMD_MODE
4275 @hook TARGET_VECTORIZE_AUTOVECTORIZE_VECTOR_SIZES
4277 @hook TARGET_VECTORIZE_GET_MASK_MODE
4279 @hook TARGET_VECTORIZE_INIT_COST
4281 @hook TARGET_VECTORIZE_ADD_STMT_COST
4283 @hook TARGET_VECTORIZE_FINISH_COST
4285 @hook TARGET_VECTORIZE_DESTROY_COST_DATA
4287 @hook TARGET_VECTORIZE_BUILTIN_GATHER
4289 @hook TARGET_VECTORIZE_BUILTIN_SCATTER
4291 @hook TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN
4293 @hook TARGET_SIMD_CLONE_ADJUST
4295 @hook TARGET_SIMD_CLONE_USABLE
4297 @hook TARGET_SIMT_VF
4299 @hook TARGET_GOACC_VALIDATE_DIMS
4301 @hook TARGET_GOACC_DIM_LIMIT
4303 @hook TARGET_GOACC_FORK_JOIN
4305 @hook TARGET_GOACC_REDUCTION
4307 @node Anchored Addresses
4308 @section Anchored Addresses
4309 @cindex anchored addresses
4310 @cindex @option{-fsection-anchors}
4312 GCC usually addresses every static object as a separate entity.
4313 For example, if we have:
4315 @smallexample
4316 static int a, b, c;
4317 int foo (void) @{ return a + b + c; @}
4318 @end smallexample
4320 the code for @code{foo} will usually calculate three separate symbolic
4321 addresses: those of @code{a}, @code{b} and @code{c}.  On some targets,
4322 it would be better to calculate just one symbolic address and access
4323 the three variables relative to it.  The equivalent pseudocode would
4324 be something like:
4326 @smallexample
4327 int foo (void)
4329   register int *xr = &x;
4330   return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
4332 @end smallexample
4334 (which isn't valid C).  We refer to shared addresses like @code{x} as
4335 ``section anchors''.  Their use is controlled by @option{-fsection-anchors}.
4337 The hooks below describe the target properties that GCC needs to know
4338 in order to make effective use of section anchors.  It won't use
4339 section anchors at all unless either @code{TARGET_MIN_ANCHOR_OFFSET}
4340 or @code{TARGET_MAX_ANCHOR_OFFSET} is set to a nonzero value.
4342 @hook TARGET_MIN_ANCHOR_OFFSET
4344 @hook TARGET_MAX_ANCHOR_OFFSET
4346 @hook TARGET_ASM_OUTPUT_ANCHOR
4348 @hook TARGET_USE_ANCHORS_FOR_SYMBOL_P
4350 @node Condition Code
4351 @section Condition Code Status
4352 @cindex condition code status
4354 The macros in this section can be split in two families, according to the
4355 two ways of representing condition codes in GCC.
4357 The first representation is the so called @code{(cc0)} representation
4358 (@pxref{Jump Patterns}), where all instructions can have an implicit
4359 clobber of the condition codes.  The second is the condition code
4360 register representation, which provides better schedulability for
4361 architectures that do have a condition code register, but on which
4362 most instructions do not affect it.  The latter category includes
4363 most RISC machines.
4365 The implicit clobbering poses a strong restriction on the placement of
4366 the definition and use of the condition code.  In the past the definition
4367 and use were always adjacent.  However, recent changes to support trapping
4368 arithmatic may result in the definition and user being in different blocks.
4369 Thus, there may be a @code{NOTE_INSN_BASIC_BLOCK} between them.  Additionally,
4370 the definition may be the source of exception handling edges.
4372 These restrictions can prevent important
4373 optimizations on some machines.  For example, on the IBM RS/6000, there
4374 is a delay for taken branches unless the condition code register is set
4375 three instructions earlier than the conditional branch.  The instruction
4376 scheduler cannot perform this optimization if it is not permitted to
4377 separate the definition and use of the condition code register.
4379 For this reason, it is possible and suggested to use a register to
4380 represent the condition code for new ports.  If there is a specific
4381 condition code register in the machine, use a hard register.  If the
4382 condition code or comparison result can be placed in any general register,
4383 or if there are multiple condition registers, use a pseudo register.
4384 Registers used to store the condition code value will usually have a mode
4385 that is in class @code{MODE_CC}.
4387 Alternatively, you can use @code{BImode} if the comparison operator is
4388 specified already in the compare instruction.  In this case, you are not
4389 interested in most macros in this section.
4391 @menu
4392 * CC0 Condition Codes::      Old style representation of condition codes.
4393 * MODE_CC Condition Codes::  Modern representation of condition codes.
4394 @end menu
4396 @node CC0 Condition Codes
4397 @subsection Representation of condition codes using @code{(cc0)}
4398 @findex cc0
4400 @findex cc_status
4401 The file @file{conditions.h} defines a variable @code{cc_status} to
4402 describe how the condition code was computed (in case the interpretation of
4403 the condition code depends on the instruction that it was set by).  This
4404 variable contains the RTL expressions on which the condition code is
4405 currently based, and several standard flags.
4407 Sometimes additional machine-specific flags must be defined in the machine
4408 description header file.  It can also add additional machine-specific
4409 information by defining @code{CC_STATUS_MDEP}.
4411 @defmac CC_STATUS_MDEP
4412 C code for a data type which is used for declaring the @code{mdep}
4413 component of @code{cc_status}.  It defaults to @code{int}.
4415 This macro is not used on machines that do not use @code{cc0}.
4416 @end defmac
4418 @defmac CC_STATUS_MDEP_INIT
4419 A C expression to initialize the @code{mdep} field to ``empty''.
4420 The default definition does nothing, since most machines don't use
4421 the field anyway.  If you want to use the field, you should probably
4422 define this macro to initialize it.
4424 This macro is not used on machines that do not use @code{cc0}.
4425 @end defmac
4427 @defmac NOTICE_UPDATE_CC (@var{exp}, @var{insn})
4428 A C compound statement to set the components of @code{cc_status}
4429 appropriately for an insn @var{insn} whose body is @var{exp}.  It is
4430 this macro's responsibility to recognize insns that set the condition
4431 code as a byproduct of other activity as well as those that explicitly
4432 set @code{(cc0)}.
4434 This macro is not used on machines that do not use @code{cc0}.
4436 If there are insns that do not set the condition code but do alter
4437 other machine registers, this macro must check to see whether they
4438 invalidate the expressions that the condition code is recorded as
4439 reflecting.  For example, on the 68000, insns that store in address
4440 registers do not set the condition code, which means that usually
4441 @code{NOTICE_UPDATE_CC} can leave @code{cc_status} unaltered for such
4442 insns.  But suppose that the previous insn set the condition code
4443 based on location @samp{a4@@(102)} and the current insn stores a new
4444 value in @samp{a4}.  Although the condition code is not changed by
4445 this, it will no longer be true that it reflects the contents of
4446 @samp{a4@@(102)}.  Therefore, @code{NOTICE_UPDATE_CC} must alter
4447 @code{cc_status} in this case to say that nothing is known about the
4448 condition code value.
4450 The definition of @code{NOTICE_UPDATE_CC} must be prepared to deal
4451 with the results of peephole optimization: insns whose patterns are
4452 @code{parallel} RTXs containing various @code{reg}, @code{mem} or
4453 constants which are just the operands.  The RTL structure of these
4454 insns is not sufficient to indicate what the insns actually do.  What
4455 @code{NOTICE_UPDATE_CC} should do when it sees one is just to run
4456 @code{CC_STATUS_INIT}.
4458 A possible definition of @code{NOTICE_UPDATE_CC} is to call a function
4459 that looks at an attribute (@pxref{Insn Attributes}) named, for example,
4460 @samp{cc}.  This avoids having detailed information about patterns in
4461 two places, the @file{md} file and in @code{NOTICE_UPDATE_CC}.
4462 @end defmac
4464 @node MODE_CC Condition Codes
4465 @subsection Representation of condition codes using registers
4466 @findex CCmode
4467 @findex MODE_CC
4469 @defmac SELECT_CC_MODE (@var{op}, @var{x}, @var{y})
4470 On many machines, the condition code may be produced by other instructions
4471 than compares, for example the branch can use directly the condition
4472 code set by a subtract instruction.  However, on some machines
4473 when the condition code is set this way some bits (such as the overflow
4474 bit) are not set in the same way as a test instruction, so that a different
4475 branch instruction must be used for some conditional branches.  When
4476 this happens, use the machine mode of the condition code register to
4477 record different formats of the condition code register.  Modes can
4478 also be used to record which compare instruction (e.g. a signed or an
4479 unsigned comparison) produced the condition codes.
4481 If other modes than @code{CCmode} are required, add them to
4482 @file{@var{machine}-modes.def} and define @code{SELECT_CC_MODE} to choose
4483 a mode given an operand of a compare.  This is needed because the modes
4484 have to be chosen not only during RTL generation but also, for example,
4485 by instruction combination.  The result of @code{SELECT_CC_MODE} should
4486 be consistent with the mode used in the patterns; for example to support
4487 the case of the add on the SPARC discussed above, we have the pattern
4489 @smallexample
4490 (define_insn ""
4491   [(set (reg:CCNZ 0)
4492         (compare:CCNZ
4493           (plus:SI (match_operand:SI 0 "register_operand" "%r")
4494                    (match_operand:SI 1 "arith_operand" "rI"))
4495           (const_int 0)))]
4496   ""
4497   "@dots{}")
4498 @end smallexample
4500 @noindent
4501 together with a @code{SELECT_CC_MODE} that returns @code{CCNZmode}
4502 for comparisons whose argument is a @code{plus}:
4504 @smallexample
4505 #define SELECT_CC_MODE(OP,X,Y) \
4506   (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT           \
4507    ? ((OP == LT || OP == LE || OP == GT || OP == GE)     \
4508       ? CCFPEmode : CCFPmode)                            \
4509    : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS     \
4510        || GET_CODE (X) == NEG || GET_CODE (x) == ASHIFT) \
4511       ? CCNZmode : CCmode))
4512 @end smallexample
4514 Another reason to use modes is to retain information on which operands
4515 were used by the comparison; see @code{REVERSIBLE_CC_MODE} later in
4516 this section.
4518 You should define this macro if and only if you define extra CC modes
4519 in @file{@var{machine}-modes.def}.
4520 @end defmac
4522 @hook TARGET_CANONICALIZE_COMPARISON
4524 @defmac REVERSIBLE_CC_MODE (@var{mode})
4525 A C expression whose value is one if it is always safe to reverse a
4526 comparison whose mode is @var{mode}.  If @code{SELECT_CC_MODE}
4527 can ever return @var{mode} for a floating-point inequality comparison,
4528 then @code{REVERSIBLE_CC_MODE (@var{mode})} must be zero.
4530 You need not define this macro if it would always returns zero or if the
4531 floating-point format is anything other than @code{IEEE_FLOAT_FORMAT}.
4532 For example, here is the definition used on the SPARC, where floating-point
4533 inequality comparisons are given either @code{CCFPEmode} or @code{CCFPmode}:
4535 @smallexample
4536 #define REVERSIBLE_CC_MODE(MODE) \
4537    ((MODE) != CCFPEmode && (MODE) != CCFPmode)
4538 @end smallexample
4539 @end defmac
4541 @defmac REVERSE_CONDITION (@var{code}, @var{mode})
4542 A C expression whose value is reversed condition code of the @var{code} for
4543 comparison done in CC_MODE @var{mode}.  The macro is used only in case
4544 @code{REVERSIBLE_CC_MODE (@var{mode})} is nonzero.  Define this macro in case
4545 machine has some non-standard way how to reverse certain conditionals.  For
4546 instance in case all floating point conditions are non-trapping, compiler may
4547 freely convert unordered compares to ordered ones.  Then definition may look
4548 like:
4550 @smallexample
4551 #define REVERSE_CONDITION(CODE, MODE) \
4552    ((MODE) != CCFPmode ? reverse_condition (CODE) \
4553     : reverse_condition_maybe_unordered (CODE))
4554 @end smallexample
4555 @end defmac
4557 @hook TARGET_FIXED_CONDITION_CODE_REGS
4559 @hook TARGET_CC_MODES_COMPATIBLE
4561 @hook TARGET_FLAGS_REGNUM
4563 @node Costs
4564 @section Describing Relative Costs of Operations
4565 @cindex costs of instructions
4566 @cindex relative costs
4567 @cindex speed of instructions
4569 These macros let you describe the relative speed of various operations
4570 on the target machine.
4572 @defmac REGISTER_MOVE_COST (@var{mode}, @var{from}, @var{to})
4573 A C expression for the cost of moving data of mode @var{mode} from a
4574 register in class @var{from} to one in class @var{to}.  The classes are
4575 expressed using the enumeration values such as @code{GENERAL_REGS}.  A
4576 value of 2 is the default; other values are interpreted relative to
4577 that.
4579 It is not required that the cost always equal 2 when @var{from} is the
4580 same as @var{to}; on some machines it is expensive to move between
4581 registers if they are not general registers.
4583 If reload sees an insn consisting of a single @code{set} between two
4584 hard registers, and if @code{REGISTER_MOVE_COST} applied to their
4585 classes returns a value of 2, reload does not check to ensure that the
4586 constraints of the insn are met.  Setting a cost of other than 2 will
4587 allow reload to verify that the constraints are met.  You should do this
4588 if the @samp{mov@var{m}} pattern's constraints do not allow such copying.
4590 These macros are obsolete, new ports should use the target hook
4591 @code{TARGET_REGISTER_MOVE_COST} instead.
4592 @end defmac
4594 @hook TARGET_REGISTER_MOVE_COST
4596 @defmac MEMORY_MOVE_COST (@var{mode}, @var{class}, @var{in})
4597 A C expression for the cost of moving data of mode @var{mode} between a
4598 register of class @var{class} and memory; @var{in} is zero if the value
4599 is to be written to memory, nonzero if it is to be read in.  This cost
4600 is relative to those in @code{REGISTER_MOVE_COST}.  If moving between
4601 registers and memory is more expensive than between two registers, you
4602 should define this macro to express the relative cost.
4604 If you do not define this macro, GCC uses a default cost of 4 plus
4605 the cost of copying via a secondary reload register, if one is
4606 needed.  If your machine requires a secondary reload register to copy
4607 between memory and a register of @var{class} but the reload mechanism is
4608 more complex than copying via an intermediate, define this macro to
4609 reflect the actual cost of the move.
4611 GCC defines the function @code{memory_move_secondary_cost} if
4612 secondary reloads are needed.  It computes the costs due to copying via
4613 a secondary register.  If your machine copies from memory using a
4614 secondary register in the conventional way but the default base value of
4615 4 is not correct for your machine, define this macro to add some other
4616 value to the result of that function.  The arguments to that function
4617 are the same as to this macro.
4619 These macros are obsolete, new ports should use the target hook
4620 @code{TARGET_MEMORY_MOVE_COST} instead.
4621 @end defmac
4623 @hook TARGET_MEMORY_MOVE_COST
4625 @defmac BRANCH_COST (@var{speed_p}, @var{predictable_p})
4626 A C expression for the cost of a branch instruction.  A value of 1 is
4627 the default; other values are interpreted relative to that. Parameter
4628 @var{speed_p} is true when the branch in question should be optimized
4629 for speed.  When it is false, @code{BRANCH_COST} should return a value
4630 optimal for code size rather than performance.  @var{predictable_p} is
4631 true for well-predicted branches. On many architectures the
4632 @code{BRANCH_COST} can be reduced then.
4633 @end defmac
4635 Here are additional macros which do not specify precise relative costs,
4636 but only that certain actions are more expensive than GCC would
4637 ordinarily expect.
4639 @defmac SLOW_BYTE_ACCESS
4640 Define this macro as a C expression which is nonzero if accessing less
4641 than a word of memory (i.e.@: a @code{char} or a @code{short}) is no
4642 faster than accessing a word of memory, i.e., if such access
4643 require more than one instruction or if there is no difference in cost
4644 between byte and (aligned) word loads.
4646 When this macro is not defined, the compiler will access a field by
4647 finding the smallest containing object; when it is defined, a fullword
4648 load will be used if alignment permits.  Unless bytes accesses are
4649 faster than word accesses, using word accesses is preferable since it
4650 may eliminate subsequent memory access if subsequent accesses occur to
4651 other fields in the same word of the structure, but to different bytes.
4652 @end defmac
4654 @defmac SLOW_UNALIGNED_ACCESS (@var{mode}, @var{alignment})
4655 Define this macro to be the value 1 if memory accesses described by the
4656 @var{mode} and @var{alignment} parameters have a cost many times greater
4657 than aligned accesses, for example if they are emulated in a trap
4658 handler.  This macro is invoked only for unaligned accesses, i.e. when
4659 @code{@var{alignment} < GET_MODE_ALIGNMENT (@var{mode})}.
4661 When this macro is nonzero, the compiler will act as if
4662 @code{STRICT_ALIGNMENT} were nonzero when generating code for block
4663 moves.  This can cause significantly more instructions to be produced.
4664 Therefore, do not set this macro nonzero if unaligned accesses only add a
4665 cycle or two to the time for a memory access.
4667 If the value of this macro is always zero, it need not be defined.  If
4668 this macro is defined, it should produce a nonzero value when
4669 @code{STRICT_ALIGNMENT} is nonzero.
4670 @end defmac
4672 @defmac MOVE_RATIO (@var{speed})
4673 The threshold of number of scalar memory-to-memory move insns, @emph{below}
4674 which a sequence of insns should be generated instead of a
4675 string move insn or a library call.  Increasing the value will always
4676 make code faster, but eventually incurs high cost in increased code size.
4678 Note that on machines where the corresponding move insn is a
4679 @code{define_expand} that emits a sequence of insns, this macro counts
4680 the number of such sequences.
4682 The parameter @var{speed} is true if the code is currently being
4683 optimized for speed rather than size.
4685 If you don't define this, a reasonable default is used.
4686 @end defmac
4688 @hook TARGET_USE_BY_PIECES_INFRASTRUCTURE_P
4690 @hook TARGET_COMPARE_BY_PIECES_BRANCH_RATIO
4692 @defmac MOVE_MAX_PIECES
4693 A C expression used by @code{move_by_pieces} to determine the largest unit
4694 a load or store used to copy memory is.  Defaults to @code{MOVE_MAX}.
4695 @end defmac
4697 @defmac STORE_MAX_PIECES
4698 A C expression used by @code{store_by_pieces} to determine the largest unit
4699 a store used to memory is.  Defaults to @code{MOVE_MAX_PIECES}, or two times
4700 the size of @code{HOST_WIDE_INT}, whichever is smaller.
4701 @end defmac
4703 @defmac COMPARE_MAX_PIECES
4704 A C expression used by @code{compare_by_pieces} to determine the largest unit
4705 a load or store used to compare memory is.  Defaults to
4706 @code{MOVE_MAX_PIECES}.
4707 @end defmac
4709 @defmac CLEAR_RATIO (@var{speed})
4710 The threshold of number of scalar move insns, @emph{below} which a sequence
4711 of insns should be generated to clear memory instead of a string clear insn
4712 or a library call.  Increasing the value will always make code faster, but
4713 eventually incurs high cost in increased code size.
4715 The parameter @var{speed} is true if the code is currently being
4716 optimized for speed rather than size.
4718 If you don't define this, a reasonable default is used.
4719 @end defmac
4721 @defmac SET_RATIO (@var{speed})
4722 The threshold of number of scalar move insns, @emph{below} which a sequence
4723 of insns should be generated to set memory to a constant value, instead of
4724 a block set insn or a library call.
4725 Increasing the value will always make code faster, but
4726 eventually incurs high cost in increased code size.
4728 The parameter @var{speed} is true if the code is currently being
4729 optimized for speed rather than size.
4731 If you don't define this, it defaults to the value of @code{MOVE_RATIO}.
4732 @end defmac
4734 @defmac USE_LOAD_POST_INCREMENT (@var{mode})
4735 A C expression used to determine whether a load postincrement is a good
4736 thing to use for a given mode.  Defaults to the value of
4737 @code{HAVE_POST_INCREMENT}.
4738 @end defmac
4740 @defmac USE_LOAD_POST_DECREMENT (@var{mode})
4741 A C expression used to determine whether a load postdecrement is a good
4742 thing to use for a given mode.  Defaults to the value of
4743 @code{HAVE_POST_DECREMENT}.
4744 @end defmac
4746 @defmac USE_LOAD_PRE_INCREMENT (@var{mode})
4747 A C expression used to determine whether a load preincrement is a good
4748 thing to use for a given mode.  Defaults to the value of
4749 @code{HAVE_PRE_INCREMENT}.
4750 @end defmac
4752 @defmac USE_LOAD_PRE_DECREMENT (@var{mode})
4753 A C expression used to determine whether a load predecrement is a good
4754 thing to use for a given mode.  Defaults to the value of
4755 @code{HAVE_PRE_DECREMENT}.
4756 @end defmac
4758 @defmac USE_STORE_POST_INCREMENT (@var{mode})
4759 A C expression used to determine whether a store postincrement is a good
4760 thing to use for a given mode.  Defaults to the value of
4761 @code{HAVE_POST_INCREMENT}.
4762 @end defmac
4764 @defmac USE_STORE_POST_DECREMENT (@var{mode})
4765 A C expression used to determine whether a store postdecrement is a good
4766 thing to use for a given mode.  Defaults to the value of
4767 @code{HAVE_POST_DECREMENT}.
4768 @end defmac
4770 @defmac USE_STORE_PRE_INCREMENT (@var{mode})
4771 This macro is used to determine whether a store preincrement is a good
4772 thing to use for a given mode.  Defaults to the value of
4773 @code{HAVE_PRE_INCREMENT}.
4774 @end defmac
4776 @defmac USE_STORE_PRE_DECREMENT (@var{mode})
4777 This macro is used to determine whether a store predecrement is a good
4778 thing to use for a given mode.  Defaults to the value of
4779 @code{HAVE_PRE_DECREMENT}.
4780 @end defmac
4782 @defmac NO_FUNCTION_CSE
4783 Define this macro to be true if it is as good or better to call a constant
4784 function address than to call an address kept in a register.
4785 @end defmac
4787 @defmac LOGICAL_OP_NON_SHORT_CIRCUIT
4788 Define this macro if a non-short-circuit operation produced by
4789 @samp{fold_range_test ()} is optimal.  This macro defaults to true if
4790 @code{BRANCH_COST} is greater than or equal to the value 2.
4791 @end defmac
4793 @hook TARGET_OPTAB_SUPPORTED_P
4795 @hook TARGET_RTX_COSTS
4797 @hook TARGET_ADDRESS_COST
4799 @hook TARGET_MAX_NOCE_IFCVT_SEQ_COST
4801 @hook TARGET_NOCE_CONVERSION_PROFITABLE_P
4803 @hook TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P
4805 @node Scheduling
4806 @section Adjusting the Instruction Scheduler
4808 The instruction scheduler may need a fair amount of machine-specific
4809 adjustment in order to produce good code.  GCC provides several target
4810 hooks for this purpose.  It is usually enough to define just a few of
4811 them: try the first ones in this list first.
4813 @hook TARGET_SCHED_ISSUE_RATE
4815 @hook TARGET_SCHED_VARIABLE_ISSUE
4817 @hook TARGET_SCHED_ADJUST_COST
4819 @hook TARGET_SCHED_ADJUST_PRIORITY
4821 @hook TARGET_SCHED_REORDER
4823 @hook TARGET_SCHED_REORDER2
4825 @hook TARGET_SCHED_MACRO_FUSION_P
4827 @hook TARGET_SCHED_MACRO_FUSION_PAIR_P
4829 @hook TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK
4831 @hook TARGET_SCHED_INIT
4833 @hook TARGET_SCHED_FINISH
4835 @hook TARGET_SCHED_INIT_GLOBAL
4837 @hook TARGET_SCHED_FINISH_GLOBAL
4839 @hook TARGET_SCHED_DFA_PRE_CYCLE_INSN
4841 @hook TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN
4843 @hook TARGET_SCHED_DFA_POST_CYCLE_INSN
4845 @hook TARGET_SCHED_INIT_DFA_POST_CYCLE_INSN
4847 @hook TARGET_SCHED_DFA_PRE_ADVANCE_CYCLE
4849 @hook TARGET_SCHED_DFA_POST_ADVANCE_CYCLE
4851 @hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
4853 @hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
4855 @hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BEGIN
4857 @hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_ISSUE
4859 @hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BACKTRACK
4861 @hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_END
4863 @hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_INIT
4865 @hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_FINI
4867 @hook TARGET_SCHED_DFA_NEW_CYCLE
4869 @hook TARGET_SCHED_IS_COSTLY_DEPENDENCE
4871 @hook TARGET_SCHED_H_I_D_EXTENDED
4873 @hook TARGET_SCHED_ALLOC_SCHED_CONTEXT
4875 @hook TARGET_SCHED_INIT_SCHED_CONTEXT
4877 @hook TARGET_SCHED_SET_SCHED_CONTEXT
4879 @hook TARGET_SCHED_CLEAR_SCHED_CONTEXT
4881 @hook TARGET_SCHED_FREE_SCHED_CONTEXT
4883 @hook TARGET_SCHED_SPECULATE_INSN
4885 @hook TARGET_SCHED_NEEDS_BLOCK_P
4887 @hook TARGET_SCHED_GEN_SPEC_CHECK
4889 @hook TARGET_SCHED_SET_SCHED_FLAGS
4891 @hook TARGET_SCHED_CAN_SPECULATE_INSN
4893 @hook TARGET_SCHED_SMS_RES_MII
4895 @hook TARGET_SCHED_DISPATCH
4897 @hook TARGET_SCHED_DISPATCH_DO
4899 @hook TARGET_SCHED_EXPOSED_PIPELINE
4901 @hook TARGET_SCHED_REASSOCIATION_WIDTH
4903 @hook TARGET_SCHED_FUSION_PRIORITY
4905 @hook TARGET_EXPAND_DIVMOD_LIBFUNC
4907 @node Sections
4908 @section Dividing the Output into Sections (Texts, Data, @dots{})
4909 @c the above section title is WAY too long.  maybe cut the part between
4910 @c the (...)?  --mew 10feb93
4912 An object file is divided into sections containing different types of
4913 data.  In the most common case, there are three sections: the @dfn{text
4914 section}, which holds instructions and read-only data; the @dfn{data
4915 section}, which holds initialized writable data; and the @dfn{bss
4916 section}, which holds uninitialized data.  Some systems have other kinds
4917 of sections.
4919 @file{varasm.c} provides several well-known sections, such as
4920 @code{text_section}, @code{data_section} and @code{bss_section}.
4921 The normal way of controlling a @code{@var{foo}_section} variable
4922 is to define the associated @code{@var{FOO}_SECTION_ASM_OP} macro,
4923 as described below.  The macros are only read once, when @file{varasm.c}
4924 initializes itself, so their values must be run-time constants.
4925 They may however depend on command-line flags.
4927 @emph{Note:} Some run-time files, such @file{crtstuff.c}, also make
4928 use of the @code{@var{FOO}_SECTION_ASM_OP} macros, and expect them
4929 to be string literals.
4931 Some assemblers require a different string to be written every time a
4932 section is selected.  If your assembler falls into this category, you
4933 should define the @code{TARGET_ASM_INIT_SECTIONS} hook and use
4934 @code{get_unnamed_section} to set up the sections.
4936 You must always create a @code{text_section}, either by defining
4937 @code{TEXT_SECTION_ASM_OP} or by initializing @code{text_section}
4938 in @code{TARGET_ASM_INIT_SECTIONS}.  The same is true of
4939 @code{data_section} and @code{DATA_SECTION_ASM_OP}.  If you do not
4940 create a distinct @code{readonly_data_section}, the default is to
4941 reuse @code{text_section}.
4943 All the other @file{varasm.c} sections are optional, and are null
4944 if the target does not provide them.
4946 @defmac TEXT_SECTION_ASM_OP
4947 A C expression whose value is a string, including spacing, containing the
4948 assembler operation that should precede instructions and read-only data.
4949 Normally @code{"\t.text"} is right.
4950 @end defmac
4952 @defmac HOT_TEXT_SECTION_NAME
4953 If defined, a C string constant for the name of the section containing most
4954 frequently executed functions of the program.  If not defined, GCC will provide
4955 a default definition if the target supports named sections.
4956 @end defmac
4958 @defmac UNLIKELY_EXECUTED_TEXT_SECTION_NAME
4959 If defined, a C string constant for the name of the section containing unlikely
4960 executed functions in the program.
4961 @end defmac
4963 @defmac DATA_SECTION_ASM_OP
4964 A C expression whose value is a string, including spacing, containing the
4965 assembler operation to identify the following data as writable initialized
4966 data.  Normally @code{"\t.data"} is right.
4967 @end defmac
4969 @defmac SDATA_SECTION_ASM_OP
4970 If defined, a C expression whose value is a string, including spacing,
4971 containing the assembler operation to identify the following data as
4972 initialized, writable small data.
4973 @end defmac
4975 @defmac READONLY_DATA_SECTION_ASM_OP
4976 A C expression whose value is a string, including spacing, containing the
4977 assembler operation to identify the following data as read-only initialized
4978 data.
4979 @end defmac
4981 @defmac BSS_SECTION_ASM_OP
4982 If defined, a C expression whose value is a string, including spacing,
4983 containing the assembler operation to identify the following data as
4984 uninitialized global data.  If not defined, and
4985 @code{ASM_OUTPUT_ALIGNED_BSS} not defined,
4986 uninitialized global data will be output in the data section if
4987 @option{-fno-common} is passed, otherwise @code{ASM_OUTPUT_COMMON} will be
4988 used.
4989 @end defmac
4991 @defmac SBSS_SECTION_ASM_OP
4992 If defined, a C expression whose value is a string, including spacing,
4993 containing the assembler operation to identify the following data as
4994 uninitialized, writable small data.
4995 @end defmac
4997 @defmac TLS_COMMON_ASM_OP
4998 If defined, a C expression whose value is a string containing the
4999 assembler operation to identify the following data as thread-local
5000 common data.  The default is @code{".tls_common"}.
5001 @end defmac
5003 @defmac TLS_SECTION_ASM_FLAG
5004 If defined, a C expression whose value is a character constant
5005 containing the flag used to mark a section as a TLS section.  The
5006 default is @code{'T'}.
5007 @end defmac
5009 @defmac INIT_SECTION_ASM_OP
5010 If defined, a C expression whose value is a string, including spacing,
5011 containing the assembler operation to identify the following data as
5012 initialization code.  If not defined, GCC will assume such a section does
5013 not exist.  This section has no corresponding @code{init_section}
5014 variable; it is used entirely in runtime code.
5015 @end defmac
5017 @defmac FINI_SECTION_ASM_OP
5018 If defined, a C expression whose value is a string, including spacing,
5019 containing the assembler operation to identify the following data as
5020 finalization code.  If not defined, GCC will assume such a section does
5021 not exist.  This section has no corresponding @code{fini_section}
5022 variable; it is used entirely in runtime code.
5023 @end defmac
5025 @defmac INIT_ARRAY_SECTION_ASM_OP
5026 If defined, a C expression whose value is a string, including spacing,
5027 containing the assembler operation to identify the following data as
5028 part of the @code{.init_array} (or equivalent) section.  If not
5029 defined, GCC will assume such a section does not exist.  Do not define
5030 both this macro and @code{INIT_SECTION_ASM_OP}.
5031 @end defmac
5033 @defmac FINI_ARRAY_SECTION_ASM_OP
5034 If defined, a C expression whose value is a string, including spacing,
5035 containing the assembler operation to identify the following data as
5036 part of the @code{.fini_array} (or equivalent) section.  If not
5037 defined, GCC will assume such a section does not exist.  Do not define
5038 both this macro and @code{FINI_SECTION_ASM_OP}.
5039 @end defmac
5041 @defmac MACH_DEP_SECTION_ASM_FLAG
5042 If defined, a C expression whose value is a character constant
5043 containing the flag used to mark a machine-dependent section.  This
5044 corresponds to the @code{SECTION_MACH_DEP} section flag.
5045 @end defmac
5047 @defmac CRT_CALL_STATIC_FUNCTION (@var{section_op}, @var{function})
5048 If defined, an ASM statement that switches to a different section
5049 via @var{section_op}, calls @var{function}, and switches back to
5050 the text section.  This is used in @file{crtstuff.c} if
5051 @code{INIT_SECTION_ASM_OP} or @code{FINI_SECTION_ASM_OP} to calls
5052 to initialization and finalization functions from the init and fini
5053 sections.  By default, this macro uses a simple function call.  Some
5054 ports need hand-crafted assembly code to avoid dependencies on
5055 registers initialized in the function prologue or to ensure that
5056 constant pools don't end up too far way in the text section.
5057 @end defmac
5059 @defmac TARGET_LIBGCC_SDATA_SECTION
5060 If defined, a string which names the section into which small
5061 variables defined in crtstuff and libgcc should go.  This is useful
5062 when the target has options for optimizing access to small data, and
5063 you want the crtstuff and libgcc routines to be conservative in what
5064 they expect of your application yet liberal in what your application
5065 expects.  For example, for targets with a @code{.sdata} section (like
5066 MIPS), you could compile crtstuff with @code{-G 0} so that it doesn't
5067 require small data support from your application, but use this macro
5068 to put small data into @code{.sdata} so that your application can
5069 access these variables whether it uses small data or not.
5070 @end defmac
5072 @defmac FORCE_CODE_SECTION_ALIGN
5073 If defined, an ASM statement that aligns a code section to some
5074 arbitrary boundary.  This is used to force all fragments of the
5075 @code{.init} and @code{.fini} sections to have to same alignment
5076 and thus prevent the linker from having to add any padding.
5077 @end defmac
5079 @defmac JUMP_TABLES_IN_TEXT_SECTION
5080 Define this macro to be an expression with a nonzero value if jump
5081 tables (for @code{tablejump} insns) should be output in the text
5082 section, along with the assembler instructions.  Otherwise, the
5083 readonly data section is used.
5085 This macro is irrelevant if there is no separate readonly data section.
5086 @end defmac
5088 @hook TARGET_ASM_INIT_SECTIONS
5090 @hook TARGET_ASM_RELOC_RW_MASK
5092 @hook TARGET_ASM_SELECT_SECTION
5094 @defmac USE_SELECT_SECTION_FOR_FUNCTIONS
5095 Define this macro if you wish TARGET_ASM_SELECT_SECTION to be called
5096 for @code{FUNCTION_DECL}s as well as for variables and constants.
5098 In the case of a @code{FUNCTION_DECL}, @var{reloc} will be zero if the
5099 function has been determined to be likely to be called, and nonzero if
5100 it is unlikely to be called.
5101 @end defmac
5103 @hook TARGET_ASM_UNIQUE_SECTION
5105 @hook TARGET_ASM_FUNCTION_RODATA_SECTION
5107 @hook TARGET_ASM_MERGEABLE_RODATA_PREFIX
5109 @hook TARGET_ASM_TM_CLONE_TABLE_SECTION
5111 @hook TARGET_ASM_SELECT_RTX_SECTION
5113 @hook TARGET_MANGLE_DECL_ASSEMBLER_NAME
5115 @hook TARGET_ENCODE_SECTION_INFO
5117 @hook TARGET_STRIP_NAME_ENCODING
5119 @hook TARGET_IN_SMALL_DATA_P
5121 @hook TARGET_HAVE_SRODATA_SECTION
5123 @hook TARGET_PROFILE_BEFORE_PROLOGUE
5125 @hook TARGET_BINDS_LOCAL_P
5127 @hook TARGET_HAVE_TLS
5130 @node PIC
5131 @section Position Independent Code
5132 @cindex position independent code
5133 @cindex PIC
5135 This section describes macros that help implement generation of position
5136 independent code.  Simply defining these macros is not enough to
5137 generate valid PIC; you must also add support to the hook
5138 @code{TARGET_LEGITIMATE_ADDRESS_P} and to the macro
5139 @code{PRINT_OPERAND_ADDRESS}, as well as @code{LEGITIMIZE_ADDRESS}.  You
5140 must modify the definition of @samp{movsi} to do something appropriate
5141 when the source operand contains a symbolic address.  You may also
5142 need to alter the handling of switch statements so that they use
5143 relative addresses.
5144 @c i rearranged the order of the macros above to try to force one of
5145 @c them to the next line, to eliminate an overfull hbox. --mew 10feb93
5147 @defmac PIC_OFFSET_TABLE_REGNUM
5148 The register number of the register used to address a table of static
5149 data addresses in memory.  In some cases this register is defined by a
5150 processor's ``application binary interface'' (ABI)@.  When this macro
5151 is defined, RTL is generated for this register once, as with the stack
5152 pointer and frame pointer registers.  If this macro is not defined, it
5153 is up to the machine-dependent files to allocate such a register (if
5154 necessary).  Note that this register must be fixed when in use (e.g.@:
5155 when @code{flag_pic} is true).
5156 @end defmac
5158 @defmac PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
5159 A C expression that is nonzero if the register defined by
5160 @code{PIC_OFFSET_TABLE_REGNUM} is clobbered by calls.  If not defined,
5161 the default is zero.  Do not define
5162 this macro if @code{PIC_OFFSET_TABLE_REGNUM} is not defined.
5163 @end defmac
5165 @defmac LEGITIMATE_PIC_OPERAND_P (@var{x})
5166 A C expression that is nonzero if @var{x} is a legitimate immediate
5167 operand on the target machine when generating position independent code.
5168 You can assume that @var{x} satisfies @code{CONSTANT_P}, so you need not
5169 check this.  You can also assume @var{flag_pic} is true, so you need not
5170 check it either.  You need not define this macro if all constants
5171 (including @code{SYMBOL_REF}) can be immediate operands when generating
5172 position independent code.
5173 @end defmac
5175 @node Assembler Format
5176 @section Defining the Output Assembler Language
5178 This section describes macros whose principal purpose is to describe how
5179 to write instructions in assembler language---rather than what the
5180 instructions do.
5182 @menu
5183 * File Framework::       Structural information for the assembler file.
5184 * Data Output::          Output of constants (numbers, strings, addresses).
5185 * Uninitialized Data::   Output of uninitialized variables.
5186 * Label Output::         Output and generation of labels.
5187 * Initialization::       General principles of initialization
5188                          and termination routines.
5189 * Macros for Initialization::
5190                          Specific macros that control the handling of
5191                          initialization and termination routines.
5192 * Instruction Output::   Output of actual instructions.
5193 * Dispatch Tables::      Output of jump tables.
5194 * Exception Region Output:: Output of exception region code.
5195 * Alignment Output::     Pseudo ops for alignment and skipping data.
5196 @end menu
5198 @node File Framework
5199 @subsection The Overall Framework of an Assembler File
5200 @cindex assembler format
5201 @cindex output of assembler code
5203 @c prevent bad page break with this line
5204 This describes the overall framework of an assembly file.
5206 @findex default_file_start
5207 @hook TARGET_ASM_FILE_START
5209 @hook TARGET_ASM_FILE_START_APP_OFF
5211 @hook TARGET_ASM_FILE_START_FILE_DIRECTIVE
5213 @hook TARGET_ASM_FILE_END
5215 @deftypefun void file_end_indicate_exec_stack ()
5216 Some systems use a common convention, the @samp{.note.GNU-stack}
5217 special section, to indicate whether or not an object file relies on
5218 the stack being executable.  If your system uses this convention, you
5219 should define @code{TARGET_ASM_FILE_END} to this function.  If you
5220 need to do other things in that hook, have your hook function call
5221 this function.
5222 @end deftypefun
5224 @hook TARGET_ASM_LTO_START
5226 @hook TARGET_ASM_LTO_END
5228 @hook TARGET_ASM_CODE_END
5230 @defmac ASM_COMMENT_START
5231 A C string constant describing how to begin a comment in the target
5232 assembler language.  The compiler assumes that the comment will end at
5233 the end of the line.
5234 @end defmac
5236 @defmac ASM_APP_ON
5237 A C string constant for text to be output before each @code{asm}
5238 statement or group of consecutive ones.  Normally this is
5239 @code{"#APP"}, which is a comment that has no effect on most
5240 assemblers but tells the GNU assembler that it must check the lines
5241 that follow for all valid assembler constructs.
5242 @end defmac
5244 @defmac ASM_APP_OFF
5245 A C string constant for text to be output after each @code{asm}
5246 statement or group of consecutive ones.  Normally this is
5247 @code{"#NO_APP"}, which tells the GNU assembler to resume making the
5248 time-saving assumptions that are valid for ordinary compiler output.
5249 @end defmac
5251 @defmac ASM_OUTPUT_SOURCE_FILENAME (@var{stream}, @var{name})
5252 A C statement to output COFF information or DWARF debugging information
5253 which indicates that filename @var{name} is the current source file to
5254 the stdio stream @var{stream}.
5256 This macro need not be defined if the standard form of output
5257 for the file format in use is appropriate.
5258 @end defmac
5260 @hook TARGET_ASM_OUTPUT_SOURCE_FILENAME
5262 @hook TARGET_ASM_OUTPUT_IDENT
5264 @defmac OUTPUT_QUOTED_STRING (@var{stream}, @var{string})
5265 A C statement to output the string @var{string} to the stdio stream
5266 @var{stream}.  If you do not call the function @code{output_quoted_string}
5267 in your config files, GCC will only call it to output filenames to
5268 the assembler source.  So you can use it to canonicalize the format
5269 of the filename using this macro.
5270 @end defmac
5272 @hook TARGET_ASM_NAMED_SECTION
5274 @hook TARGET_ASM_ELF_FLAGS_NUMERIC
5276 @hook TARGET_ASM_FUNCTION_SECTION
5278 @hook TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS
5280 @hook TARGET_HAVE_NAMED_SECTIONS
5281 This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}.
5282 It must not be modified by command-line option processing.
5283 @end deftypevr
5285 @anchor{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS}
5286 @hook TARGET_HAVE_SWITCHABLE_BSS_SECTIONS
5288 @hook TARGET_SECTION_TYPE_FLAGS
5290 @hook TARGET_ASM_RECORD_GCC_SWITCHES
5292 @hook TARGET_ASM_RECORD_GCC_SWITCHES_SECTION
5294 @need 2000
5295 @node Data Output
5296 @subsection Output of Data
5299 @hook TARGET_ASM_BYTE_OP
5301 @hook TARGET_ASM_INTEGER
5303 @hook TARGET_ASM_DECL_END
5305 @hook TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
5307 @defmac ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len})
5308 A C statement to output to the stdio stream @var{stream} an assembler
5309 instruction to assemble a string constant containing the @var{len}
5310 bytes at @var{ptr}.  @var{ptr} will be a C expression of type
5311 @code{char *} and @var{len} a C expression of type @code{int}.
5313 If the assembler has a @code{.ascii} pseudo-op as found in the
5314 Berkeley Unix assembler, do not define the macro
5315 @code{ASM_OUTPUT_ASCII}.
5316 @end defmac
5318 @defmac ASM_OUTPUT_FDESC (@var{stream}, @var{decl}, @var{n})
5319 A C statement to output word @var{n} of a function descriptor for
5320 @var{decl}.  This must be defined if @code{TARGET_VTABLE_USES_DESCRIPTORS}
5321 is defined, and is otherwise unused.
5322 @end defmac
5324 @defmac CONSTANT_POOL_BEFORE_FUNCTION
5325 You may define this macro as a C expression.  You should define the
5326 expression to have a nonzero value if GCC should output the constant
5327 pool for a function before the code for the function, or a zero value if
5328 GCC should output the constant pool after the function.  If you do
5329 not define this macro, the usual case, GCC will output the constant
5330 pool before the function.
5331 @end defmac
5333 @defmac ASM_OUTPUT_POOL_PROLOGUE (@var{file}, @var{funname}, @var{fundecl}, @var{size})
5334 A C statement to output assembler commands to define the start of the
5335 constant pool for a function.  @var{funname} is a string giving
5336 the name of the function.  Should the return type of the function
5337 be required, it can be obtained via @var{fundecl}.  @var{size}
5338 is the size, in bytes, of the constant pool that will be written
5339 immediately after this call.
5341 If no constant-pool prefix is required, the usual case, this macro need
5342 not be defined.
5343 @end defmac
5345 @defmac ASM_OUTPUT_SPECIAL_POOL_ENTRY (@var{file}, @var{x}, @var{mode}, @var{align}, @var{labelno}, @var{jumpto})
5346 A C statement (with or without semicolon) to output a constant in the
5347 constant pool, if it needs special treatment.  (This macro need not do
5348 anything for RTL expressions that can be output normally.)
5350 The argument @var{file} is the standard I/O stream to output the
5351 assembler code on.  @var{x} is the RTL expression for the constant to
5352 output, and @var{mode} is the machine mode (in case @var{x} is a
5353 @samp{const_int}).  @var{align} is the required alignment for the value
5354 @var{x}; you should output an assembler directive to force this much
5355 alignment.
5357 The argument @var{labelno} is a number to use in an internal label for
5358 the address of this pool entry.  The definition of this macro is
5359 responsible for outputting the label definition at the proper place.
5360 Here is how to do this:
5362 @smallexample
5363 @code{(*targetm.asm_out.internal_label)} (@var{file}, "LC", @var{labelno});
5364 @end smallexample
5366 When you output a pool entry specially, you should end with a
5367 @code{goto} to the label @var{jumpto}.  This will prevent the same pool
5368 entry from being output a second time in the usual manner.
5370 You need not define this macro if it would do nothing.
5371 @end defmac
5373 @defmac ASM_OUTPUT_POOL_EPILOGUE (@var{file} @var{funname} @var{fundecl} @var{size})
5374 A C statement to output assembler commands to at the end of the constant
5375 pool for a function.  @var{funname} is a string giving the name of the
5376 function.  Should the return type of the function be required, you can
5377 obtain it via @var{fundecl}.  @var{size} is the size, in bytes, of the
5378 constant pool that GCC wrote immediately before this call.
5380 If no constant-pool epilogue is required, the usual case, you need not
5381 define this macro.
5382 @end defmac
5384 @defmac IS_ASM_LOGICAL_LINE_SEPARATOR (@var{C}, @var{STR})
5385 Define this macro as a C expression which is nonzero if @var{C} is
5386 used as a logical line separator by the assembler.  @var{STR} points
5387 to the position in the string where @var{C} was found; this can be used if
5388 a line separator uses multiple characters.
5390 If you do not define this macro, the default is that only
5391 the character @samp{;} is treated as a logical line separator.
5392 @end defmac
5394 @hook TARGET_ASM_OPEN_PAREN
5396 These macros are provided by @file{real.h} for writing the definitions
5397 of @code{ASM_OUTPUT_DOUBLE} and the like:
5399 @defmac REAL_VALUE_TO_TARGET_SINGLE (@var{x}, @var{l})
5400 @defmacx REAL_VALUE_TO_TARGET_DOUBLE (@var{x}, @var{l})
5401 @defmacx REAL_VALUE_TO_TARGET_LONG_DOUBLE (@var{x}, @var{l})
5402 @defmacx REAL_VALUE_TO_TARGET_DECIMAL32 (@var{x}, @var{l})
5403 @defmacx REAL_VALUE_TO_TARGET_DECIMAL64 (@var{x}, @var{l})
5404 @defmacx REAL_VALUE_TO_TARGET_DECIMAL128 (@var{x}, @var{l})
5405 These translate @var{x}, of type @code{REAL_VALUE_TYPE}, to the
5406 target's floating point representation, and store its bit pattern in
5407 the variable @var{l}.  For @code{REAL_VALUE_TO_TARGET_SINGLE} and
5408 @code{REAL_VALUE_TO_TARGET_DECIMAL32}, this variable should be a
5409 simple @code{long int}.  For the others, it should be an array of
5410 @code{long int}.  The number of elements in this array is determined
5411 by the size of the desired target floating point data type: 32 bits of
5412 it go in each @code{long int} array element.  Each array element holds
5413 32 bits of the result, even if @code{long int} is wider than 32 bits
5414 on the host machine.
5416 The array element values are designed so that you can print them out
5417 using @code{fprintf} in the order they should appear in the target
5418 machine's memory.
5419 @end defmac
5421 @node Uninitialized Data
5422 @subsection Output of Uninitialized Variables
5424 Each of the macros in this section is used to do the whole job of
5425 outputting a single uninitialized variable.
5427 @defmac ASM_OUTPUT_COMMON (@var{stream}, @var{name}, @var{size}, @var{rounded})
5428 A C statement (sans semicolon) to output to the stdio stream
5429 @var{stream} the assembler definition of a common-label named
5430 @var{name} whose size is @var{size} bytes.  The variable @var{rounded}
5431 is the size rounded up to whatever alignment the caller wants.  It is
5432 possible that @var{size} may be zero, for instance if a struct with no
5433 other member than a zero-length array is defined.  In this case, the
5434 backend must output a symbol definition that allocates at least one
5435 byte, both so that the address of the resulting object does not compare
5436 equal to any other, and because some object formats cannot even express
5437 the concept of a zero-sized common symbol, as that is how they represent
5438 an ordinary undefined external.
5440 Use the expression @code{assemble_name (@var{stream}, @var{name})} to
5441 output the name itself; before and after that, output the additional
5442 assembler syntax for defining the name, and a newline.
5444 This macro controls how the assembler definitions of uninitialized
5445 common global variables are output.
5446 @end defmac
5448 @defmac ASM_OUTPUT_ALIGNED_COMMON (@var{stream}, @var{name}, @var{size}, @var{alignment})
5449 Like @code{ASM_OUTPUT_COMMON} except takes the required alignment as a
5450 separate, explicit argument.  If you define this macro, it is used in
5451 place of @code{ASM_OUTPUT_COMMON}, and gives you more flexibility in
5452 handling the required alignment of the variable.  The alignment is specified
5453 as the number of bits.
5454 @end defmac
5456 @defmac ASM_OUTPUT_ALIGNED_DECL_COMMON (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
5457 Like @code{ASM_OUTPUT_ALIGNED_COMMON} except that @var{decl} of the
5458 variable to be output, if there is one, or @code{NULL_TREE} if there
5459 is no corresponding variable.  If you define this macro, GCC will use it
5460 in place of both @code{ASM_OUTPUT_COMMON} and
5461 @code{ASM_OUTPUT_ALIGNED_COMMON}.  Define this macro when you need to see
5462 the variable's decl in order to chose what to output.
5463 @end defmac
5465 @defmac ASM_OUTPUT_ALIGNED_BSS (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
5466 A C statement (sans semicolon) to output to the stdio stream
5467 @var{stream} the assembler definition of uninitialized global @var{decl} named
5468 @var{name} whose size is @var{size} bytes.  The variable @var{alignment}
5469 is the alignment specified as the number of bits.
5471 Try to use function @code{asm_output_aligned_bss} defined in file
5472 @file{varasm.c} when defining this macro.  If unable, use the expression
5473 @code{assemble_name (@var{stream}, @var{name})} to output the name itself;
5474 before and after that, output the additional assembler syntax for defining
5475 the name, and a newline.
5477 There are two ways of handling global BSS@.  One is to define this macro.
5478 The other is to have @code{TARGET_ASM_SELECT_SECTION} return a
5479 switchable BSS section (@pxref{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS}).
5480 You do not need to do both.
5482 Some languages do not have @code{common} data, and require a
5483 non-common form of global BSS in order to handle uninitialized globals
5484 efficiently.  C++ is one example of this.  However, if the target does
5485 not support global BSS, the front end may choose to make globals
5486 common in order to save space in the object file.
5487 @end defmac
5489 @defmac ASM_OUTPUT_LOCAL (@var{stream}, @var{name}, @var{size}, @var{rounded})
5490 A C statement (sans semicolon) to output to the stdio stream
5491 @var{stream} the assembler definition of a local-common-label named
5492 @var{name} whose size is @var{size} bytes.  The variable @var{rounded}
5493 is the size rounded up to whatever alignment the caller wants.
5495 Use the expression @code{assemble_name (@var{stream}, @var{name})} to
5496 output the name itself; before and after that, output the additional
5497 assembler syntax for defining the name, and a newline.
5499 This macro controls how the assembler definitions of uninitialized
5500 static variables are output.
5501 @end defmac
5503 @defmac ASM_OUTPUT_ALIGNED_LOCAL (@var{stream}, @var{name}, @var{size}, @var{alignment})
5504 Like @code{ASM_OUTPUT_LOCAL} except takes the required alignment as a
5505 separate, explicit argument.  If you define this macro, it is used in
5506 place of @code{ASM_OUTPUT_LOCAL}, and gives you more flexibility in
5507 handling the required alignment of the variable.  The alignment is specified
5508 as the number of bits.
5509 @end defmac
5511 @defmac ASM_OUTPUT_ALIGNED_DECL_LOCAL (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
5512 Like @code{ASM_OUTPUT_ALIGNED_DECL} except that @var{decl} of the
5513 variable to be output, if there is one, or @code{NULL_TREE} if there
5514 is no corresponding variable.  If you define this macro, GCC will use it
5515 in place of both @code{ASM_OUTPUT_DECL} and
5516 @code{ASM_OUTPUT_ALIGNED_DECL}.  Define this macro when you need to see
5517 the variable's decl in order to chose what to output.
5518 @end defmac
5520 @node Label Output
5521 @subsection Output and Generation of Labels
5523 @c prevent bad page break with this line
5524 This is about outputting labels.
5526 @findex assemble_name
5527 @defmac ASM_OUTPUT_LABEL (@var{stream}, @var{name})
5528 A C statement (sans semicolon) to output to the stdio stream
5529 @var{stream} the assembler definition of a label named @var{name}.
5530 Use the expression @code{assemble_name (@var{stream}, @var{name})} to
5531 output the name itself; before and after that, output the additional
5532 assembler syntax for defining the name, and a newline.  A default
5533 definition of this macro is provided which is correct for most systems.
5534 @end defmac
5536 @defmac ASM_OUTPUT_FUNCTION_LABEL (@var{stream}, @var{name}, @var{decl})
5537 A C statement (sans semicolon) to output to the stdio stream
5538 @var{stream} the assembler definition of a label named @var{name} of
5539 a function.
5540 Use the expression @code{assemble_name (@var{stream}, @var{name})} to
5541 output the name itself; before and after that, output the additional
5542 assembler syntax for defining the name, and a newline.  A default
5543 definition of this macro is provided which is correct for most systems.
5545 If this macro is not defined, then the function name is defined in the
5546 usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
5547 @end defmac
5549 @findex assemble_name_raw
5550 @defmac ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{name})
5551 Identical to @code{ASM_OUTPUT_LABEL}, except that @var{name} is known
5552 to refer to a compiler-generated label.  The default definition uses
5553 @code{assemble_name_raw}, which is like @code{assemble_name} except
5554 that it is more efficient.
5555 @end defmac
5557 @defmac SIZE_ASM_OP
5558 A C string containing the appropriate assembler directive to specify the
5559 size of a symbol, without any arguments.  On systems that use ELF, the
5560 default (in @file{config/elfos.h}) is @samp{"\t.size\t"}; on other
5561 systems, the default is not to define this macro.
5563 Define this macro only if it is correct to use the default definitions
5564 of @code{ASM_OUTPUT_SIZE_DIRECTIVE} and @code{ASM_OUTPUT_MEASURED_SIZE}
5565 for your system.  If you need your own custom definitions of those
5566 macros, or if you do not need explicit symbol sizes at all, do not
5567 define this macro.
5568 @end defmac
5570 @defmac ASM_OUTPUT_SIZE_DIRECTIVE (@var{stream}, @var{name}, @var{size})
5571 A C statement (sans semicolon) to output to the stdio stream
5572 @var{stream} a directive telling the assembler that the size of the
5573 symbol @var{name} is @var{size}.  @var{size} is a @code{HOST_WIDE_INT}.
5574 If you define @code{SIZE_ASM_OP}, a default definition of this macro is
5575 provided.
5576 @end defmac
5578 @defmac ASM_OUTPUT_MEASURED_SIZE (@var{stream}, @var{name})
5579 A C statement (sans semicolon) to output to the stdio stream
5580 @var{stream} a directive telling the assembler to calculate the size of
5581 the symbol @var{name} by subtracting its address from the current
5582 address.
5584 If you define @code{SIZE_ASM_OP}, a default definition of this macro is
5585 provided.  The default assumes that the assembler recognizes a special
5586 @samp{.} symbol as referring to the current address, and can calculate
5587 the difference between this and another symbol.  If your assembler does
5588 not recognize @samp{.} or cannot do calculations with it, you will need
5589 to redefine @code{ASM_OUTPUT_MEASURED_SIZE} to use some other technique.
5590 @end defmac
5592 @defmac NO_DOLLAR_IN_LABEL
5593 Define this macro if the assembler does not accept the character
5594 @samp{$} in label names.  By default constructors and destructors in
5595 G++ have @samp{$} in the identifiers.  If this macro is defined,
5596 @samp{.} is used instead.
5597 @end defmac
5599 @defmac NO_DOT_IN_LABEL
5600 Define this macro if the assembler does not accept the character
5601 @samp{.} in label names.  By default constructors and destructors in G++
5602 have names that use @samp{.}.  If this macro is defined, these names
5603 are rewritten to avoid @samp{.}.
5604 @end defmac
5606 @defmac TYPE_ASM_OP
5607 A C string containing the appropriate assembler directive to specify the
5608 type of a symbol, without any arguments.  On systems that use ELF, the
5609 default (in @file{config/elfos.h}) is @samp{"\t.type\t"}; on other
5610 systems, the default is not to define this macro.
5612 Define this macro only if it is correct to use the default definition of
5613 @code{ASM_OUTPUT_TYPE_DIRECTIVE} for your system.  If you need your own
5614 custom definition of this macro, or if you do not need explicit symbol
5615 types at all, do not define this macro.
5616 @end defmac
5618 @defmac TYPE_OPERAND_FMT
5619 A C string which specifies (using @code{printf} syntax) the format of
5620 the second operand to @code{TYPE_ASM_OP}.  On systems that use ELF, the
5621 default (in @file{config/elfos.h}) is @samp{"@@%s"}; on other systems,
5622 the default is not to define this macro.
5624 Define this macro only if it is correct to use the default definition of
5625 @code{ASM_OUTPUT_TYPE_DIRECTIVE} for your system.  If you need your own
5626 custom definition of this macro, or if you do not need explicit symbol
5627 types at all, do not define this macro.
5628 @end defmac
5630 @defmac ASM_OUTPUT_TYPE_DIRECTIVE (@var{stream}, @var{type})
5631 A C statement (sans semicolon) to output to the stdio stream
5632 @var{stream} a directive telling the assembler that the type of the
5633 symbol @var{name} is @var{type}.  @var{type} is a C string; currently,
5634 that string is always either @samp{"function"} or @samp{"object"}, but
5635 you should not count on this.
5637 If you define @code{TYPE_ASM_OP} and @code{TYPE_OPERAND_FMT}, a default
5638 definition of this macro is provided.
5639 @end defmac
5641 @defmac ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl})
5642 A C statement (sans semicolon) to output to the stdio stream
5643 @var{stream} any text necessary for declaring the name @var{name} of a
5644 function which is being defined.  This macro is responsible for
5645 outputting the label definition (perhaps using
5646 @code{ASM_OUTPUT_FUNCTION_LABEL}).  The argument @var{decl} is the
5647 @code{FUNCTION_DECL} tree node representing the function.
5649 If this macro is not defined, then the function name is defined in the
5650 usual manner as a label (by means of @code{ASM_OUTPUT_FUNCTION_LABEL}).
5652 You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
5653 of this macro.
5654 @end defmac
5656 @defmac ASM_DECLARE_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl})
5657 A C statement (sans semicolon) to output to the stdio stream
5658 @var{stream} any text necessary for declaring the size of a function
5659 which is being defined.  The argument @var{name} is the name of the
5660 function.  The argument @var{decl} is the @code{FUNCTION_DECL} tree node
5661 representing the function.
5663 If this macro is not defined, then the function size is not defined.
5665 You may wish to use @code{ASM_OUTPUT_MEASURED_SIZE} in the definition
5666 of this macro.
5667 @end defmac
5669 @defmac ASM_DECLARE_COLD_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl})
5670 A C statement (sans semicolon) to output to the stdio stream
5671 @var{stream} any text necessary for declaring the name @var{name} of a
5672 cold function partition which is being defined.  This macro is responsible
5673 for outputting the label definition (perhaps using
5674 @code{ASM_OUTPUT_FUNCTION_LABEL}).  The argument @var{decl} is the
5675 @code{FUNCTION_DECL} tree node representing the function.
5677 If this macro is not defined, then the cold partition name is defined in the
5678 usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
5680 You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
5681 of this macro.
5682 @end defmac
5684 @defmac ASM_DECLARE_COLD_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl})
5685 A C statement (sans semicolon) to output to the stdio stream
5686 @var{stream} any text necessary for declaring the size of a cold function
5687 partition which is being defined.  The argument @var{name} is the name of the
5688 cold partition of the function.  The argument @var{decl} is the
5689 @code{FUNCTION_DECL} tree node representing the function.
5691 If this macro is not defined, then the partition size is not defined.
5693 You may wish to use @code{ASM_OUTPUT_MEASURED_SIZE} in the definition
5694 of this macro.
5695 @end defmac
5697 @defmac ASM_DECLARE_OBJECT_NAME (@var{stream}, @var{name}, @var{decl})
5698 A C statement (sans semicolon) to output to the stdio stream
5699 @var{stream} any text necessary for declaring the name @var{name} of an
5700 initialized variable which is being defined.  This macro must output the
5701 label definition (perhaps using @code{ASM_OUTPUT_LABEL}).  The argument
5702 @var{decl} is the @code{VAR_DECL} tree node representing the variable.
5704 If this macro is not defined, then the variable name is defined in the
5705 usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
5707 You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} and/or
5708 @code{ASM_OUTPUT_SIZE_DIRECTIVE} in the definition of this macro.
5709 @end defmac
5711 @hook TARGET_ASM_DECLARE_CONSTANT_NAME
5713 @defmac ASM_DECLARE_REGISTER_GLOBAL (@var{stream}, @var{decl}, @var{regno}, @var{name})
5714 A C statement (sans semicolon) to output to the stdio stream
5715 @var{stream} any text necessary for claiming a register @var{regno}
5716 for a global variable @var{decl} with name @var{name}.
5718 If you don't define this macro, that is equivalent to defining it to do
5719 nothing.
5720 @end defmac
5722 @defmac ASM_FINISH_DECLARE_OBJECT (@var{stream}, @var{decl}, @var{toplevel}, @var{atend})
5723 A C statement (sans semicolon) to finish up declaring a variable name
5724 once the compiler has processed its initializer fully and thus has had a
5725 chance to determine the size of an array when controlled by an
5726 initializer.  This is used on systems where it's necessary to declare
5727 something about the size of the object.
5729 If you don't define this macro, that is equivalent to defining it to do
5730 nothing.
5732 You may wish to use @code{ASM_OUTPUT_SIZE_DIRECTIVE} and/or
5733 @code{ASM_OUTPUT_MEASURED_SIZE} in the definition of this macro.
5734 @end defmac
5736 @hook TARGET_ASM_GLOBALIZE_LABEL
5738 @hook TARGET_ASM_GLOBALIZE_DECL_NAME
5740 @hook TARGET_ASM_ASSEMBLE_UNDEFINED_DECL
5742 @defmac ASM_WEAKEN_LABEL (@var{stream}, @var{name})
5743 A C statement (sans semicolon) to output to the stdio stream
5744 @var{stream} some commands that will make the label @var{name} weak;
5745 that is, available for reference from other files but only used if
5746 no other definition is available.  Use the expression
5747 @code{assemble_name (@var{stream}, @var{name})} to output the name
5748 itself; before and after that, output the additional assembler syntax
5749 for making that name weak, and a newline.
5751 If you don't define this macro or @code{ASM_WEAKEN_DECL}, GCC will not
5752 support weak symbols and you should not define the @code{SUPPORTS_WEAK}
5753 macro.
5754 @end defmac
5756 @defmac ASM_WEAKEN_DECL (@var{stream}, @var{decl}, @var{name}, @var{value})
5757 Combines (and replaces) the function of @code{ASM_WEAKEN_LABEL} and
5758 @code{ASM_OUTPUT_WEAK_ALIAS}, allowing access to the associated function
5759 or variable decl.  If @var{value} is not @code{NULL}, this C statement
5760 should output to the stdio stream @var{stream} assembler code which
5761 defines (equates) the weak symbol @var{name} to have the value
5762 @var{value}.  If @var{value} is @code{NULL}, it should output commands
5763 to make @var{name} weak.
5764 @end defmac
5766 @defmac ASM_OUTPUT_WEAKREF (@var{stream}, @var{decl}, @var{name}, @var{value})
5767 Outputs a directive that enables @var{name} to be used to refer to
5768 symbol @var{value} with weak-symbol semantics.  @code{decl} is the
5769 declaration of @code{name}.
5770 @end defmac
5772 @defmac SUPPORTS_WEAK
5773 A preprocessor constant expression which evaluates to true if the target
5774 supports weak symbols.
5776 If you don't define this macro, @file{defaults.h} provides a default
5777 definition.  If either @code{ASM_WEAKEN_LABEL} or @code{ASM_WEAKEN_DECL}
5778 is defined, the default definition is @samp{1}; otherwise, it is @samp{0}.
5779 @end defmac
5781 @defmac TARGET_SUPPORTS_WEAK
5782 A C expression which evaluates to true if the target supports weak symbols.
5784 If you don't define this macro, @file{defaults.h} provides a default
5785 definition.  The default definition is @samp{(SUPPORTS_WEAK)}.  Define
5786 this macro if you want to control weak symbol support with a compiler
5787 flag such as @option{-melf}.
5788 @end defmac
5790 @defmac MAKE_DECL_ONE_ONLY (@var{decl})
5791 A C statement (sans semicolon) to mark @var{decl} to be emitted as a
5792 public symbol such that extra copies in multiple translation units will
5793 be discarded by the linker.  Define this macro if your object file
5794 format provides support for this concept, such as the @samp{COMDAT}
5795 section flags in the Microsoft Windows PE/COFF format, and this support
5796 requires changes to @var{decl}, such as putting it in a separate section.
5797 @end defmac
5799 @defmac SUPPORTS_ONE_ONLY
5800 A C expression which evaluates to true if the target supports one-only
5801 semantics.
5803 If you don't define this macro, @file{varasm.c} provides a default
5804 definition.  If @code{MAKE_DECL_ONE_ONLY} is defined, the default
5805 definition is @samp{1}; otherwise, it is @samp{0}.  Define this macro if
5806 you want to control one-only symbol support with a compiler flag, or if
5807 setting the @code{DECL_ONE_ONLY} flag is enough to mark a declaration to
5808 be emitted as one-only.
5809 @end defmac
5811 @hook TARGET_ASM_ASSEMBLE_VISIBILITY
5813 @defmac TARGET_WEAK_NOT_IN_ARCHIVE_TOC
5814 A C expression that evaluates to true if the target's linker expects
5815 that weak symbols do not appear in a static archive's table of contents.
5816 The default is @code{0}.
5818 Leaving weak symbols out of an archive's table of contents means that,
5819 if a symbol will only have a definition in one translation unit and
5820 will have undefined references from other translation units, that
5821 symbol should not be weak.  Defining this macro to be nonzero will
5822 thus have the effect that certain symbols that would normally be weak
5823 (explicit template instantiations, and vtables for polymorphic classes
5824 with noninline key methods) will instead be nonweak.
5826 The C++ ABI requires this macro to be zero.  Define this macro for
5827 targets where full C++ ABI compliance is impossible and where linker
5828 restrictions require weak symbols to be left out of a static archive's
5829 table of contents.
5830 @end defmac
5832 @defmac ASM_OUTPUT_EXTERNAL (@var{stream}, @var{decl}, @var{name})
5833 A C statement (sans semicolon) to output to the stdio stream
5834 @var{stream} any text necessary for declaring the name of an external
5835 symbol named @var{name} which is referenced in this compilation but
5836 not defined.  The value of @var{decl} is the tree node for the
5837 declaration.
5839 This macro need not be defined if it does not need to output anything.
5840 The GNU assembler and most Unix assemblers don't require anything.
5841 @end defmac
5843 @hook TARGET_ASM_EXTERNAL_LIBCALL
5845 @hook TARGET_ASM_MARK_DECL_PRESERVED
5847 @defmac ASM_OUTPUT_LABELREF (@var{stream}, @var{name})
5848 A C statement (sans semicolon) to output to the stdio stream
5849 @var{stream} a reference in assembler syntax to a label named
5850 @var{name}.  This should add @samp{_} to the front of the name, if that
5851 is customary on your operating system, as it is in most Berkeley Unix
5852 systems.  This macro is used in @code{assemble_name}.
5853 @end defmac
5855 @hook TARGET_MANGLE_ASSEMBLER_NAME
5857 @defmac ASM_OUTPUT_SYMBOL_REF (@var{stream}, @var{sym})
5858 A C statement (sans semicolon) to output a reference to
5859 @code{SYMBOL_REF} @var{sym}.  If not defined, @code{assemble_name}
5860 will be used to output the name of the symbol.  This macro may be used
5861 to modify the way a symbol is referenced depending on information
5862 encoded by @code{TARGET_ENCODE_SECTION_INFO}.
5863 @end defmac
5865 @defmac ASM_OUTPUT_LABEL_REF (@var{stream}, @var{buf})
5866 A C statement (sans semicolon) to output a reference to @var{buf}, the
5867 result of @code{ASM_GENERATE_INTERNAL_LABEL}.  If not defined,
5868 @code{assemble_name} will be used to output the name of the symbol.
5869 This macro is not used by @code{output_asm_label}, or the @code{%l}
5870 specifier that calls it; the intention is that this macro should be set
5871 when it is necessary to output a label differently when its address is
5872 being taken.
5873 @end defmac
5875 @hook TARGET_ASM_INTERNAL_LABEL
5877 @defmac ASM_OUTPUT_DEBUG_LABEL (@var{stream}, @var{prefix}, @var{num})
5878 A C statement to output to the stdio stream @var{stream} a debug info
5879 label whose name is made from the string @var{prefix} and the number
5880 @var{num}.  This is useful for VLIW targets, where debug info labels
5881 may need to be treated differently than branch target labels.  On some
5882 systems, branch target labels must be at the beginning of instruction
5883 bundles, but debug info labels can occur in the middle of instruction
5884 bundles.
5886 If this macro is not defined, then @code{(*targetm.asm_out.internal_label)} will be
5887 used.
5888 @end defmac
5890 @defmac ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num})
5891 A C statement to store into the string @var{string} a label whose name
5892 is made from the string @var{prefix} and the number @var{num}.
5894 This string, when output subsequently by @code{assemble_name}, should
5895 produce the output that @code{(*targetm.asm_out.internal_label)} would produce
5896 with the same @var{prefix} and @var{num}.
5898 If the string begins with @samp{*}, then @code{assemble_name} will
5899 output the rest of the string unchanged.  It is often convenient for
5900 @code{ASM_GENERATE_INTERNAL_LABEL} to use @samp{*} in this way.  If the
5901 string doesn't start with @samp{*}, then @code{ASM_OUTPUT_LABELREF} gets
5902 to output the string, and may change it.  (Of course,
5903 @code{ASM_OUTPUT_LABELREF} is also part of your machine description, so
5904 you should know what it does on your machine.)
5905 @end defmac
5907 @defmac ASM_FORMAT_PRIVATE_NAME (@var{outvar}, @var{name}, @var{number})
5908 A C expression to assign to @var{outvar} (which is a variable of type
5909 @code{char *}) a newly allocated string made from the string
5910 @var{name} and the number @var{number}, with some suitable punctuation
5911 added.  Use @code{alloca} to get space for the string.
5913 The string will be used as an argument to @code{ASM_OUTPUT_LABELREF} to
5914 produce an assembler label for an internal static variable whose name is
5915 @var{name}.  Therefore, the string must be such as to result in valid
5916 assembler code.  The argument @var{number} is different each time this
5917 macro is executed; it prevents conflicts between similarly-named
5918 internal static variables in different scopes.
5920 Ideally this string should not be a valid C identifier, to prevent any
5921 conflict with the user's own symbols.  Most assemblers allow periods
5922 or percent signs in assembler symbols; putting at least one of these
5923 between the name and the number will suffice.
5925 If this macro is not defined, a default definition will be provided
5926 which is correct for most systems.
5927 @end defmac
5929 @defmac ASM_OUTPUT_DEF (@var{stream}, @var{name}, @var{value})
5930 A C statement to output to the stdio stream @var{stream} assembler code
5931 which defines (equates) the symbol @var{name} to have the value @var{value}.
5933 @findex SET_ASM_OP
5934 If @code{SET_ASM_OP} is defined, a default definition is provided which is
5935 correct for most systems.
5936 @end defmac
5938 @defmac ASM_OUTPUT_DEF_FROM_DECLS (@var{stream}, @var{decl_of_name}, @var{decl_of_value})
5939 A C statement to output to the stdio stream @var{stream} assembler code
5940 which defines (equates) the symbol whose tree node is @var{decl_of_name}
5941 to have the value of the tree node @var{decl_of_value}.  This macro will
5942 be used in preference to @samp{ASM_OUTPUT_DEF} if it is defined and if
5943 the tree nodes are available.
5945 @findex SET_ASM_OP
5946 If @code{SET_ASM_OP} is defined, a default definition is provided which is
5947 correct for most systems.
5948 @end defmac
5950 @defmac TARGET_DEFERRED_OUTPUT_DEFS (@var{decl_of_name}, @var{decl_of_value})
5951 A C statement that evaluates to true if the assembler code which defines
5952 (equates) the symbol whose tree node is @var{decl_of_name} to have the value
5953 of the tree node @var{decl_of_value} should be emitted near the end of the
5954 current compilation unit.  The default is to not defer output of defines.
5955 This macro affects defines output by @samp{ASM_OUTPUT_DEF} and
5956 @samp{ASM_OUTPUT_DEF_FROM_DECLS}.
5957 @end defmac
5959 @defmac ASM_OUTPUT_WEAK_ALIAS (@var{stream}, @var{name}, @var{value})
5960 A C statement to output to the stdio stream @var{stream} assembler code
5961 which defines (equates) the weak symbol @var{name} to have the value
5962 @var{value}.  If @var{value} is @code{NULL}, it defines @var{name} as
5963 an undefined weak symbol.
5965 Define this macro if the target only supports weak aliases; define
5966 @code{ASM_OUTPUT_DEF} instead if possible.
5967 @end defmac
5969 @defmac OBJC_GEN_METHOD_LABEL (@var{buf}, @var{is_inst}, @var{class_name}, @var{cat_name}, @var{sel_name})
5970 Define this macro to override the default assembler names used for
5971 Objective-C methods.
5973 The default name is a unique method number followed by the name of the
5974 class (e.g.@: @samp{_1_Foo}).  For methods in categories, the name of
5975 the category is also included in the assembler name (e.g.@:
5976 @samp{_1_Foo_Bar}).
5978 These names are safe on most systems, but make debugging difficult since
5979 the method's selector is not present in the name.  Therefore, particular
5980 systems define other ways of computing names.
5982 @var{buf} is an expression of type @code{char *} which gives you a
5983 buffer in which to store the name; its length is as long as
5984 @var{class_name}, @var{cat_name} and @var{sel_name} put together, plus
5985 50 characters extra.
5987 The argument @var{is_inst} specifies whether the method is an instance
5988 method or a class method; @var{class_name} is the name of the class;
5989 @var{cat_name} is the name of the category (or @code{NULL} if the method is not
5990 in a category); and @var{sel_name} is the name of the selector.
5992 On systems where the assembler can handle quoted names, you can use this
5993 macro to provide more human-readable names.
5994 @end defmac
5996 @node Initialization
5997 @subsection How Initialization Functions Are Handled
5998 @cindex initialization routines
5999 @cindex termination routines
6000 @cindex constructors, output of
6001 @cindex destructors, output of
6003 The compiled code for certain languages includes @dfn{constructors}
6004 (also called @dfn{initialization routines})---functions to initialize
6005 data in the program when the program is started.  These functions need
6006 to be called before the program is ``started''---that is to say, before
6007 @code{main} is called.
6009 Compiling some languages generates @dfn{destructors} (also called
6010 @dfn{termination routines}) that should be called when the program
6011 terminates.
6013 To make the initialization and termination functions work, the compiler
6014 must output something in the assembler code to cause those functions to
6015 be called at the appropriate time.  When you port the compiler to a new
6016 system, you need to specify how to do this.
6018 There are two major ways that GCC currently supports the execution of
6019 initialization and termination functions.  Each way has two variants.
6020 Much of the structure is common to all four variations.
6022 @findex __CTOR_LIST__
6023 @findex __DTOR_LIST__
6024 The linker must build two lists of these functions---a list of
6025 initialization functions, called @code{__CTOR_LIST__}, and a list of
6026 termination functions, called @code{__DTOR_LIST__}.
6028 Each list always begins with an ignored function pointer (which may hold
6029 0, @minus{}1, or a count of the function pointers after it, depending on
6030 the environment).  This is followed by a series of zero or more function
6031 pointers to constructors (or destructors), followed by a function
6032 pointer containing zero.
6034 Depending on the operating system and its executable file format, either
6035 @file{crtstuff.c} or @file{libgcc2.c} traverses these lists at startup
6036 time and exit time.  Constructors are called in reverse order of the
6037 list; destructors in forward order.
6039 The best way to handle static constructors works only for object file
6040 formats which provide arbitrarily-named sections.  A section is set
6041 aside for a list of constructors, and another for a list of destructors.
6042 Traditionally these are called @samp{.ctors} and @samp{.dtors}.  Each
6043 object file that defines an initialization function also puts a word in
6044 the constructor section to point to that function.  The linker
6045 accumulates all these words into one contiguous @samp{.ctors} section.
6046 Termination functions are handled similarly.
6048 This method will be chosen as the default by @file{target-def.h} if
6049 @code{TARGET_ASM_NAMED_SECTION} is defined.  A target that does not
6050 support arbitrary sections, but does support special designated
6051 constructor and destructor sections may define @code{CTORS_SECTION_ASM_OP}
6052 and @code{DTORS_SECTION_ASM_OP} to achieve the same effect.
6054 When arbitrary sections are available, there are two variants, depending
6055 upon how the code in @file{crtstuff.c} is called.  On systems that
6056 support a @dfn{.init} section which is executed at program startup,
6057 parts of @file{crtstuff.c} are compiled into that section.  The
6058 program is linked by the @command{gcc} driver like this:
6060 @smallexample
6061 ld -o @var{output_file} crti.o crtbegin.o @dots{} -lgcc crtend.o crtn.o
6062 @end smallexample
6064 The prologue of a function (@code{__init}) appears in the @code{.init}
6065 section of @file{crti.o}; the epilogue appears in @file{crtn.o}.  Likewise
6066 for the function @code{__fini} in the @dfn{.fini} section.  Normally these
6067 files are provided by the operating system or by the GNU C library, but
6068 are provided by GCC for a few targets.
6070 The objects @file{crtbegin.o} and @file{crtend.o} are (for most targets)
6071 compiled from @file{crtstuff.c}.  They contain, among other things, code
6072 fragments within the @code{.init} and @code{.fini} sections that branch
6073 to routines in the @code{.text} section.  The linker will pull all parts
6074 of a section together, which results in a complete @code{__init} function
6075 that invokes the routines we need at startup.
6077 To use this variant, you must define the @code{INIT_SECTION_ASM_OP}
6078 macro properly.
6080 If no init section is available, when GCC compiles any function called
6081 @code{main} (or more accurately, any function designated as a program
6082 entry point by the language front end calling @code{expand_main_function}),
6083 it inserts a procedure call to @code{__main} as the first executable code
6084 after the function prologue.  The @code{__main} function is defined
6085 in @file{libgcc2.c} and runs the global constructors.
6087 In file formats that don't support arbitrary sections, there are again
6088 two variants.  In the simplest variant, the GNU linker (GNU @code{ld})
6089 and an `a.out' format must be used.  In this case,
6090 @code{TARGET_ASM_CONSTRUCTOR} is defined to produce a @code{.stabs}
6091 entry of type @samp{N_SETT}, referencing the name @code{__CTOR_LIST__},
6092 and with the address of the void function containing the initialization
6093 code as its value.  The GNU linker recognizes this as a request to add
6094 the value to a @dfn{set}; the values are accumulated, and are eventually
6095 placed in the executable as a vector in the format described above, with
6096 a leading (ignored) count and a trailing zero element.
6097 @code{TARGET_ASM_DESTRUCTOR} is handled similarly.  Since no init
6098 section is available, the absence of @code{INIT_SECTION_ASM_OP} causes
6099 the compilation of @code{main} to call @code{__main} as above, starting
6100 the initialization process.
6102 The last variant uses neither arbitrary sections nor the GNU linker.
6103 This is preferable when you want to do dynamic linking and when using
6104 file formats which the GNU linker does not support, such as `ECOFF'@.  In
6105 this case, @code{TARGET_HAVE_CTORS_DTORS} is false, initialization and
6106 termination functions are recognized simply by their names.  This requires
6107 an extra program in the linkage step, called @command{collect2}.  This program
6108 pretends to be the linker, for use with GCC; it does its job by running
6109 the ordinary linker, but also arranges to include the vectors of
6110 initialization and termination functions.  These functions are called
6111 via @code{__main} as described above.  In order to use this method,
6112 @code{use_collect2} must be defined in the target in @file{config.gcc}.
6114 @ifinfo
6115 The following section describes the specific macros that control and
6116 customize the handling of initialization and termination functions.
6117 @end ifinfo
6119 @node Macros for Initialization
6120 @subsection Macros Controlling Initialization Routines
6122 Here are the macros that control how the compiler handles initialization
6123 and termination functions:
6125 @defmac INIT_SECTION_ASM_OP
6126 If defined, a C string constant, including spacing, for the assembler
6127 operation to identify the following data as initialization code.  If not
6128 defined, GCC will assume such a section does not exist.  When you are
6129 using special sections for initialization and termination functions, this
6130 macro also controls how @file{crtstuff.c} and @file{libgcc2.c} arrange to
6131 run the initialization functions.
6132 @end defmac
6134 @defmac HAS_INIT_SECTION
6135 If defined, @code{main} will not call @code{__main} as described above.
6136 This macro should be defined for systems that control start-up code
6137 on a symbol-by-symbol basis, such as OSF/1, and should not
6138 be defined explicitly for systems that support @code{INIT_SECTION_ASM_OP}.
6139 @end defmac
6141 @defmac LD_INIT_SWITCH
6142 If defined, a C string constant for a switch that tells the linker that
6143 the following symbol is an initialization routine.
6144 @end defmac
6146 @defmac LD_FINI_SWITCH
6147 If defined, a C string constant for a switch that tells the linker that
6148 the following symbol is a finalization routine.
6149 @end defmac
6151 @defmac COLLECT_SHARED_INIT_FUNC (@var{stream}, @var{func})
6152 If defined, a C statement that will write a function that can be
6153 automatically called when a shared library is loaded.  The function
6154 should call @var{func}, which takes no arguments.  If not defined, and
6155 the object format requires an explicit initialization function, then a
6156 function called @code{_GLOBAL__DI} will be generated.
6158 This function and the following one are used by collect2 when linking a
6159 shared library that needs constructors or destructors, or has DWARF2
6160 exception tables embedded in the code.
6161 @end defmac
6163 @defmac COLLECT_SHARED_FINI_FUNC (@var{stream}, @var{func})
6164 If defined, a C statement that will write a function that can be
6165 automatically called when a shared library is unloaded.  The function
6166 should call @var{func}, which takes no arguments.  If not defined, and
6167 the object format requires an explicit finalization function, then a
6168 function called @code{_GLOBAL__DD} will be generated.
6169 @end defmac
6171 @defmac INVOKE__main
6172 If defined, @code{main} will call @code{__main} despite the presence of
6173 @code{INIT_SECTION_ASM_OP}.  This macro should be defined for systems
6174 where the init section is not actually run automatically, but is still
6175 useful for collecting the lists of constructors and destructors.
6176 @end defmac
6178 @defmac SUPPORTS_INIT_PRIORITY
6179 If nonzero, the C++ @code{init_priority} attribute is supported and the
6180 compiler should emit instructions to control the order of initialization
6181 of objects.  If zero, the compiler will issue an error message upon
6182 encountering an @code{init_priority} attribute.
6183 @end defmac
6185 @hook TARGET_HAVE_CTORS_DTORS
6187 @hook TARGET_ASM_CONSTRUCTOR
6189 @hook TARGET_ASM_DESTRUCTOR
6191 If @code{TARGET_HAVE_CTORS_DTORS} is true, the initialization routine
6192 generated for the generated object file will have static linkage.
6194 If your system uses @command{collect2} as the means of processing
6195 constructors, then that program normally uses @command{nm} to scan
6196 an object file for constructor functions to be called.
6198 On certain kinds of systems, you can define this macro to make
6199 @command{collect2} work faster (and, in some cases, make it work at all):
6201 @defmac OBJECT_FORMAT_COFF
6202 Define this macro if the system uses COFF (Common Object File Format)
6203 object files, so that @command{collect2} can assume this format and scan
6204 object files directly for dynamic constructor/destructor functions.
6206 This macro is effective only in a native compiler; @command{collect2} as
6207 part of a cross compiler always uses @command{nm} for the target machine.
6208 @end defmac
6210 @defmac REAL_NM_FILE_NAME
6211 Define this macro as a C string constant containing the file name to use
6212 to execute @command{nm}.  The default is to search the path normally for
6213 @command{nm}.
6214 @end defmac
6216 @defmac NM_FLAGS
6217 @command{collect2} calls @command{nm} to scan object files for static
6218 constructors and destructors and LTO info.  By default, @option{-n} is
6219 passed.  Define @code{NM_FLAGS} to a C string constant if other options
6220 are needed to get the same output format as GNU @command{nm -n}
6221 produces.
6222 @end defmac
6224 If your system supports shared libraries and has a program to list the
6225 dynamic dependencies of a given library or executable, you can define
6226 these macros to enable support for running initialization and
6227 termination functions in shared libraries:
6229 @defmac LDD_SUFFIX
6230 Define this macro to a C string constant containing the name of the program
6231 which lists dynamic dependencies, like @command{ldd} under SunOS 4.
6232 @end defmac
6234 @defmac PARSE_LDD_OUTPUT (@var{ptr})
6235 Define this macro to be C code that extracts filenames from the output
6236 of the program denoted by @code{LDD_SUFFIX}.  @var{ptr} is a variable
6237 of type @code{char *} that points to the beginning of a line of output
6238 from @code{LDD_SUFFIX}.  If the line lists a dynamic dependency, the
6239 code must advance @var{ptr} to the beginning of the filename on that
6240 line.  Otherwise, it must set @var{ptr} to @code{NULL}.
6241 @end defmac
6243 @defmac SHLIB_SUFFIX
6244 Define this macro to a C string constant containing the default shared
6245 library extension of the target (e.g., @samp{".so"}).  @command{collect2}
6246 strips version information after this suffix when generating global
6247 constructor and destructor names.  This define is only needed on targets
6248 that use @command{collect2} to process constructors and destructors.
6249 @end defmac
6251 @node Instruction Output
6252 @subsection Output of Assembler Instructions
6254 @c prevent bad page break with this line
6255 This describes assembler instruction output.
6257 @defmac REGISTER_NAMES
6258 A C initializer containing the assembler's names for the machine
6259 registers, each one as a C string constant.  This is what translates
6260 register numbers in the compiler into assembler language.
6261 @end defmac
6263 @defmac ADDITIONAL_REGISTER_NAMES
6264 If defined, a C initializer for an array of structures containing a name
6265 and a register number.  This macro defines additional names for hard
6266 registers, thus allowing the @code{asm} option in declarations to refer
6267 to registers using alternate names.
6268 @end defmac
6270 @defmac OVERLAPPING_REGISTER_NAMES
6271 If defined, a C initializer for an array of structures containing a
6272 name, a register number and a count of the number of consecutive
6273 machine registers the name overlaps.  This macro defines additional
6274 names for hard registers, thus allowing the @code{asm} option in
6275 declarations to refer to registers using alternate names.  Unlike
6276 @code{ADDITIONAL_REGISTER_NAMES}, this macro should be used when the
6277 register name implies multiple underlying registers.
6279 This macro should be used when it is important that a clobber in an
6280 @code{asm} statement clobbers all the underlying values implied by the
6281 register name.  For example, on ARM, clobbering the double-precision
6282 VFP register ``d0'' implies clobbering both single-precision registers
6283 ``s0'' and ``s1''.
6284 @end defmac
6286 @defmac ASM_OUTPUT_OPCODE (@var{stream}, @var{ptr})
6287 Define this macro if you are using an unusual assembler that
6288 requires different names for the machine instructions.
6290 The definition is a C statement or statements which output an
6291 assembler instruction opcode to the stdio stream @var{stream}.  The
6292 macro-operand @var{ptr} is a variable of type @code{char *} which
6293 points to the opcode name in its ``internal'' form---the form that is
6294 written in the machine description.  The definition should output the
6295 opcode name to @var{stream}, performing any translation you desire, and
6296 increment the variable @var{ptr} to point at the end of the opcode
6297 so that it will not be output twice.
6299 In fact, your macro definition may process less than the entire opcode
6300 name, or more than the opcode name; but if you want to process text
6301 that includes @samp{%}-sequences to substitute operands, you must take
6302 care of the substitution yourself.  Just be sure to increment
6303 @var{ptr} over whatever text should not be output normally.
6305 @findex recog_data.operand
6306 If you need to look at the operand values, they can be found as the
6307 elements of @code{recog_data.operand}.
6309 If the macro definition does nothing, the instruction is output
6310 in the usual way.
6311 @end defmac
6313 @defmac FINAL_PRESCAN_INSN (@var{insn}, @var{opvec}, @var{noperands})
6314 If defined, a C statement to be executed just prior to the output of
6315 assembler code for @var{insn}, to modify the extracted operands so
6316 they will be output differently.
6318 Here the argument @var{opvec} is the vector containing the operands
6319 extracted from @var{insn}, and @var{noperands} is the number of
6320 elements of the vector which contain meaningful data for this insn.
6321 The contents of this vector are what will be used to convert the insn
6322 template into assembler code, so you can change the assembler output
6323 by changing the contents of the vector.
6325 This macro is useful when various assembler syntaxes share a single
6326 file of instruction patterns; by defining this macro differently, you
6327 can cause a large class of instructions to be output differently (such
6328 as with rearranged operands).  Naturally, variations in assembler
6329 syntax affecting individual insn patterns ought to be handled by
6330 writing conditional output routines in those patterns.
6332 If this macro is not defined, it is equivalent to a null statement.
6333 @end defmac
6335 @hook TARGET_ASM_FINAL_POSTSCAN_INSN
6337 @defmac PRINT_OPERAND (@var{stream}, @var{x}, @var{code})
6338 A C compound statement to output to stdio stream @var{stream} the
6339 assembler syntax for an instruction operand @var{x}.  @var{x} is an
6340 RTL expression.
6342 @var{code} is a value that can be used to specify one of several ways
6343 of printing the operand.  It is used when identical operands must be
6344 printed differently depending on the context.  @var{code} comes from
6345 the @samp{%} specification that was used to request printing of the
6346 operand.  If the specification was just @samp{%@var{digit}} then
6347 @var{code} is 0; if the specification was @samp{%@var{ltr}
6348 @var{digit}} then @var{code} is the ASCII code for @var{ltr}.
6350 @findex reg_names
6351 If @var{x} is a register, this macro should print the register's name.
6352 The names can be found in an array @code{reg_names} whose type is
6353 @code{char *[]}.  @code{reg_names} is initialized from
6354 @code{REGISTER_NAMES}.
6356 When the machine description has a specification @samp{%@var{punct}}
6357 (a @samp{%} followed by a punctuation character), this macro is called
6358 with a null pointer for @var{x} and the punctuation character for
6359 @var{code}.
6360 @end defmac
6362 @defmac PRINT_OPERAND_PUNCT_VALID_P (@var{code})
6363 A C expression which evaluates to true if @var{code} is a valid
6364 punctuation character for use in the @code{PRINT_OPERAND} macro.  If
6365 @code{PRINT_OPERAND_PUNCT_VALID_P} is not defined, it means that no
6366 punctuation characters (except for the standard one, @samp{%}) are used
6367 in this way.
6368 @end defmac
6370 @defmac PRINT_OPERAND_ADDRESS (@var{stream}, @var{x})
6371 A C compound statement to output to stdio stream @var{stream} the
6372 assembler syntax for an instruction operand that is a memory reference
6373 whose address is @var{x}.  @var{x} is an RTL expression.
6375 @cindex @code{TARGET_ENCODE_SECTION_INFO} usage
6376 On some machines, the syntax for a symbolic address depends on the
6377 section that the address refers to.  On these machines, define the hook
6378 @code{TARGET_ENCODE_SECTION_INFO} to store the information into the
6379 @code{symbol_ref}, and then check for it here.  @xref{Assembler
6380 Format}.
6381 @end defmac
6383 @findex dbr_sequence_length
6384 @defmac DBR_OUTPUT_SEQEND (@var{file})
6385 A C statement, to be executed after all slot-filler instructions have
6386 been output.  If necessary, call @code{dbr_sequence_length} to
6387 determine the number of slots filled in a sequence (zero if not
6388 currently outputting a sequence), to decide how many no-ops to output,
6389 or whatever.
6391 Don't define this macro if it has nothing to do, but it is helpful in
6392 reading assembly output if the extent of the delay sequence is made
6393 explicit (e.g.@: with white space).
6394 @end defmac
6396 @findex final_sequence
6397 Note that output routines for instructions with delay slots must be
6398 prepared to deal with not being output as part of a sequence
6399 (i.e.@: when the scheduling pass is not run, or when no slot fillers could be
6400 found.)  The variable @code{final_sequence} is null when not
6401 processing a sequence, otherwise it contains the @code{sequence} rtx
6402 being output.
6404 @findex asm_fprintf
6405 @defmac REGISTER_PREFIX
6406 @defmacx LOCAL_LABEL_PREFIX
6407 @defmacx USER_LABEL_PREFIX
6408 @defmacx IMMEDIATE_PREFIX
6409 If defined, C string expressions to be used for the @samp{%R}, @samp{%L},
6410 @samp{%U}, and @samp{%I} options of @code{asm_fprintf} (see
6411 @file{final.c}).  These are useful when a single @file{md} file must
6412 support multiple assembler formats.  In that case, the various @file{tm.h}
6413 files can define these macros differently.
6414 @end defmac
6416 @defmac ASM_FPRINTF_EXTENSIONS (@var{file}, @var{argptr}, @var{format})
6417 If defined this macro should expand to a series of @code{case}
6418 statements which will be parsed inside the @code{switch} statement of
6419 the @code{asm_fprintf} function.  This allows targets to define extra
6420 printf formats which may useful when generating their assembler
6421 statements.  Note that uppercase letters are reserved for future
6422 generic extensions to asm_fprintf, and so are not available to target
6423 specific code.  The output file is given by the parameter @var{file}.
6424 The varargs input pointer is @var{argptr} and the rest of the format
6425 string, starting the character after the one that is being switched
6426 upon, is pointed to by @var{format}.
6427 @end defmac
6429 @defmac ASSEMBLER_DIALECT
6430 If your target supports multiple dialects of assembler language (such as
6431 different opcodes), define this macro as a C expression that gives the
6432 numeric index of the assembler language dialect to use, with zero as the
6433 first variant.
6435 If this macro is defined, you may use constructs of the form
6436 @smallexample
6437 @samp{@{option0|option1|option2@dots{}@}}
6438 @end smallexample
6439 @noindent
6440 in the output templates of patterns (@pxref{Output Template}) or in the
6441 first argument of @code{asm_fprintf}.  This construct outputs
6442 @samp{option0}, @samp{option1}, @samp{option2}, etc., if the value of
6443 @code{ASSEMBLER_DIALECT} is zero, one, two, etc.  Any special characters
6444 within these strings retain their usual meaning.  If there are fewer
6445 alternatives within the braces than the value of
6446 @code{ASSEMBLER_DIALECT}, the construct outputs nothing. If it's needed
6447 to print curly braces or @samp{|} character in assembler output directly,
6448 @samp{%@{}, @samp{%@}} and @samp{%|} can be used.
6450 If you do not define this macro, the characters @samp{@{}, @samp{|} and
6451 @samp{@}} do not have any special meaning when used in templates or
6452 operands to @code{asm_fprintf}.
6454 Define the macros @code{REGISTER_PREFIX}, @code{LOCAL_LABEL_PREFIX},
6455 @code{USER_LABEL_PREFIX} and @code{IMMEDIATE_PREFIX} if you can express
6456 the variations in assembler language syntax with that mechanism.  Define
6457 @code{ASSEMBLER_DIALECT} and use the @samp{@{option0|option1@}} syntax
6458 if the syntax variant are larger and involve such things as different
6459 opcodes or operand order.
6460 @end defmac
6462 @defmac ASM_OUTPUT_REG_PUSH (@var{stream}, @var{regno})
6463 A C expression to output to @var{stream} some assembler code
6464 which will push hard register number @var{regno} onto the stack.
6465 The code need not be optimal, since this macro is used only when
6466 profiling.
6467 @end defmac
6469 @defmac ASM_OUTPUT_REG_POP (@var{stream}, @var{regno})
6470 A C expression to output to @var{stream} some assembler code
6471 which will pop hard register number @var{regno} off of the stack.
6472 The code need not be optimal, since this macro is used only when
6473 profiling.
6474 @end defmac
6476 @node Dispatch Tables
6477 @subsection Output of Dispatch Tables
6479 @c prevent bad page break with this line
6480 This concerns dispatch tables.
6482 @cindex dispatch table
6483 @defmac ASM_OUTPUT_ADDR_DIFF_ELT (@var{stream}, @var{body}, @var{value}, @var{rel})
6484 A C statement to output to the stdio stream @var{stream} an assembler
6485 pseudo-instruction to generate a difference between two labels.
6486 @var{value} and @var{rel} are the numbers of two internal labels.  The
6487 definitions of these labels are output using
6488 @code{(*targetm.asm_out.internal_label)}, and they must be printed in the same
6489 way here.  For example,
6491 @smallexample
6492 fprintf (@var{stream}, "\t.word L%d-L%d\n",
6493          @var{value}, @var{rel})
6494 @end smallexample
6496 You must provide this macro on machines where the addresses in a
6497 dispatch table are relative to the table's own address.  If defined, GCC
6498 will also use this macro on all machines when producing PIC@.
6499 @var{body} is the body of the @code{ADDR_DIFF_VEC}; it is provided so that the
6500 mode and flags can be read.
6501 @end defmac
6503 @defmac ASM_OUTPUT_ADDR_VEC_ELT (@var{stream}, @var{value})
6504 This macro should be provided on machines where the addresses
6505 in a dispatch table are absolute.
6507 The definition should be a C statement to output to the stdio stream
6508 @var{stream} an assembler pseudo-instruction to generate a reference to
6509 a label.  @var{value} is the number of an internal label whose
6510 definition is output using @code{(*targetm.asm_out.internal_label)}.
6511 For example,
6513 @smallexample
6514 fprintf (@var{stream}, "\t.word L%d\n", @var{value})
6515 @end smallexample
6516 @end defmac
6518 @defmac ASM_OUTPUT_CASE_LABEL (@var{stream}, @var{prefix}, @var{num}, @var{table})
6519 Define this if the label before a jump-table needs to be output
6520 specially.  The first three arguments are the same as for
6521 @code{(*targetm.asm_out.internal_label)}; the fourth argument is the
6522 jump-table which follows (a @code{jump_table_data} containing an
6523 @code{addr_vec} or @code{addr_diff_vec}).
6525 This feature is used on system V to output a @code{swbeg} statement
6526 for the table.
6528 If this macro is not defined, these labels are output with
6529 @code{(*targetm.asm_out.internal_label)}.
6530 @end defmac
6532 @defmac ASM_OUTPUT_CASE_END (@var{stream}, @var{num}, @var{table})
6533 Define this if something special must be output at the end of a
6534 jump-table.  The definition should be a C statement to be executed
6535 after the assembler code for the table is written.  It should write
6536 the appropriate code to stdio stream @var{stream}.  The argument
6537 @var{table} is the jump-table insn, and @var{num} is the label-number
6538 of the preceding label.
6540 If this macro is not defined, nothing special is output at the end of
6541 the jump-table.
6542 @end defmac
6544 @hook TARGET_ASM_EMIT_UNWIND_LABEL
6546 @hook TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL
6548 @hook TARGET_ASM_EMIT_EXCEPT_PERSONALITY
6550 @hook TARGET_ASM_UNWIND_EMIT
6552 @hook TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
6554 @node Exception Region Output
6555 @subsection Assembler Commands for Exception Regions
6557 @c prevent bad page break with this line
6559 This describes commands marking the start and the end of an exception
6560 region.
6562 @defmac EH_FRAME_SECTION_NAME
6563 If defined, a C string constant for the name of the section containing
6564 exception handling frame unwind information.  If not defined, GCC will
6565 provide a default definition if the target supports named sections.
6566 @file{crtstuff.c} uses this macro to switch to the appropriate section.
6568 You should define this symbol if your target supports DWARF 2 frame
6569 unwind information and the default definition does not work.
6570 @end defmac
6572 @defmac EH_FRAME_THROUGH_COLLECT2
6573 If defined, DWARF 2 frame unwind information will identified by
6574 specially named labels.  The collect2 process will locate these
6575 labels and generate code to register the frames.
6577 This might be necessary, for instance, if the system linker will not
6578 place the eh_frames in-between the sentinals from @file{crtstuff.c},
6579 or if the system linker does garbage collection and sections cannot
6580 be marked as not to be collected.
6581 @end defmac
6583 @defmac EH_TABLES_CAN_BE_READ_ONLY
6584 Define this macro to 1 if your target is such that no frame unwind
6585 information encoding used with non-PIC code will ever require a
6586 runtime relocation, but the linker may not support merging read-only
6587 and read-write sections into a single read-write section.
6588 @end defmac
6590 @defmac MASK_RETURN_ADDR
6591 An rtx used to mask the return address found via @code{RETURN_ADDR_RTX}, so
6592 that it does not contain any extraneous set bits in it.
6593 @end defmac
6595 @defmac DWARF2_UNWIND_INFO
6596 Define this macro to 0 if your target supports DWARF 2 frame unwind
6597 information, but it does not yet work with exception handling.
6598 Otherwise, if your target supports this information (if it defines
6599 @code{INCOMING_RETURN_ADDR_RTX} and @code{OBJECT_FORMAT_ELF}),
6600 GCC will provide a default definition of 1.
6601 @end defmac
6603 @hook TARGET_EXCEPT_UNWIND_INFO
6604 This hook defines the mechanism that will be used for exception handling
6605 by the target.  If the target has ABI specified unwind tables, the hook
6606 should return @code{UI_TARGET}.  If the target is to use the
6607 @code{setjmp}/@code{longjmp}-based exception handling scheme, the hook
6608 should return @code{UI_SJLJ}.  If the target supports DWARF 2 frame unwind
6609 information, the hook should return @code{UI_DWARF2}.
6611 A target may, if exceptions are disabled, choose to return @code{UI_NONE}.
6612 This may end up simplifying other parts of target-specific code.  The
6613 default implementation of this hook never returns @code{UI_NONE}.
6615 Note that the value returned by this hook should be constant.  It should
6616 not depend on anything except the command-line switches described by
6617 @var{opts}.  In particular, the
6618 setting @code{UI_SJLJ} must be fixed at compiler start-up as C pre-processor
6619 macros and builtin functions related to exception handling are set up
6620 depending on this setting.
6622 The default implementation of the hook first honors the
6623 @option{--enable-sjlj-exceptions} configure option, then
6624 @code{DWARF2_UNWIND_INFO}, and finally defaults to @code{UI_SJLJ}.  If
6625 @code{DWARF2_UNWIND_INFO} depends on command-line options, the target
6626 must define this hook so that @var{opts} is used correctly.
6627 @end deftypefn
6629 @hook TARGET_UNWIND_TABLES_DEFAULT
6630 This variable should be set to @code{true} if the target ABI requires unwinding
6631 tables even when exceptions are not used.  It must not be modified by
6632 command-line option processing.
6633 @end deftypevr
6635 @defmac DONT_USE_BUILTIN_SETJMP
6636 Define this macro to 1 if the @code{setjmp}/@code{longjmp}-based scheme
6637 should use the @code{setjmp}/@code{longjmp} functions from the C library
6638 instead of the @code{__builtin_setjmp}/@code{__builtin_longjmp} machinery.
6639 @end defmac
6641 @defmac JMP_BUF_SIZE
6642 This macro has no effect unless @code{DONT_USE_BUILTIN_SETJMP} is also
6643 defined.  Define this macro if the default size of @code{jmp_buf} buffer
6644 for the @code{setjmp}/@code{longjmp}-based exception handling mechanism
6645 is not large enough, or if it is much too large.
6646 The default size is @code{FIRST_PSEUDO_REGISTER * sizeof(void *)}.
6647 @end defmac
6649 @defmac DWARF_CIE_DATA_ALIGNMENT
6650 This macro need only be defined if the target might save registers in the
6651 function prologue at an offset to the stack pointer that is not aligned to
6652 @code{UNITS_PER_WORD}.  The definition should be the negative minimum
6653 alignment if @code{STACK_GROWS_DOWNWARD} is true, and the positive
6654 minimum alignment otherwise.  @xref{SDB and DWARF}.  Only applicable if
6655 the target supports DWARF 2 frame unwind information.
6656 @end defmac
6658 @hook TARGET_TERMINATE_DW2_EH_FRAME_INFO
6660 @hook TARGET_DWARF_REGISTER_SPAN
6662 @hook TARGET_DWARF_FRAME_REG_MODE
6664 @hook TARGET_INIT_DWARF_REG_SIZES_EXTRA
6666 @hook TARGET_ASM_TTYPE
6668 @hook TARGET_ARM_EABI_UNWINDER
6670 @node Alignment Output
6671 @subsection Assembler Commands for Alignment
6673 @c prevent bad page break with this line
6674 This describes commands for alignment.
6676 @defmac JUMP_ALIGN (@var{label})
6677 The alignment (log base 2) to put in front of @var{label}, which is
6678 a common destination of jumps and has no fallthru incoming edge.
6680 This macro need not be defined if you don't want any special alignment
6681 to be done at such a time.  Most machine descriptions do not currently
6682 define the macro.
6684 Unless it's necessary to inspect the @var{label} parameter, it is better
6685 to set the variable @var{align_jumps} in the target's
6686 @code{TARGET_OPTION_OVERRIDE}.  Otherwise, you should try to honor the user's
6687 selection in @var{align_jumps} in a @code{JUMP_ALIGN} implementation.
6688 @end defmac
6690 @hook TARGET_ASM_JUMP_ALIGN_MAX_SKIP
6692 @defmac LABEL_ALIGN_AFTER_BARRIER (@var{label})
6693 The alignment (log base 2) to put in front of @var{label}, which follows
6694 a @code{BARRIER}.
6696 This macro need not be defined if you don't want any special alignment
6697 to be done at such a time.  Most machine descriptions do not currently
6698 define the macro.
6699 @end defmac
6701 @hook TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
6703 @defmac LOOP_ALIGN (@var{label})
6704 The alignment (log base 2) to put in front of @var{label} that heads
6705 a frequently executed basic block (usually the header of a loop).
6707 This macro need not be defined if you don't want any special alignment
6708 to be done at such a time.  Most machine descriptions do not currently
6709 define the macro.
6711 Unless it's necessary to inspect the @var{label} parameter, it is better
6712 to set the variable @code{align_loops} in the target's
6713 @code{TARGET_OPTION_OVERRIDE}.  Otherwise, you should try to honor the user's
6714 selection in @code{align_loops} in a @code{LOOP_ALIGN} implementation.
6715 @end defmac
6717 @hook TARGET_ASM_LOOP_ALIGN_MAX_SKIP
6719 @defmac LABEL_ALIGN (@var{label})
6720 The alignment (log base 2) to put in front of @var{label}.
6721 If @code{LABEL_ALIGN_AFTER_BARRIER} / @code{LOOP_ALIGN} specify a different alignment,
6722 the maximum of the specified values is used.
6724 Unless it's necessary to inspect the @var{label} parameter, it is better
6725 to set the variable @code{align_labels} in the target's
6726 @code{TARGET_OPTION_OVERRIDE}.  Otherwise, you should try to honor the user's
6727 selection in @code{align_labels} in a @code{LABEL_ALIGN} implementation.
6728 @end defmac
6730 @hook TARGET_ASM_LABEL_ALIGN_MAX_SKIP
6732 @defmac ASM_OUTPUT_SKIP (@var{stream}, @var{nbytes})
6733 A C statement to output to the stdio stream @var{stream} an assembler
6734 instruction to advance the location counter by @var{nbytes} bytes.
6735 Those bytes should be zero when loaded.  @var{nbytes} will be a C
6736 expression of type @code{unsigned HOST_WIDE_INT}.
6737 @end defmac
6739 @defmac ASM_NO_SKIP_IN_TEXT
6740 Define this macro if @code{ASM_OUTPUT_SKIP} should not be used in the
6741 text section because it fails to put zeros in the bytes that are skipped.
6742 This is true on many Unix systems, where the pseudo--op to skip bytes
6743 produces no-op instructions rather than zeros when used in the text
6744 section.
6745 @end defmac
6747 @defmac ASM_OUTPUT_ALIGN (@var{stream}, @var{power})
6748 A C statement to output to the stdio stream @var{stream} an assembler
6749 command to advance the location counter to a multiple of 2 to the
6750 @var{power} bytes.  @var{power} will be a C expression of type @code{int}.
6751 @end defmac
6753 @defmac ASM_OUTPUT_ALIGN_WITH_NOP (@var{stream}, @var{power})
6754 Like @code{ASM_OUTPUT_ALIGN}, except that the ``nop'' instruction is used
6755 for padding, if necessary.
6756 @end defmac
6758 @defmac ASM_OUTPUT_MAX_SKIP_ALIGN (@var{stream}, @var{power}, @var{max_skip})
6759 A C statement to output to the stdio stream @var{stream} an assembler
6760 command to advance the location counter to a multiple of 2 to the
6761 @var{power} bytes, but only if @var{max_skip} or fewer bytes are needed to
6762 satisfy the alignment request.  @var{power} and @var{max_skip} will be
6763 a C expression of type @code{int}.
6764 @end defmac
6766 @need 3000
6767 @node Debugging Info
6768 @section Controlling Debugging Information Format
6770 @c prevent bad page break with this line
6771 This describes how to specify debugging information.
6773 @menu
6774 * All Debuggers::      Macros that affect all debugging formats uniformly.
6775 * DBX Options::        Macros enabling specific options in DBX format.
6776 * DBX Hooks::          Hook macros for varying DBX format.
6777 * File Names and DBX:: Macros controlling output of file names in DBX format.
6778 * SDB and DWARF::      Macros for SDB (COFF) and DWARF formats.
6779 * VMS Debug::          Macros for VMS debug format.
6780 @end menu
6782 @node All Debuggers
6783 @subsection Macros Affecting All Debugging Formats
6785 @c prevent bad page break with this line
6786 These macros affect all debugging formats.
6788 @defmac DBX_REGISTER_NUMBER (@var{regno})
6789 A C expression that returns the DBX register number for the compiler
6790 register number @var{regno}.  In the default macro provided, the value
6791 of this expression will be @var{regno} itself.  But sometimes there are
6792 some registers that the compiler knows about and DBX does not, or vice
6793 versa.  In such cases, some register may need to have one number in the
6794 compiler and another for DBX@.
6796 If two registers have consecutive numbers inside GCC, and they can be
6797 used as a pair to hold a multiword value, then they @emph{must} have
6798 consecutive numbers after renumbering with @code{DBX_REGISTER_NUMBER}.
6799 Otherwise, debuggers will be unable to access such a pair, because they
6800 expect register pairs to be consecutive in their own numbering scheme.
6802 If you find yourself defining @code{DBX_REGISTER_NUMBER} in way that
6803 does not preserve register pairs, then what you must do instead is
6804 redefine the actual register numbering scheme.
6805 @end defmac
6807 @defmac DEBUGGER_AUTO_OFFSET (@var{x})
6808 A C expression that returns the integer offset value for an automatic
6809 variable having address @var{x} (an RTL expression).  The default
6810 computation assumes that @var{x} is based on the frame-pointer and
6811 gives the offset from the frame-pointer.  This is required for targets
6812 that produce debugging output for DBX or COFF-style debugging output
6813 for SDB and allow the frame-pointer to be eliminated when the
6814 @option{-g} options is used.
6815 @end defmac
6817 @defmac DEBUGGER_ARG_OFFSET (@var{offset}, @var{x})
6818 A C expression that returns the integer offset value for an argument
6819 having address @var{x} (an RTL expression).  The nominal offset is
6820 @var{offset}.
6821 @end defmac
6823 @defmac PREFERRED_DEBUGGING_TYPE
6824 A C expression that returns the type of debugging output GCC should
6825 produce when the user specifies just @option{-g}.  Define
6826 this if you have arranged for GCC to support more than one format of
6827 debugging output.  Currently, the allowable values are @code{DBX_DEBUG},
6828 @code{SDB_DEBUG}, @code{DWARF_DEBUG}, @code{DWARF2_DEBUG},
6829 @code{XCOFF_DEBUG}, @code{VMS_DEBUG}, and @code{VMS_AND_DWARF2_DEBUG}.
6831 When the user specifies @option{-ggdb}, GCC normally also uses the
6832 value of this macro to select the debugging output format, but with two
6833 exceptions.  If @code{DWARF2_DEBUGGING_INFO} is defined, GCC uses the
6834 value @code{DWARF2_DEBUG}.  Otherwise, if @code{DBX_DEBUGGING_INFO} is
6835 defined, GCC uses @code{DBX_DEBUG}.
6837 The value of this macro only affects the default debugging output; the
6838 user can always get a specific type of output by using @option{-gstabs},
6839 @option{-gcoff}, @option{-gdwarf-2}, @option{-gxcoff}, or @option{-gvms}.
6840 @end defmac
6842 @node DBX Options
6843 @subsection Specific Options for DBX Output
6845 @c prevent bad page break with this line
6846 These are specific options for DBX output.
6848 @defmac DBX_DEBUGGING_INFO
6849 Define this macro if GCC should produce debugging output for DBX
6850 in response to the @option{-g} option.
6851 @end defmac
6853 @defmac XCOFF_DEBUGGING_INFO
6854 Define this macro if GCC should produce XCOFF format debugging output
6855 in response to the @option{-g} option.  This is a variant of DBX format.
6856 @end defmac
6858 @defmac DEFAULT_GDB_EXTENSIONS
6859 Define this macro to control whether GCC should by default generate
6860 GDB's extended version of DBX debugging information (assuming DBX-format
6861 debugging information is enabled at all).  If you don't define the
6862 macro, the default is 1: always generate the extended information
6863 if there is any occasion to.
6864 @end defmac
6866 @defmac DEBUG_SYMS_TEXT
6867 Define this macro if all @code{.stabs} commands should be output while
6868 in the text section.
6869 @end defmac
6871 @defmac ASM_STABS_OP
6872 A C string constant, including spacing, naming the assembler pseudo op to
6873 use instead of @code{"\t.stabs\t"} to define an ordinary debugging symbol.
6874 If you don't define this macro, @code{"\t.stabs\t"} is used.  This macro
6875 applies only to DBX debugging information format.
6876 @end defmac
6878 @defmac ASM_STABD_OP
6879 A C string constant, including spacing, naming the assembler pseudo op to
6880 use instead of @code{"\t.stabd\t"} to define a debugging symbol whose
6881 value is the current location.  If you don't define this macro,
6882 @code{"\t.stabd\t"} is used.  This macro applies only to DBX debugging
6883 information format.
6884 @end defmac
6886 @defmac ASM_STABN_OP
6887 A C string constant, including spacing, naming the assembler pseudo op to
6888 use instead of @code{"\t.stabn\t"} to define a debugging symbol with no
6889 name.  If you don't define this macro, @code{"\t.stabn\t"} is used.  This
6890 macro applies only to DBX debugging information format.
6891 @end defmac
6893 @defmac DBX_NO_XREFS
6894 Define this macro if DBX on your system does not support the construct
6895 @samp{xs@var{tagname}}.  On some systems, this construct is used to
6896 describe a forward reference to a structure named @var{tagname}.
6897 On other systems, this construct is not supported at all.
6898 @end defmac
6900 @defmac DBX_CONTIN_LENGTH
6901 A symbol name in DBX-format debugging information is normally
6902 continued (split into two separate @code{.stabs} directives) when it
6903 exceeds a certain length (by default, 80 characters).  On some
6904 operating systems, DBX requires this splitting; on others, splitting
6905 must not be done.  You can inhibit splitting by defining this macro
6906 with the value zero.  You can override the default splitting-length by
6907 defining this macro as an expression for the length you desire.
6908 @end defmac
6910 @defmac DBX_CONTIN_CHAR
6911 Normally continuation is indicated by adding a @samp{\} character to
6912 the end of a @code{.stabs} string when a continuation follows.  To use
6913 a different character instead, define this macro as a character
6914 constant for the character you want to use.  Do not define this macro
6915 if backslash is correct for your system.
6916 @end defmac
6918 @defmac DBX_STATIC_STAB_DATA_SECTION
6919 Define this macro if it is necessary to go to the data section before
6920 outputting the @samp{.stabs} pseudo-op for a non-global static
6921 variable.
6922 @end defmac
6924 @defmac DBX_TYPE_DECL_STABS_CODE
6925 The value to use in the ``code'' field of the @code{.stabs} directive
6926 for a typedef.  The default is @code{N_LSYM}.
6927 @end defmac
6929 @defmac DBX_STATIC_CONST_VAR_CODE
6930 The value to use in the ``code'' field of the @code{.stabs} directive
6931 for a static variable located in the text section.  DBX format does not
6932 provide any ``right'' way to do this.  The default is @code{N_FUN}.
6933 @end defmac
6935 @defmac DBX_REGPARM_STABS_CODE
6936 The value to use in the ``code'' field of the @code{.stabs} directive
6937 for a parameter passed in registers.  DBX format does not provide any
6938 ``right'' way to do this.  The default is @code{N_RSYM}.
6939 @end defmac
6941 @defmac DBX_REGPARM_STABS_LETTER
6942 The letter to use in DBX symbol data to identify a symbol as a parameter
6943 passed in registers.  DBX format does not customarily provide any way to
6944 do this.  The default is @code{'P'}.
6945 @end defmac
6947 @defmac DBX_FUNCTION_FIRST
6948 Define this macro if the DBX information for a function and its
6949 arguments should precede the assembler code for the function.  Normally,
6950 in DBX format, the debugging information entirely follows the assembler
6951 code.
6952 @end defmac
6954 @defmac DBX_BLOCKS_FUNCTION_RELATIVE
6955 Define this macro, with value 1, if the value of a symbol describing
6956 the scope of a block (@code{N_LBRAC} or @code{N_RBRAC}) should be
6957 relative to the start of the enclosing function.  Normally, GCC uses
6958 an absolute address.
6959 @end defmac
6961 @defmac DBX_LINES_FUNCTION_RELATIVE
6962 Define this macro, with value 1, if the value of a symbol indicating
6963 the current line number (@code{N_SLINE}) should be relative to the
6964 start of the enclosing function.  Normally, GCC uses an absolute address.
6965 @end defmac
6967 @defmac DBX_USE_BINCL
6968 Define this macro if GCC should generate @code{N_BINCL} and
6969 @code{N_EINCL} stabs for included header files, as on Sun systems.  This
6970 macro also directs GCC to output a type number as a pair of a file
6971 number and a type number within the file.  Normally, GCC does not
6972 generate @code{N_BINCL} or @code{N_EINCL} stabs, and it outputs a single
6973 number for a type number.
6974 @end defmac
6976 @node DBX Hooks
6977 @subsection Open-Ended Hooks for DBX Format
6979 @c prevent bad page break with this line
6980 These are hooks for DBX format.
6982 @defmac DBX_OUTPUT_SOURCE_LINE (@var{stream}, @var{line}, @var{counter})
6983 A C statement to output DBX debugging information before code for line
6984 number @var{line} of the current source file to the stdio stream
6985 @var{stream}.  @var{counter} is the number of time the macro was
6986 invoked, including the current invocation; it is intended to generate
6987 unique labels in the assembly output.
6989 This macro should not be defined if the default output is correct, or
6990 if it can be made correct by defining @code{DBX_LINES_FUNCTION_RELATIVE}.
6991 @end defmac
6993 @defmac NO_DBX_FUNCTION_END
6994 Some stabs encapsulation formats (in particular ECOFF), cannot handle the
6995 @code{.stabs "",N_FUN,,0,0,Lscope-function-1} gdb dbx extension construct.
6996 On those machines, define this macro to turn this feature off without
6997 disturbing the rest of the gdb extensions.
6998 @end defmac
7000 @defmac NO_DBX_BNSYM_ENSYM
7001 Some assemblers cannot handle the @code{.stabd BNSYM/ENSYM,0,0} gdb dbx
7002 extension construct.  On those machines, define this macro to turn this
7003 feature off without disturbing the rest of the gdb extensions.
7004 @end defmac
7006 @node File Names and DBX
7007 @subsection File Names in DBX Format
7009 @c prevent bad page break with this line
7010 This describes file names in DBX format.
7012 @defmac DBX_OUTPUT_MAIN_SOURCE_FILENAME (@var{stream}, @var{name})
7013 A C statement to output DBX debugging information to the stdio stream
7014 @var{stream}, which indicates that file @var{name} is the main source
7015 file---the file specified as the input file for compilation.
7016 This macro is called only once, at the beginning of compilation.
7018 This macro need not be defined if the standard form of output
7019 for DBX debugging information is appropriate.
7021 It may be necessary to refer to a label equal to the beginning of the
7022 text section.  You can use @samp{assemble_name (stream, ltext_label_name)}
7023 to do so.  If you do this, you must also set the variable
7024 @var{used_ltext_label_name} to @code{true}.
7025 @end defmac
7027 @defmac NO_DBX_MAIN_SOURCE_DIRECTORY
7028 Define this macro, with value 1, if GCC should not emit an indication
7029 of the current directory for compilation and current source language at
7030 the beginning of the file.
7031 @end defmac
7033 @defmac NO_DBX_GCC_MARKER
7034 Define this macro, with value 1, if GCC should not emit an indication
7035 that this object file was compiled by GCC@.  The default is to emit
7036 an @code{N_OPT} stab at the beginning of every source file, with
7037 @samp{gcc2_compiled.} for the string and value 0.
7038 @end defmac
7040 @defmac DBX_OUTPUT_MAIN_SOURCE_FILE_END (@var{stream}, @var{name})
7041 A C statement to output DBX debugging information at the end of
7042 compilation of the main source file @var{name}.  Output should be
7043 written to the stdio stream @var{stream}.
7045 If you don't define this macro, nothing special is output at the end
7046 of compilation, which is correct for most machines.
7047 @end defmac
7049 @defmac DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
7050 Define this macro @emph{instead of} defining
7051 @code{DBX_OUTPUT_MAIN_SOURCE_FILE_END}, if what needs to be output at
7052 the end of compilation is an @code{N_SO} stab with an empty string,
7053 whose value is the highest absolute text address in the file.
7054 @end defmac
7056 @need 2000
7057 @node SDB and DWARF
7058 @subsection Macros for SDB and DWARF Output
7060 @c prevent bad page break with this line
7061 Here are macros for SDB and DWARF output.
7063 @defmac SDB_DEBUGGING_INFO
7064 Define this macro to 1 if GCC should produce COFF-style debugging output
7065 for SDB in response to the @option{-g} option.
7066 @end defmac
7068 @defmac DWARF2_DEBUGGING_INFO
7069 Define this macro if GCC should produce dwarf version 2 format
7070 debugging output in response to the @option{-g} option.
7072 @hook TARGET_DWARF_CALLING_CONVENTION
7074 To support optional call frame debugging information, you must also
7075 define @code{INCOMING_RETURN_ADDR_RTX} and either set
7076 @code{RTX_FRAME_RELATED_P} on the prologue insns if you use RTL for the
7077 prologue, or call @code{dwarf2out_def_cfa} and @code{dwarf2out_reg_save}
7078 as appropriate from @code{TARGET_ASM_FUNCTION_PROLOGUE} if you don't.
7079 @end defmac
7081 @defmac DWARF2_FRAME_INFO
7082 Define this macro to a nonzero value if GCC should always output
7083 Dwarf 2 frame information.  If @code{TARGET_EXCEPT_UNWIND_INFO}
7084 (@pxref{Exception Region Output}) returns @code{UI_DWARF2}, and
7085 exceptions are enabled, GCC will output this information not matter
7086 how you define @code{DWARF2_FRAME_INFO}.
7087 @end defmac
7089 @hook TARGET_DEBUG_UNWIND_INFO
7091 @defmac DWARF2_ASM_LINE_DEBUG_INFO
7092 Define this macro to be a nonzero value if the assembler can generate Dwarf 2
7093 line debug info sections.  This will result in much more compact line number
7094 tables, and hence is desirable if it works.
7095 @end defmac
7097 @hook TARGET_WANT_DEBUG_PUB_SECTIONS
7099 @hook TARGET_DELAY_SCHED2
7101 @hook TARGET_DELAY_VARTRACK
7103 @hook TARGET_NO_REGISTER_ALLOCATION
7105 @defmac ASM_OUTPUT_DWARF_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
7106 A C statement to issue assembly directives that create a difference
7107 @var{lab1} minus @var{lab2}, using an integer of the given @var{size}.
7108 @end defmac
7110 @defmac ASM_OUTPUT_DWARF_VMS_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
7111 A C statement to issue assembly directives that create a difference
7112 between the two given labels in system defined units, e.g. instruction
7113 slots on IA64 VMS, using an integer of the given size.
7114 @end defmac
7116 @defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, @var{offset}, @var{section})
7117 A C statement to issue assembly directives that create a
7118 section-relative reference to the given @var{label} plus @var{offset}, using
7119 an integer of the given @var{size}.  The label is known to be defined in the
7120 given @var{section}.
7121 @end defmac
7123 @defmac ASM_OUTPUT_DWARF_PCREL (@var{stream}, @var{size}, @var{label})
7124 A C statement to issue assembly directives that create a self-relative
7125 reference to the given @var{label}, using an integer of the given @var{size}.
7126 @end defmac
7128 @defmac ASM_OUTPUT_DWARF_DATAREL (@var{stream}, @var{size}, @var{label})
7129 A C statement to issue assembly directives that create a reference to the
7130 given @var{label} relative to the dbase, using an integer of the given @var{size}.
7131 @end defmac
7133 @defmac ASM_OUTPUT_DWARF_TABLE_REF (@var{label})
7134 A C statement to issue assembly directives that create a reference to
7135 the DWARF table identifier @var{label} from the current section.  This
7136 is used on some systems to avoid garbage collecting a DWARF table which
7137 is referenced by a function.
7138 @end defmac
7140 @hook TARGET_ASM_OUTPUT_DWARF_DTPREL
7142 @defmac PUT_SDB_@dots{}
7143 Define these macros to override the assembler syntax for the special
7144 SDB assembler directives.  See @file{sdbout.c} for a list of these
7145 macros and their arguments.  If the standard syntax is used, you need
7146 not define them yourself.
7147 @end defmac
7149 @defmac SDB_DELIM
7150 Some assemblers do not support a semicolon as a delimiter, even between
7151 SDB assembler directives.  In that case, define this macro to be the
7152 delimiter to use (usually @samp{\n}).  It is not necessary to define
7153 a new set of @code{PUT_SDB_@var{op}} macros if this is the only change
7154 required.
7155 @end defmac
7157 @defmac SDB_ALLOW_UNKNOWN_REFERENCES
7158 Define this macro to allow references to unknown structure,
7159 union, or enumeration tags to be emitted.  Standard COFF does not
7160 allow handling of unknown references, MIPS ECOFF has support for
7162 @end defmac
7164 @defmac SDB_ALLOW_FORWARD_REFERENCES
7165 Define this macro to allow references to structure, union, or
7166 enumeration tags that have not yet been seen to be handled.  Some
7167 assemblers choke if forward tags are used, while some require it.
7168 @end defmac
7170 @defmac SDB_OUTPUT_SOURCE_LINE (@var{stream}, @var{line})
7171 A C statement to output SDB debugging information before code for line
7172 number @var{line} of the current source file to the stdio stream
7173 @var{stream}.  The default is to emit an @code{.ln} directive.
7174 @end defmac
7176 @need 2000
7177 @node VMS Debug
7178 @subsection Macros for VMS Debug Format
7180 @c prevent bad page break with this line
7181 Here are macros for VMS debug format.
7183 @defmac VMS_DEBUGGING_INFO
7184 Define this macro if GCC should produce debugging output for VMS
7185 in response to the @option{-g} option.  The default behavior for VMS
7186 is to generate minimal debug info for a traceback in the absence of
7187 @option{-g} unless explicitly overridden with @option{-g0}.  This
7188 behavior is controlled by @code{TARGET_OPTION_OPTIMIZATION} and
7189 @code{TARGET_OPTION_OVERRIDE}.
7190 @end defmac
7192 @node Floating Point
7193 @section Cross Compilation and Floating Point
7194 @cindex cross compilation and floating point
7195 @cindex floating point and cross compilation
7197 While all modern machines use twos-complement representation for integers,
7198 there are a variety of representations for floating point numbers.  This
7199 means that in a cross-compiler the representation of floating point numbers
7200 in the compiled program may be different from that used in the machine
7201 doing the compilation.
7203 Because different representation systems may offer different amounts of
7204 range and precision, all floating point constants must be represented in
7205 the target machine's format.  Therefore, the cross compiler cannot
7206 safely use the host machine's floating point arithmetic; it must emulate
7207 the target's arithmetic.  To ensure consistency, GCC always uses
7208 emulation to work with floating point values, even when the host and
7209 target floating point formats are identical.
7211 The following macros are provided by @file{real.h} for the compiler to
7212 use.  All parts of the compiler which generate or optimize
7213 floating-point calculations must use these macros.  They may evaluate
7214 their operands more than once, so operands must not have side effects.
7216 @defmac REAL_VALUE_TYPE
7217 The C data type to be used to hold a floating point value in the target
7218 machine's format.  Typically this is a @code{struct} containing an
7219 array of @code{HOST_WIDE_INT}, but all code should treat it as an opaque
7220 quantity.
7221 @end defmac
7223 @deftypefn Macro HOST_WIDE_INT REAL_VALUE_FIX (REAL_VALUE_TYPE @var{x})
7224 Truncates @var{x} to a signed integer, rounding toward zero.
7225 @end deftypefn
7227 @deftypefn Macro {unsigned HOST_WIDE_INT} REAL_VALUE_UNSIGNED_FIX (REAL_VALUE_TYPE @var{x})
7228 Truncates @var{x} to an unsigned integer, rounding toward zero.  If
7229 @var{x} is negative, returns zero.
7230 @end deftypefn
7232 @deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ATOF (const char *@var{string}, machine_mode @var{mode})
7233 Converts @var{string} into a floating point number in the target machine's
7234 representation for mode @var{mode}.  This routine can handle both
7235 decimal and hexadecimal floating point constants, using the syntax
7236 defined by the C language for both.
7237 @end deftypefn
7239 @deftypefn Macro int REAL_VALUE_NEGATIVE (REAL_VALUE_TYPE @var{x})
7240 Returns 1 if @var{x} is negative (including negative zero), 0 otherwise.
7241 @end deftypefn
7243 @deftypefn Macro int REAL_VALUE_ISINF (REAL_VALUE_TYPE @var{x})
7244 Determines whether @var{x} represents infinity (positive or negative).
7245 @end deftypefn
7247 @deftypefn Macro int REAL_VALUE_ISNAN (REAL_VALUE_TYPE @var{x})
7248 Determines whether @var{x} represents a ``NaN'' (not-a-number).
7249 @end deftypefn
7251 @deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_NEGATE (REAL_VALUE_TYPE @var{x})
7252 Returns the negative of the floating point value @var{x}.
7253 @end deftypefn
7255 @deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ABS (REAL_VALUE_TYPE @var{x})
7256 Returns the absolute value of @var{x}.
7257 @end deftypefn
7259 @node Mode Switching
7260 @section Mode Switching Instructions
7261 @cindex mode switching
7262 The following macros control mode switching optimizations:
7264 @defmac OPTIMIZE_MODE_SWITCHING (@var{entity})
7265 Define this macro if the port needs extra instructions inserted for mode
7266 switching in an optimizing compilation.
7268 For an example, the SH4 can perform both single and double precision
7269 floating point operations, but to perform a single precision operation,
7270 the FPSCR PR bit has to be cleared, while for a double precision
7271 operation, this bit has to be set.  Changing the PR bit requires a general
7272 purpose register as a scratch register, hence these FPSCR sets have to
7273 be inserted before reload, i.e.@: you cannot put this into instruction emitting
7274 or @code{TARGET_MACHINE_DEPENDENT_REORG}.
7276 You can have multiple entities that are mode-switched, and select at run time
7277 which entities actually need it.  @code{OPTIMIZE_MODE_SWITCHING} should
7278 return nonzero for any @var{entity} that needs mode-switching.
7279 If you define this macro, you also have to define
7280 @code{NUM_MODES_FOR_MODE_SWITCHING}, @code{TARGET_MODE_NEEDED},
7281 @code{TARGET_MODE_PRIORITY} and @code{TARGET_MODE_EMIT}.
7282 @code{TARGET_MODE_AFTER}, @code{TARGET_MODE_ENTRY}, and @code{TARGET_MODE_EXIT}
7283 are optional.
7284 @end defmac
7286 @defmac NUM_MODES_FOR_MODE_SWITCHING
7287 If you define @code{OPTIMIZE_MODE_SWITCHING}, you have to define this as
7288 initializer for an array of integers.  Each initializer element
7289 N refers to an entity that needs mode switching, and specifies the number
7290 of different modes that might need to be set for this entity.
7291 The position of the initializer in the initializer---starting counting at
7292 zero---determines the integer that is used to refer to the mode-switched
7293 entity in question.
7294 In macros that take mode arguments / yield a mode result, modes are
7295 represented as numbers 0 @dots{} N @minus{} 1.  N is used to specify that no mode
7296 switch is needed / supplied.
7297 @end defmac
7299 @hook TARGET_MODE_EMIT
7301 @hook TARGET_MODE_NEEDED
7303 @hook TARGET_MODE_AFTER
7305 @hook TARGET_MODE_ENTRY
7307 @hook TARGET_MODE_EXIT
7309 @hook TARGET_MODE_PRIORITY
7311 @node Target Attributes
7312 @section Defining target-specific uses of @code{__attribute__}
7313 @cindex target attributes
7314 @cindex machine attributes
7315 @cindex attributes, target-specific
7317 Target-specific attributes may be defined for functions, data and types.
7318 These are described using the following target hooks; they also need to
7319 be documented in @file{extend.texi}.
7321 @hook TARGET_ATTRIBUTE_TABLE
7323 @hook TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
7325 @hook TARGET_COMP_TYPE_ATTRIBUTES
7327 @hook TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
7329 @hook TARGET_MERGE_TYPE_ATTRIBUTES
7331 @hook TARGET_MERGE_DECL_ATTRIBUTES
7333 @hook TARGET_VALID_DLLIMPORT_ATTRIBUTE_P
7335 @defmac TARGET_DECLSPEC
7336 Define this macro to a nonzero value if you want to treat
7337 @code{__declspec(X)} as equivalent to @code{__attribute((X))}.  By
7338 default, this behavior is enabled only for targets that define
7339 @code{TARGET_DLLIMPORT_DECL_ATTRIBUTES}.  The current implementation
7340 of @code{__declspec} is via a built-in macro, but you should not rely
7341 on this implementation detail.
7342 @end defmac
7344 @hook TARGET_INSERT_ATTRIBUTES
7346 @hook TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P
7348 @hook TARGET_OPTION_VALID_ATTRIBUTE_P
7350 @hook TARGET_OPTION_SAVE
7352 @hook TARGET_OPTION_RESTORE
7354 @hook TARGET_OPTION_POST_STREAM_IN
7356 @hook TARGET_OPTION_PRINT
7358 @hook TARGET_OPTION_PRAGMA_PARSE
7360 @hook TARGET_OPTION_OVERRIDE
7362 @hook TARGET_OPTION_FUNCTION_VERSIONS
7364 @hook TARGET_CAN_INLINE_P
7366 @hook TARGET_RELAYOUT_FUNCTION
7368 @node Emulated TLS
7369 @section Emulating TLS
7370 @cindex Emulated TLS
7372 For targets whose psABI does not provide Thread Local Storage via
7373 specific relocations and instruction sequences, an emulation layer is
7374 used.  A set of target hooks allows this emulation layer to be
7375 configured for the requirements of a particular target.  For instance
7376 the psABI may in fact specify TLS support in terms of an emulation
7377 layer.
7379 The emulation layer works by creating a control object for every TLS
7380 object.  To access the TLS object, a lookup function is provided
7381 which, when given the address of the control object, will return the
7382 address of the current thread's instance of the TLS object.
7384 @hook TARGET_EMUTLS_GET_ADDRESS
7386 @hook TARGET_EMUTLS_REGISTER_COMMON
7388 @hook TARGET_EMUTLS_VAR_SECTION
7390 @hook TARGET_EMUTLS_TMPL_SECTION
7392 @hook TARGET_EMUTLS_VAR_PREFIX
7394 @hook TARGET_EMUTLS_TMPL_PREFIX
7396 @hook TARGET_EMUTLS_VAR_FIELDS
7398 @hook TARGET_EMUTLS_VAR_INIT
7400 @hook TARGET_EMUTLS_VAR_ALIGN_FIXED
7402 @hook TARGET_EMUTLS_DEBUG_FORM_TLS_ADDRESS
7404 @node MIPS Coprocessors
7405 @section Defining coprocessor specifics for MIPS targets.
7406 @cindex MIPS coprocessor-definition macros
7408 The MIPS specification allows MIPS implementations to have as many as 4
7409 coprocessors, each with as many as 32 private registers.  GCC supports
7410 accessing these registers and transferring values between the registers
7411 and memory using asm-ized variables.  For example:
7413 @smallexample
7414   register unsigned int cp0count asm ("c0r1");
7415   unsigned int d;
7417   d = cp0count + 3;
7418 @end smallexample
7420 (``c0r1'' is the default name of register 1 in coprocessor 0; alternate
7421 names may be added as described below, or the default names may be
7422 overridden entirely in @code{SUBTARGET_CONDITIONAL_REGISTER_USAGE}.)
7424 Coprocessor registers are assumed to be epilogue-used; sets to them will
7425 be preserved even if it does not appear that the register is used again
7426 later in the function.
7428 Another note: according to the MIPS spec, coprocessor 1 (if present) is
7429 the FPU@.  One accesses COP1 registers through standard mips
7430 floating-point support; they are not included in this mechanism.
7432 @node PCH Target
7433 @section Parameters for Precompiled Header Validity Checking
7434 @cindex parameters, precompiled headers
7436 @hook TARGET_GET_PCH_VALIDITY
7438 @hook TARGET_PCH_VALID_P
7440 @hook TARGET_CHECK_PCH_TARGET_FLAGS
7442 @hook TARGET_PREPARE_PCH_SAVE
7444 @node C++ ABI
7445 @section C++ ABI parameters
7446 @cindex parameters, c++ abi
7448 @hook TARGET_CXX_GUARD_TYPE
7450 @hook TARGET_CXX_GUARD_MASK_BIT
7452 @hook TARGET_CXX_GET_COOKIE_SIZE
7454 @hook TARGET_CXX_COOKIE_HAS_SIZE
7456 @hook TARGET_CXX_IMPORT_EXPORT_CLASS
7458 @hook TARGET_CXX_CDTOR_RETURNS_THIS
7460 @hook TARGET_CXX_KEY_METHOD_MAY_BE_INLINE
7462 @hook TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY
7464 @hook TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT
7466 @hook TARGET_CXX_LIBRARY_RTTI_COMDAT
7468 @hook TARGET_CXX_USE_AEABI_ATEXIT
7470 @hook TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT
7472 @hook TARGET_CXX_ADJUST_CLASS_AT_DEFINITION
7474 @hook TARGET_CXX_DECL_MANGLING_CONTEXT
7476 @node Named Address Spaces
7477 @section Adding support for named address spaces
7478 @cindex named address spaces
7480 The draft technical report of the ISO/IEC JTC1 S22 WG14 N1275
7481 standards committee, @cite{Programming Languages - C - Extensions to
7482 support embedded processors}, specifies a syntax for embedded
7483 processors to specify alternate address spaces.  You can configure a
7484 GCC port to support section 5.1 of the draft report to add support for
7485 address spaces other than the default address space.  These address
7486 spaces are new keywords that are similar to the @code{volatile} and
7487 @code{const} type attributes.
7489 Pointers to named address spaces can have a different size than
7490 pointers to the generic address space.
7492 For example, the SPU port uses the @code{__ea} address space to refer
7493 to memory in the host processor, rather than memory local to the SPU
7494 processor.  Access to memory in the @code{__ea} address space involves
7495 issuing DMA operations to move data between the host processor and the
7496 local processor memory address space.  Pointers in the @code{__ea}
7497 address space are either 32 bits or 64 bits based on the
7498 @option{-mea32} or @option{-mea64} switches (native SPU pointers are
7499 always 32 bits).
7501 Internally, address spaces are represented as a small integer in the
7502 range 0 to 15 with address space 0 being reserved for the generic
7503 address space.
7505 To register a named address space qualifier keyword with the C front end,
7506 the target may call the @code{c_register_addr_space} routine.  For example,
7507 the SPU port uses the following to declare @code{__ea} as the keyword for
7508 named address space #1:
7509 @smallexample
7510 #define ADDR_SPACE_EA 1
7511 c_register_addr_space ("__ea", ADDR_SPACE_EA);
7512 @end smallexample
7514 @hook TARGET_ADDR_SPACE_POINTER_MODE
7516 @hook TARGET_ADDR_SPACE_ADDRESS_MODE
7518 @hook TARGET_ADDR_SPACE_VALID_POINTER_MODE
7520 @hook TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P
7522 @hook TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS
7524 @hook TARGET_ADDR_SPACE_SUBSET_P
7526 @hook TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID
7528 @hook TARGET_ADDR_SPACE_CONVERT
7530 @hook TARGET_ADDR_SPACE_DEBUG
7532 @hook TARGET_ADDR_SPACE_DIAGNOSE_USAGE
7534 @node Misc
7535 @section Miscellaneous Parameters
7536 @cindex parameters, miscellaneous
7538 @c prevent bad page break with this line
7539 Here are several miscellaneous parameters.
7541 @defmac HAS_LONG_COND_BRANCH
7542 Define this boolean macro to indicate whether or not your architecture
7543 has conditional branches that can span all of memory.  It is used in
7544 conjunction with an optimization that partitions hot and cold basic
7545 blocks into separate sections of the executable.  If this macro is
7546 set to false, gcc will convert any conditional branches that attempt
7547 to cross between sections into unconditional branches or indirect jumps.
7548 @end defmac
7550 @defmac HAS_LONG_UNCOND_BRANCH
7551 Define this boolean macro to indicate whether or not your architecture
7552 has unconditional branches that can span all of memory.  It is used in
7553 conjunction with an optimization that partitions hot and cold basic
7554 blocks into separate sections of the executable.  If this macro is
7555 set to false, gcc will convert any unconditional branches that attempt
7556 to cross between sections into indirect jumps.
7557 @end defmac
7559 @defmac CASE_VECTOR_MODE
7560 An alias for a machine mode name.  This is the machine mode that
7561 elements of a jump-table should have.
7562 @end defmac
7564 @defmac CASE_VECTOR_SHORTEN_MODE (@var{min_offset}, @var{max_offset}, @var{body})
7565 Optional: return the preferred mode for an @code{addr_diff_vec}
7566 when the minimum and maximum offset are known.  If you define this,
7567 it enables extra code in branch shortening to deal with @code{addr_diff_vec}.
7568 To make this work, you also have to define @code{INSN_ALIGN} and
7569 make the alignment for @code{addr_diff_vec} explicit.
7570 The @var{body} argument is provided so that the offset_unsigned and scale
7571 flags can be updated.
7572 @end defmac
7574 @defmac CASE_VECTOR_PC_RELATIVE
7575 Define this macro to be a C expression to indicate when jump-tables
7576 should contain relative addresses.  You need not define this macro if
7577 jump-tables never contain relative addresses, or jump-tables should
7578 contain relative addresses only when @option{-fPIC} or @option{-fPIC}
7579 is in effect.
7580 @end defmac
7582 @hook TARGET_CASE_VALUES_THRESHOLD
7584 @defmac WORD_REGISTER_OPERATIONS
7585 Define this macro to 1 if operations between registers with integral mode
7586 smaller than a word are always performed on the entire register.
7587 Most RISC machines have this property and most CISC machines do not.
7588 @end defmac
7590 @hook TARGET_MIN_ARITHMETIC_PRECISION
7592 @defmac LOAD_EXTEND_OP (@var{mem_mode})
7593 Define this macro to be a C expression indicating when insns that read
7594 memory in @var{mem_mode}, an integral mode narrower than a word, set the
7595 bits outside of @var{mem_mode} to be either the sign-extension or the
7596 zero-extension of the data read.  Return @code{SIGN_EXTEND} for values
7597 of @var{mem_mode} for which the
7598 insn sign-extends, @code{ZERO_EXTEND} for which it zero-extends, and
7599 @code{UNKNOWN} for other modes.
7601 This macro is not called with @var{mem_mode} non-integral or with a width
7602 greater than or equal to @code{BITS_PER_WORD}, so you may return any
7603 value in this case.  Do not define this macro if it would always return
7604 @code{UNKNOWN}.  On machines where this macro is defined, you will normally
7605 define it as the constant @code{SIGN_EXTEND} or @code{ZERO_EXTEND}.
7607 You may return a non-@code{UNKNOWN} value even if for some hard registers
7608 the sign extension is not performed, if for the @code{REGNO_REG_CLASS}
7609 of these hard registers @code{CANNOT_CHANGE_MODE_CLASS} returns nonzero
7610 when the @var{from} mode is @var{mem_mode} and the @var{to} mode is any
7611 integral mode larger than this but not larger than @code{word_mode}.
7613 You must return @code{UNKNOWN} if for some hard registers that allow this
7614 mode, @code{CANNOT_CHANGE_MODE_CLASS} says that they cannot change to
7615 @code{word_mode}, but that they can change to another integral mode that
7616 is larger then @var{mem_mode} but still smaller than @code{word_mode}.
7617 @end defmac
7619 @defmac SHORT_IMMEDIATES_SIGN_EXTEND
7620 Define this macro to 1 if loading short immediate values into registers sign
7621 extends.
7622 @end defmac
7624 @hook TARGET_MIN_DIVISIONS_FOR_RECIP_MUL
7626 @defmac MOVE_MAX
7627 The maximum number of bytes that a single instruction can move quickly
7628 between memory and registers or between two memory locations.
7629 @end defmac
7631 @defmac MAX_MOVE_MAX
7632 The maximum number of bytes that a single instruction can move quickly
7633 between memory and registers or between two memory locations.  If this
7634 is undefined, the default is @code{MOVE_MAX}.  Otherwise, it is the
7635 constant value that is the largest value that @code{MOVE_MAX} can have
7636 at run-time.
7637 @end defmac
7639 @defmac SHIFT_COUNT_TRUNCATED
7640 A C expression that is nonzero if on this machine the number of bits
7641 actually used for the count of a shift operation is equal to the number
7642 of bits needed to represent the size of the object being shifted.  When
7643 this macro is nonzero, the compiler will assume that it is safe to omit
7644 a sign-extend, zero-extend, and certain bitwise `and' instructions that
7645 truncates the count of a shift operation.  On machines that have
7646 instructions that act on bit-fields at variable positions, which may
7647 include `bit test' instructions, a nonzero @code{SHIFT_COUNT_TRUNCATED}
7648 also enables deletion of truncations of the values that serve as
7649 arguments to bit-field instructions.
7651 If both types of instructions truncate the count (for shifts) and
7652 position (for bit-field operations), or if no variable-position bit-field
7653 instructions exist, you should define this macro.
7655 However, on some machines, such as the 80386 and the 680x0, truncation
7656 only applies to shift operations and not the (real or pretended)
7657 bit-field operations.  Define @code{SHIFT_COUNT_TRUNCATED} to be zero on
7658 such machines.  Instead, add patterns to the @file{md} file that include
7659 the implied truncation of the shift instructions.
7661 You need not define this macro if it would always have the value of zero.
7662 @end defmac
7664 @anchor{TARGET_SHIFT_TRUNCATION_MASK}
7665 @hook TARGET_SHIFT_TRUNCATION_MASK
7667 @defmac TRULY_NOOP_TRUNCATION (@var{outprec}, @var{inprec})
7668 A C expression which is nonzero if on this machine it is safe to
7669 ``convert'' an integer of @var{inprec} bits to one of @var{outprec}
7670 bits (where @var{outprec} is smaller than @var{inprec}) by merely
7671 operating on it as if it had only @var{outprec} bits.
7673 On many machines, this expression can be 1.
7675 @c rearranged this, removed the phrase "it is reported that".  this was
7676 @c to fix an overfull hbox.  --mew 10feb93
7677 When @code{TRULY_NOOP_TRUNCATION} returns 1 for a pair of sizes for
7678 modes for which @code{MODES_TIEABLE_P} is 0, suboptimal code can result.
7679 If this is the case, making @code{TRULY_NOOP_TRUNCATION} return 0 in
7680 such cases may improve things.
7681 @end defmac
7683 @hook TARGET_MODE_REP_EXTENDED
7685 @defmac STORE_FLAG_VALUE
7686 A C expression describing the value returned by a comparison operator
7687 with an integral mode and stored by a store-flag instruction
7688 (@samp{cstore@var{mode}4}) when the condition is true.  This description must
7689 apply to @emph{all} the @samp{cstore@var{mode}4} patterns and all the
7690 comparison operators whose results have a @code{MODE_INT} mode.
7692 A value of 1 or @minus{}1 means that the instruction implementing the
7693 comparison operator returns exactly 1 or @minus{}1 when the comparison is true
7694 and 0 when the comparison is false.  Otherwise, the value indicates
7695 which bits of the result are guaranteed to be 1 when the comparison is
7696 true.  This value is interpreted in the mode of the comparison
7697 operation, which is given by the mode of the first operand in the
7698 @samp{cstore@var{mode}4} pattern.  Either the low bit or the sign bit of
7699 @code{STORE_FLAG_VALUE} be on.  Presently, only those bits are used by
7700 the compiler.
7702 If @code{STORE_FLAG_VALUE} is neither 1 or @minus{}1, the compiler will
7703 generate code that depends only on the specified bits.  It can also
7704 replace comparison operators with equivalent operations if they cause
7705 the required bits to be set, even if the remaining bits are undefined.
7706 For example, on a machine whose comparison operators return an
7707 @code{SImode} value and where @code{STORE_FLAG_VALUE} is defined as
7708 @samp{0x80000000}, saying that just the sign bit is relevant, the
7709 expression
7711 @smallexample
7712 (ne:SI (and:SI @var{x} (const_int @var{power-of-2})) (const_int 0))
7713 @end smallexample
7715 @noindent
7716 can be converted to
7718 @smallexample
7719 (ashift:SI @var{x} (const_int @var{n}))
7720 @end smallexample
7722 @noindent
7723 where @var{n} is the appropriate shift count to move the bit being
7724 tested into the sign bit.
7726 There is no way to describe a machine that always sets the low-order bit
7727 for a true value, but does not guarantee the value of any other bits,
7728 but we do not know of any machine that has such an instruction.  If you
7729 are trying to port GCC to such a machine, include an instruction to
7730 perform a logical-and of the result with 1 in the pattern for the
7731 comparison operators and let us know at @email{gcc@@gcc.gnu.org}.
7733 Often, a machine will have multiple instructions that obtain a value
7734 from a comparison (or the condition codes).  Here are rules to guide the
7735 choice of value for @code{STORE_FLAG_VALUE}, and hence the instructions
7736 to be used:
7738 @itemize @bullet
7739 @item
7740 Use the shortest sequence that yields a valid definition for
7741 @code{STORE_FLAG_VALUE}.  It is more efficient for the compiler to
7742 ``normalize'' the value (convert it to, e.g., 1 or 0) than for the
7743 comparison operators to do so because there may be opportunities to
7744 combine the normalization with other operations.
7746 @item
7747 For equal-length sequences, use a value of 1 or @minus{}1, with @minus{}1 being
7748 slightly preferred on machines with expensive jumps and 1 preferred on
7749 other machines.
7751 @item
7752 As a second choice, choose a value of @samp{0x80000001} if instructions
7753 exist that set both the sign and low-order bits but do not define the
7754 others.
7756 @item
7757 Otherwise, use a value of @samp{0x80000000}.
7758 @end itemize
7760 Many machines can produce both the value chosen for
7761 @code{STORE_FLAG_VALUE} and its negation in the same number of
7762 instructions.  On those machines, you should also define a pattern for
7763 those cases, e.g., one matching
7765 @smallexample
7766 (set @var{A} (neg:@var{m} (ne:@var{m} @var{B} @var{C})))
7767 @end smallexample
7769 Some machines can also perform @code{and} or @code{plus} operations on
7770 condition code values with less instructions than the corresponding
7771 @samp{cstore@var{mode}4} insn followed by @code{and} or @code{plus}.  On those
7772 machines, define the appropriate patterns.  Use the names @code{incscc}
7773 and @code{decscc}, respectively, for the patterns which perform
7774 @code{plus} or @code{minus} operations on condition code values.  See
7775 @file{rs6000.md} for some examples.  The GNU Superoptimizer can be used to
7776 find such instruction sequences on other machines.
7778 If this macro is not defined, the default value, 1, is used.  You need
7779 not define @code{STORE_FLAG_VALUE} if the machine has no store-flag
7780 instructions, or if the value generated by these instructions is 1.
7781 @end defmac
7783 @defmac FLOAT_STORE_FLAG_VALUE (@var{mode})
7784 A C expression that gives a nonzero @code{REAL_VALUE_TYPE} value that is
7785 returned when comparison operators with floating-point results are true.
7786 Define this macro on machines that have comparison operations that return
7787 floating-point values.  If there are no such operations, do not define
7788 this macro.
7789 @end defmac
7791 @defmac VECTOR_STORE_FLAG_VALUE (@var{mode})
7792 A C expression that gives a rtx representing the nonzero true element
7793 for vector comparisons.  The returned rtx should be valid for the inner
7794 mode of @var{mode} which is guaranteed to be a vector mode.  Define
7795 this macro on machines that have vector comparison operations that
7796 return a vector result.  If there are no such operations, do not define
7797 this macro.  Typically, this macro is defined as @code{const1_rtx} or
7798 @code{constm1_rtx}.  This macro may return @code{NULL_RTX} to prevent
7799 the compiler optimizing such vector comparison operations for the
7800 given mode.
7801 @end defmac
7803 @defmac CLZ_DEFINED_VALUE_AT_ZERO (@var{mode}, @var{value})
7804 @defmacx CTZ_DEFINED_VALUE_AT_ZERO (@var{mode}, @var{value})
7805 A C expression that indicates whether the architecture defines a value
7806 for @code{clz} or @code{ctz} with a zero operand.
7807 A result of @code{0} indicates the value is undefined.
7808 If the value is defined for only the RTL expression, the macro should
7809 evaluate to @code{1}; if the value applies also to the corresponding optab
7810 entry (which is normally the case if it expands directly into
7811 the corresponding RTL), then the macro should evaluate to @code{2}.
7812 In the cases where the value is defined, @var{value} should be set to
7813 this value.
7815 If this macro is not defined, the value of @code{clz} or
7816 @code{ctz} at zero is assumed to be undefined.
7818 This macro must be defined if the target's expansion for @code{ffs}
7819 relies on a particular value to get correct results.  Otherwise it
7820 is not necessary, though it may be used to optimize some corner cases, and
7821 to provide a default expansion for the @code{ffs} optab.
7823 Note that regardless of this macro the ``definedness'' of @code{clz}
7824 and @code{ctz} at zero do @emph{not} extend to the builtin functions
7825 visible to the user.  Thus one may be free to adjust the value at will
7826 to match the target expansion of these operations without fear of
7827 breaking the API@.
7828 @end defmac
7830 @defmac Pmode
7831 An alias for the machine mode for pointers.  On most machines, define
7832 this to be the integer mode corresponding to the width of a hardware
7833 pointer; @code{SImode} on 32-bit machine or @code{DImode} on 64-bit machines.
7834 On some machines you must define this to be one of the partial integer
7835 modes, such as @code{PSImode}.
7837 The width of @code{Pmode} must be at least as large as the value of
7838 @code{POINTER_SIZE}.  If it is not equal, you must define the macro
7839 @code{POINTERS_EXTEND_UNSIGNED} to specify how pointers are extended
7840 to @code{Pmode}.
7841 @end defmac
7843 @defmac FUNCTION_MODE
7844 An alias for the machine mode used for memory references to functions
7845 being called, in @code{call} RTL expressions.  On most CISC machines,
7846 where an instruction can begin at any byte address, this should be
7847 @code{QImode}.  On most RISC machines, where all instructions have fixed
7848 size and alignment, this should be a mode with the same size and alignment
7849 as the machine instruction words - typically @code{SImode} or @code{HImode}.
7850 @end defmac
7852 @defmac STDC_0_IN_SYSTEM_HEADERS
7853 In normal operation, the preprocessor expands @code{__STDC__} to the
7854 constant 1, to signify that GCC conforms to ISO Standard C@.  On some
7855 hosts, like Solaris, the system compiler uses a different convention,
7856 where @code{__STDC__} is normally 0, but is 1 if the user specifies
7857 strict conformance to the C Standard.
7859 Defining @code{STDC_0_IN_SYSTEM_HEADERS} makes GNU CPP follows the host
7860 convention when processing system header files, but when processing user
7861 files @code{__STDC__} will always expand to 1.
7862 @end defmac
7864 @hook TARGET_C_PREINCLUDE
7866 @hook TARGET_CXX_IMPLICIT_EXTERN_C
7868 @defmac NO_IMPLICIT_EXTERN_C
7869 Define this macro if the system header files support C++ as well as C@.
7870 This macro inhibits the usual method of using system header files in
7871 C++, which is to pretend that the file's contents are enclosed in
7872 @samp{extern "C" @{@dots{}@}}.
7873 @end defmac
7875 @findex #pragma
7876 @findex pragma
7877 @defmac REGISTER_TARGET_PRAGMAS ()
7878 Define this macro if you want to implement any target-specific pragmas.
7879 If defined, it is a C expression which makes a series of calls to
7880 @code{c_register_pragma} or @code{c_register_pragma_with_expansion}
7881 for each pragma.  The macro may also do any
7882 setup required for the pragmas.
7884 The primary reason to define this macro is to provide compatibility with
7885 other compilers for the same target.  In general, we discourage
7886 definition of target-specific pragmas for GCC@.
7888 If the pragma can be implemented by attributes then you should consider
7889 defining the target hook @samp{TARGET_INSERT_ATTRIBUTES} as well.
7891 Preprocessor macros that appear on pragma lines are not expanded.  All
7892 @samp{#pragma} directives that do not match any registered pragma are
7893 silently ignored, unless the user specifies @option{-Wunknown-pragmas}.
7894 @end defmac
7896 @deftypefun void c_register_pragma (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *))
7897 @deftypefunx void c_register_pragma_with_expansion (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *))
7899 Each call to @code{c_register_pragma} or
7900 @code{c_register_pragma_with_expansion} establishes one pragma.  The
7901 @var{callback} routine will be called when the preprocessor encounters a
7902 pragma of the form
7904 @smallexample
7905 #pragma [@var{space}] @var{name} @dots{}
7906 @end smallexample
7908 @var{space} is the case-sensitive namespace of the pragma, or
7909 @code{NULL} to put the pragma in the global namespace.  The callback
7910 routine receives @var{pfile} as its first argument, which can be passed
7911 on to cpplib's functions if necessary.  You can lex tokens after the
7912 @var{name} by calling @code{pragma_lex}.  Tokens that are not read by the
7913 callback will be silently ignored.  The end of the line is indicated by
7914 a token of type @code{CPP_EOF}.  Macro expansion occurs on the
7915 arguments of pragmas registered with
7916 @code{c_register_pragma_with_expansion} but not on the arguments of
7917 pragmas registered with @code{c_register_pragma}.
7919 Note that the use of @code{pragma_lex} is specific to the C and C++
7920 compilers.  It will not work in the Java or Fortran compilers, or any
7921 other language compilers for that matter.  Thus if @code{pragma_lex} is going
7922 to be called from target-specific code, it must only be done so when
7923 building the C and C++ compilers.  This can be done by defining the
7924 variables @code{c_target_objs} and @code{cxx_target_objs} in the
7925 target entry in the @file{config.gcc} file.  These variables should name
7926 the target-specific, language-specific object file which contains the
7927 code that uses @code{pragma_lex}.  Note it will also be necessary to add a
7928 rule to the makefile fragment pointed to by @code{tmake_file} that shows
7929 how to build this object file.
7930 @end deftypefun
7932 @defmac HANDLE_PRAGMA_PACK_WITH_EXPANSION
7933 Define this macro if macros should be expanded in the
7934 arguments of @samp{#pragma pack}.
7935 @end defmac
7937 @defmac TARGET_DEFAULT_PACK_STRUCT
7938 If your target requires a structure packing default other than 0 (meaning
7939 the machine default), define this macro to the necessary value (in bytes).
7940 This must be a value that would also be valid to use with
7941 @samp{#pragma pack()} (that is, a small power of two).
7942 @end defmac
7944 @defmac DOLLARS_IN_IDENTIFIERS
7945 Define this macro to control use of the character @samp{$} in
7946 identifier names for the C family of languages.  0 means @samp{$} is
7947 not allowed by default; 1 means it is allowed.  1 is the default;
7948 there is no need to define this macro in that case.
7949 @end defmac
7951 @defmac INSN_SETS_ARE_DELAYED (@var{insn})
7952 Define this macro as a C expression that is nonzero if it is safe for the
7953 delay slot scheduler to place instructions in the delay slot of @var{insn},
7954 even if they appear to use a resource set or clobbered in @var{insn}.
7955 @var{insn} is always a @code{jump_insn} or an @code{insn}; GCC knows that
7956 every @code{call_insn} has this behavior.  On machines where some @code{insn}
7957 or @code{jump_insn} is really a function call and hence has this behavior,
7958 you should define this macro.
7960 You need not define this macro if it would always return zero.
7961 @end defmac
7963 @defmac INSN_REFERENCES_ARE_DELAYED (@var{insn})
7964 Define this macro as a C expression that is nonzero if it is safe for the
7965 delay slot scheduler to place instructions in the delay slot of @var{insn},
7966 even if they appear to set or clobber a resource referenced in @var{insn}.
7967 @var{insn} is always a @code{jump_insn} or an @code{insn}.  On machines where
7968 some @code{insn} or @code{jump_insn} is really a function call and its operands
7969 are registers whose use is actually in the subroutine it calls, you should
7970 define this macro.  Doing so allows the delay slot scheduler to move
7971 instructions which copy arguments into the argument registers into the delay
7972 slot of @var{insn}.
7974 You need not define this macro if it would always return zero.
7975 @end defmac
7977 @defmac MULTIPLE_SYMBOL_SPACES
7978 Define this macro as a C expression that is nonzero if, in some cases,
7979 global symbols from one translation unit may not be bound to undefined
7980 symbols in another translation unit without user intervention.  For
7981 instance, under Microsoft Windows symbols must be explicitly imported
7982 from shared libraries (DLLs).
7984 You need not define this macro if it would always evaluate to zero.
7985 @end defmac
7987 @hook TARGET_MD_ASM_ADJUST
7989 @defmac MATH_LIBRARY
7990 Define this macro as a C string constant for the linker argument to link
7991 in the system math library, minus the initial @samp{"-l"}, or
7992 @samp{""} if the target does not have a
7993 separate math library.
7995 You need only define this macro if the default of @samp{"m"} is wrong.
7996 @end defmac
7998 @defmac LIBRARY_PATH_ENV
7999 Define this macro as a C string constant for the environment variable that
8000 specifies where the linker should look for libraries.
8002 You need only define this macro if the default of @samp{"LIBRARY_PATH"}
8003 is wrong.
8004 @end defmac
8006 @defmac TARGET_POSIX_IO
8007 Define this macro if the target supports the following POSIX@ file
8008 functions, access, mkdir and  file locking with fcntl / F_SETLKW@.
8009 Defining @code{TARGET_POSIX_IO} will enable the test coverage code
8010 to use file locking when exiting a program, which avoids race conditions
8011 if the program has forked. It will also create directories at run-time
8012 for cross-profiling.
8013 @end defmac
8015 @defmac MAX_CONDITIONAL_EXECUTE
8017 A C expression for the maximum number of instructions to execute via
8018 conditional execution instructions instead of a branch.  A value of
8019 @code{BRANCH_COST}+1 is the default if the machine does not use cc0, and
8020 1 if it does use cc0.
8021 @end defmac
8023 @defmac IFCVT_MODIFY_TESTS (@var{ce_info}, @var{true_expr}, @var{false_expr})
8024 Used if the target needs to perform machine-dependent modifications on the
8025 conditionals used for turning basic blocks into conditionally executed code.
8026 @var{ce_info} points to a data structure, @code{struct ce_if_block}, which
8027 contains information about the currently processed blocks.  @var{true_expr}
8028 and @var{false_expr} are the tests that are used for converting the
8029 then-block and the else-block, respectively.  Set either @var{true_expr} or
8030 @var{false_expr} to a null pointer if the tests cannot be converted.
8031 @end defmac
8033 @defmac IFCVT_MODIFY_MULTIPLE_TESTS (@var{ce_info}, @var{bb}, @var{true_expr}, @var{false_expr})
8034 Like @code{IFCVT_MODIFY_TESTS}, but used when converting more complicated
8035 if-statements into conditions combined by @code{and} and @code{or} operations.
8036 @var{bb} contains the basic block that contains the test that is currently
8037 being processed and about to be turned into a condition.
8038 @end defmac
8040 @defmac IFCVT_MODIFY_INSN (@var{ce_info}, @var{pattern}, @var{insn})
8041 A C expression to modify the @var{PATTERN} of an @var{INSN} that is to
8042 be converted to conditional execution format.  @var{ce_info} points to
8043 a data structure, @code{struct ce_if_block}, which contains information
8044 about the currently processed blocks.
8045 @end defmac
8047 @defmac IFCVT_MODIFY_FINAL (@var{ce_info})
8048 A C expression to perform any final machine dependent modifications in
8049 converting code to conditional execution.  The involved basic blocks
8050 can be found in the @code{struct ce_if_block} structure that is pointed
8051 to by @var{ce_info}.
8052 @end defmac
8054 @defmac IFCVT_MODIFY_CANCEL (@var{ce_info})
8055 A C expression to cancel any machine dependent modifications in
8056 converting code to conditional execution.  The involved basic blocks
8057 can be found in the @code{struct ce_if_block} structure that is pointed
8058 to by @var{ce_info}.
8059 @end defmac
8061 @defmac IFCVT_MACHDEP_INIT (@var{ce_info})
8062 A C expression to initialize any machine specific data for if-conversion
8063 of the if-block in the @code{struct ce_if_block} structure that is pointed
8064 to by @var{ce_info}.
8065 @end defmac
8067 @hook TARGET_MACHINE_DEPENDENT_REORG
8069 @hook TARGET_INIT_BUILTINS
8071 @hook TARGET_BUILTIN_DECL
8073 @hook TARGET_EXPAND_BUILTIN
8075 @hook TARGET_BUILTIN_CHKP_FUNCTION
8076 @hook TARGET_CHKP_BOUND_TYPE
8077 @hook TARGET_CHKP_BOUND_MODE
8078 @hook TARGET_CHKP_MAKE_BOUNDS_CONSTANT
8079 @hook TARGET_CHKP_INITIALIZE_BOUNDS
8081 @hook TARGET_RESOLVE_OVERLOADED_BUILTIN
8083 @hook TARGET_FOLD_BUILTIN
8085 @hook TARGET_GIMPLE_FOLD_BUILTIN
8087 @hook TARGET_COMPARE_VERSION_PRIORITY
8089 @hook TARGET_GET_FUNCTION_VERSIONS_DISPATCHER
8091 @hook TARGET_GENERATE_VERSION_DISPATCHER_BODY
8093 @hook TARGET_CAN_USE_DOLOOP_P
8095 @hook TARGET_INVALID_WITHIN_DOLOOP
8097 @hook TARGET_LEGITIMATE_COMBINED_INSN
8099 @hook TARGET_CAN_FOLLOW_JUMP
8101 @hook TARGET_COMMUTATIVE_P
8103 @hook TARGET_ALLOCATE_INITIAL_VALUE
8105 @hook TARGET_UNSPEC_MAY_TRAP_P
8107 @hook TARGET_SET_CURRENT_FUNCTION
8109 @defmac TARGET_OBJECT_SUFFIX
8110 Define this macro to be a C string representing the suffix for object
8111 files on your target machine.  If you do not define this macro, GCC will
8112 use @samp{.o} as the suffix for object files.
8113 @end defmac
8115 @defmac TARGET_EXECUTABLE_SUFFIX
8116 Define this macro to be a C string representing the suffix to be
8117 automatically added to executable files on your target machine.  If you
8118 do not define this macro, GCC will use the null string as the suffix for
8119 executable files.
8120 @end defmac
8122 @defmac COLLECT_EXPORT_LIST
8123 If defined, @code{collect2} will scan the individual object files
8124 specified on its command line and create an export list for the linker.
8125 Define this macro for systems like AIX, where the linker discards
8126 object files that are not referenced from @code{main} and uses export
8127 lists.
8128 @end defmac
8130 @defmac MODIFY_JNI_METHOD_CALL (@var{mdecl})
8131 Define this macro to a C expression representing a variant of the
8132 method call @var{mdecl}, if Java Native Interface (JNI) methods
8133 must be invoked differently from other methods on your target.
8134 For example, on 32-bit Microsoft Windows, JNI methods must be invoked using
8135 the @code{stdcall} calling convention and this macro is then
8136 defined as this expression:
8138 @smallexample
8139 build_type_attribute_variant (@var{mdecl},
8140                               build_tree_list
8141                               (get_identifier ("stdcall"),
8142                                NULL))
8143 @end smallexample
8144 @end defmac
8146 @hook TARGET_CANNOT_MODIFY_JUMPS_P
8148 @hook TARGET_BRANCH_TARGET_REGISTER_CLASS
8150 @hook TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED
8152 @hook TARGET_HAVE_CONDITIONAL_EXECUTION
8154 @hook TARGET_GEN_CCMP_FIRST
8156 @hook TARGET_GEN_CCMP_NEXT
8158 @hook TARGET_LOOP_UNROLL_ADJUST
8160 @defmac POWI_MAX_MULTS
8161 If defined, this macro is interpreted as a signed integer C expression
8162 that specifies the maximum number of floating point multiplications
8163 that should be emitted when expanding exponentiation by an integer
8164 constant inline.  When this value is defined, exponentiation requiring
8165 more than this number of multiplications is implemented by calling the
8166 system library's @code{pow}, @code{powf} or @code{powl} routines.
8167 The default value places no upper bound on the multiplication count.
8168 @end defmac
8170 @deftypefn Macro void TARGET_EXTRA_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
8171 This target hook should register any extra include files for the
8172 target.  The parameter @var{stdinc} indicates if normal include files
8173 are present.  The parameter @var{sysroot} is the system root directory.
8174 The parameter @var{iprefix} is the prefix for the gcc directory.
8175 @end deftypefn
8177 @deftypefn Macro void TARGET_EXTRA_PRE_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
8178 This target hook should register any extra include files for the
8179 target before any standard headers.  The parameter @var{stdinc}
8180 indicates if normal include files are present.  The parameter
8181 @var{sysroot} is the system root directory.  The parameter
8182 @var{iprefix} is the prefix for the gcc directory.
8183 @end deftypefn
8185 @deftypefn Macro void TARGET_OPTF (char *@var{path})
8186 This target hook should register special include paths for the target.
8187 The parameter @var{path} is the include to register.  On Darwin
8188 systems, this is used for Framework includes, which have semantics
8189 that are different from @option{-I}.
8190 @end deftypefn
8192 @defmac bool TARGET_USE_LOCAL_THUNK_ALIAS_P (tree @var{fndecl})
8193 This target macro returns @code{true} if it is safe to use a local alias
8194 for a virtual function @var{fndecl} when constructing thunks,
8195 @code{false} otherwise.  By default, the macro returns @code{true} for all
8196 functions, if a target supports aliases (i.e.@: defines
8197 @code{ASM_OUTPUT_DEF}), @code{false} otherwise,
8198 @end defmac
8200 @defmac TARGET_FORMAT_TYPES
8201 If defined, this macro is the name of a global variable containing
8202 target-specific format checking information for the @option{-Wformat}
8203 option.  The default is to have no target-specific format checks.
8204 @end defmac
8206 @defmac TARGET_N_FORMAT_TYPES
8207 If defined, this macro is the number of entries in
8208 @code{TARGET_FORMAT_TYPES}.
8209 @end defmac
8211 @defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES
8212 If defined, this macro is the name of a global variable containing
8213 target-specific format overrides for the @option{-Wformat} option. The
8214 default is to have no target-specific format overrides. If defined,
8215 @code{TARGET_FORMAT_TYPES} must be defined, too.
8216 @end defmac
8218 @defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
8219 If defined, this macro specifies the number of entries in
8220 @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
8221 @end defmac
8223 @defmac TARGET_OVERRIDES_FORMAT_INIT
8224 If defined, this macro specifies the optional initialization
8225 routine for target specific customizations of the system printf
8226 and scanf formatter settings.
8227 @end defmac
8229 @hook TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
8231 @hook TARGET_INVALID_CONVERSION
8233 @hook TARGET_INVALID_UNARY_OP
8235 @hook TARGET_INVALID_BINARY_OP
8237 @hook TARGET_PROMOTED_TYPE
8239 @hook TARGET_CONVERT_TO_TYPE
8241 @defmac OBJC_JBLEN
8242 This macro determines the size of the objective C jump buffer for the
8243 NeXT runtime. By default, OBJC_JBLEN is defined to an innocuous value.
8244 @end defmac
8246 @defmac LIBGCC2_UNWIND_ATTRIBUTE
8247 Define this macro if any target-specific attributes need to be attached
8248 to the functions in @file{libgcc} that provide low-level support for
8249 call stack unwinding.  It is used in declarations in @file{unwind-generic.h}
8250 and the associated definitions of those functions.
8251 @end defmac
8253 @hook TARGET_UPDATE_STACK_BOUNDARY
8255 @hook TARGET_GET_DRAP_RTX
8257 @hook TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS
8259 @hook TARGET_CONST_ANCHOR
8261 @hook TARGET_ASAN_SHADOW_OFFSET
8263 @hook TARGET_MEMMODEL_CHECK
8265 @hook TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
8267 @hook TARGET_HAS_IFUNC_P
8269 @hook TARGET_ATOMIC_ALIGN_FOR_MODE
8271 @hook TARGET_ATOMIC_ASSIGN_EXPAND_FENV
8273 @hook TARGET_RECORD_OFFLOAD_SYMBOL
8275 @hook TARGET_OFFLOAD_OPTIONS
8277 @defmac TARGET_SUPPORTS_WIDE_INT
8279 On older ports, large integers are stored in @code{CONST_DOUBLE} rtl
8280 objects.  Newer ports define @code{TARGET_SUPPORTS_WIDE_INT} to be nonzero
8281 to indicate that large integers are stored in
8282 @code{CONST_WIDE_INT} rtl objects.  The @code{CONST_WIDE_INT} allows
8283 very large integer constants to be represented.  @code{CONST_DOUBLE}
8284 is limited to twice the size of the host's @code{HOST_WIDE_INT}
8285 representation.
8287 Converting a port mostly requires looking for the places where
8288 @code{CONST_DOUBLE}s are used with @code{VOIDmode} and replacing that
8289 code with code that accesses @code{CONST_WIDE_INT}s.  @samp{"grep -i
8290 const_double"} at the port level gets you to 95% of the changes that
8291 need to be made.  There are a few places that require a deeper look.
8293 @itemize @bullet
8294 @item
8295 There is no equivalent to @code{hval} and @code{lval} for
8296 @code{CONST_WIDE_INT}s.  This would be difficult to express in the md
8297 language since there are a variable number of elements.
8299 Most ports only check that @code{hval} is either 0 or -1 to see if the
8300 value is small.  As mentioned above, this will no longer be necessary
8301 since small constants are always @code{CONST_INT}.  Of course there
8302 are still a few exceptions, the alpha's constraint used by the zap
8303 instruction certainly requires careful examination by C code.
8304 However, all the current code does is pass the hval and lval to C
8305 code, so evolving the c code to look at the @code{CONST_WIDE_INT} is
8306 not really a large change.
8308 @item
8309 Because there is no standard template that ports use to materialize
8310 constants, there is likely to be some futzing that is unique to each
8311 port in this code.
8313 @item
8314 The rtx costs may have to be adjusted to properly account for larger
8315 constants that are represented as @code{CONST_WIDE_INT}.
8316 @end itemize
8318 All and all it does not take long to convert ports that the
8319 maintainer is familiar with.
8321 @end defmac
8323 @hook TARGET_RUN_TARGET_SELFTESTS