xref: /dragonfly/contrib/gcc-4.7/gcc/doc/tm.texi.in (revision 95d28233)
1e4b17023SJohn Marino@c Copyright (C) 1988,1989,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,
2e4b17023SJohn Marino@c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3e4b17023SJohn Marino@c Free Software Foundation, Inc.
4e4b17023SJohn Marino@c This is part of the GCC manual.
5e4b17023SJohn Marino@c For copying conditions, see the file gcc.texi.
6e4b17023SJohn Marino
7e4b17023SJohn Marino@node Target Macros
8e4b17023SJohn Marino@chapter Target Description Macros and Functions
9e4b17023SJohn Marino@cindex machine description macros
10e4b17023SJohn Marino@cindex target description macros
11e4b17023SJohn Marino@cindex macros, target description
12e4b17023SJohn Marino@cindex @file{tm.h} macros
13e4b17023SJohn Marino
14e4b17023SJohn MarinoIn addition to the file @file{@var{machine}.md}, a machine description
15e4b17023SJohn Marinoincludes a C header file conventionally given the name
16e4b17023SJohn Marino@file{@var{machine}.h} and a C source file named @file{@var{machine}.c}.
17e4b17023SJohn MarinoThe header file defines numerous macros that convey the information
18e4b17023SJohn Marinoabout the target machine that does not fit into the scheme of the
19e4b17023SJohn Marino@file{.md} file.  The file @file{tm.h} should be a link to
20e4b17023SJohn Marino@file{@var{machine}.h}.  The header file @file{config.h} includes
21e4b17023SJohn Marino@file{tm.h} and most compiler source files include @file{config.h}.  The
22e4b17023SJohn Marinosource file defines a variable @code{targetm}, which is a structure
23e4b17023SJohn Marinocontaining pointers to functions and data relating to the target
24e4b17023SJohn Marinomachine.  @file{@var{machine}.c} should also contain their definitions,
25e4b17023SJohn Marinoif they are not defined elsewhere in GCC, and other functions called
26e4b17023SJohn Marinothrough the macros defined in the @file{.h} file.
27e4b17023SJohn Marino
28e4b17023SJohn Marino@menu
29e4b17023SJohn Marino* Target Structure::    The @code{targetm} variable.
30e4b17023SJohn Marino* Driver::              Controlling how the driver runs the compilation passes.
31e4b17023SJohn Marino* Run-time Target::     Defining @samp{-m} options like @option{-m68000} and @option{-m68020}.
32e4b17023SJohn Marino* Per-Function Data::   Defining data structures for per-function information.
33e4b17023SJohn Marino* Storage Layout::      Defining sizes and alignments of data.
34e4b17023SJohn Marino* Type Layout::         Defining sizes and properties of basic user data types.
35e4b17023SJohn Marino* Registers::           Naming and describing the hardware registers.
36e4b17023SJohn Marino* Register Classes::    Defining the classes of hardware registers.
37e4b17023SJohn Marino* Old Constraints::     The old way to define machine-specific constraints.
38e4b17023SJohn Marino* Stack and Calling::   Defining which way the stack grows and by how much.
39e4b17023SJohn Marino* Varargs::             Defining the varargs macros.
40e4b17023SJohn Marino* Trampolines::         Code set up at run time to enter a nested function.
41e4b17023SJohn Marino* Library Calls::       Controlling how library routines are implicitly called.
42e4b17023SJohn Marino* Addressing Modes::    Defining addressing modes valid for memory operands.
43e4b17023SJohn Marino* Anchored Addresses::  Defining how @option{-fsection-anchors} should work.
44e4b17023SJohn Marino* Condition Code::      Defining how insns update the condition code.
45e4b17023SJohn Marino* Costs::               Defining relative costs of different operations.
46e4b17023SJohn Marino* Scheduling::          Adjusting the behavior of the instruction scheduler.
47e4b17023SJohn Marino* Sections::            Dividing storage into text, data, and other sections.
48e4b17023SJohn Marino* PIC::                 Macros for position independent code.
49e4b17023SJohn Marino* Assembler Format::    Defining how to write insns and pseudo-ops to output.
50e4b17023SJohn Marino* Debugging Info::      Defining the format of debugging output.
51e4b17023SJohn Marino* Floating Point::      Handling floating point for cross-compilers.
52e4b17023SJohn Marino* Mode Switching::      Insertion of mode-switching instructions.
53e4b17023SJohn Marino* Target Attributes::   Defining target-specific uses of @code{__attribute__}.
54e4b17023SJohn Marino* Emulated TLS::        Emulated TLS support.
55e4b17023SJohn Marino* MIPS Coprocessors::   MIPS coprocessor support and how to customize it.
56e4b17023SJohn Marino* PCH Target::          Validity checking for precompiled headers.
57e4b17023SJohn Marino* C++ ABI::             Controlling C++ ABI changes.
58e4b17023SJohn Marino* Named Address Spaces:: Adding support for named address spaces
59e4b17023SJohn Marino* Misc::                Everything else.
60e4b17023SJohn Marino@end menu
61e4b17023SJohn Marino
62e4b17023SJohn Marino@node Target Structure
63e4b17023SJohn Marino@section The Global @code{targetm} Variable
64e4b17023SJohn Marino@cindex target hooks
65e4b17023SJohn Marino@cindex target functions
66e4b17023SJohn Marino
67e4b17023SJohn Marino@deftypevar {struct gcc_target} targetm
68e4b17023SJohn MarinoThe target @file{.c} file must define the global @code{targetm} variable
69e4b17023SJohn Marinowhich contains pointers to functions and data relating to the target
70e4b17023SJohn Marinomachine.  The variable is declared in @file{target.h};
71e4b17023SJohn Marino@file{target-def.h} defines the macro @code{TARGET_INITIALIZER} which is
72e4b17023SJohn Marinoused to initialize the variable, and macros for the default initializers
73e4b17023SJohn Marinofor elements of the structure.  The @file{.c} file should override those
74e4b17023SJohn Marinomacros for which the default definition is inappropriate.  For example:
75e4b17023SJohn Marino@smallexample
76e4b17023SJohn Marino#include "target.h"
77e4b17023SJohn Marino#include "target-def.h"
78e4b17023SJohn Marino
79e4b17023SJohn Marino/* @r{Initialize the GCC target structure.}  */
80e4b17023SJohn Marino
81e4b17023SJohn Marino#undef TARGET_COMP_TYPE_ATTRIBUTES
82e4b17023SJohn Marino#define TARGET_COMP_TYPE_ATTRIBUTES @var{machine}_comp_type_attributes
83e4b17023SJohn Marino
84e4b17023SJohn Marinostruct gcc_target targetm = TARGET_INITIALIZER;
85e4b17023SJohn Marino@end smallexample
86e4b17023SJohn Marino@end deftypevar
87e4b17023SJohn Marino
88e4b17023SJohn MarinoWhere a macro should be defined in the @file{.c} file in this manner to
89e4b17023SJohn Marinoform part of the @code{targetm} structure, it is documented below as a
90e4b17023SJohn Marino``Target Hook'' with a prototype.  Many macros will change in future
91e4b17023SJohn Marinofrom being defined in the @file{.h} file to being part of the
92e4b17023SJohn Marino@code{targetm} structure.
93e4b17023SJohn Marino
94e4b17023SJohn MarinoSimilarly, there is a @code{targetcm} variable for hooks that are
95e4b17023SJohn Marinospecific to front ends for C-family languages, documented as ``C
96e4b17023SJohn MarinoTarget Hook''.  This is declared in @file{c-family/c-target.h}, the
97e4b17023SJohn Marinoinitializer @code{TARGETCM_INITIALIZER} in
98e4b17023SJohn Marino@file{c-family/c-target-def.h}.  If targets initialize @code{targetcm}
99e4b17023SJohn Marinothemselves, they should set @code{target_has_targetcm=yes} in
100e4b17023SJohn Marino@file{config.gcc}; otherwise a default definition is used.
101e4b17023SJohn Marino
102e4b17023SJohn MarinoSimilarly, there is a @code{targetm_common} variable for hooks that
103e4b17023SJohn Marinoare shared between the compiler driver and the compilers proper,
104e4b17023SJohn Marinodocumented as ``Common Target Hook''.  This is declared in
105e4b17023SJohn Marino@file{common/common-target.h}, the initializer
106e4b17023SJohn Marino@code{TARGETM_COMMON_INITIALIZER} in
107e4b17023SJohn Marino@file{common/common-target-def.h}.  If targets initialize
108e4b17023SJohn Marino@code{targetm_common} themselves, they should set
109e4b17023SJohn Marino@code{target_has_targetm_common=yes} in @file{config.gcc}; otherwise a
110e4b17023SJohn Marinodefault definition is used.
111e4b17023SJohn Marino
112e4b17023SJohn Marino@node Driver
113e4b17023SJohn Marino@section Controlling the Compilation Driver, @file{gcc}
114e4b17023SJohn Marino@cindex driver
115e4b17023SJohn Marino@cindex controlling the compilation driver
116e4b17023SJohn Marino
117e4b17023SJohn Marino@c prevent bad page break with this line
118e4b17023SJohn MarinoYou can control the compilation driver.
119e4b17023SJohn Marino
120e4b17023SJohn Marino@defmac DRIVER_SELF_SPECS
121e4b17023SJohn MarinoA list of specs for the driver itself.  It should be a suitable
122e4b17023SJohn Marinoinitializer for an array of strings, with no surrounding braces.
123e4b17023SJohn Marino
124e4b17023SJohn MarinoThe driver applies these specs to its own command line between loading
125e4b17023SJohn Marinodefault @file{specs} files (but not command-line specified ones) and
126e4b17023SJohn Marinochoosing the multilib directory or running any subcommands.  It
127e4b17023SJohn Marinoapplies them in the order given, so each spec can depend on the
128e4b17023SJohn Marinooptions added by earlier ones.  It is also possible to remove options
129e4b17023SJohn Marinousing @samp{%<@var{option}} in the usual way.
130e4b17023SJohn Marino
131e4b17023SJohn MarinoThis macro can be useful when a port has several interdependent target
132e4b17023SJohn Marinooptions.  It provides a way of standardizing the command line so
133e4b17023SJohn Marinothat the other specs are easier to write.
134e4b17023SJohn Marino
135e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
136e4b17023SJohn Marino@end defmac
137e4b17023SJohn Marino
138e4b17023SJohn Marino@defmac OPTION_DEFAULT_SPECS
139e4b17023SJohn MarinoA list of specs used to support configure-time default options (i.e.@:
140e4b17023SJohn Marino@option{--with} options) in the driver.  It should be a suitable initializer
141e4b17023SJohn Marinofor an array of structures, each containing two strings, without the
142e4b17023SJohn Marinooutermost pair of surrounding braces.
143e4b17023SJohn Marino
144e4b17023SJohn MarinoThe first item in the pair is the name of the default.  This must match
145e4b17023SJohn Marinothe code in @file{config.gcc} for the target.  The second item is a spec
146e4b17023SJohn Marinoto apply if a default with this name was specified.  The string
147e4b17023SJohn Marino@samp{%(VALUE)} in the spec will be replaced by the value of the default
148e4b17023SJohn Marinoeverywhere it occurs.
149e4b17023SJohn Marino
150e4b17023SJohn MarinoThe driver will apply these specs to its own command line between loading
151e4b17023SJohn Marinodefault @file{specs} files and processing @code{DRIVER_SELF_SPECS}, using
152e4b17023SJohn Marinothe same mechanism as @code{DRIVER_SELF_SPECS}.
153e4b17023SJohn Marino
154e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
155e4b17023SJohn Marino@end defmac
156e4b17023SJohn Marino
157e4b17023SJohn Marino@defmac CPP_SPEC
158e4b17023SJohn MarinoA C string constant that tells the GCC driver program options to
159e4b17023SJohn Marinopass to CPP@.  It can also specify how to translate options you
160e4b17023SJohn Marinogive to GCC into options for GCC to pass to the CPP@.
161e4b17023SJohn Marino
162e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
163e4b17023SJohn Marino@end defmac
164e4b17023SJohn Marino
165e4b17023SJohn Marino@defmac CPLUSPLUS_CPP_SPEC
166e4b17023SJohn MarinoThis macro is just like @code{CPP_SPEC}, but is used for C++, rather
167e4b17023SJohn Marinothan C@.  If you do not define this macro, then the value of
168e4b17023SJohn Marino@code{CPP_SPEC} (if any) will be used instead.
169e4b17023SJohn Marino@end defmac
170e4b17023SJohn Marino
171e4b17023SJohn Marino@defmac CC1_SPEC
172e4b17023SJohn MarinoA C string constant that tells the GCC driver program options to
173e4b17023SJohn Marinopass to @code{cc1}, @code{cc1plus}, @code{f771}, and the other language
174e4b17023SJohn Marinofront ends.
175e4b17023SJohn MarinoIt can also specify how to translate options you give to GCC into options
176e4b17023SJohn Marinofor GCC to pass to front ends.
177e4b17023SJohn Marino
178e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
179e4b17023SJohn Marino@end defmac
180e4b17023SJohn Marino
181e4b17023SJohn Marino@defmac CC1PLUS_SPEC
182e4b17023SJohn MarinoA C string constant that tells the GCC driver program options to
183e4b17023SJohn Marinopass to @code{cc1plus}.  It can also specify how to translate options you
184e4b17023SJohn Marinogive to GCC into options for GCC to pass to the @code{cc1plus}.
185e4b17023SJohn Marino
186e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
187e4b17023SJohn MarinoNote that everything defined in CC1_SPEC is already passed to
188e4b17023SJohn Marino@code{cc1plus} so there is no need to duplicate the contents of
189e4b17023SJohn MarinoCC1_SPEC in CC1PLUS_SPEC@.
190e4b17023SJohn Marino@end defmac
191e4b17023SJohn Marino
192e4b17023SJohn Marino@defmac ASM_SPEC
193e4b17023SJohn MarinoA C string constant that tells the GCC driver program options to
194e4b17023SJohn Marinopass to the assembler.  It can also specify how to translate options
195e4b17023SJohn Marinoyou give to GCC into options for GCC to pass to the assembler.
196e4b17023SJohn MarinoSee the file @file{sun3.h} for an example of this.
197e4b17023SJohn Marino
198e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
199e4b17023SJohn Marino@end defmac
200e4b17023SJohn Marino
201e4b17023SJohn Marino@defmac ASM_FINAL_SPEC
202e4b17023SJohn MarinoA C string constant that tells the GCC driver program how to
203e4b17023SJohn Marinorun any programs which cleanup after the normal assembler.
204e4b17023SJohn MarinoNormally, this is not needed.  See the file @file{mips.h} for
205e4b17023SJohn Marinoan example of this.
206e4b17023SJohn Marino
207e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
208e4b17023SJohn Marino@end defmac
209e4b17023SJohn Marino
210e4b17023SJohn Marino@defmac AS_NEEDS_DASH_FOR_PIPED_INPUT
211e4b17023SJohn MarinoDefine this macro, with no value, if the driver should give the assembler
212e4b17023SJohn Marinoan argument consisting of a single dash, @option{-}, to instruct it to
213e4b17023SJohn Marinoread from its standard input (which will be a pipe connected to the
214e4b17023SJohn Marinooutput of the compiler proper).  This argument is given after any
215e4b17023SJohn Marino@option{-o} option specifying the name of the output file.
216e4b17023SJohn Marino
217e4b17023SJohn MarinoIf you do not define this macro, the assembler is assumed to read its
218e4b17023SJohn Marinostandard input if given no non-option arguments.  If your assembler
219e4b17023SJohn Marinocannot read standard input at all, use a @samp{%@{pipe:%e@}} construct;
220e4b17023SJohn Marinosee @file{mips.h} for instance.
221e4b17023SJohn Marino@end defmac
222e4b17023SJohn Marino
223e4b17023SJohn Marino@defmac LINK_SPEC
224e4b17023SJohn MarinoA C string constant that tells the GCC driver program options to
225e4b17023SJohn Marinopass to the linker.  It can also specify how to translate options you
226e4b17023SJohn Marinogive to GCC into options for GCC to pass to the linker.
227e4b17023SJohn Marino
228e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
229e4b17023SJohn Marino@end defmac
230e4b17023SJohn Marino
231e4b17023SJohn Marino@defmac LIB_SPEC
232e4b17023SJohn MarinoAnother C string constant used much like @code{LINK_SPEC}.  The difference
233e4b17023SJohn Marinobetween the two is that @code{LIB_SPEC} is used at the end of the
234e4b17023SJohn Marinocommand given to the linker.
235e4b17023SJohn Marino
236e4b17023SJohn MarinoIf this macro is not defined, a default is provided that
237e4b17023SJohn Marinoloads the standard C library from the usual place.  See @file{gcc.c}.
238e4b17023SJohn Marino@end defmac
239e4b17023SJohn Marino
240e4b17023SJohn Marino@defmac LIBGCC_SPEC
241e4b17023SJohn MarinoAnother C string constant that tells the GCC driver program
242e4b17023SJohn Marinohow and when to place a reference to @file{libgcc.a} into the
243e4b17023SJohn Marinolinker command line.  This constant is placed both before and after
244e4b17023SJohn Marinothe value of @code{LIB_SPEC}.
245e4b17023SJohn Marino
246e4b17023SJohn MarinoIf this macro is not defined, the GCC driver provides a default that
247e4b17023SJohn Marinopasses the string @option{-lgcc} to the linker.
248e4b17023SJohn Marino@end defmac
249e4b17023SJohn Marino
250e4b17023SJohn Marino@defmac REAL_LIBGCC_SPEC
251e4b17023SJohn MarinoBy default, if @code{ENABLE_SHARED_LIBGCC} is defined, the
252e4b17023SJohn Marino@code{LIBGCC_SPEC} is not directly used by the driver program but is
253e4b17023SJohn Marinoinstead modified to refer to different versions of @file{libgcc.a}
254e4b17023SJohn Marinodepending on the values of the command line flags @option{-static},
255e4b17023SJohn Marino@option{-shared}, @option{-static-libgcc}, and @option{-shared-libgcc}.  On
256e4b17023SJohn Marinotargets where these modifications are inappropriate, define
257e4b17023SJohn Marino@code{REAL_LIBGCC_SPEC} instead.  @code{REAL_LIBGCC_SPEC} tells the
258e4b17023SJohn Marinodriver how to place a reference to @file{libgcc} on the link command
259e4b17023SJohn Marinoline, but, unlike @code{LIBGCC_SPEC}, it is used unmodified.
260e4b17023SJohn Marino@end defmac
261e4b17023SJohn Marino
262e4b17023SJohn Marino@defmac USE_LD_AS_NEEDED
263e4b17023SJohn MarinoA macro that controls the modifications to @code{LIBGCC_SPEC}
264e4b17023SJohn Marinomentioned in @code{REAL_LIBGCC_SPEC}.  If nonzero, a spec will be
265e4b17023SJohn Marinogenerated that uses --as-needed and the shared libgcc in place of the
266e4b17023SJohn Marinostatic exception handler library, when linking without any of
267e4b17023SJohn Marino@code{-static}, @code{-static-libgcc}, or @code{-shared-libgcc}.
268e4b17023SJohn Marino@end defmac
269e4b17023SJohn Marino
270e4b17023SJohn Marino@defmac LINK_EH_SPEC
271e4b17023SJohn MarinoIf defined, this C string constant is added to @code{LINK_SPEC}.
272e4b17023SJohn MarinoWhen @code{USE_LD_AS_NEEDED} is zero or undefined, it also affects
273e4b17023SJohn Marinothe modifications to @code{LIBGCC_SPEC} mentioned in
274e4b17023SJohn Marino@code{REAL_LIBGCC_SPEC}.
275e4b17023SJohn Marino@end defmac
276e4b17023SJohn Marino
277e4b17023SJohn Marino@defmac STARTFILE_SPEC
278e4b17023SJohn MarinoAnother C string constant used much like @code{LINK_SPEC}.  The
279e4b17023SJohn Marinodifference between the two is that @code{STARTFILE_SPEC} is used at
280e4b17023SJohn Marinothe very beginning of the command given to the linker.
281e4b17023SJohn Marino
282e4b17023SJohn MarinoIf this macro is not defined, a default is provided that loads the
283e4b17023SJohn Marinostandard C startup file from the usual place.  See @file{gcc.c}.
284e4b17023SJohn Marino@end defmac
285e4b17023SJohn Marino
286e4b17023SJohn Marino@defmac ENDFILE_SPEC
287e4b17023SJohn MarinoAnother C string constant used much like @code{LINK_SPEC}.  The
288e4b17023SJohn Marinodifference between the two is that @code{ENDFILE_SPEC} is used at
289e4b17023SJohn Marinothe very end of the command given to the linker.
290e4b17023SJohn Marino
291e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
292e4b17023SJohn Marino@end defmac
293e4b17023SJohn Marino
294e4b17023SJohn Marino@defmac THREAD_MODEL_SPEC
295e4b17023SJohn MarinoGCC @code{-v} will print the thread model GCC was configured to use.
296e4b17023SJohn MarinoHowever, this doesn't work on platforms that are multilibbed on thread
297e4b17023SJohn Marinomodels, such as AIX 4.3.  On such platforms, define
298e4b17023SJohn Marino@code{THREAD_MODEL_SPEC} such that it evaluates to a string without
299e4b17023SJohn Marinoblanks that names one of the recognized thread models.  @code{%*}, the
300e4b17023SJohn Marinodefault value of this macro, will expand to the value of
301e4b17023SJohn Marino@code{thread_file} set in @file{config.gcc}.
302e4b17023SJohn Marino@end defmac
303e4b17023SJohn Marino
304e4b17023SJohn Marino@defmac SYSROOT_SUFFIX_SPEC
305e4b17023SJohn MarinoDefine this macro to add a suffix to the target sysroot when GCC is
306e4b17023SJohn Marinoconfigured with a sysroot.  This will cause GCC to search for usr/lib,
307e4b17023SJohn Marinoet al, within sysroot+suffix.
308e4b17023SJohn Marino@end defmac
309e4b17023SJohn Marino
310e4b17023SJohn Marino@defmac SYSROOT_HEADERS_SUFFIX_SPEC
311e4b17023SJohn MarinoDefine this macro to add a headers_suffix to the target sysroot when
312e4b17023SJohn MarinoGCC is configured with a sysroot.  This will cause GCC to pass the
313e4b17023SJohn Marinoupdated sysroot+headers_suffix to CPP, causing it to search for
314e4b17023SJohn Marinousr/include, et al, within sysroot+headers_suffix.
315e4b17023SJohn Marino@end defmac
316e4b17023SJohn Marino
317e4b17023SJohn Marino@defmac EXTRA_SPECS
318e4b17023SJohn MarinoDefine this macro to provide additional specifications to put in the
319e4b17023SJohn Marino@file{specs} file that can be used in various specifications like
320e4b17023SJohn Marino@code{CC1_SPEC}.
321e4b17023SJohn Marino
322e4b17023SJohn MarinoThe definition should be an initializer for an array of structures,
323e4b17023SJohn Marinocontaining a string constant, that defines the specification name, and a
324e4b17023SJohn Marinostring constant that provides the specification.
325e4b17023SJohn Marino
326e4b17023SJohn MarinoDo not define this macro if it does not need to do anything.
327e4b17023SJohn Marino
328e4b17023SJohn Marino@code{EXTRA_SPECS} is useful when an architecture contains several
329e4b17023SJohn Marinorelated targets, which have various @code{@dots{}_SPECS} which are similar
330e4b17023SJohn Marinoto each other, and the maintainer would like one central place to keep
331e4b17023SJohn Marinothese definitions.
332e4b17023SJohn Marino
333e4b17023SJohn MarinoFor example, the PowerPC System V.4 targets use @code{EXTRA_SPECS} to
334e4b17023SJohn Marinodefine either @code{_CALL_SYSV} when the System V calling sequence is
335e4b17023SJohn Marinoused or @code{_CALL_AIX} when the older AIX-based calling sequence is
336e4b17023SJohn Marinoused.
337e4b17023SJohn Marino
338e4b17023SJohn MarinoThe @file{config/rs6000/rs6000.h} target file defines:
339e4b17023SJohn Marino
340e4b17023SJohn Marino@smallexample
341e4b17023SJohn Marino#define EXTRA_SPECS \
342e4b17023SJohn Marino  @{ "cpp_sysv_default", CPP_SYSV_DEFAULT @},
343e4b17023SJohn Marino
344e4b17023SJohn Marino#define CPP_SYS_DEFAULT ""
345e4b17023SJohn Marino@end smallexample
346e4b17023SJohn Marino
347e4b17023SJohn MarinoThe @file{config/rs6000/sysv.h} target file defines:
348e4b17023SJohn Marino@smallexample
349e4b17023SJohn Marino#undef CPP_SPEC
350e4b17023SJohn Marino#define CPP_SPEC \
351e4b17023SJohn Marino"%@{posix: -D_POSIX_SOURCE @} \
352e4b17023SJohn Marino%@{mcall-sysv: -D_CALL_SYSV @} \
353e4b17023SJohn Marino%@{!mcall-sysv: %(cpp_sysv_default) @} \
354e4b17023SJohn Marino%@{msoft-float: -D_SOFT_FLOAT@} %@{mcpu=403: -D_SOFT_FLOAT@}"
355e4b17023SJohn Marino
356e4b17023SJohn Marino#undef CPP_SYSV_DEFAULT
357e4b17023SJohn Marino#define CPP_SYSV_DEFAULT "-D_CALL_SYSV"
358e4b17023SJohn Marino@end smallexample
359e4b17023SJohn Marino
360e4b17023SJohn Marinowhile the @file{config/rs6000/eabiaix.h} target file defines
361e4b17023SJohn Marino@code{CPP_SYSV_DEFAULT} as:
362e4b17023SJohn Marino
363e4b17023SJohn Marino@smallexample
364e4b17023SJohn Marino#undef CPP_SYSV_DEFAULT
365e4b17023SJohn Marino#define CPP_SYSV_DEFAULT "-D_CALL_AIX"
366e4b17023SJohn Marino@end smallexample
367e4b17023SJohn Marino@end defmac
368e4b17023SJohn Marino
369e4b17023SJohn Marino@defmac LINK_LIBGCC_SPECIAL_1
370e4b17023SJohn MarinoDefine this macro if the driver program should find the library
371e4b17023SJohn Marino@file{libgcc.a}.  If you do not define this macro, the driver program will pass
372e4b17023SJohn Marinothe argument @option{-lgcc} to tell the linker to do the search.
373e4b17023SJohn Marino@end defmac
374e4b17023SJohn Marino
375e4b17023SJohn Marino@defmac LINK_GCC_C_SEQUENCE_SPEC
376e4b17023SJohn MarinoThe sequence in which libgcc and libc are specified to the linker.
377e4b17023SJohn MarinoBy default this is @code{%G %L %G}.
378e4b17023SJohn Marino@end defmac
379e4b17023SJohn Marino
380e4b17023SJohn Marino@defmac LINK_COMMAND_SPEC
381e4b17023SJohn MarinoA C string constant giving the complete command line need to execute the
382e4b17023SJohn Marinolinker.  When you do this, you will need to update your port each time a
383e4b17023SJohn Marinochange is made to the link command line within @file{gcc.c}.  Therefore,
384e4b17023SJohn Marinodefine this macro only if you need to completely redefine the command
385e4b17023SJohn Marinoline for invoking the linker and there is no other way to accomplish
386e4b17023SJohn Marinothe effect you need.  Overriding this macro may be avoidable by overriding
387e4b17023SJohn Marino@code{LINK_GCC_C_SEQUENCE_SPEC} instead.
388e4b17023SJohn Marino@end defmac
389e4b17023SJohn Marino
390e4b17023SJohn Marino@defmac LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
391e4b17023SJohn MarinoA nonzero value causes @command{collect2} to remove duplicate @option{-L@var{directory}} search
392e4b17023SJohn Marinodirectories from linking commands.  Do not give it a nonzero value if
393e4b17023SJohn Marinoremoving duplicate search directories changes the linker's semantics.
394e4b17023SJohn Marino@end defmac
395e4b17023SJohn Marino
396e4b17023SJohn Marino@hook TARGET_ALWAYS_STRIP_DOTDOT
397e4b17023SJohn Marino
398e4b17023SJohn Marino@defmac MULTILIB_DEFAULTS
399e4b17023SJohn MarinoDefine this macro as a C expression for the initializer of an array of
400e4b17023SJohn Marinostring to tell the driver program which options are defaults for this
401e4b17023SJohn Marinotarget and thus do not need to be handled specially when using
402e4b17023SJohn Marino@code{MULTILIB_OPTIONS}.
403e4b17023SJohn Marino
404e4b17023SJohn MarinoDo not define this macro if @code{MULTILIB_OPTIONS} is not defined in
405e4b17023SJohn Marinothe target makefile fragment or if none of the options listed in
406e4b17023SJohn Marino@code{MULTILIB_OPTIONS} are set by default.
407e4b17023SJohn Marino@xref{Target Fragment}.
408e4b17023SJohn Marino@end defmac
409e4b17023SJohn Marino
410e4b17023SJohn Marino@defmac RELATIVE_PREFIX_NOT_LINKDIR
411e4b17023SJohn MarinoDefine this macro to tell @command{gcc} that it should only translate
412e4b17023SJohn Marinoa @option{-B} prefix into a @option{-L} linker option if the prefix
413e4b17023SJohn Marinoindicates an absolute file name.
414e4b17023SJohn Marino@end defmac
415e4b17023SJohn Marino
416e4b17023SJohn Marino@defmac MD_EXEC_PREFIX
417e4b17023SJohn MarinoIf defined, this macro is an additional prefix to try after
418e4b17023SJohn Marino@code{STANDARD_EXEC_PREFIX}.  @code{MD_EXEC_PREFIX} is not searched
419e4b17023SJohn Marinowhen the compiler is built as a cross
420e4b17023SJohn Marinocompiler.  If you define @code{MD_EXEC_PREFIX}, then be sure to add it
421e4b17023SJohn Marinoto the list of directories used to find the assembler in @file{configure.in}.
422e4b17023SJohn Marino@end defmac
423e4b17023SJohn Marino
424e4b17023SJohn Marino@defmac STANDARD_STARTFILE_PREFIX
425e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to override the
426e4b17023SJohn Marinostandard choice of @code{libdir} as the default prefix to
427e4b17023SJohn Marinotry when searching for startup files such as @file{crt0.o}.
428e4b17023SJohn Marino@code{STANDARD_STARTFILE_PREFIX} is not searched when the compiler
429e4b17023SJohn Marinois built as a cross compiler.
430e4b17023SJohn Marino@end defmac
431e4b17023SJohn Marino
432e4b17023SJohn Marino@defmac STANDARD_STARTFILE_PREFIX_1
433e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to override the
434e4b17023SJohn Marinostandard choice of @code{/lib} as a prefix to try after the default prefix
435e4b17023SJohn Marinowhen searching for startup files such as @file{crt0.o}.
436e4b17023SJohn Marino@code{STANDARD_STARTFILE_PREFIX_1} is not searched when the compiler
437e4b17023SJohn Marinois built as a cross compiler.
438e4b17023SJohn Marino@end defmac
439e4b17023SJohn Marino
440e4b17023SJohn Marino@defmac STANDARD_STARTFILE_PREFIX_2
441e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to override the
442e4b17023SJohn Marinostandard choice of @code{/lib} as yet another prefix to try after the
443e4b17023SJohn Marinodefault prefix when searching for startup files such as @file{crt0.o}.
444e4b17023SJohn Marino@code{STANDARD_STARTFILE_PREFIX_2} is not searched when the compiler
445e4b17023SJohn Marinois built as a cross compiler.
446e4b17023SJohn Marino@end defmac
447e4b17023SJohn Marino
448e4b17023SJohn Marino@defmac MD_STARTFILE_PREFIX
449e4b17023SJohn MarinoIf defined, this macro supplies an additional prefix to try after the
450e4b17023SJohn Marinostandard prefixes.  @code{MD_EXEC_PREFIX} is not searched when the
451e4b17023SJohn Marinocompiler is built as a cross compiler.
452e4b17023SJohn Marino@end defmac
453e4b17023SJohn Marino
454e4b17023SJohn Marino@defmac MD_STARTFILE_PREFIX_1
455e4b17023SJohn MarinoIf defined, this macro supplies yet another prefix to try after the
456e4b17023SJohn Marinostandard prefixes.  It is not searched when the compiler is built as a
457e4b17023SJohn Marinocross compiler.
458e4b17023SJohn Marino@end defmac
459e4b17023SJohn Marino
460e4b17023SJohn Marino@defmac INIT_ENVIRONMENT
461e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to set environment
462e4b17023SJohn Marinovariables for programs called by the driver, such as the assembler and
463e4b17023SJohn Marinoloader.  The driver passes the value of this macro to @code{putenv} to
464e4b17023SJohn Marinoinitialize the necessary environment variables.
465e4b17023SJohn Marino@end defmac
466e4b17023SJohn Marino
467e4b17023SJohn Marino@defmac LOCAL_INCLUDE_DIR
468e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to override the
469e4b17023SJohn Marinostandard choice of @file{/usr/local/include} as the default prefix to
470e4b17023SJohn Marinotry when searching for local header files.  @code{LOCAL_INCLUDE_DIR}
471e4b17023SJohn Marinocomes before @code{NATIVE_SYSTEM_HEADER_DIR} (set in
472e4b17023SJohn Marino@file{config.gcc}, normally @file{/usr/include}) in the search order.
473e4b17023SJohn Marino
474e4b17023SJohn MarinoCross compilers do not search either @file{/usr/local/include} or its
475e4b17023SJohn Marinoreplacement.
476e4b17023SJohn Marino@end defmac
477e4b17023SJohn Marino
478e4b17023SJohn Marino@defmac NATIVE_SYSTEM_HEADER_COMPONENT
479e4b17023SJohn MarinoThe ``component'' corresponding to @code{NATIVE_SYSTEM_HEADER_DIR}.
480e4b17023SJohn MarinoSee @code{INCLUDE_DEFAULTS}, below, for the description of components.
481e4b17023SJohn MarinoIf you do not define this macro, no component is used.
482e4b17023SJohn Marino@end defmac
483e4b17023SJohn Marino
484e4b17023SJohn Marino@defmac INCLUDE_DEFAULTS
485e4b17023SJohn MarinoDefine this macro if you wish to override the entire default search path
486e4b17023SJohn Marinofor include files.  For a native compiler, the default search path
487e4b17023SJohn Marinousually consists of @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR},
488e4b17023SJohn Marino@code{GPLUSPLUS_INCLUDE_DIR}, and
489e4b17023SJohn Marino@code{NATIVE_SYSTEM_HEADER_DIR}.  In addition, @code{GPLUSPLUS_INCLUDE_DIR}
490e4b17023SJohn Marinoand @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile},
491e4b17023SJohn Marinoand specify private search areas for GCC@.  The directory
492e4b17023SJohn Marino@code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs.
493e4b17023SJohn Marino
494e4b17023SJohn MarinoThe definition should be an initializer for an array of structures.
495e4b17023SJohn MarinoEach array element should have four elements: the directory name (a
496e4b17023SJohn Marinostring constant), the component name (also a string constant), a flag
497e4b17023SJohn Marinofor C++-only directories,
498e4b17023SJohn Marinoand a flag showing that the includes in the directory don't need to be
499e4b17023SJohn Marinowrapped in @code{extern @samp{C}} when compiling C++.  Mark the end of
500e4b17023SJohn Marinothe array with a null element.
501e4b17023SJohn Marino
502e4b17023SJohn MarinoThe component name denotes what GNU package the include file is part of,
503e4b17023SJohn Marinoif any, in all uppercase letters.  For example, it might be @samp{GCC}
504e4b17023SJohn Marinoor @samp{BINUTILS}.  If the package is part of a vendor-supplied
505e4b17023SJohn Marinooperating system, code the component name as @samp{0}.
506e4b17023SJohn Marino
507e4b17023SJohn MarinoFor example, here is the definition used for VAX/VMS:
508e4b17023SJohn Marino
509e4b17023SJohn Marino@smallexample
510e4b17023SJohn Marino#define INCLUDE_DEFAULTS \
511e4b17023SJohn Marino@{                                       \
512e4b17023SJohn Marino  @{ "GNU_GXX_INCLUDE:", "G++", 1, 1@},   \
513e4b17023SJohn Marino  @{ "GNU_CC_INCLUDE:", "GCC", 0, 0@},    \
514e4b17023SJohn Marino  @{ "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0@},  \
515e4b17023SJohn Marino  @{ ".", 0, 0, 0@},                      \
516e4b17023SJohn Marino  @{ 0, 0, 0, 0@}                         \
517e4b17023SJohn Marino@}
518e4b17023SJohn Marino@end smallexample
519e4b17023SJohn Marino@end defmac
520e4b17023SJohn Marino
521e4b17023SJohn MarinoHere is the order of prefixes tried for exec files:
522e4b17023SJohn Marino
523e4b17023SJohn Marino@enumerate
524e4b17023SJohn Marino@item
525e4b17023SJohn MarinoAny prefixes specified by the user with @option{-B}.
526e4b17023SJohn Marino
527e4b17023SJohn Marino@item
528e4b17023SJohn MarinoThe environment variable @code{GCC_EXEC_PREFIX} or, if @code{GCC_EXEC_PREFIX}
529e4b17023SJohn Marinois not set and the compiler has not been installed in the configure-time
530e4b17023SJohn Marino@var{prefix}, the location in which the compiler has actually been installed.
531e4b17023SJohn Marino
532e4b17023SJohn Marino@item
533e4b17023SJohn MarinoThe directories specified by the environment variable @code{COMPILER_PATH}.
534e4b17023SJohn Marino
535e4b17023SJohn Marino@item
536e4b17023SJohn MarinoThe macro @code{STANDARD_EXEC_PREFIX}, if the compiler has been installed
537e4b17023SJohn Marinoin the configured-time @var{prefix}.
538e4b17023SJohn Marino
539e4b17023SJohn Marino@item
540e4b17023SJohn MarinoThe location @file{/usr/libexec/gcc/}, but only if this is a native compiler.
541e4b17023SJohn Marino
542e4b17023SJohn Marino@item
543e4b17023SJohn MarinoThe location @file{/usr/lib/gcc/}, but only if this is a native compiler.
544e4b17023SJohn Marino
545e4b17023SJohn Marino@item
546e4b17023SJohn MarinoThe macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native
547e4b17023SJohn Marinocompiler.
548e4b17023SJohn Marino@end enumerate
549e4b17023SJohn Marino
550e4b17023SJohn MarinoHere is the order of prefixes tried for startfiles:
551e4b17023SJohn Marino
552e4b17023SJohn Marino@enumerate
553e4b17023SJohn Marino@item
554e4b17023SJohn MarinoAny prefixes specified by the user with @option{-B}.
555e4b17023SJohn Marino
556e4b17023SJohn Marino@item
557e4b17023SJohn MarinoThe environment variable @code{GCC_EXEC_PREFIX} or its automatically determined
558e4b17023SJohn Marinovalue based on the installed toolchain location.
559e4b17023SJohn Marino
560e4b17023SJohn Marino@item
561e4b17023SJohn MarinoThe directories specified by the environment variable @code{LIBRARY_PATH}
562e4b17023SJohn Marino(or port-specific name; native only, cross compilers do not use this).
563e4b17023SJohn Marino
564e4b17023SJohn Marino@item
565e4b17023SJohn MarinoThe macro @code{STANDARD_EXEC_PREFIX}, but only if the toolchain is installed
566e4b17023SJohn Marinoin the configured @var{prefix} or this is a native compiler.
567e4b17023SJohn Marino
568e4b17023SJohn Marino@item
569e4b17023SJohn MarinoThe location @file{/usr/lib/gcc/}, but only if this is a native compiler.
570e4b17023SJohn Marino
571e4b17023SJohn Marino@item
572e4b17023SJohn MarinoThe macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native
573e4b17023SJohn Marinocompiler.
574e4b17023SJohn Marino
575e4b17023SJohn Marino@item
576e4b17023SJohn MarinoThe macro @code{MD_STARTFILE_PREFIX}, if defined, but only if this is a
577e4b17023SJohn Marinonative compiler, or we have a target system root.
578e4b17023SJohn Marino
579e4b17023SJohn Marino@item
580e4b17023SJohn MarinoThe macro @code{MD_STARTFILE_PREFIX_1}, if defined, but only if this is a
581e4b17023SJohn Marinonative compiler, or we have a target system root.
582e4b17023SJohn Marino
583e4b17023SJohn Marino@item
584e4b17023SJohn MarinoThe macro @code{STANDARD_STARTFILE_PREFIX}, with any sysroot modifications.
585e4b17023SJohn MarinoIf this path is relative it will be prefixed by @code{GCC_EXEC_PREFIX} and
586e4b17023SJohn Marinothe machine suffix or @code{STANDARD_EXEC_PREFIX} and the machine suffix.
587e4b17023SJohn Marino
588e4b17023SJohn Marino@item
589e4b17023SJohn MarinoThe macro @code{STANDARD_STARTFILE_PREFIX_1}, but only if this is a native
590e4b17023SJohn Marinocompiler, or we have a target system root. The default for this macro is
591e4b17023SJohn Marino@file{/lib/}.
592e4b17023SJohn Marino
593e4b17023SJohn Marino@item
594e4b17023SJohn MarinoThe macro @code{STANDARD_STARTFILE_PREFIX_2}, but only if this is a native
595e4b17023SJohn Marinocompiler, or we have a target system root. The default for this macro is
596e4b17023SJohn Marino@file{/usr/lib/}.
597e4b17023SJohn Marino@end enumerate
598e4b17023SJohn Marino
599e4b17023SJohn Marino@node Run-time Target
600e4b17023SJohn Marino@section Run-time Target Specification
601e4b17023SJohn Marino@cindex run-time target specification
602e4b17023SJohn Marino@cindex predefined macros
603e4b17023SJohn Marino@cindex target specifications
604e4b17023SJohn Marino
605e4b17023SJohn Marino@c prevent bad page break with this line
606e4b17023SJohn MarinoHere are run-time target specifications.
607e4b17023SJohn Marino
608e4b17023SJohn Marino@defmac TARGET_CPU_CPP_BUILTINS ()
609e4b17023SJohn MarinoThis function-like macro expands to a block of code that defines
610e4b17023SJohn Marinobuilt-in preprocessor macros and assertions for the target CPU, using
611e4b17023SJohn Marinothe functions @code{builtin_define}, @code{builtin_define_std} and
612e4b17023SJohn Marino@code{builtin_assert}.  When the front end
613e4b17023SJohn Marinocalls this macro it provides a trailing semicolon, and since it has
614e4b17023SJohn Marinofinished command line option processing your code can use those
615e4b17023SJohn Marinoresults freely.
616e4b17023SJohn Marino
617e4b17023SJohn Marino@code{builtin_assert} takes a string in the form you pass to the
618e4b17023SJohn Marinocommand-line option @option{-A}, such as @code{cpu=mips}, and creates
619e4b17023SJohn Marinothe assertion.  @code{builtin_define} takes a string in the form
620e4b17023SJohn Marinoaccepted by option @option{-D} and unconditionally defines the macro.
621e4b17023SJohn Marino
622e4b17023SJohn Marino@code{builtin_define_std} takes a string representing the name of an
623e4b17023SJohn Marinoobject-like macro.  If it doesn't lie in the user's namespace,
624e4b17023SJohn Marino@code{builtin_define_std} defines it unconditionally.  Otherwise, it
625e4b17023SJohn Marinodefines a version with two leading underscores, and another version
626e4b17023SJohn Marinowith two leading and trailing underscores, and defines the original
627e4b17023SJohn Marinoonly if an ISO standard was not requested on the command line.  For
628e4b17023SJohn Marinoexample, passing @code{unix} defines @code{__unix}, @code{__unix__}
629e4b17023SJohn Marinoand possibly @code{unix}; passing @code{_mips} defines @code{__mips},
630e4b17023SJohn Marino@code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
631e4b17023SJohn Marinodefines only @code{_ABI64}.
632e4b17023SJohn Marino
633e4b17023SJohn MarinoYou can also test for the C dialect being compiled.  The variable
634e4b17023SJohn Marino@code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus}
635e4b17023SJohn Marinoor @code{clk_objective_c}.  Note that if we are preprocessing
636e4b17023SJohn Marinoassembler, this variable will be @code{clk_c} but the function-like
637e4b17023SJohn Marinomacro @code{preprocessing_asm_p()} will return true, so you might want
638e4b17023SJohn Marinoto check for that first.  If you need to check for strict ANSI, the
639e4b17023SJohn Marinovariable @code{flag_iso} can be used.  The function-like macro
640e4b17023SJohn Marino@code{preprocessing_trad_p()} can be used to check for traditional
641e4b17023SJohn Marinopreprocessing.
642e4b17023SJohn Marino@end defmac
643e4b17023SJohn Marino
644e4b17023SJohn Marino@defmac TARGET_OS_CPP_BUILTINS ()
645e4b17023SJohn MarinoSimilarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
646e4b17023SJohn Marinoand is used for the target operating system instead.
647e4b17023SJohn Marino@end defmac
648e4b17023SJohn Marino
649e4b17023SJohn Marino@defmac TARGET_OBJFMT_CPP_BUILTINS ()
650e4b17023SJohn MarinoSimilarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
651e4b17023SJohn Marinoand is used for the target object format.  @file{elfos.h} uses this
652e4b17023SJohn Marinomacro to define @code{__ELF__}, so you probably do not need to define
653e4b17023SJohn Marinoit yourself.
654e4b17023SJohn Marino@end defmac
655e4b17023SJohn Marino
656e4b17023SJohn Marino@deftypevar {extern int} target_flags
657e4b17023SJohn MarinoThis variable is declared in @file{options.h}, which is included before
658e4b17023SJohn Marinoany target-specific headers.
659e4b17023SJohn Marino@end deftypevar
660e4b17023SJohn Marino
661e4b17023SJohn Marino@hook TARGET_DEFAULT_TARGET_FLAGS
662e4b17023SJohn MarinoThis variable specifies the initial value of @code{target_flags}.
663e4b17023SJohn MarinoIts default setting is 0.
664e4b17023SJohn Marino@end deftypevr
665e4b17023SJohn Marino
666e4b17023SJohn Marino@cindex optional hardware or system features
667e4b17023SJohn Marino@cindex features, optional, in system conventions
668e4b17023SJohn Marino
669e4b17023SJohn Marino@hook TARGET_HANDLE_OPTION
670e4b17023SJohn MarinoThis hook is called whenever the user specifies one of the
671e4b17023SJohn Marinotarget-specific options described by the @file{.opt} definition files
672e4b17023SJohn Marino(@pxref{Options}).  It has the opportunity to do some option-specific
673e4b17023SJohn Marinoprocessing and should return true if the option is valid.  The default
674e4b17023SJohn Marinodefinition does nothing but return true.
675e4b17023SJohn Marino
676e4b17023SJohn Marino@var{decoded} specifies the option and its arguments.  @var{opts} and
677e4b17023SJohn Marino@var{opts_set} are the @code{gcc_options} structures to be used for
678e4b17023SJohn Marinostoring option state, and @var{loc} is the location at which the
679e4b17023SJohn Marinooption was passed (@code{UNKNOWN_LOCATION} except for options passed
680e4b17023SJohn Marinovia attributes).
681e4b17023SJohn Marino@end deftypefn
682e4b17023SJohn Marino
683e4b17023SJohn Marino@hook TARGET_HANDLE_C_OPTION
684e4b17023SJohn MarinoThis target hook is called whenever the user specifies one of the
685e4b17023SJohn Marinotarget-specific C language family options described by the @file{.opt}
686e4b17023SJohn Marinodefinition files(@pxref{Options}).  It has the opportunity to do some
687e4b17023SJohn Marinooption-specific processing and should return true if the option is
688e4b17023SJohn Marinovalid.  The arguments are like for @code{TARGET_HANDLE_OPTION}.  The
689e4b17023SJohn Marinodefault definition does nothing but return false.
690e4b17023SJohn Marino
691e4b17023SJohn MarinoIn general, you should use @code{TARGET_HANDLE_OPTION} to handle
692e4b17023SJohn Marinooptions.  However, if processing an option requires routines that are
693e4b17023SJohn Marinoonly available in the C (and related language) front ends, then you
694e4b17023SJohn Marinoshould use @code{TARGET_HANDLE_C_OPTION} instead.
695e4b17023SJohn Marino@end deftypefn
696e4b17023SJohn Marino
697e4b17023SJohn Marino@hook TARGET_OBJC_CONSTRUCT_STRING_OBJECT
698e4b17023SJohn Marino
699*95d28233SJohn Marino@hook TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE
700*95d28233SJohn Marino
701*95d28233SJohn Marino@hook TARGET_OBJC_DECLARE_CLASS_DEFINITION
702*95d28233SJohn Marino
703e4b17023SJohn Marino@hook TARGET_STRING_OBJECT_REF_TYPE_P
704e4b17023SJohn Marino
705e4b17023SJohn Marino@hook TARGET_CHECK_STRING_OBJECT_FORMAT_ARG
706e4b17023SJohn Marino
707e4b17023SJohn Marino@hook TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
708e4b17023SJohn MarinoThis target function is similar to the hook @code{TARGET_OPTION_OVERRIDE}
709e4b17023SJohn Marinobut is called when the optimize level is changed via an attribute or
710e4b17023SJohn Marinopragma or when it is reset at the end of the code affected by the
711e4b17023SJohn Marinoattribute or pragma.  It is not called at the beginning of compilation
712e4b17023SJohn Marinowhen @code{TARGET_OPTION_OVERRIDE} is called so if you want to perform these
713e4b17023SJohn Marinoactions then, you should have @code{TARGET_OPTION_OVERRIDE} call
714e4b17023SJohn Marino@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}.
715e4b17023SJohn Marino@end deftypefn
716e4b17023SJohn Marino
717e4b17023SJohn Marino@defmac C_COMMON_OVERRIDE_OPTIONS
718e4b17023SJohn MarinoThis is similar to the @code{TARGET_OPTION_OVERRIDE} hook
719e4b17023SJohn Marinobut is only used in the C
720e4b17023SJohn Marinolanguage frontends (C, Objective-C, C++, Objective-C++) and so can be
721e4b17023SJohn Marinoused to alter option flag variables which only exist in those
722e4b17023SJohn Marinofrontends.
723e4b17023SJohn Marino@end defmac
724e4b17023SJohn Marino
725e4b17023SJohn Marino@hook TARGET_OPTION_OPTIMIZATION_TABLE
726e4b17023SJohn MarinoSome machines may desire to change what optimizations are performed for
727e4b17023SJohn Marinovarious optimization levels.   This variable, if defined, describes
728e4b17023SJohn Marinooptions to enable at particular sets of optimization levels.  These
729e4b17023SJohn Marinooptions are processed once
730e4b17023SJohn Marinojust after the optimization level is determined and before the remainder
731e4b17023SJohn Marinoof the command options have been parsed, so may be overridden by other
732e4b17023SJohn Marinooptions passed explicitly.
733e4b17023SJohn Marino
734e4b17023SJohn MarinoThis processing is run once at program startup and when the optimization
735e4b17023SJohn Marinooptions are changed via @code{#pragma GCC optimize} or by using the
736e4b17023SJohn Marino@code{optimize} attribute.
737e4b17023SJohn Marino@end deftypevr
738e4b17023SJohn Marino
739e4b17023SJohn Marino@hook TARGET_OPTION_INIT_STRUCT
740e4b17023SJohn Marino
741e4b17023SJohn Marino@hook TARGET_OPTION_DEFAULT_PARAMS
742e4b17023SJohn Marino
743e4b17023SJohn Marino@defmac SWITCHABLE_TARGET
744e4b17023SJohn MarinoSome targets need to switch between substantially different subtargets
745e4b17023SJohn Marinoduring compilation.  For example, the MIPS target has one subtarget for
746e4b17023SJohn Marinothe traditional MIPS architecture and another for MIPS16.  Source code
747e4b17023SJohn Marinocan switch between these two subarchitectures using the @code{mips16}
748e4b17023SJohn Marinoand @code{nomips16} attributes.
749e4b17023SJohn Marino
750e4b17023SJohn MarinoSuch subtargets can differ in things like the set of available
751e4b17023SJohn Marinoregisters, the set of available instructions, the costs of various
752e4b17023SJohn Marinooperations, and so on.  GCC caches a lot of this type of information
753e4b17023SJohn Marinoin global variables, and recomputing them for each subtarget takes a
754e4b17023SJohn Marinosignificant amount of time.  The compiler therefore provides a facility
755e4b17023SJohn Marinofor maintaining several versions of the global variables and quickly
756e4b17023SJohn Marinoswitching between them; see @file{target-globals.h} for details.
757e4b17023SJohn Marino
758e4b17023SJohn MarinoDefine this macro to 1 if your target needs this facility.  The default
759e4b17023SJohn Marinois 0.
760e4b17023SJohn Marino@end defmac
761e4b17023SJohn Marino
762e4b17023SJohn Marino@node Per-Function Data
763e4b17023SJohn Marino@section Defining data structures for per-function information.
764e4b17023SJohn Marino@cindex per-function data
765e4b17023SJohn Marino@cindex data structures
766e4b17023SJohn Marino
767e4b17023SJohn MarinoIf the target needs to store information on a per-function basis, GCC
768e4b17023SJohn Marinoprovides a macro and a couple of variables to allow this.  Note, just
769e4b17023SJohn Marinousing statics to store the information is a bad idea, since GCC supports
770e4b17023SJohn Marinonested functions, so you can be halfway through encoding one function
771e4b17023SJohn Marinowhen another one comes along.
772e4b17023SJohn Marino
773e4b17023SJohn MarinoGCC defines a data structure called @code{struct function} which
774e4b17023SJohn Marinocontains all of the data specific to an individual function.  This
775e4b17023SJohn Marinostructure contains a field called @code{machine} whose type is
776e4b17023SJohn Marino@code{struct machine_function *}, which can be used by targets to point
777e4b17023SJohn Marinoto their own specific data.
778e4b17023SJohn Marino
779e4b17023SJohn MarinoIf a target needs per-function specific data it should define the type
780e4b17023SJohn Marino@code{struct machine_function} and also the macro @code{INIT_EXPANDERS}.
781e4b17023SJohn MarinoThis macro should be used to initialize the function pointer
782e4b17023SJohn Marino@code{init_machine_status}.  This pointer is explained below.
783e4b17023SJohn Marino
784e4b17023SJohn MarinoOne typical use of per-function, target specific data is to create an
785e4b17023SJohn MarinoRTX to hold the register containing the function's return address.  This
786e4b17023SJohn MarinoRTX can then be used to implement the @code{__builtin_return_address}
787e4b17023SJohn Marinofunction, for level 0.
788e4b17023SJohn Marino
789e4b17023SJohn MarinoNote---earlier implementations of GCC used a single data area to hold
790e4b17023SJohn Marinoall of the per-function information.  Thus when processing of a nested
791e4b17023SJohn Marinofunction began the old per-function data had to be pushed onto a
792e4b17023SJohn Marinostack, and when the processing was finished, it had to be popped off the
793e4b17023SJohn Marinostack.  GCC used to provide function pointers called
794e4b17023SJohn Marino@code{save_machine_status} and @code{restore_machine_status} to handle
795e4b17023SJohn Marinothe saving and restoring of the target specific information.  Since the
796e4b17023SJohn Marinosingle data area approach is no longer used, these pointers are no
797e4b17023SJohn Marinolonger supported.
798e4b17023SJohn Marino
799e4b17023SJohn Marino@defmac INIT_EXPANDERS
800e4b17023SJohn MarinoMacro called to initialize any target specific information.  This macro
801e4b17023SJohn Marinois called once per function, before generation of any RTL has begun.
802e4b17023SJohn MarinoThe intention of this macro is to allow the initialization of the
803e4b17023SJohn Marinofunction pointer @code{init_machine_status}.
804e4b17023SJohn Marino@end defmac
805e4b17023SJohn Marino
806e4b17023SJohn Marino@deftypevar {void (*)(struct function *)} init_machine_status
807e4b17023SJohn MarinoIf this function pointer is non-@code{NULL} it will be called once per
808e4b17023SJohn Marinofunction, before function compilation starts, in order to allow the
809e4b17023SJohn Marinotarget to perform any target specific initialization of the
810e4b17023SJohn Marino@code{struct function} structure.  It is intended that this would be
811e4b17023SJohn Marinoused to initialize the @code{machine} of that structure.
812e4b17023SJohn Marino
813e4b17023SJohn Marino@code{struct machine_function} structures are expected to be freed by GC@.
814e4b17023SJohn MarinoGenerally, any memory that they reference must be allocated by using
815e4b17023SJohn MarinoGC allocation, including the structure itself.
816e4b17023SJohn Marino@end deftypevar
817e4b17023SJohn Marino
818e4b17023SJohn Marino@node Storage Layout
819e4b17023SJohn Marino@section Storage Layout
820e4b17023SJohn Marino@cindex storage layout
821e4b17023SJohn Marino
822e4b17023SJohn MarinoNote that the definitions of the macros in this table which are sizes or
823e4b17023SJohn Marinoalignments measured in bits do not need to be constant.  They can be C
824e4b17023SJohn Marinoexpressions that refer to static variables, such as the @code{target_flags}.
825e4b17023SJohn Marino@xref{Run-time Target}.
826e4b17023SJohn Marino
827e4b17023SJohn Marino@defmac BITS_BIG_ENDIAN
828e4b17023SJohn MarinoDefine this macro to have the value 1 if the most significant bit in a
829e4b17023SJohn Marinobyte has the lowest number; otherwise define it to have the value zero.
830e4b17023SJohn MarinoThis means that bit-field instructions count from the most significant
831e4b17023SJohn Marinobit.  If the machine has no bit-field instructions, then this must still
832e4b17023SJohn Marinobe defined, but it doesn't matter which value it is defined to.  This
833e4b17023SJohn Marinomacro need not be a constant.
834e4b17023SJohn Marino
835e4b17023SJohn MarinoThis macro does not affect the way structure fields are packed into
836e4b17023SJohn Marinobytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}.
837e4b17023SJohn Marino@end defmac
838e4b17023SJohn Marino
839e4b17023SJohn Marino@defmac BYTES_BIG_ENDIAN
840e4b17023SJohn MarinoDefine this macro to have the value 1 if the most significant byte in a
841e4b17023SJohn Marinoword has the lowest number.  This macro need not be a constant.
842e4b17023SJohn Marino@end defmac
843e4b17023SJohn Marino
844e4b17023SJohn Marino@defmac WORDS_BIG_ENDIAN
845e4b17023SJohn MarinoDefine this macro to have the value 1 if, in a multiword object, the
846e4b17023SJohn Marinomost significant word has the lowest number.  This applies to both
847e4b17023SJohn Marinomemory locations and registers; see @code{REG_WORDS_BIG_ENDIAN} if the
848e4b17023SJohn Marinoorder of words in memory is not the same as the order in registers.  This
849e4b17023SJohn Marinomacro need not be a constant.
850e4b17023SJohn Marino@end defmac
851e4b17023SJohn Marino
852e4b17023SJohn Marino@defmac REG_WORDS_BIG_ENDIAN
853e4b17023SJohn MarinoOn some machines, the order of words in a multiword object differs between
854e4b17023SJohn Marinoregisters in memory.  In such a situation, define this macro to describe
855e4b17023SJohn Marinothe order of words in a register.  The macro @code{WORDS_BIG_ENDIAN} controls
856e4b17023SJohn Marinothe order of words in memory.
857e4b17023SJohn Marino@end defmac
858e4b17023SJohn Marino
859e4b17023SJohn Marino@defmac FLOAT_WORDS_BIG_ENDIAN
860e4b17023SJohn MarinoDefine this macro to have the value 1 if @code{DFmode}, @code{XFmode} or
861e4b17023SJohn Marino@code{TFmode} floating point numbers are stored in memory with the word
862e4b17023SJohn Marinocontaining the sign bit at the lowest address; otherwise define it to
863e4b17023SJohn Marinohave the value 0.  This macro need not be a constant.
864e4b17023SJohn Marino
865e4b17023SJohn MarinoYou need not define this macro if the ordering is the same as for
866e4b17023SJohn Marinomulti-word integers.
867e4b17023SJohn Marino@end defmac
868e4b17023SJohn Marino
869e4b17023SJohn Marino@defmac BITS_PER_UNIT
870e4b17023SJohn MarinoDefine this macro to be the number of bits in an addressable storage
871e4b17023SJohn Marinounit (byte).  If you do not define this macro the default is 8.
872e4b17023SJohn Marino@end defmac
873e4b17023SJohn Marino
874e4b17023SJohn Marino@defmac BITS_PER_WORD
875e4b17023SJohn MarinoNumber of bits in a word.  If you do not define this macro, the default
876e4b17023SJohn Marinois @code{BITS_PER_UNIT * UNITS_PER_WORD}.
877e4b17023SJohn Marino@end defmac
878e4b17023SJohn Marino
879e4b17023SJohn Marino@defmac MAX_BITS_PER_WORD
880e4b17023SJohn MarinoMaximum number of bits in a word.  If this is undefined, the default is
881e4b17023SJohn Marino@code{BITS_PER_WORD}.  Otherwise, it is the constant value that is the
882e4b17023SJohn Marinolargest value that @code{BITS_PER_WORD} can have at run-time.
883e4b17023SJohn Marino@end defmac
884e4b17023SJohn Marino
885e4b17023SJohn Marino@defmac UNITS_PER_WORD
886e4b17023SJohn MarinoNumber of storage units in a word; normally the size of a general-purpose
887e4b17023SJohn Marinoregister, a power of two from 1 or 8.
888e4b17023SJohn Marino@end defmac
889e4b17023SJohn Marino
890e4b17023SJohn Marino@defmac MIN_UNITS_PER_WORD
891e4b17023SJohn MarinoMinimum number of units in a word.  If this is undefined, the default is
892e4b17023SJohn Marino@code{UNITS_PER_WORD}.  Otherwise, it is the constant value that is the
893e4b17023SJohn Marinosmallest value that @code{UNITS_PER_WORD} can have at run-time.
894e4b17023SJohn Marino@end defmac
895e4b17023SJohn Marino
896e4b17023SJohn Marino@defmac POINTER_SIZE
897e4b17023SJohn MarinoWidth of a pointer, in bits.  You must specify a value no wider than the
898e4b17023SJohn Marinowidth of @code{Pmode}.  If it is not equal to the width of @code{Pmode},
899e4b17023SJohn Marinoyou must define @code{POINTERS_EXTEND_UNSIGNED}.  If you do not specify
900e4b17023SJohn Marinoa value the default is @code{BITS_PER_WORD}.
901e4b17023SJohn Marino@end defmac
902e4b17023SJohn Marino
903e4b17023SJohn Marino@defmac POINTERS_EXTEND_UNSIGNED
904e4b17023SJohn MarinoA C expression that determines how pointers should be extended from
905e4b17023SJohn Marino@code{ptr_mode} to either @code{Pmode} or @code{word_mode}.  It is
906e4b17023SJohn Marinogreater than zero if pointers should be zero-extended, zero if they
907e4b17023SJohn Marinoshould be sign-extended, and negative if some other sort of conversion
908e4b17023SJohn Marinois needed.  In the last case, the extension is done by the target's
909e4b17023SJohn Marino@code{ptr_extend} instruction.
910e4b17023SJohn Marino
911e4b17023SJohn MarinoYou need not define this macro if the @code{ptr_mode}, @code{Pmode}
912e4b17023SJohn Marinoand @code{word_mode} are all the same width.
913e4b17023SJohn Marino@end defmac
914e4b17023SJohn Marino
915e4b17023SJohn Marino@defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type})
916e4b17023SJohn MarinoA macro to update @var{m} and @var{unsignedp} when an object whose type
917e4b17023SJohn Marinois @var{type} and which has the specified mode and signedness is to be
918e4b17023SJohn Marinostored in a register.  This macro is only called when @var{type} is a
919e4b17023SJohn Marinoscalar type.
920e4b17023SJohn Marino
921e4b17023SJohn MarinoOn most RISC machines, which only have operations that operate on a full
922e4b17023SJohn Marinoregister, define this macro to set @var{m} to @code{word_mode} if
923e4b17023SJohn Marino@var{m} is an integer mode narrower than @code{BITS_PER_WORD}.  In most
924e4b17023SJohn Marinocases, only integer modes should be widened because wider-precision
925e4b17023SJohn Marinofloating-point operations are usually more expensive than their narrower
926e4b17023SJohn Marinocounterparts.
927e4b17023SJohn Marino
928e4b17023SJohn MarinoFor most machines, the macro definition does not change @var{unsignedp}.
929e4b17023SJohn MarinoHowever, some machines, have instructions that preferentially handle
930e4b17023SJohn Marinoeither signed or unsigned quantities of certain modes.  For example, on
931e4b17023SJohn Marinothe DEC Alpha, 32-bit loads from memory and 32-bit add instructions
932e4b17023SJohn Marinosign-extend the result to 64 bits.  On such machines, set
933e4b17023SJohn Marino@var{unsignedp} according to which kind of extension is more efficient.
934e4b17023SJohn Marino
935e4b17023SJohn MarinoDo not define this macro if it would never modify @var{m}.
936e4b17023SJohn Marino@end defmac
937e4b17023SJohn Marino
938e4b17023SJohn Marino@hook TARGET_PROMOTE_FUNCTION_MODE
939e4b17023SJohn MarinoLike @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or
940e4b17023SJohn Marinofunction return values.  The target hook should return the new mode
941e4b17023SJohn Marinoand possibly change @code{*@var{punsignedp}} if the promotion should
942e4b17023SJohn Marinochange signedness.  This function is called only for scalar @emph{or
943e4b17023SJohn Marinopointer} types.
944e4b17023SJohn Marino
945e4b17023SJohn Marino@var{for_return} allows to distinguish the promotion of arguments and
946e4b17023SJohn Marinoreturn values.  If it is @code{1}, a return value is being promoted and
947e4b17023SJohn Marino@code{TARGET_FUNCTION_VALUE} must perform the same promotions done here.
948e4b17023SJohn MarinoIf it is @code{2}, the returned mode should be that of the register in
949e4b17023SJohn Marinowhich an incoming parameter is copied, or the outgoing result is computed;
950e4b17023SJohn Marinothen the hook should return the same mode as @code{promote_mode}, though
951e4b17023SJohn Marinothe signedness may be different.
952e4b17023SJohn Marino
953e4b17023SJohn Marino@var{type} can be NULL when promoting function arguments of libcalls.
954e4b17023SJohn Marino
955e4b17023SJohn MarinoThe default is to not promote arguments and return values.  You can
956e4b17023SJohn Marinoalso define the hook to @code{default_promote_function_mode_always_promote}
957e4b17023SJohn Marinoif you would like to apply the same rules given by @code{PROMOTE_MODE}.
958e4b17023SJohn Marino@end deftypefn
959e4b17023SJohn Marino
960e4b17023SJohn Marino@defmac PARM_BOUNDARY
961e4b17023SJohn MarinoNormal alignment required for function parameters on the stack, in
962e4b17023SJohn Marinobits.  All stack parameters receive at least this much alignment
963e4b17023SJohn Marinoregardless of data type.  On most machines, this is the same as the
964e4b17023SJohn Marinosize of an integer.
965e4b17023SJohn Marino@end defmac
966e4b17023SJohn Marino
967e4b17023SJohn Marino@defmac STACK_BOUNDARY
968e4b17023SJohn MarinoDefine this macro to the minimum alignment enforced by hardware for the
969e4b17023SJohn Marinostack pointer on this machine.  The definition is a C expression for the
970e4b17023SJohn Marinodesired alignment (measured in bits).  This value is used as a default
971e4b17023SJohn Marinoif @code{PREFERRED_STACK_BOUNDARY} is not defined.  On most machines,
972e4b17023SJohn Marinothis should be the same as @code{PARM_BOUNDARY}.
973e4b17023SJohn Marino@end defmac
974e4b17023SJohn Marino
975e4b17023SJohn Marino@defmac PREFERRED_STACK_BOUNDARY
976e4b17023SJohn MarinoDefine this macro if you wish to preserve a certain alignment for the
977e4b17023SJohn Marinostack pointer, greater than what the hardware enforces.  The definition
978e4b17023SJohn Marinois a C expression for the desired alignment (measured in bits).  This
979e4b17023SJohn Marinomacro must evaluate to a value equal to or larger than
980e4b17023SJohn Marino@code{STACK_BOUNDARY}.
981e4b17023SJohn Marino@end defmac
982e4b17023SJohn Marino
983e4b17023SJohn Marino@defmac INCOMING_STACK_BOUNDARY
984e4b17023SJohn MarinoDefine this macro if the incoming stack boundary may be different
985e4b17023SJohn Marinofrom @code{PREFERRED_STACK_BOUNDARY}.  This macro must evaluate
986e4b17023SJohn Marinoto a value equal to or larger than @code{STACK_BOUNDARY}.
987e4b17023SJohn Marino@end defmac
988e4b17023SJohn Marino
989e4b17023SJohn Marino@defmac FUNCTION_BOUNDARY
990e4b17023SJohn MarinoAlignment required for a function entry point, in bits.
991e4b17023SJohn Marino@end defmac
992e4b17023SJohn Marino
993e4b17023SJohn Marino@defmac BIGGEST_ALIGNMENT
994e4b17023SJohn MarinoBiggest alignment that any data type can require on this machine, in
995e4b17023SJohn Marinobits.  Note that this is not the biggest alignment that is supported,
996e4b17023SJohn Marinojust the biggest alignment that, when violated, may cause a fault.
997e4b17023SJohn Marino@end defmac
998e4b17023SJohn Marino
999e4b17023SJohn Marino@defmac MALLOC_ABI_ALIGNMENT
1000e4b17023SJohn MarinoAlignment, in bits, a C conformant malloc implementation has to
1001e4b17023SJohn Marinoprovide.  If not defined, the default value is @code{BITS_PER_WORD}.
1002e4b17023SJohn Marino@end defmac
1003e4b17023SJohn Marino
1004e4b17023SJohn Marino@defmac ATTRIBUTE_ALIGNED_VALUE
1005e4b17023SJohn MarinoAlignment used by the @code{__attribute__ ((aligned))} construct.  If
1006e4b17023SJohn Marinonot defined, the default value is @code{BIGGEST_ALIGNMENT}.
1007e4b17023SJohn Marino@end defmac
1008e4b17023SJohn Marino
1009e4b17023SJohn Marino@defmac MINIMUM_ATOMIC_ALIGNMENT
1010e4b17023SJohn MarinoIf defined, the smallest alignment, in bits, that can be given to an
1011e4b17023SJohn Marinoobject that can be referenced in one operation, without disturbing any
1012e4b17023SJohn Marinonearby object.  Normally, this is @code{BITS_PER_UNIT}, but may be larger
1013e4b17023SJohn Marinoon machines that don't have byte or half-word store operations.
1014e4b17023SJohn Marino@end defmac
1015e4b17023SJohn Marino
1016e4b17023SJohn Marino@defmac BIGGEST_FIELD_ALIGNMENT
1017e4b17023SJohn MarinoBiggest alignment that any structure or union field can require on this
1018e4b17023SJohn Marinomachine, in bits.  If defined, this overrides @code{BIGGEST_ALIGNMENT} for
1019e4b17023SJohn Marinostructure and union fields only, unless the field alignment has been set
1020e4b17023SJohn Marinoby the @code{__attribute__ ((aligned (@var{n})))} construct.
1021e4b17023SJohn Marino@end defmac
1022e4b17023SJohn Marino
1023e4b17023SJohn Marino@defmac ADJUST_FIELD_ALIGN (@var{field}, @var{computed})
1024e4b17023SJohn MarinoAn expression for the alignment of a structure field @var{field} if the
1025e4b17023SJohn Marinoalignment computed in the usual way (including applying of
1026e4b17023SJohn Marino@code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the
1027e4b17023SJohn Marinoalignment) is @var{computed}.  It overrides alignment only if the
1028e4b17023SJohn Marinofield alignment has not been set by the
1029e4b17023SJohn Marino@code{__attribute__ ((aligned (@var{n})))} construct.
1030e4b17023SJohn Marino@end defmac
1031e4b17023SJohn Marino
1032e4b17023SJohn Marino@defmac MAX_STACK_ALIGNMENT
1033e4b17023SJohn MarinoBiggest stack alignment guaranteed by the backend.  Use this macro
1034e4b17023SJohn Marinoto specify the maximum alignment of a variable on stack.
1035e4b17023SJohn Marino
1036e4b17023SJohn MarinoIf not defined, the default value is @code{STACK_BOUNDARY}.
1037e4b17023SJohn Marino
1038e4b17023SJohn Marino@c FIXME: The default should be @code{PREFERRED_STACK_BOUNDARY}.
1039e4b17023SJohn Marino@c But the fix for PR 32893 indicates that we can only guarantee
1040e4b17023SJohn Marino@c maximum stack alignment on stack up to @code{STACK_BOUNDARY}, not
1041e4b17023SJohn Marino@c @code{PREFERRED_STACK_BOUNDARY}, if stack alignment isn't supported.
1042e4b17023SJohn Marino@end defmac
1043e4b17023SJohn Marino
1044e4b17023SJohn Marino@defmac MAX_OFILE_ALIGNMENT
1045e4b17023SJohn MarinoBiggest alignment supported by the object file format of this machine.
1046e4b17023SJohn MarinoUse this macro to limit the alignment which can be specified using the
1047e4b17023SJohn Marino@code{__attribute__ ((aligned (@var{n})))} construct.  If not defined,
1048e4b17023SJohn Marinothe default value is @code{BIGGEST_ALIGNMENT}.
1049e4b17023SJohn Marino
1050e4b17023SJohn MarinoOn systems that use ELF, the default (in @file{config/elfos.h}) is
1051e4b17023SJohn Marinothe largest supported 32-bit ELF section alignment representable on
1052e4b17023SJohn Marinoa 32-bit host e.g. @samp{(((unsigned HOST_WIDEST_INT) 1 << 28) * 8)}.
1053e4b17023SJohn MarinoOn 32-bit ELF the largest supported section alignment in bits is
1054e4b17023SJohn Marino@samp{(0x80000000 * 8)}, but this is not representable on 32-bit hosts.
1055e4b17023SJohn Marino@end defmac
1056e4b17023SJohn Marino
1057e4b17023SJohn Marino@defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
1058e4b17023SJohn MarinoIf defined, a C expression to compute the alignment for a variable in
1059e4b17023SJohn Marinothe static store.  @var{type} is the data type, and @var{basic-align} is
1060e4b17023SJohn Marinothe alignment that the object would ordinarily have.  The value of this
1061e4b17023SJohn Marinomacro is used instead of that alignment to align the object.
1062e4b17023SJohn Marino
1063e4b17023SJohn MarinoIf this macro is not defined, then @var{basic-align} is used.
1064e4b17023SJohn Marino
1065e4b17023SJohn Marino@findex strcpy
1066e4b17023SJohn MarinoOne use of this macro is to increase alignment of medium-size data to
1067e4b17023SJohn Marinomake it all fit in fewer cache lines.  Another is to cause character
1068e4b17023SJohn Marinoarrays to be word-aligned so that @code{strcpy} calls that copy
1069e4b17023SJohn Marinoconstants to character arrays can be done inline.
1070e4b17023SJohn Marino@end defmac
1071e4b17023SJohn Marino
1072e4b17023SJohn Marino@defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
1073e4b17023SJohn MarinoIf defined, a C expression to compute the alignment given to a constant
1074e4b17023SJohn Marinothat is being placed in memory.  @var{constant} is the constant and
1075e4b17023SJohn Marino@var{basic-align} is the alignment that the object would ordinarily
1076e4b17023SJohn Marinohave.  The value of this macro is used instead of that alignment to
1077e4b17023SJohn Marinoalign the object.
1078e4b17023SJohn Marino
1079e4b17023SJohn MarinoIf this macro is not defined, then @var{basic-align} is used.
1080e4b17023SJohn Marino
1081e4b17023SJohn MarinoThe typical use of this macro is to increase alignment for string
1082e4b17023SJohn Marinoconstants to be word aligned so that @code{strcpy} calls that copy
1083e4b17023SJohn Marinoconstants can be done inline.
1084e4b17023SJohn Marino@end defmac
1085e4b17023SJohn Marino
1086e4b17023SJohn Marino@defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
1087e4b17023SJohn MarinoIf defined, a C expression to compute the alignment for a variable in
1088e4b17023SJohn Marinothe local store.  @var{type} is the data type, and @var{basic-align} is
1089e4b17023SJohn Marinothe alignment that the object would ordinarily have.  The value of this
1090e4b17023SJohn Marinomacro is used instead of that alignment to align the object.
1091e4b17023SJohn Marino
1092e4b17023SJohn MarinoIf this macro is not defined, then @var{basic-align} is used.
1093e4b17023SJohn Marino
1094e4b17023SJohn MarinoOne use of this macro is to increase alignment of medium-size data to
1095e4b17023SJohn Marinomake it all fit in fewer cache lines.
1096e4b17023SJohn Marino
1097e4b17023SJohn MarinoIf the value of this macro has a type, it should be an unsigned type.
1098e4b17023SJohn Marino@end defmac
1099e4b17023SJohn Marino
1100e4b17023SJohn Marino@hook TARGET_VECTOR_ALIGNMENT
1101e4b17023SJohn Marino
1102e4b17023SJohn Marino@defmac STACK_SLOT_ALIGNMENT (@var{type}, @var{mode}, @var{basic-align})
1103e4b17023SJohn MarinoIf defined, a C expression to compute the alignment for stack slot.
1104e4b17023SJohn Marino@var{type} is the data type, @var{mode} is the widest mode available,
1105e4b17023SJohn Marinoand @var{basic-align} is the alignment that the slot would ordinarily
1106e4b17023SJohn Marinohave.  The value of this macro is used instead of that alignment to
1107e4b17023SJohn Marinoalign the slot.
1108e4b17023SJohn Marino
1109e4b17023SJohn MarinoIf this macro is not defined, then @var{basic-align} is used when
1110e4b17023SJohn Marino@var{type} is @code{NULL}.  Otherwise, @code{LOCAL_ALIGNMENT} will
1111e4b17023SJohn Marinobe used.
1112e4b17023SJohn Marino
1113e4b17023SJohn MarinoThis macro is to set alignment of stack slot to the maximum alignment
1114e4b17023SJohn Marinoof all possible modes which the slot may have.
1115e4b17023SJohn Marino
1116e4b17023SJohn MarinoIf the value of this macro has a type, it should be an unsigned type.
1117e4b17023SJohn Marino@end defmac
1118e4b17023SJohn Marino
1119e4b17023SJohn Marino@defmac LOCAL_DECL_ALIGNMENT (@var{decl})
1120e4b17023SJohn MarinoIf defined, a C expression to compute the alignment for a local
1121e4b17023SJohn Marinovariable @var{decl}.
1122e4b17023SJohn Marino
1123e4b17023SJohn MarinoIf this macro is not defined, then
1124e4b17023SJohn Marino@code{LOCAL_ALIGNMENT (TREE_TYPE (@var{decl}), DECL_ALIGN (@var{decl}))}
1125e4b17023SJohn Marinois used.
1126e4b17023SJohn Marino
1127e4b17023SJohn MarinoOne use of this macro is to increase alignment of medium-size data to
1128e4b17023SJohn Marinomake it all fit in fewer cache lines.
1129e4b17023SJohn Marino
1130e4b17023SJohn MarinoIf the value of this macro has a type, it should be an unsigned type.
1131e4b17023SJohn Marino@end defmac
1132e4b17023SJohn Marino
1133e4b17023SJohn Marino@defmac MINIMUM_ALIGNMENT (@var{exp}, @var{mode}, @var{align})
1134e4b17023SJohn MarinoIf defined, a C expression to compute the minimum required alignment
1135e4b17023SJohn Marinofor dynamic stack realignment purposes for @var{exp} (a type or decl),
1136e4b17023SJohn Marino@var{mode}, assuming normal alignment @var{align}.
1137e4b17023SJohn Marino
1138e4b17023SJohn MarinoIf this macro is not defined, then @var{align} will be used.
1139e4b17023SJohn Marino@end defmac
1140e4b17023SJohn Marino
1141e4b17023SJohn Marino@defmac EMPTY_FIELD_BOUNDARY
1142e4b17023SJohn MarinoAlignment in bits to be given to a structure bit-field that follows an
1143e4b17023SJohn Marinoempty field such as @code{int : 0;}.
1144e4b17023SJohn Marino
1145e4b17023SJohn MarinoIf @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro.
1146e4b17023SJohn Marino@end defmac
1147e4b17023SJohn Marino
1148e4b17023SJohn Marino@defmac STRUCTURE_SIZE_BOUNDARY
1149e4b17023SJohn MarinoNumber of bits which any structure or union's size must be a multiple of.
1150e4b17023SJohn MarinoEach structure or union's size is rounded up to a multiple of this.
1151e4b17023SJohn Marino
1152e4b17023SJohn MarinoIf you do not define this macro, the default is the same as
1153e4b17023SJohn Marino@code{BITS_PER_UNIT}.
1154e4b17023SJohn Marino@end defmac
1155e4b17023SJohn Marino
1156e4b17023SJohn Marino@defmac STRICT_ALIGNMENT
1157e4b17023SJohn MarinoDefine this macro to be the value 1 if instructions will fail to work
1158e4b17023SJohn Marinoif given data not on the nominal alignment.  If instructions will merely
1159e4b17023SJohn Marinogo slower in that case, define this macro as 0.
1160e4b17023SJohn Marino@end defmac
1161e4b17023SJohn Marino
1162e4b17023SJohn Marino@defmac PCC_BITFIELD_TYPE_MATTERS
1163e4b17023SJohn MarinoDefine this if you wish to imitate the way many other C compilers handle
1164e4b17023SJohn Marinoalignment of bit-fields and the structures that contain them.
1165e4b17023SJohn Marino
1166e4b17023SJohn MarinoThe behavior is that the type written for a named bit-field (@code{int},
1167e4b17023SJohn Marino@code{short}, or other integer type) imposes an alignment for the entire
1168e4b17023SJohn Marinostructure, as if the structure really did contain an ordinary field of
1169e4b17023SJohn Marinothat type.  In addition, the bit-field is placed within the structure so
1170e4b17023SJohn Marinothat it would fit within such a field, not crossing a boundary for it.
1171e4b17023SJohn Marino
1172e4b17023SJohn MarinoThus, on most machines, a named bit-field whose type is written as
1173e4b17023SJohn Marino@code{int} would not cross a four-byte boundary, and would force
1174e4b17023SJohn Marinofour-byte alignment for the whole structure.  (The alignment used may
1175e4b17023SJohn Marinonot be four bytes; it is controlled by the other alignment parameters.)
1176e4b17023SJohn Marino
1177e4b17023SJohn MarinoAn unnamed bit-field will not affect the alignment of the containing
1178e4b17023SJohn Marinostructure.
1179e4b17023SJohn Marino
1180e4b17023SJohn MarinoIf the macro is defined, its definition should be a C expression;
1181e4b17023SJohn Marinoa nonzero value for the expression enables this behavior.
1182e4b17023SJohn Marino
1183e4b17023SJohn MarinoNote that if this macro is not defined, or its value is zero, some
1184e4b17023SJohn Marinobit-fields may cross more than one alignment boundary.  The compiler can
1185e4b17023SJohn Marinosupport such references if there are @samp{insv}, @samp{extv}, and
1186e4b17023SJohn Marino@samp{extzv} insns that can directly reference memory.
1187e4b17023SJohn Marino
1188e4b17023SJohn MarinoThe other known way of making bit-fields work is to define
1189e4b17023SJohn Marino@code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}.
1190e4b17023SJohn MarinoThen every structure can be accessed with fullwords.
1191e4b17023SJohn Marino
1192e4b17023SJohn MarinoUnless the machine has bit-field instructions or you define
1193e4b17023SJohn Marino@code{STRUCTURE_SIZE_BOUNDARY} that way, you must define
1194e4b17023SJohn Marino@code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value.
1195e4b17023SJohn Marino
1196e4b17023SJohn MarinoIf your aim is to make GCC use the same conventions for laying out
1197e4b17023SJohn Marinobit-fields as are used by another compiler, here is how to investigate
1198e4b17023SJohn Marinowhat the other compiler does.  Compile and run this program:
1199e4b17023SJohn Marino
1200e4b17023SJohn Marino@smallexample
1201e4b17023SJohn Marinostruct foo1
1202e4b17023SJohn Marino@{
1203e4b17023SJohn Marino  char x;
1204e4b17023SJohn Marino  char :0;
1205e4b17023SJohn Marino  char y;
1206e4b17023SJohn Marino@};
1207e4b17023SJohn Marino
1208e4b17023SJohn Marinostruct foo2
1209e4b17023SJohn Marino@{
1210e4b17023SJohn Marino  char x;
1211e4b17023SJohn Marino  int :0;
1212e4b17023SJohn Marino  char y;
1213e4b17023SJohn Marino@};
1214e4b17023SJohn Marino
1215e4b17023SJohn Marinomain ()
1216e4b17023SJohn Marino@{
1217e4b17023SJohn Marino  printf ("Size of foo1 is %d\n",
1218e4b17023SJohn Marino          sizeof (struct foo1));
1219e4b17023SJohn Marino  printf ("Size of foo2 is %d\n",
1220e4b17023SJohn Marino          sizeof (struct foo2));
1221e4b17023SJohn Marino  exit (0);
1222e4b17023SJohn Marino@}
1223e4b17023SJohn Marino@end smallexample
1224e4b17023SJohn Marino
1225e4b17023SJohn MarinoIf this prints 2 and 5, then the compiler's behavior is what you would
1226e4b17023SJohn Marinoget from @code{PCC_BITFIELD_TYPE_MATTERS}.
1227e4b17023SJohn Marino@end defmac
1228e4b17023SJohn Marino
1229e4b17023SJohn Marino@defmac BITFIELD_NBYTES_LIMITED
1230e4b17023SJohn MarinoLike @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited
1231e4b17023SJohn Marinoto aligning a bit-field within the structure.
1232e4b17023SJohn Marino@end defmac
1233e4b17023SJohn Marino
1234e4b17023SJohn Marino@hook TARGET_ALIGN_ANON_BITFIELD
1235e4b17023SJohn MarinoWhen @code{PCC_BITFIELD_TYPE_MATTERS} is true this hook will determine
1236e4b17023SJohn Marinowhether unnamed bitfields affect the alignment of the containing
1237e4b17023SJohn Marinostructure.  The hook should return true if the structure should inherit
1238e4b17023SJohn Marinothe alignment requirements of an unnamed bitfield's type.
1239e4b17023SJohn Marino@end deftypefn
1240e4b17023SJohn Marino
1241e4b17023SJohn Marino@hook TARGET_NARROW_VOLATILE_BITFIELD
1242e4b17023SJohn MarinoThis target hook should return @code{true} if accesses to volatile bitfields
1243e4b17023SJohn Marinoshould use the narrowest mode possible.  It should return @code{false} if
1244e4b17023SJohn Marinothese accesses should use the bitfield container type.
1245e4b17023SJohn Marino
1246e4b17023SJohn MarinoThe default is @code{!TARGET_STRICT_ALIGN}.
1247e4b17023SJohn Marino@end deftypefn
1248e4b17023SJohn Marino
1249e4b17023SJohn Marino@defmac MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode})
1250e4b17023SJohn MarinoReturn 1 if a structure or array containing @var{field} should be accessed using
1251e4b17023SJohn Marino@code{BLKMODE}.
1252e4b17023SJohn Marino
1253e4b17023SJohn MarinoIf @var{field} is the only field in the structure, @var{mode} is its
1254e4b17023SJohn Marinomode, otherwise @var{mode} is VOIDmode.  @var{mode} is provided in the
1255e4b17023SJohn Marinocase where structures of one field would require the structure's mode to
1256e4b17023SJohn Marinoretain the field's mode.
1257e4b17023SJohn Marino
1258e4b17023SJohn MarinoNormally, this is not needed.
1259e4b17023SJohn Marino@end defmac
1260e4b17023SJohn Marino
1261e4b17023SJohn Marino@defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified})
1262e4b17023SJohn MarinoDefine this macro as an expression for the alignment of a type (given
1263e4b17023SJohn Marinoby @var{type} as a tree node) if the alignment computed in the usual
1264e4b17023SJohn Marinoway is @var{computed} and the alignment explicitly specified was
1265e4b17023SJohn Marino@var{specified}.
1266e4b17023SJohn Marino
1267e4b17023SJohn MarinoThe default is to use @var{specified} if it is larger; otherwise, use
1268e4b17023SJohn Marinothe smaller of @var{computed} and @code{BIGGEST_ALIGNMENT}
1269e4b17023SJohn Marino@end defmac
1270e4b17023SJohn Marino
1271e4b17023SJohn Marino@defmac MAX_FIXED_MODE_SIZE
1272e4b17023SJohn MarinoAn integer expression for the size in bits of the largest integer
1273e4b17023SJohn Marinomachine mode that should actually be used.  All integer machine modes of
1274e4b17023SJohn Marinothis size or smaller can be used for structures and unions with the
1275e4b17023SJohn Marinoappropriate sizes.  If this macro is undefined, @code{GET_MODE_BITSIZE
1276e4b17023SJohn Marino(DImode)} is assumed.
1277e4b17023SJohn Marino@end defmac
1278e4b17023SJohn Marino
1279e4b17023SJohn Marino@defmac STACK_SAVEAREA_MODE (@var{save_level})
1280e4b17023SJohn MarinoIf defined, an expression of type @code{enum machine_mode} that
1281e4b17023SJohn Marinospecifies the mode of the save area operand of a
1282e4b17023SJohn Marino@code{save_stack_@var{level}} named pattern (@pxref{Standard Names}).
1283e4b17023SJohn Marino@var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or
1284e4b17023SJohn Marino@code{SAVE_NONLOCAL} and selects which of the three named patterns is
1285e4b17023SJohn Marinohaving its mode specified.
1286e4b17023SJohn Marino
1287e4b17023SJohn MarinoYou need not define this macro if it always returns @code{Pmode}.  You
1288e4b17023SJohn Marinowould most commonly define this macro if the
1289e4b17023SJohn Marino@code{save_stack_@var{level}} patterns need to support both a 32- and a
1290e4b17023SJohn Marino64-bit mode.
1291e4b17023SJohn Marino@end defmac
1292e4b17023SJohn Marino
1293e4b17023SJohn Marino@defmac STACK_SIZE_MODE
1294e4b17023SJohn MarinoIf defined, an expression of type @code{enum machine_mode} that
1295e4b17023SJohn Marinospecifies the mode of the size increment operand of an
1296e4b17023SJohn Marino@code{allocate_stack} named pattern (@pxref{Standard Names}).
1297e4b17023SJohn Marino
1298e4b17023SJohn MarinoYou need not define this macro if it always returns @code{word_mode}.
1299e4b17023SJohn MarinoYou would most commonly define this macro if the @code{allocate_stack}
1300e4b17023SJohn Marinopattern needs to support both a 32- and a 64-bit mode.
1301e4b17023SJohn Marino@end defmac
1302e4b17023SJohn Marino
1303e4b17023SJohn Marino@hook TARGET_LIBGCC_CMP_RETURN_MODE
1304e4b17023SJohn MarinoThis target hook should return the mode to be used for the return value
1305e4b17023SJohn Marinoof compare instructions expanded to libgcc calls.  If not defined
1306e4b17023SJohn Marino@code{word_mode} is returned which is the right choice for a majority of
1307e4b17023SJohn Marinotargets.
1308e4b17023SJohn Marino@end deftypefn
1309e4b17023SJohn Marino
1310e4b17023SJohn Marino@hook TARGET_LIBGCC_SHIFT_COUNT_MODE
1311e4b17023SJohn MarinoThis target hook should return the mode to be used for the shift count operand
1312e4b17023SJohn Marinoof shift instructions expanded to libgcc calls.  If not defined
1313e4b17023SJohn Marino@code{word_mode} is returned which is the right choice for a majority of
1314e4b17023SJohn Marinotargets.
1315e4b17023SJohn Marino@end deftypefn
1316e4b17023SJohn Marino
1317e4b17023SJohn Marino@hook TARGET_UNWIND_WORD_MODE
1318e4b17023SJohn MarinoReturn machine mode to be used for @code{_Unwind_Word} type.
1319e4b17023SJohn MarinoThe default is to use @code{word_mode}.
1320e4b17023SJohn Marino@end deftypefn
1321e4b17023SJohn Marino
1322e4b17023SJohn Marino@defmac ROUND_TOWARDS_ZERO
1323e4b17023SJohn MarinoIf defined, this macro should be true if the prevailing rounding
1324e4b17023SJohn Marinomode is towards zero.
1325e4b17023SJohn Marino
1326e4b17023SJohn MarinoDefining this macro only affects the way @file{libgcc.a} emulates
1327e4b17023SJohn Marinofloating-point arithmetic.
1328e4b17023SJohn Marino
1329e4b17023SJohn MarinoNot defining this macro is equivalent to returning zero.
1330e4b17023SJohn Marino@end defmac
1331e4b17023SJohn Marino
1332e4b17023SJohn Marino@defmac LARGEST_EXPONENT_IS_NORMAL (@var{size})
1333e4b17023SJohn MarinoThis macro should return true if floats with @var{size}
1334e4b17023SJohn Marinobits do not have a NaN or infinity representation, but use the largest
1335e4b17023SJohn Marinoexponent for normal numbers instead.
1336e4b17023SJohn Marino
1337e4b17023SJohn MarinoDefining this macro only affects the way @file{libgcc.a} emulates
1338e4b17023SJohn Marinofloating-point arithmetic.
1339e4b17023SJohn Marino
1340e4b17023SJohn MarinoThe default definition of this macro returns false for all sizes.
1341e4b17023SJohn Marino@end defmac
1342e4b17023SJohn Marino
1343e4b17023SJohn Marino@hook TARGET_MS_BITFIELD_LAYOUT_P
1344e4b17023SJohn MarinoThis target hook returns @code{true} if bit-fields in the given
1345e4b17023SJohn Marino@var{record_type} are to be laid out following the rules of Microsoft
1346e4b17023SJohn MarinoVisual C/C++, namely: (i) a bit-field won't share the same storage
1347e4b17023SJohn Marinounit with the previous bit-field if their underlying types have
1348e4b17023SJohn Marinodifferent sizes, and the bit-field will be aligned to the highest
1349e4b17023SJohn Marinoalignment of the underlying types of itself and of the previous
1350e4b17023SJohn Marinobit-field; (ii) a zero-sized bit-field will affect the alignment of
1351e4b17023SJohn Marinothe whole enclosing structure, even if it is unnamed; except that
1352e4b17023SJohn Marino(iii) a zero-sized bit-field will be disregarded unless it follows
1353e4b17023SJohn Marinoanother bit-field of nonzero size.  If this hook returns @code{true},
1354e4b17023SJohn Marinoother macros that control bit-field layout are ignored.
1355e4b17023SJohn Marino
1356e4b17023SJohn MarinoWhen a bit-field is inserted into a packed record, the whole size
1357e4b17023SJohn Marinoof the underlying type is used by one or more same-size adjacent
1358e4b17023SJohn Marinobit-fields (that is, if its long:3, 32 bits is used in the record,
1359e4b17023SJohn Marinoand any additional adjacent long bit-fields are packed into the same
1360e4b17023SJohn Marinochunk of 32 bits.  However, if the size changes, a new field of that
1361e4b17023SJohn Marinosize is allocated).  In an unpacked record, this is the same as using
1362e4b17023SJohn Marinoalignment, but not equivalent when packing.
1363e4b17023SJohn Marino
1364e4b17023SJohn MarinoIf both MS bit-fields and @samp{__attribute__((packed))} are used,
1365e4b17023SJohn Marinothe latter will take precedence.  If @samp{__attribute__((packed))} is
1366e4b17023SJohn Marinoused on a single field when MS bit-fields are in use, it will take
1367e4b17023SJohn Marinoprecedence for that field, but the alignment of the rest of the structure
1368e4b17023SJohn Marinomay affect its placement.
1369e4b17023SJohn Marino@end deftypefn
1370e4b17023SJohn Marino
1371e4b17023SJohn Marino@hook TARGET_DECIMAL_FLOAT_SUPPORTED_P
1372e4b17023SJohn MarinoReturns true if the target supports decimal floating point.
1373e4b17023SJohn Marino@end deftypefn
1374e4b17023SJohn Marino
1375e4b17023SJohn Marino@hook TARGET_FIXED_POINT_SUPPORTED_P
1376e4b17023SJohn MarinoReturns true if the target supports fixed-point arithmetic.
1377e4b17023SJohn Marino@end deftypefn
1378e4b17023SJohn Marino
1379e4b17023SJohn Marino@hook TARGET_EXPAND_TO_RTL_HOOK
1380e4b17023SJohn MarinoThis hook is called just before expansion into rtl, allowing the target
1381e4b17023SJohn Marinoto perform additional initializations or analysis before the expansion.
1382e4b17023SJohn MarinoFor example, the rs6000 port uses it to allocate a scratch stack slot
1383e4b17023SJohn Marinofor use in copying SDmode values between memory and floating point
1384e4b17023SJohn Marinoregisters whenever the function being expanded has any SDmode
1385e4b17023SJohn Marinousage.
1386e4b17023SJohn Marino@end deftypefn
1387e4b17023SJohn Marino
1388e4b17023SJohn Marino@hook TARGET_INSTANTIATE_DECLS
1389e4b17023SJohn MarinoThis hook allows the backend to perform additional instantiations on rtl
1390e4b17023SJohn Marinothat are not actually in any insns yet, but will be later.
1391e4b17023SJohn Marino@end deftypefn
1392e4b17023SJohn Marino
1393e4b17023SJohn Marino@hook TARGET_MANGLE_TYPE
1394e4b17023SJohn MarinoIf your target defines any fundamental types, or any types your target
1395e4b17023SJohn Marinouses should be mangled differently from the default, define this hook
1396e4b17023SJohn Marinoto return the appropriate encoding for these types as part of a C++
1397e4b17023SJohn Marinomangled name.  The @var{type} argument is the tree structure representing
1398e4b17023SJohn Marinothe type to be mangled.  The hook may be applied to trees which are
1399e4b17023SJohn Marinonot target-specific fundamental types; it should return @code{NULL}
1400e4b17023SJohn Marinofor all such types, as well as arguments it does not recognize.  If the
1401e4b17023SJohn Marinoreturn value is not @code{NULL}, it must point to a statically-allocated
1402e4b17023SJohn Marinostring constant.
1403e4b17023SJohn Marino
1404e4b17023SJohn MarinoTarget-specific fundamental types might be new fundamental types or
1405e4b17023SJohn Marinoqualified versions of ordinary fundamental types.  Encode new
1406e4b17023SJohn Marinofundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name}
1407e4b17023SJohn Marinois the name used for the type in source code, and @var{n} is the
1408e4b17023SJohn Marinolength of @var{name} in decimal.  Encode qualified versions of
1409e4b17023SJohn Marinoordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where
1410e4b17023SJohn Marino@var{name} is the name used for the type qualifier in source code,
1411e4b17023SJohn Marino@var{n} is the length of @var{name} as above, and @var{code} is the
1412e4b17023SJohn Marinocode used to represent the unqualified version of this type.  (See
1413e4b17023SJohn Marino@code{write_builtin_type} in @file{cp/mangle.c} for the list of
1414e4b17023SJohn Marinocodes.)  In both cases the spaces are for clarity; do not include any
1415e4b17023SJohn Marinospaces in your string.
1416e4b17023SJohn Marino
1417e4b17023SJohn MarinoThis hook is applied to types prior to typedef resolution.  If the mangled
1418e4b17023SJohn Marinoname for a particular type depends only on that type's main variant, you
1419e4b17023SJohn Marinocan perform typedef resolution yourself using @code{TYPE_MAIN_VARIANT}
1420e4b17023SJohn Marinobefore mangling.
1421e4b17023SJohn Marino
1422e4b17023SJohn MarinoThe default version of this hook always returns @code{NULL}, which is
1423e4b17023SJohn Marinoappropriate for a target that does not define any new fundamental
1424e4b17023SJohn Marinotypes.
1425e4b17023SJohn Marino@end deftypefn
1426e4b17023SJohn Marino
1427e4b17023SJohn Marino@node Type Layout
1428e4b17023SJohn Marino@section Layout of Source Language Data Types
1429e4b17023SJohn Marino
1430e4b17023SJohn MarinoThese macros define the sizes and other characteristics of the standard
1431e4b17023SJohn Marinobasic data types used in programs being compiled.  Unlike the macros in
1432e4b17023SJohn Marinothe previous section, these apply to specific features of C and related
1433e4b17023SJohn Marinolanguages, rather than to fundamental aspects of storage layout.
1434e4b17023SJohn Marino
1435e4b17023SJohn Marino@defmac INT_TYPE_SIZE
1436e4b17023SJohn MarinoA C expression for the size in bits of the type @code{int} on the
1437e4b17023SJohn Marinotarget machine.  If you don't define this, the default is one word.
1438e4b17023SJohn Marino@end defmac
1439e4b17023SJohn Marino
1440e4b17023SJohn Marino@defmac SHORT_TYPE_SIZE
1441e4b17023SJohn MarinoA C expression for the size in bits of the type @code{short} on the
1442e4b17023SJohn Marinotarget machine.  If you don't define this, the default is half a word.
1443e4b17023SJohn Marino(If this would be less than one storage unit, it is rounded up to one
1444e4b17023SJohn Marinounit.)
1445e4b17023SJohn Marino@end defmac
1446e4b17023SJohn Marino
1447e4b17023SJohn Marino@defmac LONG_TYPE_SIZE
1448e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long} on the
1449e4b17023SJohn Marinotarget machine.  If you don't define this, the default is one word.
1450e4b17023SJohn Marino@end defmac
1451e4b17023SJohn Marino
1452e4b17023SJohn Marino@defmac ADA_LONG_TYPE_SIZE
1453e4b17023SJohn MarinoOn some machines, the size used for the Ada equivalent of the type
1454e4b17023SJohn Marino@code{long} by a native Ada compiler differs from that used by C@.  In
1455e4b17023SJohn Marinothat situation, define this macro to be a C expression to be used for
1456e4b17023SJohn Marinothe size of that type.  If you don't define this, the default is the
1457e4b17023SJohn Marinovalue of @code{LONG_TYPE_SIZE}.
1458e4b17023SJohn Marino@end defmac
1459e4b17023SJohn Marino
1460e4b17023SJohn Marino@defmac LONG_LONG_TYPE_SIZE
1461e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long long} on the
1462e4b17023SJohn Marinotarget machine.  If you don't define this, the default is two
1463e4b17023SJohn Marinowords.  If you want to support GNU Ada on your machine, the value of this
1464e4b17023SJohn Marinomacro must be at least 64.
1465e4b17023SJohn Marino@end defmac
1466e4b17023SJohn Marino
1467e4b17023SJohn Marino@defmac CHAR_TYPE_SIZE
1468e4b17023SJohn MarinoA C expression for the size in bits of the type @code{char} on the
1469e4b17023SJohn Marinotarget machine.  If you don't define this, the default is
1470e4b17023SJohn Marino@code{BITS_PER_UNIT}.
1471e4b17023SJohn Marino@end defmac
1472e4b17023SJohn Marino
1473e4b17023SJohn Marino@defmac BOOL_TYPE_SIZE
1474e4b17023SJohn MarinoA C expression for the size in bits of the C++ type @code{bool} and
1475e4b17023SJohn MarinoC99 type @code{_Bool} on the target machine.  If you don't define
1476e4b17023SJohn Marinothis, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
1477e4b17023SJohn Marino@end defmac
1478e4b17023SJohn Marino
1479e4b17023SJohn Marino@defmac FLOAT_TYPE_SIZE
1480e4b17023SJohn MarinoA C expression for the size in bits of the type @code{float} on the
1481e4b17023SJohn Marinotarget machine.  If you don't define this, the default is one word.
1482e4b17023SJohn Marino@end defmac
1483e4b17023SJohn Marino
1484e4b17023SJohn Marino@defmac DOUBLE_TYPE_SIZE
1485e4b17023SJohn MarinoA C expression for the size in bits of the type @code{double} on the
1486e4b17023SJohn Marinotarget machine.  If you don't define this, the default is two
1487e4b17023SJohn Marinowords.
1488e4b17023SJohn Marino@end defmac
1489e4b17023SJohn Marino
1490e4b17023SJohn Marino@defmac LONG_DOUBLE_TYPE_SIZE
1491e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long double} on
1492e4b17023SJohn Marinothe target machine.  If you don't define this, the default is two
1493e4b17023SJohn Marinowords.
1494e4b17023SJohn Marino@end defmac
1495e4b17023SJohn Marino
1496e4b17023SJohn Marino@defmac SHORT_FRACT_TYPE_SIZE
1497e4b17023SJohn MarinoA C expression for the size in bits of the type @code{short _Fract} on
1498e4b17023SJohn Marinothe target machine.  If you don't define this, the default is
1499e4b17023SJohn Marino@code{BITS_PER_UNIT}.
1500e4b17023SJohn Marino@end defmac
1501e4b17023SJohn Marino
1502e4b17023SJohn Marino@defmac FRACT_TYPE_SIZE
1503e4b17023SJohn MarinoA C expression for the size in bits of the type @code{_Fract} on
1504e4b17023SJohn Marinothe target machine.  If you don't define this, the default is
1505e4b17023SJohn Marino@code{BITS_PER_UNIT * 2}.
1506e4b17023SJohn Marino@end defmac
1507e4b17023SJohn Marino
1508e4b17023SJohn Marino@defmac LONG_FRACT_TYPE_SIZE
1509e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long _Fract} on
1510e4b17023SJohn Marinothe target machine.  If you don't define this, the default is
1511e4b17023SJohn Marino@code{BITS_PER_UNIT * 4}.
1512e4b17023SJohn Marino@end defmac
1513e4b17023SJohn Marino
1514e4b17023SJohn Marino@defmac LONG_LONG_FRACT_TYPE_SIZE
1515e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long long _Fract} on
1516e4b17023SJohn Marinothe target machine.  If you don't define this, the default is
1517e4b17023SJohn Marino@code{BITS_PER_UNIT * 8}.
1518e4b17023SJohn Marino@end defmac
1519e4b17023SJohn Marino
1520e4b17023SJohn Marino@defmac SHORT_ACCUM_TYPE_SIZE
1521e4b17023SJohn MarinoA C expression for the size in bits of the type @code{short _Accum} on
1522e4b17023SJohn Marinothe target machine.  If you don't define this, the default is
1523e4b17023SJohn Marino@code{BITS_PER_UNIT * 2}.
1524e4b17023SJohn Marino@end defmac
1525e4b17023SJohn Marino
1526e4b17023SJohn Marino@defmac ACCUM_TYPE_SIZE
1527e4b17023SJohn MarinoA C expression for the size in bits of the type @code{_Accum} on
1528e4b17023SJohn Marinothe target machine.  If you don't define this, the default is
1529e4b17023SJohn Marino@code{BITS_PER_UNIT * 4}.
1530e4b17023SJohn Marino@end defmac
1531e4b17023SJohn Marino
1532e4b17023SJohn Marino@defmac LONG_ACCUM_TYPE_SIZE
1533e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long _Accum} on
1534e4b17023SJohn Marinothe target machine.  If you don't define this, the default is
1535e4b17023SJohn Marino@code{BITS_PER_UNIT * 8}.
1536e4b17023SJohn Marino@end defmac
1537e4b17023SJohn Marino
1538e4b17023SJohn Marino@defmac LONG_LONG_ACCUM_TYPE_SIZE
1539e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long long _Accum} on
1540e4b17023SJohn Marinothe target machine.  If you don't define this, the default is
1541e4b17023SJohn Marino@code{BITS_PER_UNIT * 16}.
1542e4b17023SJohn Marino@end defmac
1543e4b17023SJohn Marino
1544e4b17023SJohn Marino@defmac LIBGCC2_LONG_DOUBLE_TYPE_SIZE
1545e4b17023SJohn MarinoDefine this macro if @code{LONG_DOUBLE_TYPE_SIZE} is not constant or
1546e4b17023SJohn Marinoif you want routines in @file{libgcc2.a} for a size other than
1547e4b17023SJohn Marino@code{LONG_DOUBLE_TYPE_SIZE}.  If you don't define this, the
1548e4b17023SJohn Marinodefault is @code{LONG_DOUBLE_TYPE_SIZE}.
1549e4b17023SJohn Marino@end defmac
1550e4b17023SJohn Marino
1551e4b17023SJohn Marino@defmac LIBGCC2_HAS_DF_MODE
1552e4b17023SJohn MarinoDefine this macro if neither @code{DOUBLE_TYPE_SIZE} nor
1553e4b17023SJohn Marino@code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is
1554e4b17023SJohn Marino@code{DFmode} but you want @code{DFmode} routines in @file{libgcc2.a}
1555e4b17023SJohn Marinoanyway.  If you don't define this and either @code{DOUBLE_TYPE_SIZE}
1556e4b17023SJohn Marinoor @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64 then the default is 1,
1557e4b17023SJohn Marinootherwise it is 0.
1558e4b17023SJohn Marino@end defmac
1559e4b17023SJohn Marino
1560e4b17023SJohn Marino@defmac LIBGCC2_HAS_XF_MODE
1561e4b17023SJohn MarinoDefine this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1562e4b17023SJohn Marino@code{XFmode} but you want @code{XFmode} routines in @file{libgcc2.a}
1563e4b17023SJohn Marinoanyway.  If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1564e4b17023SJohn Marinois 80 then the default is 1, otherwise it is 0.
1565e4b17023SJohn Marino@end defmac
1566e4b17023SJohn Marino
1567e4b17023SJohn Marino@defmac LIBGCC2_HAS_TF_MODE
1568e4b17023SJohn MarinoDefine this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
1569e4b17023SJohn Marino@code{TFmode} but you want @code{TFmode} routines in @file{libgcc2.a}
1570e4b17023SJohn Marinoanyway.  If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
1571e4b17023SJohn Marinois 128 then the default is 1, otherwise it is 0.
1572e4b17023SJohn Marino@end defmac
1573e4b17023SJohn Marino
1574e4b17023SJohn Marino@defmac LIBGCC2_GNU_PREFIX
1575e4b17023SJohn MarinoThis macro corresponds to the @code{TARGET_LIBFUNC_GNU_PREFIX} target
1576e4b17023SJohn Marinohook and should be defined if that hook is overriden to be true.  It
1577e4b17023SJohn Marinocauses function names in libgcc to be changed to use a @code{__gnu_}
1578e4b17023SJohn Marinoprefix for their name rather than the default @code{__}.  A port which
1579e4b17023SJohn Marinouses this macro should also arrange to use @file{t-gnu-prefix} in
1580e4b17023SJohn Marinothe libgcc @file{config.host}.
1581e4b17023SJohn Marino@end defmac
1582e4b17023SJohn Marino
1583e4b17023SJohn Marino@defmac SF_SIZE
1584e4b17023SJohn Marino@defmacx DF_SIZE
1585e4b17023SJohn Marino@defmacx XF_SIZE
1586e4b17023SJohn Marino@defmacx TF_SIZE
1587e4b17023SJohn MarinoDefine these macros to be the size in bits of the mantissa of
1588e4b17023SJohn Marino@code{SFmode}, @code{DFmode}, @code{XFmode} and @code{TFmode} values,
1589e4b17023SJohn Marinoif the defaults in @file{libgcc2.h} are inappropriate.  By default,
1590e4b17023SJohn Marino@code{FLT_MANT_DIG} is used for @code{SF_SIZE}, @code{LDBL_MANT_DIG}
1591e4b17023SJohn Marinofor @code{XF_SIZE} and @code{TF_SIZE}, and @code{DBL_MANT_DIG} or
1592e4b17023SJohn Marino@code{LDBL_MANT_DIG} for @code{DF_SIZE} according to whether
1593e4b17023SJohn Marino@code{DOUBLE_TYPE_SIZE} or
1594e4b17023SJohn Marino@code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64.
1595e4b17023SJohn Marino@end defmac
1596e4b17023SJohn Marino
1597e4b17023SJohn Marino@defmac TARGET_FLT_EVAL_METHOD
1598e4b17023SJohn MarinoA C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h},
1599e4b17023SJohn Marinoassuming, if applicable, that the floating-point control word is in its
1600e4b17023SJohn Marinodefault state.  If you do not define this macro the value of
1601e4b17023SJohn Marino@code{FLT_EVAL_METHOD} will be zero.
1602e4b17023SJohn Marino@end defmac
1603e4b17023SJohn Marino
1604e4b17023SJohn Marino@defmac WIDEST_HARDWARE_FP_SIZE
1605e4b17023SJohn MarinoA C expression for the size in bits of the widest floating-point format
1606e4b17023SJohn Marinosupported by the hardware.  If you define this macro, you must specify a
1607e4b17023SJohn Marinovalue less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
1608e4b17023SJohn MarinoIf you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
1609e4b17023SJohn Marinois the default.
1610e4b17023SJohn Marino@end defmac
1611e4b17023SJohn Marino
1612e4b17023SJohn Marino@defmac DEFAULT_SIGNED_CHAR
1613e4b17023SJohn MarinoAn expression whose value is 1 or 0, according to whether the type
1614e4b17023SJohn Marino@code{char} should be signed or unsigned by default.  The user can
1615e4b17023SJohn Marinoalways override this default with the options @option{-fsigned-char}
1616e4b17023SJohn Marinoand @option{-funsigned-char}.
1617e4b17023SJohn Marino@end defmac
1618e4b17023SJohn Marino
1619e4b17023SJohn Marino@hook TARGET_DEFAULT_SHORT_ENUMS
1620e4b17023SJohn MarinoThis target hook should return true if the compiler should give an
1621e4b17023SJohn Marino@code{enum} type only as many bytes as it takes to represent the range
1622e4b17023SJohn Marinoof possible values of that type.  It should return false if all
1623e4b17023SJohn Marino@code{enum} types should be allocated like @code{int}.
1624e4b17023SJohn Marino
1625e4b17023SJohn MarinoThe default is to return false.
1626e4b17023SJohn Marino@end deftypefn
1627e4b17023SJohn Marino
1628e4b17023SJohn Marino@defmac SIZE_TYPE
1629e4b17023SJohn MarinoA C expression for a string describing the name of the data type to use
1630e4b17023SJohn Marinofor size values.  The typedef name @code{size_t} is defined using the
1631e4b17023SJohn Marinocontents of the string.
1632e4b17023SJohn Marino
1633e4b17023SJohn MarinoThe string can contain more than one keyword.  If so, separate them with
1634e4b17023SJohn Marinospaces, and write first any length keyword, then @code{unsigned} if
1635e4b17023SJohn Marinoappropriate, and finally @code{int}.  The string must exactly match one
1636e4b17023SJohn Marinoof the data type names defined in the function
1637e4b17023SJohn Marino@code{init_decl_processing} in the file @file{c-decl.c}.  You may not
1638e4b17023SJohn Marinoomit @code{int} or change the order---that would cause the compiler to
1639e4b17023SJohn Marinocrash on startup.
1640e4b17023SJohn Marino
1641e4b17023SJohn MarinoIf you don't define this macro, the default is @code{"long unsigned
1642e4b17023SJohn Marinoint"}.
1643e4b17023SJohn Marino@end defmac
1644e4b17023SJohn Marino
1645e4b17023SJohn Marino@defmac PTRDIFF_TYPE
1646e4b17023SJohn MarinoA C expression for a string describing the name of the data type to use
1647e4b17023SJohn Marinofor the result of subtracting two pointers.  The typedef name
1648e4b17023SJohn Marino@code{ptrdiff_t} is defined using the contents of the string.  See
1649e4b17023SJohn Marino@code{SIZE_TYPE} above for more information.
1650e4b17023SJohn Marino
1651e4b17023SJohn MarinoIf you don't define this macro, the default is @code{"long int"}.
1652e4b17023SJohn Marino@end defmac
1653e4b17023SJohn Marino
1654e4b17023SJohn Marino@defmac WCHAR_TYPE
1655e4b17023SJohn MarinoA C expression for a string describing the name of the data type to use
1656e4b17023SJohn Marinofor wide characters.  The typedef name @code{wchar_t} is defined using
1657e4b17023SJohn Marinothe contents of the string.  See @code{SIZE_TYPE} above for more
1658e4b17023SJohn Marinoinformation.
1659e4b17023SJohn Marino
1660e4b17023SJohn MarinoIf you don't define this macro, the default is @code{"int"}.
1661e4b17023SJohn Marino@end defmac
1662e4b17023SJohn Marino
1663e4b17023SJohn Marino@defmac WCHAR_TYPE_SIZE
1664e4b17023SJohn MarinoA C expression for the size in bits of the data type for wide
1665e4b17023SJohn Marinocharacters.  This is used in @code{cpp}, which cannot make use of
1666e4b17023SJohn Marino@code{WCHAR_TYPE}.
1667e4b17023SJohn Marino@end defmac
1668e4b17023SJohn Marino
1669e4b17023SJohn Marino@defmac WINT_TYPE
1670e4b17023SJohn MarinoA C expression for a string describing the name of the data type to
1671e4b17023SJohn Marinouse for wide characters passed to @code{printf} and returned from
1672e4b17023SJohn Marino@code{getwc}.  The typedef name @code{wint_t} is defined using the
1673e4b17023SJohn Marinocontents of the string.  See @code{SIZE_TYPE} above for more
1674e4b17023SJohn Marinoinformation.
1675e4b17023SJohn Marino
1676e4b17023SJohn MarinoIf you don't define this macro, the default is @code{"unsigned int"}.
1677e4b17023SJohn Marino@end defmac
1678e4b17023SJohn Marino
1679e4b17023SJohn Marino@defmac INTMAX_TYPE
1680e4b17023SJohn MarinoA C expression for a string describing the name of the data type that
1681e4b17023SJohn Marinocan represent any value of any standard or extended signed integer type.
1682e4b17023SJohn MarinoThe typedef name @code{intmax_t} is defined using the contents of the
1683e4b17023SJohn Marinostring.  See @code{SIZE_TYPE} above for more information.
1684e4b17023SJohn Marino
1685e4b17023SJohn MarinoIf you don't define this macro, the default is the first of
1686e4b17023SJohn Marino@code{"int"}, @code{"long int"}, or @code{"long long int"} that has as
1687e4b17023SJohn Marinomuch precision as @code{long long int}.
1688e4b17023SJohn Marino@end defmac
1689e4b17023SJohn Marino
1690e4b17023SJohn Marino@defmac UINTMAX_TYPE
1691e4b17023SJohn MarinoA C expression for a string describing the name of the data type that
1692e4b17023SJohn Marinocan represent any value of any standard or extended unsigned integer
1693e4b17023SJohn Marinotype.  The typedef name @code{uintmax_t} is defined using the contents
1694e4b17023SJohn Marinoof the string.  See @code{SIZE_TYPE} above for more information.
1695e4b17023SJohn Marino
1696e4b17023SJohn MarinoIf you don't define this macro, the default is the first of
1697e4b17023SJohn Marino@code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long
1698e4b17023SJohn Marinounsigned int"} that has as much precision as @code{long long unsigned
1699e4b17023SJohn Marinoint}.
1700e4b17023SJohn Marino@end defmac
1701e4b17023SJohn Marino
1702e4b17023SJohn Marino@defmac SIG_ATOMIC_TYPE
1703e4b17023SJohn Marino@defmacx INT8_TYPE
1704e4b17023SJohn Marino@defmacx INT16_TYPE
1705e4b17023SJohn Marino@defmacx INT32_TYPE
1706e4b17023SJohn Marino@defmacx INT64_TYPE
1707e4b17023SJohn Marino@defmacx UINT8_TYPE
1708e4b17023SJohn Marino@defmacx UINT16_TYPE
1709e4b17023SJohn Marino@defmacx UINT32_TYPE
1710e4b17023SJohn Marino@defmacx UINT64_TYPE
1711e4b17023SJohn Marino@defmacx INT_LEAST8_TYPE
1712e4b17023SJohn Marino@defmacx INT_LEAST16_TYPE
1713e4b17023SJohn Marino@defmacx INT_LEAST32_TYPE
1714e4b17023SJohn Marino@defmacx INT_LEAST64_TYPE
1715e4b17023SJohn Marino@defmacx UINT_LEAST8_TYPE
1716e4b17023SJohn Marino@defmacx UINT_LEAST16_TYPE
1717e4b17023SJohn Marino@defmacx UINT_LEAST32_TYPE
1718e4b17023SJohn Marino@defmacx UINT_LEAST64_TYPE
1719e4b17023SJohn Marino@defmacx INT_FAST8_TYPE
1720e4b17023SJohn Marino@defmacx INT_FAST16_TYPE
1721e4b17023SJohn Marino@defmacx INT_FAST32_TYPE
1722e4b17023SJohn Marino@defmacx INT_FAST64_TYPE
1723e4b17023SJohn Marino@defmacx UINT_FAST8_TYPE
1724e4b17023SJohn Marino@defmacx UINT_FAST16_TYPE
1725e4b17023SJohn Marino@defmacx UINT_FAST32_TYPE
1726e4b17023SJohn Marino@defmacx UINT_FAST64_TYPE
1727e4b17023SJohn Marino@defmacx INTPTR_TYPE
1728e4b17023SJohn Marino@defmacx UINTPTR_TYPE
1729e4b17023SJohn MarinoC expressions for the standard types @code{sig_atomic_t},
1730e4b17023SJohn Marino@code{int8_t}, @code{int16_t}, @code{int32_t}, @code{int64_t},
1731e4b17023SJohn Marino@code{uint8_t}, @code{uint16_t}, @code{uint32_t}, @code{uint64_t},
1732e4b17023SJohn Marino@code{int_least8_t}, @code{int_least16_t}, @code{int_least32_t},
1733e4b17023SJohn Marino@code{int_least64_t}, @code{uint_least8_t}, @code{uint_least16_t},
1734e4b17023SJohn Marino@code{uint_least32_t}, @code{uint_least64_t}, @code{int_fast8_t},
1735e4b17023SJohn Marino@code{int_fast16_t}, @code{int_fast32_t}, @code{int_fast64_t},
1736e4b17023SJohn Marino@code{uint_fast8_t}, @code{uint_fast16_t}, @code{uint_fast32_t},
1737e4b17023SJohn Marino@code{uint_fast64_t}, @code{intptr_t}, and @code{uintptr_t}.  See
1738e4b17023SJohn Marino@code{SIZE_TYPE} above for more information.
1739e4b17023SJohn Marino
1740e4b17023SJohn MarinoIf any of these macros evaluates to a null pointer, the corresponding
1741e4b17023SJohn Marinotype is not supported; if GCC is configured to provide
1742e4b17023SJohn Marino@code{<stdint.h>} in such a case, the header provided may not conform
1743e4b17023SJohn Marinoto C99, depending on the type in question.  The defaults for all of
1744e4b17023SJohn Marinothese macros are null pointers.
1745e4b17023SJohn Marino@end defmac
1746e4b17023SJohn Marino
1747e4b17023SJohn Marino@defmac TARGET_PTRMEMFUNC_VBIT_LOCATION
1748e4b17023SJohn MarinoThe C++ compiler represents a pointer-to-member-function with a struct
1749e4b17023SJohn Marinothat looks like:
1750e4b17023SJohn Marino
1751e4b17023SJohn Marino@smallexample
1752e4b17023SJohn Marino  struct @{
1753e4b17023SJohn Marino    union @{
1754e4b17023SJohn Marino      void (*fn)();
1755e4b17023SJohn Marino      ptrdiff_t vtable_index;
1756e4b17023SJohn Marino    @};
1757e4b17023SJohn Marino    ptrdiff_t delta;
1758e4b17023SJohn Marino  @};
1759e4b17023SJohn Marino@end smallexample
1760e4b17023SJohn Marino
1761e4b17023SJohn Marino@noindent
1762e4b17023SJohn MarinoThe C++ compiler must use one bit to indicate whether the function that
1763e4b17023SJohn Marinowill be called through a pointer-to-member-function is virtual.
1764e4b17023SJohn MarinoNormally, we assume that the low-order bit of a function pointer must
1765e4b17023SJohn Marinoalways be zero.  Then, by ensuring that the vtable_index is odd, we can
1766e4b17023SJohn Marinodistinguish which variant of the union is in use.  But, on some
1767e4b17023SJohn Marinoplatforms function pointers can be odd, and so this doesn't work.  In
1768e4b17023SJohn Marinothat case, we use the low-order bit of the @code{delta} field, and shift
1769e4b17023SJohn Marinothe remainder of the @code{delta} field to the left.
1770e4b17023SJohn Marino
1771e4b17023SJohn MarinoGCC will automatically make the right selection about where to store
1772e4b17023SJohn Marinothis bit using the @code{FUNCTION_BOUNDARY} setting for your platform.
1773e4b17023SJohn MarinoHowever, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY}
1774e4b17023SJohn Marinoset such that functions always start at even addresses, but the lowest
1775e4b17023SJohn Marinobit of pointers to functions indicate whether the function at that
1776e4b17023SJohn Marinoaddress is in ARM or Thumb mode.  If this is the case of your
1777e4b17023SJohn Marinoarchitecture, you should define this macro to
1778e4b17023SJohn Marino@code{ptrmemfunc_vbit_in_delta}.
1779e4b17023SJohn Marino
1780e4b17023SJohn MarinoIn general, you should not have to define this macro.  On architectures
1781e4b17023SJohn Marinoin which function addresses are always even, according to
1782e4b17023SJohn Marino@code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to
1783e4b17023SJohn Marino@code{ptrmemfunc_vbit_in_pfn}.
1784e4b17023SJohn Marino@end defmac
1785e4b17023SJohn Marino
1786e4b17023SJohn Marino@defmac TARGET_VTABLE_USES_DESCRIPTORS
1787e4b17023SJohn MarinoNormally, the C++ compiler uses function pointers in vtables.  This
1788e4b17023SJohn Marinomacro allows the target to change to use ``function descriptors''
1789e4b17023SJohn Marinoinstead.  Function descriptors are found on targets for whom a
1790e4b17023SJohn Marinofunction pointer is actually a small data structure.  Normally the
1791e4b17023SJohn Marinodata structure consists of the actual code address plus a data
1792e4b17023SJohn Marinopointer to which the function's data is relative.
1793e4b17023SJohn Marino
1794e4b17023SJohn MarinoIf vtables are used, the value of this macro should be the number
1795e4b17023SJohn Marinoof words that the function descriptor occupies.
1796e4b17023SJohn Marino@end defmac
1797e4b17023SJohn Marino
1798e4b17023SJohn Marino@defmac TARGET_VTABLE_ENTRY_ALIGN
1799e4b17023SJohn MarinoBy default, the vtable entries are void pointers, the so the alignment
1800e4b17023SJohn Marinois the same as pointer alignment.  The value of this macro specifies
1801e4b17023SJohn Marinothe alignment of the vtable entry in bits.  It should be defined only
1802e4b17023SJohn Marinowhen special alignment is necessary. */
1803e4b17023SJohn Marino@end defmac
1804e4b17023SJohn Marino
1805e4b17023SJohn Marino@defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE
1806e4b17023SJohn MarinoThere are a few non-descriptor entries in the vtable at offsets below
1807e4b17023SJohn Marinozero.  If these entries must be padded (say, to preserve the alignment
1808e4b17023SJohn Marinospecified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
1809e4b17023SJohn Marinoof words in each data entry.
1810e4b17023SJohn Marino@end defmac
1811e4b17023SJohn Marino
1812e4b17023SJohn Marino@node Registers
1813e4b17023SJohn Marino@section Register Usage
1814e4b17023SJohn Marino@cindex register usage
1815e4b17023SJohn Marino
1816e4b17023SJohn MarinoThis section explains how to describe what registers the target machine
1817e4b17023SJohn Marinohas, and how (in general) they can be used.
1818e4b17023SJohn Marino
1819e4b17023SJohn MarinoThe description of which registers a specific instruction can use is
1820e4b17023SJohn Marinodone with register classes; see @ref{Register Classes}.  For information
1821e4b17023SJohn Marinoon using registers to access a stack frame, see @ref{Frame Registers}.
1822e4b17023SJohn MarinoFor passing values in registers, see @ref{Register Arguments}.
1823e4b17023SJohn MarinoFor returning values in registers, see @ref{Scalar Return}.
1824e4b17023SJohn Marino
1825e4b17023SJohn Marino@menu
1826e4b17023SJohn Marino* Register Basics::             Number and kinds of registers.
1827e4b17023SJohn Marino* Allocation Order::            Order in which registers are allocated.
1828e4b17023SJohn Marino* Values in Registers::         What kinds of values each reg can hold.
1829e4b17023SJohn Marino* Leaf Functions::              Renumbering registers for leaf functions.
1830e4b17023SJohn Marino* Stack Registers::             Handling a register stack such as 80387.
1831e4b17023SJohn Marino@end menu
1832e4b17023SJohn Marino
1833e4b17023SJohn Marino@node Register Basics
1834e4b17023SJohn Marino@subsection Basic Characteristics of Registers
1835e4b17023SJohn Marino
1836e4b17023SJohn Marino@c prevent bad page break with this line
1837e4b17023SJohn MarinoRegisters have various characteristics.
1838e4b17023SJohn Marino
1839e4b17023SJohn Marino@defmac FIRST_PSEUDO_REGISTER
1840e4b17023SJohn MarinoNumber of hardware registers known to the compiler.  They receive
1841e4b17023SJohn Marinonumbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
1842e4b17023SJohn Marinopseudo register's number really is assigned the number
1843e4b17023SJohn Marino@code{FIRST_PSEUDO_REGISTER}.
1844e4b17023SJohn Marino@end defmac
1845e4b17023SJohn Marino
1846e4b17023SJohn Marino@defmac FIXED_REGISTERS
1847e4b17023SJohn Marino@cindex fixed register
1848e4b17023SJohn MarinoAn initializer that says which registers are used for fixed purposes
1849e4b17023SJohn Marinoall throughout the compiled code and are therefore not available for
1850e4b17023SJohn Marinogeneral allocation.  These would include the stack pointer, the frame
1851e4b17023SJohn Marinopointer (except on machines where that can be used as a general
1852e4b17023SJohn Marinoregister when no frame pointer is needed), the program counter on
1853e4b17023SJohn Marinomachines where that is considered one of the addressable registers,
1854e4b17023SJohn Marinoand any other numbered register with a standard use.
1855e4b17023SJohn Marino
1856e4b17023SJohn MarinoThis information is expressed as a sequence of numbers, separated by
1857e4b17023SJohn Marinocommas and surrounded by braces.  The @var{n}th number is 1 if
1858e4b17023SJohn Marinoregister @var{n} is fixed, 0 otherwise.
1859e4b17023SJohn Marino
1860e4b17023SJohn MarinoThe table initialized from this macro, and the table initialized by
1861e4b17023SJohn Marinothe following one, may be overridden at run time either automatically,
1862e4b17023SJohn Marinoby the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
1863e4b17023SJohn Marinothe user with the command options @option{-ffixed-@var{reg}},
1864e4b17023SJohn Marino@option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}.
1865e4b17023SJohn Marino@end defmac
1866e4b17023SJohn Marino
1867e4b17023SJohn Marino@defmac CALL_USED_REGISTERS
1868e4b17023SJohn Marino@cindex call-used register
1869e4b17023SJohn Marino@cindex call-clobbered register
1870e4b17023SJohn Marino@cindex call-saved register
1871e4b17023SJohn MarinoLike @code{FIXED_REGISTERS} but has 1 for each register that is
1872e4b17023SJohn Marinoclobbered (in general) by function calls as well as for fixed
1873e4b17023SJohn Marinoregisters.  This macro therefore identifies the registers that are not
1874e4b17023SJohn Marinoavailable for general allocation of values that must live across
1875e4b17023SJohn Marinofunction calls.
1876e4b17023SJohn Marino
1877e4b17023SJohn MarinoIf a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
1878e4b17023SJohn Marinoautomatically saves it on function entry and restores it on function
1879e4b17023SJohn Marinoexit, if the register is used within the function.
1880e4b17023SJohn Marino@end defmac
1881e4b17023SJohn Marino
1882e4b17023SJohn Marino@defmac CALL_REALLY_USED_REGISTERS
1883e4b17023SJohn Marino@cindex call-used register
1884e4b17023SJohn Marino@cindex call-clobbered register
1885e4b17023SJohn Marino@cindex call-saved register
1886e4b17023SJohn MarinoLike @code{CALL_USED_REGISTERS} except this macro doesn't require
1887e4b17023SJohn Marinothat the entire set of @code{FIXED_REGISTERS} be included.
1888e4b17023SJohn Marino(@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}).
1889e4b17023SJohn MarinoThis macro is optional.  If not specified, it defaults to the value
1890e4b17023SJohn Marinoof @code{CALL_USED_REGISTERS}.
1891e4b17023SJohn Marino@end defmac
1892e4b17023SJohn Marino
1893e4b17023SJohn Marino@defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
1894e4b17023SJohn Marino@cindex call-used register
1895e4b17023SJohn Marino@cindex call-clobbered register
1896e4b17023SJohn Marino@cindex call-saved register
1897e4b17023SJohn MarinoA C expression that is nonzero if it is not permissible to store a
1898e4b17023SJohn Marinovalue of mode @var{mode} in hard register number @var{regno} across a
1899e4b17023SJohn Marinocall without some part of it being clobbered.  For most machines this
1900e4b17023SJohn Marinomacro need not be defined.  It is only required for machines that do not
1901e4b17023SJohn Marinopreserve the entire contents of a register across a call.
1902e4b17023SJohn Marino@end defmac
1903e4b17023SJohn Marino
1904e4b17023SJohn Marino@findex fixed_regs
1905e4b17023SJohn Marino@findex call_used_regs
1906e4b17023SJohn Marino@findex global_regs
1907e4b17023SJohn Marino@findex reg_names
1908e4b17023SJohn Marino@findex reg_class_contents
1909e4b17023SJohn Marino@hook TARGET_CONDITIONAL_REGISTER_USAGE
1910e4b17023SJohn MarinoThis hook may conditionally modify five variables
1911e4b17023SJohn Marino@code{fixed_regs}, @code{call_used_regs}, @code{global_regs},
1912e4b17023SJohn Marino@code{reg_names}, and @code{reg_class_contents}, to take into account
1913e4b17023SJohn Marinoany dependence of these register sets on target flags.  The first three
1914e4b17023SJohn Marinoof these are of type @code{char []} (interpreted as Boolean vectors).
1915e4b17023SJohn Marino@code{global_regs} is a @code{const char *[]}, and
1916e4b17023SJohn Marino@code{reg_class_contents} is a @code{HARD_REG_SET}.  Before the macro is
1917e4b17023SJohn Marinocalled, @code{fixed_regs}, @code{call_used_regs},
1918e4b17023SJohn Marino@code{reg_class_contents}, and @code{reg_names} have been initialized
1919e4b17023SJohn Marinofrom @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS},
1920e4b17023SJohn Marino@code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively.
1921e4b17023SJohn Marino@code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}},
1922e4b17023SJohn Marino@option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}
1923e4b17023SJohn Marinocommand options have been applied.
1924e4b17023SJohn Marino
1925e4b17023SJohn Marino@cindex disabling certain registers
1926e4b17023SJohn Marino@cindex controlling register usage
1927e4b17023SJohn MarinoIf the usage of an entire class of registers depends on the target
1928e4b17023SJohn Marinoflags, you may indicate this to GCC by using this macro to modify
1929e4b17023SJohn Marino@code{fixed_regs} and @code{call_used_regs} to 1 for each of the
1930e4b17023SJohn Marinoregisters in the classes which should not be used by GCC@.  Also define
1931e4b17023SJohn Marinothe macro @code{REG_CLASS_FROM_LETTER} / @code{REG_CLASS_FROM_CONSTRAINT}
1932e4b17023SJohn Marinoto return @code{NO_REGS} if it
1933e4b17023SJohn Marinois called with a letter for a class that shouldn't be used.
1934e4b17023SJohn Marino
1935e4b17023SJohn Marino(However, if this class is not included in @code{GENERAL_REGS} and all
1936e4b17023SJohn Marinoof the insn patterns whose constraints permit this class are
1937e4b17023SJohn Marinocontrolled by target switches, then GCC will automatically avoid using
1938e4b17023SJohn Marinothese registers when the target switches are opposed to them.)
1939e4b17023SJohn Marino@end deftypefn
1940e4b17023SJohn Marino
1941e4b17023SJohn Marino@defmac INCOMING_REGNO (@var{out})
1942e4b17023SJohn MarinoDefine this macro if the target machine has register windows.  This C
1943e4b17023SJohn Marinoexpression returns the register number as seen by the called function
1944e4b17023SJohn Marinocorresponding to the register number @var{out} as seen by the calling
1945e4b17023SJohn Marinofunction.  Return @var{out} if register number @var{out} is not an
1946e4b17023SJohn Marinooutbound register.
1947e4b17023SJohn Marino@end defmac
1948e4b17023SJohn Marino
1949e4b17023SJohn Marino@defmac OUTGOING_REGNO (@var{in})
1950e4b17023SJohn MarinoDefine this macro if the target machine has register windows.  This C
1951e4b17023SJohn Marinoexpression returns the register number as seen by the calling function
1952e4b17023SJohn Marinocorresponding to the register number @var{in} as seen by the called
1953e4b17023SJohn Marinofunction.  Return @var{in} if register number @var{in} is not an inbound
1954e4b17023SJohn Marinoregister.
1955e4b17023SJohn Marino@end defmac
1956e4b17023SJohn Marino
1957e4b17023SJohn Marino@defmac LOCAL_REGNO (@var{regno})
1958e4b17023SJohn MarinoDefine this macro if the target machine has register windows.  This C
1959e4b17023SJohn Marinoexpression returns true if the register is call-saved but is in the
1960e4b17023SJohn Marinoregister window.  Unlike most call-saved registers, such registers
1961e4b17023SJohn Marinoneed not be explicitly restored on function exit or during non-local
1962e4b17023SJohn Marinogotos.
1963e4b17023SJohn Marino@end defmac
1964e4b17023SJohn Marino
1965e4b17023SJohn Marino@defmac PC_REGNUM
1966e4b17023SJohn MarinoIf the program counter has a register number, define this as that
1967e4b17023SJohn Marinoregister number.  Otherwise, do not define it.
1968e4b17023SJohn Marino@end defmac
1969e4b17023SJohn Marino
1970e4b17023SJohn Marino@node Allocation Order
1971e4b17023SJohn Marino@subsection Order of Allocation of Registers
1972e4b17023SJohn Marino@cindex order of register allocation
1973e4b17023SJohn Marino@cindex register allocation order
1974e4b17023SJohn Marino
1975e4b17023SJohn Marino@c prevent bad page break with this line
1976e4b17023SJohn MarinoRegisters are allocated in order.
1977e4b17023SJohn Marino
1978e4b17023SJohn Marino@defmac REG_ALLOC_ORDER
1979e4b17023SJohn MarinoIf defined, an initializer for a vector of integers, containing the
1980e4b17023SJohn Marinonumbers of hard registers in the order in which GCC should prefer
1981e4b17023SJohn Marinoto use them (from most preferred to least).
1982e4b17023SJohn Marino
1983e4b17023SJohn MarinoIf this macro is not defined, registers are used lowest numbered first
1984e4b17023SJohn Marino(all else being equal).
1985e4b17023SJohn Marino
1986e4b17023SJohn MarinoOne use of this macro is on machines where the highest numbered
1987e4b17023SJohn Marinoregisters must always be saved and the save-multiple-registers
1988e4b17023SJohn Marinoinstruction supports only sequences of consecutive registers.  On such
1989e4b17023SJohn Marinomachines, define @code{REG_ALLOC_ORDER} to be an initializer that lists
1990e4b17023SJohn Marinothe highest numbered allocable register first.
1991e4b17023SJohn Marino@end defmac
1992e4b17023SJohn Marino
1993e4b17023SJohn Marino@defmac ADJUST_REG_ALLOC_ORDER
1994e4b17023SJohn MarinoA C statement (sans semicolon) to choose the order in which to allocate
1995e4b17023SJohn Marinohard registers for pseudo-registers local to a basic block.
1996e4b17023SJohn Marino
1997e4b17023SJohn MarinoStore the desired register order in the array @code{reg_alloc_order}.
1998e4b17023SJohn MarinoElement 0 should be the register to allocate first; element 1, the next
1999e4b17023SJohn Marinoregister; and so on.
2000e4b17023SJohn Marino
2001e4b17023SJohn MarinoThe macro body should not assume anything about the contents of
2002e4b17023SJohn Marino@code{reg_alloc_order} before execution of the macro.
2003e4b17023SJohn Marino
2004e4b17023SJohn MarinoOn most machines, it is not necessary to define this macro.
2005e4b17023SJohn Marino@end defmac
2006e4b17023SJohn Marino
2007e4b17023SJohn Marino@defmac HONOR_REG_ALLOC_ORDER
2008e4b17023SJohn MarinoNormally, IRA tries to estimate the costs for saving a register in the
2009e4b17023SJohn Marinoprologue and restoring it in the epilogue.  This discourages it from
2010e4b17023SJohn Marinousing call-saved registers.  If a machine wants to ensure that IRA
2011e4b17023SJohn Marinoallocates registers in the order given by REG_ALLOC_ORDER even if some
2012e4b17023SJohn Marinocall-saved registers appear earlier than call-used ones, this macro
2013e4b17023SJohn Marinoshould be defined.
2014e4b17023SJohn Marino@end defmac
2015e4b17023SJohn Marino
2016e4b17023SJohn Marino@defmac IRA_HARD_REGNO_ADD_COST_MULTIPLIER (@var{regno})
2017e4b17023SJohn MarinoIn some case register allocation order is not enough for the
2018e4b17023SJohn MarinoIntegrated Register Allocator (@acronym{IRA}) to generate a good code.
2019e4b17023SJohn MarinoIf this macro is defined, it should return a floating point value
2020e4b17023SJohn Marinobased on @var{regno}.  The cost of using @var{regno} for a pseudo will
2021e4b17023SJohn Marinobe increased by approximately the pseudo's usage frequency times the
2022e4b17023SJohn Marinovalue returned by this macro.  Not defining this macro is equivalent
2023e4b17023SJohn Marinoto having it always return @code{0.0}.
2024e4b17023SJohn Marino
2025e4b17023SJohn MarinoOn most machines, it is not necessary to define this macro.
2026e4b17023SJohn Marino@end defmac
2027e4b17023SJohn Marino
2028e4b17023SJohn Marino@node Values in Registers
2029e4b17023SJohn Marino@subsection How Values Fit in Registers
2030e4b17023SJohn Marino
2031e4b17023SJohn MarinoThis section discusses the macros that describe which kinds of values
2032e4b17023SJohn Marino(specifically, which machine modes) each register can hold, and how many
2033e4b17023SJohn Marinoconsecutive registers are needed for a given mode.
2034e4b17023SJohn Marino
2035e4b17023SJohn Marino@defmac HARD_REGNO_NREGS (@var{regno}, @var{mode})
2036e4b17023SJohn MarinoA C expression for the number of consecutive hard registers, starting
2037e4b17023SJohn Marinoat register number @var{regno}, required to hold a value of mode
2038e4b17023SJohn Marino@var{mode}.  This macro must never return zero, even if a register
2039e4b17023SJohn Marinocannot hold the requested mode - indicate that with HARD_REGNO_MODE_OK
2040e4b17023SJohn Marinoand/or CANNOT_CHANGE_MODE_CLASS instead.
2041e4b17023SJohn Marino
2042e4b17023SJohn MarinoOn a machine where all registers are exactly one word, a suitable
2043e4b17023SJohn Marinodefinition of this macro is
2044e4b17023SJohn Marino
2045e4b17023SJohn Marino@smallexample
2046e4b17023SJohn Marino#define HARD_REGNO_NREGS(REGNO, MODE)            \
2047e4b17023SJohn Marino   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1)  \
2048e4b17023SJohn Marino    / UNITS_PER_WORD)
2049e4b17023SJohn Marino@end smallexample
2050e4b17023SJohn Marino@end defmac
2051e4b17023SJohn Marino
2052e4b17023SJohn Marino@defmac HARD_REGNO_NREGS_HAS_PADDING (@var{regno}, @var{mode})
2053e4b17023SJohn MarinoA C expression that is nonzero if a value of mode @var{mode}, stored
2054e4b17023SJohn Marinoin memory, ends with padding that causes it to take up more space than
2055e4b17023SJohn Marinoin registers starting at register number @var{regno} (as determined by
2056e4b17023SJohn Marinomultiplying GCC's notion of the size of the register when containing
2057e4b17023SJohn Marinothis mode by the number of registers returned by
2058e4b17023SJohn Marino@code{HARD_REGNO_NREGS}).  By default this is zero.
2059e4b17023SJohn Marino
2060e4b17023SJohn MarinoFor example, if a floating-point value is stored in three 32-bit
2061e4b17023SJohn Marinoregisters but takes up 128 bits in memory, then this would be
2062e4b17023SJohn Marinononzero.
2063e4b17023SJohn Marino
2064e4b17023SJohn MarinoThis macros only needs to be defined if there are cases where
2065e4b17023SJohn Marino@code{subreg_get_info}
2066e4b17023SJohn Marinowould otherwise wrongly determine that a @code{subreg} can be
2067e4b17023SJohn Marinorepresented by an offset to the register number, when in fact such a
2068e4b17023SJohn Marino@code{subreg} would contain some of the padding not stored in
2069e4b17023SJohn Marinoregisters and so not be representable.
2070e4b17023SJohn Marino@end defmac
2071e4b17023SJohn Marino
2072e4b17023SJohn Marino@defmac HARD_REGNO_NREGS_WITH_PADDING (@var{regno}, @var{mode})
2073e4b17023SJohn MarinoFor values of @var{regno} and @var{mode} for which
2074e4b17023SJohn Marino@code{HARD_REGNO_NREGS_HAS_PADDING} returns nonzero, a C expression
2075e4b17023SJohn Marinoreturning the greater number of registers required to hold the value
2076e4b17023SJohn Marinoincluding any padding.  In the example above, the value would be four.
2077e4b17023SJohn Marino@end defmac
2078e4b17023SJohn Marino
2079e4b17023SJohn Marino@defmac REGMODE_NATURAL_SIZE (@var{mode})
2080e4b17023SJohn MarinoDefine this macro if the natural size of registers that hold values
2081e4b17023SJohn Marinoof mode @var{mode} is not the word size.  It is a C expression that
2082e4b17023SJohn Marinoshould give the natural size in bytes for the specified mode.  It is
2083e4b17023SJohn Marinoused by the register allocator to try to optimize its results.  This
2084e4b17023SJohn Marinohappens for example on SPARC 64-bit where the natural size of
2085e4b17023SJohn Marinofloating-point registers is still 32-bit.
2086e4b17023SJohn Marino@end defmac
2087e4b17023SJohn Marino
2088e4b17023SJohn Marino@defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
2089e4b17023SJohn MarinoA C expression that is nonzero if it is permissible to store a value
2090e4b17023SJohn Marinoof mode @var{mode} in hard register number @var{regno} (or in several
2091e4b17023SJohn Marinoregisters starting with that one).  For a machine where all registers
2092e4b17023SJohn Marinoare equivalent, a suitable definition is
2093e4b17023SJohn Marino
2094e4b17023SJohn Marino@smallexample
2095e4b17023SJohn Marino#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
2096e4b17023SJohn Marino@end smallexample
2097e4b17023SJohn Marino
2098e4b17023SJohn MarinoYou need not include code to check for the numbers of fixed registers,
2099e4b17023SJohn Marinobecause the allocation mechanism considers them to be always occupied.
2100e4b17023SJohn Marino
2101e4b17023SJohn Marino@cindex register pairs
2102e4b17023SJohn MarinoOn some machines, double-precision values must be kept in even/odd
2103e4b17023SJohn Marinoregister pairs.  You can implement that by defining this macro to reject
2104e4b17023SJohn Marinoodd register numbers for such modes.
2105e4b17023SJohn Marino
2106e4b17023SJohn MarinoThe minimum requirement for a mode to be OK in a register is that the
2107e4b17023SJohn Marino@samp{mov@var{mode}} instruction pattern support moves between the
2108e4b17023SJohn Marinoregister and other hard register in the same class and that moving a
2109e4b17023SJohn Marinovalue into the register and back out not alter it.
2110e4b17023SJohn Marino
2111e4b17023SJohn MarinoSince the same instruction used to move @code{word_mode} will work for
2112e4b17023SJohn Marinoall narrower integer modes, it is not necessary on any machine for
2113e4b17023SJohn Marino@code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided
2114e4b17023SJohn Marinoyou define patterns @samp{movhi}, etc., to take advantage of this.  This
2115e4b17023SJohn Marinois useful because of the interaction between @code{HARD_REGNO_MODE_OK}
2116e4b17023SJohn Marinoand @code{MODES_TIEABLE_P}; it is very desirable for all integer modes
2117e4b17023SJohn Marinoto be tieable.
2118e4b17023SJohn Marino
2119e4b17023SJohn MarinoMany machines have special registers for floating point arithmetic.
2120e4b17023SJohn MarinoOften people assume that floating point machine modes are allowed only
2121e4b17023SJohn Marinoin floating point registers.  This is not true.  Any registers that
2122e4b17023SJohn Marinocan hold integers can safely @emph{hold} a floating point machine
2123e4b17023SJohn Marinomode, whether or not floating arithmetic can be done on it in those
2124e4b17023SJohn Marinoregisters.  Integer move instructions can be used to move the values.
2125e4b17023SJohn Marino
2126e4b17023SJohn MarinoOn some machines, though, the converse is true: fixed-point machine
2127e4b17023SJohn Marinomodes may not go in floating registers.  This is true if the floating
2128e4b17023SJohn Marinoregisters normalize any value stored in them, because storing a
2129e4b17023SJohn Marinonon-floating value there would garble it.  In this case,
2130e4b17023SJohn Marino@code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in
2131e4b17023SJohn Marinofloating registers.  But if the floating registers do not automatically
2132e4b17023SJohn Marinonormalize, if you can store any bit pattern in one and retrieve it
2133e4b17023SJohn Marinounchanged without a trap, then any machine mode may go in a floating
2134e4b17023SJohn Marinoregister, so you can define this macro to say so.
2135e4b17023SJohn Marino
2136e4b17023SJohn MarinoThe primary significance of special floating registers is rather that
2137e4b17023SJohn Marinothey are the registers acceptable in floating point arithmetic
2138e4b17023SJohn Marinoinstructions.  However, this is of no concern to
2139e4b17023SJohn Marino@code{HARD_REGNO_MODE_OK}.  You handle it by writing the proper
2140e4b17023SJohn Marinoconstraints for those instructions.
2141e4b17023SJohn Marino
2142e4b17023SJohn MarinoOn some machines, the floating registers are especially slow to access,
2143e4b17023SJohn Marinoso that it is better to store a value in a stack frame than in such a
2144e4b17023SJohn Marinoregister if floating point arithmetic is not being done.  As long as the
2145e4b17023SJohn Marinofloating registers are not in class @code{GENERAL_REGS}, they will not
2146e4b17023SJohn Marinobe used unless some pattern's constraint asks for one.
2147e4b17023SJohn Marino@end defmac
2148e4b17023SJohn Marino
2149e4b17023SJohn Marino@defmac HARD_REGNO_RENAME_OK (@var{from}, @var{to})
2150e4b17023SJohn MarinoA C expression that is nonzero if it is OK to rename a hard register
2151e4b17023SJohn Marino@var{from} to another hard register @var{to}.
2152e4b17023SJohn Marino
2153e4b17023SJohn MarinoOne common use of this macro is to prevent renaming of a register to
2154e4b17023SJohn Marinoanother register that is not saved by a prologue in an interrupt
2155e4b17023SJohn Marinohandler.
2156e4b17023SJohn Marino
2157e4b17023SJohn MarinoThe default is always nonzero.
2158e4b17023SJohn Marino@end defmac
2159e4b17023SJohn Marino
2160e4b17023SJohn Marino@defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2})
2161e4b17023SJohn MarinoA C expression that is nonzero if a value of mode
2162e4b17023SJohn Marino@var{mode1} is accessible in mode @var{mode2} without copying.
2163e4b17023SJohn Marino
2164e4b17023SJohn MarinoIf @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
2165e4b17023SJohn Marino@code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for
2166e4b17023SJohn Marinoany @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})}
2167e4b17023SJohn Marinoshould be nonzero.  If they differ for any @var{r}, you should define
2168e4b17023SJohn Marinothis macro to return zero unless some other mechanism ensures the
2169e4b17023SJohn Marinoaccessibility of the value in a narrower mode.
2170e4b17023SJohn Marino
2171e4b17023SJohn MarinoYou should define this macro to return nonzero in as many cases as
2172e4b17023SJohn Marinopossible since doing so will allow GCC to perform better register
2173e4b17023SJohn Marinoallocation.
2174e4b17023SJohn Marino@end defmac
2175e4b17023SJohn Marino
2176e4b17023SJohn Marino@hook TARGET_HARD_REGNO_SCRATCH_OK
2177e4b17023SJohn MarinoThis target hook should return @code{true} if it is OK to use a hard register
2178e4b17023SJohn Marino@var{regno} as scratch reg in peephole2.
2179e4b17023SJohn Marino
2180e4b17023SJohn MarinoOne common use of this macro is to prevent using of a register that
2181e4b17023SJohn Marinois not saved by a prologue in an interrupt handler.
2182e4b17023SJohn Marino
2183e4b17023SJohn MarinoThe default version of this hook always returns @code{true}.
2184e4b17023SJohn Marino@end deftypefn
2185e4b17023SJohn Marino
2186e4b17023SJohn Marino@defmac AVOID_CCMODE_COPIES
2187e4b17023SJohn MarinoDefine this macro if the compiler should avoid copies to/from @code{CCmode}
2188e4b17023SJohn Marinoregisters.  You should only define this macro if support for copying to/from
2189e4b17023SJohn Marino@code{CCmode} is incomplete.
2190e4b17023SJohn Marino@end defmac
2191e4b17023SJohn Marino
2192e4b17023SJohn Marino@node Leaf Functions
2193e4b17023SJohn Marino@subsection Handling Leaf Functions
2194e4b17023SJohn Marino
2195e4b17023SJohn Marino@cindex leaf functions
2196e4b17023SJohn Marino@cindex functions, leaf
2197e4b17023SJohn MarinoOn some machines, a leaf function (i.e., one which makes no calls) can run
2198e4b17023SJohn Marinomore efficiently if it does not make its own register window.  Often this
2199e4b17023SJohn Marinomeans it is required to receive its arguments in the registers where they
2200e4b17023SJohn Marinoare passed by the caller, instead of the registers where they would
2201e4b17023SJohn Marinonormally arrive.
2202e4b17023SJohn Marino
2203e4b17023SJohn MarinoThe special treatment for leaf functions generally applies only when
2204e4b17023SJohn Marinoother conditions are met; for example, often they may use only those
2205e4b17023SJohn Marinoregisters for its own variables and temporaries.  We use the term ``leaf
2206e4b17023SJohn Marinofunction'' to mean a function that is suitable for this special
2207e4b17023SJohn Marinohandling, so that functions with no calls are not necessarily ``leaf
2208e4b17023SJohn Marinofunctions''.
2209e4b17023SJohn Marino
2210e4b17023SJohn MarinoGCC assigns register numbers before it knows whether the function is
2211e4b17023SJohn Marinosuitable for leaf function treatment.  So it needs to renumber the
2212e4b17023SJohn Marinoregisters in order to output a leaf function.  The following macros
2213e4b17023SJohn Marinoaccomplish this.
2214e4b17023SJohn Marino
2215e4b17023SJohn Marino@defmac LEAF_REGISTERS
2216e4b17023SJohn MarinoName of a char vector, indexed by hard register number, which
2217e4b17023SJohn Marinocontains 1 for a register that is allowable in a candidate for leaf
2218e4b17023SJohn Marinofunction treatment.
2219e4b17023SJohn Marino
2220e4b17023SJohn MarinoIf leaf function treatment involves renumbering the registers, then the
2221e4b17023SJohn Marinoregisters marked here should be the ones before renumbering---those that
2222e4b17023SJohn MarinoGCC would ordinarily allocate.  The registers which will actually be
2223e4b17023SJohn Marinoused in the assembler code, after renumbering, should not be marked with 1
2224e4b17023SJohn Marinoin this vector.
2225e4b17023SJohn Marino
2226e4b17023SJohn MarinoDefine this macro only if the target machine offers a way to optimize
2227e4b17023SJohn Marinothe treatment of leaf functions.
2228e4b17023SJohn Marino@end defmac
2229e4b17023SJohn Marino
2230e4b17023SJohn Marino@defmac LEAF_REG_REMAP (@var{regno})
2231e4b17023SJohn MarinoA C expression whose value is the register number to which @var{regno}
2232e4b17023SJohn Marinoshould be renumbered, when a function is treated as a leaf function.
2233e4b17023SJohn Marino
2234e4b17023SJohn MarinoIf @var{regno} is a register number which should not appear in a leaf
2235e4b17023SJohn Marinofunction before renumbering, then the expression should yield @minus{}1, which
2236e4b17023SJohn Marinowill cause the compiler to abort.
2237e4b17023SJohn Marino
2238e4b17023SJohn MarinoDefine this macro only if the target machine offers a way to optimize the
2239e4b17023SJohn Marinotreatment of leaf functions, and registers need to be renumbered to do
2240e4b17023SJohn Marinothis.
2241e4b17023SJohn Marino@end defmac
2242e4b17023SJohn Marino
2243e4b17023SJohn Marino@findex current_function_is_leaf
2244e4b17023SJohn Marino@findex current_function_uses_only_leaf_regs
2245e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_PROLOGUE} and
2246e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions
2247e4b17023SJohn Marinospecially.  They can test the C variable @code{current_function_is_leaf}
2248e4b17023SJohn Marinowhich is nonzero for leaf functions.  @code{current_function_is_leaf} is
2249e4b17023SJohn Marinoset prior to local register allocation and is valid for the remaining
2250e4b17023SJohn Marinocompiler passes.  They can also test the C variable
2251e4b17023SJohn Marino@code{current_function_uses_only_leaf_regs} which is nonzero for leaf
2252e4b17023SJohn Marinofunctions which only use leaf registers.
2253e4b17023SJohn Marino@code{current_function_uses_only_leaf_regs} is valid after all passes
2254e4b17023SJohn Marinothat modify the instructions have been run and is only useful if
2255e4b17023SJohn Marino@code{LEAF_REGISTERS} is defined.
2256e4b17023SJohn Marino@c changed this to fix overfull.  ALSO:  why the "it" at the beginning
2257e4b17023SJohn Marino@c of the next paragraph?!  --mew 2feb93
2258e4b17023SJohn Marino
2259e4b17023SJohn Marino@node Stack Registers
2260e4b17023SJohn Marino@subsection Registers That Form a Stack
2261e4b17023SJohn Marino
2262e4b17023SJohn MarinoThere are special features to handle computers where some of the
2263e4b17023SJohn Marino``registers'' form a stack.  Stack registers are normally written by
2264e4b17023SJohn Marinopushing onto the stack, and are numbered relative to the top of the
2265e4b17023SJohn Marinostack.
2266e4b17023SJohn Marino
2267e4b17023SJohn MarinoCurrently, GCC can only handle one group of stack-like registers, and
2268e4b17023SJohn Marinothey must be consecutively numbered.  Furthermore, the existing
2269e4b17023SJohn Marinosupport for stack-like registers is specific to the 80387 floating
2270e4b17023SJohn Marinopoint coprocessor.  If you have a new architecture that uses
2271e4b17023SJohn Marinostack-like registers, you will need to do substantial work on
2272e4b17023SJohn Marino@file{reg-stack.c} and write your machine description to cooperate
2273e4b17023SJohn Marinowith it, as well as defining these macros.
2274e4b17023SJohn Marino
2275e4b17023SJohn Marino@defmac STACK_REGS
2276e4b17023SJohn MarinoDefine this if the machine has any stack-like registers.
2277e4b17023SJohn Marino@end defmac
2278e4b17023SJohn Marino
2279e4b17023SJohn Marino@defmac STACK_REG_COVER_CLASS
2280e4b17023SJohn MarinoThis is a cover class containing the stack registers.  Define this if
2281e4b17023SJohn Marinothe machine has any stack-like registers.
2282e4b17023SJohn Marino@end defmac
2283e4b17023SJohn Marino
2284e4b17023SJohn Marino@defmac FIRST_STACK_REG
2285e4b17023SJohn MarinoThe number of the first stack-like register.  This one is the top
2286e4b17023SJohn Marinoof the stack.
2287e4b17023SJohn Marino@end defmac
2288e4b17023SJohn Marino
2289e4b17023SJohn Marino@defmac LAST_STACK_REG
2290e4b17023SJohn MarinoThe number of the last stack-like register.  This one is the bottom of
2291e4b17023SJohn Marinothe stack.
2292e4b17023SJohn Marino@end defmac
2293e4b17023SJohn Marino
2294e4b17023SJohn Marino@node Register Classes
2295e4b17023SJohn Marino@section Register Classes
2296e4b17023SJohn Marino@cindex register class definitions
2297e4b17023SJohn Marino@cindex class definitions, register
2298e4b17023SJohn Marino
2299e4b17023SJohn MarinoOn many machines, the numbered registers are not all equivalent.
2300e4b17023SJohn MarinoFor example, certain registers may not be allowed for indexed addressing;
2301e4b17023SJohn Marinocertain registers may not be allowed in some instructions.  These machine
2302e4b17023SJohn Marinorestrictions are described to the compiler using @dfn{register classes}.
2303e4b17023SJohn Marino
2304e4b17023SJohn MarinoYou define a number of register classes, giving each one a name and saying
2305e4b17023SJohn Marinowhich of the registers belong to it.  Then you can specify register classes
2306e4b17023SJohn Marinothat are allowed as operands to particular instruction patterns.
2307e4b17023SJohn Marino
2308e4b17023SJohn Marino@findex ALL_REGS
2309e4b17023SJohn Marino@findex NO_REGS
2310e4b17023SJohn MarinoIn general, each register will belong to several classes.  In fact, one
2311e4b17023SJohn Marinoclass must be named @code{ALL_REGS} and contain all the registers.  Another
2312e4b17023SJohn Marinoclass must be named @code{NO_REGS} and contain no registers.  Often the
2313e4b17023SJohn Marinounion of two classes will be another class; however, this is not required.
2314e4b17023SJohn Marino
2315e4b17023SJohn Marino@findex GENERAL_REGS
2316e4b17023SJohn MarinoOne of the classes must be named @code{GENERAL_REGS}.  There is nothing
2317e4b17023SJohn Marinoterribly special about the name, but the operand constraint letters
2318e4b17023SJohn Marino@samp{r} and @samp{g} specify this class.  If @code{GENERAL_REGS} is
2319e4b17023SJohn Marinothe same as @code{ALL_REGS}, just define it as a macro which expands
2320e4b17023SJohn Marinoto @code{ALL_REGS}.
2321e4b17023SJohn Marino
2322e4b17023SJohn MarinoOrder the classes so that if class @var{x} is contained in class @var{y}
2323e4b17023SJohn Marinothen @var{x} has a lower class number than @var{y}.
2324e4b17023SJohn Marino
2325e4b17023SJohn MarinoThe way classes other than @code{GENERAL_REGS} are specified in operand
2326e4b17023SJohn Marinoconstraints is through machine-dependent operand constraint letters.
2327e4b17023SJohn MarinoYou can define such letters to correspond to various classes, then use
2328e4b17023SJohn Marinothem in operand constraints.
2329e4b17023SJohn Marino
2330e4b17023SJohn MarinoYou must define the narrowest register classes for allocatable
2331e4b17023SJohn Marinoregisters, so that each class either has no subclasses, or that for
2332e4b17023SJohn Marinosome mode, the move cost between registers within the class is
2333e4b17023SJohn Marinocheaper than moving a register in the class to or from memory
2334e4b17023SJohn Marino(@pxref{Costs}).
2335e4b17023SJohn Marino
2336e4b17023SJohn MarinoYou should define a class for the union of two classes whenever some
2337e4b17023SJohn Marinoinstruction allows both classes.  For example, if an instruction allows
2338e4b17023SJohn Marinoeither a floating point (coprocessor) register or a general register for a
2339e4b17023SJohn Marinocertain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
2340e4b17023SJohn Marinowhich includes both of them.  Otherwise you will get suboptimal code,
2341e4b17023SJohn Marinoor even internal compiler errors when reload cannot find a register in the
2342e4b17023SJohn Marinoclass computed via @code{reg_class_subunion}.
2343e4b17023SJohn Marino
2344e4b17023SJohn MarinoYou must also specify certain redundant information about the register
2345e4b17023SJohn Marinoclasses: for each class, which classes contain it and which ones are
2346e4b17023SJohn Marinocontained in it; for each pair of classes, the largest class contained
2347e4b17023SJohn Marinoin their union.
2348e4b17023SJohn Marino
2349e4b17023SJohn MarinoWhen a value occupying several consecutive registers is expected in a
2350e4b17023SJohn Marinocertain class, all the registers used must belong to that class.
2351e4b17023SJohn MarinoTherefore, register classes cannot be used to enforce a requirement for
2352e4b17023SJohn Marinoa register pair to start with an even-numbered register.  The way to
2353e4b17023SJohn Marinospecify this requirement is with @code{HARD_REGNO_MODE_OK}.
2354e4b17023SJohn Marino
2355e4b17023SJohn MarinoRegister classes used for input-operands of bitwise-and or shift
2356e4b17023SJohn Marinoinstructions have a special requirement: each such class must have, for
2357e4b17023SJohn Marinoeach fixed-point machine mode, a subclass whose registers can transfer that
2358e4b17023SJohn Marinomode to or from memory.  For example, on some machines, the operations for
2359e4b17023SJohn Marinosingle-byte values (@code{QImode}) are limited to certain registers.  When
2360e4b17023SJohn Marinothis is so, each register class that is used in a bitwise-and or shift
2361e4b17023SJohn Marinoinstruction must have a subclass consisting of registers from which
2362e4b17023SJohn Marinosingle-byte values can be loaded or stored.  This is so that
2363e4b17023SJohn Marino@code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
2364e4b17023SJohn Marino
2365e4b17023SJohn Marino@deftp {Data type} {enum reg_class}
2366e4b17023SJohn MarinoAn enumerated type that must be defined with all the register class names
2367e4b17023SJohn Marinoas enumerated values.  @code{NO_REGS} must be first.  @code{ALL_REGS}
2368e4b17023SJohn Marinomust be the last register class, followed by one more enumerated value,
2369e4b17023SJohn Marino@code{LIM_REG_CLASSES}, which is not a register class but rather
2370e4b17023SJohn Marinotells how many classes there are.
2371e4b17023SJohn Marino
2372e4b17023SJohn MarinoEach register class has a number, which is the value of casting
2373e4b17023SJohn Marinothe class name to type @code{int}.  The number serves as an index
2374e4b17023SJohn Marinoin many of the tables described below.
2375e4b17023SJohn Marino@end deftp
2376e4b17023SJohn Marino
2377e4b17023SJohn Marino@defmac N_REG_CLASSES
2378e4b17023SJohn MarinoThe number of distinct register classes, defined as follows:
2379e4b17023SJohn Marino
2380e4b17023SJohn Marino@smallexample
2381e4b17023SJohn Marino#define N_REG_CLASSES (int) LIM_REG_CLASSES
2382e4b17023SJohn Marino@end smallexample
2383e4b17023SJohn Marino@end defmac
2384e4b17023SJohn Marino
2385e4b17023SJohn Marino@defmac REG_CLASS_NAMES
2386e4b17023SJohn MarinoAn initializer containing the names of the register classes as C string
2387e4b17023SJohn Marinoconstants.  These names are used in writing some of the debugging dumps.
2388e4b17023SJohn Marino@end defmac
2389e4b17023SJohn Marino
2390e4b17023SJohn Marino@defmac REG_CLASS_CONTENTS
2391e4b17023SJohn MarinoAn initializer containing the contents of the register classes, as integers
2392e4b17023SJohn Marinowhich are bit masks.  The @var{n}th integer specifies the contents of class
2393e4b17023SJohn Marino@var{n}.  The way the integer @var{mask} is interpreted is that
2394e4b17023SJohn Marinoregister @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
2395e4b17023SJohn Marino
2396e4b17023SJohn MarinoWhen the machine has more than 32 registers, an integer does not suffice.
2397e4b17023SJohn MarinoThen the integers are replaced by sub-initializers, braced groupings containing
2398e4b17023SJohn Marinoseveral integers.  Each sub-initializer must be suitable as an initializer
2399e4b17023SJohn Marinofor the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
2400e4b17023SJohn MarinoIn this situation, the first integer in each sub-initializer corresponds to
2401e4b17023SJohn Marinoregisters 0 through 31, the second integer to registers 32 through 63, and
2402e4b17023SJohn Marinoso on.
2403e4b17023SJohn Marino@end defmac
2404e4b17023SJohn Marino
2405e4b17023SJohn Marino@defmac REGNO_REG_CLASS (@var{regno})
2406e4b17023SJohn MarinoA C expression whose value is a register class containing hard register
2407e4b17023SJohn Marino@var{regno}.  In general there is more than one such class; choose a class
2408e4b17023SJohn Marinowhich is @dfn{minimal}, meaning that no smaller class also contains the
2409e4b17023SJohn Marinoregister.
2410e4b17023SJohn Marino@end defmac
2411e4b17023SJohn Marino
2412e4b17023SJohn Marino@defmac BASE_REG_CLASS
2413e4b17023SJohn MarinoA macro whose definition is the name of the class to which a valid
2414e4b17023SJohn Marinobase register must belong.  A base register is one used in an address
2415e4b17023SJohn Marinowhich is the register value plus a displacement.
2416e4b17023SJohn Marino@end defmac
2417e4b17023SJohn Marino
2418e4b17023SJohn Marino@defmac MODE_BASE_REG_CLASS (@var{mode})
2419e4b17023SJohn MarinoThis is a variation of the @code{BASE_REG_CLASS} macro which allows
2420e4b17023SJohn Marinothe selection of a base register in a mode dependent manner.  If
2421e4b17023SJohn Marino@var{mode} is VOIDmode then it should return the same value as
2422e4b17023SJohn Marino@code{BASE_REG_CLASS}.
2423e4b17023SJohn Marino@end defmac
2424e4b17023SJohn Marino
2425e4b17023SJohn Marino@defmac MODE_BASE_REG_REG_CLASS (@var{mode})
2426e4b17023SJohn MarinoA C expression whose value is the register class to which a valid
2427e4b17023SJohn Marinobase register must belong in order to be used in a base plus index
2428e4b17023SJohn Marinoregister address.  You should define this macro if base plus index
2429e4b17023SJohn Marinoaddresses have different requirements than other base register uses.
2430e4b17023SJohn Marino@end defmac
2431e4b17023SJohn Marino
2432e4b17023SJohn Marino@defmac MODE_CODE_BASE_REG_CLASS (@var{mode}, @var{address_space}, @var{outer_code}, @var{index_code})
2433e4b17023SJohn MarinoA C expression whose value is the register class to which a valid
2434e4b17023SJohn Marinobase register for a memory reference in mode @var{mode} to address
2435e4b17023SJohn Marinospace @var{address_space} must belong.  @var{outer_code} and @var{index_code}
2436e4b17023SJohn Marinodefine the context in which the base register occurs.  @var{outer_code} is
2437e4b17023SJohn Marinothe code of the immediately enclosing expression (@code{MEM} for the top level
2438e4b17023SJohn Marinoof an address, @code{ADDRESS} for something that occurs in an
2439e4b17023SJohn Marino@code{address_operand}).  @var{index_code} is the code of the corresponding
2440e4b17023SJohn Marinoindex expression if @var{outer_code} is @code{PLUS}; @code{SCRATCH} otherwise.
2441e4b17023SJohn Marino@end defmac
2442e4b17023SJohn Marino
2443e4b17023SJohn Marino@defmac INDEX_REG_CLASS
2444e4b17023SJohn MarinoA macro whose definition is the name of the class to which a valid
2445e4b17023SJohn Marinoindex register must belong.  An index register is one used in an
2446e4b17023SJohn Marinoaddress where its value is either multiplied by a scale factor or
2447e4b17023SJohn Marinoadded to another register (as well as added to a displacement).
2448e4b17023SJohn Marino@end defmac
2449e4b17023SJohn Marino
2450e4b17023SJohn Marino@defmac REGNO_OK_FOR_BASE_P (@var{num})
2451e4b17023SJohn MarinoA C expression which is nonzero if register number @var{num} is
2452e4b17023SJohn Marinosuitable for use as a base register in operand addresses.
2453e4b17023SJohn Marino@end defmac
2454e4b17023SJohn Marino
2455e4b17023SJohn Marino@defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode})
2456e4b17023SJohn MarinoA C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that
2457e4b17023SJohn Marinothat expression may examine the mode of the memory reference in
2458e4b17023SJohn Marino@var{mode}.  You should define this macro if the mode of the memory
2459e4b17023SJohn Marinoreference affects whether a register may be used as a base register.  If
2460e4b17023SJohn Marinoyou define this macro, the compiler will use it instead of
2461e4b17023SJohn Marino@code{REGNO_OK_FOR_BASE_P}.  The mode may be @code{VOIDmode} for
2462e4b17023SJohn Marinoaddresses that appear outside a @code{MEM}, i.e., as an
2463e4b17023SJohn Marino@code{address_operand}.
2464e4b17023SJohn Marino@end defmac
2465e4b17023SJohn Marino
2466e4b17023SJohn Marino@defmac REGNO_MODE_OK_FOR_REG_BASE_P (@var{num}, @var{mode})
2467e4b17023SJohn MarinoA C expression which is nonzero if register number @var{num} is suitable for
2468e4b17023SJohn Marinouse as a base register in base plus index operand addresses, accessing
2469e4b17023SJohn Marinomemory in mode @var{mode}.  It may be either a suitable hard register or a
2470e4b17023SJohn Marinopseudo register that has been allocated such a hard register.  You should
2471e4b17023SJohn Marinodefine this macro if base plus index addresses have different requirements
2472e4b17023SJohn Marinothan other base register uses.
2473e4b17023SJohn Marino
2474e4b17023SJohn MarinoUse of this macro is deprecated; please use the more general
2475e4b17023SJohn Marino@code{REGNO_MODE_CODE_OK_FOR_BASE_P}.
2476e4b17023SJohn Marino@end defmac
2477e4b17023SJohn Marino
2478e4b17023SJohn Marino@defmac REGNO_MODE_CODE_OK_FOR_BASE_P (@var{num}, @var{mode}, @var{address_space}, @var{outer_code}, @var{index_code})
2479e4b17023SJohn MarinoA C expression which is nonzero if register number @var{num} is
2480e4b17023SJohn Marinosuitable for use as a base register in operand addresses, accessing
2481e4b17023SJohn Marinomemory in mode @var{mode} in address space @var{address_space}.
2482e4b17023SJohn MarinoThis is similar to @code{REGNO_MODE_OK_FOR_BASE_P}, except
2483e4b17023SJohn Marinothat that expression may examine the context in which the register
2484e4b17023SJohn Marinoappears in the memory reference.  @var{outer_code} is the code of the
2485e4b17023SJohn Marinoimmediately enclosing expression (@code{MEM} if at the top level of the
2486e4b17023SJohn Marinoaddress, @code{ADDRESS} for something that occurs in an
2487e4b17023SJohn Marino@code{address_operand}).  @var{index_code} is the code of the
2488e4b17023SJohn Marinocorresponding index expression if @var{outer_code} is @code{PLUS};
2489e4b17023SJohn Marino@code{SCRATCH} otherwise.  The mode may be @code{VOIDmode} for addresses
2490e4b17023SJohn Marinothat appear outside a @code{MEM}, i.e., as an @code{address_operand}.
2491e4b17023SJohn Marino@end defmac
2492e4b17023SJohn Marino
2493e4b17023SJohn Marino@defmac REGNO_OK_FOR_INDEX_P (@var{num})
2494e4b17023SJohn MarinoA C expression which is nonzero if register number @var{num} is
2495e4b17023SJohn Marinosuitable for use as an index register in operand addresses.  It may be
2496e4b17023SJohn Marinoeither a suitable hard register or a pseudo register that has been
2497e4b17023SJohn Marinoallocated such a hard register.
2498e4b17023SJohn Marino
2499e4b17023SJohn MarinoThe difference between an index register and a base register is that
2500e4b17023SJohn Marinothe index register may be scaled.  If an address involves the sum of
2501e4b17023SJohn Marinotwo registers, neither one of them scaled, then either one may be
2502e4b17023SJohn Marinolabeled the ``base'' and the other the ``index''; but whichever
2503e4b17023SJohn Marinolabeling is used must fit the machine's constraints of which registers
2504e4b17023SJohn Marinomay serve in each capacity.  The compiler will try both labelings,
2505e4b17023SJohn Marinolooking for one that is valid, and will reload one or both registers
2506e4b17023SJohn Marinoonly if neither labeling works.
2507e4b17023SJohn Marino@end defmac
2508e4b17023SJohn Marino
2509e4b17023SJohn Marino@hook TARGET_PREFERRED_RENAME_CLASS
2510e4b17023SJohn Marino
2511e4b17023SJohn Marino@hook TARGET_PREFERRED_RELOAD_CLASS
2512e4b17023SJohn MarinoA target hook that places additional restrictions on the register class
2513e4b17023SJohn Marinoto use when it is necessary to copy value @var{x} into a register in class
2514e4b17023SJohn Marino@var{rclass}.  The value is a register class; perhaps @var{rclass}, or perhaps
2515e4b17023SJohn Marinoanother, smaller class.
2516e4b17023SJohn Marino
2517e4b17023SJohn MarinoThe default version of this hook always returns value of @code{rclass} argument.
2518e4b17023SJohn Marino
2519e4b17023SJohn MarinoSometimes returning a more restrictive class makes better code.  For
2520e4b17023SJohn Marinoexample, on the 68000, when @var{x} is an integer constant that is in range
2521e4b17023SJohn Marinofor a @samp{moveq} instruction, the value of this macro is always
2522e4b17023SJohn Marino@code{DATA_REGS} as long as @var{rclass} includes the data registers.
2523e4b17023SJohn MarinoRequiring a data register guarantees that a @samp{moveq} will be used.
2524e4b17023SJohn Marino
2525e4b17023SJohn MarinoOne case where @code{TARGET_PREFERRED_RELOAD_CLASS} must not return
2526e4b17023SJohn Marino@var{rclass} is if @var{x} is a legitimate constant which cannot be
2527e4b17023SJohn Marinoloaded into some register class.  By returning @code{NO_REGS} you can
2528e4b17023SJohn Marinoforce @var{x} into a memory location.  For example, rs6000 can load
2529e4b17023SJohn Marinoimmediate values into general-purpose registers, but does not have an
2530e4b17023SJohn Marinoinstruction for loading an immediate value into a floating-point
2531e4b17023SJohn Marinoregister, so @code{TARGET_PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2532e4b17023SJohn Marino@var{x} is a floating-point constant.  If the constant can't be loaded
2533e4b17023SJohn Marinointo any kind of register, code generation will be better if
2534e4b17023SJohn Marino@code{TARGET_LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
2535e4b17023SJohn Marinoof using @code{TARGET_PREFERRED_RELOAD_CLASS}.
2536e4b17023SJohn Marino
2537e4b17023SJohn MarinoIf an insn has pseudos in it after register allocation, reload will go
2538e4b17023SJohn Marinothrough the alternatives and call repeatedly @code{TARGET_PREFERRED_RELOAD_CLASS}
2539e4b17023SJohn Marinoto find the best one.  Returning @code{NO_REGS}, in this case, makes
2540e4b17023SJohn Marinoreload add a @code{!} in front of the constraint: the x86 back-end uses
2541e4b17023SJohn Marinothis feature to discourage usage of 387 registers when math is done in
2542e4b17023SJohn Marinothe SSE registers (and vice versa).
2543e4b17023SJohn Marino@end deftypefn
2544e4b17023SJohn Marino
2545e4b17023SJohn Marino@defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
2546e4b17023SJohn MarinoA C expression that places additional restrictions on the register class
2547e4b17023SJohn Marinoto use when it is necessary to copy value @var{x} into a register in class
2548e4b17023SJohn Marino@var{class}.  The value is a register class; perhaps @var{class}, or perhaps
2549e4b17023SJohn Marinoanother, smaller class.  On many machines, the following definition is
2550e4b17023SJohn Marinosafe:
2551e4b17023SJohn Marino
2552e4b17023SJohn Marino@smallexample
2553e4b17023SJohn Marino#define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
2554e4b17023SJohn Marino@end smallexample
2555e4b17023SJohn Marino
2556e4b17023SJohn MarinoSometimes returning a more restrictive class makes better code.  For
2557e4b17023SJohn Marinoexample, on the 68000, when @var{x} is an integer constant that is in range
2558e4b17023SJohn Marinofor a @samp{moveq} instruction, the value of this macro is always
2559e4b17023SJohn Marino@code{DATA_REGS} as long as @var{class} includes the data registers.
2560e4b17023SJohn MarinoRequiring a data register guarantees that a @samp{moveq} will be used.
2561e4b17023SJohn Marino
2562e4b17023SJohn MarinoOne case where @code{PREFERRED_RELOAD_CLASS} must not return
2563e4b17023SJohn Marino@var{class} is if @var{x} is a legitimate constant which cannot be
2564e4b17023SJohn Marinoloaded into some register class.  By returning @code{NO_REGS} you can
2565e4b17023SJohn Marinoforce @var{x} into a memory location.  For example, rs6000 can load
2566e4b17023SJohn Marinoimmediate values into general-purpose registers, but does not have an
2567e4b17023SJohn Marinoinstruction for loading an immediate value into a floating-point
2568e4b17023SJohn Marinoregister, so @code{PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when
2569e4b17023SJohn Marino@var{x} is a floating-point constant.  If the constant can't be loaded
2570e4b17023SJohn Marinointo any kind of register, code generation will be better if
2571e4b17023SJohn Marino@code{TARGET_LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead
2572e4b17023SJohn Marinoof using @code{TARGET_PREFERRED_RELOAD_CLASS}.
2573e4b17023SJohn Marino
2574e4b17023SJohn MarinoIf an insn has pseudos in it after register allocation, reload will go
2575e4b17023SJohn Marinothrough the alternatives and call repeatedly @code{PREFERRED_RELOAD_CLASS}
2576e4b17023SJohn Marinoto find the best one.  Returning @code{NO_REGS}, in this case, makes
2577e4b17023SJohn Marinoreload add a @code{!} in front of the constraint: the x86 back-end uses
2578e4b17023SJohn Marinothis feature to discourage usage of 387 registers when math is done in
2579e4b17023SJohn Marinothe SSE registers (and vice versa).
2580e4b17023SJohn Marino@end defmac
2581e4b17023SJohn Marino
2582e4b17023SJohn Marino@hook TARGET_PREFERRED_OUTPUT_RELOAD_CLASS
2583e4b17023SJohn MarinoLike @code{TARGET_PREFERRED_RELOAD_CLASS}, but for output reloads instead of
2584e4b17023SJohn Marinoinput reloads.
2585e4b17023SJohn Marino
2586e4b17023SJohn MarinoThe default version of this hook always returns value of @code{rclass}
2587e4b17023SJohn Marinoargument.
2588e4b17023SJohn Marino
2589e4b17023SJohn MarinoYou can also use @code{TARGET_PREFERRED_OUTPUT_RELOAD_CLASS} to discourage
2590e4b17023SJohn Marinoreload from using some alternatives, like @code{TARGET_PREFERRED_RELOAD_CLASS}.
2591e4b17023SJohn Marino@end deftypefn
2592e4b17023SJohn Marino
2593e4b17023SJohn Marino@defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class})
2594e4b17023SJohn MarinoA C expression that places additional restrictions on the register class
2595e4b17023SJohn Marinoto use when it is necessary to be able to hold a value of mode
2596e4b17023SJohn Marino@var{mode} in a reload register for which class @var{class} would
2597e4b17023SJohn Marinoordinarily be used.
2598e4b17023SJohn Marino
2599e4b17023SJohn MarinoUnlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when
2600e4b17023SJohn Marinothere are certain modes that simply can't go in certain reload classes.
2601e4b17023SJohn Marino
2602e4b17023SJohn MarinoThe value is a register class; perhaps @var{class}, or perhaps another,
2603e4b17023SJohn Marinosmaller class.
2604e4b17023SJohn Marino
2605e4b17023SJohn MarinoDon't define this macro unless the target machine has limitations which
2606e4b17023SJohn Marinorequire the macro to do something nontrivial.
2607e4b17023SJohn Marino@end defmac
2608e4b17023SJohn Marino
2609e4b17023SJohn Marino@hook TARGET_SECONDARY_RELOAD
2610e4b17023SJohn MarinoMany machines have some registers that cannot be copied directly to or
2611e4b17023SJohn Marinofrom memory or even from other types of registers.  An example is the
2612e4b17023SJohn Marino@samp{MQ} register, which on most machines, can only be copied to or
2613e4b17023SJohn Marinofrom general registers, but not memory.  Below, we shall be using the
2614e4b17023SJohn Marinoterm 'intermediate register' when a move operation cannot be performed
2615e4b17023SJohn Marinodirectly, but has to be done by copying the source into the intermediate
2616e4b17023SJohn Marinoregister first, and then copying the intermediate register to the
2617e4b17023SJohn Marinodestination.  An intermediate register always has the same mode as
2618e4b17023SJohn Marinosource and destination.  Since it holds the actual value being copied,
2619e4b17023SJohn Marinoreload might apply optimizations to re-use an intermediate register
2620e4b17023SJohn Marinoand eliding the copy from the source when it can determine that the
2621e4b17023SJohn Marinointermediate register still holds the required value.
2622e4b17023SJohn Marino
2623e4b17023SJohn MarinoAnother kind of secondary reload is required on some machines which
2624e4b17023SJohn Marinoallow copying all registers to and from memory, but require a scratch
2625e4b17023SJohn Marinoregister for stores to some memory locations (e.g., those with symbolic
2626e4b17023SJohn Marinoaddress on the RT, and those with certain symbolic address on the SPARC
2627e4b17023SJohn Marinowhen compiling PIC)@.  Scratch registers need not have the same mode
2628e4b17023SJohn Marinoas the value being copied, and usually hold a different value than
2629e4b17023SJohn Marinothat being copied.  Special patterns in the md file are needed to
2630e4b17023SJohn Marinodescribe how the copy is performed with the help of the scratch register;
2631e4b17023SJohn Marinothese patterns also describe the number, register class(es) and mode(s)
2632e4b17023SJohn Marinoof the scratch register(s).
2633e4b17023SJohn Marino
2634e4b17023SJohn MarinoIn some cases, both an intermediate and a scratch register are required.
2635e4b17023SJohn Marino
2636e4b17023SJohn MarinoFor input reloads, this target hook is called with nonzero @var{in_p},
2637e4b17023SJohn Marinoand @var{x} is an rtx that needs to be copied to a register of class
2638e4b17023SJohn Marino@var{reload_class} in @var{reload_mode}.  For output reloads, this target
2639e4b17023SJohn Marinohook is called with zero @var{in_p}, and a register of class @var{reload_class}
2640e4b17023SJohn Marinoneeds to be copied to rtx @var{x} in @var{reload_mode}.
2641e4b17023SJohn Marino
2642e4b17023SJohn MarinoIf copying a register of @var{reload_class} from/to @var{x} requires
2643e4b17023SJohn Marinoan intermediate register, the hook @code{secondary_reload} should
2644e4b17023SJohn Marinoreturn the register class required for this intermediate register.
2645e4b17023SJohn MarinoIf no intermediate register is required, it should return NO_REGS.
2646e4b17023SJohn MarinoIf more than one intermediate register is required, describe the one
2647e4b17023SJohn Marinothat is closest in the copy chain to the reload register.
2648e4b17023SJohn Marino
2649e4b17023SJohn MarinoIf scratch registers are needed, you also have to describe how to
2650e4b17023SJohn Marinoperform the copy from/to the reload register to/from this
2651e4b17023SJohn Marinoclosest intermediate register.  Or if no intermediate register is
2652e4b17023SJohn Marinorequired, but still a scratch register is needed, describe the
2653e4b17023SJohn Marinocopy  from/to the reload register to/from the reload operand @var{x}.
2654e4b17023SJohn Marino
2655e4b17023SJohn MarinoYou do this by setting @code{sri->icode} to the instruction code of a pattern
2656e4b17023SJohn Marinoin the md file which performs the move.  Operands 0 and 1 are the output
2657e4b17023SJohn Marinoand input of this copy, respectively.  Operands from operand 2 onward are
2658e4b17023SJohn Marinofor scratch operands.  These scratch operands must have a mode, and a
2659e4b17023SJohn Marinosingle-register-class
2660e4b17023SJohn Marino@c [later: or memory]
2661e4b17023SJohn Marinooutput constraint.
2662e4b17023SJohn Marino
2663e4b17023SJohn MarinoWhen an intermediate register is used, the @code{secondary_reload}
2664e4b17023SJohn Marinohook will be called again to determine how to copy the intermediate
2665e4b17023SJohn Marinoregister to/from the reload operand @var{x}, so your hook must also
2666e4b17023SJohn Marinohave code to handle the register class of the intermediate operand.
2667e4b17023SJohn Marino
2668e4b17023SJohn Marino@c [For later: maybe we'll allow multi-alternative reload patterns -
2669e4b17023SJohn Marino@c   the port maintainer could name a mov<mode> pattern that has clobbers -
2670e4b17023SJohn Marino@c   and match the constraints of input and output to determine the required
2671e4b17023SJohn Marino@c   alternative.  A restriction would be that constraints used to match
2672e4b17023SJohn Marino@c   against reloads registers would have to be written as register class
2673e4b17023SJohn Marino@c   constraints, or we need a new target macro / hook that tells us if an
2674e4b17023SJohn Marino@c   arbitrary constraint can match an unknown register of a given class.
2675e4b17023SJohn Marino@c   Such a macro / hook would also be useful in other places.]
2676e4b17023SJohn Marino
2677e4b17023SJohn Marino
2678e4b17023SJohn Marino@var{x} might be a pseudo-register or a @code{subreg} of a
2679e4b17023SJohn Marinopseudo-register, which could either be in a hard register or in memory.
2680e4b17023SJohn MarinoUse @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2681e4b17023SJohn Marinoin memory and the hard register number if it is in a register.
2682e4b17023SJohn Marino
2683e4b17023SJohn MarinoScratch operands in memory (constraint @code{"=m"} / @code{"=&m"}) are
2684e4b17023SJohn Marinocurrently not supported.  For the time being, you will have to continue
2685e4b17023SJohn Marinoto use @code{SECONDARY_MEMORY_NEEDED} for that purpose.
2686e4b17023SJohn Marino
2687e4b17023SJohn Marino@code{copy_cost} also uses this target hook to find out how values are
2688e4b17023SJohn Marinocopied.  If you want it to include some extra cost for the need to allocate
2689e4b17023SJohn Marino(a) scratch register(s), set @code{sri->extra_cost} to the additional cost.
2690e4b17023SJohn MarinoOr if two dependent moves are supposed to have a lower cost than the sum
2691e4b17023SJohn Marinoof the individual moves due to expected fortuitous scheduling and/or special
2692e4b17023SJohn Marinoforwarding logic, you can set @code{sri->extra_cost} to a negative amount.
2693e4b17023SJohn Marino@end deftypefn
2694e4b17023SJohn Marino
2695e4b17023SJohn Marino@defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2696e4b17023SJohn Marino@defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2697e4b17023SJohn Marino@defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
2698e4b17023SJohn MarinoThese macros are obsolete, new ports should use the target hook
2699e4b17023SJohn Marino@code{TARGET_SECONDARY_RELOAD} instead.
2700e4b17023SJohn Marino
2701e4b17023SJohn MarinoThese are obsolete macros, replaced by the @code{TARGET_SECONDARY_RELOAD}
2702e4b17023SJohn Marinotarget hook.  Older ports still define these macros to indicate to the
2703e4b17023SJohn Marinoreload phase that it may
2704e4b17023SJohn Marinoneed to allocate at least one register for a reload in addition to the
2705e4b17023SJohn Marinoregister to contain the data.  Specifically, if copying @var{x} to a
2706e4b17023SJohn Marinoregister @var{class} in @var{mode} requires an intermediate register,
2707e4b17023SJohn Marinoyou were supposed to define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the
2708e4b17023SJohn Marinolargest register class all of whose registers can be used as
2709e4b17023SJohn Marinointermediate registers or scratch registers.
2710e4b17023SJohn Marino
2711e4b17023SJohn MarinoIf copying a register @var{class} in @var{mode} to @var{x} requires an
2712e4b17023SJohn Marinointermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS}
2713e4b17023SJohn Marinowas supposed to be defined be defined to return the largest register
2714e4b17023SJohn Marinoclass required.  If the
2715e4b17023SJohn Marinorequirements for input and output reloads were the same, the macro
2716e4b17023SJohn Marino@code{SECONDARY_RELOAD_CLASS} should have been used instead of defining both
2717e4b17023SJohn Marinomacros identically.
2718e4b17023SJohn Marino
2719e4b17023SJohn MarinoThe values returned by these macros are often @code{GENERAL_REGS}.
2720e4b17023SJohn MarinoReturn @code{NO_REGS} if no spare register is needed; i.e., if @var{x}
2721e4b17023SJohn Marinocan be directly copied to or from a register of @var{class} in
2722e4b17023SJohn Marino@var{mode} without requiring a scratch register.  Do not define this
2723e4b17023SJohn Marinomacro if it would always return @code{NO_REGS}.
2724e4b17023SJohn Marino
2725e4b17023SJohn MarinoIf a scratch register is required (either with or without an
2726e4b17023SJohn Marinointermediate register), you were supposed to define patterns for
2727e4b17023SJohn Marino@samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required
2728e4b17023SJohn Marino(@pxref{Standard Names}.  These patterns, which were normally
2729e4b17023SJohn Marinoimplemented with a @code{define_expand}, should be similar to the
2730e4b17023SJohn Marino@samp{mov@var{m}} patterns, except that operand 2 is the scratch
2731e4b17023SJohn Marinoregister.
2732e4b17023SJohn Marino
2733e4b17023SJohn MarinoThese patterns need constraints for the reload register and scratch
2734e4b17023SJohn Marinoregister that
2735e4b17023SJohn Marinocontain a single register class.  If the original reload register (whose
2736e4b17023SJohn Marinoclass is @var{class}) can meet the constraint given in the pattern, the
2737e4b17023SJohn Marinovalue returned by these macros is used for the class of the scratch
2738e4b17023SJohn Marinoregister.  Otherwise, two additional reload registers are required.
2739e4b17023SJohn MarinoTheir classes are obtained from the constraints in the insn pattern.
2740e4b17023SJohn Marino
2741e4b17023SJohn Marino@var{x} might be a pseudo-register or a @code{subreg} of a
2742e4b17023SJohn Marinopseudo-register, which could either be in a hard register or in memory.
2743e4b17023SJohn MarinoUse @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is
2744e4b17023SJohn Marinoin memory and the hard register number if it is in a register.
2745e4b17023SJohn Marino
2746e4b17023SJohn MarinoThese macros should not be used in the case where a particular class of
2747e4b17023SJohn Marinoregisters can only be copied to memory and not to another class of
2748e4b17023SJohn Marinoregisters.  In that case, secondary reload registers are not needed and
2749e4b17023SJohn Marinowould not be helpful.  Instead, a stack location must be used to perform
2750e4b17023SJohn Marinothe copy and the @code{mov@var{m}} pattern should use memory as an
2751e4b17023SJohn Marinointermediate storage.  This case often occurs between floating-point and
2752e4b17023SJohn Marinogeneral registers.
2753e4b17023SJohn Marino@end defmac
2754e4b17023SJohn Marino
2755e4b17023SJohn Marino@defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m})
2756e4b17023SJohn MarinoCertain machines have the property that some registers cannot be copied
2757e4b17023SJohn Marinoto some other registers without using memory.  Define this macro on
2758e4b17023SJohn Marinothose machines to be a C expression that is nonzero if objects of mode
2759e4b17023SJohn Marino@var{m} in registers of @var{class1} can only be copied to registers of
2760e4b17023SJohn Marinoclass @var{class2} by storing a register of @var{class1} into memory
2761e4b17023SJohn Marinoand loading that memory location into a register of @var{class2}.
2762e4b17023SJohn Marino
2763e4b17023SJohn MarinoDo not define this macro if its value would always be zero.
2764e4b17023SJohn Marino@end defmac
2765e4b17023SJohn Marino
2766e4b17023SJohn Marino@defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode})
2767e4b17023SJohn MarinoNormally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler
2768e4b17023SJohn Marinoallocates a stack slot for a memory location needed for register copies.
2769e4b17023SJohn MarinoIf this macro is defined, the compiler instead uses the memory location
2770e4b17023SJohn Marinodefined by this macro.
2771e4b17023SJohn Marino
2772e4b17023SJohn MarinoDo not define this macro if you do not define
2773e4b17023SJohn Marino@code{SECONDARY_MEMORY_NEEDED}.
2774e4b17023SJohn Marino@end defmac
2775e4b17023SJohn Marino
2776e4b17023SJohn Marino@defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode})
2777e4b17023SJohn MarinoWhen the compiler needs a secondary memory location to copy between two
2778e4b17023SJohn Marinoregisters of mode @var{mode}, it normally allocates sufficient memory to
2779e4b17023SJohn Marinohold a quantity of @code{BITS_PER_WORD} bits and performs the store and
2780e4b17023SJohn Marinoload operations in a mode that many bits wide and whose class is the
2781e4b17023SJohn Marinosame as that of @var{mode}.
2782e4b17023SJohn Marino
2783e4b17023SJohn MarinoThis is right thing to do on most machines because it ensures that all
2784e4b17023SJohn Marinobits of the register are copied and prevents accesses to the registers
2785e4b17023SJohn Marinoin a narrower mode, which some machines prohibit for floating-point
2786e4b17023SJohn Marinoregisters.
2787e4b17023SJohn Marino
2788e4b17023SJohn MarinoHowever, this default behavior is not correct on some machines, such as
2789e4b17023SJohn Marinothe DEC Alpha, that store short integers in floating-point registers
2790e4b17023SJohn Marinodifferently than in integer registers.  On those machines, the default
2791e4b17023SJohn Marinowidening will not work correctly and you must define this macro to
2792e4b17023SJohn Marinosuppress that widening in some cases.  See the file @file{alpha.h} for
2793e4b17023SJohn Marinodetails.
2794e4b17023SJohn Marino
2795e4b17023SJohn MarinoDo not define this macro if you do not define
2796e4b17023SJohn Marino@code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that
2797e4b17023SJohn Marinois @code{BITS_PER_WORD} bits wide is correct for your machine.
2798e4b17023SJohn Marino@end defmac
2799e4b17023SJohn Marino
2800e4b17023SJohn Marino@hook TARGET_CLASS_LIKELY_SPILLED_P
2801e4b17023SJohn MarinoA target hook which returns @code{true} if pseudos that have been assigned
2802e4b17023SJohn Marinoto registers of class @var{rclass} would likely be spilled because
2803e4b17023SJohn Marinoregisters of @var{rclass} are needed for spill registers.
2804e4b17023SJohn Marino
2805e4b17023SJohn MarinoThe default version of this target hook returns @code{true} if @var{rclass}
2806e4b17023SJohn Marinohas exactly one register and @code{false} otherwise.  On most machines, this
2807e4b17023SJohn Marinodefault should be used.  Only use this target hook to some other expression
2808e4b17023SJohn Marinoif pseudos allocated by @file{local-alloc.c} end up in memory because their
2809e4b17023SJohn Marinohard registers were needed for spill registers.  If this target hook returns
2810e4b17023SJohn Marino@code{false} for those classes, those pseudos will only be allocated by
2811e4b17023SJohn Marino@file{global.c}, which knows how to reallocate the pseudo to another
2812e4b17023SJohn Marinoregister.  If there would not be another register available for reallocation,
2813e4b17023SJohn Marinoyou should not change the implementation of this target hook since
2814e4b17023SJohn Marinothe only effect of such implementation would be to slow down register
2815e4b17023SJohn Marinoallocation.
2816e4b17023SJohn Marino@end deftypefn
2817e4b17023SJohn Marino
2818e4b17023SJohn Marino@hook TARGET_CLASS_MAX_NREGS
2819e4b17023SJohn MarinoA target hook returns the maximum number of consecutive registers
2820e4b17023SJohn Marinoof class @var{rclass} needed to hold a value of mode @var{mode}.
2821e4b17023SJohn Marino
2822e4b17023SJohn MarinoThis is closely related to the macro @code{HARD_REGNO_NREGS}.  In fact,
2823e4b17023SJohn Marinothe value returned by @code{TARGET_CLASS_MAX_NREGS (@var{rclass},
2824e4b17023SJohn Marino@var{mode})} target hook should be the maximum value of
2825e4b17023SJohn Marino@code{HARD_REGNO_NREGS (@var{regno}, @var{mode})} for all @var{regno}
2826e4b17023SJohn Marinovalues in the class @var{rclass}.
2827e4b17023SJohn Marino
2828e4b17023SJohn MarinoThis target hook helps control the handling of multiple-word values
2829e4b17023SJohn Marinoin the reload pass.
2830e4b17023SJohn Marino
2831e4b17023SJohn MarinoThe default version of this target hook returns the size of @var{mode}
2832e4b17023SJohn Marinoin words.
2833e4b17023SJohn Marino@end deftypefn
2834e4b17023SJohn Marino
2835e4b17023SJohn Marino@defmac CLASS_MAX_NREGS (@var{class}, @var{mode})
2836e4b17023SJohn MarinoA C expression for the maximum number of consecutive registers
2837e4b17023SJohn Marinoof class @var{class} needed to hold a value of mode @var{mode}.
2838e4b17023SJohn Marino
2839e4b17023SJohn MarinoThis is closely related to the macro @code{HARD_REGNO_NREGS}.  In fact,
2840e4b17023SJohn Marinothe value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
2841e4b17023SJohn Marinoshould be the maximum value of @code{HARD_REGNO_NREGS (@var{regno},
2842e4b17023SJohn Marino@var{mode})} for all @var{regno} values in the class @var{class}.
2843e4b17023SJohn Marino
2844e4b17023SJohn MarinoThis macro helps control the handling of multiple-word values
2845e4b17023SJohn Marinoin the reload pass.
2846e4b17023SJohn Marino@end defmac
2847e4b17023SJohn Marino
2848e4b17023SJohn Marino@defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
2849e4b17023SJohn MarinoIf defined, a C expression that returns nonzero for a @var{class} for which
2850e4b17023SJohn Marinoa change from mode @var{from} to mode @var{to} is invalid.
2851e4b17023SJohn Marino
2852e4b17023SJohn MarinoFor the example, loading 32-bit integer or floating-point objects into
2853e4b17023SJohn Marinofloating-point registers on the Alpha extends them to 64 bits.
2854e4b17023SJohn MarinoTherefore loading a 64-bit object and then storing it as a 32-bit object
2855e4b17023SJohn Marinodoes not store the low-order 32 bits, as would be the case for a normal
2856e4b17023SJohn Marinoregister.  Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
2857e4b17023SJohn Marinoas below:
2858e4b17023SJohn Marino
2859e4b17023SJohn Marino@smallexample
2860e4b17023SJohn Marino#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
2861e4b17023SJohn Marino  (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
2862e4b17023SJohn Marino   ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
2863e4b17023SJohn Marino@end smallexample
2864e4b17023SJohn Marino@end defmac
2865e4b17023SJohn Marino
2866e4b17023SJohn Marino@node Old Constraints
2867e4b17023SJohn Marino@section Obsolete Macros for Defining Constraints
2868e4b17023SJohn Marino@cindex defining constraints, obsolete method
2869e4b17023SJohn Marino@cindex constraints, defining, obsolete method
2870e4b17023SJohn Marino
2871e4b17023SJohn MarinoMachine-specific constraints can be defined with these macros instead
2872e4b17023SJohn Marinoof the machine description constructs described in @ref{Define
2873e4b17023SJohn MarinoConstraints}.  This mechanism is obsolete.  New ports should not use
2874e4b17023SJohn Marinoit; old ports should convert to the new mechanism.
2875e4b17023SJohn Marino
2876e4b17023SJohn Marino@defmac CONSTRAINT_LEN (@var{char}, @var{str})
2877e4b17023SJohn MarinoFor the constraint at the start of @var{str}, which starts with the letter
2878e4b17023SJohn Marino@var{c}, return the length.  This allows you to have register class /
2879e4b17023SJohn Marinoconstant / extra constraints that are longer than a single letter;
2880e4b17023SJohn Marinoyou don't need to define this macro if you can do with single-letter
2881e4b17023SJohn Marinoconstraints only.  The definition of this macro should use
2882e4b17023SJohn MarinoDEFAULT_CONSTRAINT_LEN for all the characters that you don't want
2883e4b17023SJohn Marinoto handle specially.
2884e4b17023SJohn MarinoThere are some sanity checks in genoutput.c that check the constraint lengths
2885e4b17023SJohn Marinofor the md file, so you can also use this macro to help you while you are
2886e4b17023SJohn Marinotransitioning from a byzantine single-letter-constraint scheme: when you
2887e4b17023SJohn Marinoreturn a negative length for a constraint you want to re-use, genoutput
2888e4b17023SJohn Marinowill complain about every instance where it is used in the md file.
2889e4b17023SJohn Marino@end defmac
2890e4b17023SJohn Marino
2891e4b17023SJohn Marino@defmac REG_CLASS_FROM_LETTER (@var{char})
2892e4b17023SJohn MarinoA C expression which defines the machine-dependent operand constraint
2893e4b17023SJohn Marinoletters for register classes.  If @var{char} is such a letter, the
2894e4b17023SJohn Marinovalue should be the register class corresponding to it.  Otherwise,
2895e4b17023SJohn Marinothe value should be @code{NO_REGS}.  The register letter @samp{r},
2896e4b17023SJohn Marinocorresponding to class @code{GENERAL_REGS}, will not be passed
2897e4b17023SJohn Marinoto this macro; you do not need to handle it.
2898e4b17023SJohn Marino@end defmac
2899e4b17023SJohn Marino
2900e4b17023SJohn Marino@defmac REG_CLASS_FROM_CONSTRAINT (@var{char}, @var{str})
2901e4b17023SJohn MarinoLike @code{REG_CLASS_FROM_LETTER}, but you also get the constraint string
2902e4b17023SJohn Marinopassed in @var{str}, so that you can use suffixes to distinguish between
2903e4b17023SJohn Marinodifferent variants.
2904e4b17023SJohn Marino@end defmac
2905e4b17023SJohn Marino
2906e4b17023SJohn Marino@defmac CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
2907e4b17023SJohn MarinoA C expression that defines the machine-dependent operand constraint
2908e4b17023SJohn Marinoletters (@samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}) that specify
2909e4b17023SJohn Marinoparticular ranges of integer values.  If @var{c} is one of those
2910e4b17023SJohn Marinoletters, the expression should check that @var{value}, an integer, is in
2911e4b17023SJohn Marinothe appropriate range and return 1 if so, 0 otherwise.  If @var{c} is
2912e4b17023SJohn Marinonot one of those letters, the value should be 0 regardless of
2913e4b17023SJohn Marino@var{value}.
2914e4b17023SJohn Marino@end defmac
2915e4b17023SJohn Marino
2916e4b17023SJohn Marino@defmac CONST_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2917e4b17023SJohn MarinoLike @code{CONST_OK_FOR_LETTER_P}, but you also get the constraint
2918e4b17023SJohn Marinostring passed in @var{str}, so that you can use suffixes to distinguish
2919e4b17023SJohn Marinobetween different variants.
2920e4b17023SJohn Marino@end defmac
2921e4b17023SJohn Marino
2922e4b17023SJohn Marino@defmac CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
2923e4b17023SJohn MarinoA C expression that defines the machine-dependent operand constraint
2924e4b17023SJohn Marinoletters that specify particular ranges of @code{const_double} values
2925e4b17023SJohn Marino(@samp{G} or @samp{H}).
2926e4b17023SJohn Marino
2927e4b17023SJohn MarinoIf @var{c} is one of those letters, the expression should check that
2928e4b17023SJohn Marino@var{value}, an RTX of code @code{const_double}, is in the appropriate
2929e4b17023SJohn Marinorange and return 1 if so, 0 otherwise.  If @var{c} is not one of those
2930e4b17023SJohn Marinoletters, the value should be 0 regardless of @var{value}.
2931e4b17023SJohn Marino
2932e4b17023SJohn Marino@code{const_double} is used for all floating-point constants and for
2933e4b17023SJohn Marino@code{DImode} fixed-point constants.  A given letter can accept either
2934e4b17023SJohn Marinoor both kinds of values.  It can use @code{GET_MODE} to distinguish
2935e4b17023SJohn Marinobetween these kinds.
2936e4b17023SJohn Marino@end defmac
2937e4b17023SJohn Marino
2938e4b17023SJohn Marino@defmac CONST_DOUBLE_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str})
2939e4b17023SJohn MarinoLike @code{CONST_DOUBLE_OK_FOR_LETTER_P}, but you also get the constraint
2940e4b17023SJohn Marinostring passed in @var{str}, so that you can use suffixes to distinguish
2941e4b17023SJohn Marinobetween different variants.
2942e4b17023SJohn Marino@end defmac
2943e4b17023SJohn Marino
2944e4b17023SJohn Marino@defmac EXTRA_CONSTRAINT (@var{value}, @var{c})
2945e4b17023SJohn MarinoA C expression that defines the optional machine-dependent constraint
2946e4b17023SJohn Marinoletters that can be used to segregate specific types of operands, usually
2947e4b17023SJohn Marinomemory references, for the target machine.  Any letter that is not
2948e4b17023SJohn Marinoelsewhere defined and not matched by @code{REG_CLASS_FROM_LETTER} /
2949e4b17023SJohn Marino@code{REG_CLASS_FROM_CONSTRAINT}
2950e4b17023SJohn Marinomay be used.  Normally this macro will not be defined.
2951e4b17023SJohn Marino
2952e4b17023SJohn MarinoIf it is required for a particular target machine, it should return 1
2953e4b17023SJohn Marinoif @var{value} corresponds to the operand type represented by the
2954e4b17023SJohn Marinoconstraint letter @var{c}.  If @var{c} is not defined as an extra
2955e4b17023SJohn Marinoconstraint, the value returned should be 0 regardless of @var{value}.
2956e4b17023SJohn Marino
2957e4b17023SJohn MarinoFor example, on the ROMP, load instructions cannot have their output
2958e4b17023SJohn Marinoin r0 if the memory reference contains a symbolic address.  Constraint
2959e4b17023SJohn Marinoletter @samp{Q} is defined as representing a memory address that does
2960e4b17023SJohn Marino@emph{not} contain a symbolic address.  An alternative is specified with
2961e4b17023SJohn Marinoa @samp{Q} constraint on the input and @samp{r} on the output.  The next
2962e4b17023SJohn Marinoalternative specifies @samp{m} on the input and a register class that
2963e4b17023SJohn Marinodoes not include r0 on the output.
2964e4b17023SJohn Marino@end defmac
2965e4b17023SJohn Marino
2966e4b17023SJohn Marino@defmac EXTRA_CONSTRAINT_STR (@var{value}, @var{c}, @var{str})
2967e4b17023SJohn MarinoLike @code{EXTRA_CONSTRAINT}, but you also get the constraint string passed
2968e4b17023SJohn Marinoin @var{str}, so that you can use suffixes to distinguish between different
2969e4b17023SJohn Marinovariants.
2970e4b17023SJohn Marino@end defmac
2971e4b17023SJohn Marino
2972e4b17023SJohn Marino@defmac EXTRA_MEMORY_CONSTRAINT (@var{c}, @var{str})
2973e4b17023SJohn MarinoA C expression that defines the optional machine-dependent constraint
2974e4b17023SJohn Marinoletters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should
2975e4b17023SJohn Marinobe treated like memory constraints by the reload pass.
2976e4b17023SJohn Marino
2977e4b17023SJohn MarinoIt should return 1 if the operand type represented by the constraint
2978e4b17023SJohn Marinoat the start of @var{str}, the first letter of which is the letter @var{c},
2979e4b17023SJohn Marinocomprises a subset of all memory references including
2980e4b17023SJohn Marinoall those whose address is simply a base register.  This allows the reload
2981e4b17023SJohn Marinopass to reload an operand, if it does not directly correspond to the operand
2982e4b17023SJohn Marinotype of @var{c}, by copying its address into a base register.
2983e4b17023SJohn Marino
2984e4b17023SJohn MarinoFor example, on the S/390, some instructions do not accept arbitrary
2985e4b17023SJohn Marinomemory references, but only those that do not make use of an index
2986e4b17023SJohn Marinoregister.  The constraint letter @samp{Q} is defined via
2987e4b17023SJohn Marino@code{EXTRA_CONSTRAINT} as representing a memory address of this type.
2988e4b17023SJohn MarinoIf the letter @samp{Q} is marked as @code{EXTRA_MEMORY_CONSTRAINT},
2989e4b17023SJohn Marinoa @samp{Q} constraint can handle any memory operand, because the
2990e4b17023SJohn Marinoreload pass knows it can be reloaded by copying the memory address
2991e4b17023SJohn Marinointo a base register if required.  This is analogous to the way
2992e4b17023SJohn Marinoan @samp{o} constraint can handle any memory operand.
2993e4b17023SJohn Marino@end defmac
2994e4b17023SJohn Marino
2995e4b17023SJohn Marino@defmac EXTRA_ADDRESS_CONSTRAINT (@var{c}, @var{str})
2996e4b17023SJohn MarinoA C expression that defines the optional machine-dependent constraint
2997e4b17023SJohn Marinoletters, amongst those accepted by @code{EXTRA_CONSTRAINT} /
2998e4b17023SJohn Marino@code{EXTRA_CONSTRAINT_STR}, that should
2999e4b17023SJohn Marinobe treated like address constraints by the reload pass.
3000e4b17023SJohn Marino
3001e4b17023SJohn MarinoIt should return 1 if the operand type represented by the constraint
3002e4b17023SJohn Marinoat the start of @var{str}, which starts with the letter @var{c}, comprises
3003e4b17023SJohn Marinoa subset of all memory addresses including
3004e4b17023SJohn Marinoall those that consist of just a base register.  This allows the reload
3005e4b17023SJohn Marinopass to reload an operand, if it does not directly correspond to the operand
3006e4b17023SJohn Marinotype of @var{str}, by copying it into a base register.
3007e4b17023SJohn Marino
3008e4b17023SJohn MarinoAny constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only
3009e4b17023SJohn Marinobe used with the @code{address_operand} predicate.  It is treated
3010e4b17023SJohn Marinoanalogously to the @samp{p} constraint.
3011e4b17023SJohn Marino@end defmac
3012e4b17023SJohn Marino
3013e4b17023SJohn Marino@node Stack and Calling
3014e4b17023SJohn Marino@section Stack Layout and Calling Conventions
3015e4b17023SJohn Marino@cindex calling conventions
3016e4b17023SJohn Marino
3017e4b17023SJohn Marino@c prevent bad page break with this line
3018e4b17023SJohn MarinoThis describes the stack layout and calling conventions.
3019e4b17023SJohn Marino
3020e4b17023SJohn Marino@menu
3021e4b17023SJohn Marino* Frame Layout::
3022e4b17023SJohn Marino* Exception Handling::
3023e4b17023SJohn Marino* Stack Checking::
3024e4b17023SJohn Marino* Frame Registers::
3025e4b17023SJohn Marino* Elimination::
3026e4b17023SJohn Marino* Stack Arguments::
3027e4b17023SJohn Marino* Register Arguments::
3028e4b17023SJohn Marino* Scalar Return::
3029e4b17023SJohn Marino* Aggregate Return::
3030e4b17023SJohn Marino* Caller Saves::
3031e4b17023SJohn Marino* Function Entry::
3032e4b17023SJohn Marino* Profiling::
3033e4b17023SJohn Marino* Tail Calls::
3034e4b17023SJohn Marino* Stack Smashing Protection::
3035e4b17023SJohn Marino@end menu
3036e4b17023SJohn Marino
3037e4b17023SJohn Marino@node Frame Layout
3038e4b17023SJohn Marino@subsection Basic Stack Layout
3039e4b17023SJohn Marino@cindex stack frame layout
3040e4b17023SJohn Marino@cindex frame layout
3041e4b17023SJohn Marino
3042e4b17023SJohn Marino@c prevent bad page break with this line
3043e4b17023SJohn MarinoHere is the basic stack layout.
3044e4b17023SJohn Marino
3045e4b17023SJohn Marino@defmac STACK_GROWS_DOWNWARD
3046e4b17023SJohn MarinoDefine this macro if pushing a word onto the stack moves the stack
3047e4b17023SJohn Marinopointer to a smaller address.
3048e4b17023SJohn Marino
3049e4b17023SJohn MarinoWhen we say, ``define this macro if @dots{}'', it means that the
3050e4b17023SJohn Marinocompiler checks this macro only with @code{#ifdef} so the precise
3051e4b17023SJohn Marinodefinition used does not matter.
3052e4b17023SJohn Marino@end defmac
3053e4b17023SJohn Marino
3054e4b17023SJohn Marino@defmac STACK_PUSH_CODE
3055e4b17023SJohn MarinoThis macro defines the operation used when something is pushed
3056e4b17023SJohn Marinoon the stack.  In RTL, a push operation will be
3057e4b17023SJohn Marino@code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})}
3058e4b17023SJohn Marino
3059e4b17023SJohn MarinoThe choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC},
3060e4b17023SJohn Marinoand @code{POST_INC}.  Which of these is correct depends on
3061e4b17023SJohn Marinothe stack direction and on whether the stack pointer points
3062e4b17023SJohn Marinoto the last item on the stack or whether it points to the
3063e4b17023SJohn Marinospace for the next item on the stack.
3064e4b17023SJohn Marino
3065e4b17023SJohn MarinoThe default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is
3066e4b17023SJohn Marinodefined, which is almost always right, and @code{PRE_INC} otherwise,
3067e4b17023SJohn Marinowhich is often wrong.
3068e4b17023SJohn Marino@end defmac
3069e4b17023SJohn Marino
3070e4b17023SJohn Marino@defmac FRAME_GROWS_DOWNWARD
3071e4b17023SJohn MarinoDefine this macro to nonzero value if the addresses of local variable slots
3072e4b17023SJohn Marinoare at negative offsets from the frame pointer.
3073e4b17023SJohn Marino@end defmac
3074e4b17023SJohn Marino
3075e4b17023SJohn Marino@defmac ARGS_GROW_DOWNWARD
3076e4b17023SJohn MarinoDefine this macro if successive arguments to a function occupy decreasing
3077e4b17023SJohn Marinoaddresses on the stack.
3078e4b17023SJohn Marino@end defmac
3079e4b17023SJohn Marino
3080e4b17023SJohn Marino@defmac STARTING_FRAME_OFFSET
3081e4b17023SJohn MarinoOffset from the frame pointer to the first local variable slot to be allocated.
3082e4b17023SJohn Marino
3083e4b17023SJohn MarinoIf @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
3084e4b17023SJohn Marinosubtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
3085e4b17023SJohn MarinoOtherwise, it is found by adding the length of the first slot to the
3086e4b17023SJohn Marinovalue @code{STARTING_FRAME_OFFSET}.
3087e4b17023SJohn Marino@c i'm not sure if the above is still correct.. had to change it to get
3088e4b17023SJohn Marino@c rid of an overfull.  --mew 2feb93
3089e4b17023SJohn Marino@end defmac
3090e4b17023SJohn Marino
3091e4b17023SJohn Marino@defmac STACK_ALIGNMENT_NEEDED
3092e4b17023SJohn MarinoDefine to zero to disable final alignment of the stack during reload.
3093e4b17023SJohn MarinoThe nonzero default for this macro is suitable for most ports.
3094e4b17023SJohn Marino
3095e4b17023SJohn MarinoOn ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
3096e4b17023SJohn Marinois a register save block following the local block that doesn't require
3097e4b17023SJohn Marinoalignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
3098e4b17023SJohn Marinostack alignment and do it in the backend.
3099e4b17023SJohn Marino@end defmac
3100e4b17023SJohn Marino
3101e4b17023SJohn Marino@defmac STACK_POINTER_OFFSET
3102e4b17023SJohn MarinoOffset from the stack pointer register to the first location at which
3103e4b17023SJohn Marinooutgoing arguments are placed.  If not specified, the default value of
3104e4b17023SJohn Marinozero is used.  This is the proper value for most machines.
3105e4b17023SJohn Marino
3106e4b17023SJohn MarinoIf @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
3107e4b17023SJohn Marinothe first location at which outgoing arguments are placed.
3108e4b17023SJohn Marino@end defmac
3109e4b17023SJohn Marino
3110e4b17023SJohn Marino@defmac FIRST_PARM_OFFSET (@var{fundecl})
3111e4b17023SJohn MarinoOffset from the argument pointer register to the first argument's
3112e4b17023SJohn Marinoaddress.  On some machines it may depend on the data type of the
3113e4b17023SJohn Marinofunction.
3114e4b17023SJohn Marino
3115e4b17023SJohn MarinoIf @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
3116e4b17023SJohn Marinothe first argument's address.
3117e4b17023SJohn Marino@end defmac
3118e4b17023SJohn Marino
3119e4b17023SJohn Marino@defmac STACK_DYNAMIC_OFFSET (@var{fundecl})
3120e4b17023SJohn MarinoOffset from the stack pointer register to an item dynamically allocated
3121e4b17023SJohn Marinoon the stack, e.g., by @code{alloca}.
3122e4b17023SJohn Marino
3123e4b17023SJohn MarinoThe default value for this macro is @code{STACK_POINTER_OFFSET} plus the
3124e4b17023SJohn Marinolength of the outgoing arguments.  The default is correct for most
3125e4b17023SJohn Marinomachines.  See @file{function.c} for details.
3126e4b17023SJohn Marino@end defmac
3127e4b17023SJohn Marino
3128e4b17023SJohn Marino@defmac INITIAL_FRAME_ADDRESS_RTX
3129e4b17023SJohn MarinoA C expression whose value is RTL representing the address of the initial
3130e4b17023SJohn Marinostack frame. This address is passed to @code{RETURN_ADDR_RTX} and
3131e4b17023SJohn Marino@code{DYNAMIC_CHAIN_ADDRESS}.  If you don't define this macro, a reasonable
3132e4b17023SJohn Marinodefault value will be used.  Define this macro in order to make frame pointer
3133e4b17023SJohn Marinoelimination work in the presence of @code{__builtin_frame_address (count)} and
3134e4b17023SJohn Marino@code{__builtin_return_address (count)} for @code{count} not equal to zero.
3135e4b17023SJohn Marino@end defmac
3136e4b17023SJohn Marino
3137e4b17023SJohn Marino@defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
3138e4b17023SJohn MarinoA C expression whose value is RTL representing the address in a stack
3139e4b17023SJohn Marinoframe where the pointer to the caller's frame is stored.  Assume that
3140e4b17023SJohn Marino@var{frameaddr} is an RTL expression for the address of the stack frame
3141e4b17023SJohn Marinoitself.
3142e4b17023SJohn Marino
3143e4b17023SJohn MarinoIf you don't define this macro, the default is to return the value
3144e4b17023SJohn Marinoof @var{frameaddr}---that is, the stack frame address is also the
3145e4b17023SJohn Marinoaddress of the stack word that points to the previous frame.
3146e4b17023SJohn Marino@end defmac
3147e4b17023SJohn Marino
3148e4b17023SJohn Marino@defmac SETUP_FRAME_ADDRESSES
3149e4b17023SJohn MarinoIf defined, a C expression that produces the machine-specific code to
3150e4b17023SJohn Marinosetup the stack so that arbitrary frames can be accessed.  For example,
3151e4b17023SJohn Marinoon the SPARC, we must flush all of the register windows to the stack
3152e4b17023SJohn Marinobefore we can access arbitrary stack frames.  You will seldom need to
3153e4b17023SJohn Marinodefine this macro.
3154e4b17023SJohn Marino@end defmac
3155e4b17023SJohn Marino
3156e4b17023SJohn Marino@hook TARGET_BUILTIN_SETJMP_FRAME_VALUE
3157e4b17023SJohn MarinoThis target hook should return an rtx that is used to store
3158e4b17023SJohn Marinothe address of the current frame into the built in @code{setjmp} buffer.
3159e4b17023SJohn MarinoThe default value, @code{virtual_stack_vars_rtx}, is correct for most
3160e4b17023SJohn Marinomachines.  One reason you may need to define this target hook is if
3161e4b17023SJohn Marino@code{hard_frame_pointer_rtx} is the appropriate value on your machine.
3162e4b17023SJohn Marino@end deftypefn
3163e4b17023SJohn Marino
3164e4b17023SJohn Marino@defmac FRAME_ADDR_RTX (@var{frameaddr})
3165e4b17023SJohn MarinoA C expression whose value is RTL representing the value of the frame
3166e4b17023SJohn Marinoaddress for the current frame.  @var{frameaddr} is the frame pointer
3167e4b17023SJohn Marinoof the current frame.  This is used for __builtin_frame_address.
3168e4b17023SJohn MarinoYou need only define this macro if the frame address is not the same
3169e4b17023SJohn Marinoas the frame pointer.  Most machines do not need to define it.
3170e4b17023SJohn Marino@end defmac
3171e4b17023SJohn Marino
3172e4b17023SJohn Marino@defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr})
3173e4b17023SJohn MarinoA C expression whose value is RTL representing the value of the return
3174e4b17023SJohn Marinoaddress for the frame @var{count} steps up from the current frame, after
3175e4b17023SJohn Marinothe prologue.  @var{frameaddr} is the frame pointer of the @var{count}
3176e4b17023SJohn Marinoframe, or the frame pointer of the @var{count} @minus{} 1 frame if
3177e4b17023SJohn Marino@code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined.
3178e4b17023SJohn Marino
3179e4b17023SJohn MarinoThe value of the expression must always be the correct address when
3180e4b17023SJohn Marino@var{count} is zero, but may be @code{NULL_RTX} if there is no way to
3181e4b17023SJohn Marinodetermine the return address of other frames.
3182e4b17023SJohn Marino@end defmac
3183e4b17023SJohn Marino
3184e4b17023SJohn Marino@defmac RETURN_ADDR_IN_PREVIOUS_FRAME
3185e4b17023SJohn MarinoDefine this if the return address of a particular stack frame is accessed
3186e4b17023SJohn Marinofrom the frame pointer of the previous stack frame.
3187e4b17023SJohn Marino@end defmac
3188e4b17023SJohn Marino
3189e4b17023SJohn Marino@defmac INCOMING_RETURN_ADDR_RTX
3190e4b17023SJohn MarinoA C expression whose value is RTL representing the location of the
3191e4b17023SJohn Marinoincoming return address at the beginning of any function, before the
3192e4b17023SJohn Marinoprologue.  This RTL is either a @code{REG}, indicating that the return
3193e4b17023SJohn Marinovalue is saved in @samp{REG}, or a @code{MEM} representing a location in
3194e4b17023SJohn Marinothe stack.
3195e4b17023SJohn Marino
3196e4b17023SJohn MarinoYou only need to define this macro if you want to support call frame
3197e4b17023SJohn Marinodebugging information like that provided by DWARF 2.
3198e4b17023SJohn Marino
3199e4b17023SJohn MarinoIf this RTL is a @code{REG}, you should also define
3200e4b17023SJohn Marino@code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}.
3201e4b17023SJohn Marino@end defmac
3202e4b17023SJohn Marino
3203e4b17023SJohn Marino@defmac DWARF_ALT_FRAME_RETURN_COLUMN
3204e4b17023SJohn MarinoA C expression whose value is an integer giving a DWARF 2 column
3205e4b17023SJohn Marinonumber that may be used as an alternative return column.  The column
3206e4b17023SJohn Marinomust not correspond to any gcc hard register (that is, it must not
3207e4b17023SJohn Marinobe in the range of @code{DWARF_FRAME_REGNUM}).
3208e4b17023SJohn Marino
3209e4b17023SJohn MarinoThis macro can be useful if @code{DWARF_FRAME_RETURN_COLUMN} is set to a
3210e4b17023SJohn Marinogeneral register, but an alternative column needs to be used for signal
3211e4b17023SJohn Marinoframes.  Some targets have also used different frame return columns
3212e4b17023SJohn Marinoover time.
3213e4b17023SJohn Marino@end defmac
3214e4b17023SJohn Marino
3215e4b17023SJohn Marino@defmac DWARF_ZERO_REG
3216e4b17023SJohn MarinoA C expression whose value is an integer giving a DWARF 2 register
3217e4b17023SJohn Marinonumber that is considered to always have the value zero.  This should
3218e4b17023SJohn Marinoonly be defined if the target has an architected zero register, and
3219e4b17023SJohn Marinosomeone decided it was a good idea to use that register number to
3220e4b17023SJohn Marinoterminate the stack backtrace.  New ports should avoid this.
3221e4b17023SJohn Marino@end defmac
3222e4b17023SJohn Marino
3223e4b17023SJohn Marino@hook TARGET_DWARF_HANDLE_FRAME_UNSPEC
3224e4b17023SJohn MarinoThis target hook allows the backend to emit frame-related insns that
3225e4b17023SJohn Marinocontain UNSPECs or UNSPEC_VOLATILEs.  The DWARF 2 call frame debugging
3226e4b17023SJohn Marinoinfo engine will invoke it on insns of the form
3227e4b17023SJohn Marino@smallexample
3228e4b17023SJohn Marino(set (reg) (unspec [@dots{}] UNSPEC_INDEX))
3229e4b17023SJohn Marino@end smallexample
3230e4b17023SJohn Marinoand
3231e4b17023SJohn Marino@smallexample
3232e4b17023SJohn Marino(set (reg) (unspec_volatile [@dots{}] UNSPECV_INDEX)).
3233e4b17023SJohn Marino@end smallexample
3234e4b17023SJohn Marinoto let the backend emit the call frame instructions.  @var{label} is
3235e4b17023SJohn Marinothe CFI label attached to the insn, @var{pattern} is the pattern of
3236e4b17023SJohn Marinothe insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}.
3237e4b17023SJohn Marino@end deftypefn
3238e4b17023SJohn Marino
3239e4b17023SJohn Marino@defmac INCOMING_FRAME_SP_OFFSET
3240e4b17023SJohn MarinoA C expression whose value is an integer giving the offset, in bytes,
3241e4b17023SJohn Marinofrom the value of the stack pointer register to the top of the stack
3242e4b17023SJohn Marinoframe at the beginning of any function, before the prologue.  The top of
3243e4b17023SJohn Marinothe frame is defined to be the value of the stack pointer in the
3244e4b17023SJohn Marinoprevious frame, just before the call instruction.
3245e4b17023SJohn Marino
3246e4b17023SJohn MarinoYou only need to define this macro if you want to support call frame
3247e4b17023SJohn Marinodebugging information like that provided by DWARF 2.
3248e4b17023SJohn Marino@end defmac
3249e4b17023SJohn Marino
3250e4b17023SJohn Marino@defmac ARG_POINTER_CFA_OFFSET (@var{fundecl})
3251e4b17023SJohn MarinoA C expression whose value is an integer giving the offset, in bytes,
3252e4b17023SJohn Marinofrom the argument pointer to the canonical frame address (cfa).  The
3253e4b17023SJohn Marinofinal value should coincide with that calculated by
3254e4b17023SJohn Marino@code{INCOMING_FRAME_SP_OFFSET}.  Which is unfortunately not usable
3255e4b17023SJohn Marinoduring virtual register instantiation.
3256e4b17023SJohn Marino
3257e4b17023SJohn MarinoThe default value for this macro is
3258e4b17023SJohn Marino@code{FIRST_PARM_OFFSET (fundecl) + crtl->args.pretend_args_size},
3259e4b17023SJohn Marinowhich is correct for most machines; in general, the arguments are found
3260e4b17023SJohn Marinoimmediately before the stack frame.  Note that this is not the case on
3261e4b17023SJohn Marinosome targets that save registers into the caller's frame, such as SPARC
3262e4b17023SJohn Marinoand rs6000, and so such targets need to define this macro.
3263e4b17023SJohn Marino
3264e4b17023SJohn MarinoYou only need to define this macro if the default is incorrect, and you
3265e4b17023SJohn Marinowant to support call frame debugging information like that provided by
3266e4b17023SJohn MarinoDWARF 2.
3267e4b17023SJohn Marino@end defmac
3268e4b17023SJohn Marino
3269e4b17023SJohn Marino@defmac FRAME_POINTER_CFA_OFFSET (@var{fundecl})
3270e4b17023SJohn MarinoIf defined, a C expression whose value is an integer giving the offset
3271e4b17023SJohn Marinoin bytes from the frame pointer to the canonical frame address (cfa).
3272e4b17023SJohn MarinoThe final value should coincide with that calculated by
3273e4b17023SJohn Marino@code{INCOMING_FRAME_SP_OFFSET}.
3274e4b17023SJohn Marino
3275e4b17023SJohn MarinoNormally the CFA is calculated as an offset from the argument pointer,
3276e4b17023SJohn Marinovia @code{ARG_POINTER_CFA_OFFSET}, but if the argument pointer is
3277e4b17023SJohn Marinovariable due to the ABI, this may not be possible.  If this macro is
3278e4b17023SJohn Marinodefined, it implies that the virtual register instantiation should be
3279e4b17023SJohn Marinobased on the frame pointer instead of the argument pointer.  Only one
3280e4b17023SJohn Marinoof @code{FRAME_POINTER_CFA_OFFSET} and @code{ARG_POINTER_CFA_OFFSET}
3281e4b17023SJohn Marinoshould be defined.
3282e4b17023SJohn Marino@end defmac
3283e4b17023SJohn Marino
3284e4b17023SJohn Marino@defmac CFA_FRAME_BASE_OFFSET (@var{fundecl})
3285e4b17023SJohn MarinoIf defined, a C expression whose value is an integer giving the offset
3286e4b17023SJohn Marinoin bytes from the canonical frame address (cfa) to the frame base used
3287e4b17023SJohn Marinoin DWARF 2 debug information.  The default is zero.  A different value
3288e4b17023SJohn Marinomay reduce the size of debug information on some ports.
3289e4b17023SJohn Marino@end defmac
3290e4b17023SJohn Marino
3291e4b17023SJohn Marino@node Exception Handling
3292e4b17023SJohn Marino@subsection Exception Handling Support
3293e4b17023SJohn Marino@cindex exception handling
3294e4b17023SJohn Marino
3295e4b17023SJohn Marino@defmac EH_RETURN_DATA_REGNO (@var{N})
3296e4b17023SJohn MarinoA C expression whose value is the @var{N}th register number used for
3297e4b17023SJohn Marinodata by exception handlers, or @code{INVALID_REGNUM} if fewer than
3298e4b17023SJohn Marino@var{N} registers are usable.
3299e4b17023SJohn Marino
3300e4b17023SJohn MarinoThe exception handling library routines communicate with the exception
3301e4b17023SJohn Marinohandlers via a set of agreed upon registers.  Ideally these registers
3302e4b17023SJohn Marinoshould be call-clobbered; it is possible to use call-saved registers,
3303e4b17023SJohn Marinobut may negatively impact code size.  The target must support at least
3304e4b17023SJohn Marino2 data registers, but should define 4 if there are enough free registers.
3305e4b17023SJohn Marino
3306e4b17023SJohn MarinoYou must define this macro if you want to support call frame exception
3307e4b17023SJohn Marinohandling like that provided by DWARF 2.
3308e4b17023SJohn Marino@end defmac
3309e4b17023SJohn Marino
3310e4b17023SJohn Marino@defmac EH_RETURN_STACKADJ_RTX
3311e4b17023SJohn MarinoA C expression whose value is RTL representing a location in which
3312e4b17023SJohn Marinoto store a stack adjustment to be applied before function return.
3313e4b17023SJohn MarinoThis is used to unwind the stack to an exception handler's call frame.
3314e4b17023SJohn MarinoIt will be assigned zero on code paths that return normally.
3315e4b17023SJohn Marino
3316e4b17023SJohn MarinoTypically this is a call-clobbered hard register that is otherwise
3317e4b17023SJohn Marinountouched by the epilogue, but could also be a stack slot.
3318e4b17023SJohn Marino
3319e4b17023SJohn MarinoDo not define this macro if the stack pointer is saved and restored
3320e4b17023SJohn Marinoby the regular prolog and epilog code in the call frame itself; in
3321e4b17023SJohn Marinothis case, the exception handling library routines will update the
3322e4b17023SJohn Marinostack location to be restored in place.  Otherwise, you must define
3323e4b17023SJohn Marinothis macro if you want to support call frame exception handling like
3324e4b17023SJohn Marinothat provided by DWARF 2.
3325e4b17023SJohn Marino@end defmac
3326e4b17023SJohn Marino
3327e4b17023SJohn Marino@defmac EH_RETURN_HANDLER_RTX
3328e4b17023SJohn MarinoA C expression whose value is RTL representing a location in which
3329e4b17023SJohn Marinoto store the address of an exception handler to which we should
3330e4b17023SJohn Marinoreturn.  It will not be assigned on code paths that return normally.
3331e4b17023SJohn Marino
3332e4b17023SJohn MarinoTypically this is the location in the call frame at which the normal
3333e4b17023SJohn Marinoreturn address is stored.  For targets that return by popping an
3334e4b17023SJohn Marinoaddress off the stack, this might be a memory address just below
3335e4b17023SJohn Marinothe @emph{target} call frame rather than inside the current call
3336e4b17023SJohn Marinoframe.  If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
3337e4b17023SJohn Marinobeen assigned, so it may be used to calculate the location of the
3338e4b17023SJohn Marinotarget call frame.
3339e4b17023SJohn Marino
3340e4b17023SJohn MarinoSome targets have more complex requirements than storing to an
3341e4b17023SJohn Marinoaddress calculable during initial code generation.  In that case
3342e4b17023SJohn Marinothe @code{eh_return} instruction pattern should be used instead.
3343e4b17023SJohn Marino
3344e4b17023SJohn MarinoIf you want to support call frame exception handling, you must
3345e4b17023SJohn Marinodefine either this macro or the @code{eh_return} instruction pattern.
3346e4b17023SJohn Marino@end defmac
3347e4b17023SJohn Marino
3348e4b17023SJohn Marino@defmac RETURN_ADDR_OFFSET
3349e4b17023SJohn MarinoIf defined, an integer-valued C expression for which rtl will be generated
3350e4b17023SJohn Marinoto add it to the exception handler address before it is searched in the
3351e4b17023SJohn Marinoexception handling tables, and to subtract it again from the address before
3352e4b17023SJohn Marinousing it to return to the exception handler.
3353e4b17023SJohn Marino@end defmac
3354e4b17023SJohn Marino
3355e4b17023SJohn Marino@defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global})
3356e4b17023SJohn MarinoThis macro chooses the encoding of pointers embedded in the exception
3357e4b17023SJohn Marinohandling sections.  If at all possible, this should be defined such
3358e4b17023SJohn Marinothat the exception handling section will not require dynamic relocations,
3359e4b17023SJohn Marinoand so may be read-only.
3360e4b17023SJohn Marino
3361e4b17023SJohn Marino@var{code} is 0 for data, 1 for code labels, 2 for function pointers.
3362e4b17023SJohn Marino@var{global} is true if the symbol may be affected by dynamic relocations.
3363e4b17023SJohn MarinoThe macro should return a combination of the @code{DW_EH_PE_*} defines
3364e4b17023SJohn Marinoas found in @file{dwarf2.h}.
3365e4b17023SJohn Marino
3366e4b17023SJohn MarinoIf this macro is not defined, pointers will not be encoded but
3367e4b17023SJohn Marinorepresented directly.
3368e4b17023SJohn Marino@end defmac
3369e4b17023SJohn Marino
3370e4b17023SJohn Marino@defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done})
3371e4b17023SJohn MarinoThis macro allows the target to emit whatever special magic is required
3372e4b17023SJohn Marinoto represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}.
3373e4b17023SJohn MarinoGeneric code takes care of pc-relative and indirect encodings; this must
3374e4b17023SJohn Marinobe defined if the target uses text-relative or data-relative encodings.
3375e4b17023SJohn Marino
3376e4b17023SJohn MarinoThis is a C statement that branches to @var{done} if the format was
3377e4b17023SJohn Marinohandled.  @var{encoding} is the format chosen, @var{size} is the number
3378e4b17023SJohn Marinoof bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF}
3379e4b17023SJohn Marinoto be emitted.
3380e4b17023SJohn Marino@end defmac
3381e4b17023SJohn Marino
3382e4b17023SJohn Marino@defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs})
3383e4b17023SJohn MarinoThis macro allows the target to add CPU and operating system specific
3384e4b17023SJohn Marinocode to the call-frame unwinder for use when there is no unwind data
3385e4b17023SJohn Marinoavailable.  The most common reason to implement this macro is to unwind
3386e4b17023SJohn Marinothrough signal frames.
3387e4b17023SJohn Marino
3388e4b17023SJohn MarinoThis macro is called from @code{uw_frame_state_for} in
3389e4b17023SJohn Marino@file{unwind-dw2.c}, @file{unwind-dw2-xtensa.c} and
3390e4b17023SJohn Marino@file{unwind-ia64.c}.  @var{context} is an @code{_Unwind_Context};
3391e4b17023SJohn Marino@var{fs} is an @code{_Unwind_FrameState}.  Examine @code{context->ra}
3392e4b17023SJohn Marinofor the address of the code being executed and @code{context->cfa} for
3393e4b17023SJohn Marinothe stack pointer value.  If the frame can be decoded, the register
3394e4b17023SJohn Marinosave addresses should be updated in @var{fs} and the macro should
3395e4b17023SJohn Marinoevaluate to @code{_URC_NO_REASON}.  If the frame cannot be decoded,
3396e4b17023SJohn Marinothe macro should evaluate to @code{_URC_END_OF_STACK}.
3397e4b17023SJohn Marino
3398e4b17023SJohn MarinoFor proper signal handling in Java this macro is accompanied by
3399e4b17023SJohn Marino@code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers.
3400e4b17023SJohn Marino@end defmac
3401e4b17023SJohn Marino
3402e4b17023SJohn Marino@defmac MD_HANDLE_UNWABI (@var{context}, @var{fs})
3403e4b17023SJohn MarinoThis macro allows the target to add operating system specific code to the
3404e4b17023SJohn Marinocall-frame unwinder to handle the IA-64 @code{.unwabi} unwinding directive,
3405e4b17023SJohn Marinousually used for signal or interrupt frames.
3406e4b17023SJohn Marino
3407e4b17023SJohn MarinoThis macro is called from @code{uw_update_context} in @file{unwind-ia64.c}.
3408e4b17023SJohn Marino@var{context} is an @code{_Unwind_Context};
3409e4b17023SJohn Marino@var{fs} is an @code{_Unwind_FrameState}.  Examine @code{fs->unwabi}
3410e4b17023SJohn Marinofor the abi and context in the @code{.unwabi} directive.  If the
3411e4b17023SJohn Marino@code{.unwabi} directive can be handled, the register save addresses should
3412e4b17023SJohn Marinobe updated in @var{fs}.
3413e4b17023SJohn Marino@end defmac
3414e4b17023SJohn Marino
3415e4b17023SJohn Marino@defmac TARGET_USES_WEAK_UNWIND_INFO
3416e4b17023SJohn MarinoA C expression that evaluates to true if the target requires unwind
3417e4b17023SJohn Marinoinfo to be given comdat linkage.  Define it to be @code{1} if comdat
3418e4b17023SJohn Marinolinkage is necessary.  The default is @code{0}.
3419e4b17023SJohn Marino@end defmac
3420e4b17023SJohn Marino
3421e4b17023SJohn Marino@node Stack Checking
3422e4b17023SJohn Marino@subsection Specifying How Stack Checking is Done
3423e4b17023SJohn Marino
3424e4b17023SJohn MarinoGCC will check that stack references are within the boundaries of the
3425e4b17023SJohn Marinostack, if the option @option{-fstack-check} is specified, in one of
3426e4b17023SJohn Marinothree ways:
3427e4b17023SJohn Marino
3428e4b17023SJohn Marino@enumerate
3429e4b17023SJohn Marino@item
3430e4b17023SJohn MarinoIf the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC
3431e4b17023SJohn Marinowill assume that you have arranged for full stack checking to be done
3432e4b17023SJohn Marinoat appropriate places in the configuration files.  GCC will not do
3433e4b17023SJohn Marinoother special processing.
3434e4b17023SJohn Marino
3435e4b17023SJohn Marino@item
3436e4b17023SJohn MarinoIf @code{STACK_CHECK_BUILTIN} is zero and the value of the
3437e4b17023SJohn Marino@code{STACK_CHECK_STATIC_BUILTIN} macro is nonzero, GCC will assume
3438e4b17023SJohn Marinothat you have arranged for static stack checking (checking of the
3439e4b17023SJohn Marinostatic stack frame of functions) to be done at appropriate places
3440e4b17023SJohn Marinoin the configuration files.  GCC will only emit code to do dynamic
3441e4b17023SJohn Marinostack checking (checking on dynamic stack allocations) using the third
3442e4b17023SJohn Marinoapproach below.
3443e4b17023SJohn Marino
3444e4b17023SJohn Marino@item
3445e4b17023SJohn MarinoIf neither of the above are true, GCC will generate code to periodically
3446e4b17023SJohn Marino``probe'' the stack pointer using the values of the macros defined below.
3447e4b17023SJohn Marino@end enumerate
3448e4b17023SJohn Marino
3449e4b17023SJohn MarinoIf neither STACK_CHECK_BUILTIN nor STACK_CHECK_STATIC_BUILTIN is defined,
3450e4b17023SJohn MarinoGCC will change its allocation strategy for large objects if the option
3451e4b17023SJohn Marino@option{-fstack-check} is specified: they will always be allocated
3452e4b17023SJohn Marinodynamically if their size exceeds @code{STACK_CHECK_MAX_VAR_SIZE} bytes.
3453e4b17023SJohn Marino
3454e4b17023SJohn Marino@defmac STACK_CHECK_BUILTIN
3455e4b17023SJohn MarinoA nonzero value if stack checking is done by the configuration files in a
3456e4b17023SJohn Marinomachine-dependent manner.  You should define this macro if stack checking
3457e4b17023SJohn Marinois required by the ABI of your machine or if you would like to do stack
3458e4b17023SJohn Marinochecking in some more efficient way than the generic approach.  The default
3459e4b17023SJohn Marinovalue of this macro is zero.
3460e4b17023SJohn Marino@end defmac
3461e4b17023SJohn Marino
3462e4b17023SJohn Marino@defmac STACK_CHECK_STATIC_BUILTIN
3463e4b17023SJohn MarinoA nonzero value if static stack checking is done by the configuration files
3464e4b17023SJohn Marinoin a machine-dependent manner.  You should define this macro if you would
3465e4b17023SJohn Marinolike to do static stack checking in some more efficient way than the generic
3466e4b17023SJohn Marinoapproach.  The default value of this macro is zero.
3467e4b17023SJohn Marino@end defmac
3468e4b17023SJohn Marino
3469e4b17023SJohn Marino@defmac STACK_CHECK_PROBE_INTERVAL_EXP
3470e4b17023SJohn MarinoAn integer specifying the interval at which GCC must generate stack probe
3471e4b17023SJohn Marinoinstructions, defined as 2 raised to this integer.  You will normally
3472e4b17023SJohn Marinodefine this macro so that the interval be no larger than the size of
3473e4b17023SJohn Marinothe ``guard pages'' at the end of a stack area.  The default value
3474e4b17023SJohn Marinoof 12 (4096-byte interval) is suitable for most systems.
3475e4b17023SJohn Marino@end defmac
3476e4b17023SJohn Marino
3477e4b17023SJohn Marino@defmac STACK_CHECK_MOVING_SP
3478e4b17023SJohn MarinoAn integer which is nonzero if GCC should move the stack pointer page by page
3479e4b17023SJohn Marinowhen doing probes.  This can be necessary on systems where the stack pointer
3480e4b17023SJohn Marinocontains the bottom address of the memory area accessible to the executing
3481e4b17023SJohn Marinothread at any point in time.  In this situation an alternate signal stack
3482e4b17023SJohn Marinois required in order to be able to recover from a stack overflow.  The
3483e4b17023SJohn Marinodefault value of this macro is zero.
3484e4b17023SJohn Marino@end defmac
3485e4b17023SJohn Marino
3486e4b17023SJohn Marino@defmac STACK_CHECK_PROTECT
3487e4b17023SJohn MarinoThe number of bytes of stack needed to recover from a stack overflow, for
3488e4b17023SJohn Marinolanguages where such a recovery is supported.  The default value of 75 words
3489e4b17023SJohn Marinowith the @code{setjmp}/@code{longjmp}-based exception handling mechanism and
3490e4b17023SJohn Marino8192 bytes with other exception handling mechanisms should be adequate for
3491e4b17023SJohn Marinomost machines.
3492e4b17023SJohn Marino@end defmac
3493e4b17023SJohn Marino
3494e4b17023SJohn MarinoThe following macros are relevant only if neither STACK_CHECK_BUILTIN
3495e4b17023SJohn Marinonor STACK_CHECK_STATIC_BUILTIN is defined; you can omit them altogether
3496e4b17023SJohn Marinoin the opposite case.
3497e4b17023SJohn Marino
3498e4b17023SJohn Marino@defmac STACK_CHECK_MAX_FRAME_SIZE
3499e4b17023SJohn MarinoThe maximum size of a stack frame, in bytes.  GCC will generate probe
3500e4b17023SJohn Marinoinstructions in non-leaf functions to ensure at least this many bytes of
3501e4b17023SJohn Marinostack are available.  If a stack frame is larger than this size, stack
3502e4b17023SJohn Marinochecking will not be reliable and GCC will issue a warning.  The
3503e4b17023SJohn Marinodefault is chosen so that GCC only generates one instruction on most
3504e4b17023SJohn Marinosystems.  You should normally not change the default value of this macro.
3505e4b17023SJohn Marino@end defmac
3506e4b17023SJohn Marino
3507e4b17023SJohn Marino@defmac STACK_CHECK_FIXED_FRAME_SIZE
3508e4b17023SJohn MarinoGCC uses this value to generate the above warning message.  It
3509e4b17023SJohn Marinorepresents the amount of fixed frame used by a function, not including
3510e4b17023SJohn Marinospace for any callee-saved registers, temporaries and user variables.
3511e4b17023SJohn MarinoYou need only specify an upper bound for this amount and will normally
3512e4b17023SJohn Marinouse the default of four words.
3513e4b17023SJohn Marino@end defmac
3514e4b17023SJohn Marino
3515e4b17023SJohn Marino@defmac STACK_CHECK_MAX_VAR_SIZE
3516e4b17023SJohn MarinoThe maximum size, in bytes, of an object that GCC will place in the
3517e4b17023SJohn Marinofixed area of the stack frame when the user specifies
3518e4b17023SJohn Marino@option{-fstack-check}.
3519e4b17023SJohn MarinoGCC computed the default from the values of the above macros and you will
3520e4b17023SJohn Marinonormally not need to override that default.
3521e4b17023SJohn Marino@end defmac
3522e4b17023SJohn Marino
3523e4b17023SJohn Marino@need 2000
3524e4b17023SJohn Marino@node Frame Registers
3525e4b17023SJohn Marino@subsection Registers That Address the Stack Frame
3526e4b17023SJohn Marino
3527e4b17023SJohn Marino@c prevent bad page break with this line
3528e4b17023SJohn MarinoThis discusses registers that address the stack frame.
3529e4b17023SJohn Marino
3530e4b17023SJohn Marino@defmac STACK_POINTER_REGNUM
3531e4b17023SJohn MarinoThe register number of the stack pointer register, which must also be a
3532e4b17023SJohn Marinofixed register according to @code{FIXED_REGISTERS}.  On most machines,
3533e4b17023SJohn Marinothe hardware determines which register this is.
3534e4b17023SJohn Marino@end defmac
3535e4b17023SJohn Marino
3536e4b17023SJohn Marino@defmac FRAME_POINTER_REGNUM
3537e4b17023SJohn MarinoThe register number of the frame pointer register, which is used to
3538e4b17023SJohn Marinoaccess automatic variables in the stack frame.  On some machines, the
3539e4b17023SJohn Marinohardware determines which register this is.  On other machines, you can
3540e4b17023SJohn Marinochoose any register you wish for this purpose.
3541e4b17023SJohn Marino@end defmac
3542e4b17023SJohn Marino
3543e4b17023SJohn Marino@defmac HARD_FRAME_POINTER_REGNUM
3544e4b17023SJohn MarinoOn some machines the offset between the frame pointer and starting
3545e4b17023SJohn Marinooffset of the automatic variables is not known until after register
3546e4b17023SJohn Marinoallocation has been done (for example, because the saved registers are
3547e4b17023SJohn Marinobetween these two locations).  On those machines, define
3548e4b17023SJohn Marino@code{FRAME_POINTER_REGNUM} the number of a special, fixed register to
3549e4b17023SJohn Marinobe used internally until the offset is known, and define
3550e4b17023SJohn Marino@code{HARD_FRAME_POINTER_REGNUM} to be the actual hard register number
3551e4b17023SJohn Marinoused for the frame pointer.
3552e4b17023SJohn Marino
3553e4b17023SJohn MarinoYou should define this macro only in the very rare circumstances when it
3554e4b17023SJohn Marinois not possible to calculate the offset between the frame pointer and
3555e4b17023SJohn Marinothe automatic variables until after register allocation has been
3556e4b17023SJohn Marinocompleted.  When this macro is defined, you must also indicate in your
3557e4b17023SJohn Marinodefinition of @code{ELIMINABLE_REGS} how to eliminate
3558e4b17023SJohn Marino@code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM}
3559e4b17023SJohn Marinoor @code{STACK_POINTER_REGNUM}.
3560e4b17023SJohn Marino
3561e4b17023SJohn MarinoDo not define this macro if it would be the same as
3562e4b17023SJohn Marino@code{FRAME_POINTER_REGNUM}.
3563e4b17023SJohn Marino@end defmac
3564e4b17023SJohn Marino
3565e4b17023SJohn Marino@defmac ARG_POINTER_REGNUM
3566e4b17023SJohn MarinoThe register number of the arg pointer register, which is used to access
3567e4b17023SJohn Marinothe function's argument list.  On some machines, this is the same as the
3568e4b17023SJohn Marinoframe pointer register.  On some machines, the hardware determines which
3569e4b17023SJohn Marinoregister this is.  On other machines, you can choose any register you
3570e4b17023SJohn Marinowish for this purpose.  If this is not the same register as the frame
3571e4b17023SJohn Marinopointer register, then you must mark it as a fixed register according to
3572e4b17023SJohn Marino@code{FIXED_REGISTERS}, or arrange to be able to eliminate it
3573e4b17023SJohn Marino(@pxref{Elimination}).
3574e4b17023SJohn Marino@end defmac
3575e4b17023SJohn Marino
3576e4b17023SJohn Marino@defmac HARD_FRAME_POINTER_IS_FRAME_POINTER
3577e4b17023SJohn MarinoDefine this to a preprocessor constant that is nonzero if
3578e4b17023SJohn Marino@code{hard_frame_pointer_rtx} and @code{frame_pointer_rtx} should be
3579e4b17023SJohn Marinothe same.  The default definition is @samp{(HARD_FRAME_POINTER_REGNUM
3580e4b17023SJohn Marino== FRAME_POINTER_REGNUM)}; you only need to define this macro if that
3581e4b17023SJohn Marinodefinition is not suitable for use in preprocessor conditionals.
3582e4b17023SJohn Marino@end defmac
3583e4b17023SJohn Marino
3584e4b17023SJohn Marino@defmac HARD_FRAME_POINTER_IS_ARG_POINTER
3585e4b17023SJohn MarinoDefine this to a preprocessor constant that is nonzero if
3586e4b17023SJohn Marino@code{hard_frame_pointer_rtx} and @code{arg_pointer_rtx} should be the
3587e4b17023SJohn Marinosame.  The default definition is @samp{(HARD_FRAME_POINTER_REGNUM ==
3588e4b17023SJohn MarinoARG_POINTER_REGNUM)}; you only need to define this macro if that
3589e4b17023SJohn Marinodefinition is not suitable for use in preprocessor conditionals.
3590e4b17023SJohn Marino@end defmac
3591e4b17023SJohn Marino
3592e4b17023SJohn Marino@defmac RETURN_ADDRESS_POINTER_REGNUM
3593e4b17023SJohn MarinoThe register number of the return address pointer register, which is used to
3594e4b17023SJohn Marinoaccess the current function's return address from the stack.  On some
3595e4b17023SJohn Marinomachines, the return address is not at a fixed offset from the frame
3596e4b17023SJohn Marinopointer or stack pointer or argument pointer.  This register can be defined
3597e4b17023SJohn Marinoto point to the return address on the stack, and then be converted by
3598e4b17023SJohn Marino@code{ELIMINABLE_REGS} into either the frame pointer or stack pointer.
3599e4b17023SJohn Marino
3600e4b17023SJohn MarinoDo not define this macro unless there is no other way to get the return
3601e4b17023SJohn Marinoaddress from the stack.
3602e4b17023SJohn Marino@end defmac
3603e4b17023SJohn Marino
3604e4b17023SJohn Marino@defmac STATIC_CHAIN_REGNUM
3605e4b17023SJohn Marino@defmacx STATIC_CHAIN_INCOMING_REGNUM
3606e4b17023SJohn MarinoRegister numbers used for passing a function's static chain pointer.  If
3607e4b17023SJohn Marinoregister windows are used, the register number as seen by the called
3608e4b17023SJohn Marinofunction is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register
3609e4b17023SJohn Marinonumber as seen by the calling function is @code{STATIC_CHAIN_REGNUM}.  If
3610e4b17023SJohn Marinothese registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need
3611e4b17023SJohn Marinonot be defined.
3612e4b17023SJohn Marino
3613e4b17023SJohn MarinoThe static chain register need not be a fixed register.
3614e4b17023SJohn Marino
3615e4b17023SJohn MarinoIf the static chain is passed in memory, these macros should not be
3616e4b17023SJohn Marinodefined; instead, the @code{TARGET_STATIC_CHAIN} hook should be used.
3617e4b17023SJohn Marino@end defmac
3618e4b17023SJohn Marino
3619e4b17023SJohn Marino@hook TARGET_STATIC_CHAIN
3620e4b17023SJohn MarinoThis hook replaces the use of @code{STATIC_CHAIN_REGNUM} et al for
3621e4b17023SJohn Marinotargets that may use different static chain locations for different
3622e4b17023SJohn Marinonested functions.  This may be required if the target has function
3623e4b17023SJohn Marinoattributes that affect the calling conventions of the function and
3624e4b17023SJohn Marinothose calling conventions use different static chain locations.
3625e4b17023SJohn Marino
3626e4b17023SJohn MarinoThe default version of this hook uses @code{STATIC_CHAIN_REGNUM} et al.
3627e4b17023SJohn Marino
3628e4b17023SJohn MarinoIf the static chain is passed in memory, this hook should be used to
3629e4b17023SJohn Marinoprovide rtx giving @code{mem} expressions that denote where they are stored.
3630e4b17023SJohn MarinoOften the @code{mem} expression as seen by the caller will be at an offset
3631e4b17023SJohn Marinofrom the stack pointer and the @code{mem} expression as seen by the callee
3632e4b17023SJohn Marinowill be at an offset from the frame pointer.
3633e4b17023SJohn Marino@findex stack_pointer_rtx
3634e4b17023SJohn Marino@findex frame_pointer_rtx
3635e4b17023SJohn Marino@findex arg_pointer_rtx
3636e4b17023SJohn MarinoThe variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and
3637e4b17023SJohn Marino@code{arg_pointer_rtx} will have been initialized and should be used
3638e4b17023SJohn Marinoto refer to those items.
3639e4b17023SJohn Marino@end deftypefn
3640e4b17023SJohn Marino
3641e4b17023SJohn Marino@defmac DWARF_FRAME_REGISTERS
3642e4b17023SJohn MarinoThis macro specifies the maximum number of hard registers that can be
3643e4b17023SJohn Marinosaved in a call frame.  This is used to size data structures used in
3644e4b17023SJohn MarinoDWARF2 exception handling.
3645e4b17023SJohn Marino
3646e4b17023SJohn MarinoPrior to GCC 3.0, this macro was needed in order to establish a stable
3647e4b17023SJohn Marinoexception handling ABI in the face of adding new hard registers for ISA
3648e4b17023SJohn Marinoextensions.  In GCC 3.0 and later, the EH ABI is insulated from changes
3649e4b17023SJohn Marinoin the number of hard registers.  Nevertheless, this macro can still be
3650e4b17023SJohn Marinoused to reduce the runtime memory requirements of the exception handling
3651e4b17023SJohn Marinoroutines, which can be substantial if the ISA contains a lot of
3652e4b17023SJohn Marinoregisters that are not call-saved.
3653e4b17023SJohn Marino
3654e4b17023SJohn MarinoIf this macro is not defined, it defaults to
3655e4b17023SJohn Marino@code{FIRST_PSEUDO_REGISTER}.
3656e4b17023SJohn Marino@end defmac
3657e4b17023SJohn Marino
3658e4b17023SJohn Marino@defmac PRE_GCC3_DWARF_FRAME_REGISTERS
3659e4b17023SJohn Marino
3660e4b17023SJohn MarinoThis macro is similar to @code{DWARF_FRAME_REGISTERS}, but is provided
3661e4b17023SJohn Marinofor backward compatibility in pre GCC 3.0 compiled code.
3662e4b17023SJohn Marino
3663e4b17023SJohn MarinoIf this macro is not defined, it defaults to
3664e4b17023SJohn Marino@code{DWARF_FRAME_REGISTERS}.
3665e4b17023SJohn Marino@end defmac
3666e4b17023SJohn Marino
3667e4b17023SJohn Marino@defmac DWARF_REG_TO_UNWIND_COLUMN (@var{regno})
3668e4b17023SJohn Marino
3669e4b17023SJohn MarinoDefine this macro if the target's representation for dwarf registers
3670e4b17023SJohn Marinois different than the internal representation for unwind column.
3671e4b17023SJohn MarinoGiven a dwarf register, this macro should return the internal unwind
3672e4b17023SJohn Marinocolumn number to use instead.
3673e4b17023SJohn Marino
3674e4b17023SJohn MarinoSee the PowerPC's SPE target for an example.
3675e4b17023SJohn Marino@end defmac
3676e4b17023SJohn Marino
3677e4b17023SJohn Marino@defmac DWARF_FRAME_REGNUM (@var{regno})
3678e4b17023SJohn Marino
3679e4b17023SJohn MarinoDefine this macro if the target's representation for dwarf registers
3680e4b17023SJohn Marinoused in .eh_frame or .debug_frame is different from that used in other
3681e4b17023SJohn Marinodebug info sections.  Given a GCC hard register number, this macro
3682e4b17023SJohn Marinoshould return the .eh_frame register number.  The default is
3683e4b17023SJohn Marino@code{DBX_REGISTER_NUMBER (@var{regno})}.
3684e4b17023SJohn Marino
3685e4b17023SJohn Marino@end defmac
3686e4b17023SJohn Marino
3687e4b17023SJohn Marino@defmac DWARF2_FRAME_REG_OUT (@var{regno}, @var{for_eh})
3688e4b17023SJohn Marino
3689e4b17023SJohn MarinoDefine this macro to map register numbers held in the call frame info
3690e4b17023SJohn Marinothat GCC has collected using @code{DWARF_FRAME_REGNUM} to those that
3691e4b17023SJohn Marinoshould be output in .debug_frame (@code{@var{for_eh}} is zero) and
3692e4b17023SJohn Marino.eh_frame (@code{@var{for_eh}} is nonzero).  The default is to
3693e4b17023SJohn Marinoreturn @code{@var{regno}}.
3694e4b17023SJohn Marino
3695e4b17023SJohn Marino@end defmac
3696e4b17023SJohn Marino
3697e4b17023SJohn Marino@defmac REG_VALUE_IN_UNWIND_CONTEXT
3698e4b17023SJohn Marino
3699e4b17023SJohn MarinoDefine this macro if the target stores register values as
3700e4b17023SJohn Marino@code{_Unwind_Word} type in unwind context.  It should be defined if
3701e4b17023SJohn Marinotarget register size is larger than the size of @code{void *}.  The
3702e4b17023SJohn Marinodefault is to store register values as @code{void *} type.
3703e4b17023SJohn Marino
3704e4b17023SJohn Marino@end defmac
3705e4b17023SJohn Marino
3706e4b17023SJohn Marino@defmac ASSUME_EXTENDED_UNWIND_CONTEXT
3707e4b17023SJohn Marino
3708e4b17023SJohn MarinoDefine this macro to be 1 if the target always uses extended unwind
3709e4b17023SJohn Marinocontext with version, args_size and by_value fields.  If it is undefined,
3710e4b17023SJohn Marinoit will be defined to 1 when @code{REG_VALUE_IN_UNWIND_CONTEXT} is
3711e4b17023SJohn Marinodefined and 0 otherwise.
3712e4b17023SJohn Marino
3713e4b17023SJohn Marino@end defmac
3714e4b17023SJohn Marino
3715e4b17023SJohn Marino@node Elimination
3716e4b17023SJohn Marino@subsection Eliminating Frame Pointer and Arg Pointer
3717e4b17023SJohn Marino
3718e4b17023SJohn Marino@c prevent bad page break with this line
3719e4b17023SJohn MarinoThis is about eliminating the frame pointer and arg pointer.
3720e4b17023SJohn Marino
3721e4b17023SJohn Marino@hook TARGET_FRAME_POINTER_REQUIRED
3722e4b17023SJohn MarinoThis target hook should return @code{true} if a function must have and use
3723e4b17023SJohn Marinoa frame pointer.  This target hook is called in the reload pass.  If its return
3724e4b17023SJohn Marinovalue is @code{true} the function will have a frame pointer.
3725e4b17023SJohn Marino
3726e4b17023SJohn MarinoThis target hook can in principle examine the current function and decide
3727e4b17023SJohn Marinoaccording to the facts, but on most machines the constant @code{false} or the
3728e4b17023SJohn Marinoconstant @code{true} suffices.  Use @code{false} when the machine allows code
3729e4b17023SJohn Marinoto be generated with no frame pointer, and doing so saves some time or space.
3730e4b17023SJohn MarinoUse @code{true} when there is no possible advantage to avoiding a frame
3731e4b17023SJohn Marinopointer.
3732e4b17023SJohn Marino
3733e4b17023SJohn MarinoIn certain cases, the compiler does not know how to produce valid code
3734e4b17023SJohn Marinowithout a frame pointer.  The compiler recognizes those cases and
3735e4b17023SJohn Marinoautomatically gives the function a frame pointer regardless of what
3736e4b17023SJohn Marino@code{TARGET_FRAME_POINTER_REQUIRED} returns.  You don't need to worry about
3737e4b17023SJohn Marinothem.
3738e4b17023SJohn Marino
3739e4b17023SJohn MarinoIn a function that does not require a frame pointer, the frame pointer
3740e4b17023SJohn Marinoregister can be allocated for ordinary usage, unless you mark it as a
3741e4b17023SJohn Marinofixed register.  See @code{FIXED_REGISTERS} for more information.
3742e4b17023SJohn Marino
3743e4b17023SJohn MarinoDefault return value is @code{false}.
3744e4b17023SJohn Marino@end deftypefn
3745e4b17023SJohn Marino
3746e4b17023SJohn Marino@findex get_frame_size
3747e4b17023SJohn Marino@defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var})
3748e4b17023SJohn MarinoA C statement to store in the variable @var{depth-var} the difference
3749e4b17023SJohn Marinobetween the frame pointer and the stack pointer values immediately after
3750e4b17023SJohn Marinothe function prologue.  The value would be computed from information
3751e4b17023SJohn Marinosuch as the result of @code{get_frame_size ()} and the tables of
3752e4b17023SJohn Marinoregisters @code{regs_ever_live} and @code{call_used_regs}.
3753e4b17023SJohn Marino
3754e4b17023SJohn MarinoIf @code{ELIMINABLE_REGS} is defined, this macro will be not be used and
3755e4b17023SJohn Marinoneed not be defined.  Otherwise, it must be defined even if
3756e4b17023SJohn Marino@code{TARGET_FRAME_POINTER_REQUIRED} always returns true; in that
3757e4b17023SJohn Marinocase, you may set @var{depth-var} to anything.
3758e4b17023SJohn Marino@end defmac
3759e4b17023SJohn Marino
3760e4b17023SJohn Marino@defmac ELIMINABLE_REGS
3761e4b17023SJohn MarinoIf defined, this macro specifies a table of register pairs used to
3762e4b17023SJohn Marinoeliminate unneeded registers that point into the stack frame.  If it is not
3763e4b17023SJohn Marinodefined, the only elimination attempted by the compiler is to replace
3764e4b17023SJohn Marinoreferences to the frame pointer with references to the stack pointer.
3765e4b17023SJohn Marino
3766e4b17023SJohn MarinoThe definition of this macro is a list of structure initializations, each
3767e4b17023SJohn Marinoof which specifies an original and replacement register.
3768e4b17023SJohn Marino
3769e4b17023SJohn MarinoOn some machines, the position of the argument pointer is not known until
3770e4b17023SJohn Marinothe compilation is completed.  In such a case, a separate hard register
3771e4b17023SJohn Marinomust be used for the argument pointer.  This register can be eliminated by
3772e4b17023SJohn Marinoreplacing it with either the frame pointer or the argument pointer,
3773e4b17023SJohn Marinodepending on whether or not the frame pointer has been eliminated.
3774e4b17023SJohn Marino
3775e4b17023SJohn MarinoIn this case, you might specify:
3776e4b17023SJohn Marino@smallexample
3777e4b17023SJohn Marino#define ELIMINABLE_REGS  \
3778e4b17023SJohn Marino@{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \
3779e4b17023SJohn Marino @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \
3780e4b17023SJohn Marino @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@}
3781e4b17023SJohn Marino@end smallexample
3782e4b17023SJohn Marino
3783e4b17023SJohn MarinoNote that the elimination of the argument pointer with the stack pointer is
3784e4b17023SJohn Marinospecified first since that is the preferred elimination.
3785e4b17023SJohn Marino@end defmac
3786e4b17023SJohn Marino
3787e4b17023SJohn Marino@hook TARGET_CAN_ELIMINATE
3788e4b17023SJohn MarinoThis target hook should returns @code{true} if the compiler is allowed to
3789e4b17023SJohn Marinotry to replace register number @var{from_reg} with register number
3790e4b17023SJohn Marino@var{to_reg}.  This target hook need only be defined if @code{ELIMINABLE_REGS}
3791e4b17023SJohn Marinois defined, and will usually be @code{true}, since most of the cases
3792e4b17023SJohn Marinopreventing register elimination are things that the compiler already
3793e4b17023SJohn Marinoknows about.
3794e4b17023SJohn Marino
3795e4b17023SJohn MarinoDefault return value is @code{true}.
3796e4b17023SJohn Marino@end deftypefn
3797e4b17023SJohn Marino
3798e4b17023SJohn Marino@defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var})
3799e4b17023SJohn MarinoThis macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}.  It
3800e4b17023SJohn Marinospecifies the initial difference between the specified pair of
3801e4b17023SJohn Marinoregisters.  This macro must be defined if @code{ELIMINABLE_REGS} is
3802e4b17023SJohn Marinodefined.
3803e4b17023SJohn Marino@end defmac
3804e4b17023SJohn Marino
3805e4b17023SJohn Marino@node Stack Arguments
3806e4b17023SJohn Marino@subsection Passing Function Arguments on the Stack
3807e4b17023SJohn Marino@cindex arguments on stack
3808e4b17023SJohn Marino@cindex stack arguments
3809e4b17023SJohn Marino
3810e4b17023SJohn MarinoThe macros in this section control how arguments are passed
3811e4b17023SJohn Marinoon the stack.  See the following section for other macros that
3812e4b17023SJohn Marinocontrol passing certain arguments in registers.
3813e4b17023SJohn Marino
3814e4b17023SJohn Marino@hook TARGET_PROMOTE_PROTOTYPES
3815e4b17023SJohn MarinoThis target hook returns @code{true} if an argument declared in a
3816e4b17023SJohn Marinoprototype as an integral type smaller than @code{int} should actually be
3817e4b17023SJohn Marinopassed as an @code{int}.  In addition to avoiding errors in certain
3818e4b17023SJohn Marinocases of mismatch, it also makes for better code on certain machines.
3819e4b17023SJohn MarinoThe default is to not promote prototypes.
3820e4b17023SJohn Marino@end deftypefn
3821e4b17023SJohn Marino
3822e4b17023SJohn Marino@defmac PUSH_ARGS
3823e4b17023SJohn MarinoA C expression.  If nonzero, push insns will be used to pass
3824e4b17023SJohn Marinooutgoing arguments.
3825e4b17023SJohn MarinoIf the target machine does not have a push instruction, set it to zero.
3826e4b17023SJohn MarinoThat directs GCC to use an alternate strategy: to
3827e4b17023SJohn Marinoallocate the entire argument block and then store the arguments into
3828e4b17023SJohn Marinoit.  When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too.
3829e4b17023SJohn Marino@end defmac
3830e4b17023SJohn Marino
3831e4b17023SJohn Marino@defmac PUSH_ARGS_REVERSED
3832e4b17023SJohn MarinoA C expression.  If nonzero, function arguments will be evaluated from
3833e4b17023SJohn Marinolast to first, rather than from first to last.  If this macro is not
3834e4b17023SJohn Marinodefined, it defaults to @code{PUSH_ARGS} on targets where the stack
3835e4b17023SJohn Marinoand args grow in opposite directions, and 0 otherwise.
3836e4b17023SJohn Marino@end defmac
3837e4b17023SJohn Marino
3838e4b17023SJohn Marino@defmac PUSH_ROUNDING (@var{npushed})
3839e4b17023SJohn MarinoA C expression that is the number of bytes actually pushed onto the
3840e4b17023SJohn Marinostack when an instruction attempts to push @var{npushed} bytes.
3841e4b17023SJohn Marino
3842e4b17023SJohn MarinoOn some machines, the definition
3843e4b17023SJohn Marino
3844e4b17023SJohn Marino@smallexample
3845e4b17023SJohn Marino#define PUSH_ROUNDING(BYTES) (BYTES)
3846e4b17023SJohn Marino@end smallexample
3847e4b17023SJohn Marino
3848e4b17023SJohn Marino@noindent
3849e4b17023SJohn Marinowill suffice.  But on other machines, instructions that appear
3850e4b17023SJohn Marinoto push one byte actually push two bytes in an attempt to maintain
3851e4b17023SJohn Marinoalignment.  Then the definition should be
3852e4b17023SJohn Marino
3853e4b17023SJohn Marino@smallexample
3854e4b17023SJohn Marino#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
3855e4b17023SJohn Marino@end smallexample
3856e4b17023SJohn Marino
3857e4b17023SJohn MarinoIf the value of this macro has a type, it should be an unsigned type.
3858e4b17023SJohn Marino@end defmac
3859e4b17023SJohn Marino
3860e4b17023SJohn Marino@findex current_function_outgoing_args_size
3861e4b17023SJohn Marino@defmac ACCUMULATE_OUTGOING_ARGS
3862e4b17023SJohn MarinoA C expression.  If nonzero, the maximum amount of space required for outgoing arguments
3863e4b17023SJohn Marinowill be computed and placed into the variable
3864e4b17023SJohn Marino@code{current_function_outgoing_args_size}.  No space will be pushed
3865e4b17023SJohn Marinoonto the stack for each call; instead, the function prologue should
3866e4b17023SJohn Marinoincrease the stack frame size by this amount.
3867e4b17023SJohn Marino
3868e4b17023SJohn MarinoSetting both @code{PUSH_ARGS} and @code{ACCUMULATE_OUTGOING_ARGS}
3869e4b17023SJohn Marinois not proper.
3870e4b17023SJohn Marino@end defmac
3871e4b17023SJohn Marino
3872e4b17023SJohn Marino@defmac REG_PARM_STACK_SPACE (@var{fndecl})
3873e4b17023SJohn MarinoDefine this macro if functions should assume that stack space has been
3874e4b17023SJohn Marinoallocated for arguments even when their values are passed in
3875e4b17023SJohn Marinoregisters.
3876e4b17023SJohn Marino
3877e4b17023SJohn MarinoThe value of this macro is the size, in bytes, of the area reserved for
3878e4b17023SJohn Marinoarguments passed in registers for the function represented by @var{fndecl},
3879e4b17023SJohn Marinowhich can be zero if GCC is calling a library function.
3880e4b17023SJohn MarinoThe argument @var{fndecl} can be the FUNCTION_DECL, or the type itself
3881e4b17023SJohn Marinoof the function.
3882e4b17023SJohn Marino
3883e4b17023SJohn MarinoThis space can be allocated by the caller, or be a part of the
3884e4b17023SJohn Marinomachine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE} says
3885e4b17023SJohn Marinowhich.
3886e4b17023SJohn Marino@end defmac
3887e4b17023SJohn Marino@c above is overfull.  not sure what to do.  --mew 5feb93  did
3888e4b17023SJohn Marino@c something, not sure if it looks good.  --mew 10feb93
3889e4b17023SJohn Marino
3890e4b17023SJohn Marino@defmac OUTGOING_REG_PARM_STACK_SPACE (@var{fntype})
3891e4b17023SJohn MarinoDefine this to a nonzero value if it is the responsibility of the
3892e4b17023SJohn Marinocaller to allocate the area reserved for arguments passed in registers
3893e4b17023SJohn Marinowhen calling a function of @var{fntype}.  @var{fntype} may be NULL
3894e4b17023SJohn Marinoif the function called is a library function.
3895e4b17023SJohn Marino
3896e4b17023SJohn MarinoIf @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls
3897e4b17023SJohn Marinowhether the space for these arguments counts in the value of
3898e4b17023SJohn Marino@code{current_function_outgoing_args_size}.
3899e4b17023SJohn Marino@end defmac
3900e4b17023SJohn Marino
3901e4b17023SJohn Marino@defmac STACK_PARMS_IN_REG_PARM_AREA
3902e4b17023SJohn MarinoDefine this macro if @code{REG_PARM_STACK_SPACE} is defined, but the
3903e4b17023SJohn Marinostack parameters don't skip the area specified by it.
3904e4b17023SJohn Marino@c i changed this, makes more sens and it should have taken care of the
3905e4b17023SJohn Marino@c overfull.. not as specific, tho.  --mew 5feb93
3906e4b17023SJohn Marino
3907e4b17023SJohn MarinoNormally, when a parameter is not passed in registers, it is placed on the
3908e4b17023SJohn Marinostack beyond the @code{REG_PARM_STACK_SPACE} area.  Defining this macro
3909e4b17023SJohn Marinosuppresses this behavior and causes the parameter to be passed on the
3910e4b17023SJohn Marinostack in its natural location.
3911e4b17023SJohn Marino@end defmac
3912e4b17023SJohn Marino
3913e4b17023SJohn Marino@hook TARGET_RETURN_POPS_ARGS
3914e4b17023SJohn MarinoThis target hook returns the number of bytes of its own arguments that
3915e4b17023SJohn Marinoa function pops on returning, or 0 if the function pops no arguments
3916e4b17023SJohn Marinoand the caller must therefore pop them all after the function returns.
3917e4b17023SJohn Marino
3918e4b17023SJohn Marino@var{fundecl} is a C variable whose value is a tree node that describes
3919e4b17023SJohn Marinothe function in question.  Normally it is a node of type
3920e4b17023SJohn Marino@code{FUNCTION_DECL} that describes the declaration of the function.
3921e4b17023SJohn MarinoFrom this you can obtain the @code{DECL_ATTRIBUTES} of the function.
3922e4b17023SJohn Marino
3923e4b17023SJohn Marino@var{funtype} is a C variable whose value is a tree node that
3924e4b17023SJohn Marinodescribes the function in question.  Normally it is a node of type
3925e4b17023SJohn Marino@code{FUNCTION_TYPE} that describes the data type of the function.
3926e4b17023SJohn MarinoFrom this it is possible to obtain the data types of the value and
3927e4b17023SJohn Marinoarguments (if known).
3928e4b17023SJohn Marino
3929e4b17023SJohn MarinoWhen a call to a library function is being considered, @var{fundecl}
3930e4b17023SJohn Marinowill contain an identifier node for the library function.  Thus, if
3931e4b17023SJohn Marinoyou need to distinguish among various library functions, you can do so
3932e4b17023SJohn Marinoby their names.  Note that ``library function'' in this context means
3933e4b17023SJohn Marinoa function used to perform arithmetic, whose name is known specially
3934e4b17023SJohn Marinoin the compiler and was not mentioned in the C code being compiled.
3935e4b17023SJohn Marino
3936e4b17023SJohn Marino@var{size} is the number of bytes of arguments passed on the
3937e4b17023SJohn Marinostack.  If a variable number of bytes is passed, it is zero, and
3938e4b17023SJohn Marinoargument popping will always be the responsibility of the calling function.
3939e4b17023SJohn Marino
3940e4b17023SJohn MarinoOn the VAX, all functions always pop their arguments, so the definition
3941e4b17023SJohn Marinoof this macro is @var{size}.  On the 68000, using the standard
3942e4b17023SJohn Marinocalling convention, no functions pop their arguments, so the value of
3943e4b17023SJohn Marinothe macro is always 0 in this case.  But an alternative calling
3944e4b17023SJohn Marinoconvention is available in which functions that take a fixed number of
3945e4b17023SJohn Marinoarguments pop them but other functions (such as @code{printf}) pop
3946e4b17023SJohn Marinonothing (the caller pops all).  When this convention is in use,
3947e4b17023SJohn Marino@var{funtype} is examined to determine whether a function takes a fixed
3948e4b17023SJohn Marinonumber of arguments.
3949e4b17023SJohn Marino@end deftypefn
3950e4b17023SJohn Marino
3951e4b17023SJohn Marino@defmac CALL_POPS_ARGS (@var{cum})
3952e4b17023SJohn MarinoA C expression that should indicate the number of bytes a call sequence
3953e4b17023SJohn Marinopops off the stack.  It is added to the value of @code{RETURN_POPS_ARGS}
3954e4b17023SJohn Marinowhen compiling a function call.
3955e4b17023SJohn Marino
3956e4b17023SJohn Marino@var{cum} is the variable in which all arguments to the called function
3957e4b17023SJohn Marinohave been accumulated.
3958e4b17023SJohn Marino
3959e4b17023SJohn MarinoOn certain architectures, such as the SH5, a call trampoline is used
3960e4b17023SJohn Marinothat pops certain registers off the stack, depending on the arguments
3961e4b17023SJohn Marinothat have been passed to the function.  Since this is a property of the
3962e4b17023SJohn Marinocall site, not of the called function, @code{RETURN_POPS_ARGS} is not
3963e4b17023SJohn Marinoappropriate.
3964e4b17023SJohn Marino@end defmac
3965e4b17023SJohn Marino
3966e4b17023SJohn Marino@node Register Arguments
3967e4b17023SJohn Marino@subsection Passing Arguments in Registers
3968e4b17023SJohn Marino@cindex arguments in registers
3969e4b17023SJohn Marino@cindex registers arguments
3970e4b17023SJohn Marino
3971e4b17023SJohn MarinoThis section describes the macros which let you control how various
3972e4b17023SJohn Marinotypes of arguments are passed in registers or how they are arranged in
3973e4b17023SJohn Marinothe stack.
3974e4b17023SJohn Marino
3975e4b17023SJohn Marino@hook TARGET_FUNCTION_ARG
3976e4b17023SJohn MarinoReturn an RTX indicating whether a function argument is passed in a
3977e4b17023SJohn Marinoregister and if so, which register.
3978e4b17023SJohn Marino
3979e4b17023SJohn MarinoThe arguments are @var{ca}, which summarizes all the previous
3980e4b17023SJohn Marinoarguments; @var{mode}, the machine mode of the argument; @var{type},
3981e4b17023SJohn Marinothe data type of the argument as a tree node or 0 if that is not known
3982e4b17023SJohn Marino(which happens for C support library functions); and @var{named},
3983e4b17023SJohn Marinowhich is @code{true} for an ordinary argument and @code{false} for
3984e4b17023SJohn Marinonameless arguments that correspond to @samp{@dots{}} in the called
3985e4b17023SJohn Marinofunction's prototype.  @var{type} can be an incomplete type if a
3986e4b17023SJohn Marinosyntax error has previously occurred.
3987e4b17023SJohn Marino
3988e4b17023SJohn MarinoThe return value is usually either a @code{reg} RTX for the hard
3989e4b17023SJohn Marinoregister in which to pass the argument, or zero to pass the argument
3990e4b17023SJohn Marinoon the stack.
3991e4b17023SJohn Marino
3992e4b17023SJohn MarinoThe value of the expression can also be a @code{parallel} RTX@.  This is
3993e4b17023SJohn Marinoused when an argument is passed in multiple locations.  The mode of the
3994e4b17023SJohn Marino@code{parallel} should be the mode of the entire argument.  The
3995e4b17023SJohn Marino@code{parallel} holds any number of @code{expr_list} pairs; each one
3996e4b17023SJohn Marinodescribes where part of the argument is passed.  In each
3997e4b17023SJohn Marino@code{expr_list} the first operand must be a @code{reg} RTX for the hard
3998e4b17023SJohn Marinoregister in which to pass this part of the argument, and the mode of the
3999e4b17023SJohn Marinoregister RTX indicates how large this part of the argument is.  The
4000e4b17023SJohn Marinosecond operand of the @code{expr_list} is a @code{const_int} which gives
4001e4b17023SJohn Marinothe offset in bytes into the entire argument of where this part starts.
4002e4b17023SJohn MarinoAs a special exception the first @code{expr_list} in the @code{parallel}
4003e4b17023SJohn MarinoRTX may have a first operand of zero.  This indicates that the entire
4004e4b17023SJohn Marinoargument is also stored on the stack.
4005e4b17023SJohn Marino
4006e4b17023SJohn MarinoThe last time this hook is called, it is called with @code{MODE ==
4007e4b17023SJohn MarinoVOIDmode}, and its result is passed to the @code{call} or @code{call_value}
4008e4b17023SJohn Marinopattern as operands 2 and 3 respectively.
4009e4b17023SJohn Marino
4010e4b17023SJohn Marino@cindex @file{stdarg.h} and register arguments
4011e4b17023SJohn MarinoThe usual way to make the ISO library @file{stdarg.h} work on a
4012e4b17023SJohn Marinomachine where some arguments are usually passed in registers, is to
4013e4b17023SJohn Marinocause nameless arguments to be passed on the stack instead.  This is
4014e4b17023SJohn Marinodone by making @code{TARGET_FUNCTION_ARG} return 0 whenever
4015e4b17023SJohn Marino@var{named} is @code{false}.
4016e4b17023SJohn Marino
4017e4b17023SJohn Marino@cindex @code{TARGET_MUST_PASS_IN_STACK}, and @code{TARGET_FUNCTION_ARG}
4018e4b17023SJohn Marino@cindex @code{REG_PARM_STACK_SPACE}, and @code{TARGET_FUNCTION_ARG}
4019e4b17023SJohn MarinoYou may use the hook @code{targetm.calls.must_pass_in_stack}
4020e4b17023SJohn Marinoin the definition of this macro to determine if this argument is of a
4021e4b17023SJohn Marinotype that must be passed in the stack.  If @code{REG_PARM_STACK_SPACE}
4022e4b17023SJohn Marinois not defined and @code{TARGET_FUNCTION_ARG} returns nonzero for such an
4023e4b17023SJohn Marinoargument, the compiler will abort.  If @code{REG_PARM_STACK_SPACE} is
4024e4b17023SJohn Marinodefined, the argument will be computed in the stack and then loaded into
4025e4b17023SJohn Marinoa register.
4026e4b17023SJohn Marino@end deftypefn
4027e4b17023SJohn Marino
4028e4b17023SJohn Marino@hook TARGET_MUST_PASS_IN_STACK
4029e4b17023SJohn MarinoThis target hook should return @code{true} if we should not pass @var{type}
4030e4b17023SJohn Marinosolely in registers.  The file @file{expr.h} defines a
4031e4b17023SJohn Marinodefinition that is usually appropriate, refer to @file{expr.h} for additional
4032e4b17023SJohn Marinodocumentation.
4033e4b17023SJohn Marino@end deftypefn
4034e4b17023SJohn Marino
4035e4b17023SJohn Marino@hook TARGET_FUNCTION_INCOMING_ARG
4036e4b17023SJohn MarinoDefine this hook if the target machine has ``register windows'', so
4037e4b17023SJohn Marinothat the register in which a function sees an arguments is not
4038e4b17023SJohn Marinonecessarily the same as the one in which the caller passed the
4039e4b17023SJohn Marinoargument.
4040e4b17023SJohn Marino
4041e4b17023SJohn MarinoFor such machines, @code{TARGET_FUNCTION_ARG} computes the register in
4042e4b17023SJohn Marinowhich the caller passes the value, and
4043e4b17023SJohn Marino@code{TARGET_FUNCTION_INCOMING_ARG} should be defined in a similar
4044e4b17023SJohn Marinofashion to tell the function being called where the arguments will
4045e4b17023SJohn Marinoarrive.
4046e4b17023SJohn Marino
4047e4b17023SJohn MarinoIf @code{TARGET_FUNCTION_INCOMING_ARG} is not defined,
4048e4b17023SJohn Marino@code{TARGET_FUNCTION_ARG} serves both purposes.
4049e4b17023SJohn Marino@end deftypefn
4050e4b17023SJohn Marino
4051e4b17023SJohn Marino@hook TARGET_ARG_PARTIAL_BYTES
4052e4b17023SJohn MarinoThis target hook returns the number of bytes at the beginning of an
4053e4b17023SJohn Marinoargument that must be put in registers.  The value must be zero for
4054e4b17023SJohn Marinoarguments that are passed entirely in registers or that are entirely
4055e4b17023SJohn Marinopushed on the stack.
4056e4b17023SJohn Marino
4057e4b17023SJohn MarinoOn some machines, certain arguments must be passed partially in
4058e4b17023SJohn Marinoregisters and partially in memory.  On these machines, typically the
4059e4b17023SJohn Marinofirst few words of arguments are passed in registers, and the rest
4060e4b17023SJohn Marinoon the stack.  If a multi-word argument (a @code{double} or a
4061e4b17023SJohn Marinostructure) crosses that boundary, its first few words must be passed
4062e4b17023SJohn Marinoin registers and the rest must be pushed.  This macro tells the
4063e4b17023SJohn Marinocompiler when this occurs, and how many bytes should go in registers.
4064e4b17023SJohn Marino
4065e4b17023SJohn Marino@code{TARGET_FUNCTION_ARG} for these arguments should return the first
4066e4b17023SJohn Marinoregister to be used by the caller for this argument; likewise
4067e4b17023SJohn Marino@code{TARGET_FUNCTION_INCOMING_ARG}, for the called function.
4068e4b17023SJohn Marino@end deftypefn
4069e4b17023SJohn Marino
4070e4b17023SJohn Marino@hook TARGET_PASS_BY_REFERENCE
4071e4b17023SJohn MarinoThis target hook should return @code{true} if an argument at the
4072e4b17023SJohn Marinoposition indicated by @var{cum} should be passed by reference.  This
4073e4b17023SJohn Marinopredicate is queried after target independent reasons for being
4074e4b17023SJohn Marinopassed by reference, such as @code{TREE_ADDRESSABLE (type)}.
4075e4b17023SJohn Marino
4076e4b17023SJohn MarinoIf the hook returns true, a copy of that argument is made in memory and a
4077e4b17023SJohn Marinopointer to the argument is passed instead of the argument itself.
4078e4b17023SJohn MarinoThe pointer is passed in whatever way is appropriate for passing a pointer
4079e4b17023SJohn Marinoto that type.
4080e4b17023SJohn Marino@end deftypefn
4081e4b17023SJohn Marino
4082e4b17023SJohn Marino@hook TARGET_CALLEE_COPIES
4083e4b17023SJohn MarinoThe function argument described by the parameters to this hook is
4084e4b17023SJohn Marinoknown to be passed by reference.  The hook should return true if the
4085e4b17023SJohn Marinofunction argument should be copied by the callee instead of copied
4086e4b17023SJohn Marinoby the caller.
4087e4b17023SJohn Marino
4088e4b17023SJohn MarinoFor any argument for which the hook returns true, if it can be
4089e4b17023SJohn Marinodetermined that the argument is not modified, then a copy need
4090e4b17023SJohn Marinonot be generated.
4091e4b17023SJohn Marino
4092e4b17023SJohn MarinoThe default version of this hook always returns false.
4093e4b17023SJohn Marino@end deftypefn
4094e4b17023SJohn Marino
4095e4b17023SJohn Marino@defmac CUMULATIVE_ARGS
4096e4b17023SJohn MarinoA C type for declaring a variable that is used as the first argument
4097e4b17023SJohn Marinoof @code{TARGET_FUNCTION_ARG} and other related values.  For some
4098e4b17023SJohn Marinotarget machines, the type @code{int} suffices and can hold the number
4099e4b17023SJohn Marinoof bytes of argument so far.
4100e4b17023SJohn Marino
4101e4b17023SJohn MarinoThere is no need to record in @code{CUMULATIVE_ARGS} anything about the
4102e4b17023SJohn Marinoarguments that have been passed on the stack.  The compiler has other
4103e4b17023SJohn Marinovariables to keep track of that.  For target machines on which all
4104e4b17023SJohn Marinoarguments are passed on the stack, there is no need to store anything in
4105e4b17023SJohn Marino@code{CUMULATIVE_ARGS}; however, the data structure must exist and
4106e4b17023SJohn Marinoshould not be empty, so use @code{int}.
4107e4b17023SJohn Marino@end defmac
4108e4b17023SJohn Marino
4109e4b17023SJohn Marino@defmac OVERRIDE_ABI_FORMAT (@var{fndecl})
4110e4b17023SJohn MarinoIf defined, this macro is called before generating any code for a
4111e4b17023SJohn Marinofunction, but after the @var{cfun} descriptor for the function has been
4112e4b17023SJohn Marinocreated.  The back end may use this macro to update @var{cfun} to
4113e4b17023SJohn Marinoreflect an ABI other than that which would normally be used by default.
4114e4b17023SJohn MarinoIf the compiler is generating code for a compiler-generated function,
4115e4b17023SJohn Marino@var{fndecl} may be @code{NULL}.
4116e4b17023SJohn Marino@end defmac
4117e4b17023SJohn Marino
4118e4b17023SJohn Marino@defmac INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype}, @var{libname}, @var{fndecl}, @var{n_named_args})
4119e4b17023SJohn MarinoA C statement (sans semicolon) for initializing the variable
4120e4b17023SJohn Marino@var{cum} for the state at the beginning of the argument list.  The
4121e4b17023SJohn Marinovariable has type @code{CUMULATIVE_ARGS}.  The value of @var{fntype}
4122e4b17023SJohn Marinois the tree node for the data type of the function which will receive
4123e4b17023SJohn Marinothe args, or 0 if the args are to a compiler support library function.
4124e4b17023SJohn MarinoFor direct calls that are not libcalls, @var{fndecl} contain the
4125e4b17023SJohn Marinodeclaration node of the function.  @var{fndecl} is also set when
4126e4b17023SJohn Marino@code{INIT_CUMULATIVE_ARGS} is used to find arguments for the function
4127e4b17023SJohn Marinobeing compiled.  @var{n_named_args} is set to the number of named
4128e4b17023SJohn Marinoarguments, including a structure return address if it is passed as a
4129e4b17023SJohn Marinoparameter, when making a call.  When processing incoming arguments,
4130e4b17023SJohn Marino@var{n_named_args} is set to @minus{}1.
4131e4b17023SJohn Marino
4132e4b17023SJohn MarinoWhen processing a call to a compiler support library function,
4133e4b17023SJohn Marino@var{libname} identifies which one.  It is a @code{symbol_ref} rtx which
4134e4b17023SJohn Marinocontains the name of the function, as a string.  @var{libname} is 0 when
4135e4b17023SJohn Marinoan ordinary C function call is being processed.  Thus, each time this
4136e4b17023SJohn Marinomacro is called, either @var{libname} or @var{fntype} is nonzero, but
4137e4b17023SJohn Marinonever both of them at once.
4138e4b17023SJohn Marino@end defmac
4139e4b17023SJohn Marino
4140e4b17023SJohn Marino@defmac INIT_CUMULATIVE_LIBCALL_ARGS (@var{cum}, @var{mode}, @var{libname})
4141e4b17023SJohn MarinoLike @code{INIT_CUMULATIVE_ARGS} but only used for outgoing libcalls,
4142e4b17023SJohn Marinoit gets a @code{MODE} argument instead of @var{fntype}, that would be
4143e4b17023SJohn Marino@code{NULL}.  @var{indirect} would always be zero, too.  If this macro
4144e4b17023SJohn Marinois not defined, @code{INIT_CUMULATIVE_ARGS (cum, NULL_RTX, libname,
4145e4b17023SJohn Marino0)} is used instead.
4146e4b17023SJohn Marino@end defmac
4147e4b17023SJohn Marino
4148e4b17023SJohn Marino@defmac INIT_CUMULATIVE_INCOMING_ARGS (@var{cum}, @var{fntype}, @var{libname})
4149e4b17023SJohn MarinoLike @code{INIT_CUMULATIVE_ARGS} but overrides it for the purposes of
4150e4b17023SJohn Marinofinding the arguments for the function being compiled.  If this macro is
4151e4b17023SJohn Marinoundefined, @code{INIT_CUMULATIVE_ARGS} is used instead.
4152e4b17023SJohn Marino
4153e4b17023SJohn MarinoThe value passed for @var{libname} is always 0, since library routines
4154e4b17023SJohn Marinowith special calling conventions are never compiled with GCC@.  The
4155e4b17023SJohn Marinoargument @var{libname} exists for symmetry with
4156e4b17023SJohn Marino@code{INIT_CUMULATIVE_ARGS}.
4157e4b17023SJohn Marino@c could use "this macro" in place of @code{INIT_CUMULATIVE_ARGS}, maybe.
4158e4b17023SJohn Marino@c --mew 5feb93   i switched the order of the sentences.  --mew 10feb93
4159e4b17023SJohn Marino@end defmac
4160e4b17023SJohn Marino
4161e4b17023SJohn Marino@hook TARGET_FUNCTION_ARG_ADVANCE
4162e4b17023SJohn MarinoThis hook updates the summarizer variable pointed to by @var{ca} to
4163e4b17023SJohn Marinoadvance past an argument in the argument list.  The values @var{mode},
4164e4b17023SJohn Marino@var{type} and @var{named} describe that argument.  Once this is done,
4165e4b17023SJohn Marinothe variable @var{cum} is suitable for analyzing the @emph{following}
4166e4b17023SJohn Marinoargument with @code{TARGET_FUNCTION_ARG}, etc.
4167e4b17023SJohn Marino
4168e4b17023SJohn MarinoThis hook need not do anything if the argument in question was passed
4169e4b17023SJohn Marinoon the stack.  The compiler knows how to track the amount of stack space
4170e4b17023SJohn Marinoused for arguments without any special help.
4171e4b17023SJohn Marino@end deftypefn
4172e4b17023SJohn Marino
4173e4b17023SJohn Marino@defmac FUNCTION_ARG_OFFSET (@var{mode}, @var{type})
4174e4b17023SJohn MarinoIf defined, a C expression that is the number of bytes to add to the
4175e4b17023SJohn Marinooffset of the argument passed in memory.  This is needed for the SPU,
4176e4b17023SJohn Marinowhich passes @code{char} and @code{short} arguments in the preferred
4177e4b17023SJohn Marinoslot that is in the middle of the quad word instead of starting at the
4178e4b17023SJohn Marinotop.
4179e4b17023SJohn Marino@end defmac
4180e4b17023SJohn Marino
4181e4b17023SJohn Marino@defmac FUNCTION_ARG_PADDING (@var{mode}, @var{type})
4182e4b17023SJohn MarinoIf defined, a C expression which determines whether, and in which direction,
4183e4b17023SJohn Marinoto pad out an argument with extra space.  The value should be of type
4184e4b17023SJohn Marino@code{enum direction}: either @code{upward} to pad above the argument,
4185e4b17023SJohn Marino@code{downward} to pad below, or @code{none} to inhibit padding.
4186e4b17023SJohn Marino
4187e4b17023SJohn MarinoThe @emph{amount} of padding is not controlled by this macro, but by the
4188e4b17023SJohn Marinotarget hook @code{TARGET_FUNCTION_ARG_ROUND_BOUNDARY}.  It is
4189e4b17023SJohn Marinoalways just enough to reach the next multiple of that boundary.
4190e4b17023SJohn Marino
4191e4b17023SJohn MarinoThis macro has a default definition which is right for most systems.
4192e4b17023SJohn MarinoFor little-endian machines, the default is to pad upward.  For
4193e4b17023SJohn Marinobig-endian machines, the default is to pad downward for an argument of
4194e4b17023SJohn Marinoconstant size shorter than an @code{int}, and upward otherwise.
4195e4b17023SJohn Marino@end defmac
4196e4b17023SJohn Marino
4197e4b17023SJohn Marino@defmac PAD_VARARGS_DOWN
4198e4b17023SJohn MarinoIf defined, a C expression which determines whether the default
4199e4b17023SJohn Marinoimplementation of va_arg will attempt to pad down before reading the
4200e4b17023SJohn Marinonext argument, if that argument is smaller than its aligned space as
4201e4b17023SJohn Marinocontrolled by @code{PARM_BOUNDARY}.  If this macro is not defined, all such
4202e4b17023SJohn Marinoarguments are padded down if @code{BYTES_BIG_ENDIAN} is true.
4203e4b17023SJohn Marino@end defmac
4204e4b17023SJohn Marino
4205e4b17023SJohn Marino@defmac BLOCK_REG_PADDING (@var{mode}, @var{type}, @var{first})
4206e4b17023SJohn MarinoSpecify padding for the last element of a block move between registers and
4207e4b17023SJohn Marinomemory.  @var{first} is nonzero if this is the only element.  Defining this
4208e4b17023SJohn Marinomacro allows better control of register function parameters on big-endian
4209e4b17023SJohn Marinomachines, without using @code{PARALLEL} rtl.  In particular,
4210e4b17023SJohn Marino@code{MUST_PASS_IN_STACK} need not test padding and mode of types in
4211e4b17023SJohn Marinoregisters, as there is no longer a "wrong" part of a register;  For example,
4212e4b17023SJohn Marinoa three byte aggregate may be passed in the high part of a register if so
4213e4b17023SJohn Marinorequired.
4214e4b17023SJohn Marino@end defmac
4215e4b17023SJohn Marino
4216e4b17023SJohn Marino@hook TARGET_FUNCTION_ARG_BOUNDARY
4217e4b17023SJohn MarinoThis hook returns the alignment boundary, in bits, of an argument
4218e4b17023SJohn Marinowith the specified mode and type.  The default hook returns
4219e4b17023SJohn Marino@code{PARM_BOUNDARY} for all arguments.
4220e4b17023SJohn Marino@end deftypefn
4221e4b17023SJohn Marino
4222e4b17023SJohn Marino@hook TARGET_FUNCTION_ARG_ROUND_BOUNDARY
4223e4b17023SJohn Marino
4224e4b17023SJohn Marino@defmac FUNCTION_ARG_REGNO_P (@var{regno})
4225e4b17023SJohn MarinoA C expression that is nonzero if @var{regno} is the number of a hard
4226e4b17023SJohn Marinoregister in which function arguments are sometimes passed.  This does
4227e4b17023SJohn Marino@emph{not} include implicit arguments such as the static chain and
4228e4b17023SJohn Marinothe structure-value address.  On many machines, no registers can be
4229e4b17023SJohn Marinoused for this purpose since all function arguments are pushed on the
4230e4b17023SJohn Marinostack.
4231e4b17023SJohn Marino@end defmac
4232e4b17023SJohn Marino
4233e4b17023SJohn Marino@hook TARGET_SPLIT_COMPLEX_ARG
4234e4b17023SJohn MarinoThis hook should return true if parameter of type @var{type} are passed
4235e4b17023SJohn Marinoas two scalar parameters.  By default, GCC will attempt to pack complex
4236e4b17023SJohn Marinoarguments into the target's word size.  Some ABIs require complex arguments
4237e4b17023SJohn Marinoto be split and treated as their individual components.  For example, on
4238e4b17023SJohn MarinoAIX64, complex floats should be passed in a pair of floating point
4239e4b17023SJohn Marinoregisters, even though a complex float would fit in one 64-bit floating
4240e4b17023SJohn Marinopoint register.
4241e4b17023SJohn Marino
4242e4b17023SJohn MarinoThe default value of this hook is @code{NULL}, which is treated as always
4243e4b17023SJohn Marinofalse.
4244e4b17023SJohn Marino@end deftypefn
4245e4b17023SJohn Marino
4246e4b17023SJohn Marino@hook TARGET_BUILD_BUILTIN_VA_LIST
4247e4b17023SJohn MarinoThis hook returns a type node for @code{va_list} for the target.
4248e4b17023SJohn MarinoThe default version of the hook returns @code{void*}.
4249e4b17023SJohn Marino@end deftypefn
4250e4b17023SJohn Marino
4251e4b17023SJohn Marino@hook TARGET_ENUM_VA_LIST_P
4252e4b17023SJohn MarinoThis target hook is used in function @code{c_common_nodes_and_builtins}
4253e4b17023SJohn Marinoto iterate through the target specific builtin types for va_list. The
4254e4b17023SJohn Marinovariable @var{idx} is used as iterator. @var{pname} has to be a pointer
4255e4b17023SJohn Marinoto a @code{const char *} and @var{ptree} a pointer to a @code{tree} typed
4256e4b17023SJohn Marinovariable.
4257e4b17023SJohn MarinoThe arguments @var{pname} and @var{ptree} are used to store the result of
4258e4b17023SJohn Marinothis macro and are set to the name of the va_list builtin type and its
4259e4b17023SJohn Marinointernal type.
4260e4b17023SJohn MarinoIf the return value of this macro is zero, then there is no more element.
4261e4b17023SJohn MarinoOtherwise the @var{IDX} should be increased for the next call of this
4262e4b17023SJohn Marinomacro to iterate through all types.
4263e4b17023SJohn Marino@end deftypefn
4264e4b17023SJohn Marino
4265e4b17023SJohn Marino@hook TARGET_FN_ABI_VA_LIST
4266e4b17023SJohn MarinoThis hook returns the va_list type of the calling convention specified by
4267e4b17023SJohn Marino@var{fndecl}.
4268e4b17023SJohn MarinoThe default version of this hook returns @code{va_list_type_node}.
4269e4b17023SJohn Marino@end deftypefn
4270e4b17023SJohn Marino
4271e4b17023SJohn Marino@hook TARGET_CANONICAL_VA_LIST_TYPE
4272e4b17023SJohn MarinoThis hook returns the va_list type of the calling convention specified by the
4273e4b17023SJohn Marinotype of @var{type}. If @var{type} is not a valid va_list type, it returns
4274e4b17023SJohn Marino@code{NULL_TREE}.
4275e4b17023SJohn Marino@end deftypefn
4276e4b17023SJohn Marino
4277e4b17023SJohn Marino@hook TARGET_GIMPLIFY_VA_ARG_EXPR
4278e4b17023SJohn MarinoThis hook performs target-specific gimplification of
4279e4b17023SJohn Marino@code{VA_ARG_EXPR}.  The first two parameters correspond to the
4280e4b17023SJohn Marinoarguments to @code{va_arg}; the latter two are as in
4281e4b17023SJohn Marino@code{gimplify.c:gimplify_expr}.
4282e4b17023SJohn Marino@end deftypefn
4283e4b17023SJohn Marino
4284e4b17023SJohn Marino@hook TARGET_VALID_POINTER_MODE
4285e4b17023SJohn MarinoDefine this to return nonzero if the port can handle pointers
4286e4b17023SJohn Marinowith machine mode @var{mode}.  The default version of this
4287e4b17023SJohn Marinohook returns true for both @code{ptr_mode} and @code{Pmode}.
4288e4b17023SJohn Marino@end deftypefn
4289e4b17023SJohn Marino
4290e4b17023SJohn Marino@hook TARGET_REF_MAY_ALIAS_ERRNO
4291e4b17023SJohn Marino
4292e4b17023SJohn Marino@hook TARGET_SCALAR_MODE_SUPPORTED_P
4293e4b17023SJohn MarinoDefine this to return nonzero if the port is prepared to handle
4294e4b17023SJohn Marinoinsns involving scalar mode @var{mode}.  For a scalar mode to be
4295e4b17023SJohn Marinoconsidered supported, all the basic arithmetic and comparisons
4296e4b17023SJohn Marinomust work.
4297e4b17023SJohn Marino
4298e4b17023SJohn MarinoThe default version of this hook returns true for any mode
4299e4b17023SJohn Marinorequired to handle the basic C types (as defined by the port).
4300e4b17023SJohn MarinoIncluded here are the double-word arithmetic supported by the
4301e4b17023SJohn Marinocode in @file{optabs.c}.
4302e4b17023SJohn Marino@end deftypefn
4303e4b17023SJohn Marino
4304e4b17023SJohn Marino@hook TARGET_VECTOR_MODE_SUPPORTED_P
4305e4b17023SJohn MarinoDefine this to return nonzero if the port is prepared to handle
4306e4b17023SJohn Marinoinsns involving vector mode @var{mode}.  At the very least, it
4307e4b17023SJohn Marinomust have move patterns for this mode.
4308e4b17023SJohn Marino@end deftypefn
4309e4b17023SJohn Marino
4310e4b17023SJohn Marino@hook TARGET_ARRAY_MODE_SUPPORTED_P
4311e4b17023SJohn Marino
4312e4b17023SJohn Marino@hook TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P
4313e4b17023SJohn MarinoDefine this to return nonzero for machine modes for which the port has
4314e4b17023SJohn Marinosmall register classes.  If this target hook returns nonzero for a given
4315e4b17023SJohn Marino@var{mode}, the compiler will try to minimize the lifetime of registers
4316e4b17023SJohn Marinoin @var{mode}.  The hook may be called with @code{VOIDmode} as argument.
4317e4b17023SJohn MarinoIn this case, the hook is expected to return nonzero if it returns nonzero
4318e4b17023SJohn Marinofor any mode.
4319e4b17023SJohn Marino
4320e4b17023SJohn MarinoOn some machines, it is risky to let hard registers live across arbitrary
4321e4b17023SJohn Marinoinsns.  Typically, these machines have instructions that require values
4322e4b17023SJohn Marinoto be in specific registers (like an accumulator), and reload will fail
4323e4b17023SJohn Marinoif the required hard register is used for another purpose across such an
4324e4b17023SJohn Marinoinsn.
4325e4b17023SJohn Marino
4326e4b17023SJohn MarinoPasses before reload do not know which hard registers will be used
4327e4b17023SJohn Marinoin an instruction, but the machine modes of the registers set or used in
4328e4b17023SJohn Marinothe instruction are already known.  And for some machines, register
4329e4b17023SJohn Marinoclasses are small for, say, integer registers but not for floating point
4330e4b17023SJohn Marinoregisters.  For example, the AMD x86-64 architecture requires specific
4331e4b17023SJohn Marinoregisters for the legacy x86 integer instructions, but there are many
4332e4b17023SJohn MarinoSSE registers for floating point operations.  On such targets, a good
4333e4b17023SJohn Marinostrategy may be to return nonzero from this hook for @code{INTEGRAL_MODE_P}
4334e4b17023SJohn Marinomachine modes but zero for the SSE register classes.
4335e4b17023SJohn Marino
4336e4b17023SJohn MarinoThe default version of this hook returns false for any mode.  It is always
4337e4b17023SJohn Marinosafe to redefine this hook to return with a nonzero value.  But if you
4338e4b17023SJohn Marinounnecessarily define it, you will reduce the amount of optimizations
4339e4b17023SJohn Marinothat can be performed in some cases.  If you do not define this hook
4340e4b17023SJohn Marinoto return a nonzero value when it is required, the compiler will run out
4341e4b17023SJohn Marinoof spill registers and print a fatal error message.
4342e4b17023SJohn Marino@end deftypefn
4343e4b17023SJohn Marino
4344e4b17023SJohn Marino@hook TARGET_FLAGS_REGNUM
4345e4b17023SJohn Marino
4346e4b17023SJohn Marino@node Scalar Return
4347e4b17023SJohn Marino@subsection How Scalar Function Values Are Returned
4348e4b17023SJohn Marino@cindex return values in registers
4349e4b17023SJohn Marino@cindex values, returned by functions
4350e4b17023SJohn Marino@cindex scalars, returned as values
4351e4b17023SJohn Marino
4352e4b17023SJohn MarinoThis section discusses the macros that control returning scalars as
4353e4b17023SJohn Marinovalues---values that can fit in registers.
4354e4b17023SJohn Marino
4355e4b17023SJohn Marino@hook TARGET_FUNCTION_VALUE
4356e4b17023SJohn Marino
4357e4b17023SJohn MarinoDefine this to return an RTX representing the place where a function
4358e4b17023SJohn Marinoreturns or receives a value of data type @var{ret_type}, a tree node
4359e4b17023SJohn Marinorepresenting a data type.  @var{fn_decl_or_type} is a tree node
4360e4b17023SJohn Marinorepresenting @code{FUNCTION_DECL} or @code{FUNCTION_TYPE} of a
4361e4b17023SJohn Marinofunction being called.  If @var{outgoing} is false, the hook should
4362e4b17023SJohn Marinocompute the register in which the caller will see the return value.
4363e4b17023SJohn MarinoOtherwise, the hook should return an RTX representing the place where
4364e4b17023SJohn Marinoa function returns a value.
4365e4b17023SJohn Marino
4366e4b17023SJohn MarinoOn many machines, only @code{TYPE_MODE (@var{ret_type})} is relevant.
4367e4b17023SJohn Marino(Actually, on most machines, scalar values are returned in the same
4368e4b17023SJohn Marinoplace regardless of mode.)  The value of the expression is usually a
4369e4b17023SJohn Marino@code{reg} RTX for the hard register where the return value is stored.
4370e4b17023SJohn MarinoThe value can also be a @code{parallel} RTX, if the return value is in
4371e4b17023SJohn Marinomultiple places.  See @code{TARGET_FUNCTION_ARG} for an explanation of the
4372e4b17023SJohn Marino@code{parallel} form.   Note that the callee will populate every
4373e4b17023SJohn Marinolocation specified in the @code{parallel}, but if the first element of
4374e4b17023SJohn Marinothe @code{parallel} contains the whole return value, callers will use
4375e4b17023SJohn Marinothat element as the canonical location and ignore the others.  The m68k
4376e4b17023SJohn Marinoport uses this type of @code{parallel} to return pointers in both
4377e4b17023SJohn Marino@samp{%a0} (the canonical location) and @samp{%d0}.
4378e4b17023SJohn Marino
4379e4b17023SJohn MarinoIf @code{TARGET_PROMOTE_FUNCTION_RETURN} returns true, you must apply
4380e4b17023SJohn Marinothe same promotion rules specified in @code{PROMOTE_MODE} if
4381e4b17023SJohn Marino@var{valtype} is a scalar type.
4382e4b17023SJohn Marino
4383e4b17023SJohn MarinoIf the precise function being called is known, @var{func} is a tree
4384e4b17023SJohn Marinonode (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null
4385e4b17023SJohn Marinopointer.  This makes it possible to use a different value-returning
4386e4b17023SJohn Marinoconvention for specific functions when all their calls are
4387e4b17023SJohn Marinoknown.
4388e4b17023SJohn Marino
4389e4b17023SJohn MarinoSome target machines have ``register windows'' so that the register in
4390e4b17023SJohn Marinowhich a function returns its value is not the same as the one in which
4391e4b17023SJohn Marinothe caller sees the value.  For such machines, you should return
4392e4b17023SJohn Marinodifferent RTX depending on @var{outgoing}.
4393e4b17023SJohn Marino
4394e4b17023SJohn Marino@code{TARGET_FUNCTION_VALUE} is not used for return values with
4395e4b17023SJohn Marinoaggregate data types, because these are returned in another way.  See
4396e4b17023SJohn Marino@code{TARGET_STRUCT_VALUE_RTX} and related macros, below.
4397e4b17023SJohn Marino@end deftypefn
4398e4b17023SJohn Marino
4399e4b17023SJohn Marino@defmac FUNCTION_VALUE (@var{valtype}, @var{func})
4400e4b17023SJohn MarinoThis macro has been deprecated.  Use @code{TARGET_FUNCTION_VALUE} for
4401e4b17023SJohn Marinoa new target instead.
4402e4b17023SJohn Marino@end defmac
4403e4b17023SJohn Marino
4404e4b17023SJohn Marino@defmac LIBCALL_VALUE (@var{mode})
4405e4b17023SJohn MarinoA C expression to create an RTX representing the place where a library
4406e4b17023SJohn Marinofunction returns a value of mode @var{mode}.
4407e4b17023SJohn Marino
4408e4b17023SJohn MarinoNote that ``library function'' in this context means a compiler
4409e4b17023SJohn Marinosupport routine, used to perform arithmetic, whose name is known
4410e4b17023SJohn Marinospecially by the compiler and was not mentioned in the C code being
4411e4b17023SJohn Marinocompiled.
4412e4b17023SJohn Marino@end defmac
4413e4b17023SJohn Marino
4414e4b17023SJohn Marino@hook TARGET_LIBCALL_VALUE
4415e4b17023SJohn MarinoDefine this hook if the back-end needs to know the name of the libcall
4416e4b17023SJohn Marinofunction in order to determine where the result should be returned.
4417e4b17023SJohn Marino
4418e4b17023SJohn MarinoThe mode of the result is given by @var{mode} and the name of the called
4419e4b17023SJohn Marinolibrary function is given by @var{fun}.  The hook should return an RTX
4420e4b17023SJohn Marinorepresenting the place where the library function result will be returned.
4421e4b17023SJohn Marino
4422e4b17023SJohn MarinoIf this hook is not defined, then LIBCALL_VALUE will be used.
4423e4b17023SJohn Marino@end deftypefn
4424e4b17023SJohn Marino
4425e4b17023SJohn Marino@defmac FUNCTION_VALUE_REGNO_P (@var{regno})
4426e4b17023SJohn MarinoA C expression that is nonzero if @var{regno} is the number of a hard
4427e4b17023SJohn Marinoregister in which the values of called function may come back.
4428e4b17023SJohn Marino
4429e4b17023SJohn MarinoA register whose use for returning values is limited to serving as the
4430e4b17023SJohn Marinosecond of a pair (for a value of type @code{double}, say) need not be
4431e4b17023SJohn Marinorecognized by this macro.  So for most machines, this definition
4432e4b17023SJohn Marinosuffices:
4433e4b17023SJohn Marino
4434e4b17023SJohn Marino@smallexample
4435e4b17023SJohn Marino#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
4436e4b17023SJohn Marino@end smallexample
4437e4b17023SJohn Marino
4438e4b17023SJohn MarinoIf the machine has register windows, so that the caller and the called
4439e4b17023SJohn Marinofunction use different registers for the return value, this macro
4440e4b17023SJohn Marinoshould recognize only the caller's register numbers.
4441e4b17023SJohn Marino
4442e4b17023SJohn MarinoThis macro has been deprecated.  Use @code{TARGET_FUNCTION_VALUE_REGNO_P}
4443e4b17023SJohn Marinofor a new target instead.
4444e4b17023SJohn Marino@end defmac
4445e4b17023SJohn Marino
4446e4b17023SJohn Marino@hook TARGET_FUNCTION_VALUE_REGNO_P
4447e4b17023SJohn MarinoA target hook that return @code{true} if @var{regno} is the number of a hard
4448e4b17023SJohn Marinoregister in which the values of called function may come back.
4449e4b17023SJohn Marino
4450e4b17023SJohn MarinoA register whose use for returning values is limited to serving as the
4451e4b17023SJohn Marinosecond of a pair (for a value of type @code{double}, say) need not be
4452e4b17023SJohn Marinorecognized by this target hook.
4453e4b17023SJohn Marino
4454e4b17023SJohn MarinoIf the machine has register windows, so that the caller and the called
4455e4b17023SJohn Marinofunction use different registers for the return value, this target hook
4456e4b17023SJohn Marinoshould recognize only the caller's register numbers.
4457e4b17023SJohn Marino
4458e4b17023SJohn MarinoIf this hook is not defined, then FUNCTION_VALUE_REGNO_P will be used.
4459e4b17023SJohn Marino@end deftypefn
4460e4b17023SJohn Marino
4461e4b17023SJohn Marino@defmac APPLY_RESULT_SIZE
4462e4b17023SJohn MarinoDefine this macro if @samp{untyped_call} and @samp{untyped_return}
4463e4b17023SJohn Marinoneed more space than is implied by @code{FUNCTION_VALUE_REGNO_P} for
4464e4b17023SJohn Marinosaving and restoring an arbitrary return value.
4465e4b17023SJohn Marino@end defmac
4466e4b17023SJohn Marino
4467e4b17023SJohn Marino@hook TARGET_RETURN_IN_MSB
4468e4b17023SJohn MarinoThis hook should return true if values of type @var{type} are returned
4469e4b17023SJohn Marinoat the most significant end of a register (in other words, if they are
4470e4b17023SJohn Marinopadded at the least significant end).  You can assume that @var{type}
4471e4b17023SJohn Marinois returned in a register; the caller is required to check this.
4472e4b17023SJohn Marino
4473e4b17023SJohn MarinoNote that the register provided by @code{TARGET_FUNCTION_VALUE} must
4474e4b17023SJohn Marinobe able to hold the complete return value.  For example, if a 1-, 2-
4475e4b17023SJohn Marinoor 3-byte structure is returned at the most significant end of a
4476e4b17023SJohn Marino4-byte register, @code{TARGET_FUNCTION_VALUE} should provide an
4477e4b17023SJohn Marino@code{SImode} rtx.
4478e4b17023SJohn Marino@end deftypefn
4479e4b17023SJohn Marino
4480e4b17023SJohn Marino@node Aggregate Return
4481e4b17023SJohn Marino@subsection How Large Values Are Returned
4482e4b17023SJohn Marino@cindex aggregates as return values
4483e4b17023SJohn Marino@cindex large return values
4484e4b17023SJohn Marino@cindex returning aggregate values
4485e4b17023SJohn Marino@cindex structure value address
4486e4b17023SJohn Marino
4487e4b17023SJohn MarinoWhen a function value's mode is @code{BLKmode} (and in some other
4488e4b17023SJohn Marinocases), the value is not returned according to
4489e4b17023SJohn Marino@code{TARGET_FUNCTION_VALUE} (@pxref{Scalar Return}).  Instead, the
4490e4b17023SJohn Marinocaller passes the address of a block of memory in which the value
4491e4b17023SJohn Marinoshould be stored.  This address is called the @dfn{structure value
4492e4b17023SJohn Marinoaddress}.
4493e4b17023SJohn Marino
4494e4b17023SJohn MarinoThis section describes how to control returning structure values in
4495e4b17023SJohn Marinomemory.
4496e4b17023SJohn Marino
4497e4b17023SJohn Marino@hook TARGET_RETURN_IN_MEMORY
4498e4b17023SJohn MarinoThis target hook should return a nonzero value to say to return the
4499e4b17023SJohn Marinofunction value in memory, just as large structures are always returned.
4500e4b17023SJohn MarinoHere @var{type} will be the data type of the value, and @var{fntype}
4501e4b17023SJohn Marinowill be the type of the function doing the returning, or @code{NULL} for
4502e4b17023SJohn Marinolibcalls.
4503e4b17023SJohn Marino
4504e4b17023SJohn MarinoNote that values of mode @code{BLKmode} must be explicitly handled
4505e4b17023SJohn Marinoby this function.  Also, the option @option{-fpcc-struct-return}
4506e4b17023SJohn Marinotakes effect regardless of this macro.  On most systems, it is
4507e4b17023SJohn Marinopossible to leave the hook undefined; this causes a default
4508e4b17023SJohn Marinodefinition to be used, whose value is the constant 1 for @code{BLKmode}
4509e4b17023SJohn Marinovalues, and 0 otherwise.
4510e4b17023SJohn Marino
4511e4b17023SJohn MarinoDo not use this hook to indicate that structures and unions should always
4512e4b17023SJohn Marinobe returned in memory.  You should instead use @code{DEFAULT_PCC_STRUCT_RETURN}
4513e4b17023SJohn Marinoto indicate this.
4514e4b17023SJohn Marino@end deftypefn
4515e4b17023SJohn Marino
4516e4b17023SJohn Marino@defmac DEFAULT_PCC_STRUCT_RETURN
4517e4b17023SJohn MarinoDefine this macro to be 1 if all structure and union return values must be
4518e4b17023SJohn Marinoin memory.  Since this results in slower code, this should be defined
4519e4b17023SJohn Marinoonly if needed for compatibility with other compilers or with an ABI@.
4520e4b17023SJohn MarinoIf you define this macro to be 0, then the conventions used for structure
4521e4b17023SJohn Marinoand union return values are decided by the @code{TARGET_RETURN_IN_MEMORY}
4522e4b17023SJohn Marinotarget hook.
4523e4b17023SJohn Marino
4524e4b17023SJohn MarinoIf not defined, this defaults to the value 1.
4525e4b17023SJohn Marino@end defmac
4526e4b17023SJohn Marino
4527e4b17023SJohn Marino@hook TARGET_STRUCT_VALUE_RTX
4528e4b17023SJohn MarinoThis target hook should return the location of the structure value
4529e4b17023SJohn Marinoaddress (normally a @code{mem} or @code{reg}), or 0 if the address is
4530e4b17023SJohn Marinopassed as an ``invisible'' first argument.  Note that @var{fndecl} may
4531e4b17023SJohn Marinobe @code{NULL}, for libcalls.  You do not need to define this target
4532e4b17023SJohn Marinohook if the address is always passed as an ``invisible'' first
4533e4b17023SJohn Marinoargument.
4534e4b17023SJohn Marino
4535e4b17023SJohn MarinoOn some architectures the place where the structure value address
4536e4b17023SJohn Marinois found by the called function is not the same place that the
4537e4b17023SJohn Marinocaller put it.  This can be due to register windows, or it could
4538e4b17023SJohn Marinobe because the function prologue moves it to a different place.
4539e4b17023SJohn Marino@var{incoming} is @code{1} or @code{2} when the location is needed in
4540e4b17023SJohn Marinothe context of the called function, and @code{0} in the context of
4541e4b17023SJohn Marinothe caller.
4542e4b17023SJohn Marino
4543e4b17023SJohn MarinoIf @var{incoming} is nonzero and the address is to be found on the
4544e4b17023SJohn Marinostack, return a @code{mem} which refers to the frame pointer. If
4545e4b17023SJohn Marino@var{incoming} is @code{2}, the result is being used to fetch the
4546e4b17023SJohn Marinostructure value address at the beginning of a function.  If you need
4547e4b17023SJohn Marinoto emit adjusting code, you should do it at this point.
4548e4b17023SJohn Marino@end deftypefn
4549e4b17023SJohn Marino
4550e4b17023SJohn Marino@defmac PCC_STATIC_STRUCT_RETURN
4551e4b17023SJohn MarinoDefine this macro if the usual system convention on the target machine
4552e4b17023SJohn Marinofor returning structures and unions is for the called function to return
4553e4b17023SJohn Marinothe address of a static variable containing the value.
4554e4b17023SJohn Marino
4555e4b17023SJohn MarinoDo not define this if the usual system convention is for the caller to
4556e4b17023SJohn Marinopass an address to the subroutine.
4557e4b17023SJohn Marino
4558e4b17023SJohn MarinoThis macro has effect in @option{-fpcc-struct-return} mode, but it does
4559e4b17023SJohn Marinonothing when you use @option{-freg-struct-return} mode.
4560e4b17023SJohn Marino@end defmac
4561e4b17023SJohn Marino
4562e4b17023SJohn Marino@hook TARGET_GET_RAW_RESULT_MODE
4563e4b17023SJohn Marino
4564e4b17023SJohn Marino@hook TARGET_GET_RAW_ARG_MODE
4565e4b17023SJohn Marino
4566e4b17023SJohn Marino@node Caller Saves
4567e4b17023SJohn Marino@subsection Caller-Saves Register Allocation
4568e4b17023SJohn Marino
4569e4b17023SJohn MarinoIf you enable it, GCC can save registers around function calls.  This
4570e4b17023SJohn Marinomakes it possible to use call-clobbered registers to hold variables that
4571e4b17023SJohn Marinomust live across calls.
4572e4b17023SJohn Marino
4573e4b17023SJohn Marino@defmac CALLER_SAVE_PROFITABLE (@var{refs}, @var{calls})
4574e4b17023SJohn MarinoA C expression to determine whether it is worthwhile to consider placing
4575e4b17023SJohn Marinoa pseudo-register in a call-clobbered hard register and saving and
4576e4b17023SJohn Marinorestoring it around each function call.  The expression should be 1 when
4577e4b17023SJohn Marinothis is worth doing, and 0 otherwise.
4578e4b17023SJohn Marino
4579e4b17023SJohn MarinoIf you don't define this macro, a default is used which is good on most
4580e4b17023SJohn Marinomachines: @code{4 * @var{calls} < @var{refs}}.
4581e4b17023SJohn Marino@end defmac
4582e4b17023SJohn Marino
4583e4b17023SJohn Marino@defmac HARD_REGNO_CALLER_SAVE_MODE (@var{regno}, @var{nregs})
4584e4b17023SJohn MarinoA C expression specifying which mode is required for saving @var{nregs}
4585e4b17023SJohn Marinoof a pseudo-register in call-clobbered hard register @var{regno}.  If
4586e4b17023SJohn Marino@var{regno} is unsuitable for caller save, @code{VOIDmode} should be
4587e4b17023SJohn Marinoreturned.  For most machines this macro need not be defined since GCC
4588e4b17023SJohn Marinowill select the smallest suitable mode.
4589e4b17023SJohn Marino@end defmac
4590e4b17023SJohn Marino
4591e4b17023SJohn Marino@node Function Entry
4592e4b17023SJohn Marino@subsection Function Entry and Exit
4593e4b17023SJohn Marino@cindex function entry and exit
4594e4b17023SJohn Marino@cindex prologue
4595e4b17023SJohn Marino@cindex epilogue
4596e4b17023SJohn Marino
4597e4b17023SJohn MarinoThis section describes the macros that output function entry
4598e4b17023SJohn Marino(@dfn{prologue}) and exit (@dfn{epilogue}) code.
4599e4b17023SJohn Marino
4600e4b17023SJohn Marino@hook TARGET_ASM_FUNCTION_PROLOGUE
4601e4b17023SJohn MarinoIf defined, a function that outputs the assembler code for entry to a
4602e4b17023SJohn Marinofunction.  The prologue is responsible for setting up the stack frame,
4603e4b17023SJohn Marinoinitializing the frame pointer register, saving registers that must be
4604e4b17023SJohn Marinosaved, and allocating @var{size} additional bytes of storage for the
4605e4b17023SJohn Marinolocal variables.  @var{size} is an integer.  @var{file} is a stdio
4606e4b17023SJohn Marinostream to which the assembler code should be output.
4607e4b17023SJohn Marino
4608e4b17023SJohn MarinoThe label for the beginning of the function need not be output by this
4609e4b17023SJohn Marinomacro.  That has already been done when the macro is run.
4610e4b17023SJohn Marino
4611e4b17023SJohn Marino@findex regs_ever_live
4612e4b17023SJohn MarinoTo determine which registers to save, the macro can refer to the array
4613e4b17023SJohn Marino@code{regs_ever_live}: element @var{r} is nonzero if hard register
4614e4b17023SJohn Marino@var{r} is used anywhere within the function.  This implies the function
4615e4b17023SJohn Marinoprologue should save register @var{r}, provided it is not one of the
4616e4b17023SJohn Marinocall-used registers.  (@code{TARGET_ASM_FUNCTION_EPILOGUE} must likewise use
4617e4b17023SJohn Marino@code{regs_ever_live}.)
4618e4b17023SJohn Marino
4619e4b17023SJohn MarinoOn machines that have ``register windows'', the function entry code does
4620e4b17023SJohn Marinonot save on the stack the registers that are in the windows, even if
4621e4b17023SJohn Marinothey are supposed to be preserved by function calls; instead it takes
4622e4b17023SJohn Marinoappropriate steps to ``push'' the register stack, if any non-call-used
4623e4b17023SJohn Marinoregisters are used in the function.
4624e4b17023SJohn Marino
4625e4b17023SJohn Marino@findex frame_pointer_needed
4626e4b17023SJohn MarinoOn machines where functions may or may not have frame-pointers, the
4627e4b17023SJohn Marinofunction entry code must vary accordingly; it must set up the frame
4628e4b17023SJohn Marinopointer if one is wanted, and not otherwise.  To determine whether a
4629e4b17023SJohn Marinoframe pointer is in wanted, the macro can refer to the variable
4630e4b17023SJohn Marino@code{frame_pointer_needed}.  The variable's value will be 1 at run
4631e4b17023SJohn Marinotime in a function that needs a frame pointer.  @xref{Elimination}.
4632e4b17023SJohn Marino
4633e4b17023SJohn MarinoThe function entry code is responsible for allocating any stack space
4634e4b17023SJohn Marinorequired for the function.  This stack space consists of the regions
4635e4b17023SJohn Marinolisted below.  In most cases, these regions are allocated in the
4636e4b17023SJohn Marinoorder listed, with the last listed region closest to the top of the
4637e4b17023SJohn Marinostack (the lowest address if @code{STACK_GROWS_DOWNWARD} is defined, and
4638e4b17023SJohn Marinothe highest address if it is not defined).  You can use a different order
4639e4b17023SJohn Marinofor a machine if doing so is more convenient or required for
4640e4b17023SJohn Marinocompatibility reasons.  Except in cases where required by standard
4641e4b17023SJohn Marinoor by a debugger, there is no reason why the stack layout used by GCC
4642e4b17023SJohn Marinoneed agree with that used by other compilers for a machine.
4643e4b17023SJohn Marino@end deftypefn
4644e4b17023SJohn Marino
4645e4b17023SJohn Marino@hook TARGET_ASM_FUNCTION_END_PROLOGUE
4646e4b17023SJohn MarinoIf defined, a function that outputs assembler code at the end of a
4647e4b17023SJohn Marinoprologue.  This should be used when the function prologue is being
4648e4b17023SJohn Marinoemitted as RTL, and you have some extra assembler that needs to be
4649e4b17023SJohn Marinoemitted.  @xref{prologue instruction pattern}.
4650e4b17023SJohn Marino@end deftypefn
4651e4b17023SJohn Marino
4652e4b17023SJohn Marino@hook TARGET_ASM_FUNCTION_BEGIN_EPILOGUE
4653e4b17023SJohn MarinoIf defined, a function that outputs assembler code at the start of an
4654e4b17023SJohn Marinoepilogue.  This should be used when the function epilogue is being
4655e4b17023SJohn Marinoemitted as RTL, and you have some extra assembler that needs to be
4656e4b17023SJohn Marinoemitted.  @xref{epilogue instruction pattern}.
4657e4b17023SJohn Marino@end deftypefn
4658e4b17023SJohn Marino
4659e4b17023SJohn Marino@hook TARGET_ASM_FUNCTION_EPILOGUE
4660e4b17023SJohn MarinoIf defined, a function that outputs the assembler code for exit from a
4661e4b17023SJohn Marinofunction.  The epilogue is responsible for restoring the saved
4662e4b17023SJohn Marinoregisters and stack pointer to their values when the function was
4663e4b17023SJohn Marinocalled, and returning control to the caller.  This macro takes the
4664e4b17023SJohn Marinosame arguments as the macro @code{TARGET_ASM_FUNCTION_PROLOGUE}, and the
4665e4b17023SJohn Marinoregisters to restore are determined from @code{regs_ever_live} and
4666e4b17023SJohn Marino@code{CALL_USED_REGISTERS} in the same way.
4667e4b17023SJohn Marino
4668e4b17023SJohn MarinoOn some machines, there is a single instruction that does all the work
4669e4b17023SJohn Marinoof returning from the function.  On these machines, give that
4670e4b17023SJohn Marinoinstruction the name @samp{return} and do not define the macro
4671e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} at all.
4672e4b17023SJohn Marino
4673e4b17023SJohn MarinoDo not define a pattern named @samp{return} if you want the
4674e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} to be used.  If you want the target
4675e4b17023SJohn Marinoswitches to control whether return instructions or epilogues are used,
4676e4b17023SJohn Marinodefine a @samp{return} pattern with a validity condition that tests the
4677e4b17023SJohn Marinotarget switches appropriately.  If the @samp{return} pattern's validity
4678e4b17023SJohn Marinocondition is false, epilogues will be used.
4679e4b17023SJohn Marino
4680e4b17023SJohn MarinoOn machines where functions may or may not have frame-pointers, the
4681e4b17023SJohn Marinofunction exit code must vary accordingly.  Sometimes the code for these
4682e4b17023SJohn Marinotwo cases is completely different.  To determine whether a frame pointer
4683e4b17023SJohn Marinois wanted, the macro can refer to the variable
4684e4b17023SJohn Marino@code{frame_pointer_needed}.  The variable's value will be 1 when compiling
4685e4b17023SJohn Marinoa function that needs a frame pointer.
4686e4b17023SJohn Marino
4687e4b17023SJohn MarinoNormally, @code{TARGET_ASM_FUNCTION_PROLOGUE} and
4688e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} must treat leaf functions specially.
4689e4b17023SJohn MarinoThe C variable @code{current_function_is_leaf} is nonzero for such a
4690e4b17023SJohn Marinofunction.  @xref{Leaf Functions}.
4691e4b17023SJohn Marino
4692e4b17023SJohn MarinoOn some machines, some functions pop their arguments on exit while
4693e4b17023SJohn Marinoothers leave that for the caller to do.  For example, the 68020 when
4694e4b17023SJohn Marinogiven @option{-mrtd} pops arguments in functions that take a fixed
4695e4b17023SJohn Marinonumber of arguments.
4696e4b17023SJohn Marino
4697e4b17023SJohn Marino@findex current_function_pops_args
4698e4b17023SJohn MarinoYour definition of the macro @code{RETURN_POPS_ARGS} decides which
4699e4b17023SJohn Marinofunctions pop their own arguments.  @code{TARGET_ASM_FUNCTION_EPILOGUE}
4700e4b17023SJohn Marinoneeds to know what was decided.  The number of bytes of the current
4701e4b17023SJohn Marinofunction's arguments that this function should pop is available in
4702e4b17023SJohn Marino@code{crtl->args.pops_args}.  @xref{Scalar Return}.
4703e4b17023SJohn Marino@end deftypefn
4704e4b17023SJohn Marino
4705e4b17023SJohn Marino@itemize @bullet
4706e4b17023SJohn Marino@item
4707e4b17023SJohn Marino@findex current_function_pretend_args_size
4708e4b17023SJohn MarinoA region of @code{current_function_pretend_args_size} bytes of
4709e4b17023SJohn Marinouninitialized space just underneath the first argument arriving on the
4710e4b17023SJohn Marinostack.  (This may not be at the very start of the allocated stack region
4711e4b17023SJohn Marinoif the calling sequence has pushed anything else since pushing the stack
4712e4b17023SJohn Marinoarguments.  But usually, on such machines, nothing else has been pushed
4713e4b17023SJohn Marinoyet, because the function prologue itself does all the pushing.)  This
4714e4b17023SJohn Marinoregion is used on machines where an argument may be passed partly in
4715e4b17023SJohn Marinoregisters and partly in memory, and, in some cases to support the
4716e4b17023SJohn Marinofeatures in @code{<stdarg.h>}.
4717e4b17023SJohn Marino
4718e4b17023SJohn Marino@item
4719e4b17023SJohn MarinoAn area of memory used to save certain registers used by the function.
4720e4b17023SJohn MarinoThe size of this area, which may also include space for such things as
4721e4b17023SJohn Marinothe return address and pointers to previous stack frames, is
4722e4b17023SJohn Marinomachine-specific and usually depends on which registers have been used
4723e4b17023SJohn Marinoin the function.  Machines with register windows often do not require
4724e4b17023SJohn Marinoa save area.
4725e4b17023SJohn Marino
4726e4b17023SJohn Marino@item
4727e4b17023SJohn MarinoA region of at least @var{size} bytes, possibly rounded up to an allocation
4728e4b17023SJohn Marinoboundary, to contain the local variables of the function.  On some machines,
4729e4b17023SJohn Marinothis region and the save area may occur in the opposite order, with the
4730e4b17023SJohn Marinosave area closer to the top of the stack.
4731e4b17023SJohn Marino
4732e4b17023SJohn Marino@item
4733e4b17023SJohn Marino@cindex @code{ACCUMULATE_OUTGOING_ARGS} and stack frames
4734e4b17023SJohn MarinoOptionally, when @code{ACCUMULATE_OUTGOING_ARGS} is defined, a region of
4735e4b17023SJohn Marino@code{current_function_outgoing_args_size} bytes to be used for outgoing
4736e4b17023SJohn Marinoargument lists of the function.  @xref{Stack Arguments}.
4737e4b17023SJohn Marino@end itemize
4738e4b17023SJohn Marino
4739e4b17023SJohn Marino@defmac EXIT_IGNORE_STACK
4740e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero if the return
4741e4b17023SJohn Marinoinstruction or the function epilogue ignores the value of the stack
4742e4b17023SJohn Marinopointer; in other words, if it is safe to delete an instruction to
4743e4b17023SJohn Marinoadjust the stack pointer before a return from the function.  The
4744e4b17023SJohn Marinodefault is 0.
4745e4b17023SJohn Marino
4746e4b17023SJohn MarinoNote that this macro's value is relevant only for functions for which
4747e4b17023SJohn Marinoframe pointers are maintained.  It is never safe to delete a final
4748e4b17023SJohn Marinostack adjustment in a function that has no frame pointer, and the
4749e4b17023SJohn Marinocompiler knows this regardless of @code{EXIT_IGNORE_STACK}.
4750e4b17023SJohn Marino@end defmac
4751e4b17023SJohn Marino
4752e4b17023SJohn Marino@defmac EPILOGUE_USES (@var{regno})
4753e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero for registers that are
4754e4b17023SJohn Marinoused by the epilogue or the @samp{return} pattern.  The stack and frame
4755e4b17023SJohn Marinopointer registers are already assumed to be used as needed.
4756e4b17023SJohn Marino@end defmac
4757e4b17023SJohn Marino
4758e4b17023SJohn Marino@defmac EH_USES (@var{regno})
4759e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero for registers that are
4760e4b17023SJohn Marinoused by the exception handling mechanism, and so should be considered live
4761e4b17023SJohn Marinoon entry to an exception edge.
4762e4b17023SJohn Marino@end defmac
4763e4b17023SJohn Marino
4764e4b17023SJohn Marino@defmac DELAY_SLOTS_FOR_EPILOGUE
4765e4b17023SJohn MarinoDefine this macro if the function epilogue contains delay slots to which
4766e4b17023SJohn Marinoinstructions from the rest of the function can be ``moved''.  The
4767e4b17023SJohn Marinodefinition should be a C expression whose value is an integer
4768e4b17023SJohn Marinorepresenting the number of delay slots there.
4769e4b17023SJohn Marino@end defmac
4770e4b17023SJohn Marino
4771e4b17023SJohn Marino@defmac ELIGIBLE_FOR_EPILOGUE_DELAY (@var{insn}, @var{n})
4772e4b17023SJohn MarinoA C expression that returns 1 if @var{insn} can be placed in delay
4773e4b17023SJohn Marinoslot number @var{n} of the epilogue.
4774e4b17023SJohn Marino
4775e4b17023SJohn MarinoThe argument @var{n} is an integer which identifies the delay slot now
4776e4b17023SJohn Marinobeing considered (since different slots may have different rules of
4777e4b17023SJohn Marinoeligibility).  It is never negative and is always less than the number
4778e4b17023SJohn Marinoof epilogue delay slots (what @code{DELAY_SLOTS_FOR_EPILOGUE} returns).
4779e4b17023SJohn MarinoIf you reject a particular insn for a given delay slot, in principle, it
4780e4b17023SJohn Marinomay be reconsidered for a subsequent delay slot.  Also, other insns may
4781e4b17023SJohn Marino(at least in principle) be considered for the so far unfilled delay
4782e4b17023SJohn Marinoslot.
4783e4b17023SJohn Marino
4784e4b17023SJohn Marino@findex current_function_epilogue_delay_list
4785e4b17023SJohn Marino@findex final_scan_insn
4786e4b17023SJohn MarinoThe insns accepted to fill the epilogue delay slots are put in an RTL
4787e4b17023SJohn Marinolist made with @code{insn_list} objects, stored in the variable
4788e4b17023SJohn Marino@code{current_function_epilogue_delay_list}.  The insn for the first
4789e4b17023SJohn Marinodelay slot comes first in the list.  Your definition of the macro
4790e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} should fill the delay slots by
4791e4b17023SJohn Marinooutputting the insns in this list, usually by calling
4792e4b17023SJohn Marino@code{final_scan_insn}.
4793e4b17023SJohn Marino
4794e4b17023SJohn MarinoYou need not define this macro if you did not define
4795e4b17023SJohn Marino@code{DELAY_SLOTS_FOR_EPILOGUE}.
4796e4b17023SJohn Marino@end defmac
4797e4b17023SJohn Marino
4798e4b17023SJohn Marino@hook TARGET_ASM_OUTPUT_MI_THUNK
4799e4b17023SJohn MarinoA function that outputs the assembler code for a thunk
4800e4b17023SJohn Marinofunction, used to implement C++ virtual function calls with multiple
4801e4b17023SJohn Marinoinheritance.  The thunk acts as a wrapper around a virtual function,
4802e4b17023SJohn Marinoadjusting the implicit object parameter before handing control off to
4803e4b17023SJohn Marinothe real function.
4804e4b17023SJohn Marino
4805e4b17023SJohn MarinoFirst, emit code to add the integer @var{delta} to the location that
4806e4b17023SJohn Marinocontains the incoming first argument.  Assume that this argument
4807e4b17023SJohn Marinocontains a pointer, and is the one used to pass the @code{this} pointer
4808e4b17023SJohn Marinoin C++.  This is the incoming argument @emph{before} the function prologue,
4809e4b17023SJohn Marinoe.g.@: @samp{%o0} on a sparc.  The addition must preserve the values of
4810e4b17023SJohn Marinoall other incoming arguments.
4811e4b17023SJohn Marino
4812e4b17023SJohn MarinoThen, if @var{vcall_offset} is nonzero, an additional adjustment should be
4813e4b17023SJohn Marinomade after adding @code{delta}.  In particular, if @var{p} is the
4814e4b17023SJohn Marinoadjusted pointer, the following adjustment should be made:
4815e4b17023SJohn Marino
4816e4b17023SJohn Marino@smallexample
4817e4b17023SJohn Marinop += (*((ptrdiff_t **)p))[vcall_offset/sizeof(ptrdiff_t)]
4818e4b17023SJohn Marino@end smallexample
4819e4b17023SJohn Marino
4820e4b17023SJohn MarinoAfter the additions, emit code to jump to @var{function}, which is a
4821e4b17023SJohn Marino@code{FUNCTION_DECL}.  This is a direct pure jump, not a call, and does
4822e4b17023SJohn Marinonot touch the return address.  Hence returning from @var{FUNCTION} will
4823e4b17023SJohn Marinoreturn to whoever called the current @samp{thunk}.
4824e4b17023SJohn Marino
4825e4b17023SJohn MarinoThe effect must be as if @var{function} had been called directly with
4826e4b17023SJohn Marinothe adjusted first argument.  This macro is responsible for emitting all
4827e4b17023SJohn Marinoof the code for a thunk function; @code{TARGET_ASM_FUNCTION_PROLOGUE}
4828e4b17023SJohn Marinoand @code{TARGET_ASM_FUNCTION_EPILOGUE} are not invoked.
4829e4b17023SJohn Marino
4830e4b17023SJohn MarinoThe @var{thunk_fndecl} is redundant.  (@var{delta} and @var{function}
4831e4b17023SJohn Marinohave already been extracted from it.)  It might possibly be useful on
4832e4b17023SJohn Marinosome targets, but probably not.
4833e4b17023SJohn Marino
4834e4b17023SJohn MarinoIf you do not define this macro, the target-independent code in the C++
4835e4b17023SJohn Marinofront end will generate a less efficient heavyweight thunk that calls
4836e4b17023SJohn Marino@var{function} instead of jumping to it.  The generic approach does
4837e4b17023SJohn Marinonot support varargs.
4838e4b17023SJohn Marino@end deftypefn
4839e4b17023SJohn Marino
4840e4b17023SJohn Marino@hook TARGET_ASM_CAN_OUTPUT_MI_THUNK
4841e4b17023SJohn MarinoA function that returns true if TARGET_ASM_OUTPUT_MI_THUNK would be able
4842e4b17023SJohn Marinoto output the assembler code for the thunk function specified by the
4843e4b17023SJohn Marinoarguments it is passed, and false otherwise.  In the latter case, the
4844e4b17023SJohn Marinogeneric approach will be used by the C++ front end, with the limitations
4845e4b17023SJohn Marinopreviously exposed.
4846e4b17023SJohn Marino@end deftypefn
4847e4b17023SJohn Marino
4848e4b17023SJohn Marino@node Profiling
4849e4b17023SJohn Marino@subsection Generating Code for Profiling
4850e4b17023SJohn Marino@cindex profiling, code generation
4851e4b17023SJohn Marino
4852e4b17023SJohn MarinoThese macros will help you generate code for profiling.
4853e4b17023SJohn Marino
4854e4b17023SJohn Marino@defmac FUNCTION_PROFILER (@var{file}, @var{labelno})
4855e4b17023SJohn MarinoA C statement or compound statement to output to @var{file} some
4856e4b17023SJohn Marinoassembler code to call the profiling subroutine @code{mcount}.
4857e4b17023SJohn Marino
4858e4b17023SJohn Marino@findex mcount
4859e4b17023SJohn MarinoThe details of how @code{mcount} expects to be called are determined by
4860e4b17023SJohn Marinoyour operating system environment, not by GCC@.  To figure them out,
4861e4b17023SJohn Marinocompile a small program for profiling using the system's installed C
4862e4b17023SJohn Marinocompiler and look at the assembler code that results.
4863e4b17023SJohn Marino
4864e4b17023SJohn MarinoOlder implementations of @code{mcount} expect the address of a counter
4865e4b17023SJohn Marinovariable to be loaded into some register.  The name of this variable is
4866e4b17023SJohn Marino@samp{LP} followed by the number @var{labelno}, so you would generate
4867e4b17023SJohn Marinothe name using @samp{LP%d} in a @code{fprintf}.
4868e4b17023SJohn Marino@end defmac
4869e4b17023SJohn Marino
4870e4b17023SJohn Marino@defmac PROFILE_HOOK
4871e4b17023SJohn MarinoA C statement or compound statement to output to @var{file} some assembly
4872e4b17023SJohn Marinocode to call the profiling subroutine @code{mcount} even the target does
4873e4b17023SJohn Marinonot support profiling.
4874e4b17023SJohn Marino@end defmac
4875e4b17023SJohn Marino
4876e4b17023SJohn Marino@defmac NO_PROFILE_COUNTERS
4877e4b17023SJohn MarinoDefine this macro to be an expression with a nonzero value if the
4878e4b17023SJohn Marino@code{mcount} subroutine on your system does not need a counter variable
4879e4b17023SJohn Marinoallocated for each function.  This is true for almost all modern
4880e4b17023SJohn Marinoimplementations.  If you define this macro, you must not use the
4881e4b17023SJohn Marino@var{labelno} argument to @code{FUNCTION_PROFILER}.
4882e4b17023SJohn Marino@end defmac
4883e4b17023SJohn Marino
4884e4b17023SJohn Marino@defmac PROFILE_BEFORE_PROLOGUE
4885e4b17023SJohn MarinoDefine this macro if the code for function profiling should come before
4886e4b17023SJohn Marinothe function prologue.  Normally, the profiling code comes after.
4887e4b17023SJohn Marino@end defmac
4888e4b17023SJohn Marino
4889e4b17023SJohn Marino@node Tail Calls
4890e4b17023SJohn Marino@subsection Permitting tail calls
4891e4b17023SJohn Marino@cindex tail calls
4892e4b17023SJohn Marino
4893e4b17023SJohn Marino@hook TARGET_FUNCTION_OK_FOR_SIBCALL
4894e4b17023SJohn MarinoTrue if it is ok to do sibling call optimization for the specified
4895e4b17023SJohn Marinocall expression @var{exp}.  @var{decl} will be the called function,
4896e4b17023SJohn Marinoor @code{NULL} if this is an indirect call.
4897e4b17023SJohn Marino
4898e4b17023SJohn MarinoIt is not uncommon for limitations of calling conventions to prevent
4899e4b17023SJohn Marinotail calls to functions outside the current unit of translation, or
4900e4b17023SJohn Marinoduring PIC compilation.  The hook is used to enforce these restrictions,
4901e4b17023SJohn Marinoas the @code{sibcall} md pattern can not fail, or fall over to a
4902e4b17023SJohn Marino``normal'' call.  The criteria for successful sibling call optimization
4903e4b17023SJohn Marinomay vary greatly between different architectures.
4904e4b17023SJohn Marino@end deftypefn
4905e4b17023SJohn Marino
4906e4b17023SJohn Marino@hook TARGET_EXTRA_LIVE_ON_ENTRY
4907e4b17023SJohn MarinoAdd any hard registers to @var{regs} that are live on entry to the
4908e4b17023SJohn Marinofunction.  This hook only needs to be defined to provide registers that
4909e4b17023SJohn Marinocannot be found by examination of FUNCTION_ARG_REGNO_P, the callee saved
4910e4b17023SJohn Marinoregisters, STATIC_CHAIN_INCOMING_REGNUM, STATIC_CHAIN_REGNUM,
4911e4b17023SJohn MarinoTARGET_STRUCT_VALUE_RTX, FRAME_POINTER_REGNUM, EH_USES,
4912e4b17023SJohn MarinoFRAME_POINTER_REGNUM, ARG_POINTER_REGNUM, and the PIC_OFFSET_TABLE_REGNUM.
4913e4b17023SJohn Marino@end deftypefn
4914e4b17023SJohn Marino
4915e4b17023SJohn Marino@hook TARGET_SET_UP_BY_PROLOGUE
4916e4b17023SJohn Marino
4917e4b17023SJohn Marino@node Stack Smashing Protection
4918e4b17023SJohn Marino@subsection Stack smashing protection
4919e4b17023SJohn Marino@cindex stack smashing protection
4920e4b17023SJohn Marino
4921e4b17023SJohn Marino@hook TARGET_STACK_PROTECT_GUARD
4922e4b17023SJohn MarinoThis hook returns a @code{DECL} node for the external variable to use
4923e4b17023SJohn Marinofor the stack protection guard.  This variable is initialized by the
4924e4b17023SJohn Marinoruntime to some random value and is used to initialize the guard value
4925e4b17023SJohn Marinothat is placed at the top of the local stack frame.  The type of this
4926e4b17023SJohn Marinovariable must be @code{ptr_type_node}.
4927e4b17023SJohn Marino
4928e4b17023SJohn MarinoThe default version of this hook creates a variable called
4929e4b17023SJohn Marino@samp{__stack_chk_guard}, which is normally defined in @file{libgcc2.c}.
4930e4b17023SJohn Marino@end deftypefn
4931e4b17023SJohn Marino
4932e4b17023SJohn Marino@hook TARGET_STACK_PROTECT_FAIL
4933e4b17023SJohn MarinoThis hook returns a tree expression that alerts the runtime that the
4934e4b17023SJohn Marinostack protect guard variable has been modified.  This expression should
4935e4b17023SJohn Marinoinvolve a call to a @code{noreturn} function.
4936e4b17023SJohn Marino
4937e4b17023SJohn MarinoThe default version of this hook invokes a function called
4938e4b17023SJohn Marino@samp{__stack_chk_fail}, taking no arguments.  This function is
4939e4b17023SJohn Marinonormally defined in @file{libgcc2.c}.
4940e4b17023SJohn Marino@end deftypefn
4941e4b17023SJohn Marino
4942e4b17023SJohn Marino@hook TARGET_SUPPORTS_SPLIT_STACK
4943e4b17023SJohn Marino
4944e4b17023SJohn Marino@node Varargs
4945e4b17023SJohn Marino@section Implementing the Varargs Macros
4946e4b17023SJohn Marino@cindex varargs implementation
4947e4b17023SJohn Marino
4948e4b17023SJohn MarinoGCC comes with an implementation of @code{<varargs.h>} and
4949e4b17023SJohn Marino@code{<stdarg.h>} that work without change on machines that pass arguments
4950e4b17023SJohn Marinoon the stack.  Other machines require their own implementations of
4951e4b17023SJohn Marinovarargs, and the two machine independent header files must have
4952e4b17023SJohn Marinoconditionals to include it.
4953e4b17023SJohn Marino
4954e4b17023SJohn MarinoISO @code{<stdarg.h>} differs from traditional @code{<varargs.h>} mainly in
4955e4b17023SJohn Marinothe calling convention for @code{va_start}.  The traditional
4956e4b17023SJohn Marinoimplementation takes just one argument, which is the variable in which
4957e4b17023SJohn Marinoto store the argument pointer.  The ISO implementation of
4958e4b17023SJohn Marino@code{va_start} takes an additional second argument.  The user is
4959e4b17023SJohn Marinosupposed to write the last named argument of the function here.
4960e4b17023SJohn Marino
4961e4b17023SJohn MarinoHowever, @code{va_start} should not use this argument.  The way to find
4962e4b17023SJohn Marinothe end of the named arguments is with the built-in functions described
4963e4b17023SJohn Marinobelow.
4964e4b17023SJohn Marino
4965e4b17023SJohn Marino@defmac __builtin_saveregs ()
4966e4b17023SJohn MarinoUse this built-in function to save the argument registers in memory so
4967e4b17023SJohn Marinothat the varargs mechanism can access them.  Both ISO and traditional
4968e4b17023SJohn Marinoversions of @code{va_start} must use @code{__builtin_saveregs}, unless
4969e4b17023SJohn Marinoyou use @code{TARGET_SETUP_INCOMING_VARARGS} (see below) instead.
4970e4b17023SJohn Marino
4971e4b17023SJohn MarinoOn some machines, @code{__builtin_saveregs} is open-coded under the
4972e4b17023SJohn Marinocontrol of the target hook @code{TARGET_EXPAND_BUILTIN_SAVEREGS}.  On
4973e4b17023SJohn Marinoother machines, it calls a routine written in assembler language,
4974e4b17023SJohn Marinofound in @file{libgcc2.c}.
4975e4b17023SJohn Marino
4976e4b17023SJohn MarinoCode generated for the call to @code{__builtin_saveregs} appears at the
4977e4b17023SJohn Marinobeginning of the function, as opposed to where the call to
4978e4b17023SJohn Marino@code{__builtin_saveregs} is written, regardless of what the code is.
4979e4b17023SJohn MarinoThis is because the registers must be saved before the function starts
4980e4b17023SJohn Marinoto use them for its own purposes.
4981e4b17023SJohn Marino@c i rewrote the first sentence above to fix an overfull hbox. --mew
4982e4b17023SJohn Marino@c 10feb93
4983e4b17023SJohn Marino@end defmac
4984e4b17023SJohn Marino
4985e4b17023SJohn Marino@defmac __builtin_next_arg (@var{lastarg})
4986e4b17023SJohn MarinoThis builtin returns the address of the first anonymous stack
4987e4b17023SJohn Marinoargument, as type @code{void *}.  If @code{ARGS_GROW_DOWNWARD}, it
4988e4b17023SJohn Marinoreturns the address of the location above the first anonymous stack
4989e4b17023SJohn Marinoargument.  Use it in @code{va_start} to initialize the pointer for
4990e4b17023SJohn Marinofetching arguments from the stack.  Also use it in @code{va_start} to
4991e4b17023SJohn Marinoverify that the second parameter @var{lastarg} is the last named argument
4992e4b17023SJohn Marinoof the current function.
4993e4b17023SJohn Marino@end defmac
4994e4b17023SJohn Marino
4995e4b17023SJohn Marino@defmac __builtin_classify_type (@var{object})
4996e4b17023SJohn MarinoSince each machine has its own conventions for which data types are
4997e4b17023SJohn Marinopassed in which kind of register, your implementation of @code{va_arg}
4998e4b17023SJohn Marinohas to embody these conventions.  The easiest way to categorize the
4999e4b17023SJohn Marinospecified data type is to use @code{__builtin_classify_type} together
5000e4b17023SJohn Marinowith @code{sizeof} and @code{__alignof__}.
5001e4b17023SJohn Marino
5002e4b17023SJohn Marino@code{__builtin_classify_type} ignores the value of @var{object},
5003e4b17023SJohn Marinoconsidering only its data type.  It returns an integer describing what
5004e4b17023SJohn Marinokind of type that is---integer, floating, pointer, structure, and so on.
5005e4b17023SJohn Marino
5006e4b17023SJohn MarinoThe file @file{typeclass.h} defines an enumeration that you can use to
5007e4b17023SJohn Marinointerpret the values of @code{__builtin_classify_type}.
5008e4b17023SJohn Marino@end defmac
5009e4b17023SJohn Marino
5010e4b17023SJohn MarinoThese machine description macros help implement varargs:
5011e4b17023SJohn Marino
5012e4b17023SJohn Marino@hook TARGET_EXPAND_BUILTIN_SAVEREGS
5013e4b17023SJohn MarinoIf defined, this hook produces the machine-specific code for a call to
5014e4b17023SJohn Marino@code{__builtin_saveregs}.  This code will be moved to the very
5015e4b17023SJohn Marinobeginning of the function, before any parameter access are made.  The
5016e4b17023SJohn Marinoreturn value of this function should be an RTX that contains the value
5017e4b17023SJohn Marinoto use as the return of @code{__builtin_saveregs}.
5018e4b17023SJohn Marino@end deftypefn
5019e4b17023SJohn Marino
5020e4b17023SJohn Marino@hook TARGET_SETUP_INCOMING_VARARGS
5021e4b17023SJohn MarinoThis target hook offers an alternative to using
5022e4b17023SJohn Marino@code{__builtin_saveregs} and defining the hook
5023e4b17023SJohn Marino@code{TARGET_EXPAND_BUILTIN_SAVEREGS}.  Use it to store the anonymous
5024e4b17023SJohn Marinoregister arguments into the stack so that all the arguments appear to
5025e4b17023SJohn Marinohave been passed consecutively on the stack.  Once this is done, you can
5026e4b17023SJohn Marinouse the standard implementation of varargs that works for machines that
5027e4b17023SJohn Marinopass all their arguments on the stack.
5028e4b17023SJohn Marino
5029e4b17023SJohn MarinoThe argument @var{args_so_far} points to the @code{CUMULATIVE_ARGS} data
5030e4b17023SJohn Marinostructure, containing the values that are obtained after processing the
5031e4b17023SJohn Marinonamed arguments.  The arguments @var{mode} and @var{type} describe the
5032e4b17023SJohn Marinolast named argument---its machine mode and its data type as a tree node.
5033e4b17023SJohn Marino
5034e4b17023SJohn MarinoThe target hook should do two things: first, push onto the stack all the
5035e4b17023SJohn Marinoargument registers @emph{not} used for the named arguments, and second,
5036e4b17023SJohn Marinostore the size of the data thus pushed into the @code{int}-valued
5037e4b17023SJohn Marinovariable pointed to by @var{pretend_args_size}.  The value that you
5038e4b17023SJohn Marinostore here will serve as additional offset for setting up the stack
5039e4b17023SJohn Marinoframe.
5040e4b17023SJohn Marino
5041e4b17023SJohn MarinoBecause you must generate code to push the anonymous arguments at
5042e4b17023SJohn Marinocompile time without knowing their data types,
5043e4b17023SJohn Marino@code{TARGET_SETUP_INCOMING_VARARGS} is only useful on machines that
5044e4b17023SJohn Marinohave just a single category of argument register and use it uniformly
5045e4b17023SJohn Marinofor all data types.
5046e4b17023SJohn Marino
5047e4b17023SJohn MarinoIf the argument @var{second_time} is nonzero, it means that the
5048e4b17023SJohn Marinoarguments of the function are being analyzed for the second time.  This
5049e4b17023SJohn Marinohappens for an inline function, which is not actually compiled until the
5050e4b17023SJohn Marinoend of the source file.  The hook @code{TARGET_SETUP_INCOMING_VARARGS} should
5051e4b17023SJohn Marinonot generate any instructions in this case.
5052e4b17023SJohn Marino@end deftypefn
5053e4b17023SJohn Marino
5054e4b17023SJohn Marino@hook TARGET_STRICT_ARGUMENT_NAMING
5055e4b17023SJohn MarinoDefine this hook to return @code{true} if the location where a function
5056e4b17023SJohn Marinoargument is passed depends on whether or not it is a named argument.
5057e4b17023SJohn Marino
5058e4b17023SJohn MarinoThis hook controls how the @var{named} argument to @code{TARGET_FUNCTION_ARG}
5059e4b17023SJohn Marinois set for varargs and stdarg functions.  If this hook returns
5060e4b17023SJohn Marino@code{true}, the @var{named} argument is always true for named
5061e4b17023SJohn Marinoarguments, and false for unnamed arguments.  If it returns @code{false},
5062e4b17023SJohn Marinobut @code{TARGET_PRETEND_OUTGOING_VARARGS_NAMED} returns @code{true},
5063e4b17023SJohn Marinothen all arguments are treated as named.  Otherwise, all named arguments
5064e4b17023SJohn Marinoexcept the last are treated as named.
5065e4b17023SJohn Marino
5066e4b17023SJohn MarinoYou need not define this hook if it always returns @code{false}.
5067e4b17023SJohn Marino@end deftypefn
5068e4b17023SJohn Marino
5069e4b17023SJohn Marino@hook TARGET_PRETEND_OUTGOING_VARARGS_NAMED
5070e4b17023SJohn MarinoIf you need to conditionally change ABIs so that one works with
5071e4b17023SJohn Marino@code{TARGET_SETUP_INCOMING_VARARGS}, but the other works like neither
5072e4b17023SJohn Marino@code{TARGET_SETUP_INCOMING_VARARGS} nor @code{TARGET_STRICT_ARGUMENT_NAMING} was
5073e4b17023SJohn Marinodefined, then define this hook to return @code{true} if
5074e4b17023SJohn Marino@code{TARGET_SETUP_INCOMING_VARARGS} is used, @code{false} otherwise.
5075e4b17023SJohn MarinoOtherwise, you should not define this hook.
5076e4b17023SJohn Marino@end deftypefn
5077e4b17023SJohn Marino
5078e4b17023SJohn Marino@node Trampolines
5079e4b17023SJohn Marino@section Trampolines for Nested Functions
5080e4b17023SJohn Marino@cindex trampolines for nested functions
5081e4b17023SJohn Marino@cindex nested functions, trampolines for
5082e4b17023SJohn Marino
5083e4b17023SJohn MarinoA @dfn{trampoline} is a small piece of code that is created at run time
5084e4b17023SJohn Marinowhen the address of a nested function is taken.  It normally resides on
5085e4b17023SJohn Marinothe stack, in the stack frame of the containing function.  These macros
5086e4b17023SJohn Marinotell GCC how to generate code to allocate and initialize a
5087e4b17023SJohn Marinotrampoline.
5088e4b17023SJohn Marino
5089e4b17023SJohn MarinoThe instructions in the trampoline must do two things: load a constant
5090e4b17023SJohn Marinoaddress into the static chain register, and jump to the real address of
5091e4b17023SJohn Marinothe nested function.  On CISC machines such as the m68k, this requires
5092e4b17023SJohn Marinotwo instructions, a move immediate and a jump.  Then the two addresses
5093e4b17023SJohn Marinoexist in the trampoline as word-long immediate operands.  On RISC
5094e4b17023SJohn Marinomachines, it is often necessary to load each address into a register in
5095e4b17023SJohn Marinotwo parts.  Then pieces of each address form separate immediate
5096e4b17023SJohn Marinooperands.
5097e4b17023SJohn Marino
5098e4b17023SJohn MarinoThe code generated to initialize the trampoline must store the variable
5099e4b17023SJohn Marinoparts---the static chain value and the function address---into the
5100e4b17023SJohn Marinoimmediate operands of the instructions.  On a CISC machine, this is
5101e4b17023SJohn Marinosimply a matter of copying each address to a memory reference at the
5102e4b17023SJohn Marinoproper offset from the start of the trampoline.  On a RISC machine, it
5103e4b17023SJohn Marinomay be necessary to take out pieces of the address and store them
5104e4b17023SJohn Marinoseparately.
5105e4b17023SJohn Marino
5106e4b17023SJohn Marino@hook TARGET_ASM_TRAMPOLINE_TEMPLATE
5107e4b17023SJohn MarinoThis hook is called by @code{assemble_trampoline_template} to output,
5108e4b17023SJohn Marinoon the stream @var{f}, assembler code for a block of data that contains
5109e4b17023SJohn Marinothe constant parts of a trampoline.  This code should not include a
5110e4b17023SJohn Marinolabel---the label is taken care of automatically.
5111e4b17023SJohn Marino
5112e4b17023SJohn MarinoIf you do not define this hook, it means no template is needed
5113e4b17023SJohn Marinofor the target.  Do not define this hook on systems where the block move
5114e4b17023SJohn Marinocode to copy the trampoline into place would be larger than the code
5115e4b17023SJohn Marinoto generate it on the spot.
5116e4b17023SJohn Marino@end deftypefn
5117e4b17023SJohn Marino
5118e4b17023SJohn Marino@defmac TRAMPOLINE_SECTION
5119e4b17023SJohn MarinoReturn the section into which the trampoline template is to be placed
5120e4b17023SJohn Marino(@pxref{Sections}).  The default value is @code{readonly_data_section}.
5121e4b17023SJohn Marino@end defmac
5122e4b17023SJohn Marino
5123e4b17023SJohn Marino@defmac TRAMPOLINE_SIZE
5124e4b17023SJohn MarinoA C expression for the size in bytes of the trampoline, as an integer.
5125e4b17023SJohn Marino@end defmac
5126e4b17023SJohn Marino
5127e4b17023SJohn Marino@defmac TRAMPOLINE_ALIGNMENT
5128e4b17023SJohn MarinoAlignment required for trampolines, in bits.
5129e4b17023SJohn Marino
5130e4b17023SJohn MarinoIf you don't define this macro, the value of @code{FUNCTION_ALIGNMENT}
5131e4b17023SJohn Marinois used for aligning trampolines.
5132e4b17023SJohn Marino@end defmac
5133e4b17023SJohn Marino
5134e4b17023SJohn Marino@hook TARGET_TRAMPOLINE_INIT
5135e4b17023SJohn MarinoThis hook is called to initialize a trampoline.
5136e4b17023SJohn Marino@var{m_tramp} is an RTX for the memory block for the trampoline; @var{fndecl}
5137e4b17023SJohn Marinois the @code{FUNCTION_DECL} for the nested function; @var{static_chain} is an
5138e4b17023SJohn MarinoRTX for the static chain value that should be passed to the function
5139e4b17023SJohn Marinowhen it is called.
5140e4b17023SJohn Marino
5141e4b17023SJohn MarinoIf the target defines @code{TARGET_ASM_TRAMPOLINE_TEMPLATE}, then the
5142e4b17023SJohn Marinofirst thing this hook should do is emit a block move into @var{m_tramp}
5143e4b17023SJohn Marinofrom the memory block returned by @code{assemble_trampoline_template}.
5144e4b17023SJohn MarinoNote that the block move need only cover the constant parts of the
5145e4b17023SJohn Marinotrampoline.  If the target isolates the variable parts of the trampoline
5146e4b17023SJohn Marinoto the end, not all @code{TRAMPOLINE_SIZE} bytes need be copied.
5147e4b17023SJohn Marino
5148e4b17023SJohn MarinoIf the target requires any other actions, such as flushing caches or
5149e4b17023SJohn Marinoenabling stack execution, these actions should be performed after
5150e4b17023SJohn Marinoinitializing the trampoline proper.
5151e4b17023SJohn Marino@end deftypefn
5152e4b17023SJohn Marino
5153e4b17023SJohn Marino@hook TARGET_TRAMPOLINE_ADJUST_ADDRESS
5154e4b17023SJohn MarinoThis hook should perform any machine-specific adjustment in
5155e4b17023SJohn Marinothe address of the trampoline.  Its argument contains the address of the
5156e4b17023SJohn Marinomemory block that was passed to @code{TARGET_TRAMPOLINE_INIT}.  In case
5157e4b17023SJohn Marinothe address to be used for a function call should be different from the
5158e4b17023SJohn Marinoaddress at which the template was stored, the different address should
5159e4b17023SJohn Marinobe returned; otherwise @var{addr} should be returned unchanged.
5160e4b17023SJohn MarinoIf this hook is not defined, @var{addr} will be used for function calls.
5161e4b17023SJohn Marino@end deftypefn
5162e4b17023SJohn Marino
5163e4b17023SJohn MarinoImplementing trampolines is difficult on many machines because they have
5164e4b17023SJohn Marinoseparate instruction and data caches.  Writing into a stack location
5165e4b17023SJohn Marinofails to clear the memory in the instruction cache, so when the program
5166e4b17023SJohn Marinojumps to that location, it executes the old contents.
5167e4b17023SJohn Marino
5168e4b17023SJohn MarinoHere are two possible solutions.  One is to clear the relevant parts of
5169e4b17023SJohn Marinothe instruction cache whenever a trampoline is set up.  The other is to
5170e4b17023SJohn Marinomake all trampolines identical, by having them jump to a standard
5171e4b17023SJohn Marinosubroutine.  The former technique makes trampoline execution faster; the
5172e4b17023SJohn Marinolatter makes initialization faster.
5173e4b17023SJohn Marino
5174e4b17023SJohn MarinoTo clear the instruction cache when a trampoline is initialized, define
5175e4b17023SJohn Marinothe following macro.
5176e4b17023SJohn Marino
5177e4b17023SJohn Marino@defmac CLEAR_INSN_CACHE (@var{beg}, @var{end})
5178e4b17023SJohn MarinoIf defined, expands to a C expression clearing the @emph{instruction
5179e4b17023SJohn Marinocache} in the specified interval.  The definition of this macro would
5180e4b17023SJohn Marinotypically be a series of @code{asm} statements.  Both @var{beg} and
5181e4b17023SJohn Marino@var{end} are both pointer expressions.
5182e4b17023SJohn Marino@end defmac
5183e4b17023SJohn Marino
5184e4b17023SJohn MarinoTo use a standard subroutine, define the following macro.  In addition,
5185e4b17023SJohn Marinoyou must make sure that the instructions in a trampoline fill an entire
5186e4b17023SJohn Marinocache line with identical instructions, or else ensure that the
5187e4b17023SJohn Marinobeginning of the trampoline code is always aligned at the same point in
5188e4b17023SJohn Marinoits cache line.  Look in @file{m68k.h} as a guide.
5189e4b17023SJohn Marino
5190e4b17023SJohn Marino@defmac TRANSFER_FROM_TRAMPOLINE
5191e4b17023SJohn MarinoDefine this macro if trampolines need a special subroutine to do their
5192e4b17023SJohn Marinowork.  The macro should expand to a series of @code{asm} statements
5193e4b17023SJohn Marinowhich will be compiled with GCC@.  They go in a library function named
5194e4b17023SJohn Marino@code{__transfer_from_trampoline}.
5195e4b17023SJohn Marino
5196e4b17023SJohn MarinoIf you need to avoid executing the ordinary prologue code of a compiled
5197e4b17023SJohn MarinoC function when you jump to the subroutine, you can do so by placing a
5198e4b17023SJohn Marinospecial label of your own in the assembler code.  Use one @code{asm}
5199e4b17023SJohn Marinostatement to generate an assembler label, and another to make the label
5200e4b17023SJohn Marinoglobal.  Then trampolines can use that label to jump directly to your
5201e4b17023SJohn Marinospecial assembler code.
5202e4b17023SJohn Marino@end defmac
5203e4b17023SJohn Marino
5204e4b17023SJohn Marino@node Library Calls
5205e4b17023SJohn Marino@section Implicit Calls to Library Routines
5206e4b17023SJohn Marino@cindex library subroutine names
5207e4b17023SJohn Marino@cindex @file{libgcc.a}
5208e4b17023SJohn Marino
5209e4b17023SJohn Marino@c prevent bad page break with this line
5210e4b17023SJohn MarinoHere is an explanation of implicit calls to library routines.
5211e4b17023SJohn Marino
5212e4b17023SJohn Marino@defmac DECLARE_LIBRARY_RENAMES
5213e4b17023SJohn MarinoThis macro, if defined, should expand to a piece of C code that will get
5214e4b17023SJohn Marinoexpanded when compiling functions for libgcc.a.  It can be used to
5215e4b17023SJohn Marinoprovide alternate names for GCC's internal library functions if there
5216e4b17023SJohn Marinoare ABI-mandated names that the compiler should provide.
5217e4b17023SJohn Marino@end defmac
5218e4b17023SJohn Marino
5219e4b17023SJohn Marino@findex set_optab_libfunc
5220e4b17023SJohn Marino@findex init_one_libfunc
5221e4b17023SJohn Marino@hook TARGET_INIT_LIBFUNCS
5222e4b17023SJohn MarinoThis hook should declare additional library routines or rename
5223e4b17023SJohn Marinoexisting ones, using the functions @code{set_optab_libfunc} and
5224e4b17023SJohn Marino@code{init_one_libfunc} defined in @file{optabs.c}.
5225e4b17023SJohn Marino@code{init_optabs} calls this macro after initializing all the normal
5226e4b17023SJohn Marinolibrary routines.
5227e4b17023SJohn Marino
5228e4b17023SJohn MarinoThe default is to do nothing.  Most ports don't need to define this hook.
5229e4b17023SJohn Marino@end deftypefn
5230e4b17023SJohn Marino
5231e4b17023SJohn Marino@hook TARGET_LIBFUNC_GNU_PREFIX
5232e4b17023SJohn Marino
5233e4b17023SJohn Marino@defmac FLOAT_LIB_COMPARE_RETURNS_BOOL (@var{mode}, @var{comparison})
5234e4b17023SJohn MarinoThis macro should return @code{true} if the library routine that
5235e4b17023SJohn Marinoimplements the floating point comparison operator @var{comparison} in
5236e4b17023SJohn Marinomode @var{mode} will return a boolean, and @var{false} if it will
5237e4b17023SJohn Marinoreturn a tristate.
5238e4b17023SJohn Marino
5239e4b17023SJohn MarinoGCC's own floating point libraries return tristates from the
5240e4b17023SJohn Marinocomparison operators, so the default returns false always.  Most ports
5241e4b17023SJohn Marinodon't need to define this macro.
5242e4b17023SJohn Marino@end defmac
5243e4b17023SJohn Marino
5244e4b17023SJohn Marino@defmac TARGET_LIB_INT_CMP_BIASED
5245e4b17023SJohn MarinoThis macro should evaluate to @code{true} if the integer comparison
5246e4b17023SJohn Marinofunctions (like @code{__cmpdi2}) return 0 to indicate that the first
5247e4b17023SJohn Marinooperand is smaller than the second, 1 to indicate that they are equal,
5248e4b17023SJohn Marinoand 2 to indicate that the first operand is greater than the second.
5249e4b17023SJohn MarinoIf this macro evaluates to @code{false} the comparison functions return
5250e4b17023SJohn Marino@minus{}1, 0, and 1 instead of 0, 1, and 2.  If the target uses the routines
5251e4b17023SJohn Marinoin @file{libgcc.a}, you do not need to define this macro.
5252e4b17023SJohn Marino@end defmac
5253e4b17023SJohn Marino
5254e4b17023SJohn Marino@cindex @code{EDOM}, implicit usage
5255e4b17023SJohn Marino@findex matherr
5256e4b17023SJohn Marino@defmac TARGET_EDOM
5257e4b17023SJohn MarinoThe value of @code{EDOM} on the target machine, as a C integer constant
5258e4b17023SJohn Marinoexpression.  If you don't define this macro, GCC does not attempt to
5259e4b17023SJohn Marinodeposit the value of @code{EDOM} into @code{errno} directly.  Look in
5260e4b17023SJohn Marino@file{/usr/include/errno.h} to find the value of @code{EDOM} on your
5261e4b17023SJohn Marinosystem.
5262e4b17023SJohn Marino
5263e4b17023SJohn MarinoIf you do not define @code{TARGET_EDOM}, then compiled code reports
5264e4b17023SJohn Marinodomain errors by calling the library function and letting it report the
5265e4b17023SJohn Marinoerror.  If mathematical functions on your system use @code{matherr} when
5266e4b17023SJohn Marinothere is an error, then you should leave @code{TARGET_EDOM} undefined so
5267e4b17023SJohn Marinothat @code{matherr} is used normally.
5268e4b17023SJohn Marino@end defmac
5269e4b17023SJohn Marino
5270e4b17023SJohn Marino@cindex @code{errno}, implicit usage
5271e4b17023SJohn Marino@defmac GEN_ERRNO_RTX
5272e4b17023SJohn MarinoDefine this macro as a C expression to create an rtl expression that
5273e4b17023SJohn Marinorefers to the global ``variable'' @code{errno}.  (On certain systems,
5274e4b17023SJohn Marino@code{errno} may not actually be a variable.)  If you don't define this
5275e4b17023SJohn Marinomacro, a reasonable default is used.
5276e4b17023SJohn Marino@end defmac
5277e4b17023SJohn Marino
5278e4b17023SJohn Marino@cindex C99 math functions, implicit usage
5279e4b17023SJohn Marino@defmac TARGET_C99_FUNCTIONS
5280e4b17023SJohn MarinoWhen this macro is nonzero, GCC will implicitly optimize @code{sin} calls into
5281e4b17023SJohn Marino@code{sinf} and similarly for other functions defined by C99 standard.  The
5282e4b17023SJohn Marinodefault is zero because a number of existing systems lack support for these
5283e4b17023SJohn Marinofunctions in their runtime so this macro needs to be redefined to one on
5284e4b17023SJohn Marinosystems that do support the C99 runtime.
5285e4b17023SJohn Marino@end defmac
5286e4b17023SJohn Marino
5287e4b17023SJohn Marino@cindex sincos math function, implicit usage
5288e4b17023SJohn Marino@defmac TARGET_HAS_SINCOS
5289e4b17023SJohn MarinoWhen this macro is nonzero, GCC will implicitly optimize calls to @code{sin}
5290e4b17023SJohn Marinoand @code{cos} with the same argument to a call to @code{sincos}.  The
5291e4b17023SJohn Marinodefault is zero.  The target has to provide the following functions:
5292e4b17023SJohn Marino@smallexample
5293e4b17023SJohn Marinovoid sincos(double x, double *sin, double *cos);
5294e4b17023SJohn Marinovoid sincosf(float x, float *sin, float *cos);
5295e4b17023SJohn Marinovoid sincosl(long double x, long double *sin, long double *cos);
5296e4b17023SJohn Marino@end smallexample
5297e4b17023SJohn Marino@end defmac
5298e4b17023SJohn Marino
5299e4b17023SJohn Marino@defmac NEXT_OBJC_RUNTIME
5300e4b17023SJohn MarinoSet this macro to 1 to use the "NeXT" Objective-C message sending conventions
5301e4b17023SJohn Marinoby default.  This calling convention involves passing the object, the selector
5302e4b17023SJohn Marinoand the method arguments all at once to the method-lookup library function.
5303e4b17023SJohn MarinoThis is the usual setting when targeting Darwin/Mac OS X systems, which have
5304e4b17023SJohn Marinothe NeXT runtime installed.
5305e4b17023SJohn Marino
5306e4b17023SJohn MarinoIf the macro is set to 0, the "GNU" Objective-C message sending convention
5307e4b17023SJohn Marinowill be used by default.  This convention passes just the object and the
5308e4b17023SJohn Marinoselector to the method-lookup function, which returns a pointer to the method.
5309e4b17023SJohn Marino
5310e4b17023SJohn MarinoIn either case, it remains possible to select code-generation for the alternate
5311e4b17023SJohn Marinoscheme, by means of compiler command line switches.
5312e4b17023SJohn Marino@end defmac
5313e4b17023SJohn Marino
5314e4b17023SJohn Marino@node Addressing Modes
5315e4b17023SJohn Marino@section Addressing Modes
5316e4b17023SJohn Marino@cindex addressing modes
5317e4b17023SJohn Marino
5318e4b17023SJohn Marino@c prevent bad page break with this line
5319e4b17023SJohn MarinoThis is about addressing modes.
5320e4b17023SJohn Marino
5321e4b17023SJohn Marino@defmac HAVE_PRE_INCREMENT
5322e4b17023SJohn Marino@defmacx HAVE_PRE_DECREMENT
5323e4b17023SJohn Marino@defmacx HAVE_POST_INCREMENT
5324e4b17023SJohn Marino@defmacx HAVE_POST_DECREMENT
5325e4b17023SJohn MarinoA C expression that is nonzero if the machine supports pre-increment,
5326e4b17023SJohn Marinopre-decrement, post-increment, or post-decrement addressing respectively.
5327e4b17023SJohn Marino@end defmac
5328e4b17023SJohn Marino
5329e4b17023SJohn Marino@defmac HAVE_PRE_MODIFY_DISP
5330e4b17023SJohn Marino@defmacx HAVE_POST_MODIFY_DISP
5331e4b17023SJohn MarinoA C expression that is nonzero if the machine supports pre- or
5332e4b17023SJohn Marinopost-address side-effect generation involving constants other than
5333e4b17023SJohn Marinothe size of the memory operand.
5334e4b17023SJohn Marino@end defmac
5335e4b17023SJohn Marino
5336e4b17023SJohn Marino@defmac HAVE_PRE_MODIFY_REG
5337e4b17023SJohn Marino@defmacx HAVE_POST_MODIFY_REG
5338e4b17023SJohn MarinoA C expression that is nonzero if the machine supports pre- or
5339e4b17023SJohn Marinopost-address side-effect generation involving a register displacement.
5340e4b17023SJohn Marino@end defmac
5341e4b17023SJohn Marino
5342e4b17023SJohn Marino@defmac CONSTANT_ADDRESS_P (@var{x})
5343e4b17023SJohn MarinoA C expression that is 1 if the RTX @var{x} is a constant which
5344e4b17023SJohn Marinois a valid address.  On most machines the default definition of
5345e4b17023SJohn Marino@code{(CONSTANT_P (@var{x}) && GET_CODE (@var{x}) != CONST_DOUBLE)}
5346e4b17023SJohn Marinois acceptable, but a few machines are more restrictive as to which
5347e4b17023SJohn Marinoconstant addresses are supported.
5348e4b17023SJohn Marino@end defmac
5349e4b17023SJohn Marino
5350e4b17023SJohn Marino@defmac CONSTANT_P (@var{x})
5351e4b17023SJohn Marino@code{CONSTANT_P}, which is defined by target-independent code,
5352e4b17023SJohn Marinoaccepts integer-values expressions whose values are not explicitly
5353e4b17023SJohn Marinoknown, such as @code{symbol_ref}, @code{label_ref}, and @code{high}
5354e4b17023SJohn Marinoexpressions and @code{const} arithmetic expressions, in addition to
5355e4b17023SJohn Marino@code{const_int} and @code{const_double} expressions.
5356e4b17023SJohn Marino@end defmac
5357e4b17023SJohn Marino
5358e4b17023SJohn Marino@defmac MAX_REGS_PER_ADDRESS
5359e4b17023SJohn MarinoA number, the maximum number of registers that can appear in a valid
5360e4b17023SJohn Marinomemory address.  Note that it is up to you to specify a value equal to
5361e4b17023SJohn Marinothe maximum number that @code{TARGET_LEGITIMATE_ADDRESS_P} would ever
5362e4b17023SJohn Marinoaccept.
5363e4b17023SJohn Marino@end defmac
5364e4b17023SJohn Marino
5365e4b17023SJohn Marino@hook TARGET_LEGITIMATE_ADDRESS_P
5366e4b17023SJohn MarinoA function that returns whether @var{x} (an RTX) is a legitimate memory
5367e4b17023SJohn Marinoaddress on the target machine for a memory operand of mode @var{mode}.
5368e4b17023SJohn Marino
5369e4b17023SJohn MarinoLegitimate addresses are defined in two variants: a strict variant and a
5370e4b17023SJohn Marinonon-strict one.  The @var{strict} parameter chooses which variant is
5371e4b17023SJohn Marinodesired by the caller.
5372e4b17023SJohn Marino
5373e4b17023SJohn MarinoThe strict variant is used in the reload pass.  It must be defined so
5374e4b17023SJohn Marinothat any pseudo-register that has not been allocated a hard register is
5375e4b17023SJohn Marinoconsidered a memory reference.  This is because in contexts where some
5376e4b17023SJohn Marinokind of register is required, a pseudo-register with no hard register
5377e4b17023SJohn Marinomust be rejected.  For non-hard registers, the strict variant should look
5378e4b17023SJohn Marinoup the @code{reg_renumber} array; it should then proceed using the hard
5379e4b17023SJohn Marinoregister number in the array, or treat the pseudo as a memory reference
5380e4b17023SJohn Marinoif the array holds @code{-1}.
5381e4b17023SJohn Marino
5382e4b17023SJohn MarinoThe non-strict variant is used in other passes.  It must be defined to
5383e4b17023SJohn Marinoaccept all pseudo-registers in every context where some kind of
5384e4b17023SJohn Marinoregister is required.
5385e4b17023SJohn Marino
5386e4b17023SJohn MarinoNormally, constant addresses which are the sum of a @code{symbol_ref}
5387e4b17023SJohn Marinoand an integer are stored inside a @code{const} RTX to mark them as
5388e4b17023SJohn Marinoconstant.  Therefore, there is no need to recognize such sums
5389e4b17023SJohn Marinospecifically as legitimate addresses.  Normally you would simply
5390e4b17023SJohn Marinorecognize any @code{const} as legitimate.
5391e4b17023SJohn Marino
5392e4b17023SJohn MarinoUsually @code{PRINT_OPERAND_ADDRESS} is not prepared to handle constant
5393e4b17023SJohn Marinosums that are not marked with  @code{const}.  It assumes that a naked
5394e4b17023SJohn Marino@code{plus} indicates indexing.  If so, then you @emph{must} reject such
5395e4b17023SJohn Marinonaked constant sums as illegitimate addresses, so that none of them will
5396e4b17023SJohn Marinobe given to @code{PRINT_OPERAND_ADDRESS}.
5397e4b17023SJohn Marino
5398e4b17023SJohn Marino@cindex @code{TARGET_ENCODE_SECTION_INFO} and address validation
5399e4b17023SJohn MarinoOn some machines, whether a symbolic address is legitimate depends on
5400e4b17023SJohn Marinothe section that the address refers to.  On these machines, define the
5401e4b17023SJohn Marinotarget hook @code{TARGET_ENCODE_SECTION_INFO} to store the information
5402e4b17023SJohn Marinointo the @code{symbol_ref}, and then check for it here.  When you see a
5403e4b17023SJohn Marino@code{const}, you will have to look inside it to find the
5404e4b17023SJohn Marino@code{symbol_ref} in order to determine the section.  @xref{Assembler
5405e4b17023SJohn MarinoFormat}.
5406e4b17023SJohn Marino
5407e4b17023SJohn Marino@cindex @code{GO_IF_LEGITIMATE_ADDRESS}
5408e4b17023SJohn MarinoSome ports are still using a deprecated legacy substitute for
5409e4b17023SJohn Marinothis hook, the @code{GO_IF_LEGITIMATE_ADDRESS} macro.  This macro
5410e4b17023SJohn Marinohas this syntax:
5411e4b17023SJohn Marino
5412e4b17023SJohn Marino@example
5413e4b17023SJohn Marino#define GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label})
5414e4b17023SJohn Marino@end example
5415e4b17023SJohn Marino
5416e4b17023SJohn Marino@noindent
5417e4b17023SJohn Marinoand should @code{goto @var{label}} if the address @var{x} is a valid
5418e4b17023SJohn Marinoaddress on the target machine for a memory operand of mode @var{mode}.
5419e4b17023SJohn Marino
5420e4b17023SJohn Marino@findex REG_OK_STRICT
5421e4b17023SJohn MarinoCompiler source files that want to use the strict variant of this
5422e4b17023SJohn Marinomacro define the macro @code{REG_OK_STRICT}.  You should use an
5423e4b17023SJohn Marino@code{#ifdef REG_OK_STRICT} conditional to define the strict variant in
5424e4b17023SJohn Marinothat case and the non-strict variant otherwise.
5425e4b17023SJohn Marino
5426e4b17023SJohn MarinoUsing the hook is usually simpler because it limits the number of
5427e4b17023SJohn Marinofiles that are recompiled when changes are made.
5428e4b17023SJohn Marino@end deftypefn
5429e4b17023SJohn Marino
5430e4b17023SJohn Marino@defmac TARGET_MEM_CONSTRAINT
5431e4b17023SJohn MarinoA single character to be used instead of the default @code{'m'}
5432e4b17023SJohn Marinocharacter for general memory addresses.  This defines the constraint
5433e4b17023SJohn Marinoletter which matches the memory addresses accepted by
5434e4b17023SJohn Marino@code{TARGET_LEGITIMATE_ADDRESS_P}.  Define this macro if you want to
5435e4b17023SJohn Marinosupport new address formats in your back end without changing the
5436e4b17023SJohn Marinosemantics of the @code{'m'} constraint.  This is necessary in order to
5437e4b17023SJohn Marinopreserve functionality of inline assembly constructs using the
5438e4b17023SJohn Marino@code{'m'} constraint.
5439e4b17023SJohn Marino@end defmac
5440e4b17023SJohn Marino
5441e4b17023SJohn Marino@defmac FIND_BASE_TERM (@var{x})
5442e4b17023SJohn MarinoA C expression to determine the base term of address @var{x},
5443e4b17023SJohn Marinoor to provide a simplified version of @var{x} from which @file{alias.c}
5444e4b17023SJohn Marinocan easily find the base term.  This macro is used in only two places:
5445e4b17023SJohn Marino@code{find_base_value} and @code{find_base_term} in @file{alias.c}.
5446e4b17023SJohn Marino
5447e4b17023SJohn MarinoIt is always safe for this macro to not be defined.  It exists so
5448e4b17023SJohn Marinothat alias analysis can understand machine-dependent addresses.
5449e4b17023SJohn Marino
5450e4b17023SJohn MarinoThe typical use of this macro is to handle addresses containing
5451e4b17023SJohn Marinoa label_ref or symbol_ref within an UNSPEC@.
5452e4b17023SJohn Marino@end defmac
5453e4b17023SJohn Marino
5454e4b17023SJohn Marino@hook TARGET_LEGITIMIZE_ADDRESS
5455e4b17023SJohn MarinoThis hook is given an invalid memory address @var{x} for an
5456e4b17023SJohn Marinooperand of mode @var{mode} and should try to return a valid memory
5457e4b17023SJohn Marinoaddress.
5458e4b17023SJohn Marino
5459e4b17023SJohn Marino@findex break_out_memory_refs
5460e4b17023SJohn Marino@var{x} will always be the result of a call to @code{break_out_memory_refs},
5461e4b17023SJohn Marinoand @var{oldx} will be the operand that was given to that function to produce
5462e4b17023SJohn Marino@var{x}.
5463e4b17023SJohn Marino
5464e4b17023SJohn MarinoThe code of the hook should not alter the substructure of
5465e4b17023SJohn Marino@var{x}.  If it transforms @var{x} into a more legitimate form, it
5466e4b17023SJohn Marinoshould return the new @var{x}.
5467e4b17023SJohn Marino
5468e4b17023SJohn MarinoIt is not necessary for this hook to come up with a legitimate address.
5469e4b17023SJohn MarinoThe compiler has standard ways of doing so in all cases.  In fact, it
5470e4b17023SJohn Marinois safe to omit this hook or make it return @var{x} if it cannot find
5471e4b17023SJohn Marinoa valid way to legitimize the address.  But often a machine-dependent
5472e4b17023SJohn Marinostrategy can generate better code.
5473e4b17023SJohn Marino@end deftypefn
5474e4b17023SJohn Marino
5475e4b17023SJohn Marino@defmac LEGITIMIZE_RELOAD_ADDRESS (@var{x}, @var{mode}, @var{opnum}, @var{type}, @var{ind_levels}, @var{win})
5476e4b17023SJohn MarinoA C compound statement that attempts to replace @var{x}, which is an address
5477e4b17023SJohn Marinothat needs reloading, with a valid memory address for an operand of mode
5478e4b17023SJohn Marino@var{mode}.  @var{win} will be a C statement label elsewhere in the code.
5479e4b17023SJohn MarinoIt is not necessary to define this macro, but it might be useful for
5480e4b17023SJohn Marinoperformance reasons.
5481e4b17023SJohn Marino
5482e4b17023SJohn MarinoFor example, on the i386, it is sometimes possible to use a single
5483e4b17023SJohn Marinoreload register instead of two by reloading a sum of two pseudo
5484e4b17023SJohn Marinoregisters into a register.  On the other hand, for number of RISC
5485e4b17023SJohn Marinoprocessors offsets are limited so that often an intermediate address
5486e4b17023SJohn Marinoneeds to be generated in order to address a stack slot.  By defining
5487e4b17023SJohn Marino@code{LEGITIMIZE_RELOAD_ADDRESS} appropriately, the intermediate addresses
5488e4b17023SJohn Marinogenerated for adjacent some stack slots can be made identical, and thus
5489e4b17023SJohn Marinobe shared.
5490e4b17023SJohn Marino
5491e4b17023SJohn Marino@emph{Note}: This macro should be used with caution.  It is necessary
5492e4b17023SJohn Marinoto know something of how reload works in order to effectively use this,
5493e4b17023SJohn Marinoand it is quite easy to produce macros that build in too much knowledge
5494e4b17023SJohn Marinoof reload internals.
5495e4b17023SJohn Marino
5496e4b17023SJohn Marino@emph{Note}: This macro must be able to reload an address created by a
5497e4b17023SJohn Marinoprevious invocation of this macro.  If it fails to handle such addresses
5498e4b17023SJohn Marinothen the compiler may generate incorrect code or abort.
5499e4b17023SJohn Marino
5500e4b17023SJohn Marino@findex push_reload
5501e4b17023SJohn MarinoThe macro definition should use @code{push_reload} to indicate parts that
5502e4b17023SJohn Marinoneed reloading; @var{opnum}, @var{type} and @var{ind_levels} are usually
5503e4b17023SJohn Marinosuitable to be passed unaltered to @code{push_reload}.
5504e4b17023SJohn Marino
5505e4b17023SJohn MarinoThe code generated by this macro must not alter the substructure of
5506e4b17023SJohn Marino@var{x}.  If it transforms @var{x} into a more legitimate form, it
5507e4b17023SJohn Marinoshould assign @var{x} (which will always be a C variable) a new value.
5508e4b17023SJohn MarinoThis also applies to parts that you change indirectly by calling
5509e4b17023SJohn Marino@code{push_reload}.
5510e4b17023SJohn Marino
5511e4b17023SJohn Marino@findex strict_memory_address_p
5512e4b17023SJohn MarinoThe macro definition may use @code{strict_memory_address_p} to test if
5513e4b17023SJohn Marinothe address has become legitimate.
5514e4b17023SJohn Marino
5515e4b17023SJohn Marino@findex copy_rtx
5516e4b17023SJohn MarinoIf you want to change only a part of @var{x}, one standard way of doing
5517e4b17023SJohn Marinothis is to use @code{copy_rtx}.  Note, however, that it unshares only a
5518e4b17023SJohn Marinosingle level of rtl.  Thus, if the part to be changed is not at the
5519e4b17023SJohn Marinotop level, you'll need to replace first the top level.
5520e4b17023SJohn MarinoIt is not necessary for this macro to come up with a legitimate
5521e4b17023SJohn Marinoaddress;  but often a machine-dependent strategy can generate better code.
5522e4b17023SJohn Marino@end defmac
5523e4b17023SJohn Marino
5524e4b17023SJohn Marino@hook TARGET_MODE_DEPENDENT_ADDRESS_P
5525e4b17023SJohn MarinoThis hook returns @code{true} if memory address @var{addr} can have
5526e4b17023SJohn Marinodifferent meanings depending on the machine mode of the memory
5527e4b17023SJohn Marinoreference it is used for or if the address is valid for some modes
5528e4b17023SJohn Marinobut not others.
5529e4b17023SJohn Marino
5530e4b17023SJohn MarinoAutoincrement and autodecrement addresses typically have mode-dependent
5531e4b17023SJohn Marinoeffects because the amount of the increment or decrement is the size
5532e4b17023SJohn Marinoof the operand being addressed.  Some machines have other mode-dependent
5533e4b17023SJohn Marinoaddresses.  Many RISC machines have no mode-dependent addresses.
5534e4b17023SJohn Marino
5535e4b17023SJohn MarinoYou may assume that @var{addr} is a valid address for the machine.
5536e4b17023SJohn Marino
5537e4b17023SJohn MarinoThe default version of this hook returns @code{false}.
5538e4b17023SJohn Marino@end deftypefn
5539e4b17023SJohn Marino
5540e4b17023SJohn Marino@defmac GO_IF_MODE_DEPENDENT_ADDRESS (@var{addr}, @var{label})
5541e4b17023SJohn MarinoA C statement or compound statement with a conditional @code{goto
5542e4b17023SJohn Marino@var{label};} executed if memory address @var{x} (an RTX) can have
5543e4b17023SJohn Marinodifferent meanings depending on the machine mode of the memory
5544e4b17023SJohn Marinoreference it is used for or if the address is valid for some modes
5545e4b17023SJohn Marinobut not others.
5546e4b17023SJohn Marino
5547e4b17023SJohn MarinoAutoincrement and autodecrement addresses typically have mode-dependent
5548e4b17023SJohn Marinoeffects because the amount of the increment or decrement is the size
5549e4b17023SJohn Marinoof the operand being addressed.  Some machines have other mode-dependent
5550e4b17023SJohn Marinoaddresses.  Many RISC machines have no mode-dependent addresses.
5551e4b17023SJohn Marino
5552e4b17023SJohn MarinoYou may assume that @var{addr} is a valid address for the machine.
5553e4b17023SJohn Marino
5554e4b17023SJohn MarinoThese are obsolete macros, replaced by the
5555e4b17023SJohn Marino@code{TARGET_MODE_DEPENDENT_ADDRESS_P} target hook.
5556e4b17023SJohn Marino@end defmac
5557e4b17023SJohn Marino
5558e4b17023SJohn Marino@hook TARGET_LEGITIMATE_CONSTANT_P
5559e4b17023SJohn MarinoThis hook returns true if @var{x} is a legitimate constant for a
5560e4b17023SJohn Marino@var{mode}-mode immediate operand on the target machine.  You can assume that
5561e4b17023SJohn Marino@var{x} satisfies @code{CONSTANT_P}, so you need not check this.
5562e4b17023SJohn Marino
5563e4b17023SJohn MarinoThe default definition returns true.
5564e4b17023SJohn Marino@end deftypefn
5565e4b17023SJohn Marino
5566e4b17023SJohn Marino@hook TARGET_DELEGITIMIZE_ADDRESS
5567e4b17023SJohn MarinoThis hook is used to undo the possibly obfuscating effects of the
5568e4b17023SJohn Marino@code{LEGITIMIZE_ADDRESS} and @code{LEGITIMIZE_RELOAD_ADDRESS} target
5569e4b17023SJohn Marinomacros.  Some backend implementations of these macros wrap symbol
5570e4b17023SJohn Marinoreferences inside an @code{UNSPEC} rtx to represent PIC or similar
5571e4b17023SJohn Marinoaddressing modes.  This target hook allows GCC's optimizers to understand
5572e4b17023SJohn Marinothe semantics of these opaque @code{UNSPEC}s by converting them back
5573e4b17023SJohn Marinointo their original form.
5574e4b17023SJohn Marino@end deftypefn
5575e4b17023SJohn Marino
5576e4b17023SJohn Marino@hook TARGET_CONST_NOT_OK_FOR_DEBUG_P
5577e4b17023SJohn MarinoThis hook should return true if @var{x} should not be emitted into
5578e4b17023SJohn Marinodebug sections.
5579e4b17023SJohn Marino@end deftypefn
5580e4b17023SJohn Marino
5581e4b17023SJohn Marino@hook TARGET_CANNOT_FORCE_CONST_MEM
5582e4b17023SJohn MarinoThis hook should return true if @var{x} is of a form that cannot (or
5583e4b17023SJohn Marinoshould not) be spilled to the constant pool.  @var{mode} is the mode
5584e4b17023SJohn Marinoof @var{x}.
5585e4b17023SJohn Marino
5586e4b17023SJohn MarinoThe default version of this hook returns false.
5587e4b17023SJohn Marino
5588e4b17023SJohn MarinoThe primary reason to define this hook is to prevent reload from
5589e4b17023SJohn Marinodeciding that a non-legitimate constant would be better reloaded
5590e4b17023SJohn Marinofrom the constant pool instead of spilling and reloading a register
5591e4b17023SJohn Marinoholding the constant.  This restriction is often true of addresses
5592e4b17023SJohn Marinoof TLS symbols for various targets.
5593e4b17023SJohn Marino@end deftypefn
5594e4b17023SJohn Marino
5595e4b17023SJohn Marino@hook TARGET_USE_BLOCKS_FOR_CONSTANT_P
5596e4b17023SJohn MarinoThis hook should return true if pool entries for constant @var{x} can
5597e4b17023SJohn Marinobe placed in an @code{object_block} structure.  @var{mode} is the mode
5598e4b17023SJohn Marinoof @var{x}.
5599e4b17023SJohn Marino
5600e4b17023SJohn MarinoThe default version returns false for all constants.
5601e4b17023SJohn Marino@end deftypefn
5602e4b17023SJohn Marino
5603e4b17023SJohn Marino@hook TARGET_BUILTIN_RECIPROCAL
5604e4b17023SJohn MarinoThis hook should return the DECL of a function that implements reciprocal of
5605e4b17023SJohn Marinothe builtin function with builtin function code @var{fn}, or
5606e4b17023SJohn Marino@code{NULL_TREE} if such a function is not available.  @var{md_fn} is true
5607e4b17023SJohn Marinowhen @var{fn} is a code of a machine-dependent builtin function.  When
5608e4b17023SJohn Marino@var{sqrt} is true, additional optimizations that apply only to the reciprocal
5609e4b17023SJohn Marinoof a square root function are performed, and only reciprocals of @code{sqrt}
5610e4b17023SJohn Marinofunction are valid.
5611e4b17023SJohn Marino@end deftypefn
5612e4b17023SJohn Marino
5613e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
5614e4b17023SJohn MarinoThis hook should return the DECL of a function @var{f} that given an
5615e4b17023SJohn Marinoaddress @var{addr} as an argument returns a mask @var{m} that can be
5616e4b17023SJohn Marinoused to extract from two vectors the relevant data that resides in
5617e4b17023SJohn Marino@var{addr} in case @var{addr} is not properly aligned.
5618e4b17023SJohn Marino
5619e4b17023SJohn MarinoThe autovectorizer, when vectorizing a load operation from an address
5620e4b17023SJohn Marino@var{addr} that may be unaligned, will generate two vector loads from
5621e4b17023SJohn Marinothe two aligned addresses around @var{addr}. It then generates a
5622e4b17023SJohn Marino@code{REALIGN_LOAD} operation to extract the relevant data from the
5623e4b17023SJohn Marinotwo loaded vectors. The first two arguments to @code{REALIGN_LOAD},
5624e4b17023SJohn Marino@var{v1} and @var{v2}, are the two vectors, each of size @var{VS}, and
5625e4b17023SJohn Marinothe third argument, @var{OFF}, defines how the data will be extracted
5626e4b17023SJohn Marinofrom these two vectors: if @var{OFF} is 0, then the returned vector is
5627e4b17023SJohn Marino@var{v2}; otherwise, the returned vector is composed from the last
5628e4b17023SJohn Marino@var{VS}-@var{OFF} elements of @var{v1} concatenated to the first
5629e4b17023SJohn Marino@var{OFF} elements of @var{v2}.
5630e4b17023SJohn Marino
5631e4b17023SJohn MarinoIf this hook is defined, the autovectorizer will generate a call
5632e4b17023SJohn Marinoto @var{f} (using the DECL tree that this hook returns) and will
5633e4b17023SJohn Marinouse the return value of @var{f} as the argument @var{OFF} to
5634e4b17023SJohn Marino@code{REALIGN_LOAD}. Therefore, the mask @var{m} returned by @var{f}
5635e4b17023SJohn Marinoshould comply with the semantics expected by @code{REALIGN_LOAD}
5636e4b17023SJohn Marinodescribed above.
5637e4b17023SJohn MarinoIf this hook is not defined, then @var{addr} will be used as
5638e4b17023SJohn Marinothe argument @var{OFF} to @code{REALIGN_LOAD}, in which case the low
5639e4b17023SJohn Marinolog2(@var{VS}) @minus{} 1 bits of @var{addr} will be considered.
5640e4b17023SJohn Marino@end deftypefn
5641e4b17023SJohn Marino
5642e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN
5643e4b17023SJohn MarinoThis hook should return the DECL of a function @var{f} that implements
5644e4b17023SJohn Marinowidening multiplication of the even elements of two input vectors of type @var{x}.
5645e4b17023SJohn Marino
5646e4b17023SJohn MarinoIf this hook is defined, the autovectorizer will use it along with the
5647e4b17023SJohn Marino@code{TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD} target hook when vectorizing
5648e4b17023SJohn Marinowidening multiplication in cases that the order of the results does not have to be
5649e4b17023SJohn Marinopreserved (e.g.@: used only by a reduction computation). Otherwise, the
5650e4b17023SJohn Marino@code{widen_mult_hi/lo} idioms will be used.
5651e4b17023SJohn Marino@end deftypefn
5652e4b17023SJohn Marino
5653e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD
5654e4b17023SJohn MarinoThis hook should return the DECL of a function @var{f} that implements
5655e4b17023SJohn Marinowidening multiplication of the odd elements of two input vectors of type @var{x}.
5656e4b17023SJohn Marino
5657e4b17023SJohn MarinoIf this hook is defined, the autovectorizer will use it along with the
5658e4b17023SJohn Marino@code{TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN} target hook when vectorizing
5659e4b17023SJohn Marinowidening multiplication in cases that the order of the results does not have to be
5660e4b17023SJohn Marinopreserved (e.g.@: used only by a reduction computation). Otherwise, the
5661e4b17023SJohn Marino@code{widen_mult_hi/lo} idioms will be used.
5662e4b17023SJohn Marino@end deftypefn
5663e4b17023SJohn Marino
5664e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
5665e4b17023SJohn MarinoReturns cost of different scalar or vector statements for vectorization cost model.
5666e4b17023SJohn MarinoFor vector memory operations the cost may depend on type (@var{vectype}) and
5667e4b17023SJohn Marinomisalignment value (@var{misalign}).
5668e4b17023SJohn Marino@end deftypefn
5669e4b17023SJohn Marino
5670e4b17023SJohn Marino@hook TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE
5671e4b17023SJohn MarinoReturn true if vector alignment is reachable (by peeling N iterations) for the given type.
5672e4b17023SJohn Marino@end deftypefn
5673e4b17023SJohn Marino
5674e4b17023SJohn Marino@hook TARGET_VECTORIZE_VEC_PERM_CONST_OK
5675e4b17023SJohn MarinoReturn true if a vector created for @code{vec_perm_const} is valid.
5676e4b17023SJohn Marino@end deftypefn
5677e4b17023SJohn Marino
5678e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_CONVERSION
5679e4b17023SJohn MarinoThis hook should return the DECL of a function that implements conversion of the
5680e4b17023SJohn Marinoinput vector of type @var{src_type} to type @var{dest_type}.
5681e4b17023SJohn MarinoThe value of @var{code} is one of the enumerators in @code{enum tree_code} and
5682e4b17023SJohn Marinospecifies how the conversion is to be applied
5683e4b17023SJohn Marino(truncation, rounding, etc.).
5684e4b17023SJohn Marino
5685e4b17023SJohn MarinoIf this hook is defined, the autovectorizer will use the
5686e4b17023SJohn Marino@code{TARGET_VECTORIZE_BUILTIN_CONVERSION} target hook when vectorizing
5687e4b17023SJohn Marinoconversion. Otherwise, it will return @code{NULL_TREE}.
5688e4b17023SJohn Marino@end deftypefn
5689e4b17023SJohn Marino
5690e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION
5691e4b17023SJohn MarinoThis hook should return the decl of a function that implements the
5692e4b17023SJohn Marinovectorized variant of the builtin function with builtin function code
5693e4b17023SJohn Marino@var{code} or @code{NULL_TREE} if such a function is not available.
5694e4b17023SJohn MarinoThe value of @var{fndecl} is the builtin function declaration.  The
5695e4b17023SJohn Marinoreturn type of the vectorized function shall be of vector type
5696e4b17023SJohn Marino@var{vec_type_out} and the argument types should be @var{vec_type_in}.
5697e4b17023SJohn Marino@end deftypefn
5698e4b17023SJohn Marino
5699e4b17023SJohn Marino@hook TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT
5700e4b17023SJohn MarinoThis hook should return true if the target supports misaligned vector
5701e4b17023SJohn Marinostore/load of a specific factor denoted in the @var{misalignment}
5702e4b17023SJohn Marinoparameter.  The vector store/load should be of machine mode @var{mode} and
5703e4b17023SJohn Marinothe elements in the vectors should be of type @var{type}.  @var{is_packed}
5704e4b17023SJohn Marinoparameter is true if the memory access is defined in a packed struct.
5705e4b17023SJohn Marino@end deftypefn
5706e4b17023SJohn Marino
5707e4b17023SJohn Marino@hook TARGET_VECTORIZE_PREFERRED_SIMD_MODE
5708e4b17023SJohn MarinoThis hook should return the preferred mode for vectorizing scalar
5709e4b17023SJohn Marinomode @var{mode}.  The default is
5710e4b17023SJohn Marinoequal to @code{word_mode}, because the vectorizer can do some
5711e4b17023SJohn Marinotransformations even in absence of specialized @acronym{SIMD} hardware.
5712e4b17023SJohn Marino@end deftypefn
5713e4b17023SJohn Marino
5714e4b17023SJohn Marino@hook TARGET_VECTORIZE_AUTOVECTORIZE_VECTOR_SIZES
5715e4b17023SJohn MarinoThis hook should return a mask of sizes that should be iterated over
5716e4b17023SJohn Marinoafter trying to autovectorize using the vector size derived from the
5717e4b17023SJohn Marinomode returned by @code{TARGET_VECTORIZE_PREFERRED_SIMD_MODE}.
5718e4b17023SJohn MarinoThe default is zero which means to not iterate over other vector sizes.
5719e4b17023SJohn Marino@end deftypefn
5720e4b17023SJohn Marino
5721e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_TM_LOAD
5722e4b17023SJohn Marino
5723e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_TM_STORE
5724e4b17023SJohn Marino
5725e4b17023SJohn Marino@hook TARGET_VECTORIZE_BUILTIN_GATHER
5726e4b17023SJohn MarinoTarget builtin that implements vector gather operation.  @var{mem_vectype}
5727e4b17023SJohn Marinois the vector type of the load and @var{index_type} is scalar type of
5728e4b17023SJohn Marinothe index, scaled by @var{scale}.
5729e4b17023SJohn MarinoThe default is @code{NULL_TREE} which means to not vectorize gather
5730e4b17023SJohn Marinoloads.
5731e4b17023SJohn Marino@end deftypefn
5732e4b17023SJohn Marino
5733e4b17023SJohn Marino@node Anchored Addresses
5734e4b17023SJohn Marino@section Anchored Addresses
5735e4b17023SJohn Marino@cindex anchored addresses
5736e4b17023SJohn Marino@cindex @option{-fsection-anchors}
5737e4b17023SJohn Marino
5738e4b17023SJohn MarinoGCC usually addresses every static object as a separate entity.
5739e4b17023SJohn MarinoFor example, if we have:
5740e4b17023SJohn Marino
5741e4b17023SJohn Marino@smallexample
5742e4b17023SJohn Marinostatic int a, b, c;
5743e4b17023SJohn Marinoint foo (void) @{ return a + b + c; @}
5744e4b17023SJohn Marino@end smallexample
5745e4b17023SJohn Marino
5746e4b17023SJohn Marinothe code for @code{foo} will usually calculate three separate symbolic
5747e4b17023SJohn Marinoaddresses: those of @code{a}, @code{b} and @code{c}.  On some targets,
5748e4b17023SJohn Marinoit would be better to calculate just one symbolic address and access
5749e4b17023SJohn Marinothe three variables relative to it.  The equivalent pseudocode would
5750e4b17023SJohn Marinobe something like:
5751e4b17023SJohn Marino
5752e4b17023SJohn Marino@smallexample
5753e4b17023SJohn Marinoint foo (void)
5754e4b17023SJohn Marino@{
5755e4b17023SJohn Marino  register int *xr = &x;
5756e4b17023SJohn Marino  return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
5757e4b17023SJohn Marino@}
5758e4b17023SJohn Marino@end smallexample
5759e4b17023SJohn Marino
5760e4b17023SJohn Marino(which isn't valid C).  We refer to shared addresses like @code{x} as
5761e4b17023SJohn Marino``section anchors''.  Their use is controlled by @option{-fsection-anchors}.
5762e4b17023SJohn Marino
5763e4b17023SJohn MarinoThe hooks below describe the target properties that GCC needs to know
5764e4b17023SJohn Marinoin order to make effective use of section anchors.  It won't use
5765e4b17023SJohn Marinosection anchors at all unless either @code{TARGET_MIN_ANCHOR_OFFSET}
5766e4b17023SJohn Marinoor @code{TARGET_MAX_ANCHOR_OFFSET} is set to a nonzero value.
5767e4b17023SJohn Marino
5768e4b17023SJohn Marino@hook TARGET_MIN_ANCHOR_OFFSET
5769e4b17023SJohn MarinoThe minimum offset that should be applied to a section anchor.
5770e4b17023SJohn MarinoOn most targets, it should be the smallest offset that can be
5771e4b17023SJohn Marinoapplied to a base register while still giving a legitimate address
5772e4b17023SJohn Marinofor every mode.  The default value is 0.
5773e4b17023SJohn Marino@end deftypevr
5774e4b17023SJohn Marino
5775e4b17023SJohn Marino@hook TARGET_MAX_ANCHOR_OFFSET
5776e4b17023SJohn MarinoLike @code{TARGET_MIN_ANCHOR_OFFSET}, but the maximum (inclusive)
5777e4b17023SJohn Marinooffset that should be applied to section anchors.  The default
5778e4b17023SJohn Marinovalue is 0.
5779e4b17023SJohn Marino@end deftypevr
5780e4b17023SJohn Marino
5781e4b17023SJohn Marino@hook TARGET_ASM_OUTPUT_ANCHOR
5782e4b17023SJohn MarinoWrite the assembly code to define section anchor @var{x}, which is a
5783e4b17023SJohn Marino@code{SYMBOL_REF} for which @samp{SYMBOL_REF_ANCHOR_P (@var{x})} is true.
5784e4b17023SJohn MarinoThe hook is called with the assembly output position set to the beginning
5785e4b17023SJohn Marinoof @code{SYMBOL_REF_BLOCK (@var{x})}.
5786e4b17023SJohn Marino
5787e4b17023SJohn MarinoIf @code{ASM_OUTPUT_DEF} is available, the hook's default definition uses
5788e4b17023SJohn Marinoit to define the symbol as @samp{. + SYMBOL_REF_BLOCK_OFFSET (@var{x})}.
5789e4b17023SJohn MarinoIf @code{ASM_OUTPUT_DEF} is not available, the hook's default definition
5790e4b17023SJohn Marinois @code{NULL}, which disables the use of section anchors altogether.
5791e4b17023SJohn Marino@end deftypefn
5792e4b17023SJohn Marino
5793e4b17023SJohn Marino@hook TARGET_USE_ANCHORS_FOR_SYMBOL_P
5794e4b17023SJohn MarinoReturn true if GCC should attempt to use anchors to access @code{SYMBOL_REF}
5795e4b17023SJohn Marino@var{x}.  You can assume @samp{SYMBOL_REF_HAS_BLOCK_INFO_P (@var{x})} and
5796e4b17023SJohn Marino@samp{!SYMBOL_REF_ANCHOR_P (@var{x})}.
5797e4b17023SJohn Marino
5798e4b17023SJohn MarinoThe default version is correct for most targets, but you might need to
5799e4b17023SJohn Marinointercept this hook to handle things like target-specific attributes
5800e4b17023SJohn Marinoor target-specific sections.
5801e4b17023SJohn Marino@end deftypefn
5802e4b17023SJohn Marino
5803e4b17023SJohn Marino@node Condition Code
5804e4b17023SJohn Marino@section Condition Code Status
5805e4b17023SJohn Marino@cindex condition code status
5806e4b17023SJohn Marino
5807e4b17023SJohn MarinoThe macros in this section can be split in two families, according to the
5808e4b17023SJohn Marinotwo ways of representing condition codes in GCC.
5809e4b17023SJohn Marino
5810e4b17023SJohn MarinoThe first representation is the so called @code{(cc0)} representation
5811e4b17023SJohn Marino(@pxref{Jump Patterns}), where all instructions can have an implicit
5812e4b17023SJohn Marinoclobber of the condition codes.  The second is the condition code
5813e4b17023SJohn Marinoregister representation, which provides better schedulability for
5814e4b17023SJohn Marinoarchitectures that do have a condition code register, but on which
5815e4b17023SJohn Marinomost instructions do not affect it.  The latter category includes
5816e4b17023SJohn Marinomost RISC machines.
5817e4b17023SJohn Marino
5818e4b17023SJohn MarinoThe implicit clobbering poses a strong restriction on the placement of
5819e4b17023SJohn Marinothe definition and use of the condition code, which need to be in adjacent
5820e4b17023SJohn Marinoinsns for machines using @code{(cc0)}.  This can prevent important
5821e4b17023SJohn Marinooptimizations on some machines.  For example, on the IBM RS/6000, there
5822e4b17023SJohn Marinois a delay for taken branches unless the condition code register is set
5823e4b17023SJohn Marinothree instructions earlier than the conditional branch.  The instruction
5824e4b17023SJohn Marinoscheduler cannot perform this optimization if it is not permitted to
5825e4b17023SJohn Marinoseparate the definition and use of the condition code register.
5826e4b17023SJohn Marino
5827e4b17023SJohn MarinoFor this reason, it is possible and suggested to use a register to
5828e4b17023SJohn Marinorepresent the condition code for new ports.  If there is a specific
5829e4b17023SJohn Marinocondition code register in the machine, use a hard register.  If the
5830e4b17023SJohn Marinocondition code or comparison result can be placed in any general register,
5831e4b17023SJohn Marinoor if there are multiple condition registers, use a pseudo register.
5832e4b17023SJohn MarinoRegisters used to store the condition code value will usually have a mode
5833e4b17023SJohn Marinothat is in class @code{MODE_CC}.
5834e4b17023SJohn Marino
5835e4b17023SJohn MarinoAlternatively, you can use @code{BImode} if the comparison operator is
5836e4b17023SJohn Marinospecified already in the compare instruction.  In this case, you are not
5837e4b17023SJohn Marinointerested in most macros in this section.
5838e4b17023SJohn Marino
5839e4b17023SJohn Marino@menu
5840e4b17023SJohn Marino* CC0 Condition Codes::      Old style representation of condition codes.
5841e4b17023SJohn Marino* MODE_CC Condition Codes::  Modern representation of condition codes.
5842e4b17023SJohn Marino* Cond Exec Macros::         Macros to control conditional execution.
5843e4b17023SJohn Marino@end menu
5844e4b17023SJohn Marino
5845e4b17023SJohn Marino@node CC0 Condition Codes
5846e4b17023SJohn Marino@subsection Representation of condition codes using @code{(cc0)}
5847e4b17023SJohn Marino@findex cc0
5848e4b17023SJohn Marino
5849e4b17023SJohn Marino@findex cc_status
5850e4b17023SJohn MarinoThe file @file{conditions.h} defines a variable @code{cc_status} to
5851e4b17023SJohn Marinodescribe how the condition code was computed (in case the interpretation of
5852e4b17023SJohn Marinothe condition code depends on the instruction that it was set by).  This
5853e4b17023SJohn Marinovariable contains the RTL expressions on which the condition code is
5854e4b17023SJohn Marinocurrently based, and several standard flags.
5855e4b17023SJohn Marino
5856e4b17023SJohn MarinoSometimes additional machine-specific flags must be defined in the machine
5857e4b17023SJohn Marinodescription header file.  It can also add additional machine-specific
5858e4b17023SJohn Marinoinformation by defining @code{CC_STATUS_MDEP}.
5859e4b17023SJohn Marino
5860e4b17023SJohn Marino@defmac CC_STATUS_MDEP
5861e4b17023SJohn MarinoC code for a data type which is used for declaring the @code{mdep}
5862e4b17023SJohn Marinocomponent of @code{cc_status}.  It defaults to @code{int}.
5863e4b17023SJohn Marino
5864e4b17023SJohn MarinoThis macro is not used on machines that do not use @code{cc0}.
5865e4b17023SJohn Marino@end defmac
5866e4b17023SJohn Marino
5867e4b17023SJohn Marino@defmac CC_STATUS_MDEP_INIT
5868e4b17023SJohn MarinoA C expression to initialize the @code{mdep} field to ``empty''.
5869e4b17023SJohn MarinoThe default definition does nothing, since most machines don't use
5870e4b17023SJohn Marinothe field anyway.  If you want to use the field, you should probably
5871e4b17023SJohn Marinodefine this macro to initialize it.
5872e4b17023SJohn Marino
5873e4b17023SJohn MarinoThis macro is not used on machines that do not use @code{cc0}.
5874e4b17023SJohn Marino@end defmac
5875e4b17023SJohn Marino
5876e4b17023SJohn Marino@defmac NOTICE_UPDATE_CC (@var{exp}, @var{insn})
5877e4b17023SJohn MarinoA C compound statement to set the components of @code{cc_status}
5878e4b17023SJohn Marinoappropriately for an insn @var{insn} whose body is @var{exp}.  It is
5879e4b17023SJohn Marinothis macro's responsibility to recognize insns that set the condition
5880e4b17023SJohn Marinocode as a byproduct of other activity as well as those that explicitly
5881e4b17023SJohn Marinoset @code{(cc0)}.
5882e4b17023SJohn Marino
5883e4b17023SJohn MarinoThis macro is not used on machines that do not use @code{cc0}.
5884e4b17023SJohn Marino
5885e4b17023SJohn MarinoIf there are insns that do not set the condition code but do alter
5886e4b17023SJohn Marinoother machine registers, this macro must check to see whether they
5887e4b17023SJohn Marinoinvalidate the expressions that the condition code is recorded as
5888e4b17023SJohn Marinoreflecting.  For example, on the 68000, insns that store in address
5889e4b17023SJohn Marinoregisters do not set the condition code, which means that usually
5890e4b17023SJohn Marino@code{NOTICE_UPDATE_CC} can leave @code{cc_status} unaltered for such
5891e4b17023SJohn Marinoinsns.  But suppose that the previous insn set the condition code
5892e4b17023SJohn Marinobased on location @samp{a4@@(102)} and the current insn stores a new
5893e4b17023SJohn Marinovalue in @samp{a4}.  Although the condition code is not changed by
5894e4b17023SJohn Marinothis, it will no longer be true that it reflects the contents of
5895e4b17023SJohn Marino@samp{a4@@(102)}.  Therefore, @code{NOTICE_UPDATE_CC} must alter
5896e4b17023SJohn Marino@code{cc_status} in this case to say that nothing is known about the
5897e4b17023SJohn Marinocondition code value.
5898e4b17023SJohn Marino
5899e4b17023SJohn MarinoThe definition of @code{NOTICE_UPDATE_CC} must be prepared to deal
5900e4b17023SJohn Marinowith the results of peephole optimization: insns whose patterns are
5901e4b17023SJohn Marino@code{parallel} RTXs containing various @code{reg}, @code{mem} or
5902e4b17023SJohn Marinoconstants which are just the operands.  The RTL structure of these
5903e4b17023SJohn Marinoinsns is not sufficient to indicate what the insns actually do.  What
5904e4b17023SJohn Marino@code{NOTICE_UPDATE_CC} should do when it sees one is just to run
5905e4b17023SJohn Marino@code{CC_STATUS_INIT}.
5906e4b17023SJohn Marino
5907e4b17023SJohn MarinoA possible definition of @code{NOTICE_UPDATE_CC} is to call a function
5908e4b17023SJohn Marinothat looks at an attribute (@pxref{Insn Attributes}) named, for example,
5909e4b17023SJohn Marino@samp{cc}.  This avoids having detailed information about patterns in
5910e4b17023SJohn Marinotwo places, the @file{md} file and in @code{NOTICE_UPDATE_CC}.
5911e4b17023SJohn Marino@end defmac
5912e4b17023SJohn Marino
5913e4b17023SJohn Marino@node MODE_CC Condition Codes
5914e4b17023SJohn Marino@subsection Representation of condition codes using registers
5915e4b17023SJohn Marino@findex CCmode
5916e4b17023SJohn Marino@findex MODE_CC
5917e4b17023SJohn Marino
5918e4b17023SJohn Marino@defmac SELECT_CC_MODE (@var{op}, @var{x}, @var{y})
5919e4b17023SJohn MarinoOn many machines, the condition code may be produced by other instructions
5920e4b17023SJohn Marinothan compares, for example the branch can use directly the condition
5921e4b17023SJohn Marinocode set by a subtract instruction.  However, on some machines
5922e4b17023SJohn Marinowhen the condition code is set this way some bits (such as the overflow
5923e4b17023SJohn Marinobit) are not set in the same way as a test instruction, so that a different
5924e4b17023SJohn Marinobranch instruction must be used for some conditional branches.  When
5925e4b17023SJohn Marinothis happens, use the machine mode of the condition code register to
5926e4b17023SJohn Marinorecord different formats of the condition code register.  Modes can
5927e4b17023SJohn Marinoalso be used to record which compare instruction (e.g. a signed or an
5928e4b17023SJohn Marinounsigned comparison) produced the condition codes.
5929e4b17023SJohn Marino
5930e4b17023SJohn MarinoIf other modes than @code{CCmode} are required, add them to
5931e4b17023SJohn Marino@file{@var{machine}-modes.def} and define @code{SELECT_CC_MODE} to choose
5932e4b17023SJohn Marinoa mode given an operand of a compare.  This is needed because the modes
5933e4b17023SJohn Marinohave to be chosen not only during RTL generation but also, for example,
5934e4b17023SJohn Marinoby instruction combination.  The result of @code{SELECT_CC_MODE} should
5935e4b17023SJohn Marinobe consistent with the mode used in the patterns; for example to support
5936e4b17023SJohn Marinothe case of the add on the SPARC discussed above, we have the pattern
5937e4b17023SJohn Marino
5938e4b17023SJohn Marino@smallexample
5939e4b17023SJohn Marino(define_insn ""
5940e4b17023SJohn Marino  [(set (reg:CC_NOOV 0)
5941e4b17023SJohn Marino        (compare:CC_NOOV
5942e4b17023SJohn Marino          (plus:SI (match_operand:SI 0 "register_operand" "%r")
5943e4b17023SJohn Marino                   (match_operand:SI 1 "arith_operand" "rI"))
5944e4b17023SJohn Marino          (const_int 0)))]
5945e4b17023SJohn Marino  ""
5946e4b17023SJohn Marino  "@dots{}")
5947e4b17023SJohn Marino@end smallexample
5948e4b17023SJohn Marino
5949e4b17023SJohn Marino@noindent
5950e4b17023SJohn Marinotogether with a @code{SELECT_CC_MODE} that returns @code{CC_NOOVmode}
5951e4b17023SJohn Marinofor comparisons whose argument is a @code{plus}:
5952e4b17023SJohn Marino
5953e4b17023SJohn Marino@smallexample
5954e4b17023SJohn Marino#define SELECT_CC_MODE(OP,X,Y) \
5955e4b17023SJohn Marino  (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT          \
5956e4b17023SJohn Marino   ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode)    \
5957e4b17023SJohn Marino   : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS    \
5958e4b17023SJohn Marino       || GET_CODE (X) == NEG) \
5959e4b17023SJohn Marino      ? CC_NOOVmode : CCmode))
5960e4b17023SJohn Marino@end smallexample
5961e4b17023SJohn Marino
5962e4b17023SJohn MarinoAnother reason to use modes is to retain information on which operands
5963e4b17023SJohn Marinowere used by the comparison; see @code{REVERSIBLE_CC_MODE} later in
5964e4b17023SJohn Marinothis section.
5965e4b17023SJohn Marino
5966e4b17023SJohn MarinoYou should define this macro if and only if you define extra CC modes
5967e4b17023SJohn Marinoin @file{@var{machine}-modes.def}.
5968e4b17023SJohn Marino@end defmac
5969e4b17023SJohn Marino
5970e4b17023SJohn Marino@defmac CANONICALIZE_COMPARISON (@var{code}, @var{op0}, @var{op1})
5971e4b17023SJohn MarinoOn some machines not all possible comparisons are defined, but you can
5972e4b17023SJohn Marinoconvert an invalid comparison into a valid one.  For example, the Alpha
5973e4b17023SJohn Marinodoes not have a @code{GT} comparison, but you can use an @code{LT}
5974e4b17023SJohn Marinocomparison instead and swap the order of the operands.
5975e4b17023SJohn Marino
5976e4b17023SJohn MarinoOn such machines, define this macro to be a C statement to do any
5977e4b17023SJohn Marinorequired conversions.  @var{code} is the initial comparison code
5978e4b17023SJohn Marinoand @var{op0} and @var{op1} are the left and right operands of the
5979e4b17023SJohn Marinocomparison, respectively.  You should modify @var{code}, @var{op0}, and
5980e4b17023SJohn Marino@var{op1} as required.
5981e4b17023SJohn Marino
5982e4b17023SJohn MarinoGCC will not assume that the comparison resulting from this macro is
5983e4b17023SJohn Marinovalid but will see if the resulting insn matches a pattern in the
5984e4b17023SJohn Marino@file{md} file.
5985e4b17023SJohn Marino
5986e4b17023SJohn MarinoYou need not define this macro if it would never change the comparison
5987e4b17023SJohn Marinocode or operands.
5988e4b17023SJohn Marino@end defmac
5989e4b17023SJohn Marino
5990e4b17023SJohn Marino@defmac REVERSIBLE_CC_MODE (@var{mode})
5991e4b17023SJohn MarinoA C expression whose value is one if it is always safe to reverse a
5992e4b17023SJohn Marinocomparison whose mode is @var{mode}.  If @code{SELECT_CC_MODE}
5993e4b17023SJohn Marinocan ever return @var{mode} for a floating-point inequality comparison,
5994e4b17023SJohn Marinothen @code{REVERSIBLE_CC_MODE (@var{mode})} must be zero.
5995e4b17023SJohn Marino
5996e4b17023SJohn MarinoYou need not define this macro if it would always returns zero or if the
5997e4b17023SJohn Marinofloating-point format is anything other than @code{IEEE_FLOAT_FORMAT}.
5998e4b17023SJohn MarinoFor example, here is the definition used on the SPARC, where floating-point
5999e4b17023SJohn Marinoinequality comparisons are always given @code{CCFPEmode}:
6000e4b17023SJohn Marino
6001e4b17023SJohn Marino@smallexample
6002e4b17023SJohn Marino#define REVERSIBLE_CC_MODE(MODE)  ((MODE) != CCFPEmode)
6003e4b17023SJohn Marino@end smallexample
6004e4b17023SJohn Marino@end defmac
6005e4b17023SJohn Marino
6006e4b17023SJohn Marino@defmac REVERSE_CONDITION (@var{code}, @var{mode})
6007e4b17023SJohn MarinoA C expression whose value is reversed condition code of the @var{code} for
6008e4b17023SJohn Marinocomparison done in CC_MODE @var{mode}.  The macro is used only in case
6009e4b17023SJohn Marino@code{REVERSIBLE_CC_MODE (@var{mode})} is nonzero.  Define this macro in case
6010e4b17023SJohn Marinomachine has some non-standard way how to reverse certain conditionals.  For
6011e4b17023SJohn Marinoinstance in case all floating point conditions are non-trapping, compiler may
6012e4b17023SJohn Marinofreely convert unordered compares to ordered one.  Then definition may look
6013e4b17023SJohn Marinolike:
6014e4b17023SJohn Marino
6015e4b17023SJohn Marino@smallexample
6016e4b17023SJohn Marino#define REVERSE_CONDITION(CODE, MODE) \
6017e4b17023SJohn Marino   ((MODE) != CCFPmode ? reverse_condition (CODE) \
6018e4b17023SJohn Marino    : reverse_condition_maybe_unordered (CODE))
6019e4b17023SJohn Marino@end smallexample
6020e4b17023SJohn Marino@end defmac
6021e4b17023SJohn Marino
6022e4b17023SJohn Marino@hook TARGET_FIXED_CONDITION_CODE_REGS
6023e4b17023SJohn MarinoOn targets which do not use @code{(cc0)}, and which use a hard
6024e4b17023SJohn Marinoregister rather than a pseudo-register to hold condition codes, the
6025e4b17023SJohn Marinoregular CSE passes are often not able to identify cases in which the
6026e4b17023SJohn Marinohard register is set to a common value.  Use this hook to enable a
6027e4b17023SJohn Marinosmall pass which optimizes such cases.  This hook should return true
6028e4b17023SJohn Marinoto enable this pass, and it should set the integers to which its
6029e4b17023SJohn Marinoarguments point to the hard register numbers used for condition codes.
6030e4b17023SJohn MarinoWhen there is only one such register, as is true on most systems, the
6031e4b17023SJohn Marinointeger pointed to by @var{p2} should be set to
6032e4b17023SJohn Marino@code{INVALID_REGNUM}.
6033e4b17023SJohn Marino
6034e4b17023SJohn MarinoThe default version of this hook returns false.
6035e4b17023SJohn Marino@end deftypefn
6036e4b17023SJohn Marino
6037e4b17023SJohn Marino@hook TARGET_CC_MODES_COMPATIBLE
6038e4b17023SJohn MarinoOn targets which use multiple condition code modes in class
6039e4b17023SJohn Marino@code{MODE_CC}, it is sometimes the case that a comparison can be
6040e4b17023SJohn Marinovalidly done in more than one mode.  On such a system, define this
6041e4b17023SJohn Marinotarget hook to take two mode arguments and to return a mode in which
6042e4b17023SJohn Marinoboth comparisons may be validly done.  If there is no such mode,
6043e4b17023SJohn Marinoreturn @code{VOIDmode}.
6044e4b17023SJohn Marino
6045e4b17023SJohn MarinoThe default version of this hook checks whether the modes are the
6046e4b17023SJohn Marinosame.  If they are, it returns that mode.  If they are different, it
6047e4b17023SJohn Marinoreturns @code{VOIDmode}.
6048e4b17023SJohn Marino@end deftypefn
6049e4b17023SJohn Marino
6050e4b17023SJohn Marino@node Cond Exec Macros
6051e4b17023SJohn Marino@subsection Macros to control conditional execution
6052e4b17023SJohn Marino@findex conditional execution
6053e4b17023SJohn Marino@findex predication
6054e4b17023SJohn Marino
6055e4b17023SJohn MarinoThere is one macro that may need to be defined for targets
6056e4b17023SJohn Marinosupporting conditional execution, independent of how they
6057e4b17023SJohn Marinorepresent conditional branches.
6058e4b17023SJohn Marino
6059e4b17023SJohn Marino@defmac REVERSE_CONDEXEC_PREDICATES_P (@var{op1}, @var{op2})
6060e4b17023SJohn MarinoA C expression that returns true if the conditional execution predicate
6061e4b17023SJohn Marino@var{op1}, a comparison operation, is the inverse of @var{op2} and vice
6062e4b17023SJohn Marinoversa.  Define this to return 0 if the target has conditional execution
6063e4b17023SJohn Marinopredicates that cannot be reversed safely.  There is no need to validate
6064e4b17023SJohn Marinothat the arguments of op1 and op2 are the same, this is done separately.
6065e4b17023SJohn MarinoIf no expansion is specified, this macro is defined as follows:
6066e4b17023SJohn Marino
6067e4b17023SJohn Marino@smallexample
6068e4b17023SJohn Marino#define REVERSE_CONDEXEC_PREDICATES_P (x, y) \
6069e4b17023SJohn Marino   (GET_CODE ((x)) == reversed_comparison_code ((y), NULL))
6070e4b17023SJohn Marino@end smallexample
6071e4b17023SJohn Marino@end defmac
6072e4b17023SJohn Marino
6073e4b17023SJohn Marino@node Costs
6074e4b17023SJohn Marino@section Describing Relative Costs of Operations
6075e4b17023SJohn Marino@cindex costs of instructions
6076e4b17023SJohn Marino@cindex relative costs
6077e4b17023SJohn Marino@cindex speed of instructions
6078e4b17023SJohn Marino
6079e4b17023SJohn MarinoThese macros let you describe the relative speed of various operations
6080e4b17023SJohn Marinoon the target machine.
6081e4b17023SJohn Marino
6082e4b17023SJohn Marino@defmac REGISTER_MOVE_COST (@var{mode}, @var{from}, @var{to})
6083e4b17023SJohn MarinoA C expression for the cost of moving data of mode @var{mode} from a
6084e4b17023SJohn Marinoregister in class @var{from} to one in class @var{to}.  The classes are
6085e4b17023SJohn Marinoexpressed using the enumeration values such as @code{GENERAL_REGS}.  A
6086e4b17023SJohn Marinovalue of 2 is the default; other values are interpreted relative to
6087e4b17023SJohn Marinothat.
6088e4b17023SJohn Marino
6089e4b17023SJohn MarinoIt is not required that the cost always equal 2 when @var{from} is the
6090e4b17023SJohn Marinosame as @var{to}; on some machines it is expensive to move between
6091e4b17023SJohn Marinoregisters if they are not general registers.
6092e4b17023SJohn Marino
6093e4b17023SJohn MarinoIf reload sees an insn consisting of a single @code{set} between two
6094e4b17023SJohn Marinohard registers, and if @code{REGISTER_MOVE_COST} applied to their
6095e4b17023SJohn Marinoclasses returns a value of 2, reload does not check to ensure that the
6096e4b17023SJohn Marinoconstraints of the insn are met.  Setting a cost of other than 2 will
6097e4b17023SJohn Marinoallow reload to verify that the constraints are met.  You should do this
6098e4b17023SJohn Marinoif the @samp{mov@var{m}} pattern's constraints do not allow such copying.
6099e4b17023SJohn Marino
6100e4b17023SJohn MarinoThese macros are obsolete, new ports should use the target hook
6101e4b17023SJohn Marino@code{TARGET_REGISTER_MOVE_COST} instead.
6102e4b17023SJohn Marino@end defmac
6103e4b17023SJohn Marino
6104e4b17023SJohn Marino@hook TARGET_REGISTER_MOVE_COST
6105e4b17023SJohn MarinoThis target hook should return the cost of moving data of mode @var{mode}
6106e4b17023SJohn Marinofrom a register in class @var{from} to one in class @var{to}.  The classes
6107e4b17023SJohn Marinoare expressed using the enumeration values such as @code{GENERAL_REGS}.
6108e4b17023SJohn MarinoA value of 2 is the default; other values are interpreted relative to
6109e4b17023SJohn Marinothat.
6110e4b17023SJohn Marino
6111e4b17023SJohn MarinoIt is not required that the cost always equal 2 when @var{from} is the
6112e4b17023SJohn Marinosame as @var{to}; on some machines it is expensive to move between
6113e4b17023SJohn Marinoregisters if they are not general registers.
6114e4b17023SJohn Marino
6115e4b17023SJohn MarinoIf reload sees an insn consisting of a single @code{set} between two
6116e4b17023SJohn Marinohard registers, and if @code{TARGET_REGISTER_MOVE_COST} applied to their
6117e4b17023SJohn Marinoclasses returns a value of 2, reload does not check to ensure that the
6118e4b17023SJohn Marinoconstraints of the insn are met.  Setting a cost of other than 2 will
6119e4b17023SJohn Marinoallow reload to verify that the constraints are met.  You should do this
6120e4b17023SJohn Marinoif the @samp{mov@var{m}} pattern's constraints do not allow such copying.
6121e4b17023SJohn Marino
6122e4b17023SJohn MarinoThe default version of this function returns 2.
6123e4b17023SJohn Marino@end deftypefn
6124e4b17023SJohn Marino
6125e4b17023SJohn Marino@defmac MEMORY_MOVE_COST (@var{mode}, @var{class}, @var{in})
6126e4b17023SJohn MarinoA C expression for the cost of moving data of mode @var{mode} between a
6127e4b17023SJohn Marinoregister of class @var{class} and memory; @var{in} is zero if the value
6128e4b17023SJohn Marinois to be written to memory, nonzero if it is to be read in.  This cost
6129e4b17023SJohn Marinois relative to those in @code{REGISTER_MOVE_COST}.  If moving between
6130e4b17023SJohn Marinoregisters and memory is more expensive than between two registers, you
6131e4b17023SJohn Marinoshould define this macro to express the relative cost.
6132e4b17023SJohn Marino
6133e4b17023SJohn MarinoIf you do not define this macro, GCC uses a default cost of 4 plus
6134e4b17023SJohn Marinothe cost of copying via a secondary reload register, if one is
6135e4b17023SJohn Marinoneeded.  If your machine requires a secondary reload register to copy
6136e4b17023SJohn Marinobetween memory and a register of @var{class} but the reload mechanism is
6137e4b17023SJohn Marinomore complex than copying via an intermediate, define this macro to
6138e4b17023SJohn Marinoreflect the actual cost of the move.
6139e4b17023SJohn Marino
6140e4b17023SJohn MarinoGCC defines the function @code{memory_move_secondary_cost} if
6141e4b17023SJohn Marinosecondary reloads are needed.  It computes the costs due to copying via
6142e4b17023SJohn Marinoa secondary register.  If your machine copies from memory using a
6143e4b17023SJohn Marinosecondary register in the conventional way but the default base value of
6144e4b17023SJohn Marino4 is not correct for your machine, define this macro to add some other
6145e4b17023SJohn Marinovalue to the result of that function.  The arguments to that function
6146e4b17023SJohn Marinoare the same as to this macro.
6147e4b17023SJohn Marino
6148e4b17023SJohn MarinoThese macros are obsolete, new ports should use the target hook
6149e4b17023SJohn Marino@code{TARGET_MEMORY_MOVE_COST} instead.
6150e4b17023SJohn Marino@end defmac
6151e4b17023SJohn Marino
6152e4b17023SJohn Marino@hook TARGET_MEMORY_MOVE_COST
6153e4b17023SJohn MarinoThis target hook should return the cost of moving data of mode @var{mode}
6154e4b17023SJohn Marinobetween a register of class @var{rclass} and memory; @var{in} is @code{false}
6155e4b17023SJohn Marinoif the value is to be written to memory, @code{true} if it is to be read in.
6156e4b17023SJohn MarinoThis cost is relative to those in @code{TARGET_REGISTER_MOVE_COST}.
6157e4b17023SJohn MarinoIf moving between registers and memory is more expensive than between two
6158e4b17023SJohn Marinoregisters, you should add this target hook to express the relative cost.
6159e4b17023SJohn Marino
6160e4b17023SJohn MarinoIf you do not add this target hook, GCC uses a default cost of 4 plus
6161e4b17023SJohn Marinothe cost of copying via a secondary reload register, if one is
6162e4b17023SJohn Marinoneeded.  If your machine requires a secondary reload register to copy
6163e4b17023SJohn Marinobetween memory and a register of @var{rclass} but the reload mechanism is
6164e4b17023SJohn Marinomore complex than copying via an intermediate, use this target hook to
6165e4b17023SJohn Marinoreflect the actual cost of the move.
6166e4b17023SJohn Marino
6167e4b17023SJohn MarinoGCC defines the function @code{memory_move_secondary_cost} if
6168e4b17023SJohn Marinosecondary reloads are needed.  It computes the costs due to copying via
6169e4b17023SJohn Marinoa secondary register.  If your machine copies from memory using a
6170e4b17023SJohn Marinosecondary register in the conventional way but the default base value of
6171e4b17023SJohn Marino4 is not correct for your machine, use this target hook to add some other
6172e4b17023SJohn Marinovalue to the result of that function.  The arguments to that function
6173e4b17023SJohn Marinoare the same as to this target hook.
6174e4b17023SJohn Marino@end deftypefn
6175e4b17023SJohn Marino
6176e4b17023SJohn Marino@defmac BRANCH_COST (@var{speed_p}, @var{predictable_p})
6177e4b17023SJohn MarinoA C expression for the cost of a branch instruction.  A value of 1 is
6178e4b17023SJohn Marinothe default; other values are interpreted relative to that. Parameter
6179e4b17023SJohn Marino@var{speed_p} is true when the branch in question should be optimized
6180e4b17023SJohn Marinofor speed.  When it is false, @code{BRANCH_COST} should return a value
6181e4b17023SJohn Marinooptimal for code size rather than performance.  @var{predictable_p} is
6182e4b17023SJohn Marinotrue for well-predicted branches. On many architectures the
6183e4b17023SJohn Marino@code{BRANCH_COST} can be reduced then.
6184e4b17023SJohn Marino@end defmac
6185e4b17023SJohn Marino
6186e4b17023SJohn MarinoHere are additional macros which do not specify precise relative costs,
6187e4b17023SJohn Marinobut only that certain actions are more expensive than GCC would
6188e4b17023SJohn Marinoordinarily expect.
6189e4b17023SJohn Marino
6190e4b17023SJohn Marino@defmac SLOW_BYTE_ACCESS
6191e4b17023SJohn MarinoDefine this macro as a C expression which is nonzero if accessing less
6192e4b17023SJohn Marinothan a word of memory (i.e.@: a @code{char} or a @code{short}) is no
6193e4b17023SJohn Marinofaster than accessing a word of memory, i.e., if such access
6194e4b17023SJohn Marinorequire more than one instruction or if there is no difference in cost
6195e4b17023SJohn Marinobetween byte and (aligned) word loads.
6196e4b17023SJohn Marino
6197e4b17023SJohn MarinoWhen this macro is not defined, the compiler will access a field by
6198e4b17023SJohn Marinofinding the smallest containing object; when it is defined, a fullword
6199e4b17023SJohn Marinoload will be used if alignment permits.  Unless bytes accesses are
6200e4b17023SJohn Marinofaster than word accesses, using word accesses is preferable since it
6201e4b17023SJohn Marinomay eliminate subsequent memory access if subsequent accesses occur to
6202e4b17023SJohn Marinoother fields in the same word of the structure, but to different bytes.
6203e4b17023SJohn Marino@end defmac
6204e4b17023SJohn Marino
6205e4b17023SJohn Marino@defmac SLOW_UNALIGNED_ACCESS (@var{mode}, @var{alignment})
6206e4b17023SJohn MarinoDefine this macro to be the value 1 if memory accesses described by the
6207e4b17023SJohn Marino@var{mode} and @var{alignment} parameters have a cost many times greater
6208e4b17023SJohn Marinothan aligned accesses, for example if they are emulated in a trap
6209e4b17023SJohn Marinohandler.
6210e4b17023SJohn Marino
6211e4b17023SJohn MarinoWhen this macro is nonzero, the compiler will act as if
6212e4b17023SJohn Marino@code{STRICT_ALIGNMENT} were nonzero when generating code for block
6213e4b17023SJohn Marinomoves.  This can cause significantly more instructions to be produced.
6214e4b17023SJohn MarinoTherefore, do not set this macro nonzero if unaligned accesses only add a
6215e4b17023SJohn Marinocycle or two to the time for a memory access.
6216e4b17023SJohn Marino
6217e4b17023SJohn MarinoIf the value of this macro is always zero, it need not be defined.  If
6218e4b17023SJohn Marinothis macro is defined, it should produce a nonzero value when
6219e4b17023SJohn Marino@code{STRICT_ALIGNMENT} is nonzero.
6220e4b17023SJohn Marino@end defmac
6221e4b17023SJohn Marino
6222e4b17023SJohn Marino@defmac MOVE_RATIO (@var{speed})
6223e4b17023SJohn MarinoThe threshold of number of scalar memory-to-memory move insns, @emph{below}
6224e4b17023SJohn Marinowhich a sequence of insns should be generated instead of a
6225e4b17023SJohn Marinostring move insn or a library call.  Increasing the value will always
6226e4b17023SJohn Marinomake code faster, but eventually incurs high cost in increased code size.
6227e4b17023SJohn Marino
6228e4b17023SJohn MarinoNote that on machines where the corresponding move insn is a
6229e4b17023SJohn Marino@code{define_expand} that emits a sequence of insns, this macro counts
6230e4b17023SJohn Marinothe number of such sequences.
6231e4b17023SJohn Marino
6232e4b17023SJohn MarinoThe parameter @var{speed} is true if the code is currently being
6233e4b17023SJohn Marinooptimized for speed rather than size.
6234e4b17023SJohn Marino
6235e4b17023SJohn MarinoIf you don't define this, a reasonable default is used.
6236e4b17023SJohn Marino@end defmac
6237e4b17023SJohn Marino
6238e4b17023SJohn Marino@defmac MOVE_BY_PIECES_P (@var{size}, @var{alignment})
6239e4b17023SJohn MarinoA C expression used to determine whether @code{move_by_pieces} will be used to
6240e4b17023SJohn Marinocopy a chunk of memory, or whether some other block move mechanism
6241e4b17023SJohn Marinowill be used.  Defaults to 1 if @code{move_by_pieces_ninsns} returns less
6242e4b17023SJohn Marinothan @code{MOVE_RATIO}.
6243e4b17023SJohn Marino@end defmac
6244e4b17023SJohn Marino
6245e4b17023SJohn Marino@defmac MOVE_MAX_PIECES
6246e4b17023SJohn MarinoA C expression used by @code{move_by_pieces} to determine the largest unit
6247e4b17023SJohn Marinoa load or store used to copy memory is.  Defaults to @code{MOVE_MAX}.
6248e4b17023SJohn Marino@end defmac
6249e4b17023SJohn Marino
6250e4b17023SJohn Marino@defmac CLEAR_RATIO (@var{speed})
6251e4b17023SJohn MarinoThe threshold of number of scalar move insns, @emph{below} which a sequence
6252e4b17023SJohn Marinoof insns should be generated to clear memory instead of a string clear insn
6253e4b17023SJohn Marinoor a library call.  Increasing the value will always make code faster, but
6254e4b17023SJohn Marinoeventually incurs high cost in increased code size.
6255e4b17023SJohn Marino
6256e4b17023SJohn MarinoThe parameter @var{speed} is true if the code is currently being
6257e4b17023SJohn Marinooptimized for speed rather than size.
6258e4b17023SJohn Marino
6259e4b17023SJohn MarinoIf you don't define this, a reasonable default is used.
6260e4b17023SJohn Marino@end defmac
6261e4b17023SJohn Marino
6262e4b17023SJohn Marino@defmac CLEAR_BY_PIECES_P (@var{size}, @var{alignment})
6263e4b17023SJohn MarinoA C expression used to determine whether @code{clear_by_pieces} will be used
6264e4b17023SJohn Marinoto clear a chunk of memory, or whether some other block clear mechanism
6265e4b17023SJohn Marinowill be used.  Defaults to 1 if @code{move_by_pieces_ninsns} returns less
6266e4b17023SJohn Marinothan @code{CLEAR_RATIO}.
6267e4b17023SJohn Marino@end defmac
6268e4b17023SJohn Marino
6269e4b17023SJohn Marino@defmac SET_RATIO (@var{speed})
6270e4b17023SJohn MarinoThe threshold of number of scalar move insns, @emph{below} which a sequence
6271e4b17023SJohn Marinoof insns should be generated to set memory to a constant value, instead of
6272e4b17023SJohn Marinoa block set insn or a library call.
6273e4b17023SJohn MarinoIncreasing the value will always make code faster, but
6274e4b17023SJohn Marinoeventually incurs high cost in increased code size.
6275e4b17023SJohn Marino
6276e4b17023SJohn MarinoThe parameter @var{speed} is true if the code is currently being
6277e4b17023SJohn Marinooptimized for speed rather than size.
6278e4b17023SJohn Marino
6279e4b17023SJohn MarinoIf you don't define this, it defaults to the value of @code{MOVE_RATIO}.
6280e4b17023SJohn Marino@end defmac
6281e4b17023SJohn Marino
6282e4b17023SJohn Marino@defmac SET_BY_PIECES_P (@var{size}, @var{alignment})
6283e4b17023SJohn MarinoA C expression used to determine whether @code{store_by_pieces} will be
6284e4b17023SJohn Marinoused to set a chunk of memory to a constant value, or whether some
6285e4b17023SJohn Marinoother mechanism will be used.  Used by @code{__builtin_memset} when
6286e4b17023SJohn Marinostoring values other than constant zero.
6287e4b17023SJohn MarinoDefaults to 1 if @code{move_by_pieces_ninsns} returns less
6288e4b17023SJohn Marinothan @code{SET_RATIO}.
6289e4b17023SJohn Marino@end defmac
6290e4b17023SJohn Marino
6291e4b17023SJohn Marino@defmac STORE_BY_PIECES_P (@var{size}, @var{alignment})
6292e4b17023SJohn MarinoA C expression used to determine whether @code{store_by_pieces} will be
6293e4b17023SJohn Marinoused to set a chunk of memory to a constant string value, or whether some
6294e4b17023SJohn Marinoother mechanism will be used.  Used by @code{__builtin_strcpy} when
6295e4b17023SJohn Marinocalled with a constant source string.
6296e4b17023SJohn MarinoDefaults to 1 if @code{move_by_pieces_ninsns} returns less
6297e4b17023SJohn Marinothan @code{MOVE_RATIO}.
6298e4b17023SJohn Marino@end defmac
6299e4b17023SJohn Marino
6300e4b17023SJohn Marino@defmac USE_LOAD_POST_INCREMENT (@var{mode})
6301e4b17023SJohn MarinoA C expression used to determine whether a load postincrement is a good
6302e4b17023SJohn Marinothing to use for a given mode.  Defaults to the value of
6303e4b17023SJohn Marino@code{HAVE_POST_INCREMENT}.
6304e4b17023SJohn Marino@end defmac
6305e4b17023SJohn Marino
6306e4b17023SJohn Marino@defmac USE_LOAD_POST_DECREMENT (@var{mode})
6307e4b17023SJohn MarinoA C expression used to determine whether a load postdecrement is a good
6308e4b17023SJohn Marinothing to use for a given mode.  Defaults to the value of
6309e4b17023SJohn Marino@code{HAVE_POST_DECREMENT}.
6310e4b17023SJohn Marino@end defmac
6311e4b17023SJohn Marino
6312e4b17023SJohn Marino@defmac USE_LOAD_PRE_INCREMENT (@var{mode})
6313e4b17023SJohn MarinoA C expression used to determine whether a load preincrement is a good
6314e4b17023SJohn Marinothing to use for a given mode.  Defaults to the value of
6315e4b17023SJohn Marino@code{HAVE_PRE_INCREMENT}.
6316e4b17023SJohn Marino@end defmac
6317e4b17023SJohn Marino
6318e4b17023SJohn Marino@defmac USE_LOAD_PRE_DECREMENT (@var{mode})
6319e4b17023SJohn MarinoA C expression used to determine whether a load predecrement is a good
6320e4b17023SJohn Marinothing to use for a given mode.  Defaults to the value of
6321e4b17023SJohn Marino@code{HAVE_PRE_DECREMENT}.
6322e4b17023SJohn Marino@end defmac
6323e4b17023SJohn Marino
6324e4b17023SJohn Marino@defmac USE_STORE_POST_INCREMENT (@var{mode})
6325e4b17023SJohn MarinoA C expression used to determine whether a store postincrement is a good
6326e4b17023SJohn Marinothing to use for a given mode.  Defaults to the value of
6327e4b17023SJohn Marino@code{HAVE_POST_INCREMENT}.
6328e4b17023SJohn Marino@end defmac
6329e4b17023SJohn Marino
6330e4b17023SJohn Marino@defmac USE_STORE_POST_DECREMENT (@var{mode})
6331e4b17023SJohn MarinoA C expression used to determine whether a store postdecrement is a good
6332e4b17023SJohn Marinothing to use for a given mode.  Defaults to the value of
6333e4b17023SJohn Marino@code{HAVE_POST_DECREMENT}.
6334e4b17023SJohn Marino@end defmac
6335e4b17023SJohn Marino
6336e4b17023SJohn Marino@defmac USE_STORE_PRE_INCREMENT (@var{mode})
6337e4b17023SJohn MarinoThis macro is used to determine whether a store preincrement is a good
6338e4b17023SJohn Marinothing to use for a given mode.  Defaults to the value of
6339e4b17023SJohn Marino@code{HAVE_PRE_INCREMENT}.
6340e4b17023SJohn Marino@end defmac
6341e4b17023SJohn Marino
6342e4b17023SJohn Marino@defmac USE_STORE_PRE_DECREMENT (@var{mode})
6343e4b17023SJohn MarinoThis macro is used to determine whether a store predecrement is a good
6344e4b17023SJohn Marinothing to use for a given mode.  Defaults to the value of
6345e4b17023SJohn Marino@code{HAVE_PRE_DECREMENT}.
6346e4b17023SJohn Marino@end defmac
6347e4b17023SJohn Marino
6348e4b17023SJohn Marino@defmac NO_FUNCTION_CSE
6349e4b17023SJohn MarinoDefine this macro if it is as good or better to call a constant
6350e4b17023SJohn Marinofunction address than to call an address kept in a register.
6351e4b17023SJohn Marino@end defmac
6352e4b17023SJohn Marino
6353e4b17023SJohn Marino@defmac RANGE_TEST_NON_SHORT_CIRCUIT
6354e4b17023SJohn MarinoDefine this macro if a non-short-circuit operation produced by
6355e4b17023SJohn Marino@samp{fold_range_test ()} is optimal.  This macro defaults to true if
6356e4b17023SJohn Marino@code{BRANCH_COST} is greater than or equal to the value 2.
6357e4b17023SJohn Marino@end defmac
6358e4b17023SJohn Marino
6359e4b17023SJohn Marino@hook TARGET_RTX_COSTS
6360e4b17023SJohn MarinoThis target hook describes the relative costs of RTL expressions.
6361e4b17023SJohn Marino
6362e4b17023SJohn MarinoThe cost may depend on the precise form of the expression, which is
6363e4b17023SJohn Marinoavailable for examination in @var{x}, and the fact that @var{x} appears
6364e4b17023SJohn Marinoas operand @var{opno} of an expression with rtx code @var{outer_code}.
6365e4b17023SJohn MarinoThat is, the hook can assume that there is some rtx @var{y} such
6366e4b17023SJohn Marinothat @samp{GET_CODE (@var{y}) == @var{outer_code}} and such that
6367e4b17023SJohn Marinoeither (a) @samp{XEXP (@var{y}, @var{opno}) == @var{x}} or
6368e4b17023SJohn Marino(b) @samp{XVEC (@var{y}, @var{opno})} contains @var{x}.
6369e4b17023SJohn Marino
6370e4b17023SJohn Marino@var{code} is @var{x}'s expression code---redundant, since it can be
6371e4b17023SJohn Marinoobtained with @code{GET_CODE (@var{x})}.
6372e4b17023SJohn Marino
6373e4b17023SJohn MarinoIn implementing this hook, you can use the construct
6374e4b17023SJohn Marino@code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast
6375e4b17023SJohn Marinoinstructions.
6376e4b17023SJohn Marino
6377e4b17023SJohn MarinoOn entry to the hook, @code{*@var{total}} contains a default estimate
6378e4b17023SJohn Marinofor the cost of the expression.  The hook should modify this value as
6379e4b17023SJohn Marinonecessary.  Traditionally, the default costs are @code{COSTS_N_INSNS (5)}
6380e4b17023SJohn Marinofor multiplications, @code{COSTS_N_INSNS (7)} for division and modulus
6381e4b17023SJohn Marinooperations, and @code{COSTS_N_INSNS (1)} for all other operations.
6382e4b17023SJohn Marino
6383e4b17023SJohn MarinoWhen optimizing for code size, i.e.@: when @code{speed} is
6384e4b17023SJohn Marinofalse, this target hook should be used to estimate the relative
6385e4b17023SJohn Marinosize cost of an expression, again relative to @code{COSTS_N_INSNS}.
6386e4b17023SJohn Marino
6387e4b17023SJohn MarinoThe hook returns true when all subexpressions of @var{x} have been
6388e4b17023SJohn Marinoprocessed, and false when @code{rtx_cost} should recurse.
6389e4b17023SJohn Marino@end deftypefn
6390e4b17023SJohn Marino
6391e4b17023SJohn Marino@hook TARGET_ADDRESS_COST
6392e4b17023SJohn MarinoThis hook computes the cost of an addressing mode that contains
6393e4b17023SJohn Marino@var{address}.  If not defined, the cost is computed from
6394e4b17023SJohn Marinothe @var{address} expression and the @code{TARGET_RTX_COST} hook.
6395e4b17023SJohn Marino
6396e4b17023SJohn MarinoFor most CISC machines, the default cost is a good approximation of the
6397e4b17023SJohn Marinotrue cost of the addressing mode.  However, on RISC machines, all
6398e4b17023SJohn Marinoinstructions normally have the same length and execution time.  Hence
6399e4b17023SJohn Marinoall addresses will have equal costs.
6400e4b17023SJohn Marino
6401e4b17023SJohn MarinoIn cases where more than one form of an address is known, the form with
6402e4b17023SJohn Marinothe lowest cost will be used.  If multiple forms have the same, lowest,
6403e4b17023SJohn Marinocost, the one that is the most complex will be used.
6404e4b17023SJohn Marino
6405e4b17023SJohn MarinoFor example, suppose an address that is equal to the sum of a register
6406e4b17023SJohn Marinoand a constant is used twice in the same basic block.  When this macro
6407e4b17023SJohn Marinois not defined, the address will be computed in a register and memory
6408e4b17023SJohn Marinoreferences will be indirect through that register.  On machines where
6409e4b17023SJohn Marinothe cost of the addressing mode containing the sum is no higher than
6410e4b17023SJohn Marinothat of a simple indirect reference, this will produce an additional
6411e4b17023SJohn Marinoinstruction and possibly require an additional register.  Proper
6412e4b17023SJohn Marinospecification of this macro eliminates this overhead for such machines.
6413e4b17023SJohn Marino
6414e4b17023SJohn MarinoThis hook is never called with an invalid address.
6415e4b17023SJohn Marino
6416e4b17023SJohn MarinoOn machines where an address involving more than one register is as
6417e4b17023SJohn Marinocheap as an address computation involving only one register, defining
6418e4b17023SJohn Marino@code{TARGET_ADDRESS_COST} to reflect this can cause two registers to
6419e4b17023SJohn Marinobe live over a region of code where only one would have been if
6420e4b17023SJohn Marino@code{TARGET_ADDRESS_COST} were not defined in that manner.  This effect
6421e4b17023SJohn Marinoshould be considered in the definition of this macro.  Equivalent costs
6422e4b17023SJohn Marinoshould probably only be given to addresses with different numbers of
6423e4b17023SJohn Marinoregisters on machines with lots of registers.
6424e4b17023SJohn Marino@end deftypefn
6425e4b17023SJohn Marino
6426e4b17023SJohn Marino@node Scheduling
6427e4b17023SJohn Marino@section Adjusting the Instruction Scheduler
6428e4b17023SJohn Marino
6429e4b17023SJohn MarinoThe instruction scheduler may need a fair amount of machine-specific
6430e4b17023SJohn Marinoadjustment in order to produce good code.  GCC provides several target
6431e4b17023SJohn Marinohooks for this purpose.  It is usually enough to define just a few of
6432e4b17023SJohn Marinothem: try the first ones in this list first.
6433e4b17023SJohn Marino
6434e4b17023SJohn Marino@hook TARGET_SCHED_ISSUE_RATE
6435e4b17023SJohn MarinoThis hook returns the maximum number of instructions that can ever
6436e4b17023SJohn Marinoissue at the same time on the target machine.  The default is one.
6437e4b17023SJohn MarinoAlthough the insn scheduler can define itself the possibility of issue
6438e4b17023SJohn Marinoan insn on the same cycle, the value can serve as an additional
6439e4b17023SJohn Marinoconstraint to issue insns on the same simulated processor cycle (see
6440e4b17023SJohn Marinohooks @samp{TARGET_SCHED_REORDER} and @samp{TARGET_SCHED_REORDER2}).
6441e4b17023SJohn MarinoThis value must be constant over the entire compilation.  If you need
6442e4b17023SJohn Marinoit to vary depending on what the instructions are, you must use
6443e4b17023SJohn Marino@samp{TARGET_SCHED_VARIABLE_ISSUE}.
6444e4b17023SJohn Marino@end deftypefn
6445e4b17023SJohn Marino
6446e4b17023SJohn Marino@hook TARGET_SCHED_VARIABLE_ISSUE
6447e4b17023SJohn MarinoThis hook is executed by the scheduler after it has scheduled an insn
6448e4b17023SJohn Marinofrom the ready list.  It should return the number of insns which can
6449e4b17023SJohn Marinostill be issued in the current cycle.  The default is
6450e4b17023SJohn Marino@samp{@w{@var{more} - 1}} for insns other than @code{CLOBBER} and
6451e4b17023SJohn Marino@code{USE}, which normally are not counted against the issue rate.
6452e4b17023SJohn MarinoYou should define this hook if some insns take more machine resources
6453e4b17023SJohn Marinothan others, so that fewer insns can follow them in the same cycle.
6454e4b17023SJohn Marino@var{file} is either a null pointer, or a stdio stream to write any
6455e4b17023SJohn Marinodebug output to.  @var{verbose} is the verbose level provided by
6456e4b17023SJohn Marino@option{-fsched-verbose-@var{n}}.  @var{insn} is the instruction that
6457e4b17023SJohn Marinowas scheduled.
6458e4b17023SJohn Marino@end deftypefn
6459e4b17023SJohn Marino
6460e4b17023SJohn Marino@hook TARGET_SCHED_ADJUST_COST
6461e4b17023SJohn MarinoThis function corrects the value of @var{cost} based on the
6462e4b17023SJohn Marinorelationship between @var{insn} and @var{dep_insn} through the
6463e4b17023SJohn Marinodependence @var{link}.  It should return the new value.  The default
6464e4b17023SJohn Marinois to make no adjustment to @var{cost}.  This can be used for example
6465e4b17023SJohn Marinoto specify to the scheduler using the traditional pipeline description
6466e4b17023SJohn Marinothat an output- or anti-dependence does not incur the same cost as a
6467e4b17023SJohn Marinodata-dependence.  If the scheduler using the automaton based pipeline
6468e4b17023SJohn Marinodescription, the cost of anti-dependence is zero and the cost of
6469e4b17023SJohn Marinooutput-dependence is maximum of one and the difference of latency
6470e4b17023SJohn Marinotimes of the first and the second insns.  If these values are not
6471e4b17023SJohn Marinoacceptable, you could use the hook to modify them too.  See also
6472e4b17023SJohn Marino@pxref{Processor pipeline description}.
6473e4b17023SJohn Marino@end deftypefn
6474e4b17023SJohn Marino
6475e4b17023SJohn Marino@hook TARGET_SCHED_ADJUST_PRIORITY
6476e4b17023SJohn MarinoThis hook adjusts the integer scheduling priority @var{priority} of
6477e4b17023SJohn Marino@var{insn}.  It should return the new priority.  Increase the priority to
6478e4b17023SJohn Marinoexecute @var{insn} earlier, reduce the priority to execute @var{insn}
6479e4b17023SJohn Marinolater.  Do not define this hook if you do not need to adjust the
6480e4b17023SJohn Marinoscheduling priorities of insns.
6481e4b17023SJohn Marino@end deftypefn
6482e4b17023SJohn Marino
6483e4b17023SJohn Marino@hook TARGET_SCHED_REORDER
6484e4b17023SJohn MarinoThis hook is executed by the scheduler after it has scheduled the ready
6485e4b17023SJohn Marinolist, to allow the machine description to reorder it (for example to
6486e4b17023SJohn Marinocombine two small instructions together on @samp{VLIW} machines).
6487e4b17023SJohn Marino@var{file} is either a null pointer, or a stdio stream to write any
6488e4b17023SJohn Marinodebug output to.  @var{verbose} is the verbose level provided by
6489e4b17023SJohn Marino@option{-fsched-verbose-@var{n}}.  @var{ready} is a pointer to the ready
6490e4b17023SJohn Marinolist of instructions that are ready to be scheduled.  @var{n_readyp} is
6491e4b17023SJohn Marinoa pointer to the number of elements in the ready list.  The scheduler
6492e4b17023SJohn Marinoreads the ready list in reverse order, starting with
6493e4b17023SJohn Marino@var{ready}[@var{*n_readyp} @minus{} 1] and going to @var{ready}[0].  @var{clock}
6494e4b17023SJohn Marinois the timer tick of the scheduler.  You may modify the ready list and
6495e4b17023SJohn Marinothe number of ready insns.  The return value is the number of insns that
6496e4b17023SJohn Marinocan issue this cycle; normally this is just @code{issue_rate}.  See also
6497e4b17023SJohn Marino@samp{TARGET_SCHED_REORDER2}.
6498e4b17023SJohn Marino@end deftypefn
6499e4b17023SJohn Marino
6500e4b17023SJohn Marino@hook TARGET_SCHED_REORDER2
6501e4b17023SJohn MarinoLike @samp{TARGET_SCHED_REORDER}, but called at a different time.  That
6502e4b17023SJohn Marinofunction is called whenever the scheduler starts a new cycle.  This one
6503e4b17023SJohn Marinois called once per iteration over a cycle, immediately after
6504e4b17023SJohn Marino@samp{TARGET_SCHED_VARIABLE_ISSUE}; it can reorder the ready list and
6505e4b17023SJohn Marinoreturn the number of insns to be scheduled in the same cycle.  Defining
6506e4b17023SJohn Marinothis hook can be useful if there are frequent situations where
6507e4b17023SJohn Marinoscheduling one insn causes other insns to become ready in the same
6508e4b17023SJohn Marinocycle.  These other insns can then be taken into account properly.
6509e4b17023SJohn Marino@end deftypefn
6510e4b17023SJohn Marino
6511e4b17023SJohn Marino@hook TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK
6512e4b17023SJohn MarinoThis hook is called after evaluation forward dependencies of insns in
6513e4b17023SJohn Marinochain given by two parameter values (@var{head} and @var{tail}
6514e4b17023SJohn Marinocorrespondingly) but before insns scheduling of the insn chain.  For
6515e4b17023SJohn Marinoexample, it can be used for better insn classification if it requires
6516e4b17023SJohn Marinoanalysis of dependencies.  This hook can use backward and forward
6517e4b17023SJohn Marinodependencies of the insn scheduler because they are already
6518e4b17023SJohn Marinocalculated.
6519e4b17023SJohn Marino@end deftypefn
6520e4b17023SJohn Marino
6521e4b17023SJohn Marino@hook TARGET_SCHED_INIT
6522e4b17023SJohn MarinoThis hook is executed by the scheduler at the beginning of each block of
6523e4b17023SJohn Marinoinstructions that are to be scheduled.  @var{file} is either a null
6524e4b17023SJohn Marinopointer, or a stdio stream to write any debug output to.  @var{verbose}
6525e4b17023SJohn Marinois the verbose level provided by @option{-fsched-verbose-@var{n}}.
6526e4b17023SJohn Marino@var{max_ready} is the maximum number of insns in the current scheduling
6527e4b17023SJohn Marinoregion that can be live at the same time.  This can be used to allocate
6528e4b17023SJohn Marinoscratch space if it is needed, e.g.@: by @samp{TARGET_SCHED_REORDER}.
6529e4b17023SJohn Marino@end deftypefn
6530e4b17023SJohn Marino
6531e4b17023SJohn Marino@hook TARGET_SCHED_FINISH
6532e4b17023SJohn MarinoThis hook is executed by the scheduler at the end of each block of
6533e4b17023SJohn Marinoinstructions that are to be scheduled.  It can be used to perform
6534e4b17023SJohn Marinocleanup of any actions done by the other scheduling hooks.  @var{file}
6535e4b17023SJohn Marinois either a null pointer, or a stdio stream to write any debug output
6536e4b17023SJohn Marinoto.  @var{verbose} is the verbose level provided by
6537e4b17023SJohn Marino@option{-fsched-verbose-@var{n}}.
6538e4b17023SJohn Marino@end deftypefn
6539e4b17023SJohn Marino
6540e4b17023SJohn Marino@hook TARGET_SCHED_INIT_GLOBAL
6541e4b17023SJohn MarinoThis hook is executed by the scheduler after function level initializations.
6542e4b17023SJohn Marino@var{file} is either a null pointer, or a stdio stream to write any debug output to.
6543e4b17023SJohn Marino@var{verbose} is the verbose level provided by @option{-fsched-verbose-@var{n}}.
6544e4b17023SJohn Marino@var{old_max_uid} is the maximum insn uid when scheduling begins.
6545e4b17023SJohn Marino@end deftypefn
6546e4b17023SJohn Marino
6547e4b17023SJohn Marino@hook TARGET_SCHED_FINISH_GLOBAL
6548e4b17023SJohn MarinoThis is the cleanup hook corresponding to @code{TARGET_SCHED_INIT_GLOBAL}.
6549e4b17023SJohn Marino@var{file} is either a null pointer, or a stdio stream to write any debug output to.
6550e4b17023SJohn Marino@var{verbose} is the verbose level provided by @option{-fsched-verbose-@var{n}}.
6551e4b17023SJohn Marino@end deftypefn
6552e4b17023SJohn Marino
6553e4b17023SJohn Marino@hook TARGET_SCHED_DFA_PRE_CYCLE_INSN
6554e4b17023SJohn MarinoThe hook returns an RTL insn.  The automaton state used in the
6555e4b17023SJohn Marinopipeline hazard recognizer is changed as if the insn were scheduled
6556e4b17023SJohn Marinowhen the new simulated processor cycle starts.  Usage of the hook may
6557e4b17023SJohn Marinosimplify the automaton pipeline description for some @acronym{VLIW}
6558e4b17023SJohn Marinoprocessors.  If the hook is defined, it is used only for the automaton
6559e4b17023SJohn Marinobased pipeline description.  The default is not to change the state
6560e4b17023SJohn Marinowhen the new simulated processor cycle starts.
6561e4b17023SJohn Marino@end deftypefn
6562e4b17023SJohn Marino
6563e4b17023SJohn Marino@hook TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN
6564e4b17023SJohn MarinoThe hook can be used to initialize data used by the previous hook.
6565e4b17023SJohn Marino@end deftypefn
6566e4b17023SJohn Marino
6567e4b17023SJohn Marino@hook TARGET_SCHED_DFA_POST_CYCLE_INSN
6568e4b17023SJohn MarinoThe hook is analogous to @samp{TARGET_SCHED_DFA_PRE_CYCLE_INSN} but used
6569e4b17023SJohn Marinoto changed the state as if the insn were scheduled when the new
6570e4b17023SJohn Marinosimulated processor cycle finishes.
6571e4b17023SJohn Marino@end deftypefn
6572e4b17023SJohn Marino
6573e4b17023SJohn Marino@hook TARGET_SCHED_INIT_DFA_POST_CYCLE_INSN
6574e4b17023SJohn MarinoThe hook is analogous to @samp{TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN} but
6575e4b17023SJohn Marinoused to initialize data used by the previous hook.
6576e4b17023SJohn Marino@end deftypefn
6577e4b17023SJohn Marino
6578e4b17023SJohn Marino@hook TARGET_SCHED_DFA_PRE_ADVANCE_CYCLE
6579e4b17023SJohn MarinoThe hook to notify target that the current simulated cycle is about to finish.
6580e4b17023SJohn MarinoThe hook is analogous to @samp{TARGET_SCHED_DFA_PRE_CYCLE_INSN} but used
6581e4b17023SJohn Marinoto change the state in more complicated situations - e.g., when advancing
6582e4b17023SJohn Marinostate on a single insn is not enough.
6583e4b17023SJohn Marino@end deftypefn
6584e4b17023SJohn Marino
6585e4b17023SJohn Marino@hook TARGET_SCHED_DFA_POST_ADVANCE_CYCLE
6586e4b17023SJohn MarinoThe hook to notify target that new simulated cycle has just started.
6587e4b17023SJohn MarinoThe hook is analogous to @samp{TARGET_SCHED_DFA_POST_CYCLE_INSN} but used
6588e4b17023SJohn Marinoto change the state in more complicated situations - e.g., when advancing
6589e4b17023SJohn Marinostate on a single insn is not enough.
6590e4b17023SJohn Marino@end deftypefn
6591e4b17023SJohn Marino
6592e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
6593e4b17023SJohn MarinoThis hook controls better choosing an insn from the ready insn queue
6594e4b17023SJohn Marinofor the @acronym{DFA}-based insn scheduler.  Usually the scheduler
6595e4b17023SJohn Marinochooses the first insn from the queue.  If the hook returns a positive
6596e4b17023SJohn Marinovalue, an additional scheduler code tries all permutations of
6597e4b17023SJohn Marino@samp{TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD ()}
6598e4b17023SJohn Marinosubsequent ready insns to choose an insn whose issue will result in
6599e4b17023SJohn Marinomaximal number of issued insns on the same cycle.  For the
6600e4b17023SJohn Marino@acronym{VLIW} processor, the code could actually solve the problem of
6601e4b17023SJohn Marinopacking simple insns into the @acronym{VLIW} insn.  Of course, if the
6602e4b17023SJohn Marinorules of @acronym{VLIW} packing are described in the automaton.
6603e4b17023SJohn Marino
6604e4b17023SJohn MarinoThis code also could be used for superscalar @acronym{RISC}
6605e4b17023SJohn Marinoprocessors.  Let us consider a superscalar @acronym{RISC} processor
6606e4b17023SJohn Marinowith 3 pipelines.  Some insns can be executed in pipelines @var{A} or
6607e4b17023SJohn Marino@var{B}, some insns can be executed only in pipelines @var{B} or
6608e4b17023SJohn Marino@var{C}, and one insn can be executed in pipeline @var{B}.  The
6609e4b17023SJohn Marinoprocessor may issue the 1st insn into @var{A} and the 2nd one into
6610e4b17023SJohn Marino@var{B}.  In this case, the 3rd insn will wait for freeing @var{B}
6611e4b17023SJohn Marinountil the next cycle.  If the scheduler issues the 3rd insn the first,
6612e4b17023SJohn Marinothe processor could issue all 3 insns per cycle.
6613e4b17023SJohn Marino
6614e4b17023SJohn MarinoActually this code demonstrates advantages of the automaton based
6615e4b17023SJohn Marinopipeline hazard recognizer.  We try quickly and easy many insn
6616e4b17023SJohn Marinoschedules to choose the best one.
6617e4b17023SJohn Marino
6618e4b17023SJohn MarinoThe default is no multipass scheduling.
6619e4b17023SJohn Marino@end deftypefn
6620e4b17023SJohn Marino
6621e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD
6622e4b17023SJohn Marino
6623e4b17023SJohn MarinoThis hook controls what insns from the ready insn queue will be
6624e4b17023SJohn Marinoconsidered for the multipass insn scheduling.  If the hook returns
6625e4b17023SJohn Marinozero for @var{insn}, the insn will be not chosen to
6626e4b17023SJohn Marinobe issued.
6627e4b17023SJohn Marino
6628e4b17023SJohn MarinoThe default is that any ready insns can be chosen to be issued.
6629e4b17023SJohn Marino@end deftypefn
6630e4b17023SJohn Marino
6631e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BEGIN
6632e4b17023SJohn MarinoThis hook prepares the target backend for a new round of multipass
6633e4b17023SJohn Marinoscheduling.
6634e4b17023SJohn Marino@end deftypefn
6635e4b17023SJohn Marino
6636e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_ISSUE
6637e4b17023SJohn MarinoThis hook is called when multipass scheduling evaluates instruction INSN.
6638e4b17023SJohn Marino@end deftypefn
6639e4b17023SJohn Marino
6640e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BACKTRACK
6641e4b17023SJohn MarinoThis is called when multipass scheduling backtracks from evaluation of
6642e4b17023SJohn Marinoan instruction.
6643e4b17023SJohn Marino@end deftypefn
6644e4b17023SJohn Marino
6645e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_END
6646e4b17023SJohn MarinoThis hook notifies the target about the result of the concluded current
6647e4b17023SJohn Marinoround of multipass scheduling.
6648e4b17023SJohn Marino@end deftypefn
6649e4b17023SJohn Marino
6650e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_INIT
6651e4b17023SJohn MarinoThis hook initializes target-specific data used in multipass scheduling.
6652e4b17023SJohn Marino@end deftypefn
6653e4b17023SJohn Marino
6654e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_FINI
6655e4b17023SJohn MarinoThis hook finalizes target-specific data used in multipass scheduling.
6656e4b17023SJohn Marino@end deftypefn
6657e4b17023SJohn Marino
6658e4b17023SJohn Marino@hook TARGET_SCHED_DFA_NEW_CYCLE
6659e4b17023SJohn MarinoThis hook is called by the insn scheduler before issuing @var{insn}
6660e4b17023SJohn Marinoon cycle @var{clock}.  If the hook returns nonzero,
6661e4b17023SJohn Marino@var{insn} is not issued on this processor cycle.  Instead,
6662e4b17023SJohn Marinothe processor cycle is advanced.  If *@var{sort_p}
6663e4b17023SJohn Marinois zero, the insn ready queue is not sorted on the new cycle
6664e4b17023SJohn Marinostart as usually.  @var{dump} and @var{verbose} specify the file and
6665e4b17023SJohn Marinoverbosity level to use for debugging output.
6666e4b17023SJohn Marino@var{last_clock} and @var{clock} are, respectively, the
6667e4b17023SJohn Marinoprocessor cycle on which the previous insn has been issued,
6668e4b17023SJohn Marinoand the current processor cycle.
6669e4b17023SJohn Marino@end deftypefn
6670e4b17023SJohn Marino
6671e4b17023SJohn Marino@hook TARGET_SCHED_IS_COSTLY_DEPENDENCE
6672e4b17023SJohn MarinoThis hook is used to define which dependences are considered costly by
6673e4b17023SJohn Marinothe target, so costly that it is not advisable to schedule the insns that
6674e4b17023SJohn Marinoare involved in the dependence too close to one another.  The parameters
6675e4b17023SJohn Marinoto this hook are as follows:  The first parameter @var{_dep} is the dependence
6676e4b17023SJohn Marinobeing evaluated.  The second parameter @var{cost} is the cost of the
6677e4b17023SJohn Marinodependence as estimated by the scheduler, and the third
6678e4b17023SJohn Marinoparameter @var{distance} is the distance in cycles between the two insns.
6679e4b17023SJohn MarinoThe hook returns @code{true} if considering the distance between the two
6680e4b17023SJohn Marinoinsns the dependence between them is considered costly by the target,
6681e4b17023SJohn Marinoand @code{false} otherwise.
6682e4b17023SJohn Marino
6683e4b17023SJohn MarinoDefining this hook can be useful in multiple-issue out-of-order machines,
6684e4b17023SJohn Marinowhere (a) it's practically hopeless to predict the actual data/resource
6685e4b17023SJohn Marinodelays, however: (b) there's a better chance to predict the actual grouping
6686e4b17023SJohn Marinothat will be formed, and (c) correctly emulating the grouping can be very
6687e4b17023SJohn Marinoimportant.  In such targets one may want to allow issuing dependent insns
6688e4b17023SJohn Marinocloser to one another---i.e., closer than the dependence distance;  however,
6689e4b17023SJohn Marinonot in cases of ``costly dependences'', which this hooks allows to define.
6690e4b17023SJohn Marino@end deftypefn
6691e4b17023SJohn Marino
6692e4b17023SJohn Marino@hook TARGET_SCHED_H_I_D_EXTENDED
6693e4b17023SJohn MarinoThis hook is called by the insn scheduler after emitting a new instruction to
6694e4b17023SJohn Marinothe instruction stream.  The hook notifies a target backend to extend its
6695e4b17023SJohn Marinoper instruction data structures.
6696e4b17023SJohn Marino@end deftypefn
6697e4b17023SJohn Marino
6698e4b17023SJohn Marino@hook TARGET_SCHED_ALLOC_SCHED_CONTEXT
6699e4b17023SJohn MarinoReturn a pointer to a store large enough to hold target scheduling context.
6700e4b17023SJohn Marino@end deftypefn
6701e4b17023SJohn Marino
6702e4b17023SJohn Marino@hook TARGET_SCHED_INIT_SCHED_CONTEXT
6703e4b17023SJohn MarinoInitialize store pointed to by @var{tc} to hold target scheduling context.
6704e4b17023SJohn MarinoIt @var{clean_p} is true then initialize @var{tc} as if scheduler is at the
6705e4b17023SJohn Marinobeginning of the block.  Otherwise, copy the current context into @var{tc}.
6706e4b17023SJohn Marino@end deftypefn
6707e4b17023SJohn Marino
6708e4b17023SJohn Marino@hook TARGET_SCHED_SET_SCHED_CONTEXT
6709e4b17023SJohn MarinoCopy target scheduling context pointed to by @var{tc} to the current context.
6710e4b17023SJohn Marino@end deftypefn
6711e4b17023SJohn Marino
6712e4b17023SJohn Marino@hook TARGET_SCHED_CLEAR_SCHED_CONTEXT
6713e4b17023SJohn MarinoDeallocate internal data in target scheduling context pointed to by @var{tc}.
6714e4b17023SJohn Marino@end deftypefn
6715e4b17023SJohn Marino
6716e4b17023SJohn Marino@hook TARGET_SCHED_FREE_SCHED_CONTEXT
6717e4b17023SJohn MarinoDeallocate a store for target scheduling context pointed to by @var{tc}.
6718e4b17023SJohn Marino@end deftypefn
6719e4b17023SJohn Marino
6720e4b17023SJohn Marino@hook TARGET_SCHED_SPECULATE_INSN
6721e4b17023SJohn MarinoThis hook is called by the insn scheduler when @var{insn} has only
6722e4b17023SJohn Marinospeculative dependencies and therefore can be scheduled speculatively.
6723e4b17023SJohn MarinoThe hook is used to check if the pattern of @var{insn} has a speculative
6724e4b17023SJohn Marinoversion and, in case of successful check, to generate that speculative
6725e4b17023SJohn Marinopattern.  The hook should return 1, if the instruction has a speculative form,
6726e4b17023SJohn Marinoor @minus{}1, if it doesn't.  @var{request} describes the type of requested
6727e4b17023SJohn Marinospeculation.  If the return value equals 1 then @var{new_pat} is assigned
6728e4b17023SJohn Marinothe generated speculative pattern.
6729e4b17023SJohn Marino@end deftypefn
6730e4b17023SJohn Marino
6731e4b17023SJohn Marino@hook TARGET_SCHED_NEEDS_BLOCK_P
6732e4b17023SJohn MarinoThis hook is called by the insn scheduler during generation of recovery code
6733e4b17023SJohn Marinofor @var{insn}.  It should return @code{true}, if the corresponding check
6734e4b17023SJohn Marinoinstruction should branch to recovery code, or @code{false} otherwise.
6735e4b17023SJohn Marino@end deftypefn
6736e4b17023SJohn Marino
6737e4b17023SJohn Marino@hook TARGET_SCHED_GEN_SPEC_CHECK
6738e4b17023SJohn MarinoThis hook is called by the insn scheduler to generate a pattern for recovery
6739e4b17023SJohn Marinocheck instruction.  If @var{mutate_p} is zero, then @var{insn} is a
6740e4b17023SJohn Marinospeculative instruction for which the check should be generated.
6741e4b17023SJohn Marino@var{label} is either a label of a basic block, where recovery code should
6742e4b17023SJohn Marinobe emitted, or a null pointer, when requested check doesn't branch to
6743e4b17023SJohn Marinorecovery code (a simple check).  If @var{mutate_p} is nonzero, then
6744e4b17023SJohn Marinoa pattern for a branchy check corresponding to a simple check denoted by
6745e4b17023SJohn Marino@var{insn} should be generated.  In this case @var{label} can't be null.
6746e4b17023SJohn Marino@end deftypefn
6747e4b17023SJohn Marino
6748e4b17023SJohn Marino@hook TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD_SPEC
6749e4b17023SJohn MarinoThis hook is used as a workaround for
6750e4b17023SJohn Marino@samp{TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD} not being
6751e4b17023SJohn Marinocalled on the first instruction of the ready list.  The hook is used to
6752e4b17023SJohn Marinodiscard speculative instructions that stand first in the ready list from
6753e4b17023SJohn Marinobeing scheduled on the current cycle.  If the hook returns @code{false},
6754e4b17023SJohn Marino@var{insn} will not be chosen to be issued.
6755e4b17023SJohn MarinoFor non-speculative instructions,
6756e4b17023SJohn Marinothe hook should always return @code{true}.  For example, in the ia64 backend
6757e4b17023SJohn Marinothe hook is used to cancel data speculative insns when the ALAT table
6758e4b17023SJohn Marinois nearly full.
6759e4b17023SJohn Marino@end deftypefn
6760e4b17023SJohn Marino
6761e4b17023SJohn Marino@hook TARGET_SCHED_SET_SCHED_FLAGS
6762e4b17023SJohn MarinoThis hook is used by the insn scheduler to find out what features should be
6763e4b17023SJohn Marinoenabled/used.
6764e4b17023SJohn MarinoThe structure *@var{spec_info} should be filled in by the target.
6765e4b17023SJohn MarinoThe structure describes speculation types that can be used in the scheduler.
6766e4b17023SJohn Marino@end deftypefn
6767e4b17023SJohn Marino
6768e4b17023SJohn Marino@hook TARGET_SCHED_SMS_RES_MII
6769e4b17023SJohn MarinoThis hook is called by the swing modulo scheduler to calculate a
6770e4b17023SJohn Marinoresource-based lower bound which is based on the resources available in
6771e4b17023SJohn Marinothe machine and the resources required by each instruction.  The target
6772e4b17023SJohn Marinobackend can use @var{g} to calculate such bound.  A very simple lower
6773e4b17023SJohn Marinobound will be used in case this hook is not implemented: the total number
6774e4b17023SJohn Marinoof instructions divided by the issue rate.
6775e4b17023SJohn Marino@end deftypefn
6776e4b17023SJohn Marino
6777e4b17023SJohn Marino@hook TARGET_SCHED_DISPATCH
6778e4b17023SJohn MarinoThis hook is called by Haifa Scheduler.  It returns true if dispatch scheduling
6779e4b17023SJohn Marinois supported in hardware and the condition specified in the parameter is true.
6780e4b17023SJohn Marino@end deftypefn
6781e4b17023SJohn Marino
6782e4b17023SJohn Marino@hook TARGET_SCHED_DISPATCH_DO
6783e4b17023SJohn MarinoThis hook is called by Haifa Scheduler.  It performs the operation specified
6784e4b17023SJohn Marinoin its second parameter.
6785e4b17023SJohn Marino@end deftypefn
6786e4b17023SJohn Marino
6787e4b17023SJohn Marino@hook TARGET_SCHED_EXPOSED_PIPELINE
6788e4b17023SJohn Marino
6789e4b17023SJohn Marino@hook TARGET_SCHED_REASSOCIATION_WIDTH
6790e4b17023SJohn Marino
6791e4b17023SJohn Marino@node Sections
6792e4b17023SJohn Marino@section Dividing the Output into Sections (Texts, Data, @dots{})
6793e4b17023SJohn Marino@c the above section title is WAY too long.  maybe cut the part between
6794e4b17023SJohn Marino@c the (...)?  --mew 10feb93
6795e4b17023SJohn Marino
6796e4b17023SJohn MarinoAn object file is divided into sections containing different types of
6797e4b17023SJohn Marinodata.  In the most common case, there are three sections: the @dfn{text
6798e4b17023SJohn Marinosection}, which holds instructions and read-only data; the @dfn{data
6799e4b17023SJohn Marinosection}, which holds initialized writable data; and the @dfn{bss
6800e4b17023SJohn Marinosection}, which holds uninitialized data.  Some systems have other kinds
6801e4b17023SJohn Marinoof sections.
6802e4b17023SJohn Marino
6803e4b17023SJohn Marino@file{varasm.c} provides several well-known sections, such as
6804e4b17023SJohn Marino@code{text_section}, @code{data_section} and @code{bss_section}.
6805e4b17023SJohn MarinoThe normal way of controlling a @code{@var{foo}_section} variable
6806e4b17023SJohn Marinois to define the associated @code{@var{FOO}_SECTION_ASM_OP} macro,
6807e4b17023SJohn Marinoas described below.  The macros are only read once, when @file{varasm.c}
6808e4b17023SJohn Marinoinitializes itself, so their values must be run-time constants.
6809e4b17023SJohn MarinoThey may however depend on command-line flags.
6810e4b17023SJohn Marino
6811e4b17023SJohn Marino@emph{Note:} Some run-time files, such @file{crtstuff.c}, also make
6812e4b17023SJohn Marinouse of the @code{@var{FOO}_SECTION_ASM_OP} macros, and expect them
6813e4b17023SJohn Marinoto be string literals.
6814e4b17023SJohn Marino
6815e4b17023SJohn MarinoSome assemblers require a different string to be written every time a
6816e4b17023SJohn Marinosection is selected.  If your assembler falls into this category, you
6817e4b17023SJohn Marinoshould define the @code{TARGET_ASM_INIT_SECTIONS} hook and use
6818e4b17023SJohn Marino@code{get_unnamed_section} to set up the sections.
6819e4b17023SJohn Marino
6820e4b17023SJohn MarinoYou must always create a @code{text_section}, either by defining
6821e4b17023SJohn Marino@code{TEXT_SECTION_ASM_OP} or by initializing @code{text_section}
6822e4b17023SJohn Marinoin @code{TARGET_ASM_INIT_SECTIONS}.  The same is true of
6823e4b17023SJohn Marino@code{data_section} and @code{DATA_SECTION_ASM_OP}.  If you do not
6824e4b17023SJohn Marinocreate a distinct @code{readonly_data_section}, the default is to
6825e4b17023SJohn Marinoreuse @code{text_section}.
6826e4b17023SJohn Marino
6827e4b17023SJohn MarinoAll the other @file{varasm.c} sections are optional, and are null
6828e4b17023SJohn Marinoif the target does not provide them.
6829e4b17023SJohn Marino
6830e4b17023SJohn Marino@defmac TEXT_SECTION_ASM_OP
6831e4b17023SJohn MarinoA C expression whose value is a string, including spacing, containing the
6832e4b17023SJohn Marinoassembler operation that should precede instructions and read-only data.
6833e4b17023SJohn MarinoNormally @code{"\t.text"} is right.
6834e4b17023SJohn Marino@end defmac
6835e4b17023SJohn Marino
6836e4b17023SJohn Marino@defmac HOT_TEXT_SECTION_NAME
6837e4b17023SJohn MarinoIf defined, a C string constant for the name of the section containing most
6838e4b17023SJohn Marinofrequently executed functions of the program.  If not defined, GCC will provide
6839e4b17023SJohn Marinoa default definition if the target supports named sections.
6840e4b17023SJohn Marino@end defmac
6841e4b17023SJohn Marino
6842e4b17023SJohn Marino@defmac UNLIKELY_EXECUTED_TEXT_SECTION_NAME
6843e4b17023SJohn MarinoIf defined, a C string constant for the name of the section containing unlikely
6844e4b17023SJohn Marinoexecuted functions in the program.
6845e4b17023SJohn Marino@end defmac
6846e4b17023SJohn Marino
6847e4b17023SJohn Marino@defmac DATA_SECTION_ASM_OP
6848e4b17023SJohn MarinoA C expression whose value is a string, including spacing, containing the
6849e4b17023SJohn Marinoassembler operation to identify the following data as writable initialized
6850e4b17023SJohn Marinodata.  Normally @code{"\t.data"} is right.
6851e4b17023SJohn Marino@end defmac
6852e4b17023SJohn Marino
6853e4b17023SJohn Marino@defmac SDATA_SECTION_ASM_OP
6854e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing,
6855e4b17023SJohn Marinocontaining the assembler operation to identify the following data as
6856e4b17023SJohn Marinoinitialized, writable small data.
6857e4b17023SJohn Marino@end defmac
6858e4b17023SJohn Marino
6859e4b17023SJohn Marino@defmac READONLY_DATA_SECTION_ASM_OP
6860e4b17023SJohn MarinoA C expression whose value is a string, including spacing, containing the
6861e4b17023SJohn Marinoassembler operation to identify the following data as read-only initialized
6862e4b17023SJohn Marinodata.
6863e4b17023SJohn Marino@end defmac
6864e4b17023SJohn Marino
6865e4b17023SJohn Marino@defmac BSS_SECTION_ASM_OP
6866e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing,
6867e4b17023SJohn Marinocontaining the assembler operation to identify the following data as
6868e4b17023SJohn Marinouninitialized global data.  If not defined, and
6869e4b17023SJohn Marino@code{ASM_OUTPUT_ALIGNED_BSS} not defined,
6870e4b17023SJohn Marinouninitialized global data will be output in the data section if
6871e4b17023SJohn Marino@option{-fno-common} is passed, otherwise @code{ASM_OUTPUT_COMMON} will be
6872e4b17023SJohn Marinoused.
6873e4b17023SJohn Marino@end defmac
6874e4b17023SJohn Marino
6875e4b17023SJohn Marino@defmac SBSS_SECTION_ASM_OP
6876e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing,
6877e4b17023SJohn Marinocontaining the assembler operation to identify the following data as
6878e4b17023SJohn Marinouninitialized, writable small data.
6879e4b17023SJohn Marino@end defmac
6880e4b17023SJohn Marino
6881e4b17023SJohn Marino@defmac TLS_COMMON_ASM_OP
6882e4b17023SJohn MarinoIf defined, a C expression whose value is a string containing the
6883e4b17023SJohn Marinoassembler operation to identify the following data as thread-local
6884e4b17023SJohn Marinocommon data.  The default is @code{".tls_common"}.
6885e4b17023SJohn Marino@end defmac
6886e4b17023SJohn Marino
6887e4b17023SJohn Marino@defmac TLS_SECTION_ASM_FLAG
6888e4b17023SJohn MarinoIf defined, a C expression whose value is a character constant
6889e4b17023SJohn Marinocontaining the flag used to mark a section as a TLS section.  The
6890e4b17023SJohn Marinodefault is @code{'T'}.
6891e4b17023SJohn Marino@end defmac
6892e4b17023SJohn Marino
6893e4b17023SJohn Marino@defmac INIT_SECTION_ASM_OP
6894e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing,
6895e4b17023SJohn Marinocontaining the assembler operation to identify the following data as
6896e4b17023SJohn Marinoinitialization code.  If not defined, GCC will assume such a section does
6897e4b17023SJohn Marinonot exist.  This section has no corresponding @code{init_section}
6898e4b17023SJohn Marinovariable; it is used entirely in runtime code.
6899e4b17023SJohn Marino@end defmac
6900e4b17023SJohn Marino
6901e4b17023SJohn Marino@defmac FINI_SECTION_ASM_OP
6902e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing,
6903e4b17023SJohn Marinocontaining the assembler operation to identify the following data as
6904e4b17023SJohn Marinofinalization code.  If not defined, GCC will assume such a section does
6905e4b17023SJohn Marinonot exist.  This section has no corresponding @code{fini_section}
6906e4b17023SJohn Marinovariable; it is used entirely in runtime code.
6907e4b17023SJohn Marino@end defmac
6908e4b17023SJohn Marino
6909e4b17023SJohn Marino@defmac INIT_ARRAY_SECTION_ASM_OP
6910e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing,
6911e4b17023SJohn Marinocontaining the assembler operation to identify the following data as
6912e4b17023SJohn Marinopart of the @code{.init_array} (or equivalent) section.  If not
6913e4b17023SJohn Marinodefined, GCC will assume such a section does not exist.  Do not define
6914e4b17023SJohn Marinoboth this macro and @code{INIT_SECTION_ASM_OP}.
6915e4b17023SJohn Marino@end defmac
6916e4b17023SJohn Marino
6917e4b17023SJohn Marino@defmac FINI_ARRAY_SECTION_ASM_OP
6918e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing,
6919e4b17023SJohn Marinocontaining the assembler operation to identify the following data as
6920e4b17023SJohn Marinopart of the @code{.fini_array} (or equivalent) section.  If not
6921e4b17023SJohn Marinodefined, GCC will assume such a section does not exist.  Do not define
6922e4b17023SJohn Marinoboth this macro and @code{FINI_SECTION_ASM_OP}.
6923e4b17023SJohn Marino@end defmac
6924e4b17023SJohn Marino
6925e4b17023SJohn Marino@defmac CRT_CALL_STATIC_FUNCTION (@var{section_op}, @var{function})
6926e4b17023SJohn MarinoIf defined, an ASM statement that switches to a different section
6927e4b17023SJohn Marinovia @var{section_op}, calls @var{function}, and switches back to
6928e4b17023SJohn Marinothe text section.  This is used in @file{crtstuff.c} if
6929e4b17023SJohn Marino@code{INIT_SECTION_ASM_OP} or @code{FINI_SECTION_ASM_OP} to calls
6930e4b17023SJohn Marinoto initialization and finalization functions from the init and fini
6931e4b17023SJohn Marinosections.  By default, this macro uses a simple function call.  Some
6932e4b17023SJohn Marinoports need hand-crafted assembly code to avoid dependencies on
6933e4b17023SJohn Marinoregisters initialized in the function prologue or to ensure that
6934e4b17023SJohn Marinoconstant pools don't end up too far way in the text section.
6935e4b17023SJohn Marino@end defmac
6936e4b17023SJohn Marino
6937e4b17023SJohn Marino@defmac TARGET_LIBGCC_SDATA_SECTION
6938e4b17023SJohn MarinoIf defined, a string which names the section into which small
6939e4b17023SJohn Marinovariables defined in crtstuff and libgcc should go.  This is useful
6940e4b17023SJohn Marinowhen the target has options for optimizing access to small data, and
6941e4b17023SJohn Marinoyou want the crtstuff and libgcc routines to be conservative in what
6942e4b17023SJohn Marinothey expect of your application yet liberal in what your application
6943e4b17023SJohn Marinoexpects.  For example, for targets with a @code{.sdata} section (like
6944e4b17023SJohn MarinoMIPS), you could compile crtstuff with @code{-G 0} so that it doesn't
6945e4b17023SJohn Marinorequire small data support from your application, but use this macro
6946e4b17023SJohn Marinoto put small data into @code{.sdata} so that your application can
6947e4b17023SJohn Marinoaccess these variables whether it uses small data or not.
6948e4b17023SJohn Marino@end defmac
6949e4b17023SJohn Marino
6950e4b17023SJohn Marino@defmac FORCE_CODE_SECTION_ALIGN
6951e4b17023SJohn MarinoIf defined, an ASM statement that aligns a code section to some
6952e4b17023SJohn Marinoarbitrary boundary.  This is used to force all fragments of the
6953e4b17023SJohn Marino@code{.init} and @code{.fini} sections to have to same alignment
6954e4b17023SJohn Marinoand thus prevent the linker from having to add any padding.
6955e4b17023SJohn Marino@end defmac
6956e4b17023SJohn Marino
6957e4b17023SJohn Marino@defmac JUMP_TABLES_IN_TEXT_SECTION
6958e4b17023SJohn MarinoDefine this macro to be an expression with a nonzero value if jump
6959e4b17023SJohn Marinotables (for @code{tablejump} insns) should be output in the text
6960e4b17023SJohn Marinosection, along with the assembler instructions.  Otherwise, the
6961e4b17023SJohn Marinoreadonly data section is used.
6962e4b17023SJohn Marino
6963e4b17023SJohn MarinoThis macro is irrelevant if there is no separate readonly data section.
6964e4b17023SJohn Marino@end defmac
6965e4b17023SJohn Marino
6966e4b17023SJohn Marino@hook TARGET_ASM_INIT_SECTIONS
6967e4b17023SJohn MarinoDefine this hook if you need to do something special to set up the
6968e4b17023SJohn Marino@file{varasm.c} sections, or if your target has some special sections
6969e4b17023SJohn Marinoof its own that you need to create.
6970e4b17023SJohn Marino
6971e4b17023SJohn MarinoGCC calls this hook after processing the command line, but before writing
6972e4b17023SJohn Marinoany assembly code, and before calling any of the section-returning hooks
6973e4b17023SJohn Marinodescribed below.
6974e4b17023SJohn Marino@end deftypefn
6975e4b17023SJohn Marino
6976e4b17023SJohn Marino@hook TARGET_ASM_RELOC_RW_MASK
6977e4b17023SJohn MarinoReturn a mask describing how relocations should be treated when
6978e4b17023SJohn Marinoselecting sections.  Bit 1 should be set if global relocations
6979e4b17023SJohn Marinoshould be placed in a read-write section; bit 0 should be set if
6980e4b17023SJohn Marinolocal relocations should be placed in a read-write section.
6981e4b17023SJohn Marino
6982e4b17023SJohn MarinoThe default version of this function returns 3 when @option{-fpic}
6983e4b17023SJohn Marinois in effect, and 0 otherwise.  The hook is typically redefined
6984e4b17023SJohn Marinowhen the target cannot support (some kinds of) dynamic relocations
6985e4b17023SJohn Marinoin read-only sections even in executables.
6986e4b17023SJohn Marino@end deftypefn
6987e4b17023SJohn Marino
6988e4b17023SJohn Marino@hook TARGET_ASM_SELECT_SECTION
6989e4b17023SJohn MarinoReturn the section into which @var{exp} should be placed.  You can
6990e4b17023SJohn Marinoassume that @var{exp} is either a @code{VAR_DECL} node or a constant of
6991e4b17023SJohn Marinosome sort.  @var{reloc} indicates whether the initial value of @var{exp}
6992e4b17023SJohn Marinorequires link-time relocations.  Bit 0 is set when variable contains
6993e4b17023SJohn Marinolocal relocations only, while bit 1 is set for global relocations.
6994e4b17023SJohn Marino@var{align} is the constant alignment in bits.
6995e4b17023SJohn Marino
6996e4b17023SJohn MarinoThe default version of this function takes care of putting read-only
6997e4b17023SJohn Marinovariables in @code{readonly_data_section}.
6998e4b17023SJohn Marino
6999e4b17023SJohn MarinoSee also @var{USE_SELECT_SECTION_FOR_FUNCTIONS}.
7000e4b17023SJohn Marino@end deftypefn
7001e4b17023SJohn Marino
7002e4b17023SJohn Marino@defmac USE_SELECT_SECTION_FOR_FUNCTIONS
7003e4b17023SJohn MarinoDefine this macro if you wish TARGET_ASM_SELECT_SECTION to be called
7004e4b17023SJohn Marinofor @code{FUNCTION_DECL}s as well as for variables and constants.
7005e4b17023SJohn Marino
7006e4b17023SJohn MarinoIn the case of a @code{FUNCTION_DECL}, @var{reloc} will be zero if the
7007e4b17023SJohn Marinofunction has been determined to be likely to be called, and nonzero if
7008e4b17023SJohn Marinoit is unlikely to be called.
7009e4b17023SJohn Marino@end defmac
7010e4b17023SJohn Marino
7011e4b17023SJohn Marino@hook TARGET_ASM_UNIQUE_SECTION
7012e4b17023SJohn MarinoBuild up a unique section name, expressed as a @code{STRING_CST} node,
7013e4b17023SJohn Marinoand assign it to @samp{DECL_SECTION_NAME (@var{decl})}.
7014e4b17023SJohn MarinoAs with @code{TARGET_ASM_SELECT_SECTION}, @var{reloc} indicates whether
7015e4b17023SJohn Marinothe initial value of @var{exp} requires link-time relocations.
7016e4b17023SJohn Marino
7017e4b17023SJohn MarinoThe default version of this function appends the symbol name to the
7018e4b17023SJohn MarinoELF section name that would normally be used for the symbol.  For
7019e4b17023SJohn Marinoexample, the function @code{foo} would be placed in @code{.text.foo}.
7020e4b17023SJohn MarinoWhatever the actual target object format, this is often good enough.
7021e4b17023SJohn Marino@end deftypefn
7022e4b17023SJohn Marino
7023e4b17023SJohn Marino@hook TARGET_ASM_FUNCTION_RODATA_SECTION
7024e4b17023SJohn MarinoReturn the readonly data section associated with
7025e4b17023SJohn Marino@samp{DECL_SECTION_NAME (@var{decl})}.
7026e4b17023SJohn MarinoThe default version of this function selects @code{.gnu.linkonce.r.name} if
7027e4b17023SJohn Marinothe function's section is @code{.gnu.linkonce.t.name}, @code{.rodata.name}
7028e4b17023SJohn Marinoif function is in @code{.text.name}, and the normal readonly-data section
7029e4b17023SJohn Marinootherwise.
7030e4b17023SJohn Marino@end deftypefn
7031e4b17023SJohn Marino
7032e4b17023SJohn Marino@hook TARGET_ASM_MERGEABLE_RODATA_PREFIX
7033e4b17023SJohn Marino
7034e4b17023SJohn Marino@hook TARGET_ASM_TM_CLONE_TABLE_SECTION
7035e4b17023SJohn Marino
7036e4b17023SJohn Marino@hook TARGET_ASM_SELECT_RTX_SECTION
7037e4b17023SJohn MarinoReturn the section into which a constant @var{x}, of mode @var{mode},
7038e4b17023SJohn Marinoshould be placed.  You can assume that @var{x} is some kind of
7039e4b17023SJohn Marinoconstant in RTL@.  The argument @var{mode} is redundant except in the
7040e4b17023SJohn Marinocase of a @code{const_int} rtx.  @var{align} is the constant alignment
7041e4b17023SJohn Marinoin bits.
7042e4b17023SJohn Marino
7043e4b17023SJohn MarinoThe default version of this function takes care of putting symbolic
7044e4b17023SJohn Marinoconstants in @code{flag_pic} mode in @code{data_section} and everything
7045e4b17023SJohn Marinoelse in @code{readonly_data_section}.
7046e4b17023SJohn Marino@end deftypefn
7047e4b17023SJohn Marino
7048e4b17023SJohn Marino@hook TARGET_MANGLE_DECL_ASSEMBLER_NAME
7049e4b17023SJohn MarinoDefine this hook if you need to postprocess the assembler name generated
7050e4b17023SJohn Marinoby target-independent code.  The @var{id} provided to this hook will be
7051e4b17023SJohn Marinothe computed name (e.g., the macro @code{DECL_NAME} of the @var{decl} in C,
7052e4b17023SJohn Marinoor the mangled name of the @var{decl} in C++).  The return value of the
7053e4b17023SJohn Marinohook is an @code{IDENTIFIER_NODE} for the appropriate mangled name on
7054e4b17023SJohn Marinoyour target system.  The default implementation of this hook just
7055e4b17023SJohn Marinoreturns the @var{id} provided.
7056e4b17023SJohn Marino@end deftypefn
7057e4b17023SJohn Marino
7058e4b17023SJohn Marino@hook TARGET_ENCODE_SECTION_INFO
7059e4b17023SJohn MarinoDefine this hook if references to a symbol or a constant must be
7060e4b17023SJohn Marinotreated differently depending on something about the variable or
7061e4b17023SJohn Marinofunction named by the symbol (such as what section it is in).
7062e4b17023SJohn Marino
7063e4b17023SJohn MarinoThe hook is executed immediately after rtl has been created for
7064e4b17023SJohn Marino@var{decl}, which may be a variable or function declaration or
7065e4b17023SJohn Marinoan entry in the constant pool.  In either case, @var{rtl} is the
7066e4b17023SJohn Marinortl in question.  Do @emph{not} use @code{DECL_RTL (@var{decl})}
7067e4b17023SJohn Marinoin this hook; that field may not have been initialized yet.
7068e4b17023SJohn Marino
7069e4b17023SJohn MarinoIn the case of a constant, it is safe to assume that the rtl is
7070e4b17023SJohn Marinoa @code{mem} whose address is a @code{symbol_ref}.  Most decls
7071e4b17023SJohn Marinowill also have this form, but that is not guaranteed.  Global
7072e4b17023SJohn Marinoregister variables, for instance, will have a @code{reg} for their
7073e4b17023SJohn Marinortl.  (Normally the right thing to do with such unusual rtl is
7074e4b17023SJohn Marinoleave it alone.)
7075e4b17023SJohn Marino
7076e4b17023SJohn MarinoThe @var{new_decl_p} argument will be true if this is the first time
7077e4b17023SJohn Marinothat @code{TARGET_ENCODE_SECTION_INFO} has been invoked on this decl.  It will
7078e4b17023SJohn Marinobe false for subsequent invocations, which will happen for duplicate
7079e4b17023SJohn Marinodeclarations.  Whether or not anything must be done for the duplicate
7080e4b17023SJohn Marinodeclaration depends on whether the hook examines @code{DECL_ATTRIBUTES}.
7081e4b17023SJohn Marino@var{new_decl_p} is always true when the hook is called for a constant.
7082e4b17023SJohn Marino
7083e4b17023SJohn Marino@cindex @code{SYMBOL_REF_FLAG}, in @code{TARGET_ENCODE_SECTION_INFO}
7084e4b17023SJohn MarinoThe usual thing for this hook to do is to record flags in the
7085e4b17023SJohn Marino@code{symbol_ref}, using @code{SYMBOL_REF_FLAG} or @code{SYMBOL_REF_FLAGS}.
7086e4b17023SJohn MarinoHistorically, the name string was modified if it was necessary to
7087e4b17023SJohn Marinoencode more than one bit of information, but this practice is now
7088e4b17023SJohn Marinodiscouraged; use @code{SYMBOL_REF_FLAGS}.
7089e4b17023SJohn Marino
7090e4b17023SJohn MarinoThe default definition of this hook, @code{default_encode_section_info}
7091e4b17023SJohn Marinoin @file{varasm.c}, sets a number of commonly-useful bits in
7092e4b17023SJohn Marino@code{SYMBOL_REF_FLAGS}.  Check whether the default does what you need
7093e4b17023SJohn Marinobefore overriding it.
7094e4b17023SJohn Marino@end deftypefn
7095e4b17023SJohn Marino
7096e4b17023SJohn Marino@hook TARGET_STRIP_NAME_ENCODING
7097e4b17023SJohn MarinoDecode @var{name} and return the real name part, sans
7098e4b17023SJohn Marinothe characters that @code{TARGET_ENCODE_SECTION_INFO}
7099e4b17023SJohn Marinomay have added.
7100e4b17023SJohn Marino@end deftypefn
7101e4b17023SJohn Marino
7102e4b17023SJohn Marino@hook TARGET_IN_SMALL_DATA_P
7103e4b17023SJohn MarinoReturns true if @var{exp} should be placed into a ``small data'' section.
7104e4b17023SJohn MarinoThe default version of this hook always returns false.
7105e4b17023SJohn Marino@end deftypefn
7106e4b17023SJohn Marino
7107e4b17023SJohn Marino@hook TARGET_HAVE_SRODATA_SECTION
7108e4b17023SJohn MarinoContains the value true if the target places read-only
7109e4b17023SJohn Marino``small data'' into a separate section.  The default value is false.
7110e4b17023SJohn Marino@end deftypevr
7111e4b17023SJohn Marino
7112e4b17023SJohn Marino@hook TARGET_PROFILE_BEFORE_PROLOGUE
7113e4b17023SJohn Marino
7114e4b17023SJohn Marino@hook TARGET_BINDS_LOCAL_P
7115e4b17023SJohn MarinoReturns true if @var{exp} names an object for which name resolution
7116e4b17023SJohn Marinorules must resolve to the current ``module'' (dynamic shared library
7117e4b17023SJohn Marinoor executable image).
7118e4b17023SJohn Marino
7119e4b17023SJohn MarinoThe default version of this hook implements the name resolution rules
7120e4b17023SJohn Marinofor ELF, which has a looser model of global name binding than other
7121e4b17023SJohn Marinocurrently supported object file formats.
7122e4b17023SJohn Marino@end deftypefn
7123e4b17023SJohn Marino
7124e4b17023SJohn Marino@hook TARGET_HAVE_TLS
7125e4b17023SJohn MarinoContains the value true if the target supports thread-local storage.
7126e4b17023SJohn MarinoThe default value is false.
7127e4b17023SJohn Marino@end deftypevr
7128e4b17023SJohn Marino
7129e4b17023SJohn Marino
7130e4b17023SJohn Marino@node PIC
7131e4b17023SJohn Marino@section Position Independent Code
7132e4b17023SJohn Marino@cindex position independent code
7133e4b17023SJohn Marino@cindex PIC
7134e4b17023SJohn Marino
7135e4b17023SJohn MarinoThis section describes macros that help implement generation of position
7136e4b17023SJohn Marinoindependent code.  Simply defining these macros is not enough to
7137e4b17023SJohn Marinogenerate valid PIC; you must also add support to the hook
7138e4b17023SJohn Marino@code{TARGET_LEGITIMATE_ADDRESS_P} and to the macro
7139e4b17023SJohn Marino@code{PRINT_OPERAND_ADDRESS}, as well as @code{LEGITIMIZE_ADDRESS}.  You
7140e4b17023SJohn Marinomust modify the definition of @samp{movsi} to do something appropriate
7141e4b17023SJohn Marinowhen the source operand contains a symbolic address.  You may also
7142e4b17023SJohn Marinoneed to alter the handling of switch statements so that they use
7143e4b17023SJohn Marinorelative addresses.
7144e4b17023SJohn Marino@c i rearranged the order of the macros above to try to force one of
7145e4b17023SJohn Marino@c them to the next line, to eliminate an overfull hbox. --mew 10feb93
7146e4b17023SJohn Marino
7147e4b17023SJohn Marino@defmac PIC_OFFSET_TABLE_REGNUM
7148e4b17023SJohn MarinoThe register number of the register used to address a table of static
7149e4b17023SJohn Marinodata addresses in memory.  In some cases this register is defined by a
7150e4b17023SJohn Marinoprocessor's ``application binary interface'' (ABI)@.  When this macro
7151e4b17023SJohn Marinois defined, RTL is generated for this register once, as with the stack
7152e4b17023SJohn Marinopointer and frame pointer registers.  If this macro is not defined, it
7153e4b17023SJohn Marinois up to the machine-dependent files to allocate such a register (if
7154e4b17023SJohn Marinonecessary).  Note that this register must be fixed when in use (e.g.@:
7155e4b17023SJohn Marinowhen @code{flag_pic} is true).
7156e4b17023SJohn Marino@end defmac
7157e4b17023SJohn Marino
7158e4b17023SJohn Marino@defmac PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
7159e4b17023SJohn MarinoA C expression that is nonzero if the register defined by
7160e4b17023SJohn Marino@code{PIC_OFFSET_TABLE_REGNUM} is clobbered by calls.  If not defined,
7161e4b17023SJohn Marinothe default is zero.  Do not define
7162e4b17023SJohn Marinothis macro if @code{PIC_OFFSET_TABLE_REGNUM} is not defined.
7163e4b17023SJohn Marino@end defmac
7164e4b17023SJohn Marino
7165e4b17023SJohn Marino@defmac LEGITIMATE_PIC_OPERAND_P (@var{x})
7166e4b17023SJohn MarinoA C expression that is nonzero if @var{x} is a legitimate immediate
7167e4b17023SJohn Marinooperand on the target machine when generating position independent code.
7168e4b17023SJohn MarinoYou can assume that @var{x} satisfies @code{CONSTANT_P}, so you need not
7169e4b17023SJohn Marinocheck this.  You can also assume @var{flag_pic} is true, so you need not
7170e4b17023SJohn Marinocheck it either.  You need not define this macro if all constants
7171e4b17023SJohn Marino(including @code{SYMBOL_REF}) can be immediate operands when generating
7172e4b17023SJohn Marinoposition independent code.
7173e4b17023SJohn Marino@end defmac
7174e4b17023SJohn Marino
7175e4b17023SJohn Marino@node Assembler Format
7176e4b17023SJohn Marino@section Defining the Output Assembler Language
7177e4b17023SJohn Marino
7178e4b17023SJohn MarinoThis section describes macros whose principal purpose is to describe how
7179e4b17023SJohn Marinoto write instructions in assembler language---rather than what the
7180e4b17023SJohn Marinoinstructions do.
7181e4b17023SJohn Marino
7182e4b17023SJohn Marino@menu
7183e4b17023SJohn Marino* File Framework::       Structural information for the assembler file.
7184e4b17023SJohn Marino* Data Output::          Output of constants (numbers, strings, addresses).
7185e4b17023SJohn Marino* Uninitialized Data::   Output of uninitialized variables.
7186e4b17023SJohn Marino* Label Output::         Output and generation of labels.
7187e4b17023SJohn Marino* Initialization::       General principles of initialization
7188e4b17023SJohn Marino                         and termination routines.
7189e4b17023SJohn Marino* Macros for Initialization::
7190e4b17023SJohn Marino                         Specific macros that control the handling of
7191e4b17023SJohn Marino                         initialization and termination routines.
7192e4b17023SJohn Marino* Instruction Output::   Output of actual instructions.
7193e4b17023SJohn Marino* Dispatch Tables::      Output of jump tables.
7194e4b17023SJohn Marino* Exception Region Output:: Output of exception region code.
7195e4b17023SJohn Marino* Alignment Output::     Pseudo ops for alignment and skipping data.
7196e4b17023SJohn Marino@end menu
7197e4b17023SJohn Marino
7198e4b17023SJohn Marino@node File Framework
7199e4b17023SJohn Marino@subsection The Overall Framework of an Assembler File
7200e4b17023SJohn Marino@cindex assembler format
7201e4b17023SJohn Marino@cindex output of assembler code
7202e4b17023SJohn Marino
7203e4b17023SJohn Marino@c prevent bad page break with this line
7204e4b17023SJohn MarinoThis describes the overall framework of an assembly file.
7205e4b17023SJohn Marino
7206e4b17023SJohn Marino@findex default_file_start
7207e4b17023SJohn Marino@hook TARGET_ASM_FILE_START
7208e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which the assembler expects to
7209e4b17023SJohn Marinofind at the beginning of a file.  The default behavior is controlled
7210e4b17023SJohn Marinoby two flags, documented below.  Unless your target's assembler is
7211e4b17023SJohn Marinoquite unusual, if you override the default, you should call
7212e4b17023SJohn Marino@code{default_file_start} at some point in your target hook.  This
7213e4b17023SJohn Marinolets other target files rely on these variables.
7214e4b17023SJohn Marino@end deftypefn
7215e4b17023SJohn Marino
7216e4b17023SJohn Marino@hook TARGET_ASM_FILE_START_APP_OFF
7217e4b17023SJohn MarinoIf this flag is true, the text of the macro @code{ASM_APP_OFF} will be
7218e4b17023SJohn Marinoprinted as the very first line in the assembly file, unless
7219e4b17023SJohn Marino@option{-fverbose-asm} is in effect.  (If that macro has been defined
7220e4b17023SJohn Marinoto the empty string, this variable has no effect.)  With the normal
7221e4b17023SJohn Marinodefinition of @code{ASM_APP_OFF}, the effect is to notify the GNU
7222e4b17023SJohn Marinoassembler that it need not bother stripping comments or extra
7223e4b17023SJohn Marinowhitespace from its input.  This allows it to work a bit faster.
7224e4b17023SJohn Marino
7225e4b17023SJohn MarinoThe default is false.  You should not set it to true unless you have
7226e4b17023SJohn Marinoverified that your port does not generate any extra whitespace or
7227e4b17023SJohn Marinocomments that will cause GAS to issue errors in NO_APP mode.
7228e4b17023SJohn Marino@end deftypevr
7229e4b17023SJohn Marino
7230e4b17023SJohn Marino@hook TARGET_ASM_FILE_START_FILE_DIRECTIVE
7231e4b17023SJohn MarinoIf this flag is true, @code{output_file_directive} will be called
7232e4b17023SJohn Marinofor the primary source file, immediately after printing
7233e4b17023SJohn Marino@code{ASM_APP_OFF} (if that is enabled).  Most ELF assemblers expect
7234e4b17023SJohn Marinothis to be done.  The default is false.
7235e4b17023SJohn Marino@end deftypevr
7236e4b17023SJohn Marino
7237e4b17023SJohn Marino@hook TARGET_ASM_FILE_END
7238e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which the assembler expects
7239e4b17023SJohn Marinoto find at the end of a file.  The default is to output nothing.
7240e4b17023SJohn Marino@end deftypefn
7241e4b17023SJohn Marino
7242e4b17023SJohn Marino@deftypefun void file_end_indicate_exec_stack ()
7243e4b17023SJohn MarinoSome systems use a common convention, the @samp{.note.GNU-stack}
7244e4b17023SJohn Marinospecial section, to indicate whether or not an object file relies on
7245e4b17023SJohn Marinothe stack being executable.  If your system uses this convention, you
7246e4b17023SJohn Marinoshould define @code{TARGET_ASM_FILE_END} to this function.  If you
7247e4b17023SJohn Marinoneed to do other things in that hook, have your hook function call
7248e4b17023SJohn Marinothis function.
7249e4b17023SJohn Marino@end deftypefun
7250e4b17023SJohn Marino
7251e4b17023SJohn Marino@hook TARGET_ASM_LTO_START
7252e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which the assembler expects
7253e4b17023SJohn Marinoto find at the start of an LTO section.  The default is to output
7254e4b17023SJohn Marinonothing.
7255e4b17023SJohn Marino@end deftypefn
7256e4b17023SJohn Marino
7257e4b17023SJohn Marino@hook TARGET_ASM_LTO_END
7258e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which the assembler expects
7259e4b17023SJohn Marinoto find at the end of an LTO section.  The default is to output
7260e4b17023SJohn Marinonothing.
7261e4b17023SJohn Marino@end deftypefn
7262e4b17023SJohn Marino
7263e4b17023SJohn Marino@hook TARGET_ASM_CODE_END
7264e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which is needed before emitting
7265e4b17023SJohn Marinounwind info and debug info at the end of a file.  Some targets emit
7266e4b17023SJohn Marinohere PIC setup thunks that cannot be emitted at the end of file,
7267e4b17023SJohn Marinobecause they couldn't have unwind info then.  The default is to output
7268e4b17023SJohn Marinonothing.
7269e4b17023SJohn Marino@end deftypefn
7270e4b17023SJohn Marino
7271e4b17023SJohn Marino@defmac ASM_COMMENT_START
7272e4b17023SJohn MarinoA C string constant describing how to begin a comment in the target
7273e4b17023SJohn Marinoassembler language.  The compiler assumes that the comment will end at
7274e4b17023SJohn Marinothe end of the line.
7275e4b17023SJohn Marino@end defmac
7276e4b17023SJohn Marino
7277e4b17023SJohn Marino@defmac ASM_APP_ON
7278e4b17023SJohn MarinoA C string constant for text to be output before each @code{asm}
7279e4b17023SJohn Marinostatement or group of consecutive ones.  Normally this is
7280e4b17023SJohn Marino@code{"#APP"}, which is a comment that has no effect on most
7281e4b17023SJohn Marinoassemblers but tells the GNU assembler that it must check the lines
7282e4b17023SJohn Marinothat follow for all valid assembler constructs.
7283e4b17023SJohn Marino@end defmac
7284e4b17023SJohn Marino
7285e4b17023SJohn Marino@defmac ASM_APP_OFF
7286e4b17023SJohn MarinoA C string constant for text to be output after each @code{asm}
7287e4b17023SJohn Marinostatement or group of consecutive ones.  Normally this is
7288e4b17023SJohn Marino@code{"#NO_APP"}, which tells the GNU assembler to resume making the
7289e4b17023SJohn Marinotime-saving assumptions that are valid for ordinary compiler output.
7290e4b17023SJohn Marino@end defmac
7291e4b17023SJohn Marino
7292e4b17023SJohn Marino@defmac ASM_OUTPUT_SOURCE_FILENAME (@var{stream}, @var{name})
7293e4b17023SJohn MarinoA C statement to output COFF information or DWARF debugging information
7294e4b17023SJohn Marinowhich indicates that filename @var{name} is the current source file to
7295e4b17023SJohn Marinothe stdio stream @var{stream}.
7296e4b17023SJohn Marino
7297e4b17023SJohn MarinoThis macro need not be defined if the standard form of output
7298e4b17023SJohn Marinofor the file format in use is appropriate.
7299e4b17023SJohn Marino@end defmac
7300e4b17023SJohn Marino
7301e4b17023SJohn Marino@hook TARGET_ASM_OUTPUT_SOURCE_FILENAME
7302e4b17023SJohn Marino
7303e4b17023SJohn Marino@defmac OUTPUT_QUOTED_STRING (@var{stream}, @var{string})
7304e4b17023SJohn MarinoA C statement to output the string @var{string} to the stdio stream
7305e4b17023SJohn Marino@var{stream}.  If you do not call the function @code{output_quoted_string}
7306e4b17023SJohn Marinoin your config files, GCC will only call it to output filenames to
7307e4b17023SJohn Marinothe assembler source.  So you can use it to canonicalize the format
7308e4b17023SJohn Marinoof the filename using this macro.
7309e4b17023SJohn Marino@end defmac
7310e4b17023SJohn Marino
7311e4b17023SJohn Marino@defmac ASM_OUTPUT_IDENT (@var{stream}, @var{string})
7312e4b17023SJohn MarinoA C statement to output something to the assembler file to handle a
7313e4b17023SJohn Marino@samp{#ident} directive containing the text @var{string}.  If this
7314e4b17023SJohn Marinomacro is not defined, nothing is output for a @samp{#ident} directive.
7315e4b17023SJohn Marino@end defmac
7316e4b17023SJohn Marino
7317e4b17023SJohn Marino@hook TARGET_ASM_NAMED_SECTION
7318e4b17023SJohn MarinoOutput assembly directives to switch to section @var{name}.  The section
7319e4b17023SJohn Marinoshould have attributes as specified by @var{flags}, which is a bit mask
7320e4b17023SJohn Marinoof the @code{SECTION_*} flags defined in @file{output.h}.  If @var{decl}
7321e4b17023SJohn Marinois non-NULL, it is the @code{VAR_DECL} or @code{FUNCTION_DECL} with which
7322e4b17023SJohn Marinothis section is associated.
7323e4b17023SJohn Marino@end deftypefn
7324e4b17023SJohn Marino
7325e4b17023SJohn Marino@hook TARGET_ASM_FUNCTION_SECTION
7326e4b17023SJohn MarinoReturn preferred text (sub)section for function @var{decl}.
7327e4b17023SJohn MarinoMain purpose of this function is to separate cold, normal and hot
7328e4b17023SJohn Marinofunctions. @var{startup} is true when function is known to be used only
7329e4b17023SJohn Marinoat startup (from static constructors or it is @code{main()}).
7330e4b17023SJohn Marino@var{exit} is true when function is known to be used only at exit
7331e4b17023SJohn Marino(from static destructors).
7332e4b17023SJohn MarinoReturn NULL if function should go to default text section.
7333e4b17023SJohn Marino@end deftypefn
7334e4b17023SJohn Marino
7335e4b17023SJohn Marino@hook TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS
7336e4b17023SJohn Marino
7337e4b17023SJohn Marino@hook TARGET_HAVE_NAMED_SECTIONS
7338e4b17023SJohn MarinoThis flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}.
7339e4b17023SJohn MarinoIt must not be modified by command-line option processing.
7340e4b17023SJohn Marino@end deftypevr
7341e4b17023SJohn Marino
7342e4b17023SJohn Marino@anchor{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS}
7343e4b17023SJohn Marino@hook TARGET_HAVE_SWITCHABLE_BSS_SECTIONS
7344e4b17023SJohn MarinoThis flag is true if we can create zeroed data by switching to a BSS
7345e4b17023SJohn Marinosection and then using @code{ASM_OUTPUT_SKIP} to allocate the space.
7346e4b17023SJohn MarinoThis is true on most ELF targets.
7347e4b17023SJohn Marino@end deftypevr
7348e4b17023SJohn Marino
7349e4b17023SJohn Marino@hook TARGET_SECTION_TYPE_FLAGS
7350e4b17023SJohn MarinoChoose a set of section attributes for use by @code{TARGET_ASM_NAMED_SECTION}
7351e4b17023SJohn Marinobased on a variable or function decl, a section name, and whether or not the
7352e4b17023SJohn Marinodeclaration's initializer may contain runtime relocations.  @var{decl} may be
7353e4b17023SJohn Marinonull, in which case read-write data should be assumed.
7354e4b17023SJohn Marino
7355e4b17023SJohn MarinoThe default version of this function handles choosing code vs data,
7356e4b17023SJohn Marinoread-only vs read-write data, and @code{flag_pic}.  You should only
7357e4b17023SJohn Marinoneed to override this if your target has special flags that might be
7358e4b17023SJohn Marinoset via @code{__attribute__}.
7359e4b17023SJohn Marino@end deftypefn
7360e4b17023SJohn Marino
7361e4b17023SJohn Marino@hook TARGET_ASM_RECORD_GCC_SWITCHES
7362e4b17023SJohn MarinoProvides the target with the ability to record the gcc command line
7363e4b17023SJohn Marinoswitches that have been passed to the compiler, and options that are
7364e4b17023SJohn Marinoenabled.  The @var{type} argument specifies what is being recorded.
7365e4b17023SJohn MarinoIt can take the following values:
7366e4b17023SJohn Marino
7367e4b17023SJohn Marino@table @gcctabopt
7368e4b17023SJohn Marino@item SWITCH_TYPE_PASSED
7369e4b17023SJohn Marino@var{text} is a command line switch that has been set by the user.
7370e4b17023SJohn Marino
7371e4b17023SJohn Marino@item SWITCH_TYPE_ENABLED
7372e4b17023SJohn Marino@var{text} is an option which has been enabled.  This might be as a
7373e4b17023SJohn Marinodirect result of a command line switch, or because it is enabled by
7374e4b17023SJohn Marinodefault or because it has been enabled as a side effect of a different
7375e4b17023SJohn Marinocommand line switch.  For example, the @option{-O2} switch enables
7376e4b17023SJohn Marinovarious different individual optimization passes.
7377e4b17023SJohn Marino
7378e4b17023SJohn Marino@item SWITCH_TYPE_DESCRIPTIVE
7379e4b17023SJohn Marino@var{text} is either NULL or some descriptive text which should be
7380e4b17023SJohn Marinoignored.  If @var{text} is NULL then it is being used to warn the
7381e4b17023SJohn Marinotarget hook that either recording is starting or ending.  The first
7382e4b17023SJohn Marinotime @var{type} is SWITCH_TYPE_DESCRIPTIVE and @var{text} is NULL, the
7383e4b17023SJohn Marinowarning is for start up and the second time the warning is for
7384e4b17023SJohn Marinowind down.  This feature is to allow the target hook to make any
7385e4b17023SJohn Marinonecessary preparations before it starts to record switches and to
7386e4b17023SJohn Marinoperform any necessary tidying up after it has finished recording
7387e4b17023SJohn Marinoswitches.
7388e4b17023SJohn Marino
7389e4b17023SJohn Marino@item SWITCH_TYPE_LINE_START
7390e4b17023SJohn MarinoThis option can be ignored by this target hook.
7391e4b17023SJohn Marino
7392e4b17023SJohn Marino@item  SWITCH_TYPE_LINE_END
7393e4b17023SJohn MarinoThis option can be ignored by this target hook.
7394e4b17023SJohn Marino@end table
7395e4b17023SJohn Marino
7396e4b17023SJohn MarinoThe hook's return value must be zero.  Other return values may be
7397e4b17023SJohn Marinosupported in the future.
7398e4b17023SJohn Marino
7399e4b17023SJohn MarinoBy default this hook is set to NULL, but an example implementation is
7400e4b17023SJohn Marinoprovided for ELF based targets.  Called @var{elf_record_gcc_switches},
7401e4b17023SJohn Marinoit records the switches as ASCII text inside a new, string mergeable
7402e4b17023SJohn Marinosection in the assembler output file.  The name of the new section is
7403e4b17023SJohn Marinoprovided by the @code{TARGET_ASM_RECORD_GCC_SWITCHES_SECTION} target
7404e4b17023SJohn Marinohook.
7405e4b17023SJohn Marino@end deftypefn
7406e4b17023SJohn Marino
7407e4b17023SJohn Marino@hook TARGET_ASM_RECORD_GCC_SWITCHES_SECTION
7408e4b17023SJohn MarinoThis is the name of the section that will be created by the example
7409e4b17023SJohn MarinoELF implementation of the @code{TARGET_ASM_RECORD_GCC_SWITCHES} target
7410e4b17023SJohn Marinohook.
7411e4b17023SJohn Marino@end deftypevr
7412e4b17023SJohn Marino
7413e4b17023SJohn Marino@need 2000
7414e4b17023SJohn Marino@node Data Output
7415e4b17023SJohn Marino@subsection Output of Data
7416e4b17023SJohn Marino
7417e4b17023SJohn Marino
7418e4b17023SJohn Marino@hook TARGET_ASM_BYTE_OP
7419e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_HI_OP
7420e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_SI_OP
7421e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_DI_OP
7422e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_TI_OP
7423e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_HI_OP
7424e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_SI_OP
7425e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_DI_OP
7426e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_TI_OP
7427e4b17023SJohn MarinoThese hooks specify assembly directives for creating certain kinds
7428e4b17023SJohn Marinoof integer object.  The @code{TARGET_ASM_BYTE_OP} directive creates a
7429e4b17023SJohn Marinobyte-sized object, the @code{TARGET_ASM_ALIGNED_HI_OP} one creates an
7430e4b17023SJohn Marinoaligned two-byte object, and so on.  Any of the hooks may be
7431e4b17023SJohn Marino@code{NULL}, indicating that no suitable directive is available.
7432e4b17023SJohn Marino
7433e4b17023SJohn MarinoThe compiler will print these strings at the start of a new line,
7434e4b17023SJohn Marinofollowed immediately by the object's initial value.  In most cases,
7435e4b17023SJohn Marinothe string should contain a tab, a pseudo-op, and then another tab.
7436e4b17023SJohn Marino@end deftypevr
7437e4b17023SJohn Marino
7438e4b17023SJohn Marino@hook TARGET_ASM_INTEGER
7439e4b17023SJohn MarinoThe @code{assemble_integer} function uses this hook to output an
7440e4b17023SJohn Marinointeger object.  @var{x} is the object's value, @var{size} is its size
7441e4b17023SJohn Marinoin bytes and @var{aligned_p} indicates whether it is aligned.  The
7442e4b17023SJohn Marinofunction should return @code{true} if it was able to output the
7443e4b17023SJohn Marinoobject.  If it returns false, @code{assemble_integer} will try to
7444e4b17023SJohn Marinosplit the object into smaller parts.
7445e4b17023SJohn Marino
7446e4b17023SJohn MarinoThe default implementation of this hook will use the
7447e4b17023SJohn Marino@code{TARGET_ASM_BYTE_OP} family of strings, returning @code{false}
7448e4b17023SJohn Marinowhen the relevant string is @code{NULL}.
7449e4b17023SJohn Marino@end deftypefn
7450e4b17023SJohn Marino
7451e4b17023SJohn Marino@hook TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
7452e4b17023SJohn MarinoA target hook to recognize @var{rtx} patterns that @code{output_addr_const}
7453e4b17023SJohn Marinocan't deal with, and output assembly code to @var{file} corresponding to
7454e4b17023SJohn Marinothe pattern @var{x}.  This may be used to allow machine-dependent
7455e4b17023SJohn Marino@code{UNSPEC}s to appear within constants.
7456e4b17023SJohn Marino
7457e4b17023SJohn MarinoIf target hook fails to recognize a pattern, it must return @code{false},
7458e4b17023SJohn Marinoso that a standard error message is printed.  If it prints an error message
7459e4b17023SJohn Marinoitself, by calling, for example, @code{output_operand_lossage}, it may just
7460e4b17023SJohn Marinoreturn @code{true}.
7461e4b17023SJohn Marino@end deftypefn
7462e4b17023SJohn Marino
7463e4b17023SJohn Marino@defmac ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len})
7464e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler
7465e4b17023SJohn Marinoinstruction to assemble a string constant containing the @var{len}
7466e4b17023SJohn Marinobytes at @var{ptr}.  @var{ptr} will be a C expression of type
7467e4b17023SJohn Marino@code{char *} and @var{len} a C expression of type @code{int}.
7468e4b17023SJohn Marino
7469e4b17023SJohn MarinoIf the assembler has a @code{.ascii} pseudo-op as found in the
7470e4b17023SJohn MarinoBerkeley Unix assembler, do not define the macro
7471e4b17023SJohn Marino@code{ASM_OUTPUT_ASCII}.
7472e4b17023SJohn Marino@end defmac
7473e4b17023SJohn Marino
7474e4b17023SJohn Marino@defmac ASM_OUTPUT_FDESC (@var{stream}, @var{decl}, @var{n})
7475e4b17023SJohn MarinoA C statement to output word @var{n} of a function descriptor for
7476e4b17023SJohn Marino@var{decl}.  This must be defined if @code{TARGET_VTABLE_USES_DESCRIPTORS}
7477e4b17023SJohn Marinois defined, and is otherwise unused.
7478e4b17023SJohn Marino@end defmac
7479e4b17023SJohn Marino
7480e4b17023SJohn Marino@defmac CONSTANT_POOL_BEFORE_FUNCTION
7481e4b17023SJohn MarinoYou may define this macro as a C expression.  You should define the
7482e4b17023SJohn Marinoexpression to have a nonzero value if GCC should output the constant
7483e4b17023SJohn Marinopool for a function before the code for the function, or a zero value if
7484e4b17023SJohn MarinoGCC should output the constant pool after the function.  If you do
7485e4b17023SJohn Marinonot define this macro, the usual case, GCC will output the constant
7486e4b17023SJohn Marinopool before the function.
7487e4b17023SJohn Marino@end defmac
7488e4b17023SJohn Marino
7489e4b17023SJohn Marino@defmac ASM_OUTPUT_POOL_PROLOGUE (@var{file}, @var{funname}, @var{fundecl}, @var{size})
7490e4b17023SJohn MarinoA C statement to output assembler commands to define the start of the
7491e4b17023SJohn Marinoconstant pool for a function.  @var{funname} is a string giving
7492e4b17023SJohn Marinothe name of the function.  Should the return type of the function
7493e4b17023SJohn Marinobe required, it can be obtained via @var{fundecl}.  @var{size}
7494e4b17023SJohn Marinois the size, in bytes, of the constant pool that will be written
7495e4b17023SJohn Marinoimmediately after this call.
7496e4b17023SJohn Marino
7497e4b17023SJohn MarinoIf no constant-pool prefix is required, the usual case, this macro need
7498e4b17023SJohn Marinonot be defined.
7499e4b17023SJohn Marino@end defmac
7500e4b17023SJohn Marino
7501e4b17023SJohn Marino@defmac ASM_OUTPUT_SPECIAL_POOL_ENTRY (@var{file}, @var{x}, @var{mode}, @var{align}, @var{labelno}, @var{jumpto})
7502e4b17023SJohn MarinoA C statement (with or without semicolon) to output a constant in the
7503e4b17023SJohn Marinoconstant pool, if it needs special treatment.  (This macro need not do
7504e4b17023SJohn Marinoanything for RTL expressions that can be output normally.)
7505e4b17023SJohn Marino
7506e4b17023SJohn MarinoThe argument @var{file} is the standard I/O stream to output the
7507e4b17023SJohn Marinoassembler code on.  @var{x} is the RTL expression for the constant to
7508e4b17023SJohn Marinooutput, and @var{mode} is the machine mode (in case @var{x} is a
7509e4b17023SJohn Marino@samp{const_int}).  @var{align} is the required alignment for the value
7510e4b17023SJohn Marino@var{x}; you should output an assembler directive to force this much
7511e4b17023SJohn Marinoalignment.
7512e4b17023SJohn Marino
7513e4b17023SJohn MarinoThe argument @var{labelno} is a number to use in an internal label for
7514e4b17023SJohn Marinothe address of this pool entry.  The definition of this macro is
7515e4b17023SJohn Marinoresponsible for outputting the label definition at the proper place.
7516e4b17023SJohn MarinoHere is how to do this:
7517e4b17023SJohn Marino
7518e4b17023SJohn Marino@smallexample
7519e4b17023SJohn Marino@code{(*targetm.asm_out.internal_label)} (@var{file}, "LC", @var{labelno});
7520e4b17023SJohn Marino@end smallexample
7521e4b17023SJohn Marino
7522e4b17023SJohn MarinoWhen you output a pool entry specially, you should end with a
7523e4b17023SJohn Marino@code{goto} to the label @var{jumpto}.  This will prevent the same pool
7524e4b17023SJohn Marinoentry from being output a second time in the usual manner.
7525e4b17023SJohn Marino
7526e4b17023SJohn MarinoYou need not define this macro if it would do nothing.
7527e4b17023SJohn Marino@end defmac
7528e4b17023SJohn Marino
7529e4b17023SJohn Marino@defmac ASM_OUTPUT_POOL_EPILOGUE (@var{file} @var{funname} @var{fundecl} @var{size})
7530e4b17023SJohn MarinoA C statement to output assembler commands to at the end of the constant
7531e4b17023SJohn Marinopool for a function.  @var{funname} is a string giving the name of the
7532e4b17023SJohn Marinofunction.  Should the return type of the function be required, you can
7533e4b17023SJohn Marinoobtain it via @var{fundecl}.  @var{size} is the size, in bytes, of the
7534e4b17023SJohn Marinoconstant pool that GCC wrote immediately before this call.
7535e4b17023SJohn Marino
7536e4b17023SJohn MarinoIf no constant-pool epilogue is required, the usual case, you need not
7537e4b17023SJohn Marinodefine this macro.
7538e4b17023SJohn Marino@end defmac
7539e4b17023SJohn Marino
7540e4b17023SJohn Marino@defmac IS_ASM_LOGICAL_LINE_SEPARATOR (@var{C}, @var{STR})
7541e4b17023SJohn MarinoDefine this macro as a C expression which is nonzero if @var{C} is
7542e4b17023SJohn Marinoused as a logical line separator by the assembler.  @var{STR} points
7543e4b17023SJohn Marinoto the position in the string where @var{C} was found; this can be used if
7544e4b17023SJohn Marinoa line separator uses multiple characters.
7545e4b17023SJohn Marino
7546e4b17023SJohn MarinoIf you do not define this macro, the default is that only
7547e4b17023SJohn Marinothe character @samp{;} is treated as a logical line separator.
7548e4b17023SJohn Marino@end defmac
7549e4b17023SJohn Marino
7550e4b17023SJohn Marino@hook TARGET_ASM_OPEN_PAREN
7551e4b17023SJohn MarinoThese target hooks are C string constants, describing the syntax in the
7552e4b17023SJohn Marinoassembler for grouping arithmetic expressions.  If not overridden, they
7553e4b17023SJohn Marinodefault to normal parentheses, which is correct for most assemblers.
7554e4b17023SJohn Marino@end deftypevr
7555e4b17023SJohn Marino
7556e4b17023SJohn MarinoThese macros are provided by @file{real.h} for writing the definitions
7557e4b17023SJohn Marinoof @code{ASM_OUTPUT_DOUBLE} and the like:
7558e4b17023SJohn Marino
7559e4b17023SJohn Marino@defmac REAL_VALUE_TO_TARGET_SINGLE (@var{x}, @var{l})
7560e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_DOUBLE (@var{x}, @var{l})
7561e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_LONG_DOUBLE (@var{x}, @var{l})
7562e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_DECIMAL32 (@var{x}, @var{l})
7563e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_DECIMAL64 (@var{x}, @var{l})
7564e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_DECIMAL128 (@var{x}, @var{l})
7565e4b17023SJohn MarinoThese translate @var{x}, of type @code{REAL_VALUE_TYPE}, to the
7566e4b17023SJohn Marinotarget's floating point representation, and store its bit pattern in
7567e4b17023SJohn Marinothe variable @var{l}.  For @code{REAL_VALUE_TO_TARGET_SINGLE} and
7568e4b17023SJohn Marino@code{REAL_VALUE_TO_TARGET_DECIMAL32}, this variable should be a
7569e4b17023SJohn Marinosimple @code{long int}.  For the others, it should be an array of
7570e4b17023SJohn Marino@code{long int}.  The number of elements in this array is determined
7571e4b17023SJohn Marinoby the size of the desired target floating point data type: 32 bits of
7572e4b17023SJohn Marinoit go in each @code{long int} array element.  Each array element holds
7573e4b17023SJohn Marino32 bits of the result, even if @code{long int} is wider than 32 bits
7574e4b17023SJohn Marinoon the host machine.
7575e4b17023SJohn Marino
7576e4b17023SJohn MarinoThe array element values are designed so that you can print them out
7577e4b17023SJohn Marinousing @code{fprintf} in the order they should appear in the target
7578e4b17023SJohn Marinomachine's memory.
7579e4b17023SJohn Marino@end defmac
7580e4b17023SJohn Marino
7581e4b17023SJohn Marino@node Uninitialized Data
7582e4b17023SJohn Marino@subsection Output of Uninitialized Variables
7583e4b17023SJohn Marino
7584e4b17023SJohn MarinoEach of the macros in this section is used to do the whole job of
7585e4b17023SJohn Marinooutputting a single uninitialized variable.
7586e4b17023SJohn Marino
7587e4b17023SJohn Marino@defmac ASM_OUTPUT_COMMON (@var{stream}, @var{name}, @var{size}, @var{rounded})
7588e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7589e4b17023SJohn Marino@var{stream} the assembler definition of a common-label named
7590e4b17023SJohn Marino@var{name} whose size is @var{size} bytes.  The variable @var{rounded}
7591e4b17023SJohn Marinois the size rounded up to whatever alignment the caller wants.  It is
7592e4b17023SJohn Marinopossible that @var{size} may be zero, for instance if a struct with no
7593e4b17023SJohn Marinoother member than a zero-length array is defined.  In this case, the
7594e4b17023SJohn Marinobackend must output a symbol definition that allocates at least one
7595e4b17023SJohn Marinobyte, both so that the address of the resulting object does not compare
7596e4b17023SJohn Marinoequal to any other, and because some object formats cannot even express
7597e4b17023SJohn Marinothe concept of a zero-sized common symbol, as that is how they represent
7598e4b17023SJohn Marinoan ordinary undefined external.
7599e4b17023SJohn Marino
7600e4b17023SJohn MarinoUse the expression @code{assemble_name (@var{stream}, @var{name})} to
7601e4b17023SJohn Marinooutput the name itself; before and after that, output the additional
7602e4b17023SJohn Marinoassembler syntax for defining the name, and a newline.
7603e4b17023SJohn Marino
7604e4b17023SJohn MarinoThis macro controls how the assembler definitions of uninitialized
7605e4b17023SJohn Marinocommon global variables are output.
7606e4b17023SJohn Marino@end defmac
7607e4b17023SJohn Marino
7608e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_COMMON (@var{stream}, @var{name}, @var{size}, @var{alignment})
7609e4b17023SJohn MarinoLike @code{ASM_OUTPUT_COMMON} except takes the required alignment as a
7610e4b17023SJohn Marinoseparate, explicit argument.  If you define this macro, it is used in
7611e4b17023SJohn Marinoplace of @code{ASM_OUTPUT_COMMON}, and gives you more flexibility in
7612e4b17023SJohn Marinohandling the required alignment of the variable.  The alignment is specified
7613e4b17023SJohn Marinoas the number of bits.
7614e4b17023SJohn Marino@end defmac
7615e4b17023SJohn Marino
7616e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_DECL_COMMON (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
7617e4b17023SJohn MarinoLike @code{ASM_OUTPUT_ALIGNED_COMMON} except that @var{decl} of the
7618e4b17023SJohn Marinovariable to be output, if there is one, or @code{NULL_TREE} if there
7619e4b17023SJohn Marinois no corresponding variable.  If you define this macro, GCC will use it
7620e4b17023SJohn Marinoin place of both @code{ASM_OUTPUT_COMMON} and
7621e4b17023SJohn Marino@code{ASM_OUTPUT_ALIGNED_COMMON}.  Define this macro when you need to see
7622e4b17023SJohn Marinothe variable's decl in order to chose what to output.
7623e4b17023SJohn Marino@end defmac
7624e4b17023SJohn Marino
7625e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_BSS (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
7626e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7627e4b17023SJohn Marino@var{stream} the assembler definition of uninitialized global @var{decl} named
7628e4b17023SJohn Marino@var{name} whose size is @var{size} bytes.  The variable @var{alignment}
7629e4b17023SJohn Marinois the alignment specified as the number of bits.
7630e4b17023SJohn Marino
7631e4b17023SJohn MarinoTry to use function @code{asm_output_aligned_bss} defined in file
7632e4b17023SJohn Marino@file{varasm.c} when defining this macro.  If unable, use the expression
7633e4b17023SJohn Marino@code{assemble_name (@var{stream}, @var{name})} to output the name itself;
7634e4b17023SJohn Marinobefore and after that, output the additional assembler syntax for defining
7635e4b17023SJohn Marinothe name, and a newline.
7636e4b17023SJohn Marino
7637e4b17023SJohn MarinoThere are two ways of handling global BSS@.  One is to define this macro.
7638e4b17023SJohn MarinoThe other is to have @code{TARGET_ASM_SELECT_SECTION} return a
7639e4b17023SJohn Marinoswitchable BSS section (@pxref{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS}).
7640e4b17023SJohn MarinoYou do not need to do both.
7641e4b17023SJohn Marino
7642e4b17023SJohn MarinoSome languages do not have @code{common} data, and require a
7643e4b17023SJohn Marinonon-common form of global BSS in order to handle uninitialized globals
7644e4b17023SJohn Marinoefficiently.  C++ is one example of this.  However, if the target does
7645e4b17023SJohn Marinonot support global BSS, the front end may choose to make globals
7646e4b17023SJohn Marinocommon in order to save space in the object file.
7647e4b17023SJohn Marino@end defmac
7648e4b17023SJohn Marino
7649e4b17023SJohn Marino@defmac ASM_OUTPUT_LOCAL (@var{stream}, @var{name}, @var{size}, @var{rounded})
7650e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7651e4b17023SJohn Marino@var{stream} the assembler definition of a local-common-label named
7652e4b17023SJohn Marino@var{name} whose size is @var{size} bytes.  The variable @var{rounded}
7653e4b17023SJohn Marinois the size rounded up to whatever alignment the caller wants.
7654e4b17023SJohn Marino
7655e4b17023SJohn MarinoUse the expression @code{assemble_name (@var{stream}, @var{name})} to
7656e4b17023SJohn Marinooutput the name itself; before and after that, output the additional
7657e4b17023SJohn Marinoassembler syntax for defining the name, and a newline.
7658e4b17023SJohn Marino
7659e4b17023SJohn MarinoThis macro controls how the assembler definitions of uninitialized
7660e4b17023SJohn Marinostatic variables are output.
7661e4b17023SJohn Marino@end defmac
7662e4b17023SJohn Marino
7663e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_LOCAL (@var{stream}, @var{name}, @var{size}, @var{alignment})
7664e4b17023SJohn MarinoLike @code{ASM_OUTPUT_LOCAL} except takes the required alignment as a
7665e4b17023SJohn Marinoseparate, explicit argument.  If you define this macro, it is used in
7666e4b17023SJohn Marinoplace of @code{ASM_OUTPUT_LOCAL}, and gives you more flexibility in
7667e4b17023SJohn Marinohandling the required alignment of the variable.  The alignment is specified
7668e4b17023SJohn Marinoas the number of bits.
7669e4b17023SJohn Marino@end defmac
7670e4b17023SJohn Marino
7671e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_DECL_LOCAL (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment})
7672e4b17023SJohn MarinoLike @code{ASM_OUTPUT_ALIGNED_DECL} except that @var{decl} of the
7673e4b17023SJohn Marinovariable to be output, if there is one, or @code{NULL_TREE} if there
7674e4b17023SJohn Marinois no corresponding variable.  If you define this macro, GCC will use it
7675e4b17023SJohn Marinoin place of both @code{ASM_OUTPUT_DECL} and
7676e4b17023SJohn Marino@code{ASM_OUTPUT_ALIGNED_DECL}.  Define this macro when you need to see
7677e4b17023SJohn Marinothe variable's decl in order to chose what to output.
7678e4b17023SJohn Marino@end defmac
7679e4b17023SJohn Marino
7680e4b17023SJohn Marino@node Label Output
7681e4b17023SJohn Marino@subsection Output and Generation of Labels
7682e4b17023SJohn Marino
7683e4b17023SJohn Marino@c prevent bad page break with this line
7684e4b17023SJohn MarinoThis is about outputting labels.
7685e4b17023SJohn Marino
7686e4b17023SJohn Marino@findex assemble_name
7687e4b17023SJohn Marino@defmac ASM_OUTPUT_LABEL (@var{stream}, @var{name})
7688e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7689e4b17023SJohn Marino@var{stream} the assembler definition of a label named @var{name}.
7690e4b17023SJohn MarinoUse the expression @code{assemble_name (@var{stream}, @var{name})} to
7691e4b17023SJohn Marinooutput the name itself; before and after that, output the additional
7692e4b17023SJohn Marinoassembler syntax for defining the name, and a newline.  A default
7693e4b17023SJohn Marinodefinition of this macro is provided which is correct for most systems.
7694e4b17023SJohn Marino@end defmac
7695e4b17023SJohn Marino
7696e4b17023SJohn Marino@defmac ASM_OUTPUT_FUNCTION_LABEL (@var{stream}, @var{name}, @var{decl})
7697e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7698e4b17023SJohn Marino@var{stream} the assembler definition of a label named @var{name} of
7699e4b17023SJohn Marinoa function.
7700e4b17023SJohn MarinoUse the expression @code{assemble_name (@var{stream}, @var{name})} to
7701e4b17023SJohn Marinooutput the name itself; before and after that, output the additional
7702e4b17023SJohn Marinoassembler syntax for defining the name, and a newline.  A default
7703e4b17023SJohn Marinodefinition of this macro is provided which is correct for most systems.
7704e4b17023SJohn Marino
7705e4b17023SJohn MarinoIf this macro is not defined, then the function name is defined in the
7706e4b17023SJohn Marinousual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
7707e4b17023SJohn Marino@end defmac
7708e4b17023SJohn Marino
7709e4b17023SJohn Marino@findex assemble_name_raw
7710e4b17023SJohn Marino@defmac ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{name})
7711e4b17023SJohn MarinoIdentical to @code{ASM_OUTPUT_LABEL}, except that @var{name} is known
7712e4b17023SJohn Marinoto refer to a compiler-generated label.  The default definition uses
7713e4b17023SJohn Marino@code{assemble_name_raw}, which is like @code{assemble_name} except
7714e4b17023SJohn Marinothat it is more efficient.
7715e4b17023SJohn Marino@end defmac
7716e4b17023SJohn Marino
7717e4b17023SJohn Marino@defmac SIZE_ASM_OP
7718e4b17023SJohn MarinoA C string containing the appropriate assembler directive to specify the
7719e4b17023SJohn Marinosize of a symbol, without any arguments.  On systems that use ELF, the
7720e4b17023SJohn Marinodefault (in @file{config/elfos.h}) is @samp{"\t.size\t"}; on other
7721e4b17023SJohn Marinosystems, the default is not to define this macro.
7722e4b17023SJohn Marino
7723e4b17023SJohn MarinoDefine this macro only if it is correct to use the default definitions
7724e4b17023SJohn Marinoof @code{ASM_OUTPUT_SIZE_DIRECTIVE} and @code{ASM_OUTPUT_MEASURED_SIZE}
7725e4b17023SJohn Marinofor your system.  If you need your own custom definitions of those
7726e4b17023SJohn Marinomacros, or if you do not need explicit symbol sizes at all, do not
7727e4b17023SJohn Marinodefine this macro.
7728e4b17023SJohn Marino@end defmac
7729e4b17023SJohn Marino
7730e4b17023SJohn Marino@defmac ASM_OUTPUT_SIZE_DIRECTIVE (@var{stream}, @var{name}, @var{size})
7731e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7732e4b17023SJohn Marino@var{stream} a directive telling the assembler that the size of the
7733e4b17023SJohn Marinosymbol @var{name} is @var{size}.  @var{size} is a @code{HOST_WIDE_INT}.
7734e4b17023SJohn MarinoIf you define @code{SIZE_ASM_OP}, a default definition of this macro is
7735e4b17023SJohn Marinoprovided.
7736e4b17023SJohn Marino@end defmac
7737e4b17023SJohn Marino
7738e4b17023SJohn Marino@defmac ASM_OUTPUT_MEASURED_SIZE (@var{stream}, @var{name})
7739e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7740e4b17023SJohn Marino@var{stream} a directive telling the assembler to calculate the size of
7741e4b17023SJohn Marinothe symbol @var{name} by subtracting its address from the current
7742e4b17023SJohn Marinoaddress.
7743e4b17023SJohn Marino
7744e4b17023SJohn MarinoIf you define @code{SIZE_ASM_OP}, a default definition of this macro is
7745e4b17023SJohn Marinoprovided.  The default assumes that the assembler recognizes a special
7746e4b17023SJohn Marino@samp{.} symbol as referring to the current address, and can calculate
7747e4b17023SJohn Marinothe difference between this and another symbol.  If your assembler does
7748e4b17023SJohn Marinonot recognize @samp{.} or cannot do calculations with it, you will need
7749e4b17023SJohn Marinoto redefine @code{ASM_OUTPUT_MEASURED_SIZE} to use some other technique.
7750e4b17023SJohn Marino@end defmac
7751e4b17023SJohn Marino
7752e4b17023SJohn Marino@defmac TYPE_ASM_OP
7753e4b17023SJohn MarinoA C string containing the appropriate assembler directive to specify the
7754e4b17023SJohn Marinotype of a symbol, without any arguments.  On systems that use ELF, the
7755e4b17023SJohn Marinodefault (in @file{config/elfos.h}) is @samp{"\t.type\t"}; on other
7756e4b17023SJohn Marinosystems, the default is not to define this macro.
7757e4b17023SJohn Marino
7758e4b17023SJohn MarinoDefine this macro only if it is correct to use the default definition of
7759e4b17023SJohn Marino@code{ASM_OUTPUT_TYPE_DIRECTIVE} for your system.  If you need your own
7760e4b17023SJohn Marinocustom definition of this macro, or if you do not need explicit symbol
7761e4b17023SJohn Marinotypes at all, do not define this macro.
7762e4b17023SJohn Marino@end defmac
7763e4b17023SJohn Marino
7764e4b17023SJohn Marino@defmac TYPE_OPERAND_FMT
7765e4b17023SJohn MarinoA C string which specifies (using @code{printf} syntax) the format of
7766e4b17023SJohn Marinothe second operand to @code{TYPE_ASM_OP}.  On systems that use ELF, the
7767e4b17023SJohn Marinodefault (in @file{config/elfos.h}) is @samp{"@@%s"}; on other systems,
7768e4b17023SJohn Marinothe default is not to define this macro.
7769e4b17023SJohn Marino
7770e4b17023SJohn MarinoDefine this macro only if it is correct to use the default definition of
7771e4b17023SJohn Marino@code{ASM_OUTPUT_TYPE_DIRECTIVE} for your system.  If you need your own
7772e4b17023SJohn Marinocustom definition of this macro, or if you do not need explicit symbol
7773e4b17023SJohn Marinotypes at all, do not define this macro.
7774e4b17023SJohn Marino@end defmac
7775e4b17023SJohn Marino
7776e4b17023SJohn Marino@defmac ASM_OUTPUT_TYPE_DIRECTIVE (@var{stream}, @var{type})
7777e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7778e4b17023SJohn Marino@var{stream} a directive telling the assembler that the type of the
7779e4b17023SJohn Marinosymbol @var{name} is @var{type}.  @var{type} is a C string; currently,
7780e4b17023SJohn Marinothat string is always either @samp{"function"} or @samp{"object"}, but
7781e4b17023SJohn Marinoyou should not count on this.
7782e4b17023SJohn Marino
7783e4b17023SJohn MarinoIf you define @code{TYPE_ASM_OP} and @code{TYPE_OPERAND_FMT}, a default
7784e4b17023SJohn Marinodefinition of this macro is provided.
7785e4b17023SJohn Marino@end defmac
7786e4b17023SJohn Marino
7787e4b17023SJohn Marino@defmac ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl})
7788e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7789e4b17023SJohn Marino@var{stream} any text necessary for declaring the name @var{name} of a
7790e4b17023SJohn Marinofunction which is being defined.  This macro is responsible for
7791e4b17023SJohn Marinooutputting the label definition (perhaps using
7792e4b17023SJohn Marino@code{ASM_OUTPUT_FUNCTION_LABEL}).  The argument @var{decl} is the
7793e4b17023SJohn Marino@code{FUNCTION_DECL} tree node representing the function.
7794e4b17023SJohn Marino
7795e4b17023SJohn MarinoIf this macro is not defined, then the function name is defined in the
7796e4b17023SJohn Marinousual manner as a label (by means of @code{ASM_OUTPUT_FUNCTION_LABEL}).
7797e4b17023SJohn Marino
7798e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
7799e4b17023SJohn Marinoof this macro.
7800e4b17023SJohn Marino@end defmac
7801e4b17023SJohn Marino
7802e4b17023SJohn Marino@defmac ASM_DECLARE_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl})
7803e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7804e4b17023SJohn Marino@var{stream} any text necessary for declaring the size of a function
7805e4b17023SJohn Marinowhich is being defined.  The argument @var{name} is the name of the
7806e4b17023SJohn Marinofunction.  The argument @var{decl} is the @code{FUNCTION_DECL} tree node
7807e4b17023SJohn Marinorepresenting the function.
7808e4b17023SJohn Marino
7809e4b17023SJohn MarinoIf this macro is not defined, then the function size is not defined.
7810e4b17023SJohn Marino
7811e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_MEASURED_SIZE} in the definition
7812e4b17023SJohn Marinoof this macro.
7813e4b17023SJohn Marino@end defmac
7814e4b17023SJohn Marino
7815e4b17023SJohn Marino@defmac ASM_DECLARE_OBJECT_NAME (@var{stream}, @var{name}, @var{decl})
7816e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7817e4b17023SJohn Marino@var{stream} any text necessary for declaring the name @var{name} of an
7818e4b17023SJohn Marinoinitialized variable which is being defined.  This macro must output the
7819e4b17023SJohn Marinolabel definition (perhaps using @code{ASM_OUTPUT_LABEL}).  The argument
7820e4b17023SJohn Marino@var{decl} is the @code{VAR_DECL} tree node representing the variable.
7821e4b17023SJohn Marino
7822e4b17023SJohn MarinoIf this macro is not defined, then the variable name is defined in the
7823e4b17023SJohn Marinousual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
7824e4b17023SJohn Marino
7825e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} and/or
7826e4b17023SJohn Marino@code{ASM_OUTPUT_SIZE_DIRECTIVE} in the definition of this macro.
7827e4b17023SJohn Marino@end defmac
7828e4b17023SJohn Marino
7829e4b17023SJohn Marino@hook TARGET_ASM_DECLARE_CONSTANT_NAME
7830e4b17023SJohn MarinoA target hook to output to the stdio stream @var{file} any text necessary
7831e4b17023SJohn Marinofor declaring the name @var{name} of a constant which is being defined.  This
7832e4b17023SJohn Marinotarget hook is responsible for outputting the label definition (perhaps using
7833e4b17023SJohn Marino@code{assemble_label}).  The argument @var{exp} is the value of the constant,
7834e4b17023SJohn Marinoand @var{size} is the size of the constant in bytes.  The @var{name}
7835e4b17023SJohn Marinowill be an internal label.
7836e4b17023SJohn Marino
7837e4b17023SJohn MarinoThe default version of this target hook, define the @var{name} in the
7838e4b17023SJohn Marinousual manner as a label (by means of @code{assemble_label}).
7839e4b17023SJohn Marino
7840e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in this target hook.
7841e4b17023SJohn Marino@end deftypefn
7842e4b17023SJohn Marino
7843e4b17023SJohn Marino@defmac ASM_DECLARE_REGISTER_GLOBAL (@var{stream}, @var{decl}, @var{regno}, @var{name})
7844e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7845e4b17023SJohn Marino@var{stream} any text necessary for claiming a register @var{regno}
7846e4b17023SJohn Marinofor a global variable @var{decl} with name @var{name}.
7847e4b17023SJohn Marino
7848e4b17023SJohn MarinoIf you don't define this macro, that is equivalent to defining it to do
7849e4b17023SJohn Marinonothing.
7850e4b17023SJohn Marino@end defmac
7851e4b17023SJohn Marino
7852e4b17023SJohn Marino@defmac ASM_FINISH_DECLARE_OBJECT (@var{stream}, @var{decl}, @var{toplevel}, @var{atend})
7853e4b17023SJohn MarinoA C statement (sans semicolon) to finish up declaring a variable name
7854e4b17023SJohn Marinoonce the compiler has processed its initializer fully and thus has had a
7855e4b17023SJohn Marinochance to determine the size of an array when controlled by an
7856e4b17023SJohn Marinoinitializer.  This is used on systems where it's necessary to declare
7857e4b17023SJohn Marinosomething about the size of the object.
7858e4b17023SJohn Marino
7859e4b17023SJohn MarinoIf you don't define this macro, that is equivalent to defining it to do
7860e4b17023SJohn Marinonothing.
7861e4b17023SJohn Marino
7862e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_SIZE_DIRECTIVE} and/or
7863e4b17023SJohn Marino@code{ASM_OUTPUT_MEASURED_SIZE} in the definition of this macro.
7864e4b17023SJohn Marino@end defmac
7865e4b17023SJohn Marino
7866e4b17023SJohn Marino@hook TARGET_ASM_GLOBALIZE_LABEL
7867e4b17023SJohn MarinoThis target hook is a function to output to the stdio stream
7868e4b17023SJohn Marino@var{stream} some commands that will make the label @var{name} global;
7869e4b17023SJohn Marinothat is, available for reference from other files.
7870e4b17023SJohn Marino
7871e4b17023SJohn MarinoThe default implementation relies on a proper definition of
7872e4b17023SJohn Marino@code{GLOBAL_ASM_OP}.
7873e4b17023SJohn Marino@end deftypefn
7874e4b17023SJohn Marino
7875e4b17023SJohn Marino@hook TARGET_ASM_GLOBALIZE_DECL_NAME
7876e4b17023SJohn MarinoThis target hook is a function to output to the stdio stream
7877e4b17023SJohn Marino@var{stream} some commands that will make the name associated with @var{decl}
7878e4b17023SJohn Marinoglobal; that is, available for reference from other files.
7879e4b17023SJohn Marino
7880e4b17023SJohn MarinoThe default implementation uses the TARGET_ASM_GLOBALIZE_LABEL target hook.
7881e4b17023SJohn Marino@end deftypefn
7882e4b17023SJohn Marino
7883e4b17023SJohn Marino@defmac ASM_WEAKEN_LABEL (@var{stream}, @var{name})
7884e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7885e4b17023SJohn Marino@var{stream} some commands that will make the label @var{name} weak;
7886e4b17023SJohn Marinothat is, available for reference from other files but only used if
7887e4b17023SJohn Marinono other definition is available.  Use the expression
7888e4b17023SJohn Marino@code{assemble_name (@var{stream}, @var{name})} to output the name
7889e4b17023SJohn Marinoitself; before and after that, output the additional assembler syntax
7890e4b17023SJohn Marinofor making that name weak, and a newline.
7891e4b17023SJohn Marino
7892e4b17023SJohn MarinoIf you don't define this macro or @code{ASM_WEAKEN_DECL}, GCC will not
7893e4b17023SJohn Marinosupport weak symbols and you should not define the @code{SUPPORTS_WEAK}
7894e4b17023SJohn Marinomacro.
7895e4b17023SJohn Marino@end defmac
7896e4b17023SJohn Marino
7897e4b17023SJohn Marino@defmac ASM_WEAKEN_DECL (@var{stream}, @var{decl}, @var{name}, @var{value})
7898e4b17023SJohn MarinoCombines (and replaces) the function of @code{ASM_WEAKEN_LABEL} and
7899e4b17023SJohn Marino@code{ASM_OUTPUT_WEAK_ALIAS}, allowing access to the associated function
7900e4b17023SJohn Marinoor variable decl.  If @var{value} is not @code{NULL}, this C statement
7901e4b17023SJohn Marinoshould output to the stdio stream @var{stream} assembler code which
7902e4b17023SJohn Marinodefines (equates) the weak symbol @var{name} to have the value
7903e4b17023SJohn Marino@var{value}.  If @var{value} is @code{NULL}, it should output commands
7904e4b17023SJohn Marinoto make @var{name} weak.
7905e4b17023SJohn Marino@end defmac
7906e4b17023SJohn Marino
7907e4b17023SJohn Marino@defmac ASM_OUTPUT_WEAKREF (@var{stream}, @var{decl}, @var{name}, @var{value})
7908e4b17023SJohn MarinoOutputs a directive that enables @var{name} to be used to refer to
7909e4b17023SJohn Marinosymbol @var{value} with weak-symbol semantics.  @code{decl} is the
7910e4b17023SJohn Marinodeclaration of @code{name}.
7911e4b17023SJohn Marino@end defmac
7912e4b17023SJohn Marino
7913e4b17023SJohn Marino@defmac SUPPORTS_WEAK
7914e4b17023SJohn MarinoA preprocessor constant expression which evaluates to true if the target
7915e4b17023SJohn Marinosupports weak symbols.
7916e4b17023SJohn Marino
7917e4b17023SJohn MarinoIf you don't define this macro, @file{defaults.h} provides a default
7918e4b17023SJohn Marinodefinition.  If either @code{ASM_WEAKEN_LABEL} or @code{ASM_WEAKEN_DECL}
7919e4b17023SJohn Marinois defined, the default definition is @samp{1}; otherwise, it is @samp{0}.
7920e4b17023SJohn Marino@end defmac
7921e4b17023SJohn Marino
7922e4b17023SJohn Marino@defmac TARGET_SUPPORTS_WEAK
7923e4b17023SJohn MarinoA C expression which evaluates to true if the target supports weak symbols.
7924e4b17023SJohn Marino
7925e4b17023SJohn MarinoIf you don't define this macro, @file{defaults.h} provides a default
7926e4b17023SJohn Marinodefinition.  The default definition is @samp{(SUPPORTS_WEAK)}.  Define
7927e4b17023SJohn Marinothis macro if you want to control weak symbol support with a compiler
7928e4b17023SJohn Marinoflag such as @option{-melf}.
7929e4b17023SJohn Marino@end defmac
7930e4b17023SJohn Marino
7931e4b17023SJohn Marino@defmac MAKE_DECL_ONE_ONLY (@var{decl})
7932e4b17023SJohn MarinoA C statement (sans semicolon) to mark @var{decl} to be emitted as a
7933e4b17023SJohn Marinopublic symbol such that extra copies in multiple translation units will
7934e4b17023SJohn Marinobe discarded by the linker.  Define this macro if your object file
7935e4b17023SJohn Marinoformat provides support for this concept, such as the @samp{COMDAT}
7936e4b17023SJohn Marinosection flags in the Microsoft Windows PE/COFF format, and this support
7937e4b17023SJohn Marinorequires changes to @var{decl}, such as putting it in a separate section.
7938e4b17023SJohn Marino@end defmac
7939e4b17023SJohn Marino
7940e4b17023SJohn Marino@defmac SUPPORTS_ONE_ONLY
7941e4b17023SJohn MarinoA C expression which evaluates to true if the target supports one-only
7942e4b17023SJohn Marinosemantics.
7943e4b17023SJohn Marino
7944e4b17023SJohn MarinoIf you don't define this macro, @file{varasm.c} provides a default
7945e4b17023SJohn Marinodefinition.  If @code{MAKE_DECL_ONE_ONLY} is defined, the default
7946e4b17023SJohn Marinodefinition is @samp{1}; otherwise, it is @samp{0}.  Define this macro if
7947e4b17023SJohn Marinoyou want to control one-only symbol support with a compiler flag, or if
7948e4b17023SJohn Marinosetting the @code{DECL_ONE_ONLY} flag is enough to mark a declaration to
7949e4b17023SJohn Marinobe emitted as one-only.
7950e4b17023SJohn Marino@end defmac
7951e4b17023SJohn Marino
7952e4b17023SJohn Marino@hook TARGET_ASM_ASSEMBLE_VISIBILITY
7953e4b17023SJohn MarinoThis target hook is a function to output to @var{asm_out_file} some
7954e4b17023SJohn Marinocommands that will make the symbol(s) associated with @var{decl} have
7955e4b17023SJohn Marinohidden, protected or internal visibility as specified by @var{visibility}.
7956e4b17023SJohn Marino@end deftypefn
7957e4b17023SJohn Marino
7958e4b17023SJohn Marino@defmac TARGET_WEAK_NOT_IN_ARCHIVE_TOC
7959e4b17023SJohn MarinoA C expression that evaluates to true if the target's linker expects
7960e4b17023SJohn Marinothat weak symbols do not appear in a static archive's table of contents.
7961e4b17023SJohn MarinoThe default is @code{0}.
7962e4b17023SJohn Marino
7963e4b17023SJohn MarinoLeaving weak symbols out of an archive's table of contents means that,
7964e4b17023SJohn Marinoif a symbol will only have a definition in one translation unit and
7965e4b17023SJohn Marinowill have undefined references from other translation units, that
7966e4b17023SJohn Marinosymbol should not be weak.  Defining this macro to be nonzero will
7967e4b17023SJohn Marinothus have the effect that certain symbols that would normally be weak
7968e4b17023SJohn Marino(explicit template instantiations, and vtables for polymorphic classes
7969e4b17023SJohn Marinowith noninline key methods) will instead be nonweak.
7970e4b17023SJohn Marino
7971e4b17023SJohn MarinoThe C++ ABI requires this macro to be zero.  Define this macro for
7972e4b17023SJohn Marinotargets where full C++ ABI compliance is impossible and where linker
7973e4b17023SJohn Marinorestrictions require weak symbols to be left out of a static archive's
7974e4b17023SJohn Marinotable of contents.
7975e4b17023SJohn Marino@end defmac
7976e4b17023SJohn Marino
7977e4b17023SJohn Marino@defmac ASM_OUTPUT_EXTERNAL (@var{stream}, @var{decl}, @var{name})
7978e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
7979e4b17023SJohn Marino@var{stream} any text necessary for declaring the name of an external
7980e4b17023SJohn Marinosymbol named @var{name} which is referenced in this compilation but
7981e4b17023SJohn Marinonot defined.  The value of @var{decl} is the tree node for the
7982e4b17023SJohn Marinodeclaration.
7983e4b17023SJohn Marino
7984e4b17023SJohn MarinoThis macro need not be defined if it does not need to output anything.
7985e4b17023SJohn MarinoThe GNU assembler and most Unix assemblers don't require anything.
7986e4b17023SJohn Marino@end defmac
7987e4b17023SJohn Marino
7988e4b17023SJohn Marino@hook TARGET_ASM_EXTERNAL_LIBCALL
7989e4b17023SJohn MarinoThis target hook is a function to output to @var{asm_out_file} an assembler
7990e4b17023SJohn Marinopseudo-op to declare a library function name external.  The name of the
7991e4b17023SJohn Marinolibrary function is given by @var{symref}, which is a @code{symbol_ref}.
7992e4b17023SJohn Marino@end deftypefn
7993e4b17023SJohn Marino
7994e4b17023SJohn Marino@hook TARGET_ASM_MARK_DECL_PRESERVED
7995e4b17023SJohn MarinoThis target hook is a function to output to @var{asm_out_file} an assembler
7996e4b17023SJohn Marinodirective to annotate @var{symbol} as used.  The Darwin target uses the
7997e4b17023SJohn Marino.no_dead_code_strip directive.
7998e4b17023SJohn Marino@end deftypefn
7999e4b17023SJohn Marino
8000e4b17023SJohn Marino@defmac ASM_OUTPUT_LABELREF (@var{stream}, @var{name})
8001e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream
8002e4b17023SJohn Marino@var{stream} a reference in assembler syntax to a label named
8003e4b17023SJohn Marino@var{name}.  This should add @samp{_} to the front of the name, if that
8004e4b17023SJohn Marinois customary on your operating system, as it is in most Berkeley Unix
8005e4b17023SJohn Marinosystems.  This macro is used in @code{assemble_name}.
8006e4b17023SJohn Marino@end defmac
8007e4b17023SJohn Marino
8008e4b17023SJohn Marino@hook TARGET_MANGLE_ASSEMBLER_NAME
8009e4b17023SJohn Marino
8010e4b17023SJohn Marino@defmac ASM_OUTPUT_SYMBOL_REF (@var{stream}, @var{sym})
8011e4b17023SJohn MarinoA C statement (sans semicolon) to output a reference to
8012e4b17023SJohn Marino@code{SYMBOL_REF} @var{sym}.  If not defined, @code{assemble_name}
8013e4b17023SJohn Marinowill be used to output the name of the symbol.  This macro may be used
8014e4b17023SJohn Marinoto modify the way a symbol is referenced depending on information
8015e4b17023SJohn Marinoencoded by @code{TARGET_ENCODE_SECTION_INFO}.
8016e4b17023SJohn Marino@end defmac
8017e4b17023SJohn Marino
8018e4b17023SJohn Marino@defmac ASM_OUTPUT_LABEL_REF (@var{stream}, @var{buf})
8019e4b17023SJohn MarinoA C statement (sans semicolon) to output a reference to @var{buf}, the
8020e4b17023SJohn Marinoresult of @code{ASM_GENERATE_INTERNAL_LABEL}.  If not defined,
8021e4b17023SJohn Marino@code{assemble_name} will be used to output the name of the symbol.
8022e4b17023SJohn MarinoThis macro is not used by @code{output_asm_label}, or the @code{%l}
8023e4b17023SJohn Marinospecifier that calls it; the intention is that this macro should be set
8024e4b17023SJohn Marinowhen it is necessary to output a label differently when its address is
8025e4b17023SJohn Marinobeing taken.
8026e4b17023SJohn Marino@end defmac
8027e4b17023SJohn Marino
8028e4b17023SJohn Marino@hook TARGET_ASM_INTERNAL_LABEL
8029e4b17023SJohn MarinoA function to output to the stdio stream @var{stream} a label whose
8030e4b17023SJohn Marinoname is made from the string @var{prefix} and the number @var{labelno}.
8031e4b17023SJohn Marino
8032e4b17023SJohn MarinoIt is absolutely essential that these labels be distinct from the labels
8033e4b17023SJohn Marinoused for user-level functions and variables.  Otherwise, certain programs
8034e4b17023SJohn Marinowill have name conflicts with internal labels.
8035e4b17023SJohn Marino
8036e4b17023SJohn MarinoIt is desirable to exclude internal labels from the symbol table of the
8037e4b17023SJohn Marinoobject file.  Most assemblers have a naming convention for labels that
8038e4b17023SJohn Marinoshould be excluded; on many systems, the letter @samp{L} at the
8039e4b17023SJohn Marinobeginning of a label has this effect.  You should find out what
8040e4b17023SJohn Marinoconvention your system uses, and follow it.
8041e4b17023SJohn Marino
8042e4b17023SJohn MarinoThe default version of this function utilizes @code{ASM_GENERATE_INTERNAL_LABEL}.
8043e4b17023SJohn Marino@end deftypefn
8044e4b17023SJohn Marino
8045e4b17023SJohn Marino@defmac ASM_OUTPUT_DEBUG_LABEL (@var{stream}, @var{prefix}, @var{num})
8046e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} a debug info
8047e4b17023SJohn Marinolabel whose name is made from the string @var{prefix} and the number
8048e4b17023SJohn Marino@var{num}.  This is useful for VLIW targets, where debug info labels
8049e4b17023SJohn Marinomay need to be treated differently than branch target labels.  On some
8050e4b17023SJohn Marinosystems, branch target labels must be at the beginning of instruction
8051e4b17023SJohn Marinobundles, but debug info labels can occur in the middle of instruction
8052e4b17023SJohn Marinobundles.
8053e4b17023SJohn Marino
8054e4b17023SJohn MarinoIf this macro is not defined, then @code{(*targetm.asm_out.internal_label)} will be
8055e4b17023SJohn Marinoused.
8056e4b17023SJohn Marino@end defmac
8057e4b17023SJohn Marino
8058e4b17023SJohn Marino@defmac ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num})
8059e4b17023SJohn MarinoA C statement to store into the string @var{string} a label whose name
8060e4b17023SJohn Marinois made from the string @var{prefix} and the number @var{num}.
8061e4b17023SJohn Marino
8062e4b17023SJohn MarinoThis string, when output subsequently by @code{assemble_name}, should
8063e4b17023SJohn Marinoproduce the output that @code{(*targetm.asm_out.internal_label)} would produce
8064e4b17023SJohn Marinowith the same @var{prefix} and @var{num}.
8065e4b17023SJohn Marino
8066e4b17023SJohn MarinoIf the string begins with @samp{*}, then @code{assemble_name} will
8067e4b17023SJohn Marinooutput the rest of the string unchanged.  It is often convenient for
8068e4b17023SJohn Marino@code{ASM_GENERATE_INTERNAL_LABEL} to use @samp{*} in this way.  If the
8069e4b17023SJohn Marinostring doesn't start with @samp{*}, then @code{ASM_OUTPUT_LABELREF} gets
8070e4b17023SJohn Marinoto output the string, and may change it.  (Of course,
8071e4b17023SJohn Marino@code{ASM_OUTPUT_LABELREF} is also part of your machine description, so
8072e4b17023SJohn Marinoyou should know what it does on your machine.)
8073e4b17023SJohn Marino@end defmac
8074e4b17023SJohn Marino
8075e4b17023SJohn Marino@defmac ASM_FORMAT_PRIVATE_NAME (@var{outvar}, @var{name}, @var{number})
8076e4b17023SJohn MarinoA C expression to assign to @var{outvar} (which is a variable of type
8077e4b17023SJohn Marino@code{char *}) a newly allocated string made from the string
8078e4b17023SJohn Marino@var{name} and the number @var{number}, with some suitable punctuation
8079e4b17023SJohn Marinoadded.  Use @code{alloca} to get space for the string.
8080e4b17023SJohn Marino
8081e4b17023SJohn MarinoThe string will be used as an argument to @code{ASM_OUTPUT_LABELREF} to
8082e4b17023SJohn Marinoproduce an assembler label for an internal static variable whose name is
8083e4b17023SJohn Marino@var{name}.  Therefore, the string must be such as to result in valid
8084e4b17023SJohn Marinoassembler code.  The argument @var{number} is different each time this
8085e4b17023SJohn Marinomacro is executed; it prevents conflicts between similarly-named
8086e4b17023SJohn Marinointernal static variables in different scopes.
8087e4b17023SJohn Marino
8088e4b17023SJohn MarinoIdeally this string should not be a valid C identifier, to prevent any
8089e4b17023SJohn Marinoconflict with the user's own symbols.  Most assemblers allow periods
8090e4b17023SJohn Marinoor percent signs in assembler symbols; putting at least one of these
8091e4b17023SJohn Marinobetween the name and the number will suffice.
8092e4b17023SJohn Marino
8093e4b17023SJohn MarinoIf this macro is not defined, a default definition will be provided
8094e4b17023SJohn Marinowhich is correct for most systems.
8095e4b17023SJohn Marino@end defmac
8096e4b17023SJohn Marino
8097e4b17023SJohn Marino@defmac ASM_OUTPUT_DEF (@var{stream}, @var{name}, @var{value})
8098e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} assembler code
8099e4b17023SJohn Marinowhich defines (equates) the symbol @var{name} to have the value @var{value}.
8100e4b17023SJohn Marino
8101e4b17023SJohn Marino@findex SET_ASM_OP
8102e4b17023SJohn MarinoIf @code{SET_ASM_OP} is defined, a default definition is provided which is
8103e4b17023SJohn Marinocorrect for most systems.
8104e4b17023SJohn Marino@end defmac
8105e4b17023SJohn Marino
8106e4b17023SJohn Marino@defmac ASM_OUTPUT_DEF_FROM_DECLS (@var{stream}, @var{decl_of_name}, @var{decl_of_value})
8107e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} assembler code
8108e4b17023SJohn Marinowhich defines (equates) the symbol whose tree node is @var{decl_of_name}
8109e4b17023SJohn Marinoto have the value of the tree node @var{decl_of_value}.  This macro will
8110e4b17023SJohn Marinobe used in preference to @samp{ASM_OUTPUT_DEF} if it is defined and if
8111e4b17023SJohn Marinothe tree nodes are available.
8112e4b17023SJohn Marino
8113e4b17023SJohn Marino@findex SET_ASM_OP
8114e4b17023SJohn MarinoIf @code{SET_ASM_OP} is defined, a default definition is provided which is
8115e4b17023SJohn Marinocorrect for most systems.
8116e4b17023SJohn Marino@end defmac
8117e4b17023SJohn Marino
8118e4b17023SJohn Marino@defmac TARGET_DEFERRED_OUTPUT_DEFS (@var{decl_of_name}, @var{decl_of_value})
8119e4b17023SJohn MarinoA C statement that evaluates to true if the assembler code which defines
8120e4b17023SJohn Marino(equates) the symbol whose tree node is @var{decl_of_name} to have the value
8121e4b17023SJohn Marinoof the tree node @var{decl_of_value} should be emitted near the end of the
8122e4b17023SJohn Marinocurrent compilation unit.  The default is to not defer output of defines.
8123e4b17023SJohn MarinoThis macro affects defines output by @samp{ASM_OUTPUT_DEF} and
8124e4b17023SJohn Marino@samp{ASM_OUTPUT_DEF_FROM_DECLS}.
8125e4b17023SJohn Marino@end defmac
8126e4b17023SJohn Marino
8127e4b17023SJohn Marino@defmac ASM_OUTPUT_WEAK_ALIAS (@var{stream}, @var{name}, @var{value})
8128e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} assembler code
8129e4b17023SJohn Marinowhich defines (equates) the weak symbol @var{name} to have the value
8130e4b17023SJohn Marino@var{value}.  If @var{value} is @code{NULL}, it defines @var{name} as
8131e4b17023SJohn Marinoan undefined weak symbol.
8132e4b17023SJohn Marino
8133e4b17023SJohn MarinoDefine this macro if the target only supports weak aliases; define
8134e4b17023SJohn Marino@code{ASM_OUTPUT_DEF} instead if possible.
8135e4b17023SJohn Marino@end defmac
8136e4b17023SJohn Marino
8137e4b17023SJohn Marino@defmac OBJC_GEN_METHOD_LABEL (@var{buf}, @var{is_inst}, @var{class_name}, @var{cat_name}, @var{sel_name})
8138e4b17023SJohn MarinoDefine this macro to override the default assembler names used for
8139e4b17023SJohn MarinoObjective-C methods.
8140e4b17023SJohn Marino
8141e4b17023SJohn MarinoThe default name is a unique method number followed by the name of the
8142e4b17023SJohn Marinoclass (e.g.@: @samp{_1_Foo}).  For methods in categories, the name of
8143e4b17023SJohn Marinothe category is also included in the assembler name (e.g.@:
8144e4b17023SJohn Marino@samp{_1_Foo_Bar}).
8145e4b17023SJohn Marino
8146e4b17023SJohn MarinoThese names are safe on most systems, but make debugging difficult since
8147e4b17023SJohn Marinothe method's selector is not present in the name.  Therefore, particular
8148e4b17023SJohn Marinosystems define other ways of computing names.
8149e4b17023SJohn Marino
8150e4b17023SJohn Marino@var{buf} is an expression of type @code{char *} which gives you a
8151e4b17023SJohn Marinobuffer in which to store the name; its length is as long as
8152e4b17023SJohn Marino@var{class_name}, @var{cat_name} and @var{sel_name} put together, plus
8153e4b17023SJohn Marino50 characters extra.
8154e4b17023SJohn Marino
8155e4b17023SJohn MarinoThe argument @var{is_inst} specifies whether the method is an instance
8156e4b17023SJohn Marinomethod or a class method; @var{class_name} is the name of the class;
8157e4b17023SJohn Marino@var{cat_name} is the name of the category (or @code{NULL} if the method is not
8158e4b17023SJohn Marinoin a category); and @var{sel_name} is the name of the selector.
8159e4b17023SJohn Marino
8160e4b17023SJohn MarinoOn systems where the assembler can handle quoted names, you can use this
8161e4b17023SJohn Marinomacro to provide more human-readable names.
8162e4b17023SJohn Marino@end defmac
8163e4b17023SJohn Marino
8164e4b17023SJohn Marino@node Initialization
8165e4b17023SJohn Marino@subsection How Initialization Functions Are Handled
8166e4b17023SJohn Marino@cindex initialization routines
8167e4b17023SJohn Marino@cindex termination routines
8168e4b17023SJohn Marino@cindex constructors, output of
8169e4b17023SJohn Marino@cindex destructors, output of
8170e4b17023SJohn Marino
8171e4b17023SJohn MarinoThe compiled code for certain languages includes @dfn{constructors}
8172e4b17023SJohn Marino(also called @dfn{initialization routines})---functions to initialize
8173e4b17023SJohn Marinodata in the program when the program is started.  These functions need
8174e4b17023SJohn Marinoto be called before the program is ``started''---that is to say, before
8175e4b17023SJohn Marino@code{main} is called.
8176e4b17023SJohn Marino
8177e4b17023SJohn MarinoCompiling some languages generates @dfn{destructors} (also called
8178e4b17023SJohn Marino@dfn{termination routines}) that should be called when the program
8179e4b17023SJohn Marinoterminates.
8180e4b17023SJohn Marino
8181e4b17023SJohn MarinoTo make the initialization and termination functions work, the compiler
8182e4b17023SJohn Marinomust output something in the assembler code to cause those functions to
8183e4b17023SJohn Marinobe called at the appropriate time.  When you port the compiler to a new
8184e4b17023SJohn Marinosystem, you need to specify how to do this.
8185e4b17023SJohn Marino
8186e4b17023SJohn MarinoThere are two major ways that GCC currently supports the execution of
8187e4b17023SJohn Marinoinitialization and termination functions.  Each way has two variants.
8188e4b17023SJohn MarinoMuch of the structure is common to all four variations.
8189e4b17023SJohn Marino
8190e4b17023SJohn Marino@findex __CTOR_LIST__
8191e4b17023SJohn Marino@findex __DTOR_LIST__
8192e4b17023SJohn MarinoThe linker must build two lists of these functions---a list of
8193e4b17023SJohn Marinoinitialization functions, called @code{__CTOR_LIST__}, and a list of
8194e4b17023SJohn Marinotermination functions, called @code{__DTOR_LIST__}.
8195e4b17023SJohn Marino
8196e4b17023SJohn MarinoEach list always begins with an ignored function pointer (which may hold
8197e4b17023SJohn Marino0, @minus{}1, or a count of the function pointers after it, depending on
8198e4b17023SJohn Marinothe environment).  This is followed by a series of zero or more function
8199e4b17023SJohn Marinopointers to constructors (or destructors), followed by a function
8200e4b17023SJohn Marinopointer containing zero.
8201e4b17023SJohn Marino
8202e4b17023SJohn MarinoDepending on the operating system and its executable file format, either
8203e4b17023SJohn Marino@file{crtstuff.c} or @file{libgcc2.c} traverses these lists at startup
8204e4b17023SJohn Marinotime and exit time.  Constructors are called in reverse order of the
8205e4b17023SJohn Marinolist; destructors in forward order.
8206e4b17023SJohn Marino
8207e4b17023SJohn MarinoThe best way to handle static constructors works only for object file
8208e4b17023SJohn Marinoformats which provide arbitrarily-named sections.  A section is set
8209e4b17023SJohn Marinoaside for a list of constructors, and another for a list of destructors.
8210e4b17023SJohn MarinoTraditionally these are called @samp{.ctors} and @samp{.dtors}.  Each
8211e4b17023SJohn Marinoobject file that defines an initialization function also puts a word in
8212e4b17023SJohn Marinothe constructor section to point to that function.  The linker
8213e4b17023SJohn Marinoaccumulates all these words into one contiguous @samp{.ctors} section.
8214e4b17023SJohn MarinoTermination functions are handled similarly.
8215e4b17023SJohn Marino
8216e4b17023SJohn MarinoThis method will be chosen as the default by @file{target-def.h} if
8217e4b17023SJohn Marino@code{TARGET_ASM_NAMED_SECTION} is defined.  A target that does not
8218e4b17023SJohn Marinosupport arbitrary sections, but does support special designated
8219e4b17023SJohn Marinoconstructor and destructor sections may define @code{CTORS_SECTION_ASM_OP}
8220e4b17023SJohn Marinoand @code{DTORS_SECTION_ASM_OP} to achieve the same effect.
8221e4b17023SJohn Marino
8222e4b17023SJohn MarinoWhen arbitrary sections are available, there are two variants, depending
8223e4b17023SJohn Marinoupon how the code in @file{crtstuff.c} is called.  On systems that
8224e4b17023SJohn Marinosupport a @dfn{.init} section which is executed at program startup,
8225e4b17023SJohn Marinoparts of @file{crtstuff.c} are compiled into that section.  The
8226e4b17023SJohn Marinoprogram is linked by the @command{gcc} driver like this:
8227e4b17023SJohn Marino
8228e4b17023SJohn Marino@smallexample
8229e4b17023SJohn Marinold -o @var{output_file} crti.o crtbegin.o @dots{} -lgcc crtend.o crtn.o
8230e4b17023SJohn Marino@end smallexample
8231e4b17023SJohn Marino
8232e4b17023SJohn MarinoThe prologue of a function (@code{__init}) appears in the @code{.init}
8233e4b17023SJohn Marinosection of @file{crti.o}; the epilogue appears in @file{crtn.o}.  Likewise
8234e4b17023SJohn Marinofor the function @code{__fini} in the @dfn{.fini} section.  Normally these
8235e4b17023SJohn Marinofiles are provided by the operating system or by the GNU C library, but
8236e4b17023SJohn Marinoare provided by GCC for a few targets.
8237e4b17023SJohn Marino
8238e4b17023SJohn MarinoThe objects @file{crtbegin.o} and @file{crtend.o} are (for most targets)
8239e4b17023SJohn Marinocompiled from @file{crtstuff.c}.  They contain, among other things, code
8240e4b17023SJohn Marinofragments within the @code{.init} and @code{.fini} sections that branch
8241e4b17023SJohn Marinoto routines in the @code{.text} section.  The linker will pull all parts
8242e4b17023SJohn Marinoof a section together, which results in a complete @code{__init} function
8243e4b17023SJohn Marinothat invokes the routines we need at startup.
8244e4b17023SJohn Marino
8245e4b17023SJohn MarinoTo use this variant, you must define the @code{INIT_SECTION_ASM_OP}
8246e4b17023SJohn Marinomacro properly.
8247e4b17023SJohn Marino
8248e4b17023SJohn MarinoIf no init section is available, when GCC compiles any function called
8249e4b17023SJohn Marino@code{main} (or more accurately, any function designated as a program
8250e4b17023SJohn Marinoentry point by the language front end calling @code{expand_main_function}),
8251e4b17023SJohn Marinoit inserts a procedure call to @code{__main} as the first executable code
8252e4b17023SJohn Marinoafter the function prologue.  The @code{__main} function is defined
8253e4b17023SJohn Marinoin @file{libgcc2.c} and runs the global constructors.
8254e4b17023SJohn Marino
8255e4b17023SJohn MarinoIn file formats that don't support arbitrary sections, there are again
8256e4b17023SJohn Marinotwo variants.  In the simplest variant, the GNU linker (GNU @code{ld})
8257e4b17023SJohn Marinoand an `a.out' format must be used.  In this case,
8258e4b17023SJohn Marino@code{TARGET_ASM_CONSTRUCTOR} is defined to produce a @code{.stabs}
8259e4b17023SJohn Marinoentry of type @samp{N_SETT}, referencing the name @code{__CTOR_LIST__},
8260e4b17023SJohn Marinoand with the address of the void function containing the initialization
8261e4b17023SJohn Marinocode as its value.  The GNU linker recognizes this as a request to add
8262e4b17023SJohn Marinothe value to a @dfn{set}; the values are accumulated, and are eventually
8263e4b17023SJohn Marinoplaced in the executable as a vector in the format described above, with
8264e4b17023SJohn Marinoa leading (ignored) count and a trailing zero element.
8265e4b17023SJohn Marino@code{TARGET_ASM_DESTRUCTOR} is handled similarly.  Since no init
8266e4b17023SJohn Marinosection is available, the absence of @code{INIT_SECTION_ASM_OP} causes
8267e4b17023SJohn Marinothe compilation of @code{main} to call @code{__main} as above, starting
8268e4b17023SJohn Marinothe initialization process.
8269e4b17023SJohn Marino
8270e4b17023SJohn MarinoThe last variant uses neither arbitrary sections nor the GNU linker.
8271e4b17023SJohn MarinoThis is preferable when you want to do dynamic linking and when using
8272e4b17023SJohn Marinofile formats which the GNU linker does not support, such as `ECOFF'@.  In
8273e4b17023SJohn Marinothis case, @code{TARGET_HAVE_CTORS_DTORS} is false, initialization and
8274e4b17023SJohn Marinotermination functions are recognized simply by their names.  This requires
8275e4b17023SJohn Marinoan extra program in the linkage step, called @command{collect2}.  This program
8276e4b17023SJohn Marinopretends to be the linker, for use with GCC; it does its job by running
8277e4b17023SJohn Marinothe ordinary linker, but also arranges to include the vectors of
8278e4b17023SJohn Marinoinitialization and termination functions.  These functions are called
8279e4b17023SJohn Marinovia @code{__main} as described above.  In order to use this method,
8280e4b17023SJohn Marino@code{use_collect2} must be defined in the target in @file{config.gcc}.
8281e4b17023SJohn Marino
8282e4b17023SJohn Marino@ifinfo
8283e4b17023SJohn MarinoThe following section describes the specific macros that control and
8284e4b17023SJohn Marinocustomize the handling of initialization and termination functions.
8285e4b17023SJohn Marino@end ifinfo
8286e4b17023SJohn Marino
8287e4b17023SJohn Marino@node Macros for Initialization
8288e4b17023SJohn Marino@subsection Macros Controlling Initialization Routines
8289e4b17023SJohn Marino
8290e4b17023SJohn MarinoHere are the macros that control how the compiler handles initialization
8291e4b17023SJohn Marinoand termination functions:
8292e4b17023SJohn Marino
8293e4b17023SJohn Marino@defmac INIT_SECTION_ASM_OP
8294e4b17023SJohn MarinoIf defined, a C string constant, including spacing, for the assembler
8295e4b17023SJohn Marinooperation to identify the following data as initialization code.  If not
8296e4b17023SJohn Marinodefined, GCC will assume such a section does not exist.  When you are
8297e4b17023SJohn Marinousing special sections for initialization and termination functions, this
8298e4b17023SJohn Marinomacro also controls how @file{crtstuff.c} and @file{libgcc2.c} arrange to
8299e4b17023SJohn Marinorun the initialization functions.
8300e4b17023SJohn Marino@end defmac
8301e4b17023SJohn Marino
8302e4b17023SJohn Marino@defmac HAS_INIT_SECTION
8303e4b17023SJohn MarinoIf defined, @code{main} will not call @code{__main} as described above.
8304e4b17023SJohn MarinoThis macro should be defined for systems that control start-up code
8305e4b17023SJohn Marinoon a symbol-by-symbol basis, such as OSF/1, and should not
8306e4b17023SJohn Marinobe defined explicitly for systems that support @code{INIT_SECTION_ASM_OP}.
8307e4b17023SJohn Marino@end defmac
8308e4b17023SJohn Marino
8309e4b17023SJohn Marino@defmac LD_INIT_SWITCH
8310e4b17023SJohn MarinoIf defined, a C string constant for a switch that tells the linker that
8311e4b17023SJohn Marinothe following symbol is an initialization routine.
8312e4b17023SJohn Marino@end defmac
8313e4b17023SJohn Marino
8314e4b17023SJohn Marino@defmac LD_FINI_SWITCH
8315e4b17023SJohn MarinoIf defined, a C string constant for a switch that tells the linker that
8316e4b17023SJohn Marinothe following symbol is a finalization routine.
8317e4b17023SJohn Marino@end defmac
8318e4b17023SJohn Marino
8319e4b17023SJohn Marino@defmac COLLECT_SHARED_INIT_FUNC (@var{stream}, @var{func})
8320e4b17023SJohn MarinoIf defined, a C statement that will write a function that can be
8321e4b17023SJohn Marinoautomatically called when a shared library is loaded.  The function
8322e4b17023SJohn Marinoshould call @var{func}, which takes no arguments.  If not defined, and
8323e4b17023SJohn Marinothe object format requires an explicit initialization function, then a
8324e4b17023SJohn Marinofunction called @code{_GLOBAL__DI} will be generated.
8325e4b17023SJohn Marino
8326e4b17023SJohn MarinoThis function and the following one are used by collect2 when linking a
8327e4b17023SJohn Marinoshared library that needs constructors or destructors, or has DWARF2
8328e4b17023SJohn Marinoexception tables embedded in the code.
8329e4b17023SJohn Marino@end defmac
8330e4b17023SJohn Marino
8331e4b17023SJohn Marino@defmac COLLECT_SHARED_FINI_FUNC (@var{stream}, @var{func})
8332e4b17023SJohn MarinoIf defined, a C statement that will write a function that can be
8333e4b17023SJohn Marinoautomatically called when a shared library is unloaded.  The function
8334e4b17023SJohn Marinoshould call @var{func}, which takes no arguments.  If not defined, and
8335e4b17023SJohn Marinothe object format requires an explicit finalization function, then a
8336e4b17023SJohn Marinofunction called @code{_GLOBAL__DD} will be generated.
8337e4b17023SJohn Marino@end defmac
8338e4b17023SJohn Marino
8339e4b17023SJohn Marino@defmac INVOKE__main
8340e4b17023SJohn MarinoIf defined, @code{main} will call @code{__main} despite the presence of
8341e4b17023SJohn Marino@code{INIT_SECTION_ASM_OP}.  This macro should be defined for systems
8342e4b17023SJohn Marinowhere the init section is not actually run automatically, but is still
8343e4b17023SJohn Marinouseful for collecting the lists of constructors and destructors.
8344e4b17023SJohn Marino@end defmac
8345e4b17023SJohn Marino
8346e4b17023SJohn Marino@defmac SUPPORTS_INIT_PRIORITY
8347e4b17023SJohn MarinoIf nonzero, the C++ @code{init_priority} attribute is supported and the
8348e4b17023SJohn Marinocompiler should emit instructions to control the order of initialization
8349e4b17023SJohn Marinoof objects.  If zero, the compiler will issue an error message upon
8350e4b17023SJohn Marinoencountering an @code{init_priority} attribute.
8351e4b17023SJohn Marino@end defmac
8352e4b17023SJohn Marino
8353e4b17023SJohn Marino@hook TARGET_HAVE_CTORS_DTORS
8354e4b17023SJohn MarinoThis value is true if the target supports some ``native'' method of
8355e4b17023SJohn Marinocollecting constructors and destructors to be run at startup and exit.
8356e4b17023SJohn MarinoIt is false if we must use @command{collect2}.
8357e4b17023SJohn Marino@end deftypevr
8358e4b17023SJohn Marino
8359e4b17023SJohn Marino@hook TARGET_ASM_CONSTRUCTOR
8360e4b17023SJohn MarinoIf defined, a function that outputs assembler code to arrange to call
8361e4b17023SJohn Marinothe function referenced by @var{symbol} at initialization time.
8362e4b17023SJohn Marino
8363e4b17023SJohn MarinoAssume that @var{symbol} is a @code{SYMBOL_REF} for a function taking
8364e4b17023SJohn Marinono arguments and with no return value.  If the target supports initialization
8365e4b17023SJohn Marinopriorities, @var{priority} is a value between 0 and @code{MAX_INIT_PRIORITY};
8366e4b17023SJohn Marinootherwise it must be @code{DEFAULT_INIT_PRIORITY}.
8367e4b17023SJohn Marino
8368e4b17023SJohn MarinoIf this macro is not defined by the target, a suitable default will
8369e4b17023SJohn Marinobe chosen if (1) the target supports arbitrary section names, (2) the
8370e4b17023SJohn Marinotarget defines @code{CTORS_SECTION_ASM_OP}, or (3) @code{USE_COLLECT2}
8371e4b17023SJohn Marinois not defined.
8372e4b17023SJohn Marino@end deftypefn
8373e4b17023SJohn Marino
8374e4b17023SJohn Marino@hook TARGET_ASM_DESTRUCTOR
8375e4b17023SJohn MarinoThis is like @code{TARGET_ASM_CONSTRUCTOR} but used for termination
8376e4b17023SJohn Marinofunctions rather than initialization functions.
8377e4b17023SJohn Marino@end deftypefn
8378e4b17023SJohn Marino
8379e4b17023SJohn MarinoIf @code{TARGET_HAVE_CTORS_DTORS} is true, the initialization routine
8380e4b17023SJohn Marinogenerated for the generated object file will have static linkage.
8381e4b17023SJohn Marino
8382e4b17023SJohn MarinoIf your system uses @command{collect2} as the means of processing
8383e4b17023SJohn Marinoconstructors, then that program normally uses @command{nm} to scan
8384e4b17023SJohn Marinoan object file for constructor functions to be called.
8385e4b17023SJohn Marino
8386e4b17023SJohn MarinoOn certain kinds of systems, you can define this macro to make
8387e4b17023SJohn Marino@command{collect2} work faster (and, in some cases, make it work at all):
8388e4b17023SJohn Marino
8389e4b17023SJohn Marino@defmac OBJECT_FORMAT_COFF
8390e4b17023SJohn MarinoDefine this macro if the system uses COFF (Common Object File Format)
8391e4b17023SJohn Marinoobject files, so that @command{collect2} can assume this format and scan
8392e4b17023SJohn Marinoobject files directly for dynamic constructor/destructor functions.
8393e4b17023SJohn Marino
8394e4b17023SJohn MarinoThis macro is effective only in a native compiler; @command{collect2} as
8395e4b17023SJohn Marinopart of a cross compiler always uses @command{nm} for the target machine.
8396e4b17023SJohn Marino@end defmac
8397e4b17023SJohn Marino
8398e4b17023SJohn Marino@defmac REAL_NM_FILE_NAME
8399e4b17023SJohn MarinoDefine this macro as a C string constant containing the file name to use
8400e4b17023SJohn Marinoto execute @command{nm}.  The default is to search the path normally for
8401e4b17023SJohn Marino@command{nm}.
8402e4b17023SJohn Marino@end defmac
8403e4b17023SJohn Marino
8404e4b17023SJohn Marino@defmac NM_FLAGS
8405e4b17023SJohn Marino@command{collect2} calls @command{nm} to scan object files for static
8406e4b17023SJohn Marinoconstructors and destructors and LTO info.  By default, @option{-n} is
8407e4b17023SJohn Marinopassed.  Define @code{NM_FLAGS} to a C string constant if other options
8408e4b17023SJohn Marinoare needed to get the same output format as GNU @command{nm -n}
8409e4b17023SJohn Marinoproduces.
8410e4b17023SJohn Marino@end defmac
8411e4b17023SJohn Marino
8412e4b17023SJohn MarinoIf your system supports shared libraries and has a program to list the
8413e4b17023SJohn Marinodynamic dependencies of a given library or executable, you can define
8414e4b17023SJohn Marinothese macros to enable support for running initialization and
8415e4b17023SJohn Marinotermination functions in shared libraries:
8416e4b17023SJohn Marino
8417e4b17023SJohn Marino@defmac LDD_SUFFIX
8418e4b17023SJohn MarinoDefine this macro to a C string constant containing the name of the program
8419e4b17023SJohn Marinowhich lists dynamic dependencies, like @command{ldd} under SunOS 4.
8420e4b17023SJohn Marino@end defmac
8421e4b17023SJohn Marino
8422e4b17023SJohn Marino@defmac PARSE_LDD_OUTPUT (@var{ptr})
8423e4b17023SJohn MarinoDefine this macro to be C code that extracts filenames from the output
8424e4b17023SJohn Marinoof the program denoted by @code{LDD_SUFFIX}.  @var{ptr} is a variable
8425e4b17023SJohn Marinoof type @code{char *} that points to the beginning of a line of output
8426e4b17023SJohn Marinofrom @code{LDD_SUFFIX}.  If the line lists a dynamic dependency, the
8427e4b17023SJohn Marinocode must advance @var{ptr} to the beginning of the filename on that
8428e4b17023SJohn Marinoline.  Otherwise, it must set @var{ptr} to @code{NULL}.
8429e4b17023SJohn Marino@end defmac
8430e4b17023SJohn Marino
8431e4b17023SJohn Marino@defmac SHLIB_SUFFIX
8432e4b17023SJohn MarinoDefine this macro to a C string constant containing the default shared
8433e4b17023SJohn Marinolibrary extension of the target (e.g., @samp{".so"}).  @command{collect2}
8434e4b17023SJohn Marinostrips version information after this suffix when generating global
8435e4b17023SJohn Marinoconstructor and destructor names.  This define is only needed on targets
8436e4b17023SJohn Marinothat use @command{collect2} to process constructors and destructors.
8437e4b17023SJohn Marino@end defmac
8438e4b17023SJohn Marino
8439e4b17023SJohn Marino@node Instruction Output
8440e4b17023SJohn Marino@subsection Output of Assembler Instructions
8441e4b17023SJohn Marino
8442e4b17023SJohn Marino@c prevent bad page break with this line
8443e4b17023SJohn MarinoThis describes assembler instruction output.
8444e4b17023SJohn Marino
8445e4b17023SJohn Marino@defmac REGISTER_NAMES
8446e4b17023SJohn MarinoA C initializer containing the assembler's names for the machine
8447e4b17023SJohn Marinoregisters, each one as a C string constant.  This is what translates
8448e4b17023SJohn Marinoregister numbers in the compiler into assembler language.
8449e4b17023SJohn Marino@end defmac
8450e4b17023SJohn Marino
8451e4b17023SJohn Marino@defmac ADDITIONAL_REGISTER_NAMES
8452e4b17023SJohn MarinoIf defined, a C initializer for an array of structures containing a name
8453e4b17023SJohn Marinoand a register number.  This macro defines additional names for hard
8454e4b17023SJohn Marinoregisters, thus allowing the @code{asm} option in declarations to refer
8455e4b17023SJohn Marinoto registers using alternate names.
8456e4b17023SJohn Marino@end defmac
8457e4b17023SJohn Marino
8458e4b17023SJohn Marino@defmac OVERLAPPING_REGISTER_NAMES
8459e4b17023SJohn MarinoIf defined, a C initializer for an array of structures containing a
8460e4b17023SJohn Marinoname, a register number and a count of the number of consecutive
8461e4b17023SJohn Marinomachine registers the name overlaps.  This macro defines additional
8462e4b17023SJohn Marinonames for hard registers, thus allowing the @code{asm} option in
8463e4b17023SJohn Marinodeclarations to refer to registers using alternate names.  Unlike
8464e4b17023SJohn Marino@code{ADDITIONAL_REGISTER_NAMES}, this macro should be used when the
8465e4b17023SJohn Marinoregister name implies multiple underlying registers.
8466e4b17023SJohn Marino
8467e4b17023SJohn MarinoThis macro should be used when it is important that a clobber in an
8468e4b17023SJohn Marino@code{asm} statement clobbers all the underlying values implied by the
8469e4b17023SJohn Marinoregister name.  For example, on ARM, clobbering the double-precision
8470e4b17023SJohn MarinoVFP register ``d0'' implies clobbering both single-precision registers
8471e4b17023SJohn Marino``s0'' and ``s1''.
8472e4b17023SJohn Marino@end defmac
8473e4b17023SJohn Marino
8474e4b17023SJohn Marino@defmac ASM_OUTPUT_OPCODE (@var{stream}, @var{ptr})
8475e4b17023SJohn MarinoDefine this macro if you are using an unusual assembler that
8476e4b17023SJohn Marinorequires different names for the machine instructions.
8477e4b17023SJohn Marino
8478e4b17023SJohn MarinoThe definition is a C statement or statements which output an
8479e4b17023SJohn Marinoassembler instruction opcode to the stdio stream @var{stream}.  The
8480e4b17023SJohn Marinomacro-operand @var{ptr} is a variable of type @code{char *} which
8481e4b17023SJohn Marinopoints to the opcode name in its ``internal'' form---the form that is
8482e4b17023SJohn Marinowritten in the machine description.  The definition should output the
8483e4b17023SJohn Marinoopcode name to @var{stream}, performing any translation you desire, and
8484e4b17023SJohn Marinoincrement the variable @var{ptr} to point at the end of the opcode
8485e4b17023SJohn Marinoso that it will not be output twice.
8486e4b17023SJohn Marino
8487e4b17023SJohn MarinoIn fact, your macro definition may process less than the entire opcode
8488e4b17023SJohn Marinoname, or more than the opcode name; but if you want to process text
8489e4b17023SJohn Marinothat includes @samp{%}-sequences to substitute operands, you must take
8490e4b17023SJohn Marinocare of the substitution yourself.  Just be sure to increment
8491e4b17023SJohn Marino@var{ptr} over whatever text should not be output normally.
8492e4b17023SJohn Marino
8493e4b17023SJohn Marino@findex recog_data.operand
8494e4b17023SJohn MarinoIf you need to look at the operand values, they can be found as the
8495e4b17023SJohn Marinoelements of @code{recog_data.operand}.
8496e4b17023SJohn Marino
8497e4b17023SJohn MarinoIf the macro definition does nothing, the instruction is output
8498e4b17023SJohn Marinoin the usual way.
8499e4b17023SJohn Marino@end defmac
8500e4b17023SJohn Marino
8501e4b17023SJohn Marino@defmac FINAL_PRESCAN_INSN (@var{insn}, @var{opvec}, @var{noperands})
8502e4b17023SJohn MarinoIf defined, a C statement to be executed just prior to the output of
8503e4b17023SJohn Marinoassembler code for @var{insn}, to modify the extracted operands so
8504e4b17023SJohn Marinothey will be output differently.
8505e4b17023SJohn Marino
8506e4b17023SJohn MarinoHere the argument @var{opvec} is the vector containing the operands
8507e4b17023SJohn Marinoextracted from @var{insn}, and @var{noperands} is the number of
8508e4b17023SJohn Marinoelements of the vector which contain meaningful data for this insn.
8509e4b17023SJohn MarinoThe contents of this vector are what will be used to convert the insn
8510e4b17023SJohn Marinotemplate into assembler code, so you can change the assembler output
8511e4b17023SJohn Marinoby changing the contents of the vector.
8512e4b17023SJohn Marino
8513e4b17023SJohn MarinoThis macro is useful when various assembler syntaxes share a single
8514e4b17023SJohn Marinofile of instruction patterns; by defining this macro differently, you
8515e4b17023SJohn Marinocan cause a large class of instructions to be output differently (such
8516e4b17023SJohn Marinoas with rearranged operands).  Naturally, variations in assembler
8517e4b17023SJohn Marinosyntax affecting individual insn patterns ought to be handled by
8518e4b17023SJohn Marinowriting conditional output routines in those patterns.
8519e4b17023SJohn Marino
8520e4b17023SJohn MarinoIf this macro is not defined, it is equivalent to a null statement.
8521e4b17023SJohn Marino@end defmac
8522e4b17023SJohn Marino
8523e4b17023SJohn Marino@hook TARGET_ASM_FINAL_POSTSCAN_INSN
8524e4b17023SJohn MarinoIf defined, this target hook is a function which is executed just after the
8525e4b17023SJohn Marinooutput of assembler code for @var{insn}, to change the mode of the assembler
8526e4b17023SJohn Marinoif necessary.
8527e4b17023SJohn Marino
8528e4b17023SJohn MarinoHere the argument @var{opvec} is the vector containing the operands
8529e4b17023SJohn Marinoextracted from @var{insn}, and @var{noperands} is the number of
8530e4b17023SJohn Marinoelements of the vector which contain meaningful data for this insn.
8531e4b17023SJohn MarinoThe contents of this vector are what was used to convert the insn
8532e4b17023SJohn Marinotemplate into assembler code, so you can change the assembler mode
8533e4b17023SJohn Marinoby checking the contents of the vector.
8534e4b17023SJohn Marino@end deftypefn
8535e4b17023SJohn Marino
8536e4b17023SJohn Marino@defmac PRINT_OPERAND (@var{stream}, @var{x}, @var{code})
8537e4b17023SJohn MarinoA C compound statement to output to stdio stream @var{stream} the
8538e4b17023SJohn Marinoassembler syntax for an instruction operand @var{x}.  @var{x} is an
8539e4b17023SJohn MarinoRTL expression.
8540e4b17023SJohn Marino
8541e4b17023SJohn Marino@var{code} is a value that can be used to specify one of several ways
8542e4b17023SJohn Marinoof printing the operand.  It is used when identical operands must be
8543e4b17023SJohn Marinoprinted differently depending on the context.  @var{code} comes from
8544e4b17023SJohn Marinothe @samp{%} specification that was used to request printing of the
8545e4b17023SJohn Marinooperand.  If the specification was just @samp{%@var{digit}} then
8546e4b17023SJohn Marino@var{code} is 0; if the specification was @samp{%@var{ltr}
8547e4b17023SJohn Marino@var{digit}} then @var{code} is the ASCII code for @var{ltr}.
8548e4b17023SJohn Marino
8549e4b17023SJohn Marino@findex reg_names
8550e4b17023SJohn MarinoIf @var{x} is a register, this macro should print the register's name.
8551e4b17023SJohn MarinoThe names can be found in an array @code{reg_names} whose type is
8552e4b17023SJohn Marino@code{char *[]}.  @code{reg_names} is initialized from
8553e4b17023SJohn Marino@code{REGISTER_NAMES}.
8554e4b17023SJohn Marino
8555e4b17023SJohn MarinoWhen the machine description has a specification @samp{%@var{punct}}
8556e4b17023SJohn Marino(a @samp{%} followed by a punctuation character), this macro is called
8557e4b17023SJohn Marinowith a null pointer for @var{x} and the punctuation character for
8558e4b17023SJohn Marino@var{code}.
8559e4b17023SJohn Marino@end defmac
8560e4b17023SJohn Marino
8561e4b17023SJohn Marino@defmac PRINT_OPERAND_PUNCT_VALID_P (@var{code})
8562e4b17023SJohn MarinoA C expression which evaluates to true if @var{code} is a valid
8563e4b17023SJohn Marinopunctuation character for use in the @code{PRINT_OPERAND} macro.  If
8564e4b17023SJohn Marino@code{PRINT_OPERAND_PUNCT_VALID_P} is not defined, it means that no
8565e4b17023SJohn Marinopunctuation characters (except for the standard one, @samp{%}) are used
8566e4b17023SJohn Marinoin this way.
8567e4b17023SJohn Marino@end defmac
8568e4b17023SJohn Marino
8569e4b17023SJohn Marino@defmac PRINT_OPERAND_ADDRESS (@var{stream}, @var{x})
8570e4b17023SJohn MarinoA C compound statement to output to stdio stream @var{stream} the
8571e4b17023SJohn Marinoassembler syntax for an instruction operand that is a memory reference
8572e4b17023SJohn Marinowhose address is @var{x}.  @var{x} is an RTL expression.
8573e4b17023SJohn Marino
8574e4b17023SJohn Marino@cindex @code{TARGET_ENCODE_SECTION_INFO} usage
8575e4b17023SJohn MarinoOn some machines, the syntax for a symbolic address depends on the
8576e4b17023SJohn Marinosection that the address refers to.  On these machines, define the hook
8577e4b17023SJohn Marino@code{TARGET_ENCODE_SECTION_INFO} to store the information into the
8578e4b17023SJohn Marino@code{symbol_ref}, and then check for it here.  @xref{Assembler
8579e4b17023SJohn MarinoFormat}.
8580e4b17023SJohn Marino@end defmac
8581e4b17023SJohn Marino
8582e4b17023SJohn Marino@findex dbr_sequence_length
8583e4b17023SJohn Marino@defmac DBR_OUTPUT_SEQEND (@var{file})
8584e4b17023SJohn MarinoA C statement, to be executed after all slot-filler instructions have
8585e4b17023SJohn Marinobeen output.  If necessary, call @code{dbr_sequence_length} to
8586e4b17023SJohn Marinodetermine the number of slots filled in a sequence (zero if not
8587e4b17023SJohn Marinocurrently outputting a sequence), to decide how many no-ops to output,
8588e4b17023SJohn Marinoor whatever.
8589e4b17023SJohn Marino
8590e4b17023SJohn MarinoDon't define this macro if it has nothing to do, but it is helpful in
8591e4b17023SJohn Marinoreading assembly output if the extent of the delay sequence is made
8592e4b17023SJohn Marinoexplicit (e.g.@: with white space).
8593e4b17023SJohn Marino@end defmac
8594e4b17023SJohn Marino
8595e4b17023SJohn Marino@findex final_sequence
8596e4b17023SJohn MarinoNote that output routines for instructions with delay slots must be
8597e4b17023SJohn Marinoprepared to deal with not being output as part of a sequence
8598e4b17023SJohn Marino(i.e.@: when the scheduling pass is not run, or when no slot fillers could be
8599e4b17023SJohn Marinofound.)  The variable @code{final_sequence} is null when not
8600e4b17023SJohn Marinoprocessing a sequence, otherwise it contains the @code{sequence} rtx
8601e4b17023SJohn Marinobeing output.
8602e4b17023SJohn Marino
8603e4b17023SJohn Marino@findex asm_fprintf
8604e4b17023SJohn Marino@defmac REGISTER_PREFIX
8605e4b17023SJohn Marino@defmacx LOCAL_LABEL_PREFIX
8606e4b17023SJohn Marino@defmacx USER_LABEL_PREFIX
8607e4b17023SJohn Marino@defmacx IMMEDIATE_PREFIX
8608e4b17023SJohn MarinoIf defined, C string expressions to be used for the @samp{%R}, @samp{%L},
8609e4b17023SJohn Marino@samp{%U}, and @samp{%I} options of @code{asm_fprintf} (see
8610e4b17023SJohn Marino@file{final.c}).  These are useful when a single @file{md} file must
8611e4b17023SJohn Marinosupport multiple assembler formats.  In that case, the various @file{tm.h}
8612e4b17023SJohn Marinofiles can define these macros differently.
8613e4b17023SJohn Marino@end defmac
8614e4b17023SJohn Marino
8615e4b17023SJohn Marino@defmac ASM_FPRINTF_EXTENSIONS (@var{file}, @var{argptr}, @var{format})
8616e4b17023SJohn MarinoIf defined this macro should expand to a series of @code{case}
8617e4b17023SJohn Marinostatements which will be parsed inside the @code{switch} statement of
8618e4b17023SJohn Marinothe @code{asm_fprintf} function.  This allows targets to define extra
8619e4b17023SJohn Marinoprintf formats which may useful when generating their assembler
8620e4b17023SJohn Marinostatements.  Note that uppercase letters are reserved for future
8621e4b17023SJohn Marinogeneric extensions to asm_fprintf, and so are not available to target
8622e4b17023SJohn Marinospecific code.  The output file is given by the parameter @var{file}.
8623e4b17023SJohn MarinoThe varargs input pointer is @var{argptr} and the rest of the format
8624e4b17023SJohn Marinostring, starting the character after the one that is being switched
8625e4b17023SJohn Marinoupon, is pointed to by @var{format}.
8626e4b17023SJohn Marino@end defmac
8627e4b17023SJohn Marino
8628e4b17023SJohn Marino@defmac ASSEMBLER_DIALECT
8629e4b17023SJohn MarinoIf your target supports multiple dialects of assembler language (such as
8630e4b17023SJohn Marinodifferent opcodes), define this macro as a C expression that gives the
8631e4b17023SJohn Marinonumeric index of the assembler language dialect to use, with zero as the
8632e4b17023SJohn Marinofirst variant.
8633e4b17023SJohn Marino
8634e4b17023SJohn MarinoIf this macro is defined, you may use constructs of the form
8635e4b17023SJohn Marino@smallexample
8636e4b17023SJohn Marino@samp{@{option0|option1|option2@dots{}@}}
8637e4b17023SJohn Marino@end smallexample
8638e4b17023SJohn Marino@noindent
8639e4b17023SJohn Marinoin the output templates of patterns (@pxref{Output Template}) or in the
8640e4b17023SJohn Marinofirst argument of @code{asm_fprintf}.  This construct outputs
8641e4b17023SJohn Marino@samp{option0}, @samp{option1}, @samp{option2}, etc., if the value of
8642e4b17023SJohn Marino@code{ASSEMBLER_DIALECT} is zero, one, two, etc.  Any special characters
8643e4b17023SJohn Marinowithin these strings retain their usual meaning.  If there are fewer
8644e4b17023SJohn Marinoalternatives within the braces than the value of
8645e4b17023SJohn Marino@code{ASSEMBLER_DIALECT}, the construct outputs nothing.
8646e4b17023SJohn Marino
8647e4b17023SJohn MarinoIf you do not define this macro, the characters @samp{@{}, @samp{|} and
8648e4b17023SJohn Marino@samp{@}} do not have any special meaning when used in templates or
8649e4b17023SJohn Marinooperands to @code{asm_fprintf}.
8650e4b17023SJohn Marino
8651e4b17023SJohn MarinoDefine the macros @code{REGISTER_PREFIX}, @code{LOCAL_LABEL_PREFIX},
8652e4b17023SJohn Marino@code{USER_LABEL_PREFIX} and @code{IMMEDIATE_PREFIX} if you can express
8653e4b17023SJohn Marinothe variations in assembler language syntax with that mechanism.  Define
8654e4b17023SJohn Marino@code{ASSEMBLER_DIALECT} and use the @samp{@{option0|option1@}} syntax
8655e4b17023SJohn Marinoif the syntax variant are larger and involve such things as different
8656e4b17023SJohn Marinoopcodes or operand order.
8657e4b17023SJohn Marino@end defmac
8658e4b17023SJohn Marino
8659e4b17023SJohn Marino@defmac ASM_OUTPUT_REG_PUSH (@var{stream}, @var{regno})
8660e4b17023SJohn MarinoA C expression to output to @var{stream} some assembler code
8661e4b17023SJohn Marinowhich will push hard register number @var{regno} onto the stack.
8662e4b17023SJohn MarinoThe code need not be optimal, since this macro is used only when
8663e4b17023SJohn Marinoprofiling.
8664e4b17023SJohn Marino@end defmac
8665e4b17023SJohn Marino
8666e4b17023SJohn Marino@defmac ASM_OUTPUT_REG_POP (@var{stream}, @var{regno})
8667e4b17023SJohn MarinoA C expression to output to @var{stream} some assembler code
8668e4b17023SJohn Marinowhich will pop hard register number @var{regno} off of the stack.
8669e4b17023SJohn MarinoThe code need not be optimal, since this macro is used only when
8670e4b17023SJohn Marinoprofiling.
8671e4b17023SJohn Marino@end defmac
8672e4b17023SJohn Marino
8673e4b17023SJohn Marino@node Dispatch Tables
8674e4b17023SJohn Marino@subsection Output of Dispatch Tables
8675e4b17023SJohn Marino
8676e4b17023SJohn Marino@c prevent bad page break with this line
8677e4b17023SJohn MarinoThis concerns dispatch tables.
8678e4b17023SJohn Marino
8679e4b17023SJohn Marino@cindex dispatch table
8680e4b17023SJohn Marino@defmac ASM_OUTPUT_ADDR_DIFF_ELT (@var{stream}, @var{body}, @var{value}, @var{rel})
8681e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler
8682e4b17023SJohn Marinopseudo-instruction to generate a difference between two labels.
8683e4b17023SJohn Marino@var{value} and @var{rel} are the numbers of two internal labels.  The
8684e4b17023SJohn Marinodefinitions of these labels are output using
8685e4b17023SJohn Marino@code{(*targetm.asm_out.internal_label)}, and they must be printed in the same
8686e4b17023SJohn Marinoway here.  For example,
8687e4b17023SJohn Marino
8688e4b17023SJohn Marino@smallexample
8689e4b17023SJohn Marinofprintf (@var{stream}, "\t.word L%d-L%d\n",
8690e4b17023SJohn Marino         @var{value}, @var{rel})
8691e4b17023SJohn Marino@end smallexample
8692e4b17023SJohn Marino
8693e4b17023SJohn MarinoYou must provide this macro on machines where the addresses in a
8694e4b17023SJohn Marinodispatch table are relative to the table's own address.  If defined, GCC
8695e4b17023SJohn Marinowill also use this macro on all machines when producing PIC@.
8696e4b17023SJohn Marino@var{body} is the body of the @code{ADDR_DIFF_VEC}; it is provided so that the
8697e4b17023SJohn Marinomode and flags can be read.
8698e4b17023SJohn Marino@end defmac
8699e4b17023SJohn Marino
8700e4b17023SJohn Marino@defmac ASM_OUTPUT_ADDR_VEC_ELT (@var{stream}, @var{value})
8701e4b17023SJohn MarinoThis macro should be provided on machines where the addresses
8702e4b17023SJohn Marinoin a dispatch table are absolute.
8703e4b17023SJohn Marino
8704e4b17023SJohn MarinoThe definition should be a C statement to output to the stdio stream
8705e4b17023SJohn Marino@var{stream} an assembler pseudo-instruction to generate a reference to
8706e4b17023SJohn Marinoa label.  @var{value} is the number of an internal label whose
8707e4b17023SJohn Marinodefinition is output using @code{(*targetm.asm_out.internal_label)}.
8708e4b17023SJohn MarinoFor example,
8709e4b17023SJohn Marino
8710e4b17023SJohn Marino@smallexample
8711e4b17023SJohn Marinofprintf (@var{stream}, "\t.word L%d\n", @var{value})
8712e4b17023SJohn Marino@end smallexample
8713e4b17023SJohn Marino@end defmac
8714e4b17023SJohn Marino
8715e4b17023SJohn Marino@defmac ASM_OUTPUT_CASE_LABEL (@var{stream}, @var{prefix}, @var{num}, @var{table})
8716e4b17023SJohn MarinoDefine this if the label before a jump-table needs to be output
8717e4b17023SJohn Marinospecially.  The first three arguments are the same as for
8718e4b17023SJohn Marino@code{(*targetm.asm_out.internal_label)}; the fourth argument is the
8719e4b17023SJohn Marinojump-table which follows (a @code{jump_insn} containing an
8720e4b17023SJohn Marino@code{addr_vec} or @code{addr_diff_vec}).
8721e4b17023SJohn Marino
8722e4b17023SJohn MarinoThis feature is used on system V to output a @code{swbeg} statement
8723e4b17023SJohn Marinofor the table.
8724e4b17023SJohn Marino
8725e4b17023SJohn MarinoIf this macro is not defined, these labels are output with
8726e4b17023SJohn Marino@code{(*targetm.asm_out.internal_label)}.
8727e4b17023SJohn Marino@end defmac
8728e4b17023SJohn Marino
8729e4b17023SJohn Marino@defmac ASM_OUTPUT_CASE_END (@var{stream}, @var{num}, @var{table})
8730e4b17023SJohn MarinoDefine this if something special must be output at the end of a
8731e4b17023SJohn Marinojump-table.  The definition should be a C statement to be executed
8732e4b17023SJohn Marinoafter the assembler code for the table is written.  It should write
8733e4b17023SJohn Marinothe appropriate code to stdio stream @var{stream}.  The argument
8734e4b17023SJohn Marino@var{table} is the jump-table insn, and @var{num} is the label-number
8735e4b17023SJohn Marinoof the preceding label.
8736e4b17023SJohn Marino
8737e4b17023SJohn MarinoIf this macro is not defined, nothing special is output at the end of
8738e4b17023SJohn Marinothe jump-table.
8739e4b17023SJohn Marino@end defmac
8740e4b17023SJohn Marino
8741e4b17023SJohn Marino@hook TARGET_ASM_EMIT_UNWIND_LABEL
8742e4b17023SJohn MarinoThis target hook emits a label at the beginning of each FDE@.  It
8743e4b17023SJohn Marinoshould be defined on targets where FDEs need special labels, and it
8744e4b17023SJohn Marinoshould write the appropriate label, for the FDE associated with the
8745e4b17023SJohn Marinofunction declaration @var{decl}, to the stdio stream @var{stream}.
8746e4b17023SJohn MarinoThe third argument, @var{for_eh}, is a boolean: true if this is for an
8747e4b17023SJohn Marinoexception table.  The fourth argument, @var{empty}, is a boolean:
8748e4b17023SJohn Marinotrue if this is a placeholder label for an omitted FDE@.
8749e4b17023SJohn Marino
8750e4b17023SJohn MarinoThe default is that FDEs are not given nonlocal labels.
8751e4b17023SJohn Marino@end deftypefn
8752e4b17023SJohn Marino
8753e4b17023SJohn Marino@hook TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL
8754e4b17023SJohn MarinoThis target hook emits a label at the beginning of the exception table.
8755e4b17023SJohn MarinoIt should be defined on targets where it is desirable for the table
8756e4b17023SJohn Marinoto be broken up according to function.
8757e4b17023SJohn Marino
8758e4b17023SJohn MarinoThe default is that no label is emitted.
8759e4b17023SJohn Marino@end deftypefn
8760e4b17023SJohn Marino
8761e4b17023SJohn Marino@hook TARGET_ASM_EMIT_EXCEPT_PERSONALITY
8762e4b17023SJohn Marino
8763e4b17023SJohn Marino@hook TARGET_ASM_UNWIND_EMIT
8764e4b17023SJohn MarinoThis target hook emits assembly directives required to unwind the
8765e4b17023SJohn Marinogiven instruction.  This is only used when @code{TARGET_EXCEPT_UNWIND_INFO}
8766e4b17023SJohn Marinoreturns @code{UI_TARGET}.
8767e4b17023SJohn Marino@end deftypefn
8768e4b17023SJohn Marino
8769e4b17023SJohn Marino@hook TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
8770e4b17023SJohn Marino
8771e4b17023SJohn Marino@node Exception Region Output
8772e4b17023SJohn Marino@subsection Assembler Commands for Exception Regions
8773e4b17023SJohn Marino
8774e4b17023SJohn Marino@c prevent bad page break with this line
8775e4b17023SJohn Marino
8776e4b17023SJohn MarinoThis describes commands marking the start and the end of an exception
8777e4b17023SJohn Marinoregion.
8778e4b17023SJohn Marino
8779e4b17023SJohn Marino@defmac EH_FRAME_SECTION_NAME
8780e4b17023SJohn MarinoIf defined, a C string constant for the name of the section containing
8781e4b17023SJohn Marinoexception handling frame unwind information.  If not defined, GCC will
8782e4b17023SJohn Marinoprovide a default definition if the target supports named sections.
8783e4b17023SJohn Marino@file{crtstuff.c} uses this macro to switch to the appropriate section.
8784e4b17023SJohn Marino
8785e4b17023SJohn MarinoYou should define this symbol if your target supports DWARF 2 frame
8786e4b17023SJohn Marinounwind information and the default definition does not work.
8787e4b17023SJohn Marino@end defmac
8788e4b17023SJohn Marino
8789e4b17023SJohn Marino@defmac EH_FRAME_IN_DATA_SECTION
8790e4b17023SJohn MarinoIf defined, DWARF 2 frame unwind information will be placed in the
8791e4b17023SJohn Marinodata section even though the target supports named sections.  This
8792e4b17023SJohn Marinomight be necessary, for instance, if the system linker does garbage
8793e4b17023SJohn Marinocollection and sections cannot be marked as not to be collected.
8794e4b17023SJohn Marino
8795e4b17023SJohn MarinoDo not define this macro unless @code{TARGET_ASM_NAMED_SECTION} is
8796e4b17023SJohn Marinoalso defined.
8797e4b17023SJohn Marino@end defmac
8798e4b17023SJohn Marino
8799e4b17023SJohn Marino@defmac EH_TABLES_CAN_BE_READ_ONLY
8800e4b17023SJohn MarinoDefine this macro to 1 if your target is such that no frame unwind
8801e4b17023SJohn Marinoinformation encoding used with non-PIC code will ever require a
8802e4b17023SJohn Marinoruntime relocation, but the linker may not support merging read-only
8803e4b17023SJohn Marinoand read-write sections into a single read-write section.
8804e4b17023SJohn Marino@end defmac
8805e4b17023SJohn Marino
8806e4b17023SJohn Marino@defmac MASK_RETURN_ADDR
8807e4b17023SJohn MarinoAn rtx used to mask the return address found via @code{RETURN_ADDR_RTX}, so
8808e4b17023SJohn Marinothat it does not contain any extraneous set bits in it.
8809e4b17023SJohn Marino@end defmac
8810e4b17023SJohn Marino
8811e4b17023SJohn Marino@defmac DWARF2_UNWIND_INFO
8812e4b17023SJohn MarinoDefine this macro to 0 if your target supports DWARF 2 frame unwind
8813e4b17023SJohn Marinoinformation, but it does not yet work with exception handling.
8814e4b17023SJohn MarinoOtherwise, if your target supports this information (if it defines
8815e4b17023SJohn Marino@code{INCOMING_RETURN_ADDR_RTX} and either @code{UNALIGNED_INT_ASM_OP}
8816e4b17023SJohn Marinoor @code{OBJECT_FORMAT_ELF}), GCC will provide a default definition of 1.
8817e4b17023SJohn Marino@end defmac
8818e4b17023SJohn Marino
8819e4b17023SJohn Marino@hook TARGET_EXCEPT_UNWIND_INFO
8820e4b17023SJohn MarinoThis hook defines the mechanism that will be used for exception handling
8821e4b17023SJohn Marinoby the target.  If the target has ABI specified unwind tables, the hook
8822e4b17023SJohn Marinoshould return @code{UI_TARGET}.  If the target is to use the
8823e4b17023SJohn Marino@code{setjmp}/@code{longjmp}-based exception handling scheme, the hook
8824e4b17023SJohn Marinoshould return @code{UI_SJLJ}.  If the target supports DWARF 2 frame unwind
8825e4b17023SJohn Marinoinformation, the hook should return @code{UI_DWARF2}.
8826e4b17023SJohn Marino
8827e4b17023SJohn MarinoA target may, if exceptions are disabled, choose to return @code{UI_NONE}.
8828e4b17023SJohn MarinoThis may end up simplifying other parts of target-specific code.  The
8829e4b17023SJohn Marinodefault implementation of this hook never returns @code{UI_NONE}.
8830e4b17023SJohn Marino
8831e4b17023SJohn MarinoNote that the value returned by this hook should be constant.  It should
8832e4b17023SJohn Marinonot depend on anything except the command-line switches described by
8833e4b17023SJohn Marino@var{opts}.  In particular, the
8834e4b17023SJohn Marinosetting @code{UI_SJLJ} must be fixed at compiler start-up as C pre-processor
8835e4b17023SJohn Marinomacros and builtin functions related to exception handling are set up
8836e4b17023SJohn Marinodepending on this setting.
8837e4b17023SJohn Marino
8838e4b17023SJohn MarinoThe default implementation of the hook first honors the
8839e4b17023SJohn Marino@option{--enable-sjlj-exceptions} configure option, then
8840e4b17023SJohn Marino@code{DWARF2_UNWIND_INFO}, and finally defaults to @code{UI_SJLJ}.  If
8841e4b17023SJohn Marino@code{DWARF2_UNWIND_INFO} depends on command-line options, the target
8842e4b17023SJohn Marinomust define this hook so that @var{opts} is used correctly.
8843e4b17023SJohn Marino@end deftypefn
8844e4b17023SJohn Marino
8845e4b17023SJohn Marino@hook TARGET_UNWIND_TABLES_DEFAULT
8846e4b17023SJohn MarinoThis variable should be set to @code{true} if the target ABI requires unwinding
8847e4b17023SJohn Marinotables even when exceptions are not used.  It must not be modified by
8848e4b17023SJohn Marinocommand-line option processing.
8849e4b17023SJohn Marino@end deftypevr
8850e4b17023SJohn Marino
8851e4b17023SJohn Marino@defmac DONT_USE_BUILTIN_SETJMP
8852e4b17023SJohn MarinoDefine this macro to 1 if the @code{setjmp}/@code{longjmp}-based scheme
8853e4b17023SJohn Marinoshould use the @code{setjmp}/@code{longjmp} functions from the C library
8854e4b17023SJohn Marinoinstead of the @code{__builtin_setjmp}/@code{__builtin_longjmp} machinery.
8855e4b17023SJohn Marino@end defmac
8856e4b17023SJohn Marino
8857e4b17023SJohn Marino@defmac DWARF_CIE_DATA_ALIGNMENT
8858e4b17023SJohn MarinoThis macro need only be defined if the target might save registers in the
8859e4b17023SJohn Marinofunction prologue at an offset to the stack pointer that is not aligned to
8860e4b17023SJohn Marino@code{UNITS_PER_WORD}.  The definition should be the negative minimum
8861e4b17023SJohn Marinoalignment if @code{STACK_GROWS_DOWNWARD} is defined, and the positive
8862e4b17023SJohn Marinominimum alignment otherwise.  @xref{SDB and DWARF}.  Only applicable if
8863e4b17023SJohn Marinothe target supports DWARF 2 frame unwind information.
8864e4b17023SJohn Marino@end defmac
8865e4b17023SJohn Marino
8866e4b17023SJohn Marino@hook TARGET_TERMINATE_DW2_EH_FRAME_INFO
8867e4b17023SJohn MarinoContains the value true if the target should add a zero word onto the
8868e4b17023SJohn Marinoend of a Dwarf-2 frame info section when used for exception handling.
8869e4b17023SJohn MarinoDefault value is false if @code{EH_FRAME_SECTION_NAME} is defined, and
8870e4b17023SJohn Marinotrue otherwise.
8871e4b17023SJohn Marino@end deftypevr
8872e4b17023SJohn Marino
8873e4b17023SJohn Marino@hook TARGET_DWARF_REGISTER_SPAN
8874e4b17023SJohn MarinoGiven a register, this hook should return a parallel of registers to
8875e4b17023SJohn Marinorepresent where to find the register pieces.  Define this hook if the
8876e4b17023SJohn Marinoregister and its mode are represented in Dwarf in non-contiguous
8877e4b17023SJohn Marinolocations, or if the register should be represented in more than one
8878e4b17023SJohn Marinoregister in Dwarf.  Otherwise, this hook should return @code{NULL_RTX}.
8879e4b17023SJohn MarinoIf not defined, the default is to return @code{NULL_RTX}.
8880e4b17023SJohn Marino@end deftypefn
8881e4b17023SJohn Marino
8882e4b17023SJohn Marino@hook TARGET_INIT_DWARF_REG_SIZES_EXTRA
8883e4b17023SJohn MarinoIf some registers are represented in Dwarf-2 unwind information in
8884e4b17023SJohn Marinomultiple pieces, define this hook to fill in information about the
8885e4b17023SJohn Marinosizes of those pieces in the table used by the unwinder at runtime.
8886e4b17023SJohn MarinoIt will be called by @code{expand_builtin_init_dwarf_reg_sizes} after
8887e4b17023SJohn Marinofilling in a single size corresponding to each hard register;
8888e4b17023SJohn Marino@var{address} is the address of the table.
8889e4b17023SJohn Marino@end deftypefn
8890e4b17023SJohn Marino
8891e4b17023SJohn Marino@hook TARGET_ASM_TTYPE
8892e4b17023SJohn MarinoThis hook is used to output a reference from a frame unwinding table to
8893e4b17023SJohn Marinothe type_info object identified by @var{sym}.  It should return @code{true}
8894e4b17023SJohn Marinoif the reference was output.  Returning @code{false} will cause the
8895e4b17023SJohn Marinoreference to be output using the normal Dwarf2 routines.
8896e4b17023SJohn Marino@end deftypefn
8897e4b17023SJohn Marino
8898e4b17023SJohn Marino@hook TARGET_ARM_EABI_UNWINDER
8899e4b17023SJohn MarinoThis flag should be set to @code{true} on targets that use an ARM EABI
8900e4b17023SJohn Marinobased unwinding library, and @code{false} on other targets.  This effects
8901e4b17023SJohn Marinothe format of unwinding tables, and how the unwinder in entered after
8902e4b17023SJohn Marinorunning a cleanup.  The default is @code{false}.
8903e4b17023SJohn Marino@end deftypevr
8904e4b17023SJohn Marino
8905e4b17023SJohn Marino@node Alignment Output
8906e4b17023SJohn Marino@subsection Assembler Commands for Alignment
8907e4b17023SJohn Marino
8908e4b17023SJohn Marino@c prevent bad page break with this line
8909e4b17023SJohn MarinoThis describes commands for alignment.
8910e4b17023SJohn Marino
8911e4b17023SJohn Marino@defmac JUMP_ALIGN (@var{label})
8912e4b17023SJohn MarinoThe alignment (log base 2) to put in front of @var{label}, which is
8913e4b17023SJohn Marinoa common destination of jumps and has no fallthru incoming edge.
8914e4b17023SJohn Marino
8915e4b17023SJohn MarinoThis macro need not be defined if you don't want any special alignment
8916e4b17023SJohn Marinoto be done at such a time.  Most machine descriptions do not currently
8917e4b17023SJohn Marinodefine the macro.
8918e4b17023SJohn Marino
8919e4b17023SJohn MarinoUnless it's necessary to inspect the @var{label} parameter, it is better
8920e4b17023SJohn Marinoto set the variable @var{align_jumps} in the target's
8921e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE}.  Otherwise, you should try to honor the user's
8922e4b17023SJohn Marinoselection in @var{align_jumps} in a @code{JUMP_ALIGN} implementation.
8923e4b17023SJohn Marino@end defmac
8924e4b17023SJohn Marino
8925e4b17023SJohn Marino@hook TARGET_ASM_JUMP_ALIGN_MAX_SKIP
8926e4b17023SJohn MarinoThe maximum number of bytes to skip before @var{label} when applying
8927e4b17023SJohn Marino@code{JUMP_ALIGN}.  This works only if
8928e4b17023SJohn Marino@code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined.
8929e4b17023SJohn Marino@end deftypefn
8930e4b17023SJohn Marino
8931e4b17023SJohn Marino@defmac LABEL_ALIGN_AFTER_BARRIER (@var{label})
8932e4b17023SJohn MarinoThe alignment (log base 2) to put in front of @var{label}, which follows
8933e4b17023SJohn Marinoa @code{BARRIER}.
8934e4b17023SJohn Marino
8935e4b17023SJohn MarinoThis macro need not be defined if you don't want any special alignment
8936e4b17023SJohn Marinoto be done at such a time.  Most machine descriptions do not currently
8937e4b17023SJohn Marinodefine the macro.
8938e4b17023SJohn Marino@end defmac
8939e4b17023SJohn Marino
8940e4b17023SJohn Marino@hook TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
8941e4b17023SJohn MarinoThe maximum number of bytes to skip before @var{label} when applying
8942e4b17023SJohn Marino@code{LABEL_ALIGN_AFTER_BARRIER}.  This works only if
8943e4b17023SJohn Marino@code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined.
8944e4b17023SJohn Marino@end deftypefn
8945e4b17023SJohn Marino
8946e4b17023SJohn Marino@defmac LOOP_ALIGN (@var{label})
8947e4b17023SJohn MarinoThe alignment (log base 2) to put in front of @var{label}, which follows
8948e4b17023SJohn Marinoa @code{NOTE_INSN_LOOP_BEG} note.
8949e4b17023SJohn Marino
8950e4b17023SJohn MarinoThis macro need not be defined if you don't want any special alignment
8951e4b17023SJohn Marinoto be done at such a time.  Most machine descriptions do not currently
8952e4b17023SJohn Marinodefine the macro.
8953e4b17023SJohn Marino
8954e4b17023SJohn MarinoUnless it's necessary to inspect the @var{label} parameter, it is better
8955e4b17023SJohn Marinoto set the variable @code{align_loops} in the target's
8956e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE}.  Otherwise, you should try to honor the user's
8957e4b17023SJohn Marinoselection in @code{align_loops} in a @code{LOOP_ALIGN} implementation.
8958e4b17023SJohn Marino@end defmac
8959e4b17023SJohn Marino
8960e4b17023SJohn Marino@hook TARGET_ASM_LOOP_ALIGN_MAX_SKIP
8961e4b17023SJohn MarinoThe maximum number of bytes to skip when applying @code{LOOP_ALIGN} to
8962e4b17023SJohn Marino@var{label}.  This works only if @code{ASM_OUTPUT_MAX_SKIP_ALIGN} is
8963e4b17023SJohn Marinodefined.
8964e4b17023SJohn Marino@end deftypefn
8965e4b17023SJohn Marino
8966e4b17023SJohn Marino@defmac LABEL_ALIGN (@var{label})
8967e4b17023SJohn MarinoThe alignment (log base 2) to put in front of @var{label}.
8968e4b17023SJohn MarinoIf @code{LABEL_ALIGN_AFTER_BARRIER} / @code{LOOP_ALIGN} specify a different alignment,
8969e4b17023SJohn Marinothe maximum of the specified values is used.
8970e4b17023SJohn Marino
8971e4b17023SJohn MarinoUnless it's necessary to inspect the @var{label} parameter, it is better
8972e4b17023SJohn Marinoto set the variable @code{align_labels} in the target's
8973e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE}.  Otherwise, you should try to honor the user's
8974e4b17023SJohn Marinoselection in @code{align_labels} in a @code{LABEL_ALIGN} implementation.
8975e4b17023SJohn Marino@end defmac
8976e4b17023SJohn Marino
8977e4b17023SJohn Marino@hook TARGET_ASM_LABEL_ALIGN_MAX_SKIP
8978e4b17023SJohn MarinoThe maximum number of bytes to skip when applying @code{LABEL_ALIGN}
8979e4b17023SJohn Marinoto @var{label}.  This works only if @code{ASM_OUTPUT_MAX_SKIP_ALIGN}
8980e4b17023SJohn Marinois defined.
8981e4b17023SJohn Marino@end deftypefn
8982e4b17023SJohn Marino
8983e4b17023SJohn Marino@defmac ASM_OUTPUT_SKIP (@var{stream}, @var{nbytes})
8984e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler
8985e4b17023SJohn Marinoinstruction to advance the location counter by @var{nbytes} bytes.
8986e4b17023SJohn MarinoThose bytes should be zero when loaded.  @var{nbytes} will be a C
8987e4b17023SJohn Marinoexpression of type @code{unsigned HOST_WIDE_INT}.
8988e4b17023SJohn Marino@end defmac
8989e4b17023SJohn Marino
8990e4b17023SJohn Marino@defmac ASM_NO_SKIP_IN_TEXT
8991e4b17023SJohn MarinoDefine this macro if @code{ASM_OUTPUT_SKIP} should not be used in the
8992e4b17023SJohn Marinotext section because it fails to put zeros in the bytes that are skipped.
8993e4b17023SJohn MarinoThis is true on many Unix systems, where the pseudo--op to skip bytes
8994e4b17023SJohn Marinoproduces no-op instructions rather than zeros when used in the text
8995e4b17023SJohn Marinosection.
8996e4b17023SJohn Marino@end defmac
8997e4b17023SJohn Marino
8998e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGN (@var{stream}, @var{power})
8999e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler
9000e4b17023SJohn Marinocommand to advance the location counter to a multiple of 2 to the
9001e4b17023SJohn Marino@var{power} bytes.  @var{power} will be a C expression of type @code{int}.
9002e4b17023SJohn Marino@end defmac
9003e4b17023SJohn Marino
9004e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGN_WITH_NOP (@var{stream}, @var{power})
9005e4b17023SJohn MarinoLike @code{ASM_OUTPUT_ALIGN}, except that the ``nop'' instruction is used
9006e4b17023SJohn Marinofor padding, if necessary.
9007e4b17023SJohn Marino@end defmac
9008e4b17023SJohn Marino
9009e4b17023SJohn Marino@defmac ASM_OUTPUT_MAX_SKIP_ALIGN (@var{stream}, @var{power}, @var{max_skip})
9010e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler
9011e4b17023SJohn Marinocommand to advance the location counter to a multiple of 2 to the
9012e4b17023SJohn Marino@var{power} bytes, but only if @var{max_skip} or fewer bytes are needed to
9013e4b17023SJohn Marinosatisfy the alignment request.  @var{power} and @var{max_skip} will be
9014e4b17023SJohn Marinoa C expression of type @code{int}.
9015e4b17023SJohn Marino@end defmac
9016e4b17023SJohn Marino
9017e4b17023SJohn Marino@need 3000
9018e4b17023SJohn Marino@node Debugging Info
9019e4b17023SJohn Marino@section Controlling Debugging Information Format
9020e4b17023SJohn Marino
9021e4b17023SJohn Marino@c prevent bad page break with this line
9022e4b17023SJohn MarinoThis describes how to specify debugging information.
9023e4b17023SJohn Marino
9024e4b17023SJohn Marino@menu
9025e4b17023SJohn Marino* All Debuggers::      Macros that affect all debugging formats uniformly.
9026e4b17023SJohn Marino* DBX Options::        Macros enabling specific options in DBX format.
9027e4b17023SJohn Marino* DBX Hooks::          Hook macros for varying DBX format.
9028e4b17023SJohn Marino* File Names and DBX:: Macros controlling output of file names in DBX format.
9029e4b17023SJohn Marino* SDB and DWARF::      Macros for SDB (COFF) and DWARF formats.
9030e4b17023SJohn Marino* VMS Debug::          Macros for VMS debug format.
9031e4b17023SJohn Marino@end menu
9032e4b17023SJohn Marino
9033e4b17023SJohn Marino@node All Debuggers
9034e4b17023SJohn Marino@subsection Macros Affecting All Debugging Formats
9035e4b17023SJohn Marino
9036e4b17023SJohn Marino@c prevent bad page break with this line
9037e4b17023SJohn MarinoThese macros affect all debugging formats.
9038e4b17023SJohn Marino
9039e4b17023SJohn Marino@defmac DBX_REGISTER_NUMBER (@var{regno})
9040e4b17023SJohn MarinoA C expression that returns the DBX register number for the compiler
9041e4b17023SJohn Marinoregister number @var{regno}.  In the default macro provided, the value
9042e4b17023SJohn Marinoof this expression will be @var{regno} itself.  But sometimes there are
9043e4b17023SJohn Marinosome registers that the compiler knows about and DBX does not, or vice
9044e4b17023SJohn Marinoversa.  In such cases, some register may need to have one number in the
9045e4b17023SJohn Marinocompiler and another for DBX@.
9046e4b17023SJohn Marino
9047e4b17023SJohn MarinoIf two registers have consecutive numbers inside GCC, and they can be
9048e4b17023SJohn Marinoused as a pair to hold a multiword value, then they @emph{must} have
9049e4b17023SJohn Marinoconsecutive numbers after renumbering with @code{DBX_REGISTER_NUMBER}.
9050e4b17023SJohn MarinoOtherwise, debuggers will be unable to access such a pair, because they
9051e4b17023SJohn Marinoexpect register pairs to be consecutive in their own numbering scheme.
9052e4b17023SJohn Marino
9053e4b17023SJohn MarinoIf you find yourself defining @code{DBX_REGISTER_NUMBER} in way that
9054e4b17023SJohn Marinodoes not preserve register pairs, then what you must do instead is
9055e4b17023SJohn Marinoredefine the actual register numbering scheme.
9056e4b17023SJohn Marino@end defmac
9057e4b17023SJohn Marino
9058e4b17023SJohn Marino@defmac DEBUGGER_AUTO_OFFSET (@var{x})
9059e4b17023SJohn MarinoA C expression that returns the integer offset value for an automatic
9060e4b17023SJohn Marinovariable having address @var{x} (an RTL expression).  The default
9061e4b17023SJohn Marinocomputation assumes that @var{x} is based on the frame-pointer and
9062e4b17023SJohn Marinogives the offset from the frame-pointer.  This is required for targets
9063e4b17023SJohn Marinothat produce debugging output for DBX or COFF-style debugging output
9064e4b17023SJohn Marinofor SDB and allow the frame-pointer to be eliminated when the
9065e4b17023SJohn Marino@option{-g} options is used.
9066e4b17023SJohn Marino@end defmac
9067e4b17023SJohn Marino
9068e4b17023SJohn Marino@defmac DEBUGGER_ARG_OFFSET (@var{offset}, @var{x})
9069e4b17023SJohn MarinoA C expression that returns the integer offset value for an argument
9070e4b17023SJohn Marinohaving address @var{x} (an RTL expression).  The nominal offset is
9071e4b17023SJohn Marino@var{offset}.
9072e4b17023SJohn Marino@end defmac
9073e4b17023SJohn Marino
9074e4b17023SJohn Marino@defmac PREFERRED_DEBUGGING_TYPE
9075e4b17023SJohn MarinoA C expression that returns the type of debugging output GCC should
9076e4b17023SJohn Marinoproduce when the user specifies just @option{-g}.  Define
9077e4b17023SJohn Marinothis if you have arranged for GCC to support more than one format of
9078e4b17023SJohn Marinodebugging output.  Currently, the allowable values are @code{DBX_DEBUG},
9079e4b17023SJohn Marino@code{SDB_DEBUG}, @code{DWARF_DEBUG}, @code{DWARF2_DEBUG},
9080e4b17023SJohn Marino@code{XCOFF_DEBUG}, @code{VMS_DEBUG}, and @code{VMS_AND_DWARF2_DEBUG}.
9081e4b17023SJohn Marino
9082e4b17023SJohn MarinoWhen the user specifies @option{-ggdb}, GCC normally also uses the
9083e4b17023SJohn Marinovalue of this macro to select the debugging output format, but with two
9084e4b17023SJohn Marinoexceptions.  If @code{DWARF2_DEBUGGING_INFO} is defined, GCC uses the
9085e4b17023SJohn Marinovalue @code{DWARF2_DEBUG}.  Otherwise, if @code{DBX_DEBUGGING_INFO} is
9086e4b17023SJohn Marinodefined, GCC uses @code{DBX_DEBUG}.
9087e4b17023SJohn Marino
9088e4b17023SJohn MarinoThe value of this macro only affects the default debugging output; the
9089e4b17023SJohn Marinouser can always get a specific type of output by using @option{-gstabs},
9090e4b17023SJohn Marino@option{-gcoff}, @option{-gdwarf-2}, @option{-gxcoff}, or @option{-gvms}.
9091e4b17023SJohn Marino@end defmac
9092e4b17023SJohn Marino
9093e4b17023SJohn Marino@node DBX Options
9094e4b17023SJohn Marino@subsection Specific Options for DBX Output
9095e4b17023SJohn Marino
9096e4b17023SJohn Marino@c prevent bad page break with this line
9097e4b17023SJohn MarinoThese are specific options for DBX output.
9098e4b17023SJohn Marino
9099e4b17023SJohn Marino@defmac DBX_DEBUGGING_INFO
9100e4b17023SJohn MarinoDefine this macro if GCC should produce debugging output for DBX
9101e4b17023SJohn Marinoin response to the @option{-g} option.
9102e4b17023SJohn Marino@end defmac
9103e4b17023SJohn Marino
9104e4b17023SJohn Marino@defmac XCOFF_DEBUGGING_INFO
9105e4b17023SJohn MarinoDefine this macro if GCC should produce XCOFF format debugging output
9106e4b17023SJohn Marinoin response to the @option{-g} option.  This is a variant of DBX format.
9107e4b17023SJohn Marino@end defmac
9108e4b17023SJohn Marino
9109e4b17023SJohn Marino@defmac DEFAULT_GDB_EXTENSIONS
9110e4b17023SJohn MarinoDefine this macro to control whether GCC should by default generate
9111e4b17023SJohn MarinoGDB's extended version of DBX debugging information (assuming DBX-format
9112e4b17023SJohn Marinodebugging information is enabled at all).  If you don't define the
9113e4b17023SJohn Marinomacro, the default is 1: always generate the extended information
9114e4b17023SJohn Marinoif there is any occasion to.
9115e4b17023SJohn Marino@end defmac
9116e4b17023SJohn Marino
9117e4b17023SJohn Marino@defmac DEBUG_SYMS_TEXT
9118e4b17023SJohn MarinoDefine this macro if all @code{.stabs} commands should be output while
9119e4b17023SJohn Marinoin the text section.
9120e4b17023SJohn Marino@end defmac
9121e4b17023SJohn Marino
9122e4b17023SJohn Marino@defmac ASM_STABS_OP
9123e4b17023SJohn MarinoA C string constant, including spacing, naming the assembler pseudo op to
9124e4b17023SJohn Marinouse instead of @code{"\t.stabs\t"} to define an ordinary debugging symbol.
9125e4b17023SJohn MarinoIf you don't define this macro, @code{"\t.stabs\t"} is used.  This macro
9126e4b17023SJohn Marinoapplies only to DBX debugging information format.
9127e4b17023SJohn Marino@end defmac
9128e4b17023SJohn Marino
9129e4b17023SJohn Marino@defmac ASM_STABD_OP
9130e4b17023SJohn MarinoA C string constant, including spacing, naming the assembler pseudo op to
9131e4b17023SJohn Marinouse instead of @code{"\t.stabd\t"} to define a debugging symbol whose
9132e4b17023SJohn Marinovalue is the current location.  If you don't define this macro,
9133e4b17023SJohn Marino@code{"\t.stabd\t"} is used.  This macro applies only to DBX debugging
9134e4b17023SJohn Marinoinformation format.
9135e4b17023SJohn Marino@end defmac
9136e4b17023SJohn Marino
9137e4b17023SJohn Marino@defmac ASM_STABN_OP
9138e4b17023SJohn MarinoA C string constant, including spacing, naming the assembler pseudo op to
9139e4b17023SJohn Marinouse instead of @code{"\t.stabn\t"} to define a debugging symbol with no
9140e4b17023SJohn Marinoname.  If you don't define this macro, @code{"\t.stabn\t"} is used.  This
9141e4b17023SJohn Marinomacro applies only to DBX debugging information format.
9142e4b17023SJohn Marino@end defmac
9143e4b17023SJohn Marino
9144e4b17023SJohn Marino@defmac DBX_NO_XREFS
9145e4b17023SJohn MarinoDefine this macro if DBX on your system does not support the construct
9146e4b17023SJohn Marino@samp{xs@var{tagname}}.  On some systems, this construct is used to
9147e4b17023SJohn Marinodescribe a forward reference to a structure named @var{tagname}.
9148e4b17023SJohn MarinoOn other systems, this construct is not supported at all.
9149e4b17023SJohn Marino@end defmac
9150e4b17023SJohn Marino
9151e4b17023SJohn Marino@defmac DBX_CONTIN_LENGTH
9152e4b17023SJohn MarinoA symbol name in DBX-format debugging information is normally
9153e4b17023SJohn Marinocontinued (split into two separate @code{.stabs} directives) when it
9154e4b17023SJohn Marinoexceeds a certain length (by default, 80 characters).  On some
9155e4b17023SJohn Marinooperating systems, DBX requires this splitting; on others, splitting
9156e4b17023SJohn Marinomust not be done.  You can inhibit splitting by defining this macro
9157e4b17023SJohn Marinowith the value zero.  You can override the default splitting-length by
9158e4b17023SJohn Marinodefining this macro as an expression for the length you desire.
9159e4b17023SJohn Marino@end defmac
9160e4b17023SJohn Marino
9161e4b17023SJohn Marino@defmac DBX_CONTIN_CHAR
9162e4b17023SJohn MarinoNormally continuation is indicated by adding a @samp{\} character to
9163e4b17023SJohn Marinothe end of a @code{.stabs} string when a continuation follows.  To use
9164e4b17023SJohn Marinoa different character instead, define this macro as a character
9165e4b17023SJohn Marinoconstant for the character you want to use.  Do not define this macro
9166e4b17023SJohn Marinoif backslash is correct for your system.
9167e4b17023SJohn Marino@end defmac
9168e4b17023SJohn Marino
9169e4b17023SJohn Marino@defmac DBX_STATIC_STAB_DATA_SECTION
9170e4b17023SJohn MarinoDefine this macro if it is necessary to go to the data section before
9171e4b17023SJohn Marinooutputting the @samp{.stabs} pseudo-op for a non-global static
9172e4b17023SJohn Marinovariable.
9173e4b17023SJohn Marino@end defmac
9174e4b17023SJohn Marino
9175e4b17023SJohn Marino@defmac DBX_TYPE_DECL_STABS_CODE
9176e4b17023SJohn MarinoThe value to use in the ``code'' field of the @code{.stabs} directive
9177e4b17023SJohn Marinofor a typedef.  The default is @code{N_LSYM}.
9178e4b17023SJohn Marino@end defmac
9179e4b17023SJohn Marino
9180e4b17023SJohn Marino@defmac DBX_STATIC_CONST_VAR_CODE
9181e4b17023SJohn MarinoThe value to use in the ``code'' field of the @code{.stabs} directive
9182e4b17023SJohn Marinofor a static variable located in the text section.  DBX format does not
9183e4b17023SJohn Marinoprovide any ``right'' way to do this.  The default is @code{N_FUN}.
9184e4b17023SJohn Marino@end defmac
9185e4b17023SJohn Marino
9186e4b17023SJohn Marino@defmac DBX_REGPARM_STABS_CODE
9187e4b17023SJohn MarinoThe value to use in the ``code'' field of the @code{.stabs} directive
9188e4b17023SJohn Marinofor a parameter passed in registers.  DBX format does not provide any
9189e4b17023SJohn Marino``right'' way to do this.  The default is @code{N_RSYM}.
9190e4b17023SJohn Marino@end defmac
9191e4b17023SJohn Marino
9192e4b17023SJohn Marino@defmac DBX_REGPARM_STABS_LETTER
9193e4b17023SJohn MarinoThe letter to use in DBX symbol data to identify a symbol as a parameter
9194e4b17023SJohn Marinopassed in registers.  DBX format does not customarily provide any way to
9195e4b17023SJohn Marinodo this.  The default is @code{'P'}.
9196e4b17023SJohn Marino@end defmac
9197e4b17023SJohn Marino
9198e4b17023SJohn Marino@defmac DBX_FUNCTION_FIRST
9199e4b17023SJohn MarinoDefine this macro if the DBX information for a function and its
9200e4b17023SJohn Marinoarguments should precede the assembler code for the function.  Normally,
9201e4b17023SJohn Marinoin DBX format, the debugging information entirely follows the assembler
9202e4b17023SJohn Marinocode.
9203e4b17023SJohn Marino@end defmac
9204e4b17023SJohn Marino
9205e4b17023SJohn Marino@defmac DBX_BLOCKS_FUNCTION_RELATIVE
9206e4b17023SJohn MarinoDefine this macro, with value 1, if the value of a symbol describing
9207e4b17023SJohn Marinothe scope of a block (@code{N_LBRAC} or @code{N_RBRAC}) should be
9208e4b17023SJohn Marinorelative to the start of the enclosing function.  Normally, GCC uses
9209e4b17023SJohn Marinoan absolute address.
9210e4b17023SJohn Marino@end defmac
9211e4b17023SJohn Marino
9212e4b17023SJohn Marino@defmac DBX_LINES_FUNCTION_RELATIVE
9213e4b17023SJohn MarinoDefine this macro, with value 1, if the value of a symbol indicating
9214e4b17023SJohn Marinothe current line number (@code{N_SLINE}) should be relative to the
9215e4b17023SJohn Marinostart of the enclosing function.  Normally, GCC uses an absolute address.
9216e4b17023SJohn Marino@end defmac
9217e4b17023SJohn Marino
9218e4b17023SJohn Marino@defmac DBX_USE_BINCL
9219e4b17023SJohn MarinoDefine this macro if GCC should generate @code{N_BINCL} and
9220e4b17023SJohn Marino@code{N_EINCL} stabs for included header files, as on Sun systems.  This
9221e4b17023SJohn Marinomacro also directs GCC to output a type number as a pair of a file
9222e4b17023SJohn Marinonumber and a type number within the file.  Normally, GCC does not
9223e4b17023SJohn Marinogenerate @code{N_BINCL} or @code{N_EINCL} stabs, and it outputs a single
9224e4b17023SJohn Marinonumber for a type number.
9225e4b17023SJohn Marino@end defmac
9226e4b17023SJohn Marino
9227e4b17023SJohn Marino@node DBX Hooks
9228e4b17023SJohn Marino@subsection Open-Ended Hooks for DBX Format
9229e4b17023SJohn Marino
9230e4b17023SJohn Marino@c prevent bad page break with this line
9231e4b17023SJohn MarinoThese are hooks for DBX format.
9232e4b17023SJohn Marino
9233e4b17023SJohn Marino@defmac DBX_OUTPUT_LBRAC (@var{stream}, @var{name})
9234e4b17023SJohn MarinoDefine this macro to say how to output to @var{stream} the debugging
9235e4b17023SJohn Marinoinformation for the start of a scope level for variable names.  The
9236e4b17023SJohn Marinoargument @var{name} is the name of an assembler symbol (for use with
9237e4b17023SJohn Marino@code{assemble_name}) whose value is the address where the scope begins.
9238e4b17023SJohn Marino@end defmac
9239e4b17023SJohn Marino
9240e4b17023SJohn Marino@defmac DBX_OUTPUT_RBRAC (@var{stream}, @var{name})
9241e4b17023SJohn MarinoLike @code{DBX_OUTPUT_LBRAC}, but for the end of a scope level.
9242e4b17023SJohn Marino@end defmac
9243e4b17023SJohn Marino
9244e4b17023SJohn Marino@defmac DBX_OUTPUT_NFUN (@var{stream}, @var{lscope_label}, @var{decl})
9245e4b17023SJohn MarinoDefine this macro if the target machine requires special handling to
9246e4b17023SJohn Marinooutput an @code{N_FUN} entry for the function @var{decl}.
9247e4b17023SJohn Marino@end defmac
9248e4b17023SJohn Marino
9249e4b17023SJohn Marino@defmac DBX_OUTPUT_SOURCE_LINE (@var{stream}, @var{line}, @var{counter})
9250e4b17023SJohn MarinoA C statement to output DBX debugging information before code for line
9251e4b17023SJohn Marinonumber @var{line} of the current source file to the stdio stream
9252e4b17023SJohn Marino@var{stream}.  @var{counter} is the number of time the macro was
9253e4b17023SJohn Marinoinvoked, including the current invocation; it is intended to generate
9254e4b17023SJohn Marinounique labels in the assembly output.
9255e4b17023SJohn Marino
9256e4b17023SJohn MarinoThis macro should not be defined if the default output is correct, or
9257e4b17023SJohn Marinoif it can be made correct by defining @code{DBX_LINES_FUNCTION_RELATIVE}.
9258e4b17023SJohn Marino@end defmac
9259e4b17023SJohn Marino
9260e4b17023SJohn Marino@defmac NO_DBX_FUNCTION_END
9261e4b17023SJohn MarinoSome stabs encapsulation formats (in particular ECOFF), cannot handle the
9262e4b17023SJohn Marino@code{.stabs "",N_FUN,,0,0,Lscope-function-1} gdb dbx extension construct.
9263e4b17023SJohn MarinoOn those machines, define this macro to turn this feature off without
9264e4b17023SJohn Marinodisturbing the rest of the gdb extensions.
9265e4b17023SJohn Marino@end defmac
9266e4b17023SJohn Marino
9267e4b17023SJohn Marino@defmac NO_DBX_BNSYM_ENSYM
9268e4b17023SJohn MarinoSome assemblers cannot handle the @code{.stabd BNSYM/ENSYM,0,0} gdb dbx
9269e4b17023SJohn Marinoextension construct.  On those machines, define this macro to turn this
9270e4b17023SJohn Marinofeature off without disturbing the rest of the gdb extensions.
9271e4b17023SJohn Marino@end defmac
9272e4b17023SJohn Marino
9273e4b17023SJohn Marino@node File Names and DBX
9274e4b17023SJohn Marino@subsection File Names in DBX Format
9275e4b17023SJohn Marino
9276e4b17023SJohn Marino@c prevent bad page break with this line
9277e4b17023SJohn MarinoThis describes file names in DBX format.
9278e4b17023SJohn Marino
9279e4b17023SJohn Marino@defmac DBX_OUTPUT_MAIN_SOURCE_FILENAME (@var{stream}, @var{name})
9280e4b17023SJohn MarinoA C statement to output DBX debugging information to the stdio stream
9281e4b17023SJohn Marino@var{stream}, which indicates that file @var{name} is the main source
9282e4b17023SJohn Marinofile---the file specified as the input file for compilation.
9283e4b17023SJohn MarinoThis macro is called only once, at the beginning of compilation.
9284e4b17023SJohn Marino
9285e4b17023SJohn MarinoThis macro need not be defined if the standard form of output
9286e4b17023SJohn Marinofor DBX debugging information is appropriate.
9287e4b17023SJohn Marino
9288e4b17023SJohn MarinoIt may be necessary to refer to a label equal to the beginning of the
9289e4b17023SJohn Marinotext section.  You can use @samp{assemble_name (stream, ltext_label_name)}
9290e4b17023SJohn Marinoto do so.  If you do this, you must also set the variable
9291e4b17023SJohn Marino@var{used_ltext_label_name} to @code{true}.
9292e4b17023SJohn Marino@end defmac
9293e4b17023SJohn Marino
9294e4b17023SJohn Marino@defmac NO_DBX_MAIN_SOURCE_DIRECTORY
9295e4b17023SJohn MarinoDefine this macro, with value 1, if GCC should not emit an indication
9296e4b17023SJohn Marinoof the current directory for compilation and current source language at
9297e4b17023SJohn Marinothe beginning of the file.
9298e4b17023SJohn Marino@end defmac
9299e4b17023SJohn Marino
9300e4b17023SJohn Marino@defmac NO_DBX_GCC_MARKER
9301e4b17023SJohn MarinoDefine this macro, with value 1, if GCC should not emit an indication
9302e4b17023SJohn Marinothat this object file was compiled by GCC@.  The default is to emit
9303e4b17023SJohn Marinoan @code{N_OPT} stab at the beginning of every source file, with
9304e4b17023SJohn Marino@samp{gcc2_compiled.} for the string and value 0.
9305e4b17023SJohn Marino@end defmac
9306e4b17023SJohn Marino
9307e4b17023SJohn Marino@defmac DBX_OUTPUT_MAIN_SOURCE_FILE_END (@var{stream}, @var{name})
9308e4b17023SJohn MarinoA C statement to output DBX debugging information at the end of
9309e4b17023SJohn Marinocompilation of the main source file @var{name}.  Output should be
9310e4b17023SJohn Marinowritten to the stdio stream @var{stream}.
9311e4b17023SJohn Marino
9312e4b17023SJohn MarinoIf you don't define this macro, nothing special is output at the end
9313e4b17023SJohn Marinoof compilation, which is correct for most machines.
9314e4b17023SJohn Marino@end defmac
9315e4b17023SJohn Marino
9316e4b17023SJohn Marino@defmac DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
9317e4b17023SJohn MarinoDefine this macro @emph{instead of} defining
9318e4b17023SJohn Marino@code{DBX_OUTPUT_MAIN_SOURCE_FILE_END}, if what needs to be output at
9319e4b17023SJohn Marinothe end of compilation is an @code{N_SO} stab with an empty string,
9320e4b17023SJohn Marinowhose value is the highest absolute text address in the file.
9321e4b17023SJohn Marino@end defmac
9322e4b17023SJohn Marino
9323e4b17023SJohn Marino@need 2000
9324e4b17023SJohn Marino@node SDB and DWARF
9325e4b17023SJohn Marino@subsection Macros for SDB and DWARF Output
9326e4b17023SJohn Marino
9327e4b17023SJohn Marino@c prevent bad page break with this line
9328e4b17023SJohn MarinoHere are macros for SDB and DWARF output.
9329e4b17023SJohn Marino
9330e4b17023SJohn Marino@defmac SDB_DEBUGGING_INFO
9331e4b17023SJohn MarinoDefine this macro if GCC should produce COFF-style debugging output
9332e4b17023SJohn Marinofor SDB in response to the @option{-g} option.
9333e4b17023SJohn Marino@end defmac
9334e4b17023SJohn Marino
9335e4b17023SJohn Marino@defmac DWARF2_DEBUGGING_INFO
9336e4b17023SJohn MarinoDefine this macro if GCC should produce dwarf version 2 format
9337e4b17023SJohn Marinodebugging output in response to the @option{-g} option.
9338e4b17023SJohn Marino
9339e4b17023SJohn Marino@hook TARGET_DWARF_CALLING_CONVENTION
9340e4b17023SJohn MarinoDefine this to enable the dwarf attribute @code{DW_AT_calling_convention} to
9341e4b17023SJohn Marinobe emitted for each function.  Instead of an integer return the enum
9342e4b17023SJohn Marinovalue for the @code{DW_CC_} tag.
9343e4b17023SJohn Marino@end deftypefn
9344e4b17023SJohn Marino
9345e4b17023SJohn MarinoTo support optional call frame debugging information, you must also
9346e4b17023SJohn Marinodefine @code{INCOMING_RETURN_ADDR_RTX} and either set
9347e4b17023SJohn Marino@code{RTX_FRAME_RELATED_P} on the prologue insns if you use RTL for the
9348e4b17023SJohn Marinoprologue, or call @code{dwarf2out_def_cfa} and @code{dwarf2out_reg_save}
9349e4b17023SJohn Marinoas appropriate from @code{TARGET_ASM_FUNCTION_PROLOGUE} if you don't.
9350e4b17023SJohn Marino@end defmac
9351e4b17023SJohn Marino
9352e4b17023SJohn Marino@defmac DWARF2_FRAME_INFO
9353e4b17023SJohn MarinoDefine this macro to a nonzero value if GCC should always output
9354e4b17023SJohn MarinoDwarf 2 frame information.  If @code{TARGET_EXCEPT_UNWIND_INFO}
9355e4b17023SJohn Marino(@pxref{Exception Region Output}) returns @code{UI_DWARF2}, and
9356e4b17023SJohn Marinoexceptions are enabled, GCC will output this information not matter
9357e4b17023SJohn Marinohow you define @code{DWARF2_FRAME_INFO}.
9358e4b17023SJohn Marino@end defmac
9359e4b17023SJohn Marino
9360e4b17023SJohn Marino@hook TARGET_DEBUG_UNWIND_INFO
9361e4b17023SJohn MarinoThis hook defines the mechanism that will be used for describing frame
9362e4b17023SJohn Marinounwind information to the debugger.  Normally the hook will return
9363e4b17023SJohn Marino@code{UI_DWARF2} if DWARF 2 debug information is enabled, and
9364e4b17023SJohn Marinoreturn @code{UI_NONE} otherwise.
9365e4b17023SJohn Marino
9366e4b17023SJohn MarinoA target may return @code{UI_DWARF2} even when DWARF 2 debug information
9367e4b17023SJohn Marinois disabled in order to always output DWARF 2 frame information.
9368e4b17023SJohn Marino
9369e4b17023SJohn MarinoA target may return @code{UI_TARGET} if it has ABI specified unwind tables.
9370e4b17023SJohn MarinoThis will suppress generation of the normal debug frame unwind information.
9371e4b17023SJohn Marino@end deftypefn
9372e4b17023SJohn Marino
9373e4b17023SJohn Marino@defmac DWARF2_ASM_LINE_DEBUG_INFO
9374e4b17023SJohn MarinoDefine this macro to be a nonzero value if the assembler can generate Dwarf 2
9375e4b17023SJohn Marinoline debug info sections.  This will result in much more compact line number
9376e4b17023SJohn Marinotables, and hence is desirable if it works.
9377e4b17023SJohn Marino@end defmac
9378e4b17023SJohn Marino
9379e4b17023SJohn Marino@hook TARGET_WANT_DEBUG_PUB_SECTIONS
9380e4b17023SJohn Marino
9381*95d28233SJohn Marino@hook TARGET_FORCE_AT_COMP_DIR
9382*95d28233SJohn Marino
9383e4b17023SJohn Marino@hook TARGET_DELAY_SCHED2
9384e4b17023SJohn Marino
9385e4b17023SJohn Marino@hook TARGET_DELAY_VARTRACK
9386e4b17023SJohn Marino
9387e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
9388e4b17023SJohn MarinoA C statement to issue assembly directives that create a difference
9389e4b17023SJohn Marino@var{lab1} minus @var{lab2}, using an integer of the given @var{size}.
9390e4b17023SJohn Marino@end defmac
9391e4b17023SJohn Marino
9392e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_VMS_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
9393e4b17023SJohn MarinoA C statement to issue assembly directives that create a difference
9394e4b17023SJohn Marinobetween the two given labels in system defined units, e.g. instruction
9395e4b17023SJohn Marinoslots on IA64 VMS, using an integer of the given size.
9396e4b17023SJohn Marino@end defmac
9397e4b17023SJohn Marino
9398e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, @var{section})
9399e4b17023SJohn MarinoA C statement to issue assembly directives that create a
9400e4b17023SJohn Marinosection-relative reference to the given @var{label}, using an integer of the
9401e4b17023SJohn Marinogiven @var{size}.  The label is known to be defined in the given @var{section}.
9402e4b17023SJohn Marino@end defmac
9403e4b17023SJohn Marino
9404e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_PCREL (@var{stream}, @var{size}, @var{label})
9405e4b17023SJohn MarinoA C statement to issue assembly directives that create a self-relative
9406e4b17023SJohn Marinoreference to the given @var{label}, using an integer of the given @var{size}.
9407e4b17023SJohn Marino@end defmac
9408e4b17023SJohn Marino
9409e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_TABLE_REF (@var{label})
9410e4b17023SJohn MarinoA C statement to issue assembly directives that create a reference to
9411e4b17023SJohn Marinothe DWARF table identifier @var{label} from the current section.  This
9412e4b17023SJohn Marinois used on some systems to avoid garbage collecting a DWARF table which
9413e4b17023SJohn Marinois referenced by a function.
9414e4b17023SJohn Marino@end defmac
9415e4b17023SJohn Marino
9416e4b17023SJohn Marino@hook TARGET_ASM_OUTPUT_DWARF_DTPREL
9417e4b17023SJohn MarinoIf defined, this target hook is a function which outputs a DTP-relative
9418e4b17023SJohn Marinoreference to the given TLS symbol of the specified size.
9419e4b17023SJohn Marino@end deftypefn
9420e4b17023SJohn Marino
9421e4b17023SJohn Marino@defmac PUT_SDB_@dots{}
9422e4b17023SJohn MarinoDefine these macros to override the assembler syntax for the special
9423e4b17023SJohn MarinoSDB assembler directives.  See @file{sdbout.c} for a list of these
9424e4b17023SJohn Marinomacros and their arguments.  If the standard syntax is used, you need
9425e4b17023SJohn Marinonot define them yourself.
9426e4b17023SJohn Marino@end defmac
9427e4b17023SJohn Marino
9428e4b17023SJohn Marino@defmac SDB_DELIM
9429e4b17023SJohn MarinoSome assemblers do not support a semicolon as a delimiter, even between
9430e4b17023SJohn MarinoSDB assembler directives.  In that case, define this macro to be the
9431e4b17023SJohn Marinodelimiter to use (usually @samp{\n}).  It is not necessary to define
9432e4b17023SJohn Marinoa new set of @code{PUT_SDB_@var{op}} macros if this is the only change
9433e4b17023SJohn Marinorequired.
9434e4b17023SJohn Marino@end defmac
9435e4b17023SJohn Marino
9436e4b17023SJohn Marino@defmac SDB_ALLOW_UNKNOWN_REFERENCES
9437e4b17023SJohn MarinoDefine this macro to allow references to unknown structure,
9438e4b17023SJohn Marinounion, or enumeration tags to be emitted.  Standard COFF does not
9439e4b17023SJohn Marinoallow handling of unknown references, MIPS ECOFF has support for
9440e4b17023SJohn Marinoit.
9441e4b17023SJohn Marino@end defmac
9442e4b17023SJohn Marino
9443e4b17023SJohn Marino@defmac SDB_ALLOW_FORWARD_REFERENCES
9444e4b17023SJohn MarinoDefine this macro to allow references to structure, union, or
9445e4b17023SJohn Marinoenumeration tags that have not yet been seen to be handled.  Some
9446e4b17023SJohn Marinoassemblers choke if forward tags are used, while some require it.
9447e4b17023SJohn Marino@end defmac
9448e4b17023SJohn Marino
9449e4b17023SJohn Marino@defmac SDB_OUTPUT_SOURCE_LINE (@var{stream}, @var{line})
9450e4b17023SJohn MarinoA C statement to output SDB debugging information before code for line
9451e4b17023SJohn Marinonumber @var{line} of the current source file to the stdio stream
9452e4b17023SJohn Marino@var{stream}.  The default is to emit an @code{.ln} directive.
9453e4b17023SJohn Marino@end defmac
9454e4b17023SJohn Marino
9455e4b17023SJohn Marino@need 2000
9456e4b17023SJohn Marino@node VMS Debug
9457e4b17023SJohn Marino@subsection Macros for VMS Debug Format
9458e4b17023SJohn Marino
9459e4b17023SJohn Marino@c prevent bad page break with this line
9460e4b17023SJohn MarinoHere are macros for VMS debug format.
9461e4b17023SJohn Marino
9462e4b17023SJohn Marino@defmac VMS_DEBUGGING_INFO
9463e4b17023SJohn MarinoDefine this macro if GCC should produce debugging output for VMS
9464e4b17023SJohn Marinoin response to the @option{-g} option.  The default behavior for VMS
9465e4b17023SJohn Marinois to generate minimal debug info for a traceback in the absence of
9466e4b17023SJohn Marino@option{-g} unless explicitly overridden with @option{-g0}.  This
9467e4b17023SJohn Marinobehavior is controlled by @code{TARGET_OPTION_OPTIMIZATION} and
9468e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE}.
9469e4b17023SJohn Marino@end defmac
9470e4b17023SJohn Marino
9471e4b17023SJohn Marino@node Floating Point
9472e4b17023SJohn Marino@section Cross Compilation and Floating Point
9473e4b17023SJohn Marino@cindex cross compilation and floating point
9474e4b17023SJohn Marino@cindex floating point and cross compilation
9475e4b17023SJohn Marino
9476e4b17023SJohn MarinoWhile all modern machines use twos-complement representation for integers,
9477e4b17023SJohn Marinothere are a variety of representations for floating point numbers.  This
9478e4b17023SJohn Marinomeans that in a cross-compiler the representation of floating point numbers
9479e4b17023SJohn Marinoin the compiled program may be different from that used in the machine
9480e4b17023SJohn Marinodoing the compilation.
9481e4b17023SJohn Marino
9482e4b17023SJohn MarinoBecause different representation systems may offer different amounts of
9483e4b17023SJohn Marinorange and precision, all floating point constants must be represented in
9484e4b17023SJohn Marinothe target machine's format.  Therefore, the cross compiler cannot
9485e4b17023SJohn Marinosafely use the host machine's floating point arithmetic; it must emulate
9486e4b17023SJohn Marinothe target's arithmetic.  To ensure consistency, GCC always uses
9487e4b17023SJohn Marinoemulation to work with floating point values, even when the host and
9488e4b17023SJohn Marinotarget floating point formats are identical.
9489e4b17023SJohn Marino
9490e4b17023SJohn MarinoThe following macros are provided by @file{real.h} for the compiler to
9491e4b17023SJohn Marinouse.  All parts of the compiler which generate or optimize
9492e4b17023SJohn Marinofloating-point calculations must use these macros.  They may evaluate
9493e4b17023SJohn Marinotheir operands more than once, so operands must not have side effects.
9494e4b17023SJohn Marino
9495e4b17023SJohn Marino@defmac REAL_VALUE_TYPE
9496e4b17023SJohn MarinoThe C data type to be used to hold a floating point value in the target
9497e4b17023SJohn Marinomachine's format.  Typically this is a @code{struct} containing an
9498e4b17023SJohn Marinoarray of @code{HOST_WIDE_INT}, but all code should treat it as an opaque
9499e4b17023SJohn Marinoquantity.
9500e4b17023SJohn Marino@end defmac
9501e4b17023SJohn Marino
9502e4b17023SJohn Marino@deftypefn Macro int REAL_VALUES_EQUAL (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y})
9503e4b17023SJohn MarinoCompares for equality the two values, @var{x} and @var{y}.  If the target
9504e4b17023SJohn Marinofloating point format supports negative zeroes and/or NaNs,
9505e4b17023SJohn Marino@samp{REAL_VALUES_EQUAL (-0.0, 0.0)} is true, and
9506e4b17023SJohn Marino@samp{REAL_VALUES_EQUAL (NaN, NaN)} is false.
9507e4b17023SJohn Marino@end deftypefn
9508e4b17023SJohn Marino
9509e4b17023SJohn Marino@deftypefn Macro int REAL_VALUES_LESS (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y})
9510e4b17023SJohn MarinoTests whether @var{x} is less than @var{y}.
9511e4b17023SJohn Marino@end deftypefn
9512e4b17023SJohn Marino
9513e4b17023SJohn Marino@deftypefn Macro HOST_WIDE_INT REAL_VALUE_FIX (REAL_VALUE_TYPE @var{x})
9514e4b17023SJohn MarinoTruncates @var{x} to a signed integer, rounding toward zero.
9515e4b17023SJohn Marino@end deftypefn
9516e4b17023SJohn Marino
9517e4b17023SJohn Marino@deftypefn Macro {unsigned HOST_WIDE_INT} REAL_VALUE_UNSIGNED_FIX (REAL_VALUE_TYPE @var{x})
9518e4b17023SJohn MarinoTruncates @var{x} to an unsigned integer, rounding toward zero.  If
9519e4b17023SJohn Marino@var{x} is negative, returns zero.
9520e4b17023SJohn Marino@end deftypefn
9521e4b17023SJohn Marino
9522e4b17023SJohn Marino@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ATOF (const char *@var{string}, enum machine_mode @var{mode})
9523e4b17023SJohn MarinoConverts @var{string} into a floating point number in the target machine's
9524e4b17023SJohn Marinorepresentation for mode @var{mode}.  This routine can handle both
9525e4b17023SJohn Marinodecimal and hexadecimal floating point constants, using the syntax
9526e4b17023SJohn Marinodefined by the C language for both.
9527e4b17023SJohn Marino@end deftypefn
9528e4b17023SJohn Marino
9529e4b17023SJohn Marino@deftypefn Macro int REAL_VALUE_NEGATIVE (REAL_VALUE_TYPE @var{x})
9530e4b17023SJohn MarinoReturns 1 if @var{x} is negative (including negative zero), 0 otherwise.
9531e4b17023SJohn Marino@end deftypefn
9532e4b17023SJohn Marino
9533e4b17023SJohn Marino@deftypefn Macro int REAL_VALUE_ISINF (REAL_VALUE_TYPE @var{x})
9534e4b17023SJohn MarinoDetermines whether @var{x} represents infinity (positive or negative).
9535e4b17023SJohn Marino@end deftypefn
9536e4b17023SJohn Marino
9537e4b17023SJohn Marino@deftypefn Macro int REAL_VALUE_ISNAN (REAL_VALUE_TYPE @var{x})
9538e4b17023SJohn MarinoDetermines whether @var{x} represents a ``NaN'' (not-a-number).
9539e4b17023SJohn Marino@end deftypefn
9540e4b17023SJohn Marino
9541e4b17023SJohn Marino@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})
9542e4b17023SJohn MarinoCalculates an arithmetic operation on the two floating point values
9543e4b17023SJohn Marino@var{x} and @var{y}, storing the result in @var{output} (which must be a
9544e4b17023SJohn Marinovariable).
9545e4b17023SJohn Marino
9546e4b17023SJohn MarinoThe operation to be performed is specified by @var{code}.  Only the
9547e4b17023SJohn Marinofollowing codes are supported: @code{PLUS_EXPR}, @code{MINUS_EXPR},
9548e4b17023SJohn Marino@code{MULT_EXPR}, @code{RDIV_EXPR}, @code{MAX_EXPR}, @code{MIN_EXPR}.
9549e4b17023SJohn Marino
9550e4b17023SJohn MarinoIf @code{REAL_ARITHMETIC} is asked to evaluate division by zero and the
9551e4b17023SJohn Marinotarget's floating point format cannot represent infinity, it will call
9552e4b17023SJohn Marino@code{abort}.  Callers should check for this situation first, using
9553e4b17023SJohn Marino@code{MODE_HAS_INFINITIES}.  @xref{Storage Layout}.
9554e4b17023SJohn Marino@end deftypefn
9555e4b17023SJohn Marino
9556e4b17023SJohn Marino@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_NEGATE (REAL_VALUE_TYPE @var{x})
9557e4b17023SJohn MarinoReturns the negative of the floating point value @var{x}.
9558e4b17023SJohn Marino@end deftypefn
9559e4b17023SJohn Marino
9560e4b17023SJohn Marino@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ABS (REAL_VALUE_TYPE @var{x})
9561e4b17023SJohn MarinoReturns the absolute value of @var{x}.
9562e4b17023SJohn Marino@end deftypefn
9563e4b17023SJohn Marino
9564e4b17023SJohn Marino@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_TRUNCATE (REAL_VALUE_TYPE @var{mode}, enum machine_mode @var{x})
9565e4b17023SJohn MarinoTruncates the floating point value @var{x} to fit in @var{mode}.  The
9566e4b17023SJohn Marinoreturn value is still a full-size @code{REAL_VALUE_TYPE}, but it has an
9567e4b17023SJohn Marinoappropriate bit pattern to be output as a floating constant whose
9568e4b17023SJohn Marinoprecision accords with mode @var{mode}.
9569e4b17023SJohn Marino@end deftypefn
9570e4b17023SJohn Marino
9571e4b17023SJohn Marino@deftypefn Macro void REAL_VALUE_TO_INT (HOST_WIDE_INT @var{low}, HOST_WIDE_INT @var{high}, REAL_VALUE_TYPE @var{x})
9572e4b17023SJohn MarinoConverts a floating point value @var{x} into a double-precision integer
9573e4b17023SJohn Marinowhich is then stored into @var{low} and @var{high}.  If the value is not
9574e4b17023SJohn Marinointegral, it is truncated.
9575e4b17023SJohn Marino@end deftypefn
9576e4b17023SJohn Marino
9577e4b17023SJohn Marino@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})
9578e4b17023SJohn MarinoConverts a double-precision integer found in @var{low} and @var{high},
9579e4b17023SJohn Marinointo a floating point value which is then stored into @var{x}.  The
9580e4b17023SJohn Marinovalue is truncated to fit in mode @var{mode}.
9581e4b17023SJohn Marino@end deftypefn
9582e4b17023SJohn Marino
9583e4b17023SJohn Marino@node Mode Switching
9584e4b17023SJohn Marino@section Mode Switching Instructions
9585e4b17023SJohn Marino@cindex mode switching
9586e4b17023SJohn MarinoThe following macros control mode switching optimizations:
9587e4b17023SJohn Marino
9588e4b17023SJohn Marino@defmac OPTIMIZE_MODE_SWITCHING (@var{entity})
9589e4b17023SJohn MarinoDefine this macro if the port needs extra instructions inserted for mode
9590e4b17023SJohn Marinoswitching in an optimizing compilation.
9591e4b17023SJohn Marino
9592e4b17023SJohn MarinoFor an example, the SH4 can perform both single and double precision
9593e4b17023SJohn Marinofloating point operations, but to perform a single precision operation,
9594e4b17023SJohn Marinothe FPSCR PR bit has to be cleared, while for a double precision
9595e4b17023SJohn Marinooperation, this bit has to be set.  Changing the PR bit requires a general
9596e4b17023SJohn Marinopurpose register as a scratch register, hence these FPSCR sets have to
9597e4b17023SJohn Marinobe inserted before reload, i.e.@: you can't put this into instruction emitting
9598e4b17023SJohn Marinoor @code{TARGET_MACHINE_DEPENDENT_REORG}.
9599e4b17023SJohn Marino
9600e4b17023SJohn MarinoYou can have multiple entities that are mode-switched, and select at run time
9601e4b17023SJohn Marinowhich entities actually need it.  @code{OPTIMIZE_MODE_SWITCHING} should
9602e4b17023SJohn Marinoreturn nonzero for any @var{entity} that needs mode-switching.
9603e4b17023SJohn MarinoIf you define this macro, you also have to define
9604e4b17023SJohn Marino@code{NUM_MODES_FOR_MODE_SWITCHING}, @code{MODE_NEEDED},
9605e4b17023SJohn Marino@code{MODE_PRIORITY_TO_MODE} and @code{EMIT_MODE_SET}.
9606e4b17023SJohn Marino@code{MODE_AFTER}, @code{MODE_ENTRY}, and @code{MODE_EXIT}
9607e4b17023SJohn Marinoare optional.
9608e4b17023SJohn Marino@end defmac
9609e4b17023SJohn Marino
9610e4b17023SJohn Marino@defmac NUM_MODES_FOR_MODE_SWITCHING
9611e4b17023SJohn MarinoIf you define @code{OPTIMIZE_MODE_SWITCHING}, you have to define this as
9612e4b17023SJohn Marinoinitializer for an array of integers.  Each initializer element
9613e4b17023SJohn MarinoN refers to an entity that needs mode switching, and specifies the number
9614e4b17023SJohn Marinoof different modes that might need to be set for this entity.
9615e4b17023SJohn MarinoThe position of the initializer in the initializer---starting counting at
9616e4b17023SJohn Marinozero---determines the integer that is used to refer to the mode-switched
9617e4b17023SJohn Marinoentity in question.
9618e4b17023SJohn MarinoIn macros that take mode arguments / yield a mode result, modes are
9619e4b17023SJohn Marinorepresented as numbers 0 @dots{} N @minus{} 1.  N is used to specify that no mode
9620e4b17023SJohn Marinoswitch is needed / supplied.
9621e4b17023SJohn Marino@end defmac
9622e4b17023SJohn Marino
9623e4b17023SJohn Marino@defmac MODE_NEEDED (@var{entity}, @var{insn})
9624e4b17023SJohn Marino@var{entity} is an integer specifying a mode-switched entity.  If
9625e4b17023SJohn Marino@code{OPTIMIZE_MODE_SWITCHING} is defined, you must define this macro to
9626e4b17023SJohn Marinoreturn an integer value not larger than the corresponding element in
9627e4b17023SJohn Marino@code{NUM_MODES_FOR_MODE_SWITCHING}, to denote the mode that @var{entity} must
9628e4b17023SJohn Marinobe switched into prior to the execution of @var{insn}.
9629e4b17023SJohn Marino@end defmac
9630e4b17023SJohn Marino
9631e4b17023SJohn Marino@defmac MODE_AFTER (@var{mode}, @var{insn})
9632e4b17023SJohn MarinoIf this macro is defined, it is evaluated for every @var{insn} during
9633e4b17023SJohn Marinomode switching.  It determines the mode that an insn results in (if
9634e4b17023SJohn Marinodifferent from the incoming mode).
9635e4b17023SJohn Marino@end defmac
9636e4b17023SJohn Marino
9637e4b17023SJohn Marino@defmac MODE_ENTRY (@var{entity})
9638e4b17023SJohn MarinoIf this macro is defined, it is evaluated for every @var{entity} that needs
9639e4b17023SJohn Marinomode switching.  It should evaluate to an integer, which is a mode that
9640e4b17023SJohn Marino@var{entity} is assumed to be switched to at function entry.  If @code{MODE_ENTRY}
9641e4b17023SJohn Marinois defined then @code{MODE_EXIT} must be defined.
9642e4b17023SJohn Marino@end defmac
9643e4b17023SJohn Marino
9644e4b17023SJohn Marino@defmac MODE_EXIT (@var{entity})
9645e4b17023SJohn MarinoIf this macro is defined, it is evaluated for every @var{entity} that needs
9646e4b17023SJohn Marinomode switching.  It should evaluate to an integer, which is a mode that
9647e4b17023SJohn Marino@var{entity} is assumed to be switched to at function exit.  If @code{MODE_EXIT}
9648e4b17023SJohn Marinois defined then @code{MODE_ENTRY} must be defined.
9649e4b17023SJohn Marino@end defmac
9650e4b17023SJohn Marino
9651e4b17023SJohn Marino@defmac MODE_PRIORITY_TO_MODE (@var{entity}, @var{n})
9652e4b17023SJohn MarinoThis macro specifies the order in which modes for @var{entity} are processed.
9653e4b17023SJohn Marino0 is the highest priority, @code{NUM_MODES_FOR_MODE_SWITCHING[@var{entity}] - 1} the
9654e4b17023SJohn Marinolowest.  The value of the macro should be an integer designating a mode
9655e4b17023SJohn Marinofor @var{entity}.  For any fixed @var{entity}, @code{mode_priority_to_mode}
9656e4b17023SJohn Marino(@var{entity}, @var{n}) shall be a bijection in 0 @dots{}
9657e4b17023SJohn Marino@code{num_modes_for_mode_switching[@var{entity}] - 1}.
9658e4b17023SJohn Marino@end defmac
9659e4b17023SJohn Marino
9660e4b17023SJohn Marino@defmac EMIT_MODE_SET (@var{entity}, @var{mode}, @var{hard_regs_live})
9661e4b17023SJohn MarinoGenerate one or more insns to set @var{entity} to @var{mode}.
9662e4b17023SJohn Marino@var{hard_reg_live} is the set of hard registers live at the point where
9663e4b17023SJohn Marinothe insn(s) are to be inserted.
9664e4b17023SJohn Marino@end defmac
9665e4b17023SJohn Marino
9666e4b17023SJohn Marino@node Target Attributes
9667e4b17023SJohn Marino@section Defining target-specific uses of @code{__attribute__}
9668e4b17023SJohn Marino@cindex target attributes
9669e4b17023SJohn Marino@cindex machine attributes
9670e4b17023SJohn Marino@cindex attributes, target-specific
9671e4b17023SJohn Marino
9672e4b17023SJohn MarinoTarget-specific attributes may be defined for functions, data and types.
9673e4b17023SJohn MarinoThese are described using the following target hooks; they also need to
9674e4b17023SJohn Marinobe documented in @file{extend.texi}.
9675e4b17023SJohn Marino
9676e4b17023SJohn Marino@hook TARGET_ATTRIBUTE_TABLE
9677e4b17023SJohn MarinoIf defined, this target hook points to an array of @samp{struct
9678e4b17023SJohn Marinoattribute_spec} (defined in @file{tree.h}) specifying the machine
9679e4b17023SJohn Marinospecific attributes for this target and some of the restrictions on the
9680e4b17023SJohn Marinoentities to which these attributes are applied and the arguments they
9681e4b17023SJohn Marinotake.
9682e4b17023SJohn Marino@end deftypevr
9683e4b17023SJohn Marino
9684e4b17023SJohn Marino@hook TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
9685e4b17023SJohn MarinoIf defined, this target hook is a function which returns true if the
9686e4b17023SJohn Marinomachine-specific attribute named @var{name} expects an identifier
9687e4b17023SJohn Marinogiven as its first argument to be passed on as a plain identifier, not
9688e4b17023SJohn Marinosubjected to name lookup.  If this is not defined, the default is
9689e4b17023SJohn Marinofalse for all machine-specific attributes.
9690e4b17023SJohn Marino@end deftypefn
9691e4b17023SJohn Marino
9692e4b17023SJohn Marino@hook TARGET_COMP_TYPE_ATTRIBUTES
9693e4b17023SJohn MarinoIf defined, this target hook is a function which returns zero if the attributes on
9694e4b17023SJohn Marino@var{type1} and @var{type2} are incompatible, one if they are compatible,
9695e4b17023SJohn Marinoand two if they are nearly compatible (which causes a warning to be
9696e4b17023SJohn Marinogenerated).  If this is not defined, machine-specific attributes are
9697e4b17023SJohn Marinosupposed always to be compatible.
9698e4b17023SJohn Marino@end deftypefn
9699e4b17023SJohn Marino
9700e4b17023SJohn Marino@hook TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
9701e4b17023SJohn MarinoIf defined, this target hook is a function which assigns default attributes to
9702e4b17023SJohn Marinothe newly defined @var{type}.
9703e4b17023SJohn Marino@end deftypefn
9704e4b17023SJohn Marino
9705e4b17023SJohn Marino@hook TARGET_MERGE_TYPE_ATTRIBUTES
9706e4b17023SJohn MarinoDefine this target hook if the merging of type attributes needs special
9707e4b17023SJohn Marinohandling.  If defined, the result is a list of the combined
9708e4b17023SJohn Marino@code{TYPE_ATTRIBUTES} of @var{type1} and @var{type2}.  It is assumed
9709e4b17023SJohn Marinothat @code{comptypes} has already been called and returned 1.  This
9710e4b17023SJohn Marinofunction may call @code{merge_attributes} to handle machine-independent
9711e4b17023SJohn Marinomerging.
9712e4b17023SJohn Marino@end deftypefn
9713e4b17023SJohn Marino
9714e4b17023SJohn Marino@hook TARGET_MERGE_DECL_ATTRIBUTES
9715e4b17023SJohn MarinoDefine this target hook if the merging of decl attributes needs special
9716e4b17023SJohn Marinohandling.  If defined, the result is a list of the combined
9717e4b17023SJohn Marino@code{DECL_ATTRIBUTES} of @var{olddecl} and @var{newdecl}.
9718e4b17023SJohn Marino@var{newdecl} is a duplicate declaration of @var{olddecl}.  Examples of
9719e4b17023SJohn Marinowhen this is needed are when one attribute overrides another, or when an
9720e4b17023SJohn Marinoattribute is nullified by a subsequent definition.  This function may
9721e4b17023SJohn Marinocall @code{merge_attributes} to handle machine-independent merging.
9722e4b17023SJohn Marino
9723e4b17023SJohn Marino@findex TARGET_DLLIMPORT_DECL_ATTRIBUTES
9724e4b17023SJohn MarinoIf the only target-specific handling you require is @samp{dllimport}
9725e4b17023SJohn Marinofor Microsoft Windows targets, you should define the macro
9726e4b17023SJohn Marino@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES} to @code{1}.  The compiler
9727e4b17023SJohn Marinowill then define a function called
9728e4b17023SJohn Marino@code{merge_dllimport_decl_attributes} which can then be defined as
9729e4b17023SJohn Marinothe expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}.  You can also
9730e4b17023SJohn Marinoadd @code{handle_dll_attribute} in the attribute table for your port
9731e4b17023SJohn Marinoto perform initial processing of the @samp{dllimport} and
9732e4b17023SJohn Marino@samp{dllexport} attributes.  This is done in @file{i386/cygwin.h} and
9733e4b17023SJohn Marino@file{i386/i386.c}, for example.
9734e4b17023SJohn Marino@end deftypefn
9735e4b17023SJohn Marino
9736e4b17023SJohn Marino@hook TARGET_VALID_DLLIMPORT_ATTRIBUTE_P
9737e4b17023SJohn Marino
9738e4b17023SJohn Marino@defmac TARGET_DECLSPEC
9739e4b17023SJohn MarinoDefine this macro to a nonzero value if you want to treat
9740e4b17023SJohn Marino@code{__declspec(X)} as equivalent to @code{__attribute((X))}.  By
9741e4b17023SJohn Marinodefault, this behavior is enabled only for targets that define
9742e4b17023SJohn Marino@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES}.  The current implementation
9743e4b17023SJohn Marinoof @code{__declspec} is via a built-in macro, but you should not rely
9744e4b17023SJohn Marinoon this implementation detail.
9745e4b17023SJohn Marino@end defmac
9746e4b17023SJohn Marino
9747e4b17023SJohn Marino@hook TARGET_INSERT_ATTRIBUTES
9748e4b17023SJohn MarinoDefine this target hook if you want to be able to add attributes to a decl
9749e4b17023SJohn Marinowhen it is being created.  This is normally useful for back ends which
9750e4b17023SJohn Marinowish to implement a pragma by using the attributes which correspond to
9751e4b17023SJohn Marinothe pragma's effect.  The @var{node} argument is the decl which is being
9752e4b17023SJohn Marinocreated.  The @var{attr_ptr} argument is a pointer to the attribute list
9753e4b17023SJohn Marinofor this decl.  The list itself should not be modified, since it may be
9754e4b17023SJohn Marinoshared with other decls, but attributes may be chained on the head of
9755e4b17023SJohn Marinothe list and @code{*@var{attr_ptr}} modified to point to the new
9756e4b17023SJohn Marinoattributes, or a copy of the list may be made if further changes are
9757e4b17023SJohn Marinoneeded.
9758e4b17023SJohn Marino@end deftypefn
9759e4b17023SJohn Marino
9760e4b17023SJohn Marino@hook TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P
9761e4b17023SJohn Marino@cindex inlining
9762e4b17023SJohn MarinoThis target hook returns @code{true} if it is ok to inline @var{fndecl}
9763e4b17023SJohn Marinointo the current function, despite its having target-specific
9764e4b17023SJohn Marinoattributes, @code{false} otherwise.  By default, if a function has a
9765e4b17023SJohn Marinotarget specific attribute attached to it, it will not be inlined.
9766e4b17023SJohn Marino@end deftypefn
9767e4b17023SJohn Marino
9768e4b17023SJohn Marino@hook TARGET_OPTION_VALID_ATTRIBUTE_P
9769e4b17023SJohn MarinoThis hook is called to parse the @code{attribute(option("..."))}, and
9770e4b17023SJohn Marinoit allows the function to set different target machine compile time
9771e4b17023SJohn Marinooptions for the current function that might be different than the
9772e4b17023SJohn Marinooptions specified on the command line.  The hook should return
9773e4b17023SJohn Marino@code{true} if the options are valid.
9774e4b17023SJohn Marino
9775e4b17023SJohn MarinoThe hook should set the @var{DECL_FUNCTION_SPECIFIC_TARGET} field in
9776e4b17023SJohn Marinothe function declaration to hold a pointer to a target specific
9777e4b17023SJohn Marino@var{struct cl_target_option} structure.
9778e4b17023SJohn Marino@end deftypefn
9779e4b17023SJohn Marino
9780e4b17023SJohn Marino@hook TARGET_OPTION_SAVE
9781e4b17023SJohn MarinoThis hook is called to save any additional target specific information
9782e4b17023SJohn Marinoin the @var{struct cl_target_option} structure for function specific
9783e4b17023SJohn Marinooptions.
9784e4b17023SJohn Marino@xref{Option file format}.
9785e4b17023SJohn Marino@end deftypefn
9786e4b17023SJohn Marino
9787e4b17023SJohn Marino@hook TARGET_OPTION_RESTORE
9788e4b17023SJohn MarinoThis hook is called to restore any additional target specific
9789e4b17023SJohn Marinoinformation in the @var{struct cl_target_option} structure for
9790e4b17023SJohn Marinofunction specific options.
9791e4b17023SJohn Marino@end deftypefn
9792e4b17023SJohn Marino
9793e4b17023SJohn Marino@hook TARGET_OPTION_PRINT
9794e4b17023SJohn MarinoThis hook is called to print any additional target specific
9795e4b17023SJohn Marinoinformation in the @var{struct cl_target_option} structure for
9796e4b17023SJohn Marinofunction specific options.
9797e4b17023SJohn Marino@end deftypefn
9798e4b17023SJohn Marino
9799e4b17023SJohn Marino@hook TARGET_OPTION_PRAGMA_PARSE
9800e4b17023SJohn MarinoThis target hook parses the options for @code{#pragma GCC option} to
9801e4b17023SJohn Marinoset the machine specific options for functions that occur later in the
9802e4b17023SJohn Marinoinput stream.  The options should be the same as handled by the
9803e4b17023SJohn Marino@code{TARGET_OPTION_VALID_ATTRIBUTE_P} hook.
9804e4b17023SJohn Marino@end deftypefn
9805e4b17023SJohn Marino
9806e4b17023SJohn Marino@hook TARGET_OPTION_OVERRIDE
9807e4b17023SJohn MarinoSometimes certain combinations of command options do not make sense on
9808e4b17023SJohn Marinoa particular target machine.  You can override the hook
9809e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE} to take account of this.  This hooks is called
9810e4b17023SJohn Marinoonce just after all the command options have been parsed.
9811e4b17023SJohn Marino
9812e4b17023SJohn MarinoDon't use this hook to turn on various extra optimizations for
9813e4b17023SJohn Marino@option{-O}.  That is what @code{TARGET_OPTION_OPTIMIZATION} is for.
9814e4b17023SJohn Marino
9815e4b17023SJohn MarinoIf you need to do something whenever the optimization level is
9816e4b17023SJohn Marinochanged via the optimize attribute or pragma, see
9817e4b17023SJohn Marino@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}
9818e4b17023SJohn Marino@end deftypefn
9819e4b17023SJohn Marino
9820e4b17023SJohn Marino@hook TARGET_CAN_INLINE_P
9821e4b17023SJohn MarinoThis target hook returns @code{false} if the @var{caller} function
9822e4b17023SJohn Marinocannot inline @var{callee}, based on target specific information.  By
9823e4b17023SJohn Marinodefault, inlining is not allowed if the callee function has function
9824e4b17023SJohn Marinospecific target options and the caller does not use the same options.
9825e4b17023SJohn Marino@end deftypefn
9826e4b17023SJohn Marino
9827e4b17023SJohn Marino@node Emulated TLS
9828e4b17023SJohn Marino@section Emulating TLS
9829e4b17023SJohn Marino@cindex Emulated TLS
9830e4b17023SJohn Marino
9831e4b17023SJohn MarinoFor targets whose psABI does not provide Thread Local Storage via
9832e4b17023SJohn Marinospecific relocations and instruction sequences, an emulation layer is
9833e4b17023SJohn Marinoused.  A set of target hooks allows this emulation layer to be
9834e4b17023SJohn Marinoconfigured for the requirements of a particular target.  For instance
9835e4b17023SJohn Marinothe psABI may in fact specify TLS support in terms of an emulation
9836e4b17023SJohn Marinolayer.
9837e4b17023SJohn Marino
9838e4b17023SJohn MarinoThe emulation layer works by creating a control object for every TLS
9839e4b17023SJohn Marinoobject.  To access the TLS object, a lookup function is provided
9840e4b17023SJohn Marinowhich, when given the address of the control object, will return the
9841e4b17023SJohn Marinoaddress of the current thread's instance of the TLS object.
9842e4b17023SJohn Marino
9843e4b17023SJohn Marino@hook TARGET_EMUTLS_GET_ADDRESS
9844e4b17023SJohn MarinoContains the name of the helper function that uses a TLS control
9845e4b17023SJohn Marinoobject to locate a TLS instance.  The default causes libgcc's
9846e4b17023SJohn Marinoemulated TLS helper function to be used.
9847e4b17023SJohn Marino@end deftypevr
9848e4b17023SJohn Marino
9849e4b17023SJohn Marino@hook TARGET_EMUTLS_REGISTER_COMMON
9850e4b17023SJohn MarinoContains the name of the helper function that should be used at
9851e4b17023SJohn Marinoprogram startup to register TLS objects that are implicitly
9852e4b17023SJohn Marinoinitialized to zero.  If this is @code{NULL}, all TLS objects will
9853e4b17023SJohn Marinohave explicit initializers.  The default causes libgcc's emulated TLS
9854e4b17023SJohn Marinoregistration function to be used.
9855e4b17023SJohn Marino@end deftypevr
9856e4b17023SJohn Marino
9857e4b17023SJohn Marino@hook TARGET_EMUTLS_VAR_SECTION
9858e4b17023SJohn MarinoContains the name of the section in which TLS control variables should
9859e4b17023SJohn Marinobe placed.  The default of @code{NULL} allows these to be placed in
9860e4b17023SJohn Marinoany section.
9861e4b17023SJohn Marino@end deftypevr
9862e4b17023SJohn Marino
9863e4b17023SJohn Marino@hook TARGET_EMUTLS_TMPL_SECTION
9864e4b17023SJohn MarinoContains the name of the section in which TLS initializers should be
9865e4b17023SJohn Marinoplaced.  The default of @code{NULL} allows these to be placed in any
9866e4b17023SJohn Marinosection.
9867e4b17023SJohn Marino@end deftypevr
9868e4b17023SJohn Marino
9869e4b17023SJohn Marino@hook TARGET_EMUTLS_VAR_PREFIX
9870e4b17023SJohn MarinoContains the prefix to be prepended to TLS control variable names.
9871e4b17023SJohn MarinoThe default of @code{NULL} uses a target-specific prefix.
9872e4b17023SJohn Marino@end deftypevr
9873e4b17023SJohn Marino
9874e4b17023SJohn Marino@hook TARGET_EMUTLS_TMPL_PREFIX
9875e4b17023SJohn MarinoContains the prefix to be prepended to TLS initializer objects.  The
9876e4b17023SJohn Marinodefault of @code{NULL} uses a target-specific prefix.
9877e4b17023SJohn Marino@end deftypevr
9878e4b17023SJohn Marino
9879e4b17023SJohn Marino@hook TARGET_EMUTLS_VAR_FIELDS
9880e4b17023SJohn MarinoSpecifies a function that generates the FIELD_DECLs for a TLS control
9881e4b17023SJohn Marinoobject type.  @var{type} is the RECORD_TYPE the fields are for and
9882e4b17023SJohn Marino@var{name} should be filled with the structure tag, if the default of
9883e4b17023SJohn Marino@code{__emutls_object} is unsuitable.  The default creates a type suitable
9884e4b17023SJohn Marinofor libgcc's emulated TLS function.
9885e4b17023SJohn Marino@end deftypefn
9886e4b17023SJohn Marino
9887e4b17023SJohn Marino@hook TARGET_EMUTLS_VAR_INIT
9888e4b17023SJohn MarinoSpecifies a function that generates the CONSTRUCTOR to initialize a
9889e4b17023SJohn MarinoTLS control object.  @var{var} is the TLS control object, @var{decl}
9890e4b17023SJohn Marinois the TLS object and @var{tmpl_addr} is the address of the
9891e4b17023SJohn Marinoinitializer.  The default initializes libgcc's emulated TLS control object.
9892e4b17023SJohn Marino@end deftypefn
9893e4b17023SJohn Marino
9894e4b17023SJohn Marino@hook TARGET_EMUTLS_VAR_ALIGN_FIXED
9895e4b17023SJohn MarinoSpecifies whether the alignment of TLS control variable objects is
9896e4b17023SJohn Marinofixed and should not be increased as some backends may do to optimize
9897e4b17023SJohn Marinosingle objects.  The default is false.
9898e4b17023SJohn Marino@end deftypevr
9899e4b17023SJohn Marino
9900e4b17023SJohn Marino@hook TARGET_EMUTLS_DEBUG_FORM_TLS_ADDRESS
9901e4b17023SJohn MarinoSpecifies whether a DWARF @code{DW_OP_form_tls_address} location descriptor
9902e4b17023SJohn Marinomay be used to describe emulated TLS control objects.
9903e4b17023SJohn Marino@end deftypevr
9904e4b17023SJohn Marino
9905e4b17023SJohn Marino@node MIPS Coprocessors
9906e4b17023SJohn Marino@section Defining coprocessor specifics for MIPS targets.
9907e4b17023SJohn Marino@cindex MIPS coprocessor-definition macros
9908e4b17023SJohn Marino
9909e4b17023SJohn MarinoThe MIPS specification allows MIPS implementations to have as many as 4
9910e4b17023SJohn Marinocoprocessors, each with as many as 32 private registers.  GCC supports
9911e4b17023SJohn Marinoaccessing these registers and transferring values between the registers
9912e4b17023SJohn Marinoand memory using asm-ized variables.  For example:
9913e4b17023SJohn Marino
9914e4b17023SJohn Marino@smallexample
9915e4b17023SJohn Marino  register unsigned int cp0count asm ("c0r1");
9916e4b17023SJohn Marino  unsigned int d;
9917e4b17023SJohn Marino
9918e4b17023SJohn Marino  d = cp0count + 3;
9919e4b17023SJohn Marino@end smallexample
9920e4b17023SJohn Marino
9921e4b17023SJohn Marino(``c0r1'' is the default name of register 1 in coprocessor 0; alternate
9922e4b17023SJohn Marinonames may be added as described below, or the default names may be
9923e4b17023SJohn Marinooverridden entirely in @code{SUBTARGET_CONDITIONAL_REGISTER_USAGE}.)
9924e4b17023SJohn Marino
9925e4b17023SJohn MarinoCoprocessor registers are assumed to be epilogue-used; sets to them will
9926e4b17023SJohn Marinobe preserved even if it does not appear that the register is used again
9927e4b17023SJohn Marinolater in the function.
9928e4b17023SJohn Marino
9929e4b17023SJohn MarinoAnother note: according to the MIPS spec, coprocessor 1 (if present) is
9930e4b17023SJohn Marinothe FPU@.  One accesses COP1 registers through standard mips
9931e4b17023SJohn Marinofloating-point support; they are not included in this mechanism.
9932e4b17023SJohn Marino
9933e4b17023SJohn MarinoThere is one macro used in defining the MIPS coprocessor interface which
9934e4b17023SJohn Marinoyou may want to override in subtargets; it is described below.
9935e4b17023SJohn Marino
9936e4b17023SJohn Marino@defmac ALL_COP_ADDITIONAL_REGISTER_NAMES
9937e4b17023SJohn MarinoA comma-separated list (with leading comma) of pairs describing the
9938e4b17023SJohn Marinoalternate names of coprocessor registers.  The format of each entry should be
9939e4b17023SJohn Marino@smallexample
9940e4b17023SJohn Marino@{ @var{alternatename}, @var{register_number}@}
9941e4b17023SJohn Marino@end smallexample
9942e4b17023SJohn MarinoDefault: empty.
9943e4b17023SJohn Marino@end defmac
9944e4b17023SJohn Marino
9945e4b17023SJohn Marino@node PCH Target
9946e4b17023SJohn Marino@section Parameters for Precompiled Header Validity Checking
9947e4b17023SJohn Marino@cindex parameters, precompiled headers
9948e4b17023SJohn Marino
9949e4b17023SJohn Marino@hook TARGET_GET_PCH_VALIDITY
9950e4b17023SJohn MarinoThis hook returns a pointer to the data needed by
9951e4b17023SJohn Marino@code{TARGET_PCH_VALID_P} and sets
9952e4b17023SJohn Marino@samp{*@var{sz}} to the size of the data in bytes.
9953e4b17023SJohn Marino@end deftypefn
9954e4b17023SJohn Marino
9955e4b17023SJohn Marino@hook TARGET_PCH_VALID_P
9956e4b17023SJohn MarinoThis hook checks whether the options used to create a PCH file are
9957e4b17023SJohn Marinocompatible with the current settings.  It returns @code{NULL}
9958e4b17023SJohn Marinoif so and a suitable error message if not.  Error messages will
9959e4b17023SJohn Marinobe presented to the user and must be localized using @samp{_(@var{msg})}.
9960e4b17023SJohn Marino
9961e4b17023SJohn Marino@var{data} is the data that was returned by @code{TARGET_GET_PCH_VALIDITY}
9962e4b17023SJohn Marinowhen the PCH file was created and @var{sz} is the size of that data in bytes.
9963e4b17023SJohn MarinoIt's safe to assume that the data was created by the same version of the
9964e4b17023SJohn Marinocompiler, so no format checking is needed.
9965e4b17023SJohn Marino
9966e4b17023SJohn MarinoThe default definition of @code{default_pch_valid_p} should be
9967e4b17023SJohn Marinosuitable for most targets.
9968e4b17023SJohn Marino@end deftypefn
9969e4b17023SJohn Marino
9970e4b17023SJohn Marino@hook TARGET_CHECK_PCH_TARGET_FLAGS
9971e4b17023SJohn MarinoIf this hook is nonnull, the default implementation of
9972e4b17023SJohn Marino@code{TARGET_PCH_VALID_P} will use it to check for compatible values
9973e4b17023SJohn Marinoof @code{target_flags}.  @var{pch_flags} specifies the value that
9974e4b17023SJohn Marino@code{target_flags} had when the PCH file was created.  The return
9975e4b17023SJohn Marinovalue is the same as for @code{TARGET_PCH_VALID_P}.
9976e4b17023SJohn Marino@end deftypefn
9977e4b17023SJohn Marino
9978e4b17023SJohn Marino@hook TARGET_PREPARE_PCH_SAVE
9979e4b17023SJohn Marino
9980e4b17023SJohn Marino@node C++ ABI
9981e4b17023SJohn Marino@section C++ ABI parameters
9982e4b17023SJohn Marino@cindex parameters, c++ abi
9983e4b17023SJohn Marino
9984e4b17023SJohn Marino@hook TARGET_CXX_GUARD_TYPE
9985e4b17023SJohn MarinoDefine this hook to override the integer type used for guard variables.
9986e4b17023SJohn MarinoThese are used to implement one-time construction of static objects.  The
9987e4b17023SJohn Marinodefault is long_long_integer_type_node.
9988e4b17023SJohn Marino@end deftypefn
9989e4b17023SJohn Marino
9990e4b17023SJohn Marino@hook TARGET_CXX_GUARD_MASK_BIT
9991e4b17023SJohn MarinoThis hook determines how guard variables are used.  It should return
9992e4b17023SJohn Marino@code{false} (the default) if the first byte should be used.  A return value of
9993e4b17023SJohn Marino@code{true} indicates that only the least significant bit should be used.
9994e4b17023SJohn Marino@end deftypefn
9995e4b17023SJohn Marino
9996e4b17023SJohn Marino@hook TARGET_CXX_GET_COOKIE_SIZE
9997e4b17023SJohn MarinoThis hook returns the size of the cookie to use when allocating an array
9998e4b17023SJohn Marinowhose elements have the indicated @var{type}.  Assumes that it is already
9999e4b17023SJohn Marinoknown that a cookie is needed.  The default is
10000e4b17023SJohn Marino@code{max(sizeof (size_t), alignof(type))}, as defined in section 2.7 of the
10001e4b17023SJohn MarinoIA64/Generic C++ ABI@.
10002e4b17023SJohn Marino@end deftypefn
10003e4b17023SJohn Marino
10004e4b17023SJohn Marino@hook TARGET_CXX_COOKIE_HAS_SIZE
10005e4b17023SJohn MarinoThis hook should return @code{true} if the element size should be stored in
10006e4b17023SJohn Marinoarray cookies.  The default is to return @code{false}.
10007e4b17023SJohn Marino@end deftypefn
10008e4b17023SJohn Marino
10009e4b17023SJohn Marino@hook TARGET_CXX_IMPORT_EXPORT_CLASS
10010e4b17023SJohn MarinoIf defined by a backend this hook allows the decision made to export
10011e4b17023SJohn Marinoclass @var{type} to be overruled.  Upon entry @var{import_export}
10012e4b17023SJohn Marinowill contain 1 if the class is going to be exported, @minus{}1 if it is going
10013e4b17023SJohn Marinoto be imported and 0 otherwise.  This function should return the
10014e4b17023SJohn Marinomodified value and perform any other actions necessary to support the
10015e4b17023SJohn Marinobackend's targeted operating system.
10016e4b17023SJohn Marino@end deftypefn
10017e4b17023SJohn Marino
10018e4b17023SJohn Marino@hook TARGET_CXX_CDTOR_RETURNS_THIS
10019e4b17023SJohn MarinoThis hook should return @code{true} if constructors and destructors return
10020e4b17023SJohn Marinothe address of the object created/destroyed.  The default is to return
10021e4b17023SJohn Marino@code{false}.
10022e4b17023SJohn Marino@end deftypefn
10023e4b17023SJohn Marino
10024e4b17023SJohn Marino@hook TARGET_CXX_KEY_METHOD_MAY_BE_INLINE
10025e4b17023SJohn MarinoThis hook returns true if the key method for a class (i.e., the method
10026e4b17023SJohn Marinowhich, if defined in the current translation unit, causes the virtual
10027e4b17023SJohn Marinotable to be emitted) may be an inline function.  Under the standard
10028e4b17023SJohn MarinoItanium C++ ABI the key method may be an inline function so long as
10029e4b17023SJohn Marinothe function is not declared inline in the class definition.  Under
10030e4b17023SJohn Marinosome variants of the ABI, an inline function can never be the key
10031e4b17023SJohn Marinomethod.  The default is to return @code{true}.
10032e4b17023SJohn Marino@end deftypefn
10033e4b17023SJohn Marino
10034e4b17023SJohn Marino@hook TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY
10035e4b17023SJohn Marino
10036e4b17023SJohn Marino@hook TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT
10037e4b17023SJohn MarinoThis hook returns true (the default) if virtual tables and other
10038e4b17023SJohn Marinosimilar implicit class data objects are always COMDAT if they have
10039e4b17023SJohn Marinoexternal linkage.  If this hook returns false, then class data for
10040e4b17023SJohn Marinoclasses whose virtual table will be emitted in only one translation
10041e4b17023SJohn Marinounit will not be COMDAT.
10042e4b17023SJohn Marino@end deftypefn
10043e4b17023SJohn Marino
10044e4b17023SJohn Marino@hook TARGET_CXX_LIBRARY_RTTI_COMDAT
10045e4b17023SJohn MarinoThis hook returns true (the default) if the RTTI information for
10046e4b17023SJohn Marinothe basic types which is defined in the C++ runtime should always
10047e4b17023SJohn Marinobe COMDAT, false if it should not be COMDAT.
10048e4b17023SJohn Marino@end deftypefn
10049e4b17023SJohn Marino
10050e4b17023SJohn Marino@hook TARGET_CXX_USE_AEABI_ATEXIT
10051e4b17023SJohn MarinoThis hook returns true if @code{__aeabi_atexit} (as defined by the ARM EABI)
10052e4b17023SJohn Marinoshould be used to register static destructors when @option{-fuse-cxa-atexit}
10053e4b17023SJohn Marinois in effect.  The default is to return false to use @code{__cxa_atexit}.
10054e4b17023SJohn Marino@end deftypefn
10055e4b17023SJohn Marino
10056e4b17023SJohn Marino@hook TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT
10057e4b17023SJohn MarinoThis hook returns true if the target @code{atexit} function can be used
10058e4b17023SJohn Marinoin the same manner as @code{__cxa_atexit} to register C++ static
10059e4b17023SJohn Marinodestructors. This requires that @code{atexit}-registered functions in
10060e4b17023SJohn Marinoshared libraries are run in the correct order when the libraries are
10061e4b17023SJohn Marinounloaded. The default is to return false.
10062e4b17023SJohn Marino@end deftypefn
10063e4b17023SJohn Marino
10064e4b17023SJohn Marino@hook TARGET_CXX_ADJUST_CLASS_AT_DEFINITION
10065e4b17023SJohn Marino
10066e4b17023SJohn Marino@node Named Address Spaces
10067e4b17023SJohn Marino@section Adding support for named address spaces
10068e4b17023SJohn Marino@cindex named address spaces
10069e4b17023SJohn Marino
10070e4b17023SJohn MarinoThe draft technical report of the ISO/IEC JTC1 S22 WG14 N1275
10071e4b17023SJohn Marinostandards committee, @cite{Programming Languages - C - Extensions to
10072e4b17023SJohn Marinosupport embedded processors}, specifies a syntax for embedded
10073e4b17023SJohn Marinoprocessors to specify alternate address spaces.  You can configure a
10074e4b17023SJohn MarinoGCC port to support section 5.1 of the draft report to add support for
10075e4b17023SJohn Marinoaddress spaces other than the default address space.  These address
10076e4b17023SJohn Marinospaces are new keywords that are similar to the @code{volatile} and
10077e4b17023SJohn Marino@code{const} type attributes.
10078e4b17023SJohn Marino
10079e4b17023SJohn MarinoPointers to named address spaces can have a different size than
10080e4b17023SJohn Marinopointers to the generic address space.
10081e4b17023SJohn Marino
10082e4b17023SJohn MarinoFor example, the SPU port uses the @code{__ea} address space to refer
10083e4b17023SJohn Marinoto memory in the host processor, rather than memory local to the SPU
10084e4b17023SJohn Marinoprocessor.  Access to memory in the @code{__ea} address space involves
10085e4b17023SJohn Marinoissuing DMA operations to move data between the host processor and the
10086e4b17023SJohn Marinolocal processor memory address space.  Pointers in the @code{__ea}
10087e4b17023SJohn Marinoaddress space are either 32 bits or 64 bits based on the
10088e4b17023SJohn Marino@option{-mea32} or @option{-mea64} switches (native SPU pointers are
10089e4b17023SJohn Marinoalways 32 bits).
10090e4b17023SJohn Marino
10091e4b17023SJohn MarinoInternally, address spaces are represented as a small integer in the
10092e4b17023SJohn Marinorange 0 to 15 with address space 0 being reserved for the generic
10093e4b17023SJohn Marinoaddress space.
10094e4b17023SJohn Marino
10095e4b17023SJohn MarinoTo register a named address space qualifier keyword with the C front end,
10096e4b17023SJohn Marinothe target may call the @code{c_register_addr_space} routine.  For example,
10097e4b17023SJohn Marinothe SPU port uses the following to declare @code{__ea} as the keyword for
10098e4b17023SJohn Marinonamed address space #1:
10099e4b17023SJohn Marino@smallexample
10100e4b17023SJohn Marino#define ADDR_SPACE_EA 1
10101e4b17023SJohn Marinoc_register_addr_space ("__ea", ADDR_SPACE_EA);
10102e4b17023SJohn Marino@end smallexample
10103e4b17023SJohn Marino
10104e4b17023SJohn Marino@hook TARGET_ADDR_SPACE_POINTER_MODE
10105e4b17023SJohn MarinoDefine this to return the machine mode to use for pointers to
10106e4b17023SJohn Marino@var{address_space} if the target supports named address spaces.
10107e4b17023SJohn MarinoThe default version of this hook returns @code{ptr_mode} for the
10108e4b17023SJohn Marinogeneric address space only.
10109e4b17023SJohn Marino@end deftypefn
10110e4b17023SJohn Marino
10111e4b17023SJohn Marino@hook TARGET_ADDR_SPACE_ADDRESS_MODE
10112e4b17023SJohn MarinoDefine this to return the machine mode to use for addresses in
10113e4b17023SJohn Marino@var{address_space} if the target supports named address spaces.
10114e4b17023SJohn MarinoThe default version of this hook returns @code{Pmode} for the
10115e4b17023SJohn Marinogeneric address space only.
10116e4b17023SJohn Marino@end deftypefn
10117e4b17023SJohn Marino
10118e4b17023SJohn Marino@hook TARGET_ADDR_SPACE_VALID_POINTER_MODE
10119e4b17023SJohn MarinoDefine this to return nonzero if the port can handle pointers
10120e4b17023SJohn Marinowith machine mode @var{mode} to address space @var{as}.  This target
10121e4b17023SJohn Marinohook is the same as the @code{TARGET_VALID_POINTER_MODE} target hook,
10122e4b17023SJohn Marinoexcept that it includes explicit named address space support.  The default
10123e4b17023SJohn Marinoversion of this hook returns true for the modes returned by either the
10124e4b17023SJohn Marino@code{TARGET_ADDR_SPACE_POINTER_MODE} or @code{TARGET_ADDR_SPACE_ADDRESS_MODE}
10125e4b17023SJohn Marinotarget hooks for the given address space.
10126e4b17023SJohn Marino@end deftypefn
10127e4b17023SJohn Marino
10128e4b17023SJohn Marino@hook TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P
10129e4b17023SJohn MarinoDefine this to return true if @var{exp} is a valid address for mode
10130e4b17023SJohn Marino@var{mode} in the named address space @var{as}.  The @var{strict}
10131e4b17023SJohn Marinoparameter says whether strict addressing is in effect after reload has
10132e4b17023SJohn Marinofinished.  This target hook is the same as the
10133e4b17023SJohn Marino@code{TARGET_LEGITIMATE_ADDRESS_P} target hook, except that it includes
10134e4b17023SJohn Marinoexplicit named address space support.
10135e4b17023SJohn Marino@end deftypefn
10136e4b17023SJohn Marino
10137e4b17023SJohn Marino@hook TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS
10138e4b17023SJohn MarinoDefine this to modify an invalid address @var{x} to be a valid address
10139e4b17023SJohn Marinowith mode @var{mode} in the named address space @var{as}.  This target
10140e4b17023SJohn Marinohook is the same as the @code{TARGET_LEGITIMIZE_ADDRESS} target hook,
10141e4b17023SJohn Marinoexcept that it includes explicit named address space support.
10142e4b17023SJohn Marino@end deftypefn
10143e4b17023SJohn Marino
10144e4b17023SJohn Marino@hook TARGET_ADDR_SPACE_SUBSET_P
10145e4b17023SJohn MarinoDefine this to return whether the @var{subset} named address space is
10146e4b17023SJohn Marinocontained within the @var{superset} named address space.  Pointers to
10147e4b17023SJohn Marinoa named address space that is a subset of another named address space
10148e4b17023SJohn Marinowill be converted automatically without a cast if used together in
10149e4b17023SJohn Marinoarithmetic operations.  Pointers to a superset address space can be
10150e4b17023SJohn Marinoconverted to pointers to a subset address space via explicit casts.
10151e4b17023SJohn Marino@end deftypefn
10152e4b17023SJohn Marino
10153e4b17023SJohn Marino@hook TARGET_ADDR_SPACE_CONVERT
10154e4b17023SJohn MarinoDefine this to convert the pointer expression represented by the RTL
10155e4b17023SJohn Marino@var{op} with type @var{from_type} that points to a named address
10156e4b17023SJohn Marinospace to a new pointer expression with type @var{to_type} that points
10157e4b17023SJohn Marinoto a different named address space.  When this hook it called, it is
10158e4b17023SJohn Marinoguaranteed that one of the two address spaces is a subset of the other,
10159e4b17023SJohn Marinoas determined by the @code{TARGET_ADDR_SPACE_SUBSET_P} target hook.
10160e4b17023SJohn Marino@end deftypefn
10161e4b17023SJohn Marino
10162e4b17023SJohn Marino@node Misc
10163e4b17023SJohn Marino@section Miscellaneous Parameters
10164e4b17023SJohn Marino@cindex parameters, miscellaneous
10165e4b17023SJohn Marino
10166e4b17023SJohn Marino@c prevent bad page break with this line
10167e4b17023SJohn MarinoHere are several miscellaneous parameters.
10168e4b17023SJohn Marino
10169e4b17023SJohn Marino@defmac HAS_LONG_COND_BRANCH
10170e4b17023SJohn MarinoDefine this boolean macro to indicate whether or not your architecture
10171e4b17023SJohn Marinohas conditional branches that can span all of memory.  It is used in
10172e4b17023SJohn Marinoconjunction with an optimization that partitions hot and cold basic
10173e4b17023SJohn Marinoblocks into separate sections of the executable.  If this macro is
10174e4b17023SJohn Marinoset to false, gcc will convert any conditional branches that attempt
10175e4b17023SJohn Marinoto cross between sections into unconditional branches or indirect jumps.
10176e4b17023SJohn Marino@end defmac
10177e4b17023SJohn Marino
10178e4b17023SJohn Marino@defmac HAS_LONG_UNCOND_BRANCH
10179e4b17023SJohn MarinoDefine this boolean macro to indicate whether or not your architecture
10180e4b17023SJohn Marinohas unconditional branches that can span all of memory.  It is used in
10181e4b17023SJohn Marinoconjunction with an optimization that partitions hot and cold basic
10182e4b17023SJohn Marinoblocks into separate sections of the executable.  If this macro is
10183e4b17023SJohn Marinoset to false, gcc will convert any unconditional branches that attempt
10184e4b17023SJohn Marinoto cross between sections into indirect jumps.
10185e4b17023SJohn Marino@end defmac
10186e4b17023SJohn Marino
10187e4b17023SJohn Marino@defmac CASE_VECTOR_MODE
10188e4b17023SJohn MarinoAn alias for a machine mode name.  This is the machine mode that
10189e4b17023SJohn Marinoelements of a jump-table should have.
10190e4b17023SJohn Marino@end defmac
10191e4b17023SJohn Marino
10192e4b17023SJohn Marino@defmac CASE_VECTOR_SHORTEN_MODE (@var{min_offset}, @var{max_offset}, @var{body})
10193e4b17023SJohn MarinoOptional: return the preferred mode for an @code{addr_diff_vec}
10194e4b17023SJohn Marinowhen the minimum and maximum offset are known.  If you define this,
10195e4b17023SJohn Marinoit enables extra code in branch shortening to deal with @code{addr_diff_vec}.
10196e4b17023SJohn MarinoTo make this work, you also have to define @code{INSN_ALIGN} and
10197e4b17023SJohn Marinomake the alignment for @code{addr_diff_vec} explicit.
10198e4b17023SJohn MarinoThe @var{body} argument is provided so that the offset_unsigned and scale
10199e4b17023SJohn Marinoflags can be updated.
10200e4b17023SJohn Marino@end defmac
10201e4b17023SJohn Marino
10202e4b17023SJohn Marino@defmac CASE_VECTOR_PC_RELATIVE
10203e4b17023SJohn MarinoDefine this macro to be a C expression to indicate when jump-tables
10204e4b17023SJohn Marinoshould contain relative addresses.  You need not define this macro if
10205e4b17023SJohn Marinojump-tables never contain relative addresses, or jump-tables should
10206e4b17023SJohn Marinocontain relative addresses only when @option{-fPIC} or @option{-fPIC}
10207e4b17023SJohn Marinois in effect.
10208e4b17023SJohn Marino@end defmac
10209e4b17023SJohn Marino
10210e4b17023SJohn Marino@hook TARGET_CASE_VALUES_THRESHOLD
10211e4b17023SJohn MarinoThis function return the smallest number of different values for which it
10212e4b17023SJohn Marinois best to use a jump-table instead of a tree of conditional branches.
10213e4b17023SJohn MarinoThe default is four for machines with a @code{casesi} instruction and
10214e4b17023SJohn Marinofive otherwise.  This is best for most machines.
10215e4b17023SJohn Marino@end deftypefn
10216e4b17023SJohn Marino
10217e4b17023SJohn Marino@defmac CASE_USE_BIT_TESTS
10218e4b17023SJohn MarinoDefine this macro to be a C expression to indicate whether C switch
10219e4b17023SJohn Marinostatements may be implemented by a sequence of bit tests.  This is
10220e4b17023SJohn Marinoadvantageous on processors that can efficiently implement left shift
10221e4b17023SJohn Marinoof 1 by the number of bits held in a register, but inappropriate on
10222e4b17023SJohn Marinotargets that would require a loop.  By default, this macro returns
10223e4b17023SJohn Marino@code{true} if the target defines an @code{ashlsi3} pattern, and
10224e4b17023SJohn Marino@code{false} otherwise.
10225e4b17023SJohn Marino@end defmac
10226e4b17023SJohn Marino
10227e4b17023SJohn Marino@defmac WORD_REGISTER_OPERATIONS
10228e4b17023SJohn MarinoDefine this macro if operations between registers with integral mode
10229e4b17023SJohn Marinosmaller than a word are always performed on the entire register.
10230e4b17023SJohn MarinoMost RISC machines have this property and most CISC machines do not.
10231e4b17023SJohn Marino@end defmac
10232e4b17023SJohn Marino
10233e4b17023SJohn Marino@defmac LOAD_EXTEND_OP (@var{mem_mode})
10234e4b17023SJohn MarinoDefine this macro to be a C expression indicating when insns that read
10235e4b17023SJohn Marinomemory in @var{mem_mode}, an integral mode narrower than a word, set the
10236e4b17023SJohn Marinobits outside of @var{mem_mode} to be either the sign-extension or the
10237e4b17023SJohn Marinozero-extension of the data read.  Return @code{SIGN_EXTEND} for values
10238e4b17023SJohn Marinoof @var{mem_mode} for which the
10239e4b17023SJohn Marinoinsn sign-extends, @code{ZERO_EXTEND} for which it zero-extends, and
10240e4b17023SJohn Marino@code{UNKNOWN} for other modes.
10241e4b17023SJohn Marino
10242e4b17023SJohn MarinoThis macro is not called with @var{mem_mode} non-integral or with a width
10243e4b17023SJohn Marinogreater than or equal to @code{BITS_PER_WORD}, so you may return any
10244e4b17023SJohn Marinovalue in this case.  Do not define this macro if it would always return
10245e4b17023SJohn Marino@code{UNKNOWN}.  On machines where this macro is defined, you will normally
10246e4b17023SJohn Marinodefine it as the constant @code{SIGN_EXTEND} or @code{ZERO_EXTEND}.
10247e4b17023SJohn Marino
10248e4b17023SJohn MarinoYou may return a non-@code{UNKNOWN} value even if for some hard registers
10249e4b17023SJohn Marinothe sign extension is not performed, if for the @code{REGNO_REG_CLASS}
10250e4b17023SJohn Marinoof these hard registers @code{CANNOT_CHANGE_MODE_CLASS} returns nonzero
10251e4b17023SJohn Marinowhen the @var{from} mode is @var{mem_mode} and the @var{to} mode is any
10252e4b17023SJohn Marinointegral mode larger than this but not larger than @code{word_mode}.
10253e4b17023SJohn Marino
10254e4b17023SJohn MarinoYou must return @code{UNKNOWN} if for some hard registers that allow this
10255e4b17023SJohn Marinomode, @code{CANNOT_CHANGE_MODE_CLASS} says that they cannot change to
10256e4b17023SJohn Marino@code{word_mode}, but that they can change to another integral mode that
10257e4b17023SJohn Marinois larger then @var{mem_mode} but still smaller than @code{word_mode}.
10258e4b17023SJohn Marino@end defmac
10259e4b17023SJohn Marino
10260e4b17023SJohn Marino@defmac SHORT_IMMEDIATES_SIGN_EXTEND
10261e4b17023SJohn MarinoDefine this macro if loading short immediate values into registers sign
10262e4b17023SJohn Marinoextends.
10263e4b17023SJohn Marino@end defmac
10264e4b17023SJohn Marino
10265e4b17023SJohn Marino@defmac FIXUNS_TRUNC_LIKE_FIX_TRUNC
10266e4b17023SJohn MarinoDefine this macro if the same instructions that convert a floating
10267e4b17023SJohn Marinopoint number to a signed fixed point number also convert validly to an
10268e4b17023SJohn Marinounsigned one.
10269e4b17023SJohn Marino@end defmac
10270e4b17023SJohn Marino
10271e4b17023SJohn Marino@hook TARGET_MIN_DIVISIONS_FOR_RECIP_MUL
10272e4b17023SJohn MarinoWhen @option{-ffast-math} is in effect, GCC tries to optimize
10273e4b17023SJohn Marinodivisions by the same divisor, by turning them into multiplications by
10274e4b17023SJohn Marinothe reciprocal.  This target hook specifies the minimum number of divisions
10275e4b17023SJohn Marinothat should be there for GCC to perform the optimization for a variable
10276e4b17023SJohn Marinoof mode @var{mode}.  The default implementation returns 3 if the machine
10277e4b17023SJohn Marinohas an instruction for the division, and 2 if it does not.
10278e4b17023SJohn Marino@end deftypefn
10279e4b17023SJohn Marino
10280e4b17023SJohn Marino@defmac MOVE_MAX
10281e4b17023SJohn MarinoThe maximum number of bytes that a single instruction can move quickly
10282e4b17023SJohn Marinobetween memory and registers or between two memory locations.
10283e4b17023SJohn Marino@end defmac
10284e4b17023SJohn Marino
10285e4b17023SJohn Marino@defmac MAX_MOVE_MAX
10286e4b17023SJohn MarinoThe maximum number of bytes that a single instruction can move quickly
10287e4b17023SJohn Marinobetween memory and registers or between two memory locations.  If this
10288e4b17023SJohn Marinois undefined, the default is @code{MOVE_MAX}.  Otherwise, it is the
10289e4b17023SJohn Marinoconstant value that is the largest value that @code{MOVE_MAX} can have
10290e4b17023SJohn Marinoat run-time.
10291e4b17023SJohn Marino@end defmac
10292e4b17023SJohn Marino
10293e4b17023SJohn Marino@defmac SHIFT_COUNT_TRUNCATED
10294e4b17023SJohn MarinoA C expression that is nonzero if on this machine the number of bits
10295e4b17023SJohn Marinoactually used for the count of a shift operation is equal to the number
10296e4b17023SJohn Marinoof bits needed to represent the size of the object being shifted.  When
10297e4b17023SJohn Marinothis macro is nonzero, the compiler will assume that it is safe to omit
10298e4b17023SJohn Marinoa sign-extend, zero-extend, and certain bitwise `and' instructions that
10299e4b17023SJohn Marinotruncates the count of a shift operation.  On machines that have
10300e4b17023SJohn Marinoinstructions that act on bit-fields at variable positions, which may
10301e4b17023SJohn Marinoinclude `bit test' instructions, a nonzero @code{SHIFT_COUNT_TRUNCATED}
10302e4b17023SJohn Marinoalso enables deletion of truncations of the values that serve as
10303e4b17023SJohn Marinoarguments to bit-field instructions.
10304e4b17023SJohn Marino
10305e4b17023SJohn MarinoIf both types of instructions truncate the count (for shifts) and
10306e4b17023SJohn Marinoposition (for bit-field operations), or if no variable-position bit-field
10307e4b17023SJohn Marinoinstructions exist, you should define this macro.
10308e4b17023SJohn Marino
10309e4b17023SJohn MarinoHowever, on some machines, such as the 80386 and the 680x0, truncation
10310e4b17023SJohn Marinoonly applies to shift operations and not the (real or pretended)
10311e4b17023SJohn Marinobit-field operations.  Define @code{SHIFT_COUNT_TRUNCATED} to be zero on
10312e4b17023SJohn Marinosuch machines.  Instead, add patterns to the @file{md} file that include
10313e4b17023SJohn Marinothe implied truncation of the shift instructions.
10314e4b17023SJohn Marino
10315e4b17023SJohn MarinoYou need not define this macro if it would always have the value of zero.
10316e4b17023SJohn Marino@end defmac
10317e4b17023SJohn Marino
10318e4b17023SJohn Marino@anchor{TARGET_SHIFT_TRUNCATION_MASK}
10319e4b17023SJohn Marino@hook TARGET_SHIFT_TRUNCATION_MASK
10320e4b17023SJohn MarinoThis function describes how the standard shift patterns for @var{mode}
10321e4b17023SJohn Marinodeal with shifts by negative amounts or by more than the width of the mode.
10322e4b17023SJohn Marino@xref{shift patterns}.
10323e4b17023SJohn Marino
10324e4b17023SJohn MarinoOn many machines, the shift patterns will apply a mask @var{m} to the
10325e4b17023SJohn Marinoshift count, meaning that a fixed-width shift of @var{x} by @var{y} is
10326e4b17023SJohn Marinoequivalent to an arbitrary-width shift of @var{x} by @var{y & m}.  If
10327e4b17023SJohn Marinothis is true for mode @var{mode}, the function should return @var{m},
10328e4b17023SJohn Marinootherwise it should return 0.  A return value of 0 indicates that no
10329e4b17023SJohn Marinoparticular behavior is guaranteed.
10330e4b17023SJohn Marino
10331e4b17023SJohn MarinoNote that, unlike @code{SHIFT_COUNT_TRUNCATED}, this function does
10332e4b17023SJohn Marino@emph{not} apply to general shift rtxes; it applies only to instructions
10333e4b17023SJohn Marinothat are generated by the named shift patterns.
10334e4b17023SJohn Marino
10335e4b17023SJohn MarinoThe default implementation of this function returns
10336e4b17023SJohn Marino@code{GET_MODE_BITSIZE (@var{mode}) - 1} if @code{SHIFT_COUNT_TRUNCATED}
10337e4b17023SJohn Marinoand 0 otherwise.  This definition is always safe, but if
10338e4b17023SJohn Marino@code{SHIFT_COUNT_TRUNCATED} is false, and some shift patterns
10339e4b17023SJohn Marinonevertheless truncate the shift count, you may get better code
10340e4b17023SJohn Marinoby overriding it.
10341e4b17023SJohn Marino@end deftypefn
10342e4b17023SJohn Marino
10343e4b17023SJohn Marino@defmac TRULY_NOOP_TRUNCATION (@var{outprec}, @var{inprec})
10344e4b17023SJohn MarinoA C expression which is nonzero if on this machine it is safe to
10345e4b17023SJohn Marino``convert'' an integer of @var{inprec} bits to one of @var{outprec}
10346e4b17023SJohn Marinobits (where @var{outprec} is smaller than @var{inprec}) by merely
10347e4b17023SJohn Marinooperating on it as if it had only @var{outprec} bits.
10348e4b17023SJohn Marino
10349e4b17023SJohn MarinoOn many machines, this expression can be 1.
10350e4b17023SJohn Marino
10351e4b17023SJohn Marino@c rearranged this, removed the phrase "it is reported that".  this was
10352e4b17023SJohn Marino@c to fix an overfull hbox.  --mew 10feb93
10353e4b17023SJohn MarinoWhen @code{TRULY_NOOP_TRUNCATION} returns 1 for a pair of sizes for
10354e4b17023SJohn Marinomodes for which @code{MODES_TIEABLE_P} is 0, suboptimal code can result.
10355e4b17023SJohn MarinoIf this is the case, making @code{TRULY_NOOP_TRUNCATION} return 0 in
10356e4b17023SJohn Marinosuch cases may improve things.
10357e4b17023SJohn Marino@end defmac
10358e4b17023SJohn Marino
10359e4b17023SJohn Marino@hook TARGET_MODE_REP_EXTENDED
10360e4b17023SJohn MarinoThe representation of an integral mode can be such that the values
10361e4b17023SJohn Marinoare always extended to a wider integral mode.  Return
10362e4b17023SJohn Marino@code{SIGN_EXTEND} if values of @var{mode} are represented in
10363e4b17023SJohn Marinosign-extended form to @var{rep_mode}.  Return @code{UNKNOWN}
10364e4b17023SJohn Marinootherwise.  (Currently, none of the targets use zero-extended
10365e4b17023SJohn Marinorepresentation this way so unlike @code{LOAD_EXTEND_OP},
10366e4b17023SJohn Marino@code{TARGET_MODE_REP_EXTENDED} is expected to return either
10367e4b17023SJohn Marino@code{SIGN_EXTEND} or @code{UNKNOWN}.  Also no target extends
10368e4b17023SJohn Marino@var{mode} to @var{rep_mode} so that @var{rep_mode} is not the next
10369e4b17023SJohn Marinowidest integral mode and currently we take advantage of this fact.)
10370e4b17023SJohn Marino
10371e4b17023SJohn MarinoSimilarly to @code{LOAD_EXTEND_OP} you may return a non-@code{UNKNOWN}
10372e4b17023SJohn Marinovalue even if the extension is not performed on certain hard registers
10373e4b17023SJohn Marinoas long as for the @code{REGNO_REG_CLASS} of these hard registers
10374e4b17023SJohn Marino@code{CANNOT_CHANGE_MODE_CLASS} returns nonzero.
10375e4b17023SJohn Marino
10376e4b17023SJohn MarinoNote that @code{TARGET_MODE_REP_EXTENDED} and @code{LOAD_EXTEND_OP}
10377e4b17023SJohn Marinodescribe two related properties.  If you define
10378e4b17023SJohn Marino@code{TARGET_MODE_REP_EXTENDED (mode, word_mode)} you probably also want
10379e4b17023SJohn Marinoto define @code{LOAD_EXTEND_OP (mode)} to return the same type of
10380e4b17023SJohn Marinoextension.
10381e4b17023SJohn Marino
10382e4b17023SJohn MarinoIn order to enforce the representation of @code{mode},
10383e4b17023SJohn Marino@code{TRULY_NOOP_TRUNCATION} should return false when truncating to
10384e4b17023SJohn Marino@code{mode}.
10385e4b17023SJohn Marino@end deftypefn
10386e4b17023SJohn Marino
10387e4b17023SJohn Marino@defmac STORE_FLAG_VALUE
10388e4b17023SJohn MarinoA C expression describing the value returned by a comparison operator
10389e4b17023SJohn Marinowith an integral mode and stored by a store-flag instruction
10390e4b17023SJohn Marino(@samp{cstore@var{mode}4}) when the condition is true.  This description must
10391e4b17023SJohn Marinoapply to @emph{all} the @samp{cstore@var{mode}4} patterns and all the
10392e4b17023SJohn Marinocomparison operators whose results have a @code{MODE_INT} mode.
10393e4b17023SJohn Marino
10394e4b17023SJohn MarinoA value of 1 or @minus{}1 means that the instruction implementing the
10395e4b17023SJohn Marinocomparison operator returns exactly 1 or @minus{}1 when the comparison is true
10396e4b17023SJohn Marinoand 0 when the comparison is false.  Otherwise, the value indicates
10397e4b17023SJohn Marinowhich bits of the result are guaranteed to be 1 when the comparison is
10398e4b17023SJohn Marinotrue.  This value is interpreted in the mode of the comparison
10399e4b17023SJohn Marinooperation, which is given by the mode of the first operand in the
10400e4b17023SJohn Marino@samp{cstore@var{mode}4} pattern.  Either the low bit or the sign bit of
10401e4b17023SJohn Marino@code{STORE_FLAG_VALUE} be on.  Presently, only those bits are used by
10402e4b17023SJohn Marinothe compiler.
10403e4b17023SJohn Marino
10404e4b17023SJohn MarinoIf @code{STORE_FLAG_VALUE} is neither 1 or @minus{}1, the compiler will
10405e4b17023SJohn Marinogenerate code that depends only on the specified bits.  It can also
10406e4b17023SJohn Marinoreplace comparison operators with equivalent operations if they cause
10407e4b17023SJohn Marinothe required bits to be set, even if the remaining bits are undefined.
10408e4b17023SJohn MarinoFor example, on a machine whose comparison operators return an
10409e4b17023SJohn Marino@code{SImode} value and where @code{STORE_FLAG_VALUE} is defined as
10410e4b17023SJohn Marino@samp{0x80000000}, saying that just the sign bit is relevant, the
10411e4b17023SJohn Marinoexpression
10412e4b17023SJohn Marino
10413e4b17023SJohn Marino@smallexample
10414e4b17023SJohn Marino(ne:SI (and:SI @var{x} (const_int @var{power-of-2})) (const_int 0))
10415e4b17023SJohn Marino@end smallexample
10416e4b17023SJohn Marino
10417e4b17023SJohn Marino@noindent
10418e4b17023SJohn Marinocan be converted to
10419e4b17023SJohn Marino
10420e4b17023SJohn Marino@smallexample
10421e4b17023SJohn Marino(ashift:SI @var{x} (const_int @var{n}))
10422e4b17023SJohn Marino@end smallexample
10423e4b17023SJohn Marino
10424e4b17023SJohn Marino@noindent
10425e4b17023SJohn Marinowhere @var{n} is the appropriate shift count to move the bit being
10426e4b17023SJohn Marinotested into the sign bit.
10427e4b17023SJohn Marino
10428e4b17023SJohn MarinoThere is no way to describe a machine that always sets the low-order bit
10429e4b17023SJohn Marinofor a true value, but does not guarantee the value of any other bits,
10430e4b17023SJohn Marinobut we do not know of any machine that has such an instruction.  If you
10431e4b17023SJohn Marinoare trying to port GCC to such a machine, include an instruction to
10432e4b17023SJohn Marinoperform a logical-and of the result with 1 in the pattern for the
10433e4b17023SJohn Marinocomparison operators and let us know at @email{gcc@@gcc.gnu.org}.
10434e4b17023SJohn Marino
10435e4b17023SJohn MarinoOften, a machine will have multiple instructions that obtain a value
10436e4b17023SJohn Marinofrom a comparison (or the condition codes).  Here are rules to guide the
10437e4b17023SJohn Marinochoice of value for @code{STORE_FLAG_VALUE}, and hence the instructions
10438e4b17023SJohn Marinoto be used:
10439e4b17023SJohn Marino
10440e4b17023SJohn Marino@itemize @bullet
10441e4b17023SJohn Marino@item
10442e4b17023SJohn MarinoUse the shortest sequence that yields a valid definition for
10443e4b17023SJohn Marino@code{STORE_FLAG_VALUE}.  It is more efficient for the compiler to
10444e4b17023SJohn Marino``normalize'' the value (convert it to, e.g., 1 or 0) than for the
10445e4b17023SJohn Marinocomparison operators to do so because there may be opportunities to
10446e4b17023SJohn Marinocombine the normalization with other operations.
10447e4b17023SJohn Marino
10448e4b17023SJohn Marino@item
10449e4b17023SJohn MarinoFor equal-length sequences, use a value of 1 or @minus{}1, with @minus{}1 being
10450e4b17023SJohn Marinoslightly preferred on machines with expensive jumps and 1 preferred on
10451e4b17023SJohn Marinoother machines.
10452e4b17023SJohn Marino
10453e4b17023SJohn Marino@item
10454e4b17023SJohn MarinoAs a second choice, choose a value of @samp{0x80000001} if instructions
10455e4b17023SJohn Marinoexist that set both the sign and low-order bits but do not define the
10456e4b17023SJohn Marinoothers.
10457e4b17023SJohn Marino
10458e4b17023SJohn Marino@item
10459e4b17023SJohn MarinoOtherwise, use a value of @samp{0x80000000}.
10460e4b17023SJohn Marino@end itemize
10461e4b17023SJohn Marino
10462e4b17023SJohn MarinoMany machines can produce both the value chosen for
10463e4b17023SJohn Marino@code{STORE_FLAG_VALUE} and its negation in the same number of
10464e4b17023SJohn Marinoinstructions.  On those machines, you should also define a pattern for
10465e4b17023SJohn Marinothose cases, e.g., one matching
10466e4b17023SJohn Marino
10467e4b17023SJohn Marino@smallexample
10468e4b17023SJohn Marino(set @var{A} (neg:@var{m} (ne:@var{m} @var{B} @var{C})))
10469e4b17023SJohn Marino@end smallexample
10470e4b17023SJohn Marino
10471e4b17023SJohn MarinoSome machines can also perform @code{and} or @code{plus} operations on
10472e4b17023SJohn Marinocondition code values with less instructions than the corresponding
10473e4b17023SJohn Marino@samp{cstore@var{mode}4} insn followed by @code{and} or @code{plus}.  On those
10474e4b17023SJohn Marinomachines, define the appropriate patterns.  Use the names @code{incscc}
10475e4b17023SJohn Marinoand @code{decscc}, respectively, for the patterns which perform
10476e4b17023SJohn Marino@code{plus} or @code{minus} operations on condition code values.  See
10477e4b17023SJohn Marino@file{rs6000.md} for some examples.  The GNU Superoptimizer can be used to
10478e4b17023SJohn Marinofind such instruction sequences on other machines.
10479e4b17023SJohn Marino
10480e4b17023SJohn MarinoIf this macro is not defined, the default value, 1, is used.  You need
10481e4b17023SJohn Marinonot define @code{STORE_FLAG_VALUE} if the machine has no store-flag
10482e4b17023SJohn Marinoinstructions, or if the value generated by these instructions is 1.
10483e4b17023SJohn Marino@end defmac
10484e4b17023SJohn Marino
10485e4b17023SJohn Marino@defmac FLOAT_STORE_FLAG_VALUE (@var{mode})
10486e4b17023SJohn MarinoA C expression that gives a nonzero @code{REAL_VALUE_TYPE} value that is
10487e4b17023SJohn Marinoreturned when comparison operators with floating-point results are true.
10488e4b17023SJohn MarinoDefine this macro on machines that have comparison operations that return
10489e4b17023SJohn Marinofloating-point values.  If there are no such operations, do not define
10490e4b17023SJohn Marinothis macro.
10491e4b17023SJohn Marino@end defmac
10492e4b17023SJohn Marino
10493e4b17023SJohn Marino@defmac VECTOR_STORE_FLAG_VALUE (@var{mode})
10494e4b17023SJohn MarinoA C expression that gives a rtx representing the nonzero true element
10495e4b17023SJohn Marinofor vector comparisons.  The returned rtx should be valid for the inner
10496e4b17023SJohn Marinomode of @var{mode} which is guaranteed to be a vector mode.  Define
10497e4b17023SJohn Marinothis macro on machines that have vector comparison operations that
10498e4b17023SJohn Marinoreturn a vector result.  If there are no such operations, do not define
10499e4b17023SJohn Marinothis macro.  Typically, this macro is defined as @code{const1_rtx} or
10500e4b17023SJohn Marino@code{constm1_rtx}.  This macro may return @code{NULL_RTX} to prevent
10501e4b17023SJohn Marinothe compiler optimizing such vector comparison operations for the
10502e4b17023SJohn Marinogiven mode.
10503e4b17023SJohn Marino@end defmac
10504e4b17023SJohn Marino
10505e4b17023SJohn Marino@defmac CLZ_DEFINED_VALUE_AT_ZERO (@var{mode}, @var{value})
10506e4b17023SJohn Marino@defmacx CTZ_DEFINED_VALUE_AT_ZERO (@var{mode}, @var{value})
10507e4b17023SJohn MarinoA C expression that indicates whether the architecture defines a value
10508e4b17023SJohn Marinofor @code{clz} or @code{ctz} with a zero operand.
10509e4b17023SJohn MarinoA result of @code{0} indicates the value is undefined.
10510e4b17023SJohn MarinoIf the value is defined for only the RTL expression, the macro should
10511e4b17023SJohn Marinoevaluate to @code{1}; if the value applies also to the corresponding optab
10512e4b17023SJohn Marinoentry (which is normally the case if it expands directly into
10513e4b17023SJohn Marinothe corresponding RTL), then the macro should evaluate to @code{2}.
10514e4b17023SJohn MarinoIn the cases where the value is defined, @var{value} should be set to
10515e4b17023SJohn Marinothis value.
10516e4b17023SJohn Marino
10517e4b17023SJohn MarinoIf this macro is not defined, the value of @code{clz} or
10518e4b17023SJohn Marino@code{ctz} at zero is assumed to be undefined.
10519e4b17023SJohn Marino
10520e4b17023SJohn MarinoThis macro must be defined if the target's expansion for @code{ffs}
10521e4b17023SJohn Marinorelies on a particular value to get correct results.  Otherwise it
10522e4b17023SJohn Marinois not necessary, though it may be used to optimize some corner cases, and
10523e4b17023SJohn Marinoto provide a default expansion for the @code{ffs} optab.
10524e4b17023SJohn Marino
10525e4b17023SJohn MarinoNote that regardless of this macro the ``definedness'' of @code{clz}
10526e4b17023SJohn Marinoand @code{ctz} at zero do @emph{not} extend to the builtin functions
10527e4b17023SJohn Marinovisible to the user.  Thus one may be free to adjust the value at will
10528e4b17023SJohn Marinoto match the target expansion of these operations without fear of
10529e4b17023SJohn Marinobreaking the API@.
10530e4b17023SJohn Marino@end defmac
10531e4b17023SJohn Marino
10532e4b17023SJohn Marino@defmac Pmode
10533e4b17023SJohn MarinoAn alias for the machine mode for pointers.  On most machines, define
10534e4b17023SJohn Marinothis to be the integer mode corresponding to the width of a hardware
10535e4b17023SJohn Marinopointer; @code{SImode} on 32-bit machine or @code{DImode} on 64-bit machines.
10536e4b17023SJohn MarinoOn some machines you must define this to be one of the partial integer
10537e4b17023SJohn Marinomodes, such as @code{PSImode}.
10538e4b17023SJohn Marino
10539e4b17023SJohn MarinoThe width of @code{Pmode} must be at least as large as the value of
10540e4b17023SJohn Marino@code{POINTER_SIZE}.  If it is not equal, you must define the macro
10541e4b17023SJohn Marino@code{POINTERS_EXTEND_UNSIGNED} to specify how pointers are extended
10542e4b17023SJohn Marinoto @code{Pmode}.
10543e4b17023SJohn Marino@end defmac
10544e4b17023SJohn Marino
10545e4b17023SJohn Marino@defmac FUNCTION_MODE
10546e4b17023SJohn MarinoAn alias for the machine mode used for memory references to functions
10547e4b17023SJohn Marinobeing called, in @code{call} RTL expressions.  On most CISC machines,
10548e4b17023SJohn Marinowhere an instruction can begin at any byte address, this should be
10549e4b17023SJohn Marino@code{QImode}.  On most RISC machines, where all instructions have fixed
10550e4b17023SJohn Marinosize and alignment, this should be a mode with the same size and alignment
10551e4b17023SJohn Marinoas the machine instruction words - typically @code{SImode} or @code{HImode}.
10552e4b17023SJohn Marino@end defmac
10553e4b17023SJohn Marino
10554e4b17023SJohn Marino@defmac STDC_0_IN_SYSTEM_HEADERS
10555e4b17023SJohn MarinoIn normal operation, the preprocessor expands @code{__STDC__} to the
10556e4b17023SJohn Marinoconstant 1, to signify that GCC conforms to ISO Standard C@.  On some
10557e4b17023SJohn Marinohosts, like Solaris, the system compiler uses a different convention,
10558e4b17023SJohn Marinowhere @code{__STDC__} is normally 0, but is 1 if the user specifies
10559e4b17023SJohn Marinostrict conformance to the C Standard.
10560e4b17023SJohn Marino
10561e4b17023SJohn MarinoDefining @code{STDC_0_IN_SYSTEM_HEADERS} makes GNU CPP follows the host
10562e4b17023SJohn Marinoconvention when processing system header files, but when processing user
10563e4b17023SJohn Marinofiles @code{__STDC__} will always expand to 1.
10564e4b17023SJohn Marino@end defmac
10565e4b17023SJohn Marino
10566e4b17023SJohn Marino@defmac NO_IMPLICIT_EXTERN_C
10567e4b17023SJohn MarinoDefine this macro if the system header files support C++ as well as C@.
10568e4b17023SJohn MarinoThis macro inhibits the usual method of using system header files in
10569e4b17023SJohn MarinoC++, which is to pretend that the file's contents are enclosed in
10570e4b17023SJohn Marino@samp{extern "C" @{@dots{}@}}.
10571e4b17023SJohn Marino@end defmac
10572e4b17023SJohn Marino
10573e4b17023SJohn Marino@findex #pragma
10574e4b17023SJohn Marino@findex pragma
10575e4b17023SJohn Marino@defmac REGISTER_TARGET_PRAGMAS ()
10576e4b17023SJohn MarinoDefine this macro if you want to implement any target-specific pragmas.
10577e4b17023SJohn MarinoIf defined, it is a C expression which makes a series of calls to
10578e4b17023SJohn Marino@code{c_register_pragma} or @code{c_register_pragma_with_expansion}
10579e4b17023SJohn Marinofor each pragma.  The macro may also do any
10580e4b17023SJohn Marinosetup required for the pragmas.
10581e4b17023SJohn Marino
10582e4b17023SJohn MarinoThe primary reason to define this macro is to provide compatibility with
10583e4b17023SJohn Marinoother compilers for the same target.  In general, we discourage
10584e4b17023SJohn Marinodefinition of target-specific pragmas for GCC@.
10585e4b17023SJohn Marino
10586e4b17023SJohn MarinoIf the pragma can be implemented by attributes then you should consider
10587e4b17023SJohn Marinodefining the target hook @samp{TARGET_INSERT_ATTRIBUTES} as well.
10588e4b17023SJohn Marino
10589e4b17023SJohn MarinoPreprocessor macros that appear on pragma lines are not expanded.  All
10590e4b17023SJohn Marino@samp{#pragma} directives that do not match any registered pragma are
10591e4b17023SJohn Marinosilently ignored, unless the user specifies @option{-Wunknown-pragmas}.
10592e4b17023SJohn Marino@end defmac
10593e4b17023SJohn Marino
10594e4b17023SJohn Marino@deftypefun void c_register_pragma (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *))
10595e4b17023SJohn Marino@deftypefunx void c_register_pragma_with_expansion (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *))
10596e4b17023SJohn Marino
10597e4b17023SJohn MarinoEach call to @code{c_register_pragma} or
10598e4b17023SJohn Marino@code{c_register_pragma_with_expansion} establishes one pragma.  The
10599e4b17023SJohn Marino@var{callback} routine will be called when the preprocessor encounters a
10600e4b17023SJohn Marinopragma of the form
10601e4b17023SJohn Marino
10602e4b17023SJohn Marino@smallexample
10603e4b17023SJohn Marino#pragma [@var{space}] @var{name} @dots{}
10604e4b17023SJohn Marino@end smallexample
10605e4b17023SJohn Marino
10606e4b17023SJohn Marino@var{space} is the case-sensitive namespace of the pragma, or
10607e4b17023SJohn Marino@code{NULL} to put the pragma in the global namespace.  The callback
10608e4b17023SJohn Marinoroutine receives @var{pfile} as its first argument, which can be passed
10609e4b17023SJohn Marinoon to cpplib's functions if necessary.  You can lex tokens after the
10610e4b17023SJohn Marino@var{name} by calling @code{pragma_lex}.  Tokens that are not read by the
10611e4b17023SJohn Marinocallback will be silently ignored.  The end of the line is indicated by
10612e4b17023SJohn Marinoa token of type @code{CPP_EOF}.  Macro expansion occurs on the
10613e4b17023SJohn Marinoarguments of pragmas registered with
10614e4b17023SJohn Marino@code{c_register_pragma_with_expansion} but not on the arguments of
10615e4b17023SJohn Marinopragmas registered with @code{c_register_pragma}.
10616e4b17023SJohn Marino
10617e4b17023SJohn MarinoNote that the use of @code{pragma_lex} is specific to the C and C++
10618e4b17023SJohn Marinocompilers.  It will not work in the Java or Fortran compilers, or any
10619e4b17023SJohn Marinoother language compilers for that matter.  Thus if @code{pragma_lex} is going
10620e4b17023SJohn Marinoto be called from target-specific code, it must only be done so when
10621e4b17023SJohn Marinobuilding the C and C++ compilers.  This can be done by defining the
10622e4b17023SJohn Marinovariables @code{c_target_objs} and @code{cxx_target_objs} in the
10623e4b17023SJohn Marinotarget entry in the @file{config.gcc} file.  These variables should name
10624e4b17023SJohn Marinothe target-specific, language-specific object file which contains the
10625e4b17023SJohn Marinocode that uses @code{pragma_lex}.  Note it will also be necessary to add a
10626e4b17023SJohn Marinorule to the makefile fragment pointed to by @code{tmake_file} that shows
10627e4b17023SJohn Marinohow to build this object file.
10628e4b17023SJohn Marino@end deftypefun
10629e4b17023SJohn Marino
10630e4b17023SJohn Marino@defmac HANDLE_PRAGMA_PACK_WITH_EXPANSION
10631e4b17023SJohn MarinoDefine this macro if macros should be expanded in the
10632e4b17023SJohn Marinoarguments of @samp{#pragma pack}.
10633e4b17023SJohn Marino@end defmac
10634e4b17023SJohn Marino
10635e4b17023SJohn Marino@hook TARGET_HANDLE_PRAGMA_EXTERN_PREFIX
10636e4b17023SJohn Marino
10637e4b17023SJohn Marino@defmac TARGET_DEFAULT_PACK_STRUCT
10638e4b17023SJohn MarinoIf your target requires a structure packing default other than 0 (meaning
10639e4b17023SJohn Marinothe machine default), define this macro to the necessary value (in bytes).
10640e4b17023SJohn MarinoThis must be a value that would also be valid to use with
10641e4b17023SJohn Marino@samp{#pragma pack()} (that is, a small power of two).
10642e4b17023SJohn Marino@end defmac
10643e4b17023SJohn Marino
10644e4b17023SJohn Marino@defmac DOLLARS_IN_IDENTIFIERS
10645e4b17023SJohn MarinoDefine this macro to control use of the character @samp{$} in
10646e4b17023SJohn Marinoidentifier names for the C family of languages.  0 means @samp{$} is
10647e4b17023SJohn Marinonot allowed by default; 1 means it is allowed.  1 is the default;
10648e4b17023SJohn Marinothere is no need to define this macro in that case.
10649e4b17023SJohn Marino@end defmac
10650e4b17023SJohn Marino
10651e4b17023SJohn Marino@defmac NO_DOLLAR_IN_LABEL
10652e4b17023SJohn MarinoDefine this macro if the assembler does not accept the character
10653e4b17023SJohn Marino@samp{$} in label names.  By default constructors and destructors in
10654e4b17023SJohn MarinoG++ have @samp{$} in the identifiers.  If this macro is defined,
10655e4b17023SJohn Marino@samp{.} is used instead.
10656e4b17023SJohn Marino@end defmac
10657e4b17023SJohn Marino
10658e4b17023SJohn Marino@defmac NO_DOT_IN_LABEL
10659e4b17023SJohn MarinoDefine this macro if the assembler does not accept the character
10660e4b17023SJohn Marino@samp{.} in label names.  By default constructors and destructors in G++
10661e4b17023SJohn Marinohave names that use @samp{.}.  If this macro is defined, these names
10662e4b17023SJohn Marinoare rewritten to avoid @samp{.}.
10663e4b17023SJohn Marino@end defmac
10664e4b17023SJohn Marino
10665e4b17023SJohn Marino@defmac INSN_SETS_ARE_DELAYED (@var{insn})
10666e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero if it is safe for the
10667e4b17023SJohn Marinodelay slot scheduler to place instructions in the delay slot of @var{insn},
10668e4b17023SJohn Marinoeven if they appear to use a resource set or clobbered in @var{insn}.
10669e4b17023SJohn Marino@var{insn} is always a @code{jump_insn} or an @code{insn}; GCC knows that
10670e4b17023SJohn Marinoevery @code{call_insn} has this behavior.  On machines where some @code{insn}
10671e4b17023SJohn Marinoor @code{jump_insn} is really a function call and hence has this behavior,
10672e4b17023SJohn Marinoyou should define this macro.
10673e4b17023SJohn Marino
10674e4b17023SJohn MarinoYou need not define this macro if it would always return zero.
10675e4b17023SJohn Marino@end defmac
10676e4b17023SJohn Marino
10677e4b17023SJohn Marino@defmac INSN_REFERENCES_ARE_DELAYED (@var{insn})
10678e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero if it is safe for the
10679e4b17023SJohn Marinodelay slot scheduler to place instructions in the delay slot of @var{insn},
10680e4b17023SJohn Marinoeven if they appear to set or clobber a resource referenced in @var{insn}.
10681e4b17023SJohn Marino@var{insn} is always a @code{jump_insn} or an @code{insn}.  On machines where
10682e4b17023SJohn Marinosome @code{insn} or @code{jump_insn} is really a function call and its operands
10683e4b17023SJohn Marinoare registers whose use is actually in the subroutine it calls, you should
10684e4b17023SJohn Marinodefine this macro.  Doing so allows the delay slot scheduler to move
10685e4b17023SJohn Marinoinstructions which copy arguments into the argument registers into the delay
10686e4b17023SJohn Marinoslot of @var{insn}.
10687e4b17023SJohn Marino
10688e4b17023SJohn MarinoYou need not define this macro if it would always return zero.
10689e4b17023SJohn Marino@end defmac
10690e4b17023SJohn Marino
10691e4b17023SJohn Marino@defmac MULTIPLE_SYMBOL_SPACES
10692e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero if, in some cases,
10693e4b17023SJohn Marinoglobal symbols from one translation unit may not be bound to undefined
10694e4b17023SJohn Marinosymbols in another translation unit without user intervention.  For
10695e4b17023SJohn Marinoinstance, under Microsoft Windows symbols must be explicitly imported
10696e4b17023SJohn Marinofrom shared libraries (DLLs).
10697e4b17023SJohn Marino
10698e4b17023SJohn MarinoYou need not define this macro if it would always evaluate to zero.
10699e4b17023SJohn Marino@end defmac
10700e4b17023SJohn Marino
10701e4b17023SJohn Marino@hook TARGET_MD_ASM_CLOBBERS
10702e4b17023SJohn MarinoThis target hook should add to @var{clobbers} @code{STRING_CST} trees for
10703e4b17023SJohn Marinoany hard regs the port wishes to automatically clobber for an asm.
10704e4b17023SJohn MarinoIt should return the result of the last @code{tree_cons} used to add a
10705e4b17023SJohn Marinoclobber.  The @var{outputs}, @var{inputs} and @var{clobber} lists are the
10706e4b17023SJohn Marinocorresponding parameters to the asm and may be inspected to avoid
10707e4b17023SJohn Marinoclobbering a register that is an input or output of the asm.  You can use
10708e4b17023SJohn Marino@code{tree_overlaps_hard_reg_set}, declared in @file{tree.h}, to test
10709e4b17023SJohn Marinofor overlap with regards to asm-declared registers.
10710e4b17023SJohn Marino@end deftypefn
10711e4b17023SJohn Marino
10712e4b17023SJohn Marino@defmac MATH_LIBRARY
10713e4b17023SJohn MarinoDefine this macro as a C string constant for the linker argument to link
10714e4b17023SJohn Marinoin the system math library, minus the initial @samp{"-l"}, or
10715e4b17023SJohn Marino@samp{""} if the target does not have a
10716e4b17023SJohn Marinoseparate math library.
10717e4b17023SJohn Marino
10718e4b17023SJohn MarinoYou need only define this macro if the default of @samp{"m"} is wrong.
10719e4b17023SJohn Marino@end defmac
10720e4b17023SJohn Marino
10721e4b17023SJohn Marino@defmac LIBRARY_PATH_ENV
10722e4b17023SJohn MarinoDefine this macro as a C string constant for the environment variable that
10723e4b17023SJohn Marinospecifies where the linker should look for libraries.
10724e4b17023SJohn Marino
10725e4b17023SJohn MarinoYou need only define this macro if the default of @samp{"LIBRARY_PATH"}
10726e4b17023SJohn Marinois wrong.
10727e4b17023SJohn Marino@end defmac
10728e4b17023SJohn Marino
10729e4b17023SJohn Marino@defmac TARGET_POSIX_IO
10730e4b17023SJohn MarinoDefine this macro if the target supports the following POSIX@ file
10731e4b17023SJohn Marinofunctions, access, mkdir and  file locking with fcntl / F_SETLKW@.
10732e4b17023SJohn MarinoDefining @code{TARGET_POSIX_IO} will enable the test coverage code
10733e4b17023SJohn Marinoto use file locking when exiting a program, which avoids race conditions
10734e4b17023SJohn Marinoif the program has forked. It will also create directories at run-time
10735e4b17023SJohn Marinofor cross-profiling.
10736e4b17023SJohn Marino@end defmac
10737e4b17023SJohn Marino
10738e4b17023SJohn Marino@defmac MAX_CONDITIONAL_EXECUTE
10739e4b17023SJohn Marino
10740e4b17023SJohn MarinoA C expression for the maximum number of instructions to execute via
10741e4b17023SJohn Marinoconditional execution instructions instead of a branch.  A value of
10742e4b17023SJohn Marino@code{BRANCH_COST}+1 is the default if the machine does not use cc0, and
10743e4b17023SJohn Marino1 if it does use cc0.
10744e4b17023SJohn Marino@end defmac
10745e4b17023SJohn Marino
10746e4b17023SJohn Marino@defmac IFCVT_MODIFY_TESTS (@var{ce_info}, @var{true_expr}, @var{false_expr})
10747e4b17023SJohn MarinoUsed if the target needs to perform machine-dependent modifications on the
10748e4b17023SJohn Marinoconditionals used for turning basic blocks into conditionally executed code.
10749e4b17023SJohn Marino@var{ce_info} points to a data structure, @code{struct ce_if_block}, which
10750e4b17023SJohn Marinocontains information about the currently processed blocks.  @var{true_expr}
10751e4b17023SJohn Marinoand @var{false_expr} are the tests that are used for converting the
10752e4b17023SJohn Marinothen-block and the else-block, respectively.  Set either @var{true_expr} or
10753e4b17023SJohn Marino@var{false_expr} to a null pointer if the tests cannot be converted.
10754e4b17023SJohn Marino@end defmac
10755e4b17023SJohn Marino
10756e4b17023SJohn Marino@defmac IFCVT_MODIFY_MULTIPLE_TESTS (@var{ce_info}, @var{bb}, @var{true_expr}, @var{false_expr})
10757e4b17023SJohn MarinoLike @code{IFCVT_MODIFY_TESTS}, but used when converting more complicated
10758e4b17023SJohn Marinoif-statements into conditions combined by @code{and} and @code{or} operations.
10759e4b17023SJohn Marino@var{bb} contains the basic block that contains the test that is currently
10760e4b17023SJohn Marinobeing processed and about to be turned into a condition.
10761e4b17023SJohn Marino@end defmac
10762e4b17023SJohn Marino
10763e4b17023SJohn Marino@defmac IFCVT_MODIFY_INSN (@var{ce_info}, @var{pattern}, @var{insn})
10764e4b17023SJohn MarinoA C expression to modify the @var{PATTERN} of an @var{INSN} that is to
10765e4b17023SJohn Marinobe converted to conditional execution format.  @var{ce_info} points to
10766e4b17023SJohn Marinoa data structure, @code{struct ce_if_block}, which contains information
10767e4b17023SJohn Marinoabout the currently processed blocks.
10768e4b17023SJohn Marino@end defmac
10769e4b17023SJohn Marino
10770e4b17023SJohn Marino@defmac IFCVT_MODIFY_FINAL (@var{ce_info})
10771e4b17023SJohn MarinoA C expression to perform any final machine dependent modifications in
10772e4b17023SJohn Marinoconverting code to conditional execution.  The involved basic blocks
10773e4b17023SJohn Marinocan be found in the @code{struct ce_if_block} structure that is pointed
10774e4b17023SJohn Marinoto by @var{ce_info}.
10775e4b17023SJohn Marino@end defmac
10776e4b17023SJohn Marino
10777e4b17023SJohn Marino@defmac IFCVT_MODIFY_CANCEL (@var{ce_info})
10778e4b17023SJohn MarinoA C expression to cancel any machine dependent modifications in
10779e4b17023SJohn Marinoconverting code to conditional execution.  The involved basic blocks
10780e4b17023SJohn Marinocan be found in the @code{struct ce_if_block} structure that is pointed
10781e4b17023SJohn Marinoto by @var{ce_info}.
10782e4b17023SJohn Marino@end defmac
10783e4b17023SJohn Marino
10784e4b17023SJohn Marino@defmac IFCVT_INIT_EXTRA_FIELDS (@var{ce_info})
10785e4b17023SJohn MarinoA C expression to initialize any extra fields in a @code{struct ce_if_block}
10786e4b17023SJohn Marinostructure, which are defined by the @code{IFCVT_EXTRA_FIELDS} macro.
10787e4b17023SJohn Marino@end defmac
10788e4b17023SJohn Marino
10789e4b17023SJohn Marino@defmac IFCVT_EXTRA_FIELDS
10790e4b17023SJohn MarinoIf defined, it should expand to a set of field declarations that will be
10791e4b17023SJohn Marinoadded to the @code{struct ce_if_block} structure.  These should be initialized
10792e4b17023SJohn Marinoby the @code{IFCVT_INIT_EXTRA_FIELDS} macro.
10793e4b17023SJohn Marino@end defmac
10794e4b17023SJohn Marino
10795e4b17023SJohn Marino@hook TARGET_MACHINE_DEPENDENT_REORG
10796e4b17023SJohn MarinoIf non-null, this hook performs a target-specific pass over the
10797e4b17023SJohn Marinoinstruction stream.  The compiler will run it at all optimization levels,
10798e4b17023SJohn Marinojust before the point at which it normally does delayed-branch scheduling.
10799e4b17023SJohn Marino
10800e4b17023SJohn MarinoThe exact purpose of the hook varies from target to target.  Some use
10801e4b17023SJohn Marinoit to do transformations that are necessary for correctness, such as
10802e4b17023SJohn Marinolaying out in-function constant pools or avoiding hardware hazards.
10803e4b17023SJohn MarinoOthers use it as an opportunity to do some machine-dependent optimizations.
10804e4b17023SJohn Marino
10805e4b17023SJohn MarinoYou need not implement the hook if it has nothing to do.  The default
10806e4b17023SJohn Marinodefinition is null.
10807e4b17023SJohn Marino@end deftypefn
10808e4b17023SJohn Marino
10809e4b17023SJohn Marino@hook TARGET_INIT_BUILTINS
10810e4b17023SJohn MarinoDefine this hook if you have any machine-specific built-in functions
10811e4b17023SJohn Marinothat need to be defined.  It should be a function that performs the
10812e4b17023SJohn Marinonecessary setup.
10813e4b17023SJohn Marino
10814e4b17023SJohn MarinoMachine specific built-in functions can be useful to expand special machine
10815e4b17023SJohn Marinoinstructions that would otherwise not normally be generated because
10816e4b17023SJohn Marinothey have no equivalent in the source language (for example, SIMD vector
10817e4b17023SJohn Marinoinstructions or prefetch instructions).
10818e4b17023SJohn Marino
10819e4b17023SJohn MarinoTo create a built-in function, call the function
10820e4b17023SJohn Marino@code{lang_hooks.builtin_function}
10821e4b17023SJohn Marinowhich is defined by the language front end.  You can use any type nodes set
10822e4b17023SJohn Marinoup by @code{build_common_tree_nodes};
10823e4b17023SJohn Marinoonly language front ends that use those two functions will call
10824e4b17023SJohn Marino@samp{TARGET_INIT_BUILTINS}.
10825e4b17023SJohn Marino@end deftypefn
10826e4b17023SJohn Marino
10827e4b17023SJohn Marino@hook TARGET_BUILTIN_DECL
10828e4b17023SJohn MarinoDefine this hook if you have any machine-specific built-in functions
10829e4b17023SJohn Marinothat need to be defined.  It should be a function that returns the
10830e4b17023SJohn Marinobuiltin function declaration for the builtin function code @var{code}.
10831e4b17023SJohn MarinoIf there is no such builtin and it cannot be initialized at this time
10832e4b17023SJohn Marinoif @var{initialize_p} is true the function should return @code{NULL_TREE}.
10833e4b17023SJohn MarinoIf @var{code} is out of range the function should return
10834e4b17023SJohn Marino@code{error_mark_node}.
10835e4b17023SJohn Marino@end deftypefn
10836e4b17023SJohn Marino
10837e4b17023SJohn Marino@hook TARGET_EXPAND_BUILTIN
10838e4b17023SJohn Marino
10839e4b17023SJohn MarinoExpand a call to a machine specific built-in function that was set up by
10840e4b17023SJohn Marino@samp{TARGET_INIT_BUILTINS}.  @var{exp} is the expression for the
10841e4b17023SJohn Marinofunction call; the result should go to @var{target} if that is
10842e4b17023SJohn Marinoconvenient, and have mode @var{mode} if that is convenient.
10843e4b17023SJohn Marino@var{subtarget} may be used as the target for computing one of
10844e4b17023SJohn Marino@var{exp}'s operands.  @var{ignore} is nonzero if the value is to be
10845e4b17023SJohn Marinoignored.  This function should return the result of the call to the
10846e4b17023SJohn Marinobuilt-in function.
10847e4b17023SJohn Marino@end deftypefn
10848e4b17023SJohn Marino
10849e4b17023SJohn Marino@hook TARGET_RESOLVE_OVERLOADED_BUILTIN
10850e4b17023SJohn MarinoSelect a replacement for a machine specific built-in function that
10851e4b17023SJohn Marinowas set up by @samp{TARGET_INIT_BUILTINS}.  This is done
10852e4b17023SJohn Marino@emph{before} regular type checking, and so allows the target to
10853e4b17023SJohn Marinoimplement a crude form of function overloading.  @var{fndecl} is the
10854e4b17023SJohn Marinodeclaration of the built-in function.  @var{arglist} is the list of
10855e4b17023SJohn Marinoarguments passed to the built-in function.  The result is a
10856e4b17023SJohn Marinocomplete expression that implements the operation, usually
10857e4b17023SJohn Marinoanother @code{CALL_EXPR}.
10858e4b17023SJohn Marino@var{arglist} really has type @samp{VEC(tree,gc)*}
10859e4b17023SJohn Marino@end deftypefn
10860e4b17023SJohn Marino
10861e4b17023SJohn Marino@hook TARGET_FOLD_BUILTIN
10862e4b17023SJohn MarinoFold a call to a machine specific built-in function that was set up by
10863e4b17023SJohn Marino@samp{TARGET_INIT_BUILTINS}.  @var{fndecl} is the declaration of the
10864e4b17023SJohn Marinobuilt-in function.  @var{n_args} is the number of arguments passed to
10865e4b17023SJohn Marinothe function; the arguments themselves are pointed to by @var{argp}.
10866e4b17023SJohn MarinoThe result is another tree containing a simplified expression for the
10867e4b17023SJohn Marinocall's result.  If @var{ignore} is true the value will be ignored.
10868e4b17023SJohn Marino@end deftypefn
10869e4b17023SJohn Marino
10870e4b17023SJohn Marino@hook TARGET_INVALID_WITHIN_DOLOOP
10871e4b17023SJohn Marino
10872e4b17023SJohn MarinoTake an instruction in @var{insn} and return NULL if it is valid within a
10873e4b17023SJohn Marinolow-overhead loop, otherwise return a string explaining why doloop
10874e4b17023SJohn Marinocould not be applied.
10875e4b17023SJohn Marino
10876e4b17023SJohn MarinoMany targets use special registers for low-overhead looping. For any
10877e4b17023SJohn Marinoinstruction that clobbers these this function should return a string indicating
10878e4b17023SJohn Marinothe reason why the doloop could not be applied.
10879e4b17023SJohn MarinoBy default, the RTL loop optimizer does not use a present doloop pattern for
10880e4b17023SJohn Marinoloops containing function calls or branch on table instructions.
10881e4b17023SJohn Marino@end deftypefn
10882e4b17023SJohn Marino
10883e4b17023SJohn Marino@defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2})
10884e4b17023SJohn Marino
10885e4b17023SJohn MarinoTake a branch insn in @var{branch1} and another in @var{branch2}.
10886e4b17023SJohn MarinoReturn true if redirecting @var{branch1} to the destination of
10887e4b17023SJohn Marino@var{branch2} is possible.
10888e4b17023SJohn Marino
10889e4b17023SJohn MarinoOn some targets, branches may have a limited range.  Optimizing the
10890e4b17023SJohn Marinofilling of delay slots can result in branches being redirected, and this
10891e4b17023SJohn Marinomay in turn cause a branch offset to overflow.
10892e4b17023SJohn Marino@end defmac
10893e4b17023SJohn Marino
10894e4b17023SJohn Marino@hook TARGET_COMMUTATIVE_P
10895e4b17023SJohn MarinoThis target hook returns @code{true} if @var{x} is considered to be commutative.
10896e4b17023SJohn MarinoUsually, this is just COMMUTATIVE_P (@var{x}), but the HP PA doesn't consider
10897e4b17023SJohn MarinoPLUS to be commutative inside a MEM@.  @var{outer_code} is the rtx code
10898e4b17023SJohn Marinoof the enclosing rtl, if known, otherwise it is UNKNOWN.
10899e4b17023SJohn Marino@end deftypefn
10900e4b17023SJohn Marino
10901e4b17023SJohn Marino@hook TARGET_ALLOCATE_INITIAL_VALUE
10902e4b17023SJohn Marino
10903e4b17023SJohn MarinoWhen the initial value of a hard register has been copied in a pseudo
10904e4b17023SJohn Marinoregister, it is often not necessary to actually allocate another register
10905e4b17023SJohn Marinoto this pseudo register, because the original hard register or a stack slot
10906e4b17023SJohn Marinoit has been saved into can be used.  @code{TARGET_ALLOCATE_INITIAL_VALUE}
10907e4b17023SJohn Marinois called at the start of register allocation once for each hard register
10908e4b17023SJohn Marinothat had its initial value copied by using
10909e4b17023SJohn Marino@code{get_func_hard_reg_initial_val} or @code{get_hard_reg_initial_val}.
10910e4b17023SJohn MarinoPossible values are @code{NULL_RTX}, if you don't want
10911e4b17023SJohn Marinoto do any special allocation, a @code{REG} rtx---that would typically be
10912e4b17023SJohn Marinothe hard register itself, if it is known not to be clobbered---or a
10913e4b17023SJohn Marino@code{MEM}.
10914e4b17023SJohn MarinoIf you are returning a @code{MEM}, this is only a hint for the allocator;
10915e4b17023SJohn Marinoit might decide to use another register anyways.
10916e4b17023SJohn MarinoYou may use @code{current_function_leaf_function} in the hook, functions
10917e4b17023SJohn Marinothat use @code{REG_N_SETS}, to determine if the hard
10918e4b17023SJohn Marinoregister in question will not be clobbered.
10919e4b17023SJohn MarinoThe default value of this hook is @code{NULL}, which disables any special
10920e4b17023SJohn Marinoallocation.
10921e4b17023SJohn Marino@end deftypefn
10922e4b17023SJohn Marino
10923e4b17023SJohn Marino@hook TARGET_UNSPEC_MAY_TRAP_P
10924e4b17023SJohn MarinoThis target hook returns nonzero if @var{x}, an @code{unspec} or
10925e4b17023SJohn Marino@code{unspec_volatile} operation, might cause a trap.  Targets can use
10926e4b17023SJohn Marinothis hook to enhance precision of analysis for @code{unspec} and
10927e4b17023SJohn Marino@code{unspec_volatile} operations.  You may call @code{may_trap_p_1}
10928e4b17023SJohn Marinoto analyze inner elements of @var{x} in which case @var{flags} should be
10929e4b17023SJohn Marinopassed along.
10930e4b17023SJohn Marino@end deftypefn
10931e4b17023SJohn Marino
10932e4b17023SJohn Marino@hook TARGET_SET_CURRENT_FUNCTION
10933e4b17023SJohn MarinoThe compiler invokes this hook whenever it changes its current function
10934e4b17023SJohn Marinocontext (@code{cfun}).  You can define this function if
10935e4b17023SJohn Marinothe back end needs to perform any initialization or reset actions on a
10936e4b17023SJohn Marinoper-function basis.  For example, it may be used to implement function
10937e4b17023SJohn Marinoattributes that affect register usage or code generation patterns.
10938e4b17023SJohn MarinoThe argument @var{decl} is the declaration for the new function context,
10939e4b17023SJohn Marinoand may be null to indicate that the compiler has left a function context
10940e4b17023SJohn Marinoand is returning to processing at the top level.
10941e4b17023SJohn MarinoThe default hook function does nothing.
10942e4b17023SJohn Marino
10943e4b17023SJohn MarinoGCC sets @code{cfun} to a dummy function context during initialization of
10944e4b17023SJohn Marinosome parts of the back end.  The hook function is not invoked in this
10945e4b17023SJohn Marinosituation; you need not worry about the hook being invoked recursively,
10946e4b17023SJohn Marinoor when the back end is in a partially-initialized state.
10947e4b17023SJohn Marino@code{cfun} might be @code{NULL} to indicate processing at top level,
10948e4b17023SJohn Marinooutside of any function scope.
10949e4b17023SJohn Marino@end deftypefn
10950e4b17023SJohn Marino
10951e4b17023SJohn Marino@defmac TARGET_OBJECT_SUFFIX
10952e4b17023SJohn MarinoDefine this macro to be a C string representing the suffix for object
10953e4b17023SJohn Marinofiles on your target machine.  If you do not define this macro, GCC will
10954e4b17023SJohn Marinouse @samp{.o} as the suffix for object files.
10955e4b17023SJohn Marino@end defmac
10956e4b17023SJohn Marino
10957e4b17023SJohn Marino@defmac TARGET_EXECUTABLE_SUFFIX
10958e4b17023SJohn MarinoDefine this macro to be a C string representing the suffix to be
10959e4b17023SJohn Marinoautomatically added to executable files on your target machine.  If you
10960e4b17023SJohn Marinodo not define this macro, GCC will use the null string as the suffix for
10961e4b17023SJohn Marinoexecutable files.
10962e4b17023SJohn Marino@end defmac
10963e4b17023SJohn Marino
10964e4b17023SJohn Marino@defmac COLLECT_EXPORT_LIST
10965e4b17023SJohn MarinoIf defined, @code{collect2} will scan the individual object files
10966e4b17023SJohn Marinospecified on its command line and create an export list for the linker.
10967e4b17023SJohn MarinoDefine this macro for systems like AIX, where the linker discards
10968e4b17023SJohn Marinoobject files that are not referenced from @code{main} and uses export
10969e4b17023SJohn Marinolists.
10970e4b17023SJohn Marino@end defmac
10971e4b17023SJohn Marino
10972e4b17023SJohn Marino@defmac MODIFY_JNI_METHOD_CALL (@var{mdecl})
10973e4b17023SJohn MarinoDefine this macro to a C expression representing a variant of the
10974e4b17023SJohn Marinomethod call @var{mdecl}, if Java Native Interface (JNI) methods
10975e4b17023SJohn Marinomust be invoked differently from other methods on your target.
10976e4b17023SJohn MarinoFor example, on 32-bit Microsoft Windows, JNI methods must be invoked using
10977e4b17023SJohn Marinothe @code{stdcall} calling convention and this macro is then
10978e4b17023SJohn Marinodefined as this expression:
10979e4b17023SJohn Marino
10980e4b17023SJohn Marino@smallexample
10981e4b17023SJohn Marinobuild_type_attribute_variant (@var{mdecl},
10982e4b17023SJohn Marino                              build_tree_list
10983e4b17023SJohn Marino                              (get_identifier ("stdcall"),
10984e4b17023SJohn Marino                               NULL))
10985e4b17023SJohn Marino@end smallexample
10986e4b17023SJohn Marino@end defmac
10987e4b17023SJohn Marino
10988e4b17023SJohn Marino@hook TARGET_CANNOT_MODIFY_JUMPS_P
10989e4b17023SJohn MarinoThis target hook returns @code{true} past the point in which new jump
10990e4b17023SJohn Marinoinstructions could be created.  On machines that require a register for
10991e4b17023SJohn Marinoevery jump such as the SHmedia ISA of SH5, this point would typically be
10992e4b17023SJohn Marinoreload, so this target hook should be defined to a function such as:
10993e4b17023SJohn Marino
10994e4b17023SJohn Marino@smallexample
10995e4b17023SJohn Marinostatic bool
10996e4b17023SJohn Marinocannot_modify_jumps_past_reload_p ()
10997e4b17023SJohn Marino@{
10998e4b17023SJohn Marino  return (reload_completed || reload_in_progress);
10999e4b17023SJohn Marino@}
11000e4b17023SJohn Marino@end smallexample
11001e4b17023SJohn Marino@end deftypefn
11002e4b17023SJohn Marino
11003e4b17023SJohn Marino@hook TARGET_BRANCH_TARGET_REGISTER_CLASS
11004e4b17023SJohn MarinoThis target hook returns a register class for which branch target register
11005e4b17023SJohn Marinooptimizations should be applied.  All registers in this class should be
11006e4b17023SJohn Marinousable interchangeably.  After reload, registers in this class will be
11007e4b17023SJohn Marinore-allocated and loads will be hoisted out of loops and be subjected
11008e4b17023SJohn Marinoto inter-block scheduling.
11009e4b17023SJohn Marino@end deftypefn
11010e4b17023SJohn Marino
11011e4b17023SJohn Marino@hook TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED
11012e4b17023SJohn MarinoBranch target register optimization will by default exclude callee-saved
11013e4b17023SJohn Marinoregisters
11014e4b17023SJohn Marinothat are not already live during the current function; if this target hook
11015e4b17023SJohn Marinoreturns true, they will be included.  The target code must than make sure
11016e4b17023SJohn Marinothat all target registers in the class returned by
11017e4b17023SJohn Marino@samp{TARGET_BRANCH_TARGET_REGISTER_CLASS} that might need saving are
11018e4b17023SJohn Marinosaved.  @var{after_prologue_epilogue_gen} indicates if prologues and
11019e4b17023SJohn Marinoepilogues have already been generated.  Note, even if you only return
11020e4b17023SJohn Marinotrue when @var{after_prologue_epilogue_gen} is false, you still are likely
11021e4b17023SJohn Marinoto have to make special provisions in @code{INITIAL_ELIMINATION_OFFSET}
11022e4b17023SJohn Marinoto reserve space for caller-saved target registers.
11023e4b17023SJohn Marino@end deftypefn
11024e4b17023SJohn Marino
11025e4b17023SJohn Marino@hook TARGET_HAVE_CONDITIONAL_EXECUTION
11026e4b17023SJohn MarinoThis target hook returns true if the target supports conditional execution.
11027e4b17023SJohn MarinoThis target hook is required only when the target has several different
11028e4b17023SJohn Marinomodes and they have different conditional execution capability, such as ARM.
11029e4b17023SJohn Marino@end deftypefn
11030e4b17023SJohn Marino
11031e4b17023SJohn Marino@hook TARGET_LOOP_UNROLL_ADJUST
11032e4b17023SJohn MarinoThis target hook returns a new value for the number of times @var{loop}
11033e4b17023SJohn Marinoshould be unrolled. The parameter @var{nunroll} is the number of times
11034e4b17023SJohn Marinothe loop is to be unrolled. The parameter @var{loop} is a pointer to
11035e4b17023SJohn Marinothe loop, which is going to be checked for unrolling. This target hook
11036e4b17023SJohn Marinois required only when the target has special constraints like maximum
11037e4b17023SJohn Marinonumber of memory accesses.
11038e4b17023SJohn Marino@end deftypefn
11039e4b17023SJohn Marino
11040e4b17023SJohn Marino@defmac POWI_MAX_MULTS
11041e4b17023SJohn MarinoIf defined, this macro is interpreted as a signed integer C expression
11042e4b17023SJohn Marinothat specifies the maximum number of floating point multiplications
11043e4b17023SJohn Marinothat should be emitted when expanding exponentiation by an integer
11044e4b17023SJohn Marinoconstant inline.  When this value is defined, exponentiation requiring
11045e4b17023SJohn Marinomore than this number of multiplications is implemented by calling the
11046e4b17023SJohn Marinosystem library's @code{pow}, @code{powf} or @code{powl} routines.
11047e4b17023SJohn MarinoThe default value places no upper bound on the multiplication count.
11048e4b17023SJohn Marino@end defmac
11049e4b17023SJohn Marino
11050e4b17023SJohn Marino@deftypefn Macro void TARGET_EXTRA_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
11051e4b17023SJohn MarinoThis target hook should register any extra include files for the
11052e4b17023SJohn Marinotarget.  The parameter @var{stdinc} indicates if normal include files
11053e4b17023SJohn Marinoare present.  The parameter @var{sysroot} is the system root directory.
11054e4b17023SJohn MarinoThe parameter @var{iprefix} is the prefix for the gcc directory.
11055e4b17023SJohn Marino@end deftypefn
11056e4b17023SJohn Marino
11057e4b17023SJohn Marino@deftypefn Macro void TARGET_EXTRA_PRE_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
11058e4b17023SJohn MarinoThis target hook should register any extra include files for the
11059e4b17023SJohn Marinotarget before any standard headers.  The parameter @var{stdinc}
11060e4b17023SJohn Marinoindicates if normal include files are present.  The parameter
11061e4b17023SJohn Marino@var{sysroot} is the system root directory.  The parameter
11062e4b17023SJohn Marino@var{iprefix} is the prefix for the gcc directory.
11063e4b17023SJohn Marino@end deftypefn
11064e4b17023SJohn Marino
11065e4b17023SJohn Marino@deftypefn Macro void TARGET_OPTF (char *@var{path})
11066e4b17023SJohn MarinoThis target hook should register special include paths for the target.
11067e4b17023SJohn MarinoThe parameter @var{path} is the include to register.  On Darwin
11068e4b17023SJohn Marinosystems, this is used for Framework includes, which have semantics
11069e4b17023SJohn Marinothat are different from @option{-I}.
11070e4b17023SJohn Marino@end deftypefn
11071e4b17023SJohn Marino
11072e4b17023SJohn Marino@defmac bool TARGET_USE_LOCAL_THUNK_ALIAS_P (tree @var{fndecl})
11073e4b17023SJohn MarinoThis target macro returns @code{true} if it is safe to use a local alias
11074e4b17023SJohn Marinofor a virtual function @var{fndecl} when constructing thunks,
11075e4b17023SJohn Marino@code{false} otherwise.  By default, the macro returns @code{true} for all
11076e4b17023SJohn Marinofunctions, if a target supports aliases (i.e.@: defines
11077e4b17023SJohn Marino@code{ASM_OUTPUT_DEF}), @code{false} otherwise,
11078e4b17023SJohn Marino@end defmac
11079e4b17023SJohn Marino
11080e4b17023SJohn Marino@defmac TARGET_FORMAT_TYPES
11081e4b17023SJohn MarinoIf defined, this macro is the name of a global variable containing
11082e4b17023SJohn Marinotarget-specific format checking information for the @option{-Wformat}
11083e4b17023SJohn Marinooption.  The default is to have no target-specific format checks.
11084e4b17023SJohn Marino@end defmac
11085e4b17023SJohn Marino
11086e4b17023SJohn Marino@defmac TARGET_N_FORMAT_TYPES
11087e4b17023SJohn MarinoIf defined, this macro is the number of entries in
11088e4b17023SJohn Marino@code{TARGET_FORMAT_TYPES}.
11089e4b17023SJohn Marino@end defmac
11090e4b17023SJohn Marino
11091e4b17023SJohn Marino@defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES
11092e4b17023SJohn MarinoIf defined, this macro is the name of a global variable containing
11093e4b17023SJohn Marinotarget-specific format overrides for the @option{-Wformat} option. The
11094e4b17023SJohn Marinodefault is to have no target-specific format overrides. If defined,
11095e4b17023SJohn Marino@code{TARGET_FORMAT_TYPES} must be defined, too.
11096e4b17023SJohn Marino@end defmac
11097e4b17023SJohn Marino
11098e4b17023SJohn Marino@defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
11099e4b17023SJohn MarinoIf defined, this macro specifies the number of entries in
11100e4b17023SJohn Marino@code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
11101e4b17023SJohn Marino@end defmac
11102e4b17023SJohn Marino
11103e4b17023SJohn Marino@defmac TARGET_OVERRIDES_FORMAT_INIT
11104e4b17023SJohn MarinoIf defined, this macro specifies the optional initialization
11105e4b17023SJohn Marinoroutine for target specific customizations of the system printf
11106e4b17023SJohn Marinoand scanf formatter settings.
11107e4b17023SJohn Marino@end defmac
11108e4b17023SJohn Marino
11109e4b17023SJohn Marino@hook TARGET_RELAXED_ORDERING
11110e4b17023SJohn MarinoIf set to @code{true}, means that the target's memory model does not
11111e4b17023SJohn Marinoguarantee that loads which do not depend on one another will access
11112e4b17023SJohn Marinomain memory in the order of the instruction stream; if ordering is
11113e4b17023SJohn Marinoimportant, an explicit memory barrier must be used.  This is true of
11114e4b17023SJohn Marinomany recent processors which implement a policy of ``relaxed,''
11115e4b17023SJohn Marino``weak,'' or ``release'' memory consistency, such as Alpha, PowerPC,
11116e4b17023SJohn Marinoand ia64.  The default is @code{false}.
11117e4b17023SJohn Marino@end deftypevr
11118e4b17023SJohn Marino
11119e4b17023SJohn Marino@hook TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
11120e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is
11121e4b17023SJohn Marinoillegal to pass argument @var{val} to function @var{funcdecl}
11122e4b17023SJohn Marinowith prototype @var{typelist}.
11123e4b17023SJohn Marino@end deftypefn
11124e4b17023SJohn Marino
11125e4b17023SJohn Marino@hook TARGET_INVALID_CONVERSION
11126e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is
11127e4b17023SJohn Marinoinvalid to convert from @var{fromtype} to @var{totype}, or @code{NULL}
11128e4b17023SJohn Marinoif validity should be determined by the front end.
11129e4b17023SJohn Marino@end deftypefn
11130e4b17023SJohn Marino
11131e4b17023SJohn Marino@hook TARGET_INVALID_UNARY_OP
11132e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is
11133e4b17023SJohn Marinoinvalid to apply operation @var{op} (where unary plus is denoted by
11134e4b17023SJohn Marino@code{CONVERT_EXPR}) to an operand of type @var{type}, or @code{NULL}
11135e4b17023SJohn Marinoif validity should be determined by the front end.
11136e4b17023SJohn Marino@end deftypefn
11137e4b17023SJohn Marino
11138e4b17023SJohn Marino@hook TARGET_INVALID_BINARY_OP
11139e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is
11140e4b17023SJohn Marinoinvalid to apply operation @var{op} to operands of types @var{type1}
11141e4b17023SJohn Marinoand @var{type2}, or @code{NULL} if validity should be determined by
11142e4b17023SJohn Marinothe front end.
11143e4b17023SJohn Marino@end deftypefn
11144e4b17023SJohn Marino
11145e4b17023SJohn Marino@hook TARGET_INVALID_PARAMETER_TYPE
11146e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is
11147e4b17023SJohn Marinoinvalid for functions to include parameters of type @var{type},
11148e4b17023SJohn Marinoor @code{NULL} if validity should be determined by
11149e4b17023SJohn Marinothe front end.  This is currently used only by the C and C++ front ends.
11150e4b17023SJohn Marino@end deftypefn
11151e4b17023SJohn Marino
11152e4b17023SJohn Marino@hook TARGET_INVALID_RETURN_TYPE
11153e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is
11154e4b17023SJohn Marinoinvalid for functions to have return type @var{type},
11155e4b17023SJohn Marinoor @code{NULL} if validity should be determined by
11156e4b17023SJohn Marinothe front end.  This is currently used only by the C and C++ front ends.
11157e4b17023SJohn Marino@end deftypefn
11158e4b17023SJohn Marino
11159e4b17023SJohn Marino@hook TARGET_PROMOTED_TYPE
11160e4b17023SJohn MarinoIf defined, this target hook returns the type to which values of
11161e4b17023SJohn Marino@var{type} should be promoted when they appear in expressions,
11162e4b17023SJohn Marinoanalogous to the integer promotions, or @code{NULL_TREE} to use the
11163e4b17023SJohn Marinofront end's normal promotion rules.  This hook is useful when there are
11164e4b17023SJohn Marinotarget-specific types with special promotion rules.
11165e4b17023SJohn MarinoThis is currently used only by the C and C++ front ends.
11166e4b17023SJohn Marino@end deftypefn
11167e4b17023SJohn Marino
11168e4b17023SJohn Marino@hook TARGET_CONVERT_TO_TYPE
11169e4b17023SJohn MarinoIf defined, this hook returns the result of converting @var{expr} to
11170e4b17023SJohn Marino@var{type}.  It should return the converted expression,
11171e4b17023SJohn Marinoor @code{NULL_TREE} to apply the front end's normal conversion rules.
11172e4b17023SJohn MarinoThis hook is useful when there are target-specific types with special
11173e4b17023SJohn Marinoconversion rules.
11174e4b17023SJohn MarinoThis is currently used only by the C and C++ front ends.
11175e4b17023SJohn Marino@end deftypefn
11176e4b17023SJohn Marino
11177e4b17023SJohn Marino@defmac TARGET_USE_JCR_SECTION
11178e4b17023SJohn MarinoThis macro determines whether to use the JCR section to register Java
11179e4b17023SJohn Marinoclasses. By default, TARGET_USE_JCR_SECTION is defined to 1 if both
11180e4b17023SJohn MarinoSUPPORTS_WEAK and TARGET_HAVE_NAMED_SECTIONS are true, else 0.
11181e4b17023SJohn Marino@end defmac
11182e4b17023SJohn Marino
11183e4b17023SJohn Marino@defmac OBJC_JBLEN
11184e4b17023SJohn MarinoThis macro determines the size of the objective C jump buffer for the
11185e4b17023SJohn MarinoNeXT runtime. By default, OBJC_JBLEN is defined to an innocuous value.
11186e4b17023SJohn Marino@end defmac
11187e4b17023SJohn Marino
11188e4b17023SJohn Marino@defmac LIBGCC2_UNWIND_ATTRIBUTE
11189e4b17023SJohn MarinoDefine this macro if any target-specific attributes need to be attached
11190e4b17023SJohn Marinoto the functions in @file{libgcc} that provide low-level support for
11191e4b17023SJohn Marinocall stack unwinding.  It is used in declarations in @file{unwind-generic.h}
11192e4b17023SJohn Marinoand the associated definitions of those functions.
11193e4b17023SJohn Marino@end defmac
11194e4b17023SJohn Marino
11195e4b17023SJohn Marino@hook TARGET_UPDATE_STACK_BOUNDARY
11196e4b17023SJohn MarinoDefine this macro to update the current function stack boundary if
11197e4b17023SJohn Marinonecessary.
11198e4b17023SJohn Marino@end deftypefn
11199e4b17023SJohn Marino
11200e4b17023SJohn Marino@hook TARGET_GET_DRAP_RTX
11201e4b17023SJohn MarinoThis hook should return an rtx for Dynamic Realign Argument Pointer (DRAP) if a
11202e4b17023SJohn Marinodifferent argument pointer register is needed to access the function's
11203e4b17023SJohn Marinoargument list due to stack realignment.  Return @code{NULL} if no DRAP
11204e4b17023SJohn Marinois needed.
11205e4b17023SJohn Marino@end deftypefn
11206e4b17023SJohn Marino
11207e4b17023SJohn Marino@hook TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS
11208e4b17023SJohn MarinoWhen optimization is disabled, this hook indicates whether or not
11209e4b17023SJohn Marinoarguments should be allocated to stack slots.  Normally, GCC allocates
11210e4b17023SJohn Marinostacks slots for arguments when not optimizing in order to make
11211e4b17023SJohn Marinodebugging easier.  However, when a function is declared with
11212e4b17023SJohn Marino@code{__attribute__((naked))}, there is no stack frame, and the compiler
11213e4b17023SJohn Marinocannot safely move arguments from the registers in which they are passed
11214e4b17023SJohn Marinoto the stack.  Therefore, this hook should return true in general, but
11215e4b17023SJohn Marinofalse for naked functions.  The default implementation always returns true.
11216e4b17023SJohn Marino@end deftypefn
11217e4b17023SJohn Marino
11218e4b17023SJohn Marino@hook TARGET_CONST_ANCHOR
11219e4b17023SJohn MarinoOn some architectures it can take multiple instructions to synthesize
11220e4b17023SJohn Marinoa constant.  If there is another constant already in a register that
11221e4b17023SJohn Marinois close enough in value then it is preferable that the new constant
11222e4b17023SJohn Marinois computed from this register using immediate addition or
11223e4b17023SJohn Marinosubtraction.  We accomplish this through CSE.  Besides the value of
11224e4b17023SJohn Marinothe constant we also add a lower and an upper constant anchor to the
11225e4b17023SJohn Marinoavailable expressions.  These are then queried when encountering new
11226e4b17023SJohn Marinoconstants.  The anchors are computed by rounding the constant up and
11227e4b17023SJohn Marinodown to a multiple of the value of @code{TARGET_CONST_ANCHOR}.
11228e4b17023SJohn Marino@code{TARGET_CONST_ANCHOR} should be the maximum positive value
11229e4b17023SJohn Marinoaccepted by immediate-add plus one.  We currently assume that the
11230e4b17023SJohn Marinovalue of @code{TARGET_CONST_ANCHOR} is a power of 2.  For example, on
11231e4b17023SJohn MarinoMIPS, where add-immediate takes a 16-bit signed value,
11232e4b17023SJohn Marino@code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}.  The default value
11233e4b17023SJohn Marinois zero, which disables this optimization.  @end deftypevr
11234e4b17023SJohn Marino
11235e4b17023SJohn Marino@hook TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
11236