]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/tm.texi.in
Use -z ignore instead of --as-needed on Solaris
[thirdparty/gcc.git] / gcc / doc / tm.texi.in
CommitLineData
d1e082c2 1@c Copyright (C) 1988-2013 Free Software Foundation, Inc.
38f8b050
JR
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
5@node Target Macros
6@chapter Target Description Macros and Functions
7@cindex machine description macros
8@cindex target description macros
9@cindex macros, target description
10@cindex @file{tm.h} macros
11
12In addition to the file @file{@var{machine}.md}, a machine description
13includes a C header file conventionally given the name
14@file{@var{machine}.h} and a C source file named @file{@var{machine}.c}.
15The header file defines numerous macros that convey the information
16about the target machine that does not fit into the scheme of the
17@file{.md} file. The file @file{tm.h} should be a link to
18@file{@var{machine}.h}. The header file @file{config.h} includes
19@file{tm.h} and most compiler source files include @file{config.h}. The
20source file defines a variable @code{targetm}, which is a structure
21containing pointers to functions and data relating to the target
22machine. @file{@var{machine}.c} should also contain their definitions,
23if they are not defined elsewhere in GCC, and other functions called
24through the macros defined in the @file{.h} file.
25
26@menu
27* Target Structure:: The @code{targetm} variable.
28* Driver:: Controlling how the driver runs the compilation passes.
29* Run-time Target:: Defining @samp{-m} options like @option{-m68000} and @option{-m68020}.
30* Per-Function Data:: Defining data structures for per-function information.
31* Storage Layout:: Defining sizes and alignments of data.
32* Type Layout:: Defining sizes and properties of basic user data types.
33* Registers:: Naming and describing the hardware registers.
34* Register Classes:: Defining the classes of hardware registers.
35* Old Constraints:: The old way to define machine-specific constraints.
36* Stack and Calling:: Defining which way the stack grows and by how much.
37* Varargs:: Defining the varargs macros.
38* Trampolines:: Code set up at run time to enter a nested function.
39* Library Calls:: Controlling how library routines are implicitly called.
40* Addressing Modes:: Defining addressing modes valid for memory operands.
41* Anchored Addresses:: Defining how @option{-fsection-anchors} should work.
42* Condition Code:: Defining how insns update the condition code.
43* Costs:: Defining relative costs of different operations.
44* Scheduling:: Adjusting the behavior of the instruction scheduler.
45* Sections:: Dividing storage into text, data, and other sections.
46* PIC:: Macros for position independent code.
47* Assembler Format:: Defining how to write insns and pseudo-ops to output.
48* Debugging Info:: Defining the format of debugging output.
49* Floating Point:: Handling floating point for cross-compilers.
50* Mode Switching:: Insertion of mode-switching instructions.
51* Target Attributes:: Defining target-specific uses of @code{__attribute__}.
52* Emulated TLS:: Emulated TLS support.
53* MIPS Coprocessors:: MIPS coprocessor support and how to customize it.
54* PCH Target:: Validity checking for precompiled headers.
55* C++ ABI:: Controlling C++ ABI changes.
56* Named Address Spaces:: Adding support for named address spaces
57* Misc:: Everything else.
58@end menu
59
60@node Target Structure
61@section The Global @code{targetm} Variable
62@cindex target hooks
63@cindex target functions
64
65@deftypevar {struct gcc_target} targetm
66The target @file{.c} file must define the global @code{targetm} variable
67which contains pointers to functions and data relating to the target
68machine. The variable is declared in @file{target.h};
69@file{target-def.h} defines the macro @code{TARGET_INITIALIZER} which is
70used to initialize the variable, and macros for the default initializers
71for elements of the structure. The @file{.c} file should override those
72macros for which the default definition is inappropriate. For example:
73@smallexample
74#include "target.h"
75#include "target-def.h"
76
77/* @r{Initialize the GCC target structure.} */
78
79#undef TARGET_COMP_TYPE_ATTRIBUTES
80#define TARGET_COMP_TYPE_ATTRIBUTES @var{machine}_comp_type_attributes
81
82struct gcc_target targetm = TARGET_INITIALIZER;
83@end smallexample
84@end deftypevar
85
86Where a macro should be defined in the @file{.c} file in this manner to
87form part of the @code{targetm} structure, it is documented below as a
88``Target Hook'' with a prototype. Many macros will change in future
89from being defined in the @file{.h} file to being part of the
90@code{targetm} structure.
91
acce4e77
JM
92Similarly, there is a @code{targetcm} variable for hooks that are
93specific to front ends for C-family languages, documented as ``C
94Target Hook''. This is declared in @file{c-family/c-target.h}, the
dd5a833e 95initializer @code{TARGETCM_INITIALIZER} in
acce4e77
JM
96@file{c-family/c-target-def.h}. If targets initialize @code{targetcm}
97themselves, they should set @code{target_has_targetcm=yes} in
98@file{config.gcc}; otherwise a default definition is used.
99
c49a6962
JM
100Similarly, there is a @code{targetm_common} variable for hooks that
101are shared between the compiler driver and the compilers proper,
102documented as ``Common Target Hook''. This is declared in
103@file{common/common-target.h}, the initializer
104@code{TARGETM_COMMON_INITIALIZER} in
105@file{common/common-target-def.h}. If targets initialize
106@code{targetm_common} themselves, they should set
107@code{target_has_targetm_common=yes} in @file{config.gcc}; otherwise a
108default definition is used.
109
38f8b050
JR
110@node Driver
111@section Controlling the Compilation Driver, @file{gcc}
112@cindex driver
113@cindex controlling the compilation driver
114
115@c prevent bad page break with this line
116You can control the compilation driver.
117
38f8b050
JR
118@defmac DRIVER_SELF_SPECS
119A list of specs for the driver itself. It should be a suitable
120initializer for an array of strings, with no surrounding braces.
121
122The driver applies these specs to its own command line between loading
123default @file{specs} files (but not command-line specified ones) and
124choosing the multilib directory or running any subcommands. It
125applies them in the order given, so each spec can depend on the
126options added by earlier ones. It is also possible to remove options
127using @samp{%<@var{option}} in the usual way.
128
129This macro can be useful when a port has several interdependent target
130options. It provides a way of standardizing the command line so
131that the other specs are easier to write.
132
133Do not define this macro if it does not need to do anything.
134@end defmac
135
136@defmac OPTION_DEFAULT_SPECS
137A list of specs used to support configure-time default options (i.e.@:
138@option{--with} options) in the driver. It should be a suitable initializer
139for an array of structures, each containing two strings, without the
140outermost pair of surrounding braces.
141
142The first item in the pair is the name of the default. This must match
143the code in @file{config.gcc} for the target. The second item is a spec
144to apply if a default with this name was specified. The string
145@samp{%(VALUE)} in the spec will be replaced by the value of the default
146everywhere it occurs.
147
148The driver will apply these specs to its own command line between loading
149default @file{specs} files and processing @code{DRIVER_SELF_SPECS}, using
150the same mechanism as @code{DRIVER_SELF_SPECS}.
151
152Do not define this macro if it does not need to do anything.
153@end defmac
154
155@defmac CPP_SPEC
156A C string constant that tells the GCC driver program options to
157pass to CPP@. It can also specify how to translate options you
158give to GCC into options for GCC to pass to the CPP@.
159
160Do not define this macro if it does not need to do anything.
161@end defmac
162
163@defmac CPLUSPLUS_CPP_SPEC
164This macro is just like @code{CPP_SPEC}, but is used for C++, rather
165than C@. If you do not define this macro, then the value of
166@code{CPP_SPEC} (if any) will be used instead.
167@end defmac
168
169@defmac CC1_SPEC
170A C string constant that tells the GCC driver program options to
171pass to @code{cc1}, @code{cc1plus}, @code{f771}, and the other language
172front ends.
173It can also specify how to translate options you give to GCC into options
174for GCC to pass to front ends.
175
176Do not define this macro if it does not need to do anything.
177@end defmac
178
179@defmac CC1PLUS_SPEC
180A C string constant that tells the GCC driver program options to
181pass to @code{cc1plus}. It can also specify how to translate options you
182give to GCC into options for GCC to pass to the @code{cc1plus}.
183
184Do not define this macro if it does not need to do anything.
185Note that everything defined in CC1_SPEC is already passed to
186@code{cc1plus} so there is no need to duplicate the contents of
187CC1_SPEC in CC1PLUS_SPEC@.
188@end defmac
189
190@defmac ASM_SPEC
191A C string constant that tells the GCC driver program options to
192pass to the assembler. It can also specify how to translate options
193you give to GCC into options for GCC to pass to the assembler.
194See the file @file{sun3.h} for an example of this.
195
196Do not define this macro if it does not need to do anything.
197@end defmac
198
199@defmac ASM_FINAL_SPEC
200A C string constant that tells the GCC driver program how to
201run any programs which cleanup after the normal assembler.
202Normally, this is not needed. See the file @file{mips.h} for
203an example of this.
204
205Do not define this macro if it does not need to do anything.
206@end defmac
207
208@defmac AS_NEEDS_DASH_FOR_PIPED_INPUT
209Define this macro, with no value, if the driver should give the assembler
210an argument consisting of a single dash, @option{-}, to instruct it to
211read from its standard input (which will be a pipe connected to the
212output of the compiler proper). This argument is given after any
213@option{-o} option specifying the name of the output file.
214
215If you do not define this macro, the assembler is assumed to read its
216standard input if given no non-option arguments. If your assembler
217cannot read standard input at all, use a @samp{%@{pipe:%e@}} construct;
218see @file{mips.h} for instance.
219@end defmac
220
221@defmac LINK_SPEC
222A C string constant that tells the GCC driver program options to
223pass to the linker. It can also specify how to translate options you
224give to GCC into options for GCC to pass to the linker.
225
226Do not define this macro if it does not need to do anything.
227@end defmac
228
229@defmac LIB_SPEC
230Another C string constant used much like @code{LINK_SPEC}. The difference
231between the two is that @code{LIB_SPEC} is used at the end of the
232command given to the linker.
233
234If this macro is not defined, a default is provided that
235loads the standard C library from the usual place. See @file{gcc.c}.
236@end defmac
237
238@defmac LIBGCC_SPEC
239Another C string constant that tells the GCC driver program
240how and when to place a reference to @file{libgcc.a} into the
241linker command line. This constant is placed both before and after
242the value of @code{LIB_SPEC}.
243
244If this macro is not defined, the GCC driver provides a default that
245passes the string @option{-lgcc} to the linker.
246@end defmac
247
248@defmac REAL_LIBGCC_SPEC
249By default, if @code{ENABLE_SHARED_LIBGCC} is defined, the
250@code{LIBGCC_SPEC} is not directly used by the driver program but is
251instead modified to refer to different versions of @file{libgcc.a}
252depending on the values of the command line flags @option{-static},
253@option{-shared}, @option{-static-libgcc}, and @option{-shared-libgcc}. On
254targets where these modifications are inappropriate, define
255@code{REAL_LIBGCC_SPEC} instead. @code{REAL_LIBGCC_SPEC} tells the
256driver how to place a reference to @file{libgcc} on the link command
257line, but, unlike @code{LIBGCC_SPEC}, it is used unmodified.
258@end defmac
259
260@defmac USE_LD_AS_NEEDED
261A macro that controls the modifications to @code{LIBGCC_SPEC}
262mentioned in @code{REAL_LIBGCC_SPEC}. If nonzero, a spec will be
e927b6ad
RO
263generated that uses @option{--as-needed} or equivalent options and the
264shared @file{libgcc} in place of the
38f8b050
JR
265static exception handler library, when linking without any of
266@code{-static}, @code{-static-libgcc}, or @code{-shared-libgcc}.
267@end defmac
268
269@defmac LINK_EH_SPEC
270If defined, this C string constant is added to @code{LINK_SPEC}.
271When @code{USE_LD_AS_NEEDED} is zero or undefined, it also affects
272the modifications to @code{LIBGCC_SPEC} mentioned in
273@code{REAL_LIBGCC_SPEC}.
274@end defmac
275
276@defmac STARTFILE_SPEC
277Another C string constant used much like @code{LINK_SPEC}. The
278difference between the two is that @code{STARTFILE_SPEC} is used at
279the very beginning of the command given to the linker.
280
281If this macro is not defined, a default is provided that loads the
282standard C startup file from the usual place. See @file{gcc.c}.
283@end defmac
284
285@defmac ENDFILE_SPEC
286Another C string constant used much like @code{LINK_SPEC}. The
287difference between the two is that @code{ENDFILE_SPEC} is used at
288the very end of the command given to the linker.
289
290Do not define this macro if it does not need to do anything.
291@end defmac
292
293@defmac THREAD_MODEL_SPEC
294GCC @code{-v} will print the thread model GCC was configured to use.
295However, this doesn't work on platforms that are multilibbed on thread
296models, such as AIX 4.3. On such platforms, define
297@code{THREAD_MODEL_SPEC} such that it evaluates to a string without
298blanks that names one of the recognized thread models. @code{%*}, the
299default value of this macro, will expand to the value of
300@code{thread_file} set in @file{config.gcc}.
301@end defmac
302
303@defmac SYSROOT_SUFFIX_SPEC
304Define this macro to add a suffix to the target sysroot when GCC is
305configured with a sysroot. This will cause GCC to search for usr/lib,
306et al, within sysroot+suffix.
307@end defmac
308
309@defmac SYSROOT_HEADERS_SUFFIX_SPEC
310Define this macro to add a headers_suffix to the target sysroot when
311GCC is configured with a sysroot. This will cause GCC to pass the
312updated sysroot+headers_suffix to CPP, causing it to search for
313usr/include, et al, within sysroot+headers_suffix.
314@end defmac
315
316@defmac EXTRA_SPECS
317Define this macro to provide additional specifications to put in the
318@file{specs} file that can be used in various specifications like
319@code{CC1_SPEC}.
320
321The definition should be an initializer for an array of structures,
322containing a string constant, that defines the specification name, and a
323string constant that provides the specification.
324
325Do not define this macro if it does not need to do anything.
326
327@code{EXTRA_SPECS} is useful when an architecture contains several
328related targets, which have various @code{@dots{}_SPECS} which are similar
329to each other, and the maintainer would like one central place to keep
330these definitions.
331
332For example, the PowerPC System V.4 targets use @code{EXTRA_SPECS} to
333define either @code{_CALL_SYSV} when the System V calling sequence is
334used or @code{_CALL_AIX} when the older AIX-based calling sequence is
335used.
336
337The @file{config/rs6000/rs6000.h} target file defines:
338
339@smallexample
340#define EXTRA_SPECS \
341 @{ "cpp_sysv_default", CPP_SYSV_DEFAULT @},
342
343#define CPP_SYS_DEFAULT ""
344@end smallexample
345
346The @file{config/rs6000/sysv.h} target file defines:
347@smallexample
348#undef CPP_SPEC
349#define CPP_SPEC \
350"%@{posix: -D_POSIX_SOURCE @} \
351%@{mcall-sysv: -D_CALL_SYSV @} \
352%@{!mcall-sysv: %(cpp_sysv_default) @} \
353%@{msoft-float: -D_SOFT_FLOAT@} %@{mcpu=403: -D_SOFT_FLOAT@}"
354
355#undef CPP_SYSV_DEFAULT
356#define CPP_SYSV_DEFAULT "-D_CALL_SYSV"
357@end smallexample
358
359while the @file{config/rs6000/eabiaix.h} target file defines
360@code{CPP_SYSV_DEFAULT} as:
361
362@smallexample
363#undef CPP_SYSV_DEFAULT
364#define CPP_SYSV_DEFAULT "-D_CALL_AIX"
365@end smallexample
366@end defmac
367
368@defmac LINK_LIBGCC_SPECIAL_1
369Define this macro if the driver program should find the library
370@file{libgcc.a}. If you do not define this macro, the driver program will pass
371the argument @option{-lgcc} to tell the linker to do the search.
372@end defmac
373
374@defmac LINK_GCC_C_SEQUENCE_SPEC
375The sequence in which libgcc and libc are specified to the linker.
376By default this is @code{%G %L %G}.
377@end defmac
378
379@defmac LINK_COMMAND_SPEC
380A C string constant giving the complete command line need to execute the
381linker. When you do this, you will need to update your port each time a
382change is made to the link command line within @file{gcc.c}. Therefore,
383define this macro only if you need to completely redefine the command
384line for invoking the linker and there is no other way to accomplish
385the effect you need. Overriding this macro may be avoidable by overriding
386@code{LINK_GCC_C_SEQUENCE_SPEC} instead.
387@end defmac
388
c49a6962
JM
389@hook TARGET_ALWAYS_STRIP_DOTDOT
390
38f8b050
JR
391@defmac MULTILIB_DEFAULTS
392Define this macro as a C expression for the initializer of an array of
393string to tell the driver program which options are defaults for this
394target and thus do not need to be handled specially when using
395@code{MULTILIB_OPTIONS}.
396
397Do not define this macro if @code{MULTILIB_OPTIONS} is not defined in
398the target makefile fragment or if none of the options listed in
399@code{MULTILIB_OPTIONS} are set by default.
400@xref{Target Fragment}.
401@end defmac
402
403@defmac RELATIVE_PREFIX_NOT_LINKDIR
404Define this macro to tell @command{gcc} that it should only translate
405a @option{-B} prefix into a @option{-L} linker option if the prefix
406indicates an absolute file name.
407@end defmac
408
409@defmac MD_EXEC_PREFIX
410If defined, this macro is an additional prefix to try after
411@code{STANDARD_EXEC_PREFIX}. @code{MD_EXEC_PREFIX} is not searched
412when the compiler is built as a cross
413compiler. If you define @code{MD_EXEC_PREFIX}, then be sure to add it
414to the list of directories used to find the assembler in @file{configure.in}.
415@end defmac
416
417@defmac STANDARD_STARTFILE_PREFIX
418Define this macro as a C string constant if you wish to override the
419standard choice of @code{libdir} as the default prefix to
420try when searching for startup files such as @file{crt0.o}.
421@code{STANDARD_STARTFILE_PREFIX} is not searched when the compiler
422is built as a cross compiler.
423@end defmac
424
425@defmac STANDARD_STARTFILE_PREFIX_1
426Define this macro as a C string constant if you wish to override the
427standard choice of @code{/lib} as a prefix to try after the default prefix
428when searching for startup files such as @file{crt0.o}.
429@code{STANDARD_STARTFILE_PREFIX_1} is not searched when the compiler
430is built as a cross compiler.
431@end defmac
432
433@defmac STANDARD_STARTFILE_PREFIX_2
434Define this macro as a C string constant if you wish to override the
435standard choice of @code{/lib} as yet another prefix to try after the
436default prefix when searching for startup files such as @file{crt0.o}.
437@code{STANDARD_STARTFILE_PREFIX_2} is not searched when the compiler
438is built as a cross compiler.
439@end defmac
440
441@defmac MD_STARTFILE_PREFIX
442If defined, this macro supplies an additional prefix to try after the
443standard prefixes. @code{MD_EXEC_PREFIX} is not searched when the
444compiler is built as a cross compiler.
445@end defmac
446
447@defmac MD_STARTFILE_PREFIX_1
448If defined, this macro supplies yet another prefix to try after the
449standard prefixes. It is not searched when the compiler is built as a
450cross compiler.
451@end defmac
452
453@defmac INIT_ENVIRONMENT
454Define this macro as a C string constant if you wish to set environment
455variables for programs called by the driver, such as the assembler and
456loader. The driver passes the value of this macro to @code{putenv} to
457initialize the necessary environment variables.
458@end defmac
459
460@defmac LOCAL_INCLUDE_DIR
461Define this macro as a C string constant if you wish to override the
462standard choice of @file{/usr/local/include} as the default prefix to
463try when searching for local header files. @code{LOCAL_INCLUDE_DIR}
08b2bad2
SB
464comes before @code{NATIVE_SYSTEM_HEADER_DIR} (set in
465@file{config.gcc}, normally @file{/usr/include}) in the search order.
38f8b050
JR
466
467Cross compilers do not search either @file{/usr/local/include} or its
468replacement.
469@end defmac
470
08b2bad2
SB
471@defmac NATIVE_SYSTEM_HEADER_COMPONENT
472The ``component'' corresponding to @code{NATIVE_SYSTEM_HEADER_DIR}.
38f8b050
JR
473See @code{INCLUDE_DEFAULTS}, below, for the description of components.
474If you do not define this macro, no component is used.
475@end defmac
476
477@defmac INCLUDE_DEFAULTS
478Define this macro if you wish to override the entire default search path
479for include files. For a native compiler, the default search path
480usually consists of @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR},
08b2bad2
SB
481@code{GPLUSPLUS_INCLUDE_DIR}, and
482@code{NATIVE_SYSTEM_HEADER_DIR}. In addition, @code{GPLUSPLUS_INCLUDE_DIR}
38f8b050
JR
483and @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile},
484and specify private search areas for GCC@. The directory
485@code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs.
486
487The definition should be an initializer for an array of structures.
488Each array element should have four elements: the directory name (a
489string constant), the component name (also a string constant), a flag
490for C++-only directories,
491and a flag showing that the includes in the directory don't need to be
492wrapped in @code{extern @samp{C}} when compiling C++. Mark the end of
493the array with a null element.
494
495The component name denotes what GNU package the include file is part of,
496if any, in all uppercase letters. For example, it might be @samp{GCC}
497or @samp{BINUTILS}. If the package is part of a vendor-supplied
498operating system, code the component name as @samp{0}.
499
500For example, here is the definition used for VAX/VMS:
501
502@smallexample
503#define INCLUDE_DEFAULTS \
504@{ \
505 @{ "GNU_GXX_INCLUDE:", "G++", 1, 1@}, \
506 @{ "GNU_CC_INCLUDE:", "GCC", 0, 0@}, \
507 @{ "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0@}, \
508 @{ ".", 0, 0, 0@}, \
509 @{ 0, 0, 0, 0@} \
510@}
511@end smallexample
512@end defmac
513
514Here is the order of prefixes tried for exec files:
515
516@enumerate
517@item
518Any prefixes specified by the user with @option{-B}.
519
520@item
521The environment variable @code{GCC_EXEC_PREFIX} or, if @code{GCC_EXEC_PREFIX}
ff2ce160 522is not set and the compiler has not been installed in the configure-time
38f8b050
JR
523@var{prefix}, the location in which the compiler has actually been installed.
524
525@item
526The directories specified by the environment variable @code{COMPILER_PATH}.
527
528@item
529The macro @code{STANDARD_EXEC_PREFIX}, if the compiler has been installed
ff2ce160 530in the configured-time @var{prefix}.
38f8b050
JR
531
532@item
ff2ce160 533The location @file{/usr/libexec/gcc/}, but only if this is a native compiler.
38f8b050
JR
534
535@item
ff2ce160 536The location @file{/usr/lib/gcc/}, but only if this is a native compiler.
38f8b050
JR
537
538@item
ff2ce160 539The macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native
38f8b050
JR
540compiler.
541@end enumerate
542
543Here is the order of prefixes tried for startfiles:
544
545@enumerate
546@item
547Any prefixes specified by the user with @option{-B}.
548
549@item
550The environment variable @code{GCC_EXEC_PREFIX} or its automatically determined
551value based on the installed toolchain location.
552
553@item
554The directories specified by the environment variable @code{LIBRARY_PATH}
555(or port-specific name; native only, cross compilers do not use this).
556
557@item
558The macro @code{STANDARD_EXEC_PREFIX}, but only if the toolchain is installed
ff2ce160 559in the configured @var{prefix} or this is a native compiler.
38f8b050
JR
560
561@item
562The location @file{/usr/lib/gcc/}, but only if this is a native compiler.
563
564@item
ff2ce160 565The macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native
38f8b050
JR
566compiler.
567
568@item
ff2ce160 569The macro @code{MD_STARTFILE_PREFIX}, if defined, but only if this is a
38f8b050
JR
570native compiler, or we have a target system root.
571
572@item
ff2ce160 573The macro @code{MD_STARTFILE_PREFIX_1}, if defined, but only if this is a
38f8b050
JR
574native compiler, or we have a target system root.
575
576@item
577The macro @code{STANDARD_STARTFILE_PREFIX}, with any sysroot modifications.
578If this path is relative it will be prefixed by @code{GCC_EXEC_PREFIX} and
579the machine suffix or @code{STANDARD_EXEC_PREFIX} and the machine suffix.
580
581@item
582The macro @code{STANDARD_STARTFILE_PREFIX_1}, but only if this is a native
583compiler, or we have a target system root. The default for this macro is
584@file{/lib/}.
585
586@item
587The macro @code{STANDARD_STARTFILE_PREFIX_2}, but only if this is a native
588compiler, or we have a target system root. The default for this macro is
589@file{/usr/lib/}.
590@end enumerate
591
592@node Run-time Target
593@section Run-time Target Specification
594@cindex run-time target specification
595@cindex predefined macros
596@cindex target specifications
597
598@c prevent bad page break with this line
599Here are run-time target specifications.
600
601@defmac TARGET_CPU_CPP_BUILTINS ()
602This function-like macro expands to a block of code that defines
603built-in preprocessor macros and assertions for the target CPU, using
604the functions @code{builtin_define}, @code{builtin_define_std} and
605@code{builtin_assert}. When the front end
606calls this macro it provides a trailing semicolon, and since it has
607finished command line option processing your code can use those
608results freely.
609
610@code{builtin_assert} takes a string in the form you pass to the
611command-line option @option{-A}, such as @code{cpu=mips}, and creates
612the assertion. @code{builtin_define} takes a string in the form
613accepted by option @option{-D} and unconditionally defines the macro.
614
615@code{builtin_define_std} takes a string representing the name of an
616object-like macro. If it doesn't lie in the user's namespace,
617@code{builtin_define_std} defines it unconditionally. Otherwise, it
618defines a version with two leading underscores, and another version
619with two leading and trailing underscores, and defines the original
620only if an ISO standard was not requested on the command line. For
621example, passing @code{unix} defines @code{__unix}, @code{__unix__}
622and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
623@code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
624defines only @code{_ABI64}.
625
626You can also test for the C dialect being compiled. The variable
627@code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus}
628or @code{clk_objective_c}. Note that if we are preprocessing
629assembler, this variable will be @code{clk_c} but the function-like
630macro @code{preprocessing_asm_p()} will return true, so you might want
631to check for that first. If you need to check for strict ANSI, the
632variable @code{flag_iso} can be used. The function-like macro
633@code{preprocessing_trad_p()} can be used to check for traditional
634preprocessing.
635@end defmac
636
637@defmac TARGET_OS_CPP_BUILTINS ()
638Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
639and is used for the target operating system instead.
640@end defmac
641
642@defmac TARGET_OBJFMT_CPP_BUILTINS ()
643Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
644and is used for the target object format. @file{elfos.h} uses this
645macro to define @code{__ELF__}, so you probably do not need to define
646it yourself.
647@end defmac
648
649@deftypevar {extern int} target_flags
650This variable is declared in @file{options.h}, which is included before
651any target-specific headers.
652@end deftypevar
653
654@hook TARGET_DEFAULT_TARGET_FLAGS
655This variable specifies the initial value of @code{target_flags}.
656Its default setting is 0.
657@end deftypevr
658
659@cindex optional hardware or system features
660@cindex features, optional, in system conventions
661
662@hook TARGET_HANDLE_OPTION
663This hook is called whenever the user specifies one of the
664target-specific options described by the @file{.opt} definition files
665(@pxref{Options}). It has the opportunity to do some option-specific
666processing and should return true if the option is valid. The default
667definition does nothing but return true.
668
96e45421
JM
669@var{decoded} specifies the option and its arguments. @var{opts} and
670@var{opts_set} are the @code{gcc_options} structures to be used for
671storing option state, and @var{loc} is the location at which the
672option was passed (@code{UNKNOWN_LOCATION} except for options passed
673via attributes).
38f8b050
JR
674@end deftypefn
675
676@hook TARGET_HANDLE_C_OPTION
677This target hook is called whenever the user specifies one of the
678target-specific C language family options described by the @file{.opt}
679definition files(@pxref{Options}). It has the opportunity to do some
680option-specific processing and should return true if the option is
681valid. The arguments are like for @code{TARGET_HANDLE_OPTION}. The
682default definition does nothing but return false.
683
684In general, you should use @code{TARGET_HANDLE_OPTION} to handle
685options. However, if processing an option requires routines that are
686only available in the C (and related language) front ends, then you
687should use @code{TARGET_HANDLE_C_OPTION} instead.
688@end deftypefn
689
91ebb981
IS
690@hook TARGET_OBJC_CONSTRUCT_STRING_OBJECT
691
70f42967
SB
692@hook TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE
693
694@hook TARGET_OBJC_DECLARE_CLASS_DEFINITION
695
91ebb981
IS
696@hook TARGET_STRING_OBJECT_REF_TYPE_P
697
698@hook TARGET_CHECK_STRING_OBJECT_FORMAT_ARG
26705988 699
38f8b050
JR
700@hook TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
701This target function is similar to the hook @code{TARGET_OPTION_OVERRIDE}
702but is called when the optimize level is changed via an attribute or
703pragma or when it is reset at the end of the code affected by the
704attribute or pragma. It is not called at the beginning of compilation
705when @code{TARGET_OPTION_OVERRIDE} is called so if you want to perform these
706actions then, you should have @code{TARGET_OPTION_OVERRIDE} call
707@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}.
708@end deftypefn
709
710@defmac C_COMMON_OVERRIDE_OPTIONS
c5387660
JM
711This is similar to the @code{TARGET_OPTION_OVERRIDE} hook
712but is only used in the C
38f8b050
JR
713language frontends (C, Objective-C, C++, Objective-C++) and so can be
714used to alter option flag variables which only exist in those
715frontends.
716@end defmac
717
3020190e 718@hook TARGET_OPTION_OPTIMIZATION_TABLE
38f8b050 719Some machines may desire to change what optimizations are performed for
3020190e
JM
720various optimization levels. This variable, if defined, describes
721options to enable at particular sets of optimization levels. These
722options are processed once
38f8b050 723just after the optimization level is determined and before the remainder
3020190e 724of the command options have been parsed, so may be overridden by other
2b0d3573 725options passed explicitly.
38f8b050 726
3020190e 727This processing is run once at program startup and when the optimization
38f8b050
JR
728options are changed via @code{#pragma GCC optimize} or by using the
729@code{optimize} attribute.
3020190e 730@end deftypevr
38f8b050 731
7e4aae92
JM
732@hook TARGET_OPTION_INIT_STRUCT
733
128dc8e2
JM
734@hook TARGET_OPTION_DEFAULT_PARAMS
735
3bd36029
RS
736@defmac SWITCHABLE_TARGET
737Some targets need to switch between substantially different subtargets
738during compilation. For example, the MIPS target has one subtarget for
739the traditional MIPS architecture and another for MIPS16. Source code
740can switch between these two subarchitectures using the @code{mips16}
741and @code{nomips16} attributes.
742
743Such subtargets can differ in things like the set of available
744registers, the set of available instructions, the costs of various
745operations, and so on. GCC caches a lot of this type of information
746in global variables, and recomputing them for each subtarget takes a
747significant amount of time. The compiler therefore provides a facility
748for maintaining several versions of the global variables and quickly
749switching between them; see @file{target-globals.h} for details.
750
751Define this macro to 1 if your target needs this facility. The default
752is 0.
753@end defmac
754
38f8b050
JR
755@node Per-Function Data
756@section Defining data structures for per-function information.
757@cindex per-function data
758@cindex data structures
759
760If the target needs to store information on a per-function basis, GCC
761provides a macro and a couple of variables to allow this. Note, just
762using statics to store the information is a bad idea, since GCC supports
763nested functions, so you can be halfway through encoding one function
764when another one comes along.
765
766GCC defines a data structure called @code{struct function} which
767contains all of the data specific to an individual function. This
768structure contains a field called @code{machine} whose type is
769@code{struct machine_function *}, which can be used by targets to point
770to their own specific data.
771
772If a target needs per-function specific data it should define the type
773@code{struct machine_function} and also the macro @code{INIT_EXPANDERS}.
774This macro should be used to initialize the function pointer
775@code{init_machine_status}. This pointer is explained below.
776
777One typical use of per-function, target specific data is to create an
778RTX to hold the register containing the function's return address. This
779RTX can then be used to implement the @code{__builtin_return_address}
780function, for level 0.
781
782Note---earlier implementations of GCC used a single data area to hold
783all of the per-function information. Thus when processing of a nested
784function began the old per-function data had to be pushed onto a
785stack, and when the processing was finished, it had to be popped off the
786stack. GCC used to provide function pointers called
787@code{save_machine_status} and @code{restore_machine_status} to handle
788the saving and restoring of the target specific information. Since the
789single data area approach is no longer used, these pointers are no
790longer supported.
791
792@defmac INIT_EXPANDERS
793Macro called to initialize any target specific information. This macro
794is called once per function, before generation of any RTL has begun.
795The intention of this macro is to allow the initialization of the
796function pointer @code{init_machine_status}.
797@end defmac
798
799@deftypevar {void (*)(struct function *)} init_machine_status
800If this function pointer is non-@code{NULL} it will be called once per
801function, before function compilation starts, in order to allow the
802target to perform any target specific initialization of the
803@code{struct function} structure. It is intended that this would be
804used to initialize the @code{machine} of that structure.
805
806@code{struct machine_function} structures are expected to be freed by GC@.
807Generally, any memory that they reference must be allocated by using
808GC allocation, including the structure itself.
809@end deftypevar
810
811@node Storage Layout
812@section Storage Layout
813@cindex storage layout
814
815Note that the definitions of the macros in this table which are sizes or
816alignments measured in bits do not need to be constant. They can be C
817expressions that refer to static variables, such as the @code{target_flags}.
818@xref{Run-time Target}.
819
820@defmac BITS_BIG_ENDIAN
821Define this macro to have the value 1 if the most significant bit in a
822byte has the lowest number; otherwise define it to have the value zero.
823This means that bit-field instructions count from the most significant
824bit. If the machine has no bit-field instructions, then this must still
825be defined, but it doesn't matter which value it is defined to. This
826macro need not be a constant.
827
828This macro does not affect the way structure fields are packed into
829bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}.
830@end defmac
831
832@defmac BYTES_BIG_ENDIAN
833Define this macro to have the value 1 if the most significant byte in a
834word has the lowest number. This macro need not be a constant.
835@end defmac
836
837@defmac WORDS_BIG_ENDIAN
838Define this macro to have the value 1 if, in a multiword object, the
839most significant word has the lowest number. This applies to both
c0a6a1ef
BS
840memory locations and registers; see @code{REG_WORDS_BIG_ENDIAN} if the
841order of words in memory is not the same as the order in registers. This
38f8b050
JR
842macro need not be a constant.
843@end defmac
844
c0a6a1ef
BS
845@defmac REG_WORDS_BIG_ENDIAN
846On some machines, the order of words in a multiword object differs between
847registers in memory. In such a situation, define this macro to describe
848the order of words in a register. The macro @code{WORDS_BIG_ENDIAN} controls
849the order of words in memory.
850@end defmac
851
38f8b050
JR
852@defmac FLOAT_WORDS_BIG_ENDIAN
853Define this macro to have the value 1 if @code{DFmode}, @code{XFmode} or
854@code{TFmode} floating point numbers are stored in memory with the word
855containing the sign bit at the lowest address; otherwise define it to
856have the value 0. This macro need not be a constant.
857
858You need not define this macro if the ordering is the same as for
859multi-word integers.
860@end defmac
861
862@defmac BITS_PER_UNIT
863Define this macro to be the number of bits in an addressable storage
864unit (byte). If you do not define this macro the default is 8.
865@end defmac
866
867@defmac BITS_PER_WORD
868Number of bits in a word. If you do not define this macro, the default
869is @code{BITS_PER_UNIT * UNITS_PER_WORD}.
870@end defmac
871
872@defmac MAX_BITS_PER_WORD
873Maximum number of bits in a word. If this is undefined, the default is
874@code{BITS_PER_WORD}. Otherwise, it is the constant value that is the
875largest value that @code{BITS_PER_WORD} can have at run-time.
876@end defmac
877
878@defmac UNITS_PER_WORD
879Number of storage units in a word; normally the size of a general-purpose
880register, a power of two from 1 or 8.
881@end defmac
882
883@defmac MIN_UNITS_PER_WORD
884Minimum number of units in a word. If this is undefined, the default is
885@code{UNITS_PER_WORD}. Otherwise, it is the constant value that is the
886smallest value that @code{UNITS_PER_WORD} can have at run-time.
887@end defmac
888
38f8b050
JR
889@defmac POINTER_SIZE
890Width of a pointer, in bits. You must specify a value no wider than the
891width of @code{Pmode}. If it is not equal to the width of @code{Pmode},
892you must define @code{POINTERS_EXTEND_UNSIGNED}. If you do not specify
893a value the default is @code{BITS_PER_WORD}.
894@end defmac
895
896@defmac POINTERS_EXTEND_UNSIGNED
897A C expression that determines how pointers should be extended from
898@code{ptr_mode} to either @code{Pmode} or @code{word_mode}. It is
899greater than zero if pointers should be zero-extended, zero if they
900should be sign-extended, and negative if some other sort of conversion
901is needed. In the last case, the extension is done by the target's
902@code{ptr_extend} instruction.
903
904You need not define this macro if the @code{ptr_mode}, @code{Pmode}
905and @code{word_mode} are all the same width.
906@end defmac
907
908@defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type})
909A macro to update @var{m} and @var{unsignedp} when an object whose type
910is @var{type} and which has the specified mode and signedness is to be
911stored in a register. This macro is only called when @var{type} is a
912scalar type.
913
914On most RISC machines, which only have operations that operate on a full
915register, define this macro to set @var{m} to @code{word_mode} if
916@var{m} is an integer mode narrower than @code{BITS_PER_WORD}. In most
917cases, only integer modes should be widened because wider-precision
918floating-point operations are usually more expensive than their narrower
919counterparts.
920
921For most machines, the macro definition does not change @var{unsignedp}.
922However, some machines, have instructions that preferentially handle
923either signed or unsigned quantities of certain modes. For example, on
924the DEC Alpha, 32-bit loads from memory and 32-bit add instructions
925sign-extend the result to 64 bits. On such machines, set
926@var{unsignedp} according to which kind of extension is more efficient.
927
928Do not define this macro if it would never modify @var{m}.
929@end defmac
930
931@hook TARGET_PROMOTE_FUNCTION_MODE
932Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or
933function return values. The target hook should return the new mode
934and possibly change @code{*@var{punsignedp}} if the promotion should
935change signedness. This function is called only for scalar @emph{or
936pointer} types.
937
938@var{for_return} allows to distinguish the promotion of arguments and
939return values. If it is @code{1}, a return value is being promoted and
940@code{TARGET_FUNCTION_VALUE} must perform the same promotions done here.
941If it is @code{2}, the returned mode should be that of the register in
942which an incoming parameter is copied, or the outgoing result is computed;
943then the hook should return the same mode as @code{promote_mode}, though
944the signedness may be different.
945
5e617be8
AK
946@var{type} can be NULL when promoting function arguments of libcalls.
947
38f8b050
JR
948The default is to not promote arguments and return values. You can
949also define the hook to @code{default_promote_function_mode_always_promote}
950if you would like to apply the same rules given by @code{PROMOTE_MODE}.
951@end deftypefn
952
953@defmac PARM_BOUNDARY
954Normal alignment required for function parameters on the stack, in
955bits. All stack parameters receive at least this much alignment
956regardless of data type. On most machines, this is the same as the
957size of an integer.
958@end defmac
959
960@defmac STACK_BOUNDARY
961Define this macro to the minimum alignment enforced by hardware for the
962stack pointer on this machine. The definition is a C expression for the
963desired alignment (measured in bits). This value is used as a default
964if @code{PREFERRED_STACK_BOUNDARY} is not defined. On most machines,
965this should be the same as @code{PARM_BOUNDARY}.
966@end defmac
967
968@defmac PREFERRED_STACK_BOUNDARY
969Define this macro if you wish to preserve a certain alignment for the
970stack pointer, greater than what the hardware enforces. The definition
971is a C expression for the desired alignment (measured in bits). This
972macro must evaluate to a value equal to or larger than
973@code{STACK_BOUNDARY}.
974@end defmac
975
976@defmac INCOMING_STACK_BOUNDARY
977Define this macro if the incoming stack boundary may be different
978from @code{PREFERRED_STACK_BOUNDARY}. This macro must evaluate
979to a value equal to or larger than @code{STACK_BOUNDARY}.
980@end defmac
981
982@defmac FUNCTION_BOUNDARY
983Alignment required for a function entry point, in bits.
984@end defmac
985
986@defmac BIGGEST_ALIGNMENT
987Biggest alignment that any data type can require on this machine, in
988bits. Note that this is not the biggest alignment that is supported,
989just the biggest alignment that, when violated, may cause a fault.
990@end defmac
991
992@defmac MALLOC_ABI_ALIGNMENT
993Alignment, in bits, a C conformant malloc implementation has to
994provide. If not defined, the default value is @code{BITS_PER_WORD}.
995@end defmac
996
997@defmac ATTRIBUTE_ALIGNED_VALUE
998Alignment used by the @code{__attribute__ ((aligned))} construct. If
999not defined, the default value is @code{BIGGEST_ALIGNMENT}.
1000@end defmac
1001
1002@defmac MINIMUM_ATOMIC_ALIGNMENT
1003If defined, the smallest alignment, in bits, that can be given to an
1004object that can be referenced in one operation, without disturbing any
1005nearby object. Normally, this is @code{BITS_PER_UNIT}, but may be larger
1006on machines that don't have byte or half-word store operations.
1007@end defmac
1008
1009@defmac BIGGEST_FIELD_ALIGNMENT
1010Biggest alignment that any structure or union field can require on this
1011machine, in bits. If defined, this overrides @code{BIGGEST_ALIGNMENT} for
1012structure and union fields only, unless the field alignment has been set
1013by the @code{__attribute__ ((aligned (@var{n})))} construct.
1014@end defmac
1015
1016@defmac ADJUST_FIELD_ALIGN (@var{field}, @var{computed})
1017An expression for the alignment of a structure field @var{field} if the
1018alignment computed in the usual way (including applying of
1019@code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the
1020alignment) is @var{computed}. It overrides alignment only if the
1021field alignment has not been set by the
1022@code{__attribute__ ((aligned (@var{n})))} construct.
1023@end defmac
1024
1025@defmac MAX_STACK_ALIGNMENT
1026Biggest stack alignment guaranteed by the backend. Use this macro
1027to specify the maximum alignment of a variable on stack.
1028
1029If not defined, the default value is @code{STACK_BOUNDARY}.
1030
1031@c FIXME: The default should be @code{PREFERRED_STACK_BOUNDARY}.
1032@c But the fix for PR 32893 indicates that we can only guarantee
1033@c maximum stack alignment on stack up to @code{STACK_BOUNDARY}, not
1034@c @code{PREFERRED_STACK_BOUNDARY}, if stack alignment isn't supported.
1035@end defmac
1036
1037@defmac MAX_OFILE_ALIGNMENT
1038Biggest alignment supported by the object file format of this machine.
1039Use this macro to limit the alignment which can be specified using the
1040@code{__attribute__ ((aligned (@var{n})))} construct. If not defined,
1041the default value is @code{BIGGEST_ALIGNMENT}.
1042
1043On systems that use ELF, the default (in @file{config/elfos.h}) is
1044the largest supported 32-bit ELF section alignment representable on
1045a 32-bit host e.g. @samp{(((unsigned HOST_WIDEST_INT) 1 << 28) * 8)}.
1046On 32-bit ELF the largest supported section alignment in bits is
1047@samp{(0x80000000 * 8)}, but this is not representable on 32-bit hosts.
1048@end defmac
1049
1050@defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
1051If defined, a C expression to compute the alignment for a variable in
1052the static store. @var{type} is the data type, and @var{basic-align} is
1053the alignment that the object would ordinarily have. The value of this
1054macro is used instead of that alignment to align the object.
1055
1056If this macro is not defined, then @var{basic-align} is used.
1057
1058@findex strcpy
1059One use of this macro is to increase alignment of medium-size data to
1060make it all fit in fewer cache lines. Another is to cause character
1061arrays to be word-aligned so that @code{strcpy} calls that copy
1062constants to character arrays can be done inline.
1063@end defmac
1064
1065@defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
1066If defined, a C expression to compute the alignment given to a constant
1067that is being placed in memory. @var{constant} is the constant and
1068@var{basic-align} is the alignment that the object would ordinarily
1069have. The value of this macro is used instead of that alignment to
1070align the object.
1071
1072If this macro is not defined, then @var{basic-align} is used.
1073
1074The typical use of this macro is to increase alignment for string
1075constants to be word aligned so that @code{strcpy} calls that copy
1076constants can be done inline.
1077@end defmac
1078
1079@defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
1080If defined, a C expression to compute the alignment for a variable in
1081the local store. @var{type} is the data type, and @var{basic-align} is
1082the alignment that the object would ordinarily have. The value of this
1083macro is used instead of that alignment to align the object.
1084
1085If this macro is not defined, then @var{basic-align} is used.
1086
1087One use of this macro is to increase alignment of medium-size data to
1088make it all fit in fewer cache lines.
4a6336ad 1089
64ad7c99 1090If the value of this macro has a type, it should be an unsigned type.
38f8b050
JR
1091@end defmac
1092
5aea1e76
UW
1093@hook TARGET_VECTOR_ALIGNMENT
1094
38f8b050
JR
1095@defmac STACK_SLOT_ALIGNMENT (@var{type}, @var{mode}, @var{basic-align})
1096If defined, a C expression to compute the alignment for stack slot.
1097@var{type} is the data type, @var{mode} is the widest mode available,
1098and @var{basic-align} is the alignment that the slot would ordinarily
1099have. The value of this macro is used instead of that alignment to
1100align the slot.
1101
1102If this macro is not defined, then @var{basic-align} is used when
1103@var{type} is @code{NULL}. Otherwise, @code{LOCAL_ALIGNMENT} will
1104be used.
1105
1106This macro is to set alignment of stack slot to the maximum alignment
1107of all possible modes which the slot may have.
4a6336ad 1108
64ad7c99 1109If the value of this macro has a type, it should be an unsigned type.
38f8b050
JR
1110@end defmac
1111
1112@defmac LOCAL_DECL_ALIGNMENT (@var{decl})
1113If defined, a C expression to compute the alignment for a local
1114variable @var{decl}.
1115
1116If this macro is not defined, then
1117@code{LOCAL_ALIGNMENT (TREE_TYPE (@var{decl}), DECL_ALIGN (@var{decl}))}
1118is used.
1119
1120One use of this macro is to increase alignment of medium-size data to
1121make it all fit in fewer cache lines.
4a6336ad 1122
64ad7c99 1123If the value of this macro has a type, it should be an unsigned type.
38f8b050
JR
1124@end defmac
1125
1126@defmac MINIMUM_ALIGNMENT (@var{exp}, @var{mode}, @var{align})
1127If defined, a C expression to compute the minimum required alignment
1128for dynamic stack realignment purposes for @var{exp} (a type or decl),
1129@var{mode}, assuming normal alignment @var{align}.
1130
1131If this macro is not defined, then @var{align} will be used.
1132@end defmac
1133
1134@defmac EMPTY_FIELD_BOUNDARY
1135Alignment in bits to be given to a structure bit-field that follows an
1136empty field such as @code{int : 0;}.
1137
1138If @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro.
1139@end defmac
1140
1141@defmac STRUCTURE_SIZE_BOUNDARY
1142Number of bits which any structure or union's size must be a multiple of.
1143Each structure or union's size is rounded up to a multiple of this.
1144
1145If you do not define this macro, the default is the same as
1146@code{BITS_PER_UNIT}.
1147@end defmac
1148
1149@defmac STRICT_ALIGNMENT
1150Define this macro to be the value 1 if instructions will fail to work
1151if given data not on the nominal alignment. If instructions will merely
1152go slower in that case, define this macro as 0.
1153@end defmac
1154
1155@defmac PCC_BITFIELD_TYPE_MATTERS
1156Define this if you wish to imitate the way many other C compilers handle
1157alignment of bit-fields and the structures that contain them.
1158
1159The behavior is that the type written for a named bit-field (@code{int},
1160@code{short}, or other integer type) imposes an alignment for the entire
1161structure, as if the structure really did contain an ordinary field of
1162that type. In addition, the bit-field is placed within the structure so
1163that it would fit within such a field, not crossing a boundary for it.
1164
1165Thus, on most machines, a named bit-field whose type is written as
1166@code{int} would not cross a four-byte boundary, and would force
1167four-byte alignment for the whole structure. (The alignment used may
1168not be four bytes; it is controlled by the other alignment parameters.)
1169
1170An unnamed bit-field will not affect the alignment of the containing
1171structure.
1172
1173If the macro is defined, its definition should be a C expression;
1174a nonzero value for the expression enables this behavior.
1175
1176Note that if this macro is not defined, or its value is zero, some
1177bit-fields may cross more than one alignment boundary. The compiler can
1178support such references if there are @samp{insv}, @samp{extv}, and
1179@samp{extzv} insns that can directly reference memory.
1180
1181The other known way of making bit-fields work is to define
1182@code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}.
1183Then every structure can be accessed with fullwords.
1184
1185Unless the machine has bit-field instructions or you define
1186@code{STRUCTURE_SIZE_BOUNDARY} that way, you must define
1187@code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value.
1188
1189If your aim is to make GCC use the same conventions for laying out
1190bit-fields as are used by another compiler, here is how to investigate
1191what the other compiler does. Compile and run this program:
1192
1193@smallexample
1194struct foo1
1195@{
1196 char x;
1197 char :0;
1198 char y;
1199@};
1200
1201struct foo2
1202@{
1203 char x;
1204 int :0;
1205 char y;
1206@};
1207
1208main ()
1209@{
1210 printf ("Size of foo1 is %d\n",
1211 sizeof (struct foo1));
1212 printf ("Size of foo2 is %d\n",
1213 sizeof (struct foo2));
1214 exit (0);
1215@}
1216@end smallexample
1217
1218If this prints 2 and 5, then the compiler's behavior is what you would
1219get from @code{PCC_BITFIELD_TYPE_MATTERS}.
1220@end defmac
1221
1222@defmac BITFIELD_NBYTES_LIMITED
1223Like @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited
1224to aligning a bit-field within the structure.
1225@end defmac
1226
1227@hook TARGET_ALIGN_ANON_BITFIELD
1228When @code{PCC_BITFIELD_TYPE_MATTERS} is true this hook will determine
1229whether unnamed bitfields affect the alignment of the containing
1230structure. The hook should return true if the structure should inherit
1231the alignment requirements of an unnamed bitfield's type.
1232@end deftypefn
1233
1234@hook TARGET_NARROW_VOLATILE_BITFIELD
1235This target hook should return @code{true} if accesses to volatile bitfields
1236should use the narrowest mode possible. It should return @code{false} if
1237these accesses should use the bitfield container type.
1238
1239The default is @code{!TARGET_STRICT_ALIGN}.
1240@end deftypefn
1241
d9886a9e
L
1242@hook TARGET_MEMBER_TYPE_FORCES_BLK
1243Return true if a structure, union or array containing @var{field} should
1244be accessed using @code{BLKMODE}.
38f8b050
JR
1245
1246If @var{field} is the only field in the structure, @var{mode} is its
1247mode, otherwise @var{mode} is VOIDmode. @var{mode} is provided in the
1248case where structures of one field would require the structure's mode to
1249retain the field's mode.
1250
1251Normally, this is not needed.
d9886a9e 1252@end deftypefn
38f8b050
JR
1253
1254@defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified})
1255Define this macro as an expression for the alignment of a type (given
1256by @var{type} as a tree node) if the alignment computed in the usual
1257way is @var{computed} and the alignment explicitly specified was
1258@var{specified}.
1259
1260The default is to use @var{specified} if it is larger; otherwise, use
1261the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT}
1262@end defmac
1263
1264@defmac MAX_FIXED_MODE_SIZE
1265An integer expression for the size in bits of the largest integer
1266machine mode that should actually be used. All integer machine modes of
1267this size or smaller can be used for structures and unions with the
1268appropriate sizes. If this macro is undefined, @code{GET_MODE_BITSIZE
1269(DImode)} is assumed.
1270@end defmac
1271
1272@defmac STACK_SAVEAREA_MODE (@var{save_level})
1273If defined, an expression of type @code{enum machine_mode} that
1274specifies the mode of the save area operand of a
1275@code{save_stack_@var{level}} named pattern (@pxref{Standard Names}).
1276@var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or
1277@code{SAVE_NONLOCAL} and selects which of the three named patterns is
1278having its mode specified.
1279
1280You need not define this macro if it always returns @code{Pmode}. You
1281would most commonly define this macro if the
1282@code{save_stack_@var{level}} patterns need to support both a 32- and a
128364-bit mode.
1284@end defmac
1285
1286@defmac STACK_SIZE_MODE
1287If defined, an expression of type @code{enum machine_mode} that
1288specifies the mode of the size increment operand of an
1289@code{allocate_stack} named pattern (@pxref{Standard Names}).
1290
1291You need not define this macro if it always returns @code{word_mode}.
1292You would most commonly define this macro if the @code{allocate_stack}
1293pattern needs to support both a 32- and a 64-bit mode.
1294@end defmac
1295
1296@hook TARGET_LIBGCC_CMP_RETURN_MODE
1297This target hook should return the mode to be used for the return value
1298of compare instructions expanded to libgcc calls. If not defined
1299@code{word_mode} is returned which is the right choice for a majority of
1300targets.
1301@end deftypefn
1302
1303@hook TARGET_LIBGCC_SHIFT_COUNT_MODE
1304This target hook should return the mode to be used for the shift count operand
1305of shift instructions expanded to libgcc calls. If not defined
1306@code{word_mode} is returned which is the right choice for a majority of
1307targets.
1308@end deftypefn
1309
1310@hook TARGET_UNWIND_WORD_MODE
1311Return machine mode to be used for @code{_Unwind_Word} type.
1312The default is to use @code{word_mode}.
1313@end deftypefn
1314
1315@defmac ROUND_TOWARDS_ZERO
1316If defined, this macro should be true if the prevailing rounding
1317mode is towards zero.
1318
1319Defining this macro only affects the way @file{libgcc.a} emulates
1320floating-point arithmetic.
1321
1322Not defining this macro is equivalent to returning zero.
1323@end defmac
1324
1325@defmac LARGEST_EXPONENT_IS_NORMAL (@var{size})
1326This macro should return true if floats with @var{size}
1327bits do not have a NaN or infinity representation, but use the largest
1328exponent for normal numbers instead.
1329
1330Defining this macro only affects the way @file{libgcc.a} emulates
1331floating-point arithmetic.
1332
1333The default definition of this macro returns false for all sizes.
1334@end defmac
1335
1336@hook TARGET_MS_BITFIELD_LAYOUT_P
1337This target hook returns @code{true} if bit-fields in the given
1338@var{record_type} are to be laid out following the rules of Microsoft
1339Visual C/C++, namely: (i) a bit-field won't share the same storage
1340unit with the previous bit-field if their underlying types have
1341different sizes, and the bit-field will be aligned to the highest
1342alignment of the underlying types of itself and of the previous
1343bit-field; (ii) a zero-sized bit-field will affect the alignment of
1344the whole enclosing structure, even if it is unnamed; except that
1345(iii) a zero-sized bit-field will be disregarded unless it follows
1346another bit-field of nonzero size. If this hook returns @code{true},
1347other macros that control bit-field layout are ignored.
1348
1349When a bit-field is inserted into a packed record, the whole size
1350of the underlying type is used by one or more same-size adjacent
1351bit-fields (that is, if its long:3, 32 bits is used in the record,
1352and any additional adjacent long bit-fields are packed into the same
1353chunk of 32 bits. However, if the size changes, a new field of that
1354size is allocated). In an unpacked record, this is the same as using
1355alignment, but not equivalent when packing.
1356
1357If both MS bit-fields and @samp{__attribute__((packed))} are used,
1358the latter will take precedence. If @samp{__attribute__((packed))} is
1359used on a single field when MS bit-fields are in use, it will take
1360precedence for that field, but the alignment of the rest of the structure
1361may affect its placement.
1362@end deftypefn
1363
1364@hook TARGET_DECIMAL_FLOAT_SUPPORTED_P
1365Returns true if the target supports decimal floating point.
1366@end deftypefn
1367
1368@hook TARGET_FIXED_POINT_SUPPORTED_P
1369Returns true if the target supports fixed-point arithmetic.
1370@end deftypefn
1371
1372@hook TARGET_EXPAND_TO_RTL_HOOK
1373This hook is called just before expansion into rtl, allowing the target
1374to perform additional initializations or analysis before the expansion.
1375For example, the rs6000 port uses it to allocate a scratch stack slot
1376for use in copying SDmode values between memory and floating point
1377registers whenever the function being expanded has any SDmode
1378usage.
1379@end deftypefn
1380
1381@hook TARGET_INSTANTIATE_DECLS
1382This hook allows the backend to perform additional instantiations on rtl
1383that are not actually in any insns yet, but will be later.
1384@end deftypefn
1385
1386@hook TARGET_MANGLE_TYPE
1387If your target defines any fundamental types, or any types your target
1388uses should be mangled differently from the default, define this hook
1389to return the appropriate encoding for these types as part of a C++
1390mangled name. The @var{type} argument is the tree structure representing
1391the type to be mangled. The hook may be applied to trees which are
1392not target-specific fundamental types; it should return @code{NULL}
1393for all such types, as well as arguments it does not recognize. If the
1394return value is not @code{NULL}, it must point to a statically-allocated
1395string constant.
1396
1397Target-specific fundamental types might be new fundamental types or
1398qualified versions of ordinary fundamental types. Encode new
1399fundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name}
1400is the name used for the type in source code, and @var{n} is the
1401length of @var{name} in decimal. Encode qualified versions of
1402ordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where
1403@var{name} is the name used for the type qualifier in source code,
1404@var{n} is the length of @var{name} as above, and @var{code} is the
1405code used to represent the unqualified version of this type. (See
1406@code{write_builtin_type} in @file{cp/mangle.c} for the list of
1407codes.) In both cases the spaces are for clarity; do not include any
1408spaces in your string.
1409
1410This hook is applied to types prior to typedef resolution. If the mangled
1411name for a particular type depends only on that type's main variant, you
1412can perform typedef resolution yourself using @code{TYPE_MAIN_VARIANT}
1413before mangling.
1414
1415The default version of this hook always returns @code{NULL}, which is
1416appropriate for a target that does not define any new fundamental
1417types.
1418@end deftypefn
1419
1420@node Type Layout
1421@section Layout of Source Language Data Types
1422
1423These macros define the sizes and other characteristics of the standard
1424basic data types used in programs being compiled. Unlike the macros in
1425the previous section, these apply to specific features of C and related
1426languages, rather than to fundamental aspects of storage layout.
1427
1428@defmac INT_TYPE_SIZE
1429A C expression for the size in bits of the type @code{int} on the
1430target machine. If you don't define this, the default is one word.
1431@end defmac
1432
1433@defmac SHORT_TYPE_SIZE
1434A C expression for the size in bits of the type @code{short} on the
1435target machine. If you don't define this, the default is half a word.
1436(If this would be less than one storage unit, it is rounded up to one
1437unit.)
1438@end defmac
1439
1440@defmac LONG_TYPE_SIZE
1441A C expression for the size in bits of the type @code{long} on the
1442target machine. If you don't define this, the default is one word.
1443@end defmac
1444
1445@defmac ADA_LONG_TYPE_SIZE
1446On some machines, the size used for the Ada equivalent of the type
1447@code{long} by a native Ada compiler differs from that used by C@. In
1448that situation, define this macro to be a C expression to be used for
1449the size of that type. If you don't define this, the default is the
1450value of @code{LONG_TYPE_SIZE}.
1451@end defmac
1452
1453@defmac LONG_LONG_TYPE_SIZE
1454A C expression for the size in bits of the type @code{long long} on the
1455target machine. If you don't define this, the default is two
1456words. If you want to support GNU Ada on your machine, the value of this
1457macro must be at least 64.
1458@end defmac
1459
1460@defmac CHAR_TYPE_SIZE
1461A C expression for the size in bits of the type @code{char} on the
1462target machine. If you don't define this, the default is
1463@code{BITS_PER_UNIT}.
1464@end defmac
1465
1466@defmac BOOL_TYPE_SIZE
1467A C expression for the size in bits of the C++ type @code{bool} and
1468C99 type @code{_Bool} on the target machine. If you don't define
1469this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
1470@end defmac
1471
1472@defmac FLOAT_TYPE_SIZE
1473A C expression for the size in bits of the type @code{float} on the
1474target machine. If you don't define this, the default is one word.
1475@end defmac
1476
1477@defmac DOUBLE_TYPE_SIZE
1478A C expression for the size in bits of the type @code{double} on the
1479target machine. If you don't define this, the default is two
1480words.
1481@end defmac
1482
1483@defmac LONG_DOUBLE_TYPE_SIZE
1484A C expression for the size in bits of the type @code{long double} on
1485the target machine. If you don't define this, the default is two
1486words.
1487@end defmac
1488
1489@defmac SHORT_FRACT_TYPE_SIZE
1490A C expression for the size in bits of the type @code{short _Fract} on
1491the target machine. If you don't define this, the default is
1492@code{BITS_PER_UNIT}.
1493@end defmac
1494
1495@defmac FRACT_TYPE_SIZE
1496A C expression for the size in bits of the type @code{_Fract} on
1497the target machine. If you don't define this, the default is
1498@code{BITS_PER_UNIT * 2}.
1499@end defmac
1500
1501@defmac LONG_FRACT_TYPE_SIZE
1502A C expression for the size in bits of the type @code{long _Fract} on
1503the target machine. If you don't define this, the default is
1504@code{BITS_PER_UNIT * 4}.
1505@end defmac
1506
1507@defmac LONG_LONG_FRACT_TYPE_SIZE
1508A C expression for the size in bits of the type @code{long long _Fract} on
1509the target machine. If you don't define this, the default is
1510@code{BITS_PER_UNIT * 8}.
1511@end defmac
1512
1513@defmac SHORT_ACCUM_TYPE_SIZE
1514A C expression for the size in bits of the type @code{short _Accum} on
1515the target machine. If you don't define this, the default is
1516@code{BITS_PER_UNIT * 2}.
1517@end defmac
1518
1519@defmac ACCUM_TYPE_SIZE
1520A C expression for the size in bits of the type @code{_Accum} on
1521the target machine. If you don't define this, the default is
1522@code{BITS_PER_UNIT * 4}.
1523@end defmac
1524
1525@defmac LONG_ACCUM_TYPE_SIZE
1526A C expression for the size in bits of the type @code{long _Accum} on
1527the target machine. If you don't define this, the default is
1528@code{BITS_PER_UNIT * 8}.
1529@end defmac
1530
1531@defmac LONG_LONG_ACCUM_TYPE_SIZE
1532A C expression for the size in bits of the type @code{long long _Accum} on
1533the target machine. If you don't define this, the default is
1534@code{BITS_PER_UNIT * 16}.
1535@end defmac
1536
1537@defmac LIBGCC2_LONG_DOUBLE_TYPE_SIZE
1538Define this macro if @code{LONG_DOUBLE_TYPE_SIZE} is not constant or
1539if you want routines in @file{libgcc2.a} for a size other than
1540@code{LONG_DOUBLE_TYPE_SIZE}. If you don't define this, the
1541default is @code{LONG_DOUBLE_TYPE_SIZE}.
1542@end defmac
1543
1544@defmac LIBGCC2_HAS_DF_MODE
a18bdccd 1545Define this macro if neither @code{DOUBLE_TYPE_SIZE} nor
38f8b050
JR
1546@code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is
1547@code{DFmode} but you want @code{DFmode} routines in @file{libgcc2.a}
a18bdccd 1548anyway. If you don't define this and either @code{DOUBLE_TYPE_SIZE}
38f8b050
JR
1549or @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64 then the default is 1,
1550otherwise it is 0.
1551@end defmac
1552
1553@defmac LIBGCC2_HAS_XF_MODE
1554Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1555@code{XFmode} but you want @code{XFmode} routines in @file{libgcc2.a}
1556anyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1557is 80 then the default is 1, otherwise it is 0.
1558@end defmac
1559
1560@defmac LIBGCC2_HAS_TF_MODE
1561Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1562@code{TFmode} but you want @code{TFmode} routines in @file{libgcc2.a}
1563anyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1564is 128 then the default is 1, otherwise it is 0.
1565@end defmac
1566
cdbf4541
BS
1567@defmac LIBGCC2_GNU_PREFIX
1568This macro corresponds to the @code{TARGET_LIBFUNC_GNU_PREFIX} target
1569hook and should be defined if that hook is overriden to be true. It
1570causes function names in libgcc to be changed to use a @code{__gnu_}
1571prefix for their name rather than the default @code{__}. A port which
1572uses this macro should also arrange to use @file{t-gnu-prefix} in
1573the libgcc @file{config.host}.
1574@end defmac
1575
38f8b050
JR
1576@defmac SF_SIZE
1577@defmacx DF_SIZE
1578@defmacx XF_SIZE
1579@defmacx TF_SIZE
1580Define these macros to be the size in bits of the mantissa of
1581@code{SFmode}, @code{DFmode}, @code{XFmode} and @code{TFmode} values,
1582if the defaults in @file{libgcc2.h} are inappropriate. By default,
1583@code{FLT_MANT_DIG} is used for @code{SF_SIZE}, @code{LDBL_MANT_DIG}
1584for @code{XF_SIZE} and @code{TF_SIZE}, and @code{DBL_MANT_DIG} or
1585@code{LDBL_MANT_DIG} for @code{DF_SIZE} according to whether
a18bdccd 1586@code{DOUBLE_TYPE_SIZE} or
38f8b050
JR
1587@code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64.
1588@end defmac
1589
1590@defmac TARGET_FLT_EVAL_METHOD
1591A C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h},
1592assuming, if applicable, that the floating-point control word is in its
1593default state. If you do not define this macro the value of
1594@code{FLT_EVAL_METHOD} will be zero.
1595@end defmac
1596
1597@defmac WIDEST_HARDWARE_FP_SIZE
1598A C expression for the size in bits of the widest floating-point format
1599supported by the hardware. If you define this macro, you must specify a
1600value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
1601If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
1602is the default.
1603@end defmac
1604
1605@defmac DEFAULT_SIGNED_CHAR
1606An expression whose value is 1 or 0, according to whether the type
1607@code{char} should be signed or unsigned by default. The user can
1608always override this default with the options @option{-fsigned-char}
1609and @option{-funsigned-char}.
1610@end defmac
1611
1612@hook TARGET_DEFAULT_SHORT_ENUMS
1613This target hook should return true if the compiler should give an
1614@code{enum} type only as many bytes as it takes to represent the range
1615of possible values of that type. It should return false if all
1616@code{enum} types should be allocated like @code{int}.
1617
1618The default is to return false.
1619@end deftypefn
1620
1621@defmac SIZE_TYPE
1622A C expression for a string describing the name of the data type to use
1623for size values. The typedef name @code{size_t} is defined using the
1624contents of the string.
1625
1626The string can contain more than one keyword. If so, separate them with
1627spaces, and write first any length keyword, then @code{unsigned} if
1628appropriate, and finally @code{int}. The string must exactly match one
1629of the data type names defined in the function
176a96de
HPN
1630@code{c_common_nodes_and_builtins} in the file @file{c-family/c-common.c}.
1631You may not omit @code{int} or change the order---that would cause the
1632compiler to crash on startup.
38f8b050
JR
1633
1634If you don't define this macro, the default is @code{"long unsigned
1635int"}.
1636@end defmac
1637
18dae016
TG
1638@defmac SIZETYPE
1639GCC defines internal types (@code{sizetype}, @code{ssizetype},
1640@code{bitsizetype} and @code{sbitsizetype}) for expressions
1641dealing with size. This macro is a C expression for a string describing
1642the name of the data type from which the precision of @code{sizetype}
1643is extracted.
1644
1645The string has the same restrictions as @code{SIZE_TYPE} string.
1646
1647If you don't define this macro, the default is @code{SIZE_TYPE}.
1648@end defmac
1649
38f8b050
JR
1650@defmac PTRDIFF_TYPE
1651A C expression for a string describing the name of the data type to use
1652for the result of subtracting two pointers. The typedef name
1653@code{ptrdiff_t} is defined using the contents of the string. See
1654@code{SIZE_TYPE} above for more information.
1655
1656If you don't define this macro, the default is @code{"long int"}.
1657@end defmac
1658
1659@defmac WCHAR_TYPE
1660A C expression for a string describing the name of the data type to use
1661for wide characters. The typedef name @code{wchar_t} is defined using
1662the contents of the string. See @code{SIZE_TYPE} above for more
1663information.
1664
1665If you don't define this macro, the default is @code{"int"}.
1666@end defmac
1667
1668@defmac WCHAR_TYPE_SIZE
1669A C expression for the size in bits of the data type for wide
1670characters. This is used in @code{cpp}, which cannot make use of
1671@code{WCHAR_TYPE}.
1672@end defmac
1673
1674@defmac WINT_TYPE
1675A C expression for a string describing the name of the data type to
1676use for wide characters passed to @code{printf} and returned from
1677@code{getwc}. The typedef name @code{wint_t} is defined using the
1678contents of the string. See @code{SIZE_TYPE} above for more
1679information.
1680
1681If you don't define this macro, the default is @code{"unsigned int"}.
1682@end defmac
1683
1684@defmac INTMAX_TYPE
1685A C expression for a string describing the name of the data type that
1686can represent any value of any standard or extended signed integer type.
1687The typedef name @code{intmax_t} is defined using the contents of the
1688string. See @code{SIZE_TYPE} above for more information.
1689
1690If you don't define this macro, the default is the first of
1691@code{"int"}, @code{"long int"}, or @code{"long long int"} that has as
1692much precision as @code{long long int}.
1693@end defmac
1694
1695@defmac UINTMAX_TYPE
1696A C expression for a string describing the name of the data type that
1697can represent any value of any standard or extended unsigned integer
1698type. The typedef name @code{uintmax_t} is defined using the contents
1699of the string. See @code{SIZE_TYPE} above for more information.
1700
1701If you don't define this macro, the default is the first of
1702@code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long
1703unsigned int"} that has as much precision as @code{long long unsigned
1704int}.
1705@end defmac
1706
1707@defmac SIG_ATOMIC_TYPE
1708@defmacx INT8_TYPE
1709@defmacx INT16_TYPE
1710@defmacx INT32_TYPE
1711@defmacx INT64_TYPE
1712@defmacx UINT8_TYPE
1713@defmacx UINT16_TYPE
1714@defmacx UINT32_TYPE
1715@defmacx UINT64_TYPE
1716@defmacx INT_LEAST8_TYPE
1717@defmacx INT_LEAST16_TYPE
1718@defmacx INT_LEAST32_TYPE
1719@defmacx INT_LEAST64_TYPE
1720@defmacx UINT_LEAST8_TYPE
1721@defmacx UINT_LEAST16_TYPE
1722@defmacx UINT_LEAST32_TYPE
1723@defmacx UINT_LEAST64_TYPE
1724@defmacx INT_FAST8_TYPE
1725@defmacx INT_FAST16_TYPE
1726@defmacx INT_FAST32_TYPE
1727@defmacx INT_FAST64_TYPE
1728@defmacx UINT_FAST8_TYPE
1729@defmacx UINT_FAST16_TYPE
1730@defmacx UINT_FAST32_TYPE
1731@defmacx UINT_FAST64_TYPE
1732@defmacx INTPTR_TYPE
1733@defmacx UINTPTR_TYPE
1734C expressions for the standard types @code{sig_atomic_t},
1735@code{int8_t}, @code{int16_t}, @code{int32_t}, @code{int64_t},
1736@code{uint8_t}, @code{uint16_t}, @code{uint32_t}, @code{uint64_t},
1737@code{int_least8_t}, @code{int_least16_t}, @code{int_least32_t},
1738@code{int_least64_t}, @code{uint_least8_t}, @code{uint_least16_t},
1739@code{uint_least32_t}, @code{uint_least64_t}, @code{int_fast8_t},
1740@code{int_fast16_t}, @code{int_fast32_t}, @code{int_fast64_t},
1741@code{uint_fast8_t}, @code{uint_fast16_t}, @code{uint_fast32_t},
1742@code{uint_fast64_t}, @code{intptr_t}, and @code{uintptr_t}. See
1743@code{SIZE_TYPE} above for more information.
1744
1745If any of these macros evaluates to a null pointer, the corresponding
1746type is not supported; if GCC is configured to provide
1747@code{<stdint.h>} in such a case, the header provided may not conform
1748to C99, depending on the type in question. The defaults for all of
1749these macros are null pointers.
1750@end defmac
1751
1752@defmac TARGET_PTRMEMFUNC_VBIT_LOCATION
1753The C++ compiler represents a pointer-to-member-function with a struct
1754that looks like:
1755
1756@smallexample
1757 struct @{
1758 union @{
1759 void (*fn)();
1760 ptrdiff_t vtable_index;
1761 @};
1762 ptrdiff_t delta;
1763 @};
1764@end smallexample
1765
1766@noindent
1767The C++ compiler must use one bit to indicate whether the function that
1768will be called through a pointer-to-member-function is virtual.
1769Normally, we assume that the low-order bit of a function pointer must
1770always be zero. Then, by ensuring that the vtable_index is odd, we can
1771distinguish which variant of the union is in use. But, on some
1772platforms function pointers can be odd, and so this doesn't work. In
1773that case, we use the low-order bit of the @code{delta} field, and shift
1774the remainder of the @code{delta} field to the left.
1775
1776GCC will automatically make the right selection about where to store
1777this bit using the @code{FUNCTION_BOUNDARY} setting for your platform.
1778However, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY}
1779set such that functions always start at even addresses, but the lowest
1780bit of pointers to functions indicate whether the function at that
1781address is in ARM or Thumb mode. If this is the case of your
1782architecture, you should define this macro to
1783@code{ptrmemfunc_vbit_in_delta}.
1784
1785In general, you should not have to define this macro. On architectures
1786in which function addresses are always even, according to
1787@code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to
1788@code{ptrmemfunc_vbit_in_pfn}.
1789@end defmac
1790
1791@defmac TARGET_VTABLE_USES_DESCRIPTORS
1792Normally, the C++ compiler uses function pointers in vtables. This
1793macro allows the target to change to use ``function descriptors''
1794instead. Function descriptors are found on targets for whom a
1795function pointer is actually a small data structure. Normally the
1796data structure consists of the actual code address plus a data
1797pointer to which the function's data is relative.
1798
1799If vtables are used, the value of this macro should be the number
1800of words that the function descriptor occupies.
1801@end defmac
1802
1803@defmac TARGET_VTABLE_ENTRY_ALIGN
1804By default, the vtable entries are void pointers, the so the alignment
1805is the same as pointer alignment. The value of this macro specifies
1806the alignment of the vtable entry in bits. It should be defined only
1807when special alignment is necessary. */
1808@end defmac
1809
1810@defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE
1811There are a few non-descriptor entries in the vtable at offsets below
1812zero. If these entries must be padded (say, to preserve the alignment
1813specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
1814of words in each data entry.
1815@end defmac
1816
1817@node Registers
1818@section Register Usage
1819@cindex register usage
1820
1821This section explains how to describe what registers the target machine
1822has, and how (in general) they can be used.
1823
1824The description of which registers a specific instruction can use is
1825done with register classes; see @ref{Register Classes}. For information
1826on using registers to access a stack frame, see @ref{Frame Registers}.
1827For passing values in registers, see @ref{Register Arguments}.
1828For returning values in registers, see @ref{Scalar Return}.
1829
1830@menu
1831* Register Basics:: Number and kinds of registers.
1832* Allocation Order:: Order in which registers are allocated.
1833* Values in Registers:: What kinds of values each reg can hold.
1834* Leaf Functions:: Renumbering registers for leaf functions.
1835* Stack Registers:: Handling a register stack such as 80387.
1836@end menu
1837
1838@node Register Basics
1839@subsection Basic Characteristics of Registers
1840
1841@c prevent bad page break with this line
1842Registers have various characteristics.
1843
1844@defmac FIRST_PSEUDO_REGISTER
1845Number of hardware registers known to the compiler. They receive
1846numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
1847pseudo register's number really is assigned the number
1848@code{FIRST_PSEUDO_REGISTER}.
1849@end defmac
1850
1851@defmac FIXED_REGISTERS
1852@cindex fixed register
1853An initializer that says which registers are used for fixed purposes
1854all throughout the compiled code and are therefore not available for
1855general allocation. These would include the stack pointer, the frame
1856pointer (except on machines where that can be used as a general
1857register when no frame pointer is needed), the program counter on
1858machines where that is considered one of the addressable registers,
1859and any other numbered register with a standard use.
1860
1861This information is expressed as a sequence of numbers, separated by
1862commas and surrounded by braces. The @var{n}th number is 1 if
1863register @var{n} is fixed, 0 otherwise.
1864
1865The table initialized from this macro, and the table initialized by
1866the following one, may be overridden at run time either automatically,
1867by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
1868the user with the command options @option{-ffixed-@var{reg}},
1869@option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}.
1870@end defmac
1871
1872@defmac CALL_USED_REGISTERS
1873@cindex call-used register
1874@cindex call-clobbered register
1875@cindex call-saved register
1876Like @code{FIXED_REGISTERS} but has 1 for each register that is
1877clobbered (in general) by function calls as well as for fixed
1878registers. This macro therefore identifies the registers that are not
1879available for general allocation of values that must live across
1880function calls.
1881
1882If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
1883automatically saves it on function entry and restores it on function
1884exit, if the register is used within the function.
1885@end defmac
1886
1887@defmac CALL_REALLY_USED_REGISTERS
1888@cindex call-used register
1889@cindex call-clobbered register
1890@cindex call-saved register
1891Like @code{CALL_USED_REGISTERS} except this macro doesn't require
1892that the entire set of @code{FIXED_REGISTERS} be included.
1893(@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}).
1894This macro is optional. If not specified, it defaults to the value
1895of @code{CALL_USED_REGISTERS}.
1896@end defmac
1897
1898@defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
1899@cindex call-used register
1900@cindex call-clobbered register
1901@cindex call-saved register
1902A C expression that is nonzero if it is not permissible to store a
1903value of mode @var{mode} in hard register number @var{regno} across a
1904call without some part of it being clobbered. For most machines this
1905macro need not be defined. It is only required for machines that do not
1906preserve the entire contents of a register across a call.
1907@end defmac
1908
1909@findex fixed_regs
1910@findex call_used_regs
1911@findex global_regs
1912@findex reg_names
1913@findex reg_class_contents
5efd84c5
NF
1914@hook TARGET_CONDITIONAL_REGISTER_USAGE
1915This hook may conditionally modify five variables
38f8b050
JR
1916@code{fixed_regs}, @code{call_used_regs}, @code{global_regs},
1917@code{reg_names}, and @code{reg_class_contents}, to take into account
1918any dependence of these register sets on target flags. The first three
1919of these are of type @code{char []} (interpreted as Boolean vectors).
1920@code{global_regs} is a @code{const char *[]}, and
1921@code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is
1922called, @code{fixed_regs}, @code{call_used_regs},
1923@code{reg_class_contents}, and @code{reg_names} have been initialized
1924from @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS},
1925@code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively.
1926@code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}},
1927@option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}
1928command options have been applied.
1929
38f8b050
JR
1930@cindex disabling certain registers
1931@cindex controlling register usage
1932If the usage of an entire class of registers depends on the target
1933flags, you may indicate this to GCC by using this macro to modify
1934@code{fixed_regs} and @code{call_used_regs} to 1 for each of the
1935registers in the classes which should not be used by GCC@. Also define
1936the macro @code{REG_CLASS_FROM_LETTER} / @code{REG_CLASS_FROM_CONSTRAINT}
1937to return @code{NO_REGS} if it
1938is called with a letter for a class that shouldn't be used.
1939
1940(However, if this class is not included in @code{GENERAL_REGS} and all
1941of the insn patterns whose constraints permit this class are
1942controlled by target switches, then GCC will automatically avoid using
1943these registers when the target switches are opposed to them.)
5efd84c5 1944@end deftypefn
38f8b050
JR
1945
1946@defmac INCOMING_REGNO (@var{out})
1947Define this macro if the target machine has register windows. This C
1948expression returns the register number as seen by the called function
1949corresponding to the register number @var{out} as seen by the calling
1950function. Return @var{out} if register number @var{out} is not an
1951outbound register.
1952@end defmac
1953
1954@defmac OUTGOING_REGNO (@var{in})
1955Define this macro if the target machine has register windows. This C
1956expression returns the register number as seen by the calling function
1957corresponding to the register number @var{in} as seen by the called
1958function. Return @var{in} if register number @var{in} is not an inbound
1959register.
1960@end defmac
1961
1962@defmac LOCAL_REGNO (@var{regno})
1963Define this macro if the target machine has register windows. This C
1964expression returns true if the register is call-saved but is in the
1965register window. Unlike most call-saved registers, such registers
1966need not be explicitly restored on function exit or during non-local
1967gotos.
1968@end defmac
1969
1970@defmac PC_REGNUM
1971If the program counter has a register number, define this as that
1972register number. Otherwise, do not define it.
1973@end defmac
1974
1975@node Allocation Order
1976@subsection Order of Allocation of Registers
1977@cindex order of register allocation
1978@cindex register allocation order
1979
1980@c prevent bad page break with this line
1981Registers are allocated in order.
1982
1983@defmac REG_ALLOC_ORDER
1984If defined, an initializer for a vector of integers, containing the
1985numbers of hard registers in the order in which GCC should prefer
1986to use them (from most preferred to least).
1987
1988If this macro is not defined, registers are used lowest numbered first
1989(all else being equal).
1990
1991One use of this macro is on machines where the highest numbered
1992registers must always be saved and the save-multiple-registers
1993instruction supports only sequences of consecutive registers. On such
1994machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists
1995the highest numbered allocable register first.
1996@end defmac
1997
1998@defmac ADJUST_REG_ALLOC_ORDER
1999A C statement (sans semicolon) to choose the order in which to allocate
2000hard registers for pseudo-registers local to a basic block.
2001
2002Store the desired register order in the array @code{reg_alloc_order}.
2003Element 0 should be the register to allocate first; element 1, the next
2004register; and so on.
2005
2006The macro body should not assume anything about the contents of
2007@code{reg_alloc_order} before execution of the macro.
2008
2009On most machines, it is not necessary to define this macro.
2010@end defmac
2011
2012@defmac HONOR_REG_ALLOC_ORDER
2013Normally, IRA tries to estimate the costs for saving a register in the
2014prologue and restoring it in the epilogue. This discourages it from
2015using call-saved registers. If a machine wants to ensure that IRA
2016allocates registers in the order given by REG_ALLOC_ORDER even if some
2017call-saved registers appear earlier than call-used ones, this macro
2018should be defined.
2019@end defmac
2020
2021@defmac IRA_HARD_REGNO_ADD_COST_MULTIPLIER (@var{regno})
2022In some case register allocation order is not enough for the
2023Integrated Register Allocator (@acronym{IRA}) to generate a good code.
2024If this macro is defined, it should return a floating point value
2025based on @var{regno}. The cost of using @var{regno} for a pseudo will
2026be increased by approximately the pseudo's usage frequency times the
2027value returned by this macro. Not defining this macro is equivalent
2028to having it always return @code{0.0}.
2029
2030On most machines, it is not necessary to define this macro.
2031@end defmac
2032
2033@node Values in Registers
2034@subsection How Values Fit in Registers
2035
2036This section discusses the macros that describe which kinds of values
2037(specifically, which machine modes) each register can hold, and how many
2038consecutive registers are needed for a given mode.
2039
2040@defmac HARD_REGNO_NREGS (@var{regno}, @var{mode})
2041A C expression for the number of consecutive hard registers, starting
2042at register number @var{regno}, required to hold a value of mode
2043@var{mode}. This macro must never return zero, even if a register
2044cannot hold the requested mode - indicate that with HARD_REGNO_MODE_OK
2045and/or CANNOT_CHANGE_MODE_CLASS instead.
2046
2047On a machine where all registers are exactly one word, a suitable
2048definition of this macro is
2049
2050@smallexample
2051#define HARD_REGNO_NREGS(REGNO, MODE) \
2052 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
2053 / UNITS_PER_WORD)
2054@end smallexample
2055@end defmac
2056
2057@defmac HARD_REGNO_NREGS_HAS_PADDING (@var{regno}, @var{mode})
2058A C expression that is nonzero if a value of mode @var{mode}, stored
2059in memory, ends with padding that causes it to take up more space than
2060in registers starting at register number @var{regno} (as determined by
2061multiplying GCC's notion of the size of the register when containing
2062this mode by the number of registers returned by
2063@code{HARD_REGNO_NREGS}). By default this is zero.
2064
2065For example, if a floating-point value is stored in three 32-bit
2066registers but takes up 128 bits in memory, then this would be
2067nonzero.
2068
2069This macros only needs to be defined if there are cases where
2070@code{subreg_get_info}
2071would otherwise wrongly determine that a @code{subreg} can be
2072represented by an offset to the register number, when in fact such a
2073@code{subreg} would contain some of the padding not stored in
2074registers and so not be representable.
2075@end defmac
2076
2077@defmac HARD_REGNO_NREGS_WITH_PADDING (@var{regno}, @var{mode})
2078For values of @var{regno} and @var{mode} for which
2079@code{HARD_REGNO_NREGS_HAS_PADDING} returns nonzero, a C expression
2080returning the greater number of registers required to hold the value
2081including any padding. In the example above, the value would be four.
2082@end defmac
2083
2084@defmac REGMODE_NATURAL_SIZE (@var{mode})
2085Define this macro if the natural size of registers that hold values
2086of mode @var{mode} is not the word size. It is a C expression that
2087should give the natural size in bytes for the specified mode. It is
2088used by the register allocator to try to optimize its results. This
2089happens for example on SPARC 64-bit where the natural size of
2090floating-point registers is still 32-bit.
2091@end defmac
2092
2093@defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
2094A C expression that is nonzero if it is permissible to store a value
2095of mode @var{mode} in hard register number @var{regno} (or in several
2096registers starting with that one). For a machine where all registers
2097are equivalent, a suitable definition is
2098
2099@smallexample
2100#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
2101@end smallexample
2102
2103You need not include code to check for the numbers of fixed registers,
2104because the allocation mechanism considers them to be always occupied.
2105
2106@cindex register pairs
2107On some machines, double-precision values must be kept in even/odd
2108register pairs. You can implement that by defining this macro to reject
2109odd register numbers for such modes.
2110
2111The minimum requirement for a mode to be OK in a register is that the
2112@samp{mov@var{mode}} instruction pattern support moves between the
2113register and other hard register in the same class and that moving a
2114value into the register and back out not alter it.
2115
2116Since the same instruction used to move @code{word_mode} will work for
2117all narrower integer modes, it is not necessary on any machine for
2118@code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided
2119you define patterns @samp{movhi}, etc., to take advantage of this. This
2120is useful because of the interaction between @code{HARD_REGNO_MODE_OK}
2121and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes
2122to be tieable.
2123
2124Many machines have special registers for floating point arithmetic.
2125Often people assume that floating point machine modes are allowed only
2126in floating point registers. This is not true. Any registers that
2127can hold integers can safely @emph{hold} a floating point machine
2128mode, whether or not floating arithmetic can be done on it in those
2129registers. Integer move instructions can be used to move the values.
2130
2131On some machines, though, the converse is true: fixed-point machine
2132modes may not go in floating registers. This is true if the floating
2133registers normalize any value stored in them, because storing a
2134non-floating value there would garble it. In this case,
2135@code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in
2136floating registers. But if the floating registers do not automatically
2137normalize, if you can store any bit pattern in one and retrieve it
2138unchanged without a trap, then any machine mode may go in a floating
2139register, so you can define this macro to say so.
2140
2141The primary significance of special floating registers is rather that
2142they are the registers acceptable in floating point arithmetic
2143instructions. However, this is of no concern to
2144@code{HARD_REGNO_MODE_OK}. You handle it by writing the proper
2145constraints for those instructions.
2146
2147On some machines, the floating registers are especially slow to access,
2148so that it is better to store a value in a stack frame than in such a
2149register if floating point arithmetic is not being done. As long as the
2150floating registers are not in class @code{GENERAL_REGS}, they will not
2151be used unless some pattern's constraint asks for one.
2152@end defmac
2153
2154@defmac HARD_REGNO_RENAME_OK (@var{from}, @var{to})
2155A C expression that is nonzero if it is OK to rename a hard register
2156@var{from} to another hard register @var{to}.
2157
2158One common use of this macro is to prevent renaming of a register to
2159another register that is not saved by a prologue in an interrupt
2160handler.
2161
2162The default is always nonzero.
2163@end defmac
2164
2165@defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2})
2166A C expression that is nonzero if a value of mode
2167@var{mode1} is accessible in mode @var{mode2} without copying.
2168
2169If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
2170@code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for
2171any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})}
2172should be nonzero. If they differ for any @var{r}, you should define
2173this macro to return zero unless some other mechanism ensures the
2174accessibility of the value in a narrower mode.
2175
2176You should define this macro to return nonzero in as many cases as
2177possible since doing so will allow GCC to perform better register
2178allocation.
2179@end defmac
2180
2181@hook TARGET_HARD_REGNO_SCRATCH_OK
2182This target hook should return @code{true} if it is OK to use a hard register
2183@var{regno} as scratch reg in peephole2.
2184
2185One common use of this macro is to prevent using of a register that
2186is not saved by a prologue in an interrupt handler.
2187
2188The default version of this hook always returns @code{true}.
2189@end deftypefn
2190
2191@defmac AVOID_CCMODE_COPIES
2192Define this macro if the compiler should avoid copies to/from @code{CCmode}
2193registers. You should only define this macro if support for copying to/from
2194@code{CCmode} is incomplete.
2195@end defmac
2196
2197@node Leaf Functions
2198@subsection Handling Leaf Functions
2199
2200@cindex leaf functions
2201@cindex functions, leaf
2202On some machines, a leaf function (i.e., one which makes no calls) can run
2203more efficiently if it does not make its own register window. Often this
2204means it is required to receive its arguments in the registers where they
2205are passed by the caller, instead of the registers where they would
2206normally arrive.
2207
2208The special treatment for leaf functions generally applies only when
2209other conditions are met; for example, often they may use only those
2210registers for its own variables and temporaries. We use the term ``leaf
2211function'' to mean a function that is suitable for this special
2212handling, so that functions with no calls are not necessarily ``leaf
2213functions''.
2214
2215GCC assigns register numbers before it knows whether the function is
2216suitable for leaf function treatment. So it needs to renumber the
2217registers in order to output a leaf function. The following macros
2218accomplish this.
2219
2220@defmac LEAF_REGISTERS
2221Name of a char vector, indexed by hard register number, which
2222contains 1 for a register that is allowable in a candidate for leaf
2223function treatment.
2224
2225If leaf function treatment involves renumbering the registers, then the
2226registers marked here should be the ones before renumbering---those that
2227GCC would ordinarily allocate. The registers which will actually be
2228used in the assembler code, after renumbering, should not be marked with 1
2229in this vector.
2230
2231Define this macro only if the target machine offers a way to optimize
2232the treatment of leaf functions.
2233@end defmac
2234
2235@defmac LEAF_REG_REMAP (@var{regno})
2236A C expression whose value is the register number to which @var{regno}
2237should be renumbered, when a function is treated as a leaf function.
2238
2239If @var{regno} is a register number which should not appear in a leaf
2240function before renumbering, then the expression should yield @minus{}1, which
2241will cause the compiler to abort.
2242
2243Define this macro only if the target machine offers a way to optimize the
2244treatment of leaf functions, and registers need to be renumbered to do
2245this.
2246@end defmac
2247
2248@findex current_function_is_leaf
2249@findex current_function_uses_only_leaf_regs
2250@code{TARGET_ASM_FUNCTION_PROLOGUE} and
2251@code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions
2252specially. They can test the C variable @code{current_function_is_leaf}
2253which is nonzero for leaf functions. @code{current_function_is_leaf} is
2254set prior to local register allocation and is valid for the remaining
2255compiler passes. They can also test the C variable
2256@code{current_function_uses_only_leaf_regs} which is nonzero for leaf
2257functions which only use leaf registers.
2258@code{current_function_uses_only_leaf_regs} is valid after all passes
2259that modify the instructions have been run and is only useful if
2260@code{LEAF_REGISTERS} is defined.
2261@c changed this to fix overfull. ALSO: why the "it" at the beginning
2262@c of the next paragraph?! --mew 2feb93
2263
2264@node Stack Registers
2265@subsection Registers That Form a Stack
2266
2267There are special features to handle computers where some of the
2268``registers'' form a stack. Stack registers are normally written by
2269pushing onto the stack, and are numbered relative to the top of the
2270stack.
2271
2272Currently, GCC can only handle one group of stack-like registers, and
2273they must be consecutively numbered. Furthermore, the existing
2274support for stack-like registers is specific to the 80387 floating
2275point coprocessor. If you have a new architecture that uses
2276stack-like registers, you will need to do substantial work on
2277@file{reg-stack.c} and write your machine description to cooperate
2278with it, as well as defining these macros.
2279
2280@defmac STACK_REGS
2281Define this if the machine has any stack-like registers.
2282@end defmac
2283
2284@defmac STACK_REG_COVER_CLASS
2285This is a cover class containing the stack registers. Define this if
2286the machine has any stack-like registers.
2287@end defmac
2288
2289@defmac FIRST_STACK_REG
2290The number of the first stack-like register. This one is the top
2291of the stack.
2292@end defmac
2293
2294@defmac LAST_STACK_REG
2295The number of the last stack-like register. This one is the bottom of
2296the stack.
2297@end defmac
2298
2299@node Register Classes
2300@section Register Classes
2301@cindex register class definitions
2302@cindex class definitions, register
2303
2304On many machines, the numbered registers are not all equivalent.
2305For example, certain registers may not be allowed for indexed addressing;
2306certain registers may not be allowed in some instructions. These machine
2307restrictions are described to the compiler using @dfn{register classes}.
2308
2309You define a number of register classes, giving each one a name and saying
2310which of the registers belong to it. Then you can specify register classes
2311that are allowed as operands to particular instruction patterns.
2312
2313@findex ALL_REGS
2314@findex NO_REGS
2315In general, each register will belong to several classes. In fact, one
2316class must be named @code{ALL_REGS} and contain all the registers. Another
2317class must be named @code{NO_REGS} and contain no registers. Often the
2318union of two classes will be another class; however, this is not required.
2319
2320@findex GENERAL_REGS
2321One of the classes must be named @code{GENERAL_REGS}. There is nothing
2322terribly special about the name, but the operand constraint letters
2323@samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is
2324the same as @code{ALL_REGS}, just define it as a macro which expands
2325to @code{ALL_REGS}.
2326
2327Order the classes so that if class @var{x} is contained in class @var{y}
2328then @var{x} has a lower class number than @var{y}.
2329
2330The way classes other than @code{GENERAL_REGS} are specified in operand
2331constraints is through machine-dependent operand constraint letters.
2332You can define such letters to correspond to various classes, then use
2333them in operand constraints.
2334
6049a4c8
HPN
2335You must define the narrowest register classes for allocatable
2336registers, so that each class either has no subclasses, or that for
2337some mode, the move cost between registers within the class is
2338cheaper than moving a register in the class to or from memory
2339(@pxref{Costs}).
2340
38f8b050
JR
2341You should define a class for the union of two classes whenever some
2342instruction allows both classes. For example, if an instruction allows
2343either a floating point (coprocessor) register or a general register for a
2344certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
b899fd78
JR
2345which includes both of them. Otherwise you will get suboptimal code,
2346or even internal compiler errors when reload cannot find a register in the
dd5a833e 2347class computed via @code{reg_class_subunion}.
38f8b050
JR
2348
2349You must also specify certain redundant information about the register
2350classes: for each class, which classes contain it and which ones are
2351contained in it; for each pair of classes, the largest class contained
2352in their union.
2353
2354When a value occupying several consecutive registers is expected in a
2355certain class, all the registers used must belong to that class.
2356Therefore, register classes cannot be used to enforce a requirement for
2357a register pair to start with an even-numbered register. The way to
2358specify this requirement is with @code{HARD_REGNO_MODE_OK}.
2359
2360Register classes used for input-operands of bitwise-and or shift
2361instructions have a special requirement: each such class must have, for
2362each fixed-point machine mode, a subclass whose registers can transfer that
2363mode to or from memory. For example, on some machines, the operations for
2364single-byte values (@code{QImode}) are limited to certain registers. When
2365this is so, each register class that is used in a bitwise-and or shift
2366instruction must have a subclass consisting of registers from which
2367single-byte values can be loaded or stored. This is so that
2368@code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
2369
2370@deftp {Data type} {enum reg_class}
2371An enumerated type that must be defined with all the register class names
2372as enumerated values. @code{NO_REGS} must be first. @code{ALL_REGS}
2373must be the last register class, followed by one more enumerated value,
2374@code{LIM_REG_CLASSES}, which is not a register class but rather
2375tells how many classes there are.
2376
2377Each register class has a number, which is the value of casting
2378the class name to type @code{int}. The number serves as an index
2379in many of the tables described below.
2380@end deftp
2381
2382@defmac N_REG_CLASSES
2383The number of distinct register classes, defined as follows:
2384
2385@smallexample
2386#define N_REG_CLASSES (int) LIM_REG_CLASSES
2387@end smallexample
2388@end defmac
2389
2390@defmac REG_CLASS_NAMES
2391An initializer containing the names of the register classes as C string
2392constants. These names are used in writing some of the debugging dumps.
2393@end defmac
2394
2395@defmac REG_CLASS_CONTENTS
2396An initializer containing the contents of the register classes, as integers
2397which are bit masks. The @var{n}th integer specifies the contents of class
2398@var{n}. The way the integer @var{mask} is interpreted is that
2399register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
2400
2401When the machine has more than 32 registers, an integer does not suffice.
2402Then the integers are replaced by sub-initializers, braced groupings containing
2403several integers. Each sub-initializer must be suitable as an initializer
2404for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
2405In this situation, the first integer in each sub-initializer corresponds to
2406registers 0 through 31, the second integer to registers 32 through 63, and
2407so on.
2408@end defmac
2409
2410@defmac REGNO_REG_CLASS (@var{regno})
2411A C expression whose value is a register class containing hard register
2412@var{regno}. In general there is more than one such class; choose a class
2413which is @dfn{minimal}, meaning that no smaller class also contains the
2414register.
2415@end defmac
2416
2417@defmac BASE_REG_CLASS
2418A macro whose definition is the name of the class to which a valid
2419base register must belong. A base register is one used in an address
2420which is the register value plus a displacement.
2421@end defmac
2422
2423@defmac MODE_BASE_REG_CLASS (@var{mode})
2424This is a variation of the @code{BASE_REG_CLASS} macro which allows
2425the selection of a base register in a mode dependent manner. If
2426@var{mode} is VOIDmode then it should return the same value as
2427@code{BASE_REG_CLASS}.
2428@end defmac
2429
2430@defmac MODE_BASE_REG_REG_CLASS (@var{mode})
2431A C expression whose value is the register class to which a valid
2432base register must belong in order to be used in a base plus index
2433register address. You should define this macro if base plus index
2434addresses have different requirements than other base register uses.
2435@end defmac
2436
86fc3d06 2437@defmac MODE_CODE_BASE_REG_CLASS (@var{mode}, @var{address_space}, @var{outer_code}, @var{index_code})
38f8b050 2438A C expression whose value is the register class to which a valid
86fc3d06
UW
2439base register for a memory reference in mode @var{mode} to address
2440space @var{address_space} must belong. @var{outer_code} and @var{index_code}
2441define the context in which the base register occurs. @var{outer_code} is
2442the code of the immediately enclosing expression (@code{MEM} for the top level
2443of an address, @code{ADDRESS} for something that occurs in an
38f8b050
JR
2444@code{address_operand}). @var{index_code} is the code of the corresponding
2445index expression if @var{outer_code} is @code{PLUS}; @code{SCRATCH} otherwise.
2446@end defmac
2447
2448@defmac INDEX_REG_CLASS
2449A macro whose definition is the name of the class to which a valid
2450index register must belong. An index register is one used in an
2451address where its value is either multiplied by a scale factor or
2452added to another register (as well as added to a displacement).
2453@end defmac
2454
2455@defmac REGNO_OK_FOR_BASE_P (@var{num})
2456A C expression which is nonzero if register number @var{num} is
2457suitable for use as a base register in operand addresses.
38f8b050
JR
2458@end defmac
2459
2460@defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode})
2461A C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that
2462that expression may examine the mode of the memory reference in
2463@var{mode}. You should define this macro if the mode of the memory
2464reference affects whether a register may be used as a base register. If
2465you define this macro, the compiler will use it instead of
2466@code{REGNO_OK_FOR_BASE_P}. The mode may be @code{VOIDmode} for
2467addresses that appear outside a @code{MEM}, i.e., as an
2468@code{address_operand}.
38f8b050
JR
2469@end defmac
2470
2471@defmac REGNO_MODE_OK_FOR_REG_BASE_P (@var{num}, @var{mode})
2472A C expression which is nonzero if register number @var{num} is suitable for
2473use as a base register in base plus index operand addresses, accessing
2474memory in mode @var{mode}. It may be either a suitable hard register or a
2475pseudo register that has been allocated such a hard register. You should
2476define this macro if base plus index addresses have different requirements
2477than other base register uses.
2478
2479Use of this macro is deprecated; please use the more general
2480@code{REGNO_MODE_CODE_OK_FOR_BASE_P}.
38f8b050
JR
2481@end defmac
2482
86fc3d06
UW
2483@defmac REGNO_MODE_CODE_OK_FOR_BASE_P (@var{num}, @var{mode}, @var{address_space}, @var{outer_code}, @var{index_code})
2484A C expression which is nonzero if register number @var{num} is
2485suitable for use as a base register in operand addresses, accessing
2486memory in mode @var{mode} in address space @var{address_space}.
2487This is similar to @code{REGNO_MODE_OK_FOR_BASE_P}, except
38f8b050
JR
2488that that expression may examine the context in which the register
2489appears in the memory reference. @var{outer_code} is the code of the
2490immediately enclosing expression (@code{MEM} if at the top level of the
2491address, @code{ADDRESS} for something that occurs in an
2492@code{address_operand}). @var{index_code} is the code of the
2493corresponding index expression if @var{outer_code} is @code{PLUS};
2494@code{SCRATCH} otherwise. The mode may be @code{VOIDmode} for addresses
2495that appear outside a @code{MEM}, i.e., as an @code{address_operand}.
38f8b050
JR
2496@end defmac
2497
2498@defmac REGNO_OK_FOR_INDEX_P (@var{num})
2499A C expression which is nonzero if register number @var{num} is
2500suitable for use as an index register in operand addresses. It may be
2501either a suitable hard register or a pseudo register that has been
2502allocated such a hard register.
2503
2504The difference between an index register and a base register is that
2505the index register may be scaled. If an address involves the sum of
2506two registers, neither one of them scaled, then either one may be
2507labeled the ``base'' and the other the ``index''; but whichever
2508labeling is used must fit the machine's constraints of which registers
2509may serve in each capacity. The compiler will try both labelings,
2510looking for one that is valid, and will reload one or both registers
2511only if neither labeling works.
38f8b050
JR
2512@end defmac
2513
5f286f4a
YQ
2514@hook TARGET_PREFERRED_RENAME_CLASS
2515
fba42e24
AS
2516@hook TARGET_PREFERRED_RELOAD_CLASS
2517A target hook that places additional restrictions on the register class
2518to use when it is necessary to copy value @var{x} into a register in class
2519@var{rclass}. The value is a register class; perhaps @var{rclass}, or perhaps
2520another, smaller class.
2521
2522The default version of this hook always returns value of @code{rclass} argument.
2523
2524Sometimes returning a more restrictive class makes better code. For
2525example, on the 68000, when @var{x} is an integer constant that is in range
2526for a @samp{moveq} instruction, the value of this macro is always
2527@code{DATA_REGS} as long as @var{rclass} includes the data registers.
2528Requiring a data register guarantees that a @samp{moveq} will be used.
2529
2530One case where @code{TARGET_PREFERRED_RELOAD_CLASS} must not return
2531@var{rclass} is if @var{x} is a legitimate constant which cannot be
2532loaded into some register class. By returning @code{NO_REGS} you can
2533force @var{x} into a memory location. For example, rs6000 can load
2534immediate values into general-purpose registers, but does not have an
2535instruction for loading an immediate value into a floating-point
2536register, so @code{TARGET_PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2537@var{x} is a floating-point constant. If the constant can't be loaded
2538into any kind of register, code generation will be better if
1a627b35 2539@code{TARGET_LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
fba42e24
AS
2540of using @code{TARGET_PREFERRED_RELOAD_CLASS}.
2541
2542If an insn has pseudos in it after register allocation, reload will go
2543through the alternatives and call repeatedly @code{TARGET_PREFERRED_RELOAD_CLASS}
2544to find the best one. Returning @code{NO_REGS}, in this case, makes
2545reload add a @code{!} in front of the constraint: the x86 back-end uses
2546this feature to discourage usage of 387 registers when math is done in
2547the SSE registers (and vice versa).
2548@end deftypefn
2549
38f8b050
JR
2550@defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
2551A C expression that places additional restrictions on the register class
2552to use when it is necessary to copy value @var{x} into a register in class
2553@var{class}. The value is a register class; perhaps @var{class}, or perhaps
2554another, smaller class. On many machines, the following definition is
2555safe:
2556
2557@smallexample
2558#define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
2559@end smallexample
2560
2561Sometimes returning a more restrictive class makes better code. For
2562example, on the 68000, when @var{x} is an integer constant that is in range
2563for a @samp{moveq} instruction, the value of this macro is always
2564@code{DATA_REGS} as long as @var{class} includes the data registers.
2565Requiring a data register guarantees that a @samp{moveq} will be used.
2566
2567One case where @code{PREFERRED_RELOAD_CLASS} must not return
2568@var{class} is if @var{x} is a legitimate constant which cannot be
2569loaded into some register class. By returning @code{NO_REGS} you can
2570force @var{x} into a memory location. For example, rs6000 can load
2571immediate values into general-purpose registers, but does not have an
2572instruction for loading an immediate value into a floating-point
2573register, so @code{PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2574@var{x} is a floating-point constant. If the constant can't be loaded
2575into any kind of register, code generation will be better if
1a627b35
RS
2576@code{TARGET_LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
2577of using @code{TARGET_PREFERRED_RELOAD_CLASS}.
38f8b050
JR
2578
2579If an insn has pseudos in it after register allocation, reload will go
2580through the alternatives and call repeatedly @code{PREFERRED_RELOAD_CLASS}
2581to find the best one. Returning @code{NO_REGS}, in this case, makes
2582reload add a @code{!} in front of the constraint: the x86 back-end uses
2583this feature to discourage usage of 387 registers when math is done in
2584the SSE registers (and vice versa).
2585@end defmac
2586
abd26bfb
AS
2587@hook TARGET_PREFERRED_OUTPUT_RELOAD_CLASS
2588Like @code{TARGET_PREFERRED_RELOAD_CLASS}, but for output reloads instead of
2589input reloads.
2590
2591The default version of this hook always returns value of @code{rclass}
2592argument.
2593
2594You can also use @code{TARGET_PREFERRED_OUTPUT_RELOAD_CLASS} to discourage
2595reload from using some alternatives, like @code{TARGET_PREFERRED_RELOAD_CLASS}.
2596@end deftypefn
2597
38f8b050
JR
2598@defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class})
2599A C expression that places additional restrictions on the register class
2600to use when it is necessary to be able to hold a value of mode
2601@var{mode} in a reload register for which class @var{class} would
2602ordinarily be used.
2603
2604Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when
2605there are certain modes that simply can't go in certain reload classes.
2606
2607The value is a register class; perhaps @var{class}, or perhaps another,
2608smaller class.
2609
2610Don't define this macro unless the target machine has limitations which
2611require the macro to do something nontrivial.
2612@end defmac
2613
2614@hook TARGET_SECONDARY_RELOAD
2615Many machines have some registers that cannot be copied directly to or
2616from memory or even from other types of registers. An example is the
2617@samp{MQ} register, which on most machines, can only be copied to or
2618from general registers, but not memory. Below, we shall be using the
2619term 'intermediate register' when a move operation cannot be performed
2620directly, but has to be done by copying the source into the intermediate
2621register first, and then copying the intermediate register to the
2622destination. An intermediate register always has the same mode as
2623source and destination. Since it holds the actual value being copied,
2624reload might apply optimizations to re-use an intermediate register
2625and eliding the copy from the source when it can determine that the
2626intermediate register still holds the required value.
2627
2628Another kind of secondary reload is required on some machines which
2629allow copying all registers to and from memory, but require a scratch
2630register for stores to some memory locations (e.g., those with symbolic
2631address on the RT, and those with certain symbolic address on the SPARC
2632when compiling PIC)@. Scratch registers need not have the same mode
2633as the value being copied, and usually hold a different value than
2634that being copied. Special patterns in the md file are needed to
2635describe how the copy is performed with the help of the scratch register;
2636these patterns also describe the number, register class(es) and mode(s)
2637of the scratch register(s).
2638
2639In some cases, both an intermediate and a scratch register are required.
2640
2641For input reloads, this target hook is called with nonzero @var{in_p},
2642and @var{x} is an rtx that needs to be copied to a register of class
2643@var{reload_class} in @var{reload_mode}. For output reloads, this target
2644hook is called with zero @var{in_p}, and a register of class @var{reload_class}
2645needs to be copied to rtx @var{x} in @var{reload_mode}.
2646
2647If copying a register of @var{reload_class} from/to @var{x} requires
2648an intermediate register, the hook @code{secondary_reload} should
2649return the register class required for this intermediate register.
2650If no intermediate register is required, it should return NO_REGS.
2651If more than one intermediate register is required, describe the one
2652that is closest in the copy chain to the reload register.
2653
2654If scratch registers are needed, you also have to describe how to
2655perform the copy from/to the reload register to/from this
2656closest intermediate register. Or if no intermediate register is
2657required, but still a scratch register is needed, describe the
2658copy from/to the reload register to/from the reload operand @var{x}.
2659
2660You do this by setting @code{sri->icode} to the instruction code of a pattern
2661in the md file which performs the move. Operands 0 and 1 are the output
2662and input of this copy, respectively. Operands from operand 2 onward are
2663for scratch operands. These scratch operands must have a mode, and a
2664single-register-class
2665@c [later: or memory]
2666output constraint.
2667
2668When an intermediate register is used, the @code{secondary_reload}
2669hook will be called again to determine how to copy the intermediate
2670register to/from the reload operand @var{x}, so your hook must also
2671have code to handle the register class of the intermediate operand.
2672
2673@c [For later: maybe we'll allow multi-alternative reload patterns -
2674@c the port maintainer could name a mov<mode> pattern that has clobbers -
2675@c and match the constraints of input and output to determine the required
2676@c alternative. A restriction would be that constraints used to match
2677@c against reloads registers would have to be written as register class
2678@c constraints, or we need a new target macro / hook that tells us if an
2679@c arbitrary constraint can match an unknown register of a given class.
2680@c Such a macro / hook would also be useful in other places.]
2681
2682
2683@var{x} might be a pseudo-register or a @code{subreg} of a
2684pseudo-register, which could either be in a hard register or in memory.
2685Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2686in memory and the hard register number if it is in a register.
2687
2688Scratch operands in memory (constraint @code{"=m"} / @code{"=&m"}) are
2689currently not supported. For the time being, you will have to continue
2690to use @code{SECONDARY_MEMORY_NEEDED} for that purpose.
2691
2692@code{copy_cost} also uses this target hook to find out how values are
2693copied. If you want it to include some extra cost for the need to allocate
2694(a) scratch register(s), set @code{sri->extra_cost} to the additional cost.
2695Or if two dependent moves are supposed to have a lower cost than the sum
2696of the individual moves due to expected fortuitous scheduling and/or special
2697forwarding logic, you can set @code{sri->extra_cost} to a negative amount.
2698@end deftypefn
2699
2700@defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2701@defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2702@defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2703These macros are obsolete, new ports should use the target hook
2704@code{TARGET_SECONDARY_RELOAD} instead.
2705
2706These are obsolete macros, replaced by the @code{TARGET_SECONDARY_RELOAD}
2707target hook. Older ports still define these macros to indicate to the
2708reload phase that it may
2709need to allocate at least one register for a reload in addition to the
2710register to contain the data. Specifically, if copying @var{x} to a
2711register @var{class} in @var{mode} requires an intermediate register,
2712you were supposed to define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the
2713largest register class all of whose registers can be used as
2714intermediate registers or scratch registers.
2715
2716If copying a register @var{class} in @var{mode} to @var{x} requires an
2717intermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS}
2718was supposed to be defined be defined to return the largest register
2719class required. If the
2720requirements for input and output reloads were the same, the macro
2721@code{SECONDARY_RELOAD_CLASS} should have been used instead of defining both
2722macros identically.
2723
2724The values returned by these macros are often @code{GENERAL_REGS}.
2725Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x}
2726can be directly copied to or from a register of @var{class} in
2727@var{mode} without requiring a scratch register. Do not define this
2728macro if it would always return @code{NO_REGS}.
2729
2730If a scratch register is required (either with or without an
2731intermediate register), you were supposed to define patterns for
2732@samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required
2733(@pxref{Standard Names}. These patterns, which were normally
2734implemented with a @code{define_expand}, should be similar to the
2735@samp{mov@var{m}} patterns, except that operand 2 is the scratch
2736register.
2737
2738These patterns need constraints for the reload register and scratch
2739register that
2740contain a single register class. If the original reload register (whose
2741class is @var{class}) can meet the constraint given in the pattern, the
2742value returned by these macros is used for the class of the scratch
2743register. Otherwise, two additional reload registers are required.
2744Their classes are obtained from the constraints in the insn pattern.
2745
2746@var{x} might be a pseudo-register or a @code{subreg} of a
2747pseudo-register, which could either be in a hard register or in memory.
2748Use @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2749in memory and the hard register number if it is in a register.
2750
2751These macros should not be used in the case where a particular class of
2752registers can only be copied to memory and not to another class of
2753registers. In that case, secondary reload registers are not needed and
2754would not be helpful. Instead, a stack location must be used to perform
2755the copy and the @code{mov@var{m}} pattern should use memory as an
2756intermediate storage. This case often occurs between floating-point and
2757general registers.
2758@end defmac
2759
2760@defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m})
2761Certain machines have the property that some registers cannot be copied
2762to some other registers without using memory. Define this macro on
2763those machines to be a C expression that is nonzero if objects of mode
2764@var{m} in registers of @var{class1} can only be copied to registers of
2765class @var{class2} by storing a register of @var{class1} into memory
2766and loading that memory location into a register of @var{class2}.
2767
2768Do not define this macro if its value would always be zero.
2769@end defmac
2770
2771@defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode})
2772Normally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler
2773allocates a stack slot for a memory location needed for register copies.
2774If this macro is defined, the compiler instead uses the memory location
2775defined by this macro.
2776
2777Do not define this macro if you do not define
2778@code{SECONDARY_MEMORY_NEEDED}.
2779@end defmac
2780
2781@defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode})
2782When the compiler needs a secondary memory location to copy between two
2783registers of mode @var{mode}, it normally allocates sufficient memory to
2784hold a quantity of @code{BITS_PER_WORD} bits and performs the store and
2785load operations in a mode that many bits wide and whose class is the
2786same as that of @var{mode}.
2787
2788This is right thing to do on most machines because it ensures that all
2789bits of the register are copied and prevents accesses to the registers
2790in a narrower mode, which some machines prohibit for floating-point
2791registers.
2792
2793However, this default behavior is not correct on some machines, such as
2794the DEC Alpha, that store short integers in floating-point registers
2795differently than in integer registers. On those machines, the default
2796widening will not work correctly and you must define this macro to
2797suppress that widening in some cases. See the file @file{alpha.h} for
2798details.
2799
2800Do not define this macro if you do not define
2801@code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that
2802is @code{BITS_PER_WORD} bits wide is correct for your machine.
2803@end defmac
2804
07b8f0a8
AS
2805@hook TARGET_CLASS_LIKELY_SPILLED_P
2806A target hook which returns @code{true} if pseudos that have been assigned
2807to registers of class @var{rclass} would likely be spilled because
2808registers of @var{rclass} are needed for spill registers.
2809
2810The default version of this target hook returns @code{true} if @var{rclass}
2811has exactly one register and @code{false} otherwise. On most machines, this
aeb9f7cf
SB
2812default should be used. For generally register-starved machines, such as
2813i386, or machines with right register constraints, such as SH, this hook
2814can be used to avoid excessive spilling.
2815
2816This hook is also used by some of the global intra-procedural code
2817transformations to throtle code motion, to avoid increasing register
2818pressure.
07b8f0a8 2819@end deftypefn
a8c44c52
AS
2820
2821@hook TARGET_CLASS_MAX_NREGS
2822A target hook returns the maximum number of consecutive registers
2823of class @var{rclass} needed to hold a value of mode @var{mode}.
2824
2825This is closely related to the macro @code{HARD_REGNO_NREGS}. In fact,
1c7836f0 2826the value returned by @code{TARGET_CLASS_MAX_NREGS (@var{rclass},
a8c44c52
AS
2827@var{mode})} target hook should be the maximum value of
2828@code{HARD_REGNO_NREGS (@var{regno}, @var{mode})} for all @var{regno}
2829values in the class @var{rclass}.
2830
2831This target hook helps control the handling of multiple-word values
2832in the reload pass.
2833
2834The default version of this target hook returns the size of @var{mode}
2835in words.
2836@end deftypefn
07b8f0a8 2837
38f8b050
JR
2838@defmac CLASS_MAX_NREGS (@var{class}, @var{mode})
2839A C expression for the maximum number of consecutive registers
2840of class @var{class} needed to hold a value of mode @var{mode}.
2841
2842This is closely related to the macro @code{HARD_REGNO_NREGS}. In fact,
2843the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
2844should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno},
2845@var{mode})} for all @var{regno} values in the class @var{class}.
2846
2847This macro helps control the handling of multiple-word values
2848in the reload pass.
2849@end defmac
2850
2851@defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
2852If defined, a C expression that returns nonzero for a @var{class} for which
2853a change from mode @var{from} to mode @var{to} is invalid.
2854
2855For the example, loading 32-bit integer or floating-point objects into
2856floating-point registers on the Alpha extends them to 64 bits.
2857Therefore loading a 64-bit object and then storing it as a 32-bit object
2858does not store the low-order 32 bits, as would be the case for a normal
2859register. Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
2860as below:
2861
2862@smallexample
2863#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
2864 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
2865 ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
2866@end smallexample
2867@end defmac
2868
55a2c322
VM
2869@hook TARGET_LRA_P
2870
2871@hook TARGET_REGISTER_PRIORITY
2872
2873@hook TARGET_DIFFERENT_ADDR_DISPLACEMENT_P
2874
2875@hook TARGET_SPILL_CLASS
2876
42e37616
DM
2877@hook TARGET_CSTORE_MODE
2878
38f8b050
JR
2879@node Old Constraints
2880@section Obsolete Macros for Defining Constraints
2881@cindex defining constraints, obsolete method
2882@cindex constraints, defining, obsolete method
2883
2884Machine-specific constraints can be defined with these macros instead
2885of the machine description constructs described in @ref{Define
2886Constraints}. This mechanism is obsolete. New ports should not use
2887it; old ports should convert to the new mechanism.
2888
2889@defmac CONSTRAINT_LEN (@var{char}, @var{str})
2890For the constraint at the start of @var{str}, which starts with the letter
2891@var{c}, return the length. This allows you to have register class /
2892constant / extra constraints that are longer than a single letter;
2893you don't need to define this macro if you can do with single-letter
2894constraints only. The definition of this macro should use
2895DEFAULT_CONSTRAINT_LEN for all the characters that you don't want
2896to handle specially.
2897There are some sanity checks in genoutput.c that check the constraint lengths
2898for the md file, so you can also use this macro to help you while you are
2899transitioning from a byzantine single-letter-constraint scheme: when you
2900return a negative length for a constraint you want to re-use, genoutput
2901will complain about every instance where it is used in the md file.
2902@end defmac
2903
2904@defmac REG_CLASS_FROM_LETTER (@var{char})
2905A C expression which defines the machine-dependent operand constraint
2906letters for register classes. If @var{char} is such a letter, the
2907value should be the register class corresponding to it. Otherwise,
2908the value should be @code{NO_REGS}. The register letter @samp{r},
2909corresponding to class @code{GENERAL_REGS}, will not be passed
2910to this macro; you do not need to handle it.
2911@end defmac
2912
2913@defmac REG_CLASS_FROM_CONSTRAINT (@var{char}, @var{str})
2914Like @code{REG_CLASS_FROM_LETTER}, but you also get the constraint string
2915passed in @var{str}, so that you can use suffixes to distinguish between
2916different variants.
2917@end defmac
2918
2919@defmac CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
2920A C expression that defines the machine-dependent operand constraint
2921letters (@samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}) that specify
2922particular ranges of integer values. If @var{c} is one of those
2923letters, the expression should check that @var{value}, an integer, is in
2924the appropriate range and return 1 if so, 0 otherwise. If @var{c} is
2925not one of those letters, the value should be 0 regardless of
2926@var{value}.
2927@end defmac
2928
2929@defmac CONST_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2930Like @code{CONST_OK_FOR_LETTER_P}, but you also get the constraint
2931string passed in @var{str}, so that you can use suffixes to distinguish
2932between different variants.
2933@end defmac
2934
2935@defmac CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
2936A C expression that defines the machine-dependent operand constraint
2937letters that specify particular ranges of @code{const_double} values
2938(@samp{G} or @samp{H}).
2939
2940If @var{c} is one of those letters, the expression should check that
2941@var{value}, an RTX of code @code{const_double}, is in the appropriate
2942range and return 1 if so, 0 otherwise. If @var{c} is not one of those
2943letters, the value should be 0 regardless of @var{value}.
2944
2945@code{const_double} is used for all floating-point constants and for
2946@code{DImode} fixed-point constants. A given letter can accept either
2947or both kinds of values. It can use @code{GET_MODE} to distinguish
2948between these kinds.
2949@end defmac
2950
2951@defmac CONST_DOUBLE_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2952Like @code{CONST_DOUBLE_OK_FOR_LETTER_P}, but you also get the constraint
2953string passed in @var{str}, so that you can use suffixes to distinguish
2954between different variants.
2955@end defmac
2956
2957@defmac EXTRA_CONSTRAINT (@var{value}, @var{c})
2958A C expression that defines the optional machine-dependent constraint
2959letters that can be used to segregate specific types of operands, usually
2960memory references, for the target machine. Any letter that is not
2961elsewhere defined and not matched by @code{REG_CLASS_FROM_LETTER} /
2962@code{REG_CLASS_FROM_CONSTRAINT}
2963may be used. Normally this macro will not be defined.
2964
2965If it is required for a particular target machine, it should return 1
2966if @var{value} corresponds to the operand type represented by the
2967constraint letter @var{c}. If @var{c} is not defined as an extra
2968constraint, the value returned should be 0 regardless of @var{value}.
2969
2970For example, on the ROMP, load instructions cannot have their output
2971in r0 if the memory reference contains a symbolic address. Constraint
2972letter @samp{Q} is defined as representing a memory address that does
2973@emph{not} contain a symbolic address. An alternative is specified with
2974a @samp{Q} constraint on the input and @samp{r} on the output. The next
2975alternative specifies @samp{m} on the input and a register class that
2976does not include r0 on the output.
2977@end defmac
2978
2979@defmac EXTRA_CONSTRAINT_STR (@var{value}, @var{c}, @var{str})
2980Like @code{EXTRA_CONSTRAINT}, but you also get the constraint string passed
2981in @var{str}, so that you can use suffixes to distinguish between different
2982variants.
2983@end defmac
2984
2985@defmac EXTRA_MEMORY_CONSTRAINT (@var{c}, @var{str})
2986A C expression that defines the optional machine-dependent constraint
2987letters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should
2988be treated like memory constraints by the reload pass.
2989
2990It should return 1 if the operand type represented by the constraint
2991at the start of @var{str}, the first letter of which is the letter @var{c},
2992comprises a subset of all memory references including
2993all those whose address is simply a base register. This allows the reload
2994pass to reload an operand, if it does not directly correspond to the operand
2995type of @var{c}, by copying its address into a base register.
2996
2997For example, on the S/390, some instructions do not accept arbitrary
2998memory references, but only those that do not make use of an index
2999register. The constraint letter @samp{Q} is defined via
3000@code{EXTRA_CONSTRAINT} as representing a memory address of this type.
3001If the letter @samp{Q} is marked as @code{EXTRA_MEMORY_CONSTRAINT},
3002a @samp{Q} constraint can handle any memory operand, because the
3003reload pass knows it can be reloaded by copying the memory address
3004into a base register if required. This is analogous to the way
3005an @samp{o} constraint can handle any memory operand.
3006@end defmac
3007
3008@defmac EXTRA_ADDRESS_CONSTRAINT (@var{c}, @var{str})
3009A C expression that defines the optional machine-dependent constraint
3010letters, amongst those accepted by @code{EXTRA_CONSTRAINT} /
3011@code{EXTRA_CONSTRAINT_STR}, that should
3012be treated like address constraints by the reload pass.
3013
3014It should return 1 if the operand type represented by the constraint
3015at the start of @var{str}, which starts with the letter @var{c}, comprises
3016a subset of all memory addresses including
3017all those that consist of just a base register. This allows the reload
3018pass to reload an operand, if it does not directly correspond to the operand
3019type of @var{str}, by copying it into a base register.
3020
3021Any constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only
3022be used with the @code{address_operand} predicate. It is treated
3023analogously to the @samp{p} constraint.
3024@end defmac
3025
3026@node Stack and Calling
3027@section Stack Layout and Calling Conventions
3028@cindex calling conventions
3029
3030@c prevent bad page break with this line
3031This describes the stack layout and calling conventions.
3032
3033@menu
3034* Frame Layout::
3035* Exception Handling::
3036* Stack Checking::
3037* Frame Registers::
3038* Elimination::
3039* Stack Arguments::
3040* Register Arguments::
3041* Scalar Return::
3042* Aggregate Return::
3043* Caller Saves::
3044* Function Entry::
3045* Profiling::
3046* Tail Calls::
3047* Stack Smashing Protection::
3048@end menu
3049
3050@node Frame Layout
3051@subsection Basic Stack Layout
3052@cindex stack frame layout
3053@cindex frame layout
3054
3055@c prevent bad page break with this line
3056Here is the basic stack layout.
3057
3058@defmac STACK_GROWS_DOWNWARD
3059Define this macro if pushing a word onto the stack moves the stack
3060pointer to a smaller address.
3061
3062When we say, ``define this macro if @dots{}'', it means that the
3063compiler checks this macro only with @code{#ifdef} so the precise
3064definition used does not matter.
3065@end defmac
3066
3067@defmac STACK_PUSH_CODE
3068This macro defines the operation used when something is pushed
3069on the stack. In RTL, a push operation will be
3070@code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})}
3071
3072The choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC},
3073and @code{POST_INC}. Which of these is correct depends on
3074the stack direction and on whether the stack pointer points
3075to the last item on the stack or whether it points to the
3076space for the next item on the stack.
3077
3078The default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is
3079defined, which is almost always right, and @code{PRE_INC} otherwise,
3080which is often wrong.
3081@end defmac
3082
3083@defmac FRAME_GROWS_DOWNWARD
3084Define this macro to nonzero value if the addresses of local variable slots
3085are at negative offsets from the frame pointer.
3086@end defmac
3087
3088@defmac ARGS_GROW_DOWNWARD
3089Define this macro if successive arguments to a function occupy decreasing
3090addresses on the stack.
3091@end defmac
3092
3093@defmac STARTING_FRAME_OFFSET
3094Offset from the frame pointer to the first local variable slot to be allocated.
3095
3096If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
3097subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
3098Otherwise, it is found by adding the length of the first slot to the
3099value @code{STARTING_FRAME_OFFSET}.
3100@c i'm not sure if the above is still correct.. had to change it to get
3101@c rid of an overfull. --mew 2feb93
3102@end defmac
3103
3104@defmac STACK_ALIGNMENT_NEEDED
3105Define to zero to disable final alignment of the stack during reload.
3106The nonzero default for this macro is suitable for most ports.
3107
3108On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
3109is a register save block following the local block that doesn't require
3110alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
3111stack alignment and do it in the backend.
3112@end defmac
3113
3114@defmac STACK_POINTER_OFFSET
3115Offset from the stack pointer register to the first location at which
3116outgoing arguments are placed. If not specified, the default value of
3117zero is used. This is the proper value for most machines.
3118
3119If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
3120the first location at which outgoing arguments are placed.
3121@end defmac
3122
3123@defmac FIRST_PARM_OFFSET (@var{fundecl})
3124Offset from the argument pointer register to the first argument's
3125address. On some machines it may depend on the data type of the
3126function.
3127
3128If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
3129the first argument's address.
3130@end defmac
3131
3132@defmac STACK_DYNAMIC_OFFSET (@var{fundecl})
3133Offset from the stack pointer register to an item dynamically allocated
3134on the stack, e.g., by @code{alloca}.
3135
3136The default value for this macro is @code{STACK_POINTER_OFFSET} plus the
3137length of the outgoing arguments. The default is correct for most
3138machines. See @file{function.c} for details.
3139@end defmac
3140
3141@defmac INITIAL_FRAME_ADDRESS_RTX
3142A C expression whose value is RTL representing the address of the initial
3143stack frame. This address is passed to @code{RETURN_ADDR_RTX} and
3144@code{DYNAMIC_CHAIN_ADDRESS}. If you don't define this macro, a reasonable
3145default value will be used. Define this macro in order to make frame pointer
3146elimination work in the presence of @code{__builtin_frame_address (count)} and
3147@code{__builtin_return_address (count)} for @code{count} not equal to zero.
3148@end defmac
3149
3150@defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
3151A C expression whose value is RTL representing the address in a stack
3152frame where the pointer to the caller's frame is stored. Assume that
3153@var{frameaddr} is an RTL expression for the address of the stack frame
3154itself.
3155
3156If you don't define this macro, the default is to return the value
3157of @var{frameaddr}---that is, the stack frame address is also the
3158address of the stack word that points to the previous frame.
3159@end defmac
3160
3161@defmac SETUP_FRAME_ADDRESSES
3162If defined, a C expression that produces the machine-specific code to
3163setup the stack so that arbitrary frames can be accessed. For example,
3164on the SPARC, we must flush all of the register windows to the stack
3165before we can access arbitrary stack frames. You will seldom need to
3166define this macro.
3167@end defmac
3168
3169@hook TARGET_BUILTIN_SETJMP_FRAME_VALUE
3170This target hook should return an rtx that is used to store
3171the address of the current frame into the built in @code{setjmp} buffer.
3172The default value, @code{virtual_stack_vars_rtx}, is correct for most
3173machines. One reason you may need to define this target hook is if
3174@code{hard_frame_pointer_rtx} is the appropriate value on your machine.
3175@end deftypefn
3176
3177@defmac FRAME_ADDR_RTX (@var{frameaddr})
3178A C expression whose value is RTL representing the value of the frame
3179address for the current frame. @var{frameaddr} is the frame pointer
3180of the current frame. This is used for __builtin_frame_address.
3181You need only define this macro if the frame address is not the same
3182as the frame pointer. Most machines do not need to define it.
3183@end defmac
3184
3185@defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr})
3186A C expression whose value is RTL representing the value of the return
3187address for the frame @var{count} steps up from the current frame, after
3188the prologue. @var{frameaddr} is the frame pointer of the @var{count}
3189frame, or the frame pointer of the @var{count} @minus{} 1 frame if
3190@code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined.
3191
3192The value of the expression must always be the correct address when
3193@var{count} is zero, but may be @code{NULL_RTX} if there is no way to
3194determine the return address of other frames.
3195@end defmac
3196
3197@defmac RETURN_ADDR_IN_PREVIOUS_FRAME
3198Define this if the return address of a particular stack frame is accessed
3199from the frame pointer of the previous stack frame.
3200@end defmac
3201
3202@defmac INCOMING_RETURN_ADDR_RTX
3203A C expression whose value is RTL representing the location of the
3204incoming return address at the beginning of any function, before the
3205prologue. This RTL is either a @code{REG}, indicating that the return
3206value is saved in @samp{REG}, or a @code{MEM} representing a location in
3207the stack.
3208
3209You only need to define this macro if you want to support call frame
3210debugging information like that provided by DWARF 2.
3211
3212If this RTL is a @code{REG}, you should also define
3213@code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}.
3214@end defmac
3215
3216@defmac DWARF_ALT_FRAME_RETURN_COLUMN
3217A C expression whose value is an integer giving a DWARF 2 column
3218number that may be used as an alternative return column. The column
3219must not correspond to any gcc hard register (that is, it must not
3220be in the range of @code{DWARF_FRAME_REGNUM}).
3221
3222This macro can be useful if @code{DWARF_FRAME_RETURN_COLUMN} is set to a
3223general register, but an alternative column needs to be used for signal
3224frames. Some targets have also used different frame return columns
3225over time.
3226@end defmac
3227
3228@defmac DWARF_ZERO_REG
3229A C expression whose value is an integer giving a DWARF 2 register
3230number that is considered to always have the value zero. This should
3231only be defined if the target has an architected zero register, and
3232someone decided it was a good idea to use that register number to
3233terminate the stack backtrace. New ports should avoid this.
3234@end defmac
3235
3236@hook TARGET_DWARF_HANDLE_FRAME_UNSPEC
3237This target hook allows the backend to emit frame-related insns that
3238contain UNSPECs or UNSPEC_VOLATILEs. The DWARF 2 call frame debugging
3239info engine will invoke it on insns of the form
3240@smallexample
3241(set (reg) (unspec [@dots{}] UNSPEC_INDEX))
3242@end smallexample
3243and
3244@smallexample
3245(set (reg) (unspec_volatile [@dots{}] UNSPECV_INDEX)).
3246@end smallexample
3247to let the backend emit the call frame instructions. @var{label} is
3248the CFI label attached to the insn, @var{pattern} is the pattern of
3249the insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}.
3250@end deftypefn
3251
3252@defmac INCOMING_FRAME_SP_OFFSET
3253A C expression whose value is an integer giving the offset, in bytes,
3254from the value of the stack pointer register to the top of the stack
3255frame at the beginning of any function, before the prologue. The top of
3256the frame is defined to be the value of the stack pointer in the
3257previous frame, just before the call instruction.
3258
3259You only need to define this macro if you want to support call frame
3260debugging information like that provided by DWARF 2.
3261@end defmac
3262
3263@defmac ARG_POINTER_CFA_OFFSET (@var{fundecl})
3264A C expression whose value is an integer giving the offset, in bytes,
3265from the argument pointer to the canonical frame address (cfa). The
3266final value should coincide with that calculated by
3267@code{INCOMING_FRAME_SP_OFFSET}. Which is unfortunately not usable
3268during virtual register instantiation.
3269
3270The default value for this macro is
3271@code{FIRST_PARM_OFFSET (fundecl) + crtl->args.pretend_args_size},
3272which is correct for most machines; in general, the arguments are found
3273immediately before the stack frame. Note that this is not the case on
3274some targets that save registers into the caller's frame, such as SPARC
3275and rs6000, and so such targets need to define this macro.
3276
3277You only need to define this macro if the default is incorrect, and you
3278want to support call frame debugging information like that provided by
3279DWARF 2.
3280@end defmac
3281
3282@defmac FRAME_POINTER_CFA_OFFSET (@var{fundecl})
3283If defined, a C expression whose value is an integer giving the offset
3284in bytes from the frame pointer to the canonical frame address (cfa).
3285The final value should coincide with that calculated by
3286@code{INCOMING_FRAME_SP_OFFSET}.
3287
3288Normally the CFA is calculated as an offset from the argument pointer,
3289via @code{ARG_POINTER_CFA_OFFSET}, but if the argument pointer is
3290variable due to the ABI, this may not be possible. If this macro is
3291defined, it implies that the virtual register instantiation should be
3292based on the frame pointer instead of the argument pointer. Only one
3293of @code{FRAME_POINTER_CFA_OFFSET} and @code{ARG_POINTER_CFA_OFFSET}
3294should be defined.
3295@end defmac
3296
3297@defmac CFA_FRAME_BASE_OFFSET (@var{fundecl})
3298If defined, a C expression whose value is an integer giving the offset
3299in bytes from the canonical frame address (cfa) to the frame base used
3300in DWARF 2 debug information. The default is zero. A different value
3301may reduce the size of debug information on some ports.
3302@end defmac
3303
3304@node Exception Handling
3305@subsection Exception Handling Support
3306@cindex exception handling
3307
3308@defmac EH_RETURN_DATA_REGNO (@var{N})
3309A C expression whose value is the @var{N}th register number used for
3310data by exception handlers, or @code{INVALID_REGNUM} if fewer than
3311@var{N} registers are usable.
3312
3313The exception handling library routines communicate with the exception
3314handlers via a set of agreed upon registers. Ideally these registers
3315should be call-clobbered; it is possible to use call-saved registers,
3316but may negatively impact code size. The target must support at least
33172 data registers, but should define 4 if there are enough free registers.
3318
3319You must define this macro if you want to support call frame exception
3320handling like that provided by DWARF 2.
3321@end defmac
3322
3323@defmac EH_RETURN_STACKADJ_RTX
3324A C expression whose value is RTL representing a location in which
3325to store a stack adjustment to be applied before function return.
3326This is used to unwind the stack to an exception handler's call frame.
3327It will be assigned zero on code paths that return normally.
3328
3329Typically this is a call-clobbered hard register that is otherwise
3330untouched by the epilogue, but could also be a stack slot.
3331
3332Do not define this macro if the stack pointer is saved and restored
3333by the regular prolog and epilog code in the call frame itself; in
3334this case, the exception handling library routines will update the
3335stack location to be restored in place. Otherwise, you must define
3336this macro if you want to support call frame exception handling like
3337that provided by DWARF 2.
3338@end defmac
3339
3340@defmac EH_RETURN_HANDLER_RTX
3341A C expression whose value is RTL representing a location in which
3342to store the address of an exception handler to which we should
3343return. It will not be assigned on code paths that return normally.
3344
3345Typically this is the location in the call frame at which the normal
3346return address is stored. For targets that return by popping an
3347address off the stack, this might be a memory address just below
3348the @emph{target} call frame rather than inside the current call
3349frame. If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
3350been assigned, so it may be used to calculate the location of the
3351target call frame.
3352
3353Some targets have more complex requirements than storing to an
3354address calculable during initial code generation. In that case
3355the @code{eh_return} instruction pattern should be used instead.
3356
3357If you want to support call frame exception handling, you must
3358define either this macro or the @code{eh_return} instruction pattern.
3359@end defmac
3360
3361@defmac RETURN_ADDR_OFFSET
3362If defined, an integer-valued C expression for which rtl will be generated
3363to add it to the exception handler address before it is searched in the
3364exception handling tables, and to subtract it again from the address before
3365using it to return to the exception handler.
3366@end defmac
3367
3368@defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global})
3369This macro chooses the encoding of pointers embedded in the exception
3370handling sections. If at all possible, this should be defined such
3371that the exception handling section will not require dynamic relocations,
3372and so may be read-only.
3373
3374@var{code} is 0 for data, 1 for code labels, 2 for function pointers.
3375@var{global} is true if the symbol may be affected by dynamic relocations.
3376The macro should return a combination of the @code{DW_EH_PE_*} defines
3377as found in @file{dwarf2.h}.
3378
3379If this macro is not defined, pointers will not be encoded but
3380represented directly.
3381@end defmac
3382
3383@defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done})
3384This macro allows the target to emit whatever special magic is required
3385to represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}.
3386Generic code takes care of pc-relative and indirect encodings; this must
3387be defined if the target uses text-relative or data-relative encodings.
3388
3389This is a C statement that branches to @var{done} if the format was
3390handled. @var{encoding} is the format chosen, @var{size} is the number
3391of bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF}
3392to be emitted.
3393@end defmac
3394
38f8b050
JR
3395@defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs})
3396This macro allows the target to add CPU and operating system specific
3397code to the call-frame unwinder for use when there is no unwind data
3398available. The most common reason to implement this macro is to unwind
3399through signal frames.
3400
3401This macro is called from @code{uw_frame_state_for} in
3402@file{unwind-dw2.c}, @file{unwind-dw2-xtensa.c} and
3403@file{unwind-ia64.c}. @var{context} is an @code{_Unwind_Context};
3404@var{fs} is an @code{_Unwind_FrameState}. Examine @code{context->ra}
3405for the address of the code being executed and @code{context->cfa} for
3406the stack pointer value. If the frame can be decoded, the register
3407save addresses should be updated in @var{fs} and the macro should
3408evaluate to @code{_URC_NO_REASON}. If the frame cannot be decoded,
3409the macro should evaluate to @code{_URC_END_OF_STACK}.
3410
3411For proper signal handling in Java this macro is accompanied by
3412@code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers.
3413@end defmac
3414
3415@defmac MD_HANDLE_UNWABI (@var{context}, @var{fs})
3416This macro allows the target to add operating system specific code to the
3417call-frame unwinder to handle the IA-64 @code{.unwabi} unwinding directive,
3418usually used for signal or interrupt frames.
3419
0c93ed52
SB
3420This macro is called from @code{uw_update_context} in libgcc's
3421@file{unwind-ia64.c}. @var{context} is an @code{_Unwind_Context};
38f8b050
JR
3422@var{fs} is an @code{_Unwind_FrameState}. Examine @code{fs->unwabi}
3423for the abi and context in the @code{.unwabi} directive. If the
3424@code{.unwabi} directive can be handled, the register save addresses should
3425be updated in @var{fs}.
3426@end defmac
3427
3428@defmac TARGET_USES_WEAK_UNWIND_INFO
3429A C expression that evaluates to true if the target requires unwind
3430info to be given comdat linkage. Define it to be @code{1} if comdat
3431linkage is necessary. The default is @code{0}.
3432@end defmac
3433
3434@node Stack Checking
3435@subsection Specifying How Stack Checking is Done
3436
3437GCC will check that stack references are within the boundaries of the
3438stack, if the option @option{-fstack-check} is specified, in one of
3439three ways:
3440
3441@enumerate
3442@item
3443If the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC
3444will assume that you have arranged for full stack checking to be done
3445at appropriate places in the configuration files. GCC will not do
3446other special processing.
3447
3448@item
3449If @code{STACK_CHECK_BUILTIN} is zero and the value of the
3450@code{STACK_CHECK_STATIC_BUILTIN} macro is nonzero, GCC will assume
3451that you have arranged for static stack checking (checking of the
3452static stack frame of functions) to be done at appropriate places
3453in the configuration files. GCC will only emit code to do dynamic
3454stack checking (checking on dynamic stack allocations) using the third
3455approach below.
3456
3457@item
3458If neither of the above are true, GCC will generate code to periodically
3459``probe'' the stack pointer using the values of the macros defined below.
3460@end enumerate
3461
3462If neither STACK_CHECK_BUILTIN nor STACK_CHECK_STATIC_BUILTIN is defined,
3463GCC will change its allocation strategy for large objects if the option
3464@option{-fstack-check} is specified: they will always be allocated
3465dynamically if their size exceeds @code{STACK_CHECK_MAX_VAR_SIZE} bytes.
3466
3467@defmac STACK_CHECK_BUILTIN
3468A nonzero value if stack checking is done by the configuration files in a
3469machine-dependent manner. You should define this macro if stack checking
3470is required by the ABI of your machine or if you would like to do stack
3471checking in some more efficient way than the generic approach. The default
3472value of this macro is zero.
3473@end defmac
3474
3475@defmac STACK_CHECK_STATIC_BUILTIN
3476A nonzero value if static stack checking is done by the configuration files
3477in a machine-dependent manner. You should define this macro if you would
3478like to do static stack checking in some more efficient way than the generic
3479approach. The default value of this macro is zero.
3480@end defmac
3481
3482@defmac STACK_CHECK_PROBE_INTERVAL_EXP
3483An integer specifying the interval at which GCC must generate stack probe
3484instructions, defined as 2 raised to this integer. You will normally
3485define this macro so that the interval be no larger than the size of
3486the ``guard pages'' at the end of a stack area. The default value
3487of 12 (4096-byte interval) is suitable for most systems.
3488@end defmac
3489
3490@defmac STACK_CHECK_MOVING_SP
3491An integer which is nonzero if GCC should move the stack pointer page by page
3492when doing probes. This can be necessary on systems where the stack pointer
3493contains the bottom address of the memory area accessible to the executing
3494thread at any point in time. In this situation an alternate signal stack
3495is required in order to be able to recover from a stack overflow. The
3496default value of this macro is zero.
3497@end defmac
3498
3499@defmac STACK_CHECK_PROTECT
3500The number of bytes of stack needed to recover from a stack overflow, for
3501languages where such a recovery is supported. The default value of 75 words
3502with the @code{setjmp}/@code{longjmp}-based exception handling mechanism and
35038192 bytes with other exception handling mechanisms should be adequate for
3504most machines.
3505@end defmac
3506
3507The following macros are relevant only if neither STACK_CHECK_BUILTIN
3508nor STACK_CHECK_STATIC_BUILTIN is defined; you can omit them altogether
3509in the opposite case.
3510
3511@defmac STACK_CHECK_MAX_FRAME_SIZE
3512The maximum size of a stack frame, in bytes. GCC will generate probe
3513instructions in non-leaf functions to ensure at least this many bytes of
3514stack are available. If a stack frame is larger than this size, stack
3515checking will not be reliable and GCC will issue a warning. The
3516default is chosen so that GCC only generates one instruction on most
3517systems. You should normally not change the default value of this macro.
3518@end defmac
3519
3520@defmac STACK_CHECK_FIXED_FRAME_SIZE
3521GCC uses this value to generate the above warning message. It
3522represents the amount of fixed frame used by a function, not including
3523space for any callee-saved registers, temporaries and user variables.
3524You need only specify an upper bound for this amount and will normally
3525use the default of four words.
3526@end defmac
3527
3528@defmac STACK_CHECK_MAX_VAR_SIZE
3529The maximum size, in bytes, of an object that GCC will place in the
3530fixed area of the stack frame when the user specifies
3531@option{-fstack-check}.
3532GCC computed the default from the values of the above macros and you will
3533normally not need to override that default.
3534@end defmac
3535
3536@need 2000
3537@node Frame Registers
3538@subsection Registers That Address the Stack Frame
3539
3540@c prevent bad page break with this line
3541This discusses registers that address the stack frame.
3542
3543@defmac STACK_POINTER_REGNUM
3544The register number of the stack pointer register, which must also be a
3545fixed register according to @code{FIXED_REGISTERS}. On most machines,
3546the hardware determines which register this is.
3547@end defmac
3548
3549@defmac FRAME_POINTER_REGNUM
3550The register number of the frame pointer register, which is used to
3551access automatic variables in the stack frame. On some machines, the
3552hardware determines which register this is. On other machines, you can
3553choose any register you wish for this purpose.
3554@end defmac
3555
3556@defmac HARD_FRAME_POINTER_REGNUM
3557On some machines the offset between the frame pointer and starting
3558offset of the automatic variables is not known until after register
3559allocation has been done (for example, because the saved registers are
3560between these two locations). On those machines, define
3561@code{FRAME_POINTER_REGNUM} the number of a special, fixed register to
3562be used internally until the offset is known, and define
3563@code{HARD_FRAME_POINTER_REGNUM} to be the actual hard register number
3564used for the frame pointer.
3565
3566You should define this macro only in the very rare circumstances when it
3567is not possible to calculate the offset between the frame pointer and
3568the automatic variables until after register allocation has been
3569completed. When this macro is defined, you must also indicate in your
3570definition of @code{ELIMINABLE_REGS} how to eliminate
3571@code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM}
3572or @code{STACK_POINTER_REGNUM}.
3573
3574Do not define this macro if it would be the same as
3575@code{FRAME_POINTER_REGNUM}.
3576@end defmac
3577
3578@defmac ARG_POINTER_REGNUM
3579The register number of the arg pointer register, which is used to access
3580the function's argument list. On some machines, this is the same as the
3581frame pointer register. On some machines, the hardware determines which
3582register this is. On other machines, you can choose any register you
3583wish for this purpose. If this is not the same register as the frame
3584pointer register, then you must mark it as a fixed register according to
3585@code{FIXED_REGISTERS}, or arrange to be able to eliminate it
3586(@pxref{Elimination}).
3587@end defmac
3588
e3339d0f
JM
3589@defmac HARD_FRAME_POINTER_IS_FRAME_POINTER
3590Define this to a preprocessor constant that is nonzero if
3591@code{hard_frame_pointer_rtx} and @code{frame_pointer_rtx} should be
3592the same. The default definition is @samp{(HARD_FRAME_POINTER_REGNUM
3593== FRAME_POINTER_REGNUM)}; you only need to define this macro if that
3594definition is not suitable for use in preprocessor conditionals.
3595@end defmac
3596
3597@defmac HARD_FRAME_POINTER_IS_ARG_POINTER
3598Define this to a preprocessor constant that is nonzero if
3599@code{hard_frame_pointer_rtx} and @code{arg_pointer_rtx} should be the
3600same. The default definition is @samp{(HARD_FRAME_POINTER_REGNUM ==
3601ARG_POINTER_REGNUM)}; you only need to define this macro if that
3602definition is not suitable for use in preprocessor conditionals.
3603@end defmac
3604
38f8b050
JR
3605@defmac RETURN_ADDRESS_POINTER_REGNUM
3606The register number of the return address pointer register, which is used to
3607access the current function's return address from the stack. On some
3608machines, the return address is not at a fixed offset from the frame
3609pointer or stack pointer or argument pointer. This register can be defined
3610to point to the return address on the stack, and then be converted by
3611@code{ELIMINABLE_REGS} into either the frame pointer or stack pointer.
3612
3613Do not define this macro unless there is no other way to get the return
3614address from the stack.
3615@end defmac
3616
3617@defmac STATIC_CHAIN_REGNUM
3618@defmacx STATIC_CHAIN_INCOMING_REGNUM
3619Register numbers used for passing a function's static chain pointer. If
3620register windows are used, the register number as seen by the called
3621function is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register
3622number as seen by the calling function is @code{STATIC_CHAIN_REGNUM}. If
3623these registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need
3624not be defined.
3625
3626The static chain register need not be a fixed register.
3627
3628If the static chain is passed in memory, these macros should not be
3629defined; instead, the @code{TARGET_STATIC_CHAIN} hook should be used.
3630@end defmac
3631
3632@hook TARGET_STATIC_CHAIN
3633This hook replaces the use of @code{STATIC_CHAIN_REGNUM} et al for
3634targets that may use different static chain locations for different
3635nested functions. This may be required if the target has function
3636attributes that affect the calling conventions of the function and
3637those calling conventions use different static chain locations.
3638
3639The default version of this hook uses @code{STATIC_CHAIN_REGNUM} et al.
3640
3641If the static chain is passed in memory, this hook should be used to
3642provide rtx giving @code{mem} expressions that denote where they are stored.
3643Often the @code{mem} expression as seen by the caller will be at an offset
3644from the stack pointer and the @code{mem} expression as seen by the callee
3645will be at an offset from the frame pointer.
3646@findex stack_pointer_rtx
3647@findex frame_pointer_rtx
3648@findex arg_pointer_rtx
3649The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and
3650@code{arg_pointer_rtx} will have been initialized and should be used
3651to refer to those items.
3652@end deftypefn
3653
3654@defmac DWARF_FRAME_REGISTERS
3655This macro specifies the maximum number of hard registers that can be
3656saved in a call frame. This is used to size data structures used in
3657DWARF2 exception handling.
3658
3659Prior to GCC 3.0, this macro was needed in order to establish a stable
3660exception handling ABI in the face of adding new hard registers for ISA
3661extensions. In GCC 3.0 and later, the EH ABI is insulated from changes
3662in the number of hard registers. Nevertheless, this macro can still be
3663used to reduce the runtime memory requirements of the exception handling
3664routines, which can be substantial if the ISA contains a lot of
3665registers that are not call-saved.
3666
3667If this macro is not defined, it defaults to
3668@code{FIRST_PSEUDO_REGISTER}.
3669@end defmac
3670
3671@defmac PRE_GCC3_DWARF_FRAME_REGISTERS
3672
3673This macro is similar to @code{DWARF_FRAME_REGISTERS}, but is provided
3674for backward compatibility in pre GCC 3.0 compiled code.
3675
3676If this macro is not defined, it defaults to
3677@code{DWARF_FRAME_REGISTERS}.
3678@end defmac
3679
3680@defmac DWARF_REG_TO_UNWIND_COLUMN (@var{regno})
3681
3682Define this macro if the target's representation for dwarf registers
3683is different than the internal representation for unwind column.
3684Given a dwarf register, this macro should return the internal unwind
3685column number to use instead.
3686
3687See the PowerPC's SPE target for an example.
3688@end defmac
3689
3690@defmac DWARF_FRAME_REGNUM (@var{regno})
3691
3692Define this macro if the target's representation for dwarf registers
3693used in .eh_frame or .debug_frame is different from that used in other
3694debug info sections. Given a GCC hard register number, this macro
3695should return the .eh_frame register number. The default is
3696@code{DBX_REGISTER_NUMBER (@var{regno})}.
3697
3698@end defmac
3699
3700@defmac DWARF2_FRAME_REG_OUT (@var{regno}, @var{for_eh})
3701
3702Define this macro to map register numbers held in the call frame info
3703that GCC has collected using @code{DWARF_FRAME_REGNUM} to those that
3704should be output in .debug_frame (@code{@var{for_eh}} is zero) and
3705.eh_frame (@code{@var{for_eh}} is nonzero). The default is to
3706return @code{@var{regno}}.
3707
3708@end defmac
3709
cca2207a
L
3710@defmac REG_VALUE_IN_UNWIND_CONTEXT
3711
3712Define this macro if the target stores register values as
3713@code{_Unwind_Word} type in unwind context. It should be defined if
3714target register size is larger than the size of @code{void *}. The
3715default is to store register values as @code{void *} type.
3716
3717@end defmac
3718
3719@defmac ASSUME_EXTENDED_UNWIND_CONTEXT
3720
3721Define this macro to be 1 if the target always uses extended unwind
3722context with version, args_size and by_value fields. If it is undefined,
3723it will be defined to 1 when @code{REG_VALUE_IN_UNWIND_CONTEXT} is
3724defined and 0 otherwise.
3725
3726@end defmac
3727
38f8b050
JR
3728@node Elimination
3729@subsection Eliminating Frame Pointer and Arg Pointer
3730
3731@c prevent bad page break with this line
3732This is about eliminating the frame pointer and arg pointer.
3733
3734@hook TARGET_FRAME_POINTER_REQUIRED
3735This target hook should return @code{true} if a function must have and use
3736a frame pointer. This target hook is called in the reload pass. If its return
3737value is @code{true} the function will have a frame pointer.
3738
3739This target hook can in principle examine the current function and decide
3740according to the facts, but on most machines the constant @code{false} or the
3741constant @code{true} suffices. Use @code{false} when the machine allows code
3742to be generated with no frame pointer, and doing so saves some time or space.
3743Use @code{true} when there is no possible advantage to avoiding a frame
3744pointer.
3745
3746In certain cases, the compiler does not know how to produce valid code
3747without a frame pointer. The compiler recognizes those cases and
3748automatically gives the function a frame pointer regardless of what
3749@code{TARGET_FRAME_POINTER_REQUIRED} returns. You don't need to worry about
3750them.
3751
3752In a function that does not require a frame pointer, the frame pointer
3753register can be allocated for ordinary usage, unless you mark it as a
3754fixed register. See @code{FIXED_REGISTERS} for more information.
3755
3756Default return value is @code{false}.
3757@end deftypefn
3758
3759@findex get_frame_size
3760@defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var})
3761A C statement to store in the variable @var{depth-var} the difference
3762between the frame pointer and the stack pointer values immediately after
3763the function prologue. The value would be computed from information
3764such as the result of @code{get_frame_size ()} and the tables of
3765registers @code{regs_ever_live} and @code{call_used_regs}.
3766
3767If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and
3768need not be defined. Otherwise, it must be defined even if
3769@code{TARGET_FRAME_POINTER_REQUIRED} always returns true; in that
3770case, you may set @var{depth-var} to anything.
3771@end defmac
3772
3773@defmac ELIMINABLE_REGS
3774If defined, this macro specifies a table of register pairs used to
3775eliminate unneeded registers that point into the stack frame. If it is not
3776defined, the only elimination attempted by the compiler is to replace
3777references to the frame pointer with references to the stack pointer.
3778
3779The definition of this macro is a list of structure initializations, each
3780of which specifies an original and replacement register.
3781
3782On some machines, the position of the argument pointer is not known until
3783the compilation is completed. In such a case, a separate hard register
3784must be used for the argument pointer. This register can be eliminated by
3785replacing it with either the frame pointer or the argument pointer,
3786depending on whether or not the frame pointer has been eliminated.
3787
3788In this case, you might specify:
3789@smallexample
3790#define ELIMINABLE_REGS \
3791@{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \
3792 @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \
3793 @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@}
3794@end smallexample
3795
3796Note that the elimination of the argument pointer with the stack pointer is
3797specified first since that is the preferred elimination.
3798@end defmac
3799
3800@hook TARGET_CAN_ELIMINATE
3801This target hook should returns @code{true} if the compiler is allowed to
3802try to replace register number @var{from_reg} with register number
3803@var{to_reg}. This target hook need only be defined if @code{ELIMINABLE_REGS}
3804is defined, and will usually be @code{true}, since most of the cases
3805preventing register elimination are things that the compiler already
3806knows about.
3807
3808Default return value is @code{true}.
3809@end deftypefn
3810
3811@defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var})
3812This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It
3813specifies the initial difference between the specified pair of
3814registers. This macro must be defined if @code{ELIMINABLE_REGS} is
3815defined.
3816@end defmac
3817
3818@node Stack Arguments
3819@subsection Passing Function Arguments on the Stack
3820@cindex arguments on stack
3821@cindex stack arguments
3822
3823The macros in this section control how arguments are passed
3824on the stack. See the following section for other macros that
3825control passing certain arguments in registers.
3826
3827@hook TARGET_PROMOTE_PROTOTYPES
3828This target hook returns @code{true} if an argument declared in a
3829prototype as an integral type smaller than @code{int} should actually be
3830passed as an @code{int}. In addition to avoiding errors in certain
3831cases of mismatch, it also makes for better code on certain machines.
3832The default is to not promote prototypes.
3833@end deftypefn
3834
3835@defmac PUSH_ARGS
3836A C expression. If nonzero, push insns will be used to pass
3837outgoing arguments.
3838If the target machine does not have a push instruction, set it to zero.
3839That directs GCC to use an alternate strategy: to
3840allocate the entire argument block and then store the arguments into
3841it. When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too.
3842@end defmac
3843
3844@defmac PUSH_ARGS_REVERSED
3845A C expression. If nonzero, function arguments will be evaluated from
3846last to first, rather than from first to last. If this macro is not
3847defined, it defaults to @code{PUSH_ARGS} on targets where the stack
3848and args grow in opposite directions, and 0 otherwise.
3849@end defmac
3850
3851@defmac PUSH_ROUNDING (@var{npushed})
3852A C expression that is the number of bytes actually pushed onto the
3853stack when an instruction attempts to push @var{npushed} bytes.
3854
3855On some machines, the definition
3856
3857@smallexample
3858#define PUSH_ROUNDING(BYTES) (BYTES)
3859@end smallexample
3860
3861@noindent
3862will suffice. But on other machines, instructions that appear
3863to push one byte actually push two bytes in an attempt to maintain
3864alignment. Then the definition should be
3865
3866@smallexample
3867#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
3868@end smallexample
4a6336ad 3869
64ad7c99 3870If the value of this macro has a type, it should be an unsigned type.
38f8b050
JR
3871@end defmac
3872
29454ff5
SL
3873@findex outgoing_args_size
3874@findex crtl->outgoing_args_size
38f8b050
JR
3875@defmac ACCUMULATE_OUTGOING_ARGS
3876A C expression. If nonzero, the maximum amount of space required for outgoing arguments
29454ff5
SL
3877will be computed and placed into
3878@code{crtl->outgoing_args_size}. No space will be pushed
38f8b050
JR
3879onto the stack for each call; instead, the function prologue should
3880increase the stack frame size by this amount.
3881
3882Setting both @code{PUSH_ARGS} and @code{ACCUMULATE_OUTGOING_ARGS}
3883is not proper.
3884@end defmac
3885
3886@defmac REG_PARM_STACK_SPACE (@var{fndecl})
3887Define this macro if functions should assume that stack space has been
3888allocated for arguments even when their values are passed in
3889registers.
3890
3891The value of this macro is the size, in bytes, of the area reserved for
3892arguments passed in registers for the function represented by @var{fndecl},
3893which can be zero if GCC is calling a library function.
3894The argument @var{fndecl} can be the FUNCTION_DECL, or the type itself
3895of the function.
3896
3897This space can be allocated by the caller, or be a part of the
3898machine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE} says
3899which.
3900@end defmac
3901@c above is overfull. not sure what to do. --mew 5feb93 did
3902@c something, not sure if it looks good. --mew 10feb93
3903
3904@defmac OUTGOING_REG_PARM_STACK_SPACE (@var{fntype})
3905Define this to a nonzero value if it is the responsibility of the
3906caller to allocate the area reserved for arguments passed in registers
3907when calling a function of @var{fntype}. @var{fntype} may be NULL
3908if the function called is a library function.
3909
3910If @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls
3911whether the space for these arguments counts in the value of
29454ff5 3912@code{crtl->outgoing_args_size}.
38f8b050
JR
3913@end defmac
3914
3915@defmac STACK_PARMS_IN_REG_PARM_AREA
3916Define this macro if @code{REG_PARM_STACK_SPACE} is defined, but the
3917stack parameters don't skip the area specified by it.
3918@c i changed this, makes more sens and it should have taken care of the
3919@c overfull.. not as specific, tho. --mew 5feb93
3920
3921Normally, when a parameter is not passed in registers, it is placed on the
3922stack beyond the @code{REG_PARM_STACK_SPACE} area. Defining this macro
3923suppresses this behavior and causes the parameter to be passed on the
3924stack in its natural location.
3925@end defmac
3926
893d13d5 3927@hook TARGET_RETURN_POPS_ARGS
38f8b050
JR
3928This target hook returns the number of bytes of its own arguments that
3929a function pops on returning, or 0 if the function pops no arguments
3930and the caller must therefore pop them all after the function returns.
3931
3932@var{fundecl} is a C variable whose value is a tree node that describes
3933the function in question. Normally it is a node of type
3934@code{FUNCTION_DECL} that describes the declaration of the function.
3935From this you can obtain the @code{DECL_ATTRIBUTES} of the function.
3936
3937@var{funtype} is a C variable whose value is a tree node that
3938describes the function in question. Normally it is a node of type
3939@code{FUNCTION_TYPE} that describes the data type of the function.
3940From this it is possible to obtain the data types of the value and
3941arguments (if known).
3942
3943When a call to a library function is being considered, @var{fundecl}
3944will contain an identifier node for the library function. Thus, if
3945you need to distinguish among various library functions, you can do so
3946by their names. Note that ``library function'' in this context means
3947a function used to perform arithmetic, whose name is known specially
3948in the compiler and was not mentioned in the C code being compiled.
3949
893d13d5 3950@var{size} is the number of bytes of arguments passed on the
38f8b050
JR
3951stack. If a variable number of bytes is passed, it is zero, and
3952argument popping will always be the responsibility of the calling function.
3953
3954On the VAX, all functions always pop their arguments, so the definition
893d13d5 3955of this macro is @var{size}. On the 68000, using the standard
38f8b050
JR
3956calling convention, no functions pop their arguments, so the value of
3957the macro is always 0 in this case. But an alternative calling
3958convention is available in which functions that take a fixed number of
3959arguments pop them but other functions (such as @code{printf}) pop
3960nothing (the caller pops all). When this convention is in use,
3961@var{funtype} is examined to determine whether a function takes a fixed
3962number of arguments.
3963@end deftypefn
3964
3965@defmac CALL_POPS_ARGS (@var{cum})
3966A C expression that should indicate the number of bytes a call sequence
3967pops off the stack. It is added to the value of @code{RETURN_POPS_ARGS}
3968when compiling a function call.
3969
3970@var{cum} is the variable in which all arguments to the called function
3971have been accumulated.
3972
3973On certain architectures, such as the SH5, a call trampoline is used
3974that pops certain registers off the stack, depending on the arguments
3975that have been passed to the function. Since this is a property of the
3976call site, not of the called function, @code{RETURN_POPS_ARGS} is not
3977appropriate.
3978@end defmac
3979
3980@node Register Arguments
3981@subsection Passing Arguments in Registers
3982@cindex arguments in registers
3983@cindex registers arguments
3984
3985This section describes the macros which let you control how various
3986types of arguments are passed in registers or how they are arranged in
3987the stack.
3988
b25b9e8f
NF
3989@hook TARGET_FUNCTION_ARG
3990Return an RTX indicating whether a function argument is passed in a
3991register and if so, which register.
38f8b050 3992
b25b9e8f 3993The arguments are @var{ca}, which summarizes all the previous
38f8b050
JR
3994arguments; @var{mode}, the machine mode of the argument; @var{type},
3995the data type of the argument as a tree node or 0 if that is not known
3996(which happens for C support library functions); and @var{named},
b25b9e8f
NF
3997which is @code{true} for an ordinary argument and @code{false} for
3998nameless arguments that correspond to @samp{@dots{}} in the called
3999function's prototype. @var{type} can be an incomplete type if a
4000syntax error has previously occurred.
38f8b050 4001
b25b9e8f
NF
4002The return value is usually either a @code{reg} RTX for the hard
4003register in which to pass the argument, or zero to pass the argument
4004on the stack.
38f8b050
JR
4005
4006The value of the expression can also be a @code{parallel} RTX@. This is
4007used when an argument is passed in multiple locations. The mode of the
4008@code{parallel} should be the mode of the entire argument. The
4009@code{parallel} holds any number of @code{expr_list} pairs; each one
4010describes where part of the argument is passed. In each
4011@code{expr_list} the first operand must be a @code{reg} RTX for the hard
4012register in which to pass this part of the argument, and the mode of the
4013register RTX indicates how large this part of the argument is. The
4014second operand of the @code{expr_list} is a @code{const_int} which gives
4015the offset in bytes into the entire argument of where this part starts.
4016As a special exception the first @code{expr_list} in the @code{parallel}
4017RTX may have a first operand of zero. This indicates that the entire
4018argument is also stored on the stack.
4019
b25b9e8f 4020The last time this hook is called, it is called with @code{MODE ==
38f8b050
JR
4021VOIDmode}, and its result is passed to the @code{call} or @code{call_value}
4022pattern as operands 2 and 3 respectively.
4023
4024@cindex @file{stdarg.h} and register arguments
b25b9e8f
NF
4025The usual way to make the ISO library @file{stdarg.h} work on a
4026machine where some arguments are usually passed in registers, is to
4027cause nameless arguments to be passed on the stack instead. This is
4028done by making @code{TARGET_FUNCTION_ARG} return 0 whenever
4029@var{named} is @code{false}.
4030
4031@cindex @code{TARGET_MUST_PASS_IN_STACK}, and @code{TARGET_FUNCTION_ARG}
4032@cindex @code{REG_PARM_STACK_SPACE}, and @code{TARGET_FUNCTION_ARG}
38f8b050
JR
4033You may use the hook @code{targetm.calls.must_pass_in_stack}
4034in the definition of this macro to determine if this argument is of a
4035type that must be passed in the stack. If @code{REG_PARM_STACK_SPACE}
b25b9e8f 4036is not defined and @code{TARGET_FUNCTION_ARG} returns nonzero for such an
38f8b050
JR
4037argument, the compiler will abort. If @code{REG_PARM_STACK_SPACE} is
4038defined, the argument will be computed in the stack and then loaded into
4039a register.
b25b9e8f 4040@end deftypefn
38f8b050
JR
4041
4042@hook TARGET_MUST_PASS_IN_STACK
4043This target hook should return @code{true} if we should not pass @var{type}
4044solely in registers. The file @file{expr.h} defines a
4045definition that is usually appropriate, refer to @file{expr.h} for additional
4046documentation.
4047@end deftypefn
4048
b25b9e8f
NF
4049@hook TARGET_FUNCTION_INCOMING_ARG
4050Define this hook if the target machine has ``register windows'', so
38f8b050
JR
4051that the register in which a function sees an arguments is not
4052necessarily the same as the one in which the caller passed the
4053argument.
4054
b25b9e8f
NF
4055For such machines, @code{TARGET_FUNCTION_ARG} computes the register in
4056which the caller passes the value, and
4057@code{TARGET_FUNCTION_INCOMING_ARG} should be defined in a similar
4058fashion to tell the function being called where the arguments will
4059arrive.
38f8b050 4060
b25b9e8f
NF
4061If @code{TARGET_FUNCTION_INCOMING_ARG} is not defined,
4062@code{TARGET_FUNCTION_ARG} serves both purposes.
4063@end deftypefn
38f8b050
JR
4064
4065@hook TARGET_ARG_PARTIAL_BYTES
4066This target hook returns the number of bytes at the beginning of an
4067argument that must be put in registers. The value must be zero for
4068arguments that are passed entirely in registers or that are entirely
4069pushed on the stack.
4070
4071On some machines, certain arguments must be passed partially in
4072registers and partially in memory. On these machines, typically the
4073first few words of arguments are passed in registers, and the rest
4074on the stack. If a multi-word argument (a @code{double} or a
4075structure) crosses that boundary, its first few words must be passed
4076in registers and the rest must be pushed. This macro tells the
4077compiler when this occurs, and how many bytes should go in registers.
4078
b25b9e8f 4079@code{TARGET_FUNCTION_ARG} for these arguments should return the first
38f8b050 4080register to be used by the caller for this argument; likewise
b25b9e8f 4081@code{TARGET_FUNCTION_INCOMING_ARG}, for the called function.
38f8b050
JR
4082@end deftypefn
4083
ec9f85e5 4084@hook TARGET_PASS_BY_REFERENCE
38f8b050
JR
4085This target hook should return @code{true} if an argument at the
4086position indicated by @var{cum} should be passed by reference. This
4087predicate is queried after target independent reasons for being
4088passed by reference, such as @code{TREE_ADDRESSABLE (type)}.
4089
4090If the hook returns true, a copy of that argument is made in memory and a
4091pointer to the argument is passed instead of the argument itself.
4092The pointer is passed in whatever way is appropriate for passing a pointer
4093to that type.
4094@end deftypefn
4095
4096@hook TARGET_CALLEE_COPIES
4097The function argument described by the parameters to this hook is
4098known to be passed by reference. The hook should return true if the
4099function argument should be copied by the callee instead of copied
4100by the caller.
4101
4102For any argument for which the hook returns true, if it can be
4103determined that the argument is not modified, then a copy need
4104not be generated.
4105
4106The default version of this hook always returns false.
4107@end deftypefn
4108
4109@defmac CUMULATIVE_ARGS
b25b9e8f
NF
4110A C type for declaring a variable that is used as the first argument
4111of @code{TARGET_FUNCTION_ARG} and other related values. For some
4112target machines, the type @code{int} suffices and can hold the number
4113of bytes of argument so far.
38f8b050
JR
4114
4115There is no need to record in @code{CUMULATIVE_ARGS} anything about the
4116arguments that have been passed on the stack. The compiler has other
4117variables to keep track of that. For target machines on which all
4118arguments are passed on the stack, there is no need to store anything in
4119@code{CUMULATIVE_ARGS}; however, the data structure must exist and
4120should not be empty, so use @code{int}.
4121@end defmac
4122
4123@defmac OVERRIDE_ABI_FORMAT (@var{fndecl})
4124If defined, this macro is called before generating any code for a
4125function, but after the @var{cfun} descriptor for the function has been
4126created. The back end may use this macro to update @var{cfun} to
4127reflect an ABI other than that which would normally be used by default.
4128If the compiler is generating code for a compiler-generated function,
4129@var{fndecl} may be @code{NULL}.
4130@end defmac
4131
4132@defmac INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype}, @var{libname}, @var{fndecl}, @var{n_named_args})
4133A C statement (sans semicolon) for initializing the variable
4134@var{cum} for the state at the beginning of the argument list. The
4135variable has type @code{CUMULATIVE_ARGS}. The value of @var{fntype}
4136is the tree node for the data type of the function which will receive
4137the args, or 0 if the args are to a compiler support library function.
4138For direct calls that are not libcalls, @var{fndecl} contain the
4139declaration node of the function. @var{fndecl} is also set when
4140@code{INIT_CUMULATIVE_ARGS} is used to find arguments for the function
4141being compiled. @var{n_named_args} is set to the number of named
4142arguments, including a structure return address if it is passed as a
4143parameter, when making a call. When processing incoming arguments,
4144@var{n_named_args} is set to @minus{}1.
4145
4146When processing a call to a compiler support library function,
4147@var{libname} identifies which one. It is a @code{symbol_ref} rtx which
4148contains the name of the function, as a string. @var{libname} is 0 when
4149an ordinary C function call is being processed. Thus, each time this
4150macro is called, either @var{libname} or @var{fntype} is nonzero, but
4151never both of them at once.
4152@end defmac
4153
4154@defmac INIT_CUMULATIVE_LIBCALL_ARGS (@var{cum}, @var{mode}, @var{libname})
4155Like @code{INIT_CUMULATIVE_ARGS} but only used for outgoing libcalls,
4156it gets a @code{MODE} argument instead of @var{fntype}, that would be
4157@code{NULL}. @var{indirect} would always be zero, too. If this macro
4158is not defined, @code{INIT_CUMULATIVE_ARGS (cum, NULL_RTX, libname,
41590)} is used instead.
4160@end defmac
4161
4162@defmac INIT_CUMULATIVE_INCOMING_ARGS (@var{cum}, @var{fntype}, @var{libname})
4163Like @code{INIT_CUMULATIVE_ARGS} but overrides it for the purposes of
4164finding the arguments for the function being compiled. If this macro is
4165undefined, @code{INIT_CUMULATIVE_ARGS} is used instead.
4166
4167The value passed for @var{libname} is always 0, since library routines
4168with special calling conventions are never compiled with GCC@. The
4169argument @var{libname} exists for symmetry with
4170@code{INIT_CUMULATIVE_ARGS}.
4171@c could use "this macro" in place of @code{INIT_CUMULATIVE_ARGS}, maybe.
4172@c --mew 5feb93 i switched the order of the sentences. --mew 10feb93
4173@end defmac
4174
b25b9e8f
NF
4175@hook TARGET_FUNCTION_ARG_ADVANCE
4176This hook updates the summarizer variable pointed to by @var{ca} to
4177advance past an argument in the argument list. The values @var{mode},
4178@var{type} and @var{named} describe that argument. Once this is done,
4179the variable @var{cum} is suitable for analyzing the @emph{following}
4180argument with @code{TARGET_FUNCTION_ARG}, etc.
38f8b050 4181
b25b9e8f 4182This hook need not do anything if the argument in question was passed
38f8b050
JR
4183on the stack. The compiler knows how to track the amount of stack space
4184used for arguments without any special help.
b25b9e8f 4185@end deftypefn
38f8b050
JR
4186
4187@defmac FUNCTION_ARG_OFFSET (@var{mode}, @var{type})
4188If defined, a C expression that is the number of bytes to add to the
4189offset of the argument passed in memory. This is needed for the SPU,
4190which passes @code{char} and @code{short} arguments in the preferred
4191slot that is in the middle of the quad word instead of starting at the
4192top.
4193@end defmac
4194
4195@defmac FUNCTION_ARG_PADDING (@var{mode}, @var{type})
4196If defined, a C expression which determines whether, and in which direction,
4197to pad out an argument with extra space. The value should be of type
4198@code{enum direction}: either @code{upward} to pad above the argument,
4199@code{downward} to pad below, or @code{none} to inhibit padding.
4200
123148b5
BS
4201The @emph{amount} of padding is not controlled by this macro, but by the
4202target hook @code{TARGET_FUNCTION_ARG_ROUND_BOUNDARY}. It is
4203always just enough to reach the next multiple of that boundary.
38f8b050
JR
4204
4205This macro has a default definition which is right for most systems.
4206For little-endian machines, the default is to pad upward. For
4207big-endian machines, the default is to pad downward for an argument of
4208constant size shorter than an @code{int}, and upward otherwise.
4209@end defmac
4210
4211@defmac PAD_VARARGS_DOWN
4212If defined, a C expression which determines whether the default
4213implementation of va_arg will attempt to pad down before reading the
4214next argument, if that argument is smaller than its aligned space as
4215controlled by @code{PARM_BOUNDARY}. If this macro is not defined, all such
4216arguments are padded down if @code{BYTES_BIG_ENDIAN} is true.
4217@end defmac
4218
4219@defmac BLOCK_REG_PADDING (@var{mode}, @var{type}, @var{first})
4220Specify padding for the last element of a block move between registers and
4221memory. @var{first} is nonzero if this is the only element. Defining this
4222macro allows better control of register function parameters on big-endian
4223machines, without using @code{PARALLEL} rtl. In particular,
4224@code{MUST_PASS_IN_STACK} need not test padding and mode of types in
4225registers, as there is no longer a "wrong" part of a register; For example,
4226a three byte aggregate may be passed in the high part of a register if so
4227required.
4228@end defmac
4229
c2ed6cf8 4230@hook TARGET_FUNCTION_ARG_BOUNDARY
2b0d3573 4231This hook returns the alignment boundary, in bits, of an argument
c2ed6cf8
NF
4232with the specified mode and type. The default hook returns
4233@code{PARM_BOUNDARY} for all arguments.
4234@end deftypefn
38f8b050 4235
123148b5
BS
4236@hook TARGET_FUNCTION_ARG_ROUND_BOUNDARY
4237
38f8b050
JR
4238@defmac FUNCTION_ARG_REGNO_P (@var{regno})
4239A C expression that is nonzero if @var{regno} is the number of a hard
4240register in which function arguments are sometimes passed. This does
4241@emph{not} include implicit arguments such as the static chain and
4242the structure-value address. On many machines, no registers can be
4243used for this purpose since all function arguments are pushed on the
4244stack.
4245@end defmac
4246
4247@hook TARGET_SPLIT_COMPLEX_ARG
4248This hook should return true if parameter of type @var{type} are passed
4249as two scalar parameters. By default, GCC will attempt to pack complex
4250arguments into the target's word size. Some ABIs require complex arguments
4251to be split and treated as their individual components. For example, on
4252AIX64, complex floats should be passed in a pair of floating point
4253registers, even though a complex float would fit in one 64-bit floating
4254point register.
4255
4256The default value of this hook is @code{NULL}, which is treated as always
4257false.
4258@end deftypefn
4259
4260@hook TARGET_BUILD_BUILTIN_VA_LIST
4261This hook returns a type node for @code{va_list} for the target.
4262The default version of the hook returns @code{void*}.
4263@end deftypefn
4264
07a5b2bc 4265@hook TARGET_ENUM_VA_LIST_P
38f8b050
JR
4266This target hook is used in function @code{c_common_nodes_and_builtins}
4267to iterate through the target specific builtin types for va_list. The
4268variable @var{idx} is used as iterator. @var{pname} has to be a pointer
07a5b2bc 4269to a @code{const char *} and @var{ptree} a pointer to a @code{tree} typed
38f8b050 4270variable.
07a5b2bc 4271The arguments @var{pname} and @var{ptree} are used to store the result of
38f8b050
JR
4272this macro and are set to the name of the va_list builtin type and its
4273internal type.
4274If the return value of this macro is zero, then there is no more element.
4275Otherwise the @var{IDX} should be increased for the next call of this
4276macro to iterate through all types.
4277@end deftypefn
4278
4279@hook TARGET_FN_ABI_VA_LIST
4280This hook returns the va_list type of the calling convention specified by
4281@var{fndecl}.
4282The default version of this hook returns @code{va_list_type_node}.
4283@end deftypefn
4284
4285@hook TARGET_CANONICAL_VA_LIST_TYPE
4286This hook returns the va_list type of the calling convention specified by the
4287type of @var{type}. If @var{type} is not a valid va_list type, it returns
4288@code{NULL_TREE}.
4289@end deftypefn
4290
4291@hook TARGET_GIMPLIFY_VA_ARG_EXPR
4292This hook performs target-specific gimplification of
4293@code{VA_ARG_EXPR}. The first two parameters correspond to the
4294arguments to @code{va_arg}; the latter two are as in
4295@code{gimplify.c:gimplify_expr}.
4296@end deftypefn
4297
4298@hook TARGET_VALID_POINTER_MODE
4299Define this to return nonzero if the port can handle pointers
4300with machine mode @var{mode}. The default version of this
4301hook returns true for both @code{ptr_mode} and @code{Pmode}.
4302@end deftypefn
4303
7352c013
RG
4304@hook TARGET_REF_MAY_ALIAS_ERRNO
4305
38f8b050
JR
4306@hook TARGET_SCALAR_MODE_SUPPORTED_P
4307Define this to return nonzero if the port is prepared to handle
4308insns involving scalar mode @var{mode}. For a scalar mode to be
4309considered supported, all the basic arithmetic and comparisons
4310must work.
4311
4312The default version of this hook returns true for any mode
4313required to handle the basic C types (as defined by the port).
4314Included here are the double-word arithmetic supported by the
4315code in @file{optabs.c}.
4316@end deftypefn
4317
4318@hook TARGET_VECTOR_MODE_SUPPORTED_P
4319Define this to return nonzero if the port is prepared to handle
4320insns involving vector mode @var{mode}. At the very least, it
4321must have move patterns for this mode.
4322@end deftypefn
4323
0f6d54f7
RS
4324@hook TARGET_ARRAY_MODE_SUPPORTED_P
4325
38f8b050
JR
4326@hook TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P
4327Define this to return nonzero for machine modes for which the port has
4328small register classes. If this target hook returns nonzero for a given
4329@var{mode}, the compiler will try to minimize the lifetime of registers
4330in @var{mode}. The hook may be called with @code{VOIDmode} as argument.
4331In this case, the hook is expected to return nonzero if it returns nonzero
4332for any mode.
4333
4334On some machines, it is risky to let hard registers live across arbitrary
4335insns. Typically, these machines have instructions that require values
4336to be in specific registers (like an accumulator), and reload will fail
4337if the required hard register is used for another purpose across such an
4338insn.
4339
4340Passes before reload do not know which hard registers will be used
4341in an instruction, but the machine modes of the registers set or used in
4342the instruction are already known. And for some machines, register
4343classes are small for, say, integer registers but not for floating point
4344registers. For example, the AMD x86-64 architecture requires specific
4345registers for the legacy x86 integer instructions, but there are many
4346SSE registers for floating point operations. On such targets, a good
4347strategy may be to return nonzero from this hook for @code{INTEGRAL_MODE_P}
4348machine modes but zero for the SSE register classes.
4349
2b0d3573 4350The default version of this hook returns false for any mode. It is always
38f8b050
JR
4351safe to redefine this hook to return with a nonzero value. But if you
4352unnecessarily define it, you will reduce the amount of optimizations
4353that can be performed in some cases. If you do not define this hook
4354to return a nonzero value when it is required, the compiler will run out
4355of spill registers and print a fatal error message.
4356@end deftypefn
4357
e692f276
RH
4358@hook TARGET_FLAGS_REGNUM
4359
38f8b050
JR
4360@node Scalar Return
4361@subsection How Scalar Function Values Are Returned
4362@cindex return values in registers
4363@cindex values, returned by functions
4364@cindex scalars, returned as values
4365
4366This section discusses the macros that control returning scalars as
4367values---values that can fit in registers.
4368
4369@hook TARGET_FUNCTION_VALUE
4370
4371Define this to return an RTX representing the place where a function
4372returns or receives a value of data type @var{ret_type}, a tree node
4373representing a data type. @var{fn_decl_or_type} is a tree node
4374representing @code{FUNCTION_DECL} or @code{FUNCTION_TYPE} of a
4375function being called. If @var{outgoing} is false, the hook should
4376compute the register in which the caller will see the return value.
4377Otherwise, the hook should return an RTX representing the place where
4378a function returns a value.
4379
4380On many machines, only @code{TYPE_MODE (@var{ret_type})} is relevant.
4381(Actually, on most machines, scalar values are returned in the same
4382place regardless of mode.) The value of the expression is usually a
4383@code{reg} RTX for the hard register where the return value is stored.
4384The value can also be a @code{parallel} RTX, if the return value is in
b25b9e8f 4385multiple places. See @code{TARGET_FUNCTION_ARG} for an explanation of the
38f8b050
JR
4386@code{parallel} form. Note that the callee will populate every
4387location specified in the @code{parallel}, but if the first element of
4388the @code{parallel} contains the whole return value, callers will use
4389that element as the canonical location and ignore the others. The m68k
4390port uses this type of @code{parallel} to return pointers in both
4391@samp{%a0} (the canonical location) and @samp{%d0}.
4392
4393If @code{TARGET_PROMOTE_FUNCTION_RETURN} returns true, you must apply
4394the same promotion rules specified in @code{PROMOTE_MODE} if
4395@var{valtype} is a scalar type.
4396
4397If the precise function being called is known, @var{func} is a tree
4398node (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null
4399pointer. This makes it possible to use a different value-returning
4400convention for specific functions when all their calls are
4401known.
4402
4403Some target machines have ``register windows'' so that the register in
4404which a function returns its value is not the same as the one in which
4405the caller sees the value. For such machines, you should return
4406different RTX depending on @var{outgoing}.
4407
4408@code{TARGET_FUNCTION_VALUE} is not used for return values with
4409aggregate data types, because these are returned in another way. See
4410@code{TARGET_STRUCT_VALUE_RTX} and related macros, below.
4411@end deftypefn
4412
4413@defmac FUNCTION_VALUE (@var{valtype}, @var{func})
4414This macro has been deprecated. Use @code{TARGET_FUNCTION_VALUE} for
4415a new target instead.
4416@end defmac
4417
4418@defmac LIBCALL_VALUE (@var{mode})
4419A C expression to create an RTX representing the place where a library
4420function returns a value of mode @var{mode}.
4421
4422Note that ``library function'' in this context means a compiler
4423support routine, used to perform arithmetic, whose name is known
4424specially by the compiler and was not mentioned in the C code being
4425compiled.
4426@end defmac
4427
4428@hook TARGET_LIBCALL_VALUE
4429Define this hook if the back-end needs to know the name of the libcall
ff2ce160 4430function in order to determine where the result should be returned.
38f8b050
JR
4431
4432The mode of the result is given by @var{mode} and the name of the called
ff2ce160 4433library function is given by @var{fun}. The hook should return an RTX
38f8b050
JR
4434representing the place where the library function result will be returned.
4435
4436If this hook is not defined, then LIBCALL_VALUE will be used.
4437@end deftypefn
4438
4439@defmac FUNCTION_VALUE_REGNO_P (@var{regno})
4440A C expression that is nonzero if @var{regno} is the number of a hard
4441register in which the values of called function may come back.
4442
4443A register whose use for returning values is limited to serving as the
4444second of a pair (for a value of type @code{double}, say) need not be
4445recognized by this macro. So for most machines, this definition
4446suffices:
4447
4448@smallexample
4449#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
4450@end smallexample
4451
4452If the machine has register windows, so that the caller and the called
4453function use different registers for the return value, this macro
4454should recognize only the caller's register numbers.
4455
4456This macro has been deprecated. Use @code{TARGET_FUNCTION_VALUE_REGNO_P}
4457for a new target instead.
4458@end defmac
4459
4460@hook TARGET_FUNCTION_VALUE_REGNO_P
4461A target hook that return @code{true} if @var{regno} is the number of a hard
4462register in which the values of called function may come back.
4463
4464A register whose use for returning values is limited to serving as the
4465second of a pair (for a value of type @code{double}, say) need not be
4466recognized by this target hook.
4467
4468If the machine has register windows, so that the caller and the called
4469function use different registers for the return value, this target hook
4470should recognize only the caller's register numbers.
4471
4472If this hook is not defined, then FUNCTION_VALUE_REGNO_P will be used.
4473@end deftypefn
4474
4475@defmac APPLY_RESULT_SIZE
4476Define this macro if @samp{untyped_call} and @samp{untyped_return}
4477need more space than is implied by @code{FUNCTION_VALUE_REGNO_P} for
4478saving and restoring an arbitrary return value.
4479@end defmac
4480
4481@hook TARGET_RETURN_IN_MSB
4482This hook should return true if values of type @var{type} are returned
4483at the most significant end of a register (in other words, if they are
4484padded at the least significant end). You can assume that @var{type}
4485is returned in a register; the caller is required to check this.
4486
4487Note that the register provided by @code{TARGET_FUNCTION_VALUE} must
4488be able to hold the complete return value. For example, if a 1-, 2-
4489or 3-byte structure is returned at the most significant end of a
44904-byte register, @code{TARGET_FUNCTION_VALUE} should provide an
4491@code{SImode} rtx.
4492@end deftypefn
4493
4494@node Aggregate Return
4495@subsection How Large Values Are Returned
4496@cindex aggregates as return values
4497@cindex large return values
4498@cindex returning aggregate values
4499@cindex structure value address
4500
4501When a function value's mode is @code{BLKmode} (and in some other
4502cases), the value is not returned according to
4503@code{TARGET_FUNCTION_VALUE} (@pxref{Scalar Return}). Instead, the
4504caller passes the address of a block of memory in which the value
4505should be stored. This address is called the @dfn{structure value
4506address}.
4507
4508This section describes how to control returning structure values in
4509memory.
4510
4511@hook TARGET_RETURN_IN_MEMORY
4512This target hook should return a nonzero value to say to return the
4513function value in memory, just as large structures are always returned.
4514Here @var{type} will be the data type of the value, and @var{fntype}
4515will be the type of the function doing the returning, or @code{NULL} for
4516libcalls.
4517
4518Note that values of mode @code{BLKmode} must be explicitly handled
4519by this function. Also, the option @option{-fpcc-struct-return}
4520takes effect regardless of this macro. On most systems, it is
4521possible to leave the hook undefined; this causes a default
4522definition to be used, whose value is the constant 1 for @code{BLKmode}
4523values, and 0 otherwise.
4524
4525Do not use this hook to indicate that structures and unions should always
4526be returned in memory. You should instead use @code{DEFAULT_PCC_STRUCT_RETURN}
4527to indicate this.
4528@end deftypefn
4529
4530@defmac DEFAULT_PCC_STRUCT_RETURN
4531Define this macro to be 1 if all structure and union return values must be
4532in memory. Since this results in slower code, this should be defined
4533only if needed for compatibility with other compilers or with an ABI@.
4534If you define this macro to be 0, then the conventions used for structure
4535and union return values are decided by the @code{TARGET_RETURN_IN_MEMORY}
4536target hook.
4537
4538If not defined, this defaults to the value 1.
4539@end defmac
4540
4541@hook TARGET_STRUCT_VALUE_RTX
4542This target hook should return the location of the structure value
4543address (normally a @code{mem} or @code{reg}), or 0 if the address is
4544passed as an ``invisible'' first argument. Note that @var{fndecl} may
4545be @code{NULL}, for libcalls. You do not need to define this target
4546hook if the address is always passed as an ``invisible'' first
4547argument.
4548
4549On some architectures the place where the structure value address
4550is found by the called function is not the same place that the
4551caller put it. This can be due to register windows, or it could
4552be because the function prologue moves it to a different place.
4553@var{incoming} is @code{1} or @code{2} when the location is needed in
4554the context of the called function, and @code{0} in the context of
4555the caller.
4556
4557If @var{incoming} is nonzero and the address is to be found on the
4558stack, return a @code{mem} which refers to the frame pointer. If
4559@var{incoming} is @code{2}, the result is being used to fetch the
4560structure value address at the beginning of a function. If you need
4561to emit adjusting code, you should do it at this point.
4562@end deftypefn
4563
4564@defmac PCC_STATIC_STRUCT_RETURN
4565Define this macro if the usual system convention on the target machine
4566for returning structures and unions is for the called function to return
4567the address of a static variable containing the value.
4568
4569Do not define this if the usual system convention is for the caller to
4570pass an address to the subroutine.
4571
4572This macro has effect in @option{-fpcc-struct-return} mode, but it does
4573nothing when you use @option{-freg-struct-return} mode.
4574@end defmac
4575
ffa88471
SE
4576@hook TARGET_GET_RAW_RESULT_MODE
4577
4578@hook TARGET_GET_RAW_ARG_MODE
4579
38f8b050
JR
4580@node Caller Saves
4581@subsection Caller-Saves Register Allocation
4582
4583If you enable it, GCC can save registers around function calls. This
4584makes it possible to use call-clobbered registers to hold variables that
4585must live across calls.
4586
4587@defmac CALLER_SAVE_PROFITABLE (@var{refs}, @var{calls})
4588A C expression to determine whether it is worthwhile to consider placing
4589a pseudo-register in a call-clobbered hard register and saving and
4590restoring it around each function call. The expression should be 1 when
4591this is worth doing, and 0 otherwise.
4592
4593If you don't define this macro, a default is used which is good on most
4594machines: @code{4 * @var{calls} < @var{refs}}.
4595@end defmac
4596
4597@defmac HARD_REGNO_CALLER_SAVE_MODE (@var{regno}, @var{nregs})
4598A C expression specifying which mode is required for saving @var{nregs}
4599of a pseudo-register in call-clobbered hard register @var{regno}. If
4600@var{regno} is unsuitable for caller save, @code{VOIDmode} should be
4601returned. For most machines this macro need not be defined since GCC
4602will select the smallest suitable mode.
4603@end defmac
4604
4605@node Function Entry
4606@subsection Function Entry and Exit
4607@cindex function entry and exit
4608@cindex prologue
4609@cindex epilogue
4610
4611This section describes the macros that output function entry
4612(@dfn{prologue}) and exit (@dfn{epilogue}) code.
4613
4614@hook TARGET_ASM_FUNCTION_PROLOGUE
4615If defined, a function that outputs the assembler code for entry to a
4616function. The prologue is responsible for setting up the stack frame,
4617initializing the frame pointer register, saving registers that must be
4618saved, and allocating @var{size} additional bytes of storage for the
4619local variables. @var{size} is an integer. @var{file} is a stdio
4620stream to which the assembler code should be output.
4621
4622The label for the beginning of the function need not be output by this
4623macro. That has already been done when the macro is run.
4624
4625@findex regs_ever_live
4626To determine which registers to save, the macro can refer to the array
4627@code{regs_ever_live}: element @var{r} is nonzero if hard register
4628@var{r} is used anywhere within the function. This implies the function
4629prologue should save register @var{r}, provided it is not one of the
4630call-used registers. (@code{TARGET_ASM_FUNCTION_EPILOGUE} must likewise use
4631@code{regs_ever_live}.)
4632
4633On machines that have ``register windows'', the function entry code does
4634not save on the stack the registers that are in the windows, even if
4635they are supposed to be preserved by function calls; instead it takes
4636appropriate steps to ``push'' the register stack, if any non-call-used
4637registers are used in the function.
4638
4639@findex frame_pointer_needed
4640On machines where functions may or may not have frame-pointers, the
4641function entry code must vary accordingly; it must set up the frame
4642pointer if one is wanted, and not otherwise. To determine whether a
4643frame pointer is in wanted, the macro can refer to the variable
4644@code{frame_pointer_needed}. The variable's value will be 1 at run
4645time in a function that needs a frame pointer. @xref{Elimination}.
4646
4647The function entry code is responsible for allocating any stack space
4648required for the function. This stack space consists of the regions
4649listed below. In most cases, these regions are allocated in the
4650order listed, with the last listed region closest to the top of the
4651stack (the lowest address if @code{STACK_GROWS_DOWNWARD} is defined, and
4652the highest address if it is not defined). You can use a different order
4653for a machine if doing so is more convenient or required for
4654compatibility reasons. Except in cases where required by standard
4655or by a debugger, there is no reason why the stack layout used by GCC
4656need agree with that used by other compilers for a machine.
4657@end deftypefn
4658
4659@hook TARGET_ASM_FUNCTION_END_PROLOGUE
4660If defined, a function that outputs assembler code at the end of a
4661prologue. This should be used when the function prologue is being
4662emitted as RTL, and you have some extra assembler that needs to be
4663emitted. @xref{prologue instruction pattern}.
4664@end deftypefn
4665
4666@hook TARGET_ASM_FUNCTION_BEGIN_EPILOGUE
4667If defined, a function that outputs assembler code at the start of an
4668epilogue. This should be used when the function epilogue is being
4669emitted as RTL, and you have some extra assembler that needs to be
4670emitted. @xref{epilogue instruction pattern}.
4671@end deftypefn
4672
4673@hook TARGET_ASM_FUNCTION_EPILOGUE
4674If defined, a function that outputs the assembler code for exit from a
4675function. The epilogue is responsible for restoring the saved
4676registers and stack pointer to their values when the function was
4677called, and returning control to the caller. This macro takes the
4678same arguments as the macro @code{TARGET_ASM_FUNCTION_PROLOGUE}, and the
4679registers to restore are determined from @code{regs_ever_live} and
4680@code{CALL_USED_REGISTERS} in the same way.
4681
4682On some machines, there is a single instruction that does all the work
4683of returning from the function. On these machines, give that
4684instruction the name @samp{return} and do not define the macro
4685@code{TARGET_ASM_FUNCTION_EPILOGUE} at all.
4686
4687Do not define a pattern named @samp{return} if you want the
4688@code{TARGET_ASM_FUNCTION_EPILOGUE} to be used. If you want the target
4689switches to control whether return instructions or epilogues are used,
4690define a @samp{return} pattern with a validity condition that tests the
4691target switches appropriately. If the @samp{return} pattern's validity
4692condition is false, epilogues will be used.
4693
4694On machines where functions may or may not have frame-pointers, the
4695function exit code must vary accordingly. Sometimes the code for these
4696two cases is completely different. To determine whether a frame pointer
4697is wanted, the macro can refer to the variable
4698@code{frame_pointer_needed}. The variable's value will be 1 when compiling
4699a function that needs a frame pointer.
4700
4701Normally, @code{TARGET_ASM_FUNCTION_PROLOGUE} and
4702@code{TARGET_ASM_FUNCTION_EPILOGUE} must treat leaf functions specially.
4703The C variable @code{current_function_is_leaf} is nonzero for such a
4704function. @xref{Leaf Functions}.
4705
4706On some machines, some functions pop their arguments on exit while
4707others leave that for the caller to do. For example, the 68020 when
4708given @option{-mrtd} pops arguments in functions that take a fixed
4709number of arguments.
4710
29454ff5
SL
4711@findex pops_args
4712@findex crtl->args.pops_args
38f8b050
JR
4713Your definition of the macro @code{RETURN_POPS_ARGS} decides which
4714functions pop their own arguments. @code{TARGET_ASM_FUNCTION_EPILOGUE}
4715needs to know what was decided. The number of bytes of the current
4716function's arguments that this function should pop is available in
4717@code{crtl->args.pops_args}. @xref{Scalar Return}.
4718@end deftypefn
4719
4720@itemize @bullet
4721@item
29454ff5
SL
4722@findex pretend_args_size
4723@findex crtl->args.pretend_args_size
4724A region of @code{crtl->args.pretend_args_size} bytes of
38f8b050
JR
4725uninitialized space just underneath the first argument arriving on the
4726stack. (This may not be at the very start of the allocated stack region
4727if the calling sequence has pushed anything else since pushing the stack
4728arguments. But usually, on such machines, nothing else has been pushed
4729yet, because the function prologue itself does all the pushing.) This
4730region is used on machines where an argument may be passed partly in
4731registers and partly in memory, and, in some cases to support the
4732features in @code{<stdarg.h>}.
4733
4734@item
4735An area of memory used to save certain registers used by the function.
4736The size of this area, which may also include space for such things as
4737the return address and pointers to previous stack frames, is
4738machine-specific and usually depends on which registers have been used
4739in the function. Machines with register windows often do not require
4740a save area.
4741
4742@item
4743A region of at least @var{size} bytes, possibly rounded up to an allocation
4744boundary, to contain the local variables of the function. On some machines,
4745this region and the save area may occur in the opposite order, with the
4746save area closer to the top of the stack.
4747
4748@item
4749@cindex @code{ACCUMULATE_OUTGOING_ARGS} and stack frames
4750Optionally, when @code{ACCUMULATE_OUTGOING_ARGS} is defined, a region of
29454ff5 4751@code{crtl->outgoing_args_size} bytes to be used for outgoing
38f8b050
JR
4752argument lists of the function. @xref{Stack Arguments}.
4753@end itemize
4754
4755@defmac EXIT_IGNORE_STACK
4756Define this macro as a C expression that is nonzero if the return
4757instruction or the function epilogue ignores the value of the stack
4758pointer; in other words, if it is safe to delete an instruction to
4759adjust the stack pointer before a return from the function. The
4760default is 0.
4761
4762Note that this macro's value is relevant only for functions for which
4763frame pointers are maintained. It is never safe to delete a final
4764stack adjustment in a function that has no frame pointer, and the
4765compiler knows this regardless of @code{EXIT_IGNORE_STACK}.
4766@end defmac
4767
4768@defmac EPILOGUE_USES (@var{regno})
4769Define this macro as a C expression that is nonzero for registers that are
4770used by the epilogue or the @samp{return} pattern. The stack and frame
4771pointer registers are already assumed to be used as needed.
4772@end defmac
4773
4774@defmac EH_USES (@var{regno})
4775Define this macro as a C expression that is nonzero for registers that are
4776used by the exception handling mechanism, and so should be considered live
4777on entry to an exception edge.
4778@end defmac
4779
38f8b050
JR
4780@hook TARGET_ASM_OUTPUT_MI_THUNK
4781A function that outputs the assembler code for a thunk
4782function, used to implement C++ virtual function calls with multiple
4783inheritance. The thunk acts as a wrapper around a virtual function,
4784adjusting the implicit object parameter before handing control off to
4785the real function.
4786
4787First, emit code to add the integer @var{delta} to the location that
4788contains the incoming first argument. Assume that this argument
4789contains a pointer, and is the one used to pass the @code{this} pointer
4790in C++. This is the incoming argument @emph{before} the function prologue,
4791e.g.@: @samp{%o0} on a sparc. The addition must preserve the values of
4792all other incoming arguments.
4793
4794Then, if @var{vcall_offset} is nonzero, an additional adjustment should be
4795made after adding @code{delta}. In particular, if @var{p} is the
4796adjusted pointer, the following adjustment should be made:
4797
4798@smallexample
4799p += (*((ptrdiff_t **)p))[vcall_offset/sizeof(ptrdiff_t)]
4800@end smallexample
4801
4802After the additions, emit code to jump to @var{function}, which is a
4803@code{FUNCTION_DECL}. This is a direct pure jump, not a call, and does
4804not touch the return address. Hence returning from @var{FUNCTION} will
4805return to whoever called the current @samp{thunk}.
4806
4807The effect must be as if @var{function} had been called directly with
4808the adjusted first argument. This macro is responsible for emitting all
4809of the code for a thunk function; @code{TARGET_ASM_FUNCTION_PROLOGUE}
4810and @code{TARGET_ASM_FUNCTION_EPILOGUE} are not invoked.
4811
4812The @var{thunk_fndecl} is redundant. (@var{delta} and @var{function}
4813have already been extracted from it.) It might possibly be useful on
4814some targets, but probably not.
4815
4816If you do not define this macro, the target-independent code in the C++
4817front end will generate a less efficient heavyweight thunk that calls
4818@var{function} instead of jumping to it. The generic approach does
4819not support varargs.
4820@end deftypefn
4821
4822@hook TARGET_ASM_CAN_OUTPUT_MI_THUNK
4823A function that returns true if TARGET_ASM_OUTPUT_MI_THUNK would be able
4824to output the assembler code for the thunk function specified by the
4825arguments it is passed, and false otherwise. In the latter case, the
4826generic approach will be used by the C++ front end, with the limitations
4827previously exposed.
4828@end deftypefn
4829
4830@node Profiling
4831@subsection Generating Code for Profiling
4832@cindex profiling, code generation
4833
4834These macros will help you generate code for profiling.
4835
4836@defmac FUNCTION_PROFILER (@var{file}, @var{labelno})
4837A C statement or compound statement to output to @var{file} some
4838assembler code to call the profiling subroutine @code{mcount}.
4839
4840@findex mcount
4841The details of how @code{mcount} expects to be called are determined by
4842your operating system environment, not by GCC@. To figure them out,
4843compile a small program for profiling using the system's installed C
4844compiler and look at the assembler code that results.
4845
4846Older implementations of @code{mcount} expect the address of a counter
4847variable to be loaded into some register. The name of this variable is
4848@samp{LP} followed by the number @var{labelno}, so you would generate
4849the name using @samp{LP%d} in a @code{fprintf}.
4850@end defmac
4851
4852@defmac PROFILE_HOOK
4853A C statement or compound statement to output to @var{file} some assembly
4854code to call the profiling subroutine @code{mcount} even the target does
4855not support profiling.
4856@end defmac
4857
4858@defmac NO_PROFILE_COUNTERS
4859Define this macro to be an expression with a nonzero value if the
4860@code{mcount} subroutine on your system does not need a counter variable
4861allocated for each function. This is true for almost all modern
4862implementations. If you define this macro, you must not use the
4863@var{labelno} argument to @code{FUNCTION_PROFILER}.
4864@end defmac
4865
4866@defmac PROFILE_BEFORE_PROLOGUE
4867Define this macro if the code for function profiling should come before
4868the function prologue. Normally, the profiling code comes after.
4869@end defmac
4870
4871@node Tail Calls
4872@subsection Permitting tail calls
4873@cindex tail calls
4874
4875@hook TARGET_FUNCTION_OK_FOR_SIBCALL
4876True if it is ok to do sibling call optimization for the specified
4877call expression @var{exp}. @var{decl} will be the called function,
4878or @code{NULL} if this is an indirect call.
4879
4880It is not uncommon for limitations of calling conventions to prevent
4881tail calls to functions outside the current unit of translation, or
4882during PIC compilation. The hook is used to enforce these restrictions,
4883as the @code{sibcall} md pattern can not fail, or fall over to a
4884``normal'' call. The criteria for successful sibling call optimization
4885may vary greatly between different architectures.
4886@end deftypefn
4887
4888@hook TARGET_EXTRA_LIVE_ON_ENTRY
4889Add any hard registers to @var{regs} that are live on entry to the
4890function. This hook only needs to be defined to provide registers that
4891cannot be found by examination of FUNCTION_ARG_REGNO_P, the callee saved
4892registers, STATIC_CHAIN_INCOMING_REGNUM, STATIC_CHAIN_REGNUM,
4893TARGET_STRUCT_VALUE_RTX, FRAME_POINTER_REGNUM, EH_USES,
4894FRAME_POINTER_REGNUM, ARG_POINTER_REGNUM, and the PIC_OFFSET_TABLE_REGNUM.
4895@end deftypefn
4896
ee3d2ecd
JJ
4897@hook TARGET_SET_UP_BY_PROLOGUE
4898
d45eae79
SL
4899@hook TARGET_WARN_FUNC_RETURN
4900
38f8b050
JR
4901@node Stack Smashing Protection
4902@subsection Stack smashing protection
4903@cindex stack smashing protection
4904
4905@hook TARGET_STACK_PROTECT_GUARD
4906This hook returns a @code{DECL} node for the external variable to use
4907for the stack protection guard. This variable is initialized by the
4908runtime to some random value and is used to initialize the guard value
4909that is placed at the top of the local stack frame. The type of this
4910variable must be @code{ptr_type_node}.
4911
4912The default version of this hook creates a variable called
4913@samp{__stack_chk_guard}, which is normally defined in @file{libgcc2.c}.
4914@end deftypefn
4915
4916@hook TARGET_STACK_PROTECT_FAIL
b3c144a3 4917This hook returns a @code{CALL_EXPR} that alerts the runtime that the
38f8b050
JR
4918stack protect guard variable has been modified. This expression should
4919involve a call to a @code{noreturn} function.
4920
4921The default version of this hook invokes a function called
4922@samp{__stack_chk_fail}, taking no arguments. This function is
4923normally defined in @file{libgcc2.c}.
4924@end deftypefn
4925
7458026b
ILT
4926@hook TARGET_SUPPORTS_SPLIT_STACK
4927
38f8b050
JR
4928@node Varargs
4929@section Implementing the Varargs Macros
4930@cindex varargs implementation
4931
4932GCC comes with an implementation of @code{<varargs.h>} and
4933@code{<stdarg.h>} that work without change on machines that pass arguments
4934on the stack. Other machines require their own implementations of
4935varargs, and the two machine independent header files must have
4936conditionals to include it.
4937
4938ISO @code{<stdarg.h>} differs from traditional @code{<varargs.h>} mainly in
4939the calling convention for @code{va_start}. The traditional
4940implementation takes just one argument, which is the variable in which
4941to store the argument pointer. The ISO implementation of
4942@code{va_start} takes an additional second argument. The user is
4943supposed to write the last named argument of the function here.
4944
4945However, @code{va_start} should not use this argument. The way to find
4946the end of the named arguments is with the built-in functions described
4947below.
4948
4949@defmac __builtin_saveregs ()
4950Use this built-in function to save the argument registers in memory so
4951that the varargs mechanism can access them. Both ISO and traditional
4952versions of @code{va_start} must use @code{__builtin_saveregs}, unless
4953you use @code{TARGET_SETUP_INCOMING_VARARGS} (see below) instead.
4954
4955On some machines, @code{__builtin_saveregs} is open-coded under the
4956control of the target hook @code{TARGET_EXPAND_BUILTIN_SAVEREGS}. On
4957other machines, it calls a routine written in assembler language,
4958found in @file{libgcc2.c}.
4959
4960Code generated for the call to @code{__builtin_saveregs} appears at the
4961beginning of the function, as opposed to where the call to
4962@code{__builtin_saveregs} is written, regardless of what the code is.
4963This is because the registers must be saved before the function starts
4964to use them for its own purposes.
4965@c i rewrote the first sentence above to fix an overfull hbox. --mew
4966@c 10feb93
4967@end defmac
4968
38f8b050 4969@defmac __builtin_next_arg (@var{lastarg})
c59a0a1d 4970This builtin returns the address of the first anonymous stack
38f8b050
JR
4971argument, as type @code{void *}. If @code{ARGS_GROW_DOWNWARD}, it
4972returns the address of the location above the first anonymous stack
4973argument. Use it in @code{va_start} to initialize the pointer for
4974fetching arguments from the stack. Also use it in @code{va_start} to
4975verify that the second parameter @var{lastarg} is the last named argument
4976of the current function.
4977@end defmac
4978
4979@defmac __builtin_classify_type (@var{object})
4980Since each machine has its own conventions for which data types are
4981passed in which kind of register, your implementation of @code{va_arg}
4982has to embody these conventions. The easiest way to categorize the
4983specified data type is to use @code{__builtin_classify_type} together
4984with @code{sizeof} and @code{__alignof__}.
4985
4986@code{__builtin_classify_type} ignores the value of @var{object},
4987considering only its data type. It returns an integer describing what
4988kind of type that is---integer, floating, pointer, structure, and so on.
4989
4990The file @file{typeclass.h} defines an enumeration that you can use to
4991interpret the values of @code{__builtin_classify_type}.
4992@end defmac
4993
4994These machine description macros help implement varargs:
4995
4996@hook TARGET_EXPAND_BUILTIN_SAVEREGS
4997If defined, this hook produces the machine-specific code for a call to
4998@code{__builtin_saveregs}. This code will be moved to the very
4999beginning of the function, before any parameter access are made. The
5000return value of this function should be an RTX that contains the value
5001to use as the return of @code{__builtin_saveregs}.
5002@end deftypefn
5003
5004@hook TARGET_SETUP_INCOMING_VARARGS
5005This target hook offers an alternative to using
5006@code{__builtin_saveregs} and defining the hook
5007@code{TARGET_EXPAND_BUILTIN_SAVEREGS}. Use it to store the anonymous
5008register arguments into the stack so that all the arguments appear to
5009have been passed consecutively on the stack. Once this is done, you can
5010use the standard implementation of varargs that works for machines that
5011pass all their arguments on the stack.
5012
5013The argument @var{args_so_far} points to the @code{CUMULATIVE_ARGS} data
5014structure, containing the values that are obtained after processing the
5015named arguments. The arguments @var{mode} and @var{type} describe the
5016last named argument---its machine mode and its data type as a tree node.
5017
5018The target hook should do two things: first, push onto the stack all the
5019argument registers @emph{not} used for the named arguments, and second,
5020store the size of the data thus pushed into the @code{int}-valued
5021variable pointed to by @var{pretend_args_size}. The value that you
5022store here will serve as additional offset for setting up the stack
5023frame.
5024
5025Because you must generate code to push the anonymous arguments at
5026compile time without knowing their data types,
5027@code{TARGET_SETUP_INCOMING_VARARGS} is only useful on machines that
5028have just a single category of argument register and use it uniformly
5029for all data types.
5030
5031If the argument @var{second_time} is nonzero, it means that the
5032arguments of the function are being analyzed for the second time. This
5033happens for an inline function, which is not actually compiled until the
5034end of the source file. The hook @code{TARGET_SETUP_INCOMING_VARARGS} should
5035not generate any instructions in this case.
5036@end deftypefn
5037
5038@hook TARGET_STRICT_ARGUMENT_NAMING
5039Define this hook to return @code{true} if the location where a function
5040argument is passed depends on whether or not it is a named argument.
5041
b25b9e8f 5042This hook controls how the @var{named} argument to @code{TARGET_FUNCTION_ARG}
38f8b050
JR
5043is set for varargs and stdarg functions. If this hook returns
5044@code{true}, the @var{named} argument is always true for named
5045arguments, and false for unnamed arguments. If it returns @code{false},
5046but @code{TARGET_PRETEND_OUTGOING_VARARGS_NAMED} returns @code{true},
5047then all arguments are treated as named. Otherwise, all named arguments
5048except the last are treated as named.
5049
5050You need not define this hook if it always returns @code{false}.
5051@end deftypefn
5052
5053@hook TARGET_PRETEND_OUTGOING_VARARGS_NAMED
5054If you need to conditionally change ABIs so that one works with
5055@code{TARGET_SETUP_INCOMING_VARARGS}, but the other works like neither
5056@code{TARGET_SETUP_INCOMING_VARARGS} nor @code{TARGET_STRICT_ARGUMENT_NAMING} was
5057defined, then define this hook to return @code{true} if
5058@code{TARGET_SETUP_INCOMING_VARARGS} is used, @code{false} otherwise.
5059Otherwise, you should not define this hook.
5060@end deftypefn
5061
5062@node Trampolines
5063@section Trampolines for Nested Functions
5064@cindex trampolines for nested functions
5065@cindex nested functions, trampolines for
5066
5067A @dfn{trampoline} is a small piece of code that is created at run time
5068when the address of a nested function is taken. It normally resides on
5069the stack, in the stack frame of the containing function. These macros
5070tell GCC how to generate code to allocate and initialize a
5071trampoline.
5072
5073The instructions in the trampoline must do two things: load a constant
5074address into the static chain register, and jump to the real address of
5075the nested function. On CISC machines such as the m68k, this requires
5076two instructions, a move immediate and a jump. Then the two addresses
5077exist in the trampoline as word-long immediate operands. On RISC
5078machines, it is often necessary to load each address into a register in
5079two parts. Then pieces of each address form separate immediate
5080operands.
5081
5082The code generated to initialize the trampoline must store the variable
5083parts---the static chain value and the function address---into the
5084immediate operands of the instructions. On a CISC machine, this is
5085simply a matter of copying each address to a memory reference at the
5086proper offset from the start of the trampoline. On a RISC machine, it
5087may be necessary to take out pieces of the address and store them
5088separately.
5089
5090@hook TARGET_ASM_TRAMPOLINE_TEMPLATE
5091This hook is called by @code{assemble_trampoline_template} to output,
5092on the stream @var{f}, assembler code for a block of data that contains
5093the constant parts of a trampoline. This code should not include a
5094label---the label is taken care of automatically.
5095
5096If you do not define this hook, it means no template is needed
5097for the target. Do not define this hook on systems where the block move
5098code to copy the trampoline into place would be larger than the code
5099to generate it on the spot.
5100@end deftypefn
5101
5102@defmac TRAMPOLINE_SECTION
5103Return the section into which the trampoline template is to be placed
5104(@pxref{Sections}). The default value is @code{readonly_data_section}.
5105@end defmac
5106
5107@defmac TRAMPOLINE_SIZE
5108A C expression for the size in bytes of the trampoline, as an integer.
5109@end defmac
5110
5111@defmac TRAMPOLINE_ALIGNMENT
5112Alignment required for trampolines, in bits.
5113
5114If you don't define this macro, the value of @code{FUNCTION_ALIGNMENT}
5115is used for aligning trampolines.
5116@end defmac
5117
5118@hook TARGET_TRAMPOLINE_INIT
5119This hook is called to initialize a trampoline.
5120@var{m_tramp} is an RTX for the memory block for the trampoline; @var{fndecl}
5121is the @code{FUNCTION_DECL} for the nested function; @var{static_chain} is an
5122RTX for the static chain value that should be passed to the function
5123when it is called.
5124
5125If the target defines @code{TARGET_ASM_TRAMPOLINE_TEMPLATE}, then the
5126first thing this hook should do is emit a block move into @var{m_tramp}
5127from the memory block returned by @code{assemble_trampoline_template}.
ff2ce160 5128Note that the block move need only cover the constant parts of the
38f8b050
JR
5129trampoline. If the target isolates the variable parts of the trampoline
5130to the end, not all @code{TRAMPOLINE_SIZE} bytes need be copied.
5131
5132If the target requires any other actions, such as flushing caches or
ff2ce160 5133enabling stack execution, these actions should be performed after
38f8b050
JR
5134initializing the trampoline proper.
5135@end deftypefn
5136
5137@hook TARGET_TRAMPOLINE_ADJUST_ADDRESS
5138This hook should perform any machine-specific adjustment in
5139the address of the trampoline. Its argument contains the address of the
5140memory block that was passed to @code{TARGET_TRAMPOLINE_INIT}. In case
5141the address to be used for a function call should be different from the
5142address at which the template was stored, the different address should
5143be returned; otherwise @var{addr} should be returned unchanged.
5144If this hook is not defined, @var{addr} will be used for function calls.
5145@end deftypefn
5146
5147Implementing trampolines is difficult on many machines because they have
5148separate instruction and data caches. Writing into a stack location
5149fails to clear the memory in the instruction cache, so when the program
5150jumps to that location, it executes the old contents.
5151
5152Here are two possible solutions. One is to clear the relevant parts of
5153the instruction cache whenever a trampoline is set up. The other is to
5154make all trampolines identical, by having them jump to a standard
5155subroutine. The former technique makes trampoline execution faster; the
5156latter makes initialization faster.
5157
5158To clear the instruction cache when a trampoline is initialized, define
5159the following macro.
5160
5161@defmac CLEAR_INSN_CACHE (@var{beg}, @var{end})
5162If defined, expands to a C expression clearing the @emph{instruction
5163cache} in the specified interval. The definition of this macro would
5164typically be a series of @code{asm} statements. Both @var{beg} and
5165@var{end} are both pointer expressions.
5166@end defmac
5167
38f8b050
JR
5168To use a standard subroutine, define the following macro. In addition,
5169you must make sure that the instructions in a trampoline fill an entire
5170cache line with identical instructions, or else ensure that the
5171beginning of the trampoline code is always aligned at the same point in
5172its cache line. Look in @file{m68k.h} as a guide.
5173
5174@defmac TRANSFER_FROM_TRAMPOLINE
5175Define this macro if trampolines need a special subroutine to do their
5176work. The macro should expand to a series of @code{asm} statements
5177which will be compiled with GCC@. They go in a library function named
5178@code{__transfer_from_trampoline}.
5179
5180If you need to avoid executing the ordinary prologue code of a compiled
5181C function when you jump to the subroutine, you can do so by placing a
5182special label of your own in the assembler code. Use one @code{asm}
5183statement to generate an assembler label, and another to make the label
5184global. Then trampolines can use that label to jump directly to your
5185special assembler code.
5186@end defmac
5187
5188@node Library Calls
5189@section Implicit Calls to Library Routines
5190@cindex library subroutine names
5191@cindex @file{libgcc.a}
5192
5193@c prevent bad page break with this line
5194Here is an explanation of implicit calls to library routines.
5195
5196@defmac DECLARE_LIBRARY_RENAMES
5197This macro, if defined, should expand to a piece of C code that will get
5198expanded when compiling functions for libgcc.a. It can be used to
5199provide alternate names for GCC's internal library functions if there
5200are ABI-mandated names that the compiler should provide.
5201@end defmac
5202
5203@findex set_optab_libfunc
5204@findex init_one_libfunc
5205@hook TARGET_INIT_LIBFUNCS
5206This hook should declare additional library routines or rename
5207existing ones, using the functions @code{set_optab_libfunc} and
5208@code{init_one_libfunc} defined in @file{optabs.c}.
5209@code{init_optabs} calls this macro after initializing all the normal
5210library routines.
5211
5212The default is to do nothing. Most ports don't need to define this hook.
5213@end deftypefn
5214
cdbf4541
BS
5215@hook TARGET_LIBFUNC_GNU_PREFIX
5216
38f8b050
JR
5217@defmac FLOAT_LIB_COMPARE_RETURNS_BOOL (@var{mode}, @var{comparison})
5218This macro should return @code{true} if the library routine that
5219implements the floating point comparison operator @var{comparison} in
5220mode @var{mode} will return a boolean, and @var{false} if it will
5221return a tristate.
5222
5223GCC's own floating point libraries return tristates from the
5224comparison operators, so the default returns false always. Most ports
5225don't need to define this macro.
5226@end defmac
5227
5228@defmac TARGET_LIB_INT_CMP_BIASED
5229This macro should evaluate to @code{true} if the integer comparison
5230functions (like @code{__cmpdi2}) return 0 to indicate that the first
5231operand is smaller than the second, 1 to indicate that they are equal,
5232and 2 to indicate that the first operand is greater than the second.
5233If this macro evaluates to @code{false} the comparison functions return
5234@minus{}1, 0, and 1 instead of 0, 1, and 2. If the target uses the routines
5235in @file{libgcc.a}, you do not need to define this macro.
5236@end defmac
5237
38f8b050
JR
5238@cindex @code{EDOM}, implicit usage
5239@findex matherr
5240@defmac TARGET_EDOM
5241The value of @code{EDOM} on the target machine, as a C integer constant
5242expression. If you don't define this macro, GCC does not attempt to
5243deposit the value of @code{EDOM} into @code{errno} directly. Look in
5244@file{/usr/include/errno.h} to find the value of @code{EDOM} on your
5245system.
5246
5247If you do not define @code{TARGET_EDOM}, then compiled code reports
5248domain errors by calling the library function and letting it report the
5249error. If mathematical functions on your system use @code{matherr} when
5250there is an error, then you should leave @code{TARGET_EDOM} undefined so
5251that @code{matherr} is used normally.
5252@end defmac
5253
5254@cindex @code{errno}, implicit usage
5255@defmac GEN_ERRNO_RTX
5256Define this macro as a C expression to create an rtl expression that
5257refers to the global ``variable'' @code{errno}. (On certain systems,
5258@code{errno} may not actually be a variable.) If you don't define this
5259macro, a reasonable default is used.
5260@end defmac
5261
5262@cindex C99 math functions, implicit usage
5263@defmac TARGET_C99_FUNCTIONS
5264When this macro is nonzero, GCC will implicitly optimize @code{sin} calls into
5265@code{sinf} and similarly for other functions defined by C99 standard. The
5266default is zero because a number of existing systems lack support for these
5267functions in their runtime so this macro needs to be redefined to one on
5268systems that do support the C99 runtime.
5269@end defmac
5270
5271@cindex sincos math function, implicit usage
5272@defmac TARGET_HAS_SINCOS
5273When this macro is nonzero, GCC will implicitly optimize calls to @code{sin}
5274and @code{cos} with the same argument to a call to @code{sincos}. The
5275default is zero. The target has to provide the following functions:
5276@smallexample
5277void sincos(double x, double *sin, double *cos);
5278void sincosf(float x, float *sin, float *cos);
5279void sincosl(long double x, long double *sin, long double *cos);
5280@end smallexample
5281@end defmac
5282
5283@defmac NEXT_OBJC_RUNTIME
fea3ca91
IS
5284Set this macro to 1 to use the "NeXT" Objective-C message sending conventions
5285by default. This calling convention involves passing the object, the selector
5286and the method arguments all at once to the method-lookup library function.
5287This is the usual setting when targeting Darwin/Mac OS X systems, which have
5288the NeXT runtime installed.
5289
5290If the macro is set to 0, the "GNU" Objective-C message sending convention
5291will be used by default. This convention passes just the object and the
5292selector to the method-lookup function, which returns a pointer to the method.
5293
5294In either case, it remains possible to select code-generation for the alternate
5295scheme, by means of compiler command line switches.
38f8b050
JR
5296@end defmac
5297
5298@node Addressing Modes
5299@section Addressing Modes
5300@cindex addressing modes
5301
5302@c prevent bad page break with this line
5303This is about addressing modes.
5304
5305@defmac HAVE_PRE_INCREMENT
5306@defmacx HAVE_PRE_DECREMENT
5307@defmacx HAVE_POST_INCREMENT
5308@defmacx HAVE_POST_DECREMENT
5309A C expression that is nonzero if the machine supports pre-increment,
5310pre-decrement, post-increment, or post-decrement addressing respectively.
5311@end defmac
5312
5313@defmac HAVE_PRE_MODIFY_DISP
5314@defmacx HAVE_POST_MODIFY_DISP
5315A C expression that is nonzero if the machine supports pre- or
5316post-address side-effect generation involving constants other than
5317the size of the memory operand.
5318@end defmac
5319
5320@defmac HAVE_PRE_MODIFY_REG
5321@defmacx HAVE_POST_MODIFY_REG
5322A C expression that is nonzero if the machine supports pre- or
5323post-address side-effect generation involving a register displacement.
5324@end defmac
5325
5326@defmac CONSTANT_ADDRESS_P (@var{x})
5327A C expression that is 1 if the RTX @var{x} is a constant which
5328is a valid address. On most machines the default definition of
5329@code{(CONSTANT_P (@var{x}) && GET_CODE (@var{x}) != CONST_DOUBLE)}
5330is acceptable, but a few machines are more restrictive as to which
ff2ce160 5331constant addresses are supported.
38f8b050
JR
5332@end defmac
5333
5334@defmac CONSTANT_P (@var{x})
5335@code{CONSTANT_P}, which is defined by target-independent code,
5336accepts integer-values expressions whose values are not explicitly
5337known, such as @code{symbol_ref}, @code{label_ref}, and @code{high}
5338expressions and @code{const} arithmetic expressions, in addition to
5339@code{const_int} and @code{const_double} expressions.
5340@end defmac
5341
5342@defmac MAX_REGS_PER_ADDRESS
5343A number, the maximum number of registers that can appear in a valid
5344memory address. Note that it is up to you to specify a value equal to
5345the maximum number that @code{TARGET_LEGITIMATE_ADDRESS_P} would ever
5346accept.
5347@end defmac
5348
5349@hook TARGET_LEGITIMATE_ADDRESS_P
5350A function that returns whether @var{x} (an RTX) is a legitimate memory
5351address on the target machine for a memory operand of mode @var{mode}.
5352
5353Legitimate addresses are defined in two variants: a strict variant and a
5354non-strict one. The @var{strict} parameter chooses which variant is
5355desired by the caller.
5356
5357The strict variant is used in the reload pass. It must be defined so
5358that any pseudo-register that has not been allocated a hard register is
5359considered a memory reference. This is because in contexts where some
5360kind of register is required, a pseudo-register with no hard register
5361must be rejected. For non-hard registers, the strict variant should look
5362up the @code{reg_renumber} array; it should then proceed using the hard
5363register number in the array, or treat the pseudo as a memory reference
5364if the array holds @code{-1}.
5365
5366The non-strict variant is used in other passes. It must be defined to
5367accept all pseudo-registers in every context where some kind of
5368register is required.
5369
5370Normally, constant addresses which are the sum of a @code{symbol_ref}
5371and an integer are stored inside a @code{const} RTX to mark them as
5372constant. Therefore, there is no need to recognize such sums
5373specifically as legitimate addresses. Normally you would simply
5374recognize any @code{const} as legitimate.
5375
5376Usually @code{PRINT_OPERAND_ADDRESS} is not prepared to handle constant
5377sums that are not marked with @code{const}. It assumes that a naked
5378@code{plus} indicates indexing. If so, then you @emph{must} reject such
5379naked constant sums as illegitimate addresses, so that none of them will
5380be given to @code{PRINT_OPERAND_ADDRESS}.
5381
5382@cindex @code{TARGET_ENCODE_SECTION_INFO} and address validation
5383On some machines, whether a symbolic address is legitimate depends on
5384the section that the address refers to. On these machines, define the
5385target hook @code{TARGET_ENCODE_SECTION_INFO} to store the information
5386into the @code{symbol_ref}, and then check for it here. When you see a
5387@code{const}, you will have to look inside it to find the
5388@code{symbol_ref} in order to determine the section. @xref{Assembler
5389Format}.
5390
5391@cindex @code{GO_IF_LEGITIMATE_ADDRESS}
5392Some ports are still using a deprecated legacy substitute for
5393this hook, the @code{GO_IF_LEGITIMATE_ADDRESS} macro. This macro
5394has this syntax:
5395
5396@example
5397#define GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label})
5398@end example
5399
5400@noindent
5401and should @code{goto @var{label}} if the address @var{x} is a valid
5402address on the target machine for a memory operand of mode @var{mode}.
6f7b223b
PK
5403
5404@findex REG_OK_STRICT
5405Compiler source files that want to use the strict variant of this
5406macro define the macro @code{REG_OK_STRICT}. You should use an
5407@code{#ifdef REG_OK_STRICT} conditional to define the strict variant in
5408that case and the non-strict variant otherwise.
5409
38f8b050
JR
5410Using the hook is usually simpler because it limits the number of
5411files that are recompiled when changes are made.
5412@end deftypefn
5413
5414@defmac TARGET_MEM_CONSTRAINT
5415A single character to be used instead of the default @code{'m'}
5416character for general memory addresses. This defines the constraint
5417letter which matches the memory addresses accepted by
5418@code{TARGET_LEGITIMATE_ADDRESS_P}. Define this macro if you want to
5419support new address formats in your back end without changing the
5420semantics of the @code{'m'} constraint. This is necessary in order to
5421preserve functionality of inline assembly constructs using the
5422@code{'m'} constraint.
5423@end defmac
5424
5425@defmac FIND_BASE_TERM (@var{x})
5426A C expression to determine the base term of address @var{x},
5427or to provide a simplified version of @var{x} from which @file{alias.c}
5428can easily find the base term. This macro is used in only two places:
5429@code{find_base_value} and @code{find_base_term} in @file{alias.c}.
5430
5431It is always safe for this macro to not be defined. It exists so
5432that alias analysis can understand machine-dependent addresses.
5433
5434The typical use of this macro is to handle addresses containing
5435a label_ref or symbol_ref within an UNSPEC@.
5436@end defmac
5437
5438@hook TARGET_LEGITIMIZE_ADDRESS
5439This hook is given an invalid memory address @var{x} for an
5440operand of mode @var{mode} and should try to return a valid memory
5441address.
5442
5443@findex break_out_memory_refs
5444@var{x} will always be the result of a call to @code{break_out_memory_refs},
5445and @var{oldx} will be the operand that was given to that function to produce
5446@var{x}.
5447
5448The code of the hook should not alter the substructure of
5449@var{x}. If it transforms @var{x} into a more legitimate form, it
5450should return the new @var{x}.
5451
f938987f
HPN
5452It is not necessary for this hook to come up with a legitimate address,
5453with the exception of native TLS addresses (@pxref{Emulated TLS}).
5454The compiler has standard ways of doing so in all cases. In fact, if
5455the target supports only emulated TLS, it
38f8b050
JR
5456is safe to omit this hook or make it return @var{x} if it cannot find
5457a valid way to legitimize the address. But often a machine-dependent
5458strategy can generate better code.
5459@end deftypefn
5460
5461@defmac LEGITIMIZE_RELOAD_ADDRESS (@var{x}, @var{mode}, @var{opnum}, @var{type}, @var{ind_levels}, @var{win})
5462A C compound statement that attempts to replace @var{x}, which is an address
5463that needs reloading, with a valid memory address for an operand of mode
5464@var{mode}. @var{win} will be a C statement label elsewhere in the code.
5465It is not necessary to define this macro, but it might be useful for
5466performance reasons.
5467
5468For example, on the i386, it is sometimes possible to use a single
5469reload register instead of two by reloading a sum of two pseudo
5470registers into a register. On the other hand, for number of RISC
5471processors offsets are limited so that often an intermediate address
5472needs to be generated in order to address a stack slot. By defining
5473@code{LEGITIMIZE_RELOAD_ADDRESS} appropriately, the intermediate addresses
5474generated for adjacent some stack slots can be made identical, and thus
5475be shared.
5476
5477@emph{Note}: This macro should be used with caution. It is necessary
5478to know something of how reload works in order to effectively use this,
5479and it is quite easy to produce macros that build in too much knowledge
5480of reload internals.
5481
5482@emph{Note}: This macro must be able to reload an address created by a
5483previous invocation of this macro. If it fails to handle such addresses
5484then the compiler may generate incorrect code or abort.
5485
5486@findex push_reload
5487The macro definition should use @code{push_reload} to indicate parts that
5488need reloading; @var{opnum}, @var{type} and @var{ind_levels} are usually
5489suitable to be passed unaltered to @code{push_reload}.
5490
5491The code generated by this macro must not alter the substructure of
5492@var{x}. If it transforms @var{x} into a more legitimate form, it
5493should assign @var{x} (which will always be a C variable) a new value.
5494This also applies to parts that you change indirectly by calling
5495@code{push_reload}.
5496
5497@findex strict_memory_address_p
5498The macro definition may use @code{strict_memory_address_p} to test if
5499the address has become legitimate.
5500
5501@findex copy_rtx
5502If you want to change only a part of @var{x}, one standard way of doing
5503this is to use @code{copy_rtx}. Note, however, that it unshares only a
5504single level of rtl. Thus, if the part to be changed is not at the
5505top level, you'll need to replace first the top level.
5506It is not necessary for this macro to come up with a legitimate
5507address; but often a machine-dependent strategy can generate better code.
5508@end defmac
5509
5510@hook TARGET_MODE_DEPENDENT_ADDRESS_P
5bfed9a9
GJL
5511This hook returns @code{true} if memory address @var{addr} in address
5512space @var{addrspace} can have
38f8b050
JR
5513different meanings depending on the machine mode of the memory
5514reference it is used for or if the address is valid for some modes
5515but not others.
5516
5517Autoincrement and autodecrement addresses typically have mode-dependent
5518effects because the amount of the increment or decrement is the size
5519of the operand being addressed. Some machines have other mode-dependent
5520addresses. Many RISC machines have no mode-dependent addresses.
5521
5522You may assume that @var{addr} is a valid address for the machine.
5523
5524The default version of this hook returns @code{false}.
5525@end deftypefn
5526
1a627b35
RS
5527@hook TARGET_LEGITIMATE_CONSTANT_P
5528This hook returns true if @var{x} is a legitimate constant for a
5529@var{mode}-mode immediate operand on the target machine. You can assume that
5530@var{x} satisfies @code{CONSTANT_P}, so you need not check this.
5531
5532The default definition returns true.
5533@end deftypefn
38f8b050
JR
5534
5535@hook TARGET_DELEGITIMIZE_ADDRESS
5536This hook is used to undo the possibly obfuscating effects of the
5537@code{LEGITIMIZE_ADDRESS} and @code{LEGITIMIZE_RELOAD_ADDRESS} target
5538macros. Some backend implementations of these macros wrap symbol
5539references inside an @code{UNSPEC} rtx to represent PIC or similar
5540addressing modes. This target hook allows GCC's optimizers to understand
5541the semantics of these opaque @code{UNSPEC}s by converting them back
5542into their original form.
5543@end deftypefn
5544
93bcc8c9
JJ
5545@hook TARGET_CONST_NOT_OK_FOR_DEBUG_P
5546This hook should return true if @var{x} should not be emitted into
5547debug sections.
5548@end deftypefn
5549
38f8b050
JR
5550@hook TARGET_CANNOT_FORCE_CONST_MEM
5551This hook should return true if @var{x} is of a form that cannot (or
fbbf66e7
RS
5552should not) be spilled to the constant pool. @var{mode} is the mode
5553of @var{x}.
5554
5555The default version of this hook returns false.
38f8b050
JR
5556
5557The primary reason to define this hook is to prevent reload from
5558deciding that a non-legitimate constant would be better reloaded
5559from the constant pool instead of spilling and reloading a register
5560holding the constant. This restriction is often true of addresses
5561of TLS symbols for various targets.
5562@end deftypefn
5563
5564@hook TARGET_USE_BLOCKS_FOR_CONSTANT_P
5565This hook should return true if pool entries for constant @var{x} can
5566be placed in an @code{object_block} structure. @var{mode} is the mode
5567of @var{x}.
5568
5569The default version returns false for all constants.
5570@end deftypefn
5571
361a58da
DE
5572@hook TARGET_USE_BLOCKS_FOR_DECL_P
5573This hook should return true if pool entries for @var{decl} should
5574be placed in an @code{object_block} structure.
5575
5576The default version returns true for all decls.
5577@end deftypefn
5578
89356d17 5579@hook TARGET_BUILTIN_RECIPROCAL
38f8b050
JR
5580This hook should return the DECL of a function that implements reciprocal of
5581the builtin function with builtin function code @var{fn}, or
5582@code{NULL_TREE} if such a function is not available. @var{md_fn} is true
5583when @var{fn} is a code of a machine-dependent builtin function. When
5584@var{sqrt} is true, additional optimizations that apply only to the reciprocal
5585of a square root function are performed, and only reciprocals of @code{sqrt}
5586function are valid.
5587@end deftypefn
5588
5589@hook TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
5590This hook should return the DECL of a function @var{f} that given an
5591address @var{addr} as an argument returns a mask @var{m} that can be
5592used to extract from two vectors the relevant data that resides in
5593@var{addr} in case @var{addr} is not properly aligned.
5594
5595The autovectorizer, when vectorizing a load operation from an address
5596@var{addr} that may be unaligned, will generate two vector loads from
5597the two aligned addresses around @var{addr}. It then generates a
5598@code{REALIGN_LOAD} operation to extract the relevant data from the
5599two loaded vectors. The first two arguments to @code{REALIGN_LOAD},
5600@var{v1} and @var{v2}, are the two vectors, each of size @var{VS}, and
5601the third argument, @var{OFF}, defines how the data will be extracted
5602from these two vectors: if @var{OFF} is 0, then the returned vector is
5603@var{v2}; otherwise, the returned vector is composed from the last
5604@var{VS}-@var{OFF} elements of @var{v1} concatenated to the first
5605@var{OFF} elements of @var{v2}.
5606
5607If this hook is defined, the autovectorizer will generate a call
5608to @var{f} (using the DECL tree that this hook returns) and will
5609use the return value of @var{f} as the argument @var{OFF} to
5610@code{REALIGN_LOAD}. Therefore, the mask @var{m} returned by @var{f}
5611should comply with the semantics expected by @code{REALIGN_LOAD}
5612described above.
5613If this hook is not defined, then @var{addr} will be used as
5614the argument @var{OFF} to @code{REALIGN_LOAD}, in which case the low
5615log2(@var{VS}) @minus{} 1 bits of @var{addr} will be considered.
5616@end deftypefn
5617
38f8b050
JR
5618@hook TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
5619Returns cost of different scalar or vector statements for vectorization cost model.
ff2ce160 5620For vector memory operations the cost may depend on type (@var{vectype}) and
720f5239 5621misalignment value (@var{misalign}).
38f8b050
JR
5622@end deftypefn
5623
5624@hook TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE
5625Return true if vector alignment is reachable (by peeling N iterations) for the given type.
5626@end deftypefn
5627
5a3c0068 5628@hook TARGET_VECTORIZE_VEC_PERM_CONST_OK
5dea5b2a 5629Return true if a vector created for @code{vec_perm_const} is valid.
38f8b050
JR
5630@end deftypefn
5631
5632@hook TARGET_VECTORIZE_BUILTIN_CONVERSION
5633This hook should return the DECL of a function that implements conversion of the
5634input vector of type @var{src_type} to type @var{dest_type}.
5635The value of @var{code} is one of the enumerators in @code{enum tree_code} and
5636specifies how the conversion is to be applied
5637(truncation, rounding, etc.).
5638
5639If this hook is defined, the autovectorizer will use the
5640@code{TARGET_VECTORIZE_BUILTIN_CONVERSION} target hook when vectorizing
5641conversion. Otherwise, it will return @code{NULL_TREE}.
5642@end deftypefn
5643
5644@hook TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
5645This hook should return the decl of a function that implements the
5646vectorized variant of the builtin function with builtin function code
5647@var{code} or @code{NULL_TREE} if such a function is not available.
5648The value of @var{fndecl} is the builtin function declaration. The
5649return type of the vectorized function shall be of vector type
5650@var{vec_type_out} and the argument types should be @var{vec_type_in}.
5651@end deftypefn
5652
5653@hook TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT
5654This hook should return true if the target supports misaligned vector
5655store/load of a specific factor denoted in the @var{misalignment}
5656parameter. The vector store/load should be of machine mode @var{mode} and
5657the elements in the vectors should be of type @var{type}. @var{is_packed}
5658parameter is true if the memory access is defined in a packed struct.
5659@end deftypefn
5660
cc4b5170
RG
5661@hook TARGET_VECTORIZE_PREFERRED_SIMD_MODE
5662This hook should return the preferred mode for vectorizing scalar
5663mode @var{mode}. The default is
5664equal to @code{word_mode}, because the vectorizer can do some
26983c22
L
5665transformations even in absence of specialized @acronym{SIMD} hardware.
5666@end deftypefn
5667
767f865f
RG
5668@hook TARGET_VECTORIZE_AUTOVECTORIZE_VECTOR_SIZES
5669This hook should return a mask of sizes that should be iterated over
5670after trying to autovectorize using the vector size derived from the
5671mode returned by @code{TARGET_VECTORIZE_PREFERRED_SIMD_MODE}.
5672The default is zero which means to not iterate over other vector sizes.
5673@end deftypefn
5674
c3e7ee41
BS
5675@hook TARGET_VECTORIZE_INIT_COST
5676
5677@hook TARGET_VECTORIZE_ADD_STMT_COST
5678
5679@hook TARGET_VECTORIZE_FINISH_COST
5680
5681@hook TARGET_VECTORIZE_DESTROY_COST_DATA
5682
0a35513e
AH
5683@hook TARGET_VECTORIZE_BUILTIN_TM_LOAD
5684
5685@hook TARGET_VECTORIZE_BUILTIN_TM_STORE
5686
aec7ae7d
JJ
5687@hook TARGET_VECTORIZE_BUILTIN_GATHER
5688Target builtin that implements vector gather operation. @var{mem_vectype}
5689is the vector type of the load and @var{index_type} is scalar type of
5690the index, scaled by @var{scale}.
5691The default is @code{NULL_TREE} which means to not vectorize gather
5692loads.
5693@end deftypefn
5694
38f8b050
JR
5695@node Anchored Addresses
5696@section Anchored Addresses
5697@cindex anchored addresses
5698@cindex @option{-fsection-anchors}
5699
5700GCC usually addresses every static object as a separate entity.
5701For example, if we have:
5702
5703@smallexample
5704static int a, b, c;
5705int foo (void) @{ return a + b + c; @}
5706@end smallexample
5707
5708the code for @code{foo} will usually calculate three separate symbolic
5709addresses: those of @code{a}, @code{b} and @code{c}. On some targets,
5710it would be better to calculate just one symbolic address and access
5711the three variables relative to it. The equivalent pseudocode would
5712be something like:
5713
5714@smallexample
5715int foo (void)
5716@{
5717 register int *xr = &x;
5718 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
5719@}
5720@end smallexample
5721
5722(which isn't valid C). We refer to shared addresses like @code{x} as
5723``section anchors''. Their use is controlled by @option{-fsection-anchors}.
5724
5725The hooks below describe the target properties that GCC needs to know
5726in order to make effective use of section anchors. It won't use
5727section anchors at all unless either @code{TARGET_MIN_ANCHOR_OFFSET}
5728or @code{TARGET_MAX_ANCHOR_OFFSET} is set to a nonzero value.
5729
5730@hook TARGET_MIN_ANCHOR_OFFSET
5731The minimum offset that should be applied to a section anchor.
5732On most targets, it should be the smallest offset that can be
5733applied to a base register while still giving a legitimate address
5734for every mode. The default value is 0.
5735@end deftypevr
5736
5737@hook TARGET_MAX_ANCHOR_OFFSET
5738Like @code{TARGET_MIN_ANCHOR_OFFSET}, but the maximum (inclusive)
5739offset that should be applied to section anchors. The default
5740value is 0.
5741@end deftypevr
5742
5743@hook TARGET_ASM_OUTPUT_ANCHOR
5744Write the assembly code to define section anchor @var{x}, which is a
5745@code{SYMBOL_REF} for which @samp{SYMBOL_REF_ANCHOR_P (@var{x})} is true.
5746The hook is called with the assembly output position set to the beginning
5747of @code{SYMBOL_REF_BLOCK (@var{x})}.
5748
5749If @code{ASM_OUTPUT_DEF} is available, the hook's default definition uses
5750it to define the symbol as @samp{. + SYMBOL_REF_BLOCK_OFFSET (@var{x})}.
5751If @code{ASM_OUTPUT_DEF} is not available, the hook's default definition
5752is @code{NULL}, which disables the use of section anchors altogether.
5753@end deftypefn
5754
5755@hook TARGET_USE_ANCHORS_FOR_SYMBOL_P
5756Return true if GCC should attempt to use anchors to access @code{SYMBOL_REF}
5757@var{x}. You can assume @samp{SYMBOL_REF_HAS_BLOCK_INFO_P (@var{x})} and
5758@samp{!SYMBOL_REF_ANCHOR_P (@var{x})}.
5759
5760The default version is correct for most targets, but you might need to
5761intercept this hook to handle things like target-specific attributes
5762or target-specific sections.
5763@end deftypefn
5764
5765@node Condition Code
5766@section Condition Code Status
5767@cindex condition code status
5768
5769The macros in this section can be split in two families, according to the
5770two ways of representing condition codes in GCC.
5771
5772The first representation is the so called @code{(cc0)} representation
5773(@pxref{Jump Patterns}), where all instructions can have an implicit
5774clobber of the condition codes. The second is the condition code
5775register representation, which provides better schedulability for
5776architectures that do have a condition code register, but on which
5777most instructions do not affect it. The latter category includes
5778most RISC machines.
5779
5780The implicit clobbering poses a strong restriction on the placement of
5781the definition and use of the condition code, which need to be in adjacent
5782insns for machines using @code{(cc0)}. This can prevent important
5783optimizations on some machines. For example, on the IBM RS/6000, there
5784is a delay for taken branches unless the condition code register is set
5785three instructions earlier than the conditional branch. The instruction
5786scheduler cannot perform this optimization if it is not permitted to
5787separate the definition and use of the condition code register.
5788
5789For this reason, it is possible and suggested to use a register to
5790represent the condition code for new ports. If there is a specific
5791condition code register in the machine, use a hard register. If the
5792condition code or comparison result can be placed in any general register,
5793or if there are multiple condition registers, use a pseudo register.
5794Registers used to store the condition code value will usually have a mode
5795that is in class @code{MODE_CC}.
5796
5797Alternatively, you can use @code{BImode} if the comparison operator is
5798specified already in the compare instruction. In this case, you are not
5799interested in most macros in this section.
5800
5801@menu
5802* CC0 Condition Codes:: Old style representation of condition codes.
5803* MODE_CC Condition Codes:: Modern representation of condition codes.
ac7eb5c6 5804* Cond Exec Macros:: Macros to control conditional execution.
38f8b050
JR
5805@end menu
5806
5807@node CC0 Condition Codes
5808@subsection Representation of condition codes using @code{(cc0)}
5809@findex cc0
5810
5811@findex cc_status
5812The file @file{conditions.h} defines a variable @code{cc_status} to
5813describe how the condition code was computed (in case the interpretation of
5814the condition code depends on the instruction that it was set by). This
5815variable contains the RTL expressions on which the condition code is
5816currently based, and several standard flags.
5817
5818Sometimes additional machine-specific flags must be defined in the machine
5819description header file. It can also add additional machine-specific
5820information by defining @code{CC_STATUS_MDEP}.
5821
5822@defmac CC_STATUS_MDEP
5823C code for a data type which is used for declaring the @code{mdep}
5824component of @code{cc_status}. It defaults to @code{int}.
5825
5826This macro is not used on machines that do not use @code{cc0}.
5827@end defmac
5828
5829@defmac CC_STATUS_MDEP_INIT
5830A C expression to initialize the @code{mdep} field to ``empty''.
5831The default definition does nothing, since most machines don't use
5832the field anyway. If you want to use the field, you should probably
5833define this macro to initialize it.
5834
5835This macro is not used on machines that do not use @code{cc0}.
5836@end defmac
5837
5838@defmac NOTICE_UPDATE_CC (@var{exp}, @var{insn})
5839A C compound statement to set the components of @code{cc_status}
5840appropriately for an insn @var{insn} whose body is @var{exp}. It is
5841this macro's responsibility to recognize insns that set the condition
5842code as a byproduct of other activity as well as those that explicitly
5843set @code{(cc0)}.
5844
5845This macro is not used on machines that do not use @code{cc0}.
5846
5847If there are insns that do not set the condition code but do alter
5848other machine registers, this macro must check to see whether they
5849invalidate the expressions that the condition code is recorded as
5850reflecting. For example, on the 68000, insns that store in address
5851registers do not set the condition code, which means that usually
5852@code{NOTICE_UPDATE_CC} can leave @code{cc_status} unaltered for such
5853insns. But suppose that the previous insn set the condition code
5854based on location @samp{a4@@(102)} and the current insn stores a new
5855value in @samp{a4}. Although the condition code is not changed by
5856this, it will no longer be true that it reflects the contents of
5857@samp{a4@@(102)}. Therefore, @code{NOTICE_UPDATE_CC} must alter
5858@code{cc_status} in this case to say that nothing is known about the
5859condition code value.
5860
5861The definition of @code{NOTICE_UPDATE_CC} must be prepared to deal
5862with the results of peephole optimization: insns whose patterns are
5863@code{parallel} RTXs containing various @code{reg}, @code{mem} or
5864constants which are just the operands. The RTL structure of these
5865insns is not sufficient to indicate what the insns actually do. What
5866@code{NOTICE_UPDATE_CC} should do when it sees one is just to run
5867@code{CC_STATUS_INIT}.
5868
5869A possible definition of @code{NOTICE_UPDATE_CC} is to call a function
5870that looks at an attribute (@pxref{Insn Attributes}) named, for example,
5871@samp{cc}. This avoids having detailed information about patterns in
5872two places, the @file{md} file and in @code{NOTICE_UPDATE_CC}.
5873@end defmac
5874
5875@node MODE_CC Condition Codes
5876@subsection Representation of condition codes using registers
5877@findex CCmode
5878@findex MODE_CC
5879
5880@defmac SELECT_CC_MODE (@var{op}, @var{x}, @var{y})
5881On many machines, the condition code may be produced by other instructions
5882than compares, for example the branch can use directly the condition
5883code set by a subtract instruction. However, on some machines
5884when the condition code is set this way some bits (such as the overflow
5885bit) are not set in the same way as a test instruction, so that a different
5886branch instruction must be used for some conditional branches. When
5887this happens, use the machine mode of the condition code register to
5888record different formats of the condition code register. Modes can
5889also be used to record which compare instruction (e.g. a signed or an
5890unsigned comparison) produced the condition codes.
5891
5892If other modes than @code{CCmode} are required, add them to
5893@file{@var{machine}-modes.def} and define @code{SELECT_CC_MODE} to choose
5894a mode given an operand of a compare. This is needed because the modes
5895have to be chosen not only during RTL generation but also, for example,
5896by instruction combination. The result of @code{SELECT_CC_MODE} should
5897be consistent with the mode used in the patterns; for example to support
5898the case of the add on the SPARC discussed above, we have the pattern
5899
5900@smallexample
5901(define_insn ""
5902 [(set (reg:CC_NOOV 0)
5903 (compare:CC_NOOV
5904 (plus:SI (match_operand:SI 0 "register_operand" "%r")
5905 (match_operand:SI 1 "arith_operand" "rI"))
5906 (const_int 0)))]
5907 ""
5908 "@dots{}")
5909@end smallexample
5910
5911@noindent
5912together with a @code{SELECT_CC_MODE} that returns @code{CC_NOOVmode}
5913for comparisons whose argument is a @code{plus}:
5914
5915@smallexample
5916#define SELECT_CC_MODE(OP,X,Y) \
5917 (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
5918 ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode) \
5919 : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS \
5920 || GET_CODE (X) == NEG) \
5921 ? CC_NOOVmode : CCmode))
5922@end smallexample
5923
5924Another reason to use modes is to retain information on which operands
5925were used by the comparison; see @code{REVERSIBLE_CC_MODE} later in
5926this section.
5927
5928You should define this macro if and only if you define extra CC modes
5929in @file{@var{machine}-modes.def}.
5930@end defmac
5931
c354951b 5932@hook TARGET_CANONICALIZE_COMPARISON (@var{code}, @var{op0}, @var{op1}, @var{op0_preserve_value})
38f8b050
JR
5933On some machines not all possible comparisons are defined, but you can
5934convert an invalid comparison into a valid one. For example, the Alpha
5935does not have a @code{GT} comparison, but you can use an @code{LT}
5936comparison instead and swap the order of the operands.
5937
c354951b
AK
5938On such machines, implement this hook to do any required conversions.
5939@var{code} is the initial comparison code and @var{op0} and @var{op1}
5940are the left and right operands of the comparison, respectively. If
5941@var{op0_preserve_value} is @code{true} the implementation is not
5942allowed to change the value of @var{op0} since the value might be used
5943in RTXs which aren't comparisons. E.g. the implementation is not
5944allowed to swap operands in that case.
38f8b050
JR
5945
5946GCC will not assume that the comparison resulting from this macro is
5947valid but will see if the resulting insn matches a pattern in the
5948@file{md} file.
5949
c354951b
AK
5950You need not to implement this hook if it would never change the
5951comparison code or operands.
5952@end deftypefn
38f8b050
JR
5953
5954@defmac REVERSIBLE_CC_MODE (@var{mode})
5955A C expression whose value is one if it is always safe to reverse a
5956comparison whose mode is @var{mode}. If @code{SELECT_CC_MODE}
5957can ever return @var{mode} for a floating-point inequality comparison,
5958then @code{REVERSIBLE_CC_MODE (@var{mode})} must be zero.
5959
5960You need not define this macro if it would always returns zero or if the
5961floating-point format is anything other than @code{IEEE_FLOAT_FORMAT}.
5962For example, here is the definition used on the SPARC, where floating-point
5963inequality comparisons are always given @code{CCFPEmode}:
5964
5965@smallexample
5966#define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode)
5967@end smallexample
5968@end defmac
5969
5970@defmac REVERSE_CONDITION (@var{code}, @var{mode})
5971A C expression whose value is reversed condition code of the @var{code} for
5972comparison done in CC_MODE @var{mode}. The macro is used only in case
5973@code{REVERSIBLE_CC_MODE (@var{mode})} is nonzero. Define this macro in case
5974machine has some non-standard way how to reverse certain conditionals. For
5975instance in case all floating point conditions are non-trapping, compiler may
5976freely convert unordered compares to ordered one. Then definition may look
5977like:
5978
5979@smallexample
5980#define REVERSE_CONDITION(CODE, MODE) \
5981 ((MODE) != CCFPmode ? reverse_condition (CODE) \
5982 : reverse_condition_maybe_unordered (CODE))
5983@end smallexample
5984@end defmac
5985
5986@hook TARGET_FIXED_CONDITION_CODE_REGS
5987On targets which do not use @code{(cc0)}, and which use a hard
5988register rather than a pseudo-register to hold condition codes, the
5989regular CSE passes are often not able to identify cases in which the
5990hard register is set to a common value. Use this hook to enable a
5991small pass which optimizes such cases. This hook should return true
5992to enable this pass, and it should set the integers to which its
5993arguments point to the hard register numbers used for condition codes.
5994When there is only one such register, as is true on most systems, the
5995integer pointed to by @var{p2} should be set to
5996@code{INVALID_REGNUM}.
5997
5998The default version of this hook returns false.
5999@end deftypefn
6000
6001@hook TARGET_CC_MODES_COMPATIBLE
6002On targets which use multiple condition code modes in class
6003@code{MODE_CC}, it is sometimes the case that a comparison can be
6004validly done in more than one mode. On such a system, define this
6005target hook to take two mode arguments and to return a mode in which
6006both comparisons may be validly done. If there is no such mode,
6007return @code{VOIDmode}.
6008
6009The default version of this hook checks whether the modes are the
6010same. If they are, it returns that mode. If they are different, it
6011returns @code{VOIDmode}.
6012@end deftypefn
6013
ac7eb5c6 6014@node Cond Exec Macros
38f8b050
JR
6015@subsection Macros to control conditional execution
6016@findex conditional execution
6017@findex predication
6018
6019There is one macro that may need to be defined for targets
6020supporting conditional execution, independent of how they
6021represent conditional branches.
6022
38f8b050
JR
6023@node Costs
6024@section Describing Relative Costs of Operations
6025@cindex costs of instructions
6026@cindex relative costs
6027@cindex speed of instructions
6028
6029These macros let you describe the relative speed of various operations
6030on the target machine.
6031
6032@defmac REGISTER_MOVE_COST (@var{mode}, @var{from}, @var{to})
6033A C expression for the cost of moving data of mode @var{mode} from a
6034register in class @var{from} to one in class @var{to}. The classes are
6035expressed using the enumeration values such as @code{GENERAL_REGS}. A
6036value of 2 is the default; other values are interpreted relative to
6037that.
6038
6039It is not required that the cost always equal 2 when @var{from} is the
6040same as @var{to}; on some machines it is expensive to move between
6041registers if they are not general registers.
6042
6043If reload sees an insn consisting of a single @code{set} between two
6044hard registers, and if @code{REGISTER_MOVE_COST} applied to their
6045classes returns a value of 2, reload does not check to ensure that the
6046constraints of the insn are met. Setting a cost of other than 2 will
6047allow reload to verify that the constraints are met. You should do this
6048if the @samp{mov@var{m}} pattern's constraints do not allow such copying.
6049
6050These macros are obsolete, new ports should use the target hook
6051@code{TARGET_REGISTER_MOVE_COST} instead.
6052@end defmac
6053
6054@hook TARGET_REGISTER_MOVE_COST
6055This target hook should return the cost of moving data of mode @var{mode}
6056from a register in class @var{from} to one in class @var{to}. The classes
6057are expressed using the enumeration values such as @code{GENERAL_REGS}.
6058A value of 2 is the default; other values are interpreted relative to
6059that.
6060
6061It is not required that the cost always equal 2 when @var{from} is the
6062same as @var{to}; on some machines it is expensive to move between
6063registers if they are not general registers.
6064
6065If reload sees an insn consisting of a single @code{set} between two
6066hard registers, and if @code{TARGET_REGISTER_MOVE_COST} applied to their
6067classes returns a value of 2, reload does not check to ensure that the
6068constraints of the insn are met. Setting a cost of other than 2 will
6069allow reload to verify that the constraints are met. You should do this
6070if the @samp{mov@var{m}} pattern's constraints do not allow such copying.
6071
6072The default version of this function returns 2.
6073@end deftypefn
6074
6075@defmac MEMORY_MOVE_COST (@var{mode}, @var{class}, @var{in})
6076A C expression for the cost of moving data of mode @var{mode} between a
6077register of class @var{class} and memory; @var{in} is zero if the value
6078is to be written to memory, nonzero if it is to be read in. This cost
6079is relative to those in @code{REGISTER_MOVE_COST}. If moving between
6080registers and memory is more expensive than between two registers, you
6081should define this macro to express the relative cost.
6082
6083If you do not define this macro, GCC uses a default cost of 4 plus
6084the cost of copying via a secondary reload register, if one is
6085needed. If your machine requires a secondary reload register to copy
6086between memory and a register of @var{class} but the reload mechanism is
6087more complex than copying via an intermediate, define this macro to
6088reflect the actual cost of the move.
6089
6090GCC defines the function @code{memory_move_secondary_cost} if
6091secondary reloads are needed. It computes the costs due to copying via
6092a secondary register. If your machine copies from memory using a
6093secondary register in the conventional way but the default base value of
60944 is not correct for your machine, define this macro to add some other
6095value to the result of that function. The arguments to that function
6096are the same as to this macro.
6097
6098These macros are obsolete, new ports should use the target hook
6099@code{TARGET_MEMORY_MOVE_COST} instead.
6100@end defmac
6101
911852ff 6102@hook TARGET_MEMORY_MOVE_COST
38f8b050 6103This target hook should return the cost of moving data of mode @var{mode}
911852ff 6104between a register of class @var{rclass} and memory; @var{in} is @code{false}
38f8b050
JR
6105if the value is to be written to memory, @code{true} if it is to be read in.
6106This cost is relative to those in @code{TARGET_REGISTER_MOVE_COST}.
6107If moving between registers and memory is more expensive than between two
6108registers, you should add this target hook to express the relative cost.
6109
6110If you do not add this target hook, GCC uses a default cost of 4 plus
6111the cost of copying via a secondary reload register, if one is
6112needed. If your machine requires a secondary reload register to copy
911852ff 6113between memory and a register of @var{rclass} but the reload mechanism is
38f8b050
JR
6114more complex than copying via an intermediate, use this target hook to
6115reflect the actual cost of the move.
6116
6117GCC defines the function @code{memory_move_secondary_cost} if
6118secondary reloads are needed. It computes the costs due to copying via
6119a secondary register. If your machine copies from memory using a
6120secondary register in the conventional way but the default base value of
61214 is not correct for your machine, use this target hook to add some other
6122value to the result of that function. The arguments to that function
6123are the same as to this target hook.
6124@end deftypefn
6125
6126@defmac BRANCH_COST (@var{speed_p}, @var{predictable_p})
525d13b0
MS
6127A C expression for the cost of a branch instruction. A value of 1 is
6128the default; other values are interpreted relative to that. Parameter
6129@var{speed_p} is true when the branch in question should be optimized
6130for speed. When it is false, @code{BRANCH_COST} should return a value
6131optimal for code size rather than performance. @var{predictable_p} is
6132true for well-predicted branches. On many architectures the
6133@code{BRANCH_COST} can be reduced then.
38f8b050
JR
6134@end defmac
6135
6136Here are additional macros which do not specify precise relative costs,
6137but only that certain actions are more expensive than GCC would
6138ordinarily expect.
6139
6140@defmac SLOW_BYTE_ACCESS
6141Define this macro as a C expression which is nonzero if accessing less
6142than a word of memory (i.e.@: a @code{char} or a @code{short}) is no
6143faster than accessing a word of memory, i.e., if such access
6144require more than one instruction or if there is no difference in cost
6145between byte and (aligned) word loads.
6146
6147When this macro is not defined, the compiler will access a field by
6148finding the smallest containing object; when it is defined, a fullword
6149load will be used if alignment permits. Unless bytes accesses are
6150faster than word accesses, using word accesses is preferable since it
6151may eliminate subsequent memory access if subsequent accesses occur to
6152other fields in the same word of the structure, but to different bytes.
6153@end defmac
6154
6155@defmac SLOW_UNALIGNED_ACCESS (@var{mode}, @var{alignment})
6156Define this macro to be the value 1 if memory accesses described by the
6157@var{mode} and @var{alignment} parameters have a cost many times greater
6158than aligned accesses, for example if they are emulated in a trap
6159handler.
6160
6161When this macro is nonzero, the compiler will act as if
6162@code{STRICT_ALIGNMENT} were nonzero when generating code for block
6163moves. This can cause significantly more instructions to be produced.
6164Therefore, do not set this macro nonzero if unaligned accesses only add a
6165cycle or two to the time for a memory access.
6166
6167If the value of this macro is always zero, it need not be defined. If
6168this macro is defined, it should produce a nonzero value when
6169@code{STRICT_ALIGNMENT} is nonzero.
6170@end defmac
6171
6172@defmac MOVE_RATIO (@var{speed})
6173The threshold of number of scalar memory-to-memory move insns, @emph{below}
6174which a sequence of insns should be generated instead of a
6175string move insn or a library call. Increasing the value will always
6176make code faster, but eventually incurs high cost in increased code size.
6177
6178Note that on machines where the corresponding move insn is a
6179@code{define_expand} that emits a sequence of insns, this macro counts
6180the number of such sequences.
6181
6182The parameter @var{speed} is true if the code is currently being
6183optimized for speed rather than size.
6184
6185If you don't define this, a reasonable default is used.
6186@end defmac
6187
6188@defmac MOVE_BY_PIECES_P (@var{size}, @var{alignment})
6189A C expression used to determine whether @code{move_by_pieces} will be used to
6190copy a chunk of memory, or whether some other block move mechanism
6191will be used. Defaults to 1 if @code{move_by_pieces_ninsns} returns less
6192than @code{MOVE_RATIO}.
6193@end defmac
6194
6195@defmac MOVE_MAX_PIECES
6196A C expression used by @code{move_by_pieces} to determine the largest unit
6197a load or store used to copy memory is. Defaults to @code{MOVE_MAX}.
6198@end defmac
6199
6200@defmac CLEAR_RATIO (@var{speed})
6201The threshold of number of scalar move insns, @emph{below} which a sequence
6202of insns should be generated to clear memory instead of a string clear insn
6203or a library call. Increasing the value will always make code faster, but
6204eventually incurs high cost in increased code size.
6205
6206The parameter @var{speed} is true if the code is currently being
6207optimized for speed rather than size.
6208
6209If you don't define this, a reasonable default is used.
6210@end defmac
6211
6212@defmac CLEAR_BY_PIECES_P (@var{size}, @var{alignment})
6213A C expression used to determine whether @code{clear_by_pieces} will be used
6214to clear a chunk of memory, or whether some other block clear mechanism
6215will be used. Defaults to 1 if @code{move_by_pieces_ninsns} returns less
6216than @code{CLEAR_RATIO}.
6217@end defmac
6218
6219@defmac SET_RATIO (@var{speed})
6220The threshold of number of scalar move insns, @emph{below} which a sequence
6221of insns should be generated to set memory to a constant value, instead of
ff2ce160 6222a block set insn or a library call.
38f8b050
JR
6223Increasing the value will always make code faster, but
6224eventually incurs high cost in increased code size.
6225
6226The parameter @var{speed} is true if the code is currently being
6227optimized for speed rather than size.
6228
6229If you don't define this, it defaults to the value of @code{MOVE_RATIO}.
6230@end defmac
6231
6232@defmac SET_BY_PIECES_P (@var{size}, @var{alignment})
6233A C expression used to determine whether @code{store_by_pieces} will be
ff2ce160
MS
6234used to set a chunk of memory to a constant value, or whether some
6235other mechanism will be used. Used by @code{__builtin_memset} when
38f8b050
JR
6236storing values other than constant zero.
6237Defaults to 1 if @code{move_by_pieces_ninsns} returns less
6238than @code{SET_RATIO}.
6239@end defmac
6240
6241@defmac STORE_BY_PIECES_P (@var{size}, @var{alignment})
6242A C expression used to determine whether @code{store_by_pieces} will be
6243used to set a chunk of memory to a constant string value, or whether some
6244other mechanism will be used. Used by @code{__builtin_strcpy} when
6245called with a constant source string.
6246Defaults to 1 if @code{move_by_pieces_ninsns} returns less
6247than @code{MOVE_RATIO}.
6248@end defmac
6249
6250@defmac USE_LOAD_POST_INCREMENT (@var{mode})
6251A C expression used to determine whether a load postincrement is a good
6252thing to use for a given mode. Defaults to the value of
6253@code{HAVE_POST_INCREMENT}.
6254@end defmac
6255
6256@defmac USE_LOAD_POST_DECREMENT (@var{mode})
6257A C expression used to determine whether a load postdecrement is a good
6258thing to use for a given mode. Defaults to the value of
6259@code{HAVE_POST_DECREMENT}.
6260@end defmac
6261
6262@defmac USE_LOAD_PRE_INCREMENT (@var{mode})
6263A C expression used to determine whether a load preincrement is a good
6264thing to use for a given mode. Defaults to the value of
6265@code{HAVE_PRE_INCREMENT}.
6266@end defmac
6267
6268@defmac USE_LOAD_PRE_DECREMENT (@var{mode})
6269A C expression used to determine whether a load predecrement is a good
6270thing to use for a given mode. Defaults to the value of
6271@code{HAVE_PRE_DECREMENT}.
6272@end defmac
6273
6274@defmac USE_STORE_POST_INCREMENT (@var{mode})
6275A C expression used to determine whether a store postincrement is a good
6276thing to use for a given mode. Defaults to the value of
6277@code{HAVE_POST_INCREMENT}.
6278@end defmac
6279
6280@defmac USE_STORE_POST_DECREMENT (@var{mode})
6281A C expression used to determine whether a store postdecrement is a good
6282thing to use for a given mode. Defaults to the value of
6283@code{HAVE_POST_DECREMENT}.
6284@end defmac
6285
6286@defmac USE_STORE_PRE_INCREMENT (@var{mode})
6287This macro is used to determine whether a store preincrement is a good
6288thing to use for a given mode. Defaults to the value of
6289@code{HAVE_PRE_INCREMENT}.
6290@end defmac
6291
6292@defmac USE_STORE_PRE_DECREMENT (@var{mode})
6293This macro is used to determine whether a store predecrement is a good
6294thing to use for a given mode. Defaults to the value of
6295@code{HAVE_PRE_DECREMENT}.
6296@end defmac
6297
6298@defmac NO_FUNCTION_CSE
6299Define this macro if it is as good or better to call a constant
6300function address than to call an address kept in a register.
6301@end defmac
6302
a8d56c30
SB
6303@defmac LOGICAL_OP_NON_SHORT_CIRCUIT
6304Define this macro if a non-short-circuit operation produced by
6305@samp{fold_range_test ()} is optimal. This macro defaults to true if
6306@code{BRANCH_COST} is greater than or equal to the value 2.
6307@end defmac
6308
38f8b050
JR
6309@hook TARGET_RTX_COSTS
6310This target hook describes the relative costs of RTL expressions.
6311
6312The cost may depend on the precise form of the expression, which is
68f932c4
RS
6313available for examination in @var{x}, and the fact that @var{x} appears
6314as operand @var{opno} of an expression with rtx code @var{outer_code}.
6315That is, the hook can assume that there is some rtx @var{y} such
6316that @samp{GET_CODE (@var{y}) == @var{outer_code}} and such that
6317either (a) @samp{XEXP (@var{y}, @var{opno}) == @var{x}} or
6318(b) @samp{XVEC (@var{y}, @var{opno})} contains @var{x}.
6319
6320@var{code} is @var{x}'s expression code---redundant, since it can be
6321obtained with @code{GET_CODE (@var{x})}.
38f8b050
JR
6322
6323In implementing this hook, you can use the construct
6324@code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast
6325instructions.
6326
6327On entry to the hook, @code{*@var{total}} contains a default estimate
6328for the cost of the expression. The hook should modify this value as
6329necessary. Traditionally, the default costs are @code{COSTS_N_INSNS (5)}
6330for multiplications, @code{COSTS_N_INSNS (7)} for division and modulus
6331operations, and @code{COSTS_N_INSNS (1)} for all other operations.
6332
6333When optimizing for code size, i.e.@: when @code{speed} is
6334false, this target hook should be used to estimate the relative
6335size cost of an expression, again relative to @code{COSTS_N_INSNS}.
6336
6337The hook returns true when all subexpressions of @var{x} have been
6338processed, and false when @code{rtx_cost} should recurse.
6339@end deftypefn
6340
6341@hook TARGET_ADDRESS_COST
6342This hook computes the cost of an addressing mode that contains
6343@var{address}. If not defined, the cost is computed from
6344the @var{address} expression and the @code{TARGET_RTX_COST} hook.
6345
6346For most CISC machines, the default cost is a good approximation of the
6347true cost of the addressing mode. However, on RISC machines, all
6348instructions normally have the same length and execution time. Hence
6349all addresses will have equal costs.
6350
6351In cases where more than one form of an address is known, the form with
6352the lowest cost will be used. If multiple forms have the same, lowest,
6353cost, the one that is the most complex will be used.
6354
6355For example, suppose an address that is equal to the sum of a register
6356and a constant is used twice in the same basic block. When this macro
6357is not defined, the address will be computed in a register and memory
6358references will be indirect through that register. On machines where
6359the cost of the addressing mode containing the sum is no higher than
6360that of a simple indirect reference, this will produce an additional
6361instruction and possibly require an additional register. Proper
6362specification of this macro eliminates this overhead for such machines.
6363
6364This hook is never called with an invalid address.
6365
6366On machines where an address involving more than one register is as
6367cheap as an address computation involving only one register, defining
6368@code{TARGET_ADDRESS_COST} to reflect this can cause two registers to
6369be live over a region of code where only one would have been if
6370@code{TARGET_ADDRESS_COST} were not defined in that manner. This effect
6371should be considered in the definition of this macro. Equivalent costs
6372should probably only be given to addresses with different numbers of
6373registers on machines with lots of registers.
6374@end deftypefn
6375
6376@node Scheduling
6377@section Adjusting the Instruction Scheduler
6378
6379The instruction scheduler may need a fair amount of machine-specific
6380adjustment in order to produce good code. GCC provides several target
6381hooks for this purpose. It is usually enough to define just a few of
6382them: try the first ones in this list first.
6383
6384@hook TARGET_SCHED_ISSUE_RATE
6385This hook returns the maximum number of instructions that can ever
6386issue at the same time on the target machine. The default is one.
6387Although the insn scheduler can define itself the possibility of issue
6388an insn on the same cycle, the value can serve as an additional
6389constraint to issue insns on the same simulated processor cycle (see
6390hooks @samp{TARGET_SCHED_REORDER} and @samp{TARGET_SCHED_REORDER2}).
6391This value must be constant over the entire compilation. If you need
6392it to vary depending on what the instructions are, you must use
6393@samp{TARGET_SCHED_VARIABLE_ISSUE}.
6394@end deftypefn
6395
6396@hook TARGET_SCHED_VARIABLE_ISSUE
6397This hook is executed by the scheduler after it has scheduled an insn
6398from the ready list. It should return the number of insns which can
6399still be issued in the current cycle. The default is
6400@samp{@w{@var{more} - 1}} for insns other than @code{CLOBBER} and
6401@code{USE}, which normally are not counted against the issue rate.
6402You should define this hook if some insns take more machine resources
6403than others, so that fewer insns can follow them in the same cycle.
6404@var{file} is either a null pointer, or a stdio stream to write any
6405debug output to. @var{verbose} is the verbose level provided by
6406@option{-fsched-verbose-@var{n}}. @var{insn} is the instruction that
6407was scheduled.
6408@end deftypefn
6409
6410@hook TARGET_SCHED_ADJUST_COST
6411This function corrects the value of @var{cost} based on the
6412relationship between @var{insn} and @var{dep_insn} through the
6413dependence @var{link}. It should return the new value. The default
6414is to make no adjustment to @var{cost}. This can be used for example
6415to specify to the scheduler using the traditional pipeline description
6416that an output- or anti-dependence does not incur the same cost as a
6417data-dependence. If the scheduler using the automaton based pipeline
6418description, the cost of anti-dependence is zero and the cost of
6419output-dependence is maximum of one and the difference of latency
6420times of the first and the second insns. If these values are not
6421acceptable, you could use the hook to modify them too. See also
6422@pxref{Processor pipeline description}.
6423@end deftypefn
6424
6425@hook TARGET_SCHED_ADJUST_PRIORITY
6426This hook adjusts the integer scheduling priority @var{priority} of
6427@var{insn}. It should return the new priority. Increase the priority to
6428execute @var{insn} earlier, reduce the priority to execute @var{insn}
6429later. Do not define this hook if you do not need to adjust the
6430scheduling priorities of insns.
6431@end deftypefn
6432
6433@hook TARGET_SCHED_REORDER
6434This hook is executed by the scheduler after it has scheduled the ready
6435list, to allow the machine description to reorder it (for example to
6436combine two small instructions together on @samp{VLIW} machines).
6437@var{file} is either a null pointer, or a stdio stream to write any
6438debug output to. @var{verbose} is the verbose level provided by
6439@option{-fsched-verbose-@var{n}}. @var{ready} is a pointer to the ready
6440list of instructions that are ready to be scheduled. @var{n_readyp} is
6441a pointer to the number of elements in the ready list. The scheduler
6442reads the ready list in reverse order, starting with
6443@var{ready}[@var{*n_readyp} @minus{} 1] and going to @var{ready}[0]. @var{clock}
6444is the timer tick of the scheduler. You may modify the ready list and
6445the number of ready insns. The return value is the number of insns that
6446can issue this cycle; normally this is just @code{issue_rate}. See also
6447@samp{TARGET_SCHED_REORDER2}.
6448@end deftypefn
6449
6450@hook TARGET_SCHED_REORDER2
6451Like @samp{TARGET_SCHED_REORDER}, but called at a different time. That
6452function is called whenever the scheduler starts a new cycle. This one
6453is called once per iteration over a cycle, immediately after
6454@samp{TARGET_SCHED_VARIABLE_ISSUE}; it can reorder the ready list and
6455return the number of insns to be scheduled in the same cycle. Defining
6456this hook can be useful if there are frequent situations where
6457scheduling one insn causes other insns to become ready in the same
6458cycle. These other insns can then be taken into account properly.
6459@end deftypefn
6460
6461@hook TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK
6462This hook is called after evaluation forward dependencies of insns in
6463chain given by two parameter values (@var{head} and @var{tail}
6464correspondingly) but before insns scheduling of the insn chain. For
6465example, it can be used for better insn classification if it requires
6466analysis of dependencies. This hook can use backward and forward
6467dependencies of the insn scheduler because they are already
6468calculated.
6469@end deftypefn
6470
6471@hook TARGET_SCHED_INIT
6472This hook is executed by the scheduler at the beginning of each block of
6473instructions that are to be scheduled. @var{file} is either a null
6474pointer, or a stdio stream to write any debug output to. @var{verbose}
6475is the verbose level provided by @option{-fsched-verbose-@var{n}}.
6476@var{max_ready} is the maximum number of insns in the current scheduling
6477region that can be live at the same time. This can be used to allocate
6478scratch space if it is needed, e.g.@: by @samp{TARGET_SCHED_REORDER}.
6479@end deftypefn
6480
6481@hook TARGET_SCHED_FINISH
6482This hook is executed by the scheduler at the end of each block of
6483instructions that are to be scheduled. It can be used to perform
6484cleanup of any actions done by the other scheduling hooks. @var{file}
6485is either a null pointer, or a stdio stream to write any debug output
6486to. @var{verbose} is the verbose level provided by
6487@option{-fsched-verbose-@var{n}}.
6488@end deftypefn
6489
6490@hook TARGET_SCHED_INIT_GLOBAL
6491This hook is executed by the scheduler after function level initializations.
6492@var{file} is either a null pointer, or a stdio stream to write any debug output to.
6493@var{verbose} is the verbose level provided by @option{-fsched-verbose-@var{n}}.
6494@var{old_max_uid} is the maximum insn uid when scheduling begins.
6495@end deftypefn
6496
6497@hook TARGET_SCHED_FINISH_GLOBAL
6498This is the cleanup hook corresponding to @code{TARGET_SCHED_INIT_GLOBAL}.
6499@var{file} is either a null pointer, or a stdio stream to write any debug output to.
6500@var{verbose} is the verbose level provided by @option{-fsched-verbose-@var{n}}.
6501@end deftypefn
6502
6503@hook TARGET_SCHED_DFA_PRE_CYCLE_INSN
6504The hook returns an RTL insn. The automaton state used in the
6505pipeline hazard recognizer is changed as if the insn were scheduled
6506when the new simulated processor cycle starts. Usage of the hook may
6507simplify the automaton pipeline description for some @acronym{VLIW}
6508processors. If the hook is defined, it is used only for the automaton
6509based pipeline description. The default is not to change the state
6510when the new simulated processor cycle starts.
6511@end deftypefn
6512
6513@hook TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN
6514The hook can be used to initialize data used by the previous hook.
6515@end deftypefn
6516
6517@hook TARGET_SCHED_DFA_POST_CYCLE_INSN
6518The hook is analogous to @samp{TARGET_SCHED_DFA_PRE_CYCLE_INSN} but used
6519to changed the state as if the insn were scheduled when the new
6520simulated processor cycle finishes.
6521@end deftypefn
6522
6523@hook TARGET_SCHED_INIT_DFA_POST_CYCLE_INSN
6524The hook is analogous to @samp{TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN} but
6525used to initialize data used by the previous hook.
6526@end deftypefn
6527
6528@hook TARGET_SCHED_DFA_PRE_ADVANCE_CYCLE
6529The hook to notify target that the current simulated cycle is about to finish.
6530The hook is analogous to @samp{TARGET_SCHED_DFA_PRE_CYCLE_INSN} but used
6531to change the state in more complicated situations - e.g., when advancing
6532state on a single insn is not enough.
6533@end deftypefn
6534
6535@hook TARGET_SCHED_DFA_POST_ADVANCE_CYCLE
6536The hook to notify target that new simulated cycle has just started.
6537The hook is analogous to @samp{TARGET_SCHED_DFA_POST_CYCLE_INSN} but used
6538to change the state in more complicated situations - e.g., when advancing
6539state on a single insn is not enough.
6540@end deftypefn
6541
6542@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
6543This hook controls better choosing an insn from the ready insn queue
6544for the @acronym{DFA}-based insn scheduler. Usually the scheduler
6545chooses the first insn from the queue. If the hook returns a positive
6546value, an additional scheduler code tries all permutations of
6547@samp{TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD ()}
6548subsequent ready insns to choose an insn whose issue will result in
6549maximal number of issued insns on the same cycle. For the
6550@acronym{VLIW} processor, the code could actually solve the problem of
6551packing simple insns into the @acronym{VLIW} insn. Of course, if the
6552rules of @acronym{VLIW} packing are described in the automaton.
6553
6554This code also could be used for superscalar @acronym{RISC}
6555processors. Let us consider a superscalar @acronym{RISC} processor
6556with 3 pipelines. Some insns can be executed in pipelines @var{A} or
6557@var{B}, some insns can be executed only in pipelines @var{B} or
6558@var{C}, and one insn can be executed in pipeline @var{B}. The
6559processor may issue the 1st insn into @var{A} and the 2nd one into
6560@var{B}. In this case, the 3rd insn will wait for freeing @var{B}
6561until the next cycle. If the scheduler issues the 3rd insn the first,
6562the processor could issue all 3 insns per cycle.
6563
6564Actually this code demonstrates advantages of the automaton based
6565pipeline hazard recognizer. We try quickly and easy many insn
6566schedules to choose the best one.
6567
6568The default is no multipass scheduling.
6569@end deftypefn
6570
6571@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
6572
6573This hook controls what insns from the ready insn queue will be
6574considered for the multipass insn scheduling. If the hook returns
6575zero for @var{insn}, the insn will be not chosen to
6576be issued.
6577
6578The default is that any ready insns can be chosen to be issued.
6579@end deftypefn
6580
894fd6f2
MK
6581@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BEGIN
6582This hook prepares the target backend for a new round of multipass
6583scheduling.
6584@end deftypefn
6585
6586@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_ISSUE
6587This hook is called when multipass scheduling evaluates instruction INSN.
6588@end deftypefn
6589
6590@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BACKTRACK
6591This is called when multipass scheduling backtracks from evaluation of
6592an instruction.
6593@end deftypefn
6594
6595@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_END
6596This hook notifies the target about the result of the concluded current
6597round of multipass scheduling.
6598@end deftypefn
6599
6600@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_INIT
2b0d3573 6601This hook initializes target-specific data used in multipass scheduling.
894fd6f2
MK
6602@end deftypefn
6603
6604@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_FINI
2b0d3573 6605This hook finalizes target-specific data used in multipass scheduling.
894fd6f2
MK
6606@end deftypefn
6607
c06bbdf7 6608@hook TARGET_SCHED_DFA_NEW_CYCLE
38f8b050
JR
6609This hook is called by the insn scheduler before issuing @var{insn}
6610on cycle @var{clock}. If the hook returns nonzero,
6611@var{insn} is not issued on this processor cycle. Instead,
6612the processor cycle is advanced. If *@var{sort_p}
6613is zero, the insn ready queue is not sorted on the new cycle
6614start as usually. @var{dump} and @var{verbose} specify the file and
6615verbosity level to use for debugging output.
6616@var{last_clock} and @var{clock} are, respectively, the
6617processor cycle on which the previous insn has been issued,
6618and the current processor cycle.
6619@end deftypefn
6620
6621@hook TARGET_SCHED_IS_COSTLY_DEPENDENCE
6622This hook is used to define which dependences are considered costly by
6623the target, so costly that it is not advisable to schedule the insns that
6624are involved in the dependence too close to one another. The parameters
6625to this hook are as follows: The first parameter @var{_dep} is the dependence
6626being evaluated. The second parameter @var{cost} is the cost of the
6627dependence as estimated by the scheduler, and the third
6628parameter @var{distance} is the distance in cycles between the two insns.
6629The hook returns @code{true} if considering the distance between the two
6630insns the dependence between them is considered costly by the target,
6631and @code{false} otherwise.
6632
6633Defining this hook can be useful in multiple-issue out-of-order machines,
6634where (a) it's practically hopeless to predict the actual data/resource
6635delays, however: (b) there's a better chance to predict the actual grouping
6636that will be formed, and (c) correctly emulating the grouping can be very
6637important. In such targets one may want to allow issuing dependent insns
6638closer to one another---i.e., closer than the dependence distance; however,
6639not in cases of ``costly dependences'', which this hooks allows to define.
6640@end deftypefn
6641
6642@hook TARGET_SCHED_H_I_D_EXTENDED
6643This hook is called by the insn scheduler after emitting a new instruction to
6644the instruction stream. The hook notifies a target backend to extend its
6645per instruction data structures.
6646@end deftypefn
6647
6648@hook TARGET_SCHED_ALLOC_SCHED_CONTEXT
6649Return a pointer to a store large enough to hold target scheduling context.
6650@end deftypefn
6651
6652@hook TARGET_SCHED_INIT_SCHED_CONTEXT
6653Initialize store pointed to by @var{tc} to hold target scheduling context.
6654It @var{clean_p} is true then initialize @var{tc} as if scheduler is at the
6655beginning of the block. Otherwise, copy the current context into @var{tc}.
6656@end deftypefn
6657
6658@hook TARGET_SCHED_SET_SCHED_CONTEXT
6659Copy target scheduling context pointed to by @var{tc} to the current context.
6660@end deftypefn
6661
6662@hook TARGET_SCHED_CLEAR_SCHED_CONTEXT
6663Deallocate internal data in target scheduling context pointed to by @var{tc}.
6664@end deftypefn
6665
6666@hook TARGET_SCHED_FREE_SCHED_CONTEXT
6667Deallocate a store for target scheduling context pointed to by @var{tc}.
6668@end deftypefn
6669
6670@hook TARGET_SCHED_SPECULATE_INSN
6671This hook is called by the insn scheduler when @var{insn} has only
6672speculative dependencies and therefore can be scheduled speculatively.
6673The hook is used to check if the pattern of @var{insn} has a speculative
6674version and, in case of successful check, to generate that speculative
6675pattern. The hook should return 1, if the instruction has a speculative form,
6676or @minus{}1, if it doesn't. @var{request} describes the type of requested
6677speculation. If the return value equals 1 then @var{new_pat} is assigned
6678the generated speculative pattern.
6679@end deftypefn
6680
6681@hook TARGET_SCHED_NEEDS_BLOCK_P
6682This hook is called by the insn scheduler during generation of recovery code
6683for @var{insn}. It should return @code{true}, if the corresponding check
6684instruction should branch to recovery code, or @code{false} otherwise.
6685@end deftypefn
6686
6687@hook TARGET_SCHED_GEN_SPEC_CHECK
6688This hook is called by the insn scheduler to generate a pattern for recovery
6689check instruction. If @var{mutate_p} is zero, then @var{insn} is a
6690speculative instruction for which the check should be generated.
6691@var{label} is either a label of a basic block, where recovery code should
6692be emitted, or a null pointer, when requested check doesn't branch to
6693recovery code (a simple check). If @var{mutate_p} is nonzero, then
6694a pattern for a branchy check corresponding to a simple check denoted by
6695@var{insn} should be generated. In this case @var{label} can't be null.
6696@end deftypefn
6697
6698@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD_SPEC
6699This hook is used as a workaround for
6700@samp{TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD} not being
6701called on the first instruction of the ready list. The hook is used to
6702discard speculative instructions that stand first in the ready list from
6703being scheduled on the current cycle. If the hook returns @code{false},
6704@var{insn} will not be chosen to be issued.
6705For non-speculative instructions,
6706the hook should always return @code{true}. For example, in the ia64 backend
6707the hook is used to cancel data speculative insns when the ALAT table
6708is nearly full.
6709@end deftypefn
6710
6711@hook TARGET_SCHED_SET_SCHED_FLAGS
6712This hook is used by the insn scheduler to find out what features should be
6713enabled/used.
6714The structure *@var{spec_info} should be filled in by the target.
6715The structure describes speculation types that can be used in the scheduler.
6716@end deftypefn
6717
6718@hook TARGET_SCHED_SMS_RES_MII
6719This hook is called by the swing modulo scheduler to calculate a
6720resource-based lower bound which is based on the resources available in
6721the machine and the resources required by each instruction. The target
6722backend can use @var{g} to calculate such bound. A very simple lower
6723bound will be used in case this hook is not implemented: the total number
6724of instructions divided by the issue rate.
6725@end deftypefn
6726
7942e47e
RY
6727@hook TARGET_SCHED_DISPATCH
6728This hook is called by Haifa Scheduler. It returns true if dispatch scheduling
6729is supported in hardware and the condition specified in the parameter is true.
6730@end deftypefn
6731
6732@hook TARGET_SCHED_DISPATCH_DO
6733This hook is called by Haifa Scheduler. It performs the operation specified
6734in its second parameter.
6735@end deftypefn
6736
b0bd15f7
BS
6737@hook TARGET_SCHED_EXPOSED_PIPELINE
6738
df7b0cc4
EI
6739@hook TARGET_SCHED_REASSOCIATION_WIDTH
6740
38f8b050
JR
6741@node Sections
6742@section Dividing the Output into Sections (Texts, Data, @dots{})
6743@c the above section title is WAY too long. maybe cut the part between
6744@c the (...)? --mew 10feb93
6745
6746An object file is divided into sections containing different types of
6747data. In the most common case, there are three sections: the @dfn{text
6748section}, which holds instructions and read-only data; the @dfn{data
6749section}, which holds initialized writable data; and the @dfn{bss
6750section}, which holds uninitialized data. Some systems have other kinds
6751of sections.
6752
6753@file{varasm.c} provides several well-known sections, such as
6754@code{text_section}, @code{data_section} and @code{bss_section}.
6755The normal way of controlling a @code{@var{foo}_section} variable
6756is to define the associated @code{@var{FOO}_SECTION_ASM_OP} macro,
6757as described below. The macros are only read once, when @file{varasm.c}
6758initializes itself, so their values must be run-time constants.
6759They may however depend on command-line flags.
6760
6761@emph{Note:} Some run-time files, such @file{crtstuff.c}, also make
6762use of the @code{@var{FOO}_SECTION_ASM_OP} macros, and expect them
6763to be string literals.
6764
6765Some assemblers require a different string to be written every time a
6766section is selected. If your assembler falls into this category, you
6767should define the @code{TARGET_ASM_INIT_SECTIONS} hook and use
6768@code{get_unnamed_section} to set up the sections.
6769
6770You must always create a @code{text_section}, either by defining
6771@code{TEXT_SECTION_ASM_OP} or by initializing @code{text_section}
6772in @code{TARGET_ASM_INIT_SECTIONS}. The same is true of
6773@code{data_section} and @code{DATA_SECTION_ASM_OP}. If you do not
6774create a distinct @code{readonly_data_section}, the default is to
6775reuse @code{text_section}.
6776
6777All the other @file{varasm.c} sections are optional, and are null
6778if the target does not provide them.
6779
6780@defmac TEXT_SECTION_ASM_OP
6781A C expression whose value is a string, including spacing, containing the
6782assembler operation that should precede instructions and read-only data.
6783Normally @code{"\t.text"} is right.
6784@end defmac
6785
6786@defmac HOT_TEXT_SECTION_NAME
6787If defined, a C string constant for the name of the section containing most
6788frequently executed functions of the program. If not defined, GCC will provide
6789a default definition if the target supports named sections.
6790@end defmac
6791
6792@defmac UNLIKELY_EXECUTED_TEXT_SECTION_NAME
6793If defined, a C string constant for the name of the section containing unlikely
6794executed functions in the program.
6795@end defmac
6796
6797@defmac DATA_SECTION_ASM_OP
6798A C expression whose value is a string, including spacing, containing the
6799assembler operation to identify the following data as writable initialized
6800data. Normally @code{"\t.data"} is right.
6801@end defmac
6802
6803@defmac SDATA_SECTION_ASM_OP
6804If defined, a C expression whose value is a string, including spacing,
6805containing the assembler operation to identify the following data as
6806initialized, writable small data.
6807@end defmac
6808
6809@defmac READONLY_DATA_SECTION_ASM_OP
6810A C expression whose value is a string, including spacing, containing the
6811assembler operation to identify the following data as read-only initialized
6812data.
6813@end defmac
6814
6815@defmac BSS_SECTION_ASM_OP
6816If defined, a C expression whose value is a string, including spacing,
6817containing the assembler operation to identify the following data as
07c5f94e
AS
6818uninitialized global data. If not defined, and
6819@code{ASM_OUTPUT_ALIGNED_BSS} not defined,
38f8b050
JR
6820uninitialized global data will be output in the data section if
6821@option{-fno-common} is passed, otherwise @code{ASM_OUTPUT_COMMON} will be
6822used.
6823@end defmac
6824
6825@defmac SBSS_SECTION_ASM_OP
6826If defined, a C expression whose value is a string, including spacing,
6827containing the assembler operation to identify the following data as
6828uninitialized, writable small data.
6829@end defmac
6830
6831@defmac TLS_COMMON_ASM_OP
6832If defined, a C expression whose value is a string containing the
6833assembler operation to identify the following data as thread-local
6834common data. The default is @code{".tls_common"}.
6835@end defmac
6836
6837@defmac TLS_SECTION_ASM_FLAG
6838If defined, a C expression whose value is a character constant
6839containing the flag used to mark a section as a TLS section. The
6840default is @code{'T'}.
6841@end defmac
6842
6843@defmac INIT_SECTION_ASM_OP
6844If defined, a C expression whose value is a string, including spacing,
6845containing the assembler operation to identify the following data as
6846initialization code. If not defined, GCC will assume such a section does
6847not exist. This section has no corresponding @code{init_section}
6848variable; it is used entirely in runtime code.
6849@end defmac
6850
6851@defmac FINI_SECTION_ASM_OP
6852If defined, a C expression whose value is a string, including spacing,
6853containing the assembler operation to identify the following data as
6854finalization code. If not defined, GCC will assume such a section does
6855not exist. This section has no corresponding @code{fini_section}
6856variable; it is used entirely in runtime code.
6857@end defmac
6858
6859@defmac INIT_ARRAY_SECTION_ASM_OP
6860If defined, a C expression whose value is a string, including spacing,
6861containing the assembler operation to identify the following data as
6862part of the @code{.init_array} (or equivalent) section. If not
6863defined, GCC will assume such a section does not exist. Do not define
6864both this macro and @code{INIT_SECTION_ASM_OP}.
6865@end defmac
6866
6867@defmac FINI_ARRAY_SECTION_ASM_OP
6868If defined, a C expression whose value is a string, including spacing,
6869containing the assembler operation to identify the following data as
6870part of the @code{.fini_array} (or equivalent) section. If not
6871defined, GCC will assume such a section does not exist. Do not define
6872both this macro and @code{FINI_SECTION_ASM_OP}.
6873@end defmac
6874
6875@defmac CRT_CALL_STATIC_FUNCTION (@var{section_op}, @var{function})
6876If defined, an ASM statement that switches to a different section
6877via @var{section_op}, calls @var{function}, and switches back to
6878the text section. This is used in @file{crtstuff.c} if
6879@code{INIT_SECTION_ASM_OP} or @code{FINI_SECTION_ASM_OP} to calls
6880to initialization and finalization functions from the init and fini
6881sections. By default, this macro uses a simple function call. Some
6882ports need hand-crafted assembly code to avoid dependencies on
6883registers initialized in the function prologue or to ensure that
6884constant pools don't end up too far way in the text section.
6885@end defmac
6886
6887@defmac TARGET_LIBGCC_SDATA_SECTION
6888If defined, a string which names the section into which small
6889variables defined in crtstuff and libgcc should go. This is useful
6890when the target has options for optimizing access to small data, and
6891you want the crtstuff and libgcc routines to be conservative in what
6892they expect of your application yet liberal in what your application
6893expects. For example, for targets with a @code{.sdata} section (like
6894MIPS), you could compile crtstuff with @code{-G 0} so that it doesn't
6895require small data support from your application, but use this macro
6896to put small data into @code{.sdata} so that your application can
6897access these variables whether it uses small data or not.
6898@end defmac
6899
6900@defmac FORCE_CODE_SECTION_ALIGN
6901If defined, an ASM statement that aligns a code section to some
6902arbitrary boundary. This is used to force all fragments of the
6903@code{.init} and @code{.fini} sections to have to same alignment
6904and thus prevent the linker from having to add any padding.
6905@end defmac
6906
6907@defmac JUMP_TABLES_IN_TEXT_SECTION
6908Define this macro to be an expression with a nonzero value if jump
6909tables (for @code{tablejump} insns) should be output in the text
6910section, along with the assembler instructions. Otherwise, the
6911readonly data section is used.
6912
6913This macro is irrelevant if there is no separate readonly data section.
6914@end defmac
6915
6916@hook TARGET_ASM_INIT_SECTIONS
6917Define this hook if you need to do something special to set up the
6918@file{varasm.c} sections, or if your target has some special sections
6919of its own that you need to create.
6920
6921GCC calls this hook after processing the command line, but before writing
6922any assembly code, and before calling any of the section-returning hooks
6923described below.
6924@end deftypefn
6925
6926@hook TARGET_ASM_RELOC_RW_MASK
6927Return a mask describing how relocations should be treated when
6928selecting sections. Bit 1 should be set if global relocations
6929should be placed in a read-write section; bit 0 should be set if
6930local relocations should be placed in a read-write section.
6931
6932The default version of this function returns 3 when @option{-fpic}
6933is in effect, and 0 otherwise. The hook is typically redefined
6934when the target cannot support (some kinds of) dynamic relocations
6935in read-only sections even in executables.
6936@end deftypefn
6937
6938@hook TARGET_ASM_SELECT_SECTION
6939Return the section into which @var{exp} should be placed. You can
6940assume that @var{exp} is either a @code{VAR_DECL} node or a constant of
6941some sort. @var{reloc} indicates whether the initial value of @var{exp}
6942requires link-time relocations. Bit 0 is set when variable contains
6943local relocations only, while bit 1 is set for global relocations.
6944@var{align} is the constant alignment in bits.
6945
6946The default version of this function takes care of putting read-only
6947variables in @code{readonly_data_section}.
6948
6949See also @var{USE_SELECT_SECTION_FOR_FUNCTIONS}.
6950@end deftypefn
6951
6952@defmac USE_SELECT_SECTION_FOR_FUNCTIONS
6953Define this macro if you wish TARGET_ASM_SELECT_SECTION to be called
6954for @code{FUNCTION_DECL}s as well as for variables and constants.
6955
6956In the case of a @code{FUNCTION_DECL}, @var{reloc} will be zero if the
6957function has been determined to be likely to be called, and nonzero if
6958it is unlikely to be called.
6959@end defmac
6960
6961@hook TARGET_ASM_UNIQUE_SECTION
6962Build up a unique section name, expressed as a @code{STRING_CST} node,
6963and assign it to @samp{DECL_SECTION_NAME (@var{decl})}.
6964As with @code{TARGET_ASM_SELECT_SECTION}, @var{reloc} indicates whether
6965the initial value of @var{exp} requires link-time relocations.
6966
6967The default version of this function appends the symbol name to the
6968ELF section name that would normally be used for the symbol. For
6969example, the function @code{foo} would be placed in @code{.text.foo}.
6970Whatever the actual target object format, this is often good enough.
6971@end deftypefn
6972
6973@hook TARGET_ASM_FUNCTION_RODATA_SECTION
6974Return the readonly data section associated with
6975@samp{DECL_SECTION_NAME (@var{decl})}.
6976The default version of this function selects @code{.gnu.linkonce.r.name} if
6977the function's section is @code{.gnu.linkonce.t.name}, @code{.rodata.name}
6978if function is in @code{.text.name}, and the normal readonly-data section
6979otherwise.
6980@end deftypefn
6981
727a65e6
BS
6982@hook TARGET_ASM_MERGEABLE_RODATA_PREFIX
6983
50b0b78a
IS
6984@hook TARGET_ASM_TM_CLONE_TABLE_SECTION
6985
38f8b050
JR
6986@hook TARGET_ASM_SELECT_RTX_SECTION
6987Return the section into which a constant @var{x}, of mode @var{mode},
6988should be placed. You can assume that @var{x} is some kind of
6989constant in RTL@. The argument @var{mode} is redundant except in the
6990case of a @code{const_int} rtx. @var{align} is the constant alignment
6991in bits.
6992
6993The default version of this function takes care of putting symbolic
6994constants in @code{flag_pic} mode in @code{data_section} and everything
6995else in @code{readonly_data_section}.
6996@end deftypefn
6997
6998@hook TARGET_MANGLE_DECL_ASSEMBLER_NAME
6999Define this hook if you need to postprocess the assembler name generated
7000by target-independent code. The @var{id} provided to this hook will be
7001the computed name (e.g., the macro @code{DECL_NAME} of the @var{decl} in C,
7002or the mangled name of the @var{decl} in C++). The return value of the
7003hook is an @code{IDENTIFIER_NODE} for the appropriate mangled name on
7004your target system. The default implementation of this hook just
7005returns the @var{id} provided.
7006@end deftypefn
7007
7008@hook TARGET_ENCODE_SECTION_INFO
7009Define this hook if references to a symbol or a constant must be
7010treated differently depending on something about the variable or
7011function named by the symbol (such as what section it is in).
7012
7013The hook is executed immediately after rtl has been created for
7014@var{decl}, which may be a variable or function declaration or
7015an entry in the constant pool. In either case, @var{rtl} is the
7016rtl in question. Do @emph{not} use @code{DECL_RTL (@var{decl})}
7017in this hook; that field may not have been initialized yet.
7018
7019In the case of a constant, it is safe to assume that the rtl is
7020a @code{mem} whose address is a @code{symbol_ref}. Most decls
7021will also have this form, but that is not guaranteed. Global
7022register variables, for instance, will have a @code{reg} for their
7023rtl. (Normally the right thing to do with such unusual rtl is
7024leave it alone.)
7025
7026The @var{new_decl_p} argument will be true if this is the first time
7027that @code{TARGET_ENCODE_SECTION_INFO} has been invoked on this decl. It will
7028be false for subsequent invocations, which will happen for duplicate
7029declarations. Whether or not anything must be done for the duplicate
7030declaration depends on whether the hook examines @code{DECL_ATTRIBUTES}.
7031@var{new_decl_p} is always true when the hook is called for a constant.
7032
7033@cindex @code{SYMBOL_REF_FLAG}, in @code{TARGET_ENCODE_SECTION_INFO}
7034The usual thing for this hook to do is to record flags in the
7035@code{symbol_ref}, using @code{SYMBOL_REF_FLAG} or @code{SYMBOL_REF_FLAGS}.
7036Historically, the name string was modified if it was necessary to
7037encode more than one bit of information, but this practice is now
7038discouraged; use @code{SYMBOL_REF_FLAGS}.
7039
7040The default definition of this hook, @code{default_encode_section_info}
7041in @file{varasm.c}, sets a number of commonly-useful bits in
7042@code{SYMBOL_REF_FLAGS}. Check whether the default does what you need
7043before overriding it.
7044@end deftypefn
7045
7046@hook TARGET_STRIP_NAME_ENCODING
7047Decode @var{name} and return the real name part, sans
7048the characters that @code{TARGET_ENCODE_SECTION_INFO}
7049may have added.
7050@end deftypefn
7051
7052@hook TARGET_IN_SMALL_DATA_P
7053Returns true if @var{exp} should be placed into a ``small data'' section.
7054The default version of this hook always returns false.
7055@end deftypefn
7056
7057@hook TARGET_HAVE_SRODATA_SECTION
7058Contains the value true if the target places read-only
7059``small data'' into a separate section. The default value is false.
7060@end deftypevr
7061
3c5273a9
KT
7062@hook TARGET_PROFILE_BEFORE_PROLOGUE
7063
38f8b050
JR
7064@hook TARGET_BINDS_LOCAL_P
7065Returns true if @var{exp} names an object for which name resolution
7066rules must resolve to the current ``module'' (dynamic shared library
7067or executable image).
7068
7069The default version of this hook implements the name resolution rules
7070for ELF, which has a looser model of global name binding than other
7071currently supported object file formats.
7072@end deftypefn
7073
7074@hook TARGET_HAVE_TLS
7075Contains the value true if the target supports thread-local storage.
7076The default value is false.
7077@end deftypevr
7078
7079
7080@node PIC
7081@section Position Independent Code
7082@cindex position independent code
7083@cindex PIC
7084
7085This section describes macros that help implement generation of position
7086independent code. Simply defining these macros is not enough to
7087generate valid PIC; you must also add support to the hook
7088@code{TARGET_LEGITIMATE_ADDRESS_P} and to the macro
7089@code{PRINT_OPERAND_ADDRESS}, as well as @code{LEGITIMIZE_ADDRESS}. You
7090must modify the definition of @samp{movsi} to do something appropriate
7091when the source operand contains a symbolic address. You may also
7092need to alter the handling of switch statements so that they use
7093relative addresses.
ff2ce160 7094@c i rearranged the order of the macros above to try to force one of
38f8b050
JR
7095@c them to the next line, to eliminate an overfull hbox. --mew 10feb93
7096
7097@defmac PIC_OFFSET_TABLE_REGNUM
7098The register number of the register used to address a table of static
7099data addresses in memory. In some cases this register is defined by a
7100processor's ``application binary interface'' (ABI)@. When this macro
7101is defined, RTL is generated for this register once, as with the stack
7102pointer and frame pointer registers. If this macro is not defined, it
7103is up to the machine-dependent files to allocate such a register (if
7104necessary). Note that this register must be fixed when in use (e.g.@:
7105when @code{flag_pic} is true).
7106@end defmac
7107
7108@defmac PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
f8fe0a4a
JM
7109A C expression that is nonzero if the register defined by
7110@code{PIC_OFFSET_TABLE_REGNUM} is clobbered by calls. If not defined,
7111the default is zero. Do not define
38f8b050
JR
7112this macro if @code{PIC_OFFSET_TABLE_REGNUM} is not defined.
7113@end defmac
7114
7115@defmac LEGITIMATE_PIC_OPERAND_P (@var{x})
7116A C expression that is nonzero if @var{x} is a legitimate immediate
7117operand on the target machine when generating position independent code.
7118You can assume that @var{x} satisfies @code{CONSTANT_P}, so you need not
7119check this. You can also assume @var{flag_pic} is true, so you need not
7120check it either. You need not define this macro if all constants
7121(including @code{SYMBOL_REF}) can be immediate operands when generating
7122position independent code.
7123@end defmac
7124
7125@node Assembler Format
7126@section Defining the Output Assembler Language
7127
7128This section describes macros whose principal purpose is to describe how
7129to write instructions in assembler language---rather than what the
7130instructions do.
7131
7132@menu
7133* File Framework:: Structural information for the assembler file.
7134* Data Output:: Output of constants (numbers, strings, addresses).
7135* Uninitialized Data:: Output of uninitialized variables.
7136* Label Output:: Output and generation of labels.
7137* Initialization:: General principles of initialization
7138 and termination routines.
7139* Macros for Initialization::
7140 Specific macros that control the handling of
7141 initialization and termination routines.
7142* Instruction Output:: Output of actual instructions.
7143* Dispatch Tables:: Output of jump tables.
7144* Exception Region Output:: Output of exception region code.
7145* Alignment Output:: Pseudo ops for alignment and skipping data.
7146@end menu
7147
7148@node File Framework
7149@subsection The Overall Framework of an Assembler File
7150@cindex assembler format
7151@cindex output of assembler code
7152
7153@c prevent bad page break with this line
7154This describes the overall framework of an assembly file.
7155
7156@findex default_file_start
7157@hook TARGET_ASM_FILE_START
7158Output to @code{asm_out_file} any text which the assembler expects to
7159find at the beginning of a file. The default behavior is controlled
7160by two flags, documented below. Unless your target's assembler is
7161quite unusual, if you override the default, you should call
7162@code{default_file_start} at some point in your target hook. This
7163lets other target files rely on these variables.
7164@end deftypefn
7165
7166@hook TARGET_ASM_FILE_START_APP_OFF
7167If this flag is true, the text of the macro @code{ASM_APP_OFF} will be
7168printed as the very first line in the assembly file, unless
7169@option{-fverbose-asm} is in effect. (If that macro has been defined
7170to the empty string, this variable has no effect.) With the normal
7171definition of @code{ASM_APP_OFF}, the effect is to notify the GNU
7172assembler that it need not bother stripping comments or extra
7173whitespace from its input. This allows it to work a bit faster.
7174
7175The default is false. You should not set it to true unless you have
7176verified that your port does not generate any extra whitespace or
7177comments that will cause GAS to issue errors in NO_APP mode.
7178@end deftypevr
7179
7180@hook TARGET_ASM_FILE_START_FILE_DIRECTIVE
7181If this flag is true, @code{output_file_directive} will be called
7182for the primary source file, immediately after printing
7183@code{ASM_APP_OFF} (if that is enabled). Most ELF assemblers expect
7184this to be done. The default is false.
7185@end deftypevr
7186
7187@hook TARGET_ASM_FILE_END
7188Output to @code{asm_out_file} any text which the assembler expects
7189to find at the end of a file. The default is to output nothing.
7190@end deftypefn
7191
7192@deftypefun void file_end_indicate_exec_stack ()
7193Some systems use a common convention, the @samp{.note.GNU-stack}
7194special section, to indicate whether or not an object file relies on
7195the stack being executable. If your system uses this convention, you
7196should define @code{TARGET_ASM_FILE_END} to this function. If you
7197need to do other things in that hook, have your hook function call
7198this function.
7199@end deftypefun
7200
7201@hook TARGET_ASM_LTO_START
7202Output to @code{asm_out_file} any text which the assembler expects
7203to find at the start of an LTO section. The default is to output
7204nothing.
7205@end deftypefn
7206
7207@hook TARGET_ASM_LTO_END
7208Output to @code{asm_out_file} any text which the assembler expects
7209to find at the end of an LTO section. The default is to output
7210nothing.
7211@end deftypefn
7212
7213@hook TARGET_ASM_CODE_END
7214Output to @code{asm_out_file} any text which is needed before emitting
7215unwind info and debug info at the end of a file. Some targets emit
7216here PIC setup thunks that cannot be emitted at the end of file,
7217because they couldn't have unwind info then. The default is to output
7218nothing.
7219@end deftypefn
7220
7221@defmac ASM_COMMENT_START
7222A C string constant describing how to begin a comment in the target
7223assembler language. The compiler assumes that the comment will end at
7224the end of the line.
7225@end defmac
7226
7227@defmac ASM_APP_ON
7228A C string constant for text to be output before each @code{asm}
7229statement or group of consecutive ones. Normally this is
7230@code{"#APP"}, which is a comment that has no effect on most
7231assemblers but tells the GNU assembler that it must check the lines
7232that follow for all valid assembler constructs.
7233@end defmac
7234
7235@defmac ASM_APP_OFF
7236A C string constant for text to be output after each @code{asm}
7237statement or group of consecutive ones. Normally this is
7238@code{"#NO_APP"}, which tells the GNU assembler to resume making the
7239time-saving assumptions that are valid for ordinary compiler output.
7240@end defmac
7241
7242@defmac ASM_OUTPUT_SOURCE_FILENAME (@var{stream}, @var{name})
7243A C statement to output COFF information or DWARF debugging information
7244which indicates that filename @var{name} is the current source file to
7245the stdio stream @var{stream}.
7246
7247This macro need not be defined if the standard form of output
7248for the file format in use is appropriate.
7249@end defmac
7250
b5f5d41d
AS
7251@hook TARGET_ASM_OUTPUT_SOURCE_FILENAME
7252
a8781821
SB
7253@hook TARGET_ASM_OUTPUT_IDENT
7254
38f8b050
JR
7255@defmac OUTPUT_QUOTED_STRING (@var{stream}, @var{string})
7256A C statement to output the string @var{string} to the stdio stream
7257@var{stream}. If you do not call the function @code{output_quoted_string}
7258in your config files, GCC will only call it to output filenames to
7259the assembler source. So you can use it to canonicalize the format
7260of the filename using this macro.
7261@end defmac
7262
38f8b050
JR
7263@hook TARGET_ASM_NAMED_SECTION
7264Output assembly directives to switch to section @var{name}. The section
7265should have attributes as specified by @var{flags}, which is a bit mask
7266of the @code{SECTION_*} flags defined in @file{output.h}. If @var{decl}
7267is non-NULL, it is the @code{VAR_DECL} or @code{FUNCTION_DECL} with which
7268this section is associated.
7269@end deftypefn
7270
f16d3f39
JH
7271@hook TARGET_ASM_FUNCTION_SECTION
7272Return preferred text (sub)section for function @var{decl}.
7273Main purpose of this function is to separate cold, normal and hot
ff2ce160 7274functions. @var{startup} is true when function is known to be used only
f16d3f39
JH
7275at startup (from static constructors or it is @code{main()}).
7276@var{exit} is true when function is known to be used only at exit
7277(from static destructors).
7278Return NULL if function should go to default text section.
7279@end deftypefn
7280
14d11d40
IS
7281@hook TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS
7282
38f8b050
JR
7283@hook TARGET_HAVE_NAMED_SECTIONS
7284This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}.
d5fabb58 7285It must not be modified by command-line option processing.
38f8b050
JR
7286@end deftypevr
7287
7288@anchor{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS}
7289@hook TARGET_HAVE_SWITCHABLE_BSS_SECTIONS
7290This flag is true if we can create zeroed data by switching to a BSS
7291section and then using @code{ASM_OUTPUT_SKIP} to allocate the space.
7292This is true on most ELF targets.
7293@end deftypevr
7294
7295@hook TARGET_SECTION_TYPE_FLAGS
7296Choose a set of section attributes for use by @code{TARGET_ASM_NAMED_SECTION}
7297based on a variable or function decl, a section name, and whether or not the
7298declaration's initializer may contain runtime relocations. @var{decl} may be
7299null, in which case read-write data should be assumed.
7300
7301The default version of this function handles choosing code vs data,
7302read-only vs read-write data, and @code{flag_pic}. You should only
7303need to override this if your target has special flags that might be
7304set via @code{__attribute__}.
7305@end deftypefn
7306
7307@hook TARGET_ASM_RECORD_GCC_SWITCHES
7308Provides the target with the ability to record the gcc command line
7309switches that have been passed to the compiler, and options that are
7310enabled. The @var{type} argument specifies what is being recorded.
7311It can take the following values:
7312
7313@table @gcctabopt
7314@item SWITCH_TYPE_PASSED
7315@var{text} is a command line switch that has been set by the user.
7316
7317@item SWITCH_TYPE_ENABLED
7318@var{text} is an option which has been enabled. This might be as a
7319direct result of a command line switch, or because it is enabled by
7320default or because it has been enabled as a side effect of a different
7321command line switch. For example, the @option{-O2} switch enables
7322various different individual optimization passes.
7323
7324@item SWITCH_TYPE_DESCRIPTIVE
7325@var{text} is either NULL or some descriptive text which should be
7326ignored. If @var{text} is NULL then it is being used to warn the
7327target hook that either recording is starting or ending. The first
7328time @var{type} is SWITCH_TYPE_DESCRIPTIVE and @var{text} is NULL, the
7329warning is for start up and the second time the warning is for
7330wind down. This feature is to allow the target hook to make any
7331necessary preparations before it starts to record switches and to
7332perform any necessary tidying up after it has finished recording
7333switches.
7334
7335@item SWITCH_TYPE_LINE_START
7336This option can be ignored by this target hook.
7337
7338@item SWITCH_TYPE_LINE_END
7339This option can be ignored by this target hook.
7340@end table
7341
7342The hook's return value must be zero. Other return values may be
7343supported in the future.
7344
7345By default this hook is set to NULL, but an example implementation is
7346provided for ELF based targets. Called @var{elf_record_gcc_switches},
7347it records the switches as ASCII text inside a new, string mergeable
7348section in the assembler output file. The name of the new section is
7349provided by the @code{TARGET_ASM_RECORD_GCC_SWITCHES_SECTION} target
7350hook.
7351@end deftypefn
7352
7353@hook TARGET_ASM_RECORD_GCC_SWITCHES_SECTION
7354This is the name of the section that will be created by the example
7355ELF implementation of the @code{TARGET_ASM_RECORD_GCC_SWITCHES} target
7356hook.
7357@end deftypevr
7358
7359@need 2000
7360@node Data Output
7361@subsection Output of Data
7362
7363
7364@hook TARGET_ASM_BYTE_OP
7365@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_HI_OP
7366@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_SI_OP
7367@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_DI_OP
7368@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_TI_OP
7369@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_HI_OP
7370@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_SI_OP
7371@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_DI_OP
7372@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_TI_OP
7373These hooks specify assembly directives for creating certain kinds
7374of integer object. The @code{TARGET_ASM_BYTE_OP} directive creates a
7375byte-sized object, the @code{TARGET_ASM_ALIGNED_HI_OP} one creates an
7376aligned two-byte object, and so on. Any of the hooks may be
7377@code{NULL}, indicating that no suitable directive is available.
7378
7379The compiler will print these strings at the start of a new line,
7380followed immediately by the object's initial value. In most cases,
7381the string should contain a tab, a pseudo-op, and then another tab.
7382@end deftypevr
7383
7384@hook TARGET_ASM_INTEGER
7385The @code{assemble_integer} function uses this hook to output an
7386integer object. @var{x} is the object's value, @var{size} is its size
7387in bytes and @var{aligned_p} indicates whether it is aligned. The
7388function should return @code{true} if it was able to output the
7389object. If it returns false, @code{assemble_integer} will try to
7390split the object into smaller parts.
7391
7392The default implementation of this hook will use the
7393@code{TARGET_ASM_BYTE_OP} family of strings, returning @code{false}
7394when the relevant string is @code{NULL}.
7395@end deftypefn
7396
6cbd8875
AS
7397@hook TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
7398A target hook to recognize @var{rtx} patterns that @code{output_addr_const}
7399can't deal with, and output assembly code to @var{file} corresponding to
7400the pattern @var{x}. This may be used to allow machine-dependent
7401@code{UNSPEC}s to appear within constants.
7402
7403If target hook fails to recognize a pattern, it must return @code{false},
7404so that a standard error message is printed. If it prints an error message
7405itself, by calling, for example, @code{output_operand_lossage}, it may just
7406return @code{true}.
7407@end deftypefn
7408
38f8b050
JR
7409@defmac ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len})
7410A C statement to output to the stdio stream @var{stream} an assembler
7411instruction to assemble a string constant containing the @var{len}
7412bytes at @var{ptr}. @var{ptr} will be a C expression of type
7413@code{char *} and @var{len} a C expression of type @code{int}.
7414
7415If the assembler has a @code{.ascii} pseudo-op as found in the
7416Berkeley Unix assembler, do not define the macro
7417@code{ASM_OUTPUT_ASCII}.
7418@end defmac
7419
7420@defmac ASM_OUTPUT_FDESC (@var{stream}, @var{decl}, @var{n})
7421A C statement to output word @var{n} of a function descriptor for
7422@var{decl}. This must be defined if @code{TARGET_VTABLE_USES_DESCRIPTORS}
7423is defined, and is otherwise unused.
7424@end defmac
7425
7426@defmac CONSTANT_POOL_BEFORE_FUNCTION
7427You may define this macro as a C expression. You should define the
7428expression to have a nonzero value if GCC should output the constant
7429pool for a function before the code for the function, or a zero value if
7430GCC should output the constant pool after the function. If you do
7431not define this macro, the usual case, GCC will output the constant
7432pool before the function.
7433@end defmac
7434
7435@defmac ASM_OUTPUT_POOL_PROLOGUE (@var{file}, @var{funname}, @var{fundecl}, @var{size})
7436A C statement to output assembler commands to define the start of the
7437constant pool for a function. @var{funname} is a string giving
7438the name of the function. Should the return type of the function
7439be required, it can be obtained via @var{fundecl}. @var{size}
7440is the size, in bytes, of the constant pool that will be written
7441immediately after this call.
7442
7443If no constant-pool prefix is required, the usual case, this macro need
7444not be defined.
7445@end defmac
7446
7447@defmac ASM_OUTPUT_SPECIAL_POOL_ENTRY (@var{file}, @var{x}, @var{mode}, @var{align}, @var{labelno}, @var{jumpto})
7448A C statement (with or without semicolon) to output a constant in the
7449constant pool, if it needs special treatment. (This macro need not do
7450anything for RTL expressions that can be output normally.)
7451
7452The argument @var{file} is the standard I/O stream to output the
7453assembler code on. @var{x} is the RTL expression for the constant to
7454output, and @var{mode} is the machine mode (in case @var{x} is a
7455@samp{const_int}). @var{align} is the required alignment for the value
7456@var{x}; you should output an assembler directive to force this much
7457alignment.
7458
7459The argument @var{labelno} is a number to use in an internal label for
7460the address of this pool entry. The definition of this macro is
7461responsible for outputting the label definition at the proper place.
7462Here is how to do this:
7463
7464@smallexample
7465@code{(*targetm.asm_out.internal_label)} (@var{file}, "LC", @var{labelno});
7466@end smallexample
7467
7468When you output a pool entry specially, you should end with a
7469@code{goto} to the label @var{jumpto}. This will prevent the same pool
7470entry from being output a second time in the usual manner.
7471
7472You need not define this macro if it would do nothing.
7473@end defmac
7474
7475@defmac ASM_OUTPUT_POOL_EPILOGUE (@var{file} @var{funname} @var{fundecl} @var{size})
7476A C statement to output assembler commands to at the end of the constant
7477pool for a function. @var{funname} is a string giving the name of the
7478function. Should the return type of the function be required, you can
7479obtain it via @var{fundecl}. @var{size} is the size, in bytes, of the
7480constant pool that GCC wrote immediately before this call.
7481
7482If no constant-pool epilogue is required, the usual case, you need not
7483define this macro.
7484@end defmac
7485
7486@defmac IS_ASM_LOGICAL_LINE_SEPARATOR (@var{C}, @var{STR})
7487Define this macro as a C expression which is nonzero if @var{C} is
7488used as a logical line separator by the assembler. @var{STR} points
7489to the position in the string where @var{C} was found; this can be used if
7490a line separator uses multiple characters.
7491
7492If you do not define this macro, the default is that only
7493the character @samp{;} is treated as a logical line separator.
7494@end defmac
7495
7496@hook TARGET_ASM_OPEN_PAREN
7497These target hooks are C string constants, describing the syntax in the
7498assembler for grouping arithmetic expressions. If not overridden, they
7499default to normal parentheses, which is correct for most assemblers.
7500@end deftypevr
7501
7502These macros are provided by @file{real.h} for writing the definitions
7503of @code{ASM_OUTPUT_DOUBLE} and the like:
7504
7505@defmac REAL_VALUE_TO_TARGET_SINGLE (@var{x}, @var{l})
7506@defmacx REAL_VALUE_TO_TARGET_DOUBLE (@var{x}, @var{l})
7507@defmacx REAL_VALUE_TO_TARGET_LONG_DOUBLE (@var{x}, @var{l})
7508@defmacx REAL_VALUE_TO_TARGET_DECIMAL32 (@var{x}, @var{l})
7509@defmacx REAL_VALUE_TO_TARGET_DECIMAL64 (@var{x}, @var{l})
7510@defmacx REAL_VALUE_TO_TARGET_DECIMAL128 (@var{x}, @var{l})
7511These translate @var{x}, of type @code{REAL_VALUE_TYPE}, to the
7512target's floating point representation, and store its bit pattern in
7513the variable @var{l}. For @code{REAL_VALUE_TO_TARGET_SINGLE} and
7514@code{REAL_VALUE_TO_TARGET_DECIMAL32}, this variable should be a
7515simple @code{long int}. For the others, it should be an array of
7516@code{long int}. The number of elements in this array is determined
7517by the size of the desired target floating point data type: 32 bits of
7518it go in each @code{long int} array element. Each array element holds
751932 bits of the result, even if @code{long int} is wider than 32 bits
7520on the host machine.
7521
7522The array element values are designed so that you can print them out
7523using @code{fprintf} in the order they should appear in the target
7524machine's memory.
7525@end defmac
7526
7527@node Uninitialized Data
7528@subsection Output of Uninitialized Variables
7529
7530Each of the macros in this section is used to do the whole job of
7531outputting a single uninitialized variable.
7532
7533@defmac ASM_OUTPUT_COMMON (@var{stream}, @var{name}, @var{size}, @var{rounded})
7534A C statement (sans semicolon) to output to the stdio stream
7535@var{stream} the assembler definition of a common-label named
7536@var{name} whose size is @var{size} bytes. The variable @var{rounded}
7537is the size rounded up to whatever alignment the caller wants. It is
7538possible that @var{size} may be zero, for instance if a struct with no
7539other member than a zero-length array is defined. In this case, the
7540backend must output a symbol definition that allocates at least one
7541byte, both so that the address of the resulting object does not compare
7542equal to any other, and because some object formats cannot even express
7543the concept of a zero-sized common symbol, as that is how they represent
7544an ordinary undefined external.
7545
7546Use the expression @code{assemble_name (@var{stream}, @var{name})} to
7547output the name itself; before and after that, output the additional
7548assembler syntax for defining the name, and a newline.
7549
7550This macro controls how the assembler definitions of uninitialized
7551common global variables are output.
7552@end defmac
7553
7554@defmac ASM_OUTPUT_ALIGNED_COMMON (@var{stream}, @var{name}, @var{size}, @var{alignment})
7555Like @code{ASM_OUTPUT_COMMON} except takes the required alignment as a
7556separate, explicit argument. If you define this macro, it is used in
7557place of @code{ASM_OUTPUT_COMMON}, and gives you more flexibility in
7558handling the required alignment of the variable. The alignment is specified
7559as the number of bits.
7560@end defmac
7561
7562@defmac ASM_OUTPUT_ALIGNED_DECL_COMMON (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
7563Like @code{ASM_OUTPUT_ALIGNED_COMMON} except that @var{decl} of the
7564variable to be output, if there is one, or @code{NULL_TREE} if there
7565is no corresponding variable. If you define this macro, GCC will use it
7566in place of both @code{ASM_OUTPUT_COMMON} and
7567@code{ASM_OUTPUT_ALIGNED_COMMON}. Define this macro when you need to see
7568the variable's decl in order to chose what to output.
7569@end defmac
7570
07c5f94e 7571@defmac ASM_OUTPUT_ALIGNED_BSS (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
38f8b050
JR
7572A C statement (sans semicolon) to output to the stdio stream
7573@var{stream} the assembler definition of uninitialized global @var{decl} named
07c5f94e
AS
7574@var{name} whose size is @var{size} bytes. The variable @var{alignment}
7575is the alignment specified as the number of bits.
38f8b050 7576
07c5f94e
AS
7577Try to use function @code{asm_output_aligned_bss} defined in file
7578@file{varasm.c} when defining this macro. If unable, use the expression
38f8b050
JR
7579@code{assemble_name (@var{stream}, @var{name})} to output the name itself;
7580before and after that, output the additional assembler syntax for defining
7581the name, and a newline.
7582
07c5f94e 7583There are two ways of handling global BSS@. One is to define this macro.
38f8b050
JR
7584The other is to have @code{TARGET_ASM_SELECT_SECTION} return a
7585switchable BSS section (@pxref{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS}).
7586You do not need to do both.
7587
7588Some languages do not have @code{common} data, and require a
7589non-common form of global BSS in order to handle uninitialized globals
7590efficiently. C++ is one example of this. However, if the target does
7591not support global BSS, the front end may choose to make globals
7592common in order to save space in the object file.
7593@end defmac
7594
38f8b050
JR
7595@defmac ASM_OUTPUT_LOCAL (@var{stream}, @var{name}, @var{size}, @var{rounded})
7596A C statement (sans semicolon) to output to the stdio stream
7597@var{stream} the assembler definition of a local-common-label named
7598@var{name} whose size is @var{size} bytes. The variable @var{rounded}
7599is the size rounded up to whatever alignment the caller wants.
7600
7601Use the expression @code{assemble_name (@var{stream}, @var{name})} to
7602output the name itself; before and after that, output the additional
7603assembler syntax for defining the name, and a newline.
7604
7605This macro controls how the assembler definitions of uninitialized
7606static variables are output.
7607@end defmac
7608
7609@defmac ASM_OUTPUT_ALIGNED_LOCAL (@var{stream}, @var{name}, @var{size}, @var{alignment})
7610Like @code{ASM_OUTPUT_LOCAL} except takes the required alignment as a
7611separate, explicit argument. If you define this macro, it is used in
7612place of @code{ASM_OUTPUT_LOCAL}, and gives you more flexibility in
7613handling the required alignment of the variable. The alignment is specified
7614as the number of bits.
7615@end defmac
7616
7617@defmac ASM_OUTPUT_ALIGNED_DECL_LOCAL (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
7618Like @code{ASM_OUTPUT_ALIGNED_DECL} except that @var{decl} of the
7619variable to be output, if there is one, or @code{NULL_TREE} if there
7620is no corresponding variable. If you define this macro, GCC will use it
7621in place of both @code{ASM_OUTPUT_DECL} and
7622@code{ASM_OUTPUT_ALIGNED_DECL}. Define this macro when you need to see
7623the variable's decl in order to chose what to output.
7624@end defmac
7625
7626@node Label Output
7627@subsection Output and Generation of Labels
7628
7629@c prevent bad page break with this line
7630This is about outputting labels.
7631
7632@findex assemble_name
7633@defmac ASM_OUTPUT_LABEL (@var{stream}, @var{name})
7634A C statement (sans semicolon) to output to the stdio stream
7635@var{stream} the assembler definition of a label named @var{name}.
7636Use the expression @code{assemble_name (@var{stream}, @var{name})} to
7637output the name itself; before and after that, output the additional
7638assembler syntax for defining the name, and a newline. A default
7639definition of this macro is provided which is correct for most systems.
7640@end defmac
7641
135a687e
KT
7642@defmac ASM_OUTPUT_FUNCTION_LABEL (@var{stream}, @var{name}, @var{decl})
7643A C statement (sans semicolon) to output to the stdio stream
7644@var{stream} the assembler definition of a label named @var{name} of
7645a function.
7646Use the expression @code{assemble_name (@var{stream}, @var{name})} to
7647output the name itself; before and after that, output the additional
7648assembler syntax for defining the name, and a newline. A default
7649definition of this macro is provided which is correct for most systems.
7650
7651If this macro is not defined, then the function name is defined in the
7652usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
7653@end defmac
7654
38f8b050
JR
7655@findex assemble_name_raw
7656@defmac ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{name})
7657Identical to @code{ASM_OUTPUT_LABEL}, except that @var{name} is known
7658to refer to a compiler-generated label. The default definition uses
7659@code{assemble_name_raw}, which is like @code{assemble_name} except
7660that it is more efficient.
7661@end defmac
7662
7663@defmac SIZE_ASM_OP
7664A C string containing the appropriate assembler directive to specify the
7665size of a symbol, without any arguments. On systems that use ELF, the
7666default (in @file{config/elfos.h}) is @samp{"\t.size\t"}; on other
7667systems, the default is not to define this macro.
7668
7669Define this macro only if it is correct to use the default definitions
7670of @code{ASM_OUTPUT_SIZE_DIRECTIVE} and @code{ASM_OUTPUT_MEASURED_SIZE}
7671for your system. If you need your own custom definitions of those
7672macros, or if you do not need explicit symbol sizes at all, do not
7673define this macro.
7674@end defmac
7675
7676@defmac ASM_OUTPUT_SIZE_DIRECTIVE (@var{stream}, @var{name}, @var{size})
7677A C statement (sans semicolon) to output to the stdio stream
7678@var{stream} a directive telling the assembler that the size of the
7679symbol @var{name} is @var{size}. @var{size} is a @code{HOST_WIDE_INT}.
7680If you define @code{SIZE_ASM_OP}, a default definition of this macro is
7681provided.
7682@end defmac
7683
7684@defmac ASM_OUTPUT_MEASURED_SIZE (@var{stream}, @var{name})
7685A C statement (sans semicolon) to output to the stdio stream
7686@var{stream} a directive telling the assembler to calculate the size of
7687the symbol @var{name} by subtracting its address from the current
7688address.
7689
7690If you define @code{SIZE_ASM_OP}, a default definition of this macro is
7691provided. The default assumes that the assembler recognizes a special
7692@samp{.} symbol as referring to the current address, and can calculate
7693the difference between this and another symbol. If your assembler does
7694not recognize @samp{.} or cannot do calculations with it, you will need
7695to redefine @code{ASM_OUTPUT_MEASURED_SIZE} to use some other technique.
7696@end defmac
7697
e537ef59
GP
7698@defmac NO_DOLLAR_IN_LABEL
7699Define this macro if the assembler does not accept the character
7700@samp{$} in label names. By default constructors and destructors in
7701G++ have @samp{$} in the identifiers. If this macro is defined,
7702@samp{.} is used instead.
7703@end defmac
7704
7705@defmac NO_DOT_IN_LABEL
7706Define this macro if the assembler does not accept the character
7707@samp{.} in label names. By default constructors and destructors in G++
7708have names that use @samp{.}. If this macro is defined, these names
7709are rewritten to avoid @samp{.}.
7710@end defmac
7711
38f8b050
JR
7712@defmac TYPE_ASM_OP
7713A C string containing the appropriate assembler directive to specify the
7714type of a symbol, without any arguments. On systems that use ELF, the
7715default (in @file{config/elfos.h}) is @samp{"\t.type\t"}; on other
7716systems, the default is not to define this macro.
7717
7718Define this macro only if it is correct to use the default definition of
7719@code{ASM_OUTPUT_TYPE_DIRECTIVE} for your system. If you need your own
7720custom definition of this macro, or if you do not need explicit symbol
7721types at all, do not define this macro.
7722@end defmac
7723
7724@defmac TYPE_OPERAND_FMT
7725A C string which specifies (using @code{printf} syntax) the format of
7726the second operand to @code{TYPE_ASM_OP}. On systems that use ELF, the
7727default (in @file{config/elfos.h}) is @samp{"@@%s"}; on other systems,
7728the default is not to define this macro.
7729
7730Define this macro only if it is correct to use the default definition of
7731@code{ASM_OUTPUT_TYPE_DIRECTIVE} for your system. If you need your own
7732custom definition of this macro, or if you do not need explicit symbol
7733types at all, do not define this macro.
7734@end defmac
7735
7736@defmac ASM_OUTPUT_TYPE_DIRECTIVE (@var{stream}, @var{type})
7737A C statement (sans semicolon) to output to the stdio stream
7738@var{stream} a directive telling the assembler that the type of the
7739symbol @var{name} is @var{type}. @var{type} is a C string; currently,
7740that string is always either @samp{"function"} or @samp{"object"}, but
7741you should not count on this.
7742
7743If you define @code{TYPE_ASM_OP} and @code{TYPE_OPERAND_FMT}, a default
7744definition of this macro is provided.
7745@end defmac
7746
7747@defmac ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl})
7748A C statement (sans semicolon) to output to the stdio stream
7749@var{stream} any text necessary for declaring the name @var{name} of a
7750function which is being defined. This macro is responsible for
7751outputting the label definition (perhaps using
135a687e 7752@code{ASM_OUTPUT_FUNCTION_LABEL}). The argument @var{decl} is the
38f8b050
JR
7753@code{FUNCTION_DECL} tree node representing the function.
7754
7755If this macro is not defined, then the function name is defined in the
135a687e 7756usual manner as a label (by means of @code{ASM_OUTPUT_FUNCTION_LABEL}).
38f8b050
JR
7757
7758You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
7759of this macro.
7760@end defmac
7761
7762@defmac ASM_DECLARE_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl})
7763A C statement (sans semicolon) to output to the stdio stream
7764@var{stream} any text necessary for declaring the size of a function
7765which is being defined. The argument @var{name} is the name of the
7766function. The argument @var{decl} is the @code{FUNCTION_DECL} tree node
7767representing the function.
7768
7769If this macro is not defined, then the function size is not defined.
7770
7771You may wish to use @code{ASM_OUTPUT_MEASURED_SIZE} in the definition
7772of this macro.
7773@end defmac
7774
7775@defmac ASM_DECLARE_OBJECT_NAME (@var{stream}, @var{name}, @var{decl})
7776A C statement (sans semicolon) to output to the stdio stream
7777@var{stream} any text necessary for declaring the name @var{name} of an
7778initialized variable which is being defined. This macro must output the
7779label definition (perhaps using @code{ASM_OUTPUT_LABEL}). The argument
7780@var{decl} is the @code{VAR_DECL} tree node representing the variable.
7781
7782If this macro is not defined, then the variable name is defined in the
7783usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
7784
7785You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} and/or
7786@code{ASM_OUTPUT_SIZE_DIRECTIVE} in the definition of this macro.
7787@end defmac
7788
ad78130c 7789@hook TARGET_ASM_DECLARE_CONSTANT_NAME
38f8b050
JR
7790A target hook to output to the stdio stream @var{file} any text necessary
7791for declaring the name @var{name} of a constant which is being defined. This
7792target hook is responsible for outputting the label definition (perhaps using
7793@code{assemble_label}). The argument @var{exp} is the value of the constant,
7794and @var{size} is the size of the constant in bytes. The @var{name}
7795will be an internal label.
7796
7797The default version of this target hook, define the @var{name} in the
7798usual manner as a label (by means of @code{assemble_label}).
7799
7800You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in this target hook.
7801@end deftypefn
7802
7803@defmac ASM_DECLARE_REGISTER_GLOBAL (@var{stream}, @var{decl}, @var{regno}, @var{name})
7804A C statement (sans semicolon) to output to the stdio stream
7805@var{stream} any text necessary for claiming a register @var{regno}
7806for a global variable @var{decl} with name @var{name}.
7807
7808If you don't define this macro, that is equivalent to defining it to do
7809nothing.
7810@end defmac
7811
7812@defmac ASM_FINISH_DECLARE_OBJECT (@var{stream}, @var{decl}, @var{toplevel}, @var{atend})
7813A C statement (sans semicolon) to finish up declaring a variable name
7814once the compiler has processed its initializer fully and thus has had a
7815chance to determine the size of an array when controlled by an
7816initializer. This is used on systems where it's necessary to declare
7817something about the size of the object.
7818
7819If you don't define this macro, that is equivalent to defining it to do
7820nothing.
7821
7822You may wish to use @code{ASM_OUTPUT_SIZE_DIRECTIVE} and/or
7823@code{ASM_OUTPUT_MEASURED_SIZE} in the definition of this macro.
7824@end defmac
7825
7826@hook TARGET_ASM_GLOBALIZE_LABEL
7827This target hook is a function to output to the stdio stream
7828@var{stream} some commands that will make the label @var{name} global;
7829that is, available for reference from other files.
7830
7831The default implementation relies on a proper definition of
7832@code{GLOBAL_ASM_OP}.
7833@end deftypefn
7834
7835@hook TARGET_ASM_GLOBALIZE_DECL_NAME
7836This target hook is a function to output to the stdio stream
7837@var{stream} some commands that will make the name associated with @var{decl}
7838global; that is, available for reference from other files.
7839
7840The default implementation uses the TARGET_ASM_GLOBALIZE_LABEL target hook.
7841@end deftypefn
7842
7843@defmac ASM_WEAKEN_LABEL (@var{stream}, @var{name})
7844A C statement (sans semicolon) to output to the stdio stream
7845@var{stream} some commands that will make the label @var{name} weak;
7846that is, available for reference from other files but only used if
7847no other definition is available. Use the expression
7848@code{assemble_name (@var{stream}, @var{name})} to output the name
7849itself; before and after that, output the additional assembler syntax
7850for making that name weak, and a newline.
7851
7852If you don't define this macro or @code{ASM_WEAKEN_DECL}, GCC will not
7853support weak symbols and you should not define the @code{SUPPORTS_WEAK}
7854macro.
7855@end defmac
7856
7857@defmac ASM_WEAKEN_DECL (@var{stream}, @var{decl}, @var{name}, @var{value})
7858Combines (and replaces) the function of @code{ASM_WEAKEN_LABEL} and
7859@code{ASM_OUTPUT_WEAK_ALIAS}, allowing access to the associated function
7860or variable decl. If @var{value} is not @code{NULL}, this C statement
7861should output to the stdio stream @var{stream} assembler code which
7862defines (equates) the weak symbol @var{name} to have the value
7863@var{value}. If @var{value} is @code{NULL}, it should output commands
7864to make @var{name} weak.
7865@end defmac
7866
7867@defmac ASM_OUTPUT_WEAKREF (@var{stream}, @var{decl}, @var{name}, @var{value})
7868Outputs a directive that enables @var{name} to be used to refer to
7869symbol @var{value} with weak-symbol semantics. @code{decl} is the
7870declaration of @code{name}.
7871@end defmac
7872
7873@defmac SUPPORTS_WEAK
74b90fe2
JDA
7874A preprocessor constant expression which evaluates to true if the target
7875supports weak symbols.
38f8b050
JR
7876
7877If you don't define this macro, @file{defaults.h} provides a default
7878definition. If either @code{ASM_WEAKEN_LABEL} or @code{ASM_WEAKEN_DECL}
74b90fe2
JDA
7879is defined, the default definition is @samp{1}; otherwise, it is @samp{0}.
7880@end defmac
7881
7882@defmac TARGET_SUPPORTS_WEAK
7883A C expression which evaluates to true if the target supports weak symbols.
7884
7885If you don't define this macro, @file{defaults.h} provides a default
7886definition. The default definition is @samp{(SUPPORTS_WEAK)}. Define
7887this macro if you want to control weak symbol support with a compiler
7888flag such as @option{-melf}.
38f8b050
JR
7889@end defmac
7890
7891@defmac MAKE_DECL_ONE_ONLY (@var{decl})
7892A C statement (sans semicolon) to mark @var{decl} to be emitted as a
7893public symbol such that extra copies in multiple translation units will
7894be discarded by the linker. Define this macro if your object file
7895format provides support for this concept, such as the @samp{COMDAT}
7896section flags in the Microsoft Windows PE/COFF format, and this support
7897requires changes to @var{decl}, such as putting it in a separate section.
7898@end defmac
7899
7900@defmac SUPPORTS_ONE_ONLY
7901A C expression which evaluates to true if the target supports one-only
7902semantics.
7903
7904If you don't define this macro, @file{varasm.c} provides a default
7905definition. If @code{MAKE_DECL_ONE_ONLY} is defined, the default
7906definition is @samp{1}; otherwise, it is @samp{0}. Define this macro if
7907you want to control one-only symbol support with a compiler flag, or if
7908setting the @code{DECL_ONE_ONLY} flag is enough to mark a declaration to
7909be emitted as one-only.
7910@end defmac
7911
7912@hook TARGET_ASM_ASSEMBLE_VISIBILITY
7913This target hook is a function to output to @var{asm_out_file} some
7914commands that will make the symbol(s) associated with @var{decl} have
7915hidden, protected or internal visibility as specified by @var{visibility}.
7916@end deftypefn
7917
7918@defmac TARGET_WEAK_NOT_IN_ARCHIVE_TOC
7919A C expression that evaluates to true if the target's linker expects
7920that weak symbols do not appear in a static archive's table of contents.
7921The default is @code{0}.
7922
7923Leaving weak symbols out of an archive's table of contents means that,
7924if a symbol will only have a definition in one translation unit and
7925will have undefined references from other translation units, that
7926symbol should not be weak. Defining this macro to be nonzero will
7927thus have the effect that certain symbols that would normally be weak
7928(explicit template instantiations, and vtables for polymorphic classes
7929with noninline key methods) will instead be nonweak.
7930
7931The C++ ABI requires this macro to be zero. Define this macro for
7932targets where full C++ ABI compliance is impossible and where linker
7933restrictions require weak symbols to be left out of a static archive's
7934table of contents.
7935@end defmac
7936
7937@defmac ASM_OUTPUT_EXTERNAL (@var{stream}, @var{decl}, @var{name})
7938A C statement (sans semicolon) to output to the stdio stream
7939@var{stream} any text necessary for declaring the name of an external
7940symbol named @var{name} which is referenced in this compilation but
7941not defined. The value of @var{decl} is the tree node for the
7942declaration.
7943
7944This macro need not be defined if it does not need to output anything.
7945The GNU assembler and most Unix assemblers don't require anything.
7946@end defmac
7947
7948@hook TARGET_ASM_EXTERNAL_LIBCALL
7949This target hook is a function to output to @var{asm_out_file} an assembler
7950pseudo-op to declare a library function name external. The name of the
7951library function is given by @var{symref}, which is a @code{symbol_ref}.
7952@end deftypefn
7953
7954@hook TARGET_ASM_MARK_DECL_PRESERVED
7955This target hook is a function to output to @var{asm_out_file} an assembler
7956directive to annotate @var{symbol} as used. The Darwin target uses the
7957.no_dead_code_strip directive.
7958@end deftypefn
7959
7960@defmac ASM_OUTPUT_LABELREF (@var{stream}, @var{name})
7961A C statement (sans semicolon) to output to the stdio stream
7962@var{stream} a reference in assembler syntax to a label named
7963@var{name}. This should add @samp{_} to the front of the name, if that
7964is customary on your operating system, as it is in most Berkeley Unix
7965systems. This macro is used in @code{assemble_name}.
7966@end defmac
7967
77754180
DK
7968@hook TARGET_MANGLE_ASSEMBLER_NAME
7969
38f8b050
JR
7970@defmac ASM_OUTPUT_SYMBOL_REF (@var{stream}, @var{sym})
7971A C statement (sans semicolon) to output a reference to
7972@code{SYMBOL_REF} @var{sym}. If not defined, @code{assemble_name}
7973will be used to output the name of the symbol. This macro may be used
7974to modify the way a symbol is referenced depending on information
7975encoded by @code{TARGET_ENCODE_SECTION_INFO}.
7976@end defmac
7977
7978@defmac ASM_OUTPUT_LABEL_REF (@var{stream}, @var{buf})
7979A C statement (sans semicolon) to output a reference to @var{buf}, the
7980result of @code{ASM_GENERATE_INTERNAL_LABEL}. If not defined,
7981@code{assemble_name} will be used to output the name of the symbol.
7982This macro is not used by @code{output_asm_label}, or the @code{%l}
7983specifier that calls it; the intention is that this macro should be set
7984when it is necessary to output a label differently when its address is
7985being taken.
7986@end defmac
7987
7988@hook TARGET_ASM_INTERNAL_LABEL
7989A function to output to the stdio stream @var{stream} a label whose
7990name is made from the string @var{prefix} and the number @var{labelno}.
7991
7992It is absolutely essential that these labels be distinct from the labels
7993used for user-level functions and variables. Otherwise, certain programs
7994will have name conflicts with internal labels.
7995
7996It is desirable to exclude internal labels from the symbol table of the
7997object file. Most assemblers have a naming convention for labels that
7998should be excluded; on many systems, the letter @samp{L} at the
7999beginning of a label has this effect. You should find out what
8000convention your system uses, and follow it.
8001
8002The default version of this function utilizes @code{ASM_GENERATE_INTERNAL_LABEL}.
8003@end deftypefn
8004
8005@defmac ASM_OUTPUT_DEBUG_LABEL (@var{stream}, @var{prefix}, @var{num})
8006A C statement to output to the stdio stream @var{stream} a debug info
8007label whose name is made from the string @var{prefix} and the number
8008@var{num}. This is useful for VLIW targets, where debug info labels
8009may need to be treated differently than branch target labels. On some
8010systems, branch target labels must be at the beginning of instruction
8011bundles, but debug info labels can occur in the middle of instruction
8012bundles.
8013
8014If this macro is not defined, then @code{(*targetm.asm_out.internal_label)} will be
8015used.
8016@end defmac
8017
8018@defmac ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num})
8019A C statement to store into the string @var{string} a label whose name
8020is made from the string @var{prefix} and the number @var{num}.
8021
8022This string, when output subsequently by @code{assemble_name}, should
8023produce the output that @code{(*targetm.asm_out.internal_label)} would produce
8024with the same @var{prefix} and @var{num}.
8025
8026If the string begins with @samp{*}, then @code{assemble_name} will
8027output the rest of the string unchanged. It is often convenient for
8028@code{ASM_GENERATE_INTERNAL_LABEL} to use @samp{*} in this way. If the
8029string doesn't start with @samp{*}, then @code{ASM_OUTPUT_LABELREF} gets
8030to output the string, and may change it. (Of course,
8031@code{ASM_OUTPUT_LABELREF} is also part of your machine description, so
8032you should know what it does on your machine.)
8033@end defmac
8034
8035@defmac ASM_FORMAT_PRIVATE_NAME (@var{outvar}, @var{name}, @var{number})
8036A C expression to assign to @var{outvar} (which is a variable of type
8037@code{char *}) a newly allocated string made from the string
8038@var{name} and the number @var{number}, with some suitable punctuation
8039added. Use @code{alloca} to get space for the string.
8040
8041The string will be used as an argument to @code{ASM_OUTPUT_LABELREF} to
8042produce an assembler label for an internal static variable whose name is
8043@var{name}. Therefore, the string must be such as to result in valid
8044assembler code. The argument @var{number} is different each time this
8045macro is executed; it prevents conflicts between similarly-named
8046internal static variables in different scopes.
8047
8048Ideally this string should not be a valid C identifier, to prevent any
8049conflict with the user's own symbols. Most assemblers allow periods
8050or percent signs in assembler symbols; putting at least one of these
8051between the name and the number will suffice.
8052
8053If this macro is not defined, a default definition will be provided
8054which is correct for most systems.
8055@end defmac
8056
8057@defmac ASM_OUTPUT_DEF (@var{stream}, @var{name}, @var{value})
8058A C statement to output to the stdio stream @var{stream} assembler code
8059which defines (equates) the symbol @var{name} to have the value @var{value}.
8060
8061@findex SET_ASM_OP
8062If @code{SET_ASM_OP} is defined, a default definition is provided which is
8063correct for most systems.
8064@end defmac
8065
8066@defmac ASM_OUTPUT_DEF_FROM_DECLS (@var{stream}, @var{decl_of_name}, @var{decl_of_value})
8067A C statement to output to the stdio stream @var{stream} assembler code
8068which defines (equates) the symbol whose tree node is @var{decl_of_name}
8069to have the value of the tree node @var{decl_of_value}. This macro will
8070be used in preference to @samp{ASM_OUTPUT_DEF} if it is defined and if
8071the tree nodes are available.
8072
8073@findex SET_ASM_OP
8074If @code{SET_ASM_OP} is defined, a default definition is provided which is
8075correct for most systems.
8076@end defmac
8077
8078@defmac TARGET_DEFERRED_OUTPUT_DEFS (@var{decl_of_name}, @var{decl_of_value})
8079A C statement that evaluates to true if the assembler code which defines
8080(equates) the symbol whose tree node is @var{decl_of_name} to have the value
8081of the tree node @var{decl_of_value} should be emitted near the end of the
8082current compilation unit. The default is to not defer output of defines.
8083This macro affects defines output by @samp{ASM_OUTPUT_DEF} and
8084@samp{ASM_OUTPUT_DEF_FROM_DECLS}.
8085@end defmac
8086
8087@defmac ASM_OUTPUT_WEAK_ALIAS (@var{stream}, @var{name}, @var{value})
8088A C statement to output to the stdio stream @var{stream} assembler code
8089which defines (equates) the weak symbol @var{name} to have the value
8090@var{value}. If @var{value} is @code{NULL}, it defines @var{name} as
8091an undefined weak symbol.
8092
8093Define this macro if the target only supports weak aliases; define
8094@code{ASM_OUTPUT_DEF} instead if possible.
8095@end defmac
8096
8097@defmac OBJC_GEN_METHOD_LABEL (@var{buf}, @var{is_inst}, @var{class_name}, @var{cat_name}, @var{sel_name})
8098Define this macro to override the default assembler names used for
8099Objective-C methods.
8100
8101The default name is a unique method number followed by the name of the
8102class (e.g.@: @samp{_1_Foo}). For methods in categories, the name of
8103the category is also included in the assembler name (e.g.@:
8104@samp{_1_Foo_Bar}).
8105
8106These names are safe on most systems, but make debugging difficult since
8107the method's selector is not present in the name. Therefore, particular
8108systems define other ways of computing names.
8109
8110@var{buf} is an expression of type @code{char *} which gives you a
8111buffer in which to store the name; its length is as long as
8112@var{class_name}, @var{cat_name} and @var{sel_name} put together, plus
811350 characters extra.
8114
8115The argument @var{is_inst} specifies whether the method is an instance
8116method or a class method; @var{class_name} is the name of the class;
8117@var{cat_name} is the name of the category (or @code{NULL} if the method is not
8118in a category); and @var{sel_name} is the name of the selector.
8119
8120On systems where the assembler can handle quoted names, you can use this
8121macro to provide more human-readable names.
8122@end defmac
8123
38f8b050
JR
8124@node Initialization
8125@subsection How Initialization Functions Are Handled
8126@cindex initialization routines
8127@cindex termination routines
8128@cindex constructors, output of
8129@cindex destructors, output of
8130
8131The compiled code for certain languages includes @dfn{constructors}
8132(also called @dfn{initialization routines})---functions to initialize
8133data in the program when the program is started. These functions need
8134to be called before the program is ``started''---that is to say, before
8135@code{main} is called.
8136
8137Compiling some languages generates @dfn{destructors} (also called
8138@dfn{termination routines}) that should be called when the program
8139terminates.
8140
8141To make the initialization and termination functions work, the compiler
8142must output something in the assembler code to cause those functions to
8143be called at the appropriate time. When you port the compiler to a new
8144system, you need to specify how to do this.
8145
8146There are two major ways that GCC currently supports the execution of
8147initialization and termination functions. Each way has two variants.
8148Much of the structure is common to all four variations.
8149
8150@findex __CTOR_LIST__
8151@findex __DTOR_LIST__
8152The linker must build two lists of these functions---a list of
8153initialization functions, called @code{__CTOR_LIST__}, and a list of
8154termination functions, called @code{__DTOR_LIST__}.
8155
8156Each list always begins with an ignored function pointer (which may hold
81570, @minus{}1, or a count of the function pointers after it, depending on
8158the environment). This is followed by a series of zero or more function
8159pointers to constructors (or destructors), followed by a function
8160pointer containing zero.
8161
8162Depending on the operating system and its executable file format, either
8163@file{crtstuff.c} or @file{libgcc2.c} traverses these lists at startup
8164time and exit time. Constructors are called in reverse order of the
8165list; destructors in forward order.
8166
8167The best way to handle static constructors works only for object file
8168formats which provide arbitrarily-named sections. A section is set
8169aside for a list of constructors, and another for a list of destructors.
8170Traditionally these are called @samp{.ctors} and @samp{.dtors}. Each
8171object file that defines an initialization function also puts a word in
8172the constructor section to point to that function. The linker
8173accumulates all these words into one contiguous @samp{.ctors} section.
8174Termination functions are handled similarly.
8175
8176This method will be chosen as the default by @file{target-def.h} if
8177@code{TARGET_ASM_NAMED_SECTION} is defined. A target that does not
8178support arbitrary sections, but does support special designated
8179constructor and destructor sections may define @code{CTORS_SECTION_ASM_OP}
8180and @code{DTORS_SECTION_ASM_OP} to achieve the same effect.
8181
8182When arbitrary sections are available, there are two variants, depending
8183upon how the code in @file{crtstuff.c} is called. On systems that
8184support a @dfn{.init} section which is executed at program startup,
8185parts of @file{crtstuff.c} are compiled into that section. The
8186program is linked by the @command{gcc} driver like this:
8187
8188@smallexample
8189ld -o @var{output_file} crti.o crtbegin.o @dots{} -lgcc crtend.o crtn.o
8190@end smallexample
8191
8192The prologue of a function (@code{__init}) appears in the @code{.init}
8193section of @file{crti.o}; the epilogue appears in @file{crtn.o}. Likewise
8194for the function @code{__fini} in the @dfn{.fini} section. Normally these
8195files are provided by the operating system or by the GNU C library, but
8196are provided by GCC for a few targets.
8197
8198The objects @file{crtbegin.o} and @file{crtend.o} are (for most targets)
8199compiled from @file{crtstuff.c}. They contain, among other things, code
8200fragments within the @code{.init} and @code{.fini} sections that branch
8201to routines in the @code{.text} section. The linker will pull all parts
8202of a section together, which results in a complete @code{__init} function
8203that invokes the routines we need at startup.
8204
8205To use this variant, you must define the @code{INIT_SECTION_ASM_OP}
8206macro properly.
8207
8208If no init section is available, when GCC compiles any function called
8209@code{main} (or more accurately, any function designated as a program
8210entry point by the language front end calling @code{expand_main_function}),
8211it inserts a procedure call to @code{__main} as the first executable code
8212after the function prologue. The @code{__main} function is defined
8213in @file{libgcc2.c} and runs the global constructors.
8214
8215In file formats that don't support arbitrary sections, there are again
8216two variants. In the simplest variant, the GNU linker (GNU @code{ld})
8217and an `a.out' format must be used. In this case,
8218@code{TARGET_ASM_CONSTRUCTOR} is defined to produce a @code{.stabs}
8219entry of type @samp{N_SETT}, referencing the name @code{__CTOR_LIST__},
8220and with the address of the void function containing the initialization
8221code as its value. The GNU linker recognizes this as a request to add
8222the value to a @dfn{set}; the values are accumulated, and are eventually
8223placed in the executable as a vector in the format described above, with
8224a leading (ignored) count and a trailing zero element.
8225@code{TARGET_ASM_DESTRUCTOR} is handled similarly. Since no init
8226section is available, the absence of @code{INIT_SECTION_ASM_OP} causes
8227the compilation of @code{main} to call @code{__main} as above, starting
8228the initialization process.
8229
8230The last variant uses neither arbitrary sections nor the GNU linker.
8231This is preferable when you want to do dynamic linking and when using
8232file formats which the GNU linker does not support, such as `ECOFF'@. In
8233this case, @code{TARGET_HAVE_CTORS_DTORS} is false, initialization and
8234termination functions are recognized simply by their names. This requires
8235an extra program in the linkage step, called @command{collect2}. This program
8236pretends to be the linker, for use with GCC; it does its job by running
8237the ordinary linker, but also arranges to include the vectors of
8238initialization and termination functions. These functions are called
8239via @code{__main} as described above. In order to use this method,
8240@code{use_collect2} must be defined in the target in @file{config.gcc}.
8241
8242@ifinfo
8243The following section describes the specific macros that control and
8244customize the handling of initialization and termination functions.
8245@end ifinfo
8246
8247@node Macros for Initialization
8248@subsection Macros Controlling Initialization Routines
8249
8250Here are the macros that control how the compiler handles initialization
8251and termination functions:
8252
8253@defmac INIT_SECTION_ASM_OP
8254If defined, a C string constant, including spacing, for the assembler
8255operation to identify the following data as initialization code. If not
8256defined, GCC will assume such a section does not exist. When you are
8257using special sections for initialization and termination functions, this
8258macro also controls how @file{crtstuff.c} and @file{libgcc2.c} arrange to
8259run the initialization functions.
8260@end defmac
8261
8262@defmac HAS_INIT_SECTION
8263If defined, @code{main} will not call @code{__main} as described above.
8264This macro should be defined for systems that control start-up code
8265on a symbol-by-symbol basis, such as OSF/1, and should not
8266be defined explicitly for systems that support @code{INIT_SECTION_ASM_OP}.
8267@end defmac
8268
8269@defmac LD_INIT_SWITCH
8270If defined, a C string constant for a switch that tells the linker that
8271the following symbol is an initialization routine.
8272@end defmac
8273
8274@defmac LD_FINI_SWITCH
8275If defined, a C string constant for a switch that tells the linker that
8276the following symbol is a finalization routine.
8277@end defmac
8278
8279@defmac COLLECT_SHARED_INIT_FUNC (@var{stream}, @var{func})
8280If defined, a C statement that will write a function that can be
8281automatically called when a shared library is loaded. The function
8282should call @var{func}, which takes no arguments. If not defined, and
8283the object format requires an explicit initialization function, then a
8284function called @code{_GLOBAL__DI} will be generated.
8285
8286This function and the following one are used by collect2 when linking a
8287shared library that needs constructors or destructors, or has DWARF2
8288exception tables embedded in the code.
8289@end defmac
8290
8291@defmac COLLECT_SHARED_FINI_FUNC (@var{stream}, @var{func})
8292If defined, a C statement that will write a function that can be
8293automatically called when a shared library is unloaded. The function
8294should call @var{func}, which takes no arguments. If not defined, and
8295the object format requires an explicit finalization function, then a
8296function called @code{_GLOBAL__DD} will be generated.
8297@end defmac
8298
8299@defmac INVOKE__main
8300If defined, @code{main} will call @code{__main} despite the presence of
8301@code{INIT_SECTION_ASM_OP}. This macro should be defined for systems
8302where the init section is not actually run automatically, but is still
8303useful for collecting the lists of constructors and destructors.
8304@end defmac
8305
8306@defmac SUPPORTS_INIT_PRIORITY
8307If nonzero, the C++ @code{init_priority} attribute is supported and the
8308compiler should emit instructions to control the order of initialization
8309of objects. If zero, the compiler will issue an error message upon
8310encountering an @code{init_priority} attribute.
8311@end defmac
8312
8313@hook TARGET_HAVE_CTORS_DTORS
8314This value is true if the target supports some ``native'' method of
8315collecting constructors and destructors to be run at startup and exit.
8316It is false if we must use @command{collect2}.
8317@end deftypevr
8318
8319@hook TARGET_ASM_CONSTRUCTOR
8320If defined, a function that outputs assembler code to arrange to call
8321the function referenced by @var{symbol} at initialization time.
8322
8323Assume that @var{symbol} is a @code{SYMBOL_REF} for a function taking
8324no arguments and with no return value. If the target supports initialization
8325priorities, @var{priority} is a value between 0 and @code{MAX_INIT_PRIORITY};
8326otherwise it must be @code{DEFAULT_INIT_PRIORITY}.
8327
8328If this macro is not defined by the target, a suitable default will
8329be chosen if (1) the target supports arbitrary section names, (2) the
8330target defines @code{CTORS_SECTION_ASM_OP}, or (3) @code{USE_COLLECT2}
8331is not defined.
8332@end deftypefn
8333
8334@hook TARGET_ASM_DESTRUCTOR
8335This is like @code{TARGET_ASM_CONSTRUCTOR} but used for termination
8336functions rather than initialization functions.
8337@end deftypefn
8338
8339If @code{TARGET_HAVE_CTORS_DTORS} is true, the initialization routine
8340generated for the generated object file will have static linkage.
8341
8342If your system uses @command{collect2} as the means of processing
8343constructors, then that program normally uses @command{nm} to scan
8344an object file for constructor functions to be called.
8345
8346On certain kinds of systems, you can define this macro to make
8347@command{collect2} work faster (and, in some cases, make it work at all):
8348
8349@defmac OBJECT_FORMAT_COFF
8350Define this macro if the system uses COFF (Common Object File Format)
8351object files, so that @command{collect2} can assume this format and scan
8352object files directly for dynamic constructor/destructor functions.
8353
8354This macro is effective only in a native compiler; @command{collect2} as
8355part of a cross compiler always uses @command{nm} for the target machine.
8356@end defmac
8357
8358@defmac REAL_NM_FILE_NAME
8359Define this macro as a C string constant containing the file name to use
8360to execute @command{nm}. The default is to search the path normally for
8361@command{nm}.
3e794bfe
RO
8362@end defmac
8363
8364@defmac NM_FLAGS
8365@command{collect2} calls @command{nm} to scan object files for static
8366constructors and destructors and LTO info. By default, @option{-n} is
8367passed. Define @code{NM_FLAGS} to a C string constant if other options
2b0d3573 8368are needed to get the same output format as GNU @command{nm -n}
3e794bfe
RO
8369produces.
8370@end defmac
38f8b050
JR
8371
8372If your system supports shared libraries and has a program to list the
8373dynamic dependencies of a given library or executable, you can define
8374these macros to enable support for running initialization and
8375termination functions in shared libraries:
38f8b050
JR
8376
8377@defmac LDD_SUFFIX
8378Define this macro to a C string constant containing the name of the program
3e794bfe 8379which lists dynamic dependencies, like @command{ldd} under SunOS 4.
38f8b050
JR
8380@end defmac
8381
8382@defmac PARSE_LDD_OUTPUT (@var{ptr})
8383Define this macro to be C code that extracts filenames from the output
8384of the program denoted by @code{LDD_SUFFIX}. @var{ptr} is a variable
8385of type @code{char *} that points to the beginning of a line of output
8386from @code{LDD_SUFFIX}. If the line lists a dynamic dependency, the
8387code must advance @var{ptr} to the beginning of the filename on that
8388line. Otherwise, it must set @var{ptr} to @code{NULL}.
8389@end defmac
8390
8391@defmac SHLIB_SUFFIX
8392Define this macro to a C string constant containing the default shared
8393library extension of the target (e.g., @samp{".so"}). @command{collect2}
8394strips version information after this suffix when generating global
8395constructor and destructor names. This define is only needed on targets
8396that use @command{collect2} to process constructors and destructors.
8397@end defmac
8398
8399@node Instruction Output
8400@subsection Output of Assembler Instructions
8401
8402@c prevent bad page break with this line
8403This describes assembler instruction output.
8404
8405@defmac REGISTER_NAMES
8406A C initializer containing the assembler's names for the machine
8407registers, each one as a C string constant. This is what translates
8408register numbers in the compiler into assembler language.
8409@end defmac
8410
8411@defmac ADDITIONAL_REGISTER_NAMES
8412If defined, a C initializer for an array of structures containing a name
8413and a register number. This macro defines additional names for hard
8414registers, thus allowing the @code{asm} option in declarations to refer
8415to registers using alternate names.
8416@end defmac
8417
0c6d290e
RE
8418@defmac OVERLAPPING_REGISTER_NAMES
8419If defined, a C initializer for an array of structures containing a
8420name, a register number and a count of the number of consecutive
8421machine registers the name overlaps. This macro defines additional
8422names for hard registers, thus allowing the @code{asm} option in
8423declarations to refer to registers using alternate names. Unlike
8424@code{ADDITIONAL_REGISTER_NAMES}, this macro should be used when the
8425register name implies multiple underlying registers.
8426
8427This macro should be used when it is important that a clobber in an
8428@code{asm} statement clobbers all the underlying values implied by the
8429register name. For example, on ARM, clobbering the double-precision
8430VFP register ``d0'' implies clobbering both single-precision registers
8431``s0'' and ``s1''.
8432@end defmac
8433
38f8b050
JR
8434@defmac ASM_OUTPUT_OPCODE (@var{stream}, @var{ptr})
8435Define this macro if you are using an unusual assembler that
8436requires different names for the machine instructions.
8437
8438The definition is a C statement or statements which output an
8439assembler instruction opcode to the stdio stream @var{stream}. The
8440macro-operand @var{ptr} is a variable of type @code{char *} which
8441points to the opcode name in its ``internal'' form---the form that is
8442written in the machine description. The definition should output the
8443opcode name to @var{stream}, performing any translation you desire, and
8444increment the variable @var{ptr} to point at the end of the opcode
8445so that it will not be output twice.
8446
8447In fact, your macro definition may process less than the entire opcode
8448name, or more than the opcode name; but if you want to process text
8449that includes @samp{%}-sequences to substitute operands, you must take
8450care of the substitution yourself. Just be sure to increment
8451@var{ptr} over whatever text should not be output normally.
8452
8453@findex recog_data.operand
8454If you need to look at the operand values, they can be found as the
8455elements of @code{recog_data.operand}.
8456
8457If the macro definition does nothing, the instruction is output
8458in the usual way.
8459@end defmac
8460
8461@defmac FINAL_PRESCAN_INSN (@var{insn}, @var{opvec}, @var{noperands})
8462If defined, a C statement to be executed just prior to the output of
8463assembler code for @var{insn}, to modify the extracted operands so
8464they will be output differently.
8465
8466Here the argument @var{opvec} is the vector containing the operands
8467extracted from @var{insn}, and @var{noperands} is the number of
8468elements of the vector which contain meaningful data for this insn.
8469The contents of this vector are what will be used to convert the insn
8470template into assembler code, so you can change the assembler output
8471by changing the contents of the vector.
8472
8473This macro is useful when various assembler syntaxes share a single
8474file of instruction patterns; by defining this macro differently, you
8475can cause a large class of instructions to be output differently (such
8476as with rearranged operands). Naturally, variations in assembler
8477syntax affecting individual insn patterns ought to be handled by
8478writing conditional output routines in those patterns.
8479
8480If this macro is not defined, it is equivalent to a null statement.
8481@end defmac
8482
8483@hook TARGET_ASM_FINAL_POSTSCAN_INSN
8484If defined, this target hook is a function which is executed just after the
8485output of assembler code for @var{insn}, to change the mode of the assembler
8486if necessary.
8487
8488Here the argument @var{opvec} is the vector containing the operands
8489extracted from @var{insn}, and @var{noperands} is the number of
8490elements of the vector which contain meaningful data for this insn.
8491The contents of this vector are what was used to convert the insn
8492template into assembler code, so you can change the assembler mode
8493by checking the contents of the vector.
8494@end deftypefn
8495
8496@defmac PRINT_OPERAND (@var{stream}, @var{x}, @var{code})
8497A C compound statement to output to stdio stream @var{stream} the
8498assembler syntax for an instruction operand @var{x}. @var{x} is an
8499RTL expression.
8500
8501@var{code} is a value that can be used to specify one of several ways
8502of printing the operand. It is used when identical operands must be
8503printed differently depending on the context. @var{code} comes from
8504the @samp{%} specification that was used to request printing of the
8505operand. If the specification was just @samp{%@var{digit}} then
8506@var{code} is 0; if the specification was @samp{%@var{ltr}
8507@var{digit}} then @var{code} is the ASCII code for @var{ltr}.
8508
8509@findex reg_names
8510If @var{x} is a register, this macro should print the register's name.
8511The names can be found in an array @code{reg_names} whose type is
8512@code{char *[]}. @code{reg_names} is initialized from
8513@code{REGISTER_NAMES}.
8514
8515When the machine description has a specification @samp{%@var{punct}}
8516(a @samp{%} followed by a punctuation character), this macro is called
8517with a null pointer for @var{x} and the punctuation character for
8518@var{code}.
8519@end defmac
8520
8521@defmac PRINT_OPERAND_PUNCT_VALID_P (@var{code})
8522A C expression which evaluates to true if @var{code} is a valid
8523punctuation character for use in the @code{PRINT_OPERAND} macro. If
8524@code{PRINT_OPERAND_PUNCT_VALID_P} is not defined, it means that no
8525punctuation characters (except for the standard one, @samp{%}) are used
8526in this way.
8527@end defmac
8528
8529@defmac PRINT_OPERAND_ADDRESS (@var{stream}, @var{x})
8530A C compound statement to output to stdio stream @var{stream} the
8531assembler syntax for an instruction operand that is a memory reference
8532whose address is @var{x}. @var{x} is an RTL expression.
8533
8534@cindex @code{TARGET_ENCODE_SECTION_INFO} usage
8535On some machines, the syntax for a symbolic address depends on the
8536section that the address refers to. On these machines, define the hook
8537@code{TARGET_ENCODE_SECTION_INFO} to store the information into the
8538@code{symbol_ref}, and then check for it here. @xref{Assembler
8539Format}.
8540@end defmac
8541
8542@findex dbr_sequence_length
8543@defmac DBR_OUTPUT_SEQEND (@var{file})
8544A C statement, to be executed after all slot-filler instructions have
8545been output. If necessary, call @code{dbr_sequence_length} to
8546determine the number of slots filled in a sequence (zero if not
8547currently outputting a sequence), to decide how many no-ops to output,
8548or whatever.
8549
8550Don't define this macro if it has nothing to do, but it is helpful in
8551reading assembly output if the extent of the delay sequence is made
8552explicit (e.g.@: with white space).
8553@end defmac
8554
8555@findex final_sequence
8556Note that output routines for instructions with delay slots must be
8557prepared to deal with not being output as part of a sequence
8558(i.e.@: when the scheduling pass is not run, or when no slot fillers could be
8559found.) The variable @code{final_sequence} is null when not
8560processing a sequence, otherwise it contains the @code{sequence} rtx
8561being output.
8562
8563@findex asm_fprintf
8564@defmac REGISTER_PREFIX
8565@defmacx LOCAL_LABEL_PREFIX
8566@defmacx USER_LABEL_PREFIX
8567@defmacx IMMEDIATE_PREFIX
8568If defined, C string expressions to be used for the @samp{%R}, @samp{%L},
8569@samp{%U}, and @samp{%I} options of @code{asm_fprintf} (see
8570@file{final.c}). These are useful when a single @file{md} file must
8571support multiple assembler formats. In that case, the various @file{tm.h}
8572files can define these macros differently.
8573@end defmac
8574
8575@defmac ASM_FPRINTF_EXTENSIONS (@var{file}, @var{argptr}, @var{format})
8576If defined this macro should expand to a series of @code{case}
8577statements which will be parsed inside the @code{switch} statement of
8578the @code{asm_fprintf} function. This allows targets to define extra
8579printf formats which may useful when generating their assembler
8580statements. Note that uppercase letters are reserved for future
8581generic extensions to asm_fprintf, and so are not available to target
8582specific code. The output file is given by the parameter @var{file}.
8583The varargs input pointer is @var{argptr} and the rest of the format
8584string, starting the character after the one that is being switched
8585upon, is pointed to by @var{format}.
8586@end defmac
8587
8588@defmac ASSEMBLER_DIALECT
8589If your target supports multiple dialects of assembler language (such as
8590different opcodes), define this macro as a C expression that gives the
8591numeric index of the assembler language dialect to use, with zero as the
8592first variant.
8593
8594If this macro is defined, you may use constructs of the form
8595@smallexample
8596@samp{@{option0|option1|option2@dots{}@}}
8597@end smallexample
8598@noindent
8599in the output templates of patterns (@pxref{Output Template}) or in the
8600first argument of @code{asm_fprintf}. This construct outputs
8601@samp{option0}, @samp{option1}, @samp{option2}, etc., if the value of
8602@code{ASSEMBLER_DIALECT} is zero, one, two, etc. Any special characters
8603within these strings retain their usual meaning. If there are fewer
8604alternatives within the braces than the value of
8605@code{ASSEMBLER_DIALECT}, the construct outputs nothing.
8606
8607If you do not define this macro, the characters @samp{@{}, @samp{|} and
8608@samp{@}} do not have any special meaning when used in templates or
8609operands to @code{asm_fprintf}.
8610
8611Define the macros @code{REGISTER_PREFIX}, @code{LOCAL_LABEL_PREFIX},
8612@code{USER_LABEL_PREFIX} and @code{IMMEDIATE_PREFIX} if you can express
8613the variations in assembler language syntax with that mechanism. Define
8614@code{ASSEMBLER_DIALECT} and use the @samp{@{option0|option1@}} syntax
8615if the syntax variant are larger and involve such things as different
8616opcodes or operand order.
8617@end defmac
8618
8619@defmac ASM_OUTPUT_REG_PUSH (@var{stream}, @var{regno})
8620A C expression to output to @var{stream} some assembler code
8621which will push hard register number @var{regno} onto the stack.
8622The code need not be optimal, since this macro is used only when
8623profiling.
8624@end defmac
8625
8626@defmac ASM_OUTPUT_REG_POP (@var{stream}, @var{regno})
8627A C expression to output to @var{stream} some assembler code
8628which will pop hard register number @var{regno} off of the stack.
8629The code need not be optimal, since this macro is used only when
8630profiling.
8631@end defmac
8632
8633@node Dispatch Tables
8634@subsection Output of Dispatch Tables
8635
8636@c prevent bad page break with this line
8637This concerns dispatch tables.
8638
8639@cindex dispatch table
8640@defmac ASM_OUTPUT_ADDR_DIFF_ELT (@var{stream}, @var{body}, @var{value}, @var{rel})
8641A C statement to output to the stdio stream @var{stream} an assembler
8642pseudo-instruction to generate a difference between two labels.
8643@var{value} and @var{rel} are the numbers of two internal labels. The
8644definitions of these labels are output using
8645@code{(*targetm.asm_out.internal_label)}, and they must be printed in the same
8646way here. For example,
8647
8648@smallexample
8649fprintf (@var{stream}, "\t.word L%d-L%d\n",
8650 @var{value}, @var{rel})
8651@end smallexample
8652
8653You must provide this macro on machines where the addresses in a
8654dispatch table are relative to the table's own address. If defined, GCC
8655will also use this macro on all machines when producing PIC@.
8656@var{body} is the body of the @code{ADDR_DIFF_VEC}; it is provided so that the
8657mode and flags can be read.
8658@end defmac
8659
8660@defmac ASM_OUTPUT_ADDR_VEC_ELT (@var{stream}, @var{value})
8661This macro should be provided on machines where the addresses
8662in a dispatch table are absolute.
8663
8664The definition should be a C statement to output to the stdio stream
8665@var{stream} an assembler pseudo-instruction to generate a reference to
8666a label. @var{value} is the number of an internal label whose
8667definition is output using @code{(*targetm.asm_out.internal_label)}.
8668For example,
8669
8670@smallexample
8671fprintf (@var{stream}, "\t.word L%d\n", @var{value})
8672@end smallexample
8673@end defmac
8674
8675@defmac ASM_OUTPUT_CASE_LABEL (@var{stream}, @var{prefix}, @var{num}, @var{table})
8676Define this if the label before a jump-table needs to be output
8677specially. The first three arguments are the same as for
8678@code{(*targetm.asm_out.internal_label)}; the fourth argument is the
da5c6bde 8679jump-table which follows (a @code{jump_table_data} containing an
38f8b050
JR
8680@code{addr_vec} or @code{addr_diff_vec}).
8681
8682This feature is used on system V to output a @code{swbeg} statement
8683for the table.
8684
8685If this macro is not defined, these labels are output with
8686@code{(*targetm.asm_out.internal_label)}.
8687@end defmac
8688
8689@defmac ASM_OUTPUT_CASE_END (@var{stream}, @var{num}, @var{table})
8690Define this if something special must be output at the end of a
8691jump-table. The definition should be a C statement to be executed
8692after the assembler code for the table is written. It should write
8693the appropriate code to stdio stream @var{stream}. The argument
8694@var{table} is the jump-table insn, and @var{num} is the label-number
8695of the preceding label.
8696
8697If this macro is not defined, nothing special is output at the end of
8698the jump-table.
8699@end defmac
8700
8701@hook TARGET_ASM_EMIT_UNWIND_LABEL
8702This target hook emits a label at the beginning of each FDE@. It
8703should be defined on targets where FDEs need special labels, and it
8704should write the appropriate label, for the FDE associated with the
8705function declaration @var{decl}, to the stdio stream @var{stream}.
8706The third argument, @var{for_eh}, is a boolean: true if this is for an
8707exception table. The fourth argument, @var{empty}, is a boolean:
8708true if this is a placeholder label for an omitted FDE@.
8709
8710The default is that FDEs are not given nonlocal labels.
8711@end deftypefn
8712
8713@hook TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL
8714This target hook emits a label at the beginning of the exception table.
8715It should be defined on targets where it is desirable for the table
8716to be broken up according to function.
8717
8718The default is that no label is emitted.
8719@end deftypefn
8720
a68b5e52
RH
8721@hook TARGET_ASM_EMIT_EXCEPT_PERSONALITY
8722
38f8b050
JR
8723@hook TARGET_ASM_UNWIND_EMIT
8724This target hook emits assembly directives required to unwind the
f0a0390e
RH
8725given instruction. This is only used when @code{TARGET_EXCEPT_UNWIND_INFO}
8726returns @code{UI_TARGET}.
38f8b050
JR
8727@end deftypefn
8728
3bc6b3e6
RH
8729@hook TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
8730
38f8b050
JR
8731@node Exception Region Output
8732@subsection Assembler Commands for Exception Regions
8733
8734@c prevent bad page break with this line
8735
8736This describes commands marking the start and the end of an exception
8737region.
8738
8739@defmac EH_FRAME_SECTION_NAME
8740If defined, a C string constant for the name of the section containing
8741exception handling frame unwind information. If not defined, GCC will
8742provide a default definition if the target supports named sections.
8743@file{crtstuff.c} uses this macro to switch to the appropriate section.
8744
8745You should define this symbol if your target supports DWARF 2 frame
8746unwind information and the default definition does not work.
8747@end defmac
8748
8749@defmac EH_FRAME_IN_DATA_SECTION
8750If defined, DWARF 2 frame unwind information will be placed in the
8751data section even though the target supports named sections. This
8752might be necessary, for instance, if the system linker does garbage
8753collection and sections cannot be marked as not to be collected.
8754
8755Do not define this macro unless @code{TARGET_ASM_NAMED_SECTION} is
8756also defined.
8757@end defmac
8758
8759@defmac EH_TABLES_CAN_BE_READ_ONLY
8760Define this macro to 1 if your target is such that no frame unwind
8761information encoding used with non-PIC code will ever require a
8762runtime relocation, but the linker may not support merging read-only
8763and read-write sections into a single read-write section.
8764@end defmac
8765
8766@defmac MASK_RETURN_ADDR
8767An rtx used to mask the return address found via @code{RETURN_ADDR_RTX}, so
8768that it does not contain any extraneous set bits in it.
8769@end defmac
8770
8771@defmac DWARF2_UNWIND_INFO
8772Define this macro to 0 if your target supports DWARF 2 frame unwind
8773information, but it does not yet work with exception handling.
8774Otherwise, if your target supports this information (if it defines
01a07a64
SB
8775@code{INCOMING_RETURN_ADDR_RTX} and @code{OBJECT_FORMAT_ELF}),
8776GCC will provide a default definition of 1.
f0a0390e 8777@end defmac
38f8b050 8778
f0a0390e
RH
8779@hook TARGET_EXCEPT_UNWIND_INFO
8780This hook defines the mechanism that will be used for exception handling
8781by the target. If the target has ABI specified unwind tables, the hook
8782should return @code{UI_TARGET}. If the target is to use the
8783@code{setjmp}/@code{longjmp}-based exception handling scheme, the hook
8784should return @code{UI_SJLJ}. If the target supports DWARF 2 frame unwind
8785information, the hook should return @code{UI_DWARF2}.
38f8b050 8786
f0a0390e
RH
8787A target may, if exceptions are disabled, choose to return @code{UI_NONE}.
8788This may end up simplifying other parts of target-specific code. The
8789default implementation of this hook never returns @code{UI_NONE}.
38f8b050 8790
f0a0390e 8791Note that the value returned by this hook should be constant. It should
d5fabb58
JM
8792not depend on anything except the command-line switches described by
8793@var{opts}. In particular, the
f0a0390e
RH
8794setting @code{UI_SJLJ} must be fixed at compiler start-up as C pre-processor
8795macros and builtin functions related to exception handling are set up
8796depending on this setting.
8797
8798The default implementation of the hook first honors the
8799@option{--enable-sjlj-exceptions} configure option, then
d5fabb58
JM
8800@code{DWARF2_UNWIND_INFO}, and finally defaults to @code{UI_SJLJ}. If
8801@code{DWARF2_UNWIND_INFO} depends on command-line options, the target
8802must define this hook so that @var{opts} is used correctly.
f0a0390e 8803@end deftypefn
38f8b050
JR
8804
8805@hook TARGET_UNWIND_TABLES_DEFAULT
8806This variable should be set to @code{true} if the target ABI requires unwinding
d5fabb58
JM
8807tables even when exceptions are not used. It must not be modified by
8808command-line option processing.
38f8b050
JR
8809@end deftypevr
8810
38f8b050
JR
8811@defmac DONT_USE_BUILTIN_SETJMP
8812Define this macro to 1 if the @code{setjmp}/@code{longjmp}-based scheme
8813should use the @code{setjmp}/@code{longjmp} functions from the C library
8814instead of the @code{__builtin_setjmp}/@code{__builtin_longjmp} machinery.
8815@end defmac
8816
39ce30d8
SB
8817@defmac JMP_BUF_SIZE
8818This macro has no effect unless @code{DONT_USE_BUILTIN_SETJMP} is also
8819defined. Define this macro if the default size of @code{jmp_buf} buffer
8820for the @code{setjmp}/@code{longjmp}-based exception handling mechanism
8821is not large enough, or if it is much too large.
8822The default size is @code{FIRST_PSEUDO_REGISTER * sizeof(void *)}.
8823@end defmac
8824
38f8b050
JR
8825@defmac DWARF_CIE_DATA_ALIGNMENT
8826This macro need only be defined if the target might save registers in the
8827function prologue at an offset to the stack pointer that is not aligned to
8828@code{UNITS_PER_WORD}. The definition should be the negative minimum
8829alignment if @code{STACK_GROWS_DOWNWARD} is defined, and the positive
8830minimum alignment otherwise. @xref{SDB and DWARF}. Only applicable if
8831the target supports DWARF 2 frame unwind information.
8832@end defmac
8833
8834@hook TARGET_TERMINATE_DW2_EH_FRAME_INFO
8835Contains the value true if the target should add a zero word onto the
8836end of a Dwarf-2 frame info section when used for exception handling.
8837Default value is false if @code{EH_FRAME_SECTION_NAME} is defined, and
8838true otherwise.
8839@end deftypevr
8840
8841@hook TARGET_DWARF_REGISTER_SPAN
8842Given a register, this hook should return a parallel of registers to
8843represent where to find the register pieces. Define this hook if the
8844register and its mode are represented in Dwarf in non-contiguous
8845locations, or if the register should be represented in more than one
8846register in Dwarf. Otherwise, this hook should return @code{NULL_RTX}.
8847If not defined, the default is to return @code{NULL_RTX}.
8848@end deftypefn
8849
8850@hook TARGET_INIT_DWARF_REG_SIZES_EXTRA
8851If some registers are represented in Dwarf-2 unwind information in
8852multiple pieces, define this hook to fill in information about the
8853sizes of those pieces in the table used by the unwinder at runtime.
8854It will be called by @code{expand_builtin_init_dwarf_reg_sizes} after
8855filling in a single size corresponding to each hard register;
8856@var{address} is the address of the table.
8857@end deftypefn
8858
8859@hook TARGET_ASM_TTYPE
8860This hook is used to output a reference from a frame unwinding table to
8861the type_info object identified by @var{sym}. It should return @code{true}
8862if the reference was output. Returning @code{false} will cause the
8863reference to be output using the normal Dwarf2 routines.
8864@end deftypefn
8865
8866@hook TARGET_ARM_EABI_UNWINDER
8867This flag should be set to @code{true} on targets that use an ARM EABI
8868based unwinding library, and @code{false} on other targets. This effects
8869the format of unwinding tables, and how the unwinder in entered after
8870running a cleanup. The default is @code{false}.
8871@end deftypevr
8872
8873@node Alignment Output
8874@subsection Assembler Commands for Alignment
8875
8876@c prevent bad page break with this line
8877This describes commands for alignment.
8878
8879@defmac JUMP_ALIGN (@var{label})
8880The alignment (log base 2) to put in front of @var{label}, which is
8881a common destination of jumps and has no fallthru incoming edge.
8882
8883This macro need not be defined if you don't want any special alignment
8884to be done at such a time. Most machine descriptions do not currently
8885define the macro.
8886
8887Unless it's necessary to inspect the @var{label} parameter, it is better
8888to set the variable @var{align_jumps} in the target's
8889@code{TARGET_OPTION_OVERRIDE}. Otherwise, you should try to honor the user's
8890selection in @var{align_jumps} in a @code{JUMP_ALIGN} implementation.
8891@end defmac
8892
ad0c4c36
DD
8893@hook TARGET_ASM_JUMP_ALIGN_MAX_SKIP
8894The maximum number of bytes to skip before @var{label} when applying
8895@code{JUMP_ALIGN}. This works only if
8896@code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined.
8897@end deftypefn
8898
38f8b050
JR
8899@defmac LABEL_ALIGN_AFTER_BARRIER (@var{label})
8900The alignment (log base 2) to put in front of @var{label}, which follows
8901a @code{BARRIER}.
8902
8903This macro need not be defined if you don't want any special alignment
8904to be done at such a time. Most machine descriptions do not currently
8905define the macro.
8906@end defmac
8907
ad0c4c36
DD
8908@hook TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
8909The maximum number of bytes to skip before @var{label} when applying
38f8b050
JR
8910@code{LABEL_ALIGN_AFTER_BARRIER}. This works only if
8911@code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined.
ad0c4c36 8912@end deftypefn
38f8b050
JR
8913
8914@defmac LOOP_ALIGN (@var{label})
58a51369
SB
8915The alignment (log base 2) to put in front of @var{label} that heads
8916a frequently executed basic block (usually the header of a loop).
38f8b050
JR
8917
8918This macro need not be defined if you don't want any special alignment
8919to be done at such a time. Most machine descriptions do not currently
8920define the macro.
8921
8922Unless it's necessary to inspect the @var{label} parameter, it is better
8923to set the variable @code{align_loops} in the target's
8924@code{TARGET_OPTION_OVERRIDE}. Otherwise, you should try to honor the user's
8925selection in @code{align_loops} in a @code{LOOP_ALIGN} implementation.
8926@end defmac
8927
ad0c4c36
DD
8928@hook TARGET_ASM_LOOP_ALIGN_MAX_SKIP
8929The maximum number of bytes to skip when applying @code{LOOP_ALIGN} to
8930@var{label}. This works only if @code{ASM_OUTPUT_MAX_SKIP_ALIGN} is
8931defined.
8932@end deftypefn
38f8b050
JR
8933
8934@defmac LABEL_ALIGN (@var{label})
8935The alignment (log base 2) to put in front of @var{label}.
8936If @code{LABEL_ALIGN_AFTER_BARRIER} / @code{LOOP_ALIGN} specify a different alignment,
8937the maximum of the specified values is used.
8938
8939Unless it's necessary to inspect the @var{label} parameter, it is better
8940to set the variable @code{align_labels} in the target's
8941@code{TARGET_OPTION_OVERRIDE}. Otherwise, you should try to honor the user's
8942selection in @code{align_labels} in a @code{LABEL_ALIGN} implementation.
8943@end defmac
8944
ad0c4c36
DD
8945@hook TARGET_ASM_LABEL_ALIGN_MAX_SKIP
8946The maximum number of bytes to skip when applying @code{LABEL_ALIGN}
8947to @var{label}. This works only if @code{ASM_OUTPUT_MAX_SKIP_ALIGN}
8948is defined.
8949@end deftypefn
38f8b050
JR
8950
8951@defmac ASM_OUTPUT_SKIP (@var{stream}, @var{nbytes})
8952A C statement to output to the stdio stream @var{stream} an assembler
8953instruction to advance the location counter by @var{nbytes} bytes.
8954Those bytes should be zero when loaded. @var{nbytes} will be a C
8955expression of type @code{unsigned HOST_WIDE_INT}.
8956@end defmac
8957
8958@defmac ASM_NO_SKIP_IN_TEXT
8959Define this macro if @code{ASM_OUTPUT_SKIP} should not be used in the
8960text section because it fails to put zeros in the bytes that are skipped.
8961This is true on many Unix systems, where the pseudo--op to skip bytes
8962produces no-op instructions rather than zeros when used in the text
8963section.
8964@end defmac
8965
8966@defmac ASM_OUTPUT_ALIGN (@var{stream}, @var{power})
8967A C statement to output to the stdio stream @var{stream} an assembler
8968command to advance the location counter to a multiple of 2 to the
8969@var{power} bytes. @var{power} will be a C expression of type @code{int}.
8970@end defmac
8971
8972@defmac ASM_OUTPUT_ALIGN_WITH_NOP (@var{stream}, @var{power})
8973Like @code{ASM_OUTPUT_ALIGN}, except that the ``nop'' instruction is used
8974for padding, if necessary.
8975@end defmac
8976
8977@defmac ASM_OUTPUT_MAX_SKIP_ALIGN (@var{stream}, @var{power}, @var{max_skip})
8978A C statement to output to the stdio stream @var{stream} an assembler
8979command to advance the location counter to a multiple of 2 to the
8980@var{power} bytes, but only if @var{max_skip} or fewer bytes are needed to
8981satisfy the alignment request. @var{power} and @var{max_skip} will be
8982a C expression of type @code{int}.
8983@end defmac
8984
8985@need 3000
8986@node Debugging Info
8987@section Controlling Debugging Information Format
8988
8989@c prevent bad page break with this line
8990This describes how to specify debugging information.
8991
8992@menu
8993* All Debuggers:: Macros that affect all debugging formats uniformly.
8994* DBX Options:: Macros enabling specific options in DBX format.
8995* DBX Hooks:: Hook macros for varying DBX format.
8996* File Names and DBX:: Macros controlling output of file names in DBX format.
8997* SDB and DWARF:: Macros for SDB (COFF) and DWARF formats.
8998* VMS Debug:: Macros for VMS debug format.
8999@end menu
9000
9001@node All Debuggers
9002@subsection Macros Affecting All Debugging Formats
9003
9004@c prevent bad page break with this line
9005These macros affect all debugging formats.
9006
9007@defmac DBX_REGISTER_NUMBER (@var{regno})
9008A C expression that returns the DBX register number for the compiler
9009register number @var{regno}. In the default macro provided, the value
9010of this expression will be @var{regno} itself. But sometimes there are
9011some registers that the compiler knows about and DBX does not, or vice
9012versa. In such cases, some register may need to have one number in the
9013compiler and another for DBX@.
9014
9015If two registers have consecutive numbers inside GCC, and they can be
9016used as a pair to hold a multiword value, then they @emph{must} have
9017consecutive numbers after renumbering with @code{DBX_REGISTER_NUMBER}.
9018Otherwise, debuggers will be unable to access such a pair, because they
9019expect register pairs to be consecutive in their own numbering scheme.
9020
9021If you find yourself defining @code{DBX_REGISTER_NUMBER} in way that
9022does not preserve register pairs, then what you must do instead is
9023redefine the actual register numbering scheme.
9024@end defmac
9025
9026@defmac DEBUGGER_AUTO_OFFSET (@var{x})
9027A C expression that returns the integer offset value for an automatic
9028variable having address @var{x} (an RTL expression). The default
9029computation assumes that @var{x} is based on the frame-pointer and
9030gives the offset from the frame-pointer. This is required for targets
9031that produce debugging output for DBX or COFF-style debugging output
9032for SDB and allow the frame-pointer to be eliminated when the
9033@option{-g} options is used.
9034@end defmac
9035
9036@defmac DEBUGGER_ARG_OFFSET (@var{offset}, @var{x})
9037A C expression that returns the integer offset value for an argument
9038having address @var{x} (an RTL expression). The nominal offset is
9039@var{offset}.
9040@end defmac
9041
9042@defmac PREFERRED_DEBUGGING_TYPE
9043A C expression that returns the type of debugging output GCC should
9044produce when the user specifies just @option{-g}. Define
9045this if you have arranged for GCC to support more than one format of
9046debugging output. Currently, the allowable values are @code{DBX_DEBUG},
9047@code{SDB_DEBUG}, @code{DWARF_DEBUG}, @code{DWARF2_DEBUG},
9048@code{XCOFF_DEBUG}, @code{VMS_DEBUG}, and @code{VMS_AND_DWARF2_DEBUG}.
9049
9050When the user specifies @option{-ggdb}, GCC normally also uses the
9051value of this macro to select the debugging output format, but with two
9052exceptions. If @code{DWARF2_DEBUGGING_INFO} is defined, GCC uses the
9053value @code{DWARF2_DEBUG}. Otherwise, if @code{DBX_DEBUGGING_INFO} is
9054defined, GCC uses @code{DBX_DEBUG}.
9055
9056The value of this macro only affects the default debugging output; the
9057user can always get a specific type of output by using @option{-gstabs},
9058@option{-gcoff}, @option{-gdwarf-2}, @option{-gxcoff}, or @option{-gvms}.
9059@end defmac
9060
9061@node DBX Options
9062@subsection Specific Options for DBX Output
9063
9064@c prevent bad page break with this line
9065These are specific options for DBX output.
9066
9067@defmac DBX_DEBUGGING_INFO
9068Define this macro if GCC should produce debugging output for DBX
9069in response to the @option{-g} option.
9070@end defmac
9071
9072@defmac XCOFF_DEBUGGING_INFO
9073Define this macro if GCC should produce XCOFF format debugging output
9074in response to the @option{-g} option. This is a variant of DBX format.
9075@end defmac
9076
9077@defmac DEFAULT_GDB_EXTENSIONS
9078Define this macro to control whether GCC should by default generate
9079GDB's extended version of DBX debugging information (assuming DBX-format
9080debugging information is enabled at all). If you don't define the
9081macro, the default is 1: always generate the extended information
9082if there is any occasion to.
9083@end defmac
9084
9085@defmac DEBUG_SYMS_TEXT
9086Define this macro if all @code{.stabs} commands should be output while
9087in the text section.
9088@end defmac
9089
9090@defmac ASM_STABS_OP
9091A C string constant, including spacing, naming the assembler pseudo op to
9092use instead of @code{"\t.stabs\t"} to define an ordinary debugging symbol.
9093If you don't define this macro, @code{"\t.stabs\t"} is used. This macro
9094applies only to DBX debugging information format.
9095@end defmac
9096
9097@defmac ASM_STABD_OP
9098A C string constant, including spacing, naming the assembler pseudo op to
9099use instead of @code{"\t.stabd\t"} to define a debugging symbol whose
9100value is the current location. If you don't define this macro,
9101@code{"\t.stabd\t"} is used. This macro applies only to DBX debugging
9102information format.
9103@end defmac
9104
9105@defmac ASM_STABN_OP
9106A C string constant, including spacing, naming the assembler pseudo op to
9107use instead of @code{"\t.stabn\t"} to define a debugging symbol with no
9108name. If you don't define this macro, @code{"\t.stabn\t"} is used. This
9109macro applies only to DBX debugging information format.
9110@end defmac
9111
9112@defmac DBX_NO_XREFS
9113Define this macro if DBX on your system does not support the construct
9114@samp{xs@var{tagname}}. On some systems, this construct is used to
9115describe a forward reference to a structure named @var{tagname}.
9116On other systems, this construct is not supported at all.
9117@end defmac
9118
9119@defmac DBX_CONTIN_LENGTH
9120A symbol name in DBX-format debugging information is normally
9121continued (split into two separate @code{.stabs} directives) when it
9122exceeds a certain length (by default, 80 characters). On some
9123operating systems, DBX requires this splitting; on others, splitting
9124must not be done. You can inhibit splitting by defining this macro
9125with the value zero. You can override the default splitting-length by
9126defining this macro as an expression for the length you desire.
9127@end defmac
9128
9129@defmac DBX_CONTIN_CHAR
9130Normally continuation is indicated by adding a @samp{\} character to
9131the end of a @code{.stabs} string when a continuation follows. To use
9132a different character instead, define this macro as a character
9133constant for the character you want to use. Do not define this macro
9134if backslash is correct for your system.
9135@end defmac
9136
9137@defmac DBX_STATIC_STAB_DATA_SECTION
9138Define this macro if it is necessary to go to the data section before
9139outputting the @samp{.stabs} pseudo-op for a non-global static
9140variable.
9141@end defmac
9142
9143@defmac DBX_TYPE_DECL_STABS_CODE
9144The value to use in the ``code'' field of the @code{.stabs} directive
9145for a typedef. The default is @code{N_LSYM}.
9146@end defmac
9147
9148@defmac DBX_STATIC_CONST_VAR_CODE
9149The value to use in the ``code'' field of the @code{.stabs} directive
9150for a static variable located in the text section. DBX format does not
9151provide any ``right'' way to do this. The default is @code{N_FUN}.
9152@end defmac
9153
9154@defmac DBX_REGPARM_STABS_CODE
9155The value to use in the ``code'' field of the @code{.stabs} directive
9156for a parameter passed in registers. DBX format does not provide any
9157``right'' way to do this. The default is @code{N_RSYM}.
9158@end defmac
9159
9160@defmac DBX_REGPARM_STABS_LETTER
9161The letter to use in DBX symbol data to identify a symbol as a parameter
9162passed in registers. DBX format does not customarily provide any way to
9163do this. The default is @code{'P'}.
9164@end defmac
9165
9166@defmac DBX_FUNCTION_FIRST
9167Define this macro if the DBX information for a function and its
9168arguments should precede the assembler code for the function. Normally,
9169in DBX format, the debugging information entirely follows the assembler
9170code.
9171@end defmac
9172
9173@defmac DBX_BLOCKS_FUNCTION_RELATIVE
9174Define this macro, with value 1, if the value of a symbol describing
9175the scope of a block (@code{N_LBRAC} or @code{N_RBRAC}) should be
9176relative to the start of the enclosing function. Normally, GCC uses
9177an absolute address.
9178@end defmac
9179
9180@defmac DBX_LINES_FUNCTION_RELATIVE
9181Define this macro, with value 1, if the value of a symbol indicating
9182the current line number (@code{N_SLINE}) should be relative to the
9183start of the enclosing function. Normally, GCC uses an absolute address.
9184@end defmac
9185
9186@defmac DBX_USE_BINCL
9187Define this macro if GCC should generate @code{N_BINCL} and
9188@code{N_EINCL} stabs for included header files, as on Sun systems. This
9189macro also directs GCC to output a type number as a pair of a file
9190number and a type number within the file. Normally, GCC does not
9191generate @code{N_BINCL} or @code{N_EINCL} stabs, and it outputs a single
9192number for a type number.
9193@end defmac
9194
9195@node DBX Hooks
9196@subsection Open-Ended Hooks for DBX Format
9197
9198@c prevent bad page break with this line
9199These are hooks for DBX format.
9200
38f8b050
JR
9201@defmac DBX_OUTPUT_SOURCE_LINE (@var{stream}, @var{line}, @var{counter})
9202A C statement to output DBX debugging information before code for line
9203number @var{line} of the current source file to the stdio stream
9204@var{stream}. @var{counter} is the number of time the macro was
9205invoked, including the current invocation; it is intended to generate
9206unique labels in the assembly output.
9207
9208This macro should not be defined if the default output is correct, or
9209if it can be made correct by defining @code{DBX_LINES_FUNCTION_RELATIVE}.
9210@end defmac
9211
9212@defmac NO_DBX_FUNCTION_END
9213Some stabs encapsulation formats (in particular ECOFF), cannot handle the
9214@code{.stabs "",N_FUN,,0,0,Lscope-function-1} gdb dbx extension construct.
9215On those machines, define this macro to turn this feature off without
9216disturbing the rest of the gdb extensions.
9217@end defmac
9218
9219@defmac NO_DBX_BNSYM_ENSYM
9220Some assemblers cannot handle the @code{.stabd BNSYM/ENSYM,0,0} gdb dbx
9221extension construct. On those machines, define this macro to turn this
9222feature off without disturbing the rest of the gdb extensions.
9223@end defmac
9224
9225@node File Names and DBX
9226@subsection File Names in DBX Format
9227
9228@c prevent bad page break with this line
9229This describes file names in DBX format.
9230
9231@defmac DBX_OUTPUT_MAIN_SOURCE_FILENAME (@var{stream}, @var{name})
9232A C statement to output DBX debugging information to the stdio stream
9233@var{stream}, which indicates that file @var{name} is the main source
9234file---the file specified as the input file for compilation.
9235This macro is called only once, at the beginning of compilation.
9236
9237This macro need not be defined if the standard form of output
9238for DBX debugging information is appropriate.
9239
9240It may be necessary to refer to a label equal to the beginning of the
9241text section. You can use @samp{assemble_name (stream, ltext_label_name)}
9242to do so. If you do this, you must also set the variable
9243@var{used_ltext_label_name} to @code{true}.
9244@end defmac
9245
9246@defmac NO_DBX_MAIN_SOURCE_DIRECTORY
9247Define this macro, with value 1, if GCC should not emit an indication
9248of the current directory for compilation and current source language at
9249the beginning of the file.
9250@end defmac
9251
9252@defmac NO_DBX_GCC_MARKER
9253Define this macro, with value 1, if GCC should not emit an indication
9254that this object file was compiled by GCC@. The default is to emit
9255an @code{N_OPT} stab at the beginning of every source file, with
9256@samp{gcc2_compiled.} for the string and value 0.
9257@end defmac
9258
9259@defmac DBX_OUTPUT_MAIN_SOURCE_FILE_END (@var{stream}, @var{name})
9260A C statement to output DBX debugging information at the end of
9261compilation of the main source file @var{name}. Output should be
9262written to the stdio stream @var{stream}.
9263
9264If you don't define this macro, nothing special is output at the end
9265of compilation, which is correct for most machines.
9266@end defmac
9267
9268@defmac DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
9269Define this macro @emph{instead of} defining
9270@code{DBX_OUTPUT_MAIN_SOURCE_FILE_END}, if what needs to be output at
9271the end of compilation is an @code{N_SO} stab with an empty string,
9272whose value is the highest absolute text address in the file.
9273@end defmac
9274
9275@need 2000
9276@node SDB and DWARF
9277@subsection Macros for SDB and DWARF Output
9278
9279@c prevent bad page break with this line
9280Here are macros for SDB and DWARF output.
9281
9282@defmac SDB_DEBUGGING_INFO
9283Define this macro if GCC should produce COFF-style debugging output
9284for SDB in response to the @option{-g} option.
9285@end defmac
9286
9287@defmac DWARF2_DEBUGGING_INFO
9288Define this macro if GCC should produce dwarf version 2 format
9289debugging output in response to the @option{-g} option.
9290
9291@hook TARGET_DWARF_CALLING_CONVENTION
9292Define this to enable the dwarf attribute @code{DW_AT_calling_convention} to
9293be emitted for each function. Instead of an integer return the enum
9294value for the @code{DW_CC_} tag.
9295@end deftypefn
9296
9297To support optional call frame debugging information, you must also
9298define @code{INCOMING_RETURN_ADDR_RTX} and either set
9299@code{RTX_FRAME_RELATED_P} on the prologue insns if you use RTL for the
9300prologue, or call @code{dwarf2out_def_cfa} and @code{dwarf2out_reg_save}
9301as appropriate from @code{TARGET_ASM_FUNCTION_PROLOGUE} if you don't.
9302@end defmac
9303
9304@defmac DWARF2_FRAME_INFO
9305Define this macro to a nonzero value if GCC should always output
f0a0390e
RH
9306Dwarf 2 frame information. If @code{TARGET_EXCEPT_UNWIND_INFO}
9307(@pxref{Exception Region Output}) returns @code{UI_DWARF2}, and
9308exceptions are enabled, GCC will output this information not matter
9309how you define @code{DWARF2_FRAME_INFO}.
38f8b050
JR
9310@end defmac
9311
f0a0390e
RH
9312@hook TARGET_DEBUG_UNWIND_INFO
9313This hook defines the mechanism that will be used for describing frame
9314unwind information to the debugger. Normally the hook will return
9315@code{UI_DWARF2} if DWARF 2 debug information is enabled, and
9316return @code{UI_NONE} otherwise.
9317
9318A target may return @code{UI_DWARF2} even when DWARF 2 debug information
9319is disabled in order to always output DWARF 2 frame information.
9320
9321A target may return @code{UI_TARGET} if it has ABI specified unwind tables.
9322This will suppress generation of the normal debug frame unwind information.
9323@end deftypefn
9324
38f8b050
JR
9325@defmac DWARF2_ASM_LINE_DEBUG_INFO
9326Define this macro to be a nonzero value if the assembler can generate Dwarf 2
9327line debug info sections. This will result in much more compact line number
9328tables, and hence is desirable if it works.
9329@end defmac
9330
9730bc27
TT
9331@hook TARGET_WANT_DEBUG_PUB_SECTIONS
9332
638c962f
JH
9333@hook TARGET_FORCE_AT_COMP_DIR
9334
2ba42841
AO
9335@hook TARGET_DELAY_SCHED2
9336
9337@hook TARGET_DELAY_VARTRACK
9338
38f8b050
JR
9339@defmac ASM_OUTPUT_DWARF_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
9340A C statement to issue assembly directives that create a difference
9341@var{lab1} minus @var{lab2}, using an integer of the given @var{size}.
9342@end defmac
9343
9344@defmac ASM_OUTPUT_DWARF_VMS_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
9345A C statement to issue assembly directives that create a difference
9346between the two given labels in system defined units, e.g. instruction
9347slots on IA64 VMS, using an integer of the given size.
9348@end defmac
9349
9350@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, @var{section})
9351A C statement to issue assembly directives that create a
9352section-relative reference to the given @var{label}, using an integer of the
9353given @var{size}. The label is known to be defined in the given @var{section}.
9354@end defmac
9355
9356@defmac ASM_OUTPUT_DWARF_PCREL (@var{stream}, @var{size}, @var{label})
9357A C statement to issue assembly directives that create a self-relative
9358reference to the given @var{label}, using an integer of the given @var{size}.
9359@end defmac
9360
9361@defmac ASM_OUTPUT_DWARF_TABLE_REF (@var{label})
9362A C statement to issue assembly directives that create a reference to
9363the DWARF table identifier @var{label} from the current section. This
9364is used on some systems to avoid garbage collecting a DWARF table which
9365is referenced by a function.
9366@end defmac
9367
9368@hook TARGET_ASM_OUTPUT_DWARF_DTPREL
9369If defined, this target hook is a function which outputs a DTP-relative
9370reference to the given TLS symbol of the specified size.
9371@end deftypefn
9372
9373@defmac PUT_SDB_@dots{}
9374Define these macros to override the assembler syntax for the special
9375SDB assembler directives. See @file{sdbout.c} for a list of these
9376macros and their arguments. If the standard syntax is used, you need
9377not define them yourself.
9378@end defmac
9379
9380@defmac SDB_DELIM
9381Some assemblers do not support a semicolon as a delimiter, even between
9382SDB assembler directives. In that case, define this macro to be the
9383delimiter to use (usually @samp{\n}). It is not necessary to define
9384a new set of @code{PUT_SDB_@var{op}} macros if this is the only change
9385required.
9386@end defmac
9387
9388@defmac SDB_ALLOW_UNKNOWN_REFERENCES
9389Define this macro to allow references to unknown structure,
9390union, or enumeration tags to be emitted. Standard COFF does not
9391allow handling of unknown references, MIPS ECOFF has support for
9392it.
9393@end defmac
9394
9395@defmac SDB_ALLOW_FORWARD_REFERENCES
9396Define this macro to allow references to structure, union, or
9397enumeration tags that have not yet been seen to be handled. Some
9398assemblers choke if forward tags are used, while some require it.
9399@end defmac
9400
9401@defmac SDB_OUTPUT_SOURCE_LINE (@var{stream}, @var{line})
9402A C statement to output SDB debugging information before code for line
9403number @var{line} of the current source file to the stdio stream
9404@var{stream}. The default is to emit an @code{.ln} directive.
9405@end defmac
9406
9407@need 2000
9408@node VMS Debug
9409@subsection Macros for VMS Debug Format
9410
9411@c prevent bad page break with this line
9412Here are macros for VMS debug format.
9413
9414@defmac VMS_DEBUGGING_INFO
9415Define this macro if GCC should produce debugging output for VMS
9416in response to the @option{-g} option. The default behavior for VMS
9417is to generate minimal debug info for a traceback in the absence of
9418@option{-g} unless explicitly overridden with @option{-g0}. This
fac0f722 9419behavior is controlled by @code{TARGET_OPTION_OPTIMIZATION} and
38f8b050
JR
9420@code{TARGET_OPTION_OVERRIDE}.
9421@end defmac
9422
9423@node Floating Point
9424@section Cross Compilation and Floating Point
9425@cindex cross compilation and floating point
9426@cindex floating point and cross compilation
9427
9428While all modern machines use twos-complement representation for integers,
9429there are a variety of representations for floating point numbers. This
9430means that in a cross-compiler the representation of floating point numbers
9431in the compiled program may be different from that used in the machine
9432doing the compilation.
9433
9434Because different representation systems may offer different amounts of
9435range and precision, all floating point constants must be represented in
9436the target machine's format. Therefore, the cross compiler cannot
9437safely use the host machine's floating point arithmetic; it must emulate
9438the target's arithmetic. To ensure consistency, GCC always uses
9439emulation to work with floating point values, even when the host and
9440target floating point formats are identical.
9441
9442The following macros are provided by @file{real.h} for the compiler to
9443use. All parts of the compiler which generate or optimize
9444floating-point calculations must use these macros. They may evaluate
9445their operands more than once, so operands must not have side effects.
9446
9447@defmac REAL_VALUE_TYPE
9448The C data type to be used to hold a floating point value in the target
9449machine's format. Typically this is a @code{struct} containing an
9450array of @code{HOST_WIDE_INT}, but all code should treat it as an opaque
9451quantity.
9452@end defmac
9453
9454@deftypefn Macro int REAL_VALUES_EQUAL (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y})
9455Compares for equality the two values, @var{x} and @var{y}. If the target
9456floating point format supports negative zeroes and/or NaNs,
9457@samp{REAL_VALUES_EQUAL (-0.0, 0.0)} is true, and
9458@samp{REAL_VALUES_EQUAL (NaN, NaN)} is false.
9459@end deftypefn
9460
9461@deftypefn Macro int REAL_VALUES_LESS (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y})
9462Tests whether @var{x} is less than @var{y}.
9463@end deftypefn
9464
9465@deftypefn Macro HOST_WIDE_INT REAL_VALUE_FIX (REAL_VALUE_TYPE @var{x})
9466Truncates @var{x} to a signed integer, rounding toward zero.
9467@end deftypefn
9468
9469@deftypefn Macro {unsigned HOST_WIDE_INT} REAL_VALUE_UNSIGNED_FIX (REAL_VALUE_TYPE @var{x})
9470Truncates @var{x} to an unsigned integer, rounding toward zero. If
9471@var{x} is negative, returns zero.
9472@end deftypefn
9473
9474@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ATOF (const char *@var{string}, enum machine_mode @var{mode})
9475Converts @var{string} into a floating point number in the target machine's
9476representation for mode @var{mode}. This routine can handle both
9477decimal and hexadecimal floating point constants, using the syntax
9478defined by the C language for both.
9479@end deftypefn
9480
9481@deftypefn Macro int REAL_VALUE_NEGATIVE (REAL_VALUE_TYPE @var{x})
9482Returns 1 if @var{x} is negative (including negative zero), 0 otherwise.
9483@end deftypefn
9484
9485@deftypefn Macro int REAL_VALUE_ISINF (REAL_VALUE_TYPE @var{x})
9486Determines whether @var{x} represents infinity (positive or negative).
9487@end deftypefn
9488
9489@deftypefn Macro int REAL_VALUE_ISNAN (REAL_VALUE_TYPE @var{x})
9490Determines whether @var{x} represents a ``NaN'' (not-a-number).
9491@end deftypefn
9492
9493@deftypefn Macro void REAL_ARITHMETIC (REAL_VALUE_TYPE @var{output}, enum tree_code @var{code}, REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y})
9494Calculates an arithmetic operation on the two floating point values
9495@var{x} and @var{y}, storing the result in @var{output} (which must be a
9496variable).
9497
9498The operation to be performed is specified by @var{code}. Only the
9499following codes are supported: @code{PLUS_EXPR}, @code{MINUS_EXPR},
9500@code{MULT_EXPR}, @code{RDIV_EXPR}, @code{MAX_EXPR}, @code{MIN_EXPR}.
9501
9502If @code{REAL_ARITHMETIC} is asked to evaluate division by zero and the
9503target's floating point format cannot represent infinity, it will call
9504@code{abort}. Callers should check for this situation first, using
9505@code{MODE_HAS_INFINITIES}. @xref{Storage Layout}.
9506@end deftypefn
9507
9508@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_NEGATE (REAL_VALUE_TYPE @var{x})
9509Returns the negative of the floating point value @var{x}.
9510@end deftypefn
9511
9512@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ABS (REAL_VALUE_TYPE @var{x})
9513Returns the absolute value of @var{x}.
9514@end deftypefn
9515
38f8b050
JR
9516@deftypefn Macro void REAL_VALUE_TO_INT (HOST_WIDE_INT @var{low}, HOST_WIDE_INT @var{high}, REAL_VALUE_TYPE @var{x})
9517Converts a floating point value @var{x} into a double-precision integer
9518which is then stored into @var{low} and @var{high}. If the value is not
9519integral, it is truncated.
9520@end deftypefn
9521
9522@deftypefn Macro void REAL_VALUE_FROM_INT (REAL_VALUE_TYPE @var{x}, HOST_WIDE_INT @var{low}, HOST_WIDE_INT @var{high}, enum machine_mode @var{mode})
9523Converts a double-precision integer found in @var{low} and @var{high},
9524into a floating point value which is then stored into @var{x}. The
9525value is truncated to fit in mode @var{mode}.
9526@end deftypefn
9527
9528@node Mode Switching
9529@section Mode Switching Instructions
9530@cindex mode switching
9531The following macros control mode switching optimizations:
9532
9533@defmac OPTIMIZE_MODE_SWITCHING (@var{entity})
9534Define this macro if the port needs extra instructions inserted for mode
9535switching in an optimizing compilation.
9536
9537For an example, the SH4 can perform both single and double precision
9538floating point operations, but to perform a single precision operation,
9539the FPSCR PR bit has to be cleared, while for a double precision
9540operation, this bit has to be set. Changing the PR bit requires a general
9541purpose register as a scratch register, hence these FPSCR sets have to
9542be inserted before reload, i.e.@: you can't put this into instruction emitting
9543or @code{TARGET_MACHINE_DEPENDENT_REORG}.
9544
9545You can have multiple entities that are mode-switched, and select at run time
9546which entities actually need it. @code{OPTIMIZE_MODE_SWITCHING} should
9547return nonzero for any @var{entity} that needs mode-switching.
9548If you define this macro, you also have to define
9549@code{NUM_MODES_FOR_MODE_SWITCHING}, @code{MODE_NEEDED},
9550@code{MODE_PRIORITY_TO_MODE} and @code{EMIT_MODE_SET}.
9551@code{MODE_AFTER}, @code{MODE_ENTRY}, and @code{MODE_EXIT}
9552are optional.
9553@end defmac
9554
9555@defmac NUM_MODES_FOR_MODE_SWITCHING
9556If you define @code{OPTIMIZE_MODE_SWITCHING}, you have to define this as
9557initializer for an array of integers. Each initializer element
9558N refers to an entity that needs mode switching, and specifies the number
9559of different modes that might need to be set for this entity.
9560The position of the initializer in the initializer---starting counting at
9561zero---determines the integer that is used to refer to the mode-switched
9562entity in question.
9563In macros that take mode arguments / yield a mode result, modes are
9564represented as numbers 0 @dots{} N @minus{} 1. N is used to specify that no mode
9565switch is needed / supplied.
9566@end defmac
9567
9568@defmac MODE_NEEDED (@var{entity}, @var{insn})
9569@var{entity} is an integer specifying a mode-switched entity. If
9570@code{OPTIMIZE_MODE_SWITCHING} is defined, you must define this macro to
9571return an integer value not larger than the corresponding element in
9572@code{NUM_MODES_FOR_MODE_SWITCHING}, to denote the mode that @var{entity} must
9573be switched into prior to the execution of @var{insn}.
9574@end defmac
9575
9786913b
UB
9576@defmac MODE_AFTER (@var{entity}, @var{mode}, @var{insn})
9577@var{entity} is an integer specifying a mode-switched entity. If
9578this macro is defined, it is evaluated for every @var{insn} during
38f8b050
JR
9579mode switching. It determines the mode that an insn results in (if
9580different from the incoming mode).
9581@end defmac
9582
9583@defmac MODE_ENTRY (@var{entity})
9584If this macro is defined, it is evaluated for every @var{entity} that needs
9585mode switching. It should evaluate to an integer, which is a mode that
9586@var{entity} is assumed to be switched to at function entry. If @code{MODE_ENTRY}
9587is defined then @code{MODE_EXIT} must be defined.
9588@end defmac
9589
9590@defmac MODE_EXIT (@var{entity})
9591If this macro is defined, it is evaluated for every @var{entity} that needs
9592mode switching. It should evaluate to an integer, which is a mode that
9593@var{entity} is assumed to be switched to at function exit. If @code{MODE_EXIT}
9594is defined then @code{MODE_ENTRY} must be defined.
9595@end defmac
9596
9597@defmac MODE_PRIORITY_TO_MODE (@var{entity}, @var{n})
9598This macro specifies the order in which modes for @var{entity} are processed.
95990 is the highest priority, @code{NUM_MODES_FOR_MODE_SWITCHING[@var{entity}] - 1} the
9600lowest. The value of the macro should be an integer designating a mode
9601for @var{entity}. For any fixed @var{entity}, @code{mode_priority_to_mode}
9602(@var{entity}, @var{n}) shall be a bijection in 0 @dots{}
9603@code{num_modes_for_mode_switching[@var{entity}] - 1}.
9604@end defmac
9605
9606@defmac EMIT_MODE_SET (@var{entity}, @var{mode}, @var{hard_regs_live})
9607Generate one or more insns to set @var{entity} to @var{mode}.
9608@var{hard_reg_live} is the set of hard registers live at the point where
9609the insn(s) are to be inserted.
9610@end defmac
9611
9612@node Target Attributes
9613@section Defining target-specific uses of @code{__attribute__}
9614@cindex target attributes
9615@cindex machine attributes
9616@cindex attributes, target-specific
9617
9618Target-specific attributes may be defined for functions, data and types.
9619These are described using the following target hooks; they also need to
9620be documented in @file{extend.texi}.
9621
9622@hook TARGET_ATTRIBUTE_TABLE
9623If defined, this target hook points to an array of @samp{struct
9624attribute_spec} (defined in @file{tree.h}) specifying the machine
9625specific attributes for this target and some of the restrictions on the
9626entities to which these attributes are applied and the arguments they
9627take.
9628@end deftypevr
9629
9630@hook TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
9631If defined, this target hook is a function which returns true if the
9632machine-specific attribute named @var{name} expects an identifier
9633given as its first argument to be passed on as a plain identifier, not
9634subjected to name lookup. If this is not defined, the default is
9635false for all machine-specific attributes.
9636@end deftypefn
9637
9638@hook TARGET_COMP_TYPE_ATTRIBUTES
9639If defined, this target hook is a function which returns zero if the attributes on
9640@var{type1} and @var{type2} are incompatible, one if they are compatible,
9641and two if they are nearly compatible (which causes a warning to be
9642generated). If this is not defined, machine-specific attributes are
9643supposed always to be compatible.
9644@end deftypefn
9645
9646@hook TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
9647If defined, this target hook is a function which assigns default attributes to
9648the newly defined @var{type}.
9649@end deftypefn
9650
9651@hook TARGET_MERGE_TYPE_ATTRIBUTES
9652Define this target hook if the merging of type attributes needs special
9653handling. If defined, the result is a list of the combined
9654@code{TYPE_ATTRIBUTES} of @var{type1} and @var{type2}. It is assumed
9655that @code{comptypes} has already been called and returned 1. This
9656function may call @code{merge_attributes} to handle machine-independent
9657merging.
9658@end deftypefn
9659
9660@hook TARGET_MERGE_DECL_ATTRIBUTES
9661Define this target hook if the merging of decl attributes needs special
9662handling. If defined, the result is a list of the combined
9663@code{DECL_ATTRIBUTES} of @var{olddecl} and @var{newdecl}.
9664@var{newdecl} is a duplicate declaration of @var{olddecl}. Examples of
9665when this is needed are when one attribute overrides another, or when an
9666attribute is nullified by a subsequent definition. This function may
9667call @code{merge_attributes} to handle machine-independent merging.
9668
9669@findex TARGET_DLLIMPORT_DECL_ATTRIBUTES
9670If the only target-specific handling you require is @samp{dllimport}
9671for Microsoft Windows targets, you should define the macro
9672@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES} to @code{1}. The compiler
9673will then define a function called
9674@code{merge_dllimport_decl_attributes} which can then be defined as
9675the expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}. You can also
9676add @code{handle_dll_attribute} in the attribute table for your port
9677to perform initial processing of the @samp{dllimport} and
9678@samp{dllexport} attributes. This is done in @file{i386/cygwin.h} and
9679@file{i386/i386.c}, for example.
9680@end deftypefn
9681
9682@hook TARGET_VALID_DLLIMPORT_ATTRIBUTE_P
9683
9684@defmac TARGET_DECLSPEC
9685Define this macro to a nonzero value if you want to treat
9686@code{__declspec(X)} as equivalent to @code{__attribute((X))}. By
9687default, this behavior is enabled only for targets that define
9688@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES}. The current implementation
9689of @code{__declspec} is via a built-in macro, but you should not rely
9690on this implementation detail.
9691@end defmac
9692
9693@hook TARGET_INSERT_ATTRIBUTES
9694Define this target hook if you want to be able to add attributes to a decl
9695when it is being created. This is normally useful for back ends which
9696wish to implement a pragma by using the attributes which correspond to
9697the pragma's effect. The @var{node} argument is the decl which is being
9698created. The @var{attr_ptr} argument is a pointer to the attribute list
9699for this decl. The list itself should not be modified, since it may be
9700shared with other decls, but attributes may be chained on the head of
9701the list and @code{*@var{attr_ptr}} modified to point to the new
9702attributes, or a copy of the list may be made if further changes are
9703needed.
9704@end deftypefn
9705
9706@hook TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P
9707@cindex inlining
9708This target hook returns @code{true} if it is ok to inline @var{fndecl}
9709into the current function, despite its having target-specific
9710attributes, @code{false} otherwise. By default, if a function has a
9711target specific attribute attached to it, it will not be inlined.
9712@end deftypefn
9713
9714@hook TARGET_OPTION_VALID_ATTRIBUTE_P
7aa7f2e3
SL
9715This hook is called to parse @code{attribute(target("..."))}, which
9716allows setting target-specific options on individual functions.
9717These function-specific options may differ
9718from the options specified on the command line. The hook should return
38f8b050
JR
9719@code{true} if the options are valid.
9720
7aa7f2e3
SL
9721The hook should set the @code{DECL_FUNCTION_SPECIFIC_TARGET} field in
9722the function declaration to hold a pointer to a target-specific
9723@code{struct cl_target_option} structure.
38f8b050
JR
9724@end deftypefn
9725
9726@hook TARGET_OPTION_SAVE
7aa7f2e3
SL
9727This hook is called to save any additional target-specific information
9728in the @code{struct cl_target_option} structure for function-specific
38f8b050
JR
9729options.
9730@xref{Option file format}.
9731@end deftypefn
9732
9733@hook TARGET_OPTION_RESTORE
7aa7f2e3
SL
9734This hook is called to restore any additional target-specific
9735information in the @code{struct cl_target_option} structure for
9736function-specific options.
38f8b050
JR
9737@end deftypefn
9738
9739@hook TARGET_OPTION_PRINT
7aa7f2e3
SL
9740This hook is called to print any additional target-specific
9741information in the @code{struct cl_target_option} structure for
9742function-specific options.
38f8b050
JR
9743@end deftypefn
9744
56cb42ea 9745@hook TARGET_OPTION_PRAGMA_PARSE
7aa7f2e3
SL
9746This target hook parses the options for @code{#pragma GCC target}, which
9747sets the target-specific options for functions that occur later in the
9748input stream. The options accepted should be the same as those handled by the
56cb42ea 9749@code{TARGET_OPTION_VALID_ATTRIBUTE_P} hook.
38f8b050
JR
9750@end deftypefn
9751
9752@hook TARGET_OPTION_OVERRIDE
9753Sometimes certain combinations of command options do not make sense on
9754a particular target machine. You can override the hook
9755@code{TARGET_OPTION_OVERRIDE} to take account of this. This hooks is called
9756once just after all the command options have been parsed.
9757
9758Don't use this hook to turn on various extra optimizations for
fac0f722 9759@option{-O}. That is what @code{TARGET_OPTION_OPTIMIZATION} is for.
38f8b050
JR
9760
9761If you need to do something whenever the optimization level is
9762changed via the optimize attribute or pragma, see
9763@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}
9764@end deftypefn
9765
3649b9b7
ST
9766@hook TARGET_OPTION_FUNCTION_VERSIONS
9767This target hook returns @code{true} if @var{DECL1} and @var{DECL2} are
9768versions of the same function. @var{DECL1} and @var{DECL2} are function
9769versions if and only if they have the same function signature and
9770different target specific attributes, that is, they are compiled for
9771different target machines.
9772@end deftypefn
9773
38f8b050
JR
9774@hook TARGET_CAN_INLINE_P
9775This target hook returns @code{false} if the @var{caller} function
9776cannot inline @var{callee}, based on target specific information. By
9777default, inlining is not allowed if the callee function has function
9778specific target options and the caller does not use the same options.
9779@end deftypefn
9780
9781@node Emulated TLS
9782@section Emulating TLS
9783@cindex Emulated TLS
9784
9785For targets whose psABI does not provide Thread Local Storage via
9786specific relocations and instruction sequences, an emulation layer is
9787used. A set of target hooks allows this emulation layer to be
9788configured for the requirements of a particular target. For instance
9789the psABI may in fact specify TLS support in terms of an emulation
9790layer.
9791
9792The emulation layer works by creating a control object for every TLS
9793object. To access the TLS object, a lookup function is provided
9794which, when given the address of the control object, will return the
9795address of the current thread's instance of the TLS object.
9796
9797@hook TARGET_EMUTLS_GET_ADDRESS
9798Contains the name of the helper function that uses a TLS control
9799object to locate a TLS instance. The default causes libgcc's
9800emulated TLS helper function to be used.
9801@end deftypevr
9802
9803@hook TARGET_EMUTLS_REGISTER_COMMON
9804Contains the name of the helper function that should be used at
9805program startup to register TLS objects that are implicitly
9806initialized to zero. If this is @code{NULL}, all TLS objects will
9807have explicit initializers. The default causes libgcc's emulated TLS
9808registration function to be used.
9809@end deftypevr
9810
9811@hook TARGET_EMUTLS_VAR_SECTION
9812Contains the name of the section in which TLS control variables should
9813be placed. The default of @code{NULL} allows these to be placed in
9814any section.
9815@end deftypevr
9816
9817@hook TARGET_EMUTLS_TMPL_SECTION
9818Contains the name of the section in which TLS initializers should be
9819placed. The default of @code{NULL} allows these to be placed in any
9820section.
9821@end deftypevr
9822
9823@hook TARGET_EMUTLS_VAR_PREFIX
9824Contains the prefix to be prepended to TLS control variable names.
9825The default of @code{NULL} uses a target-specific prefix.
9826@end deftypevr
9827
9828@hook TARGET_EMUTLS_TMPL_PREFIX
9829Contains the prefix to be prepended to TLS initializer objects. The
9830default of @code{NULL} uses a target-specific prefix.
9831@end deftypevr
9832
9833@hook TARGET_EMUTLS_VAR_FIELDS
9834Specifies a function that generates the FIELD_DECLs for a TLS control
9835object type. @var{type} is the RECORD_TYPE the fields are for and
9836@var{name} should be filled with the structure tag, if the default of
9837@code{__emutls_object} is unsuitable. The default creates a type suitable
9838for libgcc's emulated TLS function.
9839@end deftypefn
9840
9841@hook TARGET_EMUTLS_VAR_INIT
9842Specifies a function that generates the CONSTRUCTOR to initialize a
9843TLS control object. @var{var} is the TLS control object, @var{decl}
9844is the TLS object and @var{tmpl_addr} is the address of the
9845initializer. The default initializes libgcc's emulated TLS control object.
9846@end deftypefn
9847
9848@hook TARGET_EMUTLS_VAR_ALIGN_FIXED
9849Specifies whether the alignment of TLS control variable objects is
9850fixed and should not be increased as some backends may do to optimize
9851single objects. The default is false.
9852@end deftypevr
9853
9854@hook TARGET_EMUTLS_DEBUG_FORM_TLS_ADDRESS
9855Specifies whether a DWARF @code{DW_OP_form_tls_address} location descriptor
9856may be used to describe emulated TLS control objects.
9857@end deftypevr
9858
9859@node MIPS Coprocessors
9860@section Defining coprocessor specifics for MIPS targets.
9861@cindex MIPS coprocessor-definition macros
9862
9863The MIPS specification allows MIPS implementations to have as many as 4
9864coprocessors, each with as many as 32 private registers. GCC supports
9865accessing these registers and transferring values between the registers
9866and memory using asm-ized variables. For example:
9867
9868@smallexample
9869 register unsigned int cp0count asm ("c0r1");
9870 unsigned int d;
9871
9872 d = cp0count + 3;
9873@end smallexample
9874
9875(``c0r1'' is the default name of register 1 in coprocessor 0; alternate
9876names may be added as described below, or the default names may be
9877overridden entirely in @code{SUBTARGET_CONDITIONAL_REGISTER_USAGE}.)
9878
9879Coprocessor registers are assumed to be epilogue-used; sets to them will
9880be preserved even if it does not appear that the register is used again
9881later in the function.
9882
9883Another note: according to the MIPS spec, coprocessor 1 (if present) is
9884the FPU@. One accesses COP1 registers through standard mips
9885floating-point support; they are not included in this mechanism.
9886
9887There is one macro used in defining the MIPS coprocessor interface which
9888you may want to override in subtargets; it is described below.
9889
38f8b050
JR
9890@node PCH Target
9891@section Parameters for Precompiled Header Validity Checking
9892@cindex parameters, precompiled headers
9893
9894@hook TARGET_GET_PCH_VALIDITY
9895This hook returns a pointer to the data needed by
9896@code{TARGET_PCH_VALID_P} and sets
9897@samp{*@var{sz}} to the size of the data in bytes.
9898@end deftypefn
9899
9900@hook TARGET_PCH_VALID_P
9901This hook checks whether the options used to create a PCH file are
9902compatible with the current settings. It returns @code{NULL}
9903if so and a suitable error message if not. Error messages will
9904be presented to the user and must be localized using @samp{_(@var{msg})}.
9905
9906@var{data} is the data that was returned by @code{TARGET_GET_PCH_VALIDITY}
9907when the PCH file was created and @var{sz} is the size of that data in bytes.
9908It's safe to assume that the data was created by the same version of the
9909compiler, so no format checking is needed.
9910
9911The default definition of @code{default_pch_valid_p} should be
9912suitable for most targets.
9913@end deftypefn
9914
9915@hook TARGET_CHECK_PCH_TARGET_FLAGS
9916If this hook is nonnull, the default implementation of
9917@code{TARGET_PCH_VALID_P} will use it to check for compatible values
9918of @code{target_flags}. @var{pch_flags} specifies the value that
9919@code{target_flags} had when the PCH file was created. The return
9920value is the same as for @code{TARGET_PCH_VALID_P}.
9921@end deftypefn
9922
e32ea2d1
RS
9923@hook TARGET_PREPARE_PCH_SAVE
9924
38f8b050
JR
9925@node C++ ABI
9926@section C++ ABI parameters
9927@cindex parameters, c++ abi
9928
9929@hook TARGET_CXX_GUARD_TYPE
9930Define this hook to override the integer type used for guard variables.
9931These are used to implement one-time construction of static objects. The
9932default is long_long_integer_type_node.
9933@end deftypefn
9934
9935@hook TARGET_CXX_GUARD_MASK_BIT
9936This hook determines how guard variables are used. It should return
9937@code{false} (the default) if the first byte should be used. A return value of
9938@code{true} indicates that only the least significant bit should be used.
9939@end deftypefn
9940
9941@hook TARGET_CXX_GET_COOKIE_SIZE
9942This hook returns the size of the cookie to use when allocating an array
9943whose elements have the indicated @var{type}. Assumes that it is already
9944known that a cookie is needed. The default is
9945@code{max(sizeof (size_t), alignof(type))}, as defined in section 2.7 of the
9946IA64/Generic C++ ABI@.
9947@end deftypefn
9948
9949@hook TARGET_CXX_COOKIE_HAS_SIZE
9950This hook should return @code{true} if the element size should be stored in
9951array cookies. The default is to return @code{false}.
9952@end deftypefn
9953
9954@hook TARGET_CXX_IMPORT_EXPORT_CLASS
9955If defined by a backend this hook allows the decision made to export
9956class @var{type} to be overruled. Upon entry @var{import_export}
9957will contain 1 if the class is going to be exported, @minus{}1 if it is going
9958to be imported and 0 otherwise. This function should return the
9959modified value and perform any other actions necessary to support the
9960backend's targeted operating system.
9961@end deftypefn
9962
9963@hook TARGET_CXX_CDTOR_RETURNS_THIS
9964This hook should return @code{true} if constructors and destructors return
9965the address of the object created/destroyed. The default is to return
9966@code{false}.
9967@end deftypefn
9968
9969@hook TARGET_CXX_KEY_METHOD_MAY_BE_INLINE
9970This hook returns true if the key method for a class (i.e., the method
9971which, if defined in the current translation unit, causes the virtual
9972table to be emitted) may be an inline function. Under the standard
9973Itanium C++ ABI the key method may be an inline function so long as
9974the function is not declared inline in the class definition. Under
9975some variants of the ABI, an inline function can never be the key
9976method. The default is to return @code{true}.
9977@end deftypefn
9978
9979@hook TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY
9980
9981@hook TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT
9982This hook returns true (the default) if virtual tables and other
9983similar implicit class data objects are always COMDAT if they have
9984external linkage. If this hook returns false, then class data for
9985classes whose virtual table will be emitted in only one translation
9986unit will not be COMDAT.
9987@end deftypefn
9988
9989@hook TARGET_CXX_LIBRARY_RTTI_COMDAT
9990This hook returns true (the default) if the RTTI information for
9991the basic types which is defined in the C++ runtime should always
9992be COMDAT, false if it should not be COMDAT.
9993@end deftypefn
9994
9995@hook TARGET_CXX_USE_AEABI_ATEXIT
9996This hook returns true if @code{__aeabi_atexit} (as defined by the ARM EABI)
9997should be used to register static destructors when @option{-fuse-cxa-atexit}
9998is in effect. The default is to return false to use @code{__cxa_atexit}.
9999@end deftypefn
10000
10001@hook TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT
10002This hook returns true if the target @code{atexit} function can be used
10003in the same manner as @code{__cxa_atexit} to register C++ static
10004destructors. This requires that @code{atexit}-registered functions in
10005shared libraries are run in the correct order when the libraries are
10006unloaded. The default is to return false.
10007@end deftypefn
10008
10009@hook TARGET_CXX_ADJUST_CLASS_AT_DEFINITION
10010
17c4f786
AS
10011@hook TARGET_CXX_DECL_MANGLING_CONTEXT
10012
38f8b050
JR
10013@node Named Address Spaces
10014@section Adding support for named address spaces
10015@cindex named address spaces
10016
10017The draft technical report of the ISO/IEC JTC1 S22 WG14 N1275
10018standards committee, @cite{Programming Languages - C - Extensions to
10019support embedded processors}, specifies a syntax for embedded
10020processors to specify alternate address spaces. You can configure a
10021GCC port to support section 5.1 of the draft report to add support for
10022address spaces other than the default address space. These address
10023spaces are new keywords that are similar to the @code{volatile} and
10024@code{const} type attributes.
10025
10026Pointers to named address spaces can have a different size than
10027pointers to the generic address space.
10028
10029For example, the SPU port uses the @code{__ea} address space to refer
10030to memory in the host processor, rather than memory local to the SPU
10031processor. Access to memory in the @code{__ea} address space involves
10032issuing DMA operations to move data between the host processor and the
10033local processor memory address space. Pointers in the @code{__ea}
10034address space are either 32 bits or 64 bits based on the
10035@option{-mea32} or @option{-mea64} switches (native SPU pointers are
10036always 32 bits).
10037
10038Internally, address spaces are represented as a small integer in the
10039range 0 to 15 with address space 0 being reserved for the generic
10040address space.
10041
10042To register a named address space qualifier keyword with the C front end,
10043the target may call the @code{c_register_addr_space} routine. For example,
10044the SPU port uses the following to declare @code{__ea} as the keyword for
10045named address space #1:
10046@smallexample
10047#define ADDR_SPACE_EA 1
10048c_register_addr_space ("__ea", ADDR_SPACE_EA);
10049@end smallexample
10050
10051@hook TARGET_ADDR_SPACE_POINTER_MODE
10052Define this to return the machine mode to use for pointers to
10053@var{address_space} if the target supports named address spaces.
10054The default version of this hook returns @code{ptr_mode} for the
10055generic address space only.
10056@end deftypefn
10057
10058@hook TARGET_ADDR_SPACE_ADDRESS_MODE
10059Define this to return the machine mode to use for addresses in
10060@var{address_space} if the target supports named address spaces.
10061The default version of this hook returns @code{Pmode} for the
10062generic address space only.
10063@end deftypefn
10064
10065@hook TARGET_ADDR_SPACE_VALID_POINTER_MODE
10066Define this to return nonzero if the port can handle pointers
10067with machine mode @var{mode} to address space @var{as}. This target
10068hook is the same as the @code{TARGET_VALID_POINTER_MODE} target hook,
10069except that it includes explicit named address space support. The default
10070version of this hook returns true for the modes returned by either the
10071@code{TARGET_ADDR_SPACE_POINTER_MODE} or @code{TARGET_ADDR_SPACE_ADDRESS_MODE}
10072target hooks for the given address space.
10073@end deftypefn
10074
10075@hook TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P
10076Define this to return true if @var{exp} is a valid address for mode
10077@var{mode} in the named address space @var{as}. The @var{strict}
10078parameter says whether strict addressing is in effect after reload has
10079finished. This target hook is the same as the
10080@code{TARGET_LEGITIMATE_ADDRESS_P} target hook, except that it includes
10081explicit named address space support.
10082@end deftypefn
10083
10084@hook TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS
10085Define this to modify an invalid address @var{x} to be a valid address
10086with mode @var{mode} in the named address space @var{as}. This target
10087hook is the same as the @code{TARGET_LEGITIMIZE_ADDRESS} target hook,
10088except that it includes explicit named address space support.
10089@end deftypefn
10090
10091@hook TARGET_ADDR_SPACE_SUBSET_P
10092Define this to return whether the @var{subset} named address space is
10093contained within the @var{superset} named address space. Pointers to
10094a named address space that is a subset of another named address space
10095will be converted automatically without a cast if used together in
10096arithmetic operations. Pointers to a superset address space can be
10097converted to pointers to a subset address space via explicit casts.
10098@end deftypefn
10099
10100@hook TARGET_ADDR_SPACE_CONVERT
10101Define this to convert the pointer expression represented by the RTL
10102@var{op} with type @var{from_type} that points to a named address
10103space to a new pointer expression with type @var{to_type} that points
10104to a different named address space. When this hook it called, it is
10105guaranteed that one of the two address spaces is a subset of the other,
10106as determined by the @code{TARGET_ADDR_SPACE_SUBSET_P} target hook.
10107@end deftypefn
10108
10109@node Misc
10110@section Miscellaneous Parameters
10111@cindex parameters, miscellaneous
10112
10113@c prevent bad page break with this line
10114Here are several miscellaneous parameters.
10115
10116@defmac HAS_LONG_COND_BRANCH
10117Define this boolean macro to indicate whether or not your architecture
10118has conditional branches that can span all of memory. It is used in
10119conjunction with an optimization that partitions hot and cold basic
10120blocks into separate sections of the executable. If this macro is
10121set to false, gcc will convert any conditional branches that attempt
10122to cross between sections into unconditional branches or indirect jumps.
10123@end defmac
10124
10125@defmac HAS_LONG_UNCOND_BRANCH
10126Define this boolean macro to indicate whether or not your architecture
10127has unconditional branches that can span all of memory. It is used in
10128conjunction with an optimization that partitions hot and cold basic
10129blocks into separate sections of the executable. If this macro is
10130set to false, gcc will convert any unconditional branches that attempt
10131to cross between sections into indirect jumps.
10132@end defmac
10133
10134@defmac CASE_VECTOR_MODE
10135An alias for a machine mode name. This is the machine mode that
10136elements of a jump-table should have.
10137@end defmac
10138
10139@defmac CASE_VECTOR_SHORTEN_MODE (@var{min_offset}, @var{max_offset}, @var{body})
10140Optional: return the preferred mode for an @code{addr_diff_vec}
10141when the minimum and maximum offset are known. If you define this,
10142it enables extra code in branch shortening to deal with @code{addr_diff_vec}.
10143To make this work, you also have to define @code{INSN_ALIGN} and
10144make the alignment for @code{addr_diff_vec} explicit.
10145The @var{body} argument is provided so that the offset_unsigned and scale
10146flags can be updated.
10147@end defmac
10148
10149@defmac CASE_VECTOR_PC_RELATIVE
10150Define this macro to be a C expression to indicate when jump-tables
10151should contain relative addresses. You need not define this macro if
10152jump-tables never contain relative addresses, or jump-tables should
10153contain relative addresses only when @option{-fPIC} or @option{-fPIC}
10154is in effect.
10155@end defmac
10156
10157@hook TARGET_CASE_VALUES_THRESHOLD
10158This function return the smallest number of different values for which it
10159is best to use a jump-table instead of a tree of conditional branches.
10160The default is four for machines with a @code{casesi} instruction and
10161five otherwise. This is best for most machines.
10162@end deftypefn
10163
38f8b050
JR
10164@defmac WORD_REGISTER_OPERATIONS
10165Define this macro if operations between registers with integral mode
10166smaller than a word are always performed on the entire register.
10167Most RISC machines have this property and most CISC machines do not.
10168@end defmac
10169
10170@defmac LOAD_EXTEND_OP (@var{mem_mode})
10171Define this macro to be a C expression indicating when insns that read
10172memory in @var{mem_mode}, an integral mode narrower than a word, set the
10173bits outside of @var{mem_mode} to be either the sign-extension or the
10174zero-extension of the data read. Return @code{SIGN_EXTEND} for values
10175of @var{mem_mode} for which the
10176insn sign-extends, @code{ZERO_EXTEND} for which it zero-extends, and
10177@code{UNKNOWN} for other modes.
10178
10179This macro is not called with @var{mem_mode} non-integral or with a width
10180greater than or equal to @code{BITS_PER_WORD}, so you may return any
10181value in this case. Do not define this macro if it would always return
10182@code{UNKNOWN}. On machines where this macro is defined, you will normally
10183define it as the constant @code{SIGN_EXTEND} or @code{ZERO_EXTEND}.
10184
10185You may return a non-@code{UNKNOWN} value even if for some hard registers
10186the sign extension is not performed, if for the @code{REGNO_REG_CLASS}
10187of these hard registers @code{CANNOT_CHANGE_MODE_CLASS} returns nonzero
10188when the @var{from} mode is @var{mem_mode} and the @var{to} mode is any
10189integral mode larger than this but not larger than @code{word_mode}.
10190
10191You must return @code{UNKNOWN} if for some hard registers that allow this
10192mode, @code{CANNOT_CHANGE_MODE_CLASS} says that they cannot change to
10193@code{word_mode}, but that they can change to another integral mode that
10194is larger then @var{mem_mode} but still smaller than @code{word_mode}.
10195@end defmac
10196
10197@defmac SHORT_IMMEDIATES_SIGN_EXTEND
10198Define this macro if loading short immediate values into registers sign
10199extends.
10200@end defmac
10201
38f8b050
JR
10202@hook TARGET_MIN_DIVISIONS_FOR_RECIP_MUL
10203When @option{-ffast-math} is in effect, GCC tries to optimize
10204divisions by the same divisor, by turning them into multiplications by
10205the reciprocal. This target hook specifies the minimum number of divisions
10206that should be there for GCC to perform the optimization for a variable
10207of mode @var{mode}. The default implementation returns 3 if the machine
10208has an instruction for the division, and 2 if it does not.
10209@end deftypefn
10210
10211@defmac MOVE_MAX
10212The maximum number of bytes that a single instruction can move quickly
10213between memory and registers or between two memory locations.
10214@end defmac
10215
10216@defmac MAX_MOVE_MAX
10217The maximum number of bytes that a single instruction can move quickly
10218between memory and registers or between two memory locations. If this
10219is undefined, the default is @code{MOVE_MAX}. Otherwise, it is the
10220constant value that is the largest value that @code{MOVE_MAX} can have
10221at run-time.
10222@end defmac
10223
10224@defmac SHIFT_COUNT_TRUNCATED
10225A C expression that is nonzero if on this machine the number of bits
10226actually used for the count of a shift operation is equal to the number
10227of bits needed to represent the size of the object being shifted. When
10228this macro is nonzero, the compiler will assume that it is safe to omit
10229a sign-extend, zero-extend, and certain bitwise `and' instructions that
10230truncates the count of a shift operation. On machines that have
10231instructions that act on bit-fields at variable positions, which may
10232include `bit test' instructions, a nonzero @code{SHIFT_COUNT_TRUNCATED}
10233also enables deletion of truncations of the values that serve as
10234arguments to bit-field instructions.
10235
10236If both types of instructions truncate the count (for shifts) and
10237position (for bit-field operations), or if no variable-position bit-field
10238instructions exist, you should define this macro.
10239
10240However, on some machines, such as the 80386 and the 680x0, truncation
10241only applies to shift operations and not the (real or pretended)
10242bit-field operations. Define @code{SHIFT_COUNT_TRUNCATED} to be zero on
10243such machines. Instead, add patterns to the @file{md} file that include
10244the implied truncation of the shift instructions.
10245
10246You need not define this macro if it would always have the value of zero.
10247@end defmac
10248
10249@anchor{TARGET_SHIFT_TRUNCATION_MASK}
10250@hook TARGET_SHIFT_TRUNCATION_MASK
10251This function describes how the standard shift patterns for @var{mode}
10252deal with shifts by negative amounts or by more than the width of the mode.
10253@xref{shift patterns}.
10254
10255On many machines, the shift patterns will apply a mask @var{m} to the
10256shift count, meaning that a fixed-width shift of @var{x} by @var{y} is
10257equivalent to an arbitrary-width shift of @var{x} by @var{y & m}. If
10258this is true for mode @var{mode}, the function should return @var{m},
10259otherwise it should return 0. A return value of 0 indicates that no
10260particular behavior is guaranteed.
10261
10262Note that, unlike @code{SHIFT_COUNT_TRUNCATED}, this function does
10263@emph{not} apply to general shift rtxes; it applies only to instructions
10264that are generated by the named shift patterns.
10265
10266The default implementation of this function returns
10267@code{GET_MODE_BITSIZE (@var{mode}) - 1} if @code{SHIFT_COUNT_TRUNCATED}
10268and 0 otherwise. This definition is always safe, but if
10269@code{SHIFT_COUNT_TRUNCATED} is false, and some shift patterns
10270nevertheless truncate the shift count, you may get better code
10271by overriding it.
10272@end deftypefn
10273
10274@defmac TRULY_NOOP_TRUNCATION (@var{outprec}, @var{inprec})
10275A C expression which is nonzero if on this machine it is safe to
10276``convert'' an integer of @var{inprec} bits to one of @var{outprec}
10277bits (where @var{outprec} is smaller than @var{inprec}) by merely
10278operating on it as if it had only @var{outprec} bits.
10279
10280On many machines, this expression can be 1.
10281
10282@c rearranged this, removed the phrase "it is reported that". this was
10283@c to fix an overfull hbox. --mew 10feb93
10284When @code{TRULY_NOOP_TRUNCATION} returns 1 for a pair of sizes for
10285modes for which @code{MODES_TIEABLE_P} is 0, suboptimal code can result.
10286If this is the case, making @code{TRULY_NOOP_TRUNCATION} return 0 in
10287such cases may improve things.
10288@end defmac
10289
10290@hook TARGET_MODE_REP_EXTENDED
10291The representation of an integral mode can be such that the values
10292are always extended to a wider integral mode. Return
10293@code{SIGN_EXTEND} if values of @var{mode} are represented in
10294sign-extended form to @var{rep_mode}. Return @code{UNKNOWN}
10295otherwise. (Currently, none of the targets use zero-extended
10296representation this way so unlike @code{LOAD_EXTEND_OP},
10297@code{TARGET_MODE_REP_EXTENDED} is expected to return either
10298@code{SIGN_EXTEND} or @code{UNKNOWN}. Also no target extends
10299@var{mode} to @var{rep_mode} so that @var{rep_mode} is not the next
10300widest integral mode and currently we take advantage of this fact.)
10301
10302Similarly to @code{LOAD_EXTEND_OP} you may return a non-@code{UNKNOWN}
10303value even if the extension is not performed on certain hard registers
10304as long as for the @code{REGNO_REG_CLASS} of these hard registers
10305@code{CANNOT_CHANGE_MODE_CLASS} returns nonzero.
10306
10307Note that @code{TARGET_MODE_REP_EXTENDED} and @code{LOAD_EXTEND_OP}
10308describe two related properties. If you define
10309@code{TARGET_MODE_REP_EXTENDED (mode, word_mode)} you probably also want
10310to define @code{LOAD_EXTEND_OP (mode)} to return the same type of
10311extension.
10312
10313In order to enforce the representation of @code{mode},
10314@code{TRULY_NOOP_TRUNCATION} should return false when truncating to
10315@code{mode}.
10316@end deftypefn
10317
10318@defmac STORE_FLAG_VALUE
10319A C expression describing the value returned by a comparison operator
10320with an integral mode and stored by a store-flag instruction
10321(@samp{cstore@var{mode}4}) when the condition is true. This description must
10322apply to @emph{all} the @samp{cstore@var{mode}4} patterns and all the
10323comparison operators whose results have a @code{MODE_INT} mode.
10324
10325A value of 1 or @minus{}1 means that the instruction implementing the
10326comparison operator returns exactly 1 or @minus{}1 when the comparison is true
10327and 0 when the comparison is false. Otherwise, the value indicates
10328which bits of the result are guaranteed to be 1 when the comparison is
10329true. This value is interpreted in the mode of the comparison
10330operation, which is given by the mode of the first operand in the
10331@samp{cstore@var{mode}4} pattern. Either the low bit or the sign bit of
10332@code{STORE_FLAG_VALUE} be on. Presently, only those bits are used by
10333the compiler.
10334
10335If @code{STORE_FLAG_VALUE} is neither 1 or @minus{}1, the compiler will
10336generate code that depends only on the specified bits. It can also
10337replace comparison operators with equivalent operations if they cause
10338the required bits to be set, even if the remaining bits are undefined.
10339For example, on a machine whose comparison operators return an
10340@code{SImode} value and where @code{STORE_FLAG_VALUE} is defined as
10341@samp{0x80000000}, saying that just the sign bit is relevant, the
10342expression
10343
10344@smallexample
10345(ne:SI (and:SI @var{x} (const_int @var{power-of-2})) (const_int 0))
10346@end smallexample
10347
10348@noindent
10349can be converted to
10350
10351@smallexample
10352(ashift:SI @var{x} (const_int @var{n}))
10353@end smallexample
10354
10355@noindent
10356where @var{n} is the appropriate shift count to move the bit being
10357tested into the sign bit.
10358
10359There is no way to describe a machine that always sets the low-order bit
10360for a true value, but does not guarantee the value of any other bits,
10361but we do not know of any machine that has such an instruction. If you
10362are trying to port GCC to such a machine, include an instruction to
10363perform a logical-and of the result with 1 in the pattern for the
10364comparison operators and let us know at @email{gcc@@gcc.gnu.org}.
10365
10366Often, a machine will have multiple instructions that obtain a value
10367from a comparison (or the condition codes). Here are rules to guide the
10368choice of value for @code{STORE_FLAG_VALUE}, and hence the instructions
10369to be used:
10370
10371@itemize @bullet
10372@item
10373Use the shortest sequence that yields a valid definition for
10374@code{STORE_FLAG_VALUE}. It is more efficient for the compiler to
10375``normalize'' the value (convert it to, e.g., 1 or 0) than for the
10376comparison operators to do so because there may be opportunities to
10377combine the normalization with other operations.
10378
10379@item
10380For equal-length sequences, use a value of 1 or @minus{}1, with @minus{}1 being
10381slightly preferred on machines with expensive jumps and 1 preferred on
10382other machines.
10383
10384@item
10385As a second choice, choose a value of @samp{0x80000001} if instructions
10386exist that set both the sign and low-order bits but do not define the
10387others.
10388
10389@item
10390Otherwise, use a value of @samp{0x80000000}.
10391@end itemize
10392
10393Many machines can produce both the value chosen for
10394@code{STORE_FLAG_VALUE} and its negation in the same number of
10395instructions. On those machines, you should also define a pattern for
10396those cases, e.g., one matching
10397
10398@smallexample
10399(set @var{A} (neg:@var{m} (ne:@var{m} @var{B} @var{C})))
10400@end smallexample
10401
10402Some machines can also perform @code{and} or @code{plus} operations on
10403condition code values with less instructions than the corresponding
10404@samp{cstore@var{mode}4} insn followed by @code{and} or @code{plus}. On those
10405machines, define the appropriate patterns. Use the names @code{incscc}
10406and @code{decscc}, respectively, for the patterns which perform
10407@code{plus} or @code{minus} operations on condition code values. See
2b0d3573 10408@file{rs6000.md} for some examples. The GNU Superoptimizer can be used to
38f8b050
JR
10409find such instruction sequences on other machines.
10410
10411If this macro is not defined, the default value, 1, is used. You need
10412not define @code{STORE_FLAG_VALUE} if the machine has no store-flag
10413instructions, or if the value generated by these instructions is 1.
10414@end defmac
10415
10416@defmac FLOAT_STORE_FLAG_VALUE (@var{mode})
10417A C expression that gives a nonzero @code{REAL_VALUE_TYPE} value that is
10418returned when comparison operators with floating-point results are true.
10419Define this macro on machines that have comparison operations that return
10420floating-point values. If there are no such operations, do not define
10421this macro.
10422@end defmac
10423
10424@defmac VECTOR_STORE_FLAG_VALUE (@var{mode})
10425A C expression that gives a rtx representing the nonzero true element
10426for vector comparisons. The returned rtx should be valid for the inner
10427mode of @var{mode} which is guaranteed to be a vector mode. Define
10428this macro on machines that have vector comparison operations that
10429return a vector result. If there are no such operations, do not define
10430this macro. Typically, this macro is defined as @code{const1_rtx} or
10431@code{constm1_rtx}. This macro may return @code{NULL_RTX} to prevent
10432the compiler optimizing such vector comparison operations for the
10433given mode.
10434@end defmac
10435
10436@defmac CLZ_DEFINED_VALUE_AT_ZERO (@var{mode}, @var{value})
10437@defmacx CTZ_DEFINED_VALUE_AT_ZERO (@var{mode}, @var{value})
10438A C expression that indicates whether the architecture defines a value
ff2ce160 10439for @code{clz} or @code{ctz} with a zero operand.
38f8b050
JR
10440A result of @code{0} indicates the value is undefined.
10441If the value is defined for only the RTL expression, the macro should
10442evaluate to @code{1}; if the value applies also to the corresponding optab
10443entry (which is normally the case if it expands directly into
ff2ce160 10444the corresponding RTL), then the macro should evaluate to @code{2}.
38f8b050 10445In the cases where the value is defined, @var{value} should be set to
ff2ce160 10446this value.
38f8b050
JR
10447
10448If this macro is not defined, the value of @code{clz} or
10449@code{ctz} at zero is assumed to be undefined.
10450
10451This macro must be defined if the target's expansion for @code{ffs}
10452relies on a particular value to get correct results. Otherwise it
10453is not necessary, though it may be used to optimize some corner cases, and
10454to provide a default expansion for the @code{ffs} optab.
10455
10456Note that regardless of this macro the ``definedness'' of @code{clz}
10457and @code{ctz} at zero do @emph{not} extend to the builtin functions
10458visible to the user. Thus one may be free to adjust the value at will
10459to match the target expansion of these operations without fear of
10460breaking the API@.
10461@end defmac
10462
10463@defmac Pmode
10464An alias for the machine mode for pointers. On most machines, define
10465this to be the integer mode corresponding to the width of a hardware
10466pointer; @code{SImode} on 32-bit machine or @code{DImode} on 64-bit machines.
10467On some machines you must define this to be one of the partial integer
10468modes, such as @code{PSImode}.
10469
10470The width of @code{Pmode} must be at least as large as the value of
10471@code{POINTER_SIZE}. If it is not equal, you must define the macro
10472@code{POINTERS_EXTEND_UNSIGNED} to specify how pointers are extended
10473to @code{Pmode}.
10474@end defmac
10475
10476@defmac FUNCTION_MODE
10477An alias for the machine mode used for memory references to functions
10478being called, in @code{call} RTL expressions. On most CISC machines,
ff2ce160 10479where an instruction can begin at any byte address, this should be
38f8b050
JR
10480@code{QImode}. On most RISC machines, where all instructions have fixed
10481size and alignment, this should be a mode with the same size and alignment
10482as the machine instruction words - typically @code{SImode} or @code{HImode}.
10483@end defmac
10484
10485@defmac STDC_0_IN_SYSTEM_HEADERS
10486In normal operation, the preprocessor expands @code{__STDC__} to the
10487constant 1, to signify that GCC conforms to ISO Standard C@. On some
10488hosts, like Solaris, the system compiler uses a different convention,
10489where @code{__STDC__} is normally 0, but is 1 if the user specifies
10490strict conformance to the C Standard.
10491
10492Defining @code{STDC_0_IN_SYSTEM_HEADERS} makes GNU CPP follows the host
10493convention when processing system header files, but when processing user
10494files @code{__STDC__} will always expand to 1.
10495@end defmac
10496
1efcb8c6
JM
10497@hook TARGET_C_PREINCLUDE
10498
38f8b050
JR
10499@defmac NO_IMPLICIT_EXTERN_C
10500Define this macro if the system header files support C++ as well as C@.
10501This macro inhibits the usual method of using system header files in
10502C++, which is to pretend that the file's contents are enclosed in
10503@samp{extern "C" @{@dots{}@}}.
10504@end defmac
10505
10506@findex #pragma
10507@findex pragma
10508@defmac REGISTER_TARGET_PRAGMAS ()
10509Define this macro if you want to implement any target-specific pragmas.
10510If defined, it is a C expression which makes a series of calls to
10511@code{c_register_pragma} or @code{c_register_pragma_with_expansion}
10512for each pragma. The macro may also do any
10513setup required for the pragmas.
10514
10515The primary reason to define this macro is to provide compatibility with
10516other compilers for the same target. In general, we discourage
10517definition of target-specific pragmas for GCC@.
10518
10519If the pragma can be implemented by attributes then you should consider
10520defining the target hook @samp{TARGET_INSERT_ATTRIBUTES} as well.
10521
10522Preprocessor macros that appear on pragma lines are not expanded. All
10523@samp{#pragma} directives that do not match any registered pragma are
10524silently ignored, unless the user specifies @option{-Wunknown-pragmas}.
10525@end defmac
10526
10527@deftypefun void c_register_pragma (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *))
10528@deftypefunx void c_register_pragma_with_expansion (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *))
10529
10530Each call to @code{c_register_pragma} or
10531@code{c_register_pragma_with_expansion} establishes one pragma. The
10532@var{callback} routine will be called when the preprocessor encounters a
10533pragma of the form
10534
10535@smallexample
10536#pragma [@var{space}] @var{name} @dots{}
10537@end smallexample
10538
10539@var{space} is the case-sensitive namespace of the pragma, or
10540@code{NULL} to put the pragma in the global namespace. The callback
10541routine receives @var{pfile} as its first argument, which can be passed
10542on to cpplib's functions if necessary. You can lex tokens after the
10543@var{name} by calling @code{pragma_lex}. Tokens that are not read by the
10544callback will be silently ignored. The end of the line is indicated by
10545a token of type @code{CPP_EOF}. Macro expansion occurs on the
10546arguments of pragmas registered with
10547@code{c_register_pragma_with_expansion} but not on the arguments of
10548pragmas registered with @code{c_register_pragma}.
10549
10550Note that the use of @code{pragma_lex} is specific to the C and C++
10551compilers. It will not work in the Java or Fortran compilers, or any
10552other language compilers for that matter. Thus if @code{pragma_lex} is going
10553to be called from target-specific code, it must only be done so when
10554building the C and C++ compilers. This can be done by defining the
10555variables @code{c_target_objs} and @code{cxx_target_objs} in the
10556target entry in the @file{config.gcc} file. These variables should name
10557the target-specific, language-specific object file which contains the
10558code that uses @code{pragma_lex}. Note it will also be necessary to add a
10559rule to the makefile fragment pointed to by @code{tmake_file} that shows
10560how to build this object file.
10561@end deftypefun
10562
38f8b050 10563@defmac HANDLE_PRAGMA_PACK_WITH_EXPANSION
24a57808 10564Define this macro if macros should be expanded in the
38f8b050
JR
10565arguments of @samp{#pragma pack}.
10566@end defmac
10567
38f8b050
JR
10568@defmac TARGET_DEFAULT_PACK_STRUCT
10569If your target requires a structure packing default other than 0 (meaning
10570the machine default), define this macro to the necessary value (in bytes).
10571This must be a value that would also be valid to use with
10572@samp{#pragma pack()} (that is, a small power of two).
10573@end defmac
10574
10575@defmac DOLLARS_IN_IDENTIFIERS
10576Define this macro to control use of the character @samp{$} in
10577identifier names for the C family of languages. 0 means @samp{$} is
10578not allowed by default; 1 means it is allowed. 1 is the default;
10579there is no need to define this macro in that case.
10580@end defmac
10581
38f8b050
JR
10582@defmac INSN_SETS_ARE_DELAYED (@var{insn})
10583Define this macro as a C expression that is nonzero if it is safe for the
10584delay slot scheduler to place instructions in the delay slot of @var{insn},
10585even if they appear to use a resource set or clobbered in @var{insn}.
10586@var{insn} is always a @code{jump_insn} or an @code{insn}; GCC knows that
10587every @code{call_insn} has this behavior. On machines where some @code{insn}
10588or @code{jump_insn} is really a function call and hence has this behavior,
10589you should define this macro.
10590
10591You need not define this macro if it would always return zero.
10592@end defmac
10593
10594@defmac INSN_REFERENCES_ARE_DELAYED (@var{insn})
10595Define this macro as a C expression that is nonzero if it is safe for the
10596delay slot scheduler to place instructions in the delay slot of @var{insn},
10597even if they appear to set or clobber a resource referenced in @var{insn}.
10598@var{insn} is always a @code{jump_insn} or an @code{insn}. On machines where
10599some @code{insn} or @code{jump_insn} is really a function call and its operands
10600are registers whose use is actually in the subroutine it calls, you should
10601define this macro. Doing so allows the delay slot scheduler to move
10602instructions which copy arguments into the argument registers into the delay
10603slot of @var{insn}.
10604
10605You need not define this macro if it would always return zero.
10606@end defmac
10607
10608@defmac MULTIPLE_SYMBOL_SPACES
10609Define this macro as a C expression that is nonzero if, in some cases,
10610global symbols from one translation unit may not be bound to undefined
10611symbols in another translation unit without user intervention. For
10612instance, under Microsoft Windows symbols must be explicitly imported
10613from shared libraries (DLLs).
10614
10615You need not define this macro if it would always evaluate to zero.
10616@end defmac
10617
10618@hook TARGET_MD_ASM_CLOBBERS
10619This target hook should add to @var{clobbers} @code{STRING_CST} trees for
10620any hard regs the port wishes to automatically clobber for an asm.
10621It should return the result of the last @code{tree_cons} used to add a
10622clobber. The @var{outputs}, @var{inputs} and @var{clobber} lists are the
10623corresponding parameters to the asm and may be inspected to avoid
10624clobbering a register that is an input or output of the asm. You can use
10625@code{tree_overlaps_hard_reg_set}, declared in @file{tree.h}, to test
10626for overlap with regards to asm-declared registers.
10627@end deftypefn
10628
10629@defmac MATH_LIBRARY
10630Define this macro as a C string constant for the linker argument to link
d9d16a19
JM
10631in the system math library, minus the initial @samp{"-l"}, or
10632@samp{""} if the target does not have a
38f8b050
JR
10633separate math library.
10634
d9d16a19 10635You need only define this macro if the default of @samp{"m"} is wrong.
38f8b050
JR
10636@end defmac
10637
10638@defmac LIBRARY_PATH_ENV
10639Define this macro as a C string constant for the environment variable that
10640specifies where the linker should look for libraries.
10641
10642You need only define this macro if the default of @samp{"LIBRARY_PATH"}
10643is wrong.
10644@end defmac
10645
10646@defmac TARGET_POSIX_IO
10647Define this macro if the target supports the following POSIX@ file
10648functions, access, mkdir and file locking with fcntl / F_SETLKW@.
10649Defining @code{TARGET_POSIX_IO} will enable the test coverage code
10650to use file locking when exiting a program, which avoids race conditions
10651if the program has forked. It will also create directories at run-time
10652for cross-profiling.
10653@end defmac
10654
10655@defmac MAX_CONDITIONAL_EXECUTE
10656
10657A C expression for the maximum number of instructions to execute via
10658conditional execution instructions instead of a branch. A value of
10659@code{BRANCH_COST}+1 is the default if the machine does not use cc0, and
106601 if it does use cc0.
10661@end defmac
10662
10663@defmac IFCVT_MODIFY_TESTS (@var{ce_info}, @var{true_expr}, @var{false_expr})
10664Used if the target needs to perform machine-dependent modifications on the
10665conditionals used for turning basic blocks into conditionally executed code.
10666@var{ce_info} points to a data structure, @code{struct ce_if_block}, which
10667contains information about the currently processed blocks. @var{true_expr}
10668and @var{false_expr} are the tests that are used for converting the
10669then-block and the else-block, respectively. Set either @var{true_expr} or
10670@var{false_expr} to a null pointer if the tests cannot be converted.
10671@end defmac
10672
10673@defmac IFCVT_MODIFY_MULTIPLE_TESTS (@var{ce_info}, @var{bb}, @var{true_expr}, @var{false_expr})
10674Like @code{IFCVT_MODIFY_TESTS}, but used when converting more complicated
10675if-statements into conditions combined by @code{and} and @code{or} operations.
10676@var{bb} contains the basic block that contains the test that is currently
10677being processed and about to be turned into a condition.
10678@end defmac
10679
10680@defmac IFCVT_MODIFY_INSN (@var{ce_info}, @var{pattern}, @var{insn})
10681A C expression to modify the @var{PATTERN} of an @var{INSN} that is to
10682be converted to conditional execution format. @var{ce_info} points to
10683a data structure, @code{struct ce_if_block}, which contains information
10684about the currently processed blocks.
10685@end defmac
10686
10687@defmac IFCVT_MODIFY_FINAL (@var{ce_info})
10688A C expression to perform any final machine dependent modifications in
10689converting code to conditional execution. The involved basic blocks
10690can be found in the @code{struct ce_if_block} structure that is pointed
10691to by @var{ce_info}.
10692@end defmac
10693
10694@defmac IFCVT_MODIFY_CANCEL (@var{ce_info})
10695A C expression to cancel any machine dependent modifications in
10696converting code to conditional execution. The involved basic blocks
10697can be found in the @code{struct ce_if_block} structure that is pointed
10698to by @var{ce_info}.
10699@end defmac
10700
67a0732f
SB
10701@defmac IFCVT_MACHDEP_INIT (@var{ce_info})
10702A C expression to initialize any machine specific data for if-conversion
10703of the if-block in the @code{struct ce_if_block} structure that is pointed
10704to by @var{ce_info}.
38f8b050
JR
10705@end defmac
10706
10707@hook TARGET_MACHINE_DEPENDENT_REORG
10708If non-null, this hook performs a target-specific pass over the
10709instruction stream. The compiler will run it at all optimization levels,
10710just before the point at which it normally does delayed-branch scheduling.
10711
10712The exact purpose of the hook varies from target to target. Some use
10713it to do transformations that are necessary for correctness, such as
10714laying out in-function constant pools or avoiding hardware hazards.
10715Others use it as an opportunity to do some machine-dependent optimizations.
10716
10717You need not implement the hook if it has nothing to do. The default
10718definition is null.
10719@end deftypefn
10720
10721@hook TARGET_INIT_BUILTINS
10722Define this hook if you have any machine-specific built-in functions
10723that need to be defined. It should be a function that performs the
10724necessary setup.
10725
10726Machine specific built-in functions can be useful to expand special machine
10727instructions that would otherwise not normally be generated because
10728they have no equivalent in the source language (for example, SIMD vector
10729instructions or prefetch instructions).
10730
10731To create a built-in function, call the function
10732@code{lang_hooks.builtin_function}
10733which is defined by the language front end. You can use any type nodes set
1a072294 10734up by @code{build_common_tree_nodes};
38f8b050
JR
10735only language front ends that use those two functions will call
10736@samp{TARGET_INIT_BUILTINS}.
10737@end deftypefn
10738
10739@hook TARGET_BUILTIN_DECL
10740Define this hook if you have any machine-specific built-in functions
10741that need to be defined. It should be a function that returns the
10742builtin function declaration for the builtin function code @var{code}.
10743If there is no such builtin and it cannot be initialized at this time
10744if @var{initialize_p} is true the function should return @code{NULL_TREE}.
10745If @var{code} is out of range the function should return
10746@code{error_mark_node}.
10747@end deftypefn
10748
10749@hook TARGET_EXPAND_BUILTIN
10750
10751Expand a call to a machine specific built-in function that was set up by
10752@samp{TARGET_INIT_BUILTINS}. @var{exp} is the expression for the
10753function call; the result should go to @var{target} if that is
10754convenient, and have mode @var{mode} if that is convenient.
10755@var{subtarget} may be used as the target for computing one of
10756@var{exp}'s operands. @var{ignore} is nonzero if the value is to be
10757ignored. This function should return the result of the call to the
10758built-in function.
10759@end deftypefn
10760
d66f5459 10761@hook TARGET_RESOLVE_OVERLOADED_BUILTIN
38f8b050
JR
10762Select a replacement for a machine specific built-in function that
10763was set up by @samp{TARGET_INIT_BUILTINS}. This is done
10764@emph{before} regular type checking, and so allows the target to
10765implement a crude form of function overloading. @var{fndecl} is the
10766declaration of the built-in function. @var{arglist} is the list of
10767arguments passed to the built-in function. The result is a
10768complete expression that implements the operation, usually
10769another @code{CALL_EXPR}.
10770@var{arglist} really has type @samp{VEC(tree,gc)*}
10771@end deftypefn
10772
08914aaa 10773@hook TARGET_FOLD_BUILTIN
38f8b050
JR
10774Fold a call to a machine specific built-in function that was set up by
10775@samp{TARGET_INIT_BUILTINS}. @var{fndecl} is the declaration of the
10776built-in function. @var{n_args} is the number of arguments passed to
10777the function; the arguments themselves are pointed to by @var{argp}.
10778The result is another tree containing a simplified expression for the
10779call's result. If @var{ignore} is true the value will be ignored.
10780@end deftypefn
10781
3649b9b7
ST
10782@hook TARGET_COMPARE_VERSION_PRIORITY
10783This hook is used to compare the target attributes in two functions to
10784determine which function's features get higher priority. This is used
10785during function multi-versioning to figure out the order in which two
10786versions must be dispatched. A function version with a higher priority
10787is checked for dispatching earlier. @var{decl1} and @var{decl2} are
10788 the two function decls that will be compared.
10789@end deftypefn
10790
10791@hook TARGET_GET_FUNCTION_VERSIONS_DISPATCHER
10792This hook is used to get the dispatcher function for a set of function
10793versions. The dispatcher function is called to invoke the right function
10794version at run-time. @var{decl} is one version from a set of semantically
10795identical versions.
10796@end deftypefn
10797
10798@hook TARGET_GENERATE_VERSION_DISPATCHER_BODY
10799This hook is used to generate the dispatcher logic to invoke the right
10800function version at run-time for a given set of function versions.
10801@var{arg} points to the callgraph node of the dispatcher function whose
10802body must be generated.
10803@end deftypefn
10804
38f8b050
JR
10805@hook TARGET_INVALID_WITHIN_DOLOOP
10806
10807Take an instruction in @var{insn} and return NULL if it is valid within a
10808low-overhead loop, otherwise return a string explaining why doloop
10809could not be applied.
10810
10811Many targets use special registers for low-overhead looping. For any
10812instruction that clobbers these this function should return a string indicating
10813the reason why the doloop could not be applied.
10814By default, the RTL loop optimizer does not use a present doloop pattern for
10815loops containing function calls or branch on table instructions.
10816@end deftypefn
10817
78e4f1ad
UB
10818@hook TARGET_LEGITIMATE_COMBINED_INSN
10819
38f8b050
JR
10820@defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2})
10821
10822Take a branch insn in @var{branch1} and another in @var{branch2}.
10823Return true if redirecting @var{branch1} to the destination of
10824@var{branch2} is possible.
10825
10826On some targets, branches may have a limited range. Optimizing the
10827filling of delay slots can result in branches being redirected, and this
10828may in turn cause a branch offset to overflow.
10829@end defmac
10830
4b4de898
JR
10831@hook TARGET_CAN_FOLLOW_JUMP
10832
38f8b050
JR
10833@hook TARGET_COMMUTATIVE_P
10834This target hook returns @code{true} if @var{x} is considered to be commutative.
10835Usually, this is just COMMUTATIVE_P (@var{x}), but the HP PA doesn't consider
10836PLUS to be commutative inside a MEM@. @var{outer_code} is the rtx code
10837of the enclosing rtl, if known, otherwise it is UNKNOWN.
10838@end deftypefn
10839
10840@hook TARGET_ALLOCATE_INITIAL_VALUE
10841
10842When the initial value of a hard register has been copied in a pseudo
10843register, it is often not necessary to actually allocate another register
10844to this pseudo register, because the original hard register or a stack slot
10845it has been saved into can be used. @code{TARGET_ALLOCATE_INITIAL_VALUE}
10846is called at the start of register allocation once for each hard register
10847that had its initial value copied by using
10848@code{get_func_hard_reg_initial_val} or @code{get_hard_reg_initial_val}.
10849Possible values are @code{NULL_RTX}, if you don't want
10850to do any special allocation, a @code{REG} rtx---that would typically be
10851the hard register itself, if it is known not to be clobbered---or a
10852@code{MEM}.
10853If you are returning a @code{MEM}, this is only a hint for the allocator;
10854it might decide to use another register anyways.
29454ff5
SL
10855You may use @code{current_function_is_leaf} or
10856@code{REG_N_SETS} in the hook to determine if the hard
38f8b050
JR
10857register in question will not be clobbered.
10858The default value of this hook is @code{NULL}, which disables any special
10859allocation.
10860@end deftypefn
10861
10862@hook TARGET_UNSPEC_MAY_TRAP_P
10863This target hook returns nonzero if @var{x}, an @code{unspec} or
10864@code{unspec_volatile} operation, might cause a trap. Targets can use
10865this hook to enhance precision of analysis for @code{unspec} and
10866@code{unspec_volatile} operations. You may call @code{may_trap_p_1}
10867to analyze inner elements of @var{x} in which case @var{flags} should be
10868passed along.
10869@end deftypefn
10870
10871@hook TARGET_SET_CURRENT_FUNCTION
ff2ce160 10872The compiler invokes this hook whenever it changes its current function
38f8b050
JR
10873context (@code{cfun}). You can define this function if
10874the back end needs to perform any initialization or reset actions on a
10875per-function basis. For example, it may be used to implement function
10876attributes that affect register usage or code generation patterns.
10877The argument @var{decl} is the declaration for the new function context,
10878and may be null to indicate that the compiler has left a function context
10879and is returning to processing at the top level.
10880The default hook function does nothing.
10881
10882GCC sets @code{cfun} to a dummy function context during initialization of
10883some parts of the back end. The hook function is not invoked in this
10884situation; you need not worry about the hook being invoked recursively,
10885or when the back end is in a partially-initialized state.
10886@code{cfun} might be @code{NULL} to indicate processing at top level,
10887outside of any function scope.
10888@end deftypefn
10889
10890@defmac TARGET_OBJECT_SUFFIX
10891Define this macro to be a C string representing the suffix for object
10892files on your target machine. If you do not define this macro, GCC will
10893use @samp{.o} as the suffix for object files.
10894@end defmac
10895
10896@defmac TARGET_EXECUTABLE_SUFFIX
10897Define this macro to be a C string representing the suffix to be
10898automatically added to executable files on your target machine. If you
10899do not define this macro, GCC will use the null string as the suffix for
10900executable files.
10901@end defmac
10902
10903@defmac COLLECT_EXPORT_LIST
10904If defined, @code{collect2} will scan the individual object files
10905specified on its command line and create an export list for the linker.
10906Define this macro for systems like AIX, where the linker discards
10907object files that are not referenced from @code{main} and uses export
10908lists.
10909@end defmac
10910
10911@defmac MODIFY_JNI_METHOD_CALL (@var{mdecl})
10912Define this macro to a C expression representing a variant of the
10913method call @var{mdecl}, if Java Native Interface (JNI) methods
10914must be invoked differently from other methods on your target.
10915For example, on 32-bit Microsoft Windows, JNI methods must be invoked using
10916the @code{stdcall} calling convention and this macro is then
10917defined as this expression:
10918
10919@smallexample
10920build_type_attribute_variant (@var{mdecl},
10921 build_tree_list
10922 (get_identifier ("stdcall"),
10923 NULL))
10924@end smallexample
10925@end defmac
10926
10927@hook TARGET_CANNOT_MODIFY_JUMPS_P
10928This target hook returns @code{true} past the point in which new jump
10929instructions could be created. On machines that require a register for
10930every jump such as the SHmedia ISA of SH5, this point would typically be
10931reload, so this target hook should be defined to a function such as:
10932
10933@smallexample
10934static bool
10935cannot_modify_jumps_past_reload_p ()
10936@{
10937 return (reload_completed || reload_in_progress);
10938@}
10939@end smallexample
10940@end deftypefn
10941
10942@hook TARGET_BRANCH_TARGET_REGISTER_CLASS
10943This target hook returns a register class for which branch target register
10944optimizations should be applied. All registers in this class should be
10945usable interchangeably. After reload, registers in this class will be
10946re-allocated and loads will be hoisted out of loops and be subjected
10947to inter-block scheduling.
10948@end deftypefn
10949
10950@hook TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED
10951Branch target register optimization will by default exclude callee-saved
10952registers
10953that are not already live during the current function; if this target hook
10954returns true, they will be included. The target code must than make sure
10955that all target registers in the class returned by
10956@samp{TARGET_BRANCH_TARGET_REGISTER_CLASS} that might need saving are
10957saved. @var{after_prologue_epilogue_gen} indicates if prologues and
10958epilogues have already been generated. Note, even if you only return
10959true when @var{after_prologue_epilogue_gen} is false, you still are likely
10960to have to make special provisions in @code{INITIAL_ELIMINATION_OFFSET}
10961to reserve space for caller-saved target registers.
10962@end deftypefn
10963
10964@hook TARGET_HAVE_CONDITIONAL_EXECUTION
10965This target hook returns true if the target supports conditional execution.
10966This target hook is required only when the target has several different
10967modes and they have different conditional execution capability, such as ARM.
10968@end deftypefn
10969
10970@hook TARGET_LOOP_UNROLL_ADJUST
10971This target hook returns a new value for the number of times @var{loop}
10972should be unrolled. The parameter @var{nunroll} is the number of times
10973the loop is to be unrolled. The parameter @var{loop} is a pointer to
10974the loop, which is going to be checked for unrolling. This target hook
10975is required only when the target has special constraints like maximum
10976number of memory accesses.
10977@end deftypefn
10978
10979@defmac POWI_MAX_MULTS
10980If defined, this macro is interpreted as a signed integer C expression
10981that specifies the maximum number of floating point multiplications
10982that should be emitted when expanding exponentiation by an integer
10983constant inline. When this value is defined, exponentiation requiring
10984more than this number of multiplications is implemented by calling the
10985system library's @code{pow}, @code{powf} or @code{powl} routines.
10986The default value places no upper bound on the multiplication count.
10987@end defmac
10988
10989@deftypefn Macro void TARGET_EXTRA_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
10990This target hook should register any extra include files for the
10991target. The parameter @var{stdinc} indicates if normal include files
10992are present. The parameter @var{sysroot} is the system root directory.
10993The parameter @var{iprefix} is the prefix for the gcc directory.
10994@end deftypefn
10995
10996@deftypefn Macro void TARGET_EXTRA_PRE_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
10997This target hook should register any extra include files for the
10998target before any standard headers. The parameter @var{stdinc}
10999indicates if normal include files are present. The parameter
11000@var{sysroot} is the system root directory. The parameter
11001@var{iprefix} is the prefix for the gcc directory.
11002@end deftypefn
11003
11004@deftypefn Macro void TARGET_OPTF (char *@var{path})
11005This target hook should register special include paths for the target.
11006The parameter @var{path} is the include to register. On Darwin
11007systems, this is used for Framework includes, which have semantics
11008that are different from @option{-I}.
11009@end deftypefn
11010
11011@defmac bool TARGET_USE_LOCAL_THUNK_ALIAS_P (tree @var{fndecl})
11012This target macro returns @code{true} if it is safe to use a local alias
11013for a virtual function @var{fndecl} when constructing thunks,
11014@code{false} otherwise. By default, the macro returns @code{true} for all
11015functions, if a target supports aliases (i.e.@: defines
11016@code{ASM_OUTPUT_DEF}), @code{false} otherwise,
11017@end defmac
11018
11019@defmac TARGET_FORMAT_TYPES
11020If defined, this macro is the name of a global variable containing
11021target-specific format checking information for the @option{-Wformat}
11022option. The default is to have no target-specific format checks.
11023@end defmac
11024
11025@defmac TARGET_N_FORMAT_TYPES
11026If defined, this macro is the number of entries in
11027@code{TARGET_FORMAT_TYPES}.
11028@end defmac
11029
11030@defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES
11031If defined, this macro is the name of a global variable containing
11032target-specific format overrides for the @option{-Wformat} option. The
11033default is to have no target-specific format overrides. If defined,
11034@code{TARGET_FORMAT_TYPES} must be defined, too.
11035@end defmac
11036
11037@defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
11038If defined, this macro specifies the number of entries in
11039@code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
11040@end defmac
11041
11042@defmac TARGET_OVERRIDES_FORMAT_INIT
11043If defined, this macro specifies the optional initialization
11044routine for target specific customizations of the system printf
11045and scanf formatter settings.
11046@end defmac
11047
11048@hook TARGET_RELAXED_ORDERING
11049If set to @code{true}, means that the target's memory model does not
11050guarantee that loads which do not depend on one another will access
11051main memory in the order of the instruction stream; if ordering is
11052important, an explicit memory barrier must be used. This is true of
11053many recent processors which implement a policy of ``relaxed,''
11054``weak,'' or ``release'' memory consistency, such as Alpha, PowerPC,
11055and ia64. The default is @code{false}.
11056@end deftypevr
11057
11058@hook TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
11059If defined, this macro returns the diagnostic message when it is
11060illegal to pass argument @var{val} to function @var{funcdecl}
11061with prototype @var{typelist}.
11062@end deftypefn
11063
11064@hook TARGET_INVALID_CONVERSION
11065If defined, this macro returns the diagnostic message when it is
11066invalid to convert from @var{fromtype} to @var{totype}, or @code{NULL}
11067if validity should be determined by the front end.
11068@end deftypefn
11069
11070@hook TARGET_INVALID_UNARY_OP
11071If defined, this macro returns the diagnostic message when it is
11072invalid to apply operation @var{op} (where unary plus is denoted by
11073@code{CONVERT_EXPR}) to an operand of type @var{type}, or @code{NULL}
11074if validity should be determined by the front end.
11075@end deftypefn
11076
11077@hook TARGET_INVALID_BINARY_OP
11078If defined, this macro returns the diagnostic message when it is
11079invalid to apply operation @var{op} to operands of types @var{type1}
11080and @var{type2}, or @code{NULL} if validity should be determined by
11081the front end.
11082@end deftypefn
11083
11084@hook TARGET_INVALID_PARAMETER_TYPE
11085If defined, this macro returns the diagnostic message when it is
ff2ce160 11086invalid for functions to include parameters of type @var{type},
38f8b050
JR
11087or @code{NULL} if validity should be determined by
11088the front end. This is currently used only by the C and C++ front ends.
11089@end deftypefn
11090
11091@hook TARGET_INVALID_RETURN_TYPE
11092If defined, this macro returns the diagnostic message when it is
ff2ce160 11093invalid for functions to have return type @var{type},
38f8b050
JR
11094or @code{NULL} if validity should be determined by
11095the front end. This is currently used only by the C and C++ front ends.
11096@end deftypefn
11097
11098@hook TARGET_PROMOTED_TYPE
ff2ce160
MS
11099If defined, this target hook returns the type to which values of
11100@var{type} should be promoted when they appear in expressions,
38f8b050
JR
11101analogous to the integer promotions, or @code{NULL_TREE} to use the
11102front end's normal promotion rules. This hook is useful when there are
11103target-specific types with special promotion rules.
11104This is currently used only by the C and C++ front ends.
11105@end deftypefn
11106
11107@hook TARGET_CONVERT_TO_TYPE
ff2ce160
MS
11108If defined, this hook returns the result of converting @var{expr} to
11109@var{type}. It should return the converted expression,
38f8b050 11110or @code{NULL_TREE} to apply the front end's normal conversion rules.
ff2ce160 11111This hook is useful when there are target-specific types with special
38f8b050
JR
11112conversion rules.
11113This is currently used only by the C and C++ front ends.
11114@end deftypefn
11115
11116@defmac TARGET_USE_JCR_SECTION
11117This macro determines whether to use the JCR section to register Java
11118classes. By default, TARGET_USE_JCR_SECTION is defined to 1 if both
11119SUPPORTS_WEAK and TARGET_HAVE_NAMED_SECTIONS are true, else 0.
11120@end defmac
11121
11122@defmac OBJC_JBLEN
11123This macro determines the size of the objective C jump buffer for the
11124NeXT runtime. By default, OBJC_JBLEN is defined to an innocuous value.
11125@end defmac
11126
11127@defmac LIBGCC2_UNWIND_ATTRIBUTE
11128Define this macro if any target-specific attributes need to be attached
ff2ce160 11129to the functions in @file{libgcc} that provide low-level support for
38f8b050
JR
11130call stack unwinding. It is used in declarations in @file{unwind-generic.h}
11131and the associated definitions of those functions.
11132@end defmac
11133
11134@hook TARGET_UPDATE_STACK_BOUNDARY
11135Define this macro to update the current function stack boundary if
11136necessary.
11137@end deftypefn
11138
11139@hook TARGET_GET_DRAP_RTX
11140This hook should return an rtx for Dynamic Realign Argument Pointer (DRAP) if a
11141different argument pointer register is needed to access the function's
11142argument list due to stack realignment. Return @code{NULL} if no DRAP
11143is needed.
11144@end deftypefn
11145
11146@hook TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS
11147When optimization is disabled, this hook indicates whether or not
11148arguments should be allocated to stack slots. Normally, GCC allocates
11149stacks slots for arguments when not optimizing in order to make
11150debugging easier. However, when a function is declared with
11151@code{__attribute__((naked))}, there is no stack frame, and the compiler
11152cannot safely move arguments from the registers in which they are passed
11153to the stack. Therefore, this hook should return true in general, but
11154false for naked functions. The default implementation always returns true.
11155@end deftypefn
11156
11157@hook TARGET_CONST_ANCHOR
11158On some architectures it can take multiple instructions to synthesize
11159a constant. If there is another constant already in a register that
11160is close enough in value then it is preferable that the new constant
11161is computed from this register using immediate addition or
11162subtraction. We accomplish this through CSE. Besides the value of
11163the constant we also add a lower and an upper constant anchor to the
11164available expressions. These are then queried when encountering new
11165constants. The anchors are computed by rounding the constant up and
11166down to a multiple of the value of @code{TARGET_CONST_ANCHOR}.
11167@code{TARGET_CONST_ANCHOR} should be the maximum positive value
11168accepted by immediate-add plus one. We currently assume that the
11169value of @code{TARGET_CONST_ANCHOR} is a power of 2. For example, on
11170MIPS, where add-immediate takes a 16-bit signed value,
11171@code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}. The default value
0d8aa4b1
AS
11172is zero, which disables this optimization.
11173@end deftypevr
57c5ab1b 11174
dfe06d3e
JJ
11175@hook TARGET_ASAN_SHADOW_OFFSET
11176
5dcfdccd
KY
11177@hook TARGET_MEMMODEL_CHECK
11178Validate target specific memory model mask bits. When NULL no target specific
11179memory model bits are allowed.
11180@end deftypefn
11181
57c5ab1b 11182@hook TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
2f251a05
AI
11183
11184@hook TARGET_HAS_IFUNC_P