OSDN Git Service

PR target/46881
[pf3gnuchains/gcc-fork.git] / gcc / doc / tm.texi
1 @c Copyright (C) 1988,1989,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,
2 @c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 @c Free Software Foundation, Inc.
4 @c This is part of the GCC manual.
5 @c For copying conditions, see the file gcc.texi.
6
7 @node Target Macros
8 @chapter Target Description Macros and Functions
9 @cindex machine description macros
10 @cindex target description macros
11 @cindex macros, target description
12 @cindex @file{tm.h} macros
13
14 In addition to the file @file{@var{machine}.md}, a machine description
15 includes a C header file conventionally given the name
16 @file{@var{machine}.h} and a C source file named @file{@var{machine}.c}.
17 The header file defines numerous macros that convey the information
18 about the target machine that does not fit into the scheme of the
19 @file{.md} file.  The file @file{tm.h} should be a link to
20 @file{@var{machine}.h}.  The header file @file{config.h} includes
21 @file{tm.h} and most compiler source files include @file{config.h}.  The
22 source file defines a variable @code{targetm}, which is a structure
23 containing pointers to functions and data relating to the target
24 machine.  @file{@var{machine}.c} should also contain their definitions,
25 if they are not defined elsewhere in GCC, and other functions called
26 through the macros defined in the @file{.h} file.
27
28 @menu
29 * Target Structure::    The @code{targetm} variable.
30 * Driver::              Controlling how the driver runs the compilation passes.
31 * Run-time Target::     Defining @samp{-m} options like @option{-m68000} and @option{-m68020}.
32 * Per-Function Data::   Defining data structures for per-function information.
33 * Storage Layout::      Defining sizes and alignments of data.
34 * Type Layout::         Defining sizes and properties of basic user data types.
35 * Registers::           Naming and describing the hardware registers.
36 * Register Classes::    Defining the classes of hardware registers.
37 * Old Constraints::     The old way to define machine-specific constraints.
38 * Stack and Calling::   Defining which way the stack grows and by how much.
39 * Varargs::             Defining the varargs macros.
40 * Trampolines::         Code set up at run time to enter a nested function.
41 * Library Calls::       Controlling how library routines are implicitly called.
42 * Addressing Modes::    Defining addressing modes valid for memory operands.
43 * Anchored Addresses::  Defining how @option{-fsection-anchors} should work.
44 * Condition Code::      Defining how insns update the condition code.
45 * Costs::               Defining relative costs of different operations.
46 * Scheduling::          Adjusting the behavior of the instruction scheduler.
47 * Sections::            Dividing storage into text, data, and other sections.
48 * PIC::                 Macros for position independent code.
49 * Assembler Format::    Defining how to write insns and pseudo-ops to output.
50 * Debugging Info::      Defining the format of debugging output.
51 * Floating Point::      Handling floating point for cross-compilers.
52 * Mode Switching::      Insertion of mode-switching instructions.
53 * Target Attributes::   Defining target-specific uses of @code{__attribute__}.
54 * Emulated TLS::        Emulated TLS support.
55 * MIPS Coprocessors::   MIPS coprocessor support and how to customize it.
56 * PCH Target::          Validity checking for precompiled headers.
57 * C++ ABI::             Controlling C++ ABI changes.
58 * Named Address Spaces:: Adding support for named address spaces
59 * Misc::                Everything else.
60 @end menu
61
62 @node Target Structure
63 @section The Global @code{targetm} Variable
64 @cindex target hooks
65 @cindex target functions
66
67 @deftypevar {struct gcc_target} targetm
68 The target @file{.c} file must define the global @code{targetm} variable
69 which contains pointers to functions and data relating to the target
70 machine.  The variable is declared in @file{target.h};
71 @file{target-def.h} defines the macro @code{TARGET_INITIALIZER} which is
72 used to initialize the variable, and macros for the default initializers
73 for elements of the structure.  The @file{.c} file should override those
74 macros for which the default definition is inappropriate.  For example:
75 @smallexample
76 #include "target.h"
77 #include "target-def.h"
78
79 /* @r{Initialize the GCC target structure.}  */
80
81 #undef TARGET_COMP_TYPE_ATTRIBUTES
82 #define TARGET_COMP_TYPE_ATTRIBUTES @var{machine}_comp_type_attributes
83
84 struct gcc_target targetm = TARGET_INITIALIZER;
85 @end smallexample
86 @end deftypevar
87
88 Where a macro should be defined in the @file{.c} file in this manner to
89 form part of the @code{targetm} structure, it is documented below as a
90 ``Target Hook'' with a prototype.  Many macros will change in future
91 from being defined in the @file{.h} file to being part of the
92 @code{targetm} structure.
93
94 @node Driver
95 @section Controlling the Compilation Driver, @file{gcc}
96 @cindex driver
97 @cindex controlling the compilation driver
98
99 @c prevent bad page break with this line
100 You can control the compilation driver.
101
102 @defmac DRIVER_SELF_SPECS
103 A list of specs for the driver itself.  It should be a suitable
104 initializer for an array of strings, with no surrounding braces.
105
106 The driver applies these specs to its own command line between loading
107 default @file{specs} files (but not command-line specified ones) and
108 choosing the multilib directory or running any subcommands.  It
109 applies them in the order given, so each spec can depend on the
110 options added by earlier ones.  It is also possible to remove options
111 using @samp{%<@var{option}} in the usual way.
112
113 This macro can be useful when a port has several interdependent target
114 options.  It provides a way of standardizing the command line so
115 that the other specs are easier to write.
116
117 Do not define this macro if it does not need to do anything.
118 @end defmac
119
120 @defmac OPTION_DEFAULT_SPECS
121 A list of specs used to support configure-time default options (i.e.@:
122 @option{--with} options) in the driver.  It should be a suitable initializer
123 for an array of structures, each containing two strings, without the
124 outermost pair of surrounding braces.
125
126 The first item in the pair is the name of the default.  This must match
127 the code in @file{config.gcc} for the target.  The second item is a spec
128 to apply if a default with this name was specified.  The string
129 @samp{%(VALUE)} in the spec will be replaced by the value of the default
130 everywhere it occurs.
131
132 The driver will apply these specs to its own command line between loading
133 default @file{specs} files and processing @code{DRIVER_SELF_SPECS}, using
134 the same mechanism as @code{DRIVER_SELF_SPECS}.
135
136 Do not define this macro if it does not need to do anything.
137 @end defmac
138
139 @defmac CPP_SPEC
140 A C string constant that tells the GCC driver program options to
141 pass to CPP@.  It can also specify how to translate options you
142 give to GCC into options for GCC to pass to the CPP@.
143
144 Do not define this macro if it does not need to do anything.
145 @end defmac
146
147 @defmac CPLUSPLUS_CPP_SPEC
148 This macro is just like @code{CPP_SPEC}, but is used for C++, rather
149 than C@.  If you do not define this macro, then the value of
150 @code{CPP_SPEC} (if any) will be used instead.
151 @end defmac
152
153 @defmac CC1_SPEC
154 A C string constant that tells the GCC driver program options to
155 pass to @code{cc1}, @code{cc1plus}, @code{f771}, and the other language
156 front ends.
157 It can also specify how to translate options you give to GCC into options
158 for GCC to pass to front ends.
159
160 Do not define this macro if it does not need to do anything.
161 @end defmac
162
163 @defmac CC1PLUS_SPEC
164 A C string constant that tells the GCC driver program options to
165 pass to @code{cc1plus}.  It can also specify how to translate options you
166 give to GCC into options for GCC to pass to the @code{cc1plus}.
167
168 Do not define this macro if it does not need to do anything.
169 Note that everything defined in CC1_SPEC is already passed to
170 @code{cc1plus} so there is no need to duplicate the contents of
171 CC1_SPEC in CC1PLUS_SPEC@.
172 @end defmac
173
174 @defmac ASM_SPEC
175 A C string constant that tells the GCC driver program options to
176 pass to the assembler.  It can also specify how to translate options
177 you give to GCC into options for GCC to pass to the assembler.
178 See the file @file{sun3.h} for an example of this.
179
180 Do not define this macro if it does not need to do anything.
181 @end defmac
182
183 @defmac ASM_FINAL_SPEC
184 A C string constant that tells the GCC driver program how to
185 run any programs which cleanup after the normal assembler.
186 Normally, this is not needed.  See the file @file{mips.h} for
187 an example of this.
188
189 Do not define this macro if it does not need to do anything.
190 @end defmac
191
192 @defmac AS_NEEDS_DASH_FOR_PIPED_INPUT
193 Define this macro, with no value, if the driver should give the assembler
194 an argument consisting of a single dash, @option{-}, to instruct it to
195 read from its standard input (which will be a pipe connected to the
196 output of the compiler proper).  This argument is given after any
197 @option{-o} option specifying the name of the output file.
198
199 If you do not define this macro, the assembler is assumed to read its
200 standard input if given no non-option arguments.  If your assembler
201 cannot read standard input at all, use a @samp{%@{pipe:%e@}} construct;
202 see @file{mips.h} for instance.
203 @end defmac
204
205 @defmac LINK_SPEC
206 A C string constant that tells the GCC driver program options to
207 pass to the linker.  It can also specify how to translate options you
208 give to GCC into options for GCC to pass to the linker.
209
210 Do not define this macro if it does not need to do anything.
211 @end defmac
212
213 @defmac LIB_SPEC
214 Another C string constant used much like @code{LINK_SPEC}.  The difference
215 between the two is that @code{LIB_SPEC} is used at the end of the
216 command given to the linker.
217
218 If this macro is not defined, a default is provided that
219 loads the standard C library from the usual place.  See @file{gcc.c}.
220 @end defmac
221
222 @defmac LIBGCC_SPEC
223 Another C string constant that tells the GCC driver program
224 how and when to place a reference to @file{libgcc.a} into the
225 linker command line.  This constant is placed both before and after
226 the value of @code{LIB_SPEC}.
227
228 If this macro is not defined, the GCC driver provides a default that
229 passes the string @option{-lgcc} to the linker.
230 @end defmac
231
232 @defmac REAL_LIBGCC_SPEC
233 By default, if @code{ENABLE_SHARED_LIBGCC} is defined, the
234 @code{LIBGCC_SPEC} is not directly used by the driver program but is
235 instead modified to refer to different versions of @file{libgcc.a}
236 depending on the values of the command line flags @option{-static},
237 @option{-shared}, @option{-static-libgcc}, and @option{-shared-libgcc}.  On
238 targets where these modifications are inappropriate, define
239 @code{REAL_LIBGCC_SPEC} instead.  @code{REAL_LIBGCC_SPEC} tells the
240 driver how to place a reference to @file{libgcc} on the link command
241 line, but, unlike @code{LIBGCC_SPEC}, it is used unmodified.
242 @end defmac
243
244 @defmac USE_LD_AS_NEEDED
245 A macro that controls the modifications to @code{LIBGCC_SPEC}
246 mentioned in @code{REAL_LIBGCC_SPEC}.  If nonzero, a spec will be
247 generated that uses --as-needed and the shared libgcc in place of the
248 static exception handler library, when linking without any of
249 @code{-static}, @code{-static-libgcc}, or @code{-shared-libgcc}.
250 @end defmac
251
252 @defmac LINK_EH_SPEC
253 If defined, this C string constant is added to @code{LINK_SPEC}.
254 When @code{USE_LD_AS_NEEDED} is zero or undefined, it also affects
255 the modifications to @code{LIBGCC_SPEC} mentioned in
256 @code{REAL_LIBGCC_SPEC}.
257 @end defmac
258
259 @defmac STARTFILE_SPEC
260 Another C string constant used much like @code{LINK_SPEC}.  The
261 difference between the two is that @code{STARTFILE_SPEC} is used at
262 the very beginning of the command given to the linker.
263
264 If this macro is not defined, a default is provided that loads the
265 standard C startup file from the usual place.  See @file{gcc.c}.
266 @end defmac
267
268 @defmac ENDFILE_SPEC
269 Another C string constant used much like @code{LINK_SPEC}.  The
270 difference between the two is that @code{ENDFILE_SPEC} is used at
271 the very end of the command given to the linker.
272
273 Do not define this macro if it does not need to do anything.
274 @end defmac
275
276 @defmac THREAD_MODEL_SPEC
277 GCC @code{-v} will print the thread model GCC was configured to use.
278 However, this doesn't work on platforms that are multilibbed on thread
279 models, such as AIX 4.3.  On such platforms, define
280 @code{THREAD_MODEL_SPEC} such that it evaluates to a string without
281 blanks that names one of the recognized thread models.  @code{%*}, the
282 default value of this macro, will expand to the value of
283 @code{thread_file} set in @file{config.gcc}.
284 @end defmac
285
286 @defmac SYSROOT_SUFFIX_SPEC
287 Define this macro to add a suffix to the target sysroot when GCC is
288 configured with a sysroot.  This will cause GCC to search for usr/lib,
289 et al, within sysroot+suffix.
290 @end defmac
291
292 @defmac SYSROOT_HEADERS_SUFFIX_SPEC
293 Define this macro to add a headers_suffix to the target sysroot when
294 GCC is configured with a sysroot.  This will cause GCC to pass the
295 updated sysroot+headers_suffix to CPP, causing it to search for
296 usr/include, et al, within sysroot+headers_suffix.
297 @end defmac
298
299 @defmac EXTRA_SPECS
300 Define this macro to provide additional specifications to put in the
301 @file{specs} file that can be used in various specifications like
302 @code{CC1_SPEC}.
303
304 The definition should be an initializer for an array of structures,
305 containing a string constant, that defines the specification name, and a
306 string constant that provides the specification.
307
308 Do not define this macro if it does not need to do anything.
309
310 @code{EXTRA_SPECS} is useful when an architecture contains several
311 related targets, which have various @code{@dots{}_SPECS} which are similar
312 to each other, and the maintainer would like one central place to keep
313 these definitions.
314
315 For example, the PowerPC System V.4 targets use @code{EXTRA_SPECS} to
316 define either @code{_CALL_SYSV} when the System V calling sequence is
317 used or @code{_CALL_AIX} when the older AIX-based calling sequence is
318 used.
319
320 The @file{config/rs6000/rs6000.h} target file defines:
321
322 @smallexample
323 #define EXTRA_SPECS \
324   @{ "cpp_sysv_default", CPP_SYSV_DEFAULT @},
325
326 #define CPP_SYS_DEFAULT ""
327 @end smallexample
328
329 The @file{config/rs6000/sysv.h} target file defines:
330 @smallexample
331 #undef CPP_SPEC
332 #define CPP_SPEC \
333 "%@{posix: -D_POSIX_SOURCE @} \
334 %@{mcall-sysv: -D_CALL_SYSV @} \
335 %@{!mcall-sysv: %(cpp_sysv_default) @} \
336 %@{msoft-float: -D_SOFT_FLOAT@} %@{mcpu=403: -D_SOFT_FLOAT@}"
337
338 #undef CPP_SYSV_DEFAULT
339 #define CPP_SYSV_DEFAULT "-D_CALL_SYSV"
340 @end smallexample
341
342 while the @file{config/rs6000/eabiaix.h} target file defines
343 @code{CPP_SYSV_DEFAULT} as:
344
345 @smallexample
346 #undef CPP_SYSV_DEFAULT
347 #define CPP_SYSV_DEFAULT "-D_CALL_AIX"
348 @end smallexample
349 @end defmac
350
351 @defmac LINK_LIBGCC_SPECIAL_1
352 Define this macro if the driver program should find the library
353 @file{libgcc.a}.  If you do not define this macro, the driver program will pass
354 the argument @option{-lgcc} to tell the linker to do the search.
355 @end defmac
356
357 @defmac LINK_GCC_C_SEQUENCE_SPEC
358 The sequence in which libgcc and libc are specified to the linker.
359 By default this is @code{%G %L %G}.
360 @end defmac
361
362 @defmac LINK_COMMAND_SPEC
363 A C string constant giving the complete command line need to execute the
364 linker.  When you do this, you will need to update your port each time a
365 change is made to the link command line within @file{gcc.c}.  Therefore,
366 define this macro only if you need to completely redefine the command
367 line for invoking the linker and there is no other way to accomplish
368 the effect you need.  Overriding this macro may be avoidable by overriding
369 @code{LINK_GCC_C_SEQUENCE_SPEC} instead.
370 @end defmac
371
372 @defmac LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
373 A nonzero value causes @command{collect2} to remove duplicate @option{-L@var{directory}} search
374 directories from linking commands.  Do not give it a nonzero value if
375 removing duplicate search directories changes the linker's semantics.
376 @end defmac
377
378 @defmac MULTILIB_DEFAULTS
379 Define this macro as a C expression for the initializer of an array of
380 string to tell the driver program which options are defaults for this
381 target and thus do not need to be handled specially when using
382 @code{MULTILIB_OPTIONS}.
383
384 Do not define this macro if @code{MULTILIB_OPTIONS} is not defined in
385 the target makefile fragment or if none of the options listed in
386 @code{MULTILIB_OPTIONS} are set by default.
387 @xref{Target Fragment}.
388 @end defmac
389
390 @defmac RELATIVE_PREFIX_NOT_LINKDIR
391 Define this macro to tell @command{gcc} that it should only translate
392 a @option{-B} prefix into a @option{-L} linker option if the prefix
393 indicates an absolute file name.
394 @end defmac
395
396 @defmac MD_EXEC_PREFIX
397 If defined, this macro is an additional prefix to try after
398 @code{STANDARD_EXEC_PREFIX}.  @code{MD_EXEC_PREFIX} is not searched
399 when the compiler is built as a cross
400 compiler.  If you define @code{MD_EXEC_PREFIX}, then be sure to add it
401 to the list of directories used to find the assembler in @file{configure.in}.
402 @end defmac
403
404 @defmac STANDARD_STARTFILE_PREFIX
405 Define this macro as a C string constant if you wish to override the
406 standard choice of @code{libdir} as the default prefix to
407 try when searching for startup files such as @file{crt0.o}.
408 @code{STANDARD_STARTFILE_PREFIX} is not searched when the compiler
409 is built as a cross compiler.
410 @end defmac
411
412 @defmac STANDARD_STARTFILE_PREFIX_1
413 Define this macro as a C string constant if you wish to override the
414 standard choice of @code{/lib} as a prefix to try after the default prefix
415 when searching for startup files such as @file{crt0.o}.
416 @code{STANDARD_STARTFILE_PREFIX_1} is not searched when the compiler
417 is built as a cross compiler.
418 @end defmac
419
420 @defmac STANDARD_STARTFILE_PREFIX_2
421 Define this macro as a C string constant if you wish to override the
422 standard choice of @code{/lib} as yet another prefix to try after the
423 default prefix when searching for startup files such as @file{crt0.o}.
424 @code{STANDARD_STARTFILE_PREFIX_2} is not searched when the compiler
425 is built as a cross compiler.
426 @end defmac
427
428 @defmac MD_STARTFILE_PREFIX
429 If defined, this macro supplies an additional prefix to try after the
430 standard prefixes.  @code{MD_EXEC_PREFIX} is not searched when the
431 compiler is built as a cross compiler.
432 @end defmac
433
434 @defmac MD_STARTFILE_PREFIX_1
435 If defined, this macro supplies yet another prefix to try after the
436 standard prefixes.  It is not searched when the compiler is built as a
437 cross compiler.
438 @end defmac
439
440 @defmac INIT_ENVIRONMENT
441 Define this macro as a C string constant if you wish to set environment
442 variables for programs called by the driver, such as the assembler and
443 loader.  The driver passes the value of this macro to @code{putenv} to
444 initialize the necessary environment variables.
445 @end defmac
446
447 @defmac LOCAL_INCLUDE_DIR
448 Define this macro as a C string constant if you wish to override the
449 standard choice of @file{/usr/local/include} as the default prefix to
450 try when searching for local header files.  @code{LOCAL_INCLUDE_DIR}
451 comes before @code{SYSTEM_INCLUDE_DIR} in the search order.
452
453 Cross compilers do not search either @file{/usr/local/include} or its
454 replacement.
455 @end defmac
456
457 @defmac SYSTEM_INCLUDE_DIR
458 Define this macro as a C string constant if you wish to specify a
459 system-specific directory to search for header files before the standard
460 directory.  @code{SYSTEM_INCLUDE_DIR} comes before
461 @code{STANDARD_INCLUDE_DIR} in the search order.
462
463 Cross compilers do not use this macro and do not search the directory
464 specified.
465 @end defmac
466
467 @defmac STANDARD_INCLUDE_DIR
468 Define this macro as a C string constant if you wish to override the
469 standard choice of @file{/usr/include} as the default prefix to
470 try when searching for header files.
471
472 Cross compilers ignore this macro and do not search either
473 @file{/usr/include} or its replacement.
474 @end defmac
475
476 @defmac STANDARD_INCLUDE_COMPONENT
477 The ``component'' corresponding to @code{STANDARD_INCLUDE_DIR}.
478 See @code{INCLUDE_DEFAULTS}, below, for the description of components.
479 If you do not define this macro, no component is used.
480 @end defmac
481
482 @defmac INCLUDE_DEFAULTS
483 Define this macro if you wish to override the entire default search path
484 for include files.  For a native compiler, the default search path
485 usually consists of @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR},
486 @code{SYSTEM_INCLUDE_DIR}, @code{GPLUSPLUS_INCLUDE_DIR}, and
487 @code{STANDARD_INCLUDE_DIR}.  In addition, @code{GPLUSPLUS_INCLUDE_DIR}
488 and @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile},
489 and specify private search areas for GCC@.  The directory
490 @code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs.
491
492 The definition should be an initializer for an array of structures.
493 Each array element should have four elements: the directory name (a
494 string constant), the component name (also a string constant), a flag
495 for C++-only directories,
496 and a flag showing that the includes in the directory don't need to be
497 wrapped in @code{extern @samp{C}} when compiling C++.  Mark the end of
498 the array with a null element.
499
500 The component name denotes what GNU package the include file is part of,
501 if any, in all uppercase letters.  For example, it might be @samp{GCC}
502 or @samp{BINUTILS}.  If the package is part of a vendor-supplied
503 operating system, code the component name as @samp{0}.
504
505 For example, here is the definition used for VAX/VMS:
506
507 @smallexample
508 #define INCLUDE_DEFAULTS \
509 @{                                       \
510   @{ "GNU_GXX_INCLUDE:", "G++", 1, 1@},   \
511   @{ "GNU_CC_INCLUDE:", "GCC", 0, 0@},    \
512   @{ "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0@},  \
513   @{ ".", 0, 0, 0@},                      \
514   @{ 0, 0, 0, 0@}                         \
515 @}
516 @end smallexample
517 @end defmac
518
519 Here is the order of prefixes tried for exec files:
520
521 @enumerate
522 @item
523 Any prefixes specified by the user with @option{-B}.
524
525 @item
526 The environment variable @code{GCC_EXEC_PREFIX} or, if @code{GCC_EXEC_PREFIX}
527 is not set and the compiler has not been installed in the configure-time 
528 @var{prefix}, the location in which the compiler has actually been installed.
529
530 @item
531 The directories specified by the environment variable @code{COMPILER_PATH}.
532
533 @item
534 The macro @code{STANDARD_EXEC_PREFIX}, if the compiler has been installed
535 in the configured-time @var{prefix}. 
536
537 @item
538 The location @file{/usr/libexec/gcc/}, but only if this is a native compiler. 
539
540 @item
541 The location @file{/usr/lib/gcc/}, but only if this is a native compiler. 
542
543 @item
544 The macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native 
545 compiler.
546 @end enumerate
547
548 Here is the order of prefixes tried for startfiles:
549
550 @enumerate
551 @item
552 Any prefixes specified by the user with @option{-B}.
553
554 @item
555 The environment variable @code{GCC_EXEC_PREFIX} or its automatically determined
556 value based on the installed toolchain location.
557
558 @item
559 The directories specified by the environment variable @code{LIBRARY_PATH}
560 (or port-specific name; native only, cross compilers do not use this).
561
562 @item
563 The macro @code{STANDARD_EXEC_PREFIX}, but only if the toolchain is installed
564 in the configured @var{prefix} or this is a native compiler. 
565
566 @item
567 The location @file{/usr/lib/gcc/}, but only if this is a native compiler.
568
569 @item
570 The macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native 
571 compiler.
572
573 @item
574 The macro @code{MD_STARTFILE_PREFIX}, if defined, but only if this is a 
575 native compiler, or we have a target system root.
576
577 @item
578 The macro @code{MD_STARTFILE_PREFIX_1}, if defined, but only if this is a 
579 native compiler, or we have a target system root.
580
581 @item
582 The macro @code{STANDARD_STARTFILE_PREFIX}, with any sysroot modifications.
583 If this path is relative it will be prefixed by @code{GCC_EXEC_PREFIX} and
584 the machine suffix or @code{STANDARD_EXEC_PREFIX} and the machine suffix.
585
586 @item
587 The macro @code{STANDARD_STARTFILE_PREFIX_1}, but only if this is a native
588 compiler, or we have a target system root. The default for this macro is
589 @file{/lib/}.
590
591 @item
592 The macro @code{STANDARD_STARTFILE_PREFIX_2}, but only if this is a native
593 compiler, or we have a target system root. The default for this macro is
594 @file{/usr/lib/}.
595 @end enumerate
596
597 @node Run-time Target
598 @section Run-time Target Specification
599 @cindex run-time target specification
600 @cindex predefined macros
601 @cindex target specifications
602
603 @c prevent bad page break with this line
604 Here are run-time target specifications.
605
606 @defmac TARGET_CPU_CPP_BUILTINS ()
607 This function-like macro expands to a block of code that defines
608 built-in preprocessor macros and assertions for the target CPU, using
609 the functions @code{builtin_define}, @code{builtin_define_std} and
610 @code{builtin_assert}.  When the front end
611 calls this macro it provides a trailing semicolon, and since it has
612 finished command line option processing your code can use those
613 results freely.
614
615 @code{builtin_assert} takes a string in the form you pass to the
616 command-line option @option{-A}, such as @code{cpu=mips}, and creates
617 the assertion.  @code{builtin_define} takes a string in the form
618 accepted by option @option{-D} and unconditionally defines the macro.
619
620 @code{builtin_define_std} takes a string representing the name of an
621 object-like macro.  If it doesn't lie in the user's namespace,
622 @code{builtin_define_std} defines it unconditionally.  Otherwise, it
623 defines a version with two leading underscores, and another version
624 with two leading and trailing underscores, and defines the original
625 only if an ISO standard was not requested on the command line.  For
626 example, passing @code{unix} defines @code{__unix}, @code{__unix__}
627 and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
628 @code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
629 defines only @code{_ABI64}.
630
631 You can also test for the C dialect being compiled.  The variable
632 @code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus}
633 or @code{clk_objective_c}.  Note that if we are preprocessing
634 assembler, this variable will be @code{clk_c} but the function-like
635 macro @code{preprocessing_asm_p()} will return true, so you might want
636 to check for that first.  If you need to check for strict ANSI, the
637 variable @code{flag_iso} can be used.  The function-like macro
638 @code{preprocessing_trad_p()} can be used to check for traditional
639 preprocessing.
640 @end defmac
641
642 @defmac TARGET_OS_CPP_BUILTINS ()
643 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
644 and is used for the target operating system instead.
645 @end defmac
646
647 @defmac TARGET_OBJFMT_CPP_BUILTINS ()
648 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
649 and is used for the target object format.  @file{elfos.h} uses this
650 macro to define @code{__ELF__}, so you probably do not need to define
651 it yourself.
652 @end defmac
653
654 @deftypevar {extern int} target_flags
655 This variable is declared in @file{options.h}, which is included before
656 any target-specific headers.
657 @end deftypevar
658
659 @deftypevr {Target Hook} int TARGET_DEFAULT_TARGET_FLAGS
660 This variable specifies the initial value of @code{target_flags}.
661 Its default setting is 0.
662 @end deftypevr
663
664 @cindex optional hardware or system features
665 @cindex features, optional, in system conventions
666
667 @deftypefn {Target Hook} bool TARGET_HANDLE_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value})
668 This hook is called whenever the user specifies one of the
669 target-specific options described by the @file{.opt} definition files
670 (@pxref{Options}).  It has the opportunity to do some option-specific
671 processing and should return true if the option is valid.  The default
672 definition does nothing but return true.
673
674 @var{code} specifies the @code{OPT_@var{name}} enumeration value
675 associated with the selected option; @var{name} is just a rendering of
676 the option name in which non-alphanumeric characters are replaced by
677 underscores.  @var{arg} specifies the string argument and is null if
678 no argument was given.  If the option is flagged as a @code{UInteger}
679 (@pxref{Option properties}), @var{value} is the numeric value of the
680 argument.  Otherwise @var{value} is 1 if the positive form of the
681 option was used and 0 if the ``no-'' form was.
682 @end deftypefn
683
684 @deftypefn {Target Hook} bool TARGET_HANDLE_C_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value})
685 This target hook is called whenever the user specifies one of the
686 target-specific C language family options described by the @file{.opt}
687 definition files(@pxref{Options}).  It has the opportunity to do some
688 option-specific processing and should return true if the option is
689 valid.  The arguments are like for @code{TARGET_HANDLE_OPTION}.  The
690 default definition does nothing but return false.
691
692 In general, you should use @code{TARGET_HANDLE_OPTION} to handle
693 options.  However, if processing an option requires routines that are
694 only available in the C (and related language) front ends, then you
695 should use @code{TARGET_HANDLE_C_OPTION} instead.
696 @end deftypefn
697
698 @deftypefn {Target Hook} tree TARGET_OBJC_CONSTRUCT_STRING_OBJECT (tree @var{string})
699 Targets may provide a string object type that can be used within and between C, C++ and their respective Objective-C dialects. A string object might, for example, embed encoding and length information. These objects are considered opaque to the compiler and handled as references. An ideal implementation makes the composition of the string object match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep), allowing efficient interworking between C-only and Objective-C code. If a target implements string objects then this hook should return a reference to such an object constructed from the normal `C' string representation provided in @var{string}. At present, the hook is used by Objective-C only, to obtain a common-format string object when the target provides one.
700 @end deftypefn
701
702 @deftypefn {Target Hook} bool TARGET_STRING_OBJECT_REF_TYPE_P (const_tree @var{stringref})
703 If a target implements string objects then this hook should return @code{true} if @var{stringref} is a valid reference to such an object.
704 @end deftypefn
705
706 @deftypefn {Target Hook} void TARGET_CHECK_STRING_OBJECT_FORMAT_ARG (tree @var{format_arg}, tree @var{args_list})
707 If a target implements string objects then this hook should should  provide a facility to check the function arguments in @var{args_list}  against the format specifiers in @var{format_arg} where the type of  @var{format_arg} is one recognized as a valid string reference type.
708 @end deftypefn
709
710 @defmac TARGET_VERSION
711 This macro is a C statement to print on @code{stderr} a string
712 describing the particular machine description choice.  Every machine
713 description should define @code{TARGET_VERSION}.  For example:
714
715 @smallexample
716 #ifdef MOTOROLA
717 #define TARGET_VERSION \
718   fprintf (stderr, " (68k, Motorola syntax)");
719 #else
720 #define TARGET_VERSION \
721   fprintf (stderr, " (68k, MIT syntax)");
722 #endif
723 @end smallexample
724 @end defmac
725
726 @deftypefn {Target Hook} void TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE (void)
727 This target function is similar to the hook @code{TARGET_OPTION_OVERRIDE}
728 but is called when the optimize level is changed via an attribute or
729 pragma or when it is reset at the end of the code affected by the
730 attribute or pragma.  It is not called at the beginning of compilation
731 when @code{TARGET_OPTION_OVERRIDE} is called so if you want to perform these
732 actions then, you should have @code{TARGET_OPTION_OVERRIDE} call
733 @code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}.
734 @end deftypefn
735
736 @defmac C_COMMON_OVERRIDE_OPTIONS
737 This is similar to the @code{TARGET_OPTION_OVERRIDE} hook
738 but is only used in the C
739 language frontends (C, Objective-C, C++, Objective-C++) and so can be
740 used to alter option flag variables which only exist in those
741 frontends.
742 @end defmac
743
744 @deftypevr {Target Hook} {const struct default_options *} TARGET_OPTION_OPTIMIZATION_TABLE
745 Some machines may desire to change what optimizations are performed for
746 various optimization levels.   This variable, if defined, describes
747 options to enable at particular sets of optimization levels.  These
748 options are processed once
749 just after the optimization level is determined and before the remainder
750 of the command options have been parsed, so may be overridden by other
751 options passed explicily.
752
753 This processing is run once at program startup and when the optimization
754 options are changed via @code{#pragma GCC optimize} or by using the
755 @code{optimize} attribute.
756 @end deftypevr
757
758 @deftypefn {Target Hook} void TARGET_OPTION_INIT_STRUCT (struct gcc_options *@var{opts})
759 Set target-dependent initial values of fields in @var{opts}.
760 @end deftypefn
761
762 @deftypefn {Target Hook} void TARGET_OPTION_DEFAULT_PARAMS (void)
763 Set target-dependent default values for @option{--param} settings, using calls to @code{set_default_param_value}.
764 @end deftypefn
765
766 @deftypefn {Target Hook} void TARGET_HELP (void)
767 This hook is called in response to the user invoking
768 @option{--target-help} on the command line.  It gives the target a
769 chance to display extra information on the target specific command
770 line options found in its @file{.opt} file.
771 @end deftypefn
772
773 @defmac SWITCHABLE_TARGET
774 Some targets need to switch between substantially different subtargets
775 during compilation.  For example, the MIPS target has one subtarget for
776 the traditional MIPS architecture and another for MIPS16.  Source code
777 can switch between these two subarchitectures using the @code{mips16}
778 and @code{nomips16} attributes.
779
780 Such subtargets can differ in things like the set of available
781 registers, the set of available instructions, the costs of various
782 operations, and so on.  GCC caches a lot of this type of information
783 in global variables, and recomputing them for each subtarget takes a
784 significant amount of time.  The compiler therefore provides a facility
785 for maintaining several versions of the global variables and quickly
786 switching between them; see @file{target-globals.h} for details.
787
788 Define this macro to 1 if your target needs this facility.  The default
789 is 0.
790 @end defmac
791
792 @node Per-Function Data
793 @section Defining data structures for per-function information.
794 @cindex per-function data
795 @cindex data structures
796
797 If the target needs to store information on a per-function basis, GCC
798 provides a macro and a couple of variables to allow this.  Note, just
799 using statics to store the information is a bad idea, since GCC supports
800 nested functions, so you can be halfway through encoding one function
801 when another one comes along.
802
803 GCC defines a data structure called @code{struct function} which
804 contains all of the data specific to an individual function.  This
805 structure contains a field called @code{machine} whose type is
806 @code{struct machine_function *}, which can be used by targets to point
807 to their own specific data.
808
809 If a target needs per-function specific data it should define the type
810 @code{struct machine_function} and also the macro @code{INIT_EXPANDERS}.
811 This macro should be used to initialize the function pointer
812 @code{init_machine_status}.  This pointer is explained below.
813
814 One typical use of per-function, target specific data is to create an
815 RTX to hold the register containing the function's return address.  This
816 RTX can then be used to implement the @code{__builtin_return_address}
817 function, for level 0.
818
819 Note---earlier implementations of GCC used a single data area to hold
820 all of the per-function information.  Thus when processing of a nested
821 function began the old per-function data had to be pushed onto a
822 stack, and when the processing was finished, it had to be popped off the
823 stack.  GCC used to provide function pointers called
824 @code{save_machine_status} and @code{restore_machine_status} to handle
825 the saving and restoring of the target specific information.  Since the
826 single data area approach is no longer used, these pointers are no
827 longer supported.
828
829 @defmac INIT_EXPANDERS
830 Macro called to initialize any target specific information.  This macro
831 is called once per function, before generation of any RTL has begun.
832 The intention of this macro is to allow the initialization of the
833 function pointer @code{init_machine_status}.
834 @end defmac
835
836 @deftypevar {void (*)(struct function *)} init_machine_status
837 If this function pointer is non-@code{NULL} it will be called once per
838 function, before function compilation starts, in order to allow the
839 target to perform any target specific initialization of the
840 @code{struct function} structure.  It is intended that this would be
841 used to initialize the @code{machine} of that structure.
842
843 @code{struct machine_function} structures are expected to be freed by GC@.
844 Generally, any memory that they reference must be allocated by using
845 GC allocation, including the structure itself.
846 @end deftypevar
847
848 @node Storage Layout
849 @section Storage Layout
850 @cindex storage layout
851
852 Note that the definitions of the macros in this table which are sizes or
853 alignments measured in bits do not need to be constant.  They can be C
854 expressions that refer to static variables, such as the @code{target_flags}.
855 @xref{Run-time Target}.
856
857 @defmac BITS_BIG_ENDIAN
858 Define this macro to have the value 1 if the most significant bit in a
859 byte has the lowest number; otherwise define it to have the value zero.
860 This means that bit-field instructions count from the most significant
861 bit.  If the machine has no bit-field instructions, then this must still
862 be defined, but it doesn't matter which value it is defined to.  This
863 macro need not be a constant.
864
865 This macro does not affect the way structure fields are packed into
866 bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}.
867 @end defmac
868
869 @defmac BYTES_BIG_ENDIAN
870 Define this macro to have the value 1 if the most significant byte in a
871 word has the lowest number.  This macro need not be a constant.
872 @end defmac
873
874 @defmac WORDS_BIG_ENDIAN
875 Define this macro to have the value 1 if, in a multiword object, the
876 most significant word has the lowest number.  This applies to both
877 memory locations and registers; GCC fundamentally assumes that the
878 order of words in memory is the same as the order in registers.  This
879 macro need not be a constant.
880 @end defmac
881
882 @defmac FLOAT_WORDS_BIG_ENDIAN
883 Define this macro to have the value 1 if @code{DFmode}, @code{XFmode} or
884 @code{TFmode} floating point numbers are stored in memory with the word
885 containing the sign bit at the lowest address; otherwise define it to
886 have the value 0.  This macro need not be a constant.
887
888 You need not define this macro if the ordering is the same as for
889 multi-word integers.
890 @end defmac
891
892 @defmac BITS_PER_UNIT
893 Define this macro to be the number of bits in an addressable storage
894 unit (byte).  If you do not define this macro the default is 8.
895 @end defmac
896
897 @defmac BITS_PER_WORD
898 Number of bits in a word.  If you do not define this macro, the default
899 is @code{BITS_PER_UNIT * UNITS_PER_WORD}.
900 @end defmac
901
902 @defmac MAX_BITS_PER_WORD
903 Maximum number of bits in a word.  If this is undefined, the default is
904 @code{BITS_PER_WORD}.  Otherwise, it is the constant value that is the
905 largest value that @code{BITS_PER_WORD} can have at run-time.
906 @end defmac
907
908 @defmac UNITS_PER_WORD
909 Number of storage units in a word; normally the size of a general-purpose
910 register, a power of two from 1 or 8.
911 @end defmac
912
913 @defmac MIN_UNITS_PER_WORD
914 Minimum number of units in a word.  If this is undefined, the default is
915 @code{UNITS_PER_WORD}.  Otherwise, it is the constant value that is the
916 smallest value that @code{UNITS_PER_WORD} can have at run-time.
917 @end defmac
918
919 @defmac POINTER_SIZE
920 Width of a pointer, in bits.  You must specify a value no wider than the
921 width of @code{Pmode}.  If it is not equal to the width of @code{Pmode},
922 you must define @code{POINTERS_EXTEND_UNSIGNED}.  If you do not specify
923 a value the default is @code{BITS_PER_WORD}.
924 @end defmac
925
926 @defmac POINTERS_EXTEND_UNSIGNED
927 A C expression that determines how pointers should be extended from
928 @code{ptr_mode} to either @code{Pmode} or @code{word_mode}.  It is
929 greater than zero if pointers should be zero-extended, zero if they
930 should be sign-extended, and negative if some other sort of conversion
931 is needed.  In the last case, the extension is done by the target's
932 @code{ptr_extend} instruction.
933
934 You need not define this macro if the @code{ptr_mode}, @code{Pmode}
935 and @code{word_mode} are all the same width.
936 @end defmac
937
938 @defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type})
939 A macro to update @var{m} and @var{unsignedp} when an object whose type
940 is @var{type} and which has the specified mode and signedness is to be
941 stored in a register.  This macro is only called when @var{type} is a
942 scalar type.
943
944 On most RISC machines, which only have operations that operate on a full
945 register, define this macro to set @var{m} to @code{word_mode} if
946 @var{m} is an integer mode narrower than @code{BITS_PER_WORD}.  In most
947 cases, only integer modes should be widened because wider-precision
948 floating-point operations are usually more expensive than their narrower
949 counterparts.
950
951 For most machines, the macro definition does not change @var{unsignedp}.
952 However, some machines, have instructions that preferentially handle
953 either signed or unsigned quantities of certain modes.  For example, on
954 the DEC Alpha, 32-bit loads from memory and 32-bit add instructions
955 sign-extend the result to 64 bits.  On such machines, set
956 @var{unsignedp} according to which kind of extension is more efficient.
957
958 Do not define this macro if it would never modify @var{m}.
959 @end defmac
960
961 @deftypefn {Target Hook} {enum machine_mode} TARGET_PROMOTE_FUNCTION_MODE (const_tree @var{type}, enum machine_mode @var{mode}, int *@var{punsignedp}, const_tree @var{funtype}, int @var{for_return})
962 Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or
963 function return values.  The target hook should return the new mode
964 and possibly change @code{*@var{punsignedp}} if the promotion should
965 change signedness.  This function is called only for scalar @emph{or
966 pointer} types.
967
968 @var{for_return} allows to distinguish the promotion of arguments and
969 return values.  If it is @code{1}, a return value is being promoted and
970 @code{TARGET_FUNCTION_VALUE} must perform the same promotions done here.
971 If it is @code{2}, the returned mode should be that of the register in
972 which an incoming parameter is copied, or the outgoing result is computed;
973 then the hook should return the same mode as @code{promote_mode}, though
974 the signedness may be different.
975
976 The default is to not promote arguments and return values.  You can
977 also define the hook to @code{default_promote_function_mode_always_promote}
978 if you would like to apply the same rules given by @code{PROMOTE_MODE}.
979 @end deftypefn
980
981 @defmac PARM_BOUNDARY
982 Normal alignment required for function parameters on the stack, in
983 bits.  All stack parameters receive at least this much alignment
984 regardless of data type.  On most machines, this is the same as the
985 size of an integer.
986 @end defmac
987
988 @defmac STACK_BOUNDARY
989 Define this macro to the minimum alignment enforced by hardware for the
990 stack pointer on this machine.  The definition is a C expression for the
991 desired alignment (measured in bits).  This value is used as a default
992 if @code{PREFERRED_STACK_BOUNDARY} is not defined.  On most machines,
993 this should be the same as @code{PARM_BOUNDARY}.
994 @end defmac
995
996 @defmac PREFERRED_STACK_BOUNDARY
997 Define this macro if you wish to preserve a certain alignment for the
998 stack pointer, greater than what the hardware enforces.  The definition
999 is a C expression for the desired alignment (measured in bits).  This
1000 macro must evaluate to a value equal to or larger than
1001 @code{STACK_BOUNDARY}.
1002 @end defmac
1003
1004 @defmac INCOMING_STACK_BOUNDARY
1005 Define this macro if the incoming stack boundary may be different
1006 from @code{PREFERRED_STACK_BOUNDARY}.  This macro must evaluate
1007 to a value equal to or larger than @code{STACK_BOUNDARY}.
1008 @end defmac
1009
1010 @defmac FUNCTION_BOUNDARY
1011 Alignment required for a function entry point, in bits.
1012 @end defmac
1013
1014 @defmac BIGGEST_ALIGNMENT
1015 Biggest alignment that any data type can require on this machine, in
1016 bits.  Note that this is not the biggest alignment that is supported,
1017 just the biggest alignment that, when violated, may cause a fault.
1018 @end defmac
1019
1020 @defmac MALLOC_ABI_ALIGNMENT
1021 Alignment, in bits, a C conformant malloc implementation has to
1022 provide.  If not defined, the default value is @code{BITS_PER_WORD}.
1023 @end defmac
1024
1025 @defmac ATTRIBUTE_ALIGNED_VALUE
1026 Alignment used by the @code{__attribute__ ((aligned))} construct.  If
1027 not defined, the default value is @code{BIGGEST_ALIGNMENT}.
1028 @end defmac
1029
1030 @defmac MINIMUM_ATOMIC_ALIGNMENT
1031 If defined, the smallest alignment, in bits, that can be given to an
1032 object that can be referenced in one operation, without disturbing any
1033 nearby object.  Normally, this is @code{BITS_PER_UNIT}, but may be larger
1034 on machines that don't have byte or half-word store operations.
1035 @end defmac
1036
1037 @defmac BIGGEST_FIELD_ALIGNMENT
1038 Biggest alignment that any structure or union field can require on this
1039 machine, in bits.  If defined, this overrides @code{BIGGEST_ALIGNMENT} for
1040 structure and union fields only, unless the field alignment has been set
1041 by the @code{__attribute__ ((aligned (@var{n})))} construct.
1042 @end defmac
1043
1044 @defmac ADJUST_FIELD_ALIGN (@var{field}, @var{computed})
1045 An expression for the alignment of a structure field @var{field} if the
1046 alignment computed in the usual way (including applying of
1047 @code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the
1048 alignment) is @var{computed}.  It overrides alignment only if the
1049 field alignment has not been set by the
1050 @code{__attribute__ ((aligned (@var{n})))} construct.
1051 @end defmac
1052
1053 @defmac MAX_STACK_ALIGNMENT
1054 Biggest stack alignment guaranteed by the backend.  Use this macro
1055 to specify the maximum alignment of a variable on stack.
1056
1057 If not defined, the default value is @code{STACK_BOUNDARY}.
1058
1059 @c FIXME: The default should be @code{PREFERRED_STACK_BOUNDARY}.
1060 @c But the fix for PR 32893 indicates that we can only guarantee
1061 @c maximum stack alignment on stack up to @code{STACK_BOUNDARY}, not
1062 @c @code{PREFERRED_STACK_BOUNDARY}, if stack alignment isn't supported.
1063 @end defmac
1064
1065 @defmac MAX_OFILE_ALIGNMENT
1066 Biggest alignment supported by the object file format of this machine.
1067 Use this macro to limit the alignment which can be specified using the
1068 @code{__attribute__ ((aligned (@var{n})))} construct.  If not defined,
1069 the default value is @code{BIGGEST_ALIGNMENT}.
1070
1071 On systems that use ELF, the default (in @file{config/elfos.h}) is
1072 the largest supported 32-bit ELF section alignment representable on
1073 a 32-bit host e.g. @samp{(((unsigned HOST_WIDEST_INT) 1 << 28) * 8)}.
1074 On 32-bit ELF the largest supported section alignment in bits is
1075 @samp{(0x80000000 * 8)}, but this is not representable on 32-bit hosts.
1076 @end defmac
1077
1078 @defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
1079 If defined, a C expression to compute the alignment for a variable in
1080 the static store.  @var{type} is the data type, and @var{basic-align} is
1081 the alignment that the object would ordinarily have.  The value of this
1082 macro is used instead of that alignment to align the object.
1083
1084 If this macro is not defined, then @var{basic-align} is used.
1085
1086 @findex strcpy
1087 One use of this macro is to increase alignment of medium-size data to
1088 make it all fit in fewer cache lines.  Another is to cause character
1089 arrays to be word-aligned so that @code{strcpy} calls that copy
1090 constants to character arrays can be done inline.
1091 @end defmac
1092
1093 @defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
1094 If defined, a C expression to compute the alignment given to a constant
1095 that is being placed in memory.  @var{constant} is the constant and
1096 @var{basic-align} is the alignment that the object would ordinarily
1097 have.  The value of this macro is used instead of that alignment to
1098 align the object.
1099
1100 If this macro is not defined, then @var{basic-align} is used.
1101
1102 The typical use of this macro is to increase alignment for string
1103 constants to be word aligned so that @code{strcpy} calls that copy
1104 constants can be done inline.
1105 @end defmac
1106
1107 @defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
1108 If defined, a C expression to compute the alignment for a variable in
1109 the local store.  @var{type} is the data type, and @var{basic-align} is
1110 the alignment that the object would ordinarily have.  The value of this
1111 macro is used instead of that alignment to align the object.
1112
1113 If this macro is not defined, then @var{basic-align} is used.
1114
1115 One use of this macro is to increase alignment of medium-size data to
1116 make it all fit in fewer cache lines.
1117
1118 If the value of this macro has a type, it should be an unsigned type.
1119 @end defmac
1120
1121 @defmac STACK_SLOT_ALIGNMENT (@var{type}, @var{mode}, @var{basic-align})
1122 If defined, a C expression to compute the alignment for stack slot.
1123 @var{type} is the data type, @var{mode} is the widest mode available,
1124 and @var{basic-align} is the alignment that the slot would ordinarily
1125 have.  The value of this macro is used instead of that alignment to
1126 align the slot.
1127
1128 If this macro is not defined, then @var{basic-align} is used when
1129 @var{type} is @code{NULL}.  Otherwise, @code{LOCAL_ALIGNMENT} will
1130 be used.
1131
1132 This macro is to set alignment of stack slot to the maximum alignment
1133 of all possible modes which the slot may have.
1134
1135 If the value of this macro has a type, it should be an unsigned type.
1136 @end defmac
1137
1138 @defmac LOCAL_DECL_ALIGNMENT (@var{decl})
1139 If defined, a C expression to compute the alignment for a local
1140 variable @var{decl}.
1141
1142 If this macro is not defined, then
1143 @code{LOCAL_ALIGNMENT (TREE_TYPE (@var{decl}), DECL_ALIGN (@var{decl}))}
1144 is used.
1145
1146 One use of this macro is to increase alignment of medium-size data to
1147 make it all fit in fewer cache lines.
1148
1149 If the value of this macro has a type, it should be an unsigned type.
1150 @end defmac
1151
1152 @defmac MINIMUM_ALIGNMENT (@var{exp}, @var{mode}, @var{align})
1153 If defined, a C expression to compute the minimum required alignment
1154 for dynamic stack realignment purposes for @var{exp} (a type or decl),
1155 @var{mode}, assuming normal alignment @var{align}.
1156
1157 If this macro is not defined, then @var{align} will be used.
1158 @end defmac
1159
1160 @defmac EMPTY_FIELD_BOUNDARY
1161 Alignment in bits to be given to a structure bit-field that follows an
1162 empty field such as @code{int : 0;}.
1163
1164 If @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro.
1165 @end defmac
1166
1167 @defmac STRUCTURE_SIZE_BOUNDARY
1168 Number of bits which any structure or union's size must be a multiple of.
1169 Each structure or union's size is rounded up to a multiple of this.
1170
1171 If you do not define this macro, the default is the same as
1172 @code{BITS_PER_UNIT}.
1173 @end defmac
1174
1175 @defmac STRICT_ALIGNMENT
1176 Define this macro to be the value 1 if instructions will fail to work
1177 if given data not on the nominal alignment.  If instructions will merely
1178 go slower in that case, define this macro as 0.
1179 @end defmac
1180
1181 @defmac PCC_BITFIELD_TYPE_MATTERS
1182 Define this if you wish to imitate the way many other C compilers handle
1183 alignment of bit-fields and the structures that contain them.
1184
1185 The behavior is that the type written for a named bit-field (@code{int},
1186 @code{short}, or other integer type) imposes an alignment for the entire
1187 structure, as if the structure really did contain an ordinary field of
1188 that type.  In addition, the bit-field is placed within the structure so
1189 that it would fit within such a field, not crossing a boundary for it.
1190
1191 Thus, on most machines, a named bit-field whose type is written as
1192 @code{int} would not cross a four-byte boundary, and would force
1193 four-byte alignment for the whole structure.  (The alignment used may
1194 not be four bytes; it is controlled by the other alignment parameters.)
1195
1196 An unnamed bit-field will not affect the alignment of the containing
1197 structure.
1198
1199 If the macro is defined, its definition should be a C expression;
1200 a nonzero value for the expression enables this behavior.
1201
1202 Note that if this macro is not defined, or its value is zero, some
1203 bit-fields may cross more than one alignment boundary.  The compiler can
1204 support such references if there are @samp{insv}, @samp{extv}, and
1205 @samp{extzv} insns that can directly reference memory.
1206
1207 The other known way of making bit-fields work is to define
1208 @code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}.
1209 Then every structure can be accessed with fullwords.
1210
1211 Unless the machine has bit-field instructions or you define
1212 @code{STRUCTURE_SIZE_BOUNDARY} that way, you must define
1213 @code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value.
1214
1215 If your aim is to make GCC use the same conventions for laying out
1216 bit-fields as are used by another compiler, here is how to investigate
1217 what the other compiler does.  Compile and run this program:
1218
1219 @smallexample
1220 struct foo1
1221 @{
1222   char x;
1223   char :0;
1224   char y;
1225 @};
1226
1227 struct foo2
1228 @{
1229   char x;
1230   int :0;
1231   char y;
1232 @};
1233
1234 main ()
1235 @{
1236   printf ("Size of foo1 is %d\n",
1237           sizeof (struct foo1));
1238   printf ("Size of foo2 is %d\n",
1239           sizeof (struct foo2));
1240   exit (0);
1241 @}
1242 @end smallexample
1243
1244 If this prints 2 and 5, then the compiler's behavior is what you would
1245 get from @code{PCC_BITFIELD_TYPE_MATTERS}.
1246 @end defmac
1247
1248 @defmac BITFIELD_NBYTES_LIMITED
1249 Like @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited
1250 to aligning a bit-field within the structure.
1251 @end defmac
1252
1253 @deftypefn {Target Hook} bool TARGET_ALIGN_ANON_BITFIELD (void)
1254 When @code{PCC_BITFIELD_TYPE_MATTERS} is true this hook will determine
1255 whether unnamed bitfields affect the alignment of the containing
1256 structure.  The hook should return true if the structure should inherit
1257 the alignment requirements of an unnamed bitfield's type.
1258 @end deftypefn
1259
1260 @deftypefn {Target Hook} bool TARGET_NARROW_VOLATILE_BITFIELD (void)
1261 This target hook should return @code{true} if accesses to volatile bitfields
1262 should use the narrowest mode possible.  It should return @code{false} if
1263 these accesses should use the bitfield container type.
1264
1265 The default is @code{!TARGET_STRICT_ALIGN}.
1266 @end deftypefn
1267
1268 @defmac MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode})
1269 Return 1 if a structure or array containing @var{field} should be accessed using
1270 @code{BLKMODE}.
1271
1272 If @var{field} is the only field in the structure, @var{mode} is its
1273 mode, otherwise @var{mode} is VOIDmode.  @var{mode} is provided in the
1274 case where structures of one field would require the structure's mode to
1275 retain the field's mode.
1276
1277 Normally, this is not needed.
1278 @end defmac
1279
1280 @defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified})
1281 Define this macro as an expression for the alignment of a type (given
1282 by @var{type} as a tree node) if the alignment computed in the usual
1283 way is @var{computed} and the alignment explicitly specified was
1284 @var{specified}.
1285
1286 The default is to use @var{specified} if it is larger; otherwise, use
1287 the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT}
1288 @end defmac
1289
1290 @defmac MAX_FIXED_MODE_SIZE
1291 An integer expression for the size in bits of the largest integer
1292 machine mode that should actually be used.  All integer machine modes of
1293 this size or smaller can be used for structures and unions with the
1294 appropriate sizes.  If this macro is undefined, @code{GET_MODE_BITSIZE
1295 (DImode)} is assumed.
1296 @end defmac
1297
1298 @defmac STACK_SAVEAREA_MODE (@var{save_level})
1299 If defined, an expression of type @code{enum machine_mode} that
1300 specifies the mode of the save area operand of a
1301 @code{save_stack_@var{level}} named pattern (@pxref{Standard Names}).
1302 @var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or
1303 @code{SAVE_NONLOCAL} and selects which of the three named patterns is
1304 having its mode specified.
1305
1306 You need not define this macro if it always returns @code{Pmode}.  You
1307 would most commonly define this macro if the
1308 @code{save_stack_@var{level}} patterns need to support both a 32- and a
1309 64-bit mode.
1310 @end defmac
1311
1312 @defmac STACK_SIZE_MODE
1313 If defined, an expression of type @code{enum machine_mode} that
1314 specifies the mode of the size increment operand of an
1315 @code{allocate_stack} named pattern (@pxref{Standard Names}).
1316
1317 You need not define this macro if it always returns @code{word_mode}.
1318 You would most commonly define this macro if the @code{allocate_stack}
1319 pattern needs to support both a 32- and a 64-bit mode.
1320 @end defmac
1321
1322 @deftypefn {Target Hook} {enum machine_mode} TARGET_LIBGCC_CMP_RETURN_MODE (void)
1323 This target hook should return the mode to be used for the return value
1324 of compare instructions expanded to libgcc calls.  If not defined
1325 @code{word_mode} is returned which is the right choice for a majority of
1326 targets.
1327 @end deftypefn
1328
1329 @deftypefn {Target Hook} {enum machine_mode} TARGET_LIBGCC_SHIFT_COUNT_MODE (void)
1330 This target hook should return the mode to be used for the shift count operand
1331 of shift instructions expanded to libgcc calls.  If not defined
1332 @code{word_mode} is returned which is the right choice for a majority of
1333 targets.
1334 @end deftypefn
1335
1336 @deftypefn {Target Hook} {enum machine_mode} TARGET_UNWIND_WORD_MODE (void)
1337 Return machine mode to be used for @code{_Unwind_Word} type.
1338 The default is to use @code{word_mode}.
1339 @end deftypefn
1340
1341 @defmac ROUND_TOWARDS_ZERO
1342 If defined, this macro should be true if the prevailing rounding
1343 mode is towards zero.
1344
1345 Defining this macro only affects the way @file{libgcc.a} emulates
1346 floating-point arithmetic.
1347
1348 Not defining this macro is equivalent to returning zero.
1349 @end defmac
1350
1351 @defmac LARGEST_EXPONENT_IS_NORMAL (@var{size})
1352 This macro should return true if floats with @var{size}
1353 bits do not have a NaN or infinity representation, but use the largest
1354 exponent for normal numbers instead.
1355
1356 Defining this macro only affects the way @file{libgcc.a} emulates
1357 floating-point arithmetic.
1358
1359 The default definition of this macro returns false for all sizes.
1360 @end defmac
1361
1362 @deftypefn {Target Hook} bool TARGET_MS_BITFIELD_LAYOUT_P (const_tree @var{record_type})
1363 This target hook returns @code{true} if bit-fields in the given
1364 @var{record_type} are to be laid out following the rules of Microsoft
1365 Visual C/C++, namely: (i) a bit-field won't share the same storage
1366 unit with the previous bit-field if their underlying types have
1367 different sizes, and the bit-field will be aligned to the highest
1368 alignment of the underlying types of itself and of the previous
1369 bit-field; (ii) a zero-sized bit-field will affect the alignment of
1370 the whole enclosing structure, even if it is unnamed; except that
1371 (iii) a zero-sized bit-field will be disregarded unless it follows
1372 another bit-field of nonzero size.  If this hook returns @code{true},
1373 other macros that control bit-field layout are ignored.
1374
1375 When a bit-field is inserted into a packed record, the whole size
1376 of the underlying type is used by one or more same-size adjacent
1377 bit-fields (that is, if its long:3, 32 bits is used in the record,
1378 and any additional adjacent long bit-fields are packed into the same
1379 chunk of 32 bits.  However, if the size changes, a new field of that
1380 size is allocated).  In an unpacked record, this is the same as using
1381 alignment, but not equivalent when packing.
1382
1383 If both MS bit-fields and @samp{__attribute__((packed))} are used,
1384 the latter will take precedence.  If @samp{__attribute__((packed))} is
1385 used on a single field when MS bit-fields are in use, it will take
1386 precedence for that field, but the alignment of the rest of the structure
1387 may affect its placement.
1388 @end deftypefn
1389
1390 @deftypefn {Target Hook} bool TARGET_DECIMAL_FLOAT_SUPPORTED_P (void)
1391 Returns true if the target supports decimal floating point.
1392 @end deftypefn
1393
1394 @deftypefn {Target Hook} bool TARGET_FIXED_POINT_SUPPORTED_P (void)
1395 Returns true if the target supports fixed-point arithmetic.
1396 @end deftypefn
1397
1398 @deftypefn {Target Hook} void TARGET_EXPAND_TO_RTL_HOOK (void)
1399 This hook is called just before expansion into rtl, allowing the target
1400 to perform additional initializations or analysis before the expansion.
1401 For example, the rs6000 port uses it to allocate a scratch stack slot
1402 for use in copying SDmode values between memory and floating point
1403 registers whenever the function being expanded has any SDmode
1404 usage.
1405 @end deftypefn
1406
1407 @deftypefn {Target Hook} void TARGET_INSTANTIATE_DECLS (void)
1408 This hook allows the backend to perform additional instantiations on rtl
1409 that are not actually in any insns yet, but will be later.
1410 @end deftypefn
1411
1412 @deftypefn {Target Hook} {const char *} TARGET_MANGLE_TYPE (const_tree @var{type})
1413 If your target defines any fundamental types, or any types your target
1414 uses should be mangled differently from the default, define this hook
1415 to return the appropriate encoding for these types as part of a C++
1416 mangled name.  The @var{type} argument is the tree structure representing
1417 the type to be mangled.  The hook may be applied to trees which are
1418 not target-specific fundamental types; it should return @code{NULL}
1419 for all such types, as well as arguments it does not recognize.  If the
1420 return value is not @code{NULL}, it must point to a statically-allocated
1421 string constant.
1422
1423 Target-specific fundamental types might be new fundamental types or
1424 qualified versions of ordinary fundamental types.  Encode new
1425 fundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name}
1426 is the name used for the type in source code, and @var{n} is the
1427 length of @var{name} in decimal.  Encode qualified versions of
1428 ordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where
1429 @var{name} is the name used for the type qualifier in source code,
1430 @var{n} is the length of @var{name} as above, and @var{code} is the
1431 code used to represent the unqualified version of this type.  (See
1432 @code{write_builtin_type} in @file{cp/mangle.c} for the list of
1433 codes.)  In both cases the spaces are for clarity; do not include any
1434 spaces in your string.
1435
1436 This hook is applied to types prior to typedef resolution.  If the mangled
1437 name for a particular type depends only on that type's main variant, you
1438 can perform typedef resolution yourself using @code{TYPE_MAIN_VARIANT}
1439 before mangling.
1440
1441 The default version of this hook always returns @code{NULL}, which is
1442 appropriate for a target that does not define any new fundamental
1443 types.
1444 @end deftypefn
1445
1446 @node Type Layout
1447 @section Layout of Source Language Data Types
1448
1449 These macros define the sizes and other characteristics of the standard
1450 basic data types used in programs being compiled.  Unlike the macros in
1451 the previous section, these apply to specific features of C and related
1452 languages, rather than to fundamental aspects of storage layout.
1453
1454 @defmac INT_TYPE_SIZE
1455 A C expression for the size in bits of the type @code{int} on the
1456 target machine.  If you don't define this, the default is one word.
1457 @end defmac
1458
1459 @defmac SHORT_TYPE_SIZE
1460 A C expression for the size in bits of the type @code{short} on the
1461 target machine.  If you don't define this, the default is half a word.
1462 (If this would be less than one storage unit, it is rounded up to one
1463 unit.)
1464 @end defmac
1465
1466 @defmac LONG_TYPE_SIZE
1467 A C expression for the size in bits of the type @code{long} on the
1468 target machine.  If you don't define this, the default is one word.
1469 @end defmac
1470
1471 @defmac ADA_LONG_TYPE_SIZE
1472 On some machines, the size used for the Ada equivalent of the type
1473 @code{long} by a native Ada compiler differs from that used by C@.  In
1474 that situation, define this macro to be a C expression to be used for
1475 the size of that type.  If you don't define this, the default is the
1476 value of @code{LONG_TYPE_SIZE}.
1477 @end defmac
1478
1479 @defmac LONG_LONG_TYPE_SIZE
1480 A C expression for the size in bits of the type @code{long long} on the
1481 target machine.  If you don't define this, the default is two
1482 words.  If you want to support GNU Ada on your machine, the value of this
1483 macro must be at least 64.
1484 @end defmac
1485
1486 @defmac CHAR_TYPE_SIZE
1487 A C expression for the size in bits of the type @code{char} on the
1488 target machine.  If you don't define this, the default is
1489 @code{BITS_PER_UNIT}.
1490 @end defmac
1491
1492 @defmac BOOL_TYPE_SIZE
1493 A C expression for the size in bits of the C++ type @code{bool} and
1494 C99 type @code{_Bool} on the target machine.  If you don't define
1495 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
1496 @end defmac
1497
1498 @defmac FLOAT_TYPE_SIZE
1499 A C expression for the size in bits of the type @code{float} on the
1500 target machine.  If you don't define this, the default is one word.
1501 @end defmac
1502
1503 @defmac DOUBLE_TYPE_SIZE
1504 A C expression for the size in bits of the type @code{double} on the
1505 target machine.  If you don't define this, the default is two
1506 words.
1507 @end defmac
1508
1509 @defmac LONG_DOUBLE_TYPE_SIZE
1510 A C expression for the size in bits of the type @code{long double} on
1511 the target machine.  If you don't define this, the default is two
1512 words.
1513 @end defmac
1514
1515 @defmac SHORT_FRACT_TYPE_SIZE
1516 A C expression for the size in bits of the type @code{short _Fract} on
1517 the target machine.  If you don't define this, the default is
1518 @code{BITS_PER_UNIT}.
1519 @end defmac
1520
1521 @defmac FRACT_TYPE_SIZE
1522 A C expression for the size in bits of the type @code{_Fract} on
1523 the target machine.  If you don't define this, the default is
1524 @code{BITS_PER_UNIT * 2}.
1525 @end defmac
1526
1527 @defmac LONG_FRACT_TYPE_SIZE
1528 A C expression for the size in bits of the type @code{long _Fract} on
1529 the target machine.  If you don't define this, the default is
1530 @code{BITS_PER_UNIT * 4}.
1531 @end defmac
1532
1533 @defmac LONG_LONG_FRACT_TYPE_SIZE
1534 A C expression for the size in bits of the type @code{long long _Fract} on
1535 the target machine.  If you don't define this, the default is
1536 @code{BITS_PER_UNIT * 8}.
1537 @end defmac
1538
1539 @defmac SHORT_ACCUM_TYPE_SIZE
1540 A C expression for the size in bits of the type @code{short _Accum} on
1541 the target machine.  If you don't define this, the default is
1542 @code{BITS_PER_UNIT * 2}.
1543 @end defmac
1544
1545 @defmac ACCUM_TYPE_SIZE
1546 A C expression for the size in bits of the type @code{_Accum} on
1547 the target machine.  If you don't define this, the default is
1548 @code{BITS_PER_UNIT * 4}.
1549 @end defmac
1550
1551 @defmac LONG_ACCUM_TYPE_SIZE
1552 A C expression for the size in bits of the type @code{long _Accum} on
1553 the target machine.  If you don't define this, the default is
1554 @code{BITS_PER_UNIT * 8}.
1555 @end defmac
1556
1557 @defmac LONG_LONG_ACCUM_TYPE_SIZE
1558 A C expression for the size in bits of the type @code{long long _Accum} on
1559 the target machine.  If you don't define this, the default is
1560 @code{BITS_PER_UNIT * 16}.
1561 @end defmac
1562
1563 @defmac LIBGCC2_LONG_DOUBLE_TYPE_SIZE
1564 Define this macro if @code{LONG_DOUBLE_TYPE_SIZE} is not constant or
1565 if you want routines in @file{libgcc2.a} for a size other than
1566 @code{LONG_DOUBLE_TYPE_SIZE}.  If you don't define this, the
1567 default is @code{LONG_DOUBLE_TYPE_SIZE}.
1568 @end defmac
1569
1570 @defmac LIBGCC2_HAS_DF_MODE
1571 Define this macro if neither @code{DOUBLE_TYPE_SIZE} nor
1572 @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is
1573 @code{DFmode} but you want @code{DFmode} routines in @file{libgcc2.a}
1574 anyway.  If you don't define this and either @code{DOUBLE_TYPE_SIZE}
1575 or @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64 then the default is 1,
1576 otherwise it is 0.
1577 @end defmac
1578
1579 @defmac LIBGCC2_HAS_XF_MODE
1580 Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1581 @code{XFmode} but you want @code{XFmode} routines in @file{libgcc2.a}
1582 anyway.  If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1583 is 80 then the default is 1, otherwise it is 0.
1584 @end defmac
1585
1586 @defmac LIBGCC2_HAS_TF_MODE
1587 Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1588 @code{TFmode} but you want @code{TFmode} routines in @file{libgcc2.a}
1589 anyway.  If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1590 is 128 then the default is 1, otherwise it is 0.
1591 @end defmac
1592
1593 @defmac SF_SIZE
1594 @defmacx DF_SIZE
1595 @defmacx XF_SIZE
1596 @defmacx TF_SIZE
1597 Define these macros to be the size in bits of the mantissa of
1598 @code{SFmode}, @code{DFmode}, @code{XFmode} and @code{TFmode} values,
1599 if the defaults in @file{libgcc2.h} are inappropriate.  By default,
1600 @code{FLT_MANT_DIG} is used for @code{SF_SIZE}, @code{LDBL_MANT_DIG}
1601 for @code{XF_SIZE} and @code{TF_SIZE}, and @code{DBL_MANT_DIG} or
1602 @code{LDBL_MANT_DIG} for @code{DF_SIZE} according to whether
1603 @code{DOUBLE_TYPE_SIZE} or
1604 @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64.
1605 @end defmac
1606
1607 @defmac TARGET_FLT_EVAL_METHOD
1608 A C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h},
1609 assuming, if applicable, that the floating-point control word is in its
1610 default state.  If you do not define this macro the value of
1611 @code{FLT_EVAL_METHOD} will be zero.
1612 @end defmac
1613
1614 @defmac WIDEST_HARDWARE_FP_SIZE
1615 A C expression for the size in bits of the widest floating-point format
1616 supported by the hardware.  If you define this macro, you must specify a
1617 value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
1618 If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
1619 is the default.
1620 @end defmac
1621
1622 @defmac DEFAULT_SIGNED_CHAR
1623 An expression whose value is 1 or 0, according to whether the type
1624 @code{char} should be signed or unsigned by default.  The user can
1625 always override this default with the options @option{-fsigned-char}
1626 and @option{-funsigned-char}.
1627 @end defmac
1628
1629 @deftypefn {Target Hook} bool TARGET_DEFAULT_SHORT_ENUMS (void)
1630 This target hook should return true if the compiler should give an
1631 @code{enum} type only as many bytes as it takes to represent the range
1632 of possible values of that type.  It should return false if all
1633 @code{enum} types should be allocated like @code{int}.
1634
1635 The default is to return false.
1636 @end deftypefn
1637
1638 @defmac SIZE_TYPE
1639 A C expression for a string describing the name of the data type to use
1640 for size values.  The typedef name @code{size_t} is defined using the
1641 contents of the string.
1642
1643 The string can contain more than one keyword.  If so, separate them with
1644 spaces, and write first any length keyword, then @code{unsigned} if
1645 appropriate, and finally @code{int}.  The string must exactly match one
1646 of the data type names defined in the function
1647 @code{init_decl_processing} in the file @file{c-decl.c}.  You may not
1648 omit @code{int} or change the order---that would cause the compiler to
1649 crash on startup.
1650
1651 If you don't define this macro, the default is @code{"long unsigned
1652 int"}.
1653 @end defmac
1654
1655 @defmac PTRDIFF_TYPE
1656 A C expression for a string describing the name of the data type to use
1657 for the result of subtracting two pointers.  The typedef name
1658 @code{ptrdiff_t} is defined using the contents of the string.  See
1659 @code{SIZE_TYPE} above for more information.
1660
1661 If you don't define this macro, the default is @code{"long int"}.
1662 @end defmac
1663
1664 @defmac WCHAR_TYPE
1665 A C expression for a string describing the name of the data type to use
1666 for wide characters.  The typedef name @code{wchar_t} is defined using
1667 the contents of the string.  See @code{SIZE_TYPE} above for more
1668 information.
1669
1670 If you don't define this macro, the default is @code{"int"}.
1671 @end defmac
1672
1673 @defmac WCHAR_TYPE_SIZE
1674 A C expression for the size in bits of the data type for wide
1675 characters.  This is used in @code{cpp}, which cannot make use of
1676 @code{WCHAR_TYPE}.
1677 @end defmac
1678
1679 @defmac WINT_TYPE
1680 A C expression for a string describing the name of the data type to
1681 use for wide characters passed to @code{printf} and returned from
1682 @code{getwc}.  The typedef name @code{wint_t} is defined using the
1683 contents of the string.  See @code{SIZE_TYPE} above for more
1684 information.
1685
1686 If you don't define this macro, the default is @code{"unsigned int"}.
1687 @end defmac
1688
1689 @defmac INTMAX_TYPE
1690 A C expression for a string describing the name of the data type that
1691 can represent any value of any standard or extended signed integer type.
1692 The typedef name @code{intmax_t} is defined using the contents of the
1693 string.  See @code{SIZE_TYPE} above for more information.
1694
1695 If you don't define this macro, the default is the first of
1696 @code{"int"}, @code{"long int"}, or @code{"long long int"} that has as
1697 much precision as @code{long long int}.
1698 @end defmac
1699
1700 @defmac UINTMAX_TYPE
1701 A C expression for a string describing the name of the data type that
1702 can represent any value of any standard or extended unsigned integer
1703 type.  The typedef name @code{uintmax_t} is defined using the contents
1704 of the string.  See @code{SIZE_TYPE} above for more information.
1705
1706 If you don't define this macro, the default is the first of
1707 @code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long
1708 unsigned int"} that has as much precision as @code{long long unsigned
1709 int}.
1710 @end defmac
1711
1712 @defmac SIG_ATOMIC_TYPE
1713 @defmacx INT8_TYPE
1714 @defmacx INT16_TYPE
1715 @defmacx INT32_TYPE
1716 @defmacx INT64_TYPE
1717 @defmacx UINT8_TYPE
1718 @defmacx UINT16_TYPE
1719 @defmacx UINT32_TYPE
1720 @defmacx UINT64_TYPE
1721 @defmacx INT_LEAST8_TYPE
1722 @defmacx INT_LEAST16_TYPE
1723 @defmacx INT_LEAST32_TYPE
1724 @defmacx INT_LEAST64_TYPE
1725 @defmacx UINT_LEAST8_TYPE
1726 @defmacx UINT_LEAST16_TYPE
1727 @defmacx UINT_LEAST32_TYPE
1728 @defmacx UINT_LEAST64_TYPE
1729 @defmacx INT_FAST8_TYPE
1730 @defmacx INT_FAST16_TYPE
1731 @defmacx INT_FAST32_TYPE
1732 @defmacx INT_FAST64_TYPE
1733 @defmacx UINT_FAST8_TYPE
1734 @defmacx UINT_FAST16_TYPE
1735 @defmacx UINT_FAST32_TYPE
1736 @defmacx UINT_FAST64_TYPE
1737 @defmacx INTPTR_TYPE
1738 @defmacx UINTPTR_TYPE
1739 C expressions for the standard types @code{sig_atomic_t},
1740 @code{int8_t}, @code{int16_t}, @code{int32_t}, @code{int64_t},
1741 @code{uint8_t}, @code{uint16_t}, @code{uint32_t}, @code{uint64_t},
1742 @code{int_least8_t}, @code{int_least16_t}, @code{int_least32_t},
1743 @code{int_least64_t}, @code{uint_least8_t}, @code{uint_least16_t},
1744 @code{uint_least32_t}, @code{uint_least64_t}, @code{int_fast8_t},
1745 @code{int_fast16_t}, @code{int_fast32_t}, @code{int_fast64_t},
1746 @code{uint_fast8_t}, @code{uint_fast16_t}, @code{uint_fast32_t},
1747 @code{uint_fast64_t}, @code{intptr_t}, and @code{uintptr_t}.  See
1748 @code{SIZE_TYPE} above for more information.
1749
1750 If any of these macros evaluates to a null pointer, the corresponding
1751 type is not supported; if GCC is configured to provide
1752 @code{<stdint.h>} in such a case, the header provided may not conform
1753 to C99, depending on the type in question.  The defaults for all of
1754 these macros are null pointers.
1755 @end defmac
1756
1757 @defmac TARGET_PTRMEMFUNC_VBIT_LOCATION
1758 The C++ compiler represents a pointer-to-member-function with a struct
1759 that looks like:
1760
1761 @smallexample
1762   struct @{
1763     union @{
1764       void (*fn)();
1765       ptrdiff_t vtable_index;
1766     @};
1767     ptrdiff_t delta;
1768   @};
1769 @end smallexample
1770
1771 @noindent
1772 The C++ compiler must use one bit to indicate whether the function that
1773 will be called through a pointer-to-member-function is virtual.
1774 Normally, we assume that the low-order bit of a function pointer must
1775 always be zero.  Then, by ensuring that the vtable_index is odd, we can
1776 distinguish which variant of the union is in use.  But, on some
1777 platforms function pointers can be odd, and so this doesn't work.  In
1778 that case, we use the low-order bit of the @code{delta} field, and shift
1779 the remainder of the @code{delta} field to the left.
1780
1781 GCC will automatically make the right selection about where to store
1782 this bit using the @code{FUNCTION_BOUNDARY} setting for your platform.
1783 However, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY}
1784 set such that functions always start at even addresses, but the lowest
1785 bit of pointers to functions indicate whether the function at that
1786 address is in ARM or Thumb mode.  If this is the case of your
1787 architecture, you should define this macro to
1788 @code{ptrmemfunc_vbit_in_delta}.
1789
1790 In general, you should not have to define this macro.  On architectures
1791 in which function addresses are always even, according to
1792 @code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to
1793 @code{ptrmemfunc_vbit_in_pfn}.
1794 @end defmac
1795
1796 @defmac TARGET_VTABLE_USES_DESCRIPTORS
1797 Normally, the C++ compiler uses function pointers in vtables.  This
1798 macro allows the target to change to use ``function descriptors''
1799 instead.  Function descriptors are found on targets for whom a
1800 function pointer is actually a small data structure.  Normally the
1801 data structure consists of the actual code address plus a data
1802 pointer to which the function's data is relative.
1803
1804 If vtables are used, the value of this macro should be the number
1805 of words that the function descriptor occupies.
1806 @end defmac
1807
1808 @defmac TARGET_VTABLE_ENTRY_ALIGN
1809 By default, the vtable entries are void pointers, the so the alignment
1810 is the same as pointer alignment.  The value of this macro specifies
1811 the alignment of the vtable entry in bits.  It should be defined only
1812 when special alignment is necessary. */
1813 @end defmac
1814
1815 @defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE
1816 There are a few non-descriptor entries in the vtable at offsets below
1817 zero.  If these entries must be padded (say, to preserve the alignment
1818 specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
1819 of words in each data entry.
1820 @end defmac
1821
1822 @node Registers
1823 @section Register Usage
1824 @cindex register usage
1825
1826 This section explains how to describe what registers the target machine
1827 has, and how (in general) they can be used.
1828
1829 The description of which registers a specific instruction can use is
1830 done with register classes; see @ref{Register Classes}.  For information
1831 on using registers to access a stack frame, see @ref{Frame Registers}.
1832 For passing values in registers, see @ref{Register Arguments}.
1833 For returning values in registers, see @ref{Scalar Return}.
1834
1835 @menu
1836 * Register Basics::             Number and kinds of registers.
1837 * Allocation Order::            Order in which registers are allocated.
1838 * Values in Registers::         What kinds of values each reg can hold.
1839 * Leaf Functions::              Renumbering registers for leaf functions.
1840 * Stack Registers::             Handling a register stack such as 80387.
1841 @end menu
1842
1843 @node Register Basics
1844 @subsection Basic Characteristics of Registers
1845
1846 @c prevent bad page break with this line
1847 Registers have various characteristics.
1848
1849 @defmac FIRST_PSEUDO_REGISTER
1850 Number of hardware registers known to the compiler.  They receive
1851 numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
1852 pseudo register's number really is assigned the number
1853 @code{FIRST_PSEUDO_REGISTER}.
1854 @end defmac
1855
1856 @defmac FIXED_REGISTERS
1857 @cindex fixed register
1858 An initializer that says which registers are used for fixed purposes
1859 all throughout the compiled code and are therefore not available for
1860 general allocation.  These would include the stack pointer, the frame
1861 pointer (except on machines where that can be used as a general
1862 register when no frame pointer is needed), the program counter on
1863 machines where that is considered one of the addressable registers,
1864 and any other numbered register with a standard use.
1865
1866 This information is expressed as a sequence of numbers, separated by
1867 commas and surrounded by braces.  The @var{n}th number is 1 if
1868 register @var{n} is fixed, 0 otherwise.
1869
1870 The table initialized from this macro, and the table initialized by
1871 the following one, may be overridden at run time either automatically,
1872 by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
1873 the user with the command options @option{-ffixed-@var{reg}},
1874 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}.
1875 @end defmac
1876
1877 @defmac CALL_USED_REGISTERS
1878 @cindex call-used register
1879 @cindex call-clobbered register
1880 @cindex call-saved register
1881 Like @code{FIXED_REGISTERS} but has 1 for each register that is
1882 clobbered (in general) by function calls as well as for fixed
1883 registers.  This macro therefore identifies the registers that are not
1884 available for general allocation of values that must live across
1885 function calls.
1886
1887 If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
1888 automatically saves it on function entry and restores it on function
1889 exit, if the register is used within the function.
1890 @end defmac
1891
1892 @defmac CALL_REALLY_USED_REGISTERS
1893 @cindex call-used register
1894 @cindex call-clobbered register
1895 @cindex call-saved register
1896 Like @code{CALL_USED_REGISTERS} except this macro doesn't require
1897 that the entire set of @code{FIXED_REGISTERS} be included.
1898 (@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}).
1899 This macro is optional.  If not specified, it defaults to the value
1900 of @code{CALL_USED_REGISTERS}.
1901 @end defmac
1902
1903 @defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
1904 @cindex call-used register
1905 @cindex call-clobbered register
1906 @cindex call-saved register
1907 A C expression that is nonzero if it is not permissible to store a
1908 value of mode @var{mode} in hard register number @var{regno} across a
1909 call without some part of it being clobbered.  For most machines this
1910 macro need not be defined.  It is only required for machines that do not
1911 preserve the entire contents of a register across a call.
1912 @end defmac
1913
1914 @findex fixed_regs
1915 @findex call_used_regs
1916 @findex global_regs
1917 @findex reg_names
1918 @findex reg_class_contents
1919 @deftypefn {Target Hook} void TARGET_CONDITIONAL_REGISTER_USAGE (void)
1920 This hook may conditionally modify five variables
1921 @code{fixed_regs}, @code{call_used_regs}, @code{global_regs},
1922 @code{reg_names}, and @code{reg_class_contents}, to take into account
1923 any dependence of these register sets on target flags.  The first three
1924 of these are of type @code{char []} (interpreted as Boolean vectors).
1925 @code{global_regs} is a @code{const char *[]}, and
1926 @code{reg_class_contents} is a @code{HARD_REG_SET}.  Before the macro is
1927 called, @code{fixed_regs}, @code{call_used_regs},
1928 @code{reg_class_contents}, and @code{reg_names} have been initialized
1929 from @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS},
1930 @code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively.
1931 @code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}},
1932 @option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}
1933 command options have been applied.
1934
1935 @cindex disabling certain registers
1936 @cindex controlling register usage
1937 If the usage of an entire class of registers depends on the target
1938 flags, you may indicate this to GCC by using this macro to modify
1939 @code{fixed_regs} and @code{call_used_regs} to 1 for each of the
1940 registers in the classes which should not be used by GCC@.  Also define
1941 the macro @code{REG_CLASS_FROM_LETTER} / @code{REG_CLASS_FROM_CONSTRAINT}
1942 to return @code{NO_REGS} if it
1943 is called with a letter for a class that shouldn't be used.
1944
1945 (However, if this class is not included in @code{GENERAL_REGS} and all
1946 of the insn patterns whose constraints permit this class are
1947 controlled by target switches, then GCC will automatically avoid using
1948 these registers when the target switches are opposed to them.)
1949 @end deftypefn
1950
1951 @defmac INCOMING_REGNO (@var{out})
1952 Define this macro if the target machine has register windows.  This C
1953 expression returns the register number as seen by the called function
1954 corresponding to the register number @var{out} as seen by the calling
1955 function.  Return @var{out} if register number @var{out} is not an
1956 outbound register.
1957 @end defmac
1958
1959 @defmac OUTGOING_REGNO (@var{in})
1960 Define this macro if the target machine has register windows.  This C
1961 expression returns the register number as seen by the calling function
1962 corresponding to the register number @var{in} as seen by the called
1963 function.  Return @var{in} if register number @var{in} is not an inbound
1964 register.
1965 @end defmac
1966
1967 @defmac LOCAL_REGNO (@var{regno})
1968 Define this macro if the target machine has register windows.  This C
1969 expression returns true if the register is call-saved but is in the
1970 register window.  Unlike most call-saved registers, such registers
1971 need not be explicitly restored on function exit or during non-local
1972 gotos.
1973 @end defmac
1974
1975 @defmac PC_REGNUM
1976 If the program counter has a register number, define this as that
1977 register number.  Otherwise, do not define it.
1978 @end defmac
1979
1980 @node Allocation Order
1981 @subsection Order of Allocation of Registers
1982 @cindex order of register allocation
1983 @cindex register allocation order
1984
1985 @c prevent bad page break with this line
1986 Registers are allocated in order.
1987
1988 @defmac REG_ALLOC_ORDER
1989 If defined, an initializer for a vector of integers, containing the
1990 numbers of hard registers in the order in which GCC should prefer
1991 to use them (from most preferred to least).
1992
1993 If this macro is not defined, registers are used lowest numbered first
1994 (all else being equal).
1995
1996 One use of this macro is on machines where the highest numbered
1997 registers must always be saved and the save-multiple-registers
1998 instruction supports only sequences of consecutive registers.  On such
1999 machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists
2000 the highest numbered allocable register first.
2001 @end defmac
2002
2003 @defmac ADJUST_REG_ALLOC_ORDER
2004 A C statement (sans semicolon) to choose the order in which to allocate
2005 hard registers for pseudo-registers local to a basic block.
2006
2007 Store the desired register order in the array @code{reg_alloc_order}.
2008 Element 0 should be the register to allocate first; element 1, the next
2009 register; and so on.
2010
2011 The macro body should not assume anything about the contents of
2012 @code{reg_alloc_order} before execution of the macro.
2013
2014 On most machines, it is not necessary to define this macro.
2015 @end defmac
2016
2017 @defmac HONOR_REG_ALLOC_ORDER
2018 Normally, IRA tries to estimate the costs for saving a register in the
2019 prologue and restoring it in the epilogue.  This discourages it from
2020 using call-saved registers.  If a machine wants to ensure that IRA
2021 allocates registers in the order given by REG_ALLOC_ORDER even if some
2022 call-saved registers appear earlier than call-used ones, this macro
2023 should be defined.
2024 @end defmac
2025
2026 @defmac IRA_HARD_REGNO_ADD_COST_MULTIPLIER (@var{regno})
2027 In some case register allocation order is not enough for the
2028 Integrated Register Allocator (@acronym{IRA}) to generate a good code.
2029 If this macro is defined, it should return a floating point value
2030 based on @var{regno}.  The cost of using @var{regno} for a pseudo will
2031 be increased by approximately the pseudo's usage frequency times the
2032 value returned by this macro.  Not defining this macro is equivalent
2033 to having it always return @code{0.0}.
2034
2035 On most machines, it is not necessary to define this macro.
2036 @end defmac
2037
2038 @node Values in Registers
2039 @subsection How Values Fit in Registers
2040
2041 This section discusses the macros that describe which kinds of values
2042 (specifically, which machine modes) each register can hold, and how many
2043 consecutive registers are needed for a given mode.
2044
2045 @defmac HARD_REGNO_NREGS (@var{regno}, @var{mode})
2046 A C expression for the number of consecutive hard registers, starting
2047 at register number @var{regno}, required to hold a value of mode
2048 @var{mode}.  This macro must never return zero, even if a register
2049 cannot hold the requested mode - indicate that with HARD_REGNO_MODE_OK
2050 and/or CANNOT_CHANGE_MODE_CLASS instead.
2051
2052 On a machine where all registers are exactly one word, a suitable
2053 definition of this macro is
2054
2055 @smallexample
2056 #define HARD_REGNO_NREGS(REGNO, MODE)            \
2057    ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1)  \
2058     / UNITS_PER_WORD)
2059 @end smallexample
2060 @end defmac
2061
2062 @defmac HARD_REGNO_NREGS_HAS_PADDING (@var{regno}, @var{mode})
2063 A C expression that is nonzero if a value of mode @var{mode}, stored
2064 in memory, ends with padding that causes it to take up more space than
2065 in registers starting at register number @var{regno} (as determined by
2066 multiplying GCC's notion of the size of the register when containing
2067 this mode by the number of registers returned by
2068 @code{HARD_REGNO_NREGS}).  By default this is zero.
2069
2070 For example, if a floating-point value is stored in three 32-bit
2071 registers but takes up 128 bits in memory, then this would be
2072 nonzero.
2073
2074 This macros only needs to be defined if there are cases where
2075 @code{subreg_get_info}
2076 would otherwise wrongly determine that a @code{subreg} can be
2077 represented by an offset to the register number, when in fact such a
2078 @code{subreg} would contain some of the padding not stored in
2079 registers and so not be representable.
2080 @end defmac
2081
2082 @defmac HARD_REGNO_NREGS_WITH_PADDING (@var{regno}, @var{mode})
2083 For values of @var{regno} and @var{mode} for which
2084 @code{HARD_REGNO_NREGS_HAS_PADDING} returns nonzero, a C expression
2085 returning the greater number of registers required to hold the value
2086 including any padding.  In the example above, the value would be four.
2087 @end defmac
2088
2089 @defmac REGMODE_NATURAL_SIZE (@var{mode})
2090 Define this macro if the natural size of registers that hold values
2091 of mode @var{mode} is not the word size.  It is a C expression that
2092 should give the natural size in bytes for the specified mode.  It is
2093 used by the register allocator to try to optimize its results.  This
2094 happens for example on SPARC 64-bit where the natural size of
2095 floating-point registers is still 32-bit.
2096 @end defmac
2097
2098 @defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
2099 A C expression that is nonzero if it is permissible to store a value
2100 of mode @var{mode} in hard register number @var{regno} (or in several
2101 registers starting with that one).  For a machine where all registers
2102 are equivalent, a suitable definition is
2103
2104 @smallexample
2105 #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
2106 @end smallexample
2107
2108 You need not include code to check for the numbers of fixed registers,
2109 because the allocation mechanism considers them to be always occupied.
2110
2111 @cindex register pairs
2112 On some machines, double-precision values must be kept in even/odd
2113 register pairs.  You can implement that by defining this macro to reject
2114 odd register numbers for such modes.
2115
2116 The minimum requirement for a mode to be OK in a register is that the
2117 @samp{mov@var{mode}} instruction pattern support moves between the
2118 register and other hard register in the same class and that moving a
2119 value into the register and back out not alter it.
2120
2121 Since the same instruction used to move @code{word_mode} will work for
2122 all narrower integer modes, it is not necessary on any machine for
2123 @code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided
2124 you define patterns @samp{movhi}, etc., to take advantage of this.  This
2125 is useful because of the interaction between @code{HARD_REGNO_MODE_OK}
2126 and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes
2127 to be tieable.
2128
2129 Many machines have special registers for floating point arithmetic.
2130 Often people assume that floating point machine modes are allowed only
2131 in floating point registers.  This is not true.  Any registers that
2132 can hold integers can safely @emph{hold} a floating point machine
2133 mode, whether or not floating arithmetic can be done on it in those
2134 registers.  Integer move instructions can be used to move the values.
2135
2136 On some machines, though, the converse is true: fixed-point machine
2137 modes may not go in floating registers.  This is true if the floating
2138 registers normalize any value stored in them, because storing a
2139 non-floating value there would garble it.  In this case,
2140 @code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in
2141 floating registers.  But if the floating registers do not automatically
2142 normalize, if you can store any bit pattern in one and retrieve it
2143 unchanged without a trap, then any machine mode may go in a floating
2144 register, so you can define this macro to say so.
2145
2146 The primary significance of special floating registers is rather that
2147 they are the registers acceptable in floating point arithmetic
2148 instructions.  However, this is of no concern to
2149 @code{HARD_REGNO_MODE_OK}.  You handle it by writing the proper
2150 constraints for those instructions.
2151
2152 On some machines, the floating registers are especially slow to access,
2153 so that it is better to store a value in a stack frame than in such a
2154 register if floating point arithmetic is not being done.  As long as the
2155 floating registers are not in class @code{GENERAL_REGS}, they will not
2156 be used unless some pattern's constraint asks for one.
2157 @end defmac
2158
2159 @defmac HARD_REGNO_RENAME_OK (@var{from}, @var{to})
2160 A C expression that is nonzero if it is OK to rename a hard register
2161 @var{from} to another hard register @var{to}.
2162
2163 One common use of this macro is to prevent renaming of a register to
2164 another register that is not saved by a prologue in an interrupt
2165 handler.
2166
2167 The default is always nonzero.
2168 @end defmac
2169
2170 @defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2})
2171 A C expression that is nonzero if a value of mode
2172 @var{mode1} is accessible in mode @var{mode2} without copying.
2173
2174 If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
2175 @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for
2176 any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})}
2177 should be nonzero.  If they differ for any @var{r}, you should define
2178 this macro to return zero unless some other mechanism ensures the
2179 accessibility of the value in a narrower mode.
2180
2181 You should define this macro to return nonzero in as many cases as
2182 possible since doing so will allow GCC to perform better register
2183 allocation.
2184 @end defmac
2185
2186 @deftypefn {Target Hook} bool TARGET_HARD_REGNO_SCRATCH_OK (unsigned int @var{regno})
2187 This target hook should return @code{true} if it is OK to use a hard register
2188 @var{regno} as scratch reg in peephole2.
2189
2190 One common use of this macro is to prevent using of a register that
2191 is not saved by a prologue in an interrupt handler.
2192
2193 The default version of this hook always returns @code{true}.
2194 @end deftypefn
2195
2196 @defmac AVOID_CCMODE_COPIES
2197 Define this macro if the compiler should avoid copies to/from @code{CCmode}
2198 registers.  You should only define this macro if support for copying to/from
2199 @code{CCmode} is incomplete.
2200 @end defmac
2201
2202 @node Leaf Functions
2203 @subsection Handling Leaf Functions
2204
2205 @cindex leaf functions
2206 @cindex functions, leaf
2207 On some machines, a leaf function (i.e., one which makes no calls) can run
2208 more efficiently if it does not make its own register window.  Often this
2209 means it is required to receive its arguments in the registers where they
2210 are passed by the caller, instead of the registers where they would
2211 normally arrive.
2212
2213 The special treatment for leaf functions generally applies only when
2214 other conditions are met; for example, often they may use only those
2215 registers for its own variables and temporaries.  We use the term ``leaf
2216 function'' to mean a function that is suitable for this special
2217 handling, so that functions with no calls are not necessarily ``leaf
2218 functions''.
2219
2220 GCC assigns register numbers before it knows whether the function is
2221 suitable for leaf function treatment.  So it needs to renumber the
2222 registers in order to output a leaf function.  The following macros
2223 accomplish this.
2224
2225 @defmac LEAF_REGISTERS
2226 Name of a char vector, indexed by hard register number, which
2227 contains 1 for a register that is allowable in a candidate for leaf
2228 function treatment.
2229
2230 If leaf function treatment involves renumbering the registers, then the
2231 registers marked here should be the ones before renumbering---those that
2232 GCC would ordinarily allocate.  The registers which will actually be
2233 used in the assembler code, after renumbering, should not be marked with 1
2234 in this vector.
2235
2236 Define this macro only if the target machine offers a way to optimize
2237 the treatment of leaf functions.
2238 @end defmac
2239
2240 @defmac LEAF_REG_REMAP (@var{regno})
2241 A C expression whose value is the register number to which @var{regno}
2242 should be renumbered, when a function is treated as a leaf function.
2243
2244 If @var{regno} is a register number which should not appear in a leaf
2245 function before renumbering, then the expression should yield @minus{}1, which
2246 will cause the compiler to abort.
2247
2248 Define this macro only if the target machine offers a way to optimize the
2249 treatment of leaf functions, and registers need to be renumbered to do
2250 this.
2251 @end defmac
2252
2253 @findex current_function_is_leaf
2254 @findex current_function_uses_only_leaf_regs
2255 @code{TARGET_ASM_FUNCTION_PROLOGUE} and
2256 @code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions
2257 specially.  They can test the C variable @code{current_function_is_leaf}
2258 which is nonzero for leaf functions.  @code{current_function_is_leaf} is
2259 set prior to local register allocation and is valid for the remaining
2260 compiler passes.  They can also test the C variable
2261 @code{current_function_uses_only_leaf_regs} which is nonzero for leaf
2262 functions which only use leaf registers.
2263 @code{current_function_uses_only_leaf_regs} is valid after all passes
2264 that modify the instructions have been run and is only useful if
2265 @code{LEAF_REGISTERS} is defined.
2266 @c changed this to fix overfull.  ALSO:  why the "it" at the beginning
2267 @c of the next paragraph?!  --mew 2feb93
2268
2269 @node Stack Registers
2270 @subsection Registers That Form a Stack
2271
2272 There are special features to handle computers where some of the
2273 ``registers'' form a stack.  Stack registers are normally written by
2274 pushing onto the stack, and are numbered relative to the top of the
2275 stack.
2276
2277 Currently, GCC can only handle one group of stack-like registers, and
2278 they must be consecutively numbered.  Furthermore, the existing
2279 support for stack-like registers is specific to the 80387 floating
2280 point coprocessor.  If you have a new architecture that uses
2281 stack-like registers, you will need to do substantial work on
2282 @file{reg-stack.c} and write your machine description to cooperate
2283 with it, as well as defining these macros.
2284
2285 @defmac STACK_REGS
2286 Define this if the machine has any stack-like registers.
2287 @end defmac
2288
2289 @defmac STACK_REG_COVER_CLASS
2290 This is a cover class containing the stack registers.  Define this if
2291 the machine has any stack-like registers.
2292 @end defmac
2293
2294 @defmac FIRST_STACK_REG
2295 The number of the first stack-like register.  This one is the top
2296 of the stack.
2297 @end defmac
2298
2299 @defmac LAST_STACK_REG
2300 The number of the last stack-like register.  This one is the bottom of
2301 the stack.
2302 @end defmac
2303
2304 @node Register Classes
2305 @section Register Classes
2306 @cindex register class definitions
2307 @cindex class definitions, register
2308
2309 On many machines, the numbered registers are not all equivalent.
2310 For example, certain registers may not be allowed for indexed addressing;
2311 certain registers may not be allowed in some instructions.  These machine
2312 restrictions are described to the compiler using @dfn{register classes}.
2313
2314 You define a number of register classes, giving each one a name and saying
2315 which of the registers belong to it.  Then you can specify register classes
2316 that are allowed as operands to particular instruction patterns.
2317
2318 @findex ALL_REGS
2319 @findex NO_REGS
2320 In general, each register will belong to several classes.  In fact, one
2321 class must be named @code{ALL_REGS} and contain all the registers.  Another
2322 class must be named @code{NO_REGS} and contain no registers.  Often the
2323 union of two classes will be another class; however, this is not required.
2324
2325 @findex GENERAL_REGS
2326 One of the classes must be named @code{GENERAL_REGS}.  There is nothing
2327 terribly special about the name, but the operand constraint letters
2328 @samp{r} and @samp{g} specify this class.  If @code{GENERAL_REGS} is
2329 the same as @code{ALL_REGS}, just define it as a macro which expands
2330 to @code{ALL_REGS}.
2331
2332 Order the classes so that if class @var{x} is contained in class @var{y}
2333 then @var{x} has a lower class number than @var{y}.
2334
2335 The way classes other than @code{GENERAL_REGS} are specified in operand
2336 constraints is through machine-dependent operand constraint letters.
2337 You can define such letters to correspond to various classes, then use
2338 them in operand constraints.
2339
2340 You should define a class for the union of two classes whenever some
2341 instruction allows both classes.  For example, if an instruction allows
2342 either a floating point (coprocessor) register or a general register for a
2343 certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
2344 which includes both of them.  Otherwise you will get suboptimal code.
2345
2346 You must also specify certain redundant information about the register
2347 classes: for each class, which classes contain it and which ones are
2348 contained in it; for each pair of classes, the largest class contained
2349 in their union.
2350
2351 When a value occupying several consecutive registers is expected in a
2352 certain class, all the registers used must belong to that class.
2353 Therefore, register classes cannot be used to enforce a requirement for
2354 a register pair to start with an even-numbered register.  The way to
2355 specify this requirement is with @code{HARD_REGNO_MODE_OK}.
2356
2357 Register classes used for input-operands of bitwise-and or shift
2358 instructions have a special requirement: each such class must have, for
2359 each fixed-point machine mode, a subclass whose registers can transfer that
2360 mode to or from memory.  For example, on some machines, the operations for
2361 single-byte values (@code{QImode}) are limited to certain registers.  When
2362 this is so, each register class that is used in a bitwise-and or shift
2363 instruction must have a subclass consisting of registers from which
2364 single-byte values can be loaded or stored.  This is so that
2365 @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
2366
2367 @deftp {Data type} {enum reg_class}
2368 An enumerated type that must be defined with all the register class names
2369 as enumerated values.  @code{NO_REGS} must be first.  @code{ALL_REGS}
2370 must be the last register class, followed by one more enumerated value,
2371 @code{LIM_REG_CLASSES}, which is not a register class but rather
2372 tells how many classes there are.
2373
2374 Each register class has a number, which is the value of casting
2375 the class name to type @code{int}.  The number serves as an index
2376 in many of the tables described below.
2377 @end deftp
2378
2379 @defmac N_REG_CLASSES
2380 The number of distinct register classes, defined as follows:
2381
2382 @smallexample
2383 #define N_REG_CLASSES (int) LIM_REG_CLASSES
2384 @end smallexample
2385 @end defmac
2386
2387 @defmac REG_CLASS_NAMES
2388 An initializer containing the names of the register classes as C string
2389 constants.  These names are used in writing some of the debugging dumps.
2390 @end defmac
2391
2392 @defmac REG_CLASS_CONTENTS
2393 An initializer containing the contents of the register classes, as integers
2394 which are bit masks.  The @var{n}th integer specifies the contents of class
2395 @var{n}.  The way the integer @var{mask} is interpreted is that
2396 register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
2397
2398 When the machine has more than 32 registers, an integer does not suffice.
2399 Then the integers are replaced by sub-initializers, braced groupings containing
2400 several integers.  Each sub-initializer must be suitable as an initializer
2401 for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
2402 In this situation, the first integer in each sub-initializer corresponds to
2403 registers 0 through 31, the second integer to registers 32 through 63, and
2404 so on.
2405 @end defmac
2406
2407 @defmac REGNO_REG_CLASS (@var{regno})
2408 A C expression whose value is a register class containing hard register
2409 @var{regno}.  In general there is more than one such class; choose a class
2410 which is @dfn{minimal}, meaning that no smaller class also contains the
2411 register.
2412 @end defmac
2413
2414 @defmac BASE_REG_CLASS
2415 A macro whose definition is the name of the class to which a valid
2416 base register must belong.  A base register is one used in an address
2417 which is the register value plus a displacement.
2418 @end defmac
2419
2420 @defmac MODE_BASE_REG_CLASS (@var{mode})
2421 This is a variation of the @code{BASE_REG_CLASS} macro which allows
2422 the selection of a base register in a mode dependent manner.  If
2423 @var{mode} is VOIDmode then it should return the same value as
2424 @code{BASE_REG_CLASS}.
2425 @end defmac
2426
2427 @defmac MODE_BASE_REG_REG_CLASS (@var{mode})
2428 A C expression whose value is the register class to which a valid
2429 base register must belong in order to be used in a base plus index
2430 register address.  You should define this macro if base plus index
2431 addresses have different requirements than other base register uses.
2432 @end defmac
2433
2434 @defmac MODE_CODE_BASE_REG_CLASS (@var{mode}, @var{outer_code}, @var{index_code})
2435 A C expression whose value is the register class to which a valid
2436 base register must belong.  @var{outer_code} and @var{index_code} define the
2437 context in which the base register occurs.  @var{outer_code} is the code of
2438 the immediately enclosing expression (@code{MEM} for the top level of an
2439 address, @code{ADDRESS} for something that occurs in an
2440 @code{address_operand}).  @var{index_code} is the code of the corresponding
2441 index expression if @var{outer_code} is @code{PLUS}; @code{SCRATCH} otherwise.
2442 @end defmac
2443
2444 @defmac INDEX_REG_CLASS
2445 A macro whose definition is the name of the class to which a valid
2446 index register must belong.  An index register is one used in an
2447 address where its value is either multiplied by a scale factor or
2448 added to another register (as well as added to a displacement).
2449 @end defmac
2450
2451 @defmac REGNO_OK_FOR_BASE_P (@var{num})
2452 A C expression which is nonzero if register number @var{num} is
2453 suitable for use as a base register in operand addresses.
2454 @end defmac
2455
2456 @defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode})
2457 A C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that
2458 that expression may examine the mode of the memory reference in
2459 @var{mode}.  You should define this macro if the mode of the memory
2460 reference affects whether a register may be used as a base register.  If
2461 you define this macro, the compiler will use it instead of
2462 @code{REGNO_OK_FOR_BASE_P}.  The mode may be @code{VOIDmode} for
2463 addresses that appear outside a @code{MEM}, i.e., as an
2464 @code{address_operand}.
2465 @end defmac
2466
2467 @defmac REGNO_MODE_OK_FOR_REG_BASE_P (@var{num}, @var{mode})
2468 A C expression which is nonzero if register number @var{num} is suitable for
2469 use as a base register in base plus index operand addresses, accessing
2470 memory in mode @var{mode}.  It may be either a suitable hard register or a
2471 pseudo register that has been allocated such a hard register.  You should
2472 define this macro if base plus index addresses have different requirements
2473 than other base register uses.
2474
2475 Use of this macro is deprecated; please use the more general
2476 @code{REGNO_MODE_CODE_OK_FOR_BASE_P}.
2477 @end defmac
2478
2479 @defmac REGNO_MODE_CODE_OK_FOR_BASE_P (@var{num}, @var{mode}, @var{outer_code}, @var{index_code})
2480 A C expression that is just like @code{REGNO_MODE_OK_FOR_BASE_P}, except
2481 that that expression may examine the context in which the register
2482 appears in the memory reference.  @var{outer_code} is the code of the
2483 immediately enclosing expression (@code{MEM} if at the top level of the
2484 address, @code{ADDRESS} for something that occurs in an
2485 @code{address_operand}).  @var{index_code} is the code of the
2486 corresponding index expression if @var{outer_code} is @code{PLUS};
2487 @code{SCRATCH} otherwise.  The mode may be @code{VOIDmode} for addresses
2488 that appear outside a @code{MEM}, i.e., as an @code{address_operand}.
2489 @end defmac
2490
2491 @defmac REGNO_OK_FOR_INDEX_P (@var{num})
2492 A C expression which is nonzero if register number @var{num} is
2493 suitable for use as an index register in operand addresses.  It may be
2494 either a suitable hard register or a pseudo register that has been
2495 allocated such a hard register.
2496
2497 The difference between an index register and a base register is that
2498 the index register may be scaled.  If an address involves the sum of
2499 two registers, neither one of them scaled, then either one may be
2500 labeled the ``base'' and the other the ``index''; but whichever
2501 labeling is used must fit the machine's constraints of which registers
2502 may serve in each capacity.  The compiler will try both labelings,
2503 looking for one that is valid, and will reload one or both registers
2504 only if neither labeling works.
2505 @end defmac
2506
2507 @deftypefn {Target Hook} reg_class_t TARGET_PREFERRED_RENAME_CLASS (reg_class_t @var{rclass})
2508 A target hook that places additional preference on the register class to use when it is necessary to rename a register in class @var{rclass} to another class, or perhaps @var{NO_REGS}, if no preferred register class is found or hook @code{preferred_rename_class} is not implemented. Sometimes returning a more restrictive class makes better code.  For example, on ARM, thumb-2 instructions using @code{LO_REGS} may be smaller than instructions using @code{GENERIC_REGS}.  By returning @code{LO_REGS} from @code{preferred_rename_class}, code size can be reduced.
2509 @end deftypefn
2510
2511 @deftypefn {Target Hook} reg_class_t TARGET_PREFERRED_RELOAD_CLASS (rtx @var{x}, reg_class_t @var{rclass})
2512 A target hook that places additional restrictions on the register class
2513 to use when it is necessary to copy value @var{x} into a register in class
2514 @var{rclass}.  The value is a register class; perhaps @var{rclass}, or perhaps
2515 another, smaller class.
2516
2517 The default version of this hook always returns value of @code{rclass} argument.
2518
2519 Sometimes returning a more restrictive class makes better code.  For
2520 example, on the 68000, when @var{x} is an integer constant that is in range
2521 for a @samp{moveq} instruction, the value of this macro is always
2522 @code{DATA_REGS} as long as @var{rclass} includes the data registers.
2523 Requiring a data register guarantees that a @samp{moveq} will be used.
2524
2525 One case where @code{TARGET_PREFERRED_RELOAD_CLASS} must not return
2526 @var{rclass} is if @var{x} is a legitimate constant which cannot be
2527 loaded into some register class.  By returning @code{NO_REGS} you can
2528 force @var{x} into a memory location.  For example, rs6000 can load
2529 immediate values into general-purpose registers, but does not have an
2530 instruction for loading an immediate value into a floating-point
2531 register, so @code{TARGET_PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2532 @var{x} is a floating-point constant.  If the constant can't be loaded
2533 into any kind of register, code generation will be better if
2534 @code{LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
2535 of using @code{TARGET_PREFERRED_RELOAD_CLASS}.
2536
2537 If an insn has pseudos in it after register allocation, reload will go
2538 through the alternatives and call repeatedly @code{TARGET_PREFERRED_RELOAD_CLASS}
2539 to find the best one.  Returning @code{NO_REGS}, in this case, makes
2540 reload add a @code{!} in front of the constraint: the x86 back-end uses
2541 this feature to discourage usage of 387 registers when math is done in
2542 the SSE registers (and vice versa).
2543 @end deftypefn
2544
2545 @defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
2546 A C expression that places additional restrictions on the register class
2547 to use when it is necessary to copy value @var{x} into a register in class
2548 @var{class}.  The value is a register class; perhaps @var{class}, or perhaps
2549 another, smaller class.  On many machines, the following definition is
2550 safe:
2551
2552 @smallexample
2553 #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
2554 @end smallexample
2555
2556 Sometimes returning a more restrictive class makes better code.  For
2557 example, on the 68000, when @var{x} is an integer constant that is in range
2558 for a @samp{moveq} instruction, the value of this macro is always
2559 @code{DATA_REGS} as long as @var{class} includes the data registers.
2560 Requiring a data register guarantees that a @samp{moveq} will be used.
2561
2562 One case where @code{PREFERRED_RELOAD_CLASS} must not return
2563 @var{class} is if @var{x} is a legitimate constant which cannot be
2564 loaded into some register class.  By returning @code{NO_REGS} you can
2565 force @var{x} into a memory location.  For example, rs6000 can load
2566 immediate values into general-purpose registers, but does not have an
2567 instruction for loading an immediate value into a floating-point
2568 register, so @code{PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2569 @var{x} is a floating-point constant.  If the constant can't be loaded
2570 into any kind of register, code generation will be better if
2571 @code{LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
2572 of using @code{PREFERRED_RELOAD_CLASS}.
2573
2574 If an insn has pseudos in it after register allocation, reload will go
2575 through the alternatives and call repeatedly @code{PREFERRED_RELOAD_CLASS}
2576 to find the best one.  Returning @code{NO_REGS}, in this case, makes
2577 reload add a @code{!} in front of the constraint: the x86 back-end uses
2578 this feature to discourage usage of 387 registers when math is done in
2579 the SSE registers (and vice versa).
2580 @end defmac
2581
2582 @defmac PREFERRED_OUTPUT_RELOAD_CLASS (@var{x}, @var{class})
2583 Like @code{PREFERRED_RELOAD_CLASS}, but for output reloads instead of
2584 input reloads.  If you don't define this macro, the default is to use
2585 @var{class}, unchanged.
2586
2587 You can also use @code{PREFERRED_OUTPUT_RELOAD_CLASS} to discourage
2588 reload from using some alternatives, like @code{PREFERRED_RELOAD_CLASS}.
2589 @end defmac
2590
2591 @deftypefn {Target Hook} reg_class_t TARGET_PREFERRED_OUTPUT_RELOAD_CLASS (rtx @var{x}, reg_class_t @var{rclass})
2592 Like @code{TARGET_PREFERRED_RELOAD_CLASS}, but for output reloads instead of
2593 input reloads.
2594
2595 The default version of this hook always returns value of @code{rclass}
2596 argument.
2597
2598 You can also use @code{TARGET_PREFERRED_OUTPUT_RELOAD_CLASS} to discourage
2599 reload from using some alternatives, like @code{TARGET_PREFERRED_RELOAD_CLASS}.
2600 @end deftypefn
2601
2602 @defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class})
2603 A C expression that places additional restrictions on the register class
2604 to use when it is necessary to be able to hold a value of mode
2605 @var{mode} in a reload register for which class @var{class} would
2606 ordinarily be used.
2607
2608 Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when
2609 there are certain modes that simply can't go in certain reload classes.
2610
2611 The value is a register class; perhaps @var{class}, or perhaps another,
2612 smaller class.
2613
2614 Don't define this macro unless the target machine has limitations which
2615 require the macro to do something nontrivial.
2616 @end defmac
2617
2618 @deftypefn {Target Hook} reg_class_t TARGET_SECONDARY_RELOAD (bool @var{in_p}, rtx @var{x}, reg_class_t @var{reload_class}, enum machine_mode @var{reload_mode}, secondary_reload_info *@var{sri})
2619 Many machines have some registers that cannot be copied directly to or
2620 from memory or even from other types of registers.  An example is the
2621 @samp{MQ} register, which on most machines, can only be copied to or
2622 from general registers, but not memory.  Below, we shall be using the
2623 term 'intermediate register' when a move operation cannot be performed
2624 directly, but has to be done by copying the source into the intermediate
2625 register first, and then copying the intermediate register to the
2626 destination.  An intermediate register always has the same mode as
2627 source and destination.  Since it holds the actual value being copied,
2628 reload might apply optimizations to re-use an intermediate register
2629 and eliding the copy from the source when it can determine that the
2630 intermediate register still holds the required value.
2631
2632 Another kind of secondary reload is required on some machines which
2633 allow copying all registers to and from memory, but require a scratch
2634 register for stores to some memory locations (e.g., those with symbolic
2635 address on the RT, and those with certain symbolic address on the SPARC
2636 when compiling PIC)@.  Scratch registers need not have the same mode
2637 as the value being copied, and usually hold a different value than
2638 that being copied.  Special patterns in the md file are needed to
2639 describe how the copy is performed with the help of the scratch register;
2640 these patterns also describe the number, register class(es) and mode(s)
2641 of the scratch register(s).
2642
2643 In some cases, both an intermediate and a scratch register are required.
2644
2645 For input reloads, this target hook is called with nonzero @var{in_p},
2646 and @var{x} is an rtx that needs to be copied to a register of class
2647 @var{reload_class} in @var{reload_mode}.  For output reloads, this target
2648 hook is called with zero @var{in_p}, and a register of class @var{reload_class}
2649 needs to be copied to rtx @var{x} in @var{reload_mode}.
2650
2651 If copying a register of @var{reload_class} from/to @var{x} requires
2652 an intermediate register, the hook @code{secondary_reload} should
2653 return the register class required for this intermediate register.
2654 If no intermediate register is required, it should return NO_REGS.
2655 If more than one intermediate register is required, describe the one
2656 that is closest in the copy chain to the reload register.
2657
2658 If scratch registers are needed, you also have to describe how to
2659 perform the copy from/to the reload register to/from this
2660 closest intermediate register.  Or if no intermediate register is
2661 required, but still a scratch register is needed, describe the
2662 copy  from/to the reload register to/from the reload operand @var{x}.
2663
2664 You do this by setting @code{sri->icode} to the instruction code of a pattern
2665 in the md file which performs the move.  Operands 0 and 1 are the output
2666 and input of this copy, respectively.  Operands from operand 2 onward are
2667 for scratch operands.  These scratch operands must have a mode, and a
2668 single-register-class
2669 @c [later: or memory]
2670 output constraint.
2671
2672 When an intermediate register is used, the @code{secondary_reload}
2673 hook will be called again to determine how to copy the intermediate
2674 register to/from the reload operand @var{x}, so your hook must also
2675 have code to handle the register class of the intermediate operand.
2676
2677 @c [For later: maybe we'll allow multi-alternative reload patterns -
2678 @c   the port maintainer could name a mov<mode> pattern that has clobbers -
2679 @c   and match the constraints of input and output to determine the required
2680 @c   alternative.  A restriction would be that constraints used to match
2681 @c   against reloads registers would have to be written as register class
2682 @c   constraints, or we need a new target macro / hook that tells us if an
2683 @c   arbitrary constraint can match an unknown register of a given class.
2684 @c   Such a macro / hook would also be useful in other places.]
2685
2686
2687 @var{x} might be a pseudo-register or a @code{subreg} of a
2688 pseudo-register, which could either be in a hard register or in memory.
2689 Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2690 in memory and the hard register number if it is in a register.
2691
2692 Scratch operands in memory (constraint @code{"=m"} / @code{"=&m"}) are
2693 currently not supported.  For the time being, you will have to continue
2694 to use @code{SECONDARY_MEMORY_NEEDED} for that purpose.
2695
2696 @code{copy_cost} also uses this target hook to find out how values are
2697 copied.  If you want it to include some extra cost for the need to allocate
2698 (a) scratch register(s), set @code{sri->extra_cost} to the additional cost.
2699 Or if two dependent moves are supposed to have a lower cost than the sum
2700 of the individual moves due to expected fortuitous scheduling and/or special
2701 forwarding logic, you can set @code{sri->extra_cost} to a negative amount.
2702 @end deftypefn
2703
2704 @defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2705 @defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2706 @defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2707 These macros are obsolete, new ports should use the target hook
2708 @code{TARGET_SECONDARY_RELOAD} instead.
2709
2710 These are obsolete macros, replaced by the @code{TARGET_SECONDARY_RELOAD}
2711 target hook.  Older ports still define these macros to indicate to the
2712 reload phase that it may
2713 need to allocate at least one register for a reload in addition to the
2714 register to contain the data.  Specifically, if copying @var{x} to a
2715 register @var{class} in @var{mode} requires an intermediate register,
2716 you were supposed to define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the
2717 largest register class all of whose registers can be used as
2718 intermediate registers or scratch registers.
2719
2720 If copying a register @var{class} in @var{mode} to @var{x} requires an
2721 intermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS}
2722 was supposed to be defined be defined to return the largest register
2723 class required.  If the
2724 requirements for input and output reloads were the same, the macro
2725 @code{SECONDARY_RELOAD_CLASS} should have been used instead of defining both
2726 macros identically.
2727
2728 The values returned by these macros are often @code{GENERAL_REGS}.
2729 Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x}
2730 can be directly copied to or from a register of @var{class} in
2731 @var{mode} without requiring a scratch register.  Do not define this
2732 macro if it would always return @code{NO_REGS}.
2733
2734 If a scratch register is required (either with or without an
2735 intermediate register), you were supposed to define patterns for
2736 @samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required
2737 (@pxref{Standard Names}.  These patterns, which were normally
2738 implemented with a @code{define_expand}, should be similar to the
2739 @samp{mov@var{m}} patterns, except that operand 2 is the scratch
2740 register.
2741
2742 These patterns need constraints for the reload register and scratch
2743 register that
2744 contain a single register class.  If the original reload register (whose
2745 class is @var{class}) can meet the constraint given in the pattern, the
2746 value returned by these macros is used for the class of the scratch
2747 register.  Otherwise, two additional reload registers are required.
2748 Their classes are obtained from the constraints in the insn pattern.
2749
2750 @var{x} might be a pseudo-register or a @code{subreg} of a
2751 pseudo-register, which could either be in a hard register or in memory.
2752 Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2753 in memory and the hard register number if it is in a register.
2754
2755 These macros should not be used in the case where a particular class of
2756 registers can only be copied to memory and not to another class of
2757 registers.  In that case, secondary reload registers are not needed and
2758 would not be helpful.  Instead, a stack location must be used to perform
2759 the copy and the @code{mov@var{m}} pattern should use memory as an
2760 intermediate storage.  This case often occurs between floating-point and
2761 general registers.
2762 @end defmac
2763
2764 @defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m})
2765 Certain machines have the property that some registers cannot be copied
2766 to some other registers without using memory.  Define this macro on
2767 those machines to be a C expression that is nonzero if objects of mode
2768 @var{m} in registers of @var{class1} can only be copied to registers of
2769 class @var{class2} by storing a register of @var{class1} into memory
2770 and loading that memory location into a register of @var{class2}.
2771
2772 Do not define this macro if its value would always be zero.
2773 @end defmac
2774
2775 @defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode})
2776 Normally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler
2777 allocates a stack slot for a memory location needed for register copies.
2778 If this macro is defined, the compiler instead uses the memory location
2779 defined by this macro.
2780
2781 Do not define this macro if you do not define
2782 @code{SECONDARY_MEMORY_NEEDED}.
2783 @end defmac
2784
2785 @defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode})
2786 When the compiler needs a secondary memory location to copy between two
2787 registers of mode @var{mode}, it normally allocates sufficient memory to
2788 hold a quantity of @code{BITS_PER_WORD} bits and performs the store and
2789 load operations in a mode that many bits wide and whose class is the
2790 same as that of @var{mode}.
2791
2792 This is right thing to do on most machines because it ensures that all
2793 bits of the register are copied and prevents accesses to the registers
2794 in a narrower mode, which some machines prohibit for floating-point
2795 registers.
2796
2797 However, this default behavior is not correct on some machines, such as
2798 the DEC Alpha, that store short integers in floating-point registers
2799 differently than in integer registers.  On those machines, the default
2800 widening will not work correctly and you must define this macro to
2801 suppress that widening in some cases.  See the file @file{alpha.h} for
2802 details.
2803
2804 Do not define this macro if you do not define
2805 @code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that
2806 is @code{BITS_PER_WORD} bits wide is correct for your machine.
2807 @end defmac
2808
2809 @deftypefn {Target Hook} bool TARGET_CLASS_LIKELY_SPILLED_P (reg_class_t @var{rclass})
2810 A target hook which returns @code{true} if pseudos that have been assigned
2811 to registers of class @var{rclass} would likely be spilled because
2812 registers of @var{rclass} are needed for spill registers.
2813
2814 The default version of this target hook returns @code{true} if @var{rclass}
2815 has exactly one register and @code{false} otherwise.  On most machines, this
2816 default should be used.  Only use this target hook to some other expression
2817 if pseudos allocated by @file{local-alloc.c} end up in memory because their
2818 hard registers were needed for spill registers.  If this target hook returns
2819 @code{false} for those classes, those pseudos will only be allocated by
2820 @file{global.c}, which knows how to reallocate the pseudo to another
2821 register.  If there would not be another register available for reallocation,
2822 you should not change the implementation of this target hook since
2823 the only effect of such implementation would be to slow down register
2824 allocation.
2825 @end deftypefn
2826
2827 @defmac CLASS_MAX_NREGS (@var{class}, @var{mode})
2828 A C expression for the maximum number of consecutive registers
2829 of class @var{class} needed to hold a value of mode @var{mode}.
2830
2831 This is closely related to the macro @code{HARD_REGNO_NREGS}.  In fact,
2832 the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
2833 should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno},
2834 @var{mode})} for all @var{regno} values in the class @var{class}.
2835
2836 This macro helps control the handling of multiple-word values
2837 in the reload pass.
2838 @end defmac
2839
2840 @defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
2841 If defined, a C expression that returns nonzero for a @var{class} for which
2842 a change from mode @var{from} to mode @var{to} is invalid.
2843
2844 For the example, loading 32-bit integer or floating-point objects into
2845 floating-point registers on the Alpha extends them to 64 bits.
2846 Therefore loading a 64-bit object and then storing it as a 32-bit object
2847 does not store the low-order 32 bits, as would be the case for a normal
2848 register.  Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
2849 as below:
2850
2851 @smallexample
2852 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
2853   (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
2854    ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
2855 @end smallexample
2856 @end defmac
2857
2858 @deftypefn {Target Hook} {const reg_class_t *} TARGET_IRA_COVER_CLASSES (void)
2859 Return an array of cover classes for the Integrated Register Allocator
2860 (@acronym{IRA}).  Cover classes are a set of non-intersecting register
2861 classes covering all hard registers used for register allocation
2862 purposes.  If a move between two registers in the same cover class is
2863 possible, it should be cheaper than a load or store of the registers.
2864 The array is terminated by a @code{LIM_REG_CLASSES} element.
2865
2866 The order of cover classes in the array is important.  If two classes
2867 have the same cost of usage for a pseudo, the class occurred first in
2868 the array is chosen for the pseudo.
2869
2870 This hook is called once at compiler startup, after the command-line
2871 options have been processed. It is then re-examined by every call to
2872 @code{target_reinit}.
2873
2874 The default implementation returns @code{IRA_COVER_CLASSES}, if defined,
2875 otherwise there is no default implementation.  You must define either this
2876 macro or @code{IRA_COVER_CLASSES} in order to use the integrated register
2877 allocator with Chaitin-Briggs coloring. If the macro is not defined,
2878 the only available coloring algorithm is Chow's priority coloring.
2879
2880 This hook must not be modified from @code{NULL} to non-@code{NULL} or
2881 vice versa by command-line option processing.
2882 @end deftypefn
2883
2884 @defmac IRA_COVER_CLASSES
2885 See the documentation for @code{TARGET_IRA_COVER_CLASSES}.
2886 @end defmac
2887
2888 @node Old Constraints
2889 @section Obsolete Macros for Defining Constraints
2890 @cindex defining constraints, obsolete method
2891 @cindex constraints, defining, obsolete method
2892
2893 Machine-specific constraints can be defined with these macros instead
2894 of the machine description constructs described in @ref{Define
2895 Constraints}.  This mechanism is obsolete.  New ports should not use
2896 it; old ports should convert to the new mechanism.
2897
2898 @defmac CONSTRAINT_LEN (@var{char}, @var{str})
2899 For the constraint at the start of @var{str}, which starts with the letter
2900 @var{c}, return the length.  This allows you to have register class /
2901 constant / extra constraints that are longer than a single letter;
2902 you don't need to define this macro if you can do with single-letter
2903 constraints only.  The definition of this macro should use
2904 DEFAULT_CONSTRAINT_LEN for all the characters that you don't want
2905 to handle specially.
2906 There are some sanity checks in genoutput.c that check the constraint lengths
2907 for the md file, so you can also use this macro to help you while you are
2908 transitioning from a byzantine single-letter-constraint scheme: when you
2909 return a negative length for a constraint you want to re-use, genoutput
2910 will complain about every instance where it is used in the md file.
2911 @end defmac
2912
2913 @defmac REG_CLASS_FROM_LETTER (@var{char})
2914 A C expression which defines the machine-dependent operand constraint
2915 letters for register classes.  If @var{char} is such a letter, the
2916 value should be the register class corresponding to it.  Otherwise,
2917 the value should be @code{NO_REGS}.  The register letter @samp{r},
2918 corresponding to class @code{GENERAL_REGS}, will not be passed
2919 to this macro; you do not need to handle it.
2920 @end defmac
2921
2922 @defmac REG_CLASS_FROM_CONSTRAINT (@var{char}, @var{str})
2923 Like @code{REG_CLASS_FROM_LETTER}, but you also get the constraint string
2924 passed in @var{str}, so that you can use suffixes to distinguish between
2925 different variants.
2926 @end defmac
2927
2928 @defmac CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
2929 A C expression that defines the machine-dependent operand constraint
2930 letters (@samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}) that specify
2931 particular ranges of integer values.  If @var{c} is one of those
2932 letters, the expression should check that @var{value}, an integer, is in
2933 the appropriate range and return 1 if so, 0 otherwise.  If @var{c} is
2934 not one of those letters, the value should be 0 regardless of
2935 @var{value}.
2936 @end defmac
2937
2938 @defmac CONST_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2939 Like @code{CONST_OK_FOR_LETTER_P}, but you also get the constraint
2940 string passed in @var{str}, so that you can use suffixes to distinguish
2941 between different variants.
2942 @end defmac
2943
2944 @defmac CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
2945 A C expression that defines the machine-dependent operand constraint
2946 letters that specify particular ranges of @code{const_double} values
2947 (@samp{G} or @samp{H}).
2948
2949 If @var{c} is one of those letters, the expression should check that
2950 @var{value}, an RTX of code @code{const_double}, is in the appropriate
2951 range and return 1 if so, 0 otherwise.  If @var{c} is not one of those
2952 letters, the value should be 0 regardless of @var{value}.
2953
2954 @code{const_double} is used for all floating-point constants and for
2955 @code{DImode} fixed-point constants.  A given letter can accept either
2956 or both kinds of values.  It can use @code{GET_MODE} to distinguish
2957 between these kinds.
2958 @end defmac
2959
2960 @defmac CONST_DOUBLE_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2961 Like @code{CONST_DOUBLE_OK_FOR_LETTER_P}, but you also get the constraint
2962 string passed in @var{str}, so that you can use suffixes to distinguish
2963 between different variants.
2964 @end defmac
2965
2966 @defmac EXTRA_CONSTRAINT (@var{value}, @var{c})
2967 A C expression that defines the optional machine-dependent constraint
2968 letters that can be used to segregate specific types of operands, usually
2969 memory references, for the target machine.  Any letter that is not
2970 elsewhere defined and not matched by @code{REG_CLASS_FROM_LETTER} /
2971 @code{REG_CLASS_FROM_CONSTRAINT}
2972 may be used.  Normally this macro will not be defined.
2973
2974 If it is required for a particular target machine, it should return 1
2975 if @var{value} corresponds to the operand type represented by the
2976 constraint letter @var{c}.  If @var{c} is not defined as an extra
2977 constraint, the value returned should be 0 regardless of @var{value}.
2978
2979 For example, on the ROMP, load instructions cannot have their output
2980 in r0 if the memory reference contains a symbolic address.  Constraint
2981 letter @samp{Q} is defined as representing a memory address that does
2982 @emph{not} contain a symbolic address.  An alternative is specified with
2983 a @samp{Q} constraint on the input and @samp{r} on the output.  The next
2984 alternative specifies @samp{m} on the input and a register class that
2985 does not include r0 on the output.
2986 @end defmac
2987
2988 @defmac EXTRA_CONSTRAINT_STR (@var{value}, @var{c}, @var{str})
2989 Like @code{EXTRA_CONSTRAINT}, but you also get the constraint string passed
2990 in @var{str}, so that you can use suffixes to distinguish between different
2991 variants.
2992 @end defmac
2993
2994 @defmac EXTRA_MEMORY_CONSTRAINT (@var{c}, @var{str})
2995 A C expression that defines the optional machine-dependent constraint
2996 letters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should
2997 be treated like memory constraints by the reload pass.
2998
2999 It should return 1 if the operand type represented by the constraint
3000 at the start of @var{str}, the first letter of which is the letter @var{c},
3001 comprises a subset of all memory references including
3002 all those whose address is simply a base register.  This allows the reload
3003 pass to reload an operand, if it does not directly correspond to the operand
3004 type of @var{c}, by copying its address into a base register.
3005
3006 For example, on the S/390, some instructions do not accept arbitrary
3007 memory references, but only those that do not make use of an index
3008 register.  The constraint letter @samp{Q} is defined via
3009 @code{EXTRA_CONSTRAINT} as representing a memory address of this type.
3010 If the letter @samp{Q} is marked as @code{EXTRA_MEMORY_CONSTRAINT},
3011 a @samp{Q} constraint can handle any memory operand, because the
3012 reload pass knows it can be reloaded by copying the memory address
3013 into a base register if required.  This is analogous to the way
3014 an @samp{o} constraint can handle any memory operand.
3015 @end defmac
3016
3017 @defmac EXTRA_ADDRESS_CONSTRAINT (@var{c}, @var{str})
3018 A C expression that defines the optional machine-dependent constraint
3019 letters, amongst those accepted by @code{EXTRA_CONSTRAINT} /
3020 @code{EXTRA_CONSTRAINT_STR}, that should
3021 be treated like address constraints by the reload pass.
3022
3023 It should return 1 if the operand type represented by the constraint
3024 at the start of @var{str}, which starts with the letter @var{c}, comprises
3025 a subset of all memory addresses including
3026 all those that consist of just a base register.  This allows the reload
3027 pass to reload an operand, if it does not directly correspond to the operand
3028 type of @var{str}, by copying it into a base register.
3029
3030 Any constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only
3031 be used with the @code{address_operand} predicate.  It is treated
3032 analogously to the @samp{p} constraint.
3033 @end defmac
3034
3035 @node Stack and Calling
3036 @section Stack Layout and Calling Conventions
3037 @cindex calling conventions
3038
3039 @c prevent bad page break with this line
3040 This describes the stack layout and calling conventions.
3041
3042 @menu
3043 * Frame Layout::
3044 * Exception Handling::
3045 * Stack Checking::
3046 * Frame Registers::
3047 * Elimination::
3048 * Stack Arguments::
3049 * Register Arguments::
3050 * Scalar Return::
3051 * Aggregate Return::
3052 * Caller Saves::
3053 * Function Entry::
3054 * Profiling::
3055 * Tail Calls::
3056 * Stack Smashing Protection::
3057 @end menu
3058
3059 @node Frame Layout
3060 @subsection Basic Stack Layout
3061 @cindex stack frame layout
3062 @cindex frame layout
3063
3064 @c prevent bad page break with this line
3065 Here is the basic stack layout.
3066
3067 @defmac STACK_GROWS_DOWNWARD
3068 Define this macro if pushing a word onto the stack moves the stack
3069 pointer to a smaller address.
3070
3071 When we say, ``define this macro if @dots{}'', it means that the
3072 compiler checks this macro only with @code{#ifdef} so the precise
3073 definition used does not matter.
3074 @end defmac
3075
3076 @defmac STACK_PUSH_CODE
3077 This macro defines the operation used when something is pushed
3078 on the stack.  In RTL, a push operation will be
3079 @code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})}
3080
3081 The choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC},
3082 and @code{POST_INC}.  Which of these is correct depends on
3083 the stack direction and on whether the stack pointer points
3084 to the last item on the stack or whether it points to the
3085 space for the next item on the stack.
3086
3087 The default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is
3088 defined, which is almost always right, and @code{PRE_INC} otherwise,
3089 which is often wrong.
3090 @end defmac
3091
3092 @defmac FRAME_GROWS_DOWNWARD
3093 Define this macro to nonzero value if the addresses of local variable slots
3094 are at negative offsets from the frame pointer.
3095 @end defmac
3096
3097 @defmac ARGS_GROW_DOWNWARD
3098 Define this macro if successive arguments to a function occupy decreasing
3099 addresses on the stack.
3100 @end defmac
3101
3102 @defmac STARTING_FRAME_OFFSET
3103 Offset from the frame pointer to the first local variable slot to be allocated.
3104
3105 If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
3106 subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
3107 Otherwise, it is found by adding the length of the first slot to the
3108 value @code{STARTING_FRAME_OFFSET}.
3109 @c i'm not sure if the above is still correct.. had to change it to get
3110 @c rid of an overfull.  --mew 2feb93
3111 @end defmac
3112
3113 @defmac STACK_ALIGNMENT_NEEDED
3114 Define to zero to disable final alignment of the stack during reload.
3115 The nonzero default for this macro is suitable for most ports.
3116
3117 On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
3118 is a register save block following the local block that doesn't require
3119 alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
3120 stack alignment and do it in the backend.
3121 @end defmac
3122
3123 @defmac STACK_POINTER_OFFSET
3124 Offset from the stack pointer register to the first location at which
3125 outgoing arguments are placed.  If not specified, the default value of
3126 zero is used.  This is the proper value for most machines.
3127
3128 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
3129 the first location at which outgoing arguments are placed.
3130 @end defmac
3131
3132 @defmac FIRST_PARM_OFFSET (@var{fundecl})
3133 Offset from the argument pointer register to the first argument's
3134 address.  On some machines it may depend on the data type of the
3135 function.
3136
3137 If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
3138 the first argument's address.
3139 @end defmac
3140
3141 @defmac STACK_DYNAMIC_OFFSET (@var{fundecl})
3142 Offset from the stack pointer register to an item dynamically allocated
3143 on the stack, e.g., by @code{alloca}.
3144
3145 The default value for this macro is @code{STACK_POINTER_OFFSET} plus the
3146 length of the outgoing arguments.  The default is correct for most
3147 machines.  See @file{function.c} for details.
3148 @end defmac
3149
3150 @defmac INITIAL_FRAME_ADDRESS_RTX
3151 A C expression whose value is RTL representing the address of the initial
3152 stack frame. This address is passed to @code{RETURN_ADDR_RTX} and
3153 @code{DYNAMIC_CHAIN_ADDRESS}.  If you don't define this macro, a reasonable
3154 default value will be used.  Define this macro in order to make frame pointer
3155 elimination work in the presence of @code{__builtin_frame_address (count)} and
3156 @code{__builtin_return_address (count)} for @code{count} not equal to zero.
3157 @end defmac
3158
3159 @defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
3160 A C expression whose value is RTL representing the address in a stack
3161 frame where the pointer to the caller's frame is stored.  Assume that
3162 @var{frameaddr} is an RTL expression for the address of the stack frame
3163 itself.
3164
3165 If you don't define this macro, the default is to return the value
3166 of @var{frameaddr}---that is, the stack frame address is also the
3167 address of the stack word that points to the previous frame.
3168 @end defmac
3169
3170 @defmac SETUP_FRAME_ADDRESSES
3171 If defined, a C expression that produces the machine-specific code to
3172 setup the stack so that arbitrary frames can be accessed.  For example,
3173 on the SPARC, we must flush all of the register windows to the stack
3174 before we can access arbitrary stack frames.  You will seldom need to
3175 define this macro.
3176 @end defmac
3177
3178 @deftypefn {Target Hook} rtx TARGET_BUILTIN_SETJMP_FRAME_VALUE (void)
3179 This target hook should return an rtx that is used to store
3180 the address of the current frame into the built in @code{setjmp} buffer.
3181 The default value, @code{virtual_stack_vars_rtx}, is correct for most
3182 machines.  One reason you may need to define this target hook is if
3183 @code{hard_frame_pointer_rtx} is the appropriate value on your machine.
3184 @end deftypefn
3185
3186 @defmac FRAME_ADDR_RTX (@var{frameaddr})
3187 A C expression whose value is RTL representing the value of the frame
3188 address for the current frame.  @var{frameaddr} is the frame pointer
3189 of the current frame.  This is used for __builtin_frame_address.
3190 You need only define this macro if the frame address is not the same
3191 as the frame pointer.  Most machines do not need to define it.
3192 @end defmac
3193
3194 @defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr})
3195 A C expression whose value is RTL representing the value of the return
3196 address for the frame @var{count} steps up from the current frame, after
3197 the prologue.  @var{frameaddr} is the frame pointer of the @var{count}
3198 frame, or the frame pointer of the @var{count} @minus{} 1 frame if
3199 @code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined.
3200
3201 The value of the expression must always be the correct address when
3202 @var{count} is zero, but may be @code{NULL_RTX} if there is no way to
3203 determine the return address of other frames.
3204 @end defmac
3205
3206 @defmac RETURN_ADDR_IN_PREVIOUS_FRAME
3207 Define this if the return address of a particular stack frame is accessed
3208 from the frame pointer of the previous stack frame.
3209 @end defmac
3210
3211 @defmac INCOMING_RETURN_ADDR_RTX
3212 A C expression whose value is RTL representing the location of the
3213 incoming return address at the beginning of any function, before the
3214 prologue.  This RTL is either a @code{REG}, indicating that the return
3215 value is saved in @samp{REG}, or a @code{MEM} representing a location in
3216 the stack.
3217
3218 You only need to define this macro if you want to support call frame
3219 debugging information like that provided by DWARF 2.
3220
3221 If this RTL is a @code{REG}, you should also define
3222 @code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}.
3223 @end defmac
3224
3225 @defmac DWARF_ALT_FRAME_RETURN_COLUMN
3226 A C expression whose value is an integer giving a DWARF 2 column
3227 number that may be used as an alternative return column.  The column
3228 must not correspond to any gcc hard register (that is, it must not
3229 be in the range of @code{DWARF_FRAME_REGNUM}).
3230
3231 This macro can be useful if @code{DWARF_FRAME_RETURN_COLUMN} is set to a
3232 general register, but an alternative column needs to be used for signal
3233 frames.  Some targets have also used different frame return columns
3234 over time.
3235 @end defmac
3236
3237 @defmac DWARF_ZERO_REG
3238 A C expression whose value is an integer giving a DWARF 2 register
3239 number that is considered to always have the value zero.  This should
3240 only be defined if the target has an architected zero register, and
3241 someone decided it was a good idea to use that register number to
3242 terminate the stack backtrace.  New ports should avoid this.
3243 @end defmac
3244
3245 @deftypefn {Target Hook} void TARGET_DWARF_HANDLE_FRAME_UNSPEC (const char *@var{label}, rtx @var{pattern}, int @var{index})
3246 This target hook allows the backend to emit frame-related insns that
3247 contain UNSPECs or UNSPEC_VOLATILEs.  The DWARF 2 call frame debugging
3248 info engine will invoke it on insns of the form
3249 @smallexample
3250 (set (reg) (unspec [@dots{}] UNSPEC_INDEX))
3251 @end smallexample
3252 and
3253 @smallexample
3254 (set (reg) (unspec_volatile [@dots{}] UNSPECV_INDEX)).
3255 @end smallexample
3256 to let the backend emit the call frame instructions.  @var{label} is
3257 the CFI label attached to the insn, @var{pattern} is the pattern of
3258 the insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}.
3259 @end deftypefn
3260
3261 @defmac INCOMING_FRAME_SP_OFFSET
3262 A C expression whose value is an integer giving the offset, in bytes,
3263 from the value of the stack pointer register to the top of the stack
3264 frame at the beginning of any function, before the prologue.  The top of
3265 the frame is defined to be the value of the stack pointer in the
3266 previous frame, just before the call instruction.
3267
3268 You only need to define this macro if you want to support call frame
3269 debugging information like that provided by DWARF 2.
3270 @end defmac
3271
3272 @defmac ARG_POINTER_CFA_OFFSET (@var{fundecl})
3273 A C expression whose value is an integer giving the offset, in bytes,
3274 from the argument pointer to the canonical frame address (cfa).  The
3275 final value should coincide with that calculated by
3276 @code{INCOMING_FRAME_SP_OFFSET}.  Which is unfortunately not usable
3277 during virtual register instantiation.
3278
3279 The default value for this macro is
3280 @code{FIRST_PARM_OFFSET (fundecl) + crtl->args.pretend_args_size},
3281 which is correct for most machines; in general, the arguments are found
3282 immediately before the stack frame.  Note that this is not the case on
3283 some targets that save registers into the caller's frame, such as SPARC
3284 and rs6000, and so such targets need to define this macro.
3285
3286 You only need to define this macro if the default is incorrect, and you
3287 want to support call frame debugging information like that provided by
3288 DWARF 2.
3289 @end defmac
3290
3291 @defmac FRAME_POINTER_CFA_OFFSET (@var{fundecl})
3292 If defined, a C expression whose value is an integer giving the offset
3293 in bytes from the frame pointer to the canonical frame address (cfa).
3294 The final value should coincide with that calculated by
3295 @code{INCOMING_FRAME_SP_OFFSET}.
3296
3297 Normally the CFA is calculated as an offset from the argument pointer,
3298 via @code{ARG_POINTER_CFA_OFFSET}, but if the argument pointer is
3299 variable due to the ABI, this may not be possible.  If this macro is
3300 defined, it implies that the virtual register instantiation should be
3301 based on the frame pointer instead of the argument pointer.  Only one
3302 of @code{FRAME_POINTER_CFA_OFFSET} and @code{ARG_POINTER_CFA_OFFSET}
3303 should be defined.
3304 @end defmac
3305
3306 @defmac CFA_FRAME_BASE_OFFSET (@var{fundecl})
3307 If defined, a C expression whose value is an integer giving the offset
3308 in bytes from the canonical frame address (cfa) to the frame base used
3309 in DWARF 2 debug information.  The default is zero.  A different value
3310 may reduce the size of debug information on some ports.
3311 @end defmac
3312
3313 @node Exception Handling
3314 @subsection Exception Handling Support
3315 @cindex exception handling
3316
3317 @defmac EH_RETURN_DATA_REGNO (@var{N})
3318 A C expression whose value is the @var{N}th register number used for
3319 data by exception handlers, or @code{INVALID_REGNUM} if fewer than
3320 @var{N} registers are usable.
3321
3322 The exception handling library routines communicate with the exception
3323 handlers via a set of agreed upon registers.  Ideally these registers
3324 should be call-clobbered; it is possible to use call-saved registers,
3325 but may negatively impact code size.  The target must support at least
3326 2 data registers, but should define 4 if there are enough free registers.
3327
3328 You must define this macro if you want to support call frame exception
3329 handling like that provided by DWARF 2.
3330 @end defmac
3331
3332 @defmac EH_RETURN_STACKADJ_RTX
3333 A C expression whose value is RTL representing a location in which
3334 to store a stack adjustment to be applied before function return.
3335 This is used to unwind the stack to an exception handler's call frame.
3336 It will be assigned zero on code paths that return normally.
3337
3338 Typically this is a call-clobbered hard register that is otherwise
3339 untouched by the epilogue, but could also be a stack slot.
3340
3341 Do not define this macro if the stack pointer is saved and restored
3342 by the regular prolog and epilog code in the call frame itself; in
3343 this case, the exception handling library routines will update the
3344 stack location to be restored in place.  Otherwise, you must define
3345 this macro if you want to support call frame exception handling like
3346 that provided by DWARF 2.
3347 @end defmac
3348
3349 @defmac EH_RETURN_HANDLER_RTX
3350 A C expression whose value is RTL representing a location in which
3351 to store the address of an exception handler to which we should
3352 return.  It will not be assigned on code paths that return normally.
3353
3354 Typically this is the location in the call frame at which the normal
3355 return address is stored.  For targets that return by popping an
3356 address off the stack, this might be a memory address just below
3357 the @emph{target} call frame rather than inside the current call
3358 frame.  If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
3359 been assigned, so it may be used to calculate the location of the
3360 target call frame.
3361
3362 Some targets have more complex requirements than storing to an
3363 address calculable during initial code generation.  In that case
3364 the @code{eh_return} instruction pattern should be used instead.
3365
3366 If you want to support call frame exception handling, you must
3367 define either this macro or the @code{eh_return} instruction pattern.
3368 @end defmac
3369
3370 @defmac RETURN_ADDR_OFFSET
3371 If defined, an integer-valued C expression for which rtl will be generated
3372 to add it to the exception handler address before it is searched in the
3373 exception handling tables, and to subtract it again from the address before
3374 using it to return to the exception handler.
3375 @end defmac
3376
3377 @defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global})
3378 This macro chooses the encoding of pointers embedded in the exception
3379 handling sections.  If at all possible, this should be defined such
3380 that the exception handling section will not require dynamic relocations,
3381 and so may be read-only.
3382
3383 @var{code} is 0 for data, 1 for code labels, 2 for function pointers.
3384 @var{global} is true if the symbol may be affected by dynamic relocations.
3385 The macro should return a combination of the @code{DW_EH_PE_*} defines
3386 as found in @file{dwarf2.h}.
3387
3388 If this macro is not defined, pointers will not be encoded but
3389 represented directly.
3390 @end defmac
3391
3392 @defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done})
3393 This macro allows the target to emit whatever special magic is required
3394 to represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}.
3395 Generic code takes care of pc-relative and indirect encodings; this must
3396 be defined if the target uses text-relative or data-relative encodings.
3397
3398 This is a C statement that branches to @var{done} if the format was
3399 handled.  @var{encoding} is the format chosen, @var{size} is the number
3400 of bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF}
3401 to be emitted.
3402 @end defmac
3403
3404 @defmac MD_UNWIND_SUPPORT
3405 A string specifying a file to be #include'd in unwind-dw2.c.  The file
3406 so included typically defines @code{MD_FALLBACK_FRAME_STATE_FOR}.
3407 @end defmac
3408
3409 @defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs})
3410 This macro allows the target to add CPU and operating system specific
3411 code to the call-frame unwinder for use when there is no unwind data
3412 available.  The most common reason to implement this macro is to unwind
3413 through signal frames.
3414
3415 This macro is called from @code{uw_frame_state_for} in
3416 @file{unwind-dw2.c}, @file{unwind-dw2-xtensa.c} and
3417 @file{unwind-ia64.c}.  @var{context} is an @code{_Unwind_Context};
3418 @var{fs} is an @code{_Unwind_FrameState}.  Examine @code{context->ra}
3419 for the address of the code being executed and @code{context->cfa} for
3420 the stack pointer value.  If the frame can be decoded, the register
3421 save addresses should be updated in @var{fs} and the macro should
3422 evaluate to @code{_URC_NO_REASON}.  If the frame cannot be decoded,
3423 the macro should evaluate to @code{_URC_END_OF_STACK}.
3424
3425 For proper signal handling in Java this macro is accompanied by
3426 @code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers.
3427 @end defmac
3428
3429 @defmac MD_HANDLE_UNWABI (@var{context}, @var{fs})
3430 This macro allows the target to add operating system specific code to the
3431 call-frame unwinder to handle the IA-64 @code{.unwabi} unwinding directive,
3432 usually used for signal or interrupt frames.
3433
3434 This macro is called from @code{uw_update_context} in @file{unwind-ia64.c}.
3435 @var{context} is an @code{_Unwind_Context};
3436 @var{fs} is an @code{_Unwind_FrameState}.  Examine @code{fs->unwabi}
3437 for the abi and context in the @code{.unwabi} directive.  If the
3438 @code{.unwabi} directive can be handled, the register save addresses should
3439 be updated in @var{fs}.
3440 @end defmac
3441
3442 @defmac TARGET_USES_WEAK_UNWIND_INFO
3443 A C expression that evaluates to true if the target requires unwind
3444 info to be given comdat linkage.  Define it to be @code{1} if comdat
3445 linkage is necessary.  The default is @code{0}.
3446 @end defmac
3447
3448 @node Stack Checking
3449 @subsection Specifying How Stack Checking is Done
3450
3451 GCC will check that stack references are within the boundaries of the
3452 stack, if the option @option{-fstack-check} is specified, in one of
3453 three ways:
3454
3455 @enumerate
3456 @item
3457 If the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC
3458 will assume that you have arranged for full stack checking to be done
3459 at appropriate places in the configuration files.  GCC will not do
3460 other special processing.
3461
3462 @item
3463 If @code{STACK_CHECK_BUILTIN} is zero and the value of the
3464 @code{STACK_CHECK_STATIC_BUILTIN} macro is nonzero, GCC will assume
3465 that you have arranged for static stack checking (checking of the
3466 static stack frame of functions) to be done at appropriate places
3467 in the configuration files.  GCC will only emit code to do dynamic
3468 stack checking (checking on dynamic stack allocations) using the third
3469 approach below.
3470
3471 @item
3472 If neither of the above are true, GCC will generate code to periodically
3473 ``probe'' the stack pointer using the values of the macros defined below.
3474 @end enumerate
3475
3476 If neither STACK_CHECK_BUILTIN nor STACK_CHECK_STATIC_BUILTIN is defined,
3477 GCC will change its allocation strategy for large objects if the option
3478 @option{-fstack-check} is specified: they will always be allocated
3479 dynamically if their size exceeds @code{STACK_CHECK_MAX_VAR_SIZE} bytes.
3480
3481 @defmac STACK_CHECK_BUILTIN
3482 A nonzero value if stack checking is done by the configuration files in a
3483 machine-dependent manner.  You should define this macro if stack checking
3484 is required by the ABI of your machine or if you would like to do stack
3485 checking in some more efficient way than the generic approach.  The default
3486 value of this macro is zero.
3487 @end defmac
3488
3489 @defmac STACK_CHECK_STATIC_BUILTIN
3490 A nonzero value if static stack checking is done by the configuration files
3491 in a machine-dependent manner.  You should define this macro if you would
3492 like to do static stack checking in some more efficient way than the generic
3493 approach.  The default value of this macro is zero.
3494 @end defmac
3495
3496 @defmac STACK_CHECK_PROBE_INTERVAL_EXP
3497 An integer specifying the interval at which GCC must generate stack probe
3498 instructions, defined as 2 raised to this integer.  You will normally
3499 define this macro so that the interval be no larger than the size of
3500 the ``guard pages'' at the end of a stack area.  The default value
3501 of 12 (4096-byte interval) is suitable for most systems.
3502 @end defmac
3503
3504 @defmac STACK_CHECK_MOVING_SP
3505 An integer which is nonzero if GCC should move the stack pointer page by page
3506 when doing probes.  This can be necessary on systems where the stack pointer
3507 contains the bottom address of the memory area accessible to the executing
3508 thread at any point in time.  In this situation an alternate signal stack
3509 is required in order to be able to recover from a stack overflow.  The
3510 default value of this macro is zero.
3511 @end defmac
3512
3513 @defmac STACK_CHECK_PROTECT
3514 The number of bytes of stack needed to recover from a stack overflow, for
3515 languages where such a recovery is supported.  The default value of 75 words
3516 with the @code{setjmp}/@code{longjmp}-based exception handling mechanism and
3517 8192 bytes with other exception handling mechanisms should be adequate for
3518 most machines.
3519 @end defmac
3520
3521 The following macros are relevant only if neither STACK_CHECK_BUILTIN
3522 nor STACK_CHECK_STATIC_BUILTIN is defined; you can omit them altogether
3523 in the opposite case.
3524
3525 @defmac STACK_CHECK_MAX_FRAME_SIZE
3526 The maximum size of a stack frame, in bytes.  GCC will generate probe
3527 instructions in non-leaf functions to ensure at least this many bytes of
3528 stack are available.  If a stack frame is larger than this size, stack
3529 checking will not be reliable and GCC will issue a warning.  The
3530 default is chosen so that GCC only generates one instruction on most
3531 systems.  You should normally not change the default value of this macro.
3532 @end defmac
3533
3534 @defmac STACK_CHECK_FIXED_FRAME_SIZE
3535 GCC uses this value to generate the above warning message.  It
3536 represents the amount of fixed frame used by a function, not including
3537 space for any callee-saved registers, temporaries and user variables.
3538 You need only specify an upper bound for this amount and will normally
3539 use the default of four words.
3540 @end defmac
3541
3542 @defmac STACK_CHECK_MAX_VAR_SIZE
3543 The maximum size, in bytes, of an object that GCC will place in the
3544 fixed area of the stack frame when the user specifies
3545 @option{-fstack-check}.
3546 GCC computed the default from the values of the above macros and you will
3547 normally not need to override that default.
3548 @end defmac
3549
3550 @need 2000
3551 @node Frame Registers
3552 @subsection Registers That Address the Stack Frame
3553
3554 @c prevent bad page break with this line
3555 This discusses registers that address the stack frame.
3556
3557 @defmac STACK_POINTER_REGNUM
3558 The register number of the stack pointer register, which must also be a
3559 fixed register according to @code{FIXED_REGISTERS}.  On most machines,
3560 the hardware determines which register this is.
3561 @end defmac
3562
3563 @defmac FRAME_POINTER_REGNUM
3564 The register number of the frame pointer register, which is used to
3565 access automatic variables i