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@deftypevr {Common Target Hook} bool TARGET_ALWAYS_STRIP_DOTDOT 397e4b17023SJohn MarinoTrue if @file{..} components should always be removed from directory names computed relative to GCC's internal directories, false (default) if such components should be preserved and directory names containing them passed to other tools such as the linker. 398e4b17023SJohn Marino@end deftypevr 399e4b17023SJohn Marino 400e4b17023SJohn Marino@defmac MULTILIB_DEFAULTS 401e4b17023SJohn MarinoDefine this macro as a C expression for the initializer of an array of 402e4b17023SJohn Marinostring to tell the driver program which options are defaults for this 403e4b17023SJohn Marinotarget and thus do not need to be handled specially when using 404e4b17023SJohn Marino@code{MULTILIB_OPTIONS}. 405e4b17023SJohn Marino 406e4b17023SJohn MarinoDo not define this macro if @code{MULTILIB_OPTIONS} is not defined in 407e4b17023SJohn Marinothe target makefile fragment or if none of the options listed in 408e4b17023SJohn Marino@code{MULTILIB_OPTIONS} are set by default. 409e4b17023SJohn Marino@xref{Target Fragment}. 410e4b17023SJohn Marino@end defmac 411e4b17023SJohn Marino 412e4b17023SJohn Marino@defmac RELATIVE_PREFIX_NOT_LINKDIR 413e4b17023SJohn MarinoDefine this macro to tell @command{gcc} that it should only translate 414e4b17023SJohn Marinoa @option{-B} prefix into a @option{-L} linker option if the prefix 415e4b17023SJohn Marinoindicates an absolute file name. 416e4b17023SJohn Marino@end defmac 417e4b17023SJohn Marino 418e4b17023SJohn Marino@defmac MD_EXEC_PREFIX 419e4b17023SJohn MarinoIf defined, this macro is an additional prefix to try after 420e4b17023SJohn Marino@code{STANDARD_EXEC_PREFIX}. @code{MD_EXEC_PREFIX} is not searched 421e4b17023SJohn Marinowhen the compiler is built as a cross 422e4b17023SJohn Marinocompiler. If you define @code{MD_EXEC_PREFIX}, then be sure to add it 423e4b17023SJohn Marinoto the list of directories used to find the assembler in @file{configure.in}. 424e4b17023SJohn Marino@end defmac 425e4b17023SJohn Marino 426e4b17023SJohn Marino@defmac STANDARD_STARTFILE_PREFIX 427e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to override the 428e4b17023SJohn Marinostandard choice of @code{libdir} as the default prefix to 429e4b17023SJohn Marinotry when searching for startup files such as @file{crt0.o}. 430e4b17023SJohn Marino@code{STANDARD_STARTFILE_PREFIX} is not searched when the compiler 431e4b17023SJohn Marinois built as a cross compiler. 432e4b17023SJohn Marino@end defmac 433e4b17023SJohn Marino 434e4b17023SJohn Marino@defmac STANDARD_STARTFILE_PREFIX_1 435e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to override the 436e4b17023SJohn Marinostandard choice of @code{/lib} as a prefix to try after the default prefix 437e4b17023SJohn Marinowhen searching for startup files such as @file{crt0.o}. 438e4b17023SJohn Marino@code{STANDARD_STARTFILE_PREFIX_1} is not searched when the compiler 439e4b17023SJohn Marinois built as a cross compiler. 440e4b17023SJohn Marino@end defmac 441e4b17023SJohn Marino 442e4b17023SJohn Marino@defmac STANDARD_STARTFILE_PREFIX_2 443e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to override the 444e4b17023SJohn Marinostandard choice of @code{/lib} as yet another prefix to try after the 445e4b17023SJohn Marinodefault prefix when searching for startup files such as @file{crt0.o}. 446e4b17023SJohn Marino@code{STANDARD_STARTFILE_PREFIX_2} is not searched when the compiler 447e4b17023SJohn Marinois built as a cross compiler. 448e4b17023SJohn Marino@end defmac 449e4b17023SJohn Marino 450e4b17023SJohn Marino@defmac MD_STARTFILE_PREFIX 451e4b17023SJohn MarinoIf defined, this macro supplies an additional prefix to try after the 452e4b17023SJohn Marinostandard prefixes. @code{MD_EXEC_PREFIX} is not searched when the 453e4b17023SJohn Marinocompiler is built as a cross compiler. 454e4b17023SJohn Marino@end defmac 455e4b17023SJohn Marino 456e4b17023SJohn Marino@defmac MD_STARTFILE_PREFIX_1 457e4b17023SJohn MarinoIf defined, this macro supplies yet another prefix to try after the 458e4b17023SJohn Marinostandard prefixes. It is not searched when the compiler is built as a 459e4b17023SJohn Marinocross compiler. 460e4b17023SJohn Marino@end defmac 461e4b17023SJohn Marino 462e4b17023SJohn Marino@defmac INIT_ENVIRONMENT 463e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to set environment 464e4b17023SJohn Marinovariables for programs called by the driver, such as the assembler and 465e4b17023SJohn Marinoloader. The driver passes the value of this macro to @code{putenv} to 466e4b17023SJohn Marinoinitialize the necessary environment variables. 467e4b17023SJohn Marino@end defmac 468e4b17023SJohn Marino 469e4b17023SJohn Marino@defmac LOCAL_INCLUDE_DIR 470e4b17023SJohn MarinoDefine this macro as a C string constant if you wish to override the 471e4b17023SJohn Marinostandard choice of @file{/usr/local/include} as the default prefix to 472e4b17023SJohn Marinotry when searching for local header files. @code{LOCAL_INCLUDE_DIR} 473e4b17023SJohn Marinocomes before @code{NATIVE_SYSTEM_HEADER_DIR} (set in 474e4b17023SJohn Marino@file{config.gcc}, normally @file{/usr/include}) in the search order. 475e4b17023SJohn Marino 476e4b17023SJohn MarinoCross compilers do not search either @file{/usr/local/include} or its 477e4b17023SJohn Marinoreplacement. 478e4b17023SJohn Marino@end defmac 479e4b17023SJohn Marino 480e4b17023SJohn Marino@defmac NATIVE_SYSTEM_HEADER_COMPONENT 481e4b17023SJohn MarinoThe ``component'' corresponding to @code{NATIVE_SYSTEM_HEADER_DIR}. 482e4b17023SJohn MarinoSee @code{INCLUDE_DEFAULTS}, below, for the description of components. 483e4b17023SJohn MarinoIf you do not define this macro, no component is used. 484e4b17023SJohn Marino@end defmac 485e4b17023SJohn Marino 486e4b17023SJohn Marino@defmac INCLUDE_DEFAULTS 487e4b17023SJohn MarinoDefine this macro if you wish to override the entire default search path 488e4b17023SJohn Marinofor include files. For a native compiler, the default search path 489e4b17023SJohn Marinousually consists of @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR}, 490e4b17023SJohn Marino@code{GPLUSPLUS_INCLUDE_DIR}, and 491e4b17023SJohn Marino@code{NATIVE_SYSTEM_HEADER_DIR}. In addition, @code{GPLUSPLUS_INCLUDE_DIR} 492e4b17023SJohn Marinoand @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile}, 493e4b17023SJohn Marinoand specify private search areas for GCC@. The directory 494e4b17023SJohn Marino@code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs. 495e4b17023SJohn Marino 496e4b17023SJohn MarinoThe definition should be an initializer for an array of structures. 497e4b17023SJohn MarinoEach array element should have four elements: the directory name (a 498e4b17023SJohn Marinostring constant), the component name (also a string constant), a flag 499e4b17023SJohn Marinofor C++-only directories, 500e4b17023SJohn Marinoand a flag showing that the includes in the directory don't need to be 501e4b17023SJohn Marinowrapped in @code{extern @samp{C}} when compiling C++. Mark the end of 502e4b17023SJohn Marinothe array with a null element. 503e4b17023SJohn Marino 504e4b17023SJohn MarinoThe component name denotes what GNU package the include file is part of, 505e4b17023SJohn Marinoif any, in all uppercase letters. For example, it might be @samp{GCC} 506e4b17023SJohn Marinoor @samp{BINUTILS}. If the package is part of a vendor-supplied 507e4b17023SJohn Marinooperating system, code the component name as @samp{0}. 508e4b17023SJohn Marino 509e4b17023SJohn MarinoFor example, here is the definition used for VAX/VMS: 510e4b17023SJohn Marino 511e4b17023SJohn Marino@smallexample 512e4b17023SJohn Marino#define INCLUDE_DEFAULTS \ 513e4b17023SJohn Marino@{ \ 514e4b17023SJohn Marino @{ "GNU_GXX_INCLUDE:", "G++", 1, 1@}, \ 515e4b17023SJohn Marino @{ "GNU_CC_INCLUDE:", "GCC", 0, 0@}, \ 516e4b17023SJohn Marino @{ "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0@}, \ 517e4b17023SJohn Marino @{ ".", 0, 0, 0@}, \ 518e4b17023SJohn Marino @{ 0, 0, 0, 0@} \ 519e4b17023SJohn Marino@} 520e4b17023SJohn Marino@end smallexample 521e4b17023SJohn Marino@end defmac 522e4b17023SJohn Marino 523e4b17023SJohn MarinoHere is the order of prefixes tried for exec files: 524e4b17023SJohn Marino 525e4b17023SJohn Marino@enumerate 526e4b17023SJohn Marino@item 527e4b17023SJohn MarinoAny prefixes specified by the user with @option{-B}. 528e4b17023SJohn Marino 529e4b17023SJohn Marino@item 530e4b17023SJohn MarinoThe environment variable @code{GCC_EXEC_PREFIX} or, if @code{GCC_EXEC_PREFIX} 531e4b17023SJohn Marinois not set and the compiler has not been installed in the configure-time 532e4b17023SJohn Marino@var{prefix}, the location in which the compiler has actually been installed. 533e4b17023SJohn Marino 534e4b17023SJohn Marino@item 535e4b17023SJohn MarinoThe directories specified by the environment variable @code{COMPILER_PATH}. 536e4b17023SJohn Marino 537e4b17023SJohn Marino@item 538e4b17023SJohn MarinoThe macro @code{STANDARD_EXEC_PREFIX}, if the compiler has been installed 539e4b17023SJohn Marinoin the configured-time @var{prefix}. 540e4b17023SJohn Marino 541e4b17023SJohn Marino@item 542e4b17023SJohn MarinoThe location @file{/usr/libexec/gcc/}, but only if this is a native compiler. 543e4b17023SJohn Marino 544e4b17023SJohn Marino@item 545e4b17023SJohn MarinoThe location @file{/usr/lib/gcc/}, but only if this is a native compiler. 546e4b17023SJohn Marino 547e4b17023SJohn Marino@item 548e4b17023SJohn MarinoThe macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native 549e4b17023SJohn Marinocompiler. 550e4b17023SJohn Marino@end enumerate 551e4b17023SJohn Marino 552e4b17023SJohn MarinoHere is the order of prefixes tried for startfiles: 553e4b17023SJohn Marino 554e4b17023SJohn Marino@enumerate 555e4b17023SJohn Marino@item 556e4b17023SJohn MarinoAny prefixes specified by the user with @option{-B}. 557e4b17023SJohn Marino 558e4b17023SJohn Marino@item 559e4b17023SJohn MarinoThe environment variable @code{GCC_EXEC_PREFIX} or its automatically determined 560e4b17023SJohn Marinovalue based on the installed toolchain location. 561e4b17023SJohn Marino 562e4b17023SJohn Marino@item 563e4b17023SJohn MarinoThe directories specified by the environment variable @code{LIBRARY_PATH} 564e4b17023SJohn Marino(or port-specific name; native only, cross compilers do not use this). 565e4b17023SJohn Marino 566e4b17023SJohn Marino@item 567e4b17023SJohn MarinoThe macro @code{STANDARD_EXEC_PREFIX}, but only if the toolchain is installed 568e4b17023SJohn Marinoin the configured @var{prefix} or this is a native compiler. 569e4b17023SJohn Marino 570e4b17023SJohn Marino@item 571e4b17023SJohn MarinoThe location @file{/usr/lib/gcc/}, but only if this is a native compiler. 572e4b17023SJohn Marino 573e4b17023SJohn Marino@item 574e4b17023SJohn MarinoThe macro @code{MD_EXEC_PREFIX}, if defined, but only if this is a native 575e4b17023SJohn Marinocompiler. 576e4b17023SJohn Marino 577e4b17023SJohn Marino@item 578e4b17023SJohn MarinoThe macro @code{MD_STARTFILE_PREFIX}, if defined, but only if this is a 579e4b17023SJohn Marinonative compiler, or we have a target system root. 580e4b17023SJohn Marino 581e4b17023SJohn Marino@item 582e4b17023SJohn MarinoThe macro @code{MD_STARTFILE_PREFIX_1}, if defined, but only if this is a 583e4b17023SJohn Marinonative compiler, or we have a target system root. 584e4b17023SJohn Marino 585e4b17023SJohn Marino@item 586e4b17023SJohn MarinoThe macro @code{STANDARD_STARTFILE_PREFIX}, with any sysroot modifications. 587e4b17023SJohn MarinoIf this path is relative it will be prefixed by @code{GCC_EXEC_PREFIX} and 588e4b17023SJohn Marinothe machine suffix or @code{STANDARD_EXEC_PREFIX} and the machine suffix. 589e4b17023SJohn Marino 590e4b17023SJohn Marino@item 591e4b17023SJohn MarinoThe macro @code{STANDARD_STARTFILE_PREFIX_1}, but only if this is a native 592e4b17023SJohn Marinocompiler, or we have a target system root. The default for this macro is 593e4b17023SJohn Marino@file{/lib/}. 594e4b17023SJohn Marino 595e4b17023SJohn Marino@item 596e4b17023SJohn MarinoThe macro @code{STANDARD_STARTFILE_PREFIX_2}, but only if this is a native 597e4b17023SJohn Marinocompiler, or we have a target system root. The default for this macro is 598e4b17023SJohn Marino@file{/usr/lib/}. 599e4b17023SJohn Marino@end enumerate 600e4b17023SJohn Marino 601e4b17023SJohn Marino@node Run-time Target 602e4b17023SJohn Marino@section Run-time Target Specification 603e4b17023SJohn Marino@cindex run-time target specification 604e4b17023SJohn Marino@cindex predefined macros 605e4b17023SJohn Marino@cindex target specifications 606e4b17023SJohn Marino 607e4b17023SJohn Marino@c prevent bad page break with this line 608e4b17023SJohn MarinoHere are run-time target specifications. 609e4b17023SJohn Marino 610e4b17023SJohn Marino@defmac TARGET_CPU_CPP_BUILTINS () 611e4b17023SJohn MarinoThis function-like macro expands to a block of code that defines 612e4b17023SJohn Marinobuilt-in preprocessor macros and assertions for the target CPU, using 613e4b17023SJohn Marinothe functions @code{builtin_define}, @code{builtin_define_std} and 614e4b17023SJohn Marino@code{builtin_assert}. When the front end 615e4b17023SJohn Marinocalls this macro it provides a trailing semicolon, and since it has 616e4b17023SJohn Marinofinished command line option processing your code can use those 617e4b17023SJohn Marinoresults freely. 618e4b17023SJohn Marino 619e4b17023SJohn Marino@code{builtin_assert} takes a string in the form you pass to the 620e4b17023SJohn Marinocommand-line option @option{-A}, such as @code{cpu=mips}, and creates 621e4b17023SJohn Marinothe assertion. @code{builtin_define} takes a string in the form 622e4b17023SJohn Marinoaccepted by option @option{-D} and unconditionally defines the macro. 623e4b17023SJohn Marino 624e4b17023SJohn Marino@code{builtin_define_std} takes a string representing the name of an 625e4b17023SJohn Marinoobject-like macro. If it doesn't lie in the user's namespace, 626e4b17023SJohn Marino@code{builtin_define_std} defines it unconditionally. Otherwise, it 627e4b17023SJohn Marinodefines a version with two leading underscores, and another version 628e4b17023SJohn Marinowith two leading and trailing underscores, and defines the original 629e4b17023SJohn Marinoonly if an ISO standard was not requested on the command line. For 630e4b17023SJohn Marinoexample, passing @code{unix} defines @code{__unix}, @code{__unix__} 631e4b17023SJohn Marinoand possibly @code{unix}; passing @code{_mips} defines @code{__mips}, 632e4b17023SJohn Marino@code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64} 633e4b17023SJohn Marinodefines only @code{_ABI64}. 634e4b17023SJohn Marino 635e4b17023SJohn MarinoYou can also test for the C dialect being compiled. The variable 636e4b17023SJohn Marino@code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus} 637e4b17023SJohn Marinoor @code{clk_objective_c}. Note that if we are preprocessing 638e4b17023SJohn Marinoassembler, this variable will be @code{clk_c} but the function-like 639e4b17023SJohn Marinomacro @code{preprocessing_asm_p()} will return true, so you might want 640e4b17023SJohn Marinoto check for that first. If you need to check for strict ANSI, the 641e4b17023SJohn Marinovariable @code{flag_iso} can be used. The function-like macro 642e4b17023SJohn Marino@code{preprocessing_trad_p()} can be used to check for traditional 643e4b17023SJohn Marinopreprocessing. 644e4b17023SJohn Marino@end defmac 645e4b17023SJohn Marino 646e4b17023SJohn Marino@defmac TARGET_OS_CPP_BUILTINS () 647e4b17023SJohn MarinoSimilarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional 648e4b17023SJohn Marinoand is used for the target operating system instead. 649e4b17023SJohn Marino@end defmac 650e4b17023SJohn Marino 651e4b17023SJohn Marino@defmac TARGET_OBJFMT_CPP_BUILTINS () 652e4b17023SJohn MarinoSimilarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional 653e4b17023SJohn Marinoand is used for the target object format. @file{elfos.h} uses this 654e4b17023SJohn Marinomacro to define @code{__ELF__}, so you probably do not need to define 655e4b17023SJohn Marinoit yourself. 656e4b17023SJohn Marino@end defmac 657e4b17023SJohn Marino 658e4b17023SJohn Marino@deftypevar {extern int} target_flags 659e4b17023SJohn MarinoThis variable is declared in @file{options.h}, which is included before 660e4b17023SJohn Marinoany target-specific headers. 661e4b17023SJohn Marino@end deftypevar 662e4b17023SJohn Marino 663e4b17023SJohn Marino@deftypevr {Common Target Hook} int TARGET_DEFAULT_TARGET_FLAGS 664e4b17023SJohn MarinoThis variable specifies the initial value of @code{target_flags}. 665e4b17023SJohn MarinoIts default setting is 0. 666e4b17023SJohn Marino@end deftypevr 667e4b17023SJohn Marino 668e4b17023SJohn Marino@cindex optional hardware or system features 669e4b17023SJohn Marino@cindex features, optional, in system conventions 670e4b17023SJohn Marino 671e4b17023SJohn Marino@deftypefn {Common Target Hook} bool TARGET_HANDLE_OPTION (struct gcc_options *@var{opts}, struct gcc_options *@var{opts_set}, const struct cl_decoded_option *@var{decoded}, location_t @var{loc}) 672e4b17023SJohn MarinoThis hook is called whenever the user specifies one of the 673e4b17023SJohn Marinotarget-specific options described by the @file{.opt} definition files 674e4b17023SJohn Marino(@pxref{Options}). It has the opportunity to do some option-specific 675e4b17023SJohn Marinoprocessing and should return true if the option is valid. The default 676e4b17023SJohn Marinodefinition does nothing but return true. 677e4b17023SJohn Marino 678e4b17023SJohn Marino@var{decoded} specifies the option and its arguments. @var{opts} and 679e4b17023SJohn Marino@var{opts_set} are the @code{gcc_options} structures to be used for 680e4b17023SJohn Marinostoring option state, and @var{loc} is the location at which the 681e4b17023SJohn Marinooption was passed (@code{UNKNOWN_LOCATION} except for options passed 682e4b17023SJohn Marinovia attributes). 683e4b17023SJohn Marino@end deftypefn 684e4b17023SJohn Marino 685e4b17023SJohn Marino@deftypefn {C Target Hook} bool TARGET_HANDLE_C_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value}) 686e4b17023SJohn MarinoThis target hook is called whenever the user specifies one of the 687e4b17023SJohn Marinotarget-specific C language family options described by the @file{.opt} 688e4b17023SJohn Marinodefinition files(@pxref{Options}). It has the opportunity to do some 689e4b17023SJohn Marinooption-specific processing and should return true if the option is 690e4b17023SJohn Marinovalid. The arguments are like for @code{TARGET_HANDLE_OPTION}. The 691e4b17023SJohn Marinodefault definition does nothing but return false. 692e4b17023SJohn Marino 693e4b17023SJohn MarinoIn general, you should use @code{TARGET_HANDLE_OPTION} to handle 694e4b17023SJohn Marinooptions. However, if processing an option requires routines that are 695e4b17023SJohn Marinoonly available in the C (and related language) front ends, then you 696e4b17023SJohn Marinoshould use @code{TARGET_HANDLE_C_OPTION} instead. 697e4b17023SJohn Marino@end deftypefn 698e4b17023SJohn Marino 699e4b17023SJohn Marino@deftypefn {C Target Hook} tree TARGET_OBJC_CONSTRUCT_STRING_OBJECT (tree @var{string}) 700e4b17023SJohn MarinoTargets may provide a string object type that can be used within and between C, C++ and their respective Objective-C dialects. A string object might, for example, embed encoding and length information. These objects are considered opaque to the compiler and handled as references. An ideal implementation makes the composition of the string object match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep), allowing efficient interworking between C-only and Objective-C code. If a target implements string objects then this hook should return a reference to such an object constructed from the normal `C' string representation provided in @var{string}. At present, the hook is used by Objective-C only, to obtain a common-format string object when the target provides one. 701e4b17023SJohn Marino@end deftypefn 702e4b17023SJohn Marino 703*95d28233SJohn Marino@deftypefn {C Target Hook} void TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE (const char *@var{classname}) 704*95d28233SJohn MarinoDeclare that Objective C class @var{classname} is referenced by the current TU. 705*95d28233SJohn Marino@end deftypefn 706*95d28233SJohn Marino 707*95d28233SJohn Marino@deftypefn {C Target Hook} void TARGET_OBJC_DECLARE_CLASS_DEFINITION (const char *@var{classname}) 708*95d28233SJohn MarinoDeclare that Objective C class @var{classname} is defined by the current TU. 709*95d28233SJohn Marino@end deftypefn 710*95d28233SJohn Marino 711e4b17023SJohn Marino@deftypefn {C Target Hook} bool TARGET_STRING_OBJECT_REF_TYPE_P (const_tree @var{stringref}) 712e4b17023SJohn MarinoIf a target implements string objects then this hook should return @code{true} if @var{stringref} is a valid reference to such an object. 713e4b17023SJohn Marino@end deftypefn 714e4b17023SJohn Marino 715e4b17023SJohn Marino@deftypefn {C Target Hook} void TARGET_CHECK_STRING_OBJECT_FORMAT_ARG (tree @var{format_arg}, tree @var{args_list}) 716e4b17023SJohn MarinoIf a target implements string objects then this hook should should provide a facility to check the function arguments in @var{args_list} against the format specifiers in @var{format_arg} where the type of @var{format_arg} is one recognized as a valid string reference type. 717e4b17023SJohn Marino@end deftypefn 718e4b17023SJohn Marino 719e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE (void) 720e4b17023SJohn MarinoThis target function is similar to the hook @code{TARGET_OPTION_OVERRIDE} 721e4b17023SJohn Marinobut is called when the optimize level is changed via an attribute or 722e4b17023SJohn Marinopragma or when it is reset at the end of the code affected by the 723e4b17023SJohn Marinoattribute or pragma. It is not called at the beginning of compilation 724e4b17023SJohn Marinowhen @code{TARGET_OPTION_OVERRIDE} is called so if you want to perform these 725e4b17023SJohn Marinoactions then, you should have @code{TARGET_OPTION_OVERRIDE} call 726e4b17023SJohn Marino@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}. 727e4b17023SJohn Marino@end deftypefn 728e4b17023SJohn Marino 729e4b17023SJohn Marino@defmac C_COMMON_OVERRIDE_OPTIONS 730e4b17023SJohn MarinoThis is similar to the @code{TARGET_OPTION_OVERRIDE} hook 731e4b17023SJohn Marinobut is only used in the C 732e4b17023SJohn Marinolanguage frontends (C, Objective-C, C++, Objective-C++) and so can be 733e4b17023SJohn Marinoused to alter option flag variables which only exist in those 734e4b17023SJohn Marinofrontends. 735e4b17023SJohn Marino@end defmac 736e4b17023SJohn Marino 737e4b17023SJohn Marino@deftypevr {Common Target Hook} {const struct default_options *} TARGET_OPTION_OPTIMIZATION_TABLE 738e4b17023SJohn MarinoSome machines may desire to change what optimizations are performed for 739e4b17023SJohn Marinovarious optimization levels. This variable, if defined, describes 740e4b17023SJohn Marinooptions to enable at particular sets of optimization levels. These 741e4b17023SJohn Marinooptions are processed once 742e4b17023SJohn Marinojust after the optimization level is determined and before the remainder 743e4b17023SJohn Marinoof the command options have been parsed, so may be overridden by other 744e4b17023SJohn Marinooptions passed explicitly. 745e4b17023SJohn Marino 746e4b17023SJohn MarinoThis processing is run once at program startup and when the optimization 747e4b17023SJohn Marinooptions are changed via @code{#pragma GCC optimize} or by using the 748e4b17023SJohn Marino@code{optimize} attribute. 749e4b17023SJohn Marino@end deftypevr 750e4b17023SJohn Marino 751e4b17023SJohn Marino@deftypefn {Common Target Hook} void TARGET_OPTION_INIT_STRUCT (struct gcc_options *@var{opts}) 752e4b17023SJohn MarinoSet target-dependent initial values of fields in @var{opts}. 753e4b17023SJohn Marino@end deftypefn 754e4b17023SJohn Marino 755e4b17023SJohn Marino@deftypefn {Common Target Hook} void TARGET_OPTION_DEFAULT_PARAMS (void) 756e4b17023SJohn MarinoSet target-dependent default values for @option{--param} settings, using calls to @code{set_default_param_value}. 757e4b17023SJohn Marino@end deftypefn 758e4b17023SJohn Marino 759e4b17023SJohn Marino@defmac SWITCHABLE_TARGET 760e4b17023SJohn MarinoSome targets need to switch between substantially different subtargets 761e4b17023SJohn Marinoduring compilation. For example, the MIPS target has one subtarget for 762e4b17023SJohn Marinothe traditional MIPS architecture and another for MIPS16. Source code 763e4b17023SJohn Marinocan switch between these two subarchitectures using the @code{mips16} 764e4b17023SJohn Marinoand @code{nomips16} attributes. 765e4b17023SJohn Marino 766e4b17023SJohn MarinoSuch subtargets can differ in things like the set of available 767e4b17023SJohn Marinoregisters, the set of available instructions, the costs of various 768e4b17023SJohn Marinooperations, and so on. GCC caches a lot of this type of information 769e4b17023SJohn Marinoin global variables, and recomputing them for each subtarget takes a 770e4b17023SJohn Marinosignificant amount of time. The compiler therefore provides a facility 771e4b17023SJohn Marinofor maintaining several versions of the global variables and quickly 772e4b17023SJohn Marinoswitching between them; see @file{target-globals.h} for details. 773e4b17023SJohn Marino 774e4b17023SJohn MarinoDefine this macro to 1 if your target needs this facility. The default 775e4b17023SJohn Marinois 0. 776e4b17023SJohn Marino@end defmac 777e4b17023SJohn Marino 778e4b17023SJohn Marino@node Per-Function Data 779e4b17023SJohn Marino@section Defining data structures for per-function information. 780e4b17023SJohn Marino@cindex per-function data 781e4b17023SJohn Marino@cindex data structures 782e4b17023SJohn Marino 783e4b17023SJohn MarinoIf the target needs to store information on a per-function basis, GCC 784e4b17023SJohn Marinoprovides a macro and a couple of variables to allow this. Note, just 785e4b17023SJohn Marinousing statics to store the information is a bad idea, since GCC supports 786e4b17023SJohn Marinonested functions, so you can be halfway through encoding one function 787e4b17023SJohn Marinowhen another one comes along. 788e4b17023SJohn Marino 789e4b17023SJohn MarinoGCC defines a data structure called @code{struct function} which 790e4b17023SJohn Marinocontains all of the data specific to an individual function. This 791e4b17023SJohn Marinostructure contains a field called @code{machine} whose type is 792e4b17023SJohn Marino@code{struct machine_function *}, which can be used by targets to point 793e4b17023SJohn Marinoto their own specific data. 794e4b17023SJohn Marino 795e4b17023SJohn MarinoIf a target needs per-function specific data it should define the type 796e4b17023SJohn Marino@code{struct machine_function} and also the macro @code{INIT_EXPANDERS}. 797e4b17023SJohn MarinoThis macro should be used to initialize the function pointer 798e4b17023SJohn Marino@code{init_machine_status}. This pointer is explained below. 799e4b17023SJohn Marino 800e4b17023SJohn MarinoOne typical use of per-function, target specific data is to create an 801e4b17023SJohn MarinoRTX to hold the register containing the function's return address. This 802e4b17023SJohn MarinoRTX can then be used to implement the @code{__builtin_return_address} 803e4b17023SJohn Marinofunction, for level 0. 804e4b17023SJohn Marino 805e4b17023SJohn MarinoNote---earlier implementations of GCC used a single data area to hold 806e4b17023SJohn Marinoall of the per-function information. Thus when processing of a nested 807e4b17023SJohn Marinofunction began the old per-function data had to be pushed onto a 808e4b17023SJohn Marinostack, and when the processing was finished, it had to be popped off the 809e4b17023SJohn Marinostack. GCC used to provide function pointers called 810e4b17023SJohn Marino@code{save_machine_status} and @code{restore_machine_status} to handle 811e4b17023SJohn Marinothe saving and restoring of the target specific information. Since the 812e4b17023SJohn Marinosingle data area approach is no longer used, these pointers are no 813e4b17023SJohn Marinolonger supported. 814e4b17023SJohn Marino 815e4b17023SJohn Marino@defmac INIT_EXPANDERS 816e4b17023SJohn MarinoMacro called to initialize any target specific information. This macro 817e4b17023SJohn Marinois called once per function, before generation of any RTL has begun. 818e4b17023SJohn MarinoThe intention of this macro is to allow the initialization of the 819e4b17023SJohn Marinofunction pointer @code{init_machine_status}. 820e4b17023SJohn Marino@end defmac 821e4b17023SJohn Marino 822e4b17023SJohn Marino@deftypevar {void (*)(struct function *)} init_machine_status 823e4b17023SJohn MarinoIf this function pointer is non-@code{NULL} it will be called once per 824e4b17023SJohn Marinofunction, before function compilation starts, in order to allow the 825e4b17023SJohn Marinotarget to perform any target specific initialization of the 826e4b17023SJohn Marino@code{struct function} structure. It is intended that this would be 827e4b17023SJohn Marinoused to initialize the @code{machine} of that structure. 828e4b17023SJohn Marino 829e4b17023SJohn Marino@code{struct machine_function} structures are expected to be freed by GC@. 830e4b17023SJohn MarinoGenerally, any memory that they reference must be allocated by using 831e4b17023SJohn MarinoGC allocation, including the structure itself. 832e4b17023SJohn Marino@end deftypevar 833e4b17023SJohn Marino 834e4b17023SJohn Marino@node Storage Layout 835e4b17023SJohn Marino@section Storage Layout 836e4b17023SJohn Marino@cindex storage layout 837e4b17023SJohn Marino 838e4b17023SJohn MarinoNote that the definitions of the macros in this table which are sizes or 839e4b17023SJohn Marinoalignments measured in bits do not need to be constant. They can be C 840e4b17023SJohn Marinoexpressions that refer to static variables, such as the @code{target_flags}. 841e4b17023SJohn Marino@xref{Run-time Target}. 842e4b17023SJohn Marino 843e4b17023SJohn Marino@defmac BITS_BIG_ENDIAN 844e4b17023SJohn MarinoDefine this macro to have the value 1 if the most significant bit in a 845e4b17023SJohn Marinobyte has the lowest number; otherwise define it to have the value zero. 846e4b17023SJohn MarinoThis means that bit-field instructions count from the most significant 847e4b17023SJohn Marinobit. If the machine has no bit-field instructions, then this must still 848e4b17023SJohn Marinobe defined, but it doesn't matter which value it is defined to. This 849e4b17023SJohn Marinomacro need not be a constant. 850e4b17023SJohn Marino 851e4b17023SJohn MarinoThis macro does not affect the way structure fields are packed into 852e4b17023SJohn Marinobytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}. 853e4b17023SJohn Marino@end defmac 854e4b17023SJohn Marino 855e4b17023SJohn Marino@defmac BYTES_BIG_ENDIAN 856e4b17023SJohn MarinoDefine this macro to have the value 1 if the most significant byte in a 857e4b17023SJohn Marinoword has the lowest number. This macro need not be a constant. 858e4b17023SJohn Marino@end defmac 859e4b17023SJohn Marino 860e4b17023SJohn Marino@defmac WORDS_BIG_ENDIAN 861e4b17023SJohn MarinoDefine this macro to have the value 1 if, in a multiword object, the 862e4b17023SJohn Marinomost significant word has the lowest number. This applies to both 863e4b17023SJohn Marinomemory locations and registers; see @code{REG_WORDS_BIG_ENDIAN} if the 864e4b17023SJohn Marinoorder of words in memory is not the same as the order in registers. This 865e4b17023SJohn Marinomacro need not be a constant. 866e4b17023SJohn Marino@end defmac 867e4b17023SJohn Marino 868e4b17023SJohn Marino@defmac REG_WORDS_BIG_ENDIAN 869e4b17023SJohn MarinoOn some machines, the order of words in a multiword object differs between 870e4b17023SJohn Marinoregisters in memory. In such a situation, define this macro to describe 871e4b17023SJohn Marinothe order of words in a register. The macro @code{WORDS_BIG_ENDIAN} controls 872e4b17023SJohn Marinothe order of words in memory. 873e4b17023SJohn Marino@end defmac 874e4b17023SJohn Marino 875e4b17023SJohn Marino@defmac FLOAT_WORDS_BIG_ENDIAN 876e4b17023SJohn MarinoDefine this macro to have the value 1 if @code{DFmode}, @code{XFmode} or 877e4b17023SJohn Marino@code{TFmode} floating point numbers are stored in memory with the word 878e4b17023SJohn Marinocontaining the sign bit at the lowest address; otherwise define it to 879e4b17023SJohn Marinohave the value 0. This macro need not be a constant. 880e4b17023SJohn Marino 881e4b17023SJohn MarinoYou need not define this macro if the ordering is the same as for 882e4b17023SJohn Marinomulti-word integers. 883e4b17023SJohn Marino@end defmac 884e4b17023SJohn Marino 885e4b17023SJohn Marino@defmac BITS_PER_UNIT 886e4b17023SJohn MarinoDefine this macro to be the number of bits in an addressable storage 887e4b17023SJohn Marinounit (byte). If you do not define this macro the default is 8. 888e4b17023SJohn Marino@end defmac 889e4b17023SJohn Marino 890e4b17023SJohn Marino@defmac BITS_PER_WORD 891e4b17023SJohn MarinoNumber of bits in a word. If you do not define this macro, the default 892e4b17023SJohn Marinois @code{BITS_PER_UNIT * UNITS_PER_WORD}. 893e4b17023SJohn Marino@end defmac 894e4b17023SJohn Marino 895e4b17023SJohn Marino@defmac MAX_BITS_PER_WORD 896e4b17023SJohn MarinoMaximum number of bits in a word. If this is undefined, the default is 897e4b17023SJohn Marino@code{BITS_PER_WORD}. Otherwise, it is the constant value that is the 898e4b17023SJohn Marinolargest value that @code{BITS_PER_WORD} can have at run-time. 899e4b17023SJohn Marino@end defmac 900e4b17023SJohn Marino 901e4b17023SJohn Marino@defmac UNITS_PER_WORD 902e4b17023SJohn MarinoNumber of storage units in a word; normally the size of a general-purpose 903e4b17023SJohn Marinoregister, a power of two from 1 or 8. 904e4b17023SJohn Marino@end defmac 905e4b17023SJohn Marino 906e4b17023SJohn Marino@defmac MIN_UNITS_PER_WORD 907e4b17023SJohn MarinoMinimum number of units in a word. If this is undefined, the default is 908e4b17023SJohn Marino@code{UNITS_PER_WORD}. Otherwise, it is the constant value that is the 909e4b17023SJohn Marinosmallest value that @code{UNITS_PER_WORD} can have at run-time. 910e4b17023SJohn Marino@end defmac 911e4b17023SJohn Marino 912e4b17023SJohn Marino@defmac POINTER_SIZE 913e4b17023SJohn MarinoWidth of a pointer, in bits. You must specify a value no wider than the 914e4b17023SJohn Marinowidth of @code{Pmode}. If it is not equal to the width of @code{Pmode}, 915e4b17023SJohn Marinoyou must define @code{POINTERS_EXTEND_UNSIGNED}. If you do not specify 916e4b17023SJohn Marinoa value the default is @code{BITS_PER_WORD}. 917e4b17023SJohn Marino@end defmac 918e4b17023SJohn Marino 919e4b17023SJohn Marino@defmac POINTERS_EXTEND_UNSIGNED 920e4b17023SJohn MarinoA C expression that determines how pointers should be extended from 921e4b17023SJohn Marino@code{ptr_mode} to either @code{Pmode} or @code{word_mode}. It is 922e4b17023SJohn Marinogreater than zero if pointers should be zero-extended, zero if they 923e4b17023SJohn Marinoshould be sign-extended, and negative if some other sort of conversion 924e4b17023SJohn Marinois needed. In the last case, the extension is done by the target's 925e4b17023SJohn Marino@code{ptr_extend} instruction. 926e4b17023SJohn Marino 927e4b17023SJohn MarinoYou need not define this macro if the @code{ptr_mode}, @code{Pmode} 928e4b17023SJohn Marinoand @code{word_mode} are all the same width. 929e4b17023SJohn Marino@end defmac 930e4b17023SJohn Marino 931e4b17023SJohn Marino@defmac PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type}) 932e4b17023SJohn MarinoA macro to update @var{m} and @var{unsignedp} when an object whose type 933e4b17023SJohn Marinois @var{type} and which has the specified mode and signedness is to be 934e4b17023SJohn Marinostored in a register. This macro is only called when @var{type} is a 935e4b17023SJohn Marinoscalar type. 936e4b17023SJohn Marino 937e4b17023SJohn MarinoOn most RISC machines, which only have operations that operate on a full 938e4b17023SJohn Marinoregister, define this macro to set @var{m} to @code{word_mode} if 939e4b17023SJohn Marino@var{m} is an integer mode narrower than @code{BITS_PER_WORD}. In most 940e4b17023SJohn Marinocases, only integer modes should be widened because wider-precision 941e4b17023SJohn Marinofloating-point operations are usually more expensive than their narrower 942e4b17023SJohn Marinocounterparts. 943e4b17023SJohn Marino 944e4b17023SJohn MarinoFor most machines, the macro definition does not change @var{unsignedp}. 945e4b17023SJohn MarinoHowever, some machines, have instructions that preferentially handle 946e4b17023SJohn Marinoeither signed or unsigned quantities of certain modes. For example, on 947e4b17023SJohn Marinothe DEC Alpha, 32-bit loads from memory and 32-bit add instructions 948e4b17023SJohn Marinosign-extend the result to 64 bits. On such machines, set 949e4b17023SJohn Marino@var{unsignedp} according to which kind of extension is more efficient. 950e4b17023SJohn Marino 951e4b17023SJohn MarinoDo not define this macro if it would never modify @var{m}. 952e4b17023SJohn Marino@end defmac 953e4b17023SJohn Marino 954e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_PROMOTE_FUNCTION_MODE (const_tree @var{type}, enum machine_mode @var{mode}, int *@var{punsignedp}, const_tree @var{funtype}, int @var{for_return}) 955e4b17023SJohn MarinoLike @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or 956e4b17023SJohn Marinofunction return values. The target hook should return the new mode 957e4b17023SJohn Marinoand possibly change @code{*@var{punsignedp}} if the promotion should 958e4b17023SJohn Marinochange signedness. This function is called only for scalar @emph{or 959e4b17023SJohn Marinopointer} types. 960e4b17023SJohn Marino 961e4b17023SJohn Marino@var{for_return} allows to distinguish the promotion of arguments and 962e4b17023SJohn Marinoreturn values. If it is @code{1}, a return value is being promoted and 963e4b17023SJohn Marino@code{TARGET_FUNCTION_VALUE} must perform the same promotions done here. 964e4b17023SJohn MarinoIf it is @code{2}, the returned mode should be that of the register in 965e4b17023SJohn Marinowhich an incoming parameter is copied, or the outgoing result is computed; 966e4b17023SJohn Marinothen the hook should return the same mode as @code{promote_mode}, though 967e4b17023SJohn Marinothe signedness may be different. 968e4b17023SJohn Marino 969e4b17023SJohn Marino@var{type} can be NULL when promoting function arguments of libcalls. 970e4b17023SJohn Marino 971e4b17023SJohn MarinoThe default is to not promote arguments and return values. You can 972e4b17023SJohn Marinoalso define the hook to @code{default_promote_function_mode_always_promote} 973e4b17023SJohn Marinoif you would like to apply the same rules given by @code{PROMOTE_MODE}. 974e4b17023SJohn Marino@end deftypefn 975e4b17023SJohn Marino 976e4b17023SJohn Marino@defmac PARM_BOUNDARY 977e4b17023SJohn MarinoNormal alignment required for function parameters on the stack, in 978e4b17023SJohn Marinobits. All stack parameters receive at least this much alignment 979e4b17023SJohn Marinoregardless of data type. On most machines, this is the same as the 980e4b17023SJohn Marinosize of an integer. 981e4b17023SJohn Marino@end defmac 982e4b17023SJohn Marino 983e4b17023SJohn Marino@defmac STACK_BOUNDARY 984e4b17023SJohn MarinoDefine this macro to the minimum alignment enforced by hardware for the 985e4b17023SJohn Marinostack pointer on this machine. The definition is a C expression for the 986e4b17023SJohn Marinodesired alignment (measured in bits). This value is used as a default 987e4b17023SJohn Marinoif @code{PREFERRED_STACK_BOUNDARY} is not defined. On most machines, 988e4b17023SJohn Marinothis should be the same as @code{PARM_BOUNDARY}. 989e4b17023SJohn Marino@end defmac 990e4b17023SJohn Marino 991e4b17023SJohn Marino@defmac PREFERRED_STACK_BOUNDARY 992e4b17023SJohn MarinoDefine this macro if you wish to preserve a certain alignment for the 993e4b17023SJohn Marinostack pointer, greater than what the hardware enforces. The definition 994e4b17023SJohn Marinois a C expression for the desired alignment (measured in bits). This 995e4b17023SJohn Marinomacro must evaluate to a value equal to or larger than 996e4b17023SJohn Marino@code{STACK_BOUNDARY}. 997e4b17023SJohn Marino@end defmac 998e4b17023SJohn Marino 999e4b17023SJohn Marino@defmac INCOMING_STACK_BOUNDARY 1000e4b17023SJohn MarinoDefine this macro if the incoming stack boundary may be different 1001e4b17023SJohn Marinofrom @code{PREFERRED_STACK_BOUNDARY}. This macro must evaluate 1002e4b17023SJohn Marinoto a value equal to or larger than @code{STACK_BOUNDARY}. 1003e4b17023SJohn Marino@end defmac 1004e4b17023SJohn Marino 1005e4b17023SJohn Marino@defmac FUNCTION_BOUNDARY 1006e4b17023SJohn MarinoAlignment required for a function entry point, in bits. 1007e4b17023SJohn Marino@end defmac 1008e4b17023SJohn Marino 1009e4b17023SJohn Marino@defmac BIGGEST_ALIGNMENT 1010e4b17023SJohn MarinoBiggest alignment that any data type can require on this machine, in 1011e4b17023SJohn Marinobits. Note that this is not the biggest alignment that is supported, 1012e4b17023SJohn Marinojust the biggest alignment that, when violated, may cause a fault. 1013e4b17023SJohn Marino@end defmac 1014e4b17023SJohn Marino 1015e4b17023SJohn Marino@defmac MALLOC_ABI_ALIGNMENT 1016e4b17023SJohn MarinoAlignment, in bits, a C conformant malloc implementation has to 1017e4b17023SJohn Marinoprovide. If not defined, the default value is @code{BITS_PER_WORD}. 1018e4b17023SJohn Marino@end defmac 1019e4b17023SJohn Marino 1020e4b17023SJohn Marino@defmac ATTRIBUTE_ALIGNED_VALUE 1021e4b17023SJohn MarinoAlignment used by the @code{__attribute__ ((aligned))} construct. If 1022e4b17023SJohn Marinonot defined, the default value is @code{BIGGEST_ALIGNMENT}. 1023e4b17023SJohn Marino@end defmac 1024e4b17023SJohn Marino 1025e4b17023SJohn Marino@defmac MINIMUM_ATOMIC_ALIGNMENT 1026e4b17023SJohn MarinoIf defined, the smallest alignment, in bits, that can be given to an 1027e4b17023SJohn Marinoobject that can be referenced in one operation, without disturbing any 1028e4b17023SJohn Marinonearby object. Normally, this is @code{BITS_PER_UNIT}, but may be larger 1029e4b17023SJohn Marinoon machines that don't have byte or half-word store operations. 1030e4b17023SJohn Marino@end defmac 1031e4b17023SJohn Marino 1032e4b17023SJohn Marino@defmac BIGGEST_FIELD_ALIGNMENT 1033e4b17023SJohn MarinoBiggest alignment that any structure or union field can require on this 1034e4b17023SJohn Marinomachine, in bits. If defined, this overrides @code{BIGGEST_ALIGNMENT} for 1035e4b17023SJohn Marinostructure and union fields only, unless the field alignment has been set 1036e4b17023SJohn Marinoby the @code{__attribute__ ((aligned (@var{n})))} construct. 1037e4b17023SJohn Marino@end defmac 1038e4b17023SJohn Marino 1039e4b17023SJohn Marino@defmac ADJUST_FIELD_ALIGN (@var{field}, @var{computed}) 1040e4b17023SJohn MarinoAn expression for the alignment of a structure field @var{field} if the 1041e4b17023SJohn Marinoalignment computed in the usual way (including applying of 1042e4b17023SJohn Marino@code{BIGGEST_ALIGNMENT} and @code{BIGGEST_FIELD_ALIGNMENT} to the 1043e4b17023SJohn Marinoalignment) is @var{computed}. It overrides alignment only if the 1044e4b17023SJohn Marinofield alignment has not been set by the 1045e4b17023SJohn Marino@code{__attribute__ ((aligned (@var{n})))} construct. 1046e4b17023SJohn Marino@end defmac 1047e4b17023SJohn Marino 1048e4b17023SJohn Marino@defmac MAX_STACK_ALIGNMENT 1049e4b17023SJohn MarinoBiggest stack alignment guaranteed by the backend. Use this macro 1050e4b17023SJohn Marinoto specify the maximum alignment of a variable on stack. 1051e4b17023SJohn Marino 1052e4b17023SJohn MarinoIf not defined, the default value is @code{STACK_BOUNDARY}. 1053e4b17023SJohn Marino 1054e4b17023SJohn Marino@c FIXME: The default should be @code{PREFERRED_STACK_BOUNDARY}. 1055e4b17023SJohn Marino@c But the fix for PR 32893 indicates that we can only guarantee 1056e4b17023SJohn Marino@c maximum stack alignment on stack up to @code{STACK_BOUNDARY}, not 1057e4b17023SJohn Marino@c @code{PREFERRED_STACK_BOUNDARY}, if stack alignment isn't supported. 1058e4b17023SJohn Marino@end defmac 1059e4b17023SJohn Marino 1060e4b17023SJohn Marino@defmac MAX_OFILE_ALIGNMENT 1061e4b17023SJohn MarinoBiggest alignment supported by the object file format of this machine. 1062e4b17023SJohn MarinoUse this macro to limit the alignment which can be specified using the 1063e4b17023SJohn Marino@code{__attribute__ ((aligned (@var{n})))} construct. If not defined, 1064e4b17023SJohn Marinothe default value is @code{BIGGEST_ALIGNMENT}. 1065e4b17023SJohn Marino 1066e4b17023SJohn MarinoOn systems that use ELF, the default (in @file{config/elfos.h}) is 1067e4b17023SJohn Marinothe largest supported 32-bit ELF section alignment representable on 1068e4b17023SJohn Marinoa 32-bit host e.g. @samp{(((unsigned HOST_WIDEST_INT) 1 << 28) * 8)}. 1069e4b17023SJohn MarinoOn 32-bit ELF the largest supported section alignment in bits is 1070e4b17023SJohn Marino@samp{(0x80000000 * 8)}, but this is not representable on 32-bit hosts. 1071e4b17023SJohn Marino@end defmac 1072e4b17023SJohn Marino 1073e4b17023SJohn Marino@defmac DATA_ALIGNMENT (@var{type}, @var{basic-align}) 1074e4b17023SJohn MarinoIf defined, a C expression to compute the alignment for a variable in 1075e4b17023SJohn Marinothe static store. @var{type} is the data type, and @var{basic-align} is 1076e4b17023SJohn Marinothe alignment that the object would ordinarily have. The value of this 1077e4b17023SJohn Marinomacro is used instead of that alignment to align the object. 1078e4b17023SJohn Marino 1079e4b17023SJohn MarinoIf this macro is not defined, then @var{basic-align} is used. 1080e4b17023SJohn Marino 1081e4b17023SJohn Marino@findex strcpy 1082e4b17023SJohn MarinoOne use of this macro is to increase alignment of medium-size data to 1083e4b17023SJohn Marinomake it all fit in fewer cache lines. Another is to cause character 1084e4b17023SJohn Marinoarrays to be word-aligned so that @code{strcpy} calls that copy 1085e4b17023SJohn Marinoconstants to character arrays can be done inline. 1086e4b17023SJohn Marino@end defmac 1087e4b17023SJohn Marino 1088e4b17023SJohn Marino@defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align}) 1089e4b17023SJohn MarinoIf defined, a C expression to compute the alignment given to a constant 1090e4b17023SJohn Marinothat is being placed in memory. @var{constant} is the constant and 1091e4b17023SJohn Marino@var{basic-align} is the alignment that the object would ordinarily 1092e4b17023SJohn Marinohave. The value of this macro is used instead of that alignment to 1093e4b17023SJohn Marinoalign the object. 1094e4b17023SJohn Marino 1095e4b17023SJohn MarinoIf this macro is not defined, then @var{basic-align} is used. 1096e4b17023SJohn Marino 1097e4b17023SJohn MarinoThe typical use of this macro is to increase alignment for string 1098e4b17023SJohn Marinoconstants to be word aligned so that @code{strcpy} calls that copy 1099e4b17023SJohn Marinoconstants can be done inline. 1100e4b17023SJohn Marino@end defmac 1101e4b17023SJohn Marino 1102e4b17023SJohn Marino@defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align}) 1103e4b17023SJohn MarinoIf defined, a C expression to compute the alignment for a variable in 1104e4b17023SJohn Marinothe local store. @var{type} is the data type, and @var{basic-align} is 1105e4b17023SJohn Marinothe alignment that the object would ordinarily have. The value of this 1106e4b17023SJohn Marinomacro is used instead of that alignment to align the object. 1107e4b17023SJohn Marino 1108e4b17023SJohn MarinoIf this macro is not defined, then @var{basic-align} is used. 1109e4b17023SJohn Marino 1110e4b17023SJohn MarinoOne use of this macro is to increase alignment of medium-size data to 1111e4b17023SJohn Marinomake it all fit in fewer cache lines. 1112e4b17023SJohn Marino 1113e4b17023SJohn MarinoIf the value of this macro has a type, it should be an unsigned type. 1114e4b17023SJohn Marino@end defmac 1115e4b17023SJohn Marino 1116e4b17023SJohn Marino@deftypefn {Target Hook} HOST_WIDE_INT TARGET_VECTOR_ALIGNMENT (const_tree @var{type}) 1117e4b17023SJohn MarinoThis hook can be used to define the alignment for a vector of type 1118e4b17023SJohn Marino@var{type}, in order to comply with a platform ABI. The default is to 1119e4b17023SJohn Marinorequire natural alignment for vector types. The alignment returned by 1120e4b17023SJohn Marinothis hook must be a power-of-two multiple of the default alignment of 1121e4b17023SJohn Marinothe vector element type. 1122e4b17023SJohn Marino@end deftypefn 1123e4b17023SJohn Marino 1124e4b17023SJohn Marino@defmac STACK_SLOT_ALIGNMENT (@var{type}, @var{mode}, @var{basic-align}) 1125e4b17023SJohn MarinoIf defined, a C expression to compute the alignment for stack slot. 1126e4b17023SJohn Marino@var{type} is the data type, @var{mode} is the widest mode available, 1127e4b17023SJohn Marinoand @var{basic-align} is the alignment that the slot would ordinarily 1128e4b17023SJohn Marinohave. The value of this macro is used instead of that alignment to 1129e4b17023SJohn Marinoalign the slot. 1130e4b17023SJohn Marino 1131e4b17023SJohn MarinoIf this macro is not defined, then @var{basic-align} is used when 1132e4b17023SJohn Marino@var{type} is @code{NULL}. Otherwise, @code{LOCAL_ALIGNMENT} will 1133e4b17023SJohn Marinobe used. 1134e4b17023SJohn Marino 1135e4b17023SJohn MarinoThis macro is to set alignment of stack slot to the maximum alignment 1136e4b17023SJohn Marinoof all possible modes which the slot may have. 1137e4b17023SJohn Marino 1138e4b17023SJohn MarinoIf the value of this macro has a type, it should be an unsigned type. 1139e4b17023SJohn Marino@end defmac 1140e4b17023SJohn Marino 1141e4b17023SJohn Marino@defmac LOCAL_DECL_ALIGNMENT (@var{decl}) 1142e4b17023SJohn MarinoIf defined, a C expression to compute the alignment for a local 1143e4b17023SJohn Marinovariable @var{decl}. 1144e4b17023SJohn Marino 1145e4b17023SJohn MarinoIf this macro is not defined, then 1146e4b17023SJohn Marino@code{LOCAL_ALIGNMENT (TREE_TYPE (@var{decl}), DECL_ALIGN (@var{decl}))} 1147e4b17023SJohn Marinois used. 1148e4b17023SJohn Marino 1149e4b17023SJohn MarinoOne use of this macro is to increase alignment of medium-size data to 1150e4b17023SJohn Marinomake it all fit in fewer cache lines. 1151e4b17023SJohn Marino 1152e4b17023SJohn MarinoIf the value of this macro has a type, it should be an unsigned type. 1153e4b17023SJohn Marino@end defmac 1154e4b17023SJohn Marino 1155e4b17023SJohn Marino@defmac MINIMUM_ALIGNMENT (@var{exp}, @var{mode}, @var{align}) 1156e4b17023SJohn MarinoIf defined, a C expression to compute the minimum required alignment 1157e4b17023SJohn Marinofor dynamic stack realignment purposes for @var{exp} (a type or decl), 1158e4b17023SJohn Marino@var{mode}, assuming normal alignment @var{align}. 1159e4b17023SJohn Marino 1160e4b17023SJohn MarinoIf this macro is not defined, then @var{align} will be used. 1161e4b17023SJohn Marino@end defmac 1162e4b17023SJohn Marino 1163e4b17023SJohn Marino@defmac EMPTY_FIELD_BOUNDARY 1164e4b17023SJohn MarinoAlignment in bits to be given to a structure bit-field that follows an 1165e4b17023SJohn Marinoempty field such as @code{int : 0;}. 1166e4b17023SJohn Marino 1167e4b17023SJohn MarinoIf @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro. 1168e4b17023SJohn Marino@end defmac 1169e4b17023SJohn Marino 1170e4b17023SJohn Marino@defmac STRUCTURE_SIZE_BOUNDARY 1171e4b17023SJohn MarinoNumber of bits which any structure or union's size must be a multiple of. 1172e4b17023SJohn MarinoEach structure or union's size is rounded up to a multiple of this. 1173e4b17023SJohn Marino 1174e4b17023SJohn MarinoIf you do not define this macro, the default is the same as 1175e4b17023SJohn Marino@code{BITS_PER_UNIT}. 1176e4b17023SJohn Marino@end defmac 1177e4b17023SJohn Marino 1178e4b17023SJohn Marino@defmac STRICT_ALIGNMENT 1179e4b17023SJohn MarinoDefine this macro to be the value 1 if instructions will fail to work 1180e4b17023SJohn Marinoif given data not on the nominal alignment. If instructions will merely 1181e4b17023SJohn Marinogo slower in that case, define this macro as 0. 1182e4b17023SJohn Marino@end defmac 1183e4b17023SJohn Marino 1184e4b17023SJohn Marino@defmac PCC_BITFIELD_TYPE_MATTERS 1185e4b17023SJohn MarinoDefine this if you wish to imitate the way many other C compilers handle 1186e4b17023SJohn Marinoalignment of bit-fields and the structures that contain them. 1187e4b17023SJohn Marino 1188e4b17023SJohn MarinoThe behavior is that the type written for a named bit-field (@code{int}, 1189e4b17023SJohn Marino@code{short}, or other integer type) imposes an alignment for the entire 1190e4b17023SJohn Marinostructure, as if the structure really did contain an ordinary field of 1191e4b17023SJohn Marinothat type. In addition, the bit-field is placed within the structure so 1192e4b17023SJohn Marinothat it would fit within such a field, not crossing a boundary for it. 1193e4b17023SJohn Marino 1194e4b17023SJohn MarinoThus, on most machines, a named bit-field whose type is written as 1195e4b17023SJohn Marino@code{int} would not cross a four-byte boundary, and would force 1196e4b17023SJohn Marinofour-byte alignment for the whole structure. (The alignment used may 1197e4b17023SJohn Marinonot be four bytes; it is controlled by the other alignment parameters.) 1198e4b17023SJohn Marino 1199e4b17023SJohn MarinoAn unnamed bit-field will not affect the alignment of the containing 1200e4b17023SJohn Marinostructure. 1201e4b17023SJohn Marino 1202e4b17023SJohn MarinoIf the macro is defined, its definition should be a C expression; 1203e4b17023SJohn Marinoa nonzero value for the expression enables this behavior. 1204e4b17023SJohn Marino 1205e4b17023SJohn MarinoNote that if this macro is not defined, or its value is zero, some 1206e4b17023SJohn Marinobit-fields may cross more than one alignment boundary. The compiler can 1207e4b17023SJohn Marinosupport such references if there are @samp{insv}, @samp{extv}, and 1208e4b17023SJohn Marino@samp{extzv} insns that can directly reference memory. 1209e4b17023SJohn Marino 1210e4b17023SJohn MarinoThe other known way of making bit-fields work is to define 1211e4b17023SJohn Marino@code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}. 1212e4b17023SJohn MarinoThen every structure can be accessed with fullwords. 1213e4b17023SJohn Marino 1214e4b17023SJohn MarinoUnless the machine has bit-field instructions or you define 1215e4b17023SJohn Marino@code{STRUCTURE_SIZE_BOUNDARY} that way, you must define 1216e4b17023SJohn Marino@code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value. 1217e4b17023SJohn Marino 1218e4b17023SJohn MarinoIf your aim is to make GCC use the same conventions for laying out 1219e4b17023SJohn Marinobit-fields as are used by another compiler, here is how to investigate 1220e4b17023SJohn Marinowhat the other compiler does. Compile and run this program: 1221e4b17023SJohn Marino 1222e4b17023SJohn Marino@smallexample 1223e4b17023SJohn Marinostruct foo1 1224e4b17023SJohn Marino@{ 1225e4b17023SJohn Marino char x; 1226e4b17023SJohn Marino char :0; 1227e4b17023SJohn Marino char y; 1228e4b17023SJohn Marino@}; 1229e4b17023SJohn Marino 1230e4b17023SJohn Marinostruct foo2 1231e4b17023SJohn Marino@{ 1232e4b17023SJohn Marino char x; 1233e4b17023SJohn Marino int :0; 1234e4b17023SJohn Marino char y; 1235e4b17023SJohn Marino@}; 1236e4b17023SJohn Marino 1237e4b17023SJohn Marinomain () 1238e4b17023SJohn Marino@{ 1239e4b17023SJohn Marino printf ("Size of foo1 is %d\n", 1240e4b17023SJohn Marino sizeof (struct foo1)); 1241e4b17023SJohn Marino printf ("Size of foo2 is %d\n", 1242e4b17023SJohn Marino sizeof (struct foo2)); 1243e4b17023SJohn Marino exit (0); 1244e4b17023SJohn Marino@} 1245e4b17023SJohn Marino@end smallexample 1246e4b17023SJohn Marino 1247e4b17023SJohn MarinoIf this prints 2 and 5, then the compiler's behavior is what you would 1248e4b17023SJohn Marinoget from @code{PCC_BITFIELD_TYPE_MATTERS}. 1249e4b17023SJohn Marino@end defmac 1250e4b17023SJohn Marino 1251e4b17023SJohn Marino@defmac BITFIELD_NBYTES_LIMITED 1252e4b17023SJohn MarinoLike @code{PCC_BITFIELD_TYPE_MATTERS} except that its effect is limited 1253e4b17023SJohn Marinoto aligning a bit-field within the structure. 1254e4b17023SJohn Marino@end defmac 1255e4b17023SJohn Marino 1256e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ALIGN_ANON_BITFIELD (void) 1257e4b17023SJohn MarinoWhen @code{PCC_BITFIELD_TYPE_MATTERS} is true this hook will determine 1258e4b17023SJohn Marinowhether unnamed bitfields affect the alignment of the containing 1259e4b17023SJohn Marinostructure. The hook should return true if the structure should inherit 1260e4b17023SJohn Marinothe alignment requirements of an unnamed bitfield's type. 1261e4b17023SJohn Marino@end deftypefn 1262e4b17023SJohn Marino 1263e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_NARROW_VOLATILE_BITFIELD (void) 1264e4b17023SJohn MarinoThis target hook should return @code{true} if accesses to volatile bitfields 1265e4b17023SJohn Marinoshould use the narrowest mode possible. It should return @code{false} if 1266e4b17023SJohn Marinothese accesses should use the bitfield container type. 1267e4b17023SJohn Marino 1268e4b17023SJohn MarinoThe default is @code{!TARGET_STRICT_ALIGN}. 1269e4b17023SJohn Marino@end deftypefn 1270e4b17023SJohn Marino 1271e4b17023SJohn Marino@defmac MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode}) 1272e4b17023SJohn MarinoReturn 1 if a structure or array containing @var{field} should be accessed using 1273e4b17023SJohn Marino@code{BLKMODE}. 1274e4b17023SJohn Marino 1275e4b17023SJohn MarinoIf @var{field} is the only field in the structure, @var{mode} is its 1276e4b17023SJohn Marinomode, otherwise @var{mode} is VOIDmode. @var{mode} is provided in the 1277e4b17023SJohn Marinocase where structures of one field would require the structure's mode to 1278e4b17023SJohn Marinoretain the field's mode. 1279e4b17023SJohn Marino 1280e4b17023SJohn MarinoNormally, this is not needed. 1281e4b17023SJohn Marino@end defmac 1282e4b17023SJohn Marino 1283e4b17023SJohn Marino@defmac ROUND_TYPE_ALIGN (@var{type}, @var{computed}, @var{specified}) 1284e4b17023SJohn MarinoDefine this macro as an expression for the alignment of a type (given 1285e4b17023SJohn Marinoby @var{type} as a tree node) if the alignment computed in the usual 1286e4b17023SJohn Marinoway is @var{computed} and the alignment explicitly specified was 1287e4b17023SJohn Marino@var{specified}. 1288e4b17023SJohn Marino 1289e4b17023SJohn MarinoThe default is to use @var{specified} if it is larger; otherwise, use 1290e4b17023SJohn Marinothe smaller of @var{computed} and @code{BIGGEST_ALIGNMENT} 1291e4b17023SJohn Marino@end defmac 1292e4b17023SJohn Marino 1293e4b17023SJohn Marino@defmac MAX_FIXED_MODE_SIZE 1294e4b17023SJohn MarinoAn integer expression for the size in bits of the largest integer 1295e4b17023SJohn Marinomachine mode that should actually be used. All integer machine modes of 1296e4b17023SJohn Marinothis size or smaller can be used for structures and unions with the 1297e4b17023SJohn Marinoappropriate sizes. If this macro is undefined, @code{GET_MODE_BITSIZE 1298e4b17023SJohn Marino(DImode)} is assumed. 1299e4b17023SJohn Marino@end defmac 1300e4b17023SJohn Marino 1301e4b17023SJohn Marino@defmac STACK_SAVEAREA_MODE (@var{save_level}) 1302e4b17023SJohn MarinoIf defined, an expression of type @code{enum machine_mode} that 1303e4b17023SJohn Marinospecifies the mode of the save area operand of a 1304e4b17023SJohn Marino@code{save_stack_@var{level}} named pattern (@pxref{Standard Names}). 1305e4b17023SJohn Marino@var{save_level} is one of @code{SAVE_BLOCK}, @code{SAVE_FUNCTION}, or 1306e4b17023SJohn Marino@code{SAVE_NONLOCAL} and selects which of the three named patterns is 1307e4b17023SJohn Marinohaving its mode specified. 1308e4b17023SJohn Marino 1309e4b17023SJohn MarinoYou need not define this macro if it always returns @code{Pmode}. You 1310e4b17023SJohn Marinowould most commonly define this macro if the 1311e4b17023SJohn Marino@code{save_stack_@var{level}} patterns need to support both a 32- and a 1312e4b17023SJohn Marino64-bit mode. 1313e4b17023SJohn Marino@end defmac 1314e4b17023SJohn Marino 1315e4b17023SJohn Marino@defmac STACK_SIZE_MODE 1316e4b17023SJohn MarinoIf defined, an expression of type @code{enum machine_mode} that 1317e4b17023SJohn Marinospecifies the mode of the size increment operand of an 1318e4b17023SJohn Marino@code{allocate_stack} named pattern (@pxref{Standard Names}). 1319e4b17023SJohn Marino 1320e4b17023SJohn MarinoYou need not define this macro if it always returns @code{word_mode}. 1321e4b17023SJohn MarinoYou would most commonly define this macro if the @code{allocate_stack} 1322e4b17023SJohn Marinopattern needs to support both a 32- and a 64-bit mode. 1323e4b17023SJohn Marino@end defmac 1324e4b17023SJohn Marino 1325e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_LIBGCC_CMP_RETURN_MODE (void) 1326e4b17023SJohn MarinoThis target hook should return the mode to be used for the return value 1327e4b17023SJohn Marinoof compare instructions expanded to libgcc calls. If not defined 1328e4b17023SJohn Marino@code{word_mode} is returned which is the right choice for a majority of 1329e4b17023SJohn Marinotargets. 1330e4b17023SJohn Marino@end deftypefn 1331e4b17023SJohn Marino 1332e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_LIBGCC_SHIFT_COUNT_MODE (void) 1333e4b17023SJohn MarinoThis target hook should return the mode to be used for the shift count operand 1334e4b17023SJohn Marinoof shift instructions expanded to libgcc calls. If not defined 1335e4b17023SJohn Marino@code{word_mode} is returned which is the right choice for a majority of 1336e4b17023SJohn Marinotargets. 1337e4b17023SJohn Marino@end deftypefn 1338e4b17023SJohn Marino 1339e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_UNWIND_WORD_MODE (void) 1340e4b17023SJohn MarinoReturn machine mode to be used for @code{_Unwind_Word} type. 1341e4b17023SJohn MarinoThe default is to use @code{word_mode}. 1342e4b17023SJohn Marino@end deftypefn 1343e4b17023SJohn Marino 1344e4b17023SJohn Marino@defmac ROUND_TOWARDS_ZERO 1345e4b17023SJohn MarinoIf defined, this macro should be true if the prevailing rounding 1346e4b17023SJohn Marinomode is towards zero. 1347e4b17023SJohn Marino 1348e4b17023SJohn MarinoDefining this macro only affects the way @file{libgcc.a} emulates 1349e4b17023SJohn Marinofloating-point arithmetic. 1350e4b17023SJohn Marino 1351e4b17023SJohn MarinoNot defining this macro is equivalent to returning zero. 1352e4b17023SJohn Marino@end defmac 1353e4b17023SJohn Marino 1354e4b17023SJohn Marino@defmac LARGEST_EXPONENT_IS_NORMAL (@var{size}) 1355e4b17023SJohn MarinoThis macro should return true if floats with @var{size} 1356e4b17023SJohn Marinobits do not have a NaN or infinity representation, but use the largest 1357e4b17023SJohn Marinoexponent for normal numbers instead. 1358e4b17023SJohn Marino 1359e4b17023SJohn MarinoDefining this macro only affects the way @file{libgcc.a} emulates 1360e4b17023SJohn Marinofloating-point arithmetic. 1361e4b17023SJohn Marino 1362e4b17023SJohn MarinoThe default definition of this macro returns false for all sizes. 1363e4b17023SJohn Marino@end defmac 1364e4b17023SJohn Marino 1365e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_MS_BITFIELD_LAYOUT_P (const_tree @var{record_type}) 1366e4b17023SJohn MarinoThis target hook returns @code{true} if bit-fields in the given 1367e4b17023SJohn Marino@var{record_type} are to be laid out following the rules of Microsoft 1368e4b17023SJohn MarinoVisual C/C++, namely: (i) a bit-field won't share the same storage 1369e4b17023SJohn Marinounit with the previous bit-field if their underlying types have 1370e4b17023SJohn Marinodifferent sizes, and the bit-field will be aligned to the highest 1371e4b17023SJohn Marinoalignment of the underlying types of itself and of the previous 1372e4b17023SJohn Marinobit-field; (ii) a zero-sized bit-field will affect the alignment of 1373e4b17023SJohn Marinothe whole enclosing structure, even if it is unnamed; except that 1374e4b17023SJohn Marino(iii) a zero-sized bit-field will be disregarded unless it follows 1375e4b17023SJohn Marinoanother bit-field of nonzero size. If this hook returns @code{true}, 1376e4b17023SJohn Marinoother macros that control bit-field layout are ignored. 1377e4b17023SJohn Marino 1378e4b17023SJohn MarinoWhen a bit-field is inserted into a packed record, the whole size 1379e4b17023SJohn Marinoof the underlying type is used by one or more same-size adjacent 1380e4b17023SJohn Marinobit-fields (that is, if its long:3, 32 bits is used in the record, 1381e4b17023SJohn Marinoand any additional adjacent long bit-fields are packed into the same 1382e4b17023SJohn Marinochunk of 32 bits. However, if the size changes, a new field of that 1383e4b17023SJohn Marinosize is allocated). In an unpacked record, this is the same as using 1384e4b17023SJohn Marinoalignment, but not equivalent when packing. 1385e4b17023SJohn Marino 1386e4b17023SJohn MarinoIf both MS bit-fields and @samp{__attribute__((packed))} are used, 1387e4b17023SJohn Marinothe latter will take precedence. If @samp{__attribute__((packed))} is 1388e4b17023SJohn Marinoused on a single field when MS bit-fields are in use, it will take 1389e4b17023SJohn Marinoprecedence for that field, but the alignment of the rest of the structure 1390e4b17023SJohn Marinomay affect its placement. 1391e4b17023SJohn Marino@end deftypefn 1392e4b17023SJohn Marino 1393e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_DECIMAL_FLOAT_SUPPORTED_P (void) 1394e4b17023SJohn MarinoReturns true if the target supports decimal floating point. 1395e4b17023SJohn Marino@end deftypefn 1396e4b17023SJohn Marino 1397e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_FIXED_POINT_SUPPORTED_P (void) 1398e4b17023SJohn MarinoReturns true if the target supports fixed-point arithmetic. 1399e4b17023SJohn Marino@end deftypefn 1400e4b17023SJohn Marino 1401e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_EXPAND_TO_RTL_HOOK (void) 1402e4b17023SJohn MarinoThis hook is called just before expansion into rtl, allowing the target 1403e4b17023SJohn Marinoto perform additional initializations or analysis before the expansion. 1404e4b17023SJohn MarinoFor example, the rs6000 port uses it to allocate a scratch stack slot 1405e4b17023SJohn Marinofor use in copying SDmode values between memory and floating point 1406e4b17023SJohn Marinoregisters whenever the function being expanded has any SDmode 1407e4b17023SJohn Marinousage. 1408e4b17023SJohn Marino@end deftypefn 1409e4b17023SJohn Marino 1410e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_INSTANTIATE_DECLS (void) 1411e4b17023SJohn MarinoThis hook allows the backend to perform additional instantiations on rtl 1412e4b17023SJohn Marinothat are not actually in any insns yet, but will be later. 1413e4b17023SJohn Marino@end deftypefn 1414e4b17023SJohn Marino 1415e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_MANGLE_TYPE (const_tree @var{type}) 1416e4b17023SJohn MarinoIf your target defines any fundamental types, or any types your target 1417e4b17023SJohn Marinouses should be mangled differently from the default, define this hook 1418e4b17023SJohn Marinoto return the appropriate encoding for these types as part of a C++ 1419e4b17023SJohn Marinomangled name. The @var{type} argument is the tree structure representing 1420e4b17023SJohn Marinothe type to be mangled. The hook may be applied to trees which are 1421e4b17023SJohn Marinonot target-specific fundamental types; it should return @code{NULL} 1422e4b17023SJohn Marinofor all such types, as well as arguments it does not recognize. If the 1423e4b17023SJohn Marinoreturn value is not @code{NULL}, it must point to a statically-allocated 1424e4b17023SJohn Marinostring constant. 1425e4b17023SJohn Marino 1426e4b17023SJohn MarinoTarget-specific fundamental types might be new fundamental types or 1427e4b17023SJohn Marinoqualified versions of ordinary fundamental types. Encode new 1428e4b17023SJohn Marinofundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name} 1429e4b17023SJohn Marinois the name used for the type in source code, and @var{n} is the 1430e4b17023SJohn Marinolength of @var{name} in decimal. Encode qualified versions of 1431e4b17023SJohn Marinoordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where 1432e4b17023SJohn Marino@var{name} is the name used for the type qualifier in source code, 1433e4b17023SJohn Marino@var{n} is the length of @var{name} as above, and @var{code} is the 1434e4b17023SJohn Marinocode used to represent the unqualified version of this type. (See 1435e4b17023SJohn Marino@code{write_builtin_type} in @file{cp/mangle.c} for the list of 1436e4b17023SJohn Marinocodes.) In both cases the spaces are for clarity; do not include any 1437e4b17023SJohn Marinospaces in your string. 1438e4b17023SJohn Marino 1439e4b17023SJohn MarinoThis hook is applied to types prior to typedef resolution. If the mangled 1440e4b17023SJohn Marinoname for a particular type depends only on that type's main variant, you 1441e4b17023SJohn Marinocan perform typedef resolution yourself using @code{TYPE_MAIN_VARIANT} 1442e4b17023SJohn Marinobefore mangling. 1443e4b17023SJohn Marino 1444e4b17023SJohn MarinoThe default version of this hook always returns @code{NULL}, which is 1445e4b17023SJohn Marinoappropriate for a target that does not define any new fundamental 1446e4b17023SJohn Marinotypes. 1447e4b17023SJohn Marino@end deftypefn 1448e4b17023SJohn Marino 1449e4b17023SJohn Marino@node Type Layout 1450e4b17023SJohn Marino@section Layout of Source Language Data Types 1451e4b17023SJohn Marino 1452e4b17023SJohn MarinoThese macros define the sizes and other characteristics of the standard 1453e4b17023SJohn Marinobasic data types used in programs being compiled. Unlike the macros in 1454e4b17023SJohn Marinothe previous section, these apply to specific features of C and related 1455e4b17023SJohn Marinolanguages, rather than to fundamental aspects of storage layout. 1456e4b17023SJohn Marino 1457e4b17023SJohn Marino@defmac INT_TYPE_SIZE 1458e4b17023SJohn MarinoA C expression for the size in bits of the type @code{int} on the 1459e4b17023SJohn Marinotarget machine. If you don't define this, the default is one word. 1460e4b17023SJohn Marino@end defmac 1461e4b17023SJohn Marino 1462e4b17023SJohn Marino@defmac SHORT_TYPE_SIZE 1463e4b17023SJohn MarinoA C expression for the size in bits of the type @code{short} on the 1464e4b17023SJohn Marinotarget machine. If you don't define this, the default is half a word. 1465e4b17023SJohn Marino(If this would be less than one storage unit, it is rounded up to one 1466e4b17023SJohn Marinounit.) 1467e4b17023SJohn Marino@end defmac 1468e4b17023SJohn Marino 1469e4b17023SJohn Marino@defmac LONG_TYPE_SIZE 1470e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long} on the 1471e4b17023SJohn Marinotarget machine. If you don't define this, the default is one word. 1472e4b17023SJohn Marino@end defmac 1473e4b17023SJohn Marino 1474e4b17023SJohn Marino@defmac ADA_LONG_TYPE_SIZE 1475e4b17023SJohn MarinoOn some machines, the size used for the Ada equivalent of the type 1476e4b17023SJohn Marino@code{long} by a native Ada compiler differs from that used by C@. In 1477e4b17023SJohn Marinothat situation, define this macro to be a C expression to be used for 1478e4b17023SJohn Marinothe size of that type. If you don't define this, the default is the 1479e4b17023SJohn Marinovalue of @code{LONG_TYPE_SIZE}. 1480e4b17023SJohn Marino@end defmac 1481e4b17023SJohn Marino 1482e4b17023SJohn Marino@defmac LONG_LONG_TYPE_SIZE 1483e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long long} on the 1484e4b17023SJohn Marinotarget machine. If you don't define this, the default is two 1485e4b17023SJohn Marinowords. If you want to support GNU Ada on your machine, the value of this 1486e4b17023SJohn Marinomacro must be at least 64. 1487e4b17023SJohn Marino@end defmac 1488e4b17023SJohn Marino 1489e4b17023SJohn Marino@defmac CHAR_TYPE_SIZE 1490e4b17023SJohn MarinoA C expression for the size in bits of the type @code{char} on the 1491e4b17023SJohn Marinotarget machine. If you don't define this, the default is 1492e4b17023SJohn Marino@code{BITS_PER_UNIT}. 1493e4b17023SJohn Marino@end defmac 1494e4b17023SJohn Marino 1495e4b17023SJohn Marino@defmac BOOL_TYPE_SIZE 1496e4b17023SJohn MarinoA C expression for the size in bits of the C++ type @code{bool} and 1497e4b17023SJohn MarinoC99 type @code{_Bool} on the target machine. If you don't define 1498e4b17023SJohn Marinothis, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}. 1499e4b17023SJohn Marino@end defmac 1500e4b17023SJohn Marino 1501e4b17023SJohn Marino@defmac FLOAT_TYPE_SIZE 1502e4b17023SJohn MarinoA C expression for the size in bits of the type @code{float} on the 1503e4b17023SJohn Marinotarget machine. If you don't define this, the default is one word. 1504e4b17023SJohn Marino@end defmac 1505e4b17023SJohn Marino 1506e4b17023SJohn Marino@defmac DOUBLE_TYPE_SIZE 1507e4b17023SJohn MarinoA C expression for the size in bits of the type @code{double} on the 1508e4b17023SJohn Marinotarget machine. If you don't define this, the default is two 1509e4b17023SJohn Marinowords. 1510e4b17023SJohn Marino@end defmac 1511e4b17023SJohn Marino 1512e4b17023SJohn Marino@defmac LONG_DOUBLE_TYPE_SIZE 1513e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long double} on 1514e4b17023SJohn Marinothe target machine. If you don't define this, the default is two 1515e4b17023SJohn Marinowords. 1516e4b17023SJohn Marino@end defmac 1517e4b17023SJohn Marino 1518e4b17023SJohn Marino@defmac SHORT_FRACT_TYPE_SIZE 1519e4b17023SJohn MarinoA C expression for the size in bits of the type @code{short _Fract} on 1520e4b17023SJohn Marinothe target machine. If you don't define this, the default is 1521e4b17023SJohn Marino@code{BITS_PER_UNIT}. 1522e4b17023SJohn Marino@end defmac 1523e4b17023SJohn Marino 1524e4b17023SJohn Marino@defmac FRACT_TYPE_SIZE 1525e4b17023SJohn MarinoA C expression for the size in bits of the type @code{_Fract} on 1526e4b17023SJohn Marinothe target machine. If you don't define this, the default is 1527e4b17023SJohn Marino@code{BITS_PER_UNIT * 2}. 1528e4b17023SJohn Marino@end defmac 1529e4b17023SJohn Marino 1530e4b17023SJohn Marino@defmac LONG_FRACT_TYPE_SIZE 1531e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long _Fract} on 1532e4b17023SJohn Marinothe target machine. If you don't define this, the default is 1533e4b17023SJohn Marino@code{BITS_PER_UNIT * 4}. 1534e4b17023SJohn Marino@end defmac 1535e4b17023SJohn Marino 1536e4b17023SJohn Marino@defmac LONG_LONG_FRACT_TYPE_SIZE 1537e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long long _Fract} on 1538e4b17023SJohn Marinothe target machine. If you don't define this, the default is 1539e4b17023SJohn Marino@code{BITS_PER_UNIT * 8}. 1540e4b17023SJohn Marino@end defmac 1541e4b17023SJohn Marino 1542e4b17023SJohn Marino@defmac SHORT_ACCUM_TYPE_SIZE 1543e4b17023SJohn MarinoA C expression for the size in bits of the type @code{short _Accum} on 1544e4b17023SJohn Marinothe target machine. If you don't define this, the default is 1545e4b17023SJohn Marino@code{BITS_PER_UNIT * 2}. 1546e4b17023SJohn Marino@end defmac 1547e4b17023SJohn Marino 1548e4b17023SJohn Marino@defmac ACCUM_TYPE_SIZE 1549e4b17023SJohn MarinoA C expression for the size in bits of the type @code{_Accum} on 1550e4b17023SJohn Marinothe target machine. If you don't define this, the default is 1551e4b17023SJohn Marino@code{BITS_PER_UNIT * 4}. 1552e4b17023SJohn Marino@end defmac 1553e4b17023SJohn Marino 1554e4b17023SJohn Marino@defmac LONG_ACCUM_TYPE_SIZE 1555e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long _Accum} on 1556e4b17023SJohn Marinothe target machine. If you don't define this, the default is 1557e4b17023SJohn Marino@code{BITS_PER_UNIT * 8}. 1558e4b17023SJohn Marino@end defmac 1559e4b17023SJohn Marino 1560e4b17023SJohn Marino@defmac LONG_LONG_ACCUM_TYPE_SIZE 1561e4b17023SJohn MarinoA C expression for the size in bits of the type @code{long long _Accum} on 1562e4b17023SJohn Marinothe target machine. If you don't define this, the default is 1563e4b17023SJohn Marino@code{BITS_PER_UNIT * 16}. 1564e4b17023SJohn Marino@end defmac 1565e4b17023SJohn Marino 1566e4b17023SJohn Marino@defmac LIBGCC2_LONG_DOUBLE_TYPE_SIZE 1567e4b17023SJohn MarinoDefine this macro if @code{LONG_DOUBLE_TYPE_SIZE} is not constant or 1568e4b17023SJohn Marinoif you want routines in @file{libgcc2.a} for a size other than 1569e4b17023SJohn Marino@code{LONG_DOUBLE_TYPE_SIZE}. If you don't define this, the 1570e4b17023SJohn Marinodefault is @code{LONG_DOUBLE_TYPE_SIZE}. 1571e4b17023SJohn Marino@end defmac 1572e4b17023SJohn Marino 1573e4b17023SJohn Marino@defmac LIBGCC2_HAS_DF_MODE 1574e4b17023SJohn MarinoDefine this macro if neither @code{DOUBLE_TYPE_SIZE} nor 1575e4b17023SJohn Marino@code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 1576e4b17023SJohn Marino@code{DFmode} but you want @code{DFmode} routines in @file{libgcc2.a} 1577e4b17023SJohn Marinoanyway. If you don't define this and either @code{DOUBLE_TYPE_SIZE} 1578e4b17023SJohn Marinoor @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64 then the default is 1, 1579e4b17023SJohn Marinootherwise it is 0. 1580e4b17023SJohn Marino@end defmac 1581e4b17023SJohn Marino 1582e4b17023SJohn Marino@defmac LIBGCC2_HAS_XF_MODE 1583e4b17023SJohn MarinoDefine this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not 1584e4b17023SJohn Marino@code{XFmode} but you want @code{XFmode} routines in @file{libgcc2.a} 1585e4b17023SJohn Marinoanyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} 1586e4b17023SJohn Marinois 80 then the default is 1, otherwise it is 0. 1587e4b17023SJohn Marino@end defmac 1588e4b17023SJohn Marino 1589e4b17023SJohn Marino@defmac LIBGCC2_HAS_TF_MODE 1590e4b17023SJohn MarinoDefine this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not 1591e4b17023SJohn Marino@code{TFmode} but you want @code{TFmode} routines in @file{libgcc2.a} 1592e4b17023SJohn Marinoanyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} 1593e4b17023SJohn Marinois 128 then the default is 1, otherwise it is 0. 1594e4b17023SJohn Marino@end defmac 1595e4b17023SJohn Marino 1596e4b17023SJohn Marino@defmac LIBGCC2_GNU_PREFIX 1597e4b17023SJohn MarinoThis macro corresponds to the @code{TARGET_LIBFUNC_GNU_PREFIX} target 1598e4b17023SJohn Marinohook and should be defined if that hook is overriden to be true. It 1599e4b17023SJohn Marinocauses function names in libgcc to be changed to use a @code{__gnu_} 1600e4b17023SJohn Marinoprefix for their name rather than the default @code{__}. A port which 1601e4b17023SJohn Marinouses this macro should also arrange to use @file{t-gnu-prefix} in 1602e4b17023SJohn Marinothe libgcc @file{config.host}. 1603e4b17023SJohn Marino@end defmac 1604e4b17023SJohn Marino 1605e4b17023SJohn Marino@defmac SF_SIZE 1606e4b17023SJohn Marino@defmacx DF_SIZE 1607e4b17023SJohn Marino@defmacx XF_SIZE 1608e4b17023SJohn Marino@defmacx TF_SIZE 1609e4b17023SJohn MarinoDefine these macros to be the size in bits of the mantissa of 1610e4b17023SJohn Marino@code{SFmode}, @code{DFmode}, @code{XFmode} and @code{TFmode} values, 1611e4b17023SJohn Marinoif the defaults in @file{libgcc2.h} are inappropriate. By default, 1612e4b17023SJohn Marino@code{FLT_MANT_DIG} is used for @code{SF_SIZE}, @code{LDBL_MANT_DIG} 1613e4b17023SJohn Marinofor @code{XF_SIZE} and @code{TF_SIZE}, and @code{DBL_MANT_DIG} or 1614e4b17023SJohn Marino@code{LDBL_MANT_DIG} for @code{DF_SIZE} according to whether 1615e4b17023SJohn Marino@code{DOUBLE_TYPE_SIZE} or 1616e4b17023SJohn Marino@code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is 64. 1617e4b17023SJohn Marino@end defmac 1618e4b17023SJohn Marino 1619e4b17023SJohn Marino@defmac TARGET_FLT_EVAL_METHOD 1620e4b17023SJohn MarinoA C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h}, 1621e4b17023SJohn Marinoassuming, if applicable, that the floating-point control word is in its 1622e4b17023SJohn Marinodefault state. If you do not define this macro the value of 1623e4b17023SJohn Marino@code{FLT_EVAL_METHOD} will be zero. 1624e4b17023SJohn Marino@end defmac 1625e4b17023SJohn Marino 1626e4b17023SJohn Marino@defmac WIDEST_HARDWARE_FP_SIZE 1627e4b17023SJohn MarinoA C expression for the size in bits of the widest floating-point format 1628e4b17023SJohn Marinosupported by the hardware. If you define this macro, you must specify a 1629e4b17023SJohn Marinovalue less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}. 1630e4b17023SJohn MarinoIf you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE} 1631e4b17023SJohn Marinois the default. 1632e4b17023SJohn Marino@end defmac 1633e4b17023SJohn Marino 1634e4b17023SJohn Marino@defmac DEFAULT_SIGNED_CHAR 1635e4b17023SJohn MarinoAn expression whose value is 1 or 0, according to whether the type 1636e4b17023SJohn Marino@code{char} should be signed or unsigned by default. The user can 1637e4b17023SJohn Marinoalways override this default with the options @option{-fsigned-char} 1638e4b17023SJohn Marinoand @option{-funsigned-char}. 1639e4b17023SJohn Marino@end defmac 1640e4b17023SJohn Marino 1641e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_DEFAULT_SHORT_ENUMS (void) 1642e4b17023SJohn MarinoThis target hook should return true if the compiler should give an 1643e4b17023SJohn Marino@code{enum} type only as many bytes as it takes to represent the range 1644e4b17023SJohn Marinoof possible values of that type. It should return false if all 1645e4b17023SJohn Marino@code{enum} types should be allocated like @code{int}. 1646e4b17023SJohn Marino 1647e4b17023SJohn MarinoThe default is to return false. 1648e4b17023SJohn Marino@end deftypefn 1649e4b17023SJohn Marino 1650e4b17023SJohn Marino@defmac SIZE_TYPE 1651e4b17023SJohn MarinoA C expression for a string describing the name of the data type to use 1652e4b17023SJohn Marinofor size values. The typedef name @code{size_t} is defined using the 1653e4b17023SJohn Marinocontents of the string. 1654e4b17023SJohn Marino 1655e4b17023SJohn MarinoThe string can contain more than one keyword. If so, separate them with 1656e4b17023SJohn Marinospaces, and write first any length keyword, then @code{unsigned} if 1657e4b17023SJohn Marinoappropriate, and finally @code{int}. The string must exactly match one 1658e4b17023SJohn Marinoof the data type names defined in the function 1659e4b17023SJohn Marino@code{init_decl_processing} in the file @file{c-decl.c}. You may not 1660e4b17023SJohn Marinoomit @code{int} or change the order---that would cause the compiler to 1661e4b17023SJohn Marinocrash on startup. 1662e4b17023SJohn Marino 1663e4b17023SJohn MarinoIf you don't define this macro, the default is @code{"long unsigned 1664e4b17023SJohn Marinoint"}. 1665e4b17023SJohn Marino@end defmac 1666e4b17023SJohn Marino 1667e4b17023SJohn Marino@defmac PTRDIFF_TYPE 1668e4b17023SJohn MarinoA C expression for a string describing the name of the data type to use 1669e4b17023SJohn Marinofor the result of subtracting two pointers. The typedef name 1670e4b17023SJohn Marino@code{ptrdiff_t} is defined using the contents of the string. See 1671e4b17023SJohn Marino@code{SIZE_TYPE} above for more information. 1672e4b17023SJohn Marino 1673e4b17023SJohn MarinoIf you don't define this macro, the default is @code{"long int"}. 1674e4b17023SJohn Marino@end defmac 1675e4b17023SJohn Marino 1676e4b17023SJohn Marino@defmac WCHAR_TYPE 1677e4b17023SJohn MarinoA C expression for a string describing the name of the data type to use 1678e4b17023SJohn Marinofor wide characters. The typedef name @code{wchar_t} is defined using 1679e4b17023SJohn Marinothe contents of the string. See @code{SIZE_TYPE} above for more 1680e4b17023SJohn Marinoinformation. 1681e4b17023SJohn Marino 1682e4b17023SJohn MarinoIf you don't define this macro, the default is @code{"int"}. 1683e4b17023SJohn Marino@end defmac 1684e4b17023SJohn Marino 1685e4b17023SJohn Marino@defmac WCHAR_TYPE_SIZE 1686e4b17023SJohn MarinoA C expression for the size in bits of the data type for wide 1687e4b17023SJohn Marinocharacters. This is used in @code{cpp}, which cannot make use of 1688e4b17023SJohn Marino@code{WCHAR_TYPE}. 1689e4b17023SJohn Marino@end defmac 1690e4b17023SJohn Marino 1691e4b17023SJohn Marino@defmac WINT_TYPE 1692e4b17023SJohn MarinoA C expression for a string describing the name of the data type to 1693e4b17023SJohn Marinouse for wide characters passed to @code{printf} and returned from 1694e4b17023SJohn Marino@code{getwc}. The typedef name @code{wint_t} is defined using the 1695e4b17023SJohn Marinocontents of the string. See @code{SIZE_TYPE} above for more 1696e4b17023SJohn Marinoinformation. 1697e4b17023SJohn Marino 1698e4b17023SJohn MarinoIf you don't define this macro, the default is @code{"unsigned int"}. 1699e4b17023SJohn Marino@end defmac 1700e4b17023SJohn Marino 1701e4b17023SJohn Marino@defmac INTMAX_TYPE 1702e4b17023SJohn MarinoA C expression for a string describing the name of the data type that 1703e4b17023SJohn Marinocan represent any value of any standard or extended signed integer type. 1704e4b17023SJohn MarinoThe typedef name @code{intmax_t} is defined using the contents of the 1705e4b17023SJohn Marinostring. See @code{SIZE_TYPE} above for more information. 1706e4b17023SJohn Marino 1707e4b17023SJohn MarinoIf you don't define this macro, the default is the first of 1708e4b17023SJohn Marino@code{"int"}, @code{"long int"}, or @code{"long long int"} that has as 1709e4b17023SJohn Marinomuch precision as @code{long long int}. 1710e4b17023SJohn Marino@end defmac 1711e4b17023SJohn Marino 1712e4b17023SJohn Marino@defmac UINTMAX_TYPE 1713e4b17023SJohn MarinoA C expression for a string describing the name of the data type that 1714e4b17023SJohn Marinocan represent any value of any standard or extended unsigned integer 1715e4b17023SJohn Marinotype. The typedef name @code{uintmax_t} is defined using the contents 1716e4b17023SJohn Marinoof the string. See @code{SIZE_TYPE} above for more information. 1717e4b17023SJohn Marino 1718e4b17023SJohn MarinoIf you don't define this macro, the default is the first of 1719e4b17023SJohn Marino@code{"unsigned int"}, @code{"long unsigned int"}, or @code{"long long 1720e4b17023SJohn Marinounsigned int"} that has as much precision as @code{long long unsigned 1721e4b17023SJohn Marinoint}. 1722e4b17023SJohn Marino@end defmac 1723e4b17023SJohn Marino 1724e4b17023SJohn Marino@defmac SIG_ATOMIC_TYPE 1725e4b17023SJohn Marino@defmacx INT8_TYPE 1726e4b17023SJohn Marino@defmacx INT16_TYPE 1727e4b17023SJohn Marino@defmacx INT32_TYPE 1728e4b17023SJohn Marino@defmacx INT64_TYPE 1729e4b17023SJohn Marino@defmacx UINT8_TYPE 1730e4b17023SJohn Marino@defmacx UINT16_TYPE 1731e4b17023SJohn Marino@defmacx UINT32_TYPE 1732e4b17023SJohn Marino@defmacx UINT64_TYPE 1733e4b17023SJohn Marino@defmacx INT_LEAST8_TYPE 1734e4b17023SJohn Marino@defmacx INT_LEAST16_TYPE 1735e4b17023SJohn Marino@defmacx INT_LEAST32_TYPE 1736e4b17023SJohn Marino@defmacx INT_LEAST64_TYPE 1737e4b17023SJohn Marino@defmacx UINT_LEAST8_TYPE 1738e4b17023SJohn Marino@defmacx UINT_LEAST16_TYPE 1739e4b17023SJohn Marino@defmacx UINT_LEAST32_TYPE 1740e4b17023SJohn Marino@defmacx UINT_LEAST64_TYPE 1741e4b17023SJohn Marino@defmacx INT_FAST8_TYPE 1742e4b17023SJohn Marino@defmacx INT_FAST16_TYPE 1743e4b17023SJohn Marino@defmacx INT_FAST32_TYPE 1744e4b17023SJohn Marino@defmacx INT_FAST64_TYPE 1745e4b17023SJohn Marino@defmacx UINT_FAST8_TYPE 1746e4b17023SJohn Marino@defmacx UINT_FAST16_TYPE 1747e4b17023SJohn Marino@defmacx UINT_FAST32_TYPE 1748e4b17023SJohn Marino@defmacx UINT_FAST64_TYPE 1749e4b17023SJohn Marino@defmacx INTPTR_TYPE 1750e4b17023SJohn Marino@defmacx UINTPTR_TYPE 1751e4b17023SJohn MarinoC expressions for the standard types @code{sig_atomic_t}, 1752e4b17023SJohn Marino@code{int8_t}, @code{int16_t}, @code{int32_t}, @code{int64_t}, 1753e4b17023SJohn Marino@code{uint8_t}, @code{uint16_t}, @code{uint32_t}, @code{uint64_t}, 1754e4b17023SJohn Marino@code{int_least8_t}, @code{int_least16_t}, @code{int_least32_t}, 1755e4b17023SJohn Marino@code{int_least64_t}, @code{uint_least8_t}, @code{uint_least16_t}, 1756e4b17023SJohn Marino@code{uint_least32_t}, @code{uint_least64_t}, @code{int_fast8_t}, 1757e4b17023SJohn Marino@code{int_fast16_t}, @code{int_fast32_t}, @code{int_fast64_t}, 1758e4b17023SJohn Marino@code{uint_fast8_t}, @code{uint_fast16_t}, @code{uint_fast32_t}, 1759e4b17023SJohn Marino@code{uint_fast64_t}, @code{intptr_t}, and @code{uintptr_t}. See 1760e4b17023SJohn Marino@code{SIZE_TYPE} above for more information. 1761e4b17023SJohn Marino 1762e4b17023SJohn MarinoIf any of these macros evaluates to a null pointer, the corresponding 1763e4b17023SJohn Marinotype is not supported; if GCC is configured to provide 1764e4b17023SJohn Marino@code{<stdint.h>} in such a case, the header provided may not conform 1765e4b17023SJohn Marinoto C99, depending on the type in question. The defaults for all of 1766e4b17023SJohn Marinothese macros are null pointers. 1767e4b17023SJohn Marino@end defmac 1768e4b17023SJohn Marino 1769e4b17023SJohn Marino@defmac TARGET_PTRMEMFUNC_VBIT_LOCATION 1770e4b17023SJohn MarinoThe C++ compiler represents a pointer-to-member-function with a struct 1771e4b17023SJohn Marinothat looks like: 1772e4b17023SJohn Marino 1773e4b17023SJohn Marino@smallexample 1774e4b17023SJohn Marino struct @{ 1775e4b17023SJohn Marino union @{ 1776e4b17023SJohn Marino void (*fn)(); 1777e4b17023SJohn Marino ptrdiff_t vtable_index; 1778e4b17023SJohn Marino @}; 1779e4b17023SJohn Marino ptrdiff_t delta; 1780e4b17023SJohn Marino @}; 1781e4b17023SJohn Marino@end smallexample 1782e4b17023SJohn Marino 1783e4b17023SJohn Marino@noindent 1784e4b17023SJohn MarinoThe C++ compiler must use one bit to indicate whether the function that 1785e4b17023SJohn Marinowill be called through a pointer-to-member-function is virtual. 1786e4b17023SJohn MarinoNormally, we assume that the low-order bit of a function pointer must 1787e4b17023SJohn Marinoalways be zero. Then, by ensuring that the vtable_index is odd, we can 1788e4b17023SJohn Marinodistinguish which variant of the union is in use. But, on some 1789e4b17023SJohn Marinoplatforms function pointers can be odd, and so this doesn't work. In 1790e4b17023SJohn Marinothat case, we use the low-order bit of the @code{delta} field, and shift 1791e4b17023SJohn Marinothe remainder of the @code{delta} field to the left. 1792e4b17023SJohn Marino 1793e4b17023SJohn MarinoGCC will automatically make the right selection about where to store 1794e4b17023SJohn Marinothis bit using the @code{FUNCTION_BOUNDARY} setting for your platform. 1795e4b17023SJohn MarinoHowever, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY} 1796e4b17023SJohn Marinoset such that functions always start at even addresses, but the lowest 1797e4b17023SJohn Marinobit of pointers to functions indicate whether the function at that 1798e4b17023SJohn Marinoaddress is in ARM or Thumb mode. If this is the case of your 1799e4b17023SJohn Marinoarchitecture, you should define this macro to 1800e4b17023SJohn Marino@code{ptrmemfunc_vbit_in_delta}. 1801e4b17023SJohn Marino 1802e4b17023SJohn MarinoIn general, you should not have to define this macro. On architectures 1803e4b17023SJohn Marinoin which function addresses are always even, according to 1804e4b17023SJohn Marino@code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to 1805e4b17023SJohn Marino@code{ptrmemfunc_vbit_in_pfn}. 1806e4b17023SJohn Marino@end defmac 1807e4b17023SJohn Marino 1808e4b17023SJohn Marino@defmac TARGET_VTABLE_USES_DESCRIPTORS 1809e4b17023SJohn MarinoNormally, the C++ compiler uses function pointers in vtables. This 1810e4b17023SJohn Marinomacro allows the target to change to use ``function descriptors'' 1811e4b17023SJohn Marinoinstead. Function descriptors are found on targets for whom a 1812e4b17023SJohn Marinofunction pointer is actually a small data structure. Normally the 1813e4b17023SJohn Marinodata structure consists of the actual code address plus a data 1814e4b17023SJohn Marinopointer to which the function's data is relative. 1815e4b17023SJohn Marino 1816e4b17023SJohn MarinoIf vtables are used, the value of this macro should be the number 1817e4b17023SJohn Marinoof words that the function descriptor occupies. 1818e4b17023SJohn Marino@end defmac 1819e4b17023SJohn Marino 1820e4b17023SJohn Marino@defmac TARGET_VTABLE_ENTRY_ALIGN 1821e4b17023SJohn MarinoBy default, the vtable entries are void pointers, the so the alignment 1822e4b17023SJohn Marinois the same as pointer alignment. The value of this macro specifies 1823e4b17023SJohn Marinothe alignment of the vtable entry in bits. It should be defined only 1824e4b17023SJohn Marinowhen special alignment is necessary. */ 1825e4b17023SJohn Marino@end defmac 1826e4b17023SJohn Marino 1827e4b17023SJohn Marino@defmac TARGET_VTABLE_DATA_ENTRY_DISTANCE 1828e4b17023SJohn MarinoThere are a few non-descriptor entries in the vtable at offsets below 1829e4b17023SJohn Marinozero. If these entries must be padded (say, to preserve the alignment 1830e4b17023SJohn Marinospecified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number 1831e4b17023SJohn Marinoof words in each data entry. 1832e4b17023SJohn Marino@end defmac 1833e4b17023SJohn Marino 1834e4b17023SJohn Marino@node Registers 1835e4b17023SJohn Marino@section Register Usage 1836e4b17023SJohn Marino@cindex register usage 1837e4b17023SJohn Marino 1838e4b17023SJohn MarinoThis section explains how to describe what registers the target machine 1839e4b17023SJohn Marinohas, and how (in general) they can be used. 1840e4b17023SJohn Marino 1841e4b17023SJohn MarinoThe description of which registers a specific instruction can use is 1842e4b17023SJohn Marinodone with register classes; see @ref{Register Classes}. For information 1843e4b17023SJohn Marinoon using registers to access a stack frame, see @ref{Frame Registers}. 1844e4b17023SJohn MarinoFor passing values in registers, see @ref{Register Arguments}. 1845e4b17023SJohn MarinoFor returning values in registers, see @ref{Scalar Return}. 1846e4b17023SJohn Marino 1847e4b17023SJohn Marino@menu 1848e4b17023SJohn Marino* Register Basics:: Number and kinds of registers. 1849e4b17023SJohn Marino* Allocation Order:: Order in which registers are allocated. 1850e4b17023SJohn Marino* Values in Registers:: What kinds of values each reg can hold. 1851e4b17023SJohn Marino* Leaf Functions:: Renumbering registers for leaf functions. 1852e4b17023SJohn Marino* Stack Registers:: Handling a register stack such as 80387. 1853e4b17023SJohn Marino@end menu 1854e4b17023SJohn Marino 1855e4b17023SJohn Marino@node Register Basics 1856e4b17023SJohn Marino@subsection Basic Characteristics of Registers 1857e4b17023SJohn Marino 1858e4b17023SJohn Marino@c prevent bad page break with this line 1859e4b17023SJohn MarinoRegisters have various characteristics. 1860e4b17023SJohn Marino 1861e4b17023SJohn Marino@defmac FIRST_PSEUDO_REGISTER 1862e4b17023SJohn MarinoNumber of hardware registers known to the compiler. They receive 1863e4b17023SJohn Marinonumbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first 1864e4b17023SJohn Marinopseudo register's number really is assigned the number 1865e4b17023SJohn Marino@code{FIRST_PSEUDO_REGISTER}. 1866e4b17023SJohn Marino@end defmac 1867e4b17023SJohn Marino 1868e4b17023SJohn Marino@defmac FIXED_REGISTERS 1869e4b17023SJohn Marino@cindex fixed register 1870e4b17023SJohn MarinoAn initializer that says which registers are used for fixed purposes 1871e4b17023SJohn Marinoall throughout the compiled code and are therefore not available for 1872e4b17023SJohn Marinogeneral allocation. These would include the stack pointer, the frame 1873e4b17023SJohn Marinopointer (except on machines where that can be used as a general 1874e4b17023SJohn Marinoregister when no frame pointer is needed), the program counter on 1875e4b17023SJohn Marinomachines where that is considered one of the addressable registers, 1876e4b17023SJohn Marinoand any other numbered register with a standard use. 1877e4b17023SJohn Marino 1878e4b17023SJohn MarinoThis information is expressed as a sequence of numbers, separated by 1879e4b17023SJohn Marinocommas and surrounded by braces. The @var{n}th number is 1 if 1880e4b17023SJohn Marinoregister @var{n} is fixed, 0 otherwise. 1881e4b17023SJohn Marino 1882e4b17023SJohn MarinoThe table initialized from this macro, and the table initialized by 1883e4b17023SJohn Marinothe following one, may be overridden at run time either automatically, 1884e4b17023SJohn Marinoby the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by 1885e4b17023SJohn Marinothe user with the command options @option{-ffixed-@var{reg}}, 1886e4b17023SJohn Marino@option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}}. 1887e4b17023SJohn Marino@end defmac 1888e4b17023SJohn Marino 1889e4b17023SJohn Marino@defmac CALL_USED_REGISTERS 1890e4b17023SJohn Marino@cindex call-used register 1891e4b17023SJohn Marino@cindex call-clobbered register 1892e4b17023SJohn Marino@cindex call-saved register 1893e4b17023SJohn MarinoLike @code{FIXED_REGISTERS} but has 1 for each register that is 1894e4b17023SJohn Marinoclobbered (in general) by function calls as well as for fixed 1895e4b17023SJohn Marinoregisters. This macro therefore identifies the registers that are not 1896e4b17023SJohn Marinoavailable for general allocation of values that must live across 1897e4b17023SJohn Marinofunction calls. 1898e4b17023SJohn Marino 1899e4b17023SJohn MarinoIf a register has 0 in @code{CALL_USED_REGISTERS}, the compiler 1900e4b17023SJohn Marinoautomatically saves it on function entry and restores it on function 1901e4b17023SJohn Marinoexit, if the register is used within the function. 1902e4b17023SJohn Marino@end defmac 1903e4b17023SJohn Marino 1904e4b17023SJohn Marino@defmac CALL_REALLY_USED_REGISTERS 1905e4b17023SJohn Marino@cindex call-used register 1906e4b17023SJohn Marino@cindex call-clobbered register 1907e4b17023SJohn Marino@cindex call-saved register 1908e4b17023SJohn MarinoLike @code{CALL_USED_REGISTERS} except this macro doesn't require 1909e4b17023SJohn Marinothat the entire set of @code{FIXED_REGISTERS} be included. 1910e4b17023SJohn Marino(@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}). 1911e4b17023SJohn MarinoThis macro is optional. If not specified, it defaults to the value 1912e4b17023SJohn Marinoof @code{CALL_USED_REGISTERS}. 1913e4b17023SJohn Marino@end defmac 1914e4b17023SJohn Marino 1915e4b17023SJohn Marino@defmac HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode}) 1916e4b17023SJohn Marino@cindex call-used register 1917e4b17023SJohn Marino@cindex call-clobbered register 1918e4b17023SJohn Marino@cindex call-saved register 1919e4b17023SJohn MarinoA C expression that is nonzero if it is not permissible to store a 1920e4b17023SJohn Marinovalue of mode @var{mode} in hard register number @var{regno} across a 1921e4b17023SJohn Marinocall without some part of it being clobbered. For most machines this 1922e4b17023SJohn Marinomacro need not be defined. It is only required for machines that do not 1923e4b17023SJohn Marinopreserve the entire contents of a register across a call. 1924e4b17023SJohn Marino@end defmac 1925e4b17023SJohn Marino 1926e4b17023SJohn Marino@findex fixed_regs 1927e4b17023SJohn Marino@findex call_used_regs 1928e4b17023SJohn Marino@findex global_regs 1929e4b17023SJohn Marino@findex reg_names 1930e4b17023SJohn Marino@findex reg_class_contents 1931e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_CONDITIONAL_REGISTER_USAGE (void) 1932e4b17023SJohn MarinoThis hook may conditionally modify five variables 1933e4b17023SJohn Marino@code{fixed_regs}, @code{call_used_regs}, @code{global_regs}, 1934e4b17023SJohn Marino@code{reg_names}, and @code{reg_class_contents}, to take into account 1935e4b17023SJohn Marinoany dependence of these register sets on target flags. The first three 1936e4b17023SJohn Marinoof these are of type @code{char []} (interpreted as Boolean vectors). 1937e4b17023SJohn Marino@code{global_regs} is a @code{const char *[]}, and 1938e4b17023SJohn Marino@code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is 1939e4b17023SJohn Marinocalled, @code{fixed_regs}, @code{call_used_regs}, 1940e4b17023SJohn Marino@code{reg_class_contents}, and @code{reg_names} have been initialized 1941e4b17023SJohn Marinofrom @code{FIXED_REGISTERS}, @code{CALL_USED_REGISTERS}, 1942e4b17023SJohn Marino@code{REG_CLASS_CONTENTS}, and @code{REGISTER_NAMES}, respectively. 1943e4b17023SJohn Marino@code{global_regs} has been cleared, and any @option{-ffixed-@var{reg}}, 1944e4b17023SJohn Marino@option{-fcall-used-@var{reg}} and @option{-fcall-saved-@var{reg}} 1945e4b17023SJohn Marinocommand options have been applied. 1946e4b17023SJohn Marino 1947e4b17023SJohn Marino@cindex disabling certain registers 1948e4b17023SJohn Marino@cindex controlling register usage 1949e4b17023SJohn MarinoIf the usage of an entire class of registers depends on the target 1950e4b17023SJohn Marinoflags, you may indicate this to GCC by using this macro to modify 1951e4b17023SJohn Marino@code{fixed_regs} and @code{call_used_regs} to 1 for each of the 1952e4b17023SJohn Marinoregisters in the classes which should not be used by GCC@. Also define 1953e4b17023SJohn Marinothe macro @code{REG_CLASS_FROM_LETTER} / @code{REG_CLASS_FROM_CONSTRAINT} 1954e4b17023SJohn Marinoto return @code{NO_REGS} if it 1955e4b17023SJohn Marinois called with a letter for a class that shouldn't be used. 1956e4b17023SJohn Marino 1957e4b17023SJohn Marino(However, if this class is not included in @code{GENERAL_REGS} and all 1958e4b17023SJohn Marinoof the insn patterns whose constraints permit this class are 1959e4b17023SJohn Marinocontrolled by target switches, then GCC will automatically avoid using 1960e4b17023SJohn Marinothese registers when the target switches are opposed to them.) 1961e4b17023SJohn Marino@end deftypefn 1962e4b17023SJohn Marino 1963e4b17023SJohn Marino@defmac INCOMING_REGNO (@var{out}) 1964e4b17023SJohn MarinoDefine this macro if the target machine has register windows. This C 1965e4b17023SJohn Marinoexpression returns the register number as seen by the called function 1966e4b17023SJohn Marinocorresponding to the register number @var{out} as seen by the calling 1967e4b17023SJohn Marinofunction. Return @var{out} if register number @var{out} is not an 1968e4b17023SJohn Marinooutbound register. 1969e4b17023SJohn Marino@end defmac 1970e4b17023SJohn Marino 1971e4b17023SJohn Marino@defmac OUTGOING_REGNO (@var{in}) 1972e4b17023SJohn MarinoDefine this macro if the target machine has register windows. This C 1973e4b17023SJohn Marinoexpression returns the register number as seen by the calling function 1974e4b17023SJohn Marinocorresponding to the register number @var{in} as seen by the called 1975e4b17023SJohn Marinofunction. Return @var{in} if register number @var{in} is not an inbound 1976e4b17023SJohn Marinoregister. 1977e4b17023SJohn Marino@end defmac 1978e4b17023SJohn Marino 1979e4b17023SJohn Marino@defmac LOCAL_REGNO (@var{regno}) 1980e4b17023SJohn MarinoDefine this macro if the target machine has register windows. This C 1981e4b17023SJohn Marinoexpression returns true if the register is call-saved but is in the 1982e4b17023SJohn Marinoregister window. Unlike most call-saved registers, such registers 1983e4b17023SJohn Marinoneed not be explicitly restored on function exit or during non-local 1984e4b17023SJohn Marinogotos. 1985e4b17023SJohn Marino@end defmac 1986e4b17023SJohn Marino 1987e4b17023SJohn Marino@defmac PC_REGNUM 1988e4b17023SJohn MarinoIf the program counter has a register number, define this as that 1989e4b17023SJohn Marinoregister number. Otherwise, do not define it. 1990e4b17023SJohn Marino@end defmac 1991e4b17023SJohn Marino 1992e4b17023SJohn Marino@node Allocation Order 1993e4b17023SJohn Marino@subsection Order of Allocation of Registers 1994e4b17023SJohn Marino@cindex order of register allocation 1995e4b17023SJohn Marino@cindex register allocation order 1996e4b17023SJohn Marino 1997e4b17023SJohn Marino@c prevent bad page break with this line 1998e4b17023SJohn MarinoRegisters are allocated in order. 1999e4b17023SJohn Marino 2000e4b17023SJohn Marino@defmac REG_ALLOC_ORDER 2001e4b17023SJohn MarinoIf defined, an initializer for a vector of integers, containing the 2002e4b17023SJohn Marinonumbers of hard registers in the order in which GCC should prefer 2003e4b17023SJohn Marinoto use them (from most preferred to least). 2004e4b17023SJohn Marino 2005e4b17023SJohn MarinoIf this macro is not defined, registers are used lowest numbered first 2006e4b17023SJohn Marino(all else being equal). 2007e4b17023SJohn Marino 2008e4b17023SJohn MarinoOne use of this macro is on machines where the highest numbered 2009e4b17023SJohn Marinoregisters must always be saved and the save-multiple-registers 2010e4b17023SJohn Marinoinstruction supports only sequences of consecutive registers. On such 2011e4b17023SJohn Marinomachines, define @code{REG_ALLOC_ORDER} to be an initializer that lists 2012e4b17023SJohn Marinothe highest numbered allocable register first. 2013e4b17023SJohn Marino@end defmac 2014e4b17023SJohn Marino 2015e4b17023SJohn Marino@defmac ADJUST_REG_ALLOC_ORDER 2016e4b17023SJohn MarinoA C statement (sans semicolon) to choose the order in which to allocate 2017e4b17023SJohn Marinohard registers for pseudo-registers local to a basic block. 2018e4b17023SJohn Marino 2019e4b17023SJohn MarinoStore the desired register order in the array @code{reg_alloc_order}. 2020e4b17023SJohn MarinoElement 0 should be the register to allocate first; element 1, the next 2021e4b17023SJohn Marinoregister; and so on. 2022e4b17023SJohn Marino 2023e4b17023SJohn MarinoThe macro body should not assume anything about the contents of 2024e4b17023SJohn Marino@code{reg_alloc_order} before execution of the macro. 2025e4b17023SJohn Marino 2026e4b17023SJohn MarinoOn most machines, it is not necessary to define this macro. 2027e4b17023SJohn Marino@end defmac 2028e4b17023SJohn Marino 2029e4b17023SJohn Marino@defmac HONOR_REG_ALLOC_ORDER 2030e4b17023SJohn MarinoNormally, IRA tries to estimate the costs for saving a register in the 2031e4b17023SJohn Marinoprologue and restoring it in the epilogue. This discourages it from 2032e4b17023SJohn Marinousing call-saved registers. If a machine wants to ensure that IRA 2033e4b17023SJohn Marinoallocates registers in the order given by REG_ALLOC_ORDER even if some 2034e4b17023SJohn Marinocall-saved registers appear earlier than call-used ones, this macro 2035e4b17023SJohn Marinoshould be defined. 2036e4b17023SJohn Marino@end defmac 2037e4b17023SJohn Marino 2038e4b17023SJohn Marino@defmac IRA_HARD_REGNO_ADD_COST_MULTIPLIER (@var{regno}) 2039e4b17023SJohn MarinoIn some case register allocation order is not enough for the 2040e4b17023SJohn MarinoIntegrated Register Allocator (@acronym{IRA}) to generate a good code. 2041e4b17023SJohn MarinoIf this macro is defined, it should return a floating point value 2042e4b17023SJohn Marinobased on @var{regno}. The cost of using @var{regno} for a pseudo will 2043e4b17023SJohn Marinobe increased by approximately the pseudo's usage frequency times the 2044e4b17023SJohn Marinovalue returned by this macro. Not defining this macro is equivalent 2045e4b17023SJohn Marinoto having it always return @code{0.0}. 2046e4b17023SJohn Marino 2047e4b17023SJohn MarinoOn most machines, it is not necessary to define this macro. 2048e4b17023SJohn Marino@end defmac 2049e4b17023SJohn Marino 2050e4b17023SJohn Marino@node Values in Registers 2051e4b17023SJohn Marino@subsection How Values Fit in Registers 2052e4b17023SJohn Marino 2053e4b17023SJohn MarinoThis section discusses the macros that describe which kinds of values 2054e4b17023SJohn Marino(specifically, which machine modes) each register can hold, and how many 2055e4b17023SJohn Marinoconsecutive registers are needed for a given mode. 2056e4b17023SJohn Marino 2057e4b17023SJohn Marino@defmac HARD_REGNO_NREGS (@var{regno}, @var{mode}) 2058e4b17023SJohn MarinoA C expression for the number of consecutive hard registers, starting 2059e4b17023SJohn Marinoat register number @var{regno}, required to hold a value of mode 2060e4b17023SJohn Marino@var{mode}. This macro must never return zero, even if a register 2061e4b17023SJohn Marinocannot hold the requested mode - indicate that with HARD_REGNO_MODE_OK 2062e4b17023SJohn Marinoand/or CANNOT_CHANGE_MODE_CLASS instead. 2063e4b17023SJohn Marino 2064e4b17023SJohn MarinoOn a machine where all registers are exactly one word, a suitable 2065e4b17023SJohn Marinodefinition of this macro is 2066e4b17023SJohn Marino 2067e4b17023SJohn Marino@smallexample 2068e4b17023SJohn Marino#define HARD_REGNO_NREGS(REGNO, MODE) \ 2069e4b17023SJohn Marino ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \ 2070e4b17023SJohn Marino / UNITS_PER_WORD) 2071e4b17023SJohn Marino@end smallexample 2072e4b17023SJohn Marino@end defmac 2073e4b17023SJohn Marino 2074e4b17023SJohn Marino@defmac HARD_REGNO_NREGS_HAS_PADDING (@var{regno}, @var{mode}) 2075e4b17023SJohn MarinoA C expression that is nonzero if a value of mode @var{mode}, stored 2076e4b17023SJohn Marinoin memory, ends with padding that causes it to take up more space than 2077e4b17023SJohn Marinoin registers starting at register number @var{regno} (as determined by 2078e4b17023SJohn Marinomultiplying GCC's notion of the size of the register when containing 2079e4b17023SJohn Marinothis mode by the number of registers returned by 2080e4b17023SJohn Marino@code{HARD_REGNO_NREGS}). By default this is zero. 2081e4b17023SJohn Marino 2082e4b17023SJohn MarinoFor example, if a floating-point value is stored in three 32-bit 2083e4b17023SJohn Marinoregisters but takes up 128 bits in memory, then this would be 2084e4b17023SJohn Marinononzero. 2085e4b17023SJohn Marino 2086e4b17023SJohn MarinoThis macros only needs to be defined if there are cases where 2087e4b17023SJohn Marino@code{subreg_get_info} 2088e4b17023SJohn Marinowould otherwise wrongly determine that a @code{subreg} can be 2089e4b17023SJohn Marinorepresented by an offset to the register number, when in fact such a 2090e4b17023SJohn Marino@code{subreg} would contain some of the padding not stored in 2091e4b17023SJohn Marinoregisters and so not be representable. 2092e4b17023SJohn Marino@end defmac 2093e4b17023SJohn Marino 2094e4b17023SJohn Marino@defmac HARD_REGNO_NREGS_WITH_PADDING (@var{regno}, @var{mode}) 2095e4b17023SJohn MarinoFor values of @var{regno} and @var{mode} for which 2096e4b17023SJohn Marino@code{HARD_REGNO_NREGS_HAS_PADDING} returns nonzero, a C expression 2097e4b17023SJohn Marinoreturning the greater number of registers required to hold the value 2098e4b17023SJohn Marinoincluding any padding. In the example above, the value would be four. 2099e4b17023SJohn Marino@end defmac 2100e4b17023SJohn Marino 2101e4b17023SJohn Marino@defmac REGMODE_NATURAL_SIZE (@var{mode}) 2102e4b17023SJohn MarinoDefine this macro if the natural size of registers that hold values 2103e4b17023SJohn Marinoof mode @var{mode} is not the word size. It is a C expression that 2104e4b17023SJohn Marinoshould give the natural size in bytes for the specified mode. It is 2105e4b17023SJohn Marinoused by the register allocator to try to optimize its results. This 2106e4b17023SJohn Marinohappens for example on SPARC 64-bit where the natural size of 2107e4b17023SJohn Marinofloating-point registers is still 32-bit. 2108e4b17023SJohn Marino@end defmac 2109e4b17023SJohn Marino 2110e4b17023SJohn Marino@defmac HARD_REGNO_MODE_OK (@var{regno}, @var{mode}) 2111e4b17023SJohn MarinoA C expression that is nonzero if it is permissible to store a value 2112e4b17023SJohn Marinoof mode @var{mode} in hard register number @var{regno} (or in several 2113e4b17023SJohn Marinoregisters starting with that one). For a machine where all registers 2114e4b17023SJohn Marinoare equivalent, a suitable definition is 2115e4b17023SJohn Marino 2116e4b17023SJohn Marino@smallexample 2117e4b17023SJohn Marino#define HARD_REGNO_MODE_OK(REGNO, MODE) 1 2118e4b17023SJohn Marino@end smallexample 2119e4b17023SJohn Marino 2120e4b17023SJohn MarinoYou need not include code to check for the numbers of fixed registers, 2121e4b17023SJohn Marinobecause the allocation mechanism considers them to be always occupied. 2122e4b17023SJohn Marino 2123e4b17023SJohn Marino@cindex register pairs 2124e4b17023SJohn MarinoOn some machines, double-precision values must be kept in even/odd 2125e4b17023SJohn Marinoregister pairs. You can implement that by defining this macro to reject 2126e4b17023SJohn Marinoodd register numbers for such modes. 2127e4b17023SJohn Marino 2128e4b17023SJohn MarinoThe minimum requirement for a mode to be OK in a register is that the 2129e4b17023SJohn Marino@samp{mov@var{mode}} instruction pattern support moves between the 2130e4b17023SJohn Marinoregister and other hard register in the same class and that moving a 2131e4b17023SJohn Marinovalue into the register and back out not alter it. 2132e4b17023SJohn Marino 2133e4b17023SJohn MarinoSince the same instruction used to move @code{word_mode} will work for 2134e4b17023SJohn Marinoall narrower integer modes, it is not necessary on any machine for 2135e4b17023SJohn Marino@code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided 2136e4b17023SJohn Marinoyou define patterns @samp{movhi}, etc., to take advantage of this. This 2137e4b17023SJohn Marinois useful because of the interaction between @code{HARD_REGNO_MODE_OK} 2138e4b17023SJohn Marinoand @code{MODES_TIEABLE_P}; it is very desirable for all integer modes 2139e4b17023SJohn Marinoto be tieable. 2140e4b17023SJohn Marino 2141e4b17023SJohn MarinoMany machines have special registers for floating point arithmetic. 2142e4b17023SJohn MarinoOften people assume that floating point machine modes are allowed only 2143e4b17023SJohn Marinoin floating point registers. This is not true. Any registers that 2144e4b17023SJohn Marinocan hold integers can safely @emph{hold} a floating point machine 2145e4b17023SJohn Marinomode, whether or not floating arithmetic can be done on it in those 2146e4b17023SJohn Marinoregisters. Integer move instructions can be used to move the values. 2147e4b17023SJohn Marino 2148e4b17023SJohn MarinoOn some machines, though, the converse is true: fixed-point machine 2149e4b17023SJohn Marinomodes may not go in floating registers. This is true if the floating 2150e4b17023SJohn Marinoregisters normalize any value stored in them, because storing a 2151e4b17023SJohn Marinonon-floating value there would garble it. In this case, 2152e4b17023SJohn Marino@code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in 2153e4b17023SJohn Marinofloating registers. But if the floating registers do not automatically 2154e4b17023SJohn Marinonormalize, if you can store any bit pattern in one and retrieve it 2155e4b17023SJohn Marinounchanged without a trap, then any machine mode may go in a floating 2156e4b17023SJohn Marinoregister, so you can define this macro to say so. 2157e4b17023SJohn Marino 2158e4b17023SJohn MarinoThe primary significance of special floating registers is rather that 2159e4b17023SJohn Marinothey are the registers acceptable in floating point arithmetic 2160e4b17023SJohn Marinoinstructions. However, this is of no concern to 2161e4b17023SJohn Marino@code{HARD_REGNO_MODE_OK}. You handle it by writing the proper 2162e4b17023SJohn Marinoconstraints for those instructions. 2163e4b17023SJohn Marino 2164e4b17023SJohn MarinoOn some machines, the floating registers are especially slow to access, 2165e4b17023SJohn Marinoso that it is better to store a value in a stack frame than in such a 2166e4b17023SJohn Marinoregister if floating point arithmetic is not being done. As long as the 2167e4b17023SJohn Marinofloating registers are not in class @code{GENERAL_REGS}, they will not 2168e4b17023SJohn Marinobe used unless some pattern's constraint asks for one. 2169e4b17023SJohn Marino@end defmac 2170e4b17023SJohn Marino 2171e4b17023SJohn Marino@defmac HARD_REGNO_RENAME_OK (@var{from}, @var{to}) 2172e4b17023SJohn MarinoA C expression that is nonzero if it is OK to rename a hard register 2173e4b17023SJohn Marino@var{from} to another hard register @var{to}. 2174e4b17023SJohn Marino 2175e4b17023SJohn MarinoOne common use of this macro is to prevent renaming of a register to 2176e4b17023SJohn Marinoanother register that is not saved by a prologue in an interrupt 2177e4b17023SJohn Marinohandler. 2178e4b17023SJohn Marino 2179e4b17023SJohn MarinoThe default is always nonzero. 2180e4b17023SJohn Marino@end defmac 2181e4b17023SJohn Marino 2182e4b17023SJohn Marino@defmac MODES_TIEABLE_P (@var{mode1}, @var{mode2}) 2183e4b17023SJohn MarinoA C expression that is nonzero if a value of mode 2184e4b17023SJohn Marino@var{mode1} is accessible in mode @var{mode2} without copying. 2185e4b17023SJohn Marino 2186e4b17023SJohn MarinoIf @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and 2187e4b17023SJohn Marino@code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are always the same for 2188e4b17023SJohn Marinoany @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, @var{mode2})} 2189e4b17023SJohn Marinoshould be nonzero. If they differ for any @var{r}, you should define 2190e4b17023SJohn Marinothis macro to return zero unless some other mechanism ensures the 2191e4b17023SJohn Marinoaccessibility of the value in a narrower mode. 2192e4b17023SJohn Marino 2193e4b17023SJohn MarinoYou should define this macro to return nonzero in as many cases as 2194e4b17023SJohn Marinopossible since doing so will allow GCC to perform better register 2195e4b17023SJohn Marinoallocation. 2196e4b17023SJohn Marino@end defmac 2197e4b17023SJohn Marino 2198e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_HARD_REGNO_SCRATCH_OK (unsigned int @var{regno}) 2199e4b17023SJohn MarinoThis target hook should return @code{true} if it is OK to use a hard register 2200e4b17023SJohn Marino@var{regno} as scratch reg in peephole2. 2201e4b17023SJohn Marino 2202e4b17023SJohn MarinoOne common use of this macro is to prevent using of a register that 2203e4b17023SJohn Marinois not saved by a prologue in an interrupt handler. 2204e4b17023SJohn Marino 2205e4b17023SJohn MarinoThe default version of this hook always returns @code{true}. 2206e4b17023SJohn Marino@end deftypefn 2207e4b17023SJohn Marino 2208e4b17023SJohn Marino@defmac AVOID_CCMODE_COPIES 2209e4b17023SJohn MarinoDefine this macro if the compiler should avoid copies to/from @code{CCmode} 2210e4b17023SJohn Marinoregisters. You should only define this macro if support for copying to/from 2211e4b17023SJohn Marino@code{CCmode} is incomplete. 2212e4b17023SJohn Marino@end defmac 2213e4b17023SJohn Marino 2214e4b17023SJohn Marino@node Leaf Functions 2215e4b17023SJohn Marino@subsection Handling Leaf Functions 2216e4b17023SJohn Marino 2217e4b17023SJohn Marino@cindex leaf functions 2218e4b17023SJohn Marino@cindex functions, leaf 2219e4b17023SJohn MarinoOn some machines, a leaf function (i.e., one which makes no calls) can run 2220e4b17023SJohn Marinomore efficiently if it does not make its own register window. Often this 2221e4b17023SJohn Marinomeans it is required to receive its arguments in the registers where they 2222e4b17023SJohn Marinoare passed by the caller, instead of the registers where they would 2223e4b17023SJohn Marinonormally arrive. 2224e4b17023SJohn Marino 2225e4b17023SJohn MarinoThe special treatment for leaf functions generally applies only when 2226e4b17023SJohn Marinoother conditions are met; for example, often they may use only those 2227e4b17023SJohn Marinoregisters for its own variables and temporaries. We use the term ``leaf 2228e4b17023SJohn Marinofunction'' to mean a function that is suitable for this special 2229e4b17023SJohn Marinohandling, so that functions with no calls are not necessarily ``leaf 2230e4b17023SJohn Marinofunctions''. 2231e4b17023SJohn Marino 2232e4b17023SJohn MarinoGCC assigns register numbers before it knows whether the function is 2233e4b17023SJohn Marinosuitable for leaf function treatment. So it needs to renumber the 2234e4b17023SJohn Marinoregisters in order to output a leaf function. The following macros 2235e4b17023SJohn Marinoaccomplish this. 2236e4b17023SJohn Marino 2237e4b17023SJohn Marino@defmac LEAF_REGISTERS 2238e4b17023SJohn MarinoName of a char vector, indexed by hard register number, which 2239e4b17023SJohn Marinocontains 1 for a register that is allowable in a candidate for leaf 2240e4b17023SJohn Marinofunction treatment. 2241e4b17023SJohn Marino 2242e4b17023SJohn MarinoIf leaf function treatment involves renumbering the registers, then the 2243e4b17023SJohn Marinoregisters marked here should be the ones before renumbering---those that 2244e4b17023SJohn MarinoGCC would ordinarily allocate. The registers which will actually be 2245e4b17023SJohn Marinoused in the assembler code, after renumbering, should not be marked with 1 2246e4b17023SJohn Marinoin this vector. 2247e4b17023SJohn Marino 2248e4b17023SJohn MarinoDefine this macro only if the target machine offers a way to optimize 2249e4b17023SJohn Marinothe treatment of leaf functions. 2250e4b17023SJohn Marino@end defmac 2251e4b17023SJohn Marino 2252e4b17023SJohn Marino@defmac LEAF_REG_REMAP (@var{regno}) 2253e4b17023SJohn MarinoA C expression whose value is the register number to which @var{regno} 2254e4b17023SJohn Marinoshould be renumbered, when a function is treated as a leaf function. 2255e4b17023SJohn Marino 2256e4b17023SJohn MarinoIf @var{regno} is a register number which should not appear in a leaf 2257e4b17023SJohn Marinofunction before renumbering, then the expression should yield @minus{}1, which 2258e4b17023SJohn Marinowill cause the compiler to abort. 2259e4b17023SJohn Marino 2260e4b17023SJohn MarinoDefine this macro only if the target machine offers a way to optimize the 2261e4b17023SJohn Marinotreatment of leaf functions, and registers need to be renumbered to do 2262e4b17023SJohn Marinothis. 2263e4b17023SJohn Marino@end defmac 2264e4b17023SJohn Marino 2265e4b17023SJohn Marino@findex current_function_is_leaf 2266e4b17023SJohn Marino@findex current_function_uses_only_leaf_regs 2267e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_PROLOGUE} and 2268e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} must usually treat leaf functions 2269e4b17023SJohn Marinospecially. They can test the C variable @code{current_function_is_leaf} 2270e4b17023SJohn Marinowhich is nonzero for leaf functions. @code{current_function_is_leaf} is 2271e4b17023SJohn Marinoset prior to local register allocation and is valid for the remaining 2272e4b17023SJohn Marinocompiler passes. They can also test the C variable 2273e4b17023SJohn Marino@code{current_function_uses_only_leaf_regs} which is nonzero for leaf 2274e4b17023SJohn Marinofunctions which only use leaf registers. 2275e4b17023SJohn Marino@code{current_function_uses_only_leaf_regs} is valid after all passes 2276e4b17023SJohn Marinothat modify the instructions have been run and is only useful if 2277e4b17023SJohn Marino@code{LEAF_REGISTERS} is defined. 2278e4b17023SJohn Marino@c changed this to fix overfull. ALSO: why the "it" at the beginning 2279e4b17023SJohn Marino@c of the next paragraph?! --mew 2feb93 2280e4b17023SJohn Marino 2281e4b17023SJohn Marino@node Stack Registers 2282e4b17023SJohn Marino@subsection Registers That Form a Stack 2283e4b17023SJohn Marino 2284e4b17023SJohn MarinoThere are special features to handle computers where some of the 2285e4b17023SJohn Marino``registers'' form a stack. Stack registers are normally written by 2286e4b17023SJohn Marinopushing onto the stack, and are numbered relative to the top of the 2287e4b17023SJohn Marinostack. 2288e4b17023SJohn Marino 2289e4b17023SJohn MarinoCurrently, GCC can only handle one group of stack-like registers, and 2290e4b17023SJohn Marinothey must be consecutively numbered. Furthermore, the existing 2291e4b17023SJohn Marinosupport for stack-like registers is specific to the 80387 floating 2292e4b17023SJohn Marinopoint coprocessor. If you have a new architecture that uses 2293e4b17023SJohn Marinostack-like registers, you will need to do substantial work on 2294e4b17023SJohn Marino@file{reg-stack.c} and write your machine description to cooperate 2295e4b17023SJohn Marinowith it, as well as defining these macros. 2296e4b17023SJohn Marino 2297e4b17023SJohn Marino@defmac STACK_REGS 2298e4b17023SJohn MarinoDefine this if the machine has any stack-like registers. 2299e4b17023SJohn Marino@end defmac 2300e4b17023SJohn Marino 2301e4b17023SJohn Marino@defmac STACK_REG_COVER_CLASS 2302e4b17023SJohn MarinoThis is a cover class containing the stack registers. Define this if 2303e4b17023SJohn Marinothe machine has any stack-like registers. 2304e4b17023SJohn Marino@end defmac 2305e4b17023SJohn Marino 2306e4b17023SJohn Marino@defmac FIRST_STACK_REG 2307e4b17023SJohn MarinoThe number of the first stack-like register. This one is the top 2308e4b17023SJohn Marinoof the stack. 2309e4b17023SJohn Marino@end defmac 2310e4b17023SJohn Marino 2311e4b17023SJohn Marino@defmac LAST_STACK_REG 2312e4b17023SJohn MarinoThe number of the last stack-like register. This one is the bottom of 2313e4b17023SJohn Marinothe stack. 2314e4b17023SJohn Marino@end defmac 2315e4b17023SJohn Marino 2316e4b17023SJohn Marino@node Register Classes 2317e4b17023SJohn Marino@section Register Classes 2318e4b17023SJohn Marino@cindex register class definitions 2319e4b17023SJohn Marino@cindex class definitions, register 2320e4b17023SJohn Marino 2321e4b17023SJohn MarinoOn many machines, the numbered registers are not all equivalent. 2322e4b17023SJohn MarinoFor example, certain registers may not be allowed for indexed addressing; 2323e4b17023SJohn Marinocertain registers may not be allowed in some instructions. These machine 2324e4b17023SJohn Marinorestrictions are described to the compiler using @dfn{register classes}. 2325e4b17023SJohn Marino 2326e4b17023SJohn MarinoYou define a number of register classes, giving each one a name and saying 2327e4b17023SJohn Marinowhich of the registers belong to it. Then you can specify register classes 2328e4b17023SJohn Marinothat are allowed as operands to particular instruction patterns. 2329e4b17023SJohn Marino 2330e4b17023SJohn Marino@findex ALL_REGS 2331e4b17023SJohn Marino@findex NO_REGS 2332e4b17023SJohn MarinoIn general, each register will belong to several classes. In fact, one 2333e4b17023SJohn Marinoclass must be named @code{ALL_REGS} and contain all the registers. Another 2334e4b17023SJohn Marinoclass must be named @code{NO_REGS} and contain no registers. Often the 2335e4b17023SJohn Marinounion of two classes will be another class; however, this is not required. 2336e4b17023SJohn Marino 2337e4b17023SJohn Marino@findex GENERAL_REGS 2338e4b17023SJohn MarinoOne of the classes must be named @code{GENERAL_REGS}. There is nothing 2339e4b17023SJohn Marinoterribly special about the name, but the operand constraint letters 2340e4b17023SJohn Marino@samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is 2341e4b17023SJohn Marinothe same as @code{ALL_REGS}, just define it as a macro which expands 2342e4b17023SJohn Marinoto @code{ALL_REGS}. 2343e4b17023SJohn Marino 2344e4b17023SJohn MarinoOrder the classes so that if class @var{x} is contained in class @var{y} 2345e4b17023SJohn Marinothen @var{x} has a lower class number than @var{y}. 2346e4b17023SJohn Marino 2347e4b17023SJohn MarinoThe way classes other than @code{GENERAL_REGS} are specified in operand 2348e4b17023SJohn Marinoconstraints is through machine-dependent operand constraint letters. 2349e4b17023SJohn MarinoYou can define such letters to correspond to various classes, then use 2350e4b17023SJohn Marinothem in operand constraints. 2351e4b17023SJohn Marino 2352e4b17023SJohn MarinoYou must define the narrowest register classes for allocatable 2353e4b17023SJohn Marinoregisters, so that each class either has no subclasses, or that for 2354e4b17023SJohn Marinosome mode, the move cost between registers within the class is 2355e4b17023SJohn Marinocheaper than moving a register in the class to or from memory 2356e4b17023SJohn Marino(@pxref{Costs}). 2357e4b17023SJohn Marino 2358e4b17023SJohn MarinoYou should define a class for the union of two classes whenever some 2359e4b17023SJohn Marinoinstruction allows both classes. For example, if an instruction allows 2360e4b17023SJohn Marinoeither a floating point (coprocessor) register or a general register for a 2361e4b17023SJohn Marinocertain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS} 2362e4b17023SJohn Marinowhich includes both of them. Otherwise you will get suboptimal code, 2363e4b17023SJohn Marinoor even internal compiler errors when reload cannot find a register in the 2364e4b17023SJohn Marinoclass computed via @code{reg_class_subunion}. 2365e4b17023SJohn Marino 2366e4b17023SJohn MarinoYou must also specify certain redundant information about the register 2367e4b17023SJohn Marinoclasses: for each class, which classes contain it and which ones are 2368e4b17023SJohn Marinocontained in it; for each pair of classes, the largest class contained 2369e4b17023SJohn Marinoin their union. 2370e4b17023SJohn Marino 2371e4b17023SJohn MarinoWhen a value occupying several consecutive registers is expected in a 2372e4b17023SJohn Marinocertain class, all the registers used must belong to that class. 2373e4b17023SJohn MarinoTherefore, register classes cannot be used to enforce a requirement for 2374e4b17023SJohn Marinoa register pair to start with an even-numbered register. The way to 2375e4b17023SJohn Marinospecify this requirement is with @code{HARD_REGNO_MODE_OK}. 2376e4b17023SJohn Marino 2377e4b17023SJohn MarinoRegister classes used for input-operands of bitwise-and or shift 2378e4b17023SJohn Marinoinstructions have a special requirement: each such class must have, for 2379e4b17023SJohn Marinoeach fixed-point machine mode, a subclass whose registers can transfer that 2380e4b17023SJohn Marinomode to or from memory. For example, on some machines, the operations for 2381e4b17023SJohn Marinosingle-byte values (@code{QImode}) are limited to certain registers. When 2382e4b17023SJohn Marinothis is so, each register class that is used in a bitwise-and or shift 2383e4b17023SJohn Marinoinstruction must have a subclass consisting of registers from which 2384e4b17023SJohn Marinosingle-byte values can be loaded or stored. This is so that 2385e4b17023SJohn Marino@code{PREFERRED_RELOAD_CLASS} can always have a possible value to return. 2386e4b17023SJohn Marino 2387e4b17023SJohn Marino@deftp {Data type} {enum reg_class} 2388e4b17023SJohn MarinoAn enumerated type that must be defined with all the register class names 2389e4b17023SJohn Marinoas enumerated values. @code{NO_REGS} must be first. @code{ALL_REGS} 2390e4b17023SJohn Marinomust be the last register class, followed by one more enumerated value, 2391e4b17023SJohn Marino@code{LIM_REG_CLASSES}, which is not a register class but rather 2392e4b17023SJohn Marinotells how many classes there are. 2393e4b17023SJohn Marino 2394e4b17023SJohn MarinoEach register class has a number, which is the value of casting 2395e4b17023SJohn Marinothe class name to type @code{int}. The number serves as an index 2396e4b17023SJohn Marinoin many of the tables described below. 2397e4b17023SJohn Marino@end deftp 2398e4b17023SJohn Marino 2399e4b17023SJohn Marino@defmac N_REG_CLASSES 2400e4b17023SJohn MarinoThe number of distinct register classes, defined as follows: 2401e4b17023SJohn Marino 2402e4b17023SJohn Marino@smallexample 2403e4b17023SJohn Marino#define N_REG_CLASSES (int) LIM_REG_CLASSES 2404e4b17023SJohn Marino@end smallexample 2405e4b17023SJohn Marino@end defmac 2406e4b17023SJohn Marino 2407e4b17023SJohn Marino@defmac REG_CLASS_NAMES 2408e4b17023SJohn MarinoAn initializer containing the names of the register classes as C string 2409e4b17023SJohn Marinoconstants. These names are used in writing some of the debugging dumps. 2410e4b17023SJohn Marino@end defmac 2411e4b17023SJohn Marino 2412e4b17023SJohn Marino@defmac REG_CLASS_CONTENTS 2413e4b17023SJohn MarinoAn initializer containing the contents of the register classes, as integers 2414e4b17023SJohn Marinowhich are bit masks. The @var{n}th integer specifies the contents of class 2415e4b17023SJohn Marino@var{n}. The way the integer @var{mask} is interpreted is that 2416e4b17023SJohn Marinoregister @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1. 2417e4b17023SJohn Marino 2418e4b17023SJohn MarinoWhen the machine has more than 32 registers, an integer does not suffice. 2419e4b17023SJohn MarinoThen the integers are replaced by sub-initializers, braced groupings containing 2420e4b17023SJohn Marinoseveral integers. Each sub-initializer must be suitable as an initializer 2421e4b17023SJohn Marinofor the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}. 2422e4b17023SJohn MarinoIn this situation, the first integer in each sub-initializer corresponds to 2423e4b17023SJohn Marinoregisters 0 through 31, the second integer to registers 32 through 63, and 2424e4b17023SJohn Marinoso on. 2425e4b17023SJohn Marino@end defmac 2426e4b17023SJohn Marino 2427e4b17023SJohn Marino@defmac REGNO_REG_CLASS (@var{regno}) 2428e4b17023SJohn MarinoA C expression whose value is a register class containing hard register 2429e4b17023SJohn Marino@var{regno}. In general there is more than one such class; choose a class 2430e4b17023SJohn Marinowhich is @dfn{minimal}, meaning that no smaller class also contains the 2431e4b17023SJohn Marinoregister. 2432e4b17023SJohn Marino@end defmac 2433e4b17023SJohn Marino 2434e4b17023SJohn Marino@defmac BASE_REG_CLASS 2435e4b17023SJohn MarinoA macro whose definition is the name of the class to which a valid 2436e4b17023SJohn Marinobase register must belong. A base register is one used in an address 2437e4b17023SJohn Marinowhich is the register value plus a displacement. 2438e4b17023SJohn Marino@end defmac 2439e4b17023SJohn Marino 2440e4b17023SJohn Marino@defmac MODE_BASE_REG_CLASS (@var{mode}) 2441e4b17023SJohn MarinoThis is a variation of the @code{BASE_REG_CLASS} macro which allows 2442e4b17023SJohn Marinothe selection of a base register in a mode dependent manner. If 2443e4b17023SJohn Marino@var{mode} is VOIDmode then it should return the same value as 2444e4b17023SJohn Marino@code{BASE_REG_CLASS}. 2445e4b17023SJohn Marino@end defmac 2446e4b17023SJohn Marino 2447e4b17023SJohn Marino@defmac MODE_BASE_REG_REG_CLASS (@var{mode}) 2448e4b17023SJohn MarinoA C expression whose value is the register class to which a valid 2449e4b17023SJohn Marinobase register must belong in order to be used in a base plus index 2450e4b17023SJohn Marinoregister address. You should define this macro if base plus index 2451e4b17023SJohn Marinoaddresses have different requirements than other base register uses. 2452e4b17023SJohn Marino@end defmac 2453e4b17023SJohn Marino 2454e4b17023SJohn Marino@defmac MODE_CODE_BASE_REG_CLASS (@var{mode}, @var{address_space}, @var{outer_code}, @var{index_code}) 2455e4b17023SJohn MarinoA C expression whose value is the register class to which a valid 2456e4b17023SJohn Marinobase register for a memory reference in mode @var{mode} to address 2457e4b17023SJohn Marinospace @var{address_space} must belong. @var{outer_code} and @var{index_code} 2458e4b17023SJohn Marinodefine the context in which the base register occurs. @var{outer_code} is 2459e4b17023SJohn Marinothe code of the immediately enclosing expression (@code{MEM} for the top level 2460e4b17023SJohn Marinoof an address, @code{ADDRESS} for something that occurs in an 2461e4b17023SJohn Marino@code{address_operand}). @var{index_code} is the code of the corresponding 2462e4b17023SJohn Marinoindex expression if @var{outer_code} is @code{PLUS}; @code{SCRATCH} otherwise. 2463e4b17023SJohn Marino@end defmac 2464e4b17023SJohn Marino 2465e4b17023SJohn Marino@defmac INDEX_REG_CLASS 2466e4b17023SJohn MarinoA macro whose definition is the name of the class to which a valid 2467e4b17023SJohn Marinoindex register must belong. An index register is one used in an 2468e4b17023SJohn Marinoaddress where its value is either multiplied by a scale factor or 2469e4b17023SJohn Marinoadded to another register (as well as added to a displacement). 2470e4b17023SJohn Marino@end defmac 2471e4b17023SJohn Marino 2472e4b17023SJohn Marino@defmac REGNO_OK_FOR_BASE_P (@var{num}) 2473e4b17023SJohn MarinoA C expression which is nonzero if register number @var{num} is 2474e4b17023SJohn Marinosuitable for use as a base register in operand addresses. 2475e4b17023SJohn Marino@end defmac 2476e4b17023SJohn Marino 2477e4b17023SJohn Marino@defmac REGNO_MODE_OK_FOR_BASE_P (@var{num}, @var{mode}) 2478e4b17023SJohn MarinoA C expression that is just like @code{REGNO_OK_FOR_BASE_P}, except that 2479e4b17023SJohn Marinothat expression may examine the mode of the memory reference in 2480e4b17023SJohn Marino@var{mode}. You should define this macro if the mode of the memory 2481e4b17023SJohn Marinoreference affects whether a register may be used as a base register. If 2482e4b17023SJohn Marinoyou define this macro, the compiler will use it instead of 2483e4b17023SJohn Marino@code{REGNO_OK_FOR_BASE_P}. The mode may be @code{VOIDmode} for 2484e4b17023SJohn Marinoaddresses that appear outside a @code{MEM}, i.e., as an 2485e4b17023SJohn Marino@code{address_operand}. 2486e4b17023SJohn Marino@end defmac 2487e4b17023SJohn Marino 2488e4b17023SJohn Marino@defmac REGNO_MODE_OK_FOR_REG_BASE_P (@var{num}, @var{mode}) 2489e4b17023SJohn MarinoA C expression which is nonzero if register number @var{num} is suitable for 2490e4b17023SJohn Marinouse as a base register in base plus index operand addresses, accessing 2491e4b17023SJohn Marinomemory in mode @var{mode}. It may be either a suitable hard register or a 2492e4b17023SJohn Marinopseudo register that has been allocated such a hard register. You should 2493e4b17023SJohn Marinodefine this macro if base plus index addresses have different requirements 2494e4b17023SJohn Marinothan other base register uses. 2495e4b17023SJohn Marino 2496e4b17023SJohn MarinoUse of this macro is deprecated; please use the more general 2497e4b17023SJohn Marino@code{REGNO_MODE_CODE_OK_FOR_BASE_P}. 2498e4b17023SJohn Marino@end defmac 2499e4b17023SJohn Marino 2500e4b17023SJohn Marino@defmac REGNO_MODE_CODE_OK_FOR_BASE_P (@var{num}, @var{mode}, @var{address_space}, @var{outer_code}, @var{index_code}) 2501e4b17023SJohn MarinoA C expression which is nonzero if register number @var{num} is 2502e4b17023SJohn Marinosuitable for use as a base register in operand addresses, accessing 2503e4b17023SJohn Marinomemory in mode @var{mode} in address space @var{address_space}. 2504e4b17023SJohn MarinoThis is similar to @code{REGNO_MODE_OK_FOR_BASE_P}, except 2505e4b17023SJohn Marinothat that expression may examine the context in which the register 2506e4b17023SJohn Marinoappears in the memory reference. @var{outer_code} is the code of the 2507e4b17023SJohn Marinoimmediately enclosing expression (@code{MEM} if at the top level of the 2508e4b17023SJohn Marinoaddress, @code{ADDRESS} for something that occurs in an 2509e4b17023SJohn Marino@code{address_operand}). @var{index_code} is the code of the 2510e4b17023SJohn Marinocorresponding index expression if @var{outer_code} is @code{PLUS}; 2511e4b17023SJohn Marino@code{SCRATCH} otherwise. The mode may be @code{VOIDmode} for addresses 2512e4b17023SJohn Marinothat appear outside a @code{MEM}, i.e., as an @code{address_operand}. 2513e4b17023SJohn Marino@end defmac 2514e4b17023SJohn Marino 2515e4b17023SJohn Marino@defmac REGNO_OK_FOR_INDEX_P (@var{num}) 2516e4b17023SJohn MarinoA C expression which is nonzero if register number @var{num} is 2517e4b17023SJohn Marinosuitable for use as an index register in operand addresses. It may be 2518e4b17023SJohn Marinoeither a suitable hard register or a pseudo register that has been 2519e4b17023SJohn Marinoallocated such a hard register. 2520e4b17023SJohn Marino 2521e4b17023SJohn MarinoThe difference between an index register and a base register is that 2522e4b17023SJohn Marinothe index register may be scaled. If an address involves the sum of 2523e4b17023SJohn Marinotwo registers, neither one of them scaled, then either one may be 2524e4b17023SJohn Marinolabeled the ``base'' and the other the ``index''; but whichever 2525e4b17023SJohn Marinolabeling is used must fit the machine's constraints of which registers 2526e4b17023SJohn Marinomay serve in each capacity. The compiler will try both labelings, 2527e4b17023SJohn Marinolooking for one that is valid, and will reload one or both registers 2528e4b17023SJohn Marinoonly if neither labeling works. 2529e4b17023SJohn Marino@end defmac 2530e4b17023SJohn Marino 2531e4b17023SJohn Marino@deftypefn {Target Hook} reg_class_t TARGET_PREFERRED_RENAME_CLASS (reg_class_t @var{rclass}) 2532e4b17023SJohn MarinoA target hook that places additional preference on the register class to use when it is necessary to rename a register in class @var{rclass} to another class, or perhaps @var{NO_REGS}, if no preferred register class is found or hook @code{preferred_rename_class} is not implemented. Sometimes returning a more restrictive class makes better code. For example, on ARM, thumb-2 instructions using @code{LO_REGS} may be smaller than instructions using @code{GENERIC_REGS}. By returning @code{LO_REGS} from @code{preferred_rename_class}, code size can be reduced. 2533e4b17023SJohn Marino@end deftypefn 2534e4b17023SJohn Marino 2535e4b17023SJohn Marino@deftypefn {Target Hook} reg_class_t TARGET_PREFERRED_RELOAD_CLASS (rtx @var{x}, reg_class_t @var{rclass}) 2536e4b17023SJohn MarinoA target hook that places additional restrictions on the register class 2537e4b17023SJohn Marinoto use when it is necessary to copy value @var{x} into a register in class 2538e4b17023SJohn Marino@var{rclass}. The value is a register class; perhaps @var{rclass}, or perhaps 2539e4b17023SJohn Marinoanother, smaller class. 2540e4b17023SJohn Marino 2541e4b17023SJohn MarinoThe default version of this hook always returns value of @code{rclass} argument. 2542e4b17023SJohn Marino 2543e4b17023SJohn MarinoSometimes returning a more restrictive class makes better code. For 2544e4b17023SJohn Marinoexample, on the 68000, when @var{x} is an integer constant that is in range 2545e4b17023SJohn Marinofor a @samp{moveq} instruction, the value of this macro is always 2546e4b17023SJohn Marino@code{DATA_REGS} as long as @var{rclass} includes the data registers. 2547e4b17023SJohn MarinoRequiring a data register guarantees that a @samp{moveq} will be used. 2548e4b17023SJohn Marino 2549e4b17023SJohn MarinoOne case where @code{TARGET_PREFERRED_RELOAD_CLASS} must not return 2550e4b17023SJohn Marino@var{rclass} is if @var{x} is a legitimate constant which cannot be 2551e4b17023SJohn Marinoloaded into some register class. By returning @code{NO_REGS} you can 2552e4b17023SJohn Marinoforce @var{x} into a memory location. For example, rs6000 can load 2553e4b17023SJohn Marinoimmediate values into general-purpose registers, but does not have an 2554e4b17023SJohn Marinoinstruction for loading an immediate value into a floating-point 2555e4b17023SJohn Marinoregister, so @code{TARGET_PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when 2556e4b17023SJohn Marino@var{x} is a floating-point constant. If the constant can't be loaded 2557e4b17023SJohn Marinointo any kind of register, code generation will be better if 2558e4b17023SJohn Marino@code{TARGET_LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead 2559e4b17023SJohn Marinoof using @code{TARGET_PREFERRED_RELOAD_CLASS}. 2560e4b17023SJohn Marino 2561e4b17023SJohn MarinoIf an insn has pseudos in it after register allocation, reload will go 2562e4b17023SJohn Marinothrough the alternatives and call repeatedly @code{TARGET_PREFERRED_RELOAD_CLASS} 2563e4b17023SJohn Marinoto find the best one. Returning @code{NO_REGS}, in this case, makes 2564e4b17023SJohn Marinoreload add a @code{!} in front of the constraint: the x86 back-end uses 2565e4b17023SJohn Marinothis feature to discourage usage of 387 registers when math is done in 2566e4b17023SJohn Marinothe SSE registers (and vice versa). 2567e4b17023SJohn Marino@end deftypefn 2568e4b17023SJohn Marino 2569e4b17023SJohn Marino@defmac PREFERRED_RELOAD_CLASS (@var{x}, @var{class}) 2570e4b17023SJohn MarinoA C expression that places additional restrictions on the register class 2571e4b17023SJohn Marinoto use when it is necessary to copy value @var{x} into a register in class 2572e4b17023SJohn Marino@var{class}. The value is a register class; perhaps @var{class}, or perhaps 2573e4b17023SJohn Marinoanother, smaller class. On many machines, the following definition is 2574e4b17023SJohn Marinosafe: 2575e4b17023SJohn Marino 2576e4b17023SJohn Marino@smallexample 2577e4b17023SJohn Marino#define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS 2578e4b17023SJohn Marino@end smallexample 2579e4b17023SJohn Marino 2580e4b17023SJohn MarinoSometimes returning a more restrictive class makes better code. For 2581e4b17023SJohn Marinoexample, on the 68000, when @var{x} is an integer constant that is in range 2582e4b17023SJohn Marinofor a @samp{moveq} instruction, the value of this macro is always 2583e4b17023SJohn Marino@code{DATA_REGS} as long as @var{class} includes the data registers. 2584e4b17023SJohn MarinoRequiring a data register guarantees that a @samp{moveq} will be used. 2585e4b17023SJohn Marino 2586e4b17023SJohn MarinoOne case where @code{PREFERRED_RELOAD_CLASS} must not return 2587e4b17023SJohn Marino@var{class} is if @var{x} is a legitimate constant which cannot be 2588e4b17023SJohn Marinoloaded into some register class. By returning @code{NO_REGS} you can 2589e4b17023SJohn Marinoforce @var{x} into a memory location. For example, rs6000 can load 2590e4b17023SJohn Marinoimmediate values into general-purpose registers, but does not have an 2591e4b17023SJohn Marinoinstruction for loading an immediate value into a floating-point 2592e4b17023SJohn Marinoregister, so @code{PREFERRED_RELOAD_CLASS} returns @code{NO_REGS} when 2593e4b17023SJohn Marino@var{x} is a floating-point constant. If the constant can't be loaded 2594e4b17023SJohn Marinointo any kind of register, code generation will be better if 2595e4b17023SJohn Marino@code{TARGET_LEGITIMATE_CONSTANT_P} makes the constant illegitimate instead 2596e4b17023SJohn Marinoof using @code{TARGET_PREFERRED_RELOAD_CLASS}. 2597e4b17023SJohn Marino 2598e4b17023SJohn MarinoIf an insn has pseudos in it after register allocation, reload will go 2599e4b17023SJohn Marinothrough the alternatives and call repeatedly @code{PREFERRED_RELOAD_CLASS} 2600e4b17023SJohn Marinoto find the best one. Returning @code{NO_REGS}, in this case, makes 2601e4b17023SJohn Marinoreload add a @code{!} in front of the constraint: the x86 back-end uses 2602e4b17023SJohn Marinothis feature to discourage usage of 387 registers when math is done in 2603e4b17023SJohn Marinothe SSE registers (and vice versa). 2604e4b17023SJohn Marino@end defmac 2605e4b17023SJohn Marino 2606e4b17023SJohn Marino@deftypefn {Target Hook} reg_class_t TARGET_PREFERRED_OUTPUT_RELOAD_CLASS (rtx @var{x}, reg_class_t @var{rclass}) 2607e4b17023SJohn MarinoLike @code{TARGET_PREFERRED_RELOAD_CLASS}, but for output reloads instead of 2608e4b17023SJohn Marinoinput reloads. 2609e4b17023SJohn Marino 2610e4b17023SJohn MarinoThe default version of this hook always returns value of @code{rclass} 2611e4b17023SJohn Marinoargument. 2612e4b17023SJohn Marino 2613e4b17023SJohn MarinoYou can also use @code{TARGET_PREFERRED_OUTPUT_RELOAD_CLASS} to discourage 2614e4b17023SJohn Marinoreload from using some alternatives, like @code{TARGET_PREFERRED_RELOAD_CLASS}. 2615e4b17023SJohn Marino@end deftypefn 2616e4b17023SJohn Marino 2617e4b17023SJohn Marino@defmac LIMIT_RELOAD_CLASS (@var{mode}, @var{class}) 2618e4b17023SJohn MarinoA C expression that places additional restrictions on the register class 2619e4b17023SJohn Marinoto use when it is necessary to be able to hold a value of mode 2620e4b17023SJohn Marino@var{mode} in a reload register for which class @var{class} would 2621e4b17023SJohn Marinoordinarily be used. 2622e4b17023SJohn Marino 2623e4b17023SJohn MarinoUnlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when 2624e4b17023SJohn Marinothere are certain modes that simply can't go in certain reload classes. 2625e4b17023SJohn Marino 2626e4b17023SJohn MarinoThe value is a register class; perhaps @var{class}, or perhaps another, 2627e4b17023SJohn Marinosmaller class. 2628e4b17023SJohn Marino 2629e4b17023SJohn MarinoDon't define this macro unless the target machine has limitations which 2630e4b17023SJohn Marinorequire the macro to do something nontrivial. 2631e4b17023SJohn Marino@end defmac 2632e4b17023SJohn Marino 2633e4b17023SJohn Marino@deftypefn {Target Hook} reg_class_t TARGET_SECONDARY_RELOAD (bool @var{in_p}, rtx @var{x}, reg_class_t @var{reload_class}, enum machine_mode @var{reload_mode}, secondary_reload_info *@var{sri}) 2634e4b17023SJohn MarinoMany machines have some registers that cannot be copied directly to or 2635e4b17023SJohn Marinofrom memory or even from other types of registers. An example is the 2636e4b17023SJohn Marino@samp{MQ} register, which on most machines, can only be copied to or 2637e4b17023SJohn Marinofrom general registers, but not memory. Below, we shall be using the 2638e4b17023SJohn Marinoterm 'intermediate register' when a move operation cannot be performed 2639e4b17023SJohn Marinodirectly, but has to be done by copying the source into the intermediate 2640e4b17023SJohn Marinoregister first, and then copying the intermediate register to the 2641e4b17023SJohn Marinodestination. An intermediate register always has the same mode as 2642e4b17023SJohn Marinosource and destination. Since it holds the actual value being copied, 2643e4b17023SJohn Marinoreload might apply optimizations to re-use an intermediate register 2644e4b17023SJohn Marinoand eliding the copy from the source when it can determine that the 2645e4b17023SJohn Marinointermediate register still holds the required value. 2646e4b17023SJohn Marino 2647e4b17023SJohn MarinoAnother kind of secondary reload is required on some machines which 2648e4b17023SJohn Marinoallow copying all registers to and from memory, but require a scratch 2649e4b17023SJohn Marinoregister for stores to some memory locations (e.g., those with symbolic 2650e4b17023SJohn Marinoaddress on the RT, and those with certain symbolic address on the SPARC 2651e4b17023SJohn Marinowhen compiling PIC)@. Scratch registers need not have the same mode 2652e4b17023SJohn Marinoas the value being copied, and usually hold a different value than 2653e4b17023SJohn Marinothat being copied. Special patterns in the md file are needed to 2654e4b17023SJohn Marinodescribe how the copy is performed with the help of the scratch register; 2655e4b17023SJohn Marinothese patterns also describe the number, register class(es) and mode(s) 2656e4b17023SJohn Marinoof the scratch register(s). 2657e4b17023SJohn Marino 2658e4b17023SJohn MarinoIn some cases, both an intermediate and a scratch register are required. 2659e4b17023SJohn Marino 2660e4b17023SJohn MarinoFor input reloads, this target hook is called with nonzero @var{in_p}, 2661e4b17023SJohn Marinoand @var{x} is an rtx that needs to be copied to a register of class 2662e4b17023SJohn Marino@var{reload_class} in @var{reload_mode}. For output reloads, this target 2663e4b17023SJohn Marinohook is called with zero @var{in_p}, and a register of class @var{reload_class} 2664e4b17023SJohn Marinoneeds to be copied to rtx @var{x} in @var{reload_mode}. 2665e4b17023SJohn Marino 2666e4b17023SJohn MarinoIf copying a register of @var{reload_class} from/to @var{x} requires 2667e4b17023SJohn Marinoan intermediate register, the hook @code{secondary_reload} should 2668e4b17023SJohn Marinoreturn the register class required for this intermediate register. 2669e4b17023SJohn MarinoIf no intermediate register is required, it should return NO_REGS. 2670e4b17023SJohn MarinoIf more than one intermediate register is required, describe the one 2671e4b17023SJohn Marinothat is closest in the copy chain to the reload register. 2672e4b17023SJohn Marino 2673e4b17023SJohn MarinoIf scratch registers are needed, you also have to describe how to 2674e4b17023SJohn Marinoperform the copy from/to the reload register to/from this 2675e4b17023SJohn Marinoclosest intermediate register. Or if no intermediate register is 2676e4b17023SJohn Marinorequired, but still a scratch register is needed, describe the 2677e4b17023SJohn Marinocopy from/to the reload register to/from the reload operand @var{x}. 2678e4b17023SJohn Marino 2679e4b17023SJohn MarinoYou do this by setting @code{sri->icode} to the instruction code of a pattern 2680e4b17023SJohn Marinoin the md file which performs the move. Operands 0 and 1 are the output 2681e4b17023SJohn Marinoand input of this copy, respectively. Operands from operand 2 onward are 2682e4b17023SJohn Marinofor scratch operands. These scratch operands must have a mode, and a 2683e4b17023SJohn Marinosingle-register-class 2684e4b17023SJohn Marino@c [later: or memory] 2685e4b17023SJohn Marinooutput constraint. 2686e4b17023SJohn Marino 2687e4b17023SJohn MarinoWhen an intermediate register is used, the @code{secondary_reload} 2688e4b17023SJohn Marinohook will be called again to determine how to copy the intermediate 2689e4b17023SJohn Marinoregister to/from the reload operand @var{x}, so your hook must also 2690e4b17023SJohn Marinohave code to handle the register class of the intermediate operand. 2691e4b17023SJohn Marino 2692e4b17023SJohn Marino@c [For later: maybe we'll allow multi-alternative reload patterns - 2693e4b17023SJohn Marino@c the port maintainer could name a mov<mode> pattern that has clobbers - 2694e4b17023SJohn Marino@c and match the constraints of input and output to determine the required 2695e4b17023SJohn Marino@c alternative. A restriction would be that constraints used to match 2696e4b17023SJohn Marino@c against reloads registers would have to be written as register class 2697e4b17023SJohn Marino@c constraints, or we need a new target macro / hook that tells us if an 2698e4b17023SJohn Marino@c arbitrary constraint can match an unknown register of a given class. 2699e4b17023SJohn Marino@c Such a macro / hook would also be useful in other places.] 2700e4b17023SJohn Marino 2701e4b17023SJohn Marino 2702e4b17023SJohn Marino@var{x} might be a pseudo-register or a @code{subreg} of a 2703e4b17023SJohn Marinopseudo-register, which could either be in a hard register or in memory. 2704e4b17023SJohn MarinoUse @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is 2705e4b17023SJohn Marinoin memory and the hard register number if it is in a register. 2706e4b17023SJohn Marino 2707e4b17023SJohn MarinoScratch operands in memory (constraint @code{"=m"} / @code{"=&m"}) are 2708e4b17023SJohn Marinocurrently not supported. For the time being, you will have to continue 2709e4b17023SJohn Marinoto use @code{SECONDARY_MEMORY_NEEDED} for that purpose. 2710e4b17023SJohn Marino 2711e4b17023SJohn Marino@code{copy_cost} also uses this target hook to find out how values are 2712e4b17023SJohn Marinocopied. If you want it to include some extra cost for the need to allocate 2713e4b17023SJohn Marino(a) scratch register(s), set @code{sri->extra_cost} to the additional cost. 2714e4b17023SJohn MarinoOr if two dependent moves are supposed to have a lower cost than the sum 2715e4b17023SJohn Marinoof the individual moves due to expected fortuitous scheduling and/or special 2716e4b17023SJohn Marinoforwarding logic, you can set @code{sri->extra_cost} to a negative amount. 2717e4b17023SJohn Marino@end deftypefn 2718e4b17023SJohn Marino 2719e4b17023SJohn Marino@defmac SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) 2720e4b17023SJohn Marino@defmacx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) 2721e4b17023SJohn Marino@defmacx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) 2722e4b17023SJohn MarinoThese macros are obsolete, new ports should use the target hook 2723e4b17023SJohn Marino@code{TARGET_SECONDARY_RELOAD} instead. 2724e4b17023SJohn Marino 2725e4b17023SJohn MarinoThese are obsolete macros, replaced by the @code{TARGET_SECONDARY_RELOAD} 2726e4b17023SJohn Marinotarget hook. Older ports still define these macros to indicate to the 2727e4b17023SJohn Marinoreload phase that it may 2728e4b17023SJohn Marinoneed to allocate at least one register for a reload in addition to the 2729e4b17023SJohn Marinoregister to contain the data. Specifically, if copying @var{x} to a 2730e4b17023SJohn Marinoregister @var{class} in @var{mode} requires an intermediate register, 2731e4b17023SJohn Marinoyou were supposed to define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the 2732e4b17023SJohn Marinolargest register class all of whose registers can be used as 2733e4b17023SJohn Marinointermediate registers or scratch registers. 2734e4b17023SJohn Marino 2735e4b17023SJohn MarinoIf copying a register @var{class} in @var{mode} to @var{x} requires an 2736e4b17023SJohn Marinointermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS} 2737e4b17023SJohn Marinowas supposed to be defined be defined to return the largest register 2738e4b17023SJohn Marinoclass required. If the 2739e4b17023SJohn Marinorequirements for input and output reloads were the same, the macro 2740e4b17023SJohn Marino@code{SECONDARY_RELOAD_CLASS} should have been used instead of defining both 2741e4b17023SJohn Marinomacros identically. 2742e4b17023SJohn Marino 2743e4b17023SJohn MarinoThe values returned by these macros are often @code{GENERAL_REGS}. 2744e4b17023SJohn MarinoReturn @code{NO_REGS} if no spare register is needed; i.e., if @var{x} 2745e4b17023SJohn Marinocan be directly copied to or from a register of @var{class} in 2746e4b17023SJohn Marino@var{mode} without requiring a scratch register. Do not define this 2747e4b17023SJohn Marinomacro if it would always return @code{NO_REGS}. 2748e4b17023SJohn Marino 2749e4b17023SJohn MarinoIf a scratch register is required (either with or without an 2750e4b17023SJohn Marinointermediate register), you were supposed to define patterns for 2751e4b17023SJohn Marino@samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required 2752e4b17023SJohn Marino(@pxref{Standard Names}. These patterns, which were normally 2753e4b17023SJohn Marinoimplemented with a @code{define_expand}, should be similar to the 2754e4b17023SJohn Marino@samp{mov@var{m}} patterns, except that operand 2 is the scratch 2755e4b17023SJohn Marinoregister. 2756e4b17023SJohn Marino 2757e4b17023SJohn MarinoThese patterns need constraints for the reload register and scratch 2758e4b17023SJohn Marinoregister that 2759e4b17023SJohn Marinocontain a single register class. If the original reload register (whose 2760e4b17023SJohn Marinoclass is @var{class}) can meet the constraint given in the pattern, the 2761e4b17023SJohn Marinovalue returned by these macros is used for the class of the scratch 2762e4b17023SJohn Marinoregister. Otherwise, two additional reload registers are required. 2763e4b17023SJohn MarinoTheir classes are obtained from the constraints in the insn pattern. 2764e4b17023SJohn Marino 2765e4b17023SJohn Marino@var{x} might be a pseudo-register or a @code{subreg} of a 2766e4b17023SJohn Marinopseudo-register, which could either be in a hard register or in memory. 2767e4b17023SJohn MarinoUse @code{true_regnum} to find out; it will return @minus{}1 if the pseudo is 2768e4b17023SJohn Marinoin memory and the hard register number if it is in a register. 2769e4b17023SJohn Marino 2770e4b17023SJohn MarinoThese macros should not be used in the case where a particular class of 2771e4b17023SJohn Marinoregisters can only be copied to memory and not to another class of 2772e4b17023SJohn Marinoregisters. In that case, secondary reload registers are not needed and 2773e4b17023SJohn Marinowould not be helpful. Instead, a stack location must be used to perform 2774e4b17023SJohn Marinothe copy and the @code{mov@var{m}} pattern should use memory as an 2775e4b17023SJohn Marinointermediate storage. This case often occurs between floating-point and 2776e4b17023SJohn Marinogeneral registers. 2777e4b17023SJohn Marino@end defmac 2778e4b17023SJohn Marino 2779e4b17023SJohn Marino@defmac SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m}) 2780e4b17023SJohn MarinoCertain machines have the property that some registers cannot be copied 2781e4b17023SJohn Marinoto some other registers without using memory. Define this macro on 2782e4b17023SJohn Marinothose machines to be a C expression that is nonzero if objects of mode 2783e4b17023SJohn Marino@var{m} in registers of @var{class1} can only be copied to registers of 2784e4b17023SJohn Marinoclass @var{class2} by storing a register of @var{class1} into memory 2785e4b17023SJohn Marinoand loading that memory location into a register of @var{class2}. 2786e4b17023SJohn Marino 2787e4b17023SJohn MarinoDo not define this macro if its value would always be zero. 2788e4b17023SJohn Marino@end defmac 2789e4b17023SJohn Marino 2790e4b17023SJohn Marino@defmac SECONDARY_MEMORY_NEEDED_RTX (@var{mode}) 2791e4b17023SJohn MarinoNormally when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler 2792e4b17023SJohn Marinoallocates a stack slot for a memory location needed for register copies. 2793e4b17023SJohn MarinoIf this macro is defined, the compiler instead uses the memory location 2794e4b17023SJohn Marinodefined by this macro. 2795e4b17023SJohn Marino 2796e4b17023SJohn MarinoDo not define this macro if you do not define 2797e4b17023SJohn Marino@code{SECONDARY_MEMORY_NEEDED}. 2798e4b17023SJohn Marino@end defmac 2799e4b17023SJohn Marino 2800e4b17023SJohn Marino@defmac SECONDARY_MEMORY_NEEDED_MODE (@var{mode}) 2801e4b17023SJohn MarinoWhen the compiler needs a secondary memory location to copy between two 2802e4b17023SJohn Marinoregisters of mode @var{mode}, it normally allocates sufficient memory to 2803e4b17023SJohn Marinohold a quantity of @code{BITS_PER_WORD} bits and performs the store and 2804e4b17023SJohn Marinoload operations in a mode that many bits wide and whose class is the 2805e4b17023SJohn Marinosame as that of @var{mode}. 2806e4b17023SJohn Marino 2807e4b17023SJohn MarinoThis is right thing to do on most machines because it ensures that all 2808e4b17023SJohn Marinobits of the register are copied and prevents accesses to the registers 2809e4b17023SJohn Marinoin a narrower mode, which some machines prohibit for floating-point 2810e4b17023SJohn Marinoregisters. 2811e4b17023SJohn Marino 2812e4b17023SJohn MarinoHowever, this default behavior is not correct on some machines, such as 2813e4b17023SJohn Marinothe DEC Alpha, that store short integers in floating-point registers 2814e4b17023SJohn Marinodifferently than in integer registers. On those machines, the default 2815e4b17023SJohn Marinowidening will not work correctly and you must define this macro to 2816e4b17023SJohn Marinosuppress that widening in some cases. See the file @file{alpha.h} for 2817e4b17023SJohn Marinodetails. 2818e4b17023SJohn Marino 2819e4b17023SJohn MarinoDo not define this macro if you do not define 2820e4b17023SJohn Marino@code{SECONDARY_MEMORY_NEEDED} or if widening @var{mode} to a mode that 2821e4b17023SJohn Marinois @code{BITS_PER_WORD} bits wide is correct for your machine. 2822e4b17023SJohn Marino@end defmac 2823e4b17023SJohn Marino 2824e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CLASS_LIKELY_SPILLED_P (reg_class_t @var{rclass}) 2825e4b17023SJohn MarinoA target hook which returns @code{true} if pseudos that have been assigned 2826e4b17023SJohn Marinoto registers of class @var{rclass} would likely be spilled because 2827e4b17023SJohn Marinoregisters of @var{rclass} are needed for spill registers. 2828e4b17023SJohn Marino 2829e4b17023SJohn MarinoThe default version of this target hook returns @code{true} if @var{rclass} 2830e4b17023SJohn Marinohas exactly one register and @code{false} otherwise. On most machines, this 2831e4b17023SJohn Marinodefault should be used. Only use this target hook to some other expression 2832e4b17023SJohn Marinoif pseudos allocated by @file{local-alloc.c} end up in memory because their 2833e4b17023SJohn Marinohard registers were needed for spill registers. If this target hook returns 2834e4b17023SJohn Marino@code{false} for those classes, those pseudos will only be allocated by 2835e4b17023SJohn Marino@file{global.c}, which knows how to reallocate the pseudo to another 2836e4b17023SJohn Marinoregister. If there would not be another register available for reallocation, 2837e4b17023SJohn Marinoyou should not change the implementation of this target hook since 2838e4b17023SJohn Marinothe only effect of such implementation would be to slow down register 2839e4b17023SJohn Marinoallocation. 2840e4b17023SJohn Marino@end deftypefn 2841e4b17023SJohn Marino 2842e4b17023SJohn Marino@deftypefn {Target Hook} {unsigned char} TARGET_CLASS_MAX_NREGS (reg_class_t @var{rclass}, enum machine_mode @var{mode}) 2843e4b17023SJohn MarinoA target hook returns the maximum number of consecutive registers 2844e4b17023SJohn Marinoof class @var{rclass} needed to hold a value of mode @var{mode}. 2845e4b17023SJohn Marino 2846e4b17023SJohn MarinoThis is closely related to the macro @code{HARD_REGNO_NREGS}. In fact, 2847e4b17023SJohn Marinothe value returned by @code{TARGET_CLASS_MAX_NREGS (@var{rclass}, 2848e4b17023SJohn Marino@var{mode})} target hook should be the maximum value of 2849e4b17023SJohn Marino@code{HARD_REGNO_NREGS (@var{regno}, @var{mode})} for all @var{regno} 2850e4b17023SJohn Marinovalues in the class @var{rclass}. 2851e4b17023SJohn Marino 2852e4b17023SJohn MarinoThis target hook helps control the handling of multiple-word values 2853e4b17023SJohn Marinoin the reload pass. 2854e4b17023SJohn Marino 2855e4b17023SJohn MarinoThe default version of this target hook returns the size of @var{mode} 2856e4b17023SJohn Marinoin words. 2857e4b17023SJohn Marino@end deftypefn 2858e4b17023SJohn Marino 2859e4b17023SJohn Marino@defmac CLASS_MAX_NREGS (@var{class}, @var{mode}) 2860e4b17023SJohn MarinoA C expression for the maximum number of consecutive registers 2861e4b17023SJohn Marinoof class @var{class} needed to hold a value of mode @var{mode}. 2862e4b17023SJohn Marino 2863e4b17023SJohn MarinoThis is closely related to the macro @code{HARD_REGNO_NREGS}. In fact, 2864e4b17023SJohn Marinothe value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})} 2865e4b17023SJohn Marinoshould be the maximum value of @code{HARD_REGNO_NREGS (@var{regno}, 2866e4b17023SJohn Marino@var{mode})} for all @var{regno} values in the class @var{class}. 2867e4b17023SJohn Marino 2868e4b17023SJohn MarinoThis macro helps control the handling of multiple-word values 2869e4b17023SJohn Marinoin the reload pass. 2870e4b17023SJohn Marino@end defmac 2871e4b17023SJohn Marino 2872e4b17023SJohn Marino@defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class}) 2873e4b17023SJohn MarinoIf defined, a C expression that returns nonzero for a @var{class} for which 2874e4b17023SJohn Marinoa change from mode @var{from} to mode @var{to} is invalid. 2875e4b17023SJohn Marino 2876e4b17023SJohn MarinoFor the example, loading 32-bit integer or floating-point objects into 2877e4b17023SJohn Marinofloating-point registers on the Alpha extends them to 64 bits. 2878e4b17023SJohn MarinoTherefore loading a 64-bit object and then storing it as a 32-bit object 2879e4b17023SJohn Marinodoes not store the low-order 32 bits, as would be the case for a normal 2880e4b17023SJohn Marinoregister. Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS} 2881e4b17023SJohn Marinoas below: 2882e4b17023SJohn Marino 2883e4b17023SJohn Marino@smallexample 2884e4b17023SJohn Marino#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \ 2885e4b17023SJohn Marino (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \ 2886e4b17023SJohn Marino ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0) 2887e4b17023SJohn Marino@end smallexample 2888e4b17023SJohn Marino@end defmac 2889e4b17023SJohn Marino 2890e4b17023SJohn Marino@node Old Constraints 2891e4b17023SJohn Marino@section Obsolete Macros for Defining Constraints 2892e4b17023SJohn Marino@cindex defining constraints, obsolete method 2893e4b17023SJohn Marino@cindex constraints, defining, obsolete method 2894e4b17023SJohn Marino 2895e4b17023SJohn MarinoMachine-specific constraints can be defined with these macros instead 2896e4b17023SJohn Marinoof the machine description constructs described in @ref{Define 2897e4b17023SJohn MarinoConstraints}. This mechanism is obsolete. New ports should not use 2898e4b17023SJohn Marinoit; old ports should convert to the new mechanism. 2899e4b17023SJohn Marino 2900e4b17023SJohn Marino@defmac CONSTRAINT_LEN (@var{char}, @var{str}) 2901e4b17023SJohn MarinoFor the constraint at the start of @var{str}, which starts with the letter 2902e4b17023SJohn Marino@var{c}, return the length. This allows you to have register class / 2903e4b17023SJohn Marinoconstant / extra constraints that are longer than a single letter; 2904e4b17023SJohn Marinoyou don't need to define this macro if you can do with single-letter 2905e4b17023SJohn Marinoconstraints only. The definition of this macro should use 2906e4b17023SJohn MarinoDEFAULT_CONSTRAINT_LEN for all the characters that you don't want 2907e4b17023SJohn Marinoto handle specially. 2908e4b17023SJohn MarinoThere are some sanity checks in genoutput.c that check the constraint lengths 2909e4b17023SJohn Marinofor the md file, so you can also use this macro to help you while you are 2910e4b17023SJohn Marinotransitioning from a byzantine single-letter-constraint scheme: when you 2911e4b17023SJohn Marinoreturn a negative length for a constraint you want to re-use, genoutput 2912e4b17023SJohn Marinowill complain about every instance where it is used in the md file. 2913e4b17023SJohn Marino@end defmac 2914e4b17023SJohn Marino 2915e4b17023SJohn Marino@defmac REG_CLASS_FROM_LETTER (@var{char}) 2916e4b17023SJohn MarinoA C expression which defines the machine-dependent operand constraint 2917e4b17023SJohn Marinoletters for register classes. If @var{char} is such a letter, the 2918e4b17023SJohn Marinovalue should be the register class corresponding to it. Otherwise, 2919e4b17023SJohn Marinothe value should be @code{NO_REGS}. The register letter @samp{r}, 2920e4b17023SJohn Marinocorresponding to class @code{GENERAL_REGS}, will not be passed 2921e4b17023SJohn Marinoto this macro; you do not need to handle it. 2922e4b17023SJohn Marino@end defmac 2923e4b17023SJohn Marino 2924e4b17023SJohn Marino@defmac REG_CLASS_FROM_CONSTRAINT (@var{char}, @var{str}) 2925e4b17023SJohn MarinoLike @code{REG_CLASS_FROM_LETTER}, but you also get the constraint string 2926e4b17023SJohn Marinopassed in @var{str}, so that you can use suffixes to distinguish between 2927e4b17023SJohn Marinodifferent variants. 2928e4b17023SJohn Marino@end defmac 2929e4b17023SJohn Marino 2930e4b17023SJohn Marino@defmac CONST_OK_FOR_LETTER_P (@var{value}, @var{c}) 2931e4b17023SJohn MarinoA C expression that defines the machine-dependent operand constraint 2932e4b17023SJohn Marinoletters (@samp{I}, @samp{J}, @samp{K}, @dots{} @samp{P}) that specify 2933e4b17023SJohn Marinoparticular ranges of integer values. If @var{c} is one of those 2934e4b17023SJohn Marinoletters, the expression should check that @var{value}, an integer, is in 2935e4b17023SJohn Marinothe appropriate range and return 1 if so, 0 otherwise. If @var{c} is 2936e4b17023SJohn Marinonot one of those letters, the value should be 0 regardless of 2937e4b17023SJohn Marino@var{value}. 2938e4b17023SJohn Marino@end defmac 2939e4b17023SJohn Marino 2940e4b17023SJohn Marino@defmac CONST_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str}) 2941e4b17023SJohn MarinoLike @code{CONST_OK_FOR_LETTER_P}, but you also get the constraint 2942e4b17023SJohn Marinostring passed in @var{str}, so that you can use suffixes to distinguish 2943e4b17023SJohn Marinobetween different variants. 2944e4b17023SJohn Marino@end defmac 2945e4b17023SJohn Marino 2946e4b17023SJohn Marino@defmac CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c}) 2947e4b17023SJohn MarinoA C expression that defines the machine-dependent operand constraint 2948e4b17023SJohn Marinoletters that specify particular ranges of @code{const_double} values 2949e4b17023SJohn Marino(@samp{G} or @samp{H}). 2950e4b17023SJohn Marino 2951e4b17023SJohn MarinoIf @var{c} is one of those letters, the expression should check that 2952e4b17023SJohn Marino@var{value}, an RTX of code @code{const_double}, is in the appropriate 2953e4b17023SJohn Marinorange and return 1 if so, 0 otherwise. If @var{c} is not one of those 2954e4b17023SJohn Marinoletters, the value should be 0 regardless of @var{value}. 2955e4b17023SJohn Marino 2956e4b17023SJohn Marino@code{const_double} is used for all floating-point constants and for 2957e4b17023SJohn Marino@code{DImode} fixed-point constants. A given letter can accept either 2958e4b17023SJohn Marinoor both kinds of values. It can use @code{GET_MODE} to distinguish 2959e4b17023SJohn Marinobetween these kinds. 2960e4b17023SJohn Marino@end defmac 2961e4b17023SJohn Marino 2962e4b17023SJohn Marino@defmac CONST_DOUBLE_OK_FOR_CONSTRAINT_P (@var{value}, @var{c}, @var{str}) 2963e4b17023SJohn MarinoLike @code{CONST_DOUBLE_OK_FOR_LETTER_P}, but you also get the constraint 2964e4b17023SJohn Marinostring passed in @var{str}, so that you can use suffixes to distinguish 2965e4b17023SJohn Marinobetween different variants. 2966e4b17023SJohn Marino@end defmac 2967e4b17023SJohn Marino 2968e4b17023SJohn Marino@defmac EXTRA_CONSTRAINT (@var{value}, @var{c}) 2969e4b17023SJohn MarinoA C expression that defines the optional machine-dependent constraint 2970e4b17023SJohn Marinoletters that can be used to segregate specific types of operands, usually 2971e4b17023SJohn Marinomemory references, for the target machine. Any letter that is not 2972e4b17023SJohn Marinoelsewhere defined and not matched by @code{REG_CLASS_FROM_LETTER} / 2973e4b17023SJohn Marino@code{REG_CLASS_FROM_CONSTRAINT} 2974e4b17023SJohn Marinomay be used. Normally this macro will not be defined. 2975e4b17023SJohn Marino 2976e4b17023SJohn MarinoIf it is required for a particular target machine, it should return 1 2977e4b17023SJohn Marinoif @var{value} corresponds to the operand type represented by the 2978e4b17023SJohn Marinoconstraint letter @var{c}. If @var{c} is not defined as an extra 2979e4b17023SJohn Marinoconstraint, the value returned should be 0 regardless of @var{value}. 2980e4b17023SJohn Marino 2981e4b17023SJohn MarinoFor example, on the ROMP, load instructions cannot have their output 2982e4b17023SJohn Marinoin r0 if the memory reference contains a symbolic address. Constraint 2983e4b17023SJohn Marinoletter @samp{Q} is defined as representing a memory address that does 2984e4b17023SJohn Marino@emph{not} contain a symbolic address. An alternative is specified with 2985e4b17023SJohn Marinoa @samp{Q} constraint on the input and @samp{r} on the output. The next 2986e4b17023SJohn Marinoalternative specifies @samp{m} on the input and a register class that 2987e4b17023SJohn Marinodoes not include r0 on the output. 2988e4b17023SJohn Marino@end defmac 2989e4b17023SJohn Marino 2990e4b17023SJohn Marino@defmac EXTRA_CONSTRAINT_STR (@var{value}, @var{c}, @var{str}) 2991e4b17023SJohn MarinoLike @code{EXTRA_CONSTRAINT}, but you also get the constraint string passed 2992e4b17023SJohn Marinoin @var{str}, so that you can use suffixes to distinguish between different 2993e4b17023SJohn Marinovariants. 2994e4b17023SJohn Marino@end defmac 2995e4b17023SJohn Marino 2996e4b17023SJohn Marino@defmac EXTRA_MEMORY_CONSTRAINT (@var{c}, @var{str}) 2997e4b17023SJohn MarinoA C expression that defines the optional machine-dependent constraint 2998e4b17023SJohn Marinoletters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should 2999e4b17023SJohn Marinobe treated like memory 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}, the first letter of which is the letter @var{c}, 3003e4b17023SJohn Marinocomprises a subset of all memory references including 3004e4b17023SJohn Marinoall those whose address is simply 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{c}, by copying its address into a base register. 3007e4b17023SJohn Marino 3008e4b17023SJohn MarinoFor example, on the S/390, some instructions do not accept arbitrary 3009e4b17023SJohn Marinomemory references, but only those that do not make use of an index 3010e4b17023SJohn Marinoregister. The constraint letter @samp{Q} is defined via 3011e4b17023SJohn Marino@code{EXTRA_CONSTRAINT} as representing a memory address of this type. 3012e4b17023SJohn MarinoIf the letter @samp{Q} is marked as @code{EXTRA_MEMORY_CONSTRAINT}, 3013e4b17023SJohn Marinoa @samp{Q} constraint can handle any memory operand, because the 3014e4b17023SJohn Marinoreload pass knows it can be reloaded by copying the memory address 3015e4b17023SJohn Marinointo a base register if required. This is analogous to the way 3016e4b17023SJohn Marinoan @samp{o} constraint can handle any memory operand. 3017e4b17023SJohn Marino@end defmac 3018e4b17023SJohn Marino 3019e4b17023SJohn Marino@defmac EXTRA_ADDRESS_CONSTRAINT (@var{c}, @var{str}) 3020e4b17023SJohn MarinoA C expression that defines the optional machine-dependent constraint 3021e4b17023SJohn Marinoletters, amongst those accepted by @code{EXTRA_CONSTRAINT} / 3022e4b17023SJohn Marino@code{EXTRA_CONSTRAINT_STR}, that should 3023e4b17023SJohn Marinobe treated like address constraints by the reload pass. 3024e4b17023SJohn Marino 3025e4b17023SJohn MarinoIt should return 1 if the operand type represented by the constraint 3026e4b17023SJohn Marinoat the start of @var{str}, which starts with the letter @var{c}, comprises 3027e4b17023SJohn Marinoa subset of all memory addresses including 3028e4b17023SJohn Marinoall those that consist of just a base register. This allows the reload 3029e4b17023SJohn Marinopass to reload an operand, if it does not directly correspond to the operand 3030e4b17023SJohn Marinotype of @var{str}, by copying it into a base register. 3031e4b17023SJohn Marino 3032e4b17023SJohn MarinoAny constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only 3033e4b17023SJohn Marinobe used with the @code{address_operand} predicate. It is treated 3034e4b17023SJohn Marinoanalogously to the @samp{p} constraint. 3035e4b17023SJohn Marino@end defmac 3036e4b17023SJohn Marino 3037e4b17023SJohn Marino@node Stack and Calling 3038e4b17023SJohn Marino@section Stack Layout and Calling Conventions 3039e4b17023SJohn Marino@cindex calling conventions 3040e4b17023SJohn Marino 3041e4b17023SJohn Marino@c prevent bad page break with this line 3042e4b17023SJohn MarinoThis describes the stack layout and calling conventions. 3043e4b17023SJohn Marino 3044e4b17023SJohn Marino@menu 3045e4b17023SJohn Marino* Frame Layout:: 3046e4b17023SJohn Marino* Exception Handling:: 3047e4b17023SJohn Marino* Stack Checking:: 3048e4b17023SJohn Marino* Frame Registers:: 3049e4b17023SJohn Marino* Elimination:: 3050e4b17023SJohn Marino* Stack Arguments:: 3051e4b17023SJohn Marino* Register Arguments:: 3052e4b17023SJohn Marino* Scalar Return:: 3053e4b17023SJohn Marino* Aggregate Return:: 3054e4b17023SJohn Marino* Caller Saves:: 3055e4b17023SJohn Marino* Function Entry:: 3056e4b17023SJohn Marino* Profiling:: 3057e4b17023SJohn Marino* Tail Calls:: 3058e4b17023SJohn Marino* Stack Smashing Protection:: 3059e4b17023SJohn Marino@end menu 3060e4b17023SJohn Marino 3061e4b17023SJohn Marino@node Frame Layout 3062e4b17023SJohn Marino@subsection Basic Stack Layout 3063e4b17023SJohn Marino@cindex stack frame layout 3064e4b17023SJohn Marino@cindex frame layout 3065e4b17023SJohn Marino 3066e4b17023SJohn Marino@c prevent bad page break with this line 3067e4b17023SJohn MarinoHere is the basic stack layout. 3068e4b17023SJohn Marino 3069e4b17023SJohn Marino@defmac STACK_GROWS_DOWNWARD 3070e4b17023SJohn MarinoDefine this macro if pushing a word onto the stack moves the stack 3071e4b17023SJohn Marinopointer to a smaller address. 3072e4b17023SJohn Marino 3073e4b17023SJohn MarinoWhen we say, ``define this macro if @dots{}'', it means that the 3074e4b17023SJohn Marinocompiler checks this macro only with @code{#ifdef} so the precise 3075e4b17023SJohn Marinodefinition used does not matter. 3076e4b17023SJohn Marino@end defmac 3077e4b17023SJohn Marino 3078e4b17023SJohn Marino@defmac STACK_PUSH_CODE 3079e4b17023SJohn MarinoThis macro defines the operation used when something is pushed 3080e4b17023SJohn Marinoon the stack. In RTL, a push operation will be 3081e4b17023SJohn Marino@code{(set (mem (STACK_PUSH_CODE (reg sp))) @dots{})} 3082e4b17023SJohn Marino 3083e4b17023SJohn MarinoThe choices are @code{PRE_DEC}, @code{POST_DEC}, @code{PRE_INC}, 3084e4b17023SJohn Marinoand @code{POST_INC}. Which of these is correct depends on 3085e4b17023SJohn Marinothe stack direction and on whether the stack pointer points 3086e4b17023SJohn Marinoto the last item on the stack or whether it points to the 3087e4b17023SJohn Marinospace for the next item on the stack. 3088e4b17023SJohn Marino 3089e4b17023SJohn MarinoThe default is @code{PRE_DEC} when @code{STACK_GROWS_DOWNWARD} is 3090e4b17023SJohn Marinodefined, which is almost always right, and @code{PRE_INC} otherwise, 3091e4b17023SJohn Marinowhich is often wrong. 3092e4b17023SJohn Marino@end defmac 3093e4b17023SJohn Marino 3094e4b17023SJohn Marino@defmac FRAME_GROWS_DOWNWARD 3095e4b17023SJohn MarinoDefine this macro to nonzero value if the addresses of local variable slots 3096e4b17023SJohn Marinoare at negative offsets from the frame pointer. 3097e4b17023SJohn Marino@end defmac 3098e4b17023SJohn Marino 3099e4b17023SJohn Marino@defmac ARGS_GROW_DOWNWARD 3100e4b17023SJohn MarinoDefine this macro if successive arguments to a function occupy decreasing 3101e4b17023SJohn Marinoaddresses on the stack. 3102e4b17023SJohn Marino@end defmac 3103e4b17023SJohn Marino 3104e4b17023SJohn Marino@defmac STARTING_FRAME_OFFSET 3105e4b17023SJohn MarinoOffset from the frame pointer to the first local variable slot to be allocated. 3106e4b17023SJohn Marino 3107e4b17023SJohn MarinoIf @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by 3108e4b17023SJohn Marinosubtracting the first slot's length from @code{STARTING_FRAME_OFFSET}. 3109e4b17023SJohn MarinoOtherwise, it is found by adding the length of the first slot to the 3110e4b17023SJohn Marinovalue @code{STARTING_FRAME_OFFSET}. 3111e4b17023SJohn Marino@c i'm not sure if the above is still correct.. had to change it to get 3112e4b17023SJohn Marino@c rid of an overfull. --mew 2feb93 3113e4b17023SJohn Marino@end defmac 3114e4b17023SJohn Marino 3115e4b17023SJohn Marino@defmac STACK_ALIGNMENT_NEEDED 3116e4b17023SJohn MarinoDefine to zero to disable final alignment of the stack during reload. 3117e4b17023SJohn MarinoThe nonzero default for this macro is suitable for most ports. 3118e4b17023SJohn Marino 3119e4b17023SJohn MarinoOn ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there 3120e4b17023SJohn Marinois a register save block following the local block that doesn't require 3121e4b17023SJohn Marinoalignment to @code{STACK_BOUNDARY}, it may be beneficial to disable 3122e4b17023SJohn Marinostack alignment and do it in the backend. 3123e4b17023SJohn Marino@end defmac 3124e4b17023SJohn Marino 3125e4b17023SJohn Marino@defmac STACK_POINTER_OFFSET 3126e4b17023SJohn MarinoOffset from the stack pointer register to the first location at which 3127e4b17023SJohn Marinooutgoing arguments are placed. If not specified, the default value of 3128e4b17023SJohn Marinozero is used. This is the proper value for most machines. 3129e4b17023SJohn Marino 3130e4b17023SJohn MarinoIf @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above 3131e4b17023SJohn Marinothe first location at which outgoing arguments are placed. 3132e4b17023SJohn Marino@end defmac 3133e4b17023SJohn Marino 3134e4b17023SJohn Marino@defmac FIRST_PARM_OFFSET (@var{fundecl}) 3135e4b17023SJohn MarinoOffset from the argument pointer register to the first argument's 3136e4b17023SJohn Marinoaddress. On some machines it may depend on the data type of the 3137e4b17023SJohn Marinofunction. 3138e4b17023SJohn Marino 3139e4b17023SJohn MarinoIf @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above 3140e4b17023SJohn Marinothe first argument's address. 3141e4b17023SJohn Marino@end defmac 3142e4b17023SJohn Marino 3143e4b17023SJohn Marino@defmac STACK_DYNAMIC_OFFSET (@var{fundecl}) 3144e4b17023SJohn MarinoOffset from the stack pointer register to an item dynamically allocated 3145e4b17023SJohn Marinoon the stack, e.g., by @code{alloca}. 3146e4b17023SJohn Marino 3147e4b17023SJohn MarinoThe default value for this macro is @code{STACK_POINTER_OFFSET} plus the 3148e4b17023SJohn Marinolength of the outgoing arguments. The default is correct for most 3149e4b17023SJohn Marinomachines. See @file{function.c} for details. 3150e4b17023SJohn Marino@end defmac 3151e4b17023SJohn Marino 3152e4b17023SJohn Marino@defmac INITIAL_FRAME_ADDRESS_RTX 3153e4b17023SJohn MarinoA C expression whose value is RTL representing the address of the initial 3154e4b17023SJohn Marinostack frame. This address is passed to @code{RETURN_ADDR_RTX} and 3155e4b17023SJohn Marino@code{DYNAMIC_CHAIN_ADDRESS}. If you don't define this macro, a reasonable 3156e4b17023SJohn Marinodefault value will be used. Define this macro in order to make frame pointer 3157e4b17023SJohn Marinoelimination work in the presence of @code{__builtin_frame_address (count)} and 3158e4b17023SJohn Marino@code{__builtin_return_address (count)} for @code{count} not equal to zero. 3159e4b17023SJohn Marino@end defmac 3160e4b17023SJohn Marino 3161e4b17023SJohn Marino@defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr}) 3162e4b17023SJohn MarinoA C expression whose value is RTL representing the address in a stack 3163e4b17023SJohn Marinoframe where the pointer to the caller's frame is stored. Assume that 3164e4b17023SJohn Marino@var{frameaddr} is an RTL expression for the address of the stack frame 3165e4b17023SJohn Marinoitself. 3166e4b17023SJohn Marino 3167e4b17023SJohn MarinoIf you don't define this macro, the default is to return the value 3168e4b17023SJohn Marinoof @var{frameaddr}---that is, the stack frame address is also the 3169e4b17023SJohn Marinoaddress of the stack word that points to the previous frame. 3170e4b17023SJohn Marino@end defmac 3171e4b17023SJohn Marino 3172e4b17023SJohn Marino@defmac SETUP_FRAME_ADDRESSES 3173e4b17023SJohn MarinoIf defined, a C expression that produces the machine-specific code to 3174e4b17023SJohn Marinosetup the stack so that arbitrary frames can be accessed. For example, 3175e4b17023SJohn Marinoon the SPARC, we must flush all of the register windows to the stack 3176e4b17023SJohn Marinobefore we can access arbitrary stack frames. You will seldom need to 3177e4b17023SJohn Marinodefine this macro. 3178e4b17023SJohn Marino@end defmac 3179e4b17023SJohn Marino 3180e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_BUILTIN_SETJMP_FRAME_VALUE (void) 3181e4b17023SJohn MarinoThis target hook should return an rtx that is used to store 3182e4b17023SJohn Marinothe address of the current frame into the built in @code{setjmp} buffer. 3183e4b17023SJohn MarinoThe default value, @code{virtual_stack_vars_rtx}, is correct for most 3184e4b17023SJohn Marinomachines. One reason you may need to define this target hook is if 3185e4b17023SJohn Marino@code{hard_frame_pointer_rtx} is the appropriate value on your machine. 3186e4b17023SJohn Marino@end deftypefn 3187e4b17023SJohn Marino 3188e4b17023SJohn Marino@defmac FRAME_ADDR_RTX (@var{frameaddr}) 3189e4b17023SJohn MarinoA C expression whose value is RTL representing the value of the frame 3190e4b17023SJohn Marinoaddress for the current frame. @var{frameaddr} is the frame pointer 3191e4b17023SJohn Marinoof the current frame. This is used for __builtin_frame_address. 3192e4b17023SJohn MarinoYou need only define this macro if the frame address is not the same 3193e4b17023SJohn Marinoas the frame pointer. Most machines do not need to define it. 3194e4b17023SJohn Marino@end defmac 3195e4b17023SJohn Marino 3196e4b17023SJohn Marino@defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr}) 3197e4b17023SJohn MarinoA C expression whose value is RTL representing the value of the return 3198e4b17023SJohn Marinoaddress for the frame @var{count} steps up from the current frame, after 3199e4b17023SJohn Marinothe prologue. @var{frameaddr} is the frame pointer of the @var{count} 3200e4b17023SJohn Marinoframe, or the frame pointer of the @var{count} @minus{} 1 frame if 3201e4b17023SJohn Marino@code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined. 3202e4b17023SJohn Marino 3203e4b17023SJohn MarinoThe value of the expression must always be the correct address when 3204e4b17023SJohn Marino@var{count} is zero, but may be @code{NULL_RTX} if there is no way to 3205e4b17023SJohn Marinodetermine the return address of other frames. 3206e4b17023SJohn Marino@end defmac 3207e4b17023SJohn Marino 3208e4b17023SJohn Marino@defmac RETURN_ADDR_IN_PREVIOUS_FRAME 3209e4b17023SJohn MarinoDefine this if the return address of a particular stack frame is accessed 3210e4b17023SJohn Marinofrom the frame pointer of the previous stack frame. 3211e4b17023SJohn Marino@end defmac 3212e4b17023SJohn Marino 3213e4b17023SJohn Marino@defmac INCOMING_RETURN_ADDR_RTX 3214e4b17023SJohn MarinoA C expression whose value is RTL representing the location of the 3215e4b17023SJohn Marinoincoming return address at the beginning of any function, before the 3216e4b17023SJohn Marinoprologue. This RTL is either a @code{REG}, indicating that the return 3217e4b17023SJohn Marinovalue is saved in @samp{REG}, or a @code{MEM} representing a location in 3218e4b17023SJohn Marinothe stack. 3219e4b17023SJohn Marino 3220e4b17023SJohn MarinoYou only need to define this macro if you want to support call frame 3221e4b17023SJohn Marinodebugging information like that provided by DWARF 2. 3222e4b17023SJohn Marino 3223e4b17023SJohn MarinoIf this RTL is a @code{REG}, you should also define 3224e4b17023SJohn Marino@code{DWARF_FRAME_RETURN_COLUMN} to @code{DWARF_FRAME_REGNUM (REGNO)}. 3225e4b17023SJohn Marino@end defmac 3226e4b17023SJohn Marino 3227e4b17023SJohn Marino@defmac DWARF_ALT_FRAME_RETURN_COLUMN 3228e4b17023SJohn MarinoA C expression whose value is an integer giving a DWARF 2 column 3229e4b17023SJohn Marinonumber that may be used as an alternative return column. The column 3230e4b17023SJohn Marinomust not correspond to any gcc hard register (that is, it must not 3231e4b17023SJohn Marinobe in the range of @code{DWARF_FRAME_REGNUM}). 3232e4b17023SJohn Marino 3233e4b17023SJohn MarinoThis macro can be useful if @code{DWARF_FRAME_RETURN_COLUMN} is set to a 3234e4b17023SJohn Marinogeneral register, but an alternative column needs to be used for signal 3235e4b17023SJohn Marinoframes. Some targets have also used different frame return columns 3236e4b17023SJohn Marinoover time. 3237e4b17023SJohn Marino@end defmac 3238e4b17023SJohn Marino 3239e4b17023SJohn Marino@defmac DWARF_ZERO_REG 3240e4b17023SJohn MarinoA C expression whose value is an integer giving a DWARF 2 register 3241e4b17023SJohn Marinonumber that is considered to always have the value zero. This should 3242e4b17023SJohn Marinoonly be defined if the target has an architected zero register, and 3243e4b17023SJohn Marinosomeone decided it was a good idea to use that register number to 3244e4b17023SJohn Marinoterminate the stack backtrace. New ports should avoid this. 3245e4b17023SJohn Marino@end defmac 3246e4b17023SJohn Marino 3247e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_DWARF_HANDLE_FRAME_UNSPEC (const char *@var{label}, rtx @var{pattern}, int @var{index}) 3248e4b17023SJohn MarinoThis target hook allows the backend to emit frame-related insns that 3249e4b17023SJohn Marinocontain UNSPECs or UNSPEC_VOLATILEs. The DWARF 2 call frame debugging 3250e4b17023SJohn Marinoinfo engine will invoke it on insns of the form 3251e4b17023SJohn Marino@smallexample 3252e4b17023SJohn Marino(set (reg) (unspec [@dots{}] UNSPEC_INDEX)) 3253e4b17023SJohn Marino@end smallexample 3254e4b17023SJohn Marinoand 3255e4b17023SJohn Marino@smallexample 3256e4b17023SJohn Marino(set (reg) (unspec_volatile [@dots{}] UNSPECV_INDEX)). 3257e4b17023SJohn Marino@end smallexample 3258e4b17023SJohn Marinoto let the backend emit the call frame instructions. @var{label} is 3259e4b17023SJohn Marinothe CFI label attached to the insn, @var{pattern} is the pattern of 3260e4b17023SJohn Marinothe insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}. 3261e4b17023SJohn Marino@end deftypefn 3262e4b17023SJohn Marino 3263e4b17023SJohn Marino@defmac INCOMING_FRAME_SP_OFFSET 3264e4b17023SJohn MarinoA C expression whose value is an integer giving the offset, in bytes, 3265e4b17023SJohn Marinofrom the value of the stack pointer register to the top of the stack 3266e4b17023SJohn Marinoframe at the beginning of any function, before the prologue. The top of 3267e4b17023SJohn Marinothe frame is defined to be the value of the stack pointer in the 3268e4b17023SJohn Marinoprevious frame, just before the call instruction. 3269e4b17023SJohn Marino 3270e4b17023SJohn MarinoYou only need to define this macro if you want to support call frame 3271e4b17023SJohn Marinodebugging information like that provided by DWARF 2. 3272e4b17023SJohn Marino@end defmac 3273e4b17023SJohn Marino 3274e4b17023SJohn Marino@defmac ARG_POINTER_CFA_OFFSET (@var{fundecl}) 3275e4b17023SJohn MarinoA C expression whose value is an integer giving the offset, in bytes, 3276e4b17023SJohn Marinofrom the argument pointer to the canonical frame address (cfa). The 3277e4b17023SJohn Marinofinal value should coincide with that calculated by 3278e4b17023SJohn Marino@code{INCOMING_FRAME_SP_OFFSET}. Which is unfortunately not usable 3279e4b17023SJohn Marinoduring virtual register instantiation. 3280e4b17023SJohn Marino 3281e4b17023SJohn MarinoThe default value for this macro is 3282e4b17023SJohn Marino@code{FIRST_PARM_OFFSET (fundecl) + crtl->args.pretend_args_size}, 3283e4b17023SJohn Marinowhich is correct for most machines; in general, the arguments are found 3284e4b17023SJohn Marinoimmediately before the stack frame. Note that this is not the case on 3285e4b17023SJohn Marinosome targets that save registers into the caller's frame, such as SPARC 3286e4b17023SJohn Marinoand rs6000, and so such targets need to define this macro. 3287e4b17023SJohn Marino 3288e4b17023SJohn MarinoYou only need to define this macro if the default is incorrect, and you 3289e4b17023SJohn Marinowant to support call frame debugging information like that provided by 3290e4b17023SJohn MarinoDWARF 2. 3291e4b17023SJohn Marino@end defmac 3292e4b17023SJohn Marino 3293e4b17023SJohn Marino@defmac FRAME_POINTER_CFA_OFFSET (@var{fundecl}) 3294e4b17023SJohn MarinoIf defined, a C expression whose value is an integer giving the offset 3295e4b17023SJohn Marinoin bytes from the frame pointer to the canonical frame address (cfa). 3296e4b17023SJohn MarinoThe final value should coincide with that calculated by 3297e4b17023SJohn Marino@code{INCOMING_FRAME_SP_OFFSET}. 3298e4b17023SJohn Marino 3299e4b17023SJohn MarinoNormally the CFA is calculated as an offset from the argument pointer, 3300e4b17023SJohn Marinovia @code{ARG_POINTER_CFA_OFFSET}, but if the argument pointer is 3301e4b17023SJohn Marinovariable due to the ABI, this may not be possible. If this macro is 3302e4b17023SJohn Marinodefined, it implies that the virtual register instantiation should be 3303e4b17023SJohn Marinobased on the frame pointer instead of the argument pointer. Only one 3304e4b17023SJohn Marinoof @code{FRAME_POINTER_CFA_OFFSET} and @code{ARG_POINTER_CFA_OFFSET} 3305e4b17023SJohn Marinoshould be defined. 3306e4b17023SJohn Marino@end defmac 3307e4b17023SJohn Marino 3308e4b17023SJohn Marino@defmac CFA_FRAME_BASE_OFFSET (@var{fundecl}) 3309e4b17023SJohn MarinoIf defined, a C expression whose value is an integer giving the offset 3310e4b17023SJohn Marinoin bytes from the canonical frame address (cfa) to the frame base used 3311e4b17023SJohn Marinoin DWARF 2 debug information. The default is zero. A different value 3312e4b17023SJohn Marinomay reduce the size of debug information on some ports. 3313e4b17023SJohn Marino@end defmac 3314e4b17023SJohn Marino 3315e4b17023SJohn Marino@node Exception Handling 3316e4b17023SJohn Marino@subsection Exception Handling Support 3317e4b17023SJohn Marino@cindex exception handling 3318e4b17023SJohn Marino 3319e4b17023SJohn Marino@defmac EH_RETURN_DATA_REGNO (@var{N}) 3320e4b17023SJohn MarinoA C expression whose value is the @var{N}th register number used for 3321e4b17023SJohn Marinodata by exception handlers, or @code{INVALID_REGNUM} if fewer than 3322e4b17023SJohn Marino@var{N} registers are usable. 3323e4b17023SJohn Marino 3324e4b17023SJohn MarinoThe exception handling library routines communicate with the exception 3325e4b17023SJohn Marinohandlers via a set of agreed upon registers. Ideally these registers 3326e4b17023SJohn Marinoshould be call-clobbered; it is possible to use call-saved registers, 3327e4b17023SJohn Marinobut may negatively impact code size. The target must support at least 3328e4b17023SJohn Marino2 data registers, but should define 4 if there are enough free registers. 3329e4b17023SJohn Marino 3330e4b17023SJohn MarinoYou must define this macro if you want to support call frame exception 3331e4b17023SJohn Marinohandling like that provided by DWARF 2. 3332e4b17023SJohn Marino@end defmac 3333e4b17023SJohn Marino 3334e4b17023SJohn Marino@defmac EH_RETURN_STACKADJ_RTX 3335e4b17023SJohn MarinoA C expression whose value is RTL representing a location in which 3336e4b17023SJohn Marinoto store a stack adjustment to be applied before function return. 3337e4b17023SJohn MarinoThis is used to unwind the stack to an exception handler's call frame. 3338e4b17023SJohn MarinoIt will be assigned zero on code paths that return normally. 3339e4b17023SJohn Marino 3340e4b17023SJohn MarinoTypically this is a call-clobbered hard register that is otherwise 3341e4b17023SJohn Marinountouched by the epilogue, but could also be a stack slot. 3342e4b17023SJohn Marino 3343e4b17023SJohn MarinoDo not define this macro if the stack pointer is saved and restored 3344e4b17023SJohn Marinoby the regular prolog and epilog code in the call frame itself; in 3345e4b17023SJohn Marinothis case, the exception handling library routines will update the 3346e4b17023SJohn Marinostack location to be restored in place. Otherwise, you must define 3347e4b17023SJohn Marinothis macro if you want to support call frame exception handling like 3348e4b17023SJohn Marinothat provided by DWARF 2. 3349e4b17023SJohn Marino@end defmac 3350e4b17023SJohn Marino 3351e4b17023SJohn Marino@defmac EH_RETURN_HANDLER_RTX 3352e4b17023SJohn MarinoA C expression whose value is RTL representing a location in which 3353e4b17023SJohn Marinoto store the address of an exception handler to which we should 3354e4b17023SJohn Marinoreturn. It will not be assigned on code paths that return normally. 3355e4b17023SJohn Marino 3356e4b17023SJohn MarinoTypically this is the location in the call frame at which the normal 3357e4b17023SJohn Marinoreturn address is stored. For targets that return by popping an 3358e4b17023SJohn Marinoaddress off the stack, this might be a memory address just below 3359e4b17023SJohn Marinothe @emph{target} call frame rather than inside the current call 3360e4b17023SJohn Marinoframe. If defined, @code{EH_RETURN_STACKADJ_RTX} will have already 3361e4b17023SJohn Marinobeen assigned, so it may be used to calculate the location of the 3362e4b17023SJohn Marinotarget call frame. 3363e4b17023SJohn Marino 3364e4b17023SJohn MarinoSome targets have more complex requirements than storing to an 3365e4b17023SJohn Marinoaddress calculable during initial code generation. In that case 3366e4b17023SJohn Marinothe @code{eh_return} instruction pattern should be used instead. 3367e4b17023SJohn Marino 3368e4b17023SJohn MarinoIf you want to support call frame exception handling, you must 3369e4b17023SJohn Marinodefine either this macro or the @code{eh_return} instruction pattern. 3370e4b17023SJohn Marino@end defmac 3371e4b17023SJohn Marino 3372e4b17023SJohn Marino@defmac RETURN_ADDR_OFFSET 3373e4b17023SJohn MarinoIf defined, an integer-valued C expression for which rtl will be generated 3374e4b17023SJohn Marinoto add it to the exception handler address before it is searched in the 3375e4b17023SJohn Marinoexception handling tables, and to subtract it again from the address before 3376e4b17023SJohn Marinousing it to return to the exception handler. 3377e4b17023SJohn Marino@end defmac 3378e4b17023SJohn Marino 3379e4b17023SJohn Marino@defmac ASM_PREFERRED_EH_DATA_FORMAT (@var{code}, @var{global}) 3380e4b17023SJohn MarinoThis macro chooses the encoding of pointers embedded in the exception 3381e4b17023SJohn Marinohandling sections. If at all possible, this should be defined such 3382e4b17023SJohn Marinothat the exception handling section will not require dynamic relocations, 3383e4b17023SJohn Marinoand so may be read-only. 3384e4b17023SJohn Marino 3385e4b17023SJohn Marino@var{code} is 0 for data, 1 for code labels, 2 for function pointers. 3386e4b17023SJohn Marino@var{global} is true if the symbol may be affected by dynamic relocations. 3387e4b17023SJohn MarinoThe macro should return a combination of the @code{DW_EH_PE_*} defines 3388e4b17023SJohn Marinoas found in @file{dwarf2.h}. 3389e4b17023SJohn Marino 3390e4b17023SJohn MarinoIf this macro is not defined, pointers will not be encoded but 3391e4b17023SJohn Marinorepresented directly. 3392e4b17023SJohn Marino@end defmac 3393e4b17023SJohn Marino 3394e4b17023SJohn Marino@defmac ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (@var{file}, @var{encoding}, @var{size}, @var{addr}, @var{done}) 3395e4b17023SJohn MarinoThis macro allows the target to emit whatever special magic is required 3396e4b17023SJohn Marinoto represent the encoding chosen by @code{ASM_PREFERRED_EH_DATA_FORMAT}. 3397e4b17023SJohn MarinoGeneric code takes care of pc-relative and indirect encodings; this must 3398e4b17023SJohn Marinobe defined if the target uses text-relative or data-relative encodings. 3399e4b17023SJohn Marino 3400e4b17023SJohn MarinoThis is a C statement that branches to @var{done} if the format was 3401e4b17023SJohn Marinohandled. @var{encoding} is the format chosen, @var{size} is the number 3402e4b17023SJohn Marinoof bytes that the format occupies, @var{addr} is the @code{SYMBOL_REF} 3403e4b17023SJohn Marinoto be emitted. 3404e4b17023SJohn Marino@end defmac 3405e4b17023SJohn Marino 3406e4b17023SJohn Marino@defmac MD_FALLBACK_FRAME_STATE_FOR (@var{context}, @var{fs}) 3407e4b17023SJohn MarinoThis macro allows the target to add CPU and operating system specific 3408e4b17023SJohn Marinocode to the call-frame unwinder for use when there is no unwind data 3409e4b17023SJohn Marinoavailable. The most common reason to implement this macro is to unwind 3410e4b17023SJohn Marinothrough signal frames. 3411e4b17023SJohn Marino 3412e4b17023SJohn MarinoThis macro is called from @code{uw_frame_state_for} in 3413e4b17023SJohn Marino@file{unwind-dw2.c}, @file{unwind-dw2-xtensa.c} and 3414e4b17023SJohn Marino@file{unwind-ia64.c}. @var{context} is an @code{_Unwind_Context}; 3415e4b17023SJohn Marino@var{fs} is an @code{_Unwind_FrameState}. Examine @code{context->ra} 3416e4b17023SJohn Marinofor the address of the code being executed and @code{context->cfa} for 3417e4b17023SJohn Marinothe stack pointer value. If the frame can be decoded, the register 3418e4b17023SJohn Marinosave addresses should be updated in @var{fs} and the macro should 3419e4b17023SJohn Marinoevaluate to @code{_URC_NO_REASON}. If the frame cannot be decoded, 3420e4b17023SJohn Marinothe macro should evaluate to @code{_URC_END_OF_STACK}. 3421e4b17023SJohn Marino 3422e4b17023SJohn MarinoFor proper signal handling in Java this macro is accompanied by 3423e4b17023SJohn Marino@code{MAKE_THROW_FRAME}, defined in @file{libjava/include/*-signal.h} headers. 3424e4b17023SJohn Marino@end defmac 3425e4b17023SJohn Marino 3426e4b17023SJohn Marino@defmac MD_HANDLE_UNWABI (@var{context}, @var{fs}) 3427e4b17023SJohn MarinoThis macro allows the target to add operating system specific code to the 3428e4b17023SJohn Marinocall-frame unwinder to handle the IA-64 @code{.unwabi} unwinding directive, 3429e4b17023SJohn Marinousually used for signal or interrupt frames. 3430e4b17023SJohn Marino 3431e4b17023SJohn MarinoThis macro is called from @code{uw_update_context} in @file{unwind-ia64.c}. 3432e4b17023SJohn Marino@var{context} is an @code{_Unwind_Context}; 3433e4b17023SJohn Marino@var{fs} is an @code{_Unwind_FrameState}. Examine @code{fs->unwabi} 3434e4b17023SJohn Marinofor the abi and context in the @code{.unwabi} directive. If the 3435e4b17023SJohn Marino@code{.unwabi} directive can be handled, the register save addresses should 3436e4b17023SJohn Marinobe updated in @var{fs}. 3437e4b17023SJohn Marino@end defmac 3438e4b17023SJohn Marino 3439e4b17023SJohn Marino@defmac TARGET_USES_WEAK_UNWIND_INFO 3440e4b17023SJohn MarinoA C expression that evaluates to true if the target requires unwind 3441e4b17023SJohn Marinoinfo to be given comdat linkage. Define it to be @code{1} if comdat 3442e4b17023SJohn Marinolinkage is necessary. The default is @code{0}. 3443e4b17023SJohn Marino@end defmac 3444e4b17023SJohn Marino 3445e4b17023SJohn Marino@node Stack Checking 3446e4b17023SJohn Marino@subsection Specifying How Stack Checking is Done 3447e4b17023SJohn Marino 3448e4b17023SJohn MarinoGCC will check that stack references are within the boundaries of the 3449e4b17023SJohn Marinostack, if the option @option{-fstack-check} is specified, in one of 3450e4b17023SJohn Marinothree ways: 3451e4b17023SJohn Marino 3452e4b17023SJohn Marino@enumerate 3453e4b17023SJohn Marino@item 3454e4b17023SJohn MarinoIf the value of the @code{STACK_CHECK_BUILTIN} macro is nonzero, GCC 3455e4b17023SJohn Marinowill assume that you have arranged for full stack checking to be done 3456e4b17023SJohn Marinoat appropriate places in the configuration files. GCC will not do 3457e4b17023SJohn Marinoother special processing. 3458e4b17023SJohn Marino 3459e4b17023SJohn Marino@item 3460e4b17023SJohn MarinoIf @code{STACK_CHECK_BUILTIN} is zero and the value of the 3461e4b17023SJohn Marino@code{STACK_CHECK_STATIC_BUILTIN} macro is nonzero, GCC will assume 3462e4b17023SJohn Marinothat you have arranged for static stack checking (checking of the 3463e4b17023SJohn Marinostatic stack frame of functions) to be done at appropriate places 3464e4b17023SJohn Marinoin the configuration files. GCC will only emit code to do dynamic 3465e4b17023SJohn Marinostack checking (checking on dynamic stack allocations) using the third 3466e4b17023SJohn Marinoapproach below. 3467e4b17023SJohn Marino 3468e4b17023SJohn Marino@item 3469e4b17023SJohn MarinoIf neither of the above are true, GCC will generate code to periodically 3470e4b17023SJohn Marino``probe'' the stack pointer using the values of the macros defined below. 3471e4b17023SJohn Marino@end enumerate 3472e4b17023SJohn Marino 3473e4b17023SJohn MarinoIf neither STACK_CHECK_BUILTIN nor STACK_CHECK_STATIC_BUILTIN is defined, 3474e4b17023SJohn MarinoGCC will change its allocation strategy for large objects if the option 3475e4b17023SJohn Marino@option{-fstack-check} is specified: they will always be allocated 3476e4b17023SJohn Marinodynamically if their size exceeds @code{STACK_CHECK_MAX_VAR_SIZE} bytes. 3477e4b17023SJohn Marino 3478e4b17023SJohn Marino@defmac STACK_CHECK_BUILTIN 3479e4b17023SJohn MarinoA nonzero value if stack checking is done by the configuration files in a 3480e4b17023SJohn Marinomachine-dependent manner. You should define this macro if stack checking 3481e4b17023SJohn Marinois required by the ABI of your machine or if you would like to do stack 3482e4b17023SJohn Marinochecking in some more efficient way than the generic approach. The default 3483e4b17023SJohn Marinovalue of this macro is zero. 3484e4b17023SJohn Marino@end defmac 3485e4b17023SJohn Marino 3486e4b17023SJohn Marino@defmac STACK_CHECK_STATIC_BUILTIN 3487e4b17023SJohn MarinoA nonzero value if static stack checking is done by the configuration files 3488e4b17023SJohn Marinoin a machine-dependent manner. You should define this macro if you would 3489e4b17023SJohn Marinolike to do static stack checking in some more efficient way than the generic 3490e4b17023SJohn Marinoapproach. The default value of this macro is zero. 3491e4b17023SJohn Marino@end defmac 3492e4b17023SJohn Marino 3493e4b17023SJohn Marino@defmac STACK_CHECK_PROBE_INTERVAL_EXP 3494e4b17023SJohn MarinoAn integer specifying the interval at which GCC must generate stack probe 3495e4b17023SJohn Marinoinstructions, defined as 2 raised to this integer. You will normally 3496e4b17023SJohn Marinodefine this macro so that the interval be no larger than the size of 3497e4b17023SJohn Marinothe ``guard pages'' at the end of a stack area. The default value 3498e4b17023SJohn Marinoof 12 (4096-byte interval) is suitable for most systems. 3499e4b17023SJohn Marino@end defmac 3500e4b17023SJohn Marino 3501e4b17023SJohn Marino@defmac STACK_CHECK_MOVING_SP 3502e4b17023SJohn MarinoAn integer which is nonzero if GCC should move the stack pointer page by page 3503e4b17023SJohn Marinowhen doing probes. This can be necessary on systems where the stack pointer 3504e4b17023SJohn Marinocontains the bottom address of the memory area accessible to the executing 3505e4b17023SJohn Marinothread at any point in time. In this situation an alternate signal stack 3506e4b17023SJohn Marinois required in order to be able to recover from a stack overflow. The 3507e4b17023SJohn Marinodefault value of this macro is zero. 3508e4b17023SJohn Marino@end defmac 3509e4b17023SJohn Marino 3510e4b17023SJohn Marino@defmac STACK_CHECK_PROTECT 3511e4b17023SJohn MarinoThe number of bytes of stack needed to recover from a stack overflow, for 3512e4b17023SJohn Marinolanguages where such a recovery is supported. The default value of 75 words 3513e4b17023SJohn Marinowith the @code{setjmp}/@code{longjmp}-based exception handling mechanism and 3514e4b17023SJohn Marino8192 bytes with other exception handling mechanisms should be adequate for 3515e4b17023SJohn Marinomost machines. 3516e4b17023SJohn Marino@end defmac 3517e4b17023SJohn Marino 3518e4b17023SJohn MarinoThe following macros are relevant only if neither STACK_CHECK_BUILTIN 3519e4b17023SJohn Marinonor STACK_CHECK_STATIC_BUILTIN is defined; you can omit them altogether 3520e4b17023SJohn Marinoin the opposite case. 3521e4b17023SJohn Marino 3522e4b17023SJohn Marino@defmac STACK_CHECK_MAX_FRAME_SIZE 3523e4b17023SJohn MarinoThe maximum size of a stack frame, in bytes. GCC will generate probe 3524e4b17023SJohn Marinoinstructions in non-leaf functions to ensure at least this many bytes of 3525e4b17023SJohn Marinostack are available. If a stack frame is larger than this size, stack 3526e4b17023SJohn Marinochecking will not be reliable and GCC will issue a warning. The 3527e4b17023SJohn Marinodefault is chosen so that GCC only generates one instruction on most 3528e4b17023SJohn Marinosystems. You should normally not change the default value of this macro. 3529e4b17023SJohn Marino@end defmac 3530e4b17023SJohn Marino 3531e4b17023SJohn Marino@defmac STACK_CHECK_FIXED_FRAME_SIZE 3532e4b17023SJohn MarinoGCC uses this value to generate the above warning message. It 3533e4b17023SJohn Marinorepresents the amount of fixed frame used by a function, not including 3534e4b17023SJohn Marinospace for any callee-saved registers, temporaries and user variables. 3535e4b17023SJohn MarinoYou need only specify an upper bound for this amount and will normally 3536e4b17023SJohn Marinouse the default of four words. 3537e4b17023SJohn Marino@end defmac 3538e4b17023SJohn Marino 3539e4b17023SJohn Marino@defmac STACK_CHECK_MAX_VAR_SIZE 3540e4b17023SJohn MarinoThe maximum size, in bytes, of an object that GCC will place in the 3541e4b17023SJohn Marinofixed area of the stack frame when the user specifies 3542e4b17023SJohn Marino@option{-fstack-check}. 3543e4b17023SJohn MarinoGCC computed the default from the values of the above macros and you will 3544e4b17023SJohn Marinonormally not need to override that default. 3545e4b17023SJohn Marino@end defmac 3546e4b17023SJohn Marino 3547e4b17023SJohn Marino@need 2000 3548e4b17023SJohn Marino@node Frame Registers 3549e4b17023SJohn Marino@subsection Registers That Address the Stack Frame 3550e4b17023SJohn Marino 3551e4b17023SJohn Marino@c prevent bad page break with this line 3552e4b17023SJohn MarinoThis discusses registers that address the stack frame. 3553e4b17023SJohn Marino 3554e4b17023SJohn Marino@defmac STACK_POINTER_REGNUM 3555e4b17023SJohn MarinoThe register number of the stack pointer register, which must also be a 3556e4b17023SJohn Marinofixed register according to @code{FIXED_REGISTERS}. On most machines, 3557e4b17023SJohn Marinothe hardware determines which register this is. 3558e4b17023SJohn Marino@end defmac 3559e4b17023SJohn Marino 3560e4b17023SJohn Marino@defmac FRAME_POINTER_REGNUM 3561e4b17023SJohn MarinoThe register number of the frame pointer register, which is used to 3562e4b17023SJohn Marinoaccess automatic variables in the stack frame. On some machines, the 3563e4b17023SJohn Marinohardware determines which register this is. On other machines, you can 3564e4b17023SJohn Marinochoose any register you wish for this purpose. 3565e4b17023SJohn Marino@end defmac 3566e4b17023SJohn Marino 3567e4b17023SJohn Marino@defmac HARD_FRAME_POINTER_REGNUM 3568e4b17023SJohn MarinoOn some machines the offset between the frame pointer and starting 3569e4b17023SJohn Marinooffset of the automatic variables is not known until after register 3570e4b17023SJohn Marinoallocation has been done (for example, because the saved registers are 3571e4b17023SJohn Marinobetween these two locations). On those machines, define 3572e4b17023SJohn Marino@code{FRAME_POINTER_REGNUM} the number of a special, fixed register to 3573e4b17023SJohn Marinobe used internally until the offset is known, and define 3574e4b17023SJohn Marino@code{HARD_FRAME_POINTER_REGNUM} to be the actual hard register number 3575e4b17023SJohn Marinoused for the frame pointer. 3576e4b17023SJohn Marino 3577e4b17023SJohn MarinoYou should define this macro only in the very rare circumstances when it 3578e4b17023SJohn Marinois not possible to calculate the offset between the frame pointer and 3579e4b17023SJohn Marinothe automatic variables until after register allocation has been 3580e4b17023SJohn Marinocompleted. When this macro is defined, you must also indicate in your 3581e4b17023SJohn Marinodefinition of @code{ELIMINABLE_REGS} how to eliminate 3582e4b17023SJohn Marino@code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM} 3583e4b17023SJohn Marinoor @code{STACK_POINTER_REGNUM}. 3584e4b17023SJohn Marino 3585e4b17023SJohn MarinoDo not define this macro if it would be the same as 3586e4b17023SJohn Marino@code{FRAME_POINTER_REGNUM}. 3587e4b17023SJohn Marino@end defmac 3588e4b17023SJohn Marino 3589e4b17023SJohn Marino@defmac ARG_POINTER_REGNUM 3590e4b17023SJohn MarinoThe register number of the arg pointer register, which is used to access 3591e4b17023SJohn Marinothe function's argument list. On some machines, this is the same as the 3592e4b17023SJohn Marinoframe pointer register. On some machines, the hardware determines which 3593e4b17023SJohn Marinoregister this is. On other machines, you can choose any register you 3594e4b17023SJohn Marinowish for this purpose. If this is not the same register as the frame 3595e4b17023SJohn Marinopointer register, then you must mark it as a fixed register according to 3596e4b17023SJohn Marino@code{FIXED_REGISTERS}, or arrange to be able to eliminate it 3597e4b17023SJohn Marino(@pxref{Elimination}). 3598e4b17023SJohn Marino@end defmac 3599e4b17023SJohn Marino 3600e4b17023SJohn Marino@defmac HARD_FRAME_POINTER_IS_FRAME_POINTER 3601e4b17023SJohn MarinoDefine this to a preprocessor constant that is nonzero if 3602e4b17023SJohn Marino@code{hard_frame_pointer_rtx} and @code{frame_pointer_rtx} should be 3603e4b17023SJohn Marinothe same. The default definition is @samp{(HARD_FRAME_POINTER_REGNUM 3604e4b17023SJohn Marino== FRAME_POINTER_REGNUM)}; you only need to define this macro if that 3605e4b17023SJohn Marinodefinition is not suitable for use in preprocessor conditionals. 3606e4b17023SJohn Marino@end defmac 3607e4b17023SJohn Marino 3608e4b17023SJohn Marino@defmac HARD_FRAME_POINTER_IS_ARG_POINTER 3609e4b17023SJohn MarinoDefine this to a preprocessor constant that is nonzero if 3610e4b17023SJohn Marino@code{hard_frame_pointer_rtx} and @code{arg_pointer_rtx} should be the 3611e4b17023SJohn Marinosame. The default definition is @samp{(HARD_FRAME_POINTER_REGNUM == 3612e4b17023SJohn MarinoARG_POINTER_REGNUM)}; you only need to define this macro if that 3613e4b17023SJohn Marinodefinition is not suitable for use in preprocessor conditionals. 3614e4b17023SJohn Marino@end defmac 3615e4b17023SJohn Marino 3616e4b17023SJohn Marino@defmac RETURN_ADDRESS_POINTER_REGNUM 3617e4b17023SJohn MarinoThe register number of the return address pointer register, which is used to 3618e4b17023SJohn Marinoaccess the current function's return address from the stack. On some 3619e4b17023SJohn Marinomachines, the return address is not at a fixed offset from the frame 3620e4b17023SJohn Marinopointer or stack pointer or argument pointer. This register can be defined 3621e4b17023SJohn Marinoto point to the return address on the stack, and then be converted by 3622e4b17023SJohn Marino@code{ELIMINABLE_REGS} into either the frame pointer or stack pointer. 3623e4b17023SJohn Marino 3624e4b17023SJohn MarinoDo not define this macro unless there is no other way to get the return 3625e4b17023SJohn Marinoaddress from the stack. 3626e4b17023SJohn Marino@end defmac 3627e4b17023SJohn Marino 3628e4b17023SJohn Marino@defmac STATIC_CHAIN_REGNUM 3629e4b17023SJohn Marino@defmacx STATIC_CHAIN_INCOMING_REGNUM 3630e4b17023SJohn MarinoRegister numbers used for passing a function's static chain pointer. If 3631e4b17023SJohn Marinoregister windows are used, the register number as seen by the called 3632e4b17023SJohn Marinofunction is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register 3633e4b17023SJohn Marinonumber as seen by the calling function is @code{STATIC_CHAIN_REGNUM}. If 3634e4b17023SJohn Marinothese registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need 3635e4b17023SJohn Marinonot be defined. 3636e4b17023SJohn Marino 3637e4b17023SJohn MarinoThe static chain register need not be a fixed register. 3638e4b17023SJohn Marino 3639e4b17023SJohn MarinoIf the static chain is passed in memory, these macros should not be 3640e4b17023SJohn Marinodefined; instead, the @code{TARGET_STATIC_CHAIN} hook should be used. 3641e4b17023SJohn Marino@end defmac 3642e4b17023SJohn Marino 3643e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_STATIC_CHAIN (const_tree @var{fndecl}, bool @var{incoming_p}) 3644e4b17023SJohn MarinoThis hook replaces the use of @code{STATIC_CHAIN_REGNUM} et al for 3645e4b17023SJohn Marinotargets that may use different static chain locations for different 3646e4b17023SJohn Marinonested functions. This may be required if the target has function 3647e4b17023SJohn Marinoattributes that affect the calling conventions of the function and 3648e4b17023SJohn Marinothose calling conventions use different static chain locations. 3649e4b17023SJohn Marino 3650e4b17023SJohn MarinoThe default version of this hook uses @code{STATIC_CHAIN_REGNUM} et al. 3651e4b17023SJohn Marino 3652e4b17023SJohn MarinoIf the static chain is passed in memory, this hook should be used to 3653e4b17023SJohn Marinoprovide rtx giving @code{mem} expressions that denote where they are stored. 3654e4b17023SJohn MarinoOften the @code{mem} expression as seen by the caller will be at an offset 3655e4b17023SJohn Marinofrom the stack pointer and the @code{mem} expression as seen by the callee 3656e4b17023SJohn Marinowill be at an offset from the frame pointer. 3657e4b17023SJohn Marino@findex stack_pointer_rtx 3658e4b17023SJohn Marino@findex frame_pointer_rtx 3659e4b17023SJohn Marino@findex arg_pointer_rtx 3660e4b17023SJohn MarinoThe variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and 3661e4b17023SJohn Marino@code{arg_pointer_rtx} will have been initialized and should be used 3662e4b17023SJohn Marinoto refer to those items. 3663e4b17023SJohn Marino@end deftypefn 3664e4b17023SJohn Marino 3665e4b17023SJohn Marino@defmac DWARF_FRAME_REGISTERS 3666e4b17023SJohn MarinoThis macro specifies the maximum number of hard registers that can be 3667e4b17023SJohn Marinosaved in a call frame. This is used to size data structures used in 3668e4b17023SJohn MarinoDWARF2 exception handling. 3669e4b17023SJohn Marino 3670e4b17023SJohn MarinoPrior to GCC 3.0, this macro was needed in order to establish a stable 3671e4b17023SJohn Marinoexception handling ABI in the face of adding new hard registers for ISA 3672e4b17023SJohn Marinoextensions. In GCC 3.0 and later, the EH ABI is insulated from changes 3673e4b17023SJohn Marinoin the number of hard registers. Nevertheless, this macro can still be 3674e4b17023SJohn Marinoused to reduce the runtime memory requirements of the exception handling 3675e4b17023SJohn Marinoroutines, which can be substantial if the ISA contains a lot of 3676e4b17023SJohn Marinoregisters that are not call-saved. 3677e4b17023SJohn Marino 3678e4b17023SJohn MarinoIf this macro is not defined, it defaults to 3679e4b17023SJohn Marino@code{FIRST_PSEUDO_REGISTER}. 3680e4b17023SJohn Marino@end defmac 3681e4b17023SJohn Marino 3682e4b17023SJohn Marino@defmac PRE_GCC3_DWARF_FRAME_REGISTERS 3683e4b17023SJohn Marino 3684e4b17023SJohn MarinoThis macro is similar to @code{DWARF_FRAME_REGISTERS}, but is provided 3685e4b17023SJohn Marinofor backward compatibility in pre GCC 3.0 compiled code. 3686e4b17023SJohn Marino 3687e4b17023SJohn MarinoIf this macro is not defined, it defaults to 3688e4b17023SJohn Marino@code{DWARF_FRAME_REGISTERS}. 3689e4b17023SJohn Marino@end defmac 3690e4b17023SJohn Marino 3691e4b17023SJohn Marino@defmac DWARF_REG_TO_UNWIND_COLUMN (@var{regno}) 3692e4b17023SJohn Marino 3693e4b17023SJohn MarinoDefine this macro if the target's representation for dwarf registers 3694e4b17023SJohn Marinois different than the internal representation for unwind column. 3695e4b17023SJohn MarinoGiven a dwarf register, this macro should return the internal unwind 3696e4b17023SJohn Marinocolumn number to use instead. 3697e4b17023SJohn Marino 3698e4b17023SJohn MarinoSee the PowerPC's SPE target for an example. 3699e4b17023SJohn Marino@end defmac 3700e4b17023SJohn Marino 3701e4b17023SJohn Marino@defmac DWARF_FRAME_REGNUM (@var{regno}) 3702e4b17023SJohn Marino 3703e4b17023SJohn MarinoDefine this macro if the target's representation for dwarf registers 3704e4b17023SJohn Marinoused in .eh_frame or .debug_frame is different from that used in other 3705e4b17023SJohn Marinodebug info sections. Given a GCC hard register number, this macro 3706e4b17023SJohn Marinoshould return the .eh_frame register number. The default is 3707e4b17023SJohn Marino@code{DBX_REGISTER_NUMBER (@var{regno})}. 3708e4b17023SJohn Marino 3709e4b17023SJohn Marino@end defmac 3710e4b17023SJohn Marino 3711e4b17023SJohn Marino@defmac DWARF2_FRAME_REG_OUT (@var{regno}, @var{for_eh}) 3712e4b17023SJohn Marino 3713e4b17023SJohn MarinoDefine this macro to map register numbers held in the call frame info 3714e4b17023SJohn Marinothat GCC has collected using @code{DWARF_FRAME_REGNUM} to those that 3715e4b17023SJohn Marinoshould be output in .debug_frame (@code{@var{for_eh}} is zero) and 3716e4b17023SJohn Marino.eh_frame (@code{@var{for_eh}} is nonzero). The default is to 3717e4b17023SJohn Marinoreturn @code{@var{regno}}. 3718e4b17023SJohn Marino 3719e4b17023SJohn Marino@end defmac 3720e4b17023SJohn Marino 3721e4b17023SJohn Marino@defmac REG_VALUE_IN_UNWIND_CONTEXT 3722e4b17023SJohn Marino 3723e4b17023SJohn MarinoDefine this macro if the target stores register values as 3724e4b17023SJohn Marino@code{_Unwind_Word} type in unwind context. It should be defined if 3725e4b17023SJohn Marinotarget register size is larger than the size of @code{void *}. The 3726e4b17023SJohn Marinodefault is to store register values as @code{void *} type. 3727e4b17023SJohn Marino 3728e4b17023SJohn Marino@end defmac 3729e4b17023SJohn Marino 3730e4b17023SJohn Marino@defmac ASSUME_EXTENDED_UNWIND_CONTEXT 3731e4b17023SJohn Marino 3732e4b17023SJohn MarinoDefine this macro to be 1 if the target always uses extended unwind 3733e4b17023SJohn Marinocontext with version, args_size and by_value fields. If it is undefined, 3734e4b17023SJohn Marinoit will be defined to 1 when @code{REG_VALUE_IN_UNWIND_CONTEXT} is 3735e4b17023SJohn Marinodefined and 0 otherwise. 3736e4b17023SJohn Marino 3737e4b17023SJohn Marino@end defmac 3738e4b17023SJohn Marino 3739e4b17023SJohn Marino@node Elimination 3740e4b17023SJohn Marino@subsection Eliminating Frame Pointer and Arg Pointer 3741e4b17023SJohn Marino 3742e4b17023SJohn Marino@c prevent bad page break with this line 3743e4b17023SJohn MarinoThis is about eliminating the frame pointer and arg pointer. 3744e4b17023SJohn Marino 3745e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_FRAME_POINTER_REQUIRED (void) 3746e4b17023SJohn MarinoThis target hook should return @code{true} if a function must have and use 3747e4b17023SJohn Marinoa frame pointer. This target hook is called in the reload pass. If its return 3748e4b17023SJohn Marinovalue is @code{true} the function will have a frame pointer. 3749e4b17023SJohn Marino 3750e4b17023SJohn MarinoThis target hook can in principle examine the current function and decide 3751e4b17023SJohn Marinoaccording to the facts, but on most machines the constant @code{false} or the 3752e4b17023SJohn Marinoconstant @code{true} suffices. Use @code{false} when the machine allows code 3753e4b17023SJohn Marinoto be generated with no frame pointer, and doing so saves some time or space. 3754e4b17023SJohn MarinoUse @code{true} when there is no possible advantage to avoiding a frame 3755e4b17023SJohn Marinopointer. 3756e4b17023SJohn Marino 3757e4b17023SJohn MarinoIn certain cases, the compiler does not know how to produce valid code 3758e4b17023SJohn Marinowithout a frame pointer. The compiler recognizes those cases and 3759e4b17023SJohn Marinoautomatically gives the function a frame pointer regardless of what 3760e4b17023SJohn Marino@code{TARGET_FRAME_POINTER_REQUIRED} returns. You don't need to worry about 3761e4b17023SJohn Marinothem. 3762e4b17023SJohn Marino 3763e4b17023SJohn MarinoIn a function that does not require a frame pointer, the frame pointer 3764e4b17023SJohn Marinoregister can be allocated for ordinary usage, unless you mark it as a 3765e4b17023SJohn Marinofixed register. See @code{FIXED_REGISTERS} for more information. 3766e4b17023SJohn Marino 3767e4b17023SJohn MarinoDefault return value is @code{false}. 3768e4b17023SJohn Marino@end deftypefn 3769e4b17023SJohn Marino 3770e4b17023SJohn Marino@findex get_frame_size 3771e4b17023SJohn Marino@defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var}) 3772e4b17023SJohn MarinoA C statement to store in the variable @var{depth-var} the difference 3773e4b17023SJohn Marinobetween the frame pointer and the stack pointer values immediately after 3774e4b17023SJohn Marinothe function prologue. The value would be computed from information 3775e4b17023SJohn Marinosuch as the result of @code{get_frame_size ()} and the tables of 3776e4b17023SJohn Marinoregisters @code{regs_ever_live} and @code{call_used_regs}. 3777e4b17023SJohn Marino 3778e4b17023SJohn MarinoIf @code{ELIMINABLE_REGS} is defined, this macro will be not be used and 3779e4b17023SJohn Marinoneed not be defined. Otherwise, it must be defined even if 3780e4b17023SJohn Marino@code{TARGET_FRAME_POINTER_REQUIRED} always returns true; in that 3781e4b17023SJohn Marinocase, you may set @var{depth-var} to anything. 3782e4b17023SJohn Marino@end defmac 3783e4b17023SJohn Marino 3784e4b17023SJohn Marino@defmac ELIMINABLE_REGS 3785e4b17023SJohn MarinoIf defined, this macro specifies a table of register pairs used to 3786e4b17023SJohn Marinoeliminate unneeded registers that point into the stack frame. If it is not 3787e4b17023SJohn Marinodefined, the only elimination attempted by the compiler is to replace 3788e4b17023SJohn Marinoreferences to the frame pointer with references to the stack pointer. 3789e4b17023SJohn Marino 3790e4b17023SJohn MarinoThe definition of this macro is a list of structure initializations, each 3791e4b17023SJohn Marinoof which specifies an original and replacement register. 3792e4b17023SJohn Marino 3793e4b17023SJohn MarinoOn some machines, the position of the argument pointer is not known until 3794e4b17023SJohn Marinothe compilation is completed. In such a case, a separate hard register 3795e4b17023SJohn Marinomust be used for the argument pointer. This register can be eliminated by 3796e4b17023SJohn Marinoreplacing it with either the frame pointer or the argument pointer, 3797e4b17023SJohn Marinodepending on whether or not the frame pointer has been eliminated. 3798e4b17023SJohn Marino 3799e4b17023SJohn MarinoIn this case, you might specify: 3800e4b17023SJohn Marino@smallexample 3801e4b17023SJohn Marino#define ELIMINABLE_REGS \ 3802e4b17023SJohn Marino@{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \ 3803e4b17023SJohn Marino @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \ 3804e4b17023SJohn Marino @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@} 3805e4b17023SJohn Marino@end smallexample 3806e4b17023SJohn Marino 3807e4b17023SJohn MarinoNote that the elimination of the argument pointer with the stack pointer is 3808e4b17023SJohn Marinospecified first since that is the preferred elimination. 3809e4b17023SJohn Marino@end defmac 3810e4b17023SJohn Marino 3811e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CAN_ELIMINATE (const int @var{from_reg}, const int @var{to_reg}) 3812e4b17023SJohn MarinoThis target hook should returns @code{true} if the compiler is allowed to 3813e4b17023SJohn Marinotry to replace register number @var{from_reg} with register number 3814e4b17023SJohn Marino@var{to_reg}. This target hook need only be defined if @code{ELIMINABLE_REGS} 3815e4b17023SJohn Marinois defined, and will usually be @code{true}, since most of the cases 3816e4b17023SJohn Marinopreventing register elimination are things that the compiler already 3817e4b17023SJohn Marinoknows about. 3818e4b17023SJohn Marino 3819e4b17023SJohn MarinoDefault return value is @code{true}. 3820e4b17023SJohn Marino@end deftypefn 3821e4b17023SJohn Marino 3822e4b17023SJohn Marino@defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var}) 3823e4b17023SJohn MarinoThis macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It 3824e4b17023SJohn Marinospecifies the initial difference between the specified pair of 3825e4b17023SJohn Marinoregisters. This macro must be defined if @code{ELIMINABLE_REGS} is 3826e4b17023SJohn Marinodefined. 3827e4b17023SJohn Marino@end defmac 3828e4b17023SJohn Marino 3829e4b17023SJohn Marino@node Stack Arguments 3830e4b17023SJohn Marino@subsection Passing Function Arguments on the Stack 3831e4b17023SJohn Marino@cindex arguments on stack 3832e4b17023SJohn Marino@cindex stack arguments 3833e4b17023SJohn Marino 3834e4b17023SJohn MarinoThe macros in this section control how arguments are passed 3835e4b17023SJohn Marinoon the stack. See the following section for other macros that 3836e4b17023SJohn Marinocontrol passing certain arguments in registers. 3837e4b17023SJohn Marino 3838e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_PROMOTE_PROTOTYPES (const_tree @var{fntype}) 3839e4b17023SJohn MarinoThis target hook returns @code{true} if an argument declared in a 3840e4b17023SJohn Marinoprototype as an integral type smaller than @code{int} should actually be 3841e4b17023SJohn Marinopassed as an @code{int}. In addition to avoiding errors in certain 3842e4b17023SJohn Marinocases of mismatch, it also makes for better code on certain machines. 3843e4b17023SJohn MarinoThe default is to not promote prototypes. 3844e4b17023SJohn Marino@end deftypefn 3845e4b17023SJohn Marino 3846e4b17023SJohn Marino@defmac PUSH_ARGS 3847e4b17023SJohn MarinoA C expression. If nonzero, push insns will be used to pass 3848e4b17023SJohn Marinooutgoing arguments. 3849e4b17023SJohn MarinoIf the target machine does not have a push instruction, set it to zero. 3850e4b17023SJohn MarinoThat directs GCC to use an alternate strategy: to 3851e4b17023SJohn Marinoallocate the entire argument block and then store the arguments into 3852e4b17023SJohn Marinoit. When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too. 3853e4b17023SJohn Marino@end defmac 3854e4b17023SJohn Marino 3855e4b17023SJohn Marino@defmac PUSH_ARGS_REVERSED 3856e4b17023SJohn MarinoA C expression. If nonzero, function arguments will be evaluated from 3857e4b17023SJohn Marinolast to first, rather than from first to last. If this macro is not 3858e4b17023SJohn Marinodefined, it defaults to @code{PUSH_ARGS} on targets where the stack 3859e4b17023SJohn Marinoand args grow in opposite directions, and 0 otherwise. 3860e4b17023SJohn Marino@end defmac 3861e4b17023SJohn Marino 3862e4b17023SJohn Marino@defmac PUSH_ROUNDING (@var{npushed}) 3863e4b17023SJohn MarinoA C expression that is the number of bytes actually pushed onto the 3864e4b17023SJohn Marinostack when an instruction attempts to push @var{npushed} bytes. 3865e4b17023SJohn Marino 3866e4b17023SJohn MarinoOn some machines, the definition 3867e4b17023SJohn Marino 3868e4b17023SJohn Marino@smallexample 3869e4b17023SJohn Marino#define PUSH_ROUNDING(BYTES) (BYTES) 3870e4b17023SJohn Marino@end smallexample 3871e4b17023SJohn Marino 3872e4b17023SJohn Marino@noindent 3873e4b17023SJohn Marinowill suffice. But on other machines, instructions that appear 3874e4b17023SJohn Marinoto push one byte actually push two bytes in an attempt to maintain 3875e4b17023SJohn Marinoalignment. Then the definition should be 3876e4b17023SJohn Marino 3877e4b17023SJohn Marino@smallexample 3878e4b17023SJohn Marino#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) 3879e4b17023SJohn Marino@end smallexample 3880e4b17023SJohn Marino 3881e4b17023SJohn MarinoIf the value of this macro has a type, it should be an unsigned type. 3882e4b17023SJohn Marino@end defmac 3883e4b17023SJohn Marino 3884e4b17023SJohn Marino@findex current_function_outgoing_args_size 3885e4b17023SJohn Marino@defmac ACCUMULATE_OUTGOING_ARGS 3886e4b17023SJohn MarinoA C expression. If nonzero, the maximum amount of space required for outgoing arguments 3887e4b17023SJohn Marinowill be computed and placed into the variable 3888e4b17023SJohn Marino@code{current_function_outgoing_args_size}. No space will be pushed 3889e4b17023SJohn Marinoonto the stack for each call; instead, the function prologue should 3890e4b17023SJohn Marinoincrease the stack frame size by this amount. 3891e4b17023SJohn Marino 3892e4b17023SJohn MarinoSetting both @code{PUSH_ARGS} and @code{ACCUMULATE_OUTGOING_ARGS} 3893e4b17023SJohn Marinois not proper. 3894e4b17023SJohn Marino@end defmac 3895e4b17023SJohn Marino 3896e4b17023SJohn Marino@defmac REG_PARM_STACK_SPACE (@var{fndecl}) 3897e4b17023SJohn MarinoDefine this macro if functions should assume that stack space has been 3898e4b17023SJohn Marinoallocated for arguments even when their values are passed in 3899e4b17023SJohn Marinoregisters. 3900e4b17023SJohn Marino 3901e4b17023SJohn MarinoThe value of this macro is the size, in bytes, of the area reserved for 3902e4b17023SJohn Marinoarguments passed in registers for the function represented by @var{fndecl}, 3903e4b17023SJohn Marinowhich can be zero if GCC is calling a library function. 3904e4b17023SJohn MarinoThe argument @var{fndecl} can be the FUNCTION_DECL, or the type itself 3905e4b17023SJohn Marinoof the function. 3906e4b17023SJohn Marino 3907e4b17023SJohn MarinoThis space can be allocated by the caller, or be a part of the 3908e4b17023SJohn Marinomachine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE} says 3909e4b17023SJohn Marinowhich. 3910e4b17023SJohn Marino@end defmac 3911e4b17023SJohn Marino@c above is overfull. not sure what to do. --mew 5feb93 did 3912e4b17023SJohn Marino@c something, not sure if it looks good. --mew 10feb93 3913e4b17023SJohn Marino 3914e4b17023SJohn Marino@defmac OUTGOING_REG_PARM_STACK_SPACE (@var{fntype}) 3915e4b17023SJohn MarinoDefine this to a nonzero value if it is the responsibility of the 3916e4b17023SJohn Marinocaller to allocate the area reserved for arguments passed in registers 3917e4b17023SJohn Marinowhen calling a function of @var{fntype}. @var{fntype} may be NULL 3918e4b17023SJohn Marinoif the function called is a library function. 3919e4b17023SJohn Marino 3920e4b17023SJohn MarinoIf @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls 3921e4b17023SJohn Marinowhether the space for these arguments counts in the value of 3922e4b17023SJohn Marino@code{current_function_outgoing_args_size}. 3923e4b17023SJohn Marino@end defmac 3924e4b17023SJohn Marino 3925e4b17023SJohn Marino@defmac STACK_PARMS_IN_REG_PARM_AREA 3926e4b17023SJohn MarinoDefine this macro if @code{REG_PARM_STACK_SPACE} is defined, but the 3927e4b17023SJohn Marinostack parameters don't skip the area specified by it. 3928e4b17023SJohn Marino@c i changed this, makes more sens and it should have taken care of the 3929e4b17023SJohn Marino@c overfull.. not as specific, tho. --mew 5feb93 3930e4b17023SJohn Marino 3931e4b17023SJohn MarinoNormally, when a parameter is not passed in registers, it is placed on the 3932e4b17023SJohn Marinostack beyond the @code{REG_PARM_STACK_SPACE} area. Defining this macro 3933e4b17023SJohn Marinosuppresses this behavior and causes the parameter to be passed on the 3934e4b17023SJohn Marinostack in its natural location. 3935e4b17023SJohn Marino@end defmac 3936e4b17023SJohn Marino 3937e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_RETURN_POPS_ARGS (tree @var{fundecl}, tree @var{funtype}, int @var{size}) 3938e4b17023SJohn MarinoThis target hook returns the number of bytes of its own arguments that 3939e4b17023SJohn Marinoa function pops on returning, or 0 if the function pops no arguments 3940e4b17023SJohn Marinoand the caller must therefore pop them all after the function returns. 3941e4b17023SJohn Marino 3942e4b17023SJohn Marino@var{fundecl} is a C variable whose value is a tree node that describes 3943e4b17023SJohn Marinothe function in question. Normally it is a node of type 3944e4b17023SJohn Marino@code{FUNCTION_DECL} that describes the declaration of the function. 3945e4b17023SJohn MarinoFrom this you can obtain the @code{DECL_ATTRIBUTES} of the function. 3946e4b17023SJohn Marino 3947e4b17023SJohn Marino@var{funtype} is a C variable whose value is a tree node that 3948e4b17023SJohn Marinodescribes the function in question. Normally it is a node of type 3949e4b17023SJohn Marino@code{FUNCTION_TYPE} that describes the data type of the function. 3950e4b17023SJohn MarinoFrom this it is possible to obtain the data types of the value and 3951e4b17023SJohn Marinoarguments (if known). 3952e4b17023SJohn Marino 3953e4b17023SJohn MarinoWhen a call to a library function is being considered, @var{fundecl} 3954e4b17023SJohn Marinowill contain an identifier node for the library function. Thus, if 3955e4b17023SJohn Marinoyou need to distinguish among various library functions, you can do so 3956e4b17023SJohn Marinoby their names. Note that ``library function'' in this context means 3957e4b17023SJohn Marinoa function used to perform arithmetic, whose name is known specially 3958e4b17023SJohn Marinoin the compiler and was not mentioned in the C code being compiled. 3959e4b17023SJohn Marino 3960e4b17023SJohn Marino@var{size} is the number of bytes of arguments passed on the 3961e4b17023SJohn Marinostack. If a variable number of bytes is passed, it is zero, and 3962e4b17023SJohn Marinoargument popping will always be the responsibility of the calling function. 3963e4b17023SJohn Marino 3964e4b17023SJohn MarinoOn the VAX, all functions always pop their arguments, so the definition 3965e4b17023SJohn Marinoof this macro is @var{size}. On the 68000, using the standard 3966e4b17023SJohn Marinocalling convention, no functions pop their arguments, so the value of 3967e4b17023SJohn Marinothe macro is always 0 in this case. But an alternative calling 3968e4b17023SJohn Marinoconvention is available in which functions that take a fixed number of 3969e4b17023SJohn Marinoarguments pop them but other functions (such as @code{printf}) pop 3970e4b17023SJohn Marinonothing (the caller pops all). When this convention is in use, 3971e4b17023SJohn Marino@var{funtype} is examined to determine whether a function takes a fixed 3972e4b17023SJohn Marinonumber of arguments. 3973e4b17023SJohn Marino@end deftypefn 3974e4b17023SJohn Marino 3975e4b17023SJohn Marino@defmac CALL_POPS_ARGS (@var{cum}) 3976e4b17023SJohn MarinoA C expression that should indicate the number of bytes a call sequence 3977e4b17023SJohn Marinopops off the stack. It is added to the value of @code{RETURN_POPS_ARGS} 3978e4b17023SJohn Marinowhen compiling a function call. 3979e4b17023SJohn Marino 3980e4b17023SJohn Marino@var{cum} is the variable in which all arguments to the called function 3981e4b17023SJohn Marinohave been accumulated. 3982e4b17023SJohn Marino 3983e4b17023SJohn MarinoOn certain architectures, such as the SH5, a call trampoline is used 3984e4b17023SJohn Marinothat pops certain registers off the stack, depending on the arguments 3985e4b17023SJohn Marinothat have been passed to the function. Since this is a property of the 3986e4b17023SJohn Marinocall site, not of the called function, @code{RETURN_POPS_ARGS} is not 3987e4b17023SJohn Marinoappropriate. 3988e4b17023SJohn Marino@end defmac 3989e4b17023SJohn Marino 3990e4b17023SJohn Marino@node Register Arguments 3991e4b17023SJohn Marino@subsection Passing Arguments in Registers 3992e4b17023SJohn Marino@cindex arguments in registers 3993e4b17023SJohn Marino@cindex registers arguments 3994e4b17023SJohn Marino 3995e4b17023SJohn MarinoThis section describes the macros which let you control how various 3996e4b17023SJohn Marinotypes of arguments are passed in registers or how they are arranged in 3997e4b17023SJohn Marinothe stack. 3998e4b17023SJohn Marino 3999e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_FUNCTION_ARG (cumulative_args_t @var{ca}, enum machine_mode @var{mode}, const_tree @var{type}, bool @var{named}) 4000e4b17023SJohn MarinoReturn an RTX indicating whether a function argument is passed in a 4001e4b17023SJohn Marinoregister and if so, which register. 4002e4b17023SJohn Marino 4003e4b17023SJohn MarinoThe arguments are @var{ca}, which summarizes all the previous 4004e4b17023SJohn Marinoarguments; @var{mode}, the machine mode of the argument; @var{type}, 4005e4b17023SJohn Marinothe data type of the argument as a tree node or 0 if that is not known 4006e4b17023SJohn Marino(which happens for C support library functions); and @var{named}, 4007e4b17023SJohn Marinowhich is @code{true} for an ordinary argument and @code{false} for 4008e4b17023SJohn Marinonameless arguments that correspond to @samp{@dots{}} in the called 4009e4b17023SJohn Marinofunction's prototype. @var{type} can be an incomplete type if a 4010e4b17023SJohn Marinosyntax error has previously occurred. 4011e4b17023SJohn Marino 4012e4b17023SJohn MarinoThe return value is usually either a @code{reg} RTX for the hard 4013e4b17023SJohn Marinoregister in which to pass the argument, or zero to pass the argument 4014e4b17023SJohn Marinoon the stack. 4015e4b17023SJohn Marino 4016e4b17023SJohn MarinoThe value of the expression can also be a @code{parallel} RTX@. This is 4017e4b17023SJohn Marinoused when an argument is passed in multiple locations. The mode of the 4018e4b17023SJohn Marino@code{parallel} should be the mode of the entire argument. The 4019e4b17023SJohn Marino@code{parallel} holds any number of @code{expr_list} pairs; each one 4020e4b17023SJohn Marinodescribes where part of the argument is passed. In each 4021e4b17023SJohn Marino@code{expr_list} the first operand must be a @code{reg} RTX for the hard 4022e4b17023SJohn Marinoregister in which to pass this part of the argument, and the mode of the 4023e4b17023SJohn Marinoregister RTX indicates how large this part of the argument is. The 4024e4b17023SJohn Marinosecond operand of the @code{expr_list} is a @code{const_int} which gives 4025e4b17023SJohn Marinothe offset in bytes into the entire argument of where this part starts. 4026e4b17023SJohn MarinoAs a special exception the first @code{expr_list} in the @code{parallel} 4027e4b17023SJohn MarinoRTX may have a first operand of zero. This indicates that the entire 4028e4b17023SJohn Marinoargument is also stored on the stack. 4029e4b17023SJohn Marino 4030e4b17023SJohn MarinoThe last time this hook is called, it is called with @code{MODE == 4031e4b17023SJohn MarinoVOIDmode}, and its result is passed to the @code{call} or @code{call_value} 4032e4b17023SJohn Marinopattern as operands 2 and 3 respectively. 4033e4b17023SJohn Marino 4034e4b17023SJohn Marino@cindex @file{stdarg.h} and register arguments 4035e4b17023SJohn MarinoThe usual way to make the ISO library @file{stdarg.h} work on a 4036e4b17023SJohn Marinomachine where some arguments are usually passed in registers, is to 4037e4b17023SJohn Marinocause nameless arguments to be passed on the stack instead. This is 4038e4b17023SJohn Marinodone by making @code{TARGET_FUNCTION_ARG} return 0 whenever 4039e4b17023SJohn Marino@var{named} is @code{false}. 4040e4b17023SJohn Marino 4041e4b17023SJohn Marino@cindex @code{TARGET_MUST_PASS_IN_STACK}, and @code{TARGET_FUNCTION_ARG} 4042e4b17023SJohn Marino@cindex @code{REG_PARM_STACK_SPACE}, and @code{TARGET_FUNCTION_ARG} 4043e4b17023SJohn MarinoYou may use the hook @code{targetm.calls.must_pass_in_stack} 4044e4b17023SJohn Marinoin the definition of this macro to determine if this argument is of a 4045e4b17023SJohn Marinotype that must be passed in the stack. If @code{REG_PARM_STACK_SPACE} 4046e4b17023SJohn Marinois not defined and @code{TARGET_FUNCTION_ARG} returns nonzero for such an 4047e4b17023SJohn Marinoargument, the compiler will abort. If @code{REG_PARM_STACK_SPACE} is 4048e4b17023SJohn Marinodefined, the argument will be computed in the stack and then loaded into 4049e4b17023SJohn Marinoa register. 4050e4b17023SJohn Marino@end deftypefn 4051e4b17023SJohn Marino 4052e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_MUST_PASS_IN_STACK (enum machine_mode @var{mode}, const_tree @var{type}) 4053e4b17023SJohn MarinoThis target hook should return @code{true} if we should not pass @var{type} 4054e4b17023SJohn Marinosolely in registers. The file @file{expr.h} defines a 4055e4b17023SJohn Marinodefinition that is usually appropriate, refer to @file{expr.h} for additional 4056e4b17023SJohn Marinodocumentation. 4057e4b17023SJohn Marino@end deftypefn 4058e4b17023SJohn Marino 4059e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_FUNCTION_INCOMING_ARG (cumulative_args_t @var{ca}, enum machine_mode @var{mode}, const_tree @var{type}, bool @var{named}) 4060e4b17023SJohn MarinoDefine this hook if the target machine has ``register windows'', so 4061e4b17023SJohn Marinothat the register in which a function sees an arguments is not 4062e4b17023SJohn Marinonecessarily the same as the one in which the caller passed the 4063e4b17023SJohn Marinoargument. 4064e4b17023SJohn Marino 4065e4b17023SJohn MarinoFor such machines, @code{TARGET_FUNCTION_ARG} computes the register in 4066e4b17023SJohn Marinowhich the caller passes the value, and 4067e4b17023SJohn Marino@code{TARGET_FUNCTION_INCOMING_ARG} should be defined in a similar 4068e4b17023SJohn Marinofashion to tell the function being called where the arguments will 4069e4b17023SJohn Marinoarrive. 4070e4b17023SJohn Marino 4071e4b17023SJohn MarinoIf @code{TARGET_FUNCTION_INCOMING_ARG} is not defined, 4072e4b17023SJohn Marino@code{TARGET_FUNCTION_ARG} serves both purposes. 4073e4b17023SJohn Marino@end deftypefn 4074e4b17023SJohn Marino 4075e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ARG_PARTIAL_BYTES (cumulative_args_t @var{cum}, enum machine_mode @var{mode}, tree @var{type}, bool @var{named}) 4076e4b17023SJohn MarinoThis target hook returns the number of bytes at the beginning of an 4077e4b17023SJohn Marinoargument that must be put in registers. The value must be zero for 4078e4b17023SJohn Marinoarguments that are passed entirely in registers or that are entirely 4079e4b17023SJohn Marinopushed on the stack. 4080e4b17023SJohn Marino 4081e4b17023SJohn MarinoOn some machines, certain arguments must be passed partially in 4082e4b17023SJohn Marinoregisters and partially in memory. On these machines, typically the 4083e4b17023SJohn Marinofirst few words of arguments are passed in registers, and the rest 4084e4b17023SJohn Marinoon the stack. If a multi-word argument (a @code{double} or a 4085e4b17023SJohn Marinostructure) crosses that boundary, its first few words must be passed 4086e4b17023SJohn Marinoin registers and the rest must be pushed. This macro tells the 4087e4b17023SJohn Marinocompiler when this occurs, and how many bytes should go in registers. 4088e4b17023SJohn Marino 4089e4b17023SJohn Marino@code{TARGET_FUNCTION_ARG} for these arguments should return the first 4090e4b17023SJohn Marinoregister to be used by the caller for this argument; likewise 4091e4b17023SJohn Marino@code{TARGET_FUNCTION_INCOMING_ARG}, for the called function. 4092e4b17023SJohn Marino@end deftypefn 4093e4b17023SJohn Marino 4094e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_PASS_BY_REFERENCE (cumulative_args_t @var{cum}, enum machine_mode @var{mode}, const_tree @var{type}, bool @var{named}) 4095e4b17023SJohn MarinoThis target hook should return @code{true} if an argument at the 4096e4b17023SJohn Marinoposition indicated by @var{cum} should be passed by reference. This 4097e4b17023SJohn Marinopredicate is queried after target independent reasons for being 4098e4b17023SJohn Marinopassed by reference, such as @code{TREE_ADDRESSABLE (type)}. 4099e4b17023SJohn Marino 4100e4b17023SJohn MarinoIf the hook returns true, a copy of that argument is made in memory and a 4101e4b17023SJohn Marinopointer to the argument is passed instead of the argument itself. 4102e4b17023SJohn MarinoThe pointer is passed in whatever way is appropriate for passing a pointer 4103e4b17023SJohn Marinoto that type. 4104e4b17023SJohn Marino@end deftypefn 4105e4b17023SJohn Marino 4106e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CALLEE_COPIES (cumulative_args_t @var{cum}, enum machine_mode @var{mode}, const_tree @var{type}, bool @var{named}) 4107e4b17023SJohn MarinoThe function argument described by the parameters to this hook is 4108e4b17023SJohn Marinoknown to be passed by reference. The hook should return true if the 4109e4b17023SJohn Marinofunction argument should be copied by the callee instead of copied 4110e4b17023SJohn Marinoby the caller. 4111e4b17023SJohn Marino 4112e4b17023SJohn MarinoFor any argument for which the hook returns true, if it can be 4113e4b17023SJohn Marinodetermined that the argument is not modified, then a copy need 4114e4b17023SJohn Marinonot be generated. 4115e4b17023SJohn Marino 4116e4b17023SJohn MarinoThe default version of this hook always returns false. 4117e4b17023SJohn Marino@end deftypefn 4118e4b17023SJohn Marino 4119e4b17023SJohn Marino@defmac CUMULATIVE_ARGS 4120e4b17023SJohn MarinoA C type for declaring a variable that is used as the first argument 4121e4b17023SJohn Marinoof @code{TARGET_FUNCTION_ARG} and other related values. For some 4122e4b17023SJohn Marinotarget machines, the type @code{int} suffices and can hold the number 4123e4b17023SJohn Marinoof bytes of argument so far. 4124e4b17023SJohn Marino 4125e4b17023SJohn MarinoThere is no need to record in @code{CUMULATIVE_ARGS} anything about the 4126e4b17023SJohn Marinoarguments that have been passed on the stack. The compiler has other 4127e4b17023SJohn Marinovariables to keep track of that. For target machines on which all 4128e4b17023SJohn Marinoarguments are passed on the stack, there is no need to store anything in 4129e4b17023SJohn Marino@code{CUMULATIVE_ARGS}; however, the data structure must exist and 4130e4b17023SJohn Marinoshould not be empty, so use @code{int}. 4131e4b17023SJohn Marino@end defmac 4132e4b17023SJohn Marino 4133e4b17023SJohn Marino@defmac OVERRIDE_ABI_FORMAT (@var{fndecl}) 4134e4b17023SJohn MarinoIf defined, this macro is called before generating any code for a 4135e4b17023SJohn Marinofunction, but after the @var{cfun} descriptor for the function has been 4136e4b17023SJohn Marinocreated. The back end may use this macro to update @var{cfun} to 4137e4b17023SJohn Marinoreflect an ABI other than that which would normally be used by default. 4138e4b17023SJohn MarinoIf the compiler is generating code for a compiler-generated function, 4139e4b17023SJohn Marino@var{fndecl} may be @code{NULL}. 4140e4b17023SJohn Marino@end defmac 4141e4b17023SJohn Marino 4142e4b17023SJohn Marino@defmac INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype}, @var{libname}, @var{fndecl}, @var{n_named_args}) 4143e4b17023SJohn MarinoA C statement (sans semicolon) for initializing the variable 4144e4b17023SJohn Marino@var{cum} for the state at the beginning of the argument list. The 4145e4b17023SJohn Marinovariable has type @code{CUMULATIVE_ARGS}. The value of @var{fntype} 4146e4b17023SJohn Marinois the tree node for the data type of the function which will receive 4147e4b17023SJohn Marinothe args, or 0 if the args are to a compiler support library function. 4148e4b17023SJohn MarinoFor direct calls that are not libcalls, @var{fndecl} contain the 4149e4b17023SJohn Marinodeclaration node of the function. @var{fndecl} is also set when 4150e4b17023SJohn Marino@code{INIT_CUMULATIVE_ARGS} is used to find arguments for the function 4151e4b17023SJohn Marinobeing compiled. @var{n_named_args} is set to the number of named 4152e4b17023SJohn Marinoarguments, including a structure return address if it is passed as a 4153e4b17023SJohn Marinoparameter, when making a call. When processing incoming arguments, 4154e4b17023SJohn Marino@var{n_named_args} is set to @minus{}1. 4155e4b17023SJohn Marino 4156e4b17023SJohn MarinoWhen processing a call to a compiler support library function, 4157e4b17023SJohn Marino@var{libname} identifies which one. It is a @code{symbol_ref} rtx which 4158e4b17023SJohn Marinocontains the name of the function, as a string. @var{libname} is 0 when 4159e4b17023SJohn Marinoan ordinary C function call is being processed. Thus, each time this 4160e4b17023SJohn Marinomacro is called, either @var{libname} or @var{fntype} is nonzero, but 4161e4b17023SJohn Marinonever both of them at once. 4162e4b17023SJohn Marino@end defmac 4163e4b17023SJohn Marino 4164e4b17023SJohn Marino@defmac INIT_CUMULATIVE_LIBCALL_ARGS (@var{cum}, @var{mode}, @var{libname}) 4165e4b17023SJohn MarinoLike @code{INIT_CUMULATIVE_ARGS} but only used for outgoing libcalls, 4166e4b17023SJohn Marinoit gets a @code{MODE} argument instead of @var{fntype}, that would be 4167e4b17023SJohn Marino@code{NULL}. @var{indirect} would always be zero, too. If this macro 4168e4b17023SJohn Marinois not defined, @code{INIT_CUMULATIVE_ARGS (cum, NULL_RTX, libname, 4169e4b17023SJohn Marino0)} is used instead. 4170e4b17023SJohn Marino@end defmac 4171e4b17023SJohn Marino 4172e4b17023SJohn Marino@defmac INIT_CUMULATIVE_INCOMING_ARGS (@var{cum}, @var{fntype}, @var{libname}) 4173e4b17023SJohn MarinoLike @code{INIT_CUMULATIVE_ARGS} but overrides it for the purposes of 4174e4b17023SJohn Marinofinding the arguments for the function being compiled. If this macro is 4175e4b17023SJohn Marinoundefined, @code{INIT_CUMULATIVE_ARGS} is used instead. 4176e4b17023SJohn Marino 4177e4b17023SJohn MarinoThe value passed for @var{libname} is always 0, since library routines 4178e4b17023SJohn Marinowith special calling conventions are never compiled with GCC@. The 4179e4b17023SJohn Marinoargument @var{libname} exists for symmetry with 4180e4b17023SJohn Marino@code{INIT_CUMULATIVE_ARGS}. 4181e4b17023SJohn Marino@c could use "this macro" in place of @code{INIT_CUMULATIVE_ARGS}, maybe. 4182e4b17023SJohn Marino@c --mew 5feb93 i switched the order of the sentences. --mew 10feb93 4183e4b17023SJohn Marino@end defmac 4184e4b17023SJohn Marino 4185e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_FUNCTION_ARG_ADVANCE (cumulative_args_t @var{ca}, enum machine_mode @var{mode}, const_tree @var{type}, bool @var{named}) 4186e4b17023SJohn MarinoThis hook updates the summarizer variable pointed to by @var{ca} to 4187e4b17023SJohn Marinoadvance past an argument in the argument list. The values @var{mode}, 4188e4b17023SJohn Marino@var{type} and @var{named} describe that argument. Once this is done, 4189e4b17023SJohn Marinothe variable @var{cum} is suitable for analyzing the @emph{following} 4190e4b17023SJohn Marinoargument with @code{TARGET_FUNCTION_ARG}, etc. 4191e4b17023SJohn Marino 4192e4b17023SJohn MarinoThis hook need not do anything if the argument in question was passed 4193e4b17023SJohn Marinoon the stack. The compiler knows how to track the amount of stack space 4194e4b17023SJohn Marinoused for arguments without any special help. 4195e4b17023SJohn Marino@end deftypefn 4196e4b17023SJohn Marino 4197e4b17023SJohn Marino@defmac FUNCTION_ARG_OFFSET (@var{mode}, @var{type}) 4198e4b17023SJohn MarinoIf defined, a C expression that is the number of bytes to add to the 4199e4b17023SJohn Marinooffset of the argument passed in memory. This is needed for the SPU, 4200e4b17023SJohn Marinowhich passes @code{char} and @code{short} arguments in the preferred 4201e4b17023SJohn Marinoslot that is in the middle of the quad word instead of starting at the 4202e4b17023SJohn Marinotop. 4203e4b17023SJohn Marino@end defmac 4204e4b17023SJohn Marino 4205e4b17023SJohn Marino@defmac FUNCTION_ARG_PADDING (@var{mode}, @var{type}) 4206e4b17023SJohn MarinoIf defined, a C expression which determines whether, and in which direction, 4207e4b17023SJohn Marinoto pad out an argument with extra space. The value should be of type 4208e4b17023SJohn Marino@code{enum direction}: either @code{upward} to pad above the argument, 4209e4b17023SJohn Marino@code{downward} to pad below, or @code{none} to inhibit padding. 4210e4b17023SJohn Marino 4211e4b17023SJohn MarinoThe @emph{amount} of padding is not controlled by this macro, but by the 4212e4b17023SJohn Marinotarget hook @code{TARGET_FUNCTION_ARG_ROUND_BOUNDARY}. It is 4213e4b17023SJohn Marinoalways just enough to reach the next multiple of that boundary. 4214e4b17023SJohn Marino 4215e4b17023SJohn MarinoThis macro has a default definition which is right for most systems. 4216e4b17023SJohn MarinoFor little-endian machines, the default is to pad upward. For 4217e4b17023SJohn Marinobig-endian machines, the default is to pad downward for an argument of 4218e4b17023SJohn Marinoconstant size shorter than an @code{int}, and upward otherwise. 4219e4b17023SJohn Marino@end defmac 4220e4b17023SJohn Marino 4221e4b17023SJohn Marino@defmac PAD_VARARGS_DOWN 4222e4b17023SJohn MarinoIf defined, a C expression which determines whether the default 4223e4b17023SJohn Marinoimplementation of va_arg will attempt to pad down before reading the 4224e4b17023SJohn Marinonext argument, if that argument is smaller than its aligned space as 4225e4b17023SJohn Marinocontrolled by @code{PARM_BOUNDARY}. If this macro is not defined, all such 4226e4b17023SJohn Marinoarguments are padded down if @code{BYTES_BIG_ENDIAN} is true. 4227e4b17023SJohn Marino@end defmac 4228e4b17023SJohn Marino 4229e4b17023SJohn Marino@defmac BLOCK_REG_PADDING (@var{mode}, @var{type}, @var{first}) 4230e4b17023SJohn MarinoSpecify padding for the last element of a block move between registers and 4231e4b17023SJohn Marinomemory. @var{first} is nonzero if this is the only element. Defining this 4232e4b17023SJohn Marinomacro allows better control of register function parameters on big-endian 4233e4b17023SJohn Marinomachines, without using @code{PARALLEL} rtl. In particular, 4234e4b17023SJohn Marino@code{MUST_PASS_IN_STACK} need not test padding and mode of types in 4235e4b17023SJohn Marinoregisters, as there is no longer a "wrong" part of a register; For example, 4236e4b17023SJohn Marinoa three byte aggregate may be passed in the high part of a register if so 4237e4b17023SJohn Marinorequired. 4238e4b17023SJohn Marino@end defmac 4239e4b17023SJohn Marino 4240e4b17023SJohn Marino@deftypefn {Target Hook} {unsigned int} TARGET_FUNCTION_ARG_BOUNDARY (enum machine_mode @var{mode}, const_tree @var{type}) 4241e4b17023SJohn MarinoThis hook returns the alignment boundary, in bits, of an argument 4242e4b17023SJohn Marinowith the specified mode and type. The default hook returns 4243e4b17023SJohn Marino@code{PARM_BOUNDARY} for all arguments. 4244e4b17023SJohn Marino@end deftypefn 4245e4b17023SJohn Marino 4246e4b17023SJohn Marino@deftypefn {Target Hook} {unsigned int} TARGET_FUNCTION_ARG_ROUND_BOUNDARY (enum machine_mode @var{mode}, const_tree @var{type}) 4247e4b17023SJohn MarinoNormally, the size of an argument is rounded up to @code{PARM_BOUNDARY}, 4248e4b17023SJohn Marinowhich is the default value for this hook. You can define this hook to 4249e4b17023SJohn Marinoreturn a different value if an argument size must be rounded to a larger 4250e4b17023SJohn Marinovalue. 4251e4b17023SJohn Marino@end deftypefn 4252e4b17023SJohn Marino 4253e4b17023SJohn Marino@defmac FUNCTION_ARG_REGNO_P (@var{regno}) 4254e4b17023SJohn MarinoA C expression that is nonzero if @var{regno} is the number of a hard 4255e4b17023SJohn Marinoregister in which function arguments are sometimes passed. This does 4256e4b17023SJohn Marino@emph{not} include implicit arguments such as the static chain and 4257e4b17023SJohn Marinothe structure-value address. On many machines, no registers can be 4258e4b17023SJohn Marinoused for this purpose since all function arguments are pushed on the 4259e4b17023SJohn Marinostack. 4260e4b17023SJohn Marino@end defmac 4261e4b17023SJohn Marino 4262e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_SPLIT_COMPLEX_ARG (const_tree @var{type}) 4263e4b17023SJohn MarinoThis hook should return true if parameter of type @var{type} are passed 4264e4b17023SJohn Marinoas two scalar parameters. By default, GCC will attempt to pack complex 4265e4b17023SJohn Marinoarguments into the target's word size. Some ABIs require complex arguments 4266e4b17023SJohn Marinoto be split and treated as their individual components. For example, on 4267e4b17023SJohn MarinoAIX64, complex floats should be passed in a pair of floating point 4268e4b17023SJohn Marinoregisters, even though a complex float would fit in one 64-bit floating 4269e4b17023SJohn Marinopoint register. 4270e4b17023SJohn Marino 4271e4b17023SJohn MarinoThe default value of this hook is @code{NULL}, which is treated as always 4272e4b17023SJohn Marinofalse. 4273e4b17023SJohn Marino@end deftypefn 4274e4b17023SJohn Marino 4275e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_BUILD_BUILTIN_VA_LIST (void) 4276e4b17023SJohn MarinoThis hook returns a type node for @code{va_list} for the target. 4277e4b17023SJohn MarinoThe default version of the hook returns @code{void*}. 4278e4b17023SJohn Marino@end deftypefn 4279e4b17023SJohn Marino 4280e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ENUM_VA_LIST_P (int @var{idx}, const char **@var{pname}, tree *@var{ptree}) 4281e4b17023SJohn MarinoThis target hook is used in function @code{c_common_nodes_and_builtins} 4282e4b17023SJohn Marinoto iterate through the target specific builtin types for va_list. The 4283e4b17023SJohn Marinovariable @var{idx} is used as iterator. @var{pname} has to be a pointer 4284e4b17023SJohn Marinoto a @code{const char *} and @var{ptree} a pointer to a @code{tree} typed 4285e4b17023SJohn Marinovariable. 4286e4b17023SJohn MarinoThe arguments @var{pname} and @var{ptree} are used to store the result of 4287e4b17023SJohn Marinothis macro and are set to the name of the va_list builtin type and its 4288e4b17023SJohn Marinointernal type. 4289e4b17023SJohn MarinoIf the return value of this macro is zero, then there is no more element. 4290e4b17023SJohn MarinoOtherwise the @var{IDX} should be increased for the next call of this 4291e4b17023SJohn Marinomacro to iterate through all types. 4292e4b17023SJohn Marino@end deftypefn 4293e4b17023SJohn Marino 4294e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_FN_ABI_VA_LIST (tree @var{fndecl}) 4295e4b17023SJohn MarinoThis hook returns the va_list type of the calling convention specified by 4296e4b17023SJohn Marino@var{fndecl}. 4297e4b17023SJohn MarinoThe default version of this hook returns @code{va_list_type_node}. 4298e4b17023SJohn Marino@end deftypefn 4299e4b17023SJohn Marino 4300e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_CANONICAL_VA_LIST_TYPE (tree @var{type}) 4301e4b17023SJohn MarinoThis hook returns the va_list type of the calling convention specified by the 4302e4b17023SJohn Marinotype of @var{type}. If @var{type} is not a valid va_list type, it returns 4303e4b17023SJohn Marino@code{NULL_TREE}. 4304e4b17023SJohn Marino@end deftypefn 4305e4b17023SJohn Marino 4306e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_GIMPLIFY_VA_ARG_EXPR (tree @var{valist}, tree @var{type}, gimple_seq *@var{pre_p}, gimple_seq *@var{post_p}) 4307e4b17023SJohn MarinoThis hook performs target-specific gimplification of 4308e4b17023SJohn Marino@code{VA_ARG_EXPR}. The first two parameters correspond to the 4309e4b17023SJohn Marinoarguments to @code{va_arg}; the latter two are as in 4310e4b17023SJohn Marino@code{gimplify.c:gimplify_expr}. 4311e4b17023SJohn Marino@end deftypefn 4312e4b17023SJohn Marino 4313e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_VALID_POINTER_MODE (enum machine_mode @var{mode}) 4314e4b17023SJohn MarinoDefine this to return nonzero if the port can handle pointers 4315e4b17023SJohn Marinowith machine mode @var{mode}. The default version of this 4316e4b17023SJohn Marinohook returns true for both @code{ptr_mode} and @code{Pmode}. 4317e4b17023SJohn Marino@end deftypefn 4318e4b17023SJohn Marino 4319e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_REF_MAY_ALIAS_ERRNO (struct ao_ref_s *@var{ref}) 4320e4b17023SJohn MarinoDefine this to return nonzero if the memory reference @var{ref} may alias with the system C library errno location. The default version of this hook assumes the system C library errno location is either a declaration of type int or accessed by dereferencing a pointer to int. 4321e4b17023SJohn Marino@end deftypefn 4322e4b17023SJohn Marino 4323e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_SCALAR_MODE_SUPPORTED_P (enum machine_mode @var{mode}) 4324e4b17023SJohn MarinoDefine this to return nonzero if the port is prepared to handle 4325e4b17023SJohn Marinoinsns involving scalar mode @var{mode}. For a scalar mode to be 4326e4b17023SJohn Marinoconsidered supported, all the basic arithmetic and comparisons 4327e4b17023SJohn Marinomust work. 4328e4b17023SJohn Marino 4329e4b17023SJohn MarinoThe default version of this hook returns true for any mode 4330e4b17023SJohn Marinorequired to handle the basic C types (as defined by the port). 4331e4b17023SJohn MarinoIncluded here are the double-word arithmetic supported by the 4332e4b17023SJohn Marinocode in @file{optabs.c}. 4333e4b17023SJohn Marino@end deftypefn 4334e4b17023SJohn Marino 4335e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_VECTOR_MODE_SUPPORTED_P (enum machine_mode @var{mode}) 4336e4b17023SJohn MarinoDefine this to return nonzero if the port is prepared to handle 4337e4b17023SJohn Marinoinsns involving vector mode @var{mode}. At the very least, it 4338e4b17023SJohn Marinomust have move patterns for this mode. 4339e4b17023SJohn Marino@end deftypefn 4340e4b17023SJohn Marino 4341e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ARRAY_MODE_SUPPORTED_P (enum machine_mode @var{mode}, unsigned HOST_WIDE_INT @var{nelems}) 4342e4b17023SJohn MarinoReturn true if GCC should try to use a scalar mode to store an array 4343e4b17023SJohn Marinoof @var{nelems} elements, given that each element has mode @var{mode}. 4344e4b17023SJohn MarinoReturning true here overrides the usual @code{MAX_FIXED_MODE} limit 4345e4b17023SJohn Marinoand allows GCC to use any defined integer mode. 4346e4b17023SJohn Marino 4347e4b17023SJohn MarinoOne use of this hook is to support vector load and store operations 4348e4b17023SJohn Marinothat operate on several homogeneous vectors. For example, ARM NEON 4349e4b17023SJohn Marinohas operations like: 4350e4b17023SJohn Marino 4351e4b17023SJohn Marino@smallexample 4352e4b17023SJohn Marinoint8x8x3_t vld3_s8 (const int8_t *) 4353e4b17023SJohn Marino@end smallexample 4354e4b17023SJohn Marino 4355e4b17023SJohn Marinowhere the return type is defined as: 4356e4b17023SJohn Marino 4357e4b17023SJohn Marino@smallexample 4358e4b17023SJohn Marinotypedef struct int8x8x3_t 4359e4b17023SJohn Marino@{ 4360e4b17023SJohn Marino int8x8_t val[3]; 4361e4b17023SJohn Marino@} int8x8x3_t; 4362e4b17023SJohn Marino@end smallexample 4363e4b17023SJohn Marino 4364e4b17023SJohn MarinoIf this hook allows @code{val} to have a scalar mode, then 4365e4b17023SJohn Marino@code{int8x8x3_t} can have the same mode. GCC can then store 4366e4b17023SJohn Marino@code{int8x8x3_t}s in registers rather than forcing them onto the stack. 4367e4b17023SJohn Marino@end deftypefn 4368e4b17023SJohn Marino 4369e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P (enum machine_mode @var{mode}) 4370e4b17023SJohn MarinoDefine this to return nonzero for machine modes for which the port has 4371e4b17023SJohn Marinosmall register classes. If this target hook returns nonzero for a given 4372e4b17023SJohn Marino@var{mode}, the compiler will try to minimize the lifetime of registers 4373e4b17023SJohn Marinoin @var{mode}. The hook may be called with @code{VOIDmode} as argument. 4374e4b17023SJohn MarinoIn this case, the hook is expected to return nonzero if it returns nonzero 4375e4b17023SJohn Marinofor any mode. 4376e4b17023SJohn Marino 4377e4b17023SJohn MarinoOn some machines, it is risky to let hard registers live across arbitrary 4378e4b17023SJohn Marinoinsns. Typically, these machines have instructions that require values 4379e4b17023SJohn Marinoto be in specific registers (like an accumulator), and reload will fail 4380e4b17023SJohn Marinoif the required hard register is used for another purpose across such an 4381e4b17023SJohn Marinoinsn. 4382e4b17023SJohn Marino 4383e4b17023SJohn MarinoPasses before reload do not know which hard registers will be used 4384e4b17023SJohn Marinoin an instruction, but the machine modes of the registers set or used in 4385e4b17023SJohn Marinothe instruction are already known. And for some machines, register 4386e4b17023SJohn Marinoclasses are small for, say, integer registers but not for floating point 4387e4b17023SJohn Marinoregisters. For example, the AMD x86-64 architecture requires specific 4388e4b17023SJohn Marinoregisters for the legacy x86 integer instructions, but there are many 4389e4b17023SJohn MarinoSSE registers for floating point operations. On such targets, a good 4390e4b17023SJohn Marinostrategy may be to return nonzero from this hook for @code{INTEGRAL_MODE_P} 4391e4b17023SJohn Marinomachine modes but zero for the SSE register classes. 4392e4b17023SJohn Marino 4393e4b17023SJohn MarinoThe default version of this hook returns false for any mode. It is always 4394e4b17023SJohn Marinosafe to redefine this hook to return with a nonzero value. But if you 4395e4b17023SJohn Marinounnecessarily define it, you will reduce the amount of optimizations 4396e4b17023SJohn Marinothat can be performed in some cases. If you do not define this hook 4397e4b17023SJohn Marinoto return a nonzero value when it is required, the compiler will run out 4398e4b17023SJohn Marinoof spill registers and print a fatal error message. 4399e4b17023SJohn Marino@end deftypefn 4400e4b17023SJohn Marino 4401e4b17023SJohn Marino@deftypevr {Target Hook} {unsigned int} TARGET_FLAGS_REGNUM 4402e4b17023SJohn MarinoIf the target has a dedicated flags register, and it needs to use the post-reload comparison elimination pass, then this value should be set appropriately. 4403e4b17023SJohn Marino@end deftypevr 4404e4b17023SJohn Marino 4405e4b17023SJohn Marino@node Scalar Return 4406e4b17023SJohn Marino@subsection How Scalar Function Values Are Returned 4407e4b17023SJohn Marino@cindex return values in registers 4408e4b17023SJohn Marino@cindex values, returned by functions 4409e4b17023SJohn Marino@cindex scalars, returned as values 4410e4b17023SJohn Marino 4411e4b17023SJohn MarinoThis section discusses the macros that control returning scalars as 4412e4b17023SJohn Marinovalues---values that can fit in registers. 4413e4b17023SJohn Marino 4414e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_FUNCTION_VALUE (const_tree @var{ret_type}, const_tree @var{fn_decl_or_type}, bool @var{outgoing}) 4415e4b17023SJohn Marino 4416e4b17023SJohn MarinoDefine this to return an RTX representing the place where a function 4417e4b17023SJohn Marinoreturns or receives a value of data type @var{ret_type}, a tree node 4418e4b17023SJohn Marinorepresenting a data type. @var{fn_decl_or_type} is a tree node 4419e4b17023SJohn Marinorepresenting @code{FUNCTION_DECL} or @code{FUNCTION_TYPE} of a 4420e4b17023SJohn Marinofunction being called. If @var{outgoing} is false, the hook should 4421e4b17023SJohn Marinocompute the register in which the caller will see the return value. 4422e4b17023SJohn MarinoOtherwise, the hook should return an RTX representing the place where 4423e4b17023SJohn Marinoa function returns a value. 4424e4b17023SJohn Marino 4425e4b17023SJohn MarinoOn many machines, only @code{TYPE_MODE (@var{ret_type})} is relevant. 4426e4b17023SJohn Marino(Actually, on most machines, scalar values are returned in the same 4427e4b17023SJohn Marinoplace regardless of mode.) The value of the expression is usually a 4428e4b17023SJohn Marino@code{reg} RTX for the hard register where the return value is stored. 4429e4b17023SJohn MarinoThe value can also be a @code{parallel} RTX, if the return value is in 4430e4b17023SJohn Marinomultiple places. See @code{TARGET_FUNCTION_ARG} for an explanation of the 4431e4b17023SJohn Marino@code{parallel} form. Note that the callee will populate every 4432e4b17023SJohn Marinolocation specified in the @code{parallel}, but if the first element of 4433e4b17023SJohn Marinothe @code{parallel} contains the whole return value, callers will use 4434e4b17023SJohn Marinothat element as the canonical location and ignore the others. The m68k 4435e4b17023SJohn Marinoport uses this type of @code{parallel} to return pointers in both 4436e4b17023SJohn Marino@samp{%a0} (the canonical location) and @samp{%d0}. 4437e4b17023SJohn Marino 4438e4b17023SJohn MarinoIf @code{TARGET_PROMOTE_FUNCTION_RETURN} returns true, you must apply 4439e4b17023SJohn Marinothe same promotion rules specified in @code{PROMOTE_MODE} if 4440e4b17023SJohn Marino@var{valtype} is a scalar type. 4441e4b17023SJohn Marino 4442e4b17023SJohn MarinoIf the precise function being called is known, @var{func} is a tree 4443e4b17023SJohn Marinonode (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null 4444e4b17023SJohn Marinopointer. This makes it possible to use a different value-returning 4445e4b17023SJohn Marinoconvention for specific functions when all their calls are 4446e4b17023SJohn Marinoknown. 4447e4b17023SJohn Marino 4448e4b17023SJohn MarinoSome target machines have ``register windows'' so that the register in 4449e4b17023SJohn Marinowhich a function returns its value is not the same as the one in which 4450e4b17023SJohn Marinothe caller sees the value. For such machines, you should return 4451e4b17023SJohn Marinodifferent RTX depending on @var{outgoing}. 4452e4b17023SJohn Marino 4453e4b17023SJohn Marino@code{TARGET_FUNCTION_VALUE} is not used for return values with 4454e4b17023SJohn Marinoaggregate data types, because these are returned in another way. See 4455e4b17023SJohn Marino@code{TARGET_STRUCT_VALUE_RTX} and related macros, below. 4456e4b17023SJohn Marino@end deftypefn 4457e4b17023SJohn Marino 4458e4b17023SJohn Marino@defmac FUNCTION_VALUE (@var{valtype}, @var{func}) 4459e4b17023SJohn MarinoThis macro has been deprecated. Use @code{TARGET_FUNCTION_VALUE} for 4460e4b17023SJohn Marinoa new target instead. 4461e4b17023SJohn Marino@end defmac 4462e4b17023SJohn Marino 4463e4b17023SJohn Marino@defmac LIBCALL_VALUE (@var{mode}) 4464e4b17023SJohn MarinoA C expression to create an RTX representing the place where a library 4465e4b17023SJohn Marinofunction returns a value of mode @var{mode}. 4466e4b17023SJohn Marino 4467e4b17023SJohn MarinoNote that ``library function'' in this context means a compiler 4468e4b17023SJohn Marinosupport routine, used to perform arithmetic, whose name is known 4469e4b17023SJohn Marinospecially by the compiler and was not mentioned in the C code being 4470e4b17023SJohn Marinocompiled. 4471e4b17023SJohn Marino@end defmac 4472e4b17023SJohn Marino 4473e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_LIBCALL_VALUE (enum machine_mode @var{mode}, const_rtx @var{fun}) 4474e4b17023SJohn MarinoDefine this hook if the back-end needs to know the name of the libcall 4475e4b17023SJohn Marinofunction in order to determine where the result should be returned. 4476e4b17023SJohn Marino 4477e4b17023SJohn MarinoThe mode of the result is given by @var{mode} and the name of the called 4478e4b17023SJohn Marinolibrary function is given by @var{fun}. The hook should return an RTX 4479e4b17023SJohn Marinorepresenting the place where the library function result will be returned. 4480e4b17023SJohn Marino 4481e4b17023SJohn MarinoIf this hook is not defined, then LIBCALL_VALUE will be used. 4482e4b17023SJohn Marino@end deftypefn 4483e4b17023SJohn Marino 4484e4b17023SJohn Marino@defmac FUNCTION_VALUE_REGNO_P (@var{regno}) 4485e4b17023SJohn MarinoA C expression that is nonzero if @var{regno} is the number of a hard 4486e4b17023SJohn Marinoregister in which the values of called function may come back. 4487e4b17023SJohn Marino 4488e4b17023SJohn MarinoA register whose use for returning values is limited to serving as the 4489e4b17023SJohn Marinosecond of a pair (for a value of type @code{double}, say) need not be 4490e4b17023SJohn Marinorecognized by this macro. So for most machines, this definition 4491e4b17023SJohn Marinosuffices: 4492e4b17023SJohn Marino 4493e4b17023SJohn Marino@smallexample 4494e4b17023SJohn Marino#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0) 4495e4b17023SJohn Marino@end smallexample 4496e4b17023SJohn Marino 4497e4b17023SJohn MarinoIf the machine has register windows, so that the caller and the called 4498e4b17023SJohn Marinofunction use different registers for the return value, this macro 4499e4b17023SJohn Marinoshould recognize only the caller's register numbers. 4500e4b17023SJohn Marino 4501e4b17023SJohn MarinoThis macro has been deprecated. Use @code{TARGET_FUNCTION_VALUE_REGNO_P} 4502e4b17023SJohn Marinofor a new target instead. 4503e4b17023SJohn Marino@end defmac 4504e4b17023SJohn Marino 4505e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_FUNCTION_VALUE_REGNO_P (const unsigned int @var{regno}) 4506e4b17023SJohn MarinoA target hook that return @code{true} if @var{regno} is the number of a hard 4507e4b17023SJohn Marinoregister in which the values of called function may come back. 4508e4b17023SJohn Marino 4509e4b17023SJohn MarinoA register whose use for returning values is limited to serving as the 4510e4b17023SJohn Marinosecond of a pair (for a value of type @code{double}, say) need not be 4511e4b17023SJohn Marinorecognized by this target hook. 4512e4b17023SJohn Marino 4513e4b17023SJohn MarinoIf the machine has register windows, so that the caller and the called 4514e4b17023SJohn Marinofunction use different registers for the return value, this target hook 4515e4b17023SJohn Marinoshould recognize only the caller's register numbers. 4516e4b17023SJohn Marino 4517e4b17023SJohn MarinoIf this hook is not defined, then FUNCTION_VALUE_REGNO_P will be used. 4518e4b17023SJohn Marino@end deftypefn 4519e4b17023SJohn Marino 4520e4b17023SJohn Marino@defmac APPLY_RESULT_SIZE 4521e4b17023SJohn MarinoDefine this macro if @samp{untyped_call} and @samp{untyped_return} 4522e4b17023SJohn Marinoneed more space than is implied by @code{FUNCTION_VALUE_REGNO_P} for 4523e4b17023SJohn Marinosaving and restoring an arbitrary return value. 4524e4b17023SJohn Marino@end defmac 4525e4b17023SJohn Marino 4526e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_RETURN_IN_MSB (const_tree @var{type}) 4527e4b17023SJohn MarinoThis hook should return true if values of type @var{type} are returned 4528e4b17023SJohn Marinoat the most significant end of a register (in other words, if they are 4529e4b17023SJohn Marinopadded at the least significant end). You can assume that @var{type} 4530e4b17023SJohn Marinois returned in a register; the caller is required to check this. 4531e4b17023SJohn Marino 4532e4b17023SJohn MarinoNote that the register provided by @code{TARGET_FUNCTION_VALUE} must 4533e4b17023SJohn Marinobe able to hold the complete return value. For example, if a 1-, 2- 4534e4b17023SJohn Marinoor 3-byte structure is returned at the most significant end of a 4535e4b17023SJohn Marino4-byte register, @code{TARGET_FUNCTION_VALUE} should provide an 4536e4b17023SJohn Marino@code{SImode} rtx. 4537e4b17023SJohn Marino@end deftypefn 4538e4b17023SJohn Marino 4539e4b17023SJohn Marino@node Aggregate Return 4540e4b17023SJohn Marino@subsection How Large Values Are Returned 4541e4b17023SJohn Marino@cindex aggregates as return values 4542e4b17023SJohn Marino@cindex large return values 4543e4b17023SJohn Marino@cindex returning aggregate values 4544e4b17023SJohn Marino@cindex structure value address 4545e4b17023SJohn Marino 4546e4b17023SJohn MarinoWhen a function value's mode is @code{BLKmode} (and in some other 4547e4b17023SJohn Marinocases), the value is not returned according to 4548e4b17023SJohn Marino@code{TARGET_FUNCTION_VALUE} (@pxref{Scalar Return}). Instead, the 4549e4b17023SJohn Marinocaller passes the address of a block of memory in which the value 4550e4b17023SJohn Marinoshould be stored. This address is called the @dfn{structure value 4551e4b17023SJohn Marinoaddress}. 4552e4b17023SJohn Marino 4553e4b17023SJohn MarinoThis section describes how to control returning structure values in 4554e4b17023SJohn Marinomemory. 4555e4b17023SJohn Marino 4556e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_RETURN_IN_MEMORY (const_tree @var{type}, const_tree @var{fntype}) 4557e4b17023SJohn MarinoThis target hook should return a nonzero value to say to return the 4558e4b17023SJohn Marinofunction value in memory, just as large structures are always returned. 4559e4b17023SJohn MarinoHere @var{type} will be the data type of the value, and @var{fntype} 4560e4b17023SJohn Marinowill be the type of the function doing the returning, or @code{NULL} for 4561e4b17023SJohn Marinolibcalls. 4562e4b17023SJohn Marino 4563e4b17023SJohn MarinoNote that values of mode @code{BLKmode} must be explicitly handled 4564e4b17023SJohn Marinoby this function. Also, the option @option{-fpcc-struct-return} 4565e4b17023SJohn Marinotakes effect regardless of this macro. On most systems, it is 4566e4b17023SJohn Marinopossible to leave the hook undefined; this causes a default 4567e4b17023SJohn Marinodefinition to be used, whose value is the constant 1 for @code{BLKmode} 4568e4b17023SJohn Marinovalues, and 0 otherwise. 4569e4b17023SJohn Marino 4570e4b17023SJohn MarinoDo not use this hook to indicate that structures and unions should always 4571e4b17023SJohn Marinobe returned in memory. You should instead use @code{DEFAULT_PCC_STRUCT_RETURN} 4572e4b17023SJohn Marinoto indicate this. 4573e4b17023SJohn Marino@end deftypefn 4574e4b17023SJohn Marino 4575e4b17023SJohn Marino@defmac DEFAULT_PCC_STRUCT_RETURN 4576e4b17023SJohn MarinoDefine this macro to be 1 if all structure and union return values must be 4577e4b17023SJohn Marinoin memory. Since this results in slower code, this should be defined 4578e4b17023SJohn Marinoonly if needed for compatibility with other compilers or with an ABI@. 4579e4b17023SJohn MarinoIf you define this macro to be 0, then the conventions used for structure 4580e4b17023SJohn Marinoand union return values are decided by the @code{TARGET_RETURN_IN_MEMORY} 4581e4b17023SJohn Marinotarget hook. 4582e4b17023SJohn Marino 4583e4b17023SJohn MarinoIf not defined, this defaults to the value 1. 4584e4b17023SJohn Marino@end defmac 4585e4b17023SJohn Marino 4586e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_STRUCT_VALUE_RTX (tree @var{fndecl}, int @var{incoming}) 4587e4b17023SJohn MarinoThis target hook should return the location of the structure value 4588e4b17023SJohn Marinoaddress (normally a @code{mem} or @code{reg}), or 0 if the address is 4589e4b17023SJohn Marinopassed as an ``invisible'' first argument. Note that @var{fndecl} may 4590e4b17023SJohn Marinobe @code{NULL}, for libcalls. You do not need to define this target 4591e4b17023SJohn Marinohook if the address is always passed as an ``invisible'' first 4592e4b17023SJohn Marinoargument. 4593e4b17023SJohn Marino 4594e4b17023SJohn MarinoOn some architectures the place where the structure value address 4595e4b17023SJohn Marinois found by the called function is not the same place that the 4596e4b17023SJohn Marinocaller put it. This can be due to register windows, or it could 4597e4b17023SJohn Marinobe because the function prologue moves it to a different place. 4598e4b17023SJohn Marino@var{incoming} is @code{1} or @code{2} when the location is needed in 4599e4b17023SJohn Marinothe context of the called function, and @code{0} in the context of 4600e4b17023SJohn Marinothe caller. 4601e4b17023SJohn Marino 4602e4b17023SJohn MarinoIf @var{incoming} is nonzero and the address is to be found on the 4603e4b17023SJohn Marinostack, return a @code{mem} which refers to the frame pointer. If 4604e4b17023SJohn Marino@var{incoming} is @code{2}, the result is being used to fetch the 4605e4b17023SJohn Marinostructure value address at the beginning of a function. If you need 4606e4b17023SJohn Marinoto emit adjusting code, you should do it at this point. 4607e4b17023SJohn Marino@end deftypefn 4608e4b17023SJohn Marino 4609e4b17023SJohn Marino@defmac PCC_STATIC_STRUCT_RETURN 4610e4b17023SJohn MarinoDefine this macro if the usual system convention on the target machine 4611e4b17023SJohn Marinofor returning structures and unions is for the called function to return 4612e4b17023SJohn Marinothe address of a static variable containing the value. 4613e4b17023SJohn Marino 4614e4b17023SJohn MarinoDo not define this if the usual system convention is for the caller to 4615e4b17023SJohn Marinopass an address to the subroutine. 4616e4b17023SJohn Marino 4617e4b17023SJohn MarinoThis macro has effect in @option{-fpcc-struct-return} mode, but it does 4618e4b17023SJohn Marinonothing when you use @option{-freg-struct-return} mode. 4619e4b17023SJohn Marino@end defmac 4620e4b17023SJohn Marino 4621e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_GET_RAW_RESULT_MODE (int @var{regno}) 4622e4b17023SJohn MarinoThis target hook returns the mode to be used when accessing raw return registers in @code{__builtin_return}. Define this macro if the value in @var{reg_raw_mode} is not correct. 4623e4b17023SJohn Marino@end deftypefn 4624e4b17023SJohn Marino 4625e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_GET_RAW_ARG_MODE (int @var{regno}) 4626e4b17023SJohn MarinoThis target hook returns the mode to be used when accessing raw argument registers in @code{__builtin_apply_args}. Define this macro if the value in @var{reg_raw_mode} is not correct. 4627e4b17023SJohn Marino@end deftypefn 4628e4b17023SJohn Marino 4629e4b17023SJohn Marino@node Caller Saves 4630e4b17023SJohn Marino@subsection Caller-Saves Register Allocation 4631e4b17023SJohn Marino 4632e4b17023SJohn MarinoIf you enable it, GCC can save registers around function calls. This 4633e4b17023SJohn Marinomakes it possible to use call-clobbered registers to hold variables that 4634e4b17023SJohn Marinomust live across calls. 4635e4b17023SJohn Marino 4636e4b17023SJohn Marino@defmac CALLER_SAVE_PROFITABLE (@var{refs}, @var{calls}) 4637e4b17023SJohn MarinoA C expression to determine whether it is worthwhile to consider placing 4638e4b17023SJohn Marinoa pseudo-register in a call-clobbered hard register and saving and 4639e4b17023SJohn Marinorestoring it around each function call. The expression should be 1 when 4640e4b17023SJohn Marinothis is worth doing, and 0 otherwise. 4641e4b17023SJohn Marino 4642e4b17023SJohn MarinoIf you don't define this macro, a default is used which is good on most 4643e4b17023SJohn Marinomachines: @code{4 * @var{calls} < @var{refs}}. 4644e4b17023SJohn Marino@end defmac 4645e4b17023SJohn Marino 4646e4b17023SJohn Marino@defmac HARD_REGNO_CALLER_SAVE_MODE (@var{regno}, @var{nregs}) 4647e4b17023SJohn MarinoA C expression specifying which mode is required for saving @var{nregs} 4648e4b17023SJohn Marinoof a pseudo-register in call-clobbered hard register @var{regno}. If 4649e4b17023SJohn Marino@var{regno} is unsuitable for caller save, @code{VOIDmode} should be 4650e4b17023SJohn Marinoreturned. For most machines this macro need not be defined since GCC 4651e4b17023SJohn Marinowill select the smallest suitable mode. 4652e4b17023SJohn Marino@end defmac 4653e4b17023SJohn Marino 4654e4b17023SJohn Marino@node Function Entry 4655e4b17023SJohn Marino@subsection Function Entry and Exit 4656e4b17023SJohn Marino@cindex function entry and exit 4657e4b17023SJohn Marino@cindex prologue 4658e4b17023SJohn Marino@cindex epilogue 4659e4b17023SJohn Marino 4660e4b17023SJohn MarinoThis section describes the macros that output function entry 4661e4b17023SJohn Marino(@dfn{prologue}) and exit (@dfn{epilogue}) code. 4662e4b17023SJohn Marino 4663e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_PROLOGUE (FILE *@var{file}, HOST_WIDE_INT @var{size}) 4664e4b17023SJohn MarinoIf defined, a function that outputs the assembler code for entry to a 4665e4b17023SJohn Marinofunction. The prologue is responsible for setting up the stack frame, 4666e4b17023SJohn Marinoinitializing the frame pointer register, saving registers that must be 4667e4b17023SJohn Marinosaved, and allocating @var{size} additional bytes of storage for the 4668e4b17023SJohn Marinolocal variables. @var{size} is an integer. @var{file} is a stdio 4669e4b17023SJohn Marinostream to which the assembler code should be output. 4670e4b17023SJohn Marino 4671e4b17023SJohn MarinoThe label for the beginning of the function need not be output by this 4672e4b17023SJohn Marinomacro. That has already been done when the macro is run. 4673e4b17023SJohn Marino 4674e4b17023SJohn Marino@findex regs_ever_live 4675e4b17023SJohn MarinoTo determine which registers to save, the macro can refer to the array 4676e4b17023SJohn Marino@code{regs_ever_live}: element @var{r} is nonzero if hard register 4677e4b17023SJohn Marino@var{r} is used anywhere within the function. This implies the function 4678e4b17023SJohn Marinoprologue should save register @var{r}, provided it is not one of the 4679e4b17023SJohn Marinocall-used registers. (@code{TARGET_ASM_FUNCTION_EPILOGUE} must likewise use 4680e4b17023SJohn Marino@code{regs_ever_live}.) 4681e4b17023SJohn Marino 4682e4b17023SJohn MarinoOn machines that have ``register windows'', the function entry code does 4683e4b17023SJohn Marinonot save on the stack the registers that are in the windows, even if 4684e4b17023SJohn Marinothey are supposed to be preserved by function calls; instead it takes 4685e4b17023SJohn Marinoappropriate steps to ``push'' the register stack, if any non-call-used 4686e4b17023SJohn Marinoregisters are used in the function. 4687e4b17023SJohn Marino 4688e4b17023SJohn Marino@findex frame_pointer_needed 4689e4b17023SJohn MarinoOn machines where functions may or may not have frame-pointers, the 4690e4b17023SJohn Marinofunction entry code must vary accordingly; it must set up the frame 4691e4b17023SJohn Marinopointer if one is wanted, and not otherwise. To determine whether a 4692e4b17023SJohn Marinoframe pointer is in wanted, the macro can refer to the variable 4693e4b17023SJohn Marino@code{frame_pointer_needed}. The variable's value will be 1 at run 4694e4b17023SJohn Marinotime in a function that needs a frame pointer. @xref{Elimination}. 4695e4b17023SJohn Marino 4696e4b17023SJohn MarinoThe function entry code is responsible for allocating any stack space 4697e4b17023SJohn Marinorequired for the function. This stack space consists of the regions 4698e4b17023SJohn Marinolisted below. In most cases, these regions are allocated in the 4699e4b17023SJohn Marinoorder listed, with the last listed region closest to the top of the 4700e4b17023SJohn Marinostack (the lowest address if @code{STACK_GROWS_DOWNWARD} is defined, and 4701e4b17023SJohn Marinothe highest address if it is not defined). You can use a different order 4702e4b17023SJohn Marinofor a machine if doing so is more convenient or required for 4703e4b17023SJohn Marinocompatibility reasons. Except in cases where required by standard 4704e4b17023SJohn Marinoor by a debugger, there is no reason why the stack layout used by GCC 4705e4b17023SJohn Marinoneed agree with that used by other compilers for a machine. 4706e4b17023SJohn Marino@end deftypefn 4707e4b17023SJohn Marino 4708e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_END_PROLOGUE (FILE *@var{file}) 4709e4b17023SJohn MarinoIf defined, a function that outputs assembler code at the end of a 4710e4b17023SJohn Marinoprologue. This should be used when the function prologue is being 4711e4b17023SJohn Marinoemitted as RTL, and you have some extra assembler that needs to be 4712e4b17023SJohn Marinoemitted. @xref{prologue instruction pattern}. 4713e4b17023SJohn Marino@end deftypefn 4714e4b17023SJohn Marino 4715e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_BEGIN_EPILOGUE (FILE *@var{file}) 4716e4b17023SJohn MarinoIf defined, a function that outputs assembler code at the start of an 4717e4b17023SJohn Marinoepilogue. This should be used when the function epilogue is being 4718e4b17023SJohn Marinoemitted as RTL, and you have some extra assembler that needs to be 4719e4b17023SJohn Marinoemitted. @xref{epilogue instruction pattern}. 4720e4b17023SJohn Marino@end deftypefn 4721e4b17023SJohn Marino 4722e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_EPILOGUE (FILE *@var{file}, HOST_WIDE_INT @var{size}) 4723e4b17023SJohn MarinoIf defined, a function that outputs the assembler code for exit from a 4724e4b17023SJohn Marinofunction. The epilogue is responsible for restoring the saved 4725e4b17023SJohn Marinoregisters and stack pointer to their values when the function was 4726e4b17023SJohn Marinocalled, and returning control to the caller. This macro takes the 4727e4b17023SJohn Marinosame arguments as the macro @code{TARGET_ASM_FUNCTION_PROLOGUE}, and the 4728e4b17023SJohn Marinoregisters to restore are determined from @code{regs_ever_live} and 4729e4b17023SJohn Marino@code{CALL_USED_REGISTERS} in the same way. 4730e4b17023SJohn Marino 4731e4b17023SJohn MarinoOn some machines, there is a single instruction that does all the work 4732e4b17023SJohn Marinoof returning from the function. On these machines, give that 4733e4b17023SJohn Marinoinstruction the name @samp{return} and do not define the macro 4734e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} at all. 4735e4b17023SJohn Marino 4736e4b17023SJohn MarinoDo not define a pattern named @samp{return} if you want the 4737e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} to be used. If you want the target 4738e4b17023SJohn Marinoswitches to control whether return instructions or epilogues are used, 4739e4b17023SJohn Marinodefine a @samp{return} pattern with a validity condition that tests the 4740e4b17023SJohn Marinotarget switches appropriately. If the @samp{return} pattern's validity 4741e4b17023SJohn Marinocondition is false, epilogues will be used. 4742e4b17023SJohn Marino 4743e4b17023SJohn MarinoOn machines where functions may or may not have frame-pointers, the 4744e4b17023SJohn Marinofunction exit code must vary accordingly. Sometimes the code for these 4745e4b17023SJohn Marinotwo cases is completely different. To determine whether a frame pointer 4746e4b17023SJohn Marinois wanted, the macro can refer to the variable 4747e4b17023SJohn Marino@code{frame_pointer_needed}. The variable's value will be 1 when compiling 4748e4b17023SJohn Marinoa function that needs a frame pointer. 4749e4b17023SJohn Marino 4750e4b17023SJohn MarinoNormally, @code{TARGET_ASM_FUNCTION_PROLOGUE} and 4751e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} must treat leaf functions specially. 4752e4b17023SJohn MarinoThe C variable @code{current_function_is_leaf} is nonzero for such a 4753e4b17023SJohn Marinofunction. @xref{Leaf Functions}. 4754e4b17023SJohn Marino 4755e4b17023SJohn MarinoOn some machines, some functions pop their arguments on exit while 4756e4b17023SJohn Marinoothers leave that for the caller to do. For example, the 68020 when 4757e4b17023SJohn Marinogiven @option{-mrtd} pops arguments in functions that take a fixed 4758e4b17023SJohn Marinonumber of arguments. 4759e4b17023SJohn Marino 4760e4b17023SJohn Marino@findex current_function_pops_args 4761e4b17023SJohn MarinoYour definition of the macro @code{RETURN_POPS_ARGS} decides which 4762e4b17023SJohn Marinofunctions pop their own arguments. @code{TARGET_ASM_FUNCTION_EPILOGUE} 4763e4b17023SJohn Marinoneeds to know what was decided. The number of bytes of the current 4764e4b17023SJohn Marinofunction's arguments that this function should pop is available in 4765e4b17023SJohn Marino@code{crtl->args.pops_args}. @xref{Scalar Return}. 4766e4b17023SJohn Marino@end deftypefn 4767e4b17023SJohn Marino 4768e4b17023SJohn Marino@itemize @bullet 4769e4b17023SJohn Marino@item 4770e4b17023SJohn Marino@findex current_function_pretend_args_size 4771e4b17023SJohn MarinoA region of @code{current_function_pretend_args_size} bytes of 4772e4b17023SJohn Marinouninitialized space just underneath the first argument arriving on the 4773e4b17023SJohn Marinostack. (This may not be at the very start of the allocated stack region 4774e4b17023SJohn Marinoif the calling sequence has pushed anything else since pushing the stack 4775e4b17023SJohn Marinoarguments. But usually, on such machines, nothing else has been pushed 4776e4b17023SJohn Marinoyet, because the function prologue itself does all the pushing.) This 4777e4b17023SJohn Marinoregion is used on machines where an argument may be passed partly in 4778e4b17023SJohn Marinoregisters and partly in memory, and, in some cases to support the 4779e4b17023SJohn Marinofeatures in @code{<stdarg.h>}. 4780e4b17023SJohn Marino 4781e4b17023SJohn Marino@item 4782e4b17023SJohn MarinoAn area of memory used to save certain registers used by the function. 4783e4b17023SJohn MarinoThe size of this area, which may also include space for such things as 4784e4b17023SJohn Marinothe return address and pointers to previous stack frames, is 4785e4b17023SJohn Marinomachine-specific and usually depends on which registers have been used 4786e4b17023SJohn Marinoin the function. Machines with register windows often do not require 4787e4b17023SJohn Marinoa save area. 4788e4b17023SJohn Marino 4789e4b17023SJohn Marino@item 4790e4b17023SJohn MarinoA region of at least @var{size} bytes, possibly rounded up to an allocation 4791e4b17023SJohn Marinoboundary, to contain the local variables of the function. On some machines, 4792e4b17023SJohn Marinothis region and the save area may occur in the opposite order, with the 4793e4b17023SJohn Marinosave area closer to the top of the stack. 4794e4b17023SJohn Marino 4795e4b17023SJohn Marino@item 4796e4b17023SJohn Marino@cindex @code{ACCUMULATE_OUTGOING_ARGS} and stack frames 4797e4b17023SJohn MarinoOptionally, when @code{ACCUMULATE_OUTGOING_ARGS} is defined, a region of 4798e4b17023SJohn Marino@code{current_function_outgoing_args_size} bytes to be used for outgoing 4799e4b17023SJohn Marinoargument lists of the function. @xref{Stack Arguments}. 4800e4b17023SJohn Marino@end itemize 4801e4b17023SJohn Marino 4802e4b17023SJohn Marino@defmac EXIT_IGNORE_STACK 4803e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero if the return 4804e4b17023SJohn Marinoinstruction or the function epilogue ignores the value of the stack 4805e4b17023SJohn Marinopointer; in other words, if it is safe to delete an instruction to 4806e4b17023SJohn Marinoadjust the stack pointer before a return from the function. The 4807e4b17023SJohn Marinodefault is 0. 4808e4b17023SJohn Marino 4809e4b17023SJohn MarinoNote that this macro's value is relevant only for functions for which 4810e4b17023SJohn Marinoframe pointers are maintained. It is never safe to delete a final 4811e4b17023SJohn Marinostack adjustment in a function that has no frame pointer, and the 4812e4b17023SJohn Marinocompiler knows this regardless of @code{EXIT_IGNORE_STACK}. 4813e4b17023SJohn Marino@end defmac 4814e4b17023SJohn Marino 4815e4b17023SJohn Marino@defmac EPILOGUE_USES (@var{regno}) 4816e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero for registers that are 4817e4b17023SJohn Marinoused by the epilogue or the @samp{return} pattern. The stack and frame 4818e4b17023SJohn Marinopointer registers are already assumed to be used as needed. 4819e4b17023SJohn Marino@end defmac 4820e4b17023SJohn Marino 4821e4b17023SJohn Marino@defmac EH_USES (@var{regno}) 4822e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero for registers that are 4823e4b17023SJohn Marinoused by the exception handling mechanism, and so should be considered live 4824e4b17023SJohn Marinoon entry to an exception edge. 4825e4b17023SJohn Marino@end defmac 4826e4b17023SJohn Marino 4827e4b17023SJohn Marino@defmac DELAY_SLOTS_FOR_EPILOGUE 4828e4b17023SJohn MarinoDefine this macro if the function epilogue contains delay slots to which 4829e4b17023SJohn Marinoinstructions from the rest of the function can be ``moved''. The 4830e4b17023SJohn Marinodefinition should be a C expression whose value is an integer 4831e4b17023SJohn Marinorepresenting the number of delay slots there. 4832e4b17023SJohn Marino@end defmac 4833e4b17023SJohn Marino 4834e4b17023SJohn Marino@defmac ELIGIBLE_FOR_EPILOGUE_DELAY (@var{insn}, @var{n}) 4835e4b17023SJohn MarinoA C expression that returns 1 if @var{insn} can be placed in delay 4836e4b17023SJohn Marinoslot number @var{n} of the epilogue. 4837e4b17023SJohn Marino 4838e4b17023SJohn MarinoThe argument @var{n} is an integer which identifies the delay slot now 4839e4b17023SJohn Marinobeing considered (since different slots may have different rules of 4840e4b17023SJohn Marinoeligibility). It is never negative and is always less than the number 4841e4b17023SJohn Marinoof epilogue delay slots (what @code{DELAY_SLOTS_FOR_EPILOGUE} returns). 4842e4b17023SJohn MarinoIf you reject a particular insn for a given delay slot, in principle, it 4843e4b17023SJohn Marinomay be reconsidered for a subsequent delay slot. Also, other insns may 4844e4b17023SJohn Marino(at least in principle) be considered for the so far unfilled delay 4845e4b17023SJohn Marinoslot. 4846e4b17023SJohn Marino 4847e4b17023SJohn Marino@findex current_function_epilogue_delay_list 4848e4b17023SJohn Marino@findex final_scan_insn 4849e4b17023SJohn MarinoThe insns accepted to fill the epilogue delay slots are put in an RTL 4850e4b17023SJohn Marinolist made with @code{insn_list} objects, stored in the variable 4851e4b17023SJohn Marino@code{current_function_epilogue_delay_list}. The insn for the first 4852e4b17023SJohn Marinodelay slot comes first in the list. Your definition of the macro 4853e4b17023SJohn Marino@code{TARGET_ASM_FUNCTION_EPILOGUE} should fill the delay slots by 4854e4b17023SJohn Marinooutputting the insns in this list, usually by calling 4855e4b17023SJohn Marino@code{final_scan_insn}. 4856e4b17023SJohn Marino 4857e4b17023SJohn MarinoYou need not define this macro if you did not define 4858e4b17023SJohn Marino@code{DELAY_SLOTS_FOR_EPILOGUE}. 4859e4b17023SJohn Marino@end defmac 4860e4b17023SJohn Marino 4861e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_OUTPUT_MI_THUNK (FILE *@var{file}, tree @var{thunk_fndecl}, HOST_WIDE_INT @var{delta}, HOST_WIDE_INT @var{vcall_offset}, tree @var{function}) 4862e4b17023SJohn MarinoA function that outputs the assembler code for a thunk 4863e4b17023SJohn Marinofunction, used to implement C++ virtual function calls with multiple 4864e4b17023SJohn Marinoinheritance. The thunk acts as a wrapper around a virtual function, 4865e4b17023SJohn Marinoadjusting the implicit object parameter before handing control off to 4866e4b17023SJohn Marinothe real function. 4867e4b17023SJohn Marino 4868e4b17023SJohn MarinoFirst, emit code to add the integer @var{delta} to the location that 4869e4b17023SJohn Marinocontains the incoming first argument. Assume that this argument 4870e4b17023SJohn Marinocontains a pointer, and is the one used to pass the @code{this} pointer 4871e4b17023SJohn Marinoin C++. This is the incoming argument @emph{before} the function prologue, 4872e4b17023SJohn Marinoe.g.@: @samp{%o0} on a sparc. The addition must preserve the values of 4873e4b17023SJohn Marinoall other incoming arguments. 4874e4b17023SJohn Marino 4875e4b17023SJohn MarinoThen, if @var{vcall_offset} is nonzero, an additional adjustment should be 4876e4b17023SJohn Marinomade after adding @code{delta}. In particular, if @var{p} is the 4877e4b17023SJohn Marinoadjusted pointer, the following adjustment should be made: 4878e4b17023SJohn Marino 4879e4b17023SJohn Marino@smallexample 4880e4b17023SJohn Marinop += (*((ptrdiff_t **)p))[vcall_offset/sizeof(ptrdiff_t)] 4881e4b17023SJohn Marino@end smallexample 4882e4b17023SJohn Marino 4883e4b17023SJohn MarinoAfter the additions, emit code to jump to @var{function}, which is a 4884e4b17023SJohn Marino@code{FUNCTION_DECL}. This is a direct pure jump, not a call, and does 4885e4b17023SJohn Marinonot touch the return address. Hence returning from @var{FUNCTION} will 4886e4b17023SJohn Marinoreturn to whoever called the current @samp{thunk}. 4887e4b17023SJohn Marino 4888e4b17023SJohn MarinoThe effect must be as if @var{function} had been called directly with 4889e4b17023SJohn Marinothe adjusted first argument. This macro is responsible for emitting all 4890e4b17023SJohn Marinoof the code for a thunk function; @code{TARGET_ASM_FUNCTION_PROLOGUE} 4891e4b17023SJohn Marinoand @code{TARGET_ASM_FUNCTION_EPILOGUE} are not invoked. 4892e4b17023SJohn Marino 4893e4b17023SJohn MarinoThe @var{thunk_fndecl} is redundant. (@var{delta} and @var{function} 4894e4b17023SJohn Marinohave already been extracted from it.) It might possibly be useful on 4895e4b17023SJohn Marinosome targets, but probably not. 4896e4b17023SJohn Marino 4897e4b17023SJohn MarinoIf you do not define this macro, the target-independent code in the C++ 4898e4b17023SJohn Marinofront end will generate a less efficient heavyweight thunk that calls 4899e4b17023SJohn Marino@var{function} instead of jumping to it. The generic approach does 4900e4b17023SJohn Marinonot support varargs. 4901e4b17023SJohn Marino@end deftypefn 4902e4b17023SJohn Marino 4903e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ASM_CAN_OUTPUT_MI_THUNK (const_tree @var{thunk_fndecl}, HOST_WIDE_INT @var{delta}, HOST_WIDE_INT @var{vcall_offset}, const_tree @var{function}) 4904e4b17023SJohn MarinoA function that returns true if TARGET_ASM_OUTPUT_MI_THUNK would be able 4905e4b17023SJohn Marinoto output the assembler code for the thunk function specified by the 4906e4b17023SJohn Marinoarguments it is passed, and false otherwise. In the latter case, the 4907e4b17023SJohn Marinogeneric approach will be used by the C++ front end, with the limitations 4908e4b17023SJohn Marinopreviously exposed. 4909e4b17023SJohn Marino@end deftypefn 4910e4b17023SJohn Marino 4911e4b17023SJohn Marino@node Profiling 4912e4b17023SJohn Marino@subsection Generating Code for Profiling 4913e4b17023SJohn Marino@cindex profiling, code generation 4914e4b17023SJohn Marino 4915e4b17023SJohn MarinoThese macros will help you generate code for profiling. 4916e4b17023SJohn Marino 4917e4b17023SJohn Marino@defmac FUNCTION_PROFILER (@var{file}, @var{labelno}) 4918e4b17023SJohn MarinoA C statement or compound statement to output to @var{file} some 4919e4b17023SJohn Marinoassembler code to call the profiling subroutine @code{mcount}. 4920e4b17023SJohn Marino 4921e4b17023SJohn Marino@findex mcount 4922e4b17023SJohn MarinoThe details of how @code{mcount} expects to be called are determined by 4923e4b17023SJohn Marinoyour operating system environment, not by GCC@. To figure them out, 4924e4b17023SJohn Marinocompile a small program for profiling using the system's installed C 4925e4b17023SJohn Marinocompiler and look at the assembler code that results. 4926e4b17023SJohn Marino 4927e4b17023SJohn MarinoOlder implementations of @code{mcount} expect the address of a counter 4928e4b17023SJohn Marinovariable to be loaded into some register. The name of this variable is 4929e4b17023SJohn Marino@samp{LP} followed by the number @var{labelno}, so you would generate 4930e4b17023SJohn Marinothe name using @samp{LP%d} in a @code{fprintf}. 4931e4b17023SJohn Marino@end defmac 4932e4b17023SJohn Marino 4933e4b17023SJohn Marino@defmac PROFILE_HOOK 4934e4b17023SJohn MarinoA C statement or compound statement to output to @var{file} some assembly 4935e4b17023SJohn Marinocode to call the profiling subroutine @code{mcount} even the target does 4936e4b17023SJohn Marinonot support profiling. 4937e4b17023SJohn Marino@end defmac 4938e4b17023SJohn Marino 4939e4b17023SJohn Marino@defmac NO_PROFILE_COUNTERS 4940e4b17023SJohn MarinoDefine this macro to be an expression with a nonzero value if the 4941e4b17023SJohn Marino@code{mcount} subroutine on your system does not need a counter variable 4942e4b17023SJohn Marinoallocated for each function. This is true for almost all modern 4943e4b17023SJohn Marinoimplementations. If you define this macro, you must not use the 4944e4b17023SJohn Marino@var{labelno} argument to @code{FUNCTION_PROFILER}. 4945e4b17023SJohn Marino@end defmac 4946e4b17023SJohn Marino 4947e4b17023SJohn Marino@defmac PROFILE_BEFORE_PROLOGUE 4948e4b17023SJohn MarinoDefine this macro if the code for function profiling should come before 4949e4b17023SJohn Marinothe function prologue. Normally, the profiling code comes after. 4950e4b17023SJohn Marino@end defmac 4951e4b17023SJohn Marino 4952e4b17023SJohn Marino@node Tail Calls 4953e4b17023SJohn Marino@subsection Permitting tail calls 4954e4b17023SJohn Marino@cindex tail calls 4955e4b17023SJohn Marino 4956e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_FUNCTION_OK_FOR_SIBCALL (tree @var{decl}, tree @var{exp}) 4957e4b17023SJohn MarinoTrue if it is ok to do sibling call optimization for the specified 4958e4b17023SJohn Marinocall expression @var{exp}. @var{decl} will be the called function, 4959e4b17023SJohn Marinoor @code{NULL} if this is an indirect call. 4960e4b17023SJohn Marino 4961e4b17023SJohn MarinoIt is not uncommon for limitations of calling conventions to prevent 4962e4b17023SJohn Marinotail calls to functions outside the current unit of translation, or 4963e4b17023SJohn Marinoduring PIC compilation. The hook is used to enforce these restrictions, 4964e4b17023SJohn Marinoas the @code{sibcall} md pattern can not fail, or fall over to a 4965e4b17023SJohn Marino``normal'' call. The criteria for successful sibling call optimization 4966e4b17023SJohn Marinomay vary greatly between different architectures. 4967e4b17023SJohn Marino@end deftypefn 4968e4b17023SJohn Marino 4969e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_EXTRA_LIVE_ON_ENTRY (bitmap @var{regs}) 4970e4b17023SJohn MarinoAdd any hard registers to @var{regs} that are live on entry to the 4971e4b17023SJohn Marinofunction. This hook only needs to be defined to provide registers that 4972e4b17023SJohn Marinocannot be found by examination of FUNCTION_ARG_REGNO_P, the callee saved 4973e4b17023SJohn Marinoregisters, STATIC_CHAIN_INCOMING_REGNUM, STATIC_CHAIN_REGNUM, 4974e4b17023SJohn MarinoTARGET_STRUCT_VALUE_RTX, FRAME_POINTER_REGNUM, EH_USES, 4975e4b17023SJohn MarinoFRAME_POINTER_REGNUM, ARG_POINTER_REGNUM, and the PIC_OFFSET_TABLE_REGNUM. 4976e4b17023SJohn Marino@end deftypefn 4977e4b17023SJohn Marino 4978e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SET_UP_BY_PROLOGUE (struct hard_reg_set_container *@var{}) 4979e4b17023SJohn MarinoThis hook should add additional registers that are computed by the prologue to the hard regset for shrink-wrapping optimization purposes. 4980e4b17023SJohn Marino@end deftypefn 4981e4b17023SJohn Marino 4982e4b17023SJohn Marino@node Stack Smashing Protection 4983e4b17023SJohn Marino@subsection Stack smashing protection 4984e4b17023SJohn Marino@cindex stack smashing protection 4985e4b17023SJohn Marino 4986e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_STACK_PROTECT_GUARD (void) 4987e4b17023SJohn MarinoThis hook returns a @code{DECL} node for the external variable to use 4988e4b17023SJohn Marinofor the stack protection guard. This variable is initialized by the 4989e4b17023SJohn Marinoruntime to some random value and is used to initialize the guard value 4990e4b17023SJohn Marinothat is placed at the top of the local stack frame. The type of this 4991e4b17023SJohn Marinovariable must be @code{ptr_type_node}. 4992e4b17023SJohn Marino 4993e4b17023SJohn MarinoThe default version of this hook creates a variable called 4994e4b17023SJohn Marino@samp{__stack_chk_guard}, which is normally defined in @file{libgcc2.c}. 4995e4b17023SJohn Marino@end deftypefn 4996e4b17023SJohn Marino 4997e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_STACK_PROTECT_FAIL (void) 4998e4b17023SJohn MarinoThis hook returns a tree expression that alerts the runtime that the 4999e4b17023SJohn Marinostack protect guard variable has been modified. This expression should 5000e4b17023SJohn Marinoinvolve a call to a @code{noreturn} function. 5001e4b17023SJohn Marino 5002e4b17023SJohn MarinoThe default version of this hook invokes a function called 5003e4b17023SJohn Marino@samp{__stack_chk_fail}, taking no arguments. This function is 5004e4b17023SJohn Marinonormally defined in @file{libgcc2.c}. 5005e4b17023SJohn Marino@end deftypefn 5006e4b17023SJohn Marino 5007e4b17023SJohn Marino@deftypefn {Common Target Hook} bool TARGET_SUPPORTS_SPLIT_STACK (bool @var{report}, struct gcc_options *@var{opts}) 5008e4b17023SJohn MarinoWhether this target supports splitting the stack when the options described in @var{opts} have been passed. This is called after options have been parsed, so the target may reject splitting the stack in some configurations. The default version of this hook returns false. If @var{report} is true, this function may issue a warning or error; if @var{report} is false, it must simply return a value 5009e4b17023SJohn Marino@end deftypefn 5010e4b17023SJohn Marino 5011e4b17023SJohn Marino@node Varargs 5012e4b17023SJohn Marino@section Implementing the Varargs Macros 5013e4b17023SJohn Marino@cindex varargs implementation 5014e4b17023SJohn Marino 5015e4b17023SJohn MarinoGCC comes with an implementation of @code{<varargs.h>} and 5016e4b17023SJohn Marino@code{<stdarg.h>} that work without change on machines that pass arguments 5017e4b17023SJohn Marinoon the stack. Other machines require their own implementations of 5018e4b17023SJohn Marinovarargs, and the two machine independent header files must have 5019e4b17023SJohn Marinoconditionals to include it. 5020e4b17023SJohn Marino 5021e4b17023SJohn MarinoISO @code{<stdarg.h>} differs from traditional @code{<varargs.h>} mainly in 5022e4b17023SJohn Marinothe calling convention for @code{va_start}. The traditional 5023e4b17023SJohn Marinoimplementation takes just one argument, which is the variable in which 5024e4b17023SJohn Marinoto store the argument pointer. The ISO implementation of 5025e4b17023SJohn Marino@code{va_start} takes an additional second argument. The user is 5026e4b17023SJohn Marinosupposed to write the last named argument of the function here. 5027e4b17023SJohn Marino 5028e4b17023SJohn MarinoHowever, @code{va_start} should not use this argument. The way to find 5029e4b17023SJohn Marinothe end of the named arguments is with the built-in functions described 5030e4b17023SJohn Marinobelow. 5031e4b17023SJohn Marino 5032e4b17023SJohn Marino@defmac __builtin_saveregs () 5033e4b17023SJohn MarinoUse this built-in function to save the argument registers in memory so 5034e4b17023SJohn Marinothat the varargs mechanism can access them. Both ISO and traditional 5035e4b17023SJohn Marinoversions of @code{va_start} must use @code{__builtin_saveregs}, unless 5036e4b17023SJohn Marinoyou use @code{TARGET_SETUP_INCOMING_VARARGS} (see below) instead. 5037e4b17023SJohn Marino 5038e4b17023SJohn MarinoOn some machines, @code{__builtin_saveregs} is open-coded under the 5039e4b17023SJohn Marinocontrol of the target hook @code{TARGET_EXPAND_BUILTIN_SAVEREGS}. On 5040e4b17023SJohn Marinoother machines, it calls a routine written in assembler language, 5041e4b17023SJohn Marinofound in @file{libgcc2.c}. 5042e4b17023SJohn Marino 5043e4b17023SJohn MarinoCode generated for the call to @code{__builtin_saveregs} appears at the 5044e4b17023SJohn Marinobeginning of the function, as opposed to where the call to 5045e4b17023SJohn Marino@code{__builtin_saveregs} is written, regardless of what the code is. 5046e4b17023SJohn MarinoThis is because the registers must be saved before the function starts 5047e4b17023SJohn Marinoto use them for its own purposes. 5048e4b17023SJohn Marino@c i rewrote the first sentence above to fix an overfull hbox. --mew 5049e4b17023SJohn Marino@c 10feb93 5050e4b17023SJohn Marino@end defmac 5051e4b17023SJohn Marino 5052e4b17023SJohn Marino@defmac __builtin_next_arg (@var{lastarg}) 5053e4b17023SJohn MarinoThis builtin returns the address of the first anonymous stack 5054e4b17023SJohn Marinoargument, as type @code{void *}. If @code{ARGS_GROW_DOWNWARD}, it 5055e4b17023SJohn Marinoreturns the address of the location above the first anonymous stack 5056e4b17023SJohn Marinoargument. Use it in @code{va_start} to initialize the pointer for 5057e4b17023SJohn Marinofetching arguments from the stack. Also use it in @code{va_start} to 5058e4b17023SJohn Marinoverify that the second parameter @var{lastarg} is the last named argument 5059e4b17023SJohn Marinoof the current function. 5060e4b17023SJohn Marino@end defmac 5061e4b17023SJohn Marino 5062e4b17023SJohn Marino@defmac __builtin_classify_type (@var{object}) 5063e4b17023SJohn MarinoSince each machine has its own conventions for which data types are 5064e4b17023SJohn Marinopassed in which kind of register, your implementation of @code{va_arg} 5065e4b17023SJohn Marinohas to embody these conventions. The easiest way to categorize the 5066e4b17023SJohn Marinospecified data type is to use @code{__builtin_classify_type} together 5067e4b17023SJohn Marinowith @code{sizeof} and @code{__alignof__}. 5068e4b17023SJohn Marino 5069e4b17023SJohn Marino@code{__builtin_classify_type} ignores the value of @var{object}, 5070e4b17023SJohn Marinoconsidering only its data type. It returns an integer describing what 5071e4b17023SJohn Marinokind of type that is---integer, floating, pointer, structure, and so on. 5072e4b17023SJohn Marino 5073e4b17023SJohn MarinoThe file @file{typeclass.h} defines an enumeration that you can use to 5074e4b17023SJohn Marinointerpret the values of @code{__builtin_classify_type}. 5075e4b17023SJohn Marino@end defmac 5076e4b17023SJohn Marino 5077e4b17023SJohn MarinoThese machine description macros help implement varargs: 5078e4b17023SJohn Marino 5079e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_EXPAND_BUILTIN_SAVEREGS (void) 5080e4b17023SJohn MarinoIf defined, this hook produces the machine-specific code for a call to 5081e4b17023SJohn Marino@code{__builtin_saveregs}. This code will be moved to the very 5082e4b17023SJohn Marinobeginning of the function, before any parameter access are made. The 5083e4b17023SJohn Marinoreturn value of this function should be an RTX that contains the value 5084e4b17023SJohn Marinoto use as the return of @code{__builtin_saveregs}. 5085e4b17023SJohn Marino@end deftypefn 5086e4b17023SJohn Marino 5087e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SETUP_INCOMING_VARARGS (cumulative_args_t @var{args_so_far}, enum machine_mode @var{mode}, tree @var{type}, int *@var{pretend_args_size}, int @var{second_time}) 5088e4b17023SJohn MarinoThis target hook offers an alternative to using 5089e4b17023SJohn Marino@code{__builtin_saveregs} and defining the hook 5090e4b17023SJohn Marino@code{TARGET_EXPAND_BUILTIN_SAVEREGS}. Use it to store the anonymous 5091e4b17023SJohn Marinoregister arguments into the stack so that all the arguments appear to 5092e4b17023SJohn Marinohave been passed consecutively on the stack. Once this is done, you can 5093e4b17023SJohn Marinouse the standard implementation of varargs that works for machines that 5094e4b17023SJohn Marinopass all their arguments on the stack. 5095e4b17023SJohn Marino 5096e4b17023SJohn MarinoThe argument @var{args_so_far} points to the @code{CUMULATIVE_ARGS} data 5097e4b17023SJohn Marinostructure, containing the values that are obtained after processing the 5098e4b17023SJohn Marinonamed arguments. The arguments @var{mode} and @var{type} describe the 5099e4b17023SJohn Marinolast named argument---its machine mode and its data type as a tree node. 5100e4b17023SJohn Marino 5101e4b17023SJohn MarinoThe target hook should do two things: first, push onto the stack all the 5102e4b17023SJohn Marinoargument registers @emph{not} used for the named arguments, and second, 5103e4b17023SJohn Marinostore the size of the data thus pushed into the @code{int}-valued 5104e4b17023SJohn Marinovariable pointed to by @var{pretend_args_size}. The value that you 5105e4b17023SJohn Marinostore here will serve as additional offset for setting up the stack 5106e4b17023SJohn Marinoframe. 5107e4b17023SJohn Marino 5108e4b17023SJohn MarinoBecause you must generate code to push the anonymous arguments at 5109e4b17023SJohn Marinocompile time without knowing their data types, 5110e4b17023SJohn Marino@code{TARGET_SETUP_INCOMING_VARARGS} is only useful on machines that 5111e4b17023SJohn Marinohave just a single category of argument register and use it uniformly 5112e4b17023SJohn Marinofor all data types. 5113e4b17023SJohn Marino 5114e4b17023SJohn MarinoIf the argument @var{second_time} is nonzero, it means that the 5115e4b17023SJohn Marinoarguments of the function are being analyzed for the second time. This 5116e4b17023SJohn Marinohappens for an inline function, which is not actually compiled until the 5117e4b17023SJohn Marinoend of the source file. The hook @code{TARGET_SETUP_INCOMING_VARARGS} should 5118e4b17023SJohn Marinonot generate any instructions in this case. 5119e4b17023SJohn Marino@end deftypefn 5120e4b17023SJohn Marino 5121e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_STRICT_ARGUMENT_NAMING (cumulative_args_t @var{ca}) 5122e4b17023SJohn MarinoDefine this hook to return @code{true} if the location where a function 5123e4b17023SJohn Marinoargument is passed depends on whether or not it is a named argument. 5124e4b17023SJohn Marino 5125e4b17023SJohn MarinoThis hook controls how the @var{named} argument to @code{TARGET_FUNCTION_ARG} 5126e4b17023SJohn Marinois set for varargs and stdarg functions. If this hook returns 5127e4b17023SJohn Marino@code{true}, the @var{named} argument is always true for named 5128e4b17023SJohn Marinoarguments, and false for unnamed arguments. If it returns @code{false}, 5129e4b17023SJohn Marinobut @code{TARGET_PRETEND_OUTGOING_VARARGS_NAMED} returns @code{true}, 5130e4b17023SJohn Marinothen all arguments are treated as named. Otherwise, all named arguments 5131e4b17023SJohn Marinoexcept the last are treated as named. 5132e4b17023SJohn Marino 5133e4b17023SJohn MarinoYou need not define this hook if it always returns @code{false}. 5134e4b17023SJohn Marino@end deftypefn 5135e4b17023SJohn Marino 5136e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_PRETEND_OUTGOING_VARARGS_NAMED (cumulative_args_t @var{ca}) 5137e4b17023SJohn MarinoIf you need to conditionally change ABIs so that one works with 5138e4b17023SJohn Marino@code{TARGET_SETUP_INCOMING_VARARGS}, but the other works like neither 5139e4b17023SJohn Marino@code{TARGET_SETUP_INCOMING_VARARGS} nor @code{TARGET_STRICT_ARGUMENT_NAMING} was 5140e4b17023SJohn Marinodefined, then define this hook to return @code{true} if 5141e4b17023SJohn Marino@code{TARGET_SETUP_INCOMING_VARARGS} is used, @code{false} otherwise. 5142e4b17023SJohn MarinoOtherwise, you should not define this hook. 5143e4b17023SJohn Marino@end deftypefn 5144e4b17023SJohn Marino 5145e4b17023SJohn Marino@node Trampolines 5146e4b17023SJohn Marino@section Trampolines for Nested Functions 5147e4b17023SJohn Marino@cindex trampolines for nested functions 5148e4b17023SJohn Marino@cindex nested functions, trampolines for 5149e4b17023SJohn Marino 5150e4b17023SJohn MarinoA @dfn{trampoline} is a small piece of code that is created at run time 5151e4b17023SJohn Marinowhen the address of a nested function is taken. It normally resides on 5152e4b17023SJohn Marinothe stack, in the stack frame of the containing function. These macros 5153e4b17023SJohn Marinotell GCC how to generate code to allocate and initialize a 5154e4b17023SJohn Marinotrampoline. 5155e4b17023SJohn Marino 5156e4b17023SJohn MarinoThe instructions in the trampoline must do two things: load a constant 5157e4b17023SJohn Marinoaddress into the static chain register, and jump to the real address of 5158e4b17023SJohn Marinothe nested function. On CISC machines such as the m68k, this requires 5159e4b17023SJohn Marinotwo instructions, a move immediate and a jump. Then the two addresses 5160e4b17023SJohn Marinoexist in the trampoline as word-long immediate operands. On RISC 5161e4b17023SJohn Marinomachines, it is often necessary to load each address into a register in 5162e4b17023SJohn Marinotwo parts. Then pieces of each address form separate immediate 5163e4b17023SJohn Marinooperands. 5164e4b17023SJohn Marino 5165e4b17023SJohn MarinoThe code generated to initialize the trampoline must store the variable 5166e4b17023SJohn Marinoparts---the static chain value and the function address---into the 5167e4b17023SJohn Marinoimmediate operands of the instructions. On a CISC machine, this is 5168e4b17023SJohn Marinosimply a matter of copying each address to a memory reference at the 5169e4b17023SJohn Marinoproper offset from the start of the trampoline. On a RISC machine, it 5170e4b17023SJohn Marinomay be necessary to take out pieces of the address and store them 5171e4b17023SJohn Marinoseparately. 5172e4b17023SJohn Marino 5173e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_TRAMPOLINE_TEMPLATE (FILE *@var{f}) 5174e4b17023SJohn MarinoThis hook is called by @code{assemble_trampoline_template} to output, 5175e4b17023SJohn Marinoon the stream @var{f}, assembler code for a block of data that contains 5176e4b17023SJohn Marinothe constant parts of a trampoline. This code should not include a 5177e4b17023SJohn Marinolabel---the label is taken care of automatically. 5178e4b17023SJohn Marino 5179e4b17023SJohn MarinoIf you do not define this hook, it means no template is needed 5180e4b17023SJohn Marinofor the target. Do not define this hook on systems where the block move 5181e4b17023SJohn Marinocode to copy the trampoline into place would be larger than the code 5182e4b17023SJohn Marinoto generate it on the spot. 5183e4b17023SJohn Marino@end deftypefn 5184e4b17023SJohn Marino 5185e4b17023SJohn Marino@defmac TRAMPOLINE_SECTION 5186e4b17023SJohn MarinoReturn the section into which the trampoline template is to be placed 5187e4b17023SJohn Marino(@pxref{Sections}). The default value is @code{readonly_data_section}. 5188e4b17023SJohn Marino@end defmac 5189e4b17023SJohn Marino 5190e4b17023SJohn Marino@defmac TRAMPOLINE_SIZE 5191e4b17023SJohn MarinoA C expression for the size in bytes of the trampoline, as an integer. 5192e4b17023SJohn Marino@end defmac 5193e4b17023SJohn Marino 5194e4b17023SJohn Marino@defmac TRAMPOLINE_ALIGNMENT 5195e4b17023SJohn MarinoAlignment required for trampolines, in bits. 5196e4b17023SJohn Marino 5197e4b17023SJohn MarinoIf you don't define this macro, the value of @code{FUNCTION_ALIGNMENT} 5198e4b17023SJohn Marinois used for aligning trampolines. 5199e4b17023SJohn Marino@end defmac 5200e4b17023SJohn Marino 5201e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_TRAMPOLINE_INIT (rtx @var{m_tramp}, tree @var{fndecl}, rtx @var{static_chain}) 5202e4b17023SJohn MarinoThis hook is called to initialize a trampoline. 5203e4b17023SJohn Marino@var{m_tramp} is an RTX for the memory block for the trampoline; @var{fndecl} 5204e4b17023SJohn Marinois the @code{FUNCTION_DECL} for the nested function; @var{static_chain} is an 5205e4b17023SJohn MarinoRTX for the static chain value that should be passed to the function 5206e4b17023SJohn Marinowhen it is called. 5207e4b17023SJohn Marino 5208e4b17023SJohn MarinoIf the target defines @code{TARGET_ASM_TRAMPOLINE_TEMPLATE}, then the 5209e4b17023SJohn Marinofirst thing this hook should do is emit a block move into @var{m_tramp} 5210e4b17023SJohn Marinofrom the memory block returned by @code{assemble_trampoline_template}. 5211e4b17023SJohn MarinoNote that the block move need only cover the constant parts of the 5212e4b17023SJohn Marinotrampoline. If the target isolates the variable parts of the trampoline 5213e4b17023SJohn Marinoto the end, not all @code{TRAMPOLINE_SIZE} bytes need be copied. 5214e4b17023SJohn Marino 5215e4b17023SJohn MarinoIf the target requires any other actions, such as flushing caches or 5216e4b17023SJohn Marinoenabling stack execution, these actions should be performed after 5217e4b17023SJohn Marinoinitializing the trampoline proper. 5218e4b17023SJohn Marino@end deftypefn 5219e4b17023SJohn Marino 5220e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_TRAMPOLINE_ADJUST_ADDRESS (rtx @var{addr}) 5221e4b17023SJohn MarinoThis hook should perform any machine-specific adjustment in 5222e4b17023SJohn Marinothe address of the trampoline. Its argument contains the address of the 5223e4b17023SJohn Marinomemory block that was passed to @code{TARGET_TRAMPOLINE_INIT}. In case 5224e4b17023SJohn Marinothe address to be used for a function call should be different from the 5225e4b17023SJohn Marinoaddress at which the template was stored, the different address should 5226e4b17023SJohn Marinobe returned; otherwise @var{addr} should be returned unchanged. 5227e4b17023SJohn MarinoIf this hook is not defined, @var{addr} will be used for function calls. 5228e4b17023SJohn Marino@end deftypefn 5229e4b17023SJohn Marino 5230e4b17023SJohn MarinoImplementing trampolines is difficult on many machines because they have 5231e4b17023SJohn Marinoseparate instruction and data caches. Writing into a stack location 5232e4b17023SJohn Marinofails to clear the memory in the instruction cache, so when the program 5233e4b17023SJohn Marinojumps to that location, it executes the old contents. 5234e4b17023SJohn Marino 5235e4b17023SJohn MarinoHere are two possible solutions. One is to clear the relevant parts of 5236e4b17023SJohn Marinothe instruction cache whenever a trampoline is set up. The other is to 5237e4b17023SJohn Marinomake all trampolines identical, by having them jump to a standard 5238e4b17023SJohn Marinosubroutine. The former technique makes trampoline execution faster; the 5239e4b17023SJohn Marinolatter makes initialization faster. 5240e4b17023SJohn Marino 5241e4b17023SJohn MarinoTo clear the instruction cache when a trampoline is initialized, define 5242e4b17023SJohn Marinothe following macro. 5243e4b17023SJohn Marino 5244e4b17023SJohn Marino@defmac CLEAR_INSN_CACHE (@var{beg}, @var{end}) 5245e4b17023SJohn MarinoIf defined, expands to a C expression clearing the @emph{instruction 5246e4b17023SJohn Marinocache} in the specified interval. The definition of this macro would 5247e4b17023SJohn Marinotypically be a series of @code{asm} statements. Both @var{beg} and 5248e4b17023SJohn Marino@var{end} are both pointer expressions. 5249e4b17023SJohn Marino@end defmac 5250e4b17023SJohn Marino 5251e4b17023SJohn MarinoTo use a standard subroutine, define the following macro. In addition, 5252e4b17023SJohn Marinoyou must make sure that the instructions in a trampoline fill an entire 5253e4b17023SJohn Marinocache line with identical instructions, or else ensure that the 5254e4b17023SJohn Marinobeginning of the trampoline code is always aligned at the same point in 5255e4b17023SJohn Marinoits cache line. Look in @file{m68k.h} as a guide. 5256e4b17023SJohn Marino 5257e4b17023SJohn Marino@defmac TRANSFER_FROM_TRAMPOLINE 5258e4b17023SJohn MarinoDefine this macro if trampolines need a special subroutine to do their 5259e4b17023SJohn Marinowork. The macro should expand to a series of @code{asm} statements 5260e4b17023SJohn Marinowhich will be compiled with GCC@. They go in a library function named 5261e4b17023SJohn Marino@code{__transfer_from_trampoline}. 5262e4b17023SJohn Marino 5263e4b17023SJohn MarinoIf you need to avoid executing the ordinary prologue code of a compiled 5264e4b17023SJohn MarinoC function when you jump to the subroutine, you can do so by placing a 5265e4b17023SJohn Marinospecial label of your own in the assembler code. Use one @code{asm} 5266e4b17023SJohn Marinostatement to generate an assembler label, and another to make the label 5267e4b17023SJohn Marinoglobal. Then trampolines can use that label to jump directly to your 5268e4b17023SJohn Marinospecial assembler code. 5269e4b17023SJohn Marino@end defmac 5270e4b17023SJohn Marino 5271e4b17023SJohn Marino@node Library Calls 5272e4b17023SJohn Marino@section Implicit Calls to Library Routines 5273e4b17023SJohn Marino@cindex library subroutine names 5274e4b17023SJohn Marino@cindex @file{libgcc.a} 5275e4b17023SJohn Marino 5276e4b17023SJohn Marino@c prevent bad page break with this line 5277e4b17023SJohn MarinoHere is an explanation of implicit calls to library routines. 5278e4b17023SJohn Marino 5279e4b17023SJohn Marino@defmac DECLARE_LIBRARY_RENAMES 5280e4b17023SJohn MarinoThis macro, if defined, should expand to a piece of C code that will get 5281e4b17023SJohn Marinoexpanded when compiling functions for libgcc.a. It can be used to 5282e4b17023SJohn Marinoprovide alternate names for GCC's internal library functions if there 5283e4b17023SJohn Marinoare ABI-mandated names that the compiler should provide. 5284e4b17023SJohn Marino@end defmac 5285e4b17023SJohn Marino 5286e4b17023SJohn Marino@findex set_optab_libfunc 5287e4b17023SJohn Marino@findex init_one_libfunc 5288e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_INIT_LIBFUNCS (void) 5289e4b17023SJohn MarinoThis hook should declare additional library routines or rename 5290e4b17023SJohn Marinoexisting ones, using the functions @code{set_optab_libfunc} and 5291e4b17023SJohn Marino@code{init_one_libfunc} defined in @file{optabs.c}. 5292e4b17023SJohn Marino@code{init_optabs} calls this macro after initializing all the normal 5293e4b17023SJohn Marinolibrary routines. 5294e4b17023SJohn Marino 5295e4b17023SJohn MarinoThe default is to do nothing. Most ports don't need to define this hook. 5296e4b17023SJohn Marino@end deftypefn 5297e4b17023SJohn Marino 5298e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_LIBFUNC_GNU_PREFIX 5299e4b17023SJohn MarinoIf false (the default), internal library routines start with two 5300e4b17023SJohn Marinounderscores. If set to true, these routines start with @code{__gnu_} 5301e4b17023SJohn Marinoinstead. E.g., @code{__muldi3} changes to @code{__gnu_muldi3}. This 5302e4b17023SJohn Marinocurrently only affects functions defined in @file{libgcc2.c}. If this 5303e4b17023SJohn Marinois set to true, the @file{tm.h} file must also 5304e4b17023SJohn Marino@code{#define LIBGCC2_GNU_PREFIX}. 5305e4b17023SJohn Marino@end deftypevr 5306e4b17023SJohn Marino 5307e4b17023SJohn Marino@defmac FLOAT_LIB_COMPARE_RETURNS_BOOL (@var{mode}, @var{comparison}) 5308e4b17023SJohn MarinoThis macro should return @code{true} if the library routine that 5309e4b17023SJohn Marinoimplements the floating point comparison operator @var{comparison} in 5310e4b17023SJohn Marinomode @var{mode} will return a boolean, and @var{false} if it will 5311e4b17023SJohn Marinoreturn a tristate. 5312e4b17023SJohn Marino 5313e4b17023SJohn MarinoGCC's own floating point libraries return tristates from the 5314e4b17023SJohn Marinocomparison operators, so the default returns false always. Most ports 5315e4b17023SJohn Marinodon't need to define this macro. 5316e4b17023SJohn Marino@end defmac 5317e4b17023SJohn Marino 5318e4b17023SJohn Marino@defmac TARGET_LIB_INT_CMP_BIASED 5319e4b17023SJohn MarinoThis macro should evaluate to @code{true} if the integer comparison 5320e4b17023SJohn Marinofunctions (like @code{__cmpdi2}) return 0 to indicate that the first 5321e4b17023SJohn Marinooperand is smaller than the second, 1 to indicate that they are equal, 5322e4b17023SJohn Marinoand 2 to indicate that the first operand is greater than the second. 5323e4b17023SJohn MarinoIf this macro evaluates to @code{false} the comparison functions return 5324e4b17023SJohn Marino@minus{}1, 0, and 1 instead of 0, 1, and 2. If the target uses the routines 5325e4b17023SJohn Marinoin @file{libgcc.a}, you do not need to define this macro. 5326e4b17023SJohn Marino@end defmac 5327e4b17023SJohn Marino 5328e4b17023SJohn Marino@cindex @code{EDOM}, implicit usage 5329e4b17023SJohn Marino@findex matherr 5330e4b17023SJohn Marino@defmac TARGET_EDOM 5331e4b17023SJohn MarinoThe value of @code{EDOM} on the target machine, as a C integer constant 5332e4b17023SJohn Marinoexpression. If you don't define this macro, GCC does not attempt to 5333e4b17023SJohn Marinodeposit the value of @code{EDOM} into @code{errno} directly. Look in 5334e4b17023SJohn Marino@file{/usr/include/errno.h} to find the value of @code{EDOM} on your 5335e4b17023SJohn Marinosystem. 5336e4b17023SJohn Marino 5337e4b17023SJohn MarinoIf you do not define @code{TARGET_EDOM}, then compiled code reports 5338e4b17023SJohn Marinodomain errors by calling the library function and letting it report the 5339e4b17023SJohn Marinoerror. If mathematical functions on your system use @code{matherr} when 5340e4b17023SJohn Marinothere is an error, then you should leave @code{TARGET_EDOM} undefined so 5341e4b17023SJohn Marinothat @code{matherr} is used normally. 5342e4b17023SJohn Marino@end defmac 5343e4b17023SJohn Marino 5344e4b17023SJohn Marino@cindex @code{errno}, implicit usage 5345e4b17023SJohn Marino@defmac GEN_ERRNO_RTX 5346e4b17023SJohn MarinoDefine this macro as a C expression to create an rtl expression that 5347e4b17023SJohn Marinorefers to the global ``variable'' @code{errno}. (On certain systems, 5348e4b17023SJohn Marino@code{errno} may not actually be a variable.) If you don't define this 5349e4b17023SJohn Marinomacro, a reasonable default is used. 5350e4b17023SJohn Marino@end defmac 5351e4b17023SJohn Marino 5352e4b17023SJohn Marino@cindex C99 math functions, implicit usage 5353e4b17023SJohn Marino@defmac TARGET_C99_FUNCTIONS 5354e4b17023SJohn MarinoWhen this macro is nonzero, GCC will implicitly optimize @code{sin} calls into 5355e4b17023SJohn Marino@code{sinf} and similarly for other functions defined by C99 standard. The 5356e4b17023SJohn Marinodefault is zero because a number of existing systems lack support for these 5357e4b17023SJohn Marinofunctions in their runtime so this macro needs to be redefined to one on 5358e4b17023SJohn Marinosystems that do support the C99 runtime. 5359e4b17023SJohn Marino@end defmac 5360e4b17023SJohn Marino 5361e4b17023SJohn Marino@cindex sincos math function, implicit usage 5362e4b17023SJohn Marino@defmac TARGET_HAS_SINCOS 5363e4b17023SJohn MarinoWhen this macro is nonzero, GCC will implicitly optimize calls to @code{sin} 5364e4b17023SJohn Marinoand @code{cos} with the same argument to a call to @code{sincos}. The 5365e4b17023SJohn Marinodefault is zero. The target has to provide the following functions: 5366e4b17023SJohn Marino@smallexample 5367e4b17023SJohn Marinovoid sincos(double x, double *sin, double *cos); 5368e4b17023SJohn Marinovoid sincosf(float x, float *sin, float *cos); 5369e4b17023SJohn Marinovoid sincosl(long double x, long double *sin, long double *cos); 5370e4b17023SJohn Marino@end smallexample 5371e4b17023SJohn Marino@end defmac 5372e4b17023SJohn Marino 5373e4b17023SJohn Marino@defmac NEXT_OBJC_RUNTIME 5374e4b17023SJohn MarinoSet this macro to 1 to use the "NeXT" Objective-C message sending conventions 5375e4b17023SJohn Marinoby default. This calling convention involves passing the object, the selector 5376e4b17023SJohn Marinoand the method arguments all at once to the method-lookup library function. 5377e4b17023SJohn MarinoThis is the usual setting when targeting Darwin/Mac OS X systems, which have 5378e4b17023SJohn Marinothe NeXT runtime installed. 5379e4b17023SJohn Marino 5380e4b17023SJohn MarinoIf the macro is set to 0, the "GNU" Objective-C message sending convention 5381e4b17023SJohn Marinowill be used by default. This convention passes just the object and the 5382e4b17023SJohn Marinoselector to the method-lookup function, which returns a pointer to the method. 5383e4b17023SJohn Marino 5384e4b17023SJohn MarinoIn either case, it remains possible to select code-generation for the alternate 5385e4b17023SJohn Marinoscheme, by means of compiler command line switches. 5386e4b17023SJohn Marino@end defmac 5387e4b17023SJohn Marino 5388e4b17023SJohn Marino@node Addressing Modes 5389e4b17023SJohn Marino@section Addressing Modes 5390e4b17023SJohn Marino@cindex addressing modes 5391e4b17023SJohn Marino 5392e4b17023SJohn Marino@c prevent bad page break with this line 5393e4b17023SJohn MarinoThis is about addressing modes. 5394e4b17023SJohn Marino 5395e4b17023SJohn Marino@defmac HAVE_PRE_INCREMENT 5396e4b17023SJohn Marino@defmacx HAVE_PRE_DECREMENT 5397e4b17023SJohn Marino@defmacx HAVE_POST_INCREMENT 5398e4b17023SJohn Marino@defmacx HAVE_POST_DECREMENT 5399e4b17023SJohn MarinoA C expression that is nonzero if the machine supports pre-increment, 5400e4b17023SJohn Marinopre-decrement, post-increment, or post-decrement addressing respectively. 5401e4b17023SJohn Marino@end defmac 5402e4b17023SJohn Marino 5403e4b17023SJohn Marino@defmac HAVE_PRE_MODIFY_DISP 5404e4b17023SJohn Marino@defmacx HAVE_POST_MODIFY_DISP 5405e4b17023SJohn MarinoA C expression that is nonzero if the machine supports pre- or 5406e4b17023SJohn Marinopost-address side-effect generation involving constants other than 5407e4b17023SJohn Marinothe size of the memory operand. 5408e4b17023SJohn Marino@end defmac 5409e4b17023SJohn Marino 5410e4b17023SJohn Marino@defmac HAVE_PRE_MODIFY_REG 5411e4b17023SJohn Marino@defmacx HAVE_POST_MODIFY_REG 5412e4b17023SJohn MarinoA C expression that is nonzero if the machine supports pre- or 5413e4b17023SJohn Marinopost-address side-effect generation involving a register displacement. 5414e4b17023SJohn Marino@end defmac 5415e4b17023SJohn Marino 5416e4b17023SJohn Marino@defmac CONSTANT_ADDRESS_P (@var{x}) 5417e4b17023SJohn MarinoA C expression that is 1 if the RTX @var{x} is a constant which 5418e4b17023SJohn Marinois a valid address. On most machines the default definition of 5419e4b17023SJohn Marino@code{(CONSTANT_P (@var{x}) && GET_CODE (@var{x}) != CONST_DOUBLE)} 5420e4b17023SJohn Marinois acceptable, but a few machines are more restrictive as to which 5421e4b17023SJohn Marinoconstant addresses are supported. 5422e4b17023SJohn Marino@end defmac 5423e4b17023SJohn Marino 5424e4b17023SJohn Marino@defmac CONSTANT_P (@var{x}) 5425e4b17023SJohn Marino@code{CONSTANT_P}, which is defined by target-independent code, 5426e4b17023SJohn Marinoaccepts integer-values expressions whose values are not explicitly 5427e4b17023SJohn Marinoknown, such as @code{symbol_ref}, @code{label_ref}, and @code{high} 5428e4b17023SJohn Marinoexpressions and @code{const} arithmetic expressions, in addition to 5429e4b17023SJohn Marino@code{const_int} and @code{const_double} expressions. 5430e4b17023SJohn Marino@end defmac 5431e4b17023SJohn Marino 5432e4b17023SJohn Marino@defmac MAX_REGS_PER_ADDRESS 5433e4b17023SJohn MarinoA number, the maximum number of registers that can appear in a valid 5434e4b17023SJohn Marinomemory address. Note that it is up to you to specify a value equal to 5435e4b17023SJohn Marinothe maximum number that @code{TARGET_LEGITIMATE_ADDRESS_P} would ever 5436e4b17023SJohn Marinoaccept. 5437e4b17023SJohn Marino@end defmac 5438e4b17023SJohn Marino 5439e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_LEGITIMATE_ADDRESS_P (enum machine_mode @var{mode}, rtx @var{x}, bool @var{strict}) 5440e4b17023SJohn MarinoA function that returns whether @var{x} (an RTX) is a legitimate memory 5441e4b17023SJohn Marinoaddress on the target machine for a memory operand of mode @var{mode}. 5442e4b17023SJohn Marino 5443e4b17023SJohn MarinoLegitimate addresses are defined in two variants: a strict variant and a 5444e4b17023SJohn Marinonon-strict one. The @var{strict} parameter chooses which variant is 5445e4b17023SJohn Marinodesired by the caller. 5446e4b17023SJohn Marino 5447e4b17023SJohn MarinoThe strict variant is used in the reload pass. It must be defined so 5448e4b17023SJohn Marinothat any pseudo-register that has not been allocated a hard register is 5449e4b17023SJohn Marinoconsidered a memory reference. This is because in contexts where some 5450e4b17023SJohn Marinokind of register is required, a pseudo-register with no hard register 5451e4b17023SJohn Marinomust be rejected. For non-hard registers, the strict variant should look 5452e4b17023SJohn Marinoup the @code{reg_renumber} array; it should then proceed using the hard 5453e4b17023SJohn Marinoregister number in the array, or treat the pseudo as a memory reference 5454e4b17023SJohn Marinoif the array holds @code{-1}. 5455e4b17023SJohn Marino 5456e4b17023SJohn MarinoThe non-strict variant is used in other passes. It must be defined to 5457e4b17023SJohn Marinoaccept all pseudo-registers in every context where some kind of 5458e4b17023SJohn Marinoregister is required. 5459e4b17023SJohn Marino 5460e4b17023SJohn MarinoNormally, constant addresses which are the sum of a @code{symbol_ref} 5461e4b17023SJohn Marinoand an integer are stored inside a @code{const} RTX to mark them as 5462e4b17023SJohn Marinoconstant. Therefore, there is no need to recognize such sums 5463e4b17023SJohn Marinospecifically as legitimate addresses. Normally you would simply 5464e4b17023SJohn Marinorecognize any @code{const} as legitimate. 5465e4b17023SJohn Marino 5466e4b17023SJohn MarinoUsually @code{PRINT_OPERAND_ADDRESS} is not prepared to handle constant 5467e4b17023SJohn Marinosums that are not marked with @code{const}. It assumes that a naked 5468e4b17023SJohn Marino@code{plus} indicates indexing. If so, then you @emph{must} reject such 5469e4b17023SJohn Marinonaked constant sums as illegitimate addresses, so that none of them will 5470e4b17023SJohn Marinobe given to @code{PRINT_OPERAND_ADDRESS}. 5471e4b17023SJohn Marino 5472e4b17023SJohn Marino@cindex @code{TARGET_ENCODE_SECTION_INFO} and address validation 5473e4b17023SJohn MarinoOn some machines, whether a symbolic address is legitimate depends on 5474e4b17023SJohn Marinothe section that the address refers to. On these machines, define the 5475e4b17023SJohn Marinotarget hook @code{TARGET_ENCODE_SECTION_INFO} to store the information 5476e4b17023SJohn Marinointo the @code{symbol_ref}, and then check for it here. When you see a 5477e4b17023SJohn Marino@code{const}, you will have to look inside it to find the 5478e4b17023SJohn Marino@code{symbol_ref} in order to determine the section. @xref{Assembler 5479e4b17023SJohn MarinoFormat}. 5480e4b17023SJohn Marino 5481e4b17023SJohn Marino@cindex @code{GO_IF_LEGITIMATE_ADDRESS} 5482e4b17023SJohn MarinoSome ports are still using a deprecated legacy substitute for 5483e4b17023SJohn Marinothis hook, the @code{GO_IF_LEGITIMATE_ADDRESS} macro. This macro 5484e4b17023SJohn Marinohas this syntax: 5485e4b17023SJohn Marino 5486e4b17023SJohn Marino@example 5487e4b17023SJohn Marino#define GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label}) 5488e4b17023SJohn Marino@end example 5489e4b17023SJohn Marino 5490e4b17023SJohn Marino@noindent 5491e4b17023SJohn Marinoand should @code{goto @var{label}} if the address @var{x} is a valid 5492e4b17023SJohn Marinoaddress on the target machine for a memory operand of mode @var{mode}. 5493e4b17023SJohn Marino 5494e4b17023SJohn Marino@findex REG_OK_STRICT 5495e4b17023SJohn MarinoCompiler source files that want to use the strict variant of this 5496e4b17023SJohn Marinomacro define the macro @code{REG_OK_STRICT}. You should use an 5497e4b17023SJohn Marino@code{#ifdef REG_OK_STRICT} conditional to define the strict variant in 5498e4b17023SJohn Marinothat case and the non-strict variant otherwise. 5499e4b17023SJohn Marino 5500e4b17023SJohn MarinoUsing the hook is usually simpler because it limits the number of 5501e4b17023SJohn Marinofiles that are recompiled when changes are made. 5502e4b17023SJohn Marino@end deftypefn 5503e4b17023SJohn Marino 5504e4b17023SJohn Marino@defmac TARGET_MEM_CONSTRAINT 5505e4b17023SJohn MarinoA single character to be used instead of the default @code{'m'} 5506e4b17023SJohn Marinocharacter for general memory addresses. This defines the constraint 5507e4b17023SJohn Marinoletter which matches the memory addresses accepted by 5508e4b17023SJohn Marino@code{TARGET_LEGITIMATE_ADDRESS_P}. Define this macro if you want to 5509e4b17023SJohn Marinosupport new address formats in your back end without changing the 5510e4b17023SJohn Marinosemantics of the @code{'m'} constraint. This is necessary in order to 5511e4b17023SJohn Marinopreserve functionality of inline assembly constructs using the 5512e4b17023SJohn Marino@code{'m'} constraint. 5513e4b17023SJohn Marino@end defmac 5514e4b17023SJohn Marino 5515e4b17023SJohn Marino@defmac FIND_BASE_TERM (@var{x}) 5516e4b17023SJohn MarinoA C expression to determine the base term of address @var{x}, 5517e4b17023SJohn Marinoor to provide a simplified version of @var{x} from which @file{alias.c} 5518e4b17023SJohn Marinocan easily find the base term. This macro is used in only two places: 5519e4b17023SJohn Marino@code{find_base_value} and @code{find_base_term} in @file{alias.c}. 5520e4b17023SJohn Marino 5521e4b17023SJohn MarinoIt is always safe for this macro to not be defined. It exists so 5522e4b17023SJohn Marinothat alias analysis can understand machine-dependent addresses. 5523e4b17023SJohn Marino 5524e4b17023SJohn MarinoThe typical use of this macro is to handle addresses containing 5525e4b17023SJohn Marinoa label_ref or symbol_ref within an UNSPEC@. 5526e4b17023SJohn Marino@end defmac 5527e4b17023SJohn Marino 5528e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_LEGITIMIZE_ADDRESS (rtx @var{x}, rtx @var{oldx}, enum machine_mode @var{mode}) 5529e4b17023SJohn MarinoThis hook is given an invalid memory address @var{x} for an 5530e4b17023SJohn Marinooperand of mode @var{mode} and should try to return a valid memory 5531e4b17023SJohn Marinoaddress. 5532e4b17023SJohn Marino 5533e4b17023SJohn Marino@findex break_out_memory_refs 5534e4b17023SJohn Marino@var{x} will always be the result of a call to @code{break_out_memory_refs}, 5535e4b17023SJohn Marinoand @var{oldx} will be the operand that was given to that function to produce 5536e4b17023SJohn Marino@var{x}. 5537e4b17023SJohn Marino 5538e4b17023SJohn MarinoThe code of the hook should not alter the substructure of 5539e4b17023SJohn Marino@var{x}. If it transforms @var{x} into a more legitimate form, it 5540e4b17023SJohn Marinoshould return the new @var{x}. 5541e4b17023SJohn Marino 5542e4b17023SJohn MarinoIt is not necessary for this hook to come up with a legitimate address. 5543e4b17023SJohn MarinoThe compiler has standard ways of doing so in all cases. In fact, it 5544e4b17023SJohn Marinois safe to omit this hook or make it return @var{x} if it cannot find 5545e4b17023SJohn Marinoa valid way to legitimize the address. But often a machine-dependent 5546e4b17023SJohn Marinostrategy can generate better code. 5547e4b17023SJohn Marino@end deftypefn 5548e4b17023SJohn Marino 5549e4b17023SJohn Marino@defmac LEGITIMIZE_RELOAD_ADDRESS (@var{x}, @var{mode}, @var{opnum}, @var{type}, @var{ind_levels}, @var{win}) 5550e4b17023SJohn MarinoA C compound statement that attempts to replace @var{x}, which is an address 5551e4b17023SJohn Marinothat needs reloading, with a valid memory address for an operand of mode 5552e4b17023SJohn Marino@var{mode}. @var{win} will be a C statement label elsewhere in the code. 5553e4b17023SJohn MarinoIt is not necessary to define this macro, but it might be useful for 5554e4b17023SJohn Marinoperformance reasons. 5555e4b17023SJohn Marino 5556e4b17023SJohn MarinoFor example, on the i386, it is sometimes possible to use a single 5557e4b17023SJohn Marinoreload register instead of two by reloading a sum of two pseudo 5558e4b17023SJohn Marinoregisters into a register. On the other hand, for number of RISC 5559e4b17023SJohn Marinoprocessors offsets are limited so that often an intermediate address 5560e4b17023SJohn Marinoneeds to be generated in order to address a stack slot. By defining 5561e4b17023SJohn Marino@code{LEGITIMIZE_RELOAD_ADDRESS} appropriately, the intermediate addresses 5562e4b17023SJohn Marinogenerated for adjacent some stack slots can be made identical, and thus 5563e4b17023SJohn Marinobe shared. 5564e4b17023SJohn Marino 5565e4b17023SJohn Marino@emph{Note}: This macro should be used with caution. It is necessary 5566e4b17023SJohn Marinoto know something of how reload works in order to effectively use this, 5567e4b17023SJohn Marinoand it is quite easy to produce macros that build in too much knowledge 5568e4b17023SJohn Marinoof reload internals. 5569e4b17023SJohn Marino 5570e4b17023SJohn Marino@emph{Note}: This macro must be able to reload an address created by a 5571e4b17023SJohn Marinoprevious invocation of this macro. If it fails to handle such addresses 5572e4b17023SJohn Marinothen the compiler may generate incorrect code or abort. 5573e4b17023SJohn Marino 5574e4b17023SJohn Marino@findex push_reload 5575e4b17023SJohn MarinoThe macro definition should use @code{push_reload} to indicate parts that 5576e4b17023SJohn Marinoneed reloading; @var{opnum}, @var{type} and @var{ind_levels} are usually 5577e4b17023SJohn Marinosuitable to be passed unaltered to @code{push_reload}. 5578e4b17023SJohn Marino 5579e4b17023SJohn MarinoThe code generated by this macro must not alter the substructure of 5580e4b17023SJohn Marino@var{x}. If it transforms @var{x} into a more legitimate form, it 5581e4b17023SJohn Marinoshould assign @var{x} (which will always be a C variable) a new value. 5582e4b17023SJohn MarinoThis also applies to parts that you change indirectly by calling 5583e4b17023SJohn Marino@code{push_reload}. 5584e4b17023SJohn Marino 5585e4b17023SJohn Marino@findex strict_memory_address_p 5586e4b17023SJohn MarinoThe macro definition may use @code{strict_memory_address_p} to test if 5587e4b17023SJohn Marinothe address has become legitimate. 5588e4b17023SJohn Marino 5589e4b17023SJohn Marino@findex copy_rtx 5590e4b17023SJohn MarinoIf you want to change only a part of @var{x}, one standard way of doing 5591e4b17023SJohn Marinothis is to use @code{copy_rtx}. Note, however, that it unshares only a 5592e4b17023SJohn Marinosingle level of rtl. Thus, if the part to be changed is not at the 5593e4b17023SJohn Marinotop level, you'll need to replace first the top level. 5594e4b17023SJohn MarinoIt is not necessary for this macro to come up with a legitimate 5595e4b17023SJohn Marinoaddress; but often a machine-dependent strategy can generate better code. 5596e4b17023SJohn Marino@end defmac 5597e4b17023SJohn Marino 5598e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_MODE_DEPENDENT_ADDRESS_P (const_rtx @var{addr}) 5599e4b17023SJohn MarinoThis hook returns @code{true} if memory address @var{addr} can have 5600e4b17023SJohn Marinodifferent meanings depending on the machine mode of the memory 5601e4b17023SJohn Marinoreference it is used for or if the address is valid for some modes 5602e4b17023SJohn Marinobut not others. 5603e4b17023SJohn Marino 5604e4b17023SJohn MarinoAutoincrement and autodecrement addresses typically have mode-dependent 5605e4b17023SJohn Marinoeffects because the amount of the increment or decrement is the size 5606e4b17023SJohn Marinoof the operand being addressed. Some machines have other mode-dependent 5607e4b17023SJohn Marinoaddresses. Many RISC machines have no mode-dependent addresses. 5608e4b17023SJohn Marino 5609e4b17023SJohn MarinoYou may assume that @var{addr} is a valid address for the machine. 5610e4b17023SJohn Marino 5611e4b17023SJohn MarinoThe default version of this hook returns @code{false}. 5612e4b17023SJohn Marino@end deftypefn 5613e4b17023SJohn Marino 5614e4b17023SJohn Marino@defmac GO_IF_MODE_DEPENDENT_ADDRESS (@var{addr}, @var{label}) 5615e4b17023SJohn MarinoA C statement or compound statement with a conditional @code{goto 5616e4b17023SJohn Marino@var{label};} executed if memory address @var{x} (an RTX) can have 5617e4b17023SJohn Marinodifferent meanings depending on the machine mode of the memory 5618e4b17023SJohn Marinoreference it is used for or if the address is valid for some modes 5619e4b17023SJohn Marinobut not others. 5620e4b17023SJohn Marino 5621e4b17023SJohn MarinoAutoincrement and autodecrement addresses typically have mode-dependent 5622e4b17023SJohn Marinoeffects because the amount of the increment or decrement is the size 5623e4b17023SJohn Marinoof the operand being addressed. Some machines have other mode-dependent 5624e4b17023SJohn Marinoaddresses. Many RISC machines have no mode-dependent addresses. 5625e4b17023SJohn Marino 5626e4b17023SJohn MarinoYou may assume that @var{addr} is a valid address for the machine. 5627e4b17023SJohn Marino 5628e4b17023SJohn MarinoThese are obsolete macros, replaced by the 5629e4b17023SJohn Marino@code{TARGET_MODE_DEPENDENT_ADDRESS_P} target hook. 5630e4b17023SJohn Marino@end defmac 5631e4b17023SJohn Marino 5632e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_LEGITIMATE_CONSTANT_P (enum machine_mode @var{mode}, rtx @var{x}) 5633e4b17023SJohn MarinoThis hook returns true if @var{x} is a legitimate constant for a 5634e4b17023SJohn Marino@var{mode}-mode immediate operand on the target machine. You can assume that 5635e4b17023SJohn Marino@var{x} satisfies @code{CONSTANT_P}, so you need not check this. 5636e4b17023SJohn Marino 5637e4b17023SJohn MarinoThe default definition returns true. 5638e4b17023SJohn Marino@end deftypefn 5639e4b17023SJohn Marino 5640e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_DELEGITIMIZE_ADDRESS (rtx @var{x}) 5641e4b17023SJohn MarinoThis hook is used to undo the possibly obfuscating effects of the 5642e4b17023SJohn Marino@code{LEGITIMIZE_ADDRESS} and @code{LEGITIMIZE_RELOAD_ADDRESS} target 5643e4b17023SJohn Marinomacros. Some backend implementations of these macros wrap symbol 5644e4b17023SJohn Marinoreferences inside an @code{UNSPEC} rtx to represent PIC or similar 5645e4b17023SJohn Marinoaddressing modes. This target hook allows GCC's optimizers to understand 5646e4b17023SJohn Marinothe semantics of these opaque @code{UNSPEC}s by converting them back 5647e4b17023SJohn Marinointo their original form. 5648e4b17023SJohn Marino@end deftypefn 5649e4b17023SJohn Marino 5650e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CONST_NOT_OK_FOR_DEBUG_P (rtx @var{x}) 5651e4b17023SJohn MarinoThis hook should return true if @var{x} should not be emitted into 5652e4b17023SJohn Marinodebug sections. 5653e4b17023SJohn Marino@end deftypefn 5654e4b17023SJohn Marino 5655e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CANNOT_FORCE_CONST_MEM (enum machine_mode @var{mode}, rtx @var{x}) 5656e4b17023SJohn MarinoThis hook should return true if @var{x} is of a form that cannot (or 5657e4b17023SJohn Marinoshould not) be spilled to the constant pool. @var{mode} is the mode 5658e4b17023SJohn Marinoof @var{x}. 5659e4b17023SJohn Marino 5660e4b17023SJohn MarinoThe default version of this hook returns false. 5661e4b17023SJohn Marino 5662e4b17023SJohn MarinoThe primary reason to define this hook is to prevent reload from 5663e4b17023SJohn Marinodeciding that a non-legitimate constant would be better reloaded 5664e4b17023SJohn Marinofrom the constant pool instead of spilling and reloading a register 5665e4b17023SJohn Marinoholding the constant. This restriction is often true of addresses 5666e4b17023SJohn Marinoof TLS symbols for various targets. 5667e4b17023SJohn Marino@end deftypefn 5668e4b17023SJohn Marino 5669e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_USE_BLOCKS_FOR_CONSTANT_P (enum machine_mode @var{mode}, const_rtx @var{x}) 5670e4b17023SJohn MarinoThis hook should return true if pool entries for constant @var{x} can 5671e4b17023SJohn Marinobe placed in an @code{object_block} structure. @var{mode} is the mode 5672e4b17023SJohn Marinoof @var{x}. 5673e4b17023SJohn Marino 5674e4b17023SJohn MarinoThe default version returns false for all constants. 5675e4b17023SJohn Marino@end deftypefn 5676e4b17023SJohn Marino 5677e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_BUILTIN_RECIPROCAL (unsigned @var{fn}, bool @var{md_fn}, bool @var{sqrt}) 5678e4b17023SJohn MarinoThis hook should return the DECL of a function that implements reciprocal of 5679e4b17023SJohn Marinothe builtin function with builtin function code @var{fn}, or 5680e4b17023SJohn Marino@code{NULL_TREE} if such a function is not available. @var{md_fn} is true 5681e4b17023SJohn Marinowhen @var{fn} is a code of a machine-dependent builtin function. When 5682e4b17023SJohn Marino@var{sqrt} is true, additional optimizations that apply only to the reciprocal 5683e4b17023SJohn Marinoof a square root function are performed, and only reciprocals of @code{sqrt} 5684e4b17023SJohn Marinofunction are valid. 5685e4b17023SJohn Marino@end deftypefn 5686e4b17023SJohn Marino 5687e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD (void) 5688e4b17023SJohn MarinoThis hook should return the DECL of a function @var{f} that given an 5689e4b17023SJohn Marinoaddress @var{addr} as an argument returns a mask @var{m} that can be 5690e4b17023SJohn Marinoused to extract from two vectors the relevant data that resides in 5691e4b17023SJohn Marino@var{addr} in case @var{addr} is not properly aligned. 5692e4b17023SJohn Marino 5693e4b17023SJohn MarinoThe autovectorizer, when vectorizing a load operation from an address 5694e4b17023SJohn Marino@var{addr} that may be unaligned, will generate two vector loads from 5695e4b17023SJohn Marinothe two aligned addresses around @var{addr}. It then generates a 5696e4b17023SJohn Marino@code{REALIGN_LOAD} operation to extract the relevant data from the 5697e4b17023SJohn Marinotwo loaded vectors. The first two arguments to @code{REALIGN_LOAD}, 5698e4b17023SJohn Marino@var{v1} and @var{v2}, are the two vectors, each of size @var{VS}, and 5699e4b17023SJohn Marinothe third argument, @var{OFF}, defines how the data will be extracted 5700e4b17023SJohn Marinofrom these two vectors: if @var{OFF} is 0, then the returned vector is 5701e4b17023SJohn Marino@var{v2}; otherwise, the returned vector is composed from the last 5702e4b17023SJohn Marino@var{VS}-@var{OFF} elements of @var{v1} concatenated to the first 5703e4b17023SJohn Marino@var{OFF} elements of @var{v2}. 5704e4b17023SJohn Marino 5705e4b17023SJohn MarinoIf this hook is defined, the autovectorizer will generate a call 5706e4b17023SJohn Marinoto @var{f} (using the DECL tree that this hook returns) and will 5707e4b17023SJohn Marinouse the return value of @var{f} as the argument @var{OFF} to 5708e4b17023SJohn Marino@code{REALIGN_LOAD}. Therefore, the mask @var{m} returned by @var{f} 5709e4b17023SJohn Marinoshould comply with the semantics expected by @code{REALIGN_LOAD} 5710e4b17023SJohn Marinodescribed above. 5711e4b17023SJohn MarinoIf this hook is not defined, then @var{addr} will be used as 5712e4b17023SJohn Marinothe argument @var{OFF} to @code{REALIGN_LOAD}, in which case the low 5713e4b17023SJohn Marinolog2(@var{VS}) @minus{} 1 bits of @var{addr} will be considered. 5714e4b17023SJohn Marino@end deftypefn 5715e4b17023SJohn Marino 5716e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN (tree @var{x}) 5717e4b17023SJohn MarinoThis hook should return the DECL of a function @var{f} that implements 5718e4b17023SJohn Marinowidening multiplication of the even elements of two input vectors of type @var{x}. 5719e4b17023SJohn Marino 5720e4b17023SJohn MarinoIf this hook is defined, the autovectorizer will use it along with the 5721e4b17023SJohn Marino@code{TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD} target hook when vectorizing 5722e4b17023SJohn Marinowidening multiplication in cases that the order of the results does not have to be 5723e4b17023SJohn Marinopreserved (e.g.@: used only by a reduction computation). Otherwise, the 5724e4b17023SJohn Marino@code{widen_mult_hi/lo} idioms will be used. 5725e4b17023SJohn Marino@end deftypefn 5726e4b17023SJohn Marino 5727e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD (tree @var{x}) 5728e4b17023SJohn MarinoThis hook should return the DECL of a function @var{f} that implements 5729e4b17023SJohn Marinowidening multiplication of the odd elements of two input vectors of type @var{x}. 5730e4b17023SJohn Marino 5731e4b17023SJohn MarinoIf this hook is defined, the autovectorizer will use it along with the 5732e4b17023SJohn Marino@code{TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN} target hook when vectorizing 5733e4b17023SJohn Marinowidening multiplication in cases that the order of the results does not have to be 5734e4b17023SJohn Marinopreserved (e.g.@: used only by a reduction computation). Otherwise, the 5735e4b17023SJohn Marino@code{widen_mult_hi/lo} idioms will be used. 5736e4b17023SJohn Marino@end deftypefn 5737e4b17023SJohn Marino 5738e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST (enum vect_cost_for_stmt @var{type_of_cost}, tree @var{vectype}, int @var{misalign}) 5739e4b17023SJohn MarinoReturns cost of different scalar or vector statements for vectorization cost model. 5740e4b17023SJohn MarinoFor vector memory operations the cost may depend on type (@var{vectype}) and 5741e4b17023SJohn Marinomisalignment value (@var{misalign}). 5742e4b17023SJohn Marino@end deftypefn 5743e4b17023SJohn Marino 5744e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE (const_tree @var{type}, bool @var{is_packed}) 5745e4b17023SJohn MarinoReturn true if vector alignment is reachable (by peeling N iterations) for the given type. 5746e4b17023SJohn Marino@end deftypefn 5747e4b17023SJohn Marino 5748e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_VECTORIZE_VEC_PERM_CONST_OK (enum @var{machine_mode}, const unsigned char *@var{sel}) 5749e4b17023SJohn MarinoReturn true if a vector created for @code{vec_perm_const} is valid. 5750e4b17023SJohn Marino@end deftypefn 5751e4b17023SJohn Marino 5752e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_CONVERSION (unsigned @var{code}, tree @var{dest_type}, tree @var{src_type}) 5753e4b17023SJohn MarinoThis hook should return the DECL of a function that implements conversion of the 5754e4b17023SJohn Marinoinput vector of type @var{src_type} to type @var{dest_type}. 5755e4b17023SJohn MarinoThe value of @var{code} is one of the enumerators in @code{enum tree_code} and 5756e4b17023SJohn Marinospecifies how the conversion is to be applied 5757e4b17023SJohn Marino(truncation, rounding, etc.). 5758e4b17023SJohn Marino 5759e4b17023SJohn MarinoIf this hook is defined, the autovectorizer will use the 5760e4b17023SJohn Marino@code{TARGET_VECTORIZE_BUILTIN_CONVERSION} target hook when vectorizing 5761e4b17023SJohn Marinoconversion. Otherwise, it will return @code{NULL_TREE}. 5762e4b17023SJohn Marino@end deftypefn 5763e4b17023SJohn Marino 5764e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION (tree @var{fndecl}, tree @var{vec_type_out}, tree @var{vec_type_in}) 5765e4b17023SJohn MarinoThis hook should return the decl of a function that implements the 5766e4b17023SJohn Marinovectorized variant of the builtin function with builtin function code 5767e4b17023SJohn Marino@var{code} or @code{NULL_TREE} if such a function is not available. 5768e4b17023SJohn MarinoThe value of @var{fndecl} is the builtin function declaration. The 5769e4b17023SJohn Marinoreturn type of the vectorized function shall be of vector type 5770e4b17023SJohn Marino@var{vec_type_out} and the argument types should be @var{vec_type_in}. 5771e4b17023SJohn Marino@end deftypefn 5772e4b17023SJohn Marino 5773e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT (enum machine_mode @var{mode}, const_tree @var{type}, int @var{misalignment}, bool @var{is_packed}) 5774e4b17023SJohn MarinoThis hook should return true if the target supports misaligned vector 5775e4b17023SJohn Marinostore/load of a specific factor denoted in the @var{misalignment} 5776e4b17023SJohn Marinoparameter. The vector store/load should be of machine mode @var{mode} and 5777e4b17023SJohn Marinothe elements in the vectors should be of type @var{type}. @var{is_packed} 5778e4b17023SJohn Marinoparameter is true if the memory access is defined in a packed struct. 5779e4b17023SJohn Marino@end deftypefn 5780e4b17023SJohn Marino 5781e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_VECTORIZE_PREFERRED_SIMD_MODE (enum machine_mode @var{mode}) 5782e4b17023SJohn MarinoThis hook should return the preferred mode for vectorizing scalar 5783e4b17023SJohn Marinomode @var{mode}. The default is 5784e4b17023SJohn Marinoequal to @code{word_mode}, because the vectorizer can do some 5785e4b17023SJohn Marinotransformations even in absence of specialized @acronym{SIMD} hardware. 5786e4b17023SJohn Marino@end deftypefn 5787e4b17023SJohn Marino 5788e4b17023SJohn Marino@deftypefn {Target Hook} {unsigned int} TARGET_VECTORIZE_AUTOVECTORIZE_VECTOR_SIZES (void) 5789e4b17023SJohn MarinoThis hook should return a mask of sizes that should be iterated over 5790e4b17023SJohn Marinoafter trying to autovectorize using the vector size derived from the 5791e4b17023SJohn Marinomode returned by @code{TARGET_VECTORIZE_PREFERRED_SIMD_MODE}. 5792e4b17023SJohn MarinoThe default is zero which means to not iterate over other vector sizes. 5793e4b17023SJohn Marino@end deftypefn 5794e4b17023SJohn Marino 5795e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_TM_LOAD (tree) 5796e4b17023SJohn MarinoThis hook should return the built-in decl needed to load a vector of the given type within a transaction. 5797e4b17023SJohn Marino@end deftypefn 5798e4b17023SJohn Marino 5799e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_TM_STORE (tree) 5800e4b17023SJohn MarinoThis hook should return the built-in decl needed to store a vector of the given type within a transaction. 5801e4b17023SJohn Marino@end deftypefn 5802e4b17023SJohn Marino 5803e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_GATHER (const_tree @var{mem_vectype}, const_tree @var{index_type}, int @var{scale}) 5804e4b17023SJohn MarinoTarget builtin that implements vector gather operation. @var{mem_vectype} 5805e4b17023SJohn Marinois the vector type of the load and @var{index_type} is scalar type of 5806e4b17023SJohn Marinothe index, scaled by @var{scale}. 5807e4b17023SJohn MarinoThe default is @code{NULL_TREE} which means to not vectorize gather 5808e4b17023SJohn Marinoloads. 5809e4b17023SJohn Marino@end deftypefn 5810e4b17023SJohn Marino 5811e4b17023SJohn Marino@node Anchored Addresses 5812e4b17023SJohn Marino@section Anchored Addresses 5813e4b17023SJohn Marino@cindex anchored addresses 5814e4b17023SJohn Marino@cindex @option{-fsection-anchors} 5815e4b17023SJohn Marino 5816e4b17023SJohn MarinoGCC usually addresses every static object as a separate entity. 5817e4b17023SJohn MarinoFor example, if we have: 5818e4b17023SJohn Marino 5819e4b17023SJohn Marino@smallexample 5820e4b17023SJohn Marinostatic int a, b, c; 5821e4b17023SJohn Marinoint foo (void) @{ return a + b + c; @} 5822e4b17023SJohn Marino@end smallexample 5823e4b17023SJohn Marino 5824e4b17023SJohn Marinothe code for @code{foo} will usually calculate three separate symbolic 5825e4b17023SJohn Marinoaddresses: those of @code{a}, @code{b} and @code{c}. On some targets, 5826e4b17023SJohn Marinoit would be better to calculate just one symbolic address and access 5827e4b17023SJohn Marinothe three variables relative to it. The equivalent pseudocode would 5828e4b17023SJohn Marinobe something like: 5829e4b17023SJohn Marino 5830e4b17023SJohn Marino@smallexample 5831e4b17023SJohn Marinoint foo (void) 5832e4b17023SJohn Marino@{ 5833e4b17023SJohn Marino register int *xr = &x; 5834e4b17023SJohn Marino return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; 5835e4b17023SJohn Marino@} 5836e4b17023SJohn Marino@end smallexample 5837e4b17023SJohn Marino 5838e4b17023SJohn Marino(which isn't valid C). We refer to shared addresses like @code{x} as 5839e4b17023SJohn Marino``section anchors''. Their use is controlled by @option{-fsection-anchors}. 5840e4b17023SJohn Marino 5841e4b17023SJohn MarinoThe hooks below describe the target properties that GCC needs to know 5842e4b17023SJohn Marinoin order to make effective use of section anchors. It won't use 5843e4b17023SJohn Marinosection anchors at all unless either @code{TARGET_MIN_ANCHOR_OFFSET} 5844e4b17023SJohn Marinoor @code{TARGET_MAX_ANCHOR_OFFSET} is set to a nonzero value. 5845e4b17023SJohn Marino 5846e4b17023SJohn Marino@deftypevr {Target Hook} HOST_WIDE_INT TARGET_MIN_ANCHOR_OFFSET 5847e4b17023SJohn MarinoThe minimum offset that should be applied to a section anchor. 5848e4b17023SJohn MarinoOn most targets, it should be the smallest offset that can be 5849e4b17023SJohn Marinoapplied to a base register while still giving a legitimate address 5850e4b17023SJohn Marinofor every mode. The default value is 0. 5851e4b17023SJohn Marino@end deftypevr 5852e4b17023SJohn Marino 5853e4b17023SJohn Marino@deftypevr {Target Hook} HOST_WIDE_INT TARGET_MAX_ANCHOR_OFFSET 5854e4b17023SJohn MarinoLike @code{TARGET_MIN_ANCHOR_OFFSET}, but the maximum (inclusive) 5855e4b17023SJohn Marinooffset that should be applied to section anchors. The default 5856e4b17023SJohn Marinovalue is 0. 5857e4b17023SJohn Marino@end deftypevr 5858e4b17023SJohn Marino 5859e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_OUTPUT_ANCHOR (rtx @var{x}) 5860e4b17023SJohn MarinoWrite the assembly code to define section anchor @var{x}, which is a 5861e4b17023SJohn Marino@code{SYMBOL_REF} for which @samp{SYMBOL_REF_ANCHOR_P (@var{x})} is true. 5862e4b17023SJohn MarinoThe hook is called with the assembly output position set to the beginning 5863e4b17023SJohn Marinoof @code{SYMBOL_REF_BLOCK (@var{x})}. 5864e4b17023SJohn Marino 5865e4b17023SJohn MarinoIf @code{ASM_OUTPUT_DEF} is available, the hook's default definition uses 5866e4b17023SJohn Marinoit to define the symbol as @samp{. + SYMBOL_REF_BLOCK_OFFSET (@var{x})}. 5867e4b17023SJohn MarinoIf @code{ASM_OUTPUT_DEF} is not available, the hook's default definition 5868e4b17023SJohn Marinois @code{NULL}, which disables the use of section anchors altogether. 5869e4b17023SJohn Marino@end deftypefn 5870e4b17023SJohn Marino 5871e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_USE_ANCHORS_FOR_SYMBOL_P (const_rtx @var{x}) 5872e4b17023SJohn MarinoReturn true if GCC should attempt to use anchors to access @code{SYMBOL_REF} 5873e4b17023SJohn Marino@var{x}. You can assume @samp{SYMBOL_REF_HAS_BLOCK_INFO_P (@var{x})} and 5874e4b17023SJohn Marino@samp{!SYMBOL_REF_ANCHOR_P (@var{x})}. 5875e4b17023SJohn Marino 5876e4b17023SJohn MarinoThe default version is correct for most targets, but you might need to 5877e4b17023SJohn Marinointercept this hook to handle things like target-specific attributes 5878e4b17023SJohn Marinoor target-specific sections. 5879e4b17023SJohn Marino@end deftypefn 5880e4b17023SJohn Marino 5881e4b17023SJohn Marino@node Condition Code 5882e4b17023SJohn Marino@section Condition Code Status 5883e4b17023SJohn Marino@cindex condition code status 5884e4b17023SJohn Marino 5885e4b17023SJohn MarinoThe macros in this section can be split in two families, according to the 5886e4b17023SJohn Marinotwo ways of representing condition codes in GCC. 5887e4b17023SJohn Marino 5888e4b17023SJohn MarinoThe first representation is the so called @code{(cc0)} representation 5889e4b17023SJohn Marino(@pxref{Jump Patterns}), where all instructions can have an implicit 5890e4b17023SJohn Marinoclobber of the condition codes. The second is the condition code 5891e4b17023SJohn Marinoregister representation, which provides better schedulability for 5892e4b17023SJohn Marinoarchitectures that do have a condition code register, but on which 5893e4b17023SJohn Marinomost instructions do not affect it. The latter category includes 5894e4b17023SJohn Marinomost RISC machines. 5895e4b17023SJohn Marino 5896e4b17023SJohn MarinoThe implicit clobbering poses a strong restriction on the placement of 5897e4b17023SJohn Marinothe definition and use of the condition code, which need to be in adjacent 5898e4b17023SJohn Marinoinsns for machines using @code{(cc0)}. This can prevent important 5899e4b17023SJohn Marinooptimizations on some machines. For example, on the IBM RS/6000, there 5900e4b17023SJohn Marinois a delay for taken branches unless the condition code register is set 5901e4b17023SJohn Marinothree instructions earlier than the conditional branch. The instruction 5902e4b17023SJohn Marinoscheduler cannot perform this optimization if it is not permitted to 5903e4b17023SJohn Marinoseparate the definition and use of the condition code register. 5904e4b17023SJohn Marino 5905e4b17023SJohn MarinoFor this reason, it is possible and suggested to use a register to 5906e4b17023SJohn Marinorepresent the condition code for new ports. If there is a specific 5907e4b17023SJohn Marinocondition code register in the machine, use a hard register. If the 5908e4b17023SJohn Marinocondition code or comparison result can be placed in any general register, 5909e4b17023SJohn Marinoor if there are multiple condition registers, use a pseudo register. 5910e4b17023SJohn MarinoRegisters used to store the condition code value will usually have a mode 5911e4b17023SJohn Marinothat is in class @code{MODE_CC}. 5912e4b17023SJohn Marino 5913e4b17023SJohn MarinoAlternatively, you can use @code{BImode} if the comparison operator is 5914e4b17023SJohn Marinospecified already in the compare instruction. In this case, you are not 5915e4b17023SJohn Marinointerested in most macros in this section. 5916e4b17023SJohn Marino 5917e4b17023SJohn Marino@menu 5918e4b17023SJohn Marino* CC0 Condition Codes:: Old style representation of condition codes. 5919e4b17023SJohn Marino* MODE_CC Condition Codes:: Modern representation of condition codes. 5920e4b17023SJohn Marino* Cond Exec Macros:: Macros to control conditional execution. 5921e4b17023SJohn Marino@end menu 5922e4b17023SJohn Marino 5923e4b17023SJohn Marino@node CC0 Condition Codes 5924e4b17023SJohn Marino@subsection Representation of condition codes using @code{(cc0)} 5925e4b17023SJohn Marino@findex cc0 5926e4b17023SJohn Marino 5927e4b17023SJohn Marino@findex cc_status 5928e4b17023SJohn MarinoThe file @file{conditions.h} defines a variable @code{cc_status} to 5929e4b17023SJohn Marinodescribe how the condition code was computed (in case the interpretation of 5930e4b17023SJohn Marinothe condition code depends on the instruction that it was set by). This 5931e4b17023SJohn Marinovariable contains the RTL expressions on which the condition code is 5932e4b17023SJohn Marinocurrently based, and several standard flags. 5933e4b17023SJohn Marino 5934e4b17023SJohn MarinoSometimes additional machine-specific flags must be defined in the machine 5935e4b17023SJohn Marinodescription header file. It can also add additional machine-specific 5936e4b17023SJohn Marinoinformation by defining @code{CC_STATUS_MDEP}. 5937e4b17023SJohn Marino 5938e4b17023SJohn Marino@defmac CC_STATUS_MDEP 5939e4b17023SJohn MarinoC code for a data type which is used for declaring the @code{mdep} 5940e4b17023SJohn Marinocomponent of @code{cc_status}. It defaults to @code{int}. 5941e4b17023SJohn Marino 5942e4b17023SJohn MarinoThis macro is not used on machines that do not use @code{cc0}. 5943e4b17023SJohn Marino@end defmac 5944e4b17023SJohn Marino 5945e4b17023SJohn Marino@defmac CC_STATUS_MDEP_INIT 5946e4b17023SJohn MarinoA C expression to initialize the @code{mdep} field to ``empty''. 5947e4b17023SJohn MarinoThe default definition does nothing, since most machines don't use 5948e4b17023SJohn Marinothe field anyway. If you want to use the field, you should probably 5949e4b17023SJohn Marinodefine this macro to initialize it. 5950e4b17023SJohn Marino 5951e4b17023SJohn MarinoThis macro is not used on machines that do not use @code{cc0}. 5952e4b17023SJohn Marino@end defmac 5953e4b17023SJohn Marino 5954e4b17023SJohn Marino@defmac NOTICE_UPDATE_CC (@var{exp}, @var{insn}) 5955e4b17023SJohn MarinoA C compound statement to set the components of @code{cc_status} 5956e4b17023SJohn Marinoappropriately for an insn @var{insn} whose body is @var{exp}. It is 5957e4b17023SJohn Marinothis macro's responsibility to recognize insns that set the condition 5958e4b17023SJohn Marinocode as a byproduct of other activity as well as those that explicitly 5959e4b17023SJohn Marinoset @code{(cc0)}. 5960e4b17023SJohn Marino 5961e4b17023SJohn MarinoThis macro is not used on machines that do not use @code{cc0}. 5962e4b17023SJohn Marino 5963e4b17023SJohn MarinoIf there are insns that do not set the condition code but do alter 5964e4b17023SJohn Marinoother machine registers, this macro must check to see whether they 5965e4b17023SJohn Marinoinvalidate the expressions that the condition code is recorded as 5966e4b17023SJohn Marinoreflecting. For example, on the 68000, insns that store in address 5967e4b17023SJohn Marinoregisters do not set the condition code, which means that usually 5968e4b17023SJohn Marino@code{NOTICE_UPDATE_CC} can leave @code{cc_status} unaltered for such 5969e4b17023SJohn Marinoinsns. But suppose that the previous insn set the condition code 5970e4b17023SJohn Marinobased on location @samp{a4@@(102)} and the current insn stores a new 5971e4b17023SJohn Marinovalue in @samp{a4}. Although the condition code is not changed by 5972e4b17023SJohn Marinothis, it will no longer be true that it reflects the contents of 5973e4b17023SJohn Marino@samp{a4@@(102)}. Therefore, @code{NOTICE_UPDATE_CC} must alter 5974e4b17023SJohn Marino@code{cc_status} in this case to say that nothing is known about the 5975e4b17023SJohn Marinocondition code value. 5976e4b17023SJohn Marino 5977e4b17023SJohn MarinoThe definition of @code{NOTICE_UPDATE_CC} must be prepared to deal 5978e4b17023SJohn Marinowith the results of peephole optimization: insns whose patterns are 5979e4b17023SJohn Marino@code{parallel} RTXs containing various @code{reg}, @code{mem} or 5980e4b17023SJohn Marinoconstants which are just the operands. The RTL structure of these 5981e4b17023SJohn Marinoinsns is not sufficient to indicate what the insns actually do. What 5982e4b17023SJohn Marino@code{NOTICE_UPDATE_CC} should do when it sees one is just to run 5983e4b17023SJohn Marino@code{CC_STATUS_INIT}. 5984e4b17023SJohn Marino 5985e4b17023SJohn MarinoA possible definition of @code{NOTICE_UPDATE_CC} is to call a function 5986e4b17023SJohn Marinothat looks at an attribute (@pxref{Insn Attributes}) named, for example, 5987e4b17023SJohn Marino@samp{cc}. This avoids having detailed information about patterns in 5988e4b17023SJohn Marinotwo places, the @file{md} file and in @code{NOTICE_UPDATE_CC}. 5989e4b17023SJohn Marino@end defmac 5990e4b17023SJohn Marino 5991e4b17023SJohn Marino@node MODE_CC Condition Codes 5992e4b17023SJohn Marino@subsection Representation of condition codes using registers 5993e4b17023SJohn Marino@findex CCmode 5994e4b17023SJohn Marino@findex MODE_CC 5995e4b17023SJohn Marino 5996e4b17023SJohn Marino@defmac SELECT_CC_MODE (@var{op}, @var{x}, @var{y}) 5997e4b17023SJohn MarinoOn many machines, the condition code may be produced by other instructions 5998e4b17023SJohn Marinothan compares, for example the branch can use directly the condition 5999e4b17023SJohn Marinocode set by a subtract instruction. However, on some machines 6000e4b17023SJohn Marinowhen the condition code is set this way some bits (such as the overflow 6001e4b17023SJohn Marinobit) are not set in the same way as a test instruction, so that a different 6002e4b17023SJohn Marinobranch instruction must be used for some conditional branches. When 6003e4b17023SJohn Marinothis happens, use the machine mode of the condition code register to 6004e4b17023SJohn Marinorecord different formats of the condition code register. Modes can 6005e4b17023SJohn Marinoalso be used to record which compare instruction (e.g. a signed or an 6006e4b17023SJohn Marinounsigned comparison) produced the condition codes. 6007e4b17023SJohn Marino 6008e4b17023SJohn MarinoIf other modes than @code{CCmode} are required, add them to 6009e4b17023SJohn Marino@file{@var{machine}-modes.def} and define @code{SELECT_CC_MODE} to choose 6010e4b17023SJohn Marinoa mode given an operand of a compare. This is needed because the modes 6011e4b17023SJohn Marinohave to be chosen not only during RTL generation but also, for example, 6012e4b17023SJohn Marinoby instruction combination. The result of @code{SELECT_CC_MODE} should 6013e4b17023SJohn Marinobe consistent with the mode used in the patterns; for example to support 6014e4b17023SJohn Marinothe case of the add on the SPARC discussed above, we have the pattern 6015e4b17023SJohn Marino 6016e4b17023SJohn Marino@smallexample 6017e4b17023SJohn Marino(define_insn "" 6018e4b17023SJohn Marino [(set (reg:CC_NOOV 0) 6019e4b17023SJohn Marino (compare:CC_NOOV 6020e4b17023SJohn Marino (plus:SI (match_operand:SI 0 "register_operand" "%r") 6021e4b17023SJohn Marino (match_operand:SI 1 "arith_operand" "rI")) 6022e4b17023SJohn Marino (const_int 0)))] 6023e4b17023SJohn Marino "" 6024e4b17023SJohn Marino "@dots{}") 6025e4b17023SJohn Marino@end smallexample 6026e4b17023SJohn Marino 6027e4b17023SJohn Marino@noindent 6028e4b17023SJohn Marinotogether with a @code{SELECT_CC_MODE} that returns @code{CC_NOOVmode} 6029e4b17023SJohn Marinofor comparisons whose argument is a @code{plus}: 6030e4b17023SJohn Marino 6031e4b17023SJohn Marino@smallexample 6032e4b17023SJohn Marino#define SELECT_CC_MODE(OP,X,Y) \ 6033e4b17023SJohn Marino (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ 6034e4b17023SJohn Marino ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode) \ 6035e4b17023SJohn Marino : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS \ 6036e4b17023SJohn Marino || GET_CODE (X) == NEG) \ 6037e4b17023SJohn Marino ? CC_NOOVmode : CCmode)) 6038e4b17023SJohn Marino@end smallexample 6039e4b17023SJohn Marino 6040e4b17023SJohn MarinoAnother reason to use modes is to retain information on which operands 6041e4b17023SJohn Marinowere used by the comparison; see @code{REVERSIBLE_CC_MODE} later in 6042e4b17023SJohn Marinothis section. 6043e4b17023SJohn Marino 6044e4b17023SJohn MarinoYou should define this macro if and only if you define extra CC modes 6045e4b17023SJohn Marinoin @file{@var{machine}-modes.def}. 6046e4b17023SJohn Marino@end defmac 6047e4b17023SJohn Marino 6048e4b17023SJohn Marino@defmac CANONICALIZE_COMPARISON (@var{code}, @var{op0}, @var{op1}) 6049e4b17023SJohn MarinoOn some machines not all possible comparisons are defined, but you can 6050e4b17023SJohn Marinoconvert an invalid comparison into a valid one. For example, the Alpha 6051e4b17023SJohn Marinodoes not have a @code{GT} comparison, but you can use an @code{LT} 6052e4b17023SJohn Marinocomparison instead and swap the order of the operands. 6053e4b17023SJohn Marino 6054e4b17023SJohn MarinoOn such machines, define this macro to be a C statement to do any 6055e4b17023SJohn Marinorequired conversions. @var{code} is the initial comparison code 6056e4b17023SJohn Marinoand @var{op0} and @var{op1} are the left and right operands of the 6057e4b17023SJohn Marinocomparison, respectively. You should modify @var{code}, @var{op0}, and 6058e4b17023SJohn Marino@var{op1} as required. 6059e4b17023SJohn Marino 6060e4b17023SJohn MarinoGCC will not assume that the comparison resulting from this macro is 6061e4b17023SJohn Marinovalid but will see if the resulting insn matches a pattern in the 6062e4b17023SJohn Marino@file{md} file. 6063e4b17023SJohn Marino 6064e4b17023SJohn MarinoYou need not define this macro if it would never change the comparison 6065e4b17023SJohn Marinocode or operands. 6066e4b17023SJohn Marino@end defmac 6067e4b17023SJohn Marino 6068e4b17023SJohn Marino@defmac REVERSIBLE_CC_MODE (@var{mode}) 6069e4b17023SJohn MarinoA C expression whose value is one if it is always safe to reverse a 6070e4b17023SJohn Marinocomparison whose mode is @var{mode}. If @code{SELECT_CC_MODE} 6071e4b17023SJohn Marinocan ever return @var{mode} for a floating-point inequality comparison, 6072e4b17023SJohn Marinothen @code{REVERSIBLE_CC_MODE (@var{mode})} must be zero. 6073e4b17023SJohn Marino 6074e4b17023SJohn MarinoYou need not define this macro if it would always returns zero or if the 6075e4b17023SJohn Marinofloating-point format is anything other than @code{IEEE_FLOAT_FORMAT}. 6076e4b17023SJohn MarinoFor example, here is the definition used on the SPARC, where floating-point 6077e4b17023SJohn Marinoinequality comparisons are always given @code{CCFPEmode}: 6078e4b17023SJohn Marino 6079e4b17023SJohn Marino@smallexample 6080e4b17023SJohn Marino#define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode) 6081e4b17023SJohn Marino@end smallexample 6082e4b17023SJohn Marino@end defmac 6083e4b17023SJohn Marino 6084e4b17023SJohn Marino@defmac REVERSE_CONDITION (@var{code}, @var{mode}) 6085e4b17023SJohn MarinoA C expression whose value is reversed condition code of the @var{code} for 6086e4b17023SJohn Marinocomparison done in CC_MODE @var{mode}. The macro is used only in case 6087e4b17023SJohn Marino@code{REVERSIBLE_CC_MODE (@var{mode})} is nonzero. Define this macro in case 6088e4b17023SJohn Marinomachine has some non-standard way how to reverse certain conditionals. For 6089e4b17023SJohn Marinoinstance in case all floating point conditions are non-trapping, compiler may 6090e4b17023SJohn Marinofreely convert unordered compares to ordered one. Then definition may look 6091e4b17023SJohn Marinolike: 6092e4b17023SJohn Marino 6093e4b17023SJohn Marino@smallexample 6094e4b17023SJohn Marino#define REVERSE_CONDITION(CODE, MODE) \ 6095e4b17023SJohn Marino ((MODE) != CCFPmode ? reverse_condition (CODE) \ 6096e4b17023SJohn Marino : reverse_condition_maybe_unordered (CODE)) 6097e4b17023SJohn Marino@end smallexample 6098e4b17023SJohn Marino@end defmac 6099e4b17023SJohn Marino 6100e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_FIXED_CONDITION_CODE_REGS (unsigned int *@var{p1}, unsigned int *@var{p2}) 6101e4b17023SJohn MarinoOn targets which do not use @code{(cc0)}, and which use a hard 6102e4b17023SJohn Marinoregister rather than a pseudo-register to hold condition codes, the 6103e4b17023SJohn Marinoregular CSE passes are often not able to identify cases in which the 6104e4b17023SJohn Marinohard register is set to a common value. Use this hook to enable a 6105e4b17023SJohn Marinosmall pass which optimizes such cases. This hook should return true 6106e4b17023SJohn Marinoto enable this pass, and it should set the integers to which its 6107e4b17023SJohn Marinoarguments point to the hard register numbers used for condition codes. 6108e4b17023SJohn MarinoWhen there is only one such register, as is true on most systems, the 6109e4b17023SJohn Marinointeger pointed to by @var{p2} should be set to 6110e4b17023SJohn Marino@code{INVALID_REGNUM}. 6111e4b17023SJohn Marino 6112e4b17023SJohn MarinoThe default version of this hook returns false. 6113e4b17023SJohn Marino@end deftypefn 6114e4b17023SJohn Marino 6115e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_CC_MODES_COMPATIBLE (enum machine_mode @var{m1}, enum machine_mode @var{m2}) 6116e4b17023SJohn MarinoOn targets which use multiple condition code modes in class 6117e4b17023SJohn Marino@code{MODE_CC}, it is sometimes the case that a comparison can be 6118e4b17023SJohn Marinovalidly done in more than one mode. On such a system, define this 6119e4b17023SJohn Marinotarget hook to take two mode arguments and to return a mode in which 6120e4b17023SJohn Marinoboth comparisons may be validly done. If there is no such mode, 6121e4b17023SJohn Marinoreturn @code{VOIDmode}. 6122e4b17023SJohn Marino 6123e4b17023SJohn MarinoThe default version of this hook checks whether the modes are the 6124e4b17023SJohn Marinosame. If they are, it returns that mode. If they are different, it 6125e4b17023SJohn Marinoreturns @code{VOIDmode}. 6126e4b17023SJohn Marino@end deftypefn 6127e4b17023SJohn Marino 6128e4b17023SJohn Marino@node Cond Exec Macros 6129e4b17023SJohn Marino@subsection Macros to control conditional execution 6130e4b17023SJohn Marino@findex conditional execution 6131e4b17023SJohn Marino@findex predication 6132e4b17023SJohn Marino 6133e4b17023SJohn MarinoThere is one macro that may need to be defined for targets 6134e4b17023SJohn Marinosupporting conditional execution, independent of how they 6135e4b17023SJohn Marinorepresent conditional branches. 6136e4b17023SJohn Marino 6137e4b17023SJohn Marino@defmac REVERSE_CONDEXEC_PREDICATES_P (@var{op1}, @var{op2}) 6138e4b17023SJohn MarinoA C expression that returns true if the conditional execution predicate 6139e4b17023SJohn Marino@var{op1}, a comparison operation, is the inverse of @var{op2} and vice 6140e4b17023SJohn Marinoversa. Define this to return 0 if the target has conditional execution 6141e4b17023SJohn Marinopredicates that cannot be reversed safely. There is no need to validate 6142e4b17023SJohn Marinothat the arguments of op1 and op2 are the same, this is done separately. 6143e4b17023SJohn MarinoIf no expansion is specified, this macro is defined as follows: 6144e4b17023SJohn Marino 6145e4b17023SJohn Marino@smallexample 6146e4b17023SJohn Marino#define REVERSE_CONDEXEC_PREDICATES_P (x, y) \ 6147e4b17023SJohn Marino (GET_CODE ((x)) == reversed_comparison_code ((y), NULL)) 6148e4b17023SJohn Marino@end smallexample 6149e4b17023SJohn Marino@end defmac 6150e4b17023SJohn Marino 6151e4b17023SJohn Marino@node Costs 6152e4b17023SJohn Marino@section Describing Relative Costs of Operations 6153e4b17023SJohn Marino@cindex costs of instructions 6154e4b17023SJohn Marino@cindex relative costs 6155e4b17023SJohn Marino@cindex speed of instructions 6156e4b17023SJohn Marino 6157e4b17023SJohn MarinoThese macros let you describe the relative speed of various operations 6158e4b17023SJohn Marinoon the target machine. 6159e4b17023SJohn Marino 6160e4b17023SJohn Marino@defmac REGISTER_MOVE_COST (@var{mode}, @var{from}, @var{to}) 6161e4b17023SJohn MarinoA C expression for the cost of moving data of mode @var{mode} from a 6162e4b17023SJohn Marinoregister in class @var{from} to one in class @var{to}. The classes are 6163e4b17023SJohn Marinoexpressed using the enumeration values such as @code{GENERAL_REGS}. A 6164e4b17023SJohn Marinovalue of 2 is the default; other values are interpreted relative to 6165e4b17023SJohn Marinothat. 6166e4b17023SJohn Marino 6167e4b17023SJohn MarinoIt is not required that the cost always equal 2 when @var{from} is the 6168e4b17023SJohn Marinosame as @var{to}; on some machines it is expensive to move between 6169e4b17023SJohn Marinoregisters if they are not general registers. 6170e4b17023SJohn Marino 6171e4b17023SJohn MarinoIf reload sees an insn consisting of a single @code{set} between two 6172e4b17023SJohn Marinohard registers, and if @code{REGISTER_MOVE_COST} applied to their 6173e4b17023SJohn Marinoclasses returns a value of 2, reload does not check to ensure that the 6174e4b17023SJohn Marinoconstraints of the insn are met. Setting a cost of other than 2 will 6175e4b17023SJohn Marinoallow reload to verify that the constraints are met. You should do this 6176e4b17023SJohn Marinoif the @samp{mov@var{m}} pattern's constraints do not allow such copying. 6177e4b17023SJohn Marino 6178e4b17023SJohn MarinoThese macros are obsolete, new ports should use the target hook 6179e4b17023SJohn Marino@code{TARGET_REGISTER_MOVE_COST} instead. 6180e4b17023SJohn Marino@end defmac 6181e4b17023SJohn Marino 6182e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_REGISTER_MOVE_COST (enum machine_mode @var{mode}, reg_class_t @var{from}, reg_class_t @var{to}) 6183e4b17023SJohn MarinoThis target hook should return the cost of moving data of mode @var{mode} 6184e4b17023SJohn Marinofrom a register in class @var{from} to one in class @var{to}. The classes 6185e4b17023SJohn Marinoare expressed using the enumeration values such as @code{GENERAL_REGS}. 6186e4b17023SJohn MarinoA value of 2 is the default; other values are interpreted relative to 6187e4b17023SJohn Marinothat. 6188e4b17023SJohn Marino 6189e4b17023SJohn MarinoIt is not required that the cost always equal 2 when @var{from} is the 6190e4b17023SJohn Marinosame as @var{to}; on some machines it is expensive to move between 6191e4b17023SJohn Marinoregisters if they are not general registers. 6192e4b17023SJohn Marino 6193e4b17023SJohn MarinoIf reload sees an insn consisting of a single @code{set} between two 6194e4b17023SJohn Marinohard registers, and if @code{TARGET_REGISTER_MOVE_COST} applied to their 6195e4b17023SJohn Marinoclasses returns a value of 2, reload does not check to ensure that the 6196e4b17023SJohn Marinoconstraints of the insn are met. Setting a cost of other than 2 will 6197e4b17023SJohn Marinoallow reload to verify that the constraints are met. You should do this 6198e4b17023SJohn Marinoif the @samp{mov@var{m}} pattern's constraints do not allow such copying. 6199e4b17023SJohn Marino 6200e4b17023SJohn MarinoThe default version of this function returns 2. 6201e4b17023SJohn Marino@end deftypefn 6202e4b17023SJohn Marino 6203e4b17023SJohn Marino@defmac MEMORY_MOVE_COST (@var{mode}, @var{class}, @var{in}) 6204e4b17023SJohn MarinoA C expression for the cost of moving data of mode @var{mode} between a 6205e4b17023SJohn Marinoregister of class @var{class} and memory; @var{in} is zero if the value 6206e4b17023SJohn Marinois to be written to memory, nonzero if it is to be read in. This cost 6207e4b17023SJohn Marinois relative to those in @code{REGISTER_MOVE_COST}. If moving between 6208e4b17023SJohn Marinoregisters and memory is more expensive than between two registers, you 6209e4b17023SJohn Marinoshould define this macro to express the relative cost. 6210e4b17023SJohn Marino 6211e4b17023SJohn MarinoIf you do not define this macro, GCC uses a default cost of 4 plus 6212e4b17023SJohn Marinothe cost of copying via a secondary reload register, if one is 6213e4b17023SJohn Marinoneeded. If your machine requires a secondary reload register to copy 6214e4b17023SJohn Marinobetween memory and a register of @var{class} but the reload mechanism is 6215e4b17023SJohn Marinomore complex than copying via an intermediate, define this macro to 6216e4b17023SJohn Marinoreflect the actual cost of the move. 6217e4b17023SJohn Marino 6218e4b17023SJohn MarinoGCC defines the function @code{memory_move_secondary_cost} if 6219e4b17023SJohn Marinosecondary reloads are needed. It computes the costs due to copying via 6220e4b17023SJohn Marinoa secondary register. If your machine copies from memory using a 6221e4b17023SJohn Marinosecondary register in the conventional way but the default base value of 6222e4b17023SJohn Marino4 is not correct for your machine, define this macro to add some other 6223e4b17023SJohn Marinovalue to the result of that function. The arguments to that function 6224e4b17023SJohn Marinoare the same as to this macro. 6225e4b17023SJohn Marino 6226e4b17023SJohn MarinoThese macros are obsolete, new ports should use the target hook 6227e4b17023SJohn Marino@code{TARGET_MEMORY_MOVE_COST} instead. 6228e4b17023SJohn Marino@end defmac 6229e4b17023SJohn Marino 6230e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_MEMORY_MOVE_COST (enum machine_mode @var{mode}, reg_class_t @var{rclass}, bool @var{in}) 6231e4b17023SJohn MarinoThis target hook should return the cost of moving data of mode @var{mode} 6232e4b17023SJohn Marinobetween a register of class @var{rclass} and memory; @var{in} is @code{false} 6233e4b17023SJohn Marinoif the value is to be written to memory, @code{true} if it is to be read in. 6234e4b17023SJohn MarinoThis cost is relative to those in @code{TARGET_REGISTER_MOVE_COST}. 6235e4b17023SJohn MarinoIf moving between registers and memory is more expensive than between two 6236e4b17023SJohn Marinoregisters, you should add this target hook to express the relative cost. 6237e4b17023SJohn Marino 6238e4b17023SJohn MarinoIf you do not add this target hook, GCC uses a default cost of 4 plus 6239e4b17023SJohn Marinothe cost of copying via a secondary reload register, if one is 6240e4b17023SJohn Marinoneeded. If your machine requires a secondary reload register to copy 6241e4b17023SJohn Marinobetween memory and a register of @var{rclass} but the reload mechanism is 6242e4b17023SJohn Marinomore complex than copying via an intermediate, use this target hook to 6243e4b17023SJohn Marinoreflect the actual cost of the move. 6244e4b17023SJohn Marino 6245e4b17023SJohn MarinoGCC defines the function @code{memory_move_secondary_cost} if 6246e4b17023SJohn Marinosecondary reloads are needed. It computes the costs due to copying via 6247e4b17023SJohn Marinoa secondary register. If your machine copies from memory using a 6248e4b17023SJohn Marinosecondary register in the conventional way but the default base value of 6249e4b17023SJohn Marino4 is not correct for your machine, use this target hook to add some other 6250e4b17023SJohn Marinovalue to the result of that function. The arguments to that function 6251e4b17023SJohn Marinoare the same as to this target hook. 6252e4b17023SJohn Marino@end deftypefn 6253e4b17023SJohn Marino 6254e4b17023SJohn Marino@defmac BRANCH_COST (@var{speed_p}, @var{predictable_p}) 6255e4b17023SJohn MarinoA C expression for the cost of a branch instruction. A value of 1 is 6256e4b17023SJohn Marinothe default; other values are interpreted relative to that. Parameter 6257e4b17023SJohn Marino@var{speed_p} is true when the branch in question should be optimized 6258e4b17023SJohn Marinofor speed. When it is false, @code{BRANCH_COST} should return a value 6259e4b17023SJohn Marinooptimal for code size rather than performance. @var{predictable_p} is 6260e4b17023SJohn Marinotrue for well-predicted branches. On many architectures the 6261e4b17023SJohn Marino@code{BRANCH_COST} can be reduced then. 6262e4b17023SJohn Marino@end defmac 6263e4b17023SJohn Marino 6264e4b17023SJohn MarinoHere are additional macros which do not specify precise relative costs, 6265e4b17023SJohn Marinobut only that certain actions are more expensive than GCC would 6266e4b17023SJohn Marinoordinarily expect. 6267e4b17023SJohn Marino 6268e4b17023SJohn Marino@defmac SLOW_BYTE_ACCESS 6269e4b17023SJohn MarinoDefine this macro as a C expression which is nonzero if accessing less 6270e4b17023SJohn Marinothan a word of memory (i.e.@: a @code{char} or a @code{short}) is no 6271e4b17023SJohn Marinofaster than accessing a word of memory, i.e., if such access 6272e4b17023SJohn Marinorequire more than one instruction or if there is no difference in cost 6273e4b17023SJohn Marinobetween byte and (aligned) word loads. 6274e4b17023SJohn Marino 6275e4b17023SJohn MarinoWhen this macro is not defined, the compiler will access a field by 6276e4b17023SJohn Marinofinding the smallest containing object; when it is defined, a fullword 6277e4b17023SJohn Marinoload will be used if alignment permits. Unless bytes accesses are 6278e4b17023SJohn Marinofaster than word accesses, using word accesses is preferable since it 6279e4b17023SJohn Marinomay eliminate subsequent memory access if subsequent accesses occur to 6280e4b17023SJohn Marinoother fields in the same word of the structure, but to different bytes. 6281e4b17023SJohn Marino@end defmac 6282e4b17023SJohn Marino 6283e4b17023SJohn Marino@defmac SLOW_UNALIGNED_ACCESS (@var{mode}, @var{alignment}) 6284e4b17023SJohn MarinoDefine this macro to be the value 1 if memory accesses described by the 6285e4b17023SJohn Marino@var{mode} and @var{alignment} parameters have a cost many times greater 6286e4b17023SJohn Marinothan aligned accesses, for example if they are emulated in a trap 6287e4b17023SJohn Marinohandler. 6288e4b17023SJohn Marino 6289e4b17023SJohn MarinoWhen this macro is nonzero, the compiler will act as if 6290e4b17023SJohn Marino@code{STRICT_ALIGNMENT} were nonzero when generating code for block 6291e4b17023SJohn Marinomoves. This can cause significantly more instructions to be produced. 6292e4b17023SJohn MarinoTherefore, do not set this macro nonzero if unaligned accesses only add a 6293e4b17023SJohn Marinocycle or two to the time for a memory access. 6294e4b17023SJohn Marino 6295e4b17023SJohn MarinoIf the value of this macro is always zero, it need not be defined. If 6296e4b17023SJohn Marinothis macro is defined, it should produce a nonzero value when 6297e4b17023SJohn Marino@code{STRICT_ALIGNMENT} is nonzero. 6298e4b17023SJohn Marino@end defmac 6299e4b17023SJohn Marino 6300e4b17023SJohn Marino@defmac MOVE_RATIO (@var{speed}) 6301e4b17023SJohn MarinoThe threshold of number of scalar memory-to-memory move insns, @emph{below} 6302e4b17023SJohn Marinowhich a sequence of insns should be generated instead of a 6303e4b17023SJohn Marinostring move insn or a library call. Increasing the value will always 6304e4b17023SJohn Marinomake code faster, but eventually incurs high cost in increased code size. 6305e4b17023SJohn Marino 6306e4b17023SJohn MarinoNote that on machines where the corresponding move insn is a 6307e4b17023SJohn Marino@code{define_expand} that emits a sequence of insns, this macro counts 6308e4b17023SJohn Marinothe number of such sequences. 6309e4b17023SJohn Marino 6310e4b17023SJohn MarinoThe parameter @var{speed} is true if the code is currently being 6311e4b17023SJohn Marinooptimized for speed rather than size. 6312e4b17023SJohn Marino 6313e4b17023SJohn MarinoIf you don't define this, a reasonable default is used. 6314e4b17023SJohn Marino@end defmac 6315e4b17023SJohn Marino 6316e4b17023SJohn Marino@defmac MOVE_BY_PIECES_P (@var{size}, @var{alignment}) 6317e4b17023SJohn MarinoA C expression used to determine whether @code{move_by_pieces} will be used to 6318e4b17023SJohn Marinocopy a chunk of memory, or whether some other block move mechanism 6319e4b17023SJohn Marinowill be used. Defaults to 1 if @code{move_by_pieces_ninsns} returns less 6320e4b17023SJohn Marinothan @code{MOVE_RATIO}. 6321e4b17023SJohn Marino@end defmac 6322e4b17023SJohn Marino 6323e4b17023SJohn Marino@defmac MOVE_MAX_PIECES 6324e4b17023SJohn MarinoA C expression used by @code{move_by_pieces} to determine the largest unit 6325e4b17023SJohn Marinoa load or store used to copy memory is. Defaults to @code{MOVE_MAX}. 6326e4b17023SJohn Marino@end defmac 6327e4b17023SJohn Marino 6328e4b17023SJohn Marino@defmac CLEAR_RATIO (@var{speed}) 6329e4b17023SJohn MarinoThe threshold of number of scalar move insns, @emph{below} which a sequence 6330e4b17023SJohn Marinoof insns should be generated to clear memory instead of a string clear insn 6331e4b17023SJohn Marinoor a library call. Increasing the value will always make code faster, but 6332e4b17023SJohn Marinoeventually incurs high cost in increased code size. 6333e4b17023SJohn Marino 6334e4b17023SJohn MarinoThe parameter @var{speed} is true if the code is currently being 6335e4b17023SJohn Marinooptimized for speed rather than size. 6336e4b17023SJohn Marino 6337e4b17023SJohn MarinoIf you don't define this, a reasonable default is used. 6338e4b17023SJohn Marino@end defmac 6339e4b17023SJohn Marino 6340e4b17023SJohn Marino@defmac CLEAR_BY_PIECES_P (@var{size}, @var{alignment}) 6341e4b17023SJohn MarinoA C expression used to determine whether @code{clear_by_pieces} will be used 6342e4b17023SJohn Marinoto clear a chunk of memory, or whether some other block clear mechanism 6343e4b17023SJohn Marinowill be used. Defaults to 1 if @code{move_by_pieces_ninsns} returns less 6344e4b17023SJohn Marinothan @code{CLEAR_RATIO}. 6345e4b17023SJohn Marino@end defmac 6346e4b17023SJohn Marino 6347e4b17023SJohn Marino@defmac SET_RATIO (@var{speed}) 6348e4b17023SJohn MarinoThe threshold of number of scalar move insns, @emph{below} which a sequence 6349e4b17023SJohn Marinoof insns should be generated to set memory to a constant value, instead of 6350e4b17023SJohn Marinoa block set insn or a library call. 6351e4b17023SJohn MarinoIncreasing the value will always make code faster, but 6352e4b17023SJohn Marinoeventually incurs high cost in increased code size. 6353e4b17023SJohn Marino 6354e4b17023SJohn MarinoThe parameter @var{speed} is true if the code is currently being 6355e4b17023SJohn Marinooptimized for speed rather than size. 6356e4b17023SJohn Marino 6357e4b17023SJohn MarinoIf you don't define this, it defaults to the value of @code{MOVE_RATIO}. 6358e4b17023SJohn Marino@end defmac 6359e4b17023SJohn Marino 6360e4b17023SJohn Marino@defmac SET_BY_PIECES_P (@var{size}, @var{alignment}) 6361e4b17023SJohn MarinoA C expression used to determine whether @code{store_by_pieces} will be 6362e4b17023SJohn Marinoused to set a chunk of memory to a constant value, or whether some 6363e4b17023SJohn Marinoother mechanism will be used. Used by @code{__builtin_memset} when 6364e4b17023SJohn Marinostoring values other than constant zero. 6365e4b17023SJohn MarinoDefaults to 1 if @code{move_by_pieces_ninsns} returns less 6366e4b17023SJohn Marinothan @code{SET_RATIO}. 6367e4b17023SJohn Marino@end defmac 6368e4b17023SJohn Marino 6369e4b17023SJohn Marino@defmac STORE_BY_PIECES_P (@var{size}, @var{alignment}) 6370e4b17023SJohn MarinoA C expression used to determine whether @code{store_by_pieces} will be 6371e4b17023SJohn Marinoused to set a chunk of memory to a constant string value, or whether some 6372e4b17023SJohn Marinoother mechanism will be used. Used by @code{__builtin_strcpy} when 6373e4b17023SJohn Marinocalled with a constant source string. 6374e4b17023SJohn MarinoDefaults to 1 if @code{move_by_pieces_ninsns} returns less 6375e4b17023SJohn Marinothan @code{MOVE_RATIO}. 6376e4b17023SJohn Marino@end defmac 6377e4b17023SJohn Marino 6378e4b17023SJohn Marino@defmac USE_LOAD_POST_INCREMENT (@var{mode}) 6379e4b17023SJohn MarinoA C expression used to determine whether a load postincrement is a good 6380e4b17023SJohn Marinothing to use for a given mode. Defaults to the value of 6381e4b17023SJohn Marino@code{HAVE_POST_INCREMENT}. 6382e4b17023SJohn Marino@end defmac 6383e4b17023SJohn Marino 6384e4b17023SJohn Marino@defmac USE_LOAD_POST_DECREMENT (@var{mode}) 6385e4b17023SJohn MarinoA C expression used to determine whether a load postdecrement is a good 6386e4b17023SJohn Marinothing to use for a given mode. Defaults to the value of 6387e4b17023SJohn Marino@code{HAVE_POST_DECREMENT}. 6388e4b17023SJohn Marino@end defmac 6389e4b17023SJohn Marino 6390e4b17023SJohn Marino@defmac USE_LOAD_PRE_INCREMENT (@var{mode}) 6391e4b17023SJohn MarinoA C expression used to determine whether a load preincrement is a good 6392e4b17023SJohn Marinothing to use for a given mode. Defaults to the value of 6393e4b17023SJohn Marino@code{HAVE_PRE_INCREMENT}. 6394e4b17023SJohn Marino@end defmac 6395e4b17023SJohn Marino 6396e4b17023SJohn Marino@defmac USE_LOAD_PRE_DECREMENT (@var{mode}) 6397e4b17023SJohn MarinoA C expression used to determine whether a load predecrement is a good 6398e4b17023SJohn Marinothing to use for a given mode. Defaults to the value of 6399e4b17023SJohn Marino@code{HAVE_PRE_DECREMENT}. 6400e4b17023SJohn Marino@end defmac 6401e4b17023SJohn Marino 6402e4b17023SJohn Marino@defmac USE_STORE_POST_INCREMENT (@var{mode}) 6403e4b17023SJohn MarinoA C expression used to determine whether a store postincrement is a good 6404e4b17023SJohn Marinothing to use for a given mode. Defaults to the value of 6405e4b17023SJohn Marino@code{HAVE_POST_INCREMENT}. 6406e4b17023SJohn Marino@end defmac 6407e4b17023SJohn Marino 6408e4b17023SJohn Marino@defmac USE_STORE_POST_DECREMENT (@var{mode}) 6409e4b17023SJohn MarinoA C expression used to determine whether a store postdecrement is a good 6410e4b17023SJohn Marinothing to use for a given mode. Defaults to the value of 6411e4b17023SJohn Marino@code{HAVE_POST_DECREMENT}. 6412e4b17023SJohn Marino@end defmac 6413e4b17023SJohn Marino 6414e4b17023SJohn Marino@defmac USE_STORE_PRE_INCREMENT (@var{mode}) 6415e4b17023SJohn MarinoThis macro is used to determine whether a store preincrement is a good 6416e4b17023SJohn Marinothing to use for a given mode. Defaults to the value of 6417e4b17023SJohn Marino@code{HAVE_PRE_INCREMENT}. 6418e4b17023SJohn Marino@end defmac 6419e4b17023SJohn Marino 6420e4b17023SJohn Marino@defmac USE_STORE_PRE_DECREMENT (@var{mode}) 6421e4b17023SJohn MarinoThis macro is used to determine whether a store predecrement is a good 6422e4b17023SJohn Marinothing to use for a given mode. Defaults to the value of 6423e4b17023SJohn Marino@code{HAVE_PRE_DECREMENT}. 6424e4b17023SJohn Marino@end defmac 6425e4b17023SJohn Marino 6426e4b17023SJohn Marino@defmac NO_FUNCTION_CSE 6427e4b17023SJohn MarinoDefine this macro if it is as good or better to call a constant 6428e4b17023SJohn Marinofunction address than to call an address kept in a register. 6429e4b17023SJohn Marino@end defmac 6430e4b17023SJohn Marino 6431e4b17023SJohn Marino@defmac RANGE_TEST_NON_SHORT_CIRCUIT 6432e4b17023SJohn MarinoDefine this macro if a non-short-circuit operation produced by 6433e4b17023SJohn Marino@samp{fold_range_test ()} is optimal. This macro defaults to true if 6434e4b17023SJohn Marino@code{BRANCH_COST} is greater than or equal to the value 2. 6435e4b17023SJohn Marino@end defmac 6436e4b17023SJohn Marino 6437e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_RTX_COSTS (rtx @var{x}, int @var{code}, int @var{outer_code}, int @var{opno}, int *@var{total}, bool @var{speed}) 6438e4b17023SJohn MarinoThis target hook describes the relative costs of RTL expressions. 6439e4b17023SJohn Marino 6440e4b17023SJohn MarinoThe cost may depend on the precise form of the expression, which is 6441e4b17023SJohn Marinoavailable for examination in @var{x}, and the fact that @var{x} appears 6442e4b17023SJohn Marinoas operand @var{opno} of an expression with rtx code @var{outer_code}. 6443e4b17023SJohn MarinoThat is, the hook can assume that there is some rtx @var{y} such 6444e4b17023SJohn Marinothat @samp{GET_CODE (@var{y}) == @var{outer_code}} and such that 6445e4b17023SJohn Marinoeither (a) @samp{XEXP (@var{y}, @var{opno}) == @var{x}} or 6446e4b17023SJohn Marino(b) @samp{XVEC (@var{y}, @var{opno})} contains @var{x}. 6447e4b17023SJohn Marino 6448e4b17023SJohn Marino@var{code} is @var{x}'s expression code---redundant, since it can be 6449e4b17023SJohn Marinoobtained with @code{GET_CODE (@var{x})}. 6450e4b17023SJohn Marino 6451e4b17023SJohn MarinoIn implementing this hook, you can use the construct 6452e4b17023SJohn Marino@code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast 6453e4b17023SJohn Marinoinstructions. 6454e4b17023SJohn Marino 6455e4b17023SJohn MarinoOn entry to the hook, @code{*@var{total}} contains a default estimate 6456e4b17023SJohn Marinofor the cost of the expression. The hook should modify this value as 6457e4b17023SJohn Marinonecessary. Traditionally, the default costs are @code{COSTS_N_INSNS (5)} 6458e4b17023SJohn Marinofor multiplications, @code{COSTS_N_INSNS (7)} for division and modulus 6459e4b17023SJohn Marinooperations, and @code{COSTS_N_INSNS (1)} for all other operations. 6460e4b17023SJohn Marino 6461e4b17023SJohn MarinoWhen optimizing for code size, i.e.@: when @code{speed} is 6462e4b17023SJohn Marinofalse, this target hook should be used to estimate the relative 6463e4b17023SJohn Marinosize cost of an expression, again relative to @code{COSTS_N_INSNS}. 6464e4b17023SJohn Marino 6465e4b17023SJohn MarinoThe hook returns true when all subexpressions of @var{x} have been 6466e4b17023SJohn Marinoprocessed, and false when @code{rtx_cost} should recurse. 6467e4b17023SJohn Marino@end deftypefn 6468e4b17023SJohn Marino 6469e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ADDRESS_COST (rtx @var{address}, bool @var{speed}) 6470e4b17023SJohn MarinoThis hook computes the cost of an addressing mode that contains 6471e4b17023SJohn Marino@var{address}. If not defined, the cost is computed from 6472e4b17023SJohn Marinothe @var{address} expression and the @code{TARGET_RTX_COST} hook. 6473e4b17023SJohn Marino 6474e4b17023SJohn MarinoFor most CISC machines, the default cost is a good approximation of the 6475e4b17023SJohn Marinotrue cost of the addressing mode. However, on RISC machines, all 6476e4b17023SJohn Marinoinstructions normally have the same length and execution time. Hence 6477e4b17023SJohn Marinoall addresses will have equal costs. 6478e4b17023SJohn Marino 6479e4b17023SJohn MarinoIn cases where more than one form of an address is known, the form with 6480e4b17023SJohn Marinothe lowest cost will be used. If multiple forms have the same, lowest, 6481e4b17023SJohn Marinocost, the one that is the most complex will be used. 6482e4b17023SJohn Marino 6483e4b17023SJohn MarinoFor example, suppose an address that is equal to the sum of a register 6484e4b17023SJohn Marinoand a constant is used twice in the same basic block. When this macro 6485e4b17023SJohn Marinois not defined, the address will be computed in a register and memory 6486e4b17023SJohn Marinoreferences will be indirect through that register. On machines where 6487e4b17023SJohn Marinothe cost of the addressing mode containing the sum is no higher than 6488e4b17023SJohn Marinothat of a simple indirect reference, this will produce an additional 6489e4b17023SJohn Marinoinstruction and possibly require an additional register. Proper 6490e4b17023SJohn Marinospecification of this macro eliminates this overhead for such machines. 6491e4b17023SJohn Marino 6492e4b17023SJohn MarinoThis hook is never called with an invalid address. 6493e4b17023SJohn Marino 6494e4b17023SJohn MarinoOn machines where an address involving more than one register is as 6495e4b17023SJohn Marinocheap as an address computation involving only one register, defining 6496e4b17023SJohn Marino@code{TARGET_ADDRESS_COST} to reflect this can cause two registers to 6497e4b17023SJohn Marinobe live over a region of code where only one would have been if 6498e4b17023SJohn Marino@code{TARGET_ADDRESS_COST} were not defined in that manner. This effect 6499e4b17023SJohn Marinoshould be considered in the definition of this macro. Equivalent costs 6500e4b17023SJohn Marinoshould probably only be given to addresses with different numbers of 6501e4b17023SJohn Marinoregisters on machines with lots of registers. 6502e4b17023SJohn Marino@end deftypefn 6503e4b17023SJohn Marino 6504e4b17023SJohn Marino@node Scheduling 6505e4b17023SJohn Marino@section Adjusting the Instruction Scheduler 6506e4b17023SJohn Marino 6507e4b17023SJohn MarinoThe instruction scheduler may need a fair amount of machine-specific 6508e4b17023SJohn Marinoadjustment in order to produce good code. GCC provides several target 6509e4b17023SJohn Marinohooks for this purpose. It is usually enough to define just a few of 6510e4b17023SJohn Marinothem: try the first ones in this list first. 6511e4b17023SJohn Marino 6512e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_ISSUE_RATE (void) 6513e4b17023SJohn MarinoThis hook returns the maximum number of instructions that can ever 6514e4b17023SJohn Marinoissue at the same time on the target machine. The default is one. 6515e4b17023SJohn MarinoAlthough the insn scheduler can define itself the possibility of issue 6516e4b17023SJohn Marinoan insn on the same cycle, the value can serve as an additional 6517e4b17023SJohn Marinoconstraint to issue insns on the same simulated processor cycle (see 6518e4b17023SJohn Marinohooks @samp{TARGET_SCHED_REORDER} and @samp{TARGET_SCHED_REORDER2}). 6519e4b17023SJohn MarinoThis value must be constant over the entire compilation. If you need 6520e4b17023SJohn Marinoit to vary depending on what the instructions are, you must use 6521e4b17023SJohn Marino@samp{TARGET_SCHED_VARIABLE_ISSUE}. 6522e4b17023SJohn Marino@end deftypefn 6523e4b17023SJohn Marino 6524e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_VARIABLE_ISSUE (FILE *@var{file}, int @var{verbose}, rtx @var{insn}, int @var{more}) 6525e4b17023SJohn MarinoThis hook is executed by the scheduler after it has scheduled an insn 6526e4b17023SJohn Marinofrom the ready list. It should return the number of insns which can 6527e4b17023SJohn Marinostill be issued in the current cycle. The default is 6528e4b17023SJohn Marino@samp{@w{@var{more} - 1}} for insns other than @code{CLOBBER} and 6529e4b17023SJohn Marino@code{USE}, which normally are not counted against the issue rate. 6530e4b17023SJohn MarinoYou should define this hook if some insns take more machine resources 6531e4b17023SJohn Marinothan others, so that fewer insns can follow them in the same cycle. 6532e4b17023SJohn Marino@var{file} is either a null pointer, or a stdio stream to write any 6533e4b17023SJohn Marinodebug output to. @var{verbose} is the verbose level provided by 6534e4b17023SJohn Marino@option{-fsched-verbose-@var{n}}. @var{insn} is the instruction that 6535e4b17023SJohn Marinowas scheduled. 6536e4b17023SJohn Marino@end deftypefn 6537e4b17023SJohn Marino 6538e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_ADJUST_COST (rtx @var{insn}, rtx @var{link}, rtx @var{dep_insn}, int @var{cost}) 6539e4b17023SJohn MarinoThis function corrects the value of @var{cost} based on the 6540e4b17023SJohn Marinorelationship between @var{insn} and @var{dep_insn} through the 6541e4b17023SJohn Marinodependence @var{link}. It should return the new value. The default 6542e4b17023SJohn Marinois to make no adjustment to @var{cost}. This can be used for example 6543e4b17023SJohn Marinoto specify to the scheduler using the traditional pipeline description 6544e4b17023SJohn Marinothat an output- or anti-dependence does not incur the same cost as a 6545e4b17023SJohn Marinodata-dependence. If the scheduler using the automaton based pipeline 6546e4b17023SJohn Marinodescription, the cost of anti-dependence is zero and the cost of 6547e4b17023SJohn Marinooutput-dependence is maximum of one and the difference of latency 6548e4b17023SJohn Marinotimes of the first and the second insns. If these values are not 6549e4b17023SJohn Marinoacceptable, you could use the hook to modify them too. See also 6550e4b17023SJohn Marino@pxref{Processor pipeline description}. 6551e4b17023SJohn Marino@end deftypefn 6552e4b17023SJohn Marino 6553e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_ADJUST_PRIORITY (rtx @var{insn}, int @var{priority}) 6554e4b17023SJohn MarinoThis hook adjusts the integer scheduling priority @var{priority} of 6555e4b17023SJohn Marino@var{insn}. It should return the new priority. Increase the priority to 6556e4b17023SJohn Marinoexecute @var{insn} earlier, reduce the priority to execute @var{insn} 6557e4b17023SJohn Marinolater. Do not define this hook if you do not need to adjust the 6558e4b17023SJohn Marinoscheduling priorities of insns. 6559e4b17023SJohn Marino@end deftypefn 6560e4b17023SJohn Marino 6561e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_REORDER (FILE *@var{file}, int @var{verbose}, rtx *@var{ready}, int *@var{n_readyp}, int @var{clock}) 6562e4b17023SJohn MarinoThis hook is executed by the scheduler after it has scheduled the ready 6563e4b17023SJohn Marinolist, to allow the machine description to reorder it (for example to 6564e4b17023SJohn Marinocombine two small instructions together on @samp{VLIW} machines). 6565e4b17023SJohn Marino@var{file} is either a null pointer, or a stdio stream to write any 6566e4b17023SJohn Marinodebug output to. @var{verbose} is the verbose level provided by 6567e4b17023SJohn Marino@option{-fsched-verbose-@var{n}}. @var{ready} is a pointer to the ready 6568e4b17023SJohn Marinolist of instructions that are ready to be scheduled. @var{n_readyp} is 6569e4b17023SJohn Marinoa pointer to the number of elements in the ready list. The scheduler 6570e4b17023SJohn Marinoreads the ready list in reverse order, starting with 6571e4b17023SJohn Marino@var{ready}[@var{*n_readyp} @minus{} 1] and going to @var{ready}[0]. @var{clock} 6572e4b17023SJohn Marinois the timer tick of the scheduler. You may modify the ready list and 6573e4b17023SJohn Marinothe number of ready insns. The return value is the number of insns that 6574e4b17023SJohn Marinocan issue this cycle; normally this is just @code{issue_rate}. See also 6575e4b17023SJohn Marino@samp{TARGET_SCHED_REORDER2}. 6576e4b17023SJohn Marino@end deftypefn 6577e4b17023SJohn Marino 6578e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_REORDER2 (FILE *@var{file}, int @var{verbose}, rtx *@var{ready}, int *@var{n_readyp}, int @var{clock}) 6579e4b17023SJohn MarinoLike @samp{TARGET_SCHED_REORDER}, but called at a different time. That 6580e4b17023SJohn Marinofunction is called whenever the scheduler starts a new cycle. This one 6581e4b17023SJohn Marinois called once per iteration over a cycle, immediately after 6582e4b17023SJohn Marino@samp{TARGET_SCHED_VARIABLE_ISSUE}; it can reorder the ready list and 6583e4b17023SJohn Marinoreturn the number of insns to be scheduled in the same cycle. Defining 6584e4b17023SJohn Marinothis hook can be useful if there are frequent situations where 6585e4b17023SJohn Marinoscheduling one insn causes other insns to become ready in the same 6586e4b17023SJohn Marinocycle. These other insns can then be taken into account properly. 6587e4b17023SJohn Marino@end deftypefn 6588e4b17023SJohn Marino 6589e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK (rtx @var{head}, rtx @var{tail}) 6590e4b17023SJohn MarinoThis hook is called after evaluation forward dependencies of insns in 6591e4b17023SJohn Marinochain given by two parameter values (@var{head} and @var{tail} 6592e4b17023SJohn Marinocorrespondingly) but before insns scheduling of the insn chain. For 6593e4b17023SJohn Marinoexample, it can be used for better insn classification if it requires 6594e4b17023SJohn Marinoanalysis of dependencies. This hook can use backward and forward 6595e4b17023SJohn Marinodependencies of the insn scheduler because they are already 6596e4b17023SJohn Marinocalculated. 6597e4b17023SJohn Marino@end deftypefn 6598e4b17023SJohn Marino 6599e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_INIT (FILE *@var{file}, int @var{verbose}, int @var{max_ready}) 6600e4b17023SJohn MarinoThis hook is executed by the scheduler at the beginning of each block of 6601e4b17023SJohn Marinoinstructions that are to be scheduled. @var{file} is either a null 6602e4b17023SJohn Marinopointer, or a stdio stream to write any debug output to. @var{verbose} 6603e4b17023SJohn Marinois the verbose level provided by @option{-fsched-verbose-@var{n}}. 6604e4b17023SJohn Marino@var{max_ready} is the maximum number of insns in the current scheduling 6605e4b17023SJohn Marinoregion that can be live at the same time. This can be used to allocate 6606e4b17023SJohn Marinoscratch space if it is needed, e.g.@: by @samp{TARGET_SCHED_REORDER}. 6607e4b17023SJohn Marino@end deftypefn 6608e4b17023SJohn Marino 6609e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FINISH (FILE *@var{file}, int @var{verbose}) 6610e4b17023SJohn MarinoThis hook is executed by the scheduler at the end of each block of 6611e4b17023SJohn Marinoinstructions that are to be scheduled. It can be used to perform 6612e4b17023SJohn Marinocleanup of any actions done by the other scheduling hooks. @var{file} 6613e4b17023SJohn Marinois either a null pointer, or a stdio stream to write any debug output 6614e4b17023SJohn Marinoto. @var{verbose} is the verbose level provided by 6615e4b17023SJohn Marino@option{-fsched-verbose-@var{n}}. 6616e4b17023SJohn Marino@end deftypefn 6617e4b17023SJohn Marino 6618e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_INIT_GLOBAL (FILE *@var{file}, int @var{verbose}, int @var{old_max_uid}) 6619e4b17023SJohn MarinoThis hook is executed by the scheduler after function level initializations. 6620e4b17023SJohn Marino@var{file} is either a null pointer, or a stdio stream to write any debug output to. 6621e4b17023SJohn Marino@var{verbose} is the verbose level provided by @option{-fsched-verbose-@var{n}}. 6622e4b17023SJohn Marino@var{old_max_uid} is the maximum insn uid when scheduling begins. 6623e4b17023SJohn Marino@end deftypefn 6624e4b17023SJohn Marino 6625e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FINISH_GLOBAL (FILE *@var{file}, int @var{verbose}) 6626e4b17023SJohn MarinoThis is the cleanup hook corresponding to @code{TARGET_SCHED_INIT_GLOBAL}. 6627e4b17023SJohn Marino@var{file} is either a null pointer, or a stdio stream to write any debug output to. 6628e4b17023SJohn Marino@var{verbose} is the verbose level provided by @option{-fsched-verbose-@var{n}}. 6629e4b17023SJohn Marino@end deftypefn 6630e4b17023SJohn Marino 6631e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_SCHED_DFA_PRE_CYCLE_INSN (void) 6632e4b17023SJohn MarinoThe hook returns an RTL insn. The automaton state used in the 6633e4b17023SJohn Marinopipeline hazard recognizer is changed as if the insn were scheduled 6634e4b17023SJohn Marinowhen the new simulated processor cycle starts. Usage of the hook may 6635e4b17023SJohn Marinosimplify the automaton pipeline description for some @acronym{VLIW} 6636e4b17023SJohn Marinoprocessors. If the hook is defined, it is used only for the automaton 6637e4b17023SJohn Marinobased pipeline description. The default is not to change the state 6638e4b17023SJohn Marinowhen the new simulated processor cycle starts. 6639e4b17023SJohn Marino@end deftypefn 6640e4b17023SJohn Marino 6641e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN (void) 6642e4b17023SJohn MarinoThe hook can be used to initialize data used by the previous hook. 6643e4b17023SJohn Marino@end deftypefn 6644e4b17023SJohn Marino 6645e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_SCHED_DFA_POST_CYCLE_INSN (void) 6646e4b17023SJohn MarinoThe hook is analogous to @samp{TARGET_SCHED_DFA_PRE_CYCLE_INSN} but used 6647e4b17023SJohn Marinoto changed the state as if the insn were scheduled when the new 6648e4b17023SJohn Marinosimulated processor cycle finishes. 6649e4b17023SJohn Marino@end deftypefn 6650e4b17023SJohn Marino 6651e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_INIT_DFA_POST_CYCLE_INSN (void) 6652e4b17023SJohn MarinoThe hook is analogous to @samp{TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN} but 6653e4b17023SJohn Marinoused to initialize data used by the previous hook. 6654e4b17023SJohn Marino@end deftypefn 6655e4b17023SJohn Marino 6656e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_DFA_PRE_ADVANCE_CYCLE (void) 6657e4b17023SJohn MarinoThe hook to notify target that the current simulated cycle is about to finish. 6658e4b17023SJohn MarinoThe hook is analogous to @samp{TARGET_SCHED_DFA_PRE_CYCLE_INSN} but used 6659e4b17023SJohn Marinoto change the state in more complicated situations - e.g., when advancing 6660e4b17023SJohn Marinostate on a single insn is not enough. 6661e4b17023SJohn Marino@end deftypefn 6662e4b17023SJohn Marino 6663e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_DFA_POST_ADVANCE_CYCLE (void) 6664e4b17023SJohn MarinoThe hook to notify target that new simulated cycle has just started. 6665e4b17023SJohn MarinoThe hook is analogous to @samp{TARGET_SCHED_DFA_POST_CYCLE_INSN} but used 6666e4b17023SJohn Marinoto change the state in more complicated situations - e.g., when advancing 6667e4b17023SJohn Marinostate on a single insn is not enough. 6668e4b17023SJohn Marino@end deftypefn 6669e4b17023SJohn Marino 6670e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD (void) 6671e4b17023SJohn MarinoThis hook controls better choosing an insn from the ready insn queue 6672e4b17023SJohn Marinofor the @acronym{DFA}-based insn scheduler. Usually the scheduler 6673e4b17023SJohn Marinochooses the first insn from the queue. If the hook returns a positive 6674e4b17023SJohn Marinovalue, an additional scheduler code tries all permutations of 6675e4b17023SJohn Marino@samp{TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD ()} 6676e4b17023SJohn Marinosubsequent ready insns to choose an insn whose issue will result in 6677e4b17023SJohn Marinomaximal number of issued insns on the same cycle. For the 6678e4b17023SJohn Marino@acronym{VLIW} processor, the code could actually solve the problem of 6679e4b17023SJohn Marinopacking simple insns into the @acronym{VLIW} insn. Of course, if the 6680e4b17023SJohn Marinorules of @acronym{VLIW} packing are described in the automaton. 6681e4b17023SJohn Marino 6682e4b17023SJohn MarinoThis code also could be used for superscalar @acronym{RISC} 6683e4b17023SJohn Marinoprocessors. Let us consider a superscalar @acronym{RISC} processor 6684e4b17023SJohn Marinowith 3 pipelines. Some insns can be executed in pipelines @var{A} or 6685e4b17023SJohn Marino@var{B}, some insns can be executed only in pipelines @var{B} or 6686e4b17023SJohn Marino@var{C}, and one insn can be executed in pipeline @var{B}. The 6687e4b17023SJohn Marinoprocessor may issue the 1st insn into @var{A} and the 2nd one into 6688e4b17023SJohn Marino@var{B}. In this case, the 3rd insn will wait for freeing @var{B} 6689e4b17023SJohn Marinountil the next cycle. If the scheduler issues the 3rd insn the first, 6690e4b17023SJohn Marinothe processor could issue all 3 insns per cycle. 6691e4b17023SJohn Marino 6692e4b17023SJohn MarinoActually this code demonstrates advantages of the automaton based 6693e4b17023SJohn Marinopipeline hazard recognizer. We try quickly and easy many insn 6694e4b17023SJohn Marinoschedules to choose the best one. 6695e4b17023SJohn Marino 6696e4b17023SJohn MarinoThe default is no multipass scheduling. 6697e4b17023SJohn Marino@end deftypefn 6698e4b17023SJohn Marino 6699e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD (rtx @var{insn}) 6700e4b17023SJohn Marino 6701e4b17023SJohn MarinoThis hook controls what insns from the ready insn queue will be 6702e4b17023SJohn Marinoconsidered for the multipass insn scheduling. If the hook returns 6703e4b17023SJohn Marinozero for @var{insn}, the insn will be not chosen to 6704e4b17023SJohn Marinobe issued. 6705e4b17023SJohn Marino 6706e4b17023SJohn MarinoThe default is that any ready insns can be chosen to be issued. 6707e4b17023SJohn Marino@end deftypefn 6708e4b17023SJohn Marino 6709e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BEGIN (void *@var{data}, char *@var{ready_try}, int @var{n_ready}, bool @var{first_cycle_insn_p}) 6710e4b17023SJohn MarinoThis hook prepares the target backend for a new round of multipass 6711e4b17023SJohn Marinoscheduling. 6712e4b17023SJohn Marino@end deftypefn 6713e4b17023SJohn Marino 6714e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_ISSUE (void *@var{data}, char *@var{ready_try}, int @var{n_ready}, rtx @var{insn}, const void *@var{prev_data}) 6715e4b17023SJohn MarinoThis hook is called when multipass scheduling evaluates instruction INSN. 6716e4b17023SJohn Marino@end deftypefn 6717e4b17023SJohn Marino 6718e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BACKTRACK (const void *@var{data}, char *@var{ready_try}, int @var{n_ready}) 6719e4b17023SJohn MarinoThis is called when multipass scheduling backtracks from evaluation of 6720e4b17023SJohn Marinoan instruction. 6721e4b17023SJohn Marino@end deftypefn 6722e4b17023SJohn Marino 6723e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_END (const void *@var{data}) 6724e4b17023SJohn MarinoThis hook notifies the target about the result of the concluded current 6725e4b17023SJohn Marinoround of multipass scheduling. 6726e4b17023SJohn Marino@end deftypefn 6727e4b17023SJohn Marino 6728e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_INIT (void *@var{data}) 6729e4b17023SJohn MarinoThis hook initializes target-specific data used in multipass scheduling. 6730e4b17023SJohn Marino@end deftypefn 6731e4b17023SJohn Marino 6732e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_FINI (void *@var{data}) 6733e4b17023SJohn MarinoThis hook finalizes target-specific data used in multipass scheduling. 6734e4b17023SJohn Marino@end deftypefn 6735e4b17023SJohn Marino 6736e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_DFA_NEW_CYCLE (FILE *@var{dump}, int @var{verbose}, rtx @var{insn}, int @var{last_clock}, int @var{clock}, int *@var{sort_p}) 6737e4b17023SJohn MarinoThis hook is called by the insn scheduler before issuing @var{insn} 6738e4b17023SJohn Marinoon cycle @var{clock}. If the hook returns nonzero, 6739e4b17023SJohn Marino@var{insn} is not issued on this processor cycle. Instead, 6740e4b17023SJohn Marinothe processor cycle is advanced. If *@var{sort_p} 6741e4b17023SJohn Marinois zero, the insn ready queue is not sorted on the new cycle 6742e4b17023SJohn Marinostart as usually. @var{dump} and @var{verbose} specify the file and 6743e4b17023SJohn Marinoverbosity level to use for debugging output. 6744e4b17023SJohn Marino@var{last_clock} and @var{clock} are, respectively, the 6745e4b17023SJohn Marinoprocessor cycle on which the previous insn has been issued, 6746e4b17023SJohn Marinoand the current processor cycle. 6747e4b17023SJohn Marino@end deftypefn 6748e4b17023SJohn Marino 6749e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_SCHED_IS_COSTLY_DEPENDENCE (struct _dep *@var{_dep}, int @var{cost}, int @var{distance}) 6750e4b17023SJohn MarinoThis hook is used to define which dependences are considered costly by 6751e4b17023SJohn Marinothe target, so costly that it is not advisable to schedule the insns that 6752e4b17023SJohn Marinoare involved in the dependence too close to one another. The parameters 6753e4b17023SJohn Marinoto this hook are as follows: The first parameter @var{_dep} is the dependence 6754e4b17023SJohn Marinobeing evaluated. The second parameter @var{cost} is the cost of the 6755e4b17023SJohn Marinodependence as estimated by the scheduler, and the third 6756e4b17023SJohn Marinoparameter @var{distance} is the distance in cycles between the two insns. 6757e4b17023SJohn MarinoThe hook returns @code{true} if considering the distance between the two 6758e4b17023SJohn Marinoinsns the dependence between them is considered costly by the target, 6759e4b17023SJohn Marinoand @code{false} otherwise. 6760e4b17023SJohn Marino 6761e4b17023SJohn MarinoDefining this hook can be useful in multiple-issue out-of-order machines, 6762e4b17023SJohn Marinowhere (a) it's practically hopeless to predict the actual data/resource 6763e4b17023SJohn Marinodelays, however: (b) there's a better chance to predict the actual grouping 6764e4b17023SJohn Marinothat will be formed, and (c) correctly emulating the grouping can be very 6765e4b17023SJohn Marinoimportant. In such targets one may want to allow issuing dependent insns 6766e4b17023SJohn Marinocloser to one another---i.e., closer than the dependence distance; however, 6767e4b17023SJohn Marinonot in cases of ``costly dependences'', which this hooks allows to define. 6768e4b17023SJohn Marino@end deftypefn 6769e4b17023SJohn Marino 6770e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_H_I_D_EXTENDED (void) 6771e4b17023SJohn MarinoThis hook is called by the insn scheduler after emitting a new instruction to 6772e4b17023SJohn Marinothe instruction stream. The hook notifies a target backend to extend its 6773e4b17023SJohn Marinoper instruction data structures. 6774e4b17023SJohn Marino@end deftypefn 6775e4b17023SJohn Marino 6776e4b17023SJohn Marino@deftypefn {Target Hook} {void *} TARGET_SCHED_ALLOC_SCHED_CONTEXT (void) 6777e4b17023SJohn MarinoReturn a pointer to a store large enough to hold target scheduling context. 6778e4b17023SJohn Marino@end deftypefn 6779e4b17023SJohn Marino 6780e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_INIT_SCHED_CONTEXT (void *@var{tc}, bool @var{clean_p}) 6781e4b17023SJohn MarinoInitialize store pointed to by @var{tc} to hold target scheduling context. 6782e4b17023SJohn MarinoIt @var{clean_p} is true then initialize @var{tc} as if scheduler is at the 6783e4b17023SJohn Marinobeginning of the block. Otherwise, copy the current context into @var{tc}. 6784e4b17023SJohn Marino@end deftypefn 6785e4b17023SJohn Marino 6786e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_SET_SCHED_CONTEXT (void *@var{tc}) 6787e4b17023SJohn MarinoCopy target scheduling context pointed to by @var{tc} to the current context. 6788e4b17023SJohn Marino@end deftypefn 6789e4b17023SJohn Marino 6790e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_CLEAR_SCHED_CONTEXT (void *@var{tc}) 6791e4b17023SJohn MarinoDeallocate internal data in target scheduling context pointed to by @var{tc}. 6792e4b17023SJohn Marino@end deftypefn 6793e4b17023SJohn Marino 6794e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_FREE_SCHED_CONTEXT (void *@var{tc}) 6795e4b17023SJohn MarinoDeallocate a store for target scheduling context pointed to by @var{tc}. 6796e4b17023SJohn Marino@end deftypefn 6797e4b17023SJohn Marino 6798e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_SPECULATE_INSN (rtx @var{insn}, int @var{request}, rtx *@var{new_pat}) 6799e4b17023SJohn MarinoThis hook is called by the insn scheduler when @var{insn} has only 6800e4b17023SJohn Marinospeculative dependencies and therefore can be scheduled speculatively. 6801e4b17023SJohn MarinoThe hook is used to check if the pattern of @var{insn} has a speculative 6802e4b17023SJohn Marinoversion and, in case of successful check, to generate that speculative 6803e4b17023SJohn Marinopattern. The hook should return 1, if the instruction has a speculative form, 6804e4b17023SJohn Marinoor @minus{}1, if it doesn't. @var{request} describes the type of requested 6805e4b17023SJohn Marinospeculation. If the return value equals 1 then @var{new_pat} is assigned 6806e4b17023SJohn Marinothe generated speculative pattern. 6807e4b17023SJohn Marino@end deftypefn 6808e4b17023SJohn Marino 6809e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_SCHED_NEEDS_BLOCK_P (int @var{dep_status}) 6810e4b17023SJohn MarinoThis hook is called by the insn scheduler during generation of recovery code 6811e4b17023SJohn Marinofor @var{insn}. It should return @code{true}, if the corresponding check 6812e4b17023SJohn Marinoinstruction should branch to recovery code, or @code{false} otherwise. 6813e4b17023SJohn Marino@end deftypefn 6814e4b17023SJohn Marino 6815e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_SCHED_GEN_SPEC_CHECK (rtx @var{insn}, rtx @var{label}, int @var{mutate_p}) 6816e4b17023SJohn MarinoThis hook is called by the insn scheduler to generate a pattern for recovery 6817e4b17023SJohn Marinocheck instruction. If @var{mutate_p} is zero, then @var{insn} is a 6818e4b17023SJohn Marinospeculative instruction for which the check should be generated. 6819e4b17023SJohn Marino@var{label} is either a label of a basic block, where recovery code should 6820e4b17023SJohn Marinobe emitted, or a null pointer, when requested check doesn't branch to 6821e4b17023SJohn Marinorecovery code (a simple check). If @var{mutate_p} is nonzero, then 6822e4b17023SJohn Marinoa pattern for a branchy check corresponding to a simple check denoted by 6823e4b17023SJohn Marino@var{insn} should be generated. In this case @var{label} can't be null. 6824e4b17023SJohn Marino@end deftypefn 6825e4b17023SJohn Marino 6826e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD_SPEC (const_rtx @var{insn}) 6827e4b17023SJohn MarinoThis hook is used as a workaround for 6828e4b17023SJohn Marino@samp{TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD} not being 6829e4b17023SJohn Marinocalled on the first instruction of the ready list. The hook is used to 6830e4b17023SJohn Marinodiscard speculative instructions that stand first in the ready list from 6831e4b17023SJohn Marinobeing scheduled on the current cycle. If the hook returns @code{false}, 6832e4b17023SJohn Marino@var{insn} will not be chosen to be issued. 6833e4b17023SJohn MarinoFor non-speculative instructions, 6834e4b17023SJohn Marinothe hook should always return @code{true}. For example, in the ia64 backend 6835e4b17023SJohn Marinothe hook is used to cancel data speculative insns when the ALAT table 6836e4b17023SJohn Marinois nearly full. 6837e4b17023SJohn Marino@end deftypefn 6838e4b17023SJohn Marino 6839e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_SET_SCHED_FLAGS (struct spec_info_def *@var{spec_info}) 6840e4b17023SJohn MarinoThis hook is used by the insn scheduler to find out what features should be 6841e4b17023SJohn Marinoenabled/used. 6842e4b17023SJohn MarinoThe structure *@var{spec_info} should be filled in by the target. 6843e4b17023SJohn MarinoThe structure describes speculation types that can be used in the scheduler. 6844e4b17023SJohn Marino@end deftypefn 6845e4b17023SJohn Marino 6846e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_SMS_RES_MII (struct ddg *@var{g}) 6847e4b17023SJohn MarinoThis hook is called by the swing modulo scheduler to calculate a 6848e4b17023SJohn Marinoresource-based lower bound which is based on the resources available in 6849e4b17023SJohn Marinothe machine and the resources required by each instruction. The target 6850e4b17023SJohn Marinobackend can use @var{g} to calculate such bound. A very simple lower 6851e4b17023SJohn Marinobound will be used in case this hook is not implemented: the total number 6852e4b17023SJohn Marinoof instructions divided by the issue rate. 6853e4b17023SJohn Marino@end deftypefn 6854e4b17023SJohn Marino 6855e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_SCHED_DISPATCH (rtx @var{insn}, int @var{x}) 6856e4b17023SJohn MarinoThis hook is called by Haifa Scheduler. It returns true if dispatch scheduling 6857e4b17023SJohn Marinois supported in hardware and the condition specified in the parameter is true. 6858e4b17023SJohn Marino@end deftypefn 6859e4b17023SJohn Marino 6860e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SCHED_DISPATCH_DO (rtx @var{insn}, int @var{x}) 6861e4b17023SJohn MarinoThis hook is called by Haifa Scheduler. It performs the operation specified 6862e4b17023SJohn Marinoin its second parameter. 6863e4b17023SJohn Marino@end deftypefn 6864e4b17023SJohn Marino 6865e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_SCHED_EXPOSED_PIPELINE 6866e4b17023SJohn MarinoTrue if the processor has an exposed pipeline, which means that not just 6867e4b17023SJohn Marinothe order of instructions is important for correctness when scheduling, but 6868e4b17023SJohn Marinoalso the latencies of operations. 6869e4b17023SJohn Marino@end deftypevr 6870e4b17023SJohn Marino 6871e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_SCHED_REASSOCIATION_WIDTH (unsigned int @var{opc}, enum machine_mode @var{mode}) 6872e4b17023SJohn MarinoThis hook is called by tree reassociator to determine a level of 6873e4b17023SJohn Marinoparallelism required in output calculations chain. 6874e4b17023SJohn Marino@end deftypefn 6875e4b17023SJohn Marino 6876e4b17023SJohn Marino@node Sections 6877e4b17023SJohn Marino@section Dividing the Output into Sections (Texts, Data, @dots{}) 6878e4b17023SJohn Marino@c the above section title is WAY too long. maybe cut the part between 6879e4b17023SJohn Marino@c the (...)? --mew 10feb93 6880e4b17023SJohn Marino 6881e4b17023SJohn MarinoAn object file is divided into sections containing different types of 6882e4b17023SJohn Marinodata. In the most common case, there are three sections: the @dfn{text 6883e4b17023SJohn Marinosection}, which holds instructions and read-only data; the @dfn{data 6884e4b17023SJohn Marinosection}, which holds initialized writable data; and the @dfn{bss 6885e4b17023SJohn Marinosection}, which holds uninitialized data. Some systems have other kinds 6886e4b17023SJohn Marinoof sections. 6887e4b17023SJohn Marino 6888e4b17023SJohn Marino@file{varasm.c} provides several well-known sections, such as 6889e4b17023SJohn Marino@code{text_section}, @code{data_section} and @code{bss_section}. 6890e4b17023SJohn MarinoThe normal way of controlling a @code{@var{foo}_section} variable 6891e4b17023SJohn Marinois to define the associated @code{@var{FOO}_SECTION_ASM_OP} macro, 6892e4b17023SJohn Marinoas described below. The macros are only read once, when @file{varasm.c} 6893e4b17023SJohn Marinoinitializes itself, so their values must be run-time constants. 6894e4b17023SJohn MarinoThey may however depend on command-line flags. 6895e4b17023SJohn Marino 6896e4b17023SJohn Marino@emph{Note:} Some run-time files, such @file{crtstuff.c}, also make 6897e4b17023SJohn Marinouse of the @code{@var{FOO}_SECTION_ASM_OP} macros, and expect them 6898e4b17023SJohn Marinoto be string literals. 6899e4b17023SJohn Marino 6900e4b17023SJohn MarinoSome assemblers require a different string to be written every time a 6901e4b17023SJohn Marinosection is selected. If your assembler falls into this category, you 6902e4b17023SJohn Marinoshould define the @code{TARGET_ASM_INIT_SECTIONS} hook and use 6903e4b17023SJohn Marino@code{get_unnamed_section} to set up the sections. 6904e4b17023SJohn Marino 6905e4b17023SJohn MarinoYou must always create a @code{text_section}, either by defining 6906e4b17023SJohn Marino@code{TEXT_SECTION_ASM_OP} or by initializing @code{text_section} 6907e4b17023SJohn Marinoin @code{TARGET_ASM_INIT_SECTIONS}. The same is true of 6908e4b17023SJohn Marino@code{data_section} and @code{DATA_SECTION_ASM_OP}. If you do not 6909e4b17023SJohn Marinocreate a distinct @code{readonly_data_section}, the default is to 6910e4b17023SJohn Marinoreuse @code{text_section}. 6911e4b17023SJohn Marino 6912e4b17023SJohn MarinoAll the other @file{varasm.c} sections are optional, and are null 6913e4b17023SJohn Marinoif the target does not provide them. 6914e4b17023SJohn Marino 6915e4b17023SJohn Marino@defmac TEXT_SECTION_ASM_OP 6916e4b17023SJohn MarinoA C expression whose value is a string, including spacing, containing the 6917e4b17023SJohn Marinoassembler operation that should precede instructions and read-only data. 6918e4b17023SJohn MarinoNormally @code{"\t.text"} is right. 6919e4b17023SJohn Marino@end defmac 6920e4b17023SJohn Marino 6921e4b17023SJohn Marino@defmac HOT_TEXT_SECTION_NAME 6922e4b17023SJohn MarinoIf defined, a C string constant for the name of the section containing most 6923e4b17023SJohn Marinofrequently executed functions of the program. If not defined, GCC will provide 6924e4b17023SJohn Marinoa default definition if the target supports named sections. 6925e4b17023SJohn Marino@end defmac 6926e4b17023SJohn Marino 6927e4b17023SJohn Marino@defmac UNLIKELY_EXECUTED_TEXT_SECTION_NAME 6928e4b17023SJohn MarinoIf defined, a C string constant for the name of the section containing unlikely 6929e4b17023SJohn Marinoexecuted functions in the program. 6930e4b17023SJohn Marino@end defmac 6931e4b17023SJohn Marino 6932e4b17023SJohn Marino@defmac DATA_SECTION_ASM_OP 6933e4b17023SJohn MarinoA C expression whose value is a string, including spacing, containing the 6934e4b17023SJohn Marinoassembler operation to identify the following data as writable initialized 6935e4b17023SJohn Marinodata. Normally @code{"\t.data"} is right. 6936e4b17023SJohn Marino@end defmac 6937e4b17023SJohn Marino 6938e4b17023SJohn Marino@defmac SDATA_SECTION_ASM_OP 6939e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing, 6940e4b17023SJohn Marinocontaining the assembler operation to identify the following data as 6941e4b17023SJohn Marinoinitialized, writable small data. 6942e4b17023SJohn Marino@end defmac 6943e4b17023SJohn Marino 6944e4b17023SJohn Marino@defmac READONLY_DATA_SECTION_ASM_OP 6945e4b17023SJohn MarinoA C expression whose value is a string, including spacing, containing the 6946e4b17023SJohn Marinoassembler operation to identify the following data as read-only initialized 6947e4b17023SJohn Marinodata. 6948e4b17023SJohn Marino@end defmac 6949e4b17023SJohn Marino 6950e4b17023SJohn Marino@defmac BSS_SECTION_ASM_OP 6951e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing, 6952e4b17023SJohn Marinocontaining the assembler operation to identify the following data as 6953e4b17023SJohn Marinouninitialized global data. If not defined, and 6954e4b17023SJohn Marino@code{ASM_OUTPUT_ALIGNED_BSS} not defined, 6955e4b17023SJohn Marinouninitialized global data will be output in the data section if 6956e4b17023SJohn Marino@option{-fno-common} is passed, otherwise @code{ASM_OUTPUT_COMMON} will be 6957e4b17023SJohn Marinoused. 6958e4b17023SJohn Marino@end defmac 6959e4b17023SJohn Marino 6960e4b17023SJohn Marino@defmac SBSS_SECTION_ASM_OP 6961e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing, 6962e4b17023SJohn Marinocontaining the assembler operation to identify the following data as 6963e4b17023SJohn Marinouninitialized, writable small data. 6964e4b17023SJohn Marino@end defmac 6965e4b17023SJohn Marino 6966e4b17023SJohn Marino@defmac TLS_COMMON_ASM_OP 6967e4b17023SJohn MarinoIf defined, a C expression whose value is a string containing the 6968e4b17023SJohn Marinoassembler operation to identify the following data as thread-local 6969e4b17023SJohn Marinocommon data. The default is @code{".tls_common"}. 6970e4b17023SJohn Marino@end defmac 6971e4b17023SJohn Marino 6972e4b17023SJohn Marino@defmac TLS_SECTION_ASM_FLAG 6973e4b17023SJohn MarinoIf defined, a C expression whose value is a character constant 6974e4b17023SJohn Marinocontaining the flag used to mark a section as a TLS section. The 6975e4b17023SJohn Marinodefault is @code{'T'}. 6976e4b17023SJohn Marino@end defmac 6977e4b17023SJohn Marino 6978e4b17023SJohn Marino@defmac INIT_SECTION_ASM_OP 6979e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing, 6980e4b17023SJohn Marinocontaining the assembler operation to identify the following data as 6981e4b17023SJohn Marinoinitialization code. If not defined, GCC will assume such a section does 6982e4b17023SJohn Marinonot exist. This section has no corresponding @code{init_section} 6983e4b17023SJohn Marinovariable; it is used entirely in runtime code. 6984e4b17023SJohn Marino@end defmac 6985e4b17023SJohn Marino 6986e4b17023SJohn Marino@defmac FINI_SECTION_ASM_OP 6987e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing, 6988e4b17023SJohn Marinocontaining the assembler operation to identify the following data as 6989e4b17023SJohn Marinofinalization code. If not defined, GCC will assume such a section does 6990e4b17023SJohn Marinonot exist. This section has no corresponding @code{fini_section} 6991e4b17023SJohn Marinovariable; it is used entirely in runtime code. 6992e4b17023SJohn Marino@end defmac 6993e4b17023SJohn Marino 6994e4b17023SJohn Marino@defmac INIT_ARRAY_SECTION_ASM_OP 6995e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing, 6996e4b17023SJohn Marinocontaining the assembler operation to identify the following data as 6997e4b17023SJohn Marinopart of the @code{.init_array} (or equivalent) section. If not 6998e4b17023SJohn Marinodefined, GCC will assume such a section does not exist. Do not define 6999e4b17023SJohn Marinoboth this macro and @code{INIT_SECTION_ASM_OP}. 7000e4b17023SJohn Marino@end defmac 7001e4b17023SJohn Marino 7002e4b17023SJohn Marino@defmac FINI_ARRAY_SECTION_ASM_OP 7003e4b17023SJohn MarinoIf defined, a C expression whose value is a string, including spacing, 7004e4b17023SJohn Marinocontaining the assembler operation to identify the following data as 7005e4b17023SJohn Marinopart of the @code{.fini_array} (or equivalent) section. If not 7006e4b17023SJohn Marinodefined, GCC will assume such a section does not exist. Do not define 7007e4b17023SJohn Marinoboth this macro and @code{FINI_SECTION_ASM_OP}. 7008e4b17023SJohn Marino@end defmac 7009e4b17023SJohn Marino 7010e4b17023SJohn Marino@defmac CRT_CALL_STATIC_FUNCTION (@var{section_op}, @var{function}) 7011e4b17023SJohn MarinoIf defined, an ASM statement that switches to a different section 7012e4b17023SJohn Marinovia @var{section_op}, calls @var{function}, and switches back to 7013e4b17023SJohn Marinothe text section. This is used in @file{crtstuff.c} if 7014e4b17023SJohn Marino@code{INIT_SECTION_ASM_OP} or @code{FINI_SECTION_ASM_OP} to calls 7015e4b17023SJohn Marinoto initialization and finalization functions from the init and fini 7016e4b17023SJohn Marinosections. By default, this macro uses a simple function call. Some 7017e4b17023SJohn Marinoports need hand-crafted assembly code to avoid dependencies on 7018e4b17023SJohn Marinoregisters initialized in the function prologue or to ensure that 7019e4b17023SJohn Marinoconstant pools don't end up too far way in the text section. 7020e4b17023SJohn Marino@end defmac 7021e4b17023SJohn Marino 7022e4b17023SJohn Marino@defmac TARGET_LIBGCC_SDATA_SECTION 7023e4b17023SJohn MarinoIf defined, a string which names the section into which small 7024e4b17023SJohn Marinovariables defined in crtstuff and libgcc should go. This is useful 7025e4b17023SJohn Marinowhen the target has options for optimizing access to small data, and 7026e4b17023SJohn Marinoyou want the crtstuff and libgcc routines to be conservative in what 7027e4b17023SJohn Marinothey expect of your application yet liberal in what your application 7028e4b17023SJohn Marinoexpects. For example, for targets with a @code{.sdata} section (like 7029e4b17023SJohn MarinoMIPS), you could compile crtstuff with @code{-G 0} so that it doesn't 7030e4b17023SJohn Marinorequire small data support from your application, but use this macro 7031e4b17023SJohn Marinoto put small data into @code{.sdata} so that your application can 7032e4b17023SJohn Marinoaccess these variables whether it uses small data or not. 7033e4b17023SJohn Marino@end defmac 7034e4b17023SJohn Marino 7035e4b17023SJohn Marino@defmac FORCE_CODE_SECTION_ALIGN 7036e4b17023SJohn MarinoIf defined, an ASM statement that aligns a code section to some 7037e4b17023SJohn Marinoarbitrary boundary. This is used to force all fragments of the 7038e4b17023SJohn Marino@code{.init} and @code{.fini} sections to have to same alignment 7039e4b17023SJohn Marinoand thus prevent the linker from having to add any padding. 7040e4b17023SJohn Marino@end defmac 7041e4b17023SJohn Marino 7042e4b17023SJohn Marino@defmac JUMP_TABLES_IN_TEXT_SECTION 7043e4b17023SJohn MarinoDefine this macro to be an expression with a nonzero value if jump 7044e4b17023SJohn Marinotables (for @code{tablejump} insns) should be output in the text 7045e4b17023SJohn Marinosection, along with the assembler instructions. Otherwise, the 7046e4b17023SJohn Marinoreadonly data section is used. 7047e4b17023SJohn Marino 7048e4b17023SJohn MarinoThis macro is irrelevant if there is no separate readonly data section. 7049e4b17023SJohn Marino@end defmac 7050e4b17023SJohn Marino 7051e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_INIT_SECTIONS (void) 7052e4b17023SJohn MarinoDefine this hook if you need to do something special to set up the 7053e4b17023SJohn Marino@file{varasm.c} sections, or if your target has some special sections 7054e4b17023SJohn Marinoof its own that you need to create. 7055e4b17023SJohn Marino 7056e4b17023SJohn MarinoGCC calls this hook after processing the command line, but before writing 7057e4b17023SJohn Marinoany assembly code, and before calling any of the section-returning hooks 7058e4b17023SJohn Marinodescribed below. 7059e4b17023SJohn Marino@end deftypefn 7060e4b17023SJohn Marino 7061e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ASM_RELOC_RW_MASK (void) 7062e4b17023SJohn MarinoReturn a mask describing how relocations should be treated when 7063e4b17023SJohn Marinoselecting sections. Bit 1 should be set if global relocations 7064e4b17023SJohn Marinoshould be placed in a read-write section; bit 0 should be set if 7065e4b17023SJohn Marinolocal relocations should be placed in a read-write section. 7066e4b17023SJohn Marino 7067e4b17023SJohn MarinoThe default version of this function returns 3 when @option{-fpic} 7068e4b17023SJohn Marinois in effect, and 0 otherwise. The hook is typically redefined 7069e4b17023SJohn Marinowhen the target cannot support (some kinds of) dynamic relocations 7070e4b17023SJohn Marinoin read-only sections even in executables. 7071e4b17023SJohn Marino@end deftypefn 7072e4b17023SJohn Marino 7073e4b17023SJohn Marino@deftypefn {Target Hook} {section *} TARGET_ASM_SELECT_SECTION (tree @var{exp}, int @var{reloc}, unsigned HOST_WIDE_INT @var{align}) 7074e4b17023SJohn MarinoReturn the section into which @var{exp} should be placed. You can 7075e4b17023SJohn Marinoassume that @var{exp} is either a @code{VAR_DECL} node or a constant of 7076e4b17023SJohn Marinosome sort. @var{reloc} indicates whether the initial value of @var{exp} 7077e4b17023SJohn Marinorequires link-time relocations. Bit 0 is set when variable contains 7078e4b17023SJohn Marinolocal relocations only, while bit 1 is set for global relocations. 7079e4b17023SJohn Marino@var{align} is the constant alignment in bits. 7080e4b17023SJohn Marino 7081e4b17023SJohn MarinoThe default version of this function takes care of putting read-only 7082e4b17023SJohn Marinovariables in @code{readonly_data_section}. 7083e4b17023SJohn Marino 7084e4b17023SJohn MarinoSee also @var{USE_SELECT_SECTION_FOR_FUNCTIONS}. 7085e4b17023SJohn Marino@end deftypefn 7086e4b17023SJohn Marino 7087e4b17023SJohn Marino@defmac USE_SELECT_SECTION_FOR_FUNCTIONS 7088e4b17023SJohn MarinoDefine this macro if you wish TARGET_ASM_SELECT_SECTION to be called 7089e4b17023SJohn Marinofor @code{FUNCTION_DECL}s as well as for variables and constants. 7090e4b17023SJohn Marino 7091e4b17023SJohn MarinoIn the case of a @code{FUNCTION_DECL}, @var{reloc} will be zero if the 7092e4b17023SJohn Marinofunction has been determined to be likely to be called, and nonzero if 7093e4b17023SJohn Marinoit is unlikely to be called. 7094e4b17023SJohn Marino@end defmac 7095e4b17023SJohn Marino 7096e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_UNIQUE_SECTION (tree @var{decl}, int @var{reloc}) 7097e4b17023SJohn MarinoBuild up a unique section name, expressed as a @code{STRING_CST} node, 7098e4b17023SJohn Marinoand assign it to @samp{DECL_SECTION_NAME (@var{decl})}. 7099e4b17023SJohn MarinoAs with @code{TARGET_ASM_SELECT_SECTION}, @var{reloc} indicates whether 7100e4b17023SJohn Marinothe initial value of @var{exp} requires link-time relocations. 7101e4b17023SJohn Marino 7102e4b17023SJohn MarinoThe default version of this function appends the symbol name to the 7103e4b17023SJohn MarinoELF section name that would normally be used for the symbol. For 7104e4b17023SJohn Marinoexample, the function @code{foo} would be placed in @code{.text.foo}. 7105e4b17023SJohn MarinoWhatever the actual target object format, this is often good enough. 7106e4b17023SJohn Marino@end deftypefn 7107e4b17023SJohn Marino 7108e4b17023SJohn Marino@deftypefn {Target Hook} {section *} TARGET_ASM_FUNCTION_RODATA_SECTION (tree @var{decl}) 7109e4b17023SJohn MarinoReturn the readonly data section associated with 7110e4b17023SJohn Marino@samp{DECL_SECTION_NAME (@var{decl})}. 7111e4b17023SJohn MarinoThe default version of this function selects @code{.gnu.linkonce.r.name} if 7112e4b17023SJohn Marinothe function's section is @code{.gnu.linkonce.t.name}, @code{.rodata.name} 7113e4b17023SJohn Marinoif function is in @code{.text.name}, and the normal readonly-data section 7114e4b17023SJohn Marinootherwise. 7115e4b17023SJohn Marino@end deftypefn 7116e4b17023SJohn Marino 7117e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_ASM_MERGEABLE_RODATA_PREFIX 7118e4b17023SJohn MarinoUsually, the compiler uses the prefix @code{".rodata"} to construct 7119e4b17023SJohn Marinosection names for mergeable constant data. Define this macro to override 7120e4b17023SJohn Marinothe string if a different section name should be used. 7121e4b17023SJohn Marino@end deftypevr 7122e4b17023SJohn Marino 7123e4b17023SJohn Marino@deftypefn {Target Hook} {section *} TARGET_ASM_TM_CLONE_TABLE_SECTION (void) 7124e4b17023SJohn MarinoReturn the section that should be used for transactional memory clone tables. 7125e4b17023SJohn Marino@end deftypefn 7126e4b17023SJohn Marino 7127e4b17023SJohn Marino@deftypefn {Target Hook} {section *} TARGET_ASM_SELECT_RTX_SECTION (enum machine_mode @var{mode}, rtx @var{x}, unsigned HOST_WIDE_INT @var{align}) 7128e4b17023SJohn MarinoReturn the section into which a constant @var{x}, of mode @var{mode}, 7129e4b17023SJohn Marinoshould be placed. You can assume that @var{x} is some kind of 7130e4b17023SJohn Marinoconstant in RTL@. The argument @var{mode} is redundant except in the 7131e4b17023SJohn Marinocase of a @code{const_int} rtx. @var{align} is the constant alignment 7132e4b17023SJohn Marinoin bits. 7133e4b17023SJohn Marino 7134e4b17023SJohn MarinoThe default version of this function takes care of putting symbolic 7135e4b17023SJohn Marinoconstants in @code{flag_pic} mode in @code{data_section} and everything 7136e4b17023SJohn Marinoelse in @code{readonly_data_section}. 7137e4b17023SJohn Marino@end deftypefn 7138e4b17023SJohn Marino 7139e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_MANGLE_DECL_ASSEMBLER_NAME (tree @var{decl}, tree @var{id}) 7140e4b17023SJohn MarinoDefine this hook if you need to postprocess the assembler name generated 7141e4b17023SJohn Marinoby target-independent code. The @var{id} provided to this hook will be 7142e4b17023SJohn Marinothe computed name (e.g., the macro @code{DECL_NAME} of the @var{decl} in C, 7143e4b17023SJohn Marinoor the mangled name of the @var{decl} in C++). The return value of the 7144e4b17023SJohn Marinohook is an @code{IDENTIFIER_NODE} for the appropriate mangled name on 7145e4b17023SJohn Marinoyour target system. The default implementation of this hook just 7146e4b17023SJohn Marinoreturns the @var{id} provided. 7147e4b17023SJohn Marino@end deftypefn 7148e4b17023SJohn Marino 7149e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ENCODE_SECTION_INFO (tree @var{decl}, rtx @var{rtl}, int @var{new_decl_p}) 7150e4b17023SJohn MarinoDefine this hook if references to a symbol or a constant must be 7151e4b17023SJohn Marinotreated differently depending on something about the variable or 7152e4b17023SJohn Marinofunction named by the symbol (such as what section it is in). 7153e4b17023SJohn Marino 7154e4b17023SJohn MarinoThe hook is executed immediately after rtl has been created for 7155e4b17023SJohn Marino@var{decl}, which may be a variable or function declaration or 7156e4b17023SJohn Marinoan entry in the constant pool. In either case, @var{rtl} is the 7157e4b17023SJohn Marinortl in question. Do @emph{not} use @code{DECL_RTL (@var{decl})} 7158e4b17023SJohn Marinoin this hook; that field may not have been initialized yet. 7159e4b17023SJohn Marino 7160e4b17023SJohn MarinoIn the case of a constant, it is safe to assume that the rtl is 7161e4b17023SJohn Marinoa @code{mem} whose address is a @code{symbol_ref}. Most decls 7162e4b17023SJohn Marinowill also have this form, but that is not guaranteed. Global 7163e4b17023SJohn Marinoregister variables, for instance, will have a @code{reg} for their 7164e4b17023SJohn Marinortl. (Normally the right thing to do with such unusual rtl is 7165e4b17023SJohn Marinoleave it alone.) 7166e4b17023SJohn Marino 7167e4b17023SJohn MarinoThe @var{new_decl_p} argument will be true if this is the first time 7168e4b17023SJohn Marinothat @code{TARGET_ENCODE_SECTION_INFO} has been invoked on this decl. It will 7169e4b17023SJohn Marinobe false for subsequent invocations, which will happen for duplicate 7170e4b17023SJohn Marinodeclarations. Whether or not anything must be done for the duplicate 7171e4b17023SJohn Marinodeclaration depends on whether the hook examines @code{DECL_ATTRIBUTES}. 7172e4b17023SJohn Marino@var{new_decl_p} is always true when the hook is called for a constant. 7173e4b17023SJohn Marino 7174e4b17023SJohn Marino@cindex @code{SYMBOL_REF_FLAG}, in @code{TARGET_ENCODE_SECTION_INFO} 7175e4b17023SJohn MarinoThe usual thing for this hook to do is to record flags in the 7176e4b17023SJohn Marino@code{symbol_ref}, using @code{SYMBOL_REF_FLAG} or @code{SYMBOL_REF_FLAGS}. 7177e4b17023SJohn MarinoHistorically, the name string was modified if it was necessary to 7178e4b17023SJohn Marinoencode more than one bit of information, but this practice is now 7179e4b17023SJohn Marinodiscouraged; use @code{SYMBOL_REF_FLAGS}. 7180e4b17023SJohn Marino 7181e4b17023SJohn MarinoThe default definition of this hook, @code{default_encode_section_info} 7182e4b17023SJohn Marinoin @file{varasm.c}, sets a number of commonly-useful bits in 7183e4b17023SJohn Marino@code{SYMBOL_REF_FLAGS}. Check whether the default does what you need 7184e4b17023SJohn Marinobefore overriding it. 7185e4b17023SJohn Marino@end deftypefn 7186e4b17023SJohn Marino 7187e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_STRIP_NAME_ENCODING (const char *@var{name}) 7188e4b17023SJohn MarinoDecode @var{name} and return the real name part, sans 7189e4b17023SJohn Marinothe characters that @code{TARGET_ENCODE_SECTION_INFO} 7190e4b17023SJohn Marinomay have added. 7191e4b17023SJohn Marino@end deftypefn 7192e4b17023SJohn Marino 7193e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_IN_SMALL_DATA_P (const_tree @var{exp}) 7194e4b17023SJohn MarinoReturns true if @var{exp} should be placed into a ``small data'' section. 7195e4b17023SJohn MarinoThe default version of this hook always returns false. 7196e4b17023SJohn Marino@end deftypefn 7197e4b17023SJohn Marino 7198e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_HAVE_SRODATA_SECTION 7199e4b17023SJohn MarinoContains the value true if the target places read-only 7200e4b17023SJohn Marino``small data'' into a separate section. The default value is false. 7201e4b17023SJohn Marino@end deftypevr 7202e4b17023SJohn Marino 7203e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_PROFILE_BEFORE_PROLOGUE (void) 7204e4b17023SJohn MarinoIt returns true if target wants profile code emitted before prologue. 7205e4b17023SJohn Marino 7206e4b17023SJohn MarinoThe default version of this hook use the target macro 7207e4b17023SJohn Marino@code{PROFILE_BEFORE_PROLOGUE}. 7208e4b17023SJohn Marino@end deftypefn 7209e4b17023SJohn Marino 7210e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_BINDS_LOCAL_P (const_tree @var{exp}) 7211e4b17023SJohn MarinoReturns true if @var{exp} names an object for which name resolution 7212e4b17023SJohn Marinorules must resolve to the current ``module'' (dynamic shared library 7213e4b17023SJohn Marinoor executable image). 7214e4b17023SJohn Marino 7215e4b17023SJohn MarinoThe default version of this hook implements the name resolution rules 7216e4b17023SJohn Marinofor ELF, which has a looser model of global name binding than other 7217e4b17023SJohn Marinocurrently supported object file formats. 7218e4b17023SJohn Marino@end deftypefn 7219e4b17023SJohn Marino 7220e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_HAVE_TLS 7221e4b17023SJohn MarinoContains the value true if the target supports thread-local storage. 7222e4b17023SJohn MarinoThe default value is false. 7223e4b17023SJohn Marino@end deftypevr 7224e4b17023SJohn Marino 7225e4b17023SJohn Marino 7226e4b17023SJohn Marino@node PIC 7227e4b17023SJohn Marino@section Position Independent Code 7228e4b17023SJohn Marino@cindex position independent code 7229e4b17023SJohn Marino@cindex PIC 7230e4b17023SJohn Marino 7231e4b17023SJohn MarinoThis section describes macros that help implement generation of position 7232e4b17023SJohn Marinoindependent code. Simply defining these macros is not enough to 7233e4b17023SJohn Marinogenerate valid PIC; you must also add support to the hook 7234e4b17023SJohn Marino@code{TARGET_LEGITIMATE_ADDRESS_P} and to the macro 7235e4b17023SJohn Marino@code{PRINT_OPERAND_ADDRESS}, as well as @code{LEGITIMIZE_ADDRESS}. You 7236e4b17023SJohn Marinomust modify the definition of @samp{movsi} to do something appropriate 7237e4b17023SJohn Marinowhen the source operand contains a symbolic address. You may also 7238e4b17023SJohn Marinoneed to alter the handling of switch statements so that they use 7239e4b17023SJohn Marinorelative addresses. 7240e4b17023SJohn Marino@c i rearranged the order of the macros above to try to force one of 7241e4b17023SJohn Marino@c them to the next line, to eliminate an overfull hbox. --mew 10feb93 7242e4b17023SJohn Marino 7243e4b17023SJohn Marino@defmac PIC_OFFSET_TABLE_REGNUM 7244e4b17023SJohn MarinoThe register number of the register used to address a table of static 7245e4b17023SJohn Marinodata addresses in memory. In some cases this register is defined by a 7246e4b17023SJohn Marinoprocessor's ``application binary interface'' (ABI)@. When this macro 7247e4b17023SJohn Marinois defined, RTL is generated for this register once, as with the stack 7248e4b17023SJohn Marinopointer and frame pointer registers. If this macro is not defined, it 7249e4b17023SJohn Marinois up to the machine-dependent files to allocate such a register (if 7250e4b17023SJohn Marinonecessary). Note that this register must be fixed when in use (e.g.@: 7251e4b17023SJohn Marinowhen @code{flag_pic} is true). 7252e4b17023SJohn Marino@end defmac 7253e4b17023SJohn Marino 7254e4b17023SJohn Marino@defmac PIC_OFFSET_TABLE_REG_CALL_CLOBBERED 7255e4b17023SJohn MarinoA C expression that is nonzero if the register defined by 7256e4b17023SJohn Marino@code{PIC_OFFSET_TABLE_REGNUM} is clobbered by calls. If not defined, 7257e4b17023SJohn Marinothe default is zero. Do not define 7258e4b17023SJohn Marinothis macro if @code{PIC_OFFSET_TABLE_REGNUM} is not defined. 7259e4b17023SJohn Marino@end defmac 7260e4b17023SJohn Marino 7261e4b17023SJohn Marino@defmac LEGITIMATE_PIC_OPERAND_P (@var{x}) 7262e4b17023SJohn MarinoA C expression that is nonzero if @var{x} is a legitimate immediate 7263e4b17023SJohn Marinooperand on the target machine when generating position independent code. 7264e4b17023SJohn MarinoYou can assume that @var{x} satisfies @code{CONSTANT_P}, so you need not 7265e4b17023SJohn Marinocheck this. You can also assume @var{flag_pic} is true, so you need not 7266e4b17023SJohn Marinocheck it either. You need not define this macro if all constants 7267e4b17023SJohn Marino(including @code{SYMBOL_REF}) can be immediate operands when generating 7268e4b17023SJohn Marinoposition independent code. 7269e4b17023SJohn Marino@end defmac 7270e4b17023SJohn Marino 7271e4b17023SJohn Marino@node Assembler Format 7272e4b17023SJohn Marino@section Defining the Output Assembler Language 7273e4b17023SJohn Marino 7274e4b17023SJohn MarinoThis section describes macros whose principal purpose is to describe how 7275e4b17023SJohn Marinoto write instructions in assembler language---rather than what the 7276e4b17023SJohn Marinoinstructions do. 7277e4b17023SJohn Marino 7278e4b17023SJohn Marino@menu 7279e4b17023SJohn Marino* File Framework:: Structural information for the assembler file. 7280e4b17023SJohn Marino* Data Output:: Output of constants (numbers, strings, addresses). 7281e4b17023SJohn Marino* Uninitialized Data:: Output of uninitialized variables. 7282e4b17023SJohn Marino* Label Output:: Output and generation of labels. 7283e4b17023SJohn Marino* Initialization:: General principles of initialization 7284e4b17023SJohn Marino and termination routines. 7285e4b17023SJohn Marino* Macros for Initialization:: 7286e4b17023SJohn Marino Specific macros that control the handling of 7287e4b17023SJohn Marino initialization and termination routines. 7288e4b17023SJohn Marino* Instruction Output:: Output of actual instructions. 7289e4b17023SJohn Marino* Dispatch Tables:: Output of jump tables. 7290e4b17023SJohn Marino* Exception Region Output:: Output of exception region code. 7291e4b17023SJohn Marino* Alignment Output:: Pseudo ops for alignment and skipping data. 7292e4b17023SJohn Marino@end menu 7293e4b17023SJohn Marino 7294e4b17023SJohn Marino@node File Framework 7295e4b17023SJohn Marino@subsection The Overall Framework of an Assembler File 7296e4b17023SJohn Marino@cindex assembler format 7297e4b17023SJohn Marino@cindex output of assembler code 7298e4b17023SJohn Marino 7299e4b17023SJohn Marino@c prevent bad page break with this line 7300e4b17023SJohn MarinoThis describes the overall framework of an assembly file. 7301e4b17023SJohn Marino 7302e4b17023SJohn Marino@findex default_file_start 7303e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_FILE_START (void) 7304e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which the assembler expects to 7305e4b17023SJohn Marinofind at the beginning of a file. The default behavior is controlled 7306e4b17023SJohn Marinoby two flags, documented below. Unless your target's assembler is 7307e4b17023SJohn Marinoquite unusual, if you override the default, you should call 7308e4b17023SJohn Marino@code{default_file_start} at some point in your target hook. This 7309e4b17023SJohn Marinolets other target files rely on these variables. 7310e4b17023SJohn Marino@end deftypefn 7311e4b17023SJohn Marino 7312e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_ASM_FILE_START_APP_OFF 7313e4b17023SJohn MarinoIf this flag is true, the text of the macro @code{ASM_APP_OFF} will be 7314e4b17023SJohn Marinoprinted as the very first line in the assembly file, unless 7315e4b17023SJohn Marino@option{-fverbose-asm} is in effect. (If that macro has been defined 7316e4b17023SJohn Marinoto the empty string, this variable has no effect.) With the normal 7317e4b17023SJohn Marinodefinition of @code{ASM_APP_OFF}, the effect is to notify the GNU 7318e4b17023SJohn Marinoassembler that it need not bother stripping comments or extra 7319e4b17023SJohn Marinowhitespace from its input. This allows it to work a bit faster. 7320e4b17023SJohn Marino 7321e4b17023SJohn MarinoThe default is false. You should not set it to true unless you have 7322e4b17023SJohn Marinoverified that your port does not generate any extra whitespace or 7323e4b17023SJohn Marinocomments that will cause GAS to issue errors in NO_APP mode. 7324e4b17023SJohn Marino@end deftypevr 7325e4b17023SJohn Marino 7326e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_ASM_FILE_START_FILE_DIRECTIVE 7327e4b17023SJohn MarinoIf this flag is true, @code{output_file_directive} will be called 7328e4b17023SJohn Marinofor the primary source file, immediately after printing 7329e4b17023SJohn Marino@code{ASM_APP_OFF} (if that is enabled). Most ELF assemblers expect 7330e4b17023SJohn Marinothis to be done. The default is false. 7331e4b17023SJohn Marino@end deftypevr 7332e4b17023SJohn Marino 7333e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_FILE_END (void) 7334e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which the assembler expects 7335e4b17023SJohn Marinoto find at the end of a file. The default is to output nothing. 7336e4b17023SJohn Marino@end deftypefn 7337e4b17023SJohn Marino 7338e4b17023SJohn Marino@deftypefun void file_end_indicate_exec_stack () 7339e4b17023SJohn MarinoSome systems use a common convention, the @samp{.note.GNU-stack} 7340e4b17023SJohn Marinospecial section, to indicate whether or not an object file relies on 7341e4b17023SJohn Marinothe stack being executable. If your system uses this convention, you 7342e4b17023SJohn Marinoshould define @code{TARGET_ASM_FILE_END} to this function. If you 7343e4b17023SJohn Marinoneed to do other things in that hook, have your hook function call 7344e4b17023SJohn Marinothis function. 7345e4b17023SJohn Marino@end deftypefun 7346e4b17023SJohn Marino 7347e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_LTO_START (void) 7348e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which the assembler expects 7349e4b17023SJohn Marinoto find at the start of an LTO section. The default is to output 7350e4b17023SJohn Marinonothing. 7351e4b17023SJohn Marino@end deftypefn 7352e4b17023SJohn Marino 7353e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_LTO_END (void) 7354e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which the assembler expects 7355e4b17023SJohn Marinoto find at the end of an LTO section. The default is to output 7356e4b17023SJohn Marinonothing. 7357e4b17023SJohn Marino@end deftypefn 7358e4b17023SJohn Marino 7359e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_CODE_END (void) 7360e4b17023SJohn MarinoOutput to @code{asm_out_file} any text which is needed before emitting 7361e4b17023SJohn Marinounwind info and debug info at the end of a file. Some targets emit 7362e4b17023SJohn Marinohere PIC setup thunks that cannot be emitted at the end of file, 7363e4b17023SJohn Marinobecause they couldn't have unwind info then. The default is to output 7364e4b17023SJohn Marinonothing. 7365e4b17023SJohn Marino@end deftypefn 7366e4b17023SJohn Marino 7367e4b17023SJohn Marino@defmac ASM_COMMENT_START 7368e4b17023SJohn MarinoA C string constant describing how to begin a comment in the target 7369e4b17023SJohn Marinoassembler language. The compiler assumes that the comment will end at 7370e4b17023SJohn Marinothe end of the line. 7371e4b17023SJohn Marino@end defmac 7372e4b17023SJohn Marino 7373e4b17023SJohn Marino@defmac ASM_APP_ON 7374e4b17023SJohn MarinoA C string constant for text to be output before each @code{asm} 7375e4b17023SJohn Marinostatement or group of consecutive ones. Normally this is 7376e4b17023SJohn Marino@code{"#APP"}, which is a comment that has no effect on most 7377e4b17023SJohn Marinoassemblers but tells the GNU assembler that it must check the lines 7378e4b17023SJohn Marinothat follow for all valid assembler constructs. 7379e4b17023SJohn Marino@end defmac 7380e4b17023SJohn Marino 7381e4b17023SJohn Marino@defmac ASM_APP_OFF 7382e4b17023SJohn MarinoA C string constant for text to be output after each @code{asm} 7383e4b17023SJohn Marinostatement or group of consecutive ones. Normally this is 7384e4b17023SJohn Marino@code{"#NO_APP"}, which tells the GNU assembler to resume making the 7385e4b17023SJohn Marinotime-saving assumptions that are valid for ordinary compiler output. 7386e4b17023SJohn Marino@end defmac 7387e4b17023SJohn Marino 7388e4b17023SJohn Marino@defmac ASM_OUTPUT_SOURCE_FILENAME (@var{stream}, @var{name}) 7389e4b17023SJohn MarinoA C statement to output COFF information or DWARF debugging information 7390e4b17023SJohn Marinowhich indicates that filename @var{name} is the current source file to 7391e4b17023SJohn Marinothe stdio stream @var{stream}. 7392e4b17023SJohn Marino 7393e4b17023SJohn MarinoThis macro need not be defined if the standard form of output 7394e4b17023SJohn Marinofor the file format in use is appropriate. 7395e4b17023SJohn Marino@end defmac 7396e4b17023SJohn Marino 7397e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_OUTPUT_SOURCE_FILENAME (FILE *@var{file}, const char *@var{name}) 7398e4b17023SJohn MarinoOutput COFF information or DWARF debugging information which indicates that filename @var{name} is the current source file to the stdio stream @var{file}. 7399e4b17023SJohn Marino 7400e4b17023SJohn Marino This target hook need not be defined if the standard form of output for the file format in use is appropriate. 7401e4b17023SJohn Marino@end deftypefn 7402e4b17023SJohn Marino 7403e4b17023SJohn Marino@defmac OUTPUT_QUOTED_STRING (@var{stream}, @var{string}) 7404e4b17023SJohn MarinoA C statement to output the string @var{string} to the stdio stream 7405e4b17023SJohn Marino@var{stream}. If you do not call the function @code{output_quoted_string} 7406e4b17023SJohn Marinoin your config files, GCC will only call it to output filenames to 7407e4b17023SJohn Marinothe assembler source. So you can use it to canonicalize the format 7408e4b17023SJohn Marinoof the filename using this macro. 7409e4b17023SJohn Marino@end defmac 7410e4b17023SJohn Marino 7411e4b17023SJohn Marino@defmac ASM_OUTPUT_IDENT (@var{stream}, @var{string}) 7412e4b17023SJohn MarinoA C statement to output something to the assembler file to handle a 7413e4b17023SJohn Marino@samp{#ident} directive containing the text @var{string}. If this 7414e4b17023SJohn Marinomacro is not defined, nothing is output for a @samp{#ident} directive. 7415e4b17023SJohn Marino@end defmac 7416e4b17023SJohn Marino 7417e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_NAMED_SECTION (const char *@var{name}, unsigned int @var{flags}, tree @var{decl}) 7418e4b17023SJohn MarinoOutput assembly directives to switch to section @var{name}. The section 7419e4b17023SJohn Marinoshould have attributes as specified by @var{flags}, which is a bit mask 7420e4b17023SJohn Marinoof the @code{SECTION_*} flags defined in @file{output.h}. If @var{decl} 7421e4b17023SJohn Marinois non-NULL, it is the @code{VAR_DECL} or @code{FUNCTION_DECL} with which 7422e4b17023SJohn Marinothis section is associated. 7423e4b17023SJohn Marino@end deftypefn 7424e4b17023SJohn Marino 7425e4b17023SJohn Marino@deftypefn {Target Hook} {section *} TARGET_ASM_FUNCTION_SECTION (tree @var{decl}, enum node_frequency @var{freq}, bool @var{startup}, bool @var{exit}) 7426e4b17023SJohn MarinoReturn preferred text (sub)section for function @var{decl}. 7427e4b17023SJohn MarinoMain purpose of this function is to separate cold, normal and hot 7428e4b17023SJohn Marinofunctions. @var{startup} is true when function is known to be used only 7429e4b17023SJohn Marinoat startup (from static constructors or it is @code{main()}). 7430e4b17023SJohn Marino@var{exit} is true when function is known to be used only at exit 7431e4b17023SJohn Marino(from static destructors). 7432e4b17023SJohn MarinoReturn NULL if function should go to default text section. 7433e4b17023SJohn Marino@end deftypefn 7434e4b17023SJohn Marino 7435e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS (FILE *@var{file}, tree @var{decl}, bool @var{new_is_cold}) 7436e4b17023SJohn MarinoUsed by the target to emit any assembler directives or additional labels needed when a function is partitioned between different sections. Output should be written to @var{file}. The function decl is available as @var{decl} and the new section is `cold' if @var{new_is_cold} is @code{true}. 7437e4b17023SJohn Marino@end deftypefn 7438e4b17023SJohn Marino 7439e4b17023SJohn Marino@deftypevr {Common Target Hook} bool TARGET_HAVE_NAMED_SECTIONS 7440e4b17023SJohn MarinoThis flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}. 7441e4b17023SJohn MarinoIt must not be modified by command-line option processing. 7442e4b17023SJohn Marino@end deftypevr 7443e4b17023SJohn Marino 7444e4b17023SJohn Marino@anchor{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS} 7445e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_HAVE_SWITCHABLE_BSS_SECTIONS 7446e4b17023SJohn MarinoThis flag is true if we can create zeroed data by switching to a BSS 7447e4b17023SJohn Marinosection and then using @code{ASM_OUTPUT_SKIP} to allocate the space. 7448e4b17023SJohn MarinoThis is true on most ELF targets. 7449e4b17023SJohn Marino@end deftypevr 7450e4b17023SJohn Marino 7451e4b17023SJohn Marino@deftypefn {Target Hook} {unsigned int} TARGET_SECTION_TYPE_FLAGS (tree @var{decl}, const char *@var{name}, int @var{reloc}) 7452e4b17023SJohn MarinoChoose a set of section attributes for use by @code{TARGET_ASM_NAMED_SECTION} 7453e4b17023SJohn Marinobased on a variable or function decl, a section name, and whether or not the 7454e4b17023SJohn Marinodeclaration's initializer may contain runtime relocations. @var{decl} may be 7455e4b17023SJohn Marinonull, in which case read-write data should be assumed. 7456e4b17023SJohn Marino 7457e4b17023SJohn MarinoThe default version of this function handles choosing code vs data, 7458e4b17023SJohn Marinoread-only vs read-write data, and @code{flag_pic}. You should only 7459e4b17023SJohn Marinoneed to override this if your target has special flags that might be 7460e4b17023SJohn Marinoset via @code{__attribute__}. 7461e4b17023SJohn Marino@end deftypefn 7462e4b17023SJohn Marino 7463e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ASM_RECORD_GCC_SWITCHES (print_switch_type @var{type}, const char *@var{text}) 7464e4b17023SJohn MarinoProvides the target with the ability to record the gcc command line 7465e4b17023SJohn Marinoswitches that have been passed to the compiler, and options that are 7466e4b17023SJohn Marinoenabled. The @var{type} argument specifies what is being recorded. 7467e4b17023SJohn MarinoIt can take the following values: 7468e4b17023SJohn Marino 7469e4b17023SJohn Marino@table @gcctabopt 7470e4b17023SJohn Marino@item SWITCH_TYPE_PASSED 7471e4b17023SJohn Marino@var{text} is a command line switch that has been set by the user. 7472e4b17023SJohn Marino 7473e4b17023SJohn Marino@item SWITCH_TYPE_ENABLED 7474e4b17023SJohn Marino@var{text} is an option which has been enabled. This might be as a 7475e4b17023SJohn Marinodirect result of a command line switch, or because it is enabled by 7476e4b17023SJohn Marinodefault or because it has been enabled as a side effect of a different 7477e4b17023SJohn Marinocommand line switch. For example, the @option{-O2} switch enables 7478e4b17023SJohn Marinovarious different individual optimization passes. 7479e4b17023SJohn Marino 7480e4b17023SJohn Marino@item SWITCH_TYPE_DESCRIPTIVE 7481e4b17023SJohn Marino@var{text} is either NULL or some descriptive text which should be 7482e4b17023SJohn Marinoignored. If @var{text} is NULL then it is being used to warn the 7483e4b17023SJohn Marinotarget hook that either recording is starting or ending. The first 7484e4b17023SJohn Marinotime @var{type} is SWITCH_TYPE_DESCRIPTIVE and @var{text} is NULL, the 7485e4b17023SJohn Marinowarning is for start up and the second time the warning is for 7486e4b17023SJohn Marinowind down. This feature is to allow the target hook to make any 7487e4b17023SJohn Marinonecessary preparations before it starts to record switches and to 7488e4b17023SJohn Marinoperform any necessary tidying up after it has finished recording 7489e4b17023SJohn Marinoswitches. 7490e4b17023SJohn Marino 7491e4b17023SJohn Marino@item SWITCH_TYPE_LINE_START 7492e4b17023SJohn MarinoThis option can be ignored by this target hook. 7493e4b17023SJohn Marino 7494e4b17023SJohn Marino@item SWITCH_TYPE_LINE_END 7495e4b17023SJohn MarinoThis option can be ignored by this target hook. 7496e4b17023SJohn Marino@end table 7497e4b17023SJohn Marino 7498e4b17023SJohn MarinoThe hook's return value must be zero. Other return values may be 7499e4b17023SJohn Marinosupported in the future. 7500e4b17023SJohn Marino 7501e4b17023SJohn MarinoBy default this hook is set to NULL, but an example implementation is 7502e4b17023SJohn Marinoprovided for ELF based targets. Called @var{elf_record_gcc_switches}, 7503e4b17023SJohn Marinoit records the switches as ASCII text inside a new, string mergeable 7504e4b17023SJohn Marinosection in the assembler output file. The name of the new section is 7505e4b17023SJohn Marinoprovided by the @code{TARGET_ASM_RECORD_GCC_SWITCHES_SECTION} target 7506e4b17023SJohn Marinohook. 7507e4b17023SJohn Marino@end deftypefn 7508e4b17023SJohn Marino 7509e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_ASM_RECORD_GCC_SWITCHES_SECTION 7510e4b17023SJohn MarinoThis is the name of the section that will be created by the example 7511e4b17023SJohn MarinoELF implementation of the @code{TARGET_ASM_RECORD_GCC_SWITCHES} target 7512e4b17023SJohn Marinohook. 7513e4b17023SJohn Marino@end deftypevr 7514e4b17023SJohn Marino 7515e4b17023SJohn Marino@need 2000 7516e4b17023SJohn Marino@node Data Output 7517e4b17023SJohn Marino@subsection Output of Data 7518e4b17023SJohn Marino 7519e4b17023SJohn Marino 7520e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_ASM_BYTE_OP 7521e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_HI_OP 7522e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_SI_OP 7523e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_DI_OP 7524e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_TI_OP 7525e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_HI_OP 7526e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_SI_OP 7527e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_DI_OP 7528e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_TI_OP 7529e4b17023SJohn MarinoThese hooks specify assembly directives for creating certain kinds 7530e4b17023SJohn Marinoof integer object. The @code{TARGET_ASM_BYTE_OP} directive creates a 7531e4b17023SJohn Marinobyte-sized object, the @code{TARGET_ASM_ALIGNED_HI_OP} one creates an 7532e4b17023SJohn Marinoaligned two-byte object, and so on. Any of the hooks may be 7533e4b17023SJohn Marino@code{NULL}, indicating that no suitable directive is available. 7534e4b17023SJohn Marino 7535e4b17023SJohn MarinoThe compiler will print these strings at the start of a new line, 7536e4b17023SJohn Marinofollowed immediately by the object's initial value. In most cases, 7537e4b17023SJohn Marinothe string should contain a tab, a pseudo-op, and then another tab. 7538e4b17023SJohn Marino@end deftypevr 7539e4b17023SJohn Marino 7540e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ASM_INTEGER (rtx @var{x}, unsigned int @var{size}, int @var{aligned_p}) 7541e4b17023SJohn MarinoThe @code{assemble_integer} function uses this hook to output an 7542e4b17023SJohn Marinointeger object. @var{x} is the object's value, @var{size} is its size 7543e4b17023SJohn Marinoin bytes and @var{aligned_p} indicates whether it is aligned. The 7544e4b17023SJohn Marinofunction should return @code{true} if it was able to output the 7545e4b17023SJohn Marinoobject. If it returns false, @code{assemble_integer} will try to 7546e4b17023SJohn Marinosplit the object into smaller parts. 7547e4b17023SJohn Marino 7548e4b17023SJohn MarinoThe default implementation of this hook will use the 7549e4b17023SJohn Marino@code{TARGET_ASM_BYTE_OP} family of strings, returning @code{false} 7550e4b17023SJohn Marinowhen the relevant string is @code{NULL}. 7551e4b17023SJohn Marino@end deftypefn 7552e4b17023SJohn Marino 7553e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA (FILE *@var{file}, rtx @var{x}) 7554e4b17023SJohn MarinoA target hook to recognize @var{rtx} patterns that @code{output_addr_const} 7555e4b17023SJohn Marinocan't deal with, and output assembly code to @var{file} corresponding to 7556e4b17023SJohn Marinothe pattern @var{x}. This may be used to allow machine-dependent 7557e4b17023SJohn Marino@code{UNSPEC}s to appear within constants. 7558e4b17023SJohn Marino 7559e4b17023SJohn MarinoIf target hook fails to recognize a pattern, it must return @code{false}, 7560e4b17023SJohn Marinoso that a standard error message is printed. If it prints an error message 7561e4b17023SJohn Marinoitself, by calling, for example, @code{output_operand_lossage}, it may just 7562e4b17023SJohn Marinoreturn @code{true}. 7563e4b17023SJohn Marino@end deftypefn 7564e4b17023SJohn Marino 7565e4b17023SJohn Marino@defmac ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len}) 7566e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler 7567e4b17023SJohn Marinoinstruction to assemble a string constant containing the @var{len} 7568e4b17023SJohn Marinobytes at @var{ptr}. @var{ptr} will be a C expression of type 7569e4b17023SJohn Marino@code{char *} and @var{len} a C expression of type @code{int}. 7570e4b17023SJohn Marino 7571e4b17023SJohn MarinoIf the assembler has a @code{.ascii} pseudo-op as found in the 7572e4b17023SJohn MarinoBerkeley Unix assembler, do not define the macro 7573e4b17023SJohn Marino@code{ASM_OUTPUT_ASCII}. 7574e4b17023SJohn Marino@end defmac 7575e4b17023SJohn Marino 7576e4b17023SJohn Marino@defmac ASM_OUTPUT_FDESC (@var{stream}, @var{decl}, @var{n}) 7577e4b17023SJohn MarinoA C statement to output word @var{n} of a function descriptor for 7578e4b17023SJohn Marino@var{decl}. This must be defined if @code{TARGET_VTABLE_USES_DESCRIPTORS} 7579e4b17023SJohn Marinois defined, and is otherwise unused. 7580e4b17023SJohn Marino@end defmac 7581e4b17023SJohn Marino 7582e4b17023SJohn Marino@defmac CONSTANT_POOL_BEFORE_FUNCTION 7583e4b17023SJohn MarinoYou may define this macro as a C expression. You should define the 7584e4b17023SJohn Marinoexpression to have a nonzero value if GCC should output the constant 7585e4b17023SJohn Marinopool for a function before the code for the function, or a zero value if 7586e4b17023SJohn MarinoGCC should output the constant pool after the function. If you do 7587e4b17023SJohn Marinonot define this macro, the usual case, GCC will output the constant 7588e4b17023SJohn Marinopool before the function. 7589e4b17023SJohn Marino@end defmac 7590e4b17023SJohn Marino 7591e4b17023SJohn Marino@defmac ASM_OUTPUT_POOL_PROLOGUE (@var{file}, @var{funname}, @var{fundecl}, @var{size}) 7592e4b17023SJohn MarinoA C statement to output assembler commands to define the start of the 7593e4b17023SJohn Marinoconstant pool for a function. @var{funname} is a string giving 7594e4b17023SJohn Marinothe name of the function. Should the return type of the function 7595e4b17023SJohn Marinobe required, it can be obtained via @var{fundecl}. @var{size} 7596e4b17023SJohn Marinois the size, in bytes, of the constant pool that will be written 7597e4b17023SJohn Marinoimmediately after this call. 7598e4b17023SJohn Marino 7599e4b17023SJohn MarinoIf no constant-pool prefix is required, the usual case, this macro need 7600e4b17023SJohn Marinonot be defined. 7601e4b17023SJohn Marino@end defmac 7602e4b17023SJohn Marino 7603e4b17023SJohn Marino@defmac ASM_OUTPUT_SPECIAL_POOL_ENTRY (@var{file}, @var{x}, @var{mode}, @var{align}, @var{labelno}, @var{jumpto}) 7604e4b17023SJohn MarinoA C statement (with or without semicolon) to output a constant in the 7605e4b17023SJohn Marinoconstant pool, if it needs special treatment. (This macro need not do 7606e4b17023SJohn Marinoanything for RTL expressions that can be output normally.) 7607e4b17023SJohn Marino 7608e4b17023SJohn MarinoThe argument @var{file} is the standard I/O stream to output the 7609e4b17023SJohn Marinoassembler code on. @var{x} is the RTL expression for the constant to 7610e4b17023SJohn Marinooutput, and @var{mode} is the machine mode (in case @var{x} is a 7611e4b17023SJohn Marino@samp{const_int}). @var{align} is the required alignment for the value 7612e4b17023SJohn Marino@var{x}; you should output an assembler directive to force this much 7613e4b17023SJohn Marinoalignment. 7614e4b17023SJohn Marino 7615e4b17023SJohn MarinoThe argument @var{labelno} is a number to use in an internal label for 7616e4b17023SJohn Marinothe address of this pool entry. The definition of this macro is 7617e4b17023SJohn Marinoresponsible for outputting the label definition at the proper place. 7618e4b17023SJohn MarinoHere is how to do this: 7619e4b17023SJohn Marino 7620e4b17023SJohn Marino@smallexample 7621e4b17023SJohn Marino@code{(*targetm.asm_out.internal_label)} (@var{file}, "LC", @var{labelno}); 7622e4b17023SJohn Marino@end smallexample 7623e4b17023SJohn Marino 7624e4b17023SJohn MarinoWhen you output a pool entry specially, you should end with a 7625e4b17023SJohn Marino@code{goto} to the label @var{jumpto}. This will prevent the same pool 7626e4b17023SJohn Marinoentry from being output a second time in the usual manner. 7627e4b17023SJohn Marino 7628e4b17023SJohn MarinoYou need not define this macro if it would do nothing. 7629e4b17023SJohn Marino@end defmac 7630e4b17023SJohn Marino 7631e4b17023SJohn Marino@defmac ASM_OUTPUT_POOL_EPILOGUE (@var{file} @var{funname} @var{fundecl} @var{size}) 7632e4b17023SJohn MarinoA C statement to output assembler commands to at the end of the constant 7633e4b17023SJohn Marinopool for a function. @var{funname} is a string giving the name of the 7634e4b17023SJohn Marinofunction. Should the return type of the function be required, you can 7635e4b17023SJohn Marinoobtain it via @var{fundecl}. @var{size} is the size, in bytes, of the 7636e4b17023SJohn Marinoconstant pool that GCC wrote immediately before this call. 7637e4b17023SJohn Marino 7638e4b17023SJohn MarinoIf no constant-pool epilogue is required, the usual case, you need not 7639e4b17023SJohn Marinodefine this macro. 7640e4b17023SJohn Marino@end defmac 7641e4b17023SJohn Marino 7642e4b17023SJohn Marino@defmac IS_ASM_LOGICAL_LINE_SEPARATOR (@var{C}, @var{STR}) 7643e4b17023SJohn MarinoDefine this macro as a C expression which is nonzero if @var{C} is 7644e4b17023SJohn Marinoused as a logical line separator by the assembler. @var{STR} points 7645e4b17023SJohn Marinoto the position in the string where @var{C} was found; this can be used if 7646e4b17023SJohn Marinoa line separator uses multiple characters. 7647e4b17023SJohn Marino 7648e4b17023SJohn MarinoIf you do not define this macro, the default is that only 7649e4b17023SJohn Marinothe character @samp{;} is treated as a logical line separator. 7650e4b17023SJohn Marino@end defmac 7651e4b17023SJohn Marino 7652e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_ASM_OPEN_PAREN 7653e4b17023SJohn Marino@deftypevrx {Target Hook} {const char *} TARGET_ASM_CLOSE_PAREN 7654e4b17023SJohn MarinoThese target hooks are C string constants, describing the syntax in the 7655e4b17023SJohn Marinoassembler for grouping arithmetic expressions. If not overridden, they 7656e4b17023SJohn Marinodefault to normal parentheses, which is correct for most assemblers. 7657e4b17023SJohn Marino@end deftypevr 7658e4b17023SJohn Marino 7659e4b17023SJohn MarinoThese macros are provided by @file{real.h} for writing the definitions 7660e4b17023SJohn Marinoof @code{ASM_OUTPUT_DOUBLE} and the like: 7661e4b17023SJohn Marino 7662e4b17023SJohn Marino@defmac REAL_VALUE_TO_TARGET_SINGLE (@var{x}, @var{l}) 7663e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_DOUBLE (@var{x}, @var{l}) 7664e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_LONG_DOUBLE (@var{x}, @var{l}) 7665e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_DECIMAL32 (@var{x}, @var{l}) 7666e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_DECIMAL64 (@var{x}, @var{l}) 7667e4b17023SJohn Marino@defmacx REAL_VALUE_TO_TARGET_DECIMAL128 (@var{x}, @var{l}) 7668e4b17023SJohn MarinoThese translate @var{x}, of type @code{REAL_VALUE_TYPE}, to the 7669e4b17023SJohn Marinotarget's floating point representation, and store its bit pattern in 7670e4b17023SJohn Marinothe variable @var{l}. For @code{REAL_VALUE_TO_TARGET_SINGLE} and 7671e4b17023SJohn Marino@code{REAL_VALUE_TO_TARGET_DECIMAL32}, this variable should be a 7672e4b17023SJohn Marinosimple @code{long int}. For the others, it should be an array of 7673e4b17023SJohn Marino@code{long int}. The number of elements in this array is determined 7674e4b17023SJohn Marinoby the size of the desired target floating point data type: 32 bits of 7675e4b17023SJohn Marinoit go in each @code{long int} array element. Each array element holds 7676e4b17023SJohn Marino32 bits of the result, even if @code{long int} is wider than 32 bits 7677e4b17023SJohn Marinoon the host machine. 7678e4b17023SJohn Marino 7679e4b17023SJohn MarinoThe array element values are designed so that you can print them out 7680e4b17023SJohn Marinousing @code{fprintf} in the order they should appear in the target 7681e4b17023SJohn Marinomachine's memory. 7682e4b17023SJohn Marino@end defmac 7683e4b17023SJohn Marino 7684e4b17023SJohn Marino@node Uninitialized Data 7685e4b17023SJohn Marino@subsection Output of Uninitialized Variables 7686e4b17023SJohn Marino 7687e4b17023SJohn MarinoEach of the macros in this section is used to do the whole job of 7688e4b17023SJohn Marinooutputting a single uninitialized variable. 7689e4b17023SJohn Marino 7690e4b17023SJohn Marino@defmac ASM_OUTPUT_COMMON (@var{stream}, @var{name}, @var{size}, @var{rounded}) 7691e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7692e4b17023SJohn Marino@var{stream} the assembler definition of a common-label named 7693e4b17023SJohn Marino@var{name} whose size is @var{size} bytes. The variable @var{rounded} 7694e4b17023SJohn Marinois the size rounded up to whatever alignment the caller wants. It is 7695e4b17023SJohn Marinopossible that @var{size} may be zero, for instance if a struct with no 7696e4b17023SJohn Marinoother member than a zero-length array is defined. In this case, the 7697e4b17023SJohn Marinobackend must output a symbol definition that allocates at least one 7698e4b17023SJohn Marinobyte, both so that the address of the resulting object does not compare 7699e4b17023SJohn Marinoequal to any other, and because some object formats cannot even express 7700e4b17023SJohn Marinothe concept of a zero-sized common symbol, as that is how they represent 7701e4b17023SJohn Marinoan ordinary undefined external. 7702e4b17023SJohn Marino 7703e4b17023SJohn MarinoUse the expression @code{assemble_name (@var{stream}, @var{name})} to 7704e4b17023SJohn Marinooutput the name itself; before and after that, output the additional 7705e4b17023SJohn Marinoassembler syntax for defining the name, and a newline. 7706e4b17023SJohn Marino 7707e4b17023SJohn MarinoThis macro controls how the assembler definitions of uninitialized 7708e4b17023SJohn Marinocommon global variables are output. 7709e4b17023SJohn Marino@end defmac 7710e4b17023SJohn Marino 7711e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_COMMON (@var{stream}, @var{name}, @var{size}, @var{alignment}) 7712e4b17023SJohn MarinoLike @code{ASM_OUTPUT_COMMON} except takes the required alignment as a 7713e4b17023SJohn Marinoseparate, explicit argument. If you define this macro, it is used in 7714e4b17023SJohn Marinoplace of @code{ASM_OUTPUT_COMMON}, and gives you more flexibility in 7715e4b17023SJohn Marinohandling the required alignment of the variable. The alignment is specified 7716e4b17023SJohn Marinoas the number of bits. 7717e4b17023SJohn Marino@end defmac 7718e4b17023SJohn Marino 7719e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_DECL_COMMON (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment}) 7720e4b17023SJohn MarinoLike @code{ASM_OUTPUT_ALIGNED_COMMON} except that @var{decl} of the 7721e4b17023SJohn Marinovariable to be output, if there is one, or @code{NULL_TREE} if there 7722e4b17023SJohn Marinois no corresponding variable. If you define this macro, GCC will use it 7723e4b17023SJohn Marinoin place of both @code{ASM_OUTPUT_COMMON} and 7724e4b17023SJohn Marino@code{ASM_OUTPUT_ALIGNED_COMMON}. Define this macro when you need to see 7725e4b17023SJohn Marinothe variable's decl in order to chose what to output. 7726e4b17023SJohn Marino@end defmac 7727e4b17023SJohn Marino 7728e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_BSS (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment}) 7729e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7730e4b17023SJohn Marino@var{stream} the assembler definition of uninitialized global @var{decl} named 7731e4b17023SJohn Marino@var{name} whose size is @var{size} bytes. The variable @var{alignment} 7732e4b17023SJohn Marinois the alignment specified as the number of bits. 7733e4b17023SJohn Marino 7734e4b17023SJohn MarinoTry to use function @code{asm_output_aligned_bss} defined in file 7735e4b17023SJohn Marino@file{varasm.c} when defining this macro. If unable, use the expression 7736e4b17023SJohn Marino@code{assemble_name (@var{stream}, @var{name})} to output the name itself; 7737e4b17023SJohn Marinobefore and after that, output the additional assembler syntax for defining 7738e4b17023SJohn Marinothe name, and a newline. 7739e4b17023SJohn Marino 7740e4b17023SJohn MarinoThere are two ways of handling global BSS@. One is to define this macro. 7741e4b17023SJohn MarinoThe other is to have @code{TARGET_ASM_SELECT_SECTION} return a 7742e4b17023SJohn Marinoswitchable BSS section (@pxref{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS}). 7743e4b17023SJohn MarinoYou do not need to do both. 7744e4b17023SJohn Marino 7745e4b17023SJohn MarinoSome languages do not have @code{common} data, and require a 7746e4b17023SJohn Marinonon-common form of global BSS in order to handle uninitialized globals 7747e4b17023SJohn Marinoefficiently. C++ is one example of this. However, if the target does 7748e4b17023SJohn Marinonot support global BSS, the front end may choose to make globals 7749e4b17023SJohn Marinocommon in order to save space in the object file. 7750e4b17023SJohn Marino@end defmac 7751e4b17023SJohn Marino 7752e4b17023SJohn Marino@defmac ASM_OUTPUT_LOCAL (@var{stream}, @var{name}, @var{size}, @var{rounded}) 7753e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7754e4b17023SJohn Marino@var{stream} the assembler definition of a local-common-label named 7755e4b17023SJohn Marino@var{name} whose size is @var{size} bytes. The variable @var{rounded} 7756e4b17023SJohn Marinois the size rounded up to whatever alignment the caller wants. 7757e4b17023SJohn Marino 7758e4b17023SJohn MarinoUse the expression @code{assemble_name (@var{stream}, @var{name})} to 7759e4b17023SJohn Marinooutput the name itself; before and after that, output the additional 7760e4b17023SJohn Marinoassembler syntax for defining the name, and a newline. 7761e4b17023SJohn Marino 7762e4b17023SJohn MarinoThis macro controls how the assembler definitions of uninitialized 7763e4b17023SJohn Marinostatic variables are output. 7764e4b17023SJohn Marino@end defmac 7765e4b17023SJohn Marino 7766e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_LOCAL (@var{stream}, @var{name}, @var{size}, @var{alignment}) 7767e4b17023SJohn MarinoLike @code{ASM_OUTPUT_LOCAL} except takes the required alignment as a 7768e4b17023SJohn Marinoseparate, explicit argument. If you define this macro, it is used in 7769e4b17023SJohn Marinoplace of @code{ASM_OUTPUT_LOCAL}, and gives you more flexibility in 7770e4b17023SJohn Marinohandling the required alignment of the variable. The alignment is specified 7771e4b17023SJohn Marinoas the number of bits. 7772e4b17023SJohn Marino@end defmac 7773e4b17023SJohn Marino 7774e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGNED_DECL_LOCAL (@var{stream}, @var{decl}, @var{name}, @var{size}, @var{alignment}) 7775e4b17023SJohn MarinoLike @code{ASM_OUTPUT_ALIGNED_DECL} except that @var{decl} of the 7776e4b17023SJohn Marinovariable to be output, if there is one, or @code{NULL_TREE} if there 7777e4b17023SJohn Marinois no corresponding variable. If you define this macro, GCC will use it 7778e4b17023SJohn Marinoin place of both @code{ASM_OUTPUT_DECL} and 7779e4b17023SJohn Marino@code{ASM_OUTPUT_ALIGNED_DECL}. Define this macro when you need to see 7780e4b17023SJohn Marinothe variable's decl in order to chose what to output. 7781e4b17023SJohn Marino@end defmac 7782e4b17023SJohn Marino 7783e4b17023SJohn Marino@node Label Output 7784e4b17023SJohn Marino@subsection Output and Generation of Labels 7785e4b17023SJohn Marino 7786e4b17023SJohn Marino@c prevent bad page break with this line 7787e4b17023SJohn MarinoThis is about outputting labels. 7788e4b17023SJohn Marino 7789e4b17023SJohn Marino@findex assemble_name 7790e4b17023SJohn Marino@defmac ASM_OUTPUT_LABEL (@var{stream}, @var{name}) 7791e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7792e4b17023SJohn Marino@var{stream} the assembler definition of a label named @var{name}. 7793e4b17023SJohn MarinoUse the expression @code{assemble_name (@var{stream}, @var{name})} to 7794e4b17023SJohn Marinooutput the name itself; before and after that, output the additional 7795e4b17023SJohn Marinoassembler syntax for defining the name, and a newline. A default 7796e4b17023SJohn Marinodefinition of this macro is provided which is correct for most systems. 7797e4b17023SJohn Marino@end defmac 7798e4b17023SJohn Marino 7799e4b17023SJohn Marino@defmac ASM_OUTPUT_FUNCTION_LABEL (@var{stream}, @var{name}, @var{decl}) 7800e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7801e4b17023SJohn Marino@var{stream} the assembler definition of a label named @var{name} of 7802e4b17023SJohn Marinoa function. 7803e4b17023SJohn MarinoUse the expression @code{assemble_name (@var{stream}, @var{name})} to 7804e4b17023SJohn Marinooutput the name itself; before and after that, output the additional 7805e4b17023SJohn Marinoassembler syntax for defining the name, and a newline. A default 7806e4b17023SJohn Marinodefinition of this macro is provided which is correct for most systems. 7807e4b17023SJohn Marino 7808e4b17023SJohn MarinoIf this macro is not defined, then the function name is defined in the 7809e4b17023SJohn Marinousual manner as a label (by means of @code{ASM_OUTPUT_LABEL}). 7810e4b17023SJohn Marino@end defmac 7811e4b17023SJohn Marino 7812e4b17023SJohn Marino@findex assemble_name_raw 7813e4b17023SJohn Marino@defmac ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{name}) 7814e4b17023SJohn MarinoIdentical to @code{ASM_OUTPUT_LABEL}, except that @var{name} is known 7815e4b17023SJohn Marinoto refer to a compiler-generated label. The default definition uses 7816e4b17023SJohn Marino@code{assemble_name_raw}, which is like @code{assemble_name} except 7817e4b17023SJohn Marinothat it is more efficient. 7818e4b17023SJohn Marino@end defmac 7819e4b17023SJohn Marino 7820e4b17023SJohn Marino@defmac SIZE_ASM_OP 7821e4b17023SJohn MarinoA C string containing the appropriate assembler directive to specify the 7822e4b17023SJohn Marinosize of a symbol, without any arguments. On systems that use ELF, the 7823e4b17023SJohn Marinodefault (in @file{config/elfos.h}) is @samp{"\t.size\t"}; on other 7824e4b17023SJohn Marinosystems, the default is not to define this macro. 7825e4b17023SJohn Marino 7826e4b17023SJohn MarinoDefine this macro only if it is correct to use the default definitions 7827e4b17023SJohn Marinoof @code{ASM_OUTPUT_SIZE_DIRECTIVE} and @code{ASM_OUTPUT_MEASURED_SIZE} 7828e4b17023SJohn Marinofor your system. If you need your own custom definitions of those 7829e4b17023SJohn Marinomacros, or if you do not need explicit symbol sizes at all, do not 7830e4b17023SJohn Marinodefine this macro. 7831e4b17023SJohn Marino@end defmac 7832e4b17023SJohn Marino 7833e4b17023SJohn Marino@defmac ASM_OUTPUT_SIZE_DIRECTIVE (@var{stream}, @var{name}, @var{size}) 7834e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7835e4b17023SJohn Marino@var{stream} a directive telling the assembler that the size of the 7836e4b17023SJohn Marinosymbol @var{name} is @var{size}. @var{size} is a @code{HOST_WIDE_INT}. 7837e4b17023SJohn MarinoIf you define @code{SIZE_ASM_OP}, a default definition of this macro is 7838e4b17023SJohn Marinoprovided. 7839e4b17023SJohn Marino@end defmac 7840e4b17023SJohn Marino 7841e4b17023SJohn Marino@defmac ASM_OUTPUT_MEASURED_SIZE (@var{stream}, @var{name}) 7842e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7843e4b17023SJohn Marino@var{stream} a directive telling the assembler to calculate the size of 7844e4b17023SJohn Marinothe symbol @var{name} by subtracting its address from the current 7845e4b17023SJohn Marinoaddress. 7846e4b17023SJohn Marino 7847e4b17023SJohn MarinoIf you define @code{SIZE_ASM_OP}, a default definition of this macro is 7848e4b17023SJohn Marinoprovided. The default assumes that the assembler recognizes a special 7849e4b17023SJohn Marino@samp{.} symbol as referring to the current address, and can calculate 7850e4b17023SJohn Marinothe difference between this and another symbol. If your assembler does 7851e4b17023SJohn Marinonot recognize @samp{.} or cannot do calculations with it, you will need 7852e4b17023SJohn Marinoto redefine @code{ASM_OUTPUT_MEASURED_SIZE} to use some other technique. 7853e4b17023SJohn Marino@end defmac 7854e4b17023SJohn Marino 7855e4b17023SJohn Marino@defmac TYPE_ASM_OP 7856e4b17023SJohn MarinoA C string containing the appropriate assembler directive to specify the 7857e4b17023SJohn Marinotype of a symbol, without any arguments. On systems that use ELF, the 7858e4b17023SJohn Marinodefault (in @file{config/elfos.h}) is @samp{"\t.type\t"}; on other 7859e4b17023SJohn Marinosystems, the default is not to define this macro. 7860e4b17023SJohn Marino 7861e4b17023SJohn MarinoDefine this macro only if it is correct to use the default definition of 7862e4b17023SJohn Marino@code{ASM_OUTPUT_TYPE_DIRECTIVE} for your system. If you need your own 7863e4b17023SJohn Marinocustom definition of this macro, or if you do not need explicit symbol 7864e4b17023SJohn Marinotypes at all, do not define this macro. 7865e4b17023SJohn Marino@end defmac 7866e4b17023SJohn Marino 7867e4b17023SJohn Marino@defmac TYPE_OPERAND_FMT 7868e4b17023SJohn MarinoA C string which specifies (using @code{printf} syntax) the format of 7869e4b17023SJohn Marinothe second operand to @code{TYPE_ASM_OP}. On systems that use ELF, the 7870e4b17023SJohn Marinodefault (in @file{config/elfos.h}) is @samp{"@@%s"}; on other systems, 7871e4b17023SJohn Marinothe default is not to define this macro. 7872e4b17023SJohn Marino 7873e4b17023SJohn MarinoDefine this macro only if it is correct to use the default definition of 7874e4b17023SJohn Marino@code{ASM_OUTPUT_TYPE_DIRECTIVE} for your system. If you need your own 7875e4b17023SJohn Marinocustom definition of this macro, or if you do not need explicit symbol 7876e4b17023SJohn Marinotypes at all, do not define this macro. 7877e4b17023SJohn Marino@end defmac 7878e4b17023SJohn Marino 7879e4b17023SJohn Marino@defmac ASM_OUTPUT_TYPE_DIRECTIVE (@var{stream}, @var{type}) 7880e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7881e4b17023SJohn Marino@var{stream} a directive telling the assembler that the type of the 7882e4b17023SJohn Marinosymbol @var{name} is @var{type}. @var{type} is a C string; currently, 7883e4b17023SJohn Marinothat string is always either @samp{"function"} or @samp{"object"}, but 7884e4b17023SJohn Marinoyou should not count on this. 7885e4b17023SJohn Marino 7886e4b17023SJohn MarinoIf you define @code{TYPE_ASM_OP} and @code{TYPE_OPERAND_FMT}, a default 7887e4b17023SJohn Marinodefinition of this macro is provided. 7888e4b17023SJohn Marino@end defmac 7889e4b17023SJohn Marino 7890e4b17023SJohn Marino@defmac ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl}) 7891e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7892e4b17023SJohn Marino@var{stream} any text necessary for declaring the name @var{name} of a 7893e4b17023SJohn Marinofunction which is being defined. This macro is responsible for 7894e4b17023SJohn Marinooutputting the label definition (perhaps using 7895e4b17023SJohn Marino@code{ASM_OUTPUT_FUNCTION_LABEL}). The argument @var{decl} is the 7896e4b17023SJohn Marino@code{FUNCTION_DECL} tree node representing the function. 7897e4b17023SJohn Marino 7898e4b17023SJohn MarinoIf this macro is not defined, then the function name is defined in the 7899e4b17023SJohn Marinousual manner as a label (by means of @code{ASM_OUTPUT_FUNCTION_LABEL}). 7900e4b17023SJohn Marino 7901e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition 7902e4b17023SJohn Marinoof this macro. 7903e4b17023SJohn Marino@end defmac 7904e4b17023SJohn Marino 7905e4b17023SJohn Marino@defmac ASM_DECLARE_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl}) 7906e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7907e4b17023SJohn Marino@var{stream} any text necessary for declaring the size of a function 7908e4b17023SJohn Marinowhich is being defined. The argument @var{name} is the name of the 7909e4b17023SJohn Marinofunction. The argument @var{decl} is the @code{FUNCTION_DECL} tree node 7910e4b17023SJohn Marinorepresenting the function. 7911e4b17023SJohn Marino 7912e4b17023SJohn MarinoIf this macro is not defined, then the function size is not defined. 7913e4b17023SJohn Marino 7914e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_MEASURED_SIZE} in the definition 7915e4b17023SJohn Marinoof this macro. 7916e4b17023SJohn Marino@end defmac 7917e4b17023SJohn Marino 7918e4b17023SJohn Marino@defmac ASM_DECLARE_OBJECT_NAME (@var{stream}, @var{name}, @var{decl}) 7919e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7920e4b17023SJohn Marino@var{stream} any text necessary for declaring the name @var{name} of an 7921e4b17023SJohn Marinoinitialized variable which is being defined. This macro must output the 7922e4b17023SJohn Marinolabel definition (perhaps using @code{ASM_OUTPUT_LABEL}). The argument 7923e4b17023SJohn Marino@var{decl} is the @code{VAR_DECL} tree node representing the variable. 7924e4b17023SJohn Marino 7925e4b17023SJohn MarinoIf this macro is not defined, then the variable name is defined in the 7926e4b17023SJohn Marinousual manner as a label (by means of @code{ASM_OUTPUT_LABEL}). 7927e4b17023SJohn Marino 7928e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} and/or 7929e4b17023SJohn Marino@code{ASM_OUTPUT_SIZE_DIRECTIVE} in the definition of this macro. 7930e4b17023SJohn Marino@end defmac 7931e4b17023SJohn Marino 7932e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_DECLARE_CONSTANT_NAME (FILE *@var{file}, const char *@var{name}, const_tree @var{expr}, HOST_WIDE_INT @var{size}) 7933e4b17023SJohn MarinoA target hook to output to the stdio stream @var{file} any text necessary 7934e4b17023SJohn Marinofor declaring the name @var{name} of a constant which is being defined. This 7935e4b17023SJohn Marinotarget hook is responsible for outputting the label definition (perhaps using 7936e4b17023SJohn Marino@code{assemble_label}). The argument @var{exp} is the value of the constant, 7937e4b17023SJohn Marinoand @var{size} is the size of the constant in bytes. The @var{name} 7938e4b17023SJohn Marinowill be an internal label. 7939e4b17023SJohn Marino 7940e4b17023SJohn MarinoThe default version of this target hook, define the @var{name} in the 7941e4b17023SJohn Marinousual manner as a label (by means of @code{assemble_label}). 7942e4b17023SJohn Marino 7943e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in this target hook. 7944e4b17023SJohn Marino@end deftypefn 7945e4b17023SJohn Marino 7946e4b17023SJohn Marino@defmac ASM_DECLARE_REGISTER_GLOBAL (@var{stream}, @var{decl}, @var{regno}, @var{name}) 7947e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7948e4b17023SJohn Marino@var{stream} any text necessary for claiming a register @var{regno} 7949e4b17023SJohn Marinofor a global variable @var{decl} with name @var{name}. 7950e4b17023SJohn Marino 7951e4b17023SJohn MarinoIf you don't define this macro, that is equivalent to defining it to do 7952e4b17023SJohn Marinonothing. 7953e4b17023SJohn Marino@end defmac 7954e4b17023SJohn Marino 7955e4b17023SJohn Marino@defmac ASM_FINISH_DECLARE_OBJECT (@var{stream}, @var{decl}, @var{toplevel}, @var{atend}) 7956e4b17023SJohn MarinoA C statement (sans semicolon) to finish up declaring a variable name 7957e4b17023SJohn Marinoonce the compiler has processed its initializer fully and thus has had a 7958e4b17023SJohn Marinochance to determine the size of an array when controlled by an 7959e4b17023SJohn Marinoinitializer. This is used on systems where it's necessary to declare 7960e4b17023SJohn Marinosomething about the size of the object. 7961e4b17023SJohn Marino 7962e4b17023SJohn MarinoIf you don't define this macro, that is equivalent to defining it to do 7963e4b17023SJohn Marinonothing. 7964e4b17023SJohn Marino 7965e4b17023SJohn MarinoYou may wish to use @code{ASM_OUTPUT_SIZE_DIRECTIVE} and/or 7966e4b17023SJohn Marino@code{ASM_OUTPUT_MEASURED_SIZE} in the definition of this macro. 7967e4b17023SJohn Marino@end defmac 7968e4b17023SJohn Marino 7969e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_GLOBALIZE_LABEL (FILE *@var{stream}, const char *@var{name}) 7970e4b17023SJohn MarinoThis target hook is a function to output to the stdio stream 7971e4b17023SJohn Marino@var{stream} some commands that will make the label @var{name} global; 7972e4b17023SJohn Marinothat is, available for reference from other files. 7973e4b17023SJohn Marino 7974e4b17023SJohn MarinoThe default implementation relies on a proper definition of 7975e4b17023SJohn Marino@code{GLOBAL_ASM_OP}. 7976e4b17023SJohn Marino@end deftypefn 7977e4b17023SJohn Marino 7978e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_GLOBALIZE_DECL_NAME (FILE *@var{stream}, tree @var{decl}) 7979e4b17023SJohn MarinoThis target hook is a function to output to the stdio stream 7980e4b17023SJohn Marino@var{stream} some commands that will make the name associated with @var{decl} 7981e4b17023SJohn Marinoglobal; that is, available for reference from other files. 7982e4b17023SJohn Marino 7983e4b17023SJohn MarinoThe default implementation uses the TARGET_ASM_GLOBALIZE_LABEL target hook. 7984e4b17023SJohn Marino@end deftypefn 7985e4b17023SJohn Marino 7986e4b17023SJohn Marino@defmac ASM_WEAKEN_LABEL (@var{stream}, @var{name}) 7987e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 7988e4b17023SJohn Marino@var{stream} some commands that will make the label @var{name} weak; 7989e4b17023SJohn Marinothat is, available for reference from other files but only used if 7990e4b17023SJohn Marinono other definition is available. Use the expression 7991e4b17023SJohn Marino@code{assemble_name (@var{stream}, @var{name})} to output the name 7992e4b17023SJohn Marinoitself; before and after that, output the additional assembler syntax 7993e4b17023SJohn Marinofor making that name weak, and a newline. 7994e4b17023SJohn Marino 7995e4b17023SJohn MarinoIf you don't define this macro or @code{ASM_WEAKEN_DECL}, GCC will not 7996e4b17023SJohn Marinosupport weak symbols and you should not define the @code{SUPPORTS_WEAK} 7997e4b17023SJohn Marinomacro. 7998e4b17023SJohn Marino@end defmac 7999e4b17023SJohn Marino 8000e4b17023SJohn Marino@defmac ASM_WEAKEN_DECL (@var{stream}, @var{decl}, @var{name}, @var{value}) 8001e4b17023SJohn MarinoCombines (and replaces) the function of @code{ASM_WEAKEN_LABEL} and 8002e4b17023SJohn Marino@code{ASM_OUTPUT_WEAK_ALIAS}, allowing access to the associated function 8003e4b17023SJohn Marinoor variable decl. If @var{value} is not @code{NULL}, this C statement 8004e4b17023SJohn Marinoshould output to the stdio stream @var{stream} assembler code which 8005e4b17023SJohn Marinodefines (equates) the weak symbol @var{name} to have the value 8006e4b17023SJohn Marino@var{value}. If @var{value} is @code{NULL}, it should output commands 8007e4b17023SJohn Marinoto make @var{name} weak. 8008e4b17023SJohn Marino@end defmac 8009e4b17023SJohn Marino 8010e4b17023SJohn Marino@defmac ASM_OUTPUT_WEAKREF (@var{stream}, @var{decl}, @var{name}, @var{value}) 8011e4b17023SJohn MarinoOutputs a directive that enables @var{name} to be used to refer to 8012e4b17023SJohn Marinosymbol @var{value} with weak-symbol semantics. @code{decl} is the 8013e4b17023SJohn Marinodeclaration of @code{name}. 8014e4b17023SJohn Marino@end defmac 8015e4b17023SJohn Marino 8016e4b17023SJohn Marino@defmac SUPPORTS_WEAK 8017e4b17023SJohn MarinoA preprocessor constant expression which evaluates to true if the target 8018e4b17023SJohn Marinosupports weak symbols. 8019e4b17023SJohn Marino 8020e4b17023SJohn MarinoIf you don't define this macro, @file{defaults.h} provides a default 8021e4b17023SJohn Marinodefinition. If either @code{ASM_WEAKEN_LABEL} or @code{ASM_WEAKEN_DECL} 8022e4b17023SJohn Marinois defined, the default definition is @samp{1}; otherwise, it is @samp{0}. 8023e4b17023SJohn Marino@end defmac 8024e4b17023SJohn Marino 8025e4b17023SJohn Marino@defmac TARGET_SUPPORTS_WEAK 8026e4b17023SJohn MarinoA C expression which evaluates to true if the target supports weak symbols. 8027e4b17023SJohn Marino 8028e4b17023SJohn MarinoIf you don't define this macro, @file{defaults.h} provides a default 8029e4b17023SJohn Marinodefinition. The default definition is @samp{(SUPPORTS_WEAK)}. Define 8030e4b17023SJohn Marinothis macro if you want to control weak symbol support with a compiler 8031e4b17023SJohn Marinoflag such as @option{-melf}. 8032e4b17023SJohn Marino@end defmac 8033e4b17023SJohn Marino 8034e4b17023SJohn Marino@defmac MAKE_DECL_ONE_ONLY (@var{decl}) 8035e4b17023SJohn MarinoA C statement (sans semicolon) to mark @var{decl} to be emitted as a 8036e4b17023SJohn Marinopublic symbol such that extra copies in multiple translation units will 8037e4b17023SJohn Marinobe discarded by the linker. Define this macro if your object file 8038e4b17023SJohn Marinoformat provides support for this concept, such as the @samp{COMDAT} 8039e4b17023SJohn Marinosection flags in the Microsoft Windows PE/COFF format, and this support 8040e4b17023SJohn Marinorequires changes to @var{decl}, such as putting it in a separate section. 8041e4b17023SJohn Marino@end defmac 8042e4b17023SJohn Marino 8043e4b17023SJohn Marino@defmac SUPPORTS_ONE_ONLY 8044e4b17023SJohn MarinoA C expression which evaluates to true if the target supports one-only 8045e4b17023SJohn Marinosemantics. 8046e4b17023SJohn Marino 8047e4b17023SJohn MarinoIf you don't define this macro, @file{varasm.c} provides a default 8048e4b17023SJohn Marinodefinition. If @code{MAKE_DECL_ONE_ONLY} is defined, the default 8049e4b17023SJohn Marinodefinition is @samp{1}; otherwise, it is @samp{0}. Define this macro if 8050e4b17023SJohn Marinoyou want to control one-only symbol support with a compiler flag, or if 8051e4b17023SJohn Marinosetting the @code{DECL_ONE_ONLY} flag is enough to mark a declaration to 8052e4b17023SJohn Marinobe emitted as one-only. 8053e4b17023SJohn Marino@end defmac 8054e4b17023SJohn Marino 8055e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_ASSEMBLE_VISIBILITY (tree @var{decl}, int @var{visibility}) 8056e4b17023SJohn MarinoThis target hook is a function to output to @var{asm_out_file} some 8057e4b17023SJohn Marinocommands that will make the symbol(s) associated with @var{decl} have 8058e4b17023SJohn Marinohidden, protected or internal visibility as specified by @var{visibility}. 8059e4b17023SJohn Marino@end deftypefn 8060e4b17023SJohn Marino 8061e4b17023SJohn Marino@defmac TARGET_WEAK_NOT_IN_ARCHIVE_TOC 8062e4b17023SJohn MarinoA C expression that evaluates to true if the target's linker expects 8063e4b17023SJohn Marinothat weak symbols do not appear in a static archive's table of contents. 8064e4b17023SJohn MarinoThe default is @code{0}. 8065e4b17023SJohn Marino 8066e4b17023SJohn MarinoLeaving weak symbols out of an archive's table of contents means that, 8067e4b17023SJohn Marinoif a symbol will only have a definition in one translation unit and 8068e4b17023SJohn Marinowill have undefined references from other translation units, that 8069e4b17023SJohn Marinosymbol should not be weak. Defining this macro to be nonzero will 8070e4b17023SJohn Marinothus have the effect that certain symbols that would normally be weak 8071e4b17023SJohn Marino(explicit template instantiations, and vtables for polymorphic classes 8072e4b17023SJohn Marinowith noninline key methods) will instead be nonweak. 8073e4b17023SJohn Marino 8074e4b17023SJohn MarinoThe C++ ABI requires this macro to be zero. Define this macro for 8075e4b17023SJohn Marinotargets where full C++ ABI compliance is impossible and where linker 8076e4b17023SJohn Marinorestrictions require weak symbols to be left out of a static archive's 8077e4b17023SJohn Marinotable of contents. 8078e4b17023SJohn Marino@end defmac 8079e4b17023SJohn Marino 8080e4b17023SJohn Marino@defmac ASM_OUTPUT_EXTERNAL (@var{stream}, @var{decl}, @var{name}) 8081e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 8082e4b17023SJohn Marino@var{stream} any text necessary for declaring the name of an external 8083e4b17023SJohn Marinosymbol named @var{name} which is referenced in this compilation but 8084e4b17023SJohn Marinonot defined. The value of @var{decl} is the tree node for the 8085e4b17023SJohn Marinodeclaration. 8086e4b17023SJohn Marino 8087e4b17023SJohn MarinoThis macro need not be defined if it does not need to output anything. 8088e4b17023SJohn MarinoThe GNU assembler and most Unix assemblers don't require anything. 8089e4b17023SJohn Marino@end defmac 8090e4b17023SJohn Marino 8091e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_EXTERNAL_LIBCALL (rtx @var{symref}) 8092e4b17023SJohn MarinoThis target hook is a function to output to @var{asm_out_file} an assembler 8093e4b17023SJohn Marinopseudo-op to declare a library function name external. The name of the 8094e4b17023SJohn Marinolibrary function is given by @var{symref}, which is a @code{symbol_ref}. 8095e4b17023SJohn Marino@end deftypefn 8096e4b17023SJohn Marino 8097e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_MARK_DECL_PRESERVED (const char *@var{symbol}) 8098e4b17023SJohn MarinoThis target hook is a function to output to @var{asm_out_file} an assembler 8099e4b17023SJohn Marinodirective to annotate @var{symbol} as used. The Darwin target uses the 8100e4b17023SJohn Marino.no_dead_code_strip directive. 8101e4b17023SJohn Marino@end deftypefn 8102e4b17023SJohn Marino 8103e4b17023SJohn Marino@defmac ASM_OUTPUT_LABELREF (@var{stream}, @var{name}) 8104e4b17023SJohn MarinoA C statement (sans semicolon) to output to the stdio stream 8105e4b17023SJohn Marino@var{stream} a reference in assembler syntax to a label named 8106e4b17023SJohn Marino@var{name}. This should add @samp{_} to the front of the name, if that 8107e4b17023SJohn Marinois customary on your operating system, as it is in most Berkeley Unix 8108e4b17023SJohn Marinosystems. This macro is used in @code{assemble_name}. 8109e4b17023SJohn Marino@end defmac 8110e4b17023SJohn Marino 8111e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_MANGLE_ASSEMBLER_NAME (const char *@var{name}) 8112e4b17023SJohn MarinoGiven a symbol @var{name}, perform same mangling as @code{varasm.c}'s @code{assemble_name}, but in memory rather than to a file stream, returning result as an @code{IDENTIFIER_NODE}. Required for correct LTO symtabs. The default implementation calls the @code{TARGET_STRIP_NAME_ENCODING} hook and then prepends the @code{USER_LABEL_PREFIX}, if any. 8113e4b17023SJohn Marino@end deftypefn 8114e4b17023SJohn Marino 8115e4b17023SJohn Marino@defmac ASM_OUTPUT_SYMBOL_REF (@var{stream}, @var{sym}) 8116e4b17023SJohn MarinoA C statement (sans semicolon) to output a reference to 8117e4b17023SJohn Marino@code{SYMBOL_REF} @var{sym}. If not defined, @code{assemble_name} 8118e4b17023SJohn Marinowill be used to output the name of the symbol. This macro may be used 8119e4b17023SJohn Marinoto modify the way a symbol is referenced depending on information 8120e4b17023SJohn Marinoencoded by @code{TARGET_ENCODE_SECTION_INFO}. 8121e4b17023SJohn Marino@end defmac 8122e4b17023SJohn Marino 8123e4b17023SJohn Marino@defmac ASM_OUTPUT_LABEL_REF (@var{stream}, @var{buf}) 8124e4b17023SJohn MarinoA C statement (sans semicolon) to output a reference to @var{buf}, the 8125e4b17023SJohn Marinoresult of @code{ASM_GENERATE_INTERNAL_LABEL}. If not defined, 8126e4b17023SJohn Marino@code{assemble_name} will be used to output the name of the symbol. 8127e4b17023SJohn MarinoThis macro is not used by @code{output_asm_label}, or the @code{%l} 8128e4b17023SJohn Marinospecifier that calls it; the intention is that this macro should be set 8129e4b17023SJohn Marinowhen it is necessary to output a label differently when its address is 8130e4b17023SJohn Marinobeing taken. 8131e4b17023SJohn Marino@end defmac 8132e4b17023SJohn Marino 8133e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_INTERNAL_LABEL (FILE *@var{stream}, const char *@var{prefix}, unsigned long @var{labelno}) 8134e4b17023SJohn MarinoA function to output to the stdio stream @var{stream} a label whose 8135e4b17023SJohn Marinoname is made from the string @var{prefix} and the number @var{labelno}. 8136e4b17023SJohn Marino 8137e4b17023SJohn MarinoIt is absolutely essential that these labels be distinct from the labels 8138e4b17023SJohn Marinoused for user-level functions and variables. Otherwise, certain programs 8139e4b17023SJohn Marinowill have name conflicts with internal labels. 8140e4b17023SJohn Marino 8141e4b17023SJohn MarinoIt is desirable to exclude internal labels from the symbol table of the 8142e4b17023SJohn Marinoobject file. Most assemblers have a naming convention for labels that 8143e4b17023SJohn Marinoshould be excluded; on many systems, the letter @samp{L} at the 8144e4b17023SJohn Marinobeginning of a label has this effect. You should find out what 8145e4b17023SJohn Marinoconvention your system uses, and follow it. 8146e4b17023SJohn Marino 8147e4b17023SJohn MarinoThe default version of this function utilizes @code{ASM_GENERATE_INTERNAL_LABEL}. 8148e4b17023SJohn Marino@end deftypefn 8149e4b17023SJohn Marino 8150e4b17023SJohn Marino@defmac ASM_OUTPUT_DEBUG_LABEL (@var{stream}, @var{prefix}, @var{num}) 8151e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} a debug info 8152e4b17023SJohn Marinolabel whose name is made from the string @var{prefix} and the number 8153e4b17023SJohn Marino@var{num}. This is useful for VLIW targets, where debug info labels 8154e4b17023SJohn Marinomay need to be treated differently than branch target labels. On some 8155e4b17023SJohn Marinosystems, branch target labels must be at the beginning of instruction 8156e4b17023SJohn Marinobundles, but debug info labels can occur in the middle of instruction 8157e4b17023SJohn Marinobundles. 8158e4b17023SJohn Marino 8159e4b17023SJohn MarinoIf this macro is not defined, then @code{(*targetm.asm_out.internal_label)} will be 8160e4b17023SJohn Marinoused. 8161e4b17023SJohn Marino@end defmac 8162e4b17023SJohn Marino 8163e4b17023SJohn Marino@defmac ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num}) 8164e4b17023SJohn MarinoA C statement to store into the string @var{string} a label whose name 8165e4b17023SJohn Marinois made from the string @var{prefix} and the number @var{num}. 8166e4b17023SJohn Marino 8167e4b17023SJohn MarinoThis string, when output subsequently by @code{assemble_name}, should 8168e4b17023SJohn Marinoproduce the output that @code{(*targetm.asm_out.internal_label)} would produce 8169e4b17023SJohn Marinowith the same @var{prefix} and @var{num}. 8170e4b17023SJohn Marino 8171e4b17023SJohn MarinoIf the string begins with @samp{*}, then @code{assemble_name} will 8172e4b17023SJohn Marinooutput the rest of the string unchanged. It is often convenient for 8173e4b17023SJohn Marino@code{ASM_GENERATE_INTERNAL_LABEL} to use @samp{*} in this way. If the 8174e4b17023SJohn Marinostring doesn't start with @samp{*}, then @code{ASM_OUTPUT_LABELREF} gets 8175e4b17023SJohn Marinoto output the string, and may change it. (Of course, 8176e4b17023SJohn Marino@code{ASM_OUTPUT_LABELREF} is also part of your machine description, so 8177e4b17023SJohn Marinoyou should know what it does on your machine.) 8178e4b17023SJohn Marino@end defmac 8179e4b17023SJohn Marino 8180e4b17023SJohn Marino@defmac ASM_FORMAT_PRIVATE_NAME (@var{outvar}, @var{name}, @var{number}) 8181e4b17023SJohn MarinoA C expression to assign to @var{outvar} (which is a variable of type 8182e4b17023SJohn Marino@code{char *}) a newly allocated string made from the string 8183e4b17023SJohn Marino@var{name} and the number @var{number}, with some suitable punctuation 8184e4b17023SJohn Marinoadded. Use @code{alloca} to get space for the string. 8185e4b17023SJohn Marino 8186e4b17023SJohn MarinoThe string will be used as an argument to @code{ASM_OUTPUT_LABELREF} to 8187e4b17023SJohn Marinoproduce an assembler label for an internal static variable whose name is 8188e4b17023SJohn Marino@var{name}. Therefore, the string must be such as to result in valid 8189e4b17023SJohn Marinoassembler code. The argument @var{number} is different each time this 8190e4b17023SJohn Marinomacro is executed; it prevents conflicts between similarly-named 8191e4b17023SJohn Marinointernal static variables in different scopes. 8192e4b17023SJohn Marino 8193e4b17023SJohn MarinoIdeally this string should not be a valid C identifier, to prevent any 8194e4b17023SJohn Marinoconflict with the user's own symbols. Most assemblers allow periods 8195e4b17023SJohn Marinoor percent signs in assembler symbols; putting at least one of these 8196e4b17023SJohn Marinobetween the name and the number will suffice. 8197e4b17023SJohn Marino 8198e4b17023SJohn MarinoIf this macro is not defined, a default definition will be provided 8199e4b17023SJohn Marinowhich is correct for most systems. 8200e4b17023SJohn Marino@end defmac 8201e4b17023SJohn Marino 8202e4b17023SJohn Marino@defmac ASM_OUTPUT_DEF (@var{stream}, @var{name}, @var{value}) 8203e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} assembler code 8204e4b17023SJohn Marinowhich defines (equates) the symbol @var{name} to have the value @var{value}. 8205e4b17023SJohn Marino 8206e4b17023SJohn Marino@findex SET_ASM_OP 8207e4b17023SJohn MarinoIf @code{SET_ASM_OP} is defined, a default definition is provided which is 8208e4b17023SJohn Marinocorrect for most systems. 8209e4b17023SJohn Marino@end defmac 8210e4b17023SJohn Marino 8211e4b17023SJohn Marino@defmac ASM_OUTPUT_DEF_FROM_DECLS (@var{stream}, @var{decl_of_name}, @var{decl_of_value}) 8212e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} assembler code 8213e4b17023SJohn Marinowhich defines (equates) the symbol whose tree node is @var{decl_of_name} 8214e4b17023SJohn Marinoto have the value of the tree node @var{decl_of_value}. This macro will 8215e4b17023SJohn Marinobe used in preference to @samp{ASM_OUTPUT_DEF} if it is defined and if 8216e4b17023SJohn Marinothe tree nodes are available. 8217e4b17023SJohn Marino 8218e4b17023SJohn Marino@findex SET_ASM_OP 8219e4b17023SJohn MarinoIf @code{SET_ASM_OP} is defined, a default definition is provided which is 8220e4b17023SJohn Marinocorrect for most systems. 8221e4b17023SJohn Marino@end defmac 8222e4b17023SJohn Marino 8223e4b17023SJohn Marino@defmac TARGET_DEFERRED_OUTPUT_DEFS (@var{decl_of_name}, @var{decl_of_value}) 8224e4b17023SJohn MarinoA C statement that evaluates to true if the assembler code which defines 8225e4b17023SJohn Marino(equates) the symbol whose tree node is @var{decl_of_name} to have the value 8226e4b17023SJohn Marinoof the tree node @var{decl_of_value} should be emitted near the end of the 8227e4b17023SJohn Marinocurrent compilation unit. The default is to not defer output of defines. 8228e4b17023SJohn MarinoThis macro affects defines output by @samp{ASM_OUTPUT_DEF} and 8229e4b17023SJohn Marino@samp{ASM_OUTPUT_DEF_FROM_DECLS}. 8230e4b17023SJohn Marino@end defmac 8231e4b17023SJohn Marino 8232e4b17023SJohn Marino@defmac ASM_OUTPUT_WEAK_ALIAS (@var{stream}, @var{name}, @var{value}) 8233e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} assembler code 8234e4b17023SJohn Marinowhich defines (equates) the weak symbol @var{name} to have the value 8235e4b17023SJohn Marino@var{value}. If @var{value} is @code{NULL}, it defines @var{name} as 8236e4b17023SJohn Marinoan undefined weak symbol. 8237e4b17023SJohn Marino 8238e4b17023SJohn MarinoDefine this macro if the target only supports weak aliases; define 8239e4b17023SJohn Marino@code{ASM_OUTPUT_DEF} instead if possible. 8240e4b17023SJohn Marino@end defmac 8241e4b17023SJohn Marino 8242e4b17023SJohn Marino@defmac OBJC_GEN_METHOD_LABEL (@var{buf}, @var{is_inst}, @var{class_name}, @var{cat_name}, @var{sel_name}) 8243e4b17023SJohn MarinoDefine this macro to override the default assembler names used for 8244e4b17023SJohn MarinoObjective-C methods. 8245e4b17023SJohn Marino 8246e4b17023SJohn MarinoThe default name is a unique method number followed by the name of the 8247e4b17023SJohn Marinoclass (e.g.@: @samp{_1_Foo}). For methods in categories, the name of 8248e4b17023SJohn Marinothe category is also included in the assembler name (e.g.@: 8249e4b17023SJohn Marino@samp{_1_Foo_Bar}). 8250e4b17023SJohn Marino 8251e4b17023SJohn MarinoThese names are safe on most systems, but make debugging difficult since 8252e4b17023SJohn Marinothe method's selector is not present in the name. Therefore, particular 8253e4b17023SJohn Marinosystems define other ways of computing names. 8254e4b17023SJohn Marino 8255e4b17023SJohn Marino@var{buf} is an expression of type @code{char *} which gives you a 8256e4b17023SJohn Marinobuffer in which to store the name; its length is as long as 8257e4b17023SJohn Marino@var{class_name}, @var{cat_name} and @var{sel_name} put together, plus 8258e4b17023SJohn Marino50 characters extra. 8259e4b17023SJohn Marino 8260e4b17023SJohn MarinoThe argument @var{is_inst} specifies whether the method is an instance 8261e4b17023SJohn Marinomethod or a class method; @var{class_name} is the name of the class; 8262e4b17023SJohn Marino@var{cat_name} is the name of the category (or @code{NULL} if the method is not 8263e4b17023SJohn Marinoin a category); and @var{sel_name} is the name of the selector. 8264e4b17023SJohn Marino 8265e4b17023SJohn MarinoOn systems where the assembler can handle quoted names, you can use this 8266e4b17023SJohn Marinomacro to provide more human-readable names. 8267e4b17023SJohn Marino@end defmac 8268e4b17023SJohn Marino 8269e4b17023SJohn Marino@node Initialization 8270e4b17023SJohn Marino@subsection How Initialization Functions Are Handled 8271e4b17023SJohn Marino@cindex initialization routines 8272e4b17023SJohn Marino@cindex termination routines 8273e4b17023SJohn Marino@cindex constructors, output of 8274e4b17023SJohn Marino@cindex destructors, output of 8275e4b17023SJohn Marino 8276e4b17023SJohn MarinoThe compiled code for certain languages includes @dfn{constructors} 8277e4b17023SJohn Marino(also called @dfn{initialization routines})---functions to initialize 8278e4b17023SJohn Marinodata in the program when the program is started. These functions need 8279e4b17023SJohn Marinoto be called before the program is ``started''---that is to say, before 8280e4b17023SJohn Marino@code{main} is called. 8281e4b17023SJohn Marino 8282e4b17023SJohn MarinoCompiling some languages generates @dfn{destructors} (also called 8283e4b17023SJohn Marino@dfn{termination routines}) that should be called when the program 8284e4b17023SJohn Marinoterminates. 8285e4b17023SJohn Marino 8286e4b17023SJohn MarinoTo make the initialization and termination functions work, the compiler 8287e4b17023SJohn Marinomust output something in the assembler code to cause those functions to 8288e4b17023SJohn Marinobe called at the appropriate time. When you port the compiler to a new 8289e4b17023SJohn Marinosystem, you need to specify how to do this. 8290e4b17023SJohn Marino 8291e4b17023SJohn MarinoThere are two major ways that GCC currently supports the execution of 8292e4b17023SJohn Marinoinitialization and termination functions. Each way has two variants. 8293e4b17023SJohn MarinoMuch of the structure is common to all four variations. 8294e4b17023SJohn Marino 8295e4b17023SJohn Marino@findex __CTOR_LIST__ 8296e4b17023SJohn Marino@findex __DTOR_LIST__ 8297e4b17023SJohn MarinoThe linker must build two lists of these functions---a list of 8298e4b17023SJohn Marinoinitialization functions, called @code{__CTOR_LIST__}, and a list of 8299e4b17023SJohn Marinotermination functions, called @code{__DTOR_LIST__}. 8300e4b17023SJohn Marino 8301e4b17023SJohn MarinoEach list always begins with an ignored function pointer (which may hold 8302e4b17023SJohn Marino0, @minus{}1, or a count of the function pointers after it, depending on 8303e4b17023SJohn Marinothe environment). This is followed by a series of zero or more function 8304e4b17023SJohn Marinopointers to constructors (or destructors), followed by a function 8305e4b17023SJohn Marinopointer containing zero. 8306e4b17023SJohn Marino 8307e4b17023SJohn MarinoDepending on the operating system and its executable file format, either 8308e4b17023SJohn Marino@file{crtstuff.c} or @file{libgcc2.c} traverses these lists at startup 8309e4b17023SJohn Marinotime and exit time. Constructors are called in reverse order of the 8310e4b17023SJohn Marinolist; destructors in forward order. 8311e4b17023SJohn Marino 8312e4b17023SJohn MarinoThe best way to handle static constructors works only for object file 8313e4b17023SJohn Marinoformats which provide arbitrarily-named sections. A section is set 8314e4b17023SJohn Marinoaside for a list of constructors, and another for a list of destructors. 8315e4b17023SJohn MarinoTraditionally these are called @samp{.ctors} and @samp{.dtors}. Each 8316e4b17023SJohn Marinoobject file that defines an initialization function also puts a word in 8317e4b17023SJohn Marinothe constructor section to point to that function. The linker 8318e4b17023SJohn Marinoaccumulates all these words into one contiguous @samp{.ctors} section. 8319e4b17023SJohn MarinoTermination functions are handled similarly. 8320e4b17023SJohn Marino 8321e4b17023SJohn MarinoThis method will be chosen as the default by @file{target-def.h} if 8322e4b17023SJohn Marino@code{TARGET_ASM_NAMED_SECTION} is defined. A target that does not 8323e4b17023SJohn Marinosupport arbitrary sections, but does support special designated 8324e4b17023SJohn Marinoconstructor and destructor sections may define @code{CTORS_SECTION_ASM_OP} 8325e4b17023SJohn Marinoand @code{DTORS_SECTION_ASM_OP} to achieve the same effect. 8326e4b17023SJohn Marino 8327e4b17023SJohn MarinoWhen arbitrary sections are available, there are two variants, depending 8328e4b17023SJohn Marinoupon how the code in @file{crtstuff.c} is called. On systems that 8329e4b17023SJohn Marinosupport a @dfn{.init} section which is executed at program startup, 8330e4b17023SJohn Marinoparts of @file{crtstuff.c} are compiled into that section. The 8331e4b17023SJohn Marinoprogram is linked by the @command{gcc} driver like this: 8332e4b17023SJohn Marino 8333e4b17023SJohn Marino@smallexample 8334e4b17023SJohn Marinold -o @var{output_file} crti.o crtbegin.o @dots{} -lgcc crtend.o crtn.o 8335e4b17023SJohn Marino@end smallexample 8336e4b17023SJohn Marino 8337e4b17023SJohn MarinoThe prologue of a function (@code{__init}) appears in the @code{.init} 8338e4b17023SJohn Marinosection of @file{crti.o}; the epilogue appears in @file{crtn.o}. Likewise 8339e4b17023SJohn Marinofor the function @code{__fini} in the @dfn{.fini} section. Normally these 8340e4b17023SJohn Marinofiles are provided by the operating system or by the GNU C library, but 8341e4b17023SJohn Marinoare provided by GCC for a few targets. 8342e4b17023SJohn Marino 8343e4b17023SJohn MarinoThe objects @file{crtbegin.o} and @file{crtend.o} are (for most targets) 8344e4b17023SJohn Marinocompiled from @file{crtstuff.c}. They contain, among other things, code 8345e4b17023SJohn Marinofragments within the @code{.init} and @code{.fini} sections that branch 8346e4b17023SJohn Marinoto routines in the @code{.text} section. The linker will pull all parts 8347e4b17023SJohn Marinoof a section together, which results in a complete @code{__init} function 8348e4b17023SJohn Marinothat invokes the routines we need at startup. 8349e4b17023SJohn Marino 8350e4b17023SJohn MarinoTo use this variant, you must define the @code{INIT_SECTION_ASM_OP} 8351e4b17023SJohn Marinomacro properly. 8352e4b17023SJohn Marino 8353e4b17023SJohn MarinoIf no init section is available, when GCC compiles any function called 8354e4b17023SJohn Marino@code{main} (or more accurately, any function designated as a program 8355e4b17023SJohn Marinoentry point by the language front end calling @code{expand_main_function}), 8356e4b17023SJohn Marinoit inserts a procedure call to @code{__main} as the first executable code 8357e4b17023SJohn Marinoafter the function prologue. The @code{__main} function is defined 8358e4b17023SJohn Marinoin @file{libgcc2.c} and runs the global constructors. 8359e4b17023SJohn Marino 8360e4b17023SJohn MarinoIn file formats that don't support arbitrary sections, there are again 8361e4b17023SJohn Marinotwo variants. In the simplest variant, the GNU linker (GNU @code{ld}) 8362e4b17023SJohn Marinoand an `a.out' format must be used. In this case, 8363e4b17023SJohn Marino@code{TARGET_ASM_CONSTRUCTOR} is defined to produce a @code{.stabs} 8364e4b17023SJohn Marinoentry of type @samp{N_SETT}, referencing the name @code{__CTOR_LIST__}, 8365e4b17023SJohn Marinoand with the address of the void function containing the initialization 8366e4b17023SJohn Marinocode as its value. The GNU linker recognizes this as a request to add 8367e4b17023SJohn Marinothe value to a @dfn{set}; the values are accumulated, and are eventually 8368e4b17023SJohn Marinoplaced in the executable as a vector in the format described above, with 8369e4b17023SJohn Marinoa leading (ignored) count and a trailing zero element. 8370e4b17023SJohn Marino@code{TARGET_ASM_DESTRUCTOR} is handled similarly. Since no init 8371e4b17023SJohn Marinosection is available, the absence of @code{INIT_SECTION_ASM_OP} causes 8372e4b17023SJohn Marinothe compilation of @code{main} to call @code{__main} as above, starting 8373e4b17023SJohn Marinothe initialization process. 8374e4b17023SJohn Marino 8375e4b17023SJohn MarinoThe last variant uses neither arbitrary sections nor the GNU linker. 8376e4b17023SJohn MarinoThis is preferable when you want to do dynamic linking and when using 8377e4b17023SJohn Marinofile formats which the GNU linker does not support, such as `ECOFF'@. In 8378e4b17023SJohn Marinothis case, @code{TARGET_HAVE_CTORS_DTORS} is false, initialization and 8379e4b17023SJohn Marinotermination functions are recognized simply by their names. This requires 8380e4b17023SJohn Marinoan extra program in the linkage step, called @command{collect2}. This program 8381e4b17023SJohn Marinopretends to be the linker, for use with GCC; it does its job by running 8382e4b17023SJohn Marinothe ordinary linker, but also arranges to include the vectors of 8383e4b17023SJohn Marinoinitialization and termination functions. These functions are called 8384e4b17023SJohn Marinovia @code{__main} as described above. In order to use this method, 8385e4b17023SJohn Marino@code{use_collect2} must be defined in the target in @file{config.gcc}. 8386e4b17023SJohn Marino 8387e4b17023SJohn Marino@ifinfo 8388e4b17023SJohn MarinoThe following section describes the specific macros that control and 8389e4b17023SJohn Marinocustomize the handling of initialization and termination functions. 8390e4b17023SJohn Marino@end ifinfo 8391e4b17023SJohn Marino 8392e4b17023SJohn Marino@node Macros for Initialization 8393e4b17023SJohn Marino@subsection Macros Controlling Initialization Routines 8394e4b17023SJohn Marino 8395e4b17023SJohn MarinoHere are the macros that control how the compiler handles initialization 8396e4b17023SJohn Marinoand termination functions: 8397e4b17023SJohn Marino 8398e4b17023SJohn Marino@defmac INIT_SECTION_ASM_OP 8399e4b17023SJohn MarinoIf defined, a C string constant, including spacing, for the assembler 8400e4b17023SJohn Marinooperation to identify the following data as initialization code. If not 8401e4b17023SJohn Marinodefined, GCC will assume such a section does not exist. When you are 8402e4b17023SJohn Marinousing special sections for initialization and termination functions, this 8403e4b17023SJohn Marinomacro also controls how @file{crtstuff.c} and @file{libgcc2.c} arrange to 8404e4b17023SJohn Marinorun the initialization functions. 8405e4b17023SJohn Marino@end defmac 8406e4b17023SJohn Marino 8407e4b17023SJohn Marino@defmac HAS_INIT_SECTION 8408e4b17023SJohn MarinoIf defined, @code{main} will not call @code{__main} as described above. 8409e4b17023SJohn MarinoThis macro should be defined for systems that control start-up code 8410e4b17023SJohn Marinoon a symbol-by-symbol basis, such as OSF/1, and should not 8411e4b17023SJohn Marinobe defined explicitly for systems that support @code{INIT_SECTION_ASM_OP}. 8412e4b17023SJohn Marino@end defmac 8413e4b17023SJohn Marino 8414e4b17023SJohn Marino@defmac LD_INIT_SWITCH 8415e4b17023SJohn MarinoIf defined, a C string constant for a switch that tells the linker that 8416e4b17023SJohn Marinothe following symbol is an initialization routine. 8417e4b17023SJohn Marino@end defmac 8418e4b17023SJohn Marino 8419e4b17023SJohn Marino@defmac LD_FINI_SWITCH 8420e4b17023SJohn MarinoIf defined, a C string constant for a switch that tells the linker that 8421e4b17023SJohn Marinothe following symbol is a finalization routine. 8422e4b17023SJohn Marino@end defmac 8423e4b17023SJohn Marino 8424e4b17023SJohn Marino@defmac COLLECT_SHARED_INIT_FUNC (@var{stream}, @var{func}) 8425e4b17023SJohn MarinoIf defined, a C statement that will write a function that can be 8426e4b17023SJohn Marinoautomatically called when a shared library is loaded. The function 8427e4b17023SJohn Marinoshould call @var{func}, which takes no arguments. If not defined, and 8428e4b17023SJohn Marinothe object format requires an explicit initialization function, then a 8429e4b17023SJohn Marinofunction called @code{_GLOBAL__DI} will be generated. 8430e4b17023SJohn Marino 8431e4b17023SJohn MarinoThis function and the following one are used by collect2 when linking a 8432e4b17023SJohn Marinoshared library that needs constructors or destructors, or has DWARF2 8433e4b17023SJohn Marinoexception tables embedded in the code. 8434e4b17023SJohn Marino@end defmac 8435e4b17023SJohn Marino 8436e4b17023SJohn Marino@defmac COLLECT_SHARED_FINI_FUNC (@var{stream}, @var{func}) 8437e4b17023SJohn MarinoIf defined, a C statement that will write a function that can be 8438e4b17023SJohn Marinoautomatically called when a shared library is unloaded. The function 8439e4b17023SJohn Marinoshould call @var{func}, which takes no arguments. If not defined, and 8440e4b17023SJohn Marinothe object format requires an explicit finalization function, then a 8441e4b17023SJohn Marinofunction called @code{_GLOBAL__DD} will be generated. 8442e4b17023SJohn Marino@end defmac 8443e4b17023SJohn Marino 8444e4b17023SJohn Marino@defmac INVOKE__main 8445e4b17023SJohn MarinoIf defined, @code{main} will call @code{__main} despite the presence of 8446e4b17023SJohn Marino@code{INIT_SECTION_ASM_OP}. This macro should be defined for systems 8447e4b17023SJohn Marinowhere the init section is not actually run automatically, but is still 8448e4b17023SJohn Marinouseful for collecting the lists of constructors and destructors. 8449e4b17023SJohn Marino@end defmac 8450e4b17023SJohn Marino 8451e4b17023SJohn Marino@defmac SUPPORTS_INIT_PRIORITY 8452e4b17023SJohn MarinoIf nonzero, the C++ @code{init_priority} attribute is supported and the 8453e4b17023SJohn Marinocompiler should emit instructions to control the order of initialization 8454e4b17023SJohn Marinoof objects. If zero, the compiler will issue an error message upon 8455e4b17023SJohn Marinoencountering an @code{init_priority} attribute. 8456e4b17023SJohn Marino@end defmac 8457e4b17023SJohn Marino 8458e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_HAVE_CTORS_DTORS 8459e4b17023SJohn MarinoThis value is true if the target supports some ``native'' method of 8460e4b17023SJohn Marinocollecting constructors and destructors to be run at startup and exit. 8461e4b17023SJohn MarinoIt is false if we must use @command{collect2}. 8462e4b17023SJohn Marino@end deftypevr 8463e4b17023SJohn Marino 8464e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_CONSTRUCTOR (rtx @var{symbol}, int @var{priority}) 8465e4b17023SJohn MarinoIf defined, a function that outputs assembler code to arrange to call 8466e4b17023SJohn Marinothe function referenced by @var{symbol} at initialization time. 8467e4b17023SJohn Marino 8468e4b17023SJohn MarinoAssume that @var{symbol} is a @code{SYMBOL_REF} for a function taking 8469e4b17023SJohn Marinono arguments and with no return value. If the target supports initialization 8470e4b17023SJohn Marinopriorities, @var{priority} is a value between 0 and @code{MAX_INIT_PRIORITY}; 8471e4b17023SJohn Marinootherwise it must be @code{DEFAULT_INIT_PRIORITY}. 8472e4b17023SJohn Marino 8473e4b17023SJohn MarinoIf this macro is not defined by the target, a suitable default will 8474e4b17023SJohn Marinobe chosen if (1) the target supports arbitrary section names, (2) the 8475e4b17023SJohn Marinotarget defines @code{CTORS_SECTION_ASM_OP}, or (3) @code{USE_COLLECT2} 8476e4b17023SJohn Marinois not defined. 8477e4b17023SJohn Marino@end deftypefn 8478e4b17023SJohn Marino 8479e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_DESTRUCTOR (rtx @var{symbol}, int @var{priority}) 8480e4b17023SJohn MarinoThis is like @code{TARGET_ASM_CONSTRUCTOR} but used for termination 8481e4b17023SJohn Marinofunctions rather than initialization functions. 8482e4b17023SJohn Marino@end deftypefn 8483e4b17023SJohn Marino 8484e4b17023SJohn MarinoIf @code{TARGET_HAVE_CTORS_DTORS} is true, the initialization routine 8485e4b17023SJohn Marinogenerated for the generated object file will have static linkage. 8486e4b17023SJohn Marino 8487e4b17023SJohn MarinoIf your system uses @command{collect2} as the means of processing 8488e4b17023SJohn Marinoconstructors, then that program normally uses @command{nm} to scan 8489e4b17023SJohn Marinoan object file for constructor functions to be called. 8490e4b17023SJohn Marino 8491e4b17023SJohn MarinoOn certain kinds of systems, you can define this macro to make 8492e4b17023SJohn Marino@command{collect2} work faster (and, in some cases, make it work at all): 8493e4b17023SJohn Marino 8494e4b17023SJohn Marino@defmac OBJECT_FORMAT_COFF 8495e4b17023SJohn MarinoDefine this macro if the system uses COFF (Common Object File Format) 8496e4b17023SJohn Marinoobject files, so that @command{collect2} can assume this format and scan 8497e4b17023SJohn Marinoobject files directly for dynamic constructor/destructor functions. 8498e4b17023SJohn Marino 8499e4b17023SJohn MarinoThis macro is effective only in a native compiler; @command{collect2} as 8500e4b17023SJohn Marinopart of a cross compiler always uses @command{nm} for the target machine. 8501e4b17023SJohn Marino@end defmac 8502e4b17023SJohn Marino 8503e4b17023SJohn Marino@defmac REAL_NM_FILE_NAME 8504e4b17023SJohn MarinoDefine this macro as a C string constant containing the file name to use 8505e4b17023SJohn Marinoto execute @command{nm}. The default is to search the path normally for 8506e4b17023SJohn Marino@command{nm}. 8507e4b17023SJohn Marino@end defmac 8508e4b17023SJohn Marino 8509e4b17023SJohn Marino@defmac NM_FLAGS 8510e4b17023SJohn Marino@command{collect2} calls @command{nm} to scan object files for static 8511e4b17023SJohn Marinoconstructors and destructors and LTO info. By default, @option{-n} is 8512e4b17023SJohn Marinopassed. Define @code{NM_FLAGS} to a C string constant if other options 8513e4b17023SJohn Marinoare needed to get the same output format as GNU @command{nm -n} 8514e4b17023SJohn Marinoproduces. 8515e4b17023SJohn Marino@end defmac 8516e4b17023SJohn Marino 8517e4b17023SJohn MarinoIf your system supports shared libraries and has a program to list the 8518e4b17023SJohn Marinodynamic dependencies of a given library or executable, you can define 8519e4b17023SJohn Marinothese macros to enable support for running initialization and 8520e4b17023SJohn Marinotermination functions in shared libraries: 8521e4b17023SJohn Marino 8522e4b17023SJohn Marino@defmac LDD_SUFFIX 8523e4b17023SJohn MarinoDefine this macro to a C string constant containing the name of the program 8524e4b17023SJohn Marinowhich lists dynamic dependencies, like @command{ldd} under SunOS 4. 8525e4b17023SJohn Marino@end defmac 8526e4b17023SJohn Marino 8527e4b17023SJohn Marino@defmac PARSE_LDD_OUTPUT (@var{ptr}) 8528e4b17023SJohn MarinoDefine this macro to be C code that extracts filenames from the output 8529e4b17023SJohn Marinoof the program denoted by @code{LDD_SUFFIX}. @var{ptr} is a variable 8530e4b17023SJohn Marinoof type @code{char *} that points to the beginning of a line of output 8531e4b17023SJohn Marinofrom @code{LDD_SUFFIX}. If the line lists a dynamic dependency, the 8532e4b17023SJohn Marinocode must advance @var{ptr} to the beginning of the filename on that 8533e4b17023SJohn Marinoline. Otherwise, it must set @var{ptr} to @code{NULL}. 8534e4b17023SJohn Marino@end defmac 8535e4b17023SJohn Marino 8536e4b17023SJohn Marino@defmac SHLIB_SUFFIX 8537e4b17023SJohn MarinoDefine this macro to a C string constant containing the default shared 8538e4b17023SJohn Marinolibrary extension of the target (e.g., @samp{".so"}). @command{collect2} 8539e4b17023SJohn Marinostrips version information after this suffix when generating global 8540e4b17023SJohn Marinoconstructor and destructor names. This define is only needed on targets 8541e4b17023SJohn Marinothat use @command{collect2} to process constructors and destructors. 8542e4b17023SJohn Marino@end defmac 8543e4b17023SJohn Marino 8544e4b17023SJohn Marino@node Instruction Output 8545e4b17023SJohn Marino@subsection Output of Assembler Instructions 8546e4b17023SJohn Marino 8547e4b17023SJohn Marino@c prevent bad page break with this line 8548e4b17023SJohn MarinoThis describes assembler instruction output. 8549e4b17023SJohn Marino 8550e4b17023SJohn Marino@defmac REGISTER_NAMES 8551e4b17023SJohn MarinoA C initializer containing the assembler's names for the machine 8552e4b17023SJohn Marinoregisters, each one as a C string constant. This is what translates 8553e4b17023SJohn Marinoregister numbers in the compiler into assembler language. 8554e4b17023SJohn Marino@end defmac 8555e4b17023SJohn Marino 8556e4b17023SJohn Marino@defmac ADDITIONAL_REGISTER_NAMES 8557e4b17023SJohn MarinoIf defined, a C initializer for an array of structures containing a name 8558e4b17023SJohn Marinoand a register number. This macro defines additional names for hard 8559e4b17023SJohn Marinoregisters, thus allowing the @code{asm} option in declarations to refer 8560e4b17023SJohn Marinoto registers using alternate names. 8561e4b17023SJohn Marino@end defmac 8562e4b17023SJohn Marino 8563e4b17023SJohn Marino@defmac OVERLAPPING_REGISTER_NAMES 8564e4b17023SJohn MarinoIf defined, a C initializer for an array of structures containing a 8565e4b17023SJohn Marinoname, a register number and a count of the number of consecutive 8566e4b17023SJohn Marinomachine registers the name overlaps. This macro defines additional 8567e4b17023SJohn Marinonames for hard registers, thus allowing the @code{asm} option in 8568e4b17023SJohn Marinodeclarations to refer to registers using alternate names. Unlike 8569e4b17023SJohn Marino@code{ADDITIONAL_REGISTER_NAMES}, this macro should be used when the 8570e4b17023SJohn Marinoregister name implies multiple underlying registers. 8571e4b17023SJohn Marino 8572e4b17023SJohn MarinoThis macro should be used when it is important that a clobber in an 8573e4b17023SJohn Marino@code{asm} statement clobbers all the underlying values implied by the 8574e4b17023SJohn Marinoregister name. For example, on ARM, clobbering the double-precision 8575e4b17023SJohn MarinoVFP register ``d0'' implies clobbering both single-precision registers 8576e4b17023SJohn Marino``s0'' and ``s1''. 8577e4b17023SJohn Marino@end defmac 8578e4b17023SJohn Marino 8579e4b17023SJohn Marino@defmac ASM_OUTPUT_OPCODE (@var{stream}, @var{ptr}) 8580e4b17023SJohn MarinoDefine this macro if you are using an unusual assembler that 8581e4b17023SJohn Marinorequires different names for the machine instructions. 8582e4b17023SJohn Marino 8583e4b17023SJohn MarinoThe definition is a C statement or statements which output an 8584e4b17023SJohn Marinoassembler instruction opcode to the stdio stream @var{stream}. The 8585e4b17023SJohn Marinomacro-operand @var{ptr} is a variable of type @code{char *} which 8586e4b17023SJohn Marinopoints to the opcode name in its ``internal'' form---the form that is 8587e4b17023SJohn Marinowritten in the machine description. The definition should output the 8588e4b17023SJohn Marinoopcode name to @var{stream}, performing any translation you desire, and 8589e4b17023SJohn Marinoincrement the variable @var{ptr} to point at the end of the opcode 8590e4b17023SJohn Marinoso that it will not be output twice. 8591e4b17023SJohn Marino 8592e4b17023SJohn MarinoIn fact, your macro definition may process less than the entire opcode 8593e4b17023SJohn Marinoname, or more than the opcode name; but if you want to process text 8594e4b17023SJohn Marinothat includes @samp{%}-sequences to substitute operands, you must take 8595e4b17023SJohn Marinocare of the substitution yourself. Just be sure to increment 8596e4b17023SJohn Marino@var{ptr} over whatever text should not be output normally. 8597e4b17023SJohn Marino 8598e4b17023SJohn Marino@findex recog_data.operand 8599e4b17023SJohn MarinoIf you need to look at the operand values, they can be found as the 8600e4b17023SJohn Marinoelements of @code{recog_data.operand}. 8601e4b17023SJohn Marino 8602e4b17023SJohn MarinoIf the macro definition does nothing, the instruction is output 8603e4b17023SJohn Marinoin the usual way. 8604e4b17023SJohn Marino@end defmac 8605e4b17023SJohn Marino 8606e4b17023SJohn Marino@defmac FINAL_PRESCAN_INSN (@var{insn}, @var{opvec}, @var{noperands}) 8607e4b17023SJohn MarinoIf defined, a C statement to be executed just prior to the output of 8608e4b17023SJohn Marinoassembler code for @var{insn}, to modify the extracted operands so 8609e4b17023SJohn Marinothey will be output differently. 8610e4b17023SJohn Marino 8611e4b17023SJohn MarinoHere the argument @var{opvec} is the vector containing the operands 8612e4b17023SJohn Marinoextracted from @var{insn}, and @var{noperands} is the number of 8613e4b17023SJohn Marinoelements of the vector which contain meaningful data for this insn. 8614e4b17023SJohn MarinoThe contents of this vector are what will be used to convert the insn 8615e4b17023SJohn Marinotemplate into assembler code, so you can change the assembler output 8616e4b17023SJohn Marinoby changing the contents of the vector. 8617e4b17023SJohn Marino 8618e4b17023SJohn MarinoThis macro is useful when various assembler syntaxes share a single 8619e4b17023SJohn Marinofile of instruction patterns; by defining this macro differently, you 8620e4b17023SJohn Marinocan cause a large class of instructions to be output differently (such 8621e4b17023SJohn Marinoas with rearranged operands). Naturally, variations in assembler 8622e4b17023SJohn Marinosyntax affecting individual insn patterns ought to be handled by 8623e4b17023SJohn Marinowriting conditional output routines in those patterns. 8624e4b17023SJohn Marino 8625e4b17023SJohn MarinoIf this macro is not defined, it is equivalent to a null statement. 8626e4b17023SJohn Marino@end defmac 8627e4b17023SJohn Marino 8628e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_FINAL_POSTSCAN_INSN (FILE *@var{file}, rtx @var{insn}, rtx *@var{opvec}, int @var{noperands}) 8629e4b17023SJohn MarinoIf defined, this target hook is a function which is executed just after the 8630e4b17023SJohn Marinooutput of assembler code for @var{insn}, to change the mode of the assembler 8631e4b17023SJohn Marinoif necessary. 8632e4b17023SJohn Marino 8633e4b17023SJohn MarinoHere the argument @var{opvec} is the vector containing the operands 8634e4b17023SJohn Marinoextracted from @var{insn}, and @var{noperands} is the number of 8635e4b17023SJohn Marinoelements of the vector which contain meaningful data for this insn. 8636e4b17023SJohn MarinoThe contents of this vector are what was used to convert the insn 8637e4b17023SJohn Marinotemplate into assembler code, so you can change the assembler mode 8638e4b17023SJohn Marinoby checking the contents of the vector. 8639e4b17023SJohn Marino@end deftypefn 8640e4b17023SJohn Marino 8641e4b17023SJohn Marino@defmac PRINT_OPERAND (@var{stream}, @var{x}, @var{code}) 8642e4b17023SJohn MarinoA C compound statement to output to stdio stream @var{stream} the 8643e4b17023SJohn Marinoassembler syntax for an instruction operand @var{x}. @var{x} is an 8644e4b17023SJohn MarinoRTL expression. 8645e4b17023SJohn Marino 8646e4b17023SJohn Marino@var{code} is a value that can be used to specify one of several ways 8647e4b17023SJohn Marinoof printing the operand. It is used when identical operands must be 8648e4b17023SJohn Marinoprinted differently depending on the context. @var{code} comes from 8649e4b17023SJohn Marinothe @samp{%} specification that was used to request printing of the 8650e4b17023SJohn Marinooperand. If the specification was just @samp{%@var{digit}} then 8651e4b17023SJohn Marino@var{code} is 0; if the specification was @samp{%@var{ltr} 8652e4b17023SJohn Marino@var{digit}} then @var{code} is the ASCII code for @var{ltr}. 8653e4b17023SJohn Marino 8654e4b17023SJohn Marino@findex reg_names 8655e4b17023SJohn MarinoIf @var{x} is a register, this macro should print the register's name. 8656e4b17023SJohn MarinoThe names can be found in an array @code{reg_names} whose type is 8657e4b17023SJohn Marino@code{char *[]}. @code{reg_names} is initialized from 8658e4b17023SJohn Marino@code{REGISTER_NAMES}. 8659e4b17023SJohn Marino 8660e4b17023SJohn MarinoWhen the machine description has a specification @samp{%@var{punct}} 8661e4b17023SJohn Marino(a @samp{%} followed by a punctuation character), this macro is called 8662e4b17023SJohn Marinowith a null pointer for @var{x} and the punctuation character for 8663e4b17023SJohn Marino@var{code}. 8664e4b17023SJohn Marino@end defmac 8665e4b17023SJohn Marino 8666e4b17023SJohn Marino@defmac PRINT_OPERAND_PUNCT_VALID_P (@var{code}) 8667e4b17023SJohn MarinoA C expression which evaluates to true if @var{code} is a valid 8668e4b17023SJohn Marinopunctuation character for use in the @code{PRINT_OPERAND} macro. If 8669e4b17023SJohn Marino@code{PRINT_OPERAND_PUNCT_VALID_P} is not defined, it means that no 8670e4b17023SJohn Marinopunctuation characters (except for the standard one, @samp{%}) are used 8671e4b17023SJohn Marinoin this way. 8672e4b17023SJohn Marino@end defmac 8673e4b17023SJohn Marino 8674e4b17023SJohn Marino@defmac PRINT_OPERAND_ADDRESS (@var{stream}, @var{x}) 8675e4b17023SJohn MarinoA C compound statement to output to stdio stream @var{stream} the 8676e4b17023SJohn Marinoassembler syntax for an instruction operand that is a memory reference 8677e4b17023SJohn Marinowhose address is @var{x}. @var{x} is an RTL expression. 8678e4b17023SJohn Marino 8679e4b17023SJohn Marino@cindex @code{TARGET_ENCODE_SECTION_INFO} usage 8680e4b17023SJohn MarinoOn some machines, the syntax for a symbolic address depends on the 8681e4b17023SJohn Marinosection that the address refers to. On these machines, define the hook 8682e4b17023SJohn Marino@code{TARGET_ENCODE_SECTION_INFO} to store the information into the 8683e4b17023SJohn Marino@code{symbol_ref}, and then check for it here. @xref{Assembler 8684e4b17023SJohn MarinoFormat}. 8685e4b17023SJohn Marino@end defmac 8686e4b17023SJohn Marino 8687e4b17023SJohn Marino@findex dbr_sequence_length 8688e4b17023SJohn Marino@defmac DBR_OUTPUT_SEQEND (@var{file}) 8689e4b17023SJohn MarinoA C statement, to be executed after all slot-filler instructions have 8690e4b17023SJohn Marinobeen output. If necessary, call @code{dbr_sequence_length} to 8691e4b17023SJohn Marinodetermine the number of slots filled in a sequence (zero if not 8692e4b17023SJohn Marinocurrently outputting a sequence), to decide how many no-ops to output, 8693e4b17023SJohn Marinoor whatever. 8694e4b17023SJohn Marino 8695e4b17023SJohn MarinoDon't define this macro if it has nothing to do, but it is helpful in 8696e4b17023SJohn Marinoreading assembly output if the extent of the delay sequence is made 8697e4b17023SJohn Marinoexplicit (e.g.@: with white space). 8698e4b17023SJohn Marino@end defmac 8699e4b17023SJohn Marino 8700e4b17023SJohn Marino@findex final_sequence 8701e4b17023SJohn MarinoNote that output routines for instructions with delay slots must be 8702e4b17023SJohn Marinoprepared to deal with not being output as part of a sequence 8703e4b17023SJohn Marino(i.e.@: when the scheduling pass is not run, or when no slot fillers could be 8704e4b17023SJohn Marinofound.) The variable @code{final_sequence} is null when not 8705e4b17023SJohn Marinoprocessing a sequence, otherwise it contains the @code{sequence} rtx 8706e4b17023SJohn Marinobeing output. 8707e4b17023SJohn Marino 8708e4b17023SJohn Marino@findex asm_fprintf 8709e4b17023SJohn Marino@defmac REGISTER_PREFIX 8710e4b17023SJohn Marino@defmacx LOCAL_LABEL_PREFIX 8711e4b17023SJohn Marino@defmacx USER_LABEL_PREFIX 8712e4b17023SJohn Marino@defmacx IMMEDIATE_PREFIX 8713e4b17023SJohn MarinoIf defined, C string expressions to be used for the @samp{%R}, @samp{%L}, 8714e4b17023SJohn Marino@samp{%U}, and @samp{%I} options of @code{asm_fprintf} (see 8715e4b17023SJohn Marino@file{final.c}). These are useful when a single @file{md} file must 8716e4b17023SJohn Marinosupport multiple assembler formats. In that case, the various @file{tm.h} 8717e4b17023SJohn Marinofiles can define these macros differently. 8718e4b17023SJohn Marino@end defmac 8719e4b17023SJohn Marino 8720e4b17023SJohn Marino@defmac ASM_FPRINTF_EXTENSIONS (@var{file}, @var{argptr}, @var{format}) 8721e4b17023SJohn MarinoIf defined this macro should expand to a series of @code{case} 8722e4b17023SJohn Marinostatements which will be parsed inside the @code{switch} statement of 8723e4b17023SJohn Marinothe @code{asm_fprintf} function. This allows targets to define extra 8724e4b17023SJohn Marinoprintf formats which may useful when generating their assembler 8725e4b17023SJohn Marinostatements. Note that uppercase letters are reserved for future 8726e4b17023SJohn Marinogeneric extensions to asm_fprintf, and so are not available to target 8727e4b17023SJohn Marinospecific code. The output file is given by the parameter @var{file}. 8728e4b17023SJohn MarinoThe varargs input pointer is @var{argptr} and the rest of the format 8729e4b17023SJohn Marinostring, starting the character after the one that is being switched 8730e4b17023SJohn Marinoupon, is pointed to by @var{format}. 8731e4b17023SJohn Marino@end defmac 8732e4b17023SJohn Marino 8733e4b17023SJohn Marino@defmac ASSEMBLER_DIALECT 8734e4b17023SJohn MarinoIf your target supports multiple dialects of assembler language (such as 8735e4b17023SJohn Marinodifferent opcodes), define this macro as a C expression that gives the 8736e4b17023SJohn Marinonumeric index of the assembler language dialect to use, with zero as the 8737e4b17023SJohn Marinofirst variant. 8738e4b17023SJohn Marino 8739e4b17023SJohn MarinoIf this macro is defined, you may use constructs of the form 8740e4b17023SJohn Marino@smallexample 8741e4b17023SJohn Marino@samp{@{option0|option1|option2@dots{}@}} 8742e4b17023SJohn Marino@end smallexample 8743e4b17023SJohn Marino@noindent 8744e4b17023SJohn Marinoin the output templates of patterns (@pxref{Output Template}) or in the 8745e4b17023SJohn Marinofirst argument of @code{asm_fprintf}. This construct outputs 8746e4b17023SJohn Marino@samp{option0}, @samp{option1}, @samp{option2}, etc., if the value of 8747e4b17023SJohn Marino@code{ASSEMBLER_DIALECT} is zero, one, two, etc. Any special characters 8748e4b17023SJohn Marinowithin these strings retain their usual meaning. If there are fewer 8749e4b17023SJohn Marinoalternatives within the braces than the value of 8750e4b17023SJohn Marino@code{ASSEMBLER_DIALECT}, the construct outputs nothing. 8751e4b17023SJohn Marino 8752e4b17023SJohn MarinoIf you do not define this macro, the characters @samp{@{}, @samp{|} and 8753e4b17023SJohn Marino@samp{@}} do not have any special meaning when used in templates or 8754e4b17023SJohn Marinooperands to @code{asm_fprintf}. 8755e4b17023SJohn Marino 8756e4b17023SJohn MarinoDefine the macros @code{REGISTER_PREFIX}, @code{LOCAL_LABEL_PREFIX}, 8757e4b17023SJohn Marino@code{USER_LABEL_PREFIX} and @code{IMMEDIATE_PREFIX} if you can express 8758e4b17023SJohn Marinothe variations in assembler language syntax with that mechanism. Define 8759e4b17023SJohn Marino@code{ASSEMBLER_DIALECT} and use the @samp{@{option0|option1@}} syntax 8760e4b17023SJohn Marinoif the syntax variant are larger and involve such things as different 8761e4b17023SJohn Marinoopcodes or operand order. 8762e4b17023SJohn Marino@end defmac 8763e4b17023SJohn Marino 8764e4b17023SJohn Marino@defmac ASM_OUTPUT_REG_PUSH (@var{stream}, @var{regno}) 8765e4b17023SJohn MarinoA C expression to output to @var{stream} some assembler code 8766e4b17023SJohn Marinowhich will push hard register number @var{regno} onto the stack. 8767e4b17023SJohn MarinoThe code need not be optimal, since this macro is used only when 8768e4b17023SJohn Marinoprofiling. 8769e4b17023SJohn Marino@end defmac 8770e4b17023SJohn Marino 8771e4b17023SJohn Marino@defmac ASM_OUTPUT_REG_POP (@var{stream}, @var{regno}) 8772e4b17023SJohn MarinoA C expression to output to @var{stream} some assembler code 8773e4b17023SJohn Marinowhich will pop hard register number @var{regno} off of the stack. 8774e4b17023SJohn MarinoThe code need not be optimal, since this macro is used only when 8775e4b17023SJohn Marinoprofiling. 8776e4b17023SJohn Marino@end defmac 8777e4b17023SJohn Marino 8778e4b17023SJohn Marino@node Dispatch Tables 8779e4b17023SJohn Marino@subsection Output of Dispatch Tables 8780e4b17023SJohn Marino 8781e4b17023SJohn Marino@c prevent bad page break with this line 8782e4b17023SJohn MarinoThis concerns dispatch tables. 8783e4b17023SJohn Marino 8784e4b17023SJohn Marino@cindex dispatch table 8785e4b17023SJohn Marino@defmac ASM_OUTPUT_ADDR_DIFF_ELT (@var{stream}, @var{body}, @var{value}, @var{rel}) 8786e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler 8787e4b17023SJohn Marinopseudo-instruction to generate a difference between two labels. 8788e4b17023SJohn Marino@var{value} and @var{rel} are the numbers of two internal labels. The 8789e4b17023SJohn Marinodefinitions of these labels are output using 8790e4b17023SJohn Marino@code{(*targetm.asm_out.internal_label)}, and they must be printed in the same 8791e4b17023SJohn Marinoway here. For example, 8792e4b17023SJohn Marino 8793e4b17023SJohn Marino@smallexample 8794e4b17023SJohn Marinofprintf (@var{stream}, "\t.word L%d-L%d\n", 8795e4b17023SJohn Marino @var{value}, @var{rel}) 8796e4b17023SJohn Marino@end smallexample 8797e4b17023SJohn Marino 8798e4b17023SJohn MarinoYou must provide this macro on machines where the addresses in a 8799e4b17023SJohn Marinodispatch table are relative to the table's own address. If defined, GCC 8800e4b17023SJohn Marinowill also use this macro on all machines when producing PIC@. 8801e4b17023SJohn Marino@var{body} is the body of the @code{ADDR_DIFF_VEC}; it is provided so that the 8802e4b17023SJohn Marinomode and flags can be read. 8803e4b17023SJohn Marino@end defmac 8804e4b17023SJohn Marino 8805e4b17023SJohn Marino@defmac ASM_OUTPUT_ADDR_VEC_ELT (@var{stream}, @var{value}) 8806e4b17023SJohn MarinoThis macro should be provided on machines where the addresses 8807e4b17023SJohn Marinoin a dispatch table are absolute. 8808e4b17023SJohn Marino 8809e4b17023SJohn MarinoThe definition should be a C statement to output to the stdio stream 8810e4b17023SJohn Marino@var{stream} an assembler pseudo-instruction to generate a reference to 8811e4b17023SJohn Marinoa label. @var{value} is the number of an internal label whose 8812e4b17023SJohn Marinodefinition is output using @code{(*targetm.asm_out.internal_label)}. 8813e4b17023SJohn MarinoFor example, 8814e4b17023SJohn Marino 8815e4b17023SJohn Marino@smallexample 8816e4b17023SJohn Marinofprintf (@var{stream}, "\t.word L%d\n", @var{value}) 8817e4b17023SJohn Marino@end smallexample 8818e4b17023SJohn Marino@end defmac 8819e4b17023SJohn Marino 8820e4b17023SJohn Marino@defmac ASM_OUTPUT_CASE_LABEL (@var{stream}, @var{prefix}, @var{num}, @var{table}) 8821e4b17023SJohn MarinoDefine this if the label before a jump-table needs to be output 8822e4b17023SJohn Marinospecially. The first three arguments are the same as for 8823e4b17023SJohn Marino@code{(*targetm.asm_out.internal_label)}; the fourth argument is the 8824e4b17023SJohn Marinojump-table which follows (a @code{jump_insn} containing an 8825e4b17023SJohn Marino@code{addr_vec} or @code{addr_diff_vec}). 8826e4b17023SJohn Marino 8827e4b17023SJohn MarinoThis feature is used on system V to output a @code{swbeg} statement 8828e4b17023SJohn Marinofor the table. 8829e4b17023SJohn Marino 8830e4b17023SJohn MarinoIf this macro is not defined, these labels are output with 8831e4b17023SJohn Marino@code{(*targetm.asm_out.internal_label)}. 8832e4b17023SJohn Marino@end defmac 8833e4b17023SJohn Marino 8834e4b17023SJohn Marino@defmac ASM_OUTPUT_CASE_END (@var{stream}, @var{num}, @var{table}) 8835e4b17023SJohn MarinoDefine this if something special must be output at the end of a 8836e4b17023SJohn Marinojump-table. The definition should be a C statement to be executed 8837e4b17023SJohn Marinoafter the assembler code for the table is written. It should write 8838e4b17023SJohn Marinothe appropriate code to stdio stream @var{stream}. The argument 8839e4b17023SJohn Marino@var{table} is the jump-table insn, and @var{num} is the label-number 8840e4b17023SJohn Marinoof the preceding label. 8841e4b17023SJohn Marino 8842e4b17023SJohn MarinoIf this macro is not defined, nothing special is output at the end of 8843e4b17023SJohn Marinothe jump-table. 8844e4b17023SJohn Marino@end defmac 8845e4b17023SJohn Marino 8846e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_EMIT_UNWIND_LABEL (FILE *@var{stream}, tree @var{decl}, int @var{for_eh}, int @var{empty}) 8847e4b17023SJohn MarinoThis target hook emits a label at the beginning of each FDE@. It 8848e4b17023SJohn Marinoshould be defined on targets where FDEs need special labels, and it 8849e4b17023SJohn Marinoshould write the appropriate label, for the FDE associated with the 8850e4b17023SJohn Marinofunction declaration @var{decl}, to the stdio stream @var{stream}. 8851e4b17023SJohn MarinoThe third argument, @var{for_eh}, is a boolean: true if this is for an 8852e4b17023SJohn Marinoexception table. The fourth argument, @var{empty}, is a boolean: 8853e4b17023SJohn Marinotrue if this is a placeholder label for an omitted FDE@. 8854e4b17023SJohn Marino 8855e4b17023SJohn MarinoThe default is that FDEs are not given nonlocal labels. 8856e4b17023SJohn Marino@end deftypefn 8857e4b17023SJohn Marino 8858e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL (FILE *@var{stream}) 8859e4b17023SJohn MarinoThis target hook emits a label at the beginning of the exception table. 8860e4b17023SJohn MarinoIt should be defined on targets where it is desirable for the table 8861e4b17023SJohn Marinoto be broken up according to function. 8862e4b17023SJohn Marino 8863e4b17023SJohn MarinoThe default is that no label is emitted. 8864e4b17023SJohn Marino@end deftypefn 8865e4b17023SJohn Marino 8866e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_EMIT_EXCEPT_PERSONALITY (rtx @var{personality}) 8867e4b17023SJohn MarinoIf the target implements @code{TARGET_ASM_UNWIND_EMIT}, this hook may be used to emit a directive to install a personality hook into the unwind info. This hook should not be used if dwarf2 unwind info is used. 8868e4b17023SJohn Marino@end deftypefn 8869e4b17023SJohn Marino 8870e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_UNWIND_EMIT (FILE *@var{stream}, rtx @var{insn}) 8871e4b17023SJohn MarinoThis target hook emits assembly directives required to unwind the 8872e4b17023SJohn Marinogiven instruction. This is only used when @code{TARGET_EXCEPT_UNWIND_INFO} 8873e4b17023SJohn Marinoreturns @code{UI_TARGET}. 8874e4b17023SJohn Marino@end deftypefn 8875e4b17023SJohn Marino 8876e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_ASM_UNWIND_EMIT_BEFORE_INSN 8877e4b17023SJohn MarinoTrue if the @code{TARGET_ASM_UNWIND_EMIT} hook should be called before the assembly for @var{insn} has been emitted, false if the hook should be called afterward. 8878e4b17023SJohn Marino@end deftypevr 8879e4b17023SJohn Marino 8880e4b17023SJohn Marino@node Exception Region Output 8881e4b17023SJohn Marino@subsection Assembler Commands for Exception Regions 8882e4b17023SJohn Marino 8883e4b17023SJohn Marino@c prevent bad page break with this line 8884e4b17023SJohn Marino 8885e4b17023SJohn MarinoThis describes commands marking the start and the end of an exception 8886e4b17023SJohn Marinoregion. 8887e4b17023SJohn Marino 8888e4b17023SJohn Marino@defmac EH_FRAME_SECTION_NAME 8889e4b17023SJohn MarinoIf defined, a C string constant for the name of the section containing 8890e4b17023SJohn Marinoexception handling frame unwind information. If not defined, GCC will 8891e4b17023SJohn Marinoprovide a default definition if the target supports named sections. 8892e4b17023SJohn Marino@file{crtstuff.c} uses this macro to switch to the appropriate section. 8893e4b17023SJohn Marino 8894e4b17023SJohn MarinoYou should define this symbol if your target supports DWARF 2 frame 8895e4b17023SJohn Marinounwind information and the default definition does not work. 8896e4b17023SJohn Marino@end defmac 8897e4b17023SJohn Marino 8898e4b17023SJohn Marino@defmac EH_FRAME_IN_DATA_SECTION 8899e4b17023SJohn MarinoIf defined, DWARF 2 frame unwind information will be placed in the 8900e4b17023SJohn Marinodata section even though the target supports named sections. This 8901e4b17023SJohn Marinomight be necessary, for instance, if the system linker does garbage 8902e4b17023SJohn Marinocollection and sections cannot be marked as not to be collected. 8903e4b17023SJohn Marino 8904e4b17023SJohn MarinoDo not define this macro unless @code{TARGET_ASM_NAMED_SECTION} is 8905e4b17023SJohn Marinoalso defined. 8906e4b17023SJohn Marino@end defmac 8907e4b17023SJohn Marino 8908e4b17023SJohn Marino@defmac EH_TABLES_CAN_BE_READ_ONLY 8909e4b17023SJohn MarinoDefine this macro to 1 if your target is such that no frame unwind 8910e4b17023SJohn Marinoinformation encoding used with non-PIC code will ever require a 8911e4b17023SJohn Marinoruntime relocation, but the linker may not support merging read-only 8912e4b17023SJohn Marinoand read-write sections into a single read-write section. 8913e4b17023SJohn Marino@end defmac 8914e4b17023SJohn Marino 8915e4b17023SJohn Marino@defmac MASK_RETURN_ADDR 8916e4b17023SJohn MarinoAn rtx used to mask the return address found via @code{RETURN_ADDR_RTX}, so 8917e4b17023SJohn Marinothat it does not contain any extraneous set bits in it. 8918e4b17023SJohn Marino@end defmac 8919e4b17023SJohn Marino 8920e4b17023SJohn Marino@defmac DWARF2_UNWIND_INFO 8921e4b17023SJohn MarinoDefine this macro to 0 if your target supports DWARF 2 frame unwind 8922e4b17023SJohn Marinoinformation, but it does not yet work with exception handling. 8923e4b17023SJohn MarinoOtherwise, if your target supports this information (if it defines 8924e4b17023SJohn Marino@code{INCOMING_RETURN_ADDR_RTX} and either @code{UNALIGNED_INT_ASM_OP} 8925e4b17023SJohn Marinoor @code{OBJECT_FORMAT_ELF}), GCC will provide a default definition of 1. 8926e4b17023SJohn Marino@end defmac 8927e4b17023SJohn Marino 8928e4b17023SJohn Marino@deftypefn {Common Target Hook} {enum unwind_info_type} TARGET_EXCEPT_UNWIND_INFO (struct gcc_options *@var{opts}) 8929e4b17023SJohn MarinoThis hook defines the mechanism that will be used for exception handling 8930e4b17023SJohn Marinoby the target. If the target has ABI specified unwind tables, the hook 8931e4b17023SJohn Marinoshould return @code{UI_TARGET}. If the target is to use the 8932e4b17023SJohn Marino@code{setjmp}/@code{longjmp}-based exception handling scheme, the hook 8933e4b17023SJohn Marinoshould return @code{UI_SJLJ}. If the target supports DWARF 2 frame unwind 8934e4b17023SJohn Marinoinformation, the hook should return @code{UI_DWARF2}. 8935e4b17023SJohn Marino 8936e4b17023SJohn MarinoA target may, if exceptions are disabled, choose to return @code{UI_NONE}. 8937e4b17023SJohn MarinoThis may end up simplifying other parts of target-specific code. The 8938e4b17023SJohn Marinodefault implementation of this hook never returns @code{UI_NONE}. 8939e4b17023SJohn Marino 8940e4b17023SJohn MarinoNote that the value returned by this hook should be constant. It should 8941e4b17023SJohn Marinonot depend on anything except the command-line switches described by 8942e4b17023SJohn Marino@var{opts}. In particular, the 8943e4b17023SJohn Marinosetting @code{UI_SJLJ} must be fixed at compiler start-up as C pre-processor 8944e4b17023SJohn Marinomacros and builtin functions related to exception handling are set up 8945e4b17023SJohn Marinodepending on this setting. 8946e4b17023SJohn Marino 8947e4b17023SJohn MarinoThe default implementation of the hook first honors the 8948e4b17023SJohn Marino@option{--enable-sjlj-exceptions} configure option, then 8949e4b17023SJohn Marino@code{DWARF2_UNWIND_INFO}, and finally defaults to @code{UI_SJLJ}. If 8950e4b17023SJohn Marino@code{DWARF2_UNWIND_INFO} depends on command-line options, the target 8951e4b17023SJohn Marinomust define this hook so that @var{opts} is used correctly. 8952e4b17023SJohn Marino@end deftypefn 8953e4b17023SJohn Marino 8954e4b17023SJohn Marino@deftypevr {Common Target Hook} bool TARGET_UNWIND_TABLES_DEFAULT 8955e4b17023SJohn MarinoThis variable should be set to @code{true} if the target ABI requires unwinding 8956e4b17023SJohn Marinotables even when exceptions are not used. It must not be modified by 8957e4b17023SJohn Marinocommand-line option processing. 8958e4b17023SJohn Marino@end deftypevr 8959e4b17023SJohn Marino 8960e4b17023SJohn Marino@defmac DONT_USE_BUILTIN_SETJMP 8961e4b17023SJohn MarinoDefine this macro to 1 if the @code{setjmp}/@code{longjmp}-based scheme 8962e4b17023SJohn Marinoshould use the @code{setjmp}/@code{longjmp} functions from the C library 8963e4b17023SJohn Marinoinstead of the @code{__builtin_setjmp}/@code{__builtin_longjmp} machinery. 8964e4b17023SJohn Marino@end defmac 8965e4b17023SJohn Marino 8966e4b17023SJohn Marino@defmac DWARF_CIE_DATA_ALIGNMENT 8967e4b17023SJohn MarinoThis macro need only be defined if the target might save registers in the 8968e4b17023SJohn Marinofunction prologue at an offset to the stack pointer that is not aligned to 8969e4b17023SJohn Marino@code{UNITS_PER_WORD}. The definition should be the negative minimum 8970e4b17023SJohn Marinoalignment if @code{STACK_GROWS_DOWNWARD} is defined, and the positive 8971e4b17023SJohn Marinominimum alignment otherwise. @xref{SDB and DWARF}. Only applicable if 8972e4b17023SJohn Marinothe target supports DWARF 2 frame unwind information. 8973e4b17023SJohn Marino@end defmac 8974e4b17023SJohn Marino 8975e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_TERMINATE_DW2_EH_FRAME_INFO 8976e4b17023SJohn MarinoContains the value true if the target should add a zero word onto the 8977e4b17023SJohn Marinoend of a Dwarf-2 frame info section when used for exception handling. 8978e4b17023SJohn MarinoDefault value is false if @code{EH_FRAME_SECTION_NAME} is defined, and 8979e4b17023SJohn Marinotrue otherwise. 8980e4b17023SJohn Marino@end deftypevr 8981e4b17023SJohn Marino 8982e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_DWARF_REGISTER_SPAN (rtx @var{reg}) 8983e4b17023SJohn MarinoGiven a register, this hook should return a parallel of registers to 8984e4b17023SJohn Marinorepresent where to find the register pieces. Define this hook if the 8985e4b17023SJohn Marinoregister and its mode are represented in Dwarf in non-contiguous 8986e4b17023SJohn Marinolocations, or if the register should be represented in more than one 8987e4b17023SJohn Marinoregister in Dwarf. Otherwise, this hook should return @code{NULL_RTX}. 8988e4b17023SJohn MarinoIf not defined, the default is to return @code{NULL_RTX}. 8989e4b17023SJohn Marino@end deftypefn 8990e4b17023SJohn Marino 8991e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_INIT_DWARF_REG_SIZES_EXTRA (tree @var{address}) 8992e4b17023SJohn MarinoIf some registers are represented in Dwarf-2 unwind information in 8993e4b17023SJohn Marinomultiple pieces, define this hook to fill in information about the 8994e4b17023SJohn Marinosizes of those pieces in the table used by the unwinder at runtime. 8995e4b17023SJohn MarinoIt will be called by @code{expand_builtin_init_dwarf_reg_sizes} after 8996e4b17023SJohn Marinofilling in a single size corresponding to each hard register; 8997e4b17023SJohn Marino@var{address} is the address of the table. 8998e4b17023SJohn Marino@end deftypefn 8999e4b17023SJohn Marino 9000e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ASM_TTYPE (rtx @var{sym}) 9001e4b17023SJohn MarinoThis hook is used to output a reference from a frame unwinding table to 9002e4b17023SJohn Marinothe type_info object identified by @var{sym}. It should return @code{true} 9003e4b17023SJohn Marinoif the reference was output. Returning @code{false} will cause the 9004e4b17023SJohn Marinoreference to be output using the normal Dwarf2 routines. 9005e4b17023SJohn Marino@end deftypefn 9006e4b17023SJohn Marino 9007e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_ARM_EABI_UNWINDER 9008e4b17023SJohn MarinoThis flag should be set to @code{true} on targets that use an ARM EABI 9009e4b17023SJohn Marinobased unwinding library, and @code{false} on other targets. This effects 9010e4b17023SJohn Marinothe format of unwinding tables, and how the unwinder in entered after 9011e4b17023SJohn Marinorunning a cleanup. The default is @code{false}. 9012e4b17023SJohn Marino@end deftypevr 9013e4b17023SJohn Marino 9014e4b17023SJohn Marino@node Alignment Output 9015e4b17023SJohn Marino@subsection Assembler Commands for Alignment 9016e4b17023SJohn Marino 9017e4b17023SJohn Marino@c prevent bad page break with this line 9018e4b17023SJohn MarinoThis describes commands for alignment. 9019e4b17023SJohn Marino 9020e4b17023SJohn Marino@defmac JUMP_ALIGN (@var{label}) 9021e4b17023SJohn MarinoThe alignment (log base 2) to put in front of @var{label}, which is 9022e4b17023SJohn Marinoa common destination of jumps and has no fallthru incoming edge. 9023e4b17023SJohn Marino 9024e4b17023SJohn MarinoThis macro need not be defined if you don't want any special alignment 9025e4b17023SJohn Marinoto be done at such a time. Most machine descriptions do not currently 9026e4b17023SJohn Marinodefine the macro. 9027e4b17023SJohn Marino 9028e4b17023SJohn MarinoUnless it's necessary to inspect the @var{label} parameter, it is better 9029e4b17023SJohn Marinoto set the variable @var{align_jumps} in the target's 9030e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE}. Otherwise, you should try to honor the user's 9031e4b17023SJohn Marinoselection in @var{align_jumps} in a @code{JUMP_ALIGN} implementation. 9032e4b17023SJohn Marino@end defmac 9033e4b17023SJohn Marino 9034e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ASM_JUMP_ALIGN_MAX_SKIP (rtx @var{label}) 9035e4b17023SJohn MarinoThe maximum number of bytes to skip before @var{label} when applying 9036e4b17023SJohn Marino@code{JUMP_ALIGN}. This works only if 9037e4b17023SJohn Marino@code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined. 9038e4b17023SJohn Marino@end deftypefn 9039e4b17023SJohn Marino 9040e4b17023SJohn Marino@defmac LABEL_ALIGN_AFTER_BARRIER (@var{label}) 9041e4b17023SJohn MarinoThe alignment (log base 2) to put in front of @var{label}, which follows 9042e4b17023SJohn Marinoa @code{BARRIER}. 9043e4b17023SJohn Marino 9044e4b17023SJohn MarinoThis macro need not be defined if you don't want any special alignment 9045e4b17023SJohn Marinoto be done at such a time. Most machine descriptions do not currently 9046e4b17023SJohn Marinodefine the macro. 9047e4b17023SJohn Marino@end defmac 9048e4b17023SJohn Marino 9049e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP (rtx @var{label}) 9050e4b17023SJohn MarinoThe maximum number of bytes to skip before @var{label} when applying 9051e4b17023SJohn Marino@code{LABEL_ALIGN_AFTER_BARRIER}. This works only if 9052e4b17023SJohn Marino@code{ASM_OUTPUT_MAX_SKIP_ALIGN} is defined. 9053e4b17023SJohn Marino@end deftypefn 9054e4b17023SJohn Marino 9055e4b17023SJohn Marino@defmac LOOP_ALIGN (@var{label}) 9056e4b17023SJohn MarinoThe alignment (log base 2) to put in front of @var{label}, which follows 9057e4b17023SJohn Marinoa @code{NOTE_INSN_LOOP_BEG} note. 9058e4b17023SJohn Marino 9059e4b17023SJohn MarinoThis macro need not be defined if you don't want any special alignment 9060e4b17023SJohn Marinoto be done at such a time. Most machine descriptions do not currently 9061e4b17023SJohn Marinodefine the macro. 9062e4b17023SJohn Marino 9063e4b17023SJohn MarinoUnless it's necessary to inspect the @var{label} parameter, it is better 9064e4b17023SJohn Marinoto set the variable @code{align_loops} in the target's 9065e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE}. Otherwise, you should try to honor the user's 9066e4b17023SJohn Marinoselection in @code{align_loops} in a @code{LOOP_ALIGN} implementation. 9067e4b17023SJohn Marino@end defmac 9068e4b17023SJohn Marino 9069e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ASM_LOOP_ALIGN_MAX_SKIP (rtx @var{label}) 9070e4b17023SJohn MarinoThe maximum number of bytes to skip when applying @code{LOOP_ALIGN} to 9071e4b17023SJohn Marino@var{label}. This works only if @code{ASM_OUTPUT_MAX_SKIP_ALIGN} is 9072e4b17023SJohn Marinodefined. 9073e4b17023SJohn Marino@end deftypefn 9074e4b17023SJohn Marino 9075e4b17023SJohn Marino@defmac LABEL_ALIGN (@var{label}) 9076e4b17023SJohn MarinoThe alignment (log base 2) to put in front of @var{label}. 9077e4b17023SJohn MarinoIf @code{LABEL_ALIGN_AFTER_BARRIER} / @code{LOOP_ALIGN} specify a different alignment, 9078e4b17023SJohn Marinothe maximum of the specified values is used. 9079e4b17023SJohn Marino 9080e4b17023SJohn MarinoUnless it's necessary to inspect the @var{label} parameter, it is better 9081e4b17023SJohn Marinoto set the variable @code{align_labels} in the target's 9082e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE}. Otherwise, you should try to honor the user's 9083e4b17023SJohn Marinoselection in @code{align_labels} in a @code{LABEL_ALIGN} implementation. 9084e4b17023SJohn Marino@end defmac 9085e4b17023SJohn Marino 9086e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_ASM_LABEL_ALIGN_MAX_SKIP (rtx @var{label}) 9087e4b17023SJohn MarinoThe maximum number of bytes to skip when applying @code{LABEL_ALIGN} 9088e4b17023SJohn Marinoto @var{label}. This works only if @code{ASM_OUTPUT_MAX_SKIP_ALIGN} 9089e4b17023SJohn Marinois defined. 9090e4b17023SJohn Marino@end deftypefn 9091e4b17023SJohn Marino 9092e4b17023SJohn Marino@defmac ASM_OUTPUT_SKIP (@var{stream}, @var{nbytes}) 9093e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler 9094e4b17023SJohn Marinoinstruction to advance the location counter by @var{nbytes} bytes. 9095e4b17023SJohn MarinoThose bytes should be zero when loaded. @var{nbytes} will be a C 9096e4b17023SJohn Marinoexpression of type @code{unsigned HOST_WIDE_INT}. 9097e4b17023SJohn Marino@end defmac 9098e4b17023SJohn Marino 9099e4b17023SJohn Marino@defmac ASM_NO_SKIP_IN_TEXT 9100e4b17023SJohn MarinoDefine this macro if @code{ASM_OUTPUT_SKIP} should not be used in the 9101e4b17023SJohn Marinotext section because it fails to put zeros in the bytes that are skipped. 9102e4b17023SJohn MarinoThis is true on many Unix systems, where the pseudo--op to skip bytes 9103e4b17023SJohn Marinoproduces no-op instructions rather than zeros when used in the text 9104e4b17023SJohn Marinosection. 9105e4b17023SJohn Marino@end defmac 9106e4b17023SJohn Marino 9107e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGN (@var{stream}, @var{power}) 9108e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler 9109e4b17023SJohn Marinocommand to advance the location counter to a multiple of 2 to the 9110e4b17023SJohn Marino@var{power} bytes. @var{power} will be a C expression of type @code{int}. 9111e4b17023SJohn Marino@end defmac 9112e4b17023SJohn Marino 9113e4b17023SJohn Marino@defmac ASM_OUTPUT_ALIGN_WITH_NOP (@var{stream}, @var{power}) 9114e4b17023SJohn MarinoLike @code{ASM_OUTPUT_ALIGN}, except that the ``nop'' instruction is used 9115e4b17023SJohn Marinofor padding, if necessary. 9116e4b17023SJohn Marino@end defmac 9117e4b17023SJohn Marino 9118e4b17023SJohn Marino@defmac ASM_OUTPUT_MAX_SKIP_ALIGN (@var{stream}, @var{power}, @var{max_skip}) 9119e4b17023SJohn MarinoA C statement to output to the stdio stream @var{stream} an assembler 9120e4b17023SJohn Marinocommand to advance the location counter to a multiple of 2 to the 9121e4b17023SJohn Marino@var{power} bytes, but only if @var{max_skip} or fewer bytes are needed to 9122e4b17023SJohn Marinosatisfy the alignment request. @var{power} and @var{max_skip} will be 9123e4b17023SJohn Marinoa C expression of type @code{int}. 9124e4b17023SJohn Marino@end defmac 9125e4b17023SJohn Marino 9126e4b17023SJohn Marino@need 3000 9127e4b17023SJohn Marino@node Debugging Info 9128e4b17023SJohn Marino@section Controlling Debugging Information Format 9129e4b17023SJohn Marino 9130e4b17023SJohn Marino@c prevent bad page break with this line 9131e4b17023SJohn MarinoThis describes how to specify debugging information. 9132e4b17023SJohn Marino 9133e4b17023SJohn Marino@menu 9134e4b17023SJohn Marino* All Debuggers:: Macros that affect all debugging formats uniformly. 9135e4b17023SJohn Marino* DBX Options:: Macros enabling specific options in DBX format. 9136e4b17023SJohn Marino* DBX Hooks:: Hook macros for varying DBX format. 9137e4b17023SJohn Marino* File Names and DBX:: Macros controlling output of file names in DBX format. 9138e4b17023SJohn Marino* SDB and DWARF:: Macros for SDB (COFF) and DWARF formats. 9139e4b17023SJohn Marino* VMS Debug:: Macros for VMS debug format. 9140e4b17023SJohn Marino@end menu 9141e4b17023SJohn Marino 9142e4b17023SJohn Marino@node All Debuggers 9143e4b17023SJohn Marino@subsection Macros Affecting All Debugging Formats 9144e4b17023SJohn Marino 9145e4b17023SJohn Marino@c prevent bad page break with this line 9146e4b17023SJohn MarinoThese macros affect all debugging formats. 9147e4b17023SJohn Marino 9148e4b17023SJohn Marino@defmac DBX_REGISTER_NUMBER (@var{regno}) 9149e4b17023SJohn MarinoA C expression that returns the DBX register number for the compiler 9150e4b17023SJohn Marinoregister number @var{regno}. In the default macro provided, the value 9151e4b17023SJohn Marinoof this expression will be @var{regno} itself. But sometimes there are 9152e4b17023SJohn Marinosome registers that the compiler knows about and DBX does not, or vice 9153e4b17023SJohn Marinoversa. In such cases, some register may need to have one number in the 9154e4b17023SJohn Marinocompiler and another for DBX@. 9155e4b17023SJohn Marino 9156e4b17023SJohn MarinoIf two registers have consecutive numbers inside GCC, and they can be 9157e4b17023SJohn Marinoused as a pair to hold a multiword value, then they @emph{must} have 9158e4b17023SJohn Marinoconsecutive numbers after renumbering with @code{DBX_REGISTER_NUMBER}. 9159e4b17023SJohn MarinoOtherwise, debuggers will be unable to access such a pair, because they 9160e4b17023SJohn Marinoexpect register pairs to be consecutive in their own numbering scheme. 9161e4b17023SJohn Marino 9162e4b17023SJohn MarinoIf you find yourself defining @code{DBX_REGISTER_NUMBER} in way that 9163e4b17023SJohn Marinodoes not preserve register pairs, then what you must do instead is 9164e4b17023SJohn Marinoredefine the actual register numbering scheme. 9165e4b17023SJohn Marino@end defmac 9166e4b17023SJohn Marino 9167e4b17023SJohn Marino@defmac DEBUGGER_AUTO_OFFSET (@var{x}) 9168e4b17023SJohn MarinoA C expression that returns the integer offset value for an automatic 9169e4b17023SJohn Marinovariable having address @var{x} (an RTL expression). The default 9170e4b17023SJohn Marinocomputation assumes that @var{x} is based on the frame-pointer and 9171e4b17023SJohn Marinogives the offset from the frame-pointer. This is required for targets 9172e4b17023SJohn Marinothat produce debugging output for DBX or COFF-style debugging output 9173e4b17023SJohn Marinofor SDB and allow the frame-pointer to be eliminated when the 9174e4b17023SJohn Marino@option{-g} options is used. 9175e4b17023SJohn Marino@end defmac 9176e4b17023SJohn Marino 9177e4b17023SJohn Marino@defmac DEBUGGER_ARG_OFFSET (@var{offset}, @var{x}) 9178e4b17023SJohn MarinoA C expression that returns the integer offset value for an argument 9179e4b17023SJohn Marinohaving address @var{x} (an RTL expression). The nominal offset is 9180e4b17023SJohn Marino@var{offset}. 9181e4b17023SJohn Marino@end defmac 9182e4b17023SJohn Marino 9183e4b17023SJohn Marino@defmac PREFERRED_DEBUGGING_TYPE 9184e4b17023SJohn MarinoA C expression that returns the type of debugging output GCC should 9185e4b17023SJohn Marinoproduce when the user specifies just @option{-g}. Define 9186e4b17023SJohn Marinothis if you have arranged for GCC to support more than one format of 9187e4b17023SJohn Marinodebugging output. Currently, the allowable values are @code{DBX_DEBUG}, 9188e4b17023SJohn Marino@code{SDB_DEBUG}, @code{DWARF_DEBUG}, @code{DWARF2_DEBUG}, 9189e4b17023SJohn Marino@code{XCOFF_DEBUG}, @code{VMS_DEBUG}, and @code{VMS_AND_DWARF2_DEBUG}. 9190e4b17023SJohn Marino 9191e4b17023SJohn MarinoWhen the user specifies @option{-ggdb}, GCC normally also uses the 9192e4b17023SJohn Marinovalue of this macro to select the debugging output format, but with two 9193e4b17023SJohn Marinoexceptions. If @code{DWARF2_DEBUGGING_INFO} is defined, GCC uses the 9194e4b17023SJohn Marinovalue @code{DWARF2_DEBUG}. Otherwise, if @code{DBX_DEBUGGING_INFO} is 9195e4b17023SJohn Marinodefined, GCC uses @code{DBX_DEBUG}. 9196e4b17023SJohn Marino 9197e4b17023SJohn MarinoThe value of this macro only affects the default debugging output; the 9198e4b17023SJohn Marinouser can always get a specific type of output by using @option{-gstabs}, 9199e4b17023SJohn Marino@option{-gcoff}, @option{-gdwarf-2}, @option{-gxcoff}, or @option{-gvms}. 9200e4b17023SJohn Marino@end defmac 9201e4b17023SJohn Marino 9202e4b17023SJohn Marino@node DBX Options 9203e4b17023SJohn Marino@subsection Specific Options for DBX Output 9204e4b17023SJohn Marino 9205e4b17023SJohn Marino@c prevent bad page break with this line 9206e4b17023SJohn MarinoThese are specific options for DBX output. 9207e4b17023SJohn Marino 9208e4b17023SJohn Marino@defmac DBX_DEBUGGING_INFO 9209e4b17023SJohn MarinoDefine this macro if GCC should produce debugging output for DBX 9210e4b17023SJohn Marinoin response to the @option{-g} option. 9211e4b17023SJohn Marino@end defmac 9212e4b17023SJohn Marino 9213e4b17023SJohn Marino@defmac XCOFF_DEBUGGING_INFO 9214e4b17023SJohn MarinoDefine this macro if GCC should produce XCOFF format debugging output 9215e4b17023SJohn Marinoin response to the @option{-g} option. This is a variant of DBX format. 9216e4b17023SJohn Marino@end defmac 9217e4b17023SJohn Marino 9218e4b17023SJohn Marino@defmac DEFAULT_GDB_EXTENSIONS 9219e4b17023SJohn MarinoDefine this macro to control whether GCC should by default generate 9220e4b17023SJohn MarinoGDB's extended version of DBX debugging information (assuming DBX-format 9221e4b17023SJohn Marinodebugging information is enabled at all). If you don't define the 9222e4b17023SJohn Marinomacro, the default is 1: always generate the extended information 9223e4b17023SJohn Marinoif there is any occasion to. 9224e4b17023SJohn Marino@end defmac 9225e4b17023SJohn Marino 9226e4b17023SJohn Marino@defmac DEBUG_SYMS_TEXT 9227e4b17023SJohn MarinoDefine this macro if all @code{.stabs} commands should be output while 9228e4b17023SJohn Marinoin the text section. 9229e4b17023SJohn Marino@end defmac 9230e4b17023SJohn Marino 9231e4b17023SJohn Marino@defmac ASM_STABS_OP 9232e4b17023SJohn MarinoA C string constant, including spacing, naming the assembler pseudo op to 9233e4b17023SJohn Marinouse instead of @code{"\t.stabs\t"} to define an ordinary debugging symbol. 9234e4b17023SJohn MarinoIf you don't define this macro, @code{"\t.stabs\t"} is used. This macro 9235e4b17023SJohn Marinoapplies only to DBX debugging information format. 9236e4b17023SJohn Marino@end defmac 9237e4b17023SJohn Marino 9238e4b17023SJohn Marino@defmac ASM_STABD_OP 9239e4b17023SJohn MarinoA C string constant, including spacing, naming the assembler pseudo op to 9240e4b17023SJohn Marinouse instead of @code{"\t.stabd\t"} to define a debugging symbol whose 9241e4b17023SJohn Marinovalue is the current location. If you don't define this macro, 9242e4b17023SJohn Marino@code{"\t.stabd\t"} is used. This macro applies only to DBX debugging 9243e4b17023SJohn Marinoinformation format. 9244e4b17023SJohn Marino@end defmac 9245e4b17023SJohn Marino 9246e4b17023SJohn Marino@defmac ASM_STABN_OP 9247e4b17023SJohn MarinoA C string constant, including spacing, naming the assembler pseudo op to 9248e4b17023SJohn Marinouse instead of @code{"\t.stabn\t"} to define a debugging symbol with no 9249e4b17023SJohn Marinoname. If you don't define this macro, @code{"\t.stabn\t"} is used. This 9250e4b17023SJohn Marinomacro applies only to DBX debugging information format. 9251e4b17023SJohn Marino@end defmac 9252e4b17023SJohn Marino 9253e4b17023SJohn Marino@defmac DBX_NO_XREFS 9254e4b17023SJohn MarinoDefine this macro if DBX on your system does not support the construct 9255e4b17023SJohn Marino@samp{xs@var{tagname}}. On some systems, this construct is used to 9256e4b17023SJohn Marinodescribe a forward reference to a structure named @var{tagname}. 9257e4b17023SJohn MarinoOn other systems, this construct is not supported at all. 9258e4b17023SJohn Marino@end defmac 9259e4b17023SJohn Marino 9260e4b17023SJohn Marino@defmac DBX_CONTIN_LENGTH 9261e4b17023SJohn MarinoA symbol name in DBX-format debugging information is normally 9262e4b17023SJohn Marinocontinued (split into two separate @code{.stabs} directives) when it 9263e4b17023SJohn Marinoexceeds a certain length (by default, 80 characters). On some 9264e4b17023SJohn Marinooperating systems, DBX requires this splitting; on others, splitting 9265e4b17023SJohn Marinomust not be done. You can inhibit splitting by defining this macro 9266e4b17023SJohn Marinowith the value zero. You can override the default splitting-length by 9267e4b17023SJohn Marinodefining this macro as an expression for the length you desire. 9268e4b17023SJohn Marino@end defmac 9269e4b17023SJohn Marino 9270e4b17023SJohn Marino@defmac DBX_CONTIN_CHAR 9271e4b17023SJohn MarinoNormally continuation is indicated by adding a @samp{\} character to 9272e4b17023SJohn Marinothe end of a @code{.stabs} string when a continuation follows. To use 9273e4b17023SJohn Marinoa different character instead, define this macro as a character 9274e4b17023SJohn Marinoconstant for the character you want to use. Do not define this macro 9275e4b17023SJohn Marinoif backslash is correct for your system. 9276e4b17023SJohn Marino@end defmac 9277e4b17023SJohn Marino 9278e4b17023SJohn Marino@defmac DBX_STATIC_STAB_DATA_SECTION 9279e4b17023SJohn MarinoDefine this macro if it is necessary to go to the data section before 9280e4b17023SJohn Marinooutputting the @samp{.stabs} pseudo-op for a non-global static 9281e4b17023SJohn Marinovariable. 9282e4b17023SJohn Marino@end defmac 9283e4b17023SJohn Marino 9284e4b17023SJohn Marino@defmac DBX_TYPE_DECL_STABS_CODE 9285e4b17023SJohn MarinoThe value to use in the ``code'' field of the @code{.stabs} directive 9286e4b17023SJohn Marinofor a typedef. The default is @code{N_LSYM}. 9287e4b17023SJohn Marino@end defmac 9288e4b17023SJohn Marino 9289e4b17023SJohn Marino@defmac DBX_STATIC_CONST_VAR_CODE 9290e4b17023SJohn MarinoThe value to use in the ``code'' field of the @code{.stabs} directive 9291e4b17023SJohn Marinofor a static variable located in the text section. DBX format does not 9292e4b17023SJohn Marinoprovide any ``right'' way to do this. The default is @code{N_FUN}. 9293e4b17023SJohn Marino@end defmac 9294e4b17023SJohn Marino 9295e4b17023SJohn Marino@defmac DBX_REGPARM_STABS_CODE 9296e4b17023SJohn MarinoThe value to use in the ``code'' field of the @code{.stabs} directive 9297e4b17023SJohn Marinofor a parameter passed in registers. DBX format does not provide any 9298e4b17023SJohn Marino``right'' way to do this. The default is @code{N_RSYM}. 9299e4b17023SJohn Marino@end defmac 9300e4b17023SJohn Marino 9301e4b17023SJohn Marino@defmac DBX_REGPARM_STABS_LETTER 9302e4b17023SJohn MarinoThe letter to use in DBX symbol data to identify a symbol as a parameter 9303e4b17023SJohn Marinopassed in registers. DBX format does not customarily provide any way to 9304e4b17023SJohn Marinodo this. The default is @code{'P'}. 9305e4b17023SJohn Marino@end defmac 9306e4b17023SJohn Marino 9307e4b17023SJohn Marino@defmac DBX_FUNCTION_FIRST 9308e4b17023SJohn MarinoDefine this macro if the DBX information for a function and its 9309e4b17023SJohn Marinoarguments should precede the assembler code for the function. Normally, 9310e4b17023SJohn Marinoin DBX format, the debugging information entirely follows the assembler 9311e4b17023SJohn Marinocode. 9312e4b17023SJohn Marino@end defmac 9313e4b17023SJohn Marino 9314e4b17023SJohn Marino@defmac DBX_BLOCKS_FUNCTION_RELATIVE 9315e4b17023SJohn MarinoDefine this macro, with value 1, if the value of a symbol describing 9316e4b17023SJohn Marinothe scope of a block (@code{N_LBRAC} or @code{N_RBRAC}) should be 9317e4b17023SJohn Marinorelative to the start of the enclosing function. Normally, GCC uses 9318e4b17023SJohn Marinoan absolute address. 9319e4b17023SJohn Marino@end defmac 9320e4b17023SJohn Marino 9321e4b17023SJohn Marino@defmac DBX_LINES_FUNCTION_RELATIVE 9322e4b17023SJohn MarinoDefine this macro, with value 1, if the value of a symbol indicating 9323e4b17023SJohn Marinothe current line number (@code{N_SLINE}) should be relative to the 9324e4b17023SJohn Marinostart of the enclosing function. Normally, GCC uses an absolute address. 9325e4b17023SJohn Marino@end defmac 9326e4b17023SJohn Marino 9327e4b17023SJohn Marino@defmac DBX_USE_BINCL 9328e4b17023SJohn MarinoDefine this macro if GCC should generate @code{N_BINCL} and 9329e4b17023SJohn Marino@code{N_EINCL} stabs for included header files, as on Sun systems. This 9330e4b17023SJohn Marinomacro also directs GCC to output a type number as a pair of a file 9331e4b17023SJohn Marinonumber and a type number within the file. Normally, GCC does not 9332e4b17023SJohn Marinogenerate @code{N_BINCL} or @code{N_EINCL} stabs, and it outputs a single 9333e4b17023SJohn Marinonumber for a type number. 9334e4b17023SJohn Marino@end defmac 9335e4b17023SJohn Marino 9336e4b17023SJohn Marino@node DBX Hooks 9337e4b17023SJohn Marino@subsection Open-Ended Hooks for DBX Format 9338e4b17023SJohn Marino 9339e4b17023SJohn Marino@c prevent bad page break with this line 9340e4b17023SJohn MarinoThese are hooks for DBX format. 9341e4b17023SJohn Marino 9342e4b17023SJohn Marino@defmac DBX_OUTPUT_LBRAC (@var{stream}, @var{name}) 9343e4b17023SJohn MarinoDefine this macro to say how to output to @var{stream} the debugging 9344e4b17023SJohn Marinoinformation for the start of a scope level for variable names. The 9345e4b17023SJohn Marinoargument @var{name} is the name of an assembler symbol (for use with 9346e4b17023SJohn Marino@code{assemble_name}) whose value is the address where the scope begins. 9347e4b17023SJohn Marino@end defmac 9348e4b17023SJohn Marino 9349e4b17023SJohn Marino@defmac DBX_OUTPUT_RBRAC (@var{stream}, @var{name}) 9350e4b17023SJohn MarinoLike @code{DBX_OUTPUT_LBRAC}, but for the end of a scope level. 9351e4b17023SJohn Marino@end defmac 9352e4b17023SJohn Marino 9353e4b17023SJohn Marino@defmac DBX_OUTPUT_NFUN (@var{stream}, @var{lscope_label}, @var{decl}) 9354e4b17023SJohn MarinoDefine this macro if the target machine requires special handling to 9355e4b17023SJohn Marinooutput an @code{N_FUN} entry for the function @var{decl}. 9356e4b17023SJohn Marino@end defmac 9357e4b17023SJohn Marino 9358e4b17023SJohn Marino@defmac DBX_OUTPUT_SOURCE_LINE (@var{stream}, @var{line}, @var{counter}) 9359e4b17023SJohn MarinoA C statement to output DBX debugging information before code for line 9360e4b17023SJohn Marinonumber @var{line} of the current source file to the stdio stream 9361e4b17023SJohn Marino@var{stream}. @var{counter} is the number of time the macro was 9362e4b17023SJohn Marinoinvoked, including the current invocation; it is intended to generate 9363e4b17023SJohn Marinounique labels in the assembly output. 9364e4b17023SJohn Marino 9365e4b17023SJohn MarinoThis macro should not be defined if the default output is correct, or 9366e4b17023SJohn Marinoif it can be made correct by defining @code{DBX_LINES_FUNCTION_RELATIVE}. 9367e4b17023SJohn Marino@end defmac 9368e4b17023SJohn Marino 9369e4b17023SJohn Marino@defmac NO_DBX_FUNCTION_END 9370e4b17023SJohn MarinoSome stabs encapsulation formats (in particular ECOFF), cannot handle the 9371e4b17023SJohn Marino@code{.stabs "",N_FUN,,0,0,Lscope-function-1} gdb dbx extension construct. 9372e4b17023SJohn MarinoOn those machines, define this macro to turn this feature off without 9373e4b17023SJohn Marinodisturbing the rest of the gdb extensions. 9374e4b17023SJohn Marino@end defmac 9375e4b17023SJohn Marino 9376e4b17023SJohn Marino@defmac NO_DBX_BNSYM_ENSYM 9377e4b17023SJohn MarinoSome assemblers cannot handle the @code{.stabd BNSYM/ENSYM,0,0} gdb dbx 9378e4b17023SJohn Marinoextension construct. On those machines, define this macro to turn this 9379e4b17023SJohn Marinofeature off without disturbing the rest of the gdb extensions. 9380e4b17023SJohn Marino@end defmac 9381e4b17023SJohn Marino 9382e4b17023SJohn Marino@node File Names and DBX 9383e4b17023SJohn Marino@subsection File Names in DBX Format 9384e4b17023SJohn Marino 9385e4b17023SJohn Marino@c prevent bad page break with this line 9386e4b17023SJohn MarinoThis describes file names in DBX format. 9387e4b17023SJohn Marino 9388e4b17023SJohn Marino@defmac DBX_OUTPUT_MAIN_SOURCE_FILENAME (@var{stream}, @var{name}) 9389e4b17023SJohn MarinoA C statement to output DBX debugging information to the stdio stream 9390e4b17023SJohn Marino@var{stream}, which indicates that file @var{name} is the main source 9391e4b17023SJohn Marinofile---the file specified as the input file for compilation. 9392e4b17023SJohn MarinoThis macro is called only once, at the beginning of compilation. 9393e4b17023SJohn Marino 9394e4b17023SJohn MarinoThis macro need not be defined if the standard form of output 9395e4b17023SJohn Marinofor DBX debugging information is appropriate. 9396e4b17023SJohn Marino 9397e4b17023SJohn MarinoIt may be necessary to refer to a label equal to the beginning of the 9398e4b17023SJohn Marinotext section. You can use @samp{assemble_name (stream, ltext_label_name)} 9399e4b17023SJohn Marinoto do so. If you do this, you must also set the variable 9400e4b17023SJohn Marino@var{used_ltext_label_name} to @code{true}. 9401e4b17023SJohn Marino@end defmac 9402e4b17023SJohn Marino 9403e4b17023SJohn Marino@defmac NO_DBX_MAIN_SOURCE_DIRECTORY 9404e4b17023SJohn MarinoDefine this macro, with value 1, if GCC should not emit an indication 9405e4b17023SJohn Marinoof the current directory for compilation and current source language at 9406e4b17023SJohn Marinothe beginning of the file. 9407e4b17023SJohn Marino@end defmac 9408e4b17023SJohn Marino 9409e4b17023SJohn Marino@defmac NO_DBX_GCC_MARKER 9410e4b17023SJohn MarinoDefine this macro, with value 1, if GCC should not emit an indication 9411e4b17023SJohn Marinothat this object file was compiled by GCC@. The default is to emit 9412e4b17023SJohn Marinoan @code{N_OPT} stab at the beginning of every source file, with 9413e4b17023SJohn Marino@samp{gcc2_compiled.} for the string and value 0. 9414e4b17023SJohn Marino@end defmac 9415e4b17023SJohn Marino 9416e4b17023SJohn Marino@defmac DBX_OUTPUT_MAIN_SOURCE_FILE_END (@var{stream}, @var{name}) 9417e4b17023SJohn MarinoA C statement to output DBX debugging information at the end of 9418e4b17023SJohn Marinocompilation of the main source file @var{name}. Output should be 9419e4b17023SJohn Marinowritten to the stdio stream @var{stream}. 9420e4b17023SJohn Marino 9421e4b17023SJohn MarinoIf you don't define this macro, nothing special is output at the end 9422e4b17023SJohn Marinoof compilation, which is correct for most machines. 9423e4b17023SJohn Marino@end defmac 9424e4b17023SJohn Marino 9425e4b17023SJohn Marino@defmac DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END 9426e4b17023SJohn MarinoDefine this macro @emph{instead of} defining 9427e4b17023SJohn Marino@code{DBX_OUTPUT_MAIN_SOURCE_FILE_END}, if what needs to be output at 9428e4b17023SJohn Marinothe end of compilation is an @code{N_SO} stab with an empty string, 9429e4b17023SJohn Marinowhose value is the highest absolute text address in the file. 9430e4b17023SJohn Marino@end defmac 9431e4b17023SJohn Marino 9432e4b17023SJohn Marino@need 2000 9433e4b17023SJohn Marino@node SDB and DWARF 9434e4b17023SJohn Marino@subsection Macros for SDB and DWARF Output 9435e4b17023SJohn Marino 9436e4b17023SJohn Marino@c prevent bad page break with this line 9437e4b17023SJohn MarinoHere are macros for SDB and DWARF output. 9438e4b17023SJohn Marino 9439e4b17023SJohn Marino@defmac SDB_DEBUGGING_INFO 9440e4b17023SJohn MarinoDefine this macro if GCC should produce COFF-style debugging output 9441e4b17023SJohn Marinofor SDB in response to the @option{-g} option. 9442e4b17023SJohn Marino@end defmac 9443e4b17023SJohn Marino 9444e4b17023SJohn Marino@defmac DWARF2_DEBUGGING_INFO 9445e4b17023SJohn MarinoDefine this macro if GCC should produce dwarf version 2 format 9446e4b17023SJohn Marinodebugging output in response to the @option{-g} option. 9447e4b17023SJohn Marino 9448e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_DWARF_CALLING_CONVENTION (const_tree @var{function}) 9449e4b17023SJohn MarinoDefine this to enable the dwarf attribute @code{DW_AT_calling_convention} to 9450e4b17023SJohn Marinobe emitted for each function. Instead of an integer return the enum 9451e4b17023SJohn Marinovalue for the @code{DW_CC_} tag. 9452e4b17023SJohn Marino@end deftypefn 9453e4b17023SJohn Marino 9454e4b17023SJohn MarinoTo support optional call frame debugging information, you must also 9455e4b17023SJohn Marinodefine @code{INCOMING_RETURN_ADDR_RTX} and either set 9456e4b17023SJohn Marino@code{RTX_FRAME_RELATED_P} on the prologue insns if you use RTL for the 9457e4b17023SJohn Marinoprologue, or call @code{dwarf2out_def_cfa} and @code{dwarf2out_reg_save} 9458e4b17023SJohn Marinoas appropriate from @code{TARGET_ASM_FUNCTION_PROLOGUE} if you don't. 9459e4b17023SJohn Marino@end defmac 9460e4b17023SJohn Marino 9461e4b17023SJohn Marino@defmac DWARF2_FRAME_INFO 9462e4b17023SJohn MarinoDefine this macro to a nonzero value if GCC should always output 9463e4b17023SJohn MarinoDwarf 2 frame information. If @code{TARGET_EXCEPT_UNWIND_INFO} 9464e4b17023SJohn Marino(@pxref{Exception Region Output}) returns @code{UI_DWARF2}, and 9465e4b17023SJohn Marinoexceptions are enabled, GCC will output this information not matter 9466e4b17023SJohn Marinohow you define @code{DWARF2_FRAME_INFO}. 9467e4b17023SJohn Marino@end defmac 9468e4b17023SJohn Marino 9469e4b17023SJohn Marino@deftypefn {Target Hook} {enum unwind_info_type} TARGET_DEBUG_UNWIND_INFO (void) 9470e4b17023SJohn MarinoThis hook defines the mechanism that will be used for describing frame 9471e4b17023SJohn Marinounwind information to the debugger. Normally the hook will return 9472e4b17023SJohn Marino@code{UI_DWARF2} if DWARF 2 debug information is enabled, and 9473e4b17023SJohn Marinoreturn @code{UI_NONE} otherwise. 9474e4b17023SJohn Marino 9475e4b17023SJohn MarinoA target may return @code{UI_DWARF2} even when DWARF 2 debug information 9476e4b17023SJohn Marinois disabled in order to always output DWARF 2 frame information. 9477e4b17023SJohn Marino 9478e4b17023SJohn MarinoA target may return @code{UI_TARGET} if it has ABI specified unwind tables. 9479e4b17023SJohn MarinoThis will suppress generation of the normal debug frame unwind information. 9480e4b17023SJohn Marino@end deftypefn 9481e4b17023SJohn Marino 9482e4b17023SJohn Marino@defmac DWARF2_ASM_LINE_DEBUG_INFO 9483e4b17023SJohn MarinoDefine this macro to be a nonzero value if the assembler can generate Dwarf 2 9484e4b17023SJohn Marinoline debug info sections. This will result in much more compact line number 9485e4b17023SJohn Marinotables, and hence is desirable if it works. 9486e4b17023SJohn Marino@end defmac 9487e4b17023SJohn Marino 9488e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_WANT_DEBUG_PUB_SECTIONS 9489e4b17023SJohn MarinoTrue if the @code{.debug_pubtypes} and @code{.debug_pubnames} sections should be emitted. These sections are not used on most platforms, and in particular GDB does not use them. 9490e4b17023SJohn Marino@end deftypevr 9491e4b17023SJohn Marino 9492*95d28233SJohn Marino@deftypevr {Target Hook} bool TARGET_FORCE_AT_COMP_DIR 9493*95d28233SJohn MarinoTrue if the @code{DW_AT_comp_dir} attribute should be emitted for each compilation unit. This attribute is required for the darwin linker to emit debug information. 9494*95d28233SJohn Marino@end deftypevr 9495*95d28233SJohn Marino 9496e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_DELAY_SCHED2 9497e4b17023SJohn MarinoTrue if sched2 is not to be run at its normal place. This usually means it will be run as part of machine-specific reorg. 9498e4b17023SJohn Marino@end deftypevr 9499e4b17023SJohn Marino 9500e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_DELAY_VARTRACK 9501e4b17023SJohn MarinoTrue if vartrack is not to be run at its normal place. This usually means it will be run as part of machine-specific reorg. 9502e4b17023SJohn Marino@end deftypevr 9503e4b17023SJohn Marino 9504e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2}) 9505e4b17023SJohn MarinoA C statement to issue assembly directives that create a difference 9506e4b17023SJohn Marino@var{lab1} minus @var{lab2}, using an integer of the given @var{size}. 9507e4b17023SJohn Marino@end defmac 9508e4b17023SJohn Marino 9509e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_VMS_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2}) 9510e4b17023SJohn MarinoA C statement to issue assembly directives that create a difference 9511e4b17023SJohn Marinobetween the two given labels in system defined units, e.g. instruction 9512e4b17023SJohn Marinoslots on IA64 VMS, using an integer of the given size. 9513e4b17023SJohn Marino@end defmac 9514e4b17023SJohn Marino 9515e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, @var{section}) 9516e4b17023SJohn MarinoA C statement to issue assembly directives that create a 9517e4b17023SJohn Marinosection-relative reference to the given @var{label}, using an integer of the 9518e4b17023SJohn Marinogiven @var{size}. The label is known to be defined in the given @var{section}. 9519e4b17023SJohn Marino@end defmac 9520e4b17023SJohn Marino 9521e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_PCREL (@var{stream}, @var{size}, @var{label}) 9522e4b17023SJohn MarinoA C statement to issue assembly directives that create a self-relative 9523e4b17023SJohn Marinoreference to the given @var{label}, using an integer of the given @var{size}. 9524e4b17023SJohn Marino@end defmac 9525e4b17023SJohn Marino 9526e4b17023SJohn Marino@defmac ASM_OUTPUT_DWARF_TABLE_REF (@var{label}) 9527e4b17023SJohn MarinoA C statement to issue assembly directives that create a reference to 9528e4b17023SJohn Marinothe DWARF table identifier @var{label} from the current section. This 9529e4b17023SJohn Marinois used on some systems to avoid garbage collecting a DWARF table which 9530e4b17023SJohn Marinois referenced by a function. 9531e4b17023SJohn Marino@end defmac 9532e4b17023SJohn Marino 9533e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_ASM_OUTPUT_DWARF_DTPREL (FILE *@var{file}, int @var{size}, rtx @var{x}) 9534e4b17023SJohn MarinoIf defined, this target hook is a function which outputs a DTP-relative 9535e4b17023SJohn Marinoreference to the given TLS symbol of the specified size. 9536e4b17023SJohn Marino@end deftypefn 9537e4b17023SJohn Marino 9538e4b17023SJohn Marino@defmac PUT_SDB_@dots{} 9539e4b17023SJohn MarinoDefine these macros to override the assembler syntax for the special 9540e4b17023SJohn MarinoSDB assembler directives. See @file{sdbout.c} for a list of these 9541e4b17023SJohn Marinomacros and their arguments. If the standard syntax is used, you need 9542e4b17023SJohn Marinonot define them yourself. 9543e4b17023SJohn Marino@end defmac 9544e4b17023SJohn Marino 9545e4b17023SJohn Marino@defmac SDB_DELIM 9546e4b17023SJohn MarinoSome assemblers do not support a semicolon as a delimiter, even between 9547e4b17023SJohn MarinoSDB assembler directives. In that case, define this macro to be the 9548e4b17023SJohn Marinodelimiter to use (usually @samp{\n}). It is not necessary to define 9549e4b17023SJohn Marinoa new set of @code{PUT_SDB_@var{op}} macros if this is the only change 9550e4b17023SJohn Marinorequired. 9551e4b17023SJohn Marino@end defmac 9552e4b17023SJohn Marino 9553e4b17023SJohn Marino@defmac SDB_ALLOW_UNKNOWN_REFERENCES 9554e4b17023SJohn MarinoDefine this macro to allow references to unknown structure, 9555e4b17023SJohn Marinounion, or enumeration tags to be emitted. Standard COFF does not 9556e4b17023SJohn Marinoallow handling of unknown references, MIPS ECOFF has support for 9557e4b17023SJohn Marinoit. 9558e4b17023SJohn Marino@end defmac 9559e4b17023SJohn Marino 9560e4b17023SJohn Marino@defmac SDB_ALLOW_FORWARD_REFERENCES 9561e4b17023SJohn MarinoDefine this macro to allow references to structure, union, or 9562e4b17023SJohn Marinoenumeration tags that have not yet been seen to be handled. Some 9563e4b17023SJohn Marinoassemblers choke if forward tags are used, while some require it. 9564e4b17023SJohn Marino@end defmac 9565e4b17023SJohn Marino 9566e4b17023SJohn Marino@defmac SDB_OUTPUT_SOURCE_LINE (@var{stream}, @var{line}) 9567e4b17023SJohn MarinoA C statement to output SDB debugging information before code for line 9568e4b17023SJohn Marinonumber @var{line} of the current source file to the stdio stream 9569e4b17023SJohn Marino@var{stream}. The default is to emit an @code{.ln} directive. 9570e4b17023SJohn Marino@end defmac 9571e4b17023SJohn Marino 9572e4b17023SJohn Marino@need 2000 9573e4b17023SJohn Marino@node VMS Debug 9574e4b17023SJohn Marino@subsection Macros for VMS Debug Format 9575e4b17023SJohn Marino 9576e4b17023SJohn Marino@c prevent bad page break with this line 9577e4b17023SJohn MarinoHere are macros for VMS debug format. 9578e4b17023SJohn Marino 9579e4b17023SJohn Marino@defmac VMS_DEBUGGING_INFO 9580e4b17023SJohn MarinoDefine this macro if GCC should produce debugging output for VMS 9581e4b17023SJohn Marinoin response to the @option{-g} option. The default behavior for VMS 9582e4b17023SJohn Marinois to generate minimal debug info for a traceback in the absence of 9583e4b17023SJohn Marino@option{-g} unless explicitly overridden with @option{-g0}. This 9584e4b17023SJohn Marinobehavior is controlled by @code{TARGET_OPTION_OPTIMIZATION} and 9585e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE}. 9586e4b17023SJohn Marino@end defmac 9587e4b17023SJohn Marino 9588e4b17023SJohn Marino@node Floating Point 9589e4b17023SJohn Marino@section Cross Compilation and Floating Point 9590e4b17023SJohn Marino@cindex cross compilation and floating point 9591e4b17023SJohn Marino@cindex floating point and cross compilation 9592e4b17023SJohn Marino 9593e4b17023SJohn MarinoWhile all modern machines use twos-complement representation for integers, 9594e4b17023SJohn Marinothere are a variety of representations for floating point numbers. This 9595e4b17023SJohn Marinomeans that in a cross-compiler the representation of floating point numbers 9596e4b17023SJohn Marinoin the compiled program may be different from that used in the machine 9597e4b17023SJohn Marinodoing the compilation. 9598e4b17023SJohn Marino 9599e4b17023SJohn MarinoBecause different representation systems may offer different amounts of 9600e4b17023SJohn Marinorange and precision, all floating point constants must be represented in 9601e4b17023SJohn Marinothe target machine's format. Therefore, the cross compiler cannot 9602e4b17023SJohn Marinosafely use the host machine's floating point arithmetic; it must emulate 9603e4b17023SJohn Marinothe target's arithmetic. To ensure consistency, GCC always uses 9604e4b17023SJohn Marinoemulation to work with floating point values, even when the host and 9605e4b17023SJohn Marinotarget floating point formats are identical. 9606e4b17023SJohn Marino 9607e4b17023SJohn MarinoThe following macros are provided by @file{real.h} for the compiler to 9608e4b17023SJohn Marinouse. All parts of the compiler which generate or optimize 9609e4b17023SJohn Marinofloating-point calculations must use these macros. They may evaluate 9610e4b17023SJohn Marinotheir operands more than once, so operands must not have side effects. 9611e4b17023SJohn Marino 9612e4b17023SJohn Marino@defmac REAL_VALUE_TYPE 9613e4b17023SJohn MarinoThe C data type to be used to hold a floating point value in the target 9614e4b17023SJohn Marinomachine's format. Typically this is a @code{struct} containing an 9615e4b17023SJohn Marinoarray of @code{HOST_WIDE_INT}, but all code should treat it as an opaque 9616e4b17023SJohn Marinoquantity. 9617e4b17023SJohn Marino@end defmac 9618e4b17023SJohn Marino 9619e4b17023SJohn Marino@deftypefn Macro int REAL_VALUES_EQUAL (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y}) 9620e4b17023SJohn MarinoCompares for equality the two values, @var{x} and @var{y}. If the target 9621e4b17023SJohn Marinofloating point format supports negative zeroes and/or NaNs, 9622e4b17023SJohn Marino@samp{REAL_VALUES_EQUAL (-0.0, 0.0)} is true, and 9623e4b17023SJohn Marino@samp{REAL_VALUES_EQUAL (NaN, NaN)} is false. 9624e4b17023SJohn Marino@end deftypefn 9625e4b17023SJohn Marino 9626e4b17023SJohn Marino@deftypefn Macro int REAL_VALUES_LESS (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y}) 9627e4b17023SJohn MarinoTests whether @var{x} is less than @var{y}. 9628e4b17023SJohn Marino@end deftypefn 9629e4b17023SJohn Marino 9630e4b17023SJohn Marino@deftypefn Macro HOST_WIDE_INT REAL_VALUE_FIX (REAL_VALUE_TYPE @var{x}) 9631e4b17023SJohn MarinoTruncates @var{x} to a signed integer, rounding toward zero. 9632e4b17023SJohn Marino@end deftypefn 9633e4b17023SJohn Marino 9634e4b17023SJohn Marino@deftypefn Macro {unsigned HOST_WIDE_INT} REAL_VALUE_UNSIGNED_FIX (REAL_VALUE_TYPE @var{x}) 9635e4b17023SJohn MarinoTruncates @var{x} to an unsigned integer, rounding toward zero. If 9636e4b17023SJohn Marino@var{x} is negative, returns zero. 9637e4b17023SJohn Marino@end deftypefn 9638e4b17023SJohn Marino 9639e4b17023SJohn Marino@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ATOF (const char *@var{string}, enum machine_mode @var{mode}) 9640e4b17023SJohn MarinoConverts @var{string} into a floating point number in the target machine's 9641e4b17023SJohn Marinorepresentation for mode @var{mode}. This routine can handle both 9642e4b17023SJohn Marinodecimal and hexadecimal floating point constants, using the syntax 9643e4b17023SJohn Marinodefined by the C language for both. 9644e4b17023SJohn Marino@end deftypefn 9645e4b17023SJohn Marino 9646e4b17023SJohn Marino@deftypefn Macro int REAL_VALUE_NEGATIVE (REAL_VALUE_TYPE @var{x}) 9647e4b17023SJohn MarinoReturns 1 if @var{x} is negative (including negative zero), 0 otherwise. 9648e4b17023SJohn Marino@end deftypefn 9649e4b17023SJohn Marino 9650e4b17023SJohn Marino@deftypefn Macro int REAL_VALUE_ISINF (REAL_VALUE_TYPE @var{x}) 9651e4b17023SJohn MarinoDetermines whether @var{x} represents infinity (positive or negative). 9652e4b17023SJohn Marino@end deftypefn 9653e4b17023SJohn Marino 9654e4b17023SJohn Marino@deftypefn Macro int REAL_VALUE_ISNAN (REAL_VALUE_TYPE @var{x}) 9655e4b17023SJohn MarinoDetermines whether @var{x} represents a ``NaN'' (not-a-number). 9656e4b17023SJohn Marino@end deftypefn 9657e4b17023SJohn Marino 9658e4b17023SJohn 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}) 9659e4b17023SJohn MarinoCalculates an arithmetic operation on the two floating point values 9660e4b17023SJohn Marino@var{x} and @var{y}, storing the result in @var{output} (which must be a 9661e4b17023SJohn Marinovariable). 9662e4b17023SJohn Marino 9663e4b17023SJohn MarinoThe operation to be performed is specified by @var{code}. Only the 9664e4b17023SJohn Marinofollowing codes are supported: @code{PLUS_EXPR}, @code{MINUS_EXPR}, 9665e4b17023SJohn Marino@code{MULT_EXPR}, @code{RDIV_EXPR}, @code{MAX_EXPR}, @code{MIN_EXPR}. 9666e4b17023SJohn Marino 9667e4b17023SJohn MarinoIf @code{REAL_ARITHMETIC} is asked to evaluate division by zero and the 9668e4b17023SJohn Marinotarget's floating point format cannot represent infinity, it will call 9669e4b17023SJohn Marino@code{abort}. Callers should check for this situation first, using 9670e4b17023SJohn Marino@code{MODE_HAS_INFINITIES}. @xref{Storage Layout}. 9671e4b17023SJohn Marino@end deftypefn 9672e4b17023SJohn Marino 9673e4b17023SJohn Marino@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_NEGATE (REAL_VALUE_TYPE @var{x}) 9674e4b17023SJohn MarinoReturns the negative of the floating point value @var{x}. 9675e4b17023SJohn Marino@end deftypefn 9676e4b17023SJohn Marino 9677e4b17023SJohn Marino@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ABS (REAL_VALUE_TYPE @var{x}) 9678e4b17023SJohn MarinoReturns the absolute value of @var{x}. 9679e4b17023SJohn Marino@end deftypefn 9680e4b17023SJohn Marino 9681e4b17023SJohn Marino@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_TRUNCATE (REAL_VALUE_TYPE @var{mode}, enum machine_mode @var{x}) 9682e4b17023SJohn MarinoTruncates the floating point value @var{x} to fit in @var{mode}. The 9683e4b17023SJohn Marinoreturn value is still a full-size @code{REAL_VALUE_TYPE}, but it has an 9684e4b17023SJohn Marinoappropriate bit pattern to be output as a floating constant whose 9685e4b17023SJohn Marinoprecision accords with mode @var{mode}. 9686e4b17023SJohn Marino@end deftypefn 9687e4b17023SJohn Marino 9688e4b17023SJohn Marino@deftypefn Macro void REAL_VALUE_TO_INT (HOST_WIDE_INT @var{low}, HOST_WIDE_INT @var{high}, REAL_VALUE_TYPE @var{x}) 9689e4b17023SJohn MarinoConverts a floating point value @var{x} into a double-precision integer 9690e4b17023SJohn Marinowhich is then stored into @var{low} and @var{high}. If the value is not 9691e4b17023SJohn Marinointegral, it is truncated. 9692e4b17023SJohn Marino@end deftypefn 9693e4b17023SJohn Marino 9694e4b17023SJohn 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}) 9695e4b17023SJohn MarinoConverts a double-precision integer found in @var{low} and @var{high}, 9696e4b17023SJohn Marinointo a floating point value which is then stored into @var{x}. The 9697e4b17023SJohn Marinovalue is truncated to fit in mode @var{mode}. 9698e4b17023SJohn Marino@end deftypefn 9699e4b17023SJohn Marino 9700e4b17023SJohn Marino@node Mode Switching 9701e4b17023SJohn Marino@section Mode Switching Instructions 9702e4b17023SJohn Marino@cindex mode switching 9703e4b17023SJohn MarinoThe following macros control mode switching optimizations: 9704e4b17023SJohn Marino 9705e4b17023SJohn Marino@defmac OPTIMIZE_MODE_SWITCHING (@var{entity}) 9706e4b17023SJohn MarinoDefine this macro if the port needs extra instructions inserted for mode 9707e4b17023SJohn Marinoswitching in an optimizing compilation. 9708e4b17023SJohn Marino 9709e4b17023SJohn MarinoFor an example, the SH4 can perform both single and double precision 9710e4b17023SJohn Marinofloating point operations, but to perform a single precision operation, 9711e4b17023SJohn Marinothe FPSCR PR bit has to be cleared, while for a double precision 9712e4b17023SJohn Marinooperation, this bit has to be set. Changing the PR bit requires a general 9713e4b17023SJohn Marinopurpose register as a scratch register, hence these FPSCR sets have to 9714e4b17023SJohn Marinobe inserted before reload, i.e.@: you can't put this into instruction emitting 9715e4b17023SJohn Marinoor @code{TARGET_MACHINE_DEPENDENT_REORG}. 9716e4b17023SJohn Marino 9717e4b17023SJohn MarinoYou can have multiple entities that are mode-switched, and select at run time 9718e4b17023SJohn Marinowhich entities actually need it. @code{OPTIMIZE_MODE_SWITCHING} should 9719e4b17023SJohn Marinoreturn nonzero for any @var{entity} that needs mode-switching. 9720e4b17023SJohn MarinoIf you define this macro, you also have to define 9721e4b17023SJohn Marino@code{NUM_MODES_FOR_MODE_SWITCHING}, @code{MODE_NEEDED}, 9722e4b17023SJohn Marino@code{MODE_PRIORITY_TO_MODE} and @code{EMIT_MODE_SET}. 9723e4b17023SJohn Marino@code{MODE_AFTER}, @code{MODE_ENTRY}, and @code{MODE_EXIT} 9724e4b17023SJohn Marinoare optional. 9725e4b17023SJohn Marino@end defmac 9726e4b17023SJohn Marino 9727e4b17023SJohn Marino@defmac NUM_MODES_FOR_MODE_SWITCHING 9728e4b17023SJohn MarinoIf you define @code{OPTIMIZE_MODE_SWITCHING}, you have to define this as 9729e4b17023SJohn Marinoinitializer for an array of integers. Each initializer element 9730e4b17023SJohn MarinoN refers to an entity that needs mode switching, and specifies the number 9731e4b17023SJohn Marinoof different modes that might need to be set for this entity. 9732e4b17023SJohn MarinoThe position of the initializer in the initializer---starting counting at 9733e4b17023SJohn Marinozero---determines the integer that is used to refer to the mode-switched 9734e4b17023SJohn Marinoentity in question. 9735e4b17023SJohn MarinoIn macros that take mode arguments / yield a mode result, modes are 9736e4b17023SJohn Marinorepresented as numbers 0 @dots{} N @minus{} 1. N is used to specify that no mode 9737e4b17023SJohn Marinoswitch is needed / supplied. 9738e4b17023SJohn Marino@end defmac 9739e4b17023SJohn Marino 9740e4b17023SJohn Marino@defmac MODE_NEEDED (@var{entity}, @var{insn}) 9741e4b17023SJohn Marino@var{entity} is an integer specifying a mode-switched entity. If 9742e4b17023SJohn Marino@code{OPTIMIZE_MODE_SWITCHING} is defined, you must define this macro to 9743e4b17023SJohn Marinoreturn an integer value not larger than the corresponding element in 9744e4b17023SJohn Marino@code{NUM_MODES_FOR_MODE_SWITCHING}, to denote the mode that @var{entity} must 9745e4b17023SJohn Marinobe switched into prior to the execution of @var{insn}. 9746e4b17023SJohn Marino@end defmac 9747e4b17023SJohn Marino 9748e4b17023SJohn Marino@defmac MODE_AFTER (@var{mode}, @var{insn}) 9749e4b17023SJohn MarinoIf this macro is defined, it is evaluated for every @var{insn} during 9750e4b17023SJohn Marinomode switching. It determines the mode that an insn results in (if 9751e4b17023SJohn Marinodifferent from the incoming mode). 9752e4b17023SJohn Marino@end defmac 9753e4b17023SJohn Marino 9754e4b17023SJohn Marino@defmac MODE_ENTRY (@var{entity}) 9755e4b17023SJohn MarinoIf this macro is defined, it is evaluated for every @var{entity} that needs 9756e4b17023SJohn Marinomode switching. It should evaluate to an integer, which is a mode that 9757e4b17023SJohn Marino@var{entity} is assumed to be switched to at function entry. If @code{MODE_ENTRY} 9758e4b17023SJohn Marinois defined then @code{MODE_EXIT} must be defined. 9759e4b17023SJohn Marino@end defmac 9760e4b17023SJohn Marino 9761e4b17023SJohn Marino@defmac MODE_EXIT (@var{entity}) 9762e4b17023SJohn MarinoIf this macro is defined, it is evaluated for every @var{entity} that needs 9763e4b17023SJohn Marinomode switching. It should evaluate to an integer, which is a mode that 9764e4b17023SJohn Marino@var{entity} is assumed to be switched to at function exit. If @code{MODE_EXIT} 9765e4b17023SJohn Marinois defined then @code{MODE_ENTRY} must be defined. 9766e4b17023SJohn Marino@end defmac 9767e4b17023SJohn Marino 9768e4b17023SJohn Marino@defmac MODE_PRIORITY_TO_MODE (@var{entity}, @var{n}) 9769e4b17023SJohn MarinoThis macro specifies the order in which modes for @var{entity} are processed. 9770e4b17023SJohn Marino0 is the highest priority, @code{NUM_MODES_FOR_MODE_SWITCHING[@var{entity}] - 1} the 9771e4b17023SJohn Marinolowest. The value of the macro should be an integer designating a mode 9772e4b17023SJohn Marinofor @var{entity}. For any fixed @var{entity}, @code{mode_priority_to_mode} 9773e4b17023SJohn Marino(@var{entity}, @var{n}) shall be a bijection in 0 @dots{} 9774e4b17023SJohn Marino@code{num_modes_for_mode_switching[@var{entity}] - 1}. 9775e4b17023SJohn Marino@end defmac 9776e4b17023SJohn Marino 9777e4b17023SJohn Marino@defmac EMIT_MODE_SET (@var{entity}, @var{mode}, @var{hard_regs_live}) 9778e4b17023SJohn MarinoGenerate one or more insns to set @var{entity} to @var{mode}. 9779e4b17023SJohn Marino@var{hard_reg_live} is the set of hard registers live at the point where 9780e4b17023SJohn Marinothe insn(s) are to be inserted. 9781e4b17023SJohn Marino@end defmac 9782e4b17023SJohn Marino 9783e4b17023SJohn Marino@node Target Attributes 9784e4b17023SJohn Marino@section Defining target-specific uses of @code{__attribute__} 9785e4b17023SJohn Marino@cindex target attributes 9786e4b17023SJohn Marino@cindex machine attributes 9787e4b17023SJohn Marino@cindex attributes, target-specific 9788e4b17023SJohn Marino 9789e4b17023SJohn MarinoTarget-specific attributes may be defined for functions, data and types. 9790e4b17023SJohn MarinoThese are described using the following target hooks; they also need to 9791e4b17023SJohn Marinobe documented in @file{extend.texi}. 9792e4b17023SJohn Marino 9793e4b17023SJohn Marino@deftypevr {Target Hook} {const struct attribute_spec *} TARGET_ATTRIBUTE_TABLE 9794e4b17023SJohn MarinoIf defined, this target hook points to an array of @samp{struct 9795e4b17023SJohn Marinoattribute_spec} (defined in @file{tree.h}) specifying the machine 9796e4b17023SJohn Marinospecific attributes for this target and some of the restrictions on the 9797e4b17023SJohn Marinoentities to which these attributes are applied and the arguments they 9798e4b17023SJohn Marinotake. 9799e4b17023SJohn Marino@end deftypevr 9800e4b17023SJohn Marino 9801e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P (const_tree @var{name}) 9802e4b17023SJohn MarinoIf defined, this target hook is a function which returns true if the 9803e4b17023SJohn Marinomachine-specific attribute named @var{name} expects an identifier 9804e4b17023SJohn Marinogiven as its first argument to be passed on as a plain identifier, not 9805e4b17023SJohn Marinosubjected to name lookup. If this is not defined, the default is 9806e4b17023SJohn Marinofalse for all machine-specific attributes. 9807e4b17023SJohn Marino@end deftypefn 9808e4b17023SJohn Marino 9809e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_COMP_TYPE_ATTRIBUTES (const_tree @var{type1}, const_tree @var{type2}) 9810e4b17023SJohn MarinoIf defined, this target hook is a function which returns zero if the attributes on 9811e4b17023SJohn Marino@var{type1} and @var{type2} are incompatible, one if they are compatible, 9812e4b17023SJohn Marinoand two if they are nearly compatible (which causes a warning to be 9813e4b17023SJohn Marinogenerated). If this is not defined, machine-specific attributes are 9814e4b17023SJohn Marinosupposed always to be compatible. 9815e4b17023SJohn Marino@end deftypefn 9816e4b17023SJohn Marino 9817e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SET_DEFAULT_TYPE_ATTRIBUTES (tree @var{type}) 9818e4b17023SJohn MarinoIf defined, this target hook is a function which assigns default attributes to 9819e4b17023SJohn Marinothe newly defined @var{type}. 9820e4b17023SJohn Marino@end deftypefn 9821e4b17023SJohn Marino 9822e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_MERGE_TYPE_ATTRIBUTES (tree @var{type1}, tree @var{type2}) 9823e4b17023SJohn MarinoDefine this target hook if the merging of type attributes needs special 9824e4b17023SJohn Marinohandling. If defined, the result is a list of the combined 9825e4b17023SJohn Marino@code{TYPE_ATTRIBUTES} of @var{type1} and @var{type2}. It is assumed 9826e4b17023SJohn Marinothat @code{comptypes} has already been called and returned 1. This 9827e4b17023SJohn Marinofunction may call @code{merge_attributes} to handle machine-independent 9828e4b17023SJohn Marinomerging. 9829e4b17023SJohn Marino@end deftypefn 9830e4b17023SJohn Marino 9831e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_MERGE_DECL_ATTRIBUTES (tree @var{olddecl}, tree @var{newdecl}) 9832e4b17023SJohn MarinoDefine this target hook if the merging of decl attributes needs special 9833e4b17023SJohn Marinohandling. If defined, the result is a list of the combined 9834e4b17023SJohn Marino@code{DECL_ATTRIBUTES} of @var{olddecl} and @var{newdecl}. 9835e4b17023SJohn Marino@var{newdecl} is a duplicate declaration of @var{olddecl}. Examples of 9836e4b17023SJohn Marinowhen this is needed are when one attribute overrides another, or when an 9837e4b17023SJohn Marinoattribute is nullified by a subsequent definition. This function may 9838e4b17023SJohn Marinocall @code{merge_attributes} to handle machine-independent merging. 9839e4b17023SJohn Marino 9840e4b17023SJohn Marino@findex TARGET_DLLIMPORT_DECL_ATTRIBUTES 9841e4b17023SJohn MarinoIf the only target-specific handling you require is @samp{dllimport} 9842e4b17023SJohn Marinofor Microsoft Windows targets, you should define the macro 9843e4b17023SJohn Marino@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES} to @code{1}. The compiler 9844e4b17023SJohn Marinowill then define a function called 9845e4b17023SJohn Marino@code{merge_dllimport_decl_attributes} which can then be defined as 9846e4b17023SJohn Marinothe expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}. You can also 9847e4b17023SJohn Marinoadd @code{handle_dll_attribute} in the attribute table for your port 9848e4b17023SJohn Marinoto perform initial processing of the @samp{dllimport} and 9849e4b17023SJohn Marino@samp{dllexport} attributes. This is done in @file{i386/cygwin.h} and 9850e4b17023SJohn Marino@file{i386/i386.c}, for example. 9851e4b17023SJohn Marino@end deftypefn 9852e4b17023SJohn Marino 9853e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_VALID_DLLIMPORT_ATTRIBUTE_P (const_tree @var{decl}) 9854e4b17023SJohn Marino@var{decl} is a variable or function with @code{__attribute__((dllimport))} specified. Use this hook if the target needs to add extra validation checks to @code{handle_dll_attribute}. 9855e4b17023SJohn Marino@end deftypefn 9856e4b17023SJohn Marino 9857e4b17023SJohn Marino@defmac TARGET_DECLSPEC 9858e4b17023SJohn MarinoDefine this macro to a nonzero value if you want to treat 9859e4b17023SJohn Marino@code{__declspec(X)} as equivalent to @code{__attribute((X))}. By 9860e4b17023SJohn Marinodefault, this behavior is enabled only for targets that define 9861e4b17023SJohn Marino@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES}. The current implementation 9862e4b17023SJohn Marinoof @code{__declspec} is via a built-in macro, but you should not rely 9863e4b17023SJohn Marinoon this implementation detail. 9864e4b17023SJohn Marino@end defmac 9865e4b17023SJohn Marino 9866e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_INSERT_ATTRIBUTES (tree @var{node}, tree *@var{attr_ptr}) 9867e4b17023SJohn MarinoDefine this target hook if you want to be able to add attributes to a decl 9868e4b17023SJohn Marinowhen it is being created. This is normally useful for back ends which 9869e4b17023SJohn Marinowish to implement a pragma by using the attributes which correspond to 9870e4b17023SJohn Marinothe pragma's effect. The @var{node} argument is the decl which is being 9871e4b17023SJohn Marinocreated. The @var{attr_ptr} argument is a pointer to the attribute list 9872e4b17023SJohn Marinofor this decl. The list itself should not be modified, since it may be 9873e4b17023SJohn Marinoshared with other decls, but attributes may be chained on the head of 9874e4b17023SJohn Marinothe list and @code{*@var{attr_ptr}} modified to point to the new 9875e4b17023SJohn Marinoattributes, or a copy of the list may be made if further changes are 9876e4b17023SJohn Marinoneeded. 9877e4b17023SJohn Marino@end deftypefn 9878e4b17023SJohn Marino 9879e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P (const_tree @var{fndecl}) 9880e4b17023SJohn Marino@cindex inlining 9881e4b17023SJohn MarinoThis target hook returns @code{true} if it is ok to inline @var{fndecl} 9882e4b17023SJohn Marinointo the current function, despite its having target-specific 9883e4b17023SJohn Marinoattributes, @code{false} otherwise. By default, if a function has a 9884e4b17023SJohn Marinotarget specific attribute attached to it, it will not be inlined. 9885e4b17023SJohn Marino@end deftypefn 9886e4b17023SJohn Marino 9887e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_OPTION_VALID_ATTRIBUTE_P (tree @var{fndecl}, tree @var{name}, tree @var{args}, int @var{flags}) 9888e4b17023SJohn MarinoThis hook is called to parse the @code{attribute(option("..."))}, and 9889e4b17023SJohn Marinoit allows the function to set different target machine compile time 9890e4b17023SJohn Marinooptions for the current function that might be different than the 9891e4b17023SJohn Marinooptions specified on the command line. The hook should return 9892e4b17023SJohn Marino@code{true} if the options are valid. 9893e4b17023SJohn Marino 9894e4b17023SJohn MarinoThe hook should set the @var{DECL_FUNCTION_SPECIFIC_TARGET} field in 9895e4b17023SJohn Marinothe function declaration to hold a pointer to a target specific 9896e4b17023SJohn Marino@var{struct cl_target_option} structure. 9897e4b17023SJohn Marino@end deftypefn 9898e4b17023SJohn Marino 9899e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_OPTION_SAVE (struct cl_target_option *@var{ptr}) 9900e4b17023SJohn MarinoThis hook is called to save any additional target specific information 9901e4b17023SJohn Marinoin the @var{struct cl_target_option} structure for function specific 9902e4b17023SJohn Marinooptions. 9903e4b17023SJohn Marino@xref{Option file format}. 9904e4b17023SJohn Marino@end deftypefn 9905e4b17023SJohn Marino 9906e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_OPTION_RESTORE (struct cl_target_option *@var{ptr}) 9907e4b17023SJohn MarinoThis hook is called to restore any additional target specific 9908e4b17023SJohn Marinoinformation in the @var{struct cl_target_option} structure for 9909e4b17023SJohn Marinofunction specific options. 9910e4b17023SJohn Marino@end deftypefn 9911e4b17023SJohn Marino 9912e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_OPTION_PRINT (FILE *@var{file}, int @var{indent}, struct cl_target_option *@var{ptr}) 9913e4b17023SJohn MarinoThis hook is called to print any additional target specific 9914e4b17023SJohn Marinoinformation in the @var{struct cl_target_option} structure for 9915e4b17023SJohn Marinofunction specific options. 9916e4b17023SJohn Marino@end deftypefn 9917e4b17023SJohn Marino 9918e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_OPTION_PRAGMA_PARSE (tree @var{args}, tree @var{pop_target}) 9919e4b17023SJohn MarinoThis target hook parses the options for @code{#pragma GCC option} to 9920e4b17023SJohn Marinoset the machine specific options for functions that occur later in the 9921e4b17023SJohn Marinoinput stream. The options should be the same as handled by the 9922e4b17023SJohn Marino@code{TARGET_OPTION_VALID_ATTRIBUTE_P} hook. 9923e4b17023SJohn Marino@end deftypefn 9924e4b17023SJohn Marino 9925e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_OPTION_OVERRIDE (void) 9926e4b17023SJohn MarinoSometimes certain combinations of command options do not make sense on 9927e4b17023SJohn Marinoa particular target machine. You can override the hook 9928e4b17023SJohn Marino@code{TARGET_OPTION_OVERRIDE} to take account of this. This hooks is called 9929e4b17023SJohn Marinoonce just after all the command options have been parsed. 9930e4b17023SJohn Marino 9931e4b17023SJohn MarinoDon't use this hook to turn on various extra optimizations for 9932e4b17023SJohn Marino@option{-O}. That is what @code{TARGET_OPTION_OPTIMIZATION} is for. 9933e4b17023SJohn Marino 9934e4b17023SJohn MarinoIf you need to do something whenever the optimization level is 9935e4b17023SJohn Marinochanged via the optimize attribute or pragma, see 9936e4b17023SJohn Marino@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE} 9937e4b17023SJohn Marino@end deftypefn 9938e4b17023SJohn Marino 9939e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CAN_INLINE_P (tree @var{caller}, tree @var{callee}) 9940e4b17023SJohn MarinoThis target hook returns @code{false} if the @var{caller} function 9941e4b17023SJohn Marinocannot inline @var{callee}, based on target specific information. By 9942e4b17023SJohn Marinodefault, inlining is not allowed if the callee function has function 9943e4b17023SJohn Marinospecific target options and the caller does not use the same options. 9944e4b17023SJohn Marino@end deftypefn 9945e4b17023SJohn Marino 9946e4b17023SJohn Marino@node Emulated TLS 9947e4b17023SJohn Marino@section Emulating TLS 9948e4b17023SJohn Marino@cindex Emulated TLS 9949e4b17023SJohn Marino 9950e4b17023SJohn MarinoFor targets whose psABI does not provide Thread Local Storage via 9951e4b17023SJohn Marinospecific relocations and instruction sequences, an emulation layer is 9952e4b17023SJohn Marinoused. A set of target hooks allows this emulation layer to be 9953e4b17023SJohn Marinoconfigured for the requirements of a particular target. For instance 9954e4b17023SJohn Marinothe psABI may in fact specify TLS support in terms of an emulation 9955e4b17023SJohn Marinolayer. 9956e4b17023SJohn Marino 9957e4b17023SJohn MarinoThe emulation layer works by creating a control object for every TLS 9958e4b17023SJohn Marinoobject. To access the TLS object, a lookup function is provided 9959e4b17023SJohn Marinowhich, when given the address of the control object, will return the 9960e4b17023SJohn Marinoaddress of the current thread's instance of the TLS object. 9961e4b17023SJohn Marino 9962e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_EMUTLS_GET_ADDRESS 9963e4b17023SJohn MarinoContains the name of the helper function that uses a TLS control 9964e4b17023SJohn Marinoobject to locate a TLS instance. The default causes libgcc's 9965e4b17023SJohn Marinoemulated TLS helper function to be used. 9966e4b17023SJohn Marino@end deftypevr 9967e4b17023SJohn Marino 9968e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_EMUTLS_REGISTER_COMMON 9969e4b17023SJohn MarinoContains the name of the helper function that should be used at 9970e4b17023SJohn Marinoprogram startup to register TLS objects that are implicitly 9971e4b17023SJohn Marinoinitialized to zero. If this is @code{NULL}, all TLS objects will 9972e4b17023SJohn Marinohave explicit initializers. The default causes libgcc's emulated TLS 9973e4b17023SJohn Marinoregistration function to be used. 9974e4b17023SJohn Marino@end deftypevr 9975e4b17023SJohn Marino 9976e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_EMUTLS_VAR_SECTION 9977e4b17023SJohn MarinoContains the name of the section in which TLS control variables should 9978e4b17023SJohn Marinobe placed. The default of @code{NULL} allows these to be placed in 9979e4b17023SJohn Marinoany section. 9980e4b17023SJohn Marino@end deftypevr 9981e4b17023SJohn Marino 9982e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_EMUTLS_TMPL_SECTION 9983e4b17023SJohn MarinoContains the name of the section in which TLS initializers should be 9984e4b17023SJohn Marinoplaced. The default of @code{NULL} allows these to be placed in any 9985e4b17023SJohn Marinosection. 9986e4b17023SJohn Marino@end deftypevr 9987e4b17023SJohn Marino 9988e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_EMUTLS_VAR_PREFIX 9989e4b17023SJohn MarinoContains the prefix to be prepended to TLS control variable names. 9990e4b17023SJohn MarinoThe default of @code{NULL} uses a target-specific prefix. 9991e4b17023SJohn Marino@end deftypevr 9992e4b17023SJohn Marino 9993e4b17023SJohn Marino@deftypevr {Target Hook} {const char *} TARGET_EMUTLS_TMPL_PREFIX 9994e4b17023SJohn MarinoContains the prefix to be prepended to TLS initializer objects. The 9995e4b17023SJohn Marinodefault of @code{NULL} uses a target-specific prefix. 9996e4b17023SJohn Marino@end deftypevr 9997e4b17023SJohn Marino 9998e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_EMUTLS_VAR_FIELDS (tree @var{type}, tree *@var{name}) 9999e4b17023SJohn MarinoSpecifies a function that generates the FIELD_DECLs for a TLS control 10000e4b17023SJohn Marinoobject type. @var{type} is the RECORD_TYPE the fields are for and 10001e4b17023SJohn Marino@var{name} should be filled with the structure tag, if the default of 10002e4b17023SJohn Marino@code{__emutls_object} is unsuitable. The default creates a type suitable 10003e4b17023SJohn Marinofor libgcc's emulated TLS function. 10004e4b17023SJohn Marino@end deftypefn 10005e4b17023SJohn Marino 10006e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_EMUTLS_VAR_INIT (tree @var{var}, tree @var{decl}, tree @var{tmpl_addr}) 10007e4b17023SJohn MarinoSpecifies a function that generates the CONSTRUCTOR to initialize a 10008e4b17023SJohn MarinoTLS control object. @var{var} is the TLS control object, @var{decl} 10009e4b17023SJohn Marinois the TLS object and @var{tmpl_addr} is the address of the 10010e4b17023SJohn Marinoinitializer. The default initializes libgcc's emulated TLS control object. 10011e4b17023SJohn Marino@end deftypefn 10012e4b17023SJohn Marino 10013e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_EMUTLS_VAR_ALIGN_FIXED 10014e4b17023SJohn MarinoSpecifies whether the alignment of TLS control variable objects is 10015e4b17023SJohn Marinofixed and should not be increased as some backends may do to optimize 10016e4b17023SJohn Marinosingle objects. The default is false. 10017e4b17023SJohn Marino@end deftypevr 10018e4b17023SJohn Marino 10019e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_EMUTLS_DEBUG_FORM_TLS_ADDRESS 10020e4b17023SJohn MarinoSpecifies whether a DWARF @code{DW_OP_form_tls_address} location descriptor 10021e4b17023SJohn Marinomay be used to describe emulated TLS control objects. 10022e4b17023SJohn Marino@end deftypevr 10023e4b17023SJohn Marino 10024e4b17023SJohn Marino@node MIPS Coprocessors 10025e4b17023SJohn Marino@section Defining coprocessor specifics for MIPS targets. 10026e4b17023SJohn Marino@cindex MIPS coprocessor-definition macros 10027e4b17023SJohn Marino 10028e4b17023SJohn MarinoThe MIPS specification allows MIPS implementations to have as many as 4 10029e4b17023SJohn Marinocoprocessors, each with as many as 32 private registers. GCC supports 10030e4b17023SJohn Marinoaccessing these registers and transferring values between the registers 10031e4b17023SJohn Marinoand memory using asm-ized variables. For example: 10032e4b17023SJohn Marino 10033e4b17023SJohn Marino@smallexample 10034e4b17023SJohn Marino register unsigned int cp0count asm ("c0r1"); 10035e4b17023SJohn Marino unsigned int d; 10036e4b17023SJohn Marino 10037e4b17023SJohn Marino d = cp0count + 3; 10038e4b17023SJohn Marino@end smallexample 10039e4b17023SJohn Marino 10040e4b17023SJohn Marino(``c0r1'' is the default name of register 1 in coprocessor 0; alternate 10041e4b17023SJohn Marinonames may be added as described below, or the default names may be 10042e4b17023SJohn Marinooverridden entirely in @code{SUBTARGET_CONDITIONAL_REGISTER_USAGE}.) 10043e4b17023SJohn Marino 10044e4b17023SJohn MarinoCoprocessor registers are assumed to be epilogue-used; sets to them will 10045e4b17023SJohn Marinobe preserved even if it does not appear that the register is used again 10046e4b17023SJohn Marinolater in the function. 10047e4b17023SJohn Marino 10048e4b17023SJohn MarinoAnother note: according to the MIPS spec, coprocessor 1 (if present) is 10049e4b17023SJohn Marinothe FPU@. One accesses COP1 registers through standard mips 10050e4b17023SJohn Marinofloating-point support; they are not included in this mechanism. 10051e4b17023SJohn Marino 10052e4b17023SJohn MarinoThere is one macro used in defining the MIPS coprocessor interface which 10053e4b17023SJohn Marinoyou may want to override in subtargets; it is described below. 10054e4b17023SJohn Marino 10055e4b17023SJohn Marino@defmac ALL_COP_ADDITIONAL_REGISTER_NAMES 10056e4b17023SJohn MarinoA comma-separated list (with leading comma) of pairs describing the 10057e4b17023SJohn Marinoalternate names of coprocessor registers. The format of each entry should be 10058e4b17023SJohn Marino@smallexample 10059e4b17023SJohn Marino@{ @var{alternatename}, @var{register_number}@} 10060e4b17023SJohn Marino@end smallexample 10061e4b17023SJohn MarinoDefault: empty. 10062e4b17023SJohn Marino@end defmac 10063e4b17023SJohn Marino 10064e4b17023SJohn Marino@node PCH Target 10065e4b17023SJohn Marino@section Parameters for Precompiled Header Validity Checking 10066e4b17023SJohn Marino@cindex parameters, precompiled headers 10067e4b17023SJohn Marino 10068e4b17023SJohn Marino@deftypefn {Target Hook} {void *} TARGET_GET_PCH_VALIDITY (size_t *@var{sz}) 10069e4b17023SJohn MarinoThis hook returns a pointer to the data needed by 10070e4b17023SJohn Marino@code{TARGET_PCH_VALID_P} and sets 10071e4b17023SJohn Marino@samp{*@var{sz}} to the size of the data in bytes. 10072e4b17023SJohn Marino@end deftypefn 10073e4b17023SJohn Marino 10074e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_PCH_VALID_P (const void *@var{data}, size_t @var{sz}) 10075e4b17023SJohn MarinoThis hook checks whether the options used to create a PCH file are 10076e4b17023SJohn Marinocompatible with the current settings. It returns @code{NULL} 10077e4b17023SJohn Marinoif so and a suitable error message if not. Error messages will 10078e4b17023SJohn Marinobe presented to the user and must be localized using @samp{_(@var{msg})}. 10079e4b17023SJohn Marino 10080e4b17023SJohn Marino@var{data} is the data that was returned by @code{TARGET_GET_PCH_VALIDITY} 10081e4b17023SJohn Marinowhen the PCH file was created and @var{sz} is the size of that data in bytes. 10082e4b17023SJohn MarinoIt's safe to assume that the data was created by the same version of the 10083e4b17023SJohn Marinocompiler, so no format checking is needed. 10084e4b17023SJohn Marino 10085e4b17023SJohn MarinoThe default definition of @code{default_pch_valid_p} should be 10086e4b17023SJohn Marinosuitable for most targets. 10087e4b17023SJohn Marino@end deftypefn 10088e4b17023SJohn Marino 10089e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_CHECK_PCH_TARGET_FLAGS (int @var{pch_flags}) 10090e4b17023SJohn MarinoIf this hook is nonnull, the default implementation of 10091e4b17023SJohn Marino@code{TARGET_PCH_VALID_P} will use it to check for compatible values 10092e4b17023SJohn Marinoof @code{target_flags}. @var{pch_flags} specifies the value that 10093e4b17023SJohn Marino@code{target_flags} had when the PCH file was created. The return 10094e4b17023SJohn Marinovalue is the same as for @code{TARGET_PCH_VALID_P}. 10095e4b17023SJohn Marino@end deftypefn 10096e4b17023SJohn Marino 10097e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_PREPARE_PCH_SAVE (void) 10098e4b17023SJohn MarinoCalled before writing out a PCH file. If the target has some 10099e4b17023SJohn Marinogarbage-collected data that needs to be in a particular state on PCH loads, 10100e4b17023SJohn Marinoit can use this hook to enforce that state. Very few targets need 10101e4b17023SJohn Marinoto do anything here. 10102e4b17023SJohn Marino@end deftypefn 10103e4b17023SJohn Marino 10104e4b17023SJohn Marino@node C++ ABI 10105e4b17023SJohn Marino@section C++ ABI parameters 10106e4b17023SJohn Marino@cindex parameters, c++ abi 10107e4b17023SJohn Marino 10108e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_CXX_GUARD_TYPE (void) 10109e4b17023SJohn MarinoDefine this hook to override the integer type used for guard variables. 10110e4b17023SJohn MarinoThese are used to implement one-time construction of static objects. The 10111e4b17023SJohn Marinodefault is long_long_integer_type_node. 10112e4b17023SJohn Marino@end deftypefn 10113e4b17023SJohn Marino 10114e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CXX_GUARD_MASK_BIT (void) 10115e4b17023SJohn MarinoThis hook determines how guard variables are used. It should return 10116e4b17023SJohn Marino@code{false} (the default) if the first byte should be used. A return value of 10117e4b17023SJohn Marino@code{true} indicates that only the least significant bit should be used. 10118e4b17023SJohn Marino@end deftypefn 10119e4b17023SJohn Marino 10120e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_CXX_GET_COOKIE_SIZE (tree @var{type}) 10121e4b17023SJohn MarinoThis hook returns the size of the cookie to use when allocating an array 10122e4b17023SJohn Marinowhose elements have the indicated @var{type}. Assumes that it is already 10123e4b17023SJohn Marinoknown that a cookie is needed. The default is 10124e4b17023SJohn Marino@code{max(sizeof (size_t), alignof(type))}, as defined in section 2.7 of the 10125e4b17023SJohn MarinoIA64/Generic C++ ABI@. 10126e4b17023SJohn Marino@end deftypefn 10127e4b17023SJohn Marino 10128e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CXX_COOKIE_HAS_SIZE (void) 10129e4b17023SJohn MarinoThis hook should return @code{true} if the element size should be stored in 10130e4b17023SJohn Marinoarray cookies. The default is to return @code{false}. 10131e4b17023SJohn Marino@end deftypefn 10132e4b17023SJohn Marino 10133e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_CXX_IMPORT_EXPORT_CLASS (tree @var{type}, int @var{import_export}) 10134e4b17023SJohn MarinoIf defined by a backend this hook allows the decision made to export 10135e4b17023SJohn Marinoclass @var{type} to be overruled. Upon entry @var{import_export} 10136e4b17023SJohn Marinowill contain 1 if the class is going to be exported, @minus{}1 if it is going 10137e4b17023SJohn Marinoto be imported and 0 otherwise. This function should return the 10138e4b17023SJohn Marinomodified value and perform any other actions necessary to support the 10139e4b17023SJohn Marinobackend's targeted operating system. 10140e4b17023SJohn Marino@end deftypefn 10141e4b17023SJohn Marino 10142e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CXX_CDTOR_RETURNS_THIS (void) 10143e4b17023SJohn MarinoThis hook should return @code{true} if constructors and destructors return 10144e4b17023SJohn Marinothe address of the object created/destroyed. The default is to return 10145e4b17023SJohn Marino@code{false}. 10146e4b17023SJohn Marino@end deftypefn 10147e4b17023SJohn Marino 10148e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CXX_KEY_METHOD_MAY_BE_INLINE (void) 10149e4b17023SJohn MarinoThis hook returns true if the key method for a class (i.e., the method 10150e4b17023SJohn Marinowhich, if defined in the current translation unit, causes the virtual 10151e4b17023SJohn Marinotable to be emitted) may be an inline function. Under the standard 10152e4b17023SJohn MarinoItanium C++ ABI the key method may be an inline function so long as 10153e4b17023SJohn Marinothe function is not declared inline in the class definition. Under 10154e4b17023SJohn Marinosome variants of the ABI, an inline function can never be the key 10155e4b17023SJohn Marinomethod. The default is to return @code{true}. 10156e4b17023SJohn Marino@end deftypefn 10157e4b17023SJohn Marino 10158e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY (tree @var{decl}) 10159e4b17023SJohn Marino@var{decl} is a virtual table, virtual table table, typeinfo object, or other similar implicit class data object that will be emitted with external linkage in this translation unit. No ELF visibility has been explicitly specified. If the target needs to specify a visibility other than that of the containing class, use this hook to set @code{DECL_VISIBILITY} and @code{DECL_VISIBILITY_SPECIFIED}. 10160e4b17023SJohn Marino@end deftypefn 10161e4b17023SJohn Marino 10162e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT (void) 10163e4b17023SJohn MarinoThis hook returns true (the default) if virtual tables and other 10164e4b17023SJohn Marinosimilar implicit class data objects are always COMDAT if they have 10165e4b17023SJohn Marinoexternal linkage. If this hook returns false, then class data for 10166e4b17023SJohn Marinoclasses whose virtual table will be emitted in only one translation 10167e4b17023SJohn Marinounit will not be COMDAT. 10168e4b17023SJohn Marino@end deftypefn 10169e4b17023SJohn Marino 10170e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CXX_LIBRARY_RTTI_COMDAT (void) 10171e4b17023SJohn MarinoThis hook returns true (the default) if the RTTI information for 10172e4b17023SJohn Marinothe basic types which is defined in the C++ runtime should always 10173e4b17023SJohn Marinobe COMDAT, false if it should not be COMDAT. 10174e4b17023SJohn Marino@end deftypefn 10175e4b17023SJohn Marino 10176e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CXX_USE_AEABI_ATEXIT (void) 10177e4b17023SJohn MarinoThis hook returns true if @code{__aeabi_atexit} (as defined by the ARM EABI) 10178e4b17023SJohn Marinoshould be used to register static destructors when @option{-fuse-cxa-atexit} 10179e4b17023SJohn Marinois in effect. The default is to return false to use @code{__cxa_atexit}. 10180e4b17023SJohn Marino@end deftypefn 10181e4b17023SJohn Marino 10182e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT (void) 10183e4b17023SJohn MarinoThis hook returns true if the target @code{atexit} function can be used 10184e4b17023SJohn Marinoin the same manner as @code{__cxa_atexit} to register C++ static 10185e4b17023SJohn Marinodestructors. This requires that @code{atexit}-registered functions in 10186e4b17023SJohn Marinoshared libraries are run in the correct order when the libraries are 10187e4b17023SJohn Marinounloaded. The default is to return false. 10188e4b17023SJohn Marino@end deftypefn 10189e4b17023SJohn Marino 10190e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_CXX_ADJUST_CLASS_AT_DEFINITION (tree @var{type}) 10191e4b17023SJohn Marino@var{type} is a C++ class (i.e., RECORD_TYPE or UNION_TYPE) that has just been defined. Use this hook to make adjustments to the class (eg, tweak visibility or perform any other required target modifications). 10192e4b17023SJohn Marino@end deftypefn 10193e4b17023SJohn Marino 10194e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_CXX_DECL_MANGLING_CONTEXT (const_tree @var{decl}) 10195e4b17023SJohn MarinoReturn target-specific mangling context of @var{decl} or @code{NULL_TREE}. 10196e4b17023SJohn Marino@end deftypefn 10197e4b17023SJohn Marino 10198e4b17023SJohn Marino@node Named Address Spaces 10199e4b17023SJohn Marino@section Adding support for named address spaces 10200e4b17023SJohn Marino@cindex named address spaces 10201e4b17023SJohn Marino 10202e4b17023SJohn MarinoThe draft technical report of the ISO/IEC JTC1 S22 WG14 N1275 10203e4b17023SJohn Marinostandards committee, @cite{Programming Languages - C - Extensions to 10204e4b17023SJohn Marinosupport embedded processors}, specifies a syntax for embedded 10205e4b17023SJohn Marinoprocessors to specify alternate address spaces. You can configure a 10206e4b17023SJohn MarinoGCC port to support section 5.1 of the draft report to add support for 10207e4b17023SJohn Marinoaddress spaces other than the default address space. These address 10208e4b17023SJohn Marinospaces are new keywords that are similar to the @code{volatile} and 10209e4b17023SJohn Marino@code{const} type attributes. 10210e4b17023SJohn Marino 10211e4b17023SJohn MarinoPointers to named address spaces can have a different size than 10212e4b17023SJohn Marinopointers to the generic address space. 10213e4b17023SJohn Marino 10214e4b17023SJohn MarinoFor example, the SPU port uses the @code{__ea} address space to refer 10215e4b17023SJohn Marinoto memory in the host processor, rather than memory local to the SPU 10216e4b17023SJohn Marinoprocessor. Access to memory in the @code{__ea} address space involves 10217e4b17023SJohn Marinoissuing DMA operations to move data between the host processor and the 10218e4b17023SJohn Marinolocal processor memory address space. Pointers in the @code{__ea} 10219e4b17023SJohn Marinoaddress space are either 32 bits or 64 bits based on the 10220e4b17023SJohn Marino@option{-mea32} or @option{-mea64} switches (native SPU pointers are 10221e4b17023SJohn Marinoalways 32 bits). 10222e4b17023SJohn Marino 10223e4b17023SJohn MarinoInternally, address spaces are represented as a small integer in the 10224e4b17023SJohn Marinorange 0 to 15 with address space 0 being reserved for the generic 10225e4b17023SJohn Marinoaddress space. 10226e4b17023SJohn Marino 10227e4b17023SJohn MarinoTo register a named address space qualifier keyword with the C front end, 10228e4b17023SJohn Marinothe target may call the @code{c_register_addr_space} routine. For example, 10229e4b17023SJohn Marinothe SPU port uses the following to declare @code{__ea} as the keyword for 10230e4b17023SJohn Marinonamed address space #1: 10231e4b17023SJohn Marino@smallexample 10232e4b17023SJohn Marino#define ADDR_SPACE_EA 1 10233e4b17023SJohn Marinoc_register_addr_space ("__ea", ADDR_SPACE_EA); 10234e4b17023SJohn Marino@end smallexample 10235e4b17023SJohn Marino 10236e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_ADDR_SPACE_POINTER_MODE (addr_space_t @var{address_space}) 10237e4b17023SJohn MarinoDefine this to return the machine mode to use for pointers to 10238e4b17023SJohn Marino@var{address_space} if the target supports named address spaces. 10239e4b17023SJohn MarinoThe default version of this hook returns @code{ptr_mode} for the 10240e4b17023SJohn Marinogeneric address space only. 10241e4b17023SJohn Marino@end deftypefn 10242e4b17023SJohn Marino 10243e4b17023SJohn Marino@deftypefn {Target Hook} {enum machine_mode} TARGET_ADDR_SPACE_ADDRESS_MODE (addr_space_t @var{address_space}) 10244e4b17023SJohn MarinoDefine this to return the machine mode to use for addresses in 10245e4b17023SJohn Marino@var{address_space} if the target supports named address spaces. 10246e4b17023SJohn MarinoThe default version of this hook returns @code{Pmode} for the 10247e4b17023SJohn Marinogeneric address space only. 10248e4b17023SJohn Marino@end deftypefn 10249e4b17023SJohn Marino 10250e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ADDR_SPACE_VALID_POINTER_MODE (enum machine_mode @var{mode}, addr_space_t @var{as}) 10251e4b17023SJohn MarinoDefine this to return nonzero if the port can handle pointers 10252e4b17023SJohn Marinowith machine mode @var{mode} to address space @var{as}. This target 10253e4b17023SJohn Marinohook is the same as the @code{TARGET_VALID_POINTER_MODE} target hook, 10254e4b17023SJohn Marinoexcept that it includes explicit named address space support. The default 10255e4b17023SJohn Marinoversion of this hook returns true for the modes returned by either the 10256e4b17023SJohn Marino@code{TARGET_ADDR_SPACE_POINTER_MODE} or @code{TARGET_ADDR_SPACE_ADDRESS_MODE} 10257e4b17023SJohn Marinotarget hooks for the given address space. 10258e4b17023SJohn Marino@end deftypefn 10259e4b17023SJohn Marino 10260e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P (enum machine_mode @var{mode}, rtx @var{exp}, bool @var{strict}, addr_space_t @var{as}) 10261e4b17023SJohn MarinoDefine this to return true if @var{exp} is a valid address for mode 10262e4b17023SJohn Marino@var{mode} in the named address space @var{as}. The @var{strict} 10263e4b17023SJohn Marinoparameter says whether strict addressing is in effect after reload has 10264e4b17023SJohn Marinofinished. This target hook is the same as the 10265e4b17023SJohn Marino@code{TARGET_LEGITIMATE_ADDRESS_P} target hook, except that it includes 10266e4b17023SJohn Marinoexplicit named address space support. 10267e4b17023SJohn Marino@end deftypefn 10268e4b17023SJohn Marino 10269e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS (rtx @var{x}, rtx @var{oldx}, enum machine_mode @var{mode}, addr_space_t @var{as}) 10270e4b17023SJohn MarinoDefine this to modify an invalid address @var{x} to be a valid address 10271e4b17023SJohn Marinowith mode @var{mode} in the named address space @var{as}. This target 10272e4b17023SJohn Marinohook is the same as the @code{TARGET_LEGITIMIZE_ADDRESS} target hook, 10273e4b17023SJohn Marinoexcept that it includes explicit named address space support. 10274e4b17023SJohn Marino@end deftypefn 10275e4b17023SJohn Marino 10276e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ADDR_SPACE_SUBSET_P (addr_space_t @var{subset}, addr_space_t @var{superset}) 10277e4b17023SJohn MarinoDefine this to return whether the @var{subset} named address space is 10278e4b17023SJohn Marinocontained within the @var{superset} named address space. Pointers to 10279e4b17023SJohn Marinoa named address space that is a subset of another named address space 10280e4b17023SJohn Marinowill be converted automatically without a cast if used together in 10281e4b17023SJohn Marinoarithmetic operations. Pointers to a superset address space can be 10282e4b17023SJohn Marinoconverted to pointers to a subset address space via explicit casts. 10283e4b17023SJohn Marino@end deftypefn 10284e4b17023SJohn Marino 10285e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_ADDR_SPACE_CONVERT (rtx @var{op}, tree @var{from_type}, tree @var{to_type}) 10286e4b17023SJohn MarinoDefine this to convert the pointer expression represented by the RTL 10287e4b17023SJohn Marino@var{op} with type @var{from_type} that points to a named address 10288e4b17023SJohn Marinospace to a new pointer expression with type @var{to_type} that points 10289e4b17023SJohn Marinoto a different named address space. When this hook it called, it is 10290e4b17023SJohn Marinoguaranteed that one of the two address spaces is a subset of the other, 10291e4b17023SJohn Marinoas determined by the @code{TARGET_ADDR_SPACE_SUBSET_P} target hook. 10292e4b17023SJohn Marino@end deftypefn 10293e4b17023SJohn Marino 10294e4b17023SJohn Marino@node Misc 10295e4b17023SJohn Marino@section Miscellaneous Parameters 10296e4b17023SJohn Marino@cindex parameters, miscellaneous 10297e4b17023SJohn Marino 10298e4b17023SJohn Marino@c prevent bad page break with this line 10299e4b17023SJohn MarinoHere are several miscellaneous parameters. 10300e4b17023SJohn Marino 10301e4b17023SJohn Marino@defmac HAS_LONG_COND_BRANCH 10302e4b17023SJohn MarinoDefine this boolean macro to indicate whether or not your architecture 10303e4b17023SJohn Marinohas conditional branches that can span all of memory. It is used in 10304e4b17023SJohn Marinoconjunction with an optimization that partitions hot and cold basic 10305e4b17023SJohn Marinoblocks into separate sections of the executable. If this macro is 10306e4b17023SJohn Marinoset to false, gcc will convert any conditional branches that attempt 10307e4b17023SJohn Marinoto cross between sections into unconditional branches or indirect jumps. 10308e4b17023SJohn Marino@end defmac 10309e4b17023SJohn Marino 10310e4b17023SJohn Marino@defmac HAS_LONG_UNCOND_BRANCH 10311e4b17023SJohn MarinoDefine this boolean macro to indicate whether or not your architecture 10312e4b17023SJohn Marinohas unconditional branches that can span all of memory. It is used in 10313e4b17023SJohn Marinoconjunction with an optimization that partitions hot and cold basic 10314e4b17023SJohn Marinoblocks into separate sections of the executable. If this macro is 10315e4b17023SJohn Marinoset to false, gcc will convert any unconditional branches that attempt 10316e4b17023SJohn Marinoto cross between sections into indirect jumps. 10317e4b17023SJohn Marino@end defmac 10318e4b17023SJohn Marino 10319e4b17023SJohn Marino@defmac CASE_VECTOR_MODE 10320e4b17023SJohn MarinoAn alias for a machine mode name. This is the machine mode that 10321e4b17023SJohn Marinoelements of a jump-table should have. 10322e4b17023SJohn Marino@end defmac 10323e4b17023SJohn Marino 10324e4b17023SJohn Marino@defmac CASE_VECTOR_SHORTEN_MODE (@var{min_offset}, @var{max_offset}, @var{body}) 10325e4b17023SJohn MarinoOptional: return the preferred mode for an @code{addr_diff_vec} 10326e4b17023SJohn Marinowhen the minimum and maximum offset are known. If you define this, 10327e4b17023SJohn Marinoit enables extra code in branch shortening to deal with @code{addr_diff_vec}. 10328e4b17023SJohn MarinoTo make this work, you also have to define @code{INSN_ALIGN} and 10329e4b17023SJohn Marinomake the alignment for @code{addr_diff_vec} explicit. 10330e4b17023SJohn MarinoThe @var{body} argument is provided so that the offset_unsigned and scale 10331e4b17023SJohn Marinoflags can be updated. 10332e4b17023SJohn Marino@end defmac 10333e4b17023SJohn Marino 10334e4b17023SJohn Marino@defmac CASE_VECTOR_PC_RELATIVE 10335e4b17023SJohn MarinoDefine this macro to be a C expression to indicate when jump-tables 10336e4b17023SJohn Marinoshould contain relative addresses. You need not define this macro if 10337e4b17023SJohn Marinojump-tables never contain relative addresses, or jump-tables should 10338e4b17023SJohn Marinocontain relative addresses only when @option{-fPIC} or @option{-fPIC} 10339e4b17023SJohn Marinois in effect. 10340e4b17023SJohn Marino@end defmac 10341e4b17023SJohn Marino 10342e4b17023SJohn Marino@deftypefn {Target Hook} {unsigned int} TARGET_CASE_VALUES_THRESHOLD (void) 10343e4b17023SJohn MarinoThis function return the smallest number of different values for which it 10344e4b17023SJohn Marinois best to use a jump-table instead of a tree of conditional branches. 10345e4b17023SJohn MarinoThe default is four for machines with a @code{casesi} instruction and 10346e4b17023SJohn Marinofive otherwise. This is best for most machines. 10347e4b17023SJohn Marino@end deftypefn 10348e4b17023SJohn Marino 10349e4b17023SJohn Marino@defmac CASE_USE_BIT_TESTS 10350e4b17023SJohn MarinoDefine this macro to be a C expression to indicate whether C switch 10351e4b17023SJohn Marinostatements may be implemented by a sequence of bit tests. This is 10352e4b17023SJohn Marinoadvantageous on processors that can efficiently implement left shift 10353e4b17023SJohn Marinoof 1 by the number of bits held in a register, but inappropriate on 10354e4b17023SJohn Marinotargets that would require a loop. By default, this macro returns 10355e4b17023SJohn Marino@code{true} if the target defines an @code{ashlsi3} pattern, and 10356e4b17023SJohn Marino@code{false} otherwise. 10357e4b17023SJohn Marino@end defmac 10358e4b17023SJohn Marino 10359e4b17023SJohn Marino@defmac WORD_REGISTER_OPERATIONS 10360e4b17023SJohn MarinoDefine this macro if operations between registers with integral mode 10361e4b17023SJohn Marinosmaller than a word are always performed on the entire register. 10362e4b17023SJohn MarinoMost RISC machines have this property and most CISC machines do not. 10363e4b17023SJohn Marino@end defmac 10364e4b17023SJohn Marino 10365e4b17023SJohn Marino@defmac LOAD_EXTEND_OP (@var{mem_mode}) 10366e4b17023SJohn MarinoDefine this macro to be a C expression indicating when insns that read 10367e4b17023SJohn Marinomemory in @var{mem_mode}, an integral mode narrower than a word, set the 10368e4b17023SJohn Marinobits outside of @var{mem_mode} to be either the sign-extension or the 10369e4b17023SJohn Marinozero-extension of the data read. Return @code{SIGN_EXTEND} for values 10370e4b17023SJohn Marinoof @var{mem_mode} for which the 10371e4b17023SJohn Marinoinsn sign-extends, @code{ZERO_EXTEND} for which it zero-extends, and 10372e4b17023SJohn Marino@code{UNKNOWN} for other modes. 10373e4b17023SJohn Marino 10374e4b17023SJohn MarinoThis macro is not called with @var{mem_mode} non-integral or with a width 10375e4b17023SJohn Marinogreater than or equal to @code{BITS_PER_WORD}, so you may return any 10376e4b17023SJohn Marinovalue in this case. Do not define this macro if it would always return 10377e4b17023SJohn Marino@code{UNKNOWN}. On machines where this macro is defined, you will normally 10378e4b17023SJohn Marinodefine it as the constant @code{SIGN_EXTEND} or @code{ZERO_EXTEND}. 10379e4b17023SJohn Marino 10380e4b17023SJohn MarinoYou may return a non-@code{UNKNOWN} value even if for some hard registers 10381e4b17023SJohn Marinothe sign extension is not performed, if for the @code{REGNO_REG_CLASS} 10382e4b17023SJohn Marinoof these hard registers @code{CANNOT_CHANGE_MODE_CLASS} returns nonzero 10383e4b17023SJohn Marinowhen the @var{from} mode is @var{mem_mode} and the @var{to} mode is any 10384e4b17023SJohn Marinointegral mode larger than this but not larger than @code{word_mode}. 10385e4b17023SJohn Marino 10386e4b17023SJohn MarinoYou must return @code{UNKNOWN} if for some hard registers that allow this 10387e4b17023SJohn Marinomode, @code{CANNOT_CHANGE_MODE_CLASS} says that they cannot change to 10388e4b17023SJohn Marino@code{word_mode}, but that they can change to another integral mode that 10389e4b17023SJohn Marinois larger then @var{mem_mode} but still smaller than @code{word_mode}. 10390e4b17023SJohn Marino@end defmac 10391e4b17023SJohn Marino 10392e4b17023SJohn Marino@defmac SHORT_IMMEDIATES_SIGN_EXTEND 10393e4b17023SJohn MarinoDefine this macro if loading short immediate values into registers sign 10394e4b17023SJohn Marinoextends. 10395e4b17023SJohn Marino@end defmac 10396e4b17023SJohn Marino 10397e4b17023SJohn Marino@defmac FIXUNS_TRUNC_LIKE_FIX_TRUNC 10398e4b17023SJohn MarinoDefine this macro if the same instructions that convert a floating 10399e4b17023SJohn Marinopoint number to a signed fixed point number also convert validly to an 10400e4b17023SJohn Marinounsigned one. 10401e4b17023SJohn Marino@end defmac 10402e4b17023SJohn Marino 10403e4b17023SJohn Marino@deftypefn {Target Hook} {unsigned int} TARGET_MIN_DIVISIONS_FOR_RECIP_MUL (enum machine_mode @var{mode}) 10404e4b17023SJohn MarinoWhen @option{-ffast-math} is in effect, GCC tries to optimize 10405e4b17023SJohn Marinodivisions by the same divisor, by turning them into multiplications by 10406e4b17023SJohn Marinothe reciprocal. This target hook specifies the minimum number of divisions 10407e4b17023SJohn Marinothat should be there for GCC to perform the optimization for a variable 10408e4b17023SJohn Marinoof mode @var{mode}. The default implementation returns 3 if the machine 10409e4b17023SJohn Marinohas an instruction for the division, and 2 if it does not. 10410e4b17023SJohn Marino@end deftypefn 10411e4b17023SJohn Marino 10412e4b17023SJohn Marino@defmac MOVE_MAX 10413e4b17023SJohn MarinoThe maximum number of bytes that a single instruction can move quickly 10414e4b17023SJohn Marinobetween memory and registers or between two memory locations. 10415e4b17023SJohn Marino@end defmac 10416e4b17023SJohn Marino 10417e4b17023SJohn Marino@defmac MAX_MOVE_MAX 10418e4b17023SJohn MarinoThe maximum number of bytes that a single instruction can move quickly 10419e4b17023SJohn Marinobetween memory and registers or between two memory locations. If this 10420e4b17023SJohn Marinois undefined, the default is @code{MOVE_MAX}. Otherwise, it is the 10421e4b17023SJohn Marinoconstant value that is the largest value that @code{MOVE_MAX} can have 10422e4b17023SJohn Marinoat run-time. 10423e4b17023SJohn Marino@end defmac 10424e4b17023SJohn Marino 10425e4b17023SJohn Marino@defmac SHIFT_COUNT_TRUNCATED 10426e4b17023SJohn MarinoA C expression that is nonzero if on this machine the number of bits 10427e4b17023SJohn Marinoactually used for the count of a shift operation is equal to the number 10428e4b17023SJohn Marinoof bits needed to represent the size of the object being shifted. When 10429e4b17023SJohn Marinothis macro is nonzero, the compiler will assume that it is safe to omit 10430e4b17023SJohn Marinoa sign-extend, zero-extend, and certain bitwise `and' instructions that 10431e4b17023SJohn Marinotruncates the count of a shift operation. On machines that have 10432e4b17023SJohn Marinoinstructions that act on bit-fields at variable positions, which may 10433e4b17023SJohn Marinoinclude `bit test' instructions, a nonzero @code{SHIFT_COUNT_TRUNCATED} 10434e4b17023SJohn Marinoalso enables deletion of truncations of the values that serve as 10435e4b17023SJohn Marinoarguments to bit-field instructions. 10436e4b17023SJohn Marino 10437e4b17023SJohn MarinoIf both types of instructions truncate the count (for shifts) and 10438e4b17023SJohn Marinoposition (for bit-field operations), or if no variable-position bit-field 10439e4b17023SJohn Marinoinstructions exist, you should define this macro. 10440e4b17023SJohn Marino 10441e4b17023SJohn MarinoHowever, on some machines, such as the 80386 and the 680x0, truncation 10442e4b17023SJohn Marinoonly applies to shift operations and not the (real or pretended) 10443e4b17023SJohn Marinobit-field operations. Define @code{SHIFT_COUNT_TRUNCATED} to be zero on 10444e4b17023SJohn Marinosuch machines. Instead, add patterns to the @file{md} file that include 10445e4b17023SJohn Marinothe implied truncation of the shift instructions. 10446e4b17023SJohn Marino 10447e4b17023SJohn MarinoYou need not define this macro if it would always have the value of zero. 10448e4b17023SJohn Marino@end defmac 10449e4b17023SJohn Marino 10450e4b17023SJohn Marino@anchor{TARGET_SHIFT_TRUNCATION_MASK} 10451e4b17023SJohn Marino@deftypefn {Target Hook} {unsigned HOST_WIDE_INT} TARGET_SHIFT_TRUNCATION_MASK (enum machine_mode @var{mode}) 10452e4b17023SJohn MarinoThis function describes how the standard shift patterns for @var{mode} 10453e4b17023SJohn Marinodeal with shifts by negative amounts or by more than the width of the mode. 10454e4b17023SJohn Marino@xref{shift patterns}. 10455e4b17023SJohn Marino 10456e4b17023SJohn MarinoOn many machines, the shift patterns will apply a mask @var{m} to the 10457e4b17023SJohn Marinoshift count, meaning that a fixed-width shift of @var{x} by @var{y} is 10458e4b17023SJohn Marinoequivalent to an arbitrary-width shift of @var{x} by @var{y & m}. If 10459e4b17023SJohn Marinothis is true for mode @var{mode}, the function should return @var{m}, 10460e4b17023SJohn Marinootherwise it should return 0. A return value of 0 indicates that no 10461e4b17023SJohn Marinoparticular behavior is guaranteed. 10462e4b17023SJohn Marino 10463e4b17023SJohn MarinoNote that, unlike @code{SHIFT_COUNT_TRUNCATED}, this function does 10464e4b17023SJohn Marino@emph{not} apply to general shift rtxes; it applies only to instructions 10465e4b17023SJohn Marinothat are generated by the named shift patterns. 10466e4b17023SJohn Marino 10467e4b17023SJohn MarinoThe default implementation of this function returns 10468e4b17023SJohn Marino@code{GET_MODE_BITSIZE (@var{mode}) - 1} if @code{SHIFT_COUNT_TRUNCATED} 10469e4b17023SJohn Marinoand 0 otherwise. This definition is always safe, but if 10470e4b17023SJohn Marino@code{SHIFT_COUNT_TRUNCATED} is false, and some shift patterns 10471e4b17023SJohn Marinonevertheless truncate the shift count, you may get better code 10472e4b17023SJohn Marinoby overriding it. 10473e4b17023SJohn Marino@end deftypefn 10474e4b17023SJohn Marino 10475e4b17023SJohn Marino@defmac TRULY_NOOP_TRUNCATION (@var{outprec}, @var{inprec}) 10476e4b17023SJohn MarinoA C expression which is nonzero if on this machine it is safe to 10477e4b17023SJohn Marino``convert'' an integer of @var{inprec} bits to one of @var{outprec} 10478e4b17023SJohn Marinobits (where @var{outprec} is smaller than @var{inprec}) by merely 10479e4b17023SJohn Marinooperating on it as if it had only @var{outprec} bits. 10480e4b17023SJohn Marino 10481e4b17023SJohn MarinoOn many machines, this expression can be 1. 10482e4b17023SJohn Marino 10483e4b17023SJohn Marino@c rearranged this, removed the phrase "it is reported that". this was 10484e4b17023SJohn Marino@c to fix an overfull hbox. --mew 10feb93 10485e4b17023SJohn MarinoWhen @code{TRULY_NOOP_TRUNCATION} returns 1 for a pair of sizes for 10486e4b17023SJohn Marinomodes for which @code{MODES_TIEABLE_P} is 0, suboptimal code can result. 10487e4b17023SJohn MarinoIf this is the case, making @code{TRULY_NOOP_TRUNCATION} return 0 in 10488e4b17023SJohn Marinosuch cases may improve things. 10489e4b17023SJohn Marino@end defmac 10490e4b17023SJohn Marino 10491e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_MODE_REP_EXTENDED (enum machine_mode @var{mode}, enum machine_mode @var{rep_mode}) 10492e4b17023SJohn MarinoThe representation of an integral mode can be such that the values 10493e4b17023SJohn Marinoare always extended to a wider integral mode. Return 10494e4b17023SJohn Marino@code{SIGN_EXTEND} if values of @var{mode} are represented in 10495e4b17023SJohn Marinosign-extended form to @var{rep_mode}. Return @code{UNKNOWN} 10496e4b17023SJohn Marinootherwise. (Currently, none of the targets use zero-extended 10497e4b17023SJohn Marinorepresentation this way so unlike @code{LOAD_EXTEND_OP}, 10498e4b17023SJohn Marino@code{TARGET_MODE_REP_EXTENDED} is expected to return either 10499e4b17023SJohn Marino@code{SIGN_EXTEND} or @code{UNKNOWN}. Also no target extends 10500e4b17023SJohn Marino@var{mode} to @var{rep_mode} so that @var{rep_mode} is not the next 10501e4b17023SJohn Marinowidest integral mode and currently we take advantage of this fact.) 10502e4b17023SJohn Marino 10503e4b17023SJohn MarinoSimilarly to @code{LOAD_EXTEND_OP} you may return a non-@code{UNKNOWN} 10504e4b17023SJohn Marinovalue even if the extension is not performed on certain hard registers 10505e4b17023SJohn Marinoas long as for the @code{REGNO_REG_CLASS} of these hard registers 10506e4b17023SJohn Marino@code{CANNOT_CHANGE_MODE_CLASS} returns nonzero. 10507e4b17023SJohn Marino 10508e4b17023SJohn MarinoNote that @code{TARGET_MODE_REP_EXTENDED} and @code{LOAD_EXTEND_OP} 10509e4b17023SJohn Marinodescribe two related properties. If you define 10510e4b17023SJohn Marino@code{TARGET_MODE_REP_EXTENDED (mode, word_mode)} you probably also want 10511e4b17023SJohn Marinoto define @code{LOAD_EXTEND_OP (mode)} to return the same type of 10512e4b17023SJohn Marinoextension. 10513e4b17023SJohn Marino 10514e4b17023SJohn MarinoIn order to enforce the representation of @code{mode}, 10515e4b17023SJohn Marino@code{TRULY_NOOP_TRUNCATION} should return false when truncating to 10516e4b17023SJohn Marino@code{mode}. 10517e4b17023SJohn Marino@end deftypefn 10518e4b17023SJohn Marino 10519e4b17023SJohn Marino@defmac STORE_FLAG_VALUE 10520e4b17023SJohn MarinoA C expression describing the value returned by a comparison operator 10521e4b17023SJohn Marinowith an integral mode and stored by a store-flag instruction 10522e4b17023SJohn Marino(@samp{cstore@var{mode}4}) when the condition is true. This description must 10523e4b17023SJohn Marinoapply to @emph{all} the @samp{cstore@var{mode}4} patterns and all the 10524e4b17023SJohn Marinocomparison operators whose results have a @code{MODE_INT} mode. 10525e4b17023SJohn Marino 10526e4b17023SJohn MarinoA value of 1 or @minus{}1 means that the instruction implementing the 10527e4b17023SJohn Marinocomparison operator returns exactly 1 or @minus{}1 when the comparison is true 10528e4b17023SJohn Marinoand 0 when the comparison is false. Otherwise, the value indicates 10529e4b17023SJohn Marinowhich bits of the result are guaranteed to be 1 when the comparison is 10530e4b17023SJohn Marinotrue. This value is interpreted in the mode of the comparison 10531e4b17023SJohn Marinooperation, which is given by the mode of the first operand in the 10532e4b17023SJohn Marino@samp{cstore@var{mode}4} pattern. Either the low bit or the sign bit of 10533e4b17023SJohn Marino@code{STORE_FLAG_VALUE} be on. Presently, only those bits are used by 10534e4b17023SJohn Marinothe compiler. 10535e4b17023SJohn Marino 10536e4b17023SJohn MarinoIf @code{STORE_FLAG_VALUE} is neither 1 or @minus{}1, the compiler will 10537e4b17023SJohn Marinogenerate code that depends only on the specified bits. It can also 10538e4b17023SJohn Marinoreplace comparison operators with equivalent operations if they cause 10539e4b17023SJohn Marinothe required bits to be set, even if the remaining bits are undefined. 10540e4b17023SJohn MarinoFor example, on a machine whose comparison operators return an 10541e4b17023SJohn Marino@code{SImode} value and where @code{STORE_FLAG_VALUE} is defined as 10542e4b17023SJohn Marino@samp{0x80000000}, saying that just the sign bit is relevant, the 10543e4b17023SJohn Marinoexpression 10544e4b17023SJohn Marino 10545e4b17023SJohn Marino@smallexample 10546e4b17023SJohn Marino(ne:SI (and:SI @var{x} (const_int @var{power-of-2})) (const_int 0)) 10547e4b17023SJohn Marino@end smallexample 10548e4b17023SJohn Marino 10549e4b17023SJohn Marino@noindent 10550e4b17023SJohn Marinocan be converted to 10551e4b17023SJohn Marino 10552e4b17023SJohn Marino@smallexample 10553e4b17023SJohn Marino(ashift:SI @var{x} (const_int @var{n})) 10554e4b17023SJohn Marino@end smallexample 10555e4b17023SJohn Marino 10556e4b17023SJohn Marino@noindent 10557e4b17023SJohn Marinowhere @var{n} is the appropriate shift count to move the bit being 10558e4b17023SJohn Marinotested into the sign bit. 10559e4b17023SJohn Marino 10560e4b17023SJohn MarinoThere is no way to describe a machine that always sets the low-order bit 10561e4b17023SJohn Marinofor a true value, but does not guarantee the value of any other bits, 10562e4b17023SJohn Marinobut we do not know of any machine that has such an instruction. If you 10563e4b17023SJohn Marinoare trying to port GCC to such a machine, include an instruction to 10564e4b17023SJohn Marinoperform a logical-and of the result with 1 in the pattern for the 10565e4b17023SJohn Marinocomparison operators and let us know at @email{gcc@@gcc.gnu.org}. 10566e4b17023SJohn Marino 10567e4b17023SJohn MarinoOften, a machine will have multiple instructions that obtain a value 10568e4b17023SJohn Marinofrom a comparison (or the condition codes). Here are rules to guide the 10569e4b17023SJohn Marinochoice of value for @code{STORE_FLAG_VALUE}, and hence the instructions 10570e4b17023SJohn Marinoto be used: 10571e4b17023SJohn Marino 10572e4b17023SJohn Marino@itemize @bullet 10573e4b17023SJohn Marino@item 10574e4b17023SJohn MarinoUse the shortest sequence that yields a valid definition for 10575e4b17023SJohn Marino@code{STORE_FLAG_VALUE}. It is more efficient for the compiler to 10576e4b17023SJohn Marino``normalize'' the value (convert it to, e.g., 1 or 0) than for the 10577e4b17023SJohn Marinocomparison operators to do so because there may be opportunities to 10578e4b17023SJohn Marinocombine the normalization with other operations. 10579e4b17023SJohn Marino 10580e4b17023SJohn Marino@item 10581e4b17023SJohn MarinoFor equal-length sequences, use a value of 1 or @minus{}1, with @minus{}1 being 10582e4b17023SJohn Marinoslightly preferred on machines with expensive jumps and 1 preferred on 10583e4b17023SJohn Marinoother machines. 10584e4b17023SJohn Marino 10585e4b17023SJohn Marino@item 10586e4b17023SJohn MarinoAs a second choice, choose a value of @samp{0x80000001} if instructions 10587e4b17023SJohn Marinoexist that set both the sign and low-order bits but do not define the 10588e4b17023SJohn Marinoothers. 10589e4b17023SJohn Marino 10590e4b17023SJohn Marino@item 10591e4b17023SJohn MarinoOtherwise, use a value of @samp{0x80000000}. 10592e4b17023SJohn Marino@end itemize 10593e4b17023SJohn Marino 10594e4b17023SJohn MarinoMany machines can produce both the value chosen for 10595e4b17023SJohn Marino@code{STORE_FLAG_VALUE} and its negation in the same number of 10596e4b17023SJohn Marinoinstructions. On those machines, you should also define a pattern for 10597e4b17023SJohn Marinothose cases, e.g., one matching 10598e4b17023SJohn Marino 10599e4b17023SJohn Marino@smallexample 10600e4b17023SJohn Marino(set @var{A} (neg:@var{m} (ne:@var{m} @var{B} @var{C}))) 10601e4b17023SJohn Marino@end smallexample 10602e4b17023SJohn Marino 10603e4b17023SJohn MarinoSome machines can also perform @code{and} or @code{plus} operations on 10604e4b17023SJohn Marinocondition code values with less instructions than the corresponding 10605e4b17023SJohn Marino@samp{cstore@var{mode}4} insn followed by @code{and} or @code{plus}. On those 10606e4b17023SJohn Marinomachines, define the appropriate patterns. Use the names @code{incscc} 10607e4b17023SJohn Marinoand @code{decscc}, respectively, for the patterns which perform 10608e4b17023SJohn Marino@code{plus} or @code{minus} operations on condition code values. See 10609e4b17023SJohn Marino@file{rs6000.md} for some examples. The GNU Superoptimizer can be used to 10610e4b17023SJohn Marinofind such instruction sequences on other machines. 10611e4b17023SJohn Marino 10612e4b17023SJohn MarinoIf this macro is not defined, the default value, 1, is used. You need 10613e4b17023SJohn Marinonot define @code{STORE_FLAG_VALUE} if the machine has no store-flag 10614e4b17023SJohn Marinoinstructions, or if the value generated by these instructions is 1. 10615e4b17023SJohn Marino@end defmac 10616e4b17023SJohn Marino 10617e4b17023SJohn Marino@defmac FLOAT_STORE_FLAG_VALUE (@var{mode}) 10618e4b17023SJohn MarinoA C expression that gives a nonzero @code{REAL_VALUE_TYPE} value that is 10619e4b17023SJohn Marinoreturned when comparison operators with floating-point results are true. 10620e4b17023SJohn MarinoDefine this macro on machines that have comparison operations that return 10621e4b17023SJohn Marinofloating-point values. If there are no such operations, do not define 10622e4b17023SJohn Marinothis macro. 10623e4b17023SJohn Marino@end defmac 10624e4b17023SJohn Marino 10625e4b17023SJohn Marino@defmac VECTOR_STORE_FLAG_VALUE (@var{mode}) 10626e4b17023SJohn MarinoA C expression that gives a rtx representing the nonzero true element 10627e4b17023SJohn Marinofor vector comparisons. The returned rtx should be valid for the inner 10628e4b17023SJohn Marinomode of @var{mode} which is guaranteed to be a vector mode. Define 10629e4b17023SJohn Marinothis macro on machines that have vector comparison operations that 10630e4b17023SJohn Marinoreturn a vector result. If there are no such operations, do not define 10631e4b17023SJohn Marinothis macro. Typically, this macro is defined as @code{const1_rtx} or 10632e4b17023SJohn Marino@code{constm1_rtx}. This macro may return @code{NULL_RTX} to prevent 10633e4b17023SJohn Marinothe compiler optimizing such vector comparison operations for the 10634e4b17023SJohn Marinogiven mode. 10635e4b17023SJohn Marino@end defmac 10636e4b17023SJohn Marino 10637e4b17023SJohn Marino@defmac CLZ_DEFINED_VALUE_AT_ZERO (@var{mode}, @var{value}) 10638e4b17023SJohn Marino@defmacx CTZ_DEFINED_VALUE_AT_ZERO (@var{mode}, @var{value}) 10639e4b17023SJohn MarinoA C expression that indicates whether the architecture defines a value 10640e4b17023SJohn Marinofor @code{clz} or @code{ctz} with a zero operand. 10641e4b17023SJohn MarinoA result of @code{0} indicates the value is undefined. 10642e4b17023SJohn MarinoIf the value is defined for only the RTL expression, the macro should 10643e4b17023SJohn Marinoevaluate to @code{1}; if the value applies also to the corresponding optab 10644e4b17023SJohn Marinoentry (which is normally the case if it expands directly into 10645e4b17023SJohn Marinothe corresponding RTL), then the macro should evaluate to @code{2}. 10646e4b17023SJohn MarinoIn the cases where the value is defined, @var{value} should be set to 10647e4b17023SJohn Marinothis value. 10648e4b17023SJohn Marino 10649e4b17023SJohn MarinoIf this macro is not defined, the value of @code{clz} or 10650e4b17023SJohn Marino@code{ctz} at zero is assumed to be undefined. 10651e4b17023SJohn Marino 10652e4b17023SJohn MarinoThis macro must be defined if the target's expansion for @code{ffs} 10653e4b17023SJohn Marinorelies on a particular value to get correct results. Otherwise it 10654e4b17023SJohn Marinois not necessary, though it may be used to optimize some corner cases, and 10655e4b17023SJohn Marinoto provide a default expansion for the @code{ffs} optab. 10656e4b17023SJohn Marino 10657e4b17023SJohn MarinoNote that regardless of this macro the ``definedness'' of @code{clz} 10658e4b17023SJohn Marinoand @code{ctz} at zero do @emph{not} extend to the builtin functions 10659e4b17023SJohn Marinovisible to the user. Thus one may be free to adjust the value at will 10660e4b17023SJohn Marinoto match the target expansion of these operations without fear of 10661e4b17023SJohn Marinobreaking the API@. 10662e4b17023SJohn Marino@end defmac 10663e4b17023SJohn Marino 10664e4b17023SJohn Marino@defmac Pmode 10665e4b17023SJohn MarinoAn alias for the machine mode for pointers. On most machines, define 10666e4b17023SJohn Marinothis to be the integer mode corresponding to the width of a hardware 10667e4b17023SJohn Marinopointer; @code{SImode} on 32-bit machine or @code{DImode} on 64-bit machines. 10668e4b17023SJohn MarinoOn some machines you must define this to be one of the partial integer 10669e4b17023SJohn Marinomodes, such as @code{PSImode}. 10670e4b17023SJohn Marino 10671e4b17023SJohn MarinoThe width of @code{Pmode} must be at least as large as the value of 10672e4b17023SJohn Marino@code{POINTER_SIZE}. If it is not equal, you must define the macro 10673e4b17023SJohn Marino@code{POINTERS_EXTEND_UNSIGNED} to specify how pointers are extended 10674e4b17023SJohn Marinoto @code{Pmode}. 10675e4b17023SJohn Marino@end defmac 10676e4b17023SJohn Marino 10677e4b17023SJohn Marino@defmac FUNCTION_MODE 10678e4b17023SJohn MarinoAn alias for the machine mode used for memory references to functions 10679e4b17023SJohn Marinobeing called, in @code{call} RTL expressions. On most CISC machines, 10680e4b17023SJohn Marinowhere an instruction can begin at any byte address, this should be 10681e4b17023SJohn Marino@code{QImode}. On most RISC machines, where all instructions have fixed 10682e4b17023SJohn Marinosize and alignment, this should be a mode with the same size and alignment 10683e4b17023SJohn Marinoas the machine instruction words - typically @code{SImode} or @code{HImode}. 10684e4b17023SJohn Marino@end defmac 10685e4b17023SJohn Marino 10686e4b17023SJohn Marino@defmac STDC_0_IN_SYSTEM_HEADERS 10687e4b17023SJohn MarinoIn normal operation, the preprocessor expands @code{__STDC__} to the 10688e4b17023SJohn Marinoconstant 1, to signify that GCC conforms to ISO Standard C@. On some 10689e4b17023SJohn Marinohosts, like Solaris, the system compiler uses a different convention, 10690e4b17023SJohn Marinowhere @code{__STDC__} is normally 0, but is 1 if the user specifies 10691e4b17023SJohn Marinostrict conformance to the C Standard. 10692e4b17023SJohn Marino 10693e4b17023SJohn MarinoDefining @code{STDC_0_IN_SYSTEM_HEADERS} makes GNU CPP follows the host 10694e4b17023SJohn Marinoconvention when processing system header files, but when processing user 10695e4b17023SJohn Marinofiles @code{__STDC__} will always expand to 1. 10696e4b17023SJohn Marino@end defmac 10697e4b17023SJohn Marino 10698e4b17023SJohn Marino@defmac NO_IMPLICIT_EXTERN_C 10699e4b17023SJohn MarinoDefine this macro if the system header files support C++ as well as C@. 10700e4b17023SJohn MarinoThis macro inhibits the usual method of using system header files in 10701e4b17023SJohn MarinoC++, which is to pretend that the file's contents are enclosed in 10702e4b17023SJohn Marino@samp{extern "C" @{@dots{}@}}. 10703e4b17023SJohn Marino@end defmac 10704e4b17023SJohn Marino 10705e4b17023SJohn Marino@findex #pragma 10706e4b17023SJohn Marino@findex pragma 10707e4b17023SJohn Marino@defmac REGISTER_TARGET_PRAGMAS () 10708e4b17023SJohn MarinoDefine this macro if you want to implement any target-specific pragmas. 10709e4b17023SJohn MarinoIf defined, it is a C expression which makes a series of calls to 10710e4b17023SJohn Marino@code{c_register_pragma} or @code{c_register_pragma_with_expansion} 10711e4b17023SJohn Marinofor each pragma. The macro may also do any 10712e4b17023SJohn Marinosetup required for the pragmas. 10713e4b17023SJohn Marino 10714e4b17023SJohn MarinoThe primary reason to define this macro is to provide compatibility with 10715e4b17023SJohn Marinoother compilers for the same target. In general, we discourage 10716e4b17023SJohn Marinodefinition of target-specific pragmas for GCC@. 10717e4b17023SJohn Marino 10718e4b17023SJohn MarinoIf the pragma can be implemented by attributes then you should consider 10719e4b17023SJohn Marinodefining the target hook @samp{TARGET_INSERT_ATTRIBUTES} as well. 10720e4b17023SJohn Marino 10721e4b17023SJohn MarinoPreprocessor macros that appear on pragma lines are not expanded. All 10722e4b17023SJohn Marino@samp{#pragma} directives that do not match any registered pragma are 10723e4b17023SJohn Marinosilently ignored, unless the user specifies @option{-Wunknown-pragmas}. 10724e4b17023SJohn Marino@end defmac 10725e4b17023SJohn Marino 10726e4b17023SJohn Marino@deftypefun void c_register_pragma (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *)) 10727e4b17023SJohn Marino@deftypefunx void c_register_pragma_with_expansion (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *)) 10728e4b17023SJohn Marino 10729e4b17023SJohn MarinoEach call to @code{c_register_pragma} or 10730e4b17023SJohn Marino@code{c_register_pragma_with_expansion} establishes one pragma. The 10731e4b17023SJohn Marino@var{callback} routine will be called when the preprocessor encounters a 10732e4b17023SJohn Marinopragma of the form 10733e4b17023SJohn Marino 10734e4b17023SJohn Marino@smallexample 10735e4b17023SJohn Marino#pragma [@var{space}] @var{name} @dots{} 10736e4b17023SJohn Marino@end smallexample 10737e4b17023SJohn Marino 10738e4b17023SJohn Marino@var{space} is the case-sensitive namespace of the pragma, or 10739e4b17023SJohn Marino@code{NULL} to put the pragma in the global namespace. The callback 10740e4b17023SJohn Marinoroutine receives @var{pfile} as its first argument, which can be passed 10741e4b17023SJohn Marinoon to cpplib's functions if necessary. You can lex tokens after the 10742e4b17023SJohn Marino@var{name} by calling @code{pragma_lex}. Tokens that are not read by the 10743e4b17023SJohn Marinocallback will be silently ignored. The end of the line is indicated by 10744e4b17023SJohn Marinoa token of type @code{CPP_EOF}. Macro expansion occurs on the 10745e4b17023SJohn Marinoarguments of pragmas registered with 10746e4b17023SJohn Marino@code{c_register_pragma_with_expansion} but not on the arguments of 10747e4b17023SJohn Marinopragmas registered with @code{c_register_pragma}. 10748e4b17023SJohn Marino 10749e4b17023SJohn MarinoNote that the use of @code{pragma_lex} is specific to the C and C++ 10750e4b17023SJohn Marinocompilers. It will not work in the Java or Fortran compilers, or any 10751e4b17023SJohn Marinoother language compilers for that matter. Thus if @code{pragma_lex} is going 10752e4b17023SJohn Marinoto be called from target-specific code, it must only be done so when 10753e4b17023SJohn Marinobuilding the C and C++ compilers. This can be done by defining the 10754e4b17023SJohn Marinovariables @code{c_target_objs} and @code{cxx_target_objs} in the 10755e4b17023SJohn Marinotarget entry in the @file{config.gcc} file. These variables should name 10756e4b17023SJohn Marinothe target-specific, language-specific object file which contains the 10757e4b17023SJohn Marinocode that uses @code{pragma_lex}. Note it will also be necessary to add a 10758e4b17023SJohn Marinorule to the makefile fragment pointed to by @code{tmake_file} that shows 10759e4b17023SJohn Marinohow to build this object file. 10760e4b17023SJohn Marino@end deftypefun 10761e4b17023SJohn Marino 10762e4b17023SJohn Marino@defmac HANDLE_PRAGMA_PACK_WITH_EXPANSION 10763e4b17023SJohn MarinoDefine this macro if macros should be expanded in the 10764e4b17023SJohn Marinoarguments of @samp{#pragma pack}. 10765e4b17023SJohn Marino@end defmac 10766e4b17023SJohn Marino 10767e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_HANDLE_PRAGMA_EXTERN_PREFIX 10768e4b17023SJohn MarinoTrue if @code{#pragma extern_prefix} is to be supported. 10769e4b17023SJohn Marino@end deftypevr 10770e4b17023SJohn Marino 10771e4b17023SJohn Marino@defmac TARGET_DEFAULT_PACK_STRUCT 10772e4b17023SJohn MarinoIf your target requires a structure packing default other than 0 (meaning 10773e4b17023SJohn Marinothe machine default), define this macro to the necessary value (in bytes). 10774e4b17023SJohn MarinoThis must be a value that would also be valid to use with 10775e4b17023SJohn Marino@samp{#pragma pack()} (that is, a small power of two). 10776e4b17023SJohn Marino@end defmac 10777e4b17023SJohn Marino 10778e4b17023SJohn Marino@defmac DOLLARS_IN_IDENTIFIERS 10779e4b17023SJohn MarinoDefine this macro to control use of the character @samp{$} in 10780e4b17023SJohn Marinoidentifier names for the C family of languages. 0 means @samp{$} is 10781e4b17023SJohn Marinonot allowed by default; 1 means it is allowed. 1 is the default; 10782e4b17023SJohn Marinothere is no need to define this macro in that case. 10783e4b17023SJohn Marino@end defmac 10784e4b17023SJohn Marino 10785e4b17023SJohn Marino@defmac NO_DOLLAR_IN_LABEL 10786e4b17023SJohn MarinoDefine this macro if the assembler does not accept the character 10787e4b17023SJohn Marino@samp{$} in label names. By default constructors and destructors in 10788e4b17023SJohn MarinoG++ have @samp{$} in the identifiers. If this macro is defined, 10789e4b17023SJohn Marino@samp{.} is used instead. 10790e4b17023SJohn Marino@end defmac 10791e4b17023SJohn Marino 10792e4b17023SJohn Marino@defmac NO_DOT_IN_LABEL 10793e4b17023SJohn MarinoDefine this macro if the assembler does not accept the character 10794e4b17023SJohn Marino@samp{.} in label names. By default constructors and destructors in G++ 10795e4b17023SJohn Marinohave names that use @samp{.}. If this macro is defined, these names 10796e4b17023SJohn Marinoare rewritten to avoid @samp{.}. 10797e4b17023SJohn Marino@end defmac 10798e4b17023SJohn Marino 10799e4b17023SJohn Marino@defmac INSN_SETS_ARE_DELAYED (@var{insn}) 10800e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero if it is safe for the 10801e4b17023SJohn Marinodelay slot scheduler to place instructions in the delay slot of @var{insn}, 10802e4b17023SJohn Marinoeven if they appear to use a resource set or clobbered in @var{insn}. 10803e4b17023SJohn Marino@var{insn} is always a @code{jump_insn} or an @code{insn}; GCC knows that 10804e4b17023SJohn Marinoevery @code{call_insn} has this behavior. On machines where some @code{insn} 10805e4b17023SJohn Marinoor @code{jump_insn} is really a function call and hence has this behavior, 10806e4b17023SJohn Marinoyou should define this macro. 10807e4b17023SJohn Marino 10808e4b17023SJohn MarinoYou need not define this macro if it would always return zero. 10809e4b17023SJohn Marino@end defmac 10810e4b17023SJohn Marino 10811e4b17023SJohn Marino@defmac INSN_REFERENCES_ARE_DELAYED (@var{insn}) 10812e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero if it is safe for the 10813e4b17023SJohn Marinodelay slot scheduler to place instructions in the delay slot of @var{insn}, 10814e4b17023SJohn Marinoeven if they appear to set or clobber a resource referenced in @var{insn}. 10815e4b17023SJohn Marino@var{insn} is always a @code{jump_insn} or an @code{insn}. On machines where 10816e4b17023SJohn Marinosome @code{insn} or @code{jump_insn} is really a function call and its operands 10817e4b17023SJohn Marinoare registers whose use is actually in the subroutine it calls, you should 10818e4b17023SJohn Marinodefine this macro. Doing so allows the delay slot scheduler to move 10819e4b17023SJohn Marinoinstructions which copy arguments into the argument registers into the delay 10820e4b17023SJohn Marinoslot of @var{insn}. 10821e4b17023SJohn Marino 10822e4b17023SJohn MarinoYou need not define this macro if it would always return zero. 10823e4b17023SJohn Marino@end defmac 10824e4b17023SJohn Marino 10825e4b17023SJohn Marino@defmac MULTIPLE_SYMBOL_SPACES 10826e4b17023SJohn MarinoDefine this macro as a C expression that is nonzero if, in some cases, 10827e4b17023SJohn Marinoglobal symbols from one translation unit may not be bound to undefined 10828e4b17023SJohn Marinosymbols in another translation unit without user intervention. For 10829e4b17023SJohn Marinoinstance, under Microsoft Windows symbols must be explicitly imported 10830e4b17023SJohn Marinofrom shared libraries (DLLs). 10831e4b17023SJohn Marino 10832e4b17023SJohn MarinoYou need not define this macro if it would always evaluate to zero. 10833e4b17023SJohn Marino@end defmac 10834e4b17023SJohn Marino 10835e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_MD_ASM_CLOBBERS (tree @var{outputs}, tree @var{inputs}, tree @var{clobbers}) 10836e4b17023SJohn MarinoThis target hook should add to @var{clobbers} @code{STRING_CST} trees for 10837e4b17023SJohn Marinoany hard regs the port wishes to automatically clobber for an asm. 10838e4b17023SJohn MarinoIt should return the result of the last @code{tree_cons} used to add a 10839e4b17023SJohn Marinoclobber. The @var{outputs}, @var{inputs} and @var{clobber} lists are the 10840e4b17023SJohn Marinocorresponding parameters to the asm and may be inspected to avoid 10841e4b17023SJohn Marinoclobbering a register that is an input or output of the asm. You can use 10842e4b17023SJohn Marino@code{tree_overlaps_hard_reg_set}, declared in @file{tree.h}, to test 10843e4b17023SJohn Marinofor overlap with regards to asm-declared registers. 10844e4b17023SJohn Marino@end deftypefn 10845e4b17023SJohn Marino 10846e4b17023SJohn Marino@defmac MATH_LIBRARY 10847e4b17023SJohn MarinoDefine this macro as a C string constant for the linker argument to link 10848e4b17023SJohn Marinoin the system math library, minus the initial @samp{"-l"}, or 10849e4b17023SJohn Marino@samp{""} if the target does not have a 10850e4b17023SJohn Marinoseparate math library. 10851e4b17023SJohn Marino 10852e4b17023SJohn MarinoYou need only define this macro if the default of @samp{"m"} is wrong. 10853e4b17023SJohn Marino@end defmac 10854e4b17023SJohn Marino 10855e4b17023SJohn Marino@defmac LIBRARY_PATH_ENV 10856e4b17023SJohn MarinoDefine this macro as a C string constant for the environment variable that 10857e4b17023SJohn Marinospecifies where the linker should look for libraries. 10858e4b17023SJohn Marino 10859e4b17023SJohn MarinoYou need only define this macro if the default of @samp{"LIBRARY_PATH"} 10860e4b17023SJohn Marinois wrong. 10861e4b17023SJohn Marino@end defmac 10862e4b17023SJohn Marino 10863e4b17023SJohn Marino@defmac TARGET_POSIX_IO 10864e4b17023SJohn MarinoDefine this macro if the target supports the following POSIX@ file 10865e4b17023SJohn Marinofunctions, access, mkdir and file locking with fcntl / F_SETLKW@. 10866e4b17023SJohn MarinoDefining @code{TARGET_POSIX_IO} will enable the test coverage code 10867e4b17023SJohn Marinoto use file locking when exiting a program, which avoids race conditions 10868e4b17023SJohn Marinoif the program has forked. It will also create directories at run-time 10869e4b17023SJohn Marinofor cross-profiling. 10870e4b17023SJohn Marino@end defmac 10871e4b17023SJohn Marino 10872e4b17023SJohn Marino@defmac MAX_CONDITIONAL_EXECUTE 10873e4b17023SJohn Marino 10874e4b17023SJohn MarinoA C expression for the maximum number of instructions to execute via 10875e4b17023SJohn Marinoconditional execution instructions instead of a branch. A value of 10876e4b17023SJohn Marino@code{BRANCH_COST}+1 is the default if the machine does not use cc0, and 10877e4b17023SJohn Marino1 if it does use cc0. 10878e4b17023SJohn Marino@end defmac 10879e4b17023SJohn Marino 10880e4b17023SJohn Marino@defmac IFCVT_MODIFY_TESTS (@var{ce_info}, @var{true_expr}, @var{false_expr}) 10881e4b17023SJohn MarinoUsed if the target needs to perform machine-dependent modifications on the 10882e4b17023SJohn Marinoconditionals used for turning basic blocks into conditionally executed code. 10883e4b17023SJohn Marino@var{ce_info} points to a data structure, @code{struct ce_if_block}, which 10884e4b17023SJohn Marinocontains information about the currently processed blocks. @var{true_expr} 10885e4b17023SJohn Marinoand @var{false_expr} are the tests that are used for converting the 10886e4b17023SJohn Marinothen-block and the else-block, respectively. Set either @var{true_expr} or 10887e4b17023SJohn Marino@var{false_expr} to a null pointer if the tests cannot be converted. 10888e4b17023SJohn Marino@end defmac 10889e4b17023SJohn Marino 10890e4b17023SJohn Marino@defmac IFCVT_MODIFY_MULTIPLE_TESTS (@var{ce_info}, @var{bb}, @var{true_expr}, @var{false_expr}) 10891e4b17023SJohn MarinoLike @code{IFCVT_MODIFY_TESTS}, but used when converting more complicated 10892e4b17023SJohn Marinoif-statements into conditions combined by @code{and} and @code{or} operations. 10893e4b17023SJohn Marino@var{bb} contains the basic block that contains the test that is currently 10894e4b17023SJohn Marinobeing processed and about to be turned into a condition. 10895e4b17023SJohn Marino@end defmac 10896e4b17023SJohn Marino 10897e4b17023SJohn Marino@defmac IFCVT_MODIFY_INSN (@var{ce_info}, @var{pattern}, @var{insn}) 10898e4b17023SJohn MarinoA C expression to modify the @var{PATTERN} of an @var{INSN} that is to 10899e4b17023SJohn Marinobe converted to conditional execution format. @var{ce_info} points to 10900e4b17023SJohn Marinoa data structure, @code{struct ce_if_block}, which contains information 10901e4b17023SJohn Marinoabout the currently processed blocks. 10902e4b17023SJohn Marino@end defmac 10903e4b17023SJohn Marino 10904e4b17023SJohn Marino@defmac IFCVT_MODIFY_FINAL (@var{ce_info}) 10905e4b17023SJohn MarinoA C expression to perform any final machine dependent modifications in 10906e4b17023SJohn Marinoconverting code to conditional execution. The involved basic blocks 10907e4b17023SJohn Marinocan be found in the @code{struct ce_if_block} structure that is pointed 10908e4b17023SJohn Marinoto by @var{ce_info}. 10909e4b17023SJohn Marino@end defmac 10910e4b17023SJohn Marino 10911e4b17023SJohn Marino@defmac IFCVT_MODIFY_CANCEL (@var{ce_info}) 10912e4b17023SJohn MarinoA C expression to cancel any machine dependent modifications in 10913e4b17023SJohn Marinoconverting code to conditional execution. The involved basic blocks 10914e4b17023SJohn Marinocan be found in the @code{struct ce_if_block} structure that is pointed 10915e4b17023SJohn Marinoto by @var{ce_info}. 10916e4b17023SJohn Marino@end defmac 10917e4b17023SJohn Marino 10918e4b17023SJohn Marino@defmac IFCVT_INIT_EXTRA_FIELDS (@var{ce_info}) 10919e4b17023SJohn MarinoA C expression to initialize any extra fields in a @code{struct ce_if_block} 10920e4b17023SJohn Marinostructure, which are defined by the @code{IFCVT_EXTRA_FIELDS} macro. 10921e4b17023SJohn Marino@end defmac 10922e4b17023SJohn Marino 10923e4b17023SJohn Marino@defmac IFCVT_EXTRA_FIELDS 10924e4b17023SJohn MarinoIf defined, it should expand to a set of field declarations that will be 10925e4b17023SJohn Marinoadded to the @code{struct ce_if_block} structure. These should be initialized 10926e4b17023SJohn Marinoby the @code{IFCVT_INIT_EXTRA_FIELDS} macro. 10927e4b17023SJohn Marino@end defmac 10928e4b17023SJohn Marino 10929e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_MACHINE_DEPENDENT_REORG (void) 10930e4b17023SJohn MarinoIf non-null, this hook performs a target-specific pass over the 10931e4b17023SJohn Marinoinstruction stream. The compiler will run it at all optimization levels, 10932e4b17023SJohn Marinojust before the point at which it normally does delayed-branch scheduling. 10933e4b17023SJohn Marino 10934e4b17023SJohn MarinoThe exact purpose of the hook varies from target to target. Some use 10935e4b17023SJohn Marinoit to do transformations that are necessary for correctness, such as 10936e4b17023SJohn Marinolaying out in-function constant pools or avoiding hardware hazards. 10937e4b17023SJohn MarinoOthers use it as an opportunity to do some machine-dependent optimizations. 10938e4b17023SJohn Marino 10939e4b17023SJohn MarinoYou need not implement the hook if it has nothing to do. The default 10940e4b17023SJohn Marinodefinition is null. 10941e4b17023SJohn Marino@end deftypefn 10942e4b17023SJohn Marino 10943e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_INIT_BUILTINS (void) 10944e4b17023SJohn MarinoDefine this hook if you have any machine-specific built-in functions 10945e4b17023SJohn Marinothat need to be defined. It should be a function that performs the 10946e4b17023SJohn Marinonecessary setup. 10947e4b17023SJohn Marino 10948e4b17023SJohn MarinoMachine specific built-in functions can be useful to expand special machine 10949e4b17023SJohn Marinoinstructions that would otherwise not normally be generated because 10950e4b17023SJohn Marinothey have no equivalent in the source language (for example, SIMD vector 10951e4b17023SJohn Marinoinstructions or prefetch instructions). 10952e4b17023SJohn Marino 10953e4b17023SJohn MarinoTo create a built-in function, call the function 10954e4b17023SJohn Marino@code{lang_hooks.builtin_function} 10955e4b17023SJohn Marinowhich is defined by the language front end. You can use any type nodes set 10956e4b17023SJohn Marinoup by @code{build_common_tree_nodes}; 10957e4b17023SJohn Marinoonly language front ends that use those two functions will call 10958e4b17023SJohn Marino@samp{TARGET_INIT_BUILTINS}. 10959e4b17023SJohn Marino@end deftypefn 10960e4b17023SJohn Marino 10961e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_BUILTIN_DECL (unsigned @var{code}, bool @var{initialize_p}) 10962e4b17023SJohn MarinoDefine this hook if you have any machine-specific built-in functions 10963e4b17023SJohn Marinothat need to be defined. It should be a function that returns the 10964e4b17023SJohn Marinobuiltin function declaration for the builtin function code @var{code}. 10965e4b17023SJohn MarinoIf there is no such builtin and it cannot be initialized at this time 10966e4b17023SJohn Marinoif @var{initialize_p} is true the function should return @code{NULL_TREE}. 10967e4b17023SJohn MarinoIf @var{code} is out of range the function should return 10968e4b17023SJohn Marino@code{error_mark_node}. 10969e4b17023SJohn Marino@end deftypefn 10970e4b17023SJohn Marino 10971e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_EXPAND_BUILTIN (tree @var{exp}, rtx @var{target}, rtx @var{subtarget}, enum machine_mode @var{mode}, int @var{ignore}) 10972e4b17023SJohn Marino 10973e4b17023SJohn MarinoExpand a call to a machine specific built-in function that was set up by 10974e4b17023SJohn Marino@samp{TARGET_INIT_BUILTINS}. @var{exp} is the expression for the 10975e4b17023SJohn Marinofunction call; the result should go to @var{target} if that is 10976e4b17023SJohn Marinoconvenient, and have mode @var{mode} if that is convenient. 10977e4b17023SJohn Marino@var{subtarget} may be used as the target for computing one of 10978e4b17023SJohn Marino@var{exp}'s operands. @var{ignore} is nonzero if the value is to be 10979e4b17023SJohn Marinoignored. This function should return the result of the call to the 10980e4b17023SJohn Marinobuilt-in function. 10981e4b17023SJohn Marino@end deftypefn 10982e4b17023SJohn Marino 10983e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_RESOLVE_OVERLOADED_BUILTIN (unsigned int @var{loc}, tree @var{fndecl}, void *@var{arglist}) 10984e4b17023SJohn MarinoSelect a replacement for a machine specific built-in function that 10985e4b17023SJohn Marinowas set up by @samp{TARGET_INIT_BUILTINS}. This is done 10986e4b17023SJohn Marino@emph{before} regular type checking, and so allows the target to 10987e4b17023SJohn Marinoimplement a crude form of function overloading. @var{fndecl} is the 10988e4b17023SJohn Marinodeclaration of the built-in function. @var{arglist} is the list of 10989e4b17023SJohn Marinoarguments passed to the built-in function. The result is a 10990e4b17023SJohn Marinocomplete expression that implements the operation, usually 10991e4b17023SJohn Marinoanother @code{CALL_EXPR}. 10992e4b17023SJohn Marino@var{arglist} really has type @samp{VEC(tree,gc)*} 10993e4b17023SJohn Marino@end deftypefn 10994e4b17023SJohn Marino 10995e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_FOLD_BUILTIN (tree @var{fndecl}, int @var{n_args}, tree *@var{argp}, bool @var{ignore}) 10996e4b17023SJohn MarinoFold a call to a machine specific built-in function that was set up by 10997e4b17023SJohn Marino@samp{TARGET_INIT_BUILTINS}. @var{fndecl} is the declaration of the 10998e4b17023SJohn Marinobuilt-in function. @var{n_args} is the number of arguments passed to 10999e4b17023SJohn Marinothe function; the arguments themselves are pointed to by @var{argp}. 11000e4b17023SJohn MarinoThe result is another tree containing a simplified expression for the 11001e4b17023SJohn Marinocall's result. If @var{ignore} is true the value will be ignored. 11002e4b17023SJohn Marino@end deftypefn 11003e4b17023SJohn Marino 11004e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_INVALID_WITHIN_DOLOOP (const_rtx @var{insn}) 11005e4b17023SJohn Marino 11006e4b17023SJohn MarinoTake an instruction in @var{insn} and return NULL if it is valid within a 11007e4b17023SJohn Marinolow-overhead loop, otherwise return a string explaining why doloop 11008e4b17023SJohn Marinocould not be applied. 11009e4b17023SJohn Marino 11010e4b17023SJohn MarinoMany targets use special registers for low-overhead looping. For any 11011e4b17023SJohn Marinoinstruction that clobbers these this function should return a string indicating 11012e4b17023SJohn Marinothe reason why the doloop could not be applied. 11013e4b17023SJohn MarinoBy default, the RTL loop optimizer does not use a present doloop pattern for 11014e4b17023SJohn Marinoloops containing function calls or branch on table instructions. 11015e4b17023SJohn Marino@end deftypefn 11016e4b17023SJohn Marino 11017e4b17023SJohn Marino@defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2}) 11018e4b17023SJohn Marino 11019e4b17023SJohn MarinoTake a branch insn in @var{branch1} and another in @var{branch2}. 11020e4b17023SJohn MarinoReturn true if redirecting @var{branch1} to the destination of 11021e4b17023SJohn Marino@var{branch2} is possible. 11022e4b17023SJohn Marino 11023e4b17023SJohn MarinoOn some targets, branches may have a limited range. Optimizing the 11024e4b17023SJohn Marinofilling of delay slots can result in branches being redirected, and this 11025e4b17023SJohn Marinomay in turn cause a branch offset to overflow. 11026e4b17023SJohn Marino@end defmac 11027e4b17023SJohn Marino 11028e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_COMMUTATIVE_P (const_rtx @var{x}, int @var{outer_code}) 11029e4b17023SJohn MarinoThis target hook returns @code{true} if @var{x} is considered to be commutative. 11030e4b17023SJohn MarinoUsually, this is just COMMUTATIVE_P (@var{x}), but the HP PA doesn't consider 11031e4b17023SJohn MarinoPLUS to be commutative inside a MEM@. @var{outer_code} is the rtx code 11032e4b17023SJohn Marinoof the enclosing rtl, if known, otherwise it is UNKNOWN. 11033e4b17023SJohn Marino@end deftypefn 11034e4b17023SJohn Marino 11035e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_ALLOCATE_INITIAL_VALUE (rtx @var{hard_reg}) 11036e4b17023SJohn Marino 11037e4b17023SJohn MarinoWhen the initial value of a hard register has been copied in a pseudo 11038e4b17023SJohn Marinoregister, it is often not necessary to actually allocate another register 11039e4b17023SJohn Marinoto this pseudo register, because the original hard register or a stack slot 11040e4b17023SJohn Marinoit has been saved into can be used. @code{TARGET_ALLOCATE_INITIAL_VALUE} 11041e4b17023SJohn Marinois called at the start of register allocation once for each hard register 11042e4b17023SJohn Marinothat had its initial value copied by using 11043e4b17023SJohn Marino@code{get_func_hard_reg_initial_val} or @code{get_hard_reg_initial_val}. 11044e4b17023SJohn MarinoPossible values are @code{NULL_RTX}, if you don't want 11045e4b17023SJohn Marinoto do any special allocation, a @code{REG} rtx---that would typically be 11046e4b17023SJohn Marinothe hard register itself, if it is known not to be clobbered---or a 11047e4b17023SJohn Marino@code{MEM}. 11048e4b17023SJohn MarinoIf you are returning a @code{MEM}, this is only a hint for the allocator; 11049e4b17023SJohn Marinoit might decide to use another register anyways. 11050e4b17023SJohn MarinoYou may use @code{current_function_leaf_function} in the hook, functions 11051e4b17023SJohn Marinothat use @code{REG_N_SETS}, to determine if the hard 11052e4b17023SJohn Marinoregister in question will not be clobbered. 11053e4b17023SJohn MarinoThe default value of this hook is @code{NULL}, which disables any special 11054e4b17023SJohn Marinoallocation. 11055e4b17023SJohn Marino@end deftypefn 11056e4b17023SJohn Marino 11057e4b17023SJohn Marino@deftypefn {Target Hook} int TARGET_UNSPEC_MAY_TRAP_P (const_rtx @var{x}, unsigned @var{flags}) 11058e4b17023SJohn MarinoThis target hook returns nonzero if @var{x}, an @code{unspec} or 11059e4b17023SJohn Marino@code{unspec_volatile} operation, might cause a trap. Targets can use 11060e4b17023SJohn Marinothis hook to enhance precision of analysis for @code{unspec} and 11061e4b17023SJohn Marino@code{unspec_volatile} operations. You may call @code{may_trap_p_1} 11062e4b17023SJohn Marinoto analyze inner elements of @var{x} in which case @var{flags} should be 11063e4b17023SJohn Marinopassed along. 11064e4b17023SJohn Marino@end deftypefn 11065e4b17023SJohn Marino 11066e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_SET_CURRENT_FUNCTION (tree @var{decl}) 11067e4b17023SJohn MarinoThe compiler invokes this hook whenever it changes its current function 11068e4b17023SJohn Marinocontext (@code{cfun}). You can define this function if 11069e4b17023SJohn Marinothe back end needs to perform any initialization or reset actions on a 11070e4b17023SJohn Marinoper-function basis. For example, it may be used to implement function 11071e4b17023SJohn Marinoattributes that affect register usage or code generation patterns. 11072e4b17023SJohn MarinoThe argument @var{decl} is the declaration for the new function context, 11073e4b17023SJohn Marinoand may be null to indicate that the compiler has left a function context 11074e4b17023SJohn Marinoand is returning to processing at the top level. 11075e4b17023SJohn MarinoThe default hook function does nothing. 11076e4b17023SJohn Marino 11077e4b17023SJohn MarinoGCC sets @code{cfun} to a dummy function context during initialization of 11078e4b17023SJohn Marinosome parts of the back end. The hook function is not invoked in this 11079e4b17023SJohn Marinosituation; you need not worry about the hook being invoked recursively, 11080e4b17023SJohn Marinoor when the back end is in a partially-initialized state. 11081e4b17023SJohn Marino@code{cfun} might be @code{NULL} to indicate processing at top level, 11082e4b17023SJohn Marinooutside of any function scope. 11083e4b17023SJohn Marino@end deftypefn 11084e4b17023SJohn Marino 11085e4b17023SJohn Marino@defmac TARGET_OBJECT_SUFFIX 11086e4b17023SJohn MarinoDefine this macro to be a C string representing the suffix for object 11087e4b17023SJohn Marinofiles on your target machine. If you do not define this macro, GCC will 11088e4b17023SJohn Marinouse @samp{.o} as the suffix for object files. 11089e4b17023SJohn Marino@end defmac 11090e4b17023SJohn Marino 11091e4b17023SJohn Marino@defmac TARGET_EXECUTABLE_SUFFIX 11092e4b17023SJohn MarinoDefine this macro to be a C string representing the suffix to be 11093e4b17023SJohn Marinoautomatically added to executable files on your target machine. If you 11094e4b17023SJohn Marinodo not define this macro, GCC will use the null string as the suffix for 11095e4b17023SJohn Marinoexecutable files. 11096e4b17023SJohn Marino@end defmac 11097e4b17023SJohn Marino 11098e4b17023SJohn Marino@defmac COLLECT_EXPORT_LIST 11099e4b17023SJohn MarinoIf defined, @code{collect2} will scan the individual object files 11100e4b17023SJohn Marinospecified on its command line and create an export list for the linker. 11101e4b17023SJohn MarinoDefine this macro for systems like AIX, where the linker discards 11102e4b17023SJohn Marinoobject files that are not referenced from @code{main} and uses export 11103e4b17023SJohn Marinolists. 11104e4b17023SJohn Marino@end defmac 11105e4b17023SJohn Marino 11106e4b17023SJohn Marino@defmac MODIFY_JNI_METHOD_CALL (@var{mdecl}) 11107e4b17023SJohn MarinoDefine this macro to a C expression representing a variant of the 11108e4b17023SJohn Marinomethod call @var{mdecl}, if Java Native Interface (JNI) methods 11109e4b17023SJohn Marinomust be invoked differently from other methods on your target. 11110e4b17023SJohn MarinoFor example, on 32-bit Microsoft Windows, JNI methods must be invoked using 11111e4b17023SJohn Marinothe @code{stdcall} calling convention and this macro is then 11112e4b17023SJohn Marinodefined as this expression: 11113e4b17023SJohn Marino 11114e4b17023SJohn Marino@smallexample 11115e4b17023SJohn Marinobuild_type_attribute_variant (@var{mdecl}, 11116e4b17023SJohn Marino build_tree_list 11117e4b17023SJohn Marino (get_identifier ("stdcall"), 11118e4b17023SJohn Marino NULL)) 11119e4b17023SJohn Marino@end smallexample 11120e4b17023SJohn Marino@end defmac 11121e4b17023SJohn Marino 11122e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_CANNOT_MODIFY_JUMPS_P (void) 11123e4b17023SJohn MarinoThis target hook returns @code{true} past the point in which new jump 11124e4b17023SJohn Marinoinstructions could be created. On machines that require a register for 11125e4b17023SJohn Marinoevery jump such as the SHmedia ISA of SH5, this point would typically be 11126e4b17023SJohn Marinoreload, so this target hook should be defined to a function such as: 11127e4b17023SJohn Marino 11128e4b17023SJohn Marino@smallexample 11129e4b17023SJohn Marinostatic bool 11130e4b17023SJohn Marinocannot_modify_jumps_past_reload_p () 11131e4b17023SJohn Marino@{ 11132e4b17023SJohn Marino return (reload_completed || reload_in_progress); 11133e4b17023SJohn Marino@} 11134e4b17023SJohn Marino@end smallexample 11135e4b17023SJohn Marino@end deftypefn 11136e4b17023SJohn Marino 11137e4b17023SJohn Marino@deftypefn {Target Hook} reg_class_t TARGET_BRANCH_TARGET_REGISTER_CLASS (void) 11138e4b17023SJohn MarinoThis target hook returns a register class for which branch target register 11139e4b17023SJohn Marinooptimizations should be applied. All registers in this class should be 11140e4b17023SJohn Marinousable interchangeably. After reload, registers in this class will be 11141e4b17023SJohn Marinore-allocated and loads will be hoisted out of loops and be subjected 11142e4b17023SJohn Marinoto inter-block scheduling. 11143e4b17023SJohn Marino@end deftypefn 11144e4b17023SJohn Marino 11145e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED (bool @var{after_prologue_epilogue_gen}) 11146e4b17023SJohn MarinoBranch target register optimization will by default exclude callee-saved 11147e4b17023SJohn Marinoregisters 11148e4b17023SJohn Marinothat are not already live during the current function; if this target hook 11149e4b17023SJohn Marinoreturns true, they will be included. The target code must than make sure 11150e4b17023SJohn Marinothat all target registers in the class returned by 11151e4b17023SJohn Marino@samp{TARGET_BRANCH_TARGET_REGISTER_CLASS} that might need saving are 11152e4b17023SJohn Marinosaved. @var{after_prologue_epilogue_gen} indicates if prologues and 11153e4b17023SJohn Marinoepilogues have already been generated. Note, even if you only return 11154e4b17023SJohn Marinotrue when @var{after_prologue_epilogue_gen} is false, you still are likely 11155e4b17023SJohn Marinoto have to make special provisions in @code{INITIAL_ELIMINATION_OFFSET} 11156e4b17023SJohn Marinoto reserve space for caller-saved target registers. 11157e4b17023SJohn Marino@end deftypefn 11158e4b17023SJohn Marino 11159e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_HAVE_CONDITIONAL_EXECUTION (void) 11160e4b17023SJohn MarinoThis target hook returns true if the target supports conditional execution. 11161e4b17023SJohn MarinoThis target hook is required only when the target has several different 11162e4b17023SJohn Marinomodes and they have different conditional execution capability, such as ARM. 11163e4b17023SJohn Marino@end deftypefn 11164e4b17023SJohn Marino 11165e4b17023SJohn Marino@deftypefn {Target Hook} unsigned TARGET_LOOP_UNROLL_ADJUST (unsigned @var{nunroll}, struct loop *@var{loop}) 11166e4b17023SJohn MarinoThis target hook returns a new value for the number of times @var{loop} 11167e4b17023SJohn Marinoshould be unrolled. The parameter @var{nunroll} is the number of times 11168e4b17023SJohn Marinothe loop is to be unrolled. The parameter @var{loop} is a pointer to 11169e4b17023SJohn Marinothe loop, which is going to be checked for unrolling. This target hook 11170e4b17023SJohn Marinois required only when the target has special constraints like maximum 11171e4b17023SJohn Marinonumber of memory accesses. 11172e4b17023SJohn Marino@end deftypefn 11173e4b17023SJohn Marino 11174e4b17023SJohn Marino@defmac POWI_MAX_MULTS 11175e4b17023SJohn MarinoIf defined, this macro is interpreted as a signed integer C expression 11176e4b17023SJohn Marinothat specifies the maximum number of floating point multiplications 11177e4b17023SJohn Marinothat should be emitted when expanding exponentiation by an integer 11178e4b17023SJohn Marinoconstant inline. When this value is defined, exponentiation requiring 11179e4b17023SJohn Marinomore than this number of multiplications is implemented by calling the 11180e4b17023SJohn Marinosystem library's @code{pow}, @code{powf} or @code{powl} routines. 11181e4b17023SJohn MarinoThe default value places no upper bound on the multiplication count. 11182e4b17023SJohn Marino@end defmac 11183e4b17023SJohn Marino 11184e4b17023SJohn Marino@deftypefn Macro void TARGET_EXTRA_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc}) 11185e4b17023SJohn MarinoThis target hook should register any extra include files for the 11186e4b17023SJohn Marinotarget. The parameter @var{stdinc} indicates if normal include files 11187e4b17023SJohn Marinoare present. The parameter @var{sysroot} is the system root directory. 11188e4b17023SJohn MarinoThe parameter @var{iprefix} is the prefix for the gcc directory. 11189e4b17023SJohn Marino@end deftypefn 11190e4b17023SJohn Marino 11191e4b17023SJohn Marino@deftypefn Macro void TARGET_EXTRA_PRE_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc}) 11192e4b17023SJohn MarinoThis target hook should register any extra include files for the 11193e4b17023SJohn Marinotarget before any standard headers. The parameter @var{stdinc} 11194e4b17023SJohn Marinoindicates if normal include files are present. The parameter 11195e4b17023SJohn Marino@var{sysroot} is the system root directory. The parameter 11196e4b17023SJohn Marino@var{iprefix} is the prefix for the gcc directory. 11197e4b17023SJohn Marino@end deftypefn 11198e4b17023SJohn Marino 11199e4b17023SJohn Marino@deftypefn Macro void TARGET_OPTF (char *@var{path}) 11200e4b17023SJohn MarinoThis target hook should register special include paths for the target. 11201e4b17023SJohn MarinoThe parameter @var{path} is the include to register. On Darwin 11202e4b17023SJohn Marinosystems, this is used for Framework includes, which have semantics 11203e4b17023SJohn Marinothat are different from @option{-I}. 11204e4b17023SJohn Marino@end deftypefn 11205e4b17023SJohn Marino 11206e4b17023SJohn Marino@defmac bool TARGET_USE_LOCAL_THUNK_ALIAS_P (tree @var{fndecl}) 11207e4b17023SJohn MarinoThis target macro returns @code{true} if it is safe to use a local alias 11208e4b17023SJohn Marinofor a virtual function @var{fndecl} when constructing thunks, 11209e4b17023SJohn Marino@code{false} otherwise. By default, the macro returns @code{true} for all 11210e4b17023SJohn Marinofunctions, if a target supports aliases (i.e.@: defines 11211e4b17023SJohn Marino@code{ASM_OUTPUT_DEF}), @code{false} otherwise, 11212e4b17023SJohn Marino@end defmac 11213e4b17023SJohn Marino 11214e4b17023SJohn Marino@defmac TARGET_FORMAT_TYPES 11215e4b17023SJohn MarinoIf defined, this macro is the name of a global variable containing 11216e4b17023SJohn Marinotarget-specific format checking information for the @option{-Wformat} 11217e4b17023SJohn Marinooption. The default is to have no target-specific format checks. 11218e4b17023SJohn Marino@end defmac 11219e4b17023SJohn Marino 11220e4b17023SJohn Marino@defmac TARGET_N_FORMAT_TYPES 11221e4b17023SJohn MarinoIf defined, this macro is the number of entries in 11222e4b17023SJohn Marino@code{TARGET_FORMAT_TYPES}. 11223e4b17023SJohn Marino@end defmac 11224e4b17023SJohn Marino 11225e4b17023SJohn Marino@defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES 11226e4b17023SJohn MarinoIf defined, this macro is the name of a global variable containing 11227e4b17023SJohn Marinotarget-specific format overrides for the @option{-Wformat} option. The 11228e4b17023SJohn Marinodefault is to have no target-specific format overrides. If defined, 11229e4b17023SJohn Marino@code{TARGET_FORMAT_TYPES} must be defined, too. 11230e4b17023SJohn Marino@end defmac 11231e4b17023SJohn Marino 11232e4b17023SJohn Marino@defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 11233e4b17023SJohn MarinoIf defined, this macro specifies the number of entries in 11234e4b17023SJohn Marino@code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}. 11235e4b17023SJohn Marino@end defmac 11236e4b17023SJohn Marino 11237e4b17023SJohn Marino@defmac TARGET_OVERRIDES_FORMAT_INIT 11238e4b17023SJohn MarinoIf defined, this macro specifies the optional initialization 11239e4b17023SJohn Marinoroutine for target specific customizations of the system printf 11240e4b17023SJohn Marinoand scanf formatter settings. 11241e4b17023SJohn Marino@end defmac 11242e4b17023SJohn Marino 11243e4b17023SJohn Marino@deftypevr {Target Hook} bool TARGET_RELAXED_ORDERING 11244e4b17023SJohn MarinoIf set to @code{true}, means that the target's memory model does not 11245e4b17023SJohn Marinoguarantee that loads which do not depend on one another will access 11246e4b17023SJohn Marinomain memory in the order of the instruction stream; if ordering is 11247e4b17023SJohn Marinoimportant, an explicit memory barrier must be used. This is true of 11248e4b17023SJohn Marinomany recent processors which implement a policy of ``relaxed,'' 11249e4b17023SJohn Marino``weak,'' or ``release'' memory consistency, such as Alpha, PowerPC, 11250e4b17023SJohn Marinoand ia64. The default is @code{false}. 11251e4b17023SJohn Marino@end deftypevr 11252e4b17023SJohn Marino 11253e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN (const_tree @var{typelist}, const_tree @var{funcdecl}, const_tree @var{val}) 11254e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is 11255e4b17023SJohn Marinoillegal to pass argument @var{val} to function @var{funcdecl} 11256e4b17023SJohn Marinowith prototype @var{typelist}. 11257e4b17023SJohn Marino@end deftypefn 11258e4b17023SJohn Marino 11259e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_INVALID_CONVERSION (const_tree @var{fromtype}, const_tree @var{totype}) 11260e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is 11261e4b17023SJohn Marinoinvalid to convert from @var{fromtype} to @var{totype}, or @code{NULL} 11262e4b17023SJohn Marinoif validity should be determined by the front end. 11263e4b17023SJohn Marino@end deftypefn 11264e4b17023SJohn Marino 11265e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_INVALID_UNARY_OP (int @var{op}, const_tree @var{type}) 11266e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is 11267e4b17023SJohn Marinoinvalid to apply operation @var{op} (where unary plus is denoted by 11268e4b17023SJohn Marino@code{CONVERT_EXPR}) to an operand of type @var{type}, or @code{NULL} 11269e4b17023SJohn Marinoif validity should be determined by the front end. 11270e4b17023SJohn Marino@end deftypefn 11271e4b17023SJohn Marino 11272e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_INVALID_BINARY_OP (int @var{op}, const_tree @var{type1}, const_tree @var{type2}) 11273e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is 11274e4b17023SJohn Marinoinvalid to apply operation @var{op} to operands of types @var{type1} 11275e4b17023SJohn Marinoand @var{type2}, or @code{NULL} if validity should be determined by 11276e4b17023SJohn Marinothe front end. 11277e4b17023SJohn Marino@end deftypefn 11278e4b17023SJohn Marino 11279e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_INVALID_PARAMETER_TYPE (const_tree @var{type}) 11280e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is 11281e4b17023SJohn Marinoinvalid for functions to include parameters of type @var{type}, 11282e4b17023SJohn Marinoor @code{NULL} if validity should be determined by 11283e4b17023SJohn Marinothe front end. This is currently used only by the C and C++ front ends. 11284e4b17023SJohn Marino@end deftypefn 11285e4b17023SJohn Marino 11286e4b17023SJohn Marino@deftypefn {Target Hook} {const char *} TARGET_INVALID_RETURN_TYPE (const_tree @var{type}) 11287e4b17023SJohn MarinoIf defined, this macro returns the diagnostic message when it is 11288e4b17023SJohn Marinoinvalid for functions to have return type @var{type}, 11289e4b17023SJohn Marinoor @code{NULL} if validity should be determined by 11290e4b17023SJohn Marinothe front end. This is currently used only by the C and C++ front ends. 11291e4b17023SJohn Marino@end deftypefn 11292e4b17023SJohn Marino 11293e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_PROMOTED_TYPE (const_tree @var{type}) 11294e4b17023SJohn MarinoIf defined, this target hook returns the type to which values of 11295e4b17023SJohn Marino@var{type} should be promoted when they appear in expressions, 11296e4b17023SJohn Marinoanalogous to the integer promotions, or @code{NULL_TREE} to use the 11297e4b17023SJohn Marinofront end's normal promotion rules. This hook is useful when there are 11298e4b17023SJohn Marinotarget-specific types with special promotion rules. 11299e4b17023SJohn MarinoThis is currently used only by the C and C++ front ends. 11300e4b17023SJohn Marino@end deftypefn 11301e4b17023SJohn Marino 11302e4b17023SJohn Marino@deftypefn {Target Hook} tree TARGET_CONVERT_TO_TYPE (tree @var{type}, tree @var{expr}) 11303e4b17023SJohn MarinoIf defined, this hook returns the result of converting @var{expr} to 11304e4b17023SJohn Marino@var{type}. It should return the converted expression, 11305e4b17023SJohn Marinoor @code{NULL_TREE} to apply the front end's normal conversion rules. 11306e4b17023SJohn MarinoThis hook is useful when there are target-specific types with special 11307e4b17023SJohn Marinoconversion rules. 11308e4b17023SJohn MarinoThis is currently used only by the C and C++ front ends. 11309e4b17023SJohn Marino@end deftypefn 11310e4b17023SJohn Marino 11311e4b17023SJohn Marino@defmac TARGET_USE_JCR_SECTION 11312e4b17023SJohn MarinoThis macro determines whether to use the JCR section to register Java 11313e4b17023SJohn Marinoclasses. By default, TARGET_USE_JCR_SECTION is defined to 1 if both 11314e4b17023SJohn MarinoSUPPORTS_WEAK and TARGET_HAVE_NAMED_SECTIONS are true, else 0. 11315e4b17023SJohn Marino@end defmac 11316e4b17023SJohn Marino 11317e4b17023SJohn Marino@defmac OBJC_JBLEN 11318e4b17023SJohn MarinoThis macro determines the size of the objective C jump buffer for the 11319e4b17023SJohn MarinoNeXT runtime. By default, OBJC_JBLEN is defined to an innocuous value. 11320e4b17023SJohn Marino@end defmac 11321e4b17023SJohn Marino 11322e4b17023SJohn Marino@defmac LIBGCC2_UNWIND_ATTRIBUTE 11323e4b17023SJohn MarinoDefine this macro if any target-specific attributes need to be attached 11324e4b17023SJohn Marinoto the functions in @file{libgcc} that provide low-level support for 11325e4b17023SJohn Marinocall stack unwinding. It is used in declarations in @file{unwind-generic.h} 11326e4b17023SJohn Marinoand the associated definitions of those functions. 11327e4b17023SJohn Marino@end defmac 11328e4b17023SJohn Marino 11329e4b17023SJohn Marino@deftypefn {Target Hook} void TARGET_UPDATE_STACK_BOUNDARY (void) 11330e4b17023SJohn MarinoDefine this macro to update the current function stack boundary if 11331e4b17023SJohn Marinonecessary. 11332e4b17023SJohn Marino@end deftypefn 11333e4b17023SJohn Marino 11334e4b17023SJohn Marino@deftypefn {Target Hook} rtx TARGET_GET_DRAP_RTX (void) 11335e4b17023SJohn MarinoThis hook should return an rtx for Dynamic Realign Argument Pointer (DRAP) if a 11336e4b17023SJohn Marinodifferent argument pointer register is needed to access the function's 11337e4b17023SJohn Marinoargument list due to stack realignment. Return @code{NULL} if no DRAP 11338e4b17023SJohn Marinois needed. 11339e4b17023SJohn Marino@end deftypefn 11340e4b17023SJohn Marino 11341e4b17023SJohn Marino@deftypefn {Target Hook} bool TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS (void) 11342e4b17023SJohn MarinoWhen optimization is disabled, this hook indicates whether or not 11343e4b17023SJohn Marinoarguments should be allocated to stack slots. Normally, GCC allocates 11344e4b17023SJohn Marinostacks slots for arguments when not optimizing in order to make 11345e4b17023SJohn Marinodebugging easier. However, when a function is declared with 11346e4b17023SJohn Marino@code{__attribute__((naked))}, there is no stack frame, and the compiler 11347e4b17023SJohn Marinocannot safely move arguments from the registers in which they are passed 11348e4b17023SJohn Marinoto the stack. Therefore, this hook should return true in general, but 11349e4b17023SJohn Marinofalse for naked functions. The default implementation always returns true. 11350e4b17023SJohn Marino@end deftypefn 11351e4b17023SJohn Marino 11352e4b17023SJohn Marino@deftypevr {Target Hook} {unsigned HOST_WIDE_INT} TARGET_CONST_ANCHOR 11353e4b17023SJohn MarinoOn some architectures it can take multiple instructions to synthesize 11354e4b17023SJohn Marinoa constant. If there is another constant already in a register that 11355e4b17023SJohn Marinois close enough in value then it is preferable that the new constant 11356e4b17023SJohn Marinois computed from this register using immediate addition or 11357e4b17023SJohn Marinosubtraction. We accomplish this through CSE. Besides the value of 11358e4b17023SJohn Marinothe constant we also add a lower and an upper constant anchor to the 11359e4b17023SJohn Marinoavailable expressions. These are then queried when encountering new 11360e4b17023SJohn Marinoconstants. The anchors are computed by rounding the constant up and 11361e4b17023SJohn Marinodown to a multiple of the value of @code{TARGET_CONST_ANCHOR}. 11362e4b17023SJohn Marino@code{TARGET_CONST_ANCHOR} should be the maximum positive value 11363e4b17023SJohn Marinoaccepted by immediate-add plus one. We currently assume that the 11364e4b17023SJohn Marinovalue of @code{TARGET_CONST_ANCHOR} is a power of 2. For example, on 11365e4b17023SJohn MarinoMIPS, where add-immediate takes a 16-bit signed value, 11366e4b17023SJohn Marino@code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}. The default value 11367e4b17023SJohn Marinois zero, which disables this optimization. @end deftypevr 11368e4b17023SJohn Marino 11369e4b17023SJohn Marino@deftypevr {Target Hook} {unsigned char} TARGET_ATOMIC_TEST_AND_SET_TRUEVAL 11370e4b17023SJohn MarinoThis value should be set if the result written by @code{atomic_test_and_set} is not exactly 1, i.e. the @code{bool} @code{true}. 11371e4b17023SJohn Marino@end deftypevr 11372