|
|
1.1 ! root 1: @c Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc. ! 2: @c This is part of the GCC manual. ! 3: @c For copying conditions, see the file gcc.texi. ! 4: ! 5: @node Target Macros ! 6: @chapter Target Description Macros ! 7: @cindex machine description macros ! 8: @cindex target description macros ! 9: @cindex macros, target description ! 10: @cindex @file{tm.h} macros ! 11: ! 12: In addition to the file @file{@var{machine}.md}, a machine description ! 13: includes a C header file conventionally given the name ! 14: @file{@var{machine}.h}. This header file defines numerous macros ! 15: that convey the information about the target machine that does not fit ! 16: into the scheme of the @file{.md} file. The file @file{tm.h} should be ! 17: a link to @file{@var{machine}.h}. The header file @file{config.h} ! 18: includes @file{tm.h} and most compiler source files include ! 19: @file{config.h}. ! 20: ! 21: @menu ! 22: * Driver:: Controlling how the driver runs the compilation passes. ! 23: * Run-time Target:: Defining @samp{-m} options like @samp{-m68000} and @samp{-m68020}. ! 24: * Storage Layout:: Defining sizes and alignments of data. ! 25: * Type Layout:: Defining sizes and properties of basic user data types. ! 26: * Registers:: Naming and describing the hardware registers. ! 27: * Register Classes:: Defining the classes of hardware registers. ! 28: * Stack and Calling:: Defining which way the stack grows and by how much. ! 29: * Varargs:: Defining the varargs macros. ! 30: * Trampolines:: Code set up at run time to enter a nested function. ! 31: * Library Calls:: Controlling how library routines are implicitly called. ! 32: * Addressing Modes:: Defining addressing modes valid for memory operands. ! 33: * Condition Code:: Defining how insns update the condition code. ! 34: * Costs:: Defining relative costs of different operations. ! 35: * Sections:: Dividing storage into text, data, and other sections. ! 36: * PIC:: Macros for position independent code. ! 37: * Assembler Format:: Defining how to write insns and pseudo-ops to output. ! 38: * Debugging Info:: Defining the format of debugging output. ! 39: * Cross-compilation:: Handling floating point for cross-compilers. ! 40: * Misc:: Everything else. ! 41: @end menu ! 42: ! 43: @node Driver ! 44: @section Controlling the Compilation Driver, @file{gcc} ! 45: @cindex driver ! 46: @cindex controlling the compilation driver ! 47: ! 48: @table @code ! 49: @findex SWITCH_TAKES_ARG ! 50: @item SWITCH_TAKES_ARG (@var{char}) ! 51: A C expression which determines whether the option @samp{-@var{char}} ! 52: takes arguments. The value should be the number of arguments that ! 53: option takes--zero, for many options. ! 54: ! 55: By default, this macro is defined to handle the standard options ! 56: properly. You need not define it unless you wish to add additional ! 57: options which take arguments. ! 58: ! 59: @findex WORD_SWITCH_TAKES_ARG ! 60: @item WORD_SWITCH_TAKES_ARG (@var{name}) ! 61: A C expression which determines whether the option @samp{-@var{name}} ! 62: takes arguments. The value should be the number of arguments that ! 63: option takes--zero, for many options. This macro rather than ! 64: @code{SWITCH_TAKES_ARG} is used for multi-character option names. ! 65: ! 66: By default, this macro is defined as ! 67: @code{DEFAULT_WORD_SWITCH_TAKES_ARG}, which handles the standard options ! 68: properly. You need not define @code{WORD_SWITCH_TAKES_ARG} unless you ! 69: wish to add additional options which take arguments. Any redefinition ! 70: should call @code{DEFAULT_WORD_SWITCH_TAKES_ARG} and then check for ! 71: additional options. ! 72: ! 73: @findex SWITCHES_NEED_SPACES ! 74: @item SWITCHES_NEED_SPACES ! 75: A string-valued C expression which is nonempty if the linker needs a ! 76: space between the @samp{-L} or @samp{-o} option and its argument. ! 77: ! 78: If this macro is not defined, the default value is 0. ! 79: ! 80: @findex CPP_SPEC ! 81: @item CPP_SPEC ! 82: A C string constant that tells the GNU CC driver program options to ! 83: pass to CPP. It can also specify how to translate options you ! 84: give to GNU CC into options for GNU CC to pass to the CPP. ! 85: ! 86: Do not define this macro if it does not need to do anything. ! 87: ! 88: @findex NO_BUILTIN_SIZE_TYPE ! 89: @item NO_BUILTIN_SIZE_TYPE ! 90: If this macro is defined, the preprocessor will not define the builtin macro ! 91: @code{__SIZE_TYPE__}. The macro @code{__SIZE_TYPE__} must then be defined ! 92: by @code{CPP_SPEC} instead. ! 93: ! 94: This should be defined if @code{SIZE_TYPE} depends on target dependent flags ! 95: which are not accessible to the preprocessor. Otherwise, it should not ! 96: be defined. ! 97: ! 98: @findex NO_BUILTIN_PTRDIFF_TYPE ! 99: @item NO_BUILTIN_PTRDIFF_TYPE ! 100: If this macro is defined, the preprocessor will not define the builtin macro ! 101: @code{__PTRDIFF_TYPE__}. The macro @code{__PTRDIFF_TYPE__} must then be ! 102: defined by @code{CPP_SPEC} instead. ! 103: ! 104: This should be defined if @code{PTRDIFF_TYPE} depends on target dependent flags ! 105: which are not accessible to the preprocessor. Otherwise, it should not ! 106: be defined. ! 107: ! 108: @findex SIGNED_CHAR_SPEC ! 109: @item SIGNED_CHAR_SPEC ! 110: A C string constant that tells the GNU CC driver program options to ! 111: pass to CPP. By default, this macro is defined to pass the option ! 112: @samp{-D__CHAR_UNSIGNED__} to CPP if @code{char} will be treated as ! 113: @code{unsigned char} by @code{cc1}. ! 114: ! 115: Do not define this macro unless you need to override the default ! 116: definition. ! 117: ! 118: @findex CC1_SPEC ! 119: @item CC1_SPEC ! 120: A C string constant that tells the GNU CC driver program options to ! 121: pass to @code{cc1}. It can also specify how to translate options you ! 122: give to GNU CC into options for GNU CC to pass to the @code{cc1}. ! 123: ! 124: Do not define this macro if it does not need to do anything. ! 125: ! 126: @findex CC1PLUS_SPEC ! 127: @item CC1PLUS_SPEC ! 128: A C string constant that tells the GNU CC driver program options to ! 129: pass to @code{cc1plus}. It can also specify how to translate options you ! 130: give to GNU CC into options for GNU CC to pass to the @code{cc1plus}. ! 131: ! 132: Do not define this macro if it does not need to do anything. ! 133: ! 134: @findex ASM_SPEC ! 135: @item ASM_SPEC ! 136: A C string constant that tells the GNU CC driver program options to ! 137: pass to the assembler. It can also specify how to translate options ! 138: you give to GNU CC into options for GNU CC to pass to the assembler. ! 139: See the file @file{sun3.h} for an example of this. ! 140: ! 141: Do not define this macro if it does not need to do anything. ! 142: ! 143: @findex ASM_FINAL_SPEC ! 144: @item ASM_FINAL_SPEC ! 145: A C string constant that tells the GNU CC driver program how to ! 146: run any programs which cleanup after the normal assembler. ! 147: Normally, this is not needed. See the file @file{mips.h} for ! 148: an example of this. ! 149: ! 150: Do not define this macro if it does not need to do anything. ! 151: ! 152: @findex LINK_SPEC ! 153: @item LINK_SPEC ! 154: A C string constant that tells the GNU CC driver program options to ! 155: pass to the linker. It can also specify how to translate options you ! 156: give to GNU CC into options for GNU CC to pass to the linker. ! 157: ! 158: Do not define this macro if it does not need to do anything. ! 159: ! 160: @findex LIB_SPEC ! 161: @item LIB_SPEC ! 162: Another C string constant used much like @code{LINK_SPEC}. The difference ! 163: between the two is that @code{LIB_SPEC} is used at the end of the ! 164: command given to the linker. ! 165: ! 166: If this macro is not defined, a default is provided that ! 167: loads the standard C library from the usual place. See @file{gcc.c}. ! 168: ! 169: @findex STARTFILE_SPEC ! 170: @item STARTFILE_SPEC ! 171: Another C string constant used much like @code{LINK_SPEC}. The ! 172: difference between the two is that @code{STARTFILE_SPEC} is used at ! 173: the very beginning of the command given to the linker. ! 174: ! 175: If this macro is not defined, a default is provided that loads the ! 176: standard C startup file from the usual place. See @file{gcc.c}. ! 177: ! 178: @findex ENDFILE_SPEC ! 179: @item ENDFILE_SPEC ! 180: Another C string constant used much like @code{LINK_SPEC}. The ! 181: difference between the two is that @code{ENDFILE_SPEC} is used at ! 182: the very end of the command given to the linker. ! 183: ! 184: Do not define this macro if it does not need to do anything. ! 185: ! 186: @findex LINK_LIBGCC_SPECIAL ! 187: @item LINK_LIBGCC_SPECIAL ! 188: Define this macro meaning that @code{gcc} should find the library ! 189: @file{libgcc.a} by hand, rather than passing the argument @samp{-lgcc} ! 190: to tell the linker to do the search; also, @code{gcc} should not ! 191: generate @samp{-L} options to pass to the linker (as it normally does). ! 192: ! 193: @findex LINK_LIBGCC_SPECIAL_1 ! 194: @item LINK_LIBGCC_SPECIAL_1 ! 195: Define this macro meaning that @code{gcc} should find the ! 196: library @file{libgcc.a} by hand, rather than passing the argument ! 197: @samp{-lgcc} to tell the linker to do the search. ! 198: ! 199: @findex RELATIVE_PREFIX_NOT_LINKDIR ! 200: @item RELATIVE_PREFIX_NOT_LINKDIR ! 201: Define this macro to tell @code{gcc} that it should only translate ! 202: a @samp{-B} prefix into a @samp{-L} linker option if the prefix ! 203: indicates an absolute file name. ! 204: ! 205: @findex STANDARD_EXEC_PREFIX ! 206: @item STANDARD_EXEC_PREFIX ! 207: Define this macro as a C string constant if you wish to override the ! 208: standard choice of @file{/usr/local/lib/gcc-lib/} as the default prefix to ! 209: try when searching for the executable files of the compiler. ! 210: ! 211: @findex MD_EXEC_PREFIX ! 212: @item MD_EXEC_PREFIX ! 213: If defined, this macro is an additional prefix to try after ! 214: @code{STANDARD_EXEC_PREFIX}. @code{MD_EXEC_PREFIX} is not searched ! 215: when the @samp{-b} option is used, or the compiler is built as a cross ! 216: compiler. ! 217: ! 218: @findex STANDARD_STARTFILE_PREFIX ! 219: @item STANDARD_STARTFILE_PREFIX ! 220: Define this macro as a C string constant if you wish to override the ! 221: standard choice of @file{/usr/local/lib/} as the default prefix to ! 222: try when searching for startup files such as @file{crt0.o}. ! 223: ! 224: @findex MD_STARTFILE_PREFIX ! 225: @item MD_STARTFILE_PREFIX ! 226: If defined, this macro supplies an additional prefix to try after the ! 227: standard prefixes. @code{MD_EXEC_PREFIX} is not searched when the ! 228: @samp{-b} option is used, or when the compiler is built as a cross ! 229: compiler. ! 230: ! 231: @findex MD_STARTFILE_PREFIX_1 ! 232: @item MD_STARTFILE_PREFIX_1 ! 233: If defined, this macro supplies yet another prefix to try after the ! 234: standard prefixes. It is not searched when the @samp{-b} option is ! 235: used, or when the compiler is built as a cross compiler. ! 236: ! 237: @findex LOCAL_INCLUDE_DIR ! 238: @item LOCAL_INCLUDE_DIR ! 239: Define this macro as a C string constant if you wish to override the ! 240: standard choice of @file{/usr/local/include} as the default prefix to ! 241: try when searching for local header files. @code{LOCAL_INCLUDE_DIR} ! 242: comes before @code{SYSTEM_INCLUDE_DIR} in the search order. ! 243: ! 244: Cross compilers do not use this macro and do not search either ! 245: @file{/usr/local/include} or its replacement. ! 246: ! 247: @findex SYSTEM_INCLUDE_DIR ! 248: @item SYSTEM_INCLUDE_DIR ! 249: Define this macro as a C string constant if you wish to specify a ! 250: system-specific directory to search for header files before the standard ! 251: directory. @code{SYSTEM_INCLUDE_DIR} comes before ! 252: @code{STANDARD_INCLUDE_DIR} in the search order. ! 253: ! 254: Cross compilers do not use this macro and do not search the directory ! 255: specified. ! 256: ! 257: @findex STANDARD_INCLUDE_DIR ! 258: @item STANDARD_INCLUDE_DIR ! 259: Define this macro as a C string constant if you wish to override the ! 260: standard choice of @file{/usr/include} as the default prefix to ! 261: try when searching for header files. ! 262: ! 263: Cross compilers do not use this macro and do not search either ! 264: @file{/usr/include} or its replacement. ! 265: ! 266: @findex INCLUDE_DEFAULTS ! 267: @item INCLUDE_DEFAULTS ! 268: Define this macro if you wish to override the entire default search path ! 269: for include files. The default search path includes ! 270: @code{GCC_INCLUDE_DIR}, @code{LOCAL_INCLUDE_DIR}, ! 271: @code{SYSTEM_INCLUDE_DIR}, @code{GPLUSPLUS_INCLUDE_DIR}, and ! 272: @code{STANDARD_INCLUDE_DIR}. In addition, @code{GPLUSPLUS_INCLUDE_DIR} ! 273: and @code{GCC_INCLUDE_DIR} are defined automatically by @file{Makefile}, ! 274: and specify private search areas for GCC. The directory ! 275: @code{GPLUSPLUS_INCLUDE_DIR} is used only for C++ programs. ! 276: ! 277: The definition should be an initializer for an array of structures. ! 278: Each array element should have two elements: the directory name (a ! 279: string constant) and a flag for C++-only directories. Mark the end of ! 280: the array with a null element. For example, here is the definition used ! 281: for VMS: ! 282: ! 283: @example ! 284: #define INCLUDE_DEFAULTS \ ! 285: @{ \ ! 286: @{ "GNU_GXX_INCLUDE:", 1@}, \ ! 287: @{ "GNU_CC_INCLUDE:", 0@}, \ ! 288: @{ "SYS$SYSROOT:[SYSLIB.]", 0@}, \ ! 289: @{ ".", 0@}, \ ! 290: @{ 0, 0@} \ ! 291: @} ! 292: @end example ! 293: @end table ! 294: ! 295: Here is the order of prefixes tried for exec files: ! 296: ! 297: @enumerate ! 298: @item ! 299: Any prefixes specified by the user with @samp{-B}. ! 300: ! 301: @item ! 302: The environment variable @code{GCC_EXEC_PREFIX}, if any. ! 303: ! 304: @item ! 305: The directories specified by the environment variable @code{COMPILER_PATH}. ! 306: ! 307: @item ! 308: The macro @code{STANDARD_EXEC_PREFIX}. ! 309: ! 310: @item ! 311: @file{/usr/lib/gcc/}. ! 312: ! 313: @item ! 314: The macro @code{MD_EXEC_PREFIX}, if any. ! 315: @end enumerate ! 316: ! 317: Here is the order of prefixes tried for startfiles: ! 318: ! 319: @enumerate ! 320: @item ! 321: Any prefixes specified by the user with @samp{-B}. ! 322: ! 323: @item ! 324: The environment variable @code{GCC_EXEC_PREFIX}, if any. ! 325: ! 326: @item ! 327: The directories specified by the environment variable @code{LIBRARY_PATH}. ! 328: ! 329: @item ! 330: The macro @code{STANDARD_EXEC_PREFIX}. ! 331: ! 332: @item ! 333: @file{/usr/lib/gcc/}. ! 334: ! 335: @item ! 336: The macro @code{MD_EXEC_PREFIX}, if any. ! 337: ! 338: @item ! 339: The macro @code{MD_STARTFILE_PREFIX}, if any. ! 340: ! 341: @item ! 342: The macro @code{STANDARD_STARTFILE_PREFIX}. ! 343: ! 344: @item ! 345: @file{/lib/}. ! 346: ! 347: @item ! 348: @file{/usr/lib/}. ! 349: @end enumerate ! 350: ! 351: @node Run-time Target ! 352: @section Run-time Target Specification ! 353: @cindex run-time target specification ! 354: @cindex predefined macros ! 355: @cindex target specifications ! 356: ! 357: @table @code ! 358: @findex CPP_PREDEFINES ! 359: @item CPP_PREDEFINES ! 360: Define this to be a string constant containing @samp{-D} options to ! 361: define the predefined macros that identify this machine and system. ! 362: These macros will be predefined unless the @samp{-ansi} option is ! 363: specified. ! 364: ! 365: In addition, a parallel set of macros are predefined, whose names are ! 366: made by appending @samp{__} at the beginning and at the end. These ! 367: @samp{__} macros are permitted by the ANSI standard, so they are ! 368: predefined regardless of whether @samp{-ansi} is specified. ! 369: ! 370: For example, on the Sun, one can use the following value: ! 371: ! 372: @smallexample ! 373: "-Dmc68000 -Dsun -Dunix" ! 374: @end smallexample ! 375: ! 376: The result is to define the macros @code{__mc68000__}, @code{__sun__} ! 377: and @code{__unix__} unconditionally, and the macros @code{mc68000}, ! 378: @code{sun} and @code{unix} provided @samp{-ansi} is not specified. ! 379: ! 380: @findex STDC_VALUE ! 381: @item STDC_VALUE ! 382: Define the value to be assigned to the built-in macro @code{__STDC__}. ! 383: The default is the value @samp{1}. ! 384: ! 385: @findex extern int target_flags ! 386: @item extern int target_flags; ! 387: This declaration should be present. ! 388: ! 389: @cindex optional hardware or system features ! 390: @cindex features, optional, in system conventions ! 391: @item TARGET_@dots{} ! 392: This series of macros is to allow compiler command arguments to ! 393: enable or disable the use of optional features of the target machine. ! 394: For example, one machine description serves both the 68000 and ! 395: the 68020; a command argument tells the compiler whether it should ! 396: use 68020-only instructions or not. This command argument works ! 397: by means of a macro @code{TARGET_68020} that tests a bit in ! 398: @code{target_flags}. ! 399: ! 400: Define a macro @code{TARGET_@var{featurename}} for each such option. ! 401: Its definition should test a bit in @code{target_flags}; for example: ! 402: ! 403: @smallexample ! 404: #define TARGET_68020 (target_flags & 1) ! 405: @end smallexample ! 406: ! 407: One place where these macros are used is in the condition-expressions ! 408: of instruction patterns. Note how @code{TARGET_68020} appears ! 409: frequently in the 68000 machine description file, @file{m68k.md}. ! 410: Another place they are used is in the definitions of the other ! 411: macros in the @file{@var{machine}.h} file. ! 412: ! 413: @findex TARGET_SWITCHES ! 414: @item TARGET_SWITCHES ! 415: This macro defines names of command options to set and clear ! 416: bits in @code{target_flags}. Its definition is an initializer ! 417: with a subgrouping for each command option. ! 418: ! 419: Each subgrouping contains a string constant, that defines the option ! 420: name, and a number, which contains the bits to set in ! 421: @code{target_flags}. A negative number says to clear bits instead; ! 422: the negative of the number is which bits to clear. The actual option ! 423: name is made by appending @samp{-m} to the specified name. ! 424: ! 425: One of the subgroupings should have a null string. The number in ! 426: this grouping is the default value for @code{target_flags}. Any ! 427: target options act starting with that value. ! 428: ! 429: Here is an example which defines @samp{-m68000} and @samp{-m68020} ! 430: with opposite meanings, and picks the latter as the default: ! 431: ! 432: @smallexample ! 433: #define TARGET_SWITCHES \ ! 434: @{ @{ "68020", 1@}, \ ! 435: @{ "68000", -1@}, \ ! 436: @{ "", 1@}@} ! 437: @end smallexample ! 438: ! 439: @findex TARGET_OPTIONS ! 440: @item TARGET_OPTIONS ! 441: This macro is similar to @code{TARGET_SWITCHES} but defines names of command ! 442: options that have values. Its definition is an initializer with a ! 443: subgrouping for each command option. ! 444: ! 445: Each subgrouping contains a string constant, that defines the fixed part ! 446: of the option name, and the address of a variable. The variable, type ! 447: @code{char *}, is set to the variable part of the given option if the fixed ! 448: part matches. The actual option name is made by appending @samp{-m} to the ! 449: specified name. ! 450: ! 451: Here is an example which defines @samp{-mshort-data-@var{number}}. If the ! 452: given option is @samp{-mshort-data-512}, the variable @code{m88k_short_data} ! 453: will be set to the string @code{"512"}. ! 454: ! 455: @smallexample ! 456: extern char *m88k_short_data; ! 457: #define TARGET_OPTIONS \ ! 458: @{ @{ "short-data-", &m88k_short_data @} @} ! 459: @end smallexample ! 460: ! 461: @findex TARGET_VERSION ! 462: @item TARGET_VERSION ! 463: This macro is a C statement to print on @code{stderr} a string ! 464: describing the particular machine description choice. Every machine ! 465: description should define @code{TARGET_VERSION}. For example: ! 466: ! 467: @smallexample ! 468: #ifdef MOTOROLA ! 469: #define TARGET_VERSION \ ! 470: fprintf (stderr, " (68k, Motorola syntax)"); ! 471: #else ! 472: #define TARGET_VERSION \ ! 473: fprintf (stderr, " (68k, MIT syntax)"); ! 474: #endif ! 475: @end smallexample ! 476: ! 477: @findex OVERRIDE_OPTIONS ! 478: @item OVERRIDE_OPTIONS ! 479: Sometimes certain combinations of command options do not make sense on ! 480: a particular target machine. You can define a macro ! 481: @code{OVERRIDE_OPTIONS} to take account of this. This macro, if ! 482: defined, is executed once just after all the command options have been ! 483: parsed. ! 484: ! 485: Don't use this macro to turn on various extra optimizations for ! 486: @samp{-O}. That is what @code{OPTIMIZATION_OPTIONS} is for. ! 487: ! 488: @findex OPTIMIZATION_OPTIONS ! 489: @item OPTIMIZATION_OPTIONS (@var{level}) ! 490: Some machines may desire to change what optimizations are performed for ! 491: various optimization levels. This macro, if defined, is executed once ! 492: just after the optimization level is determined and before the remainder ! 493: of the command options have been parsed. Values set in this macro are ! 494: used as the default values for the other command line options. ! 495: ! 496: @var{level} is the optimization level specified; 2 if -O2 is specified, ! 497: 1 if -O is specified, and 0 if neither is specified. ! 498: ! 499: @strong{Do not examine @code{write_symbols} in this macro!} ! 500: The debugging options are not supposed to alter the generated code. ! 501: @end table ! 502: ! 503: @node Storage Layout ! 504: @section Storage Layout ! 505: @cindex storage layout ! 506: ! 507: Note that the definitions of the macros in this table which are sizes or ! 508: alignments measured in bits do not need to be constant. They can be C ! 509: expressions that refer to static variables, such as the @code{target_flags}. ! 510: @xref{Run-time Target}. ! 511: ! 512: @table @code ! 513: @findex BITS_BIG_ENDIAN ! 514: @item BITS_BIG_ENDIAN ! 515: Define this macro to be the value 1 if the most significant bit in a ! 516: byte has the lowest number; otherwise define it to be the value zero. ! 517: This means that bit-field instructions count from the most significant ! 518: bit. If the machine has no bit-field instructions, then this must still ! 519: be defined, but it doesn't matter which value it is defined to. ! 520: ! 521: This macro does not affect the way structure fields are packed into ! 522: bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}. ! 523: ! 524: @findex BYTES_BIG_ENDIAN ! 525: @item BYTES_BIG_ENDIAN ! 526: Define this macro to be 1 if the most significant byte in a word has the ! 527: lowest number. ! 528: ! 529: @findex WORDS_BIG_ENDIAN ! 530: @item WORDS_BIG_ENDIAN ! 531: Define this macro to be 1 if, in a multiword object, the most ! 532: significant word has the lowest number. This applies to both memory ! 533: locations and registers; GNU CC fundamentally assumes that the order of ! 534: words in memory is the same as the order in registers. ! 535: ! 536: @findex FLOAT_WORDS_BIG_ENDIAN ! 537: @item FLOAT_WORDS_BIG_ENDIAN ! 538: Define this macro to be 1 if @code{DFmode}, @code{XFmode} or ! 539: @code{TFmode} floating point numbers are stored in memory with the word ! 540: containing the sign bit at the lowest address; otherwise define it to be ! 541: 0. ! 542: ! 543: You need not define this macro if the ordering is the same as for ! 544: multi-word integers. ! 545: ! 546: @findex BITS_PER_UNIT ! 547: @item BITS_PER_UNIT ! 548: Define this macro to be the number of bits in an addressable storage ! 549: unit (byte); normally 8. ! 550: ! 551: @findex BITS_PER_WORD ! 552: @item BITS_PER_WORD ! 553: Number of bits in a word; normally 32. ! 554: ! 555: @findex MAX_BITS_PER_WORD ! 556: @item MAX_BITS_PER_WORD ! 557: Maximum number of bits in a word. If this is undefined, the default is ! 558: @code{BITS_PER_WORD}. Otherwise, it is the constant value that is the ! 559: largest value that @code{BITS_PER_WORD} can have at run-time. ! 560: ! 561: @findex UNITS_PER_WORD ! 562: @item UNITS_PER_WORD ! 563: Number of storage units in a word; normally 4. ! 564: ! 565: @findex MAX_UNITS_PER_WORD ! 566: @item MAX_UNITS_PER_WORD ! 567: Maximum number of units in a word. If this is undefined, the default is ! 568: @code{UNITS_PER_WORD}. Otherwise, it is the constant value that is the ! 569: largest value that @code{UNITS_PER_WORD} can have at run-time. ! 570: ! 571: @findex POINTER_SIZE ! 572: @item POINTER_SIZE ! 573: Width of a pointer, in bits. ! 574: ! 575: @findex PROMOTE_MODE ! 576: @item PROMOTE_MODE (@var{m}, @var{unsignedp}, @var{type}) ! 577: A macro to update @var{m} and @var{unsignedp} when an object whose type ! 578: is @var{type} and which has the specified mode and signedness is to be ! 579: stored in a register. This macro is only called when @var{type} is a ! 580: scalar type. ! 581: ! 582: On most RISC machines, which only have operations that operate on a full ! 583: register, define this macro to set @var{m} to @code{word_mode} if ! 584: @var{m} is an integer mode narrower than @code{BITS_PER_WORD}. In most ! 585: cases, only integer modes should be widened because wider-precision ! 586: floating-point operations are usually more expensive than their narrower ! 587: counterparts. ! 588: ! 589: For most machines, the macro definition does not change @var{unsignedp}. ! 590: However, some machines, have instructions that preferentially handle ! 591: either signed or unsigned quantities of certain modes. For example, on ! 592: the DEC Alpha, 32-bit loads from memory and 32-bit add instructions ! 593: sign-extend the result to 64 bits. On such machines, set ! 594: @var{unsignedp} according to which kind of extension is more efficient. ! 595: ! 596: Do not define this macro if it would never modify @var{m}. ! 597: ! 598: @findex PROMOTE_FUNCTION_ARGS ! 599: @item PROMOTE_FUNCTION_ARGS ! 600: Define this macro if the promotion described by @code{PROMOTE_MODE} ! 601: should also be done for outgoing function arguments. ! 602: ! 603: @findex PROMOTE_FUNCTION_RETURN ! 604: @item PROMOTE_FUNCTION_RETURN ! 605: Define this macro if the promotion described by @code{PROMOTE_MODE} ! 606: should also be done for the return value of functions. ! 607: ! 608: If this macro is defined, @code{FUNCTION_VALUE} must perform the same ! 609: promotions done by @code{PROMOTE_MODE}. ! 610: ! 611: @findex PARM_BOUNDARY ! 612: @item PARM_BOUNDARY ! 613: Normal alignment required for function parameters on the stack, in ! 614: bits. All stack parameters receive at least this much alignment ! 615: regardless of data type. On most machines, this is the same as the ! 616: size of an integer. ! 617: ! 618: @findex STACK_BOUNDARY ! 619: @item STACK_BOUNDARY ! 620: Define this macro if you wish to preserve a certain alignment for ! 621: the stack pointer. The definition is a C expression ! 622: for the desired alignment (measured in bits). ! 623: ! 624: @cindex @code{PUSH_ROUNDING}, interaction with @code{STACK_BOUNDARY} ! 625: If @code{PUSH_ROUNDING} is not defined, the stack will always be aligned ! 626: to the specified boundary. If @code{PUSH_ROUNDING} is defined and specifies a ! 627: less strict alignment than @code{STACK_BOUNDARY}, the stack may be ! 628: momentarily unaligned while pushing arguments. ! 629: ! 630: @findex FUNCTION_BOUNDARY ! 631: @item FUNCTION_BOUNDARY ! 632: Alignment required for a function entry point, in bits. ! 633: ! 634: @findex BIGGEST_ALIGNMENT ! 635: @item BIGGEST_ALIGNMENT ! 636: Biggest alignment that any data type can require on this machine, in bits. ! 637: ! 638: @findex BIGGEST_FIELD_ALIGNMENT ! 639: @item BIGGEST_FIELD_ALIGNMENT ! 640: Biggest alignment that any structure field can require on this machine, ! 641: in bits. If defined, this overrides @code{BIGGEST_ALIGNMENT} for ! 642: structure fields only. ! 643: ! 644: @findex MAX_OFILE_ALIGNMENT ! 645: @item MAX_OFILE_ALIGNMENT ! 646: Biggest alignment supported by the object file format of this machine. ! 647: Use this macro to limit the alignment which can be specified using the ! 648: @code{__attribute__ ((aligned (@var{n})))} construct. If not defined, ! 649: the default value is @code{BIGGEST_ALIGNMENT}. ! 650: ! 651: @findex DATA_ALIGNMENT ! 652: @item DATA_ALIGNMENT (@var{type}, @var{basic-align}) ! 653: If defined, a C expression to compute the alignment for a static ! 654: variable. @var{type} is the data type, and @var{basic-align} is the ! 655: alignment that the object would ordinarily have. The value of this ! 656: macro is used instead of that alignment to align the object. ! 657: ! 658: If this macro is not defined, then @var{basic-align} is used. ! 659: ! 660: @findex strcpy ! 661: One use of this macro is to increase alignment of medium-size data to ! 662: make it all fit in fewer cache lines. Another is to cause character ! 663: arrays to be word-aligned so that @code{strcpy} calls that copy ! 664: constants to character arrays can be done inline. ! 665: ! 666: @findex CONSTANT_ALIGNMENT ! 667: @item CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align}) ! 668: If defined, a C expression to compute the alignment given to a constant ! 669: that is being placed in memory. @var{constant} is the constant and ! 670: @var{basic-align} is the alignment that the object would ordinarily ! 671: have. The value of this macro is used instead of that alignment to ! 672: align the object. ! 673: ! 674: If this macro is not defined, then @var{basic-align} is used. ! 675: ! 676: The typical use of this macro is to increase alignment for string ! 677: constants to be word aligned so that @code{strcpy} calls that copy ! 678: constants can be done inline. ! 679: ! 680: @findex EMPTY_FIELD_BOUNDARY ! 681: @item EMPTY_FIELD_BOUNDARY ! 682: Alignment in bits to be given to a structure bit field that follows an ! 683: empty field such as @code{int : 0;}. ! 684: ! 685: Note that @code{PCC_BITFIELD_TYPE_MATTERS} also affects the alignment ! 686: that results from an empty field. ! 687: ! 688: @findex STRUCTURE_SIZE_BOUNDARY ! 689: @item STRUCTURE_SIZE_BOUNDARY ! 690: Number of bits which any structure or union's size must be a multiple of. ! 691: Each structure or union's size is rounded up to a multiple of this. ! 692: ! 693: If you do not define this macro, the default is the same as ! 694: @code{BITS_PER_UNIT}. ! 695: ! 696: @findex STRICT_ALIGNMENT ! 697: @item STRICT_ALIGNMENT ! 698: Define this macro to be the value 1 if instructions will fail to work ! 699: if given data not on the nominal alignment. If instructions will merely ! 700: go slower in that case, define this macro as 0. ! 701: ! 702: @findex PCC_BITFIELD_TYPE_MATTERS ! 703: @item PCC_BITFIELD_TYPE_MATTERS ! 704: Define this if you wish to imitate the way many other C compilers handle ! 705: alignment of bitfields and the structures that contain them. ! 706: ! 707: The behavior is that the type written for a bitfield (@code{int}, ! 708: @code{short}, or other integer type) imposes an alignment for the ! 709: entire structure, as if the structure really did contain an ordinary ! 710: field of that type. In addition, the bitfield is placed within the ! 711: structure so that it would fit within such a field, not crossing a ! 712: boundary for it. ! 713: ! 714: Thus, on most machines, a bitfield whose type is written as @code{int} ! 715: would not cross a four-byte boundary, and would force four-byte ! 716: alignment for the whole structure. (The alignment used may not be four ! 717: bytes; it is controlled by the other alignment parameters.) ! 718: ! 719: If the macro is defined, its definition should be a C expression; ! 720: a nonzero value for the expression enables this behavior. ! 721: ! 722: Note that if this macro is not defined, or its value is zero, some ! 723: bitfields may cross more than one alignment boundary. The compiler can ! 724: support such references if there are @samp{insv}, @samp{extv}, and ! 725: @samp{extzv} insns that can directly reference memory. ! 726: ! 727: The other known way of making bitfields work is to define ! 728: @code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}. ! 729: Then every structure can be accessed with fullwords. ! 730: ! 731: Unless the machine has bitfield instructions or you define ! 732: @code{STRUCTURE_SIZE_BOUNDARY} that way, you must define ! 733: @code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value. ! 734: ! 735: If your aim is to make GNU CC use the same conventions for laying out ! 736: bitfields as are used by another compiler, here is how to investigate ! 737: what the other compiler does. Compile and run this program: ! 738: ! 739: @example ! 740: struct foo1 ! 741: @{ ! 742: char x; ! 743: char :0; ! 744: char y; ! 745: @}; ! 746: ! 747: struct foo2 ! 748: @{ ! 749: char x; ! 750: int :0; ! 751: char y; ! 752: @}; ! 753: ! 754: main () ! 755: @{ ! 756: printf ("Size of foo1 is %d\n", ! 757: sizeof (struct foo1)); ! 758: printf ("Size of foo2 is %d\n", ! 759: sizeof (struct foo2)); ! 760: exit (0); ! 761: @} ! 762: @end example ! 763: ! 764: If this prints 2 and 5, then the compiler's behavior is what you would ! 765: get from @code{PCC_BITFIELD_TYPE_MATTERS}. ! 766: ! 767: @findex BITFIELD_NBYTES_LIMITED ! 768: @item BITFIELD_NBYTES_LIMITED ! 769: Like PCC_BITFIELD_TYPE_MATTERS except that its effect is limited to ! 770: aligning a bitfield within the structure. ! 771: ! 772: @findex ROUND_TYPE_SIZE ! 773: @item ROUND_TYPE_SIZE (@var{struct}, @var{size}, @var{align}) ! 774: Define this macro as an expression for the overall size of a structure ! 775: (given by @var{struct} as a tree node) when the size computed from the ! 776: fields is @var{size} and the alignment is @var{align}. ! 777: ! 778: The default is to round @var{size} up to a multiple of @var{align}. ! 779: ! 780: @findex ROUND_TYPE_ALIGN ! 781: @item ROUND_TYPE_ALIGN (@var{struct}, @var{computed}, @var{specified}) ! 782: Define this macro as an expression for the alignment of a structure ! 783: (given by @var{struct} as a tree node) if the alignment computed in the ! 784: usual way is @var{computed} and the alignment explicitly specified was ! 785: @var{specified}. ! 786: ! 787: The default is to use @var{specified} if it is larger; otherwise, use ! 788: the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT} ! 789: ! 790: @findex MAX_FIXED_MODE_SIZE ! 791: @item MAX_FIXED_MODE_SIZE ! 792: An integer expression for the size in bits of the largest integer ! 793: machine mode that should actually be used. All integer machine modes of ! 794: this size or smaller can be used for structures and unions with the ! 795: appropriate sizes. If this macro is undefined, @code{GET_MODE_BITSIZE ! 796: (DImode)} is assumed. ! 797: ! 798: @findex CHECK_FLOAT_VALUE ! 799: @item CHECK_FLOAT_VALUE (@var{mode}, @var{value}) ! 800: A C statement to validate the value @var{value} (of type ! 801: @code{double}) for mode @var{mode}. This means that you check whether ! 802: @var{value} fits within the possible range of values for mode ! 803: @var{mode} on this target machine. The mode @var{mode} is always ! 804: @code{SFmode} or @code{DFmode}. ! 805: ! 806: @findex error ! 807: If @var{value} is not valid, you should call @code{error} to print an ! 808: error message and then assign some valid value to @var{value}. ! 809: Allowing an invalid value to go through the compiler can produce ! 810: incorrect assembler code which may even cause Unix assemblers to ! 811: crash. ! 812: ! 813: This macro need not be defined if there is no work for it to do. ! 814: ! 815: @findex TARGET_FLOAT_FORMAT ! 816: @item TARGET_FLOAT_FORMAT ! 817: A code distinguishing the floating point format of the target machine. ! 818: There are three defined values: ! 819: ! 820: @table @code ! 821: @findex IEEE_FLOAT_FORMAT ! 822: @item IEEE_FLOAT_FORMAT ! 823: This code indicates IEEE floating point. It is the default; there is no ! 824: need to define this macro when the format is IEEE. ! 825: ! 826: @findex VAX_FLOAT_FORMAT ! 827: @item VAX_FLOAT_FORMAT ! 828: This code indicates the peculiar format used on the Vax. ! 829: ! 830: @findex UNKNOWN_FLOAT_FORMAT ! 831: @item UNKNOWN_FLOAT_FORMAT ! 832: This code indicates any other format. ! 833: @end table ! 834: ! 835: The value of this macro is compared with @code{HOST_FLOAT_FORMAT} ! 836: (@pxref{Config}) to determine whether the target machine has the same ! 837: format as the host machine. If any other formats are actually in use on ! 838: supported machines, new codes should be defined for them. ! 839: ! 840: The ordering of the component words of floating point values stored in ! 841: memory is controlled by @code{FLOAT_WORDS_BIG_ENDIAN} for the target ! 842: machine and @code{HOST_FLOAT_WORDS_BIG_ENDIAN} for the host. ! 843: @end table ! 844: ! 845: @node Type Layout ! 846: @section Layout of Source Language Data Types ! 847: ! 848: These macros define the sizes and other characteristics of the standard ! 849: basic data types used in programs being compiled. Unlike the macros in ! 850: the previous section, these apply to specific features of C and related ! 851: languages, rather than to fundamental aspects of storage layout. ! 852: ! 853: @table @code ! 854: @findex INT_TYPE_SIZE ! 855: @item INT_TYPE_SIZE ! 856: A C expression for the size in bits of the type @code{int} on the ! 857: target machine. If you don't define this, the default is one word. ! 858: ! 859: @findex MAX_INT_TYPE_SIZE ! 860: @item MAX_INT_TYPE_SIZE ! 861: Maximum number for the size in bits of the type @code{int} on the target ! 862: machine. If this is undefined, the default is @code{INT_TYPE_SIZE}. ! 863: Otherwise, it is the constant value that is the largest value that ! 864: @code{INT_TYPE_SIZE} can have at run-time. This is used in @code{cpp}. ! 865: ! 866: @findex SHORT_TYPE_SIZE ! 867: @item SHORT_TYPE_SIZE ! 868: A C expression for the size in bits of the type @code{short} on the ! 869: target machine. If you don't define this, the default is half a word. ! 870: (If this would be less than one storage unit, it is rounded up to one ! 871: unit.) ! 872: ! 873: @findex LONG_TYPE_SIZE ! 874: @item LONG_TYPE_SIZE ! 875: A C expression for the size in bits of the type @code{long} on the ! 876: target machine. If you don't define this, the default is one word. ! 877: ! 878: @findex MAX_LONG_TYPE_SIZE ! 879: @item MAX_LONG_TYPE_SIZE ! 880: Maximum number for the size in bits of the type @code{long} on the ! 881: target machine. If this is undefined, the default is ! 882: @code{LONG_TYPE_SIZE}. Otherwise, it is the constant value that is the ! 883: largest value that @code{LONG_TYPE_SIZE} can have at run-time. This is ! 884: used in @code{cpp}. ! 885: ! 886: @findex LONG_LONG_TYPE_SIZE ! 887: @item LONG_LONG_TYPE_SIZE ! 888: A C expression for the size in bits of the type @code{long long} on the ! 889: target machine. If you don't define this, the default is two ! 890: words. ! 891: ! 892: @findex CHAR_TYPE_SIZE ! 893: @item CHAR_TYPE_SIZE ! 894: A C expression for the size in bits of the type @code{char} on the ! 895: target machine. If you don't define this, the default is one quarter ! 896: of a word. (If this would be less than one storage unit, it is rounded up ! 897: to one unit.) ! 898: ! 899: @findex MAX_CHAR_TYPE_SIZE ! 900: @item MAX_CHAR_TYPE_SIZE ! 901: Maximum number for the size in bits of the type @code{char} on the ! 902: target machine. If this is undefined, the default is ! 903: @code{CHAR_TYPE_SIZE}. Otherwise, it is the constant value that is the ! 904: largest value that @code{CHAR_TYPE_SIZE} can have at run-time. This is ! 905: used in @code{cpp}. ! 906: ! 907: @findex FLOAT_TYPE_SIZE ! 908: @item FLOAT_TYPE_SIZE ! 909: A C expression for the size in bits of the type @code{float} on the ! 910: target machine. If you don't define this, the default is one word. ! 911: ! 912: @findex DOUBLE_TYPE_SIZE ! 913: @item DOUBLE_TYPE_SIZE ! 914: A C expression for the size in bits of the type @code{double} on the ! 915: target machine. If you don't define this, the default is two ! 916: words. ! 917: ! 918: @findex LONG_DOUBLE_TYPE_SIZE ! 919: @item LONG_DOUBLE_TYPE_SIZE ! 920: A C expression for the size in bits of the type @code{long double} on ! 921: the target machine. If you don't define this, the default is two ! 922: words. ! 923: ! 924: @findex DEFAULT_SIGNED_CHAR ! 925: @item DEFAULT_SIGNED_CHAR ! 926: An expression whose value is 1 or 0, according to whether the type ! 927: @code{char} should be signed or unsigned by default. The user can ! 928: always override this default with the options @samp{-fsigned-char} ! 929: and @samp{-funsigned-char}. ! 930: ! 931: @findex DEFAULT_SHORT_ENUMS ! 932: @item DEFAULT_SHORT_ENUMS ! 933: A C expression to determine whether to give an @code{enum} type ! 934: only as many bytes as it takes to represent the range of possible values ! 935: of that type. A nonzero value means to do that; a zero value means all ! 936: @code{enum} types should be allocated like @code{int}. ! 937: ! 938: If you don't define the macro, the default is 0. ! 939: ! 940: @findex SIZE_TYPE ! 941: @item SIZE_TYPE ! 942: A C expression for a string describing the name of the data type to use ! 943: for size values. The typedef name @code{size_t} is defined using the ! 944: contents of the string. ! 945: ! 946: The string can contain more than one keyword. If so, separate them with ! 947: spaces, and write first any length keyword, then @code{unsigned} if ! 948: appropriate, and finally @code{int}. The string must exactly match one ! 949: of the data type names defined in the function ! 950: @code{init_decl_processing} in the file @file{c-decl.c}. You may not ! 951: omit @code{int} or change the order---that would cause the compiler to ! 952: crash on startup. ! 953: ! 954: If you don't define this macro, the default is @code{"long unsigned ! 955: int"}. ! 956: ! 957: @findex PTRDIFF_TYPE ! 958: @item PTRDIFF_TYPE ! 959: A C expression for a string describing the name of the data type to use ! 960: for the result of subtracting two pointers. The typedef name ! 961: @code{ptrdiff_t} is defined using the contents of the string. See ! 962: @code{SIZE_TYPE} above for more information. ! 963: ! 964: If you don't define this macro, the default is @code{"long int"}. ! 965: ! 966: @findex WCHAR_TYPE ! 967: @item WCHAR_TYPE ! 968: A C expression for a string describing the name of the data type to use ! 969: for wide characters. The typedef name @code{wchar_t} is defined using ! 970: the contents of the string. See @code{SIZE_TYPE} above for more ! 971: information. ! 972: ! 973: If you don't define this macro, the default is @code{"int"}. ! 974: ! 975: @findex WCHAR_TYPE_SIZE ! 976: @item WCHAR_TYPE_SIZE ! 977: A C expression for the size in bits of the data type for wide ! 978: characters. This is used in @code{cpp}, which cannot make use of ! 979: @code{WCHAR_TYPE}. ! 980: ! 981: @findex MAX_WCHAR_TYPE_SIZE ! 982: @item MAX_WCHAR_TYPE_SIZE ! 983: Maximum number for the size in bits of the data type for wide ! 984: characters. If this is undefined, the default is ! 985: @code{WCHAR_TYPE_SIZE}. Otherwise, it is the constant value that is the ! 986: largest value that @code{WCHAR_TYPE_SIZE} can have at run-time. This is ! 987: used in @code{cpp}. ! 988: ! 989: @findex OBJC_INT_SELECTORS ! 990: @item OBJC_INT_SELECTORS ! 991: Define this macro if the type of Objective C selectors should be ! 992: @code{int}. ! 993: ! 994: If this macro is not defined, then selectors should have the type ! 995: @code{struct objc_selector *}. ! 996: ! 997: @findex OBJC_SELECTORS_WITHOUT_LABELS ! 998: @item OBJC_SELECTORS_WITHOUT_LABELS ! 999: Define this macro if the compiler can group all the selectors together ! 1000: into a vector and use just one label at the beginning of the vector. ! 1001: Otherwise, the compiler must give each selector its own assembler ! 1002: label. ! 1003: ! 1004: On certain machines, it is important to have a separate label for each ! 1005: selector because this enables the linker to eliminate duplicate selectors. ! 1006: ! 1007: @findex TARGET_BELL ! 1008: @item TARGET_BELL ! 1009: A C constant expression for the integer value for escape sequence ! 1010: @samp{\a}. ! 1011: ! 1012: @findex TARGET_TAB ! 1013: @findex TARGET_BS ! 1014: @findex TARGET_NEWLINE ! 1015: @item TARGET_BS ! 1016: @itemx TARGET_TAB ! 1017: @itemx TARGET_NEWLINE ! 1018: C constant expressions for the integer values for escape sequences ! 1019: @samp{\b}, @samp{\t} and @samp{\n}. ! 1020: ! 1021: @findex TARGET_VT ! 1022: @findex TARGET_FF ! 1023: @findex TARGET_CR ! 1024: @item TARGET_VT ! 1025: @itemx TARGET_FF ! 1026: @itemx TARGET_CR ! 1027: C constant expressions for the integer values for escape sequences ! 1028: @samp{\v}, @samp{\f} and @samp{\r}. ! 1029: @end table ! 1030: ! 1031: @node Registers ! 1032: @section Register Usage ! 1033: @cindex register usage ! 1034: ! 1035: This section explains how to describe what registers the target machine ! 1036: has, and how (in general) they can be used. ! 1037: ! 1038: The description of which registers a specific instruction can use is ! 1039: done with register classes; see @ref{Register Classes}. For information ! 1040: on using registers to access a stack frame, see @ref{Frame Registers}. ! 1041: For passing values in registers, see @ref{Register Arguments}. ! 1042: For returning values in registers, see @ref{Scalar Return}. ! 1043: ! 1044: @menu ! 1045: * Register Basics:: Number and kinds of registers. ! 1046: * Allocation Order:: Order in which registers are allocated. ! 1047: * Values in Registers:: What kinds of values each reg can hold. ! 1048: * Leaf Functions:: Renumbering registers for leaf functions. ! 1049: * Stack Registers:: Handling a register stack such as 80387. ! 1050: * Obsolete Register Macros:: Macros formerly used for the 80387. ! 1051: @end menu ! 1052: ! 1053: @node Register Basics ! 1054: @subsection Basic Characteristics of Registers ! 1055: ! 1056: @table @code ! 1057: @findex FIRST_PSEUDO_REGISTER ! 1058: @item FIRST_PSEUDO_REGISTER ! 1059: Number of hardware registers known to the compiler. They receive ! 1060: numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first ! 1061: pseudo register's number really is assigned the number ! 1062: @code{FIRST_PSEUDO_REGISTER}. ! 1063: ! 1064: @item FIXED_REGISTERS ! 1065: @findex FIXED_REGISTERS ! 1066: @cindex fixed register ! 1067: An initializer that says which registers are used for fixed purposes ! 1068: all throughout the compiled code and are therefore not available for ! 1069: general allocation. These would include the stack pointer, the frame ! 1070: pointer (except on machines where that can be used as a general ! 1071: register when no frame pointer is needed), the program counter on ! 1072: machines where that is considered one of the addressable registers, ! 1073: and any other numbered register with a standard use. ! 1074: ! 1075: This information is expressed as a sequence of numbers, separated by ! 1076: commas and surrounded by braces. The @var{n}th number is 1 if ! 1077: register @var{n} is fixed, 0 otherwise. ! 1078: ! 1079: The table initialized from this macro, and the table initialized by ! 1080: the following one, may be overridden at run time either automatically, ! 1081: by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by ! 1082: the user with the command options @samp{-ffixed-@var{reg}}, ! 1083: @samp{-fcall-used-@var{reg}} and @samp{-fcall-saved-@var{reg}}. ! 1084: ! 1085: @findex CALL_USED_REGISTERS ! 1086: @item CALL_USED_REGISTERS ! 1087: @cindex call-used register ! 1088: @cindex call-clobbered register ! 1089: @cindex call-saved register ! 1090: Like @code{FIXED_REGISTERS} but has 1 for each register that is ! 1091: clobbered (in general) by function calls as well as for fixed ! 1092: registers. This macro therefore identifies the registers that are not ! 1093: available for general allocation of values that must live across ! 1094: function calls. ! 1095: ! 1096: If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler ! 1097: automatically saves it on function entry and restores it on function ! 1098: exit, if the register is used within the function. ! 1099: ! 1100: @findex CONDITIONAL_REGISTER_USAGE ! 1101: @findex fixed_regs ! 1102: @findex call_used_regs ! 1103: @item CONDITIONAL_REGISTER_USAGE ! 1104: Zero or more C statements that may conditionally modify two variables ! 1105: @code{fixed_regs} and @code{call_used_regs} (both of type @code{char ! 1106: []}) after they have been initialized from the two preceding macros. ! 1107: ! 1108: This is necessary in case the fixed or call-clobbered registers depend ! 1109: on target flags. ! 1110: ! 1111: You need not define this macro if it has no work to do. ! 1112: ! 1113: @cindex disabling certain registers ! 1114: @cindex controlling register usage ! 1115: If the usage of an entire class of registers depends on the target ! 1116: flags, you may indicate this to GCC by using this macro to modify ! 1117: @code{fixed_regs} and @code{call_used_regs} to 1 for each of the ! 1118: registers in the classes which should not be used by GCC. Also define ! 1119: the macro @code{REG_CLASS_FROM_LETTER} to return @code{NO_REGS} if it ! 1120: is called with a letter for a class that shouldn't be used. ! 1121: ! 1122: (However, if this class is not included in @code{GENERAL_REGS} and all ! 1123: of the insn patterns whose constraints permit this class are ! 1124: controlled by target switches, then GCC will automatically avoid using ! 1125: these registers when the target switches are opposed to them.) ! 1126: ! 1127: @findex NON_SAVING_SETJMP ! 1128: @item NON_SAVING_SETJMP ! 1129: If this macro is defined and has a nonzero value, it means that ! 1130: @code{setjmp} and related functions fail to save the registers, or that ! 1131: @code{longjmp} fails to restore them. To compensate, the compiler ! 1132: avoids putting variables in registers in functions that use ! 1133: @code{setjmp}. ! 1134: ! 1135: @findex INCOMING_REGNO ! 1136: @item INCOMING_REGNO (@var{out}) ! 1137: Define this macro if the target machine has register windows. This C ! 1138: expression returns the register number as seen by the called function ! 1139: corresponding to the register number @var{out} as seen by the calling ! 1140: function. Return @var{out} if register number @var{out} is not an ! 1141: outbound register. ! 1142: ! 1143: @findex OUTGOING_REGNO ! 1144: @item OUTGOING_REGNO (@var{in}) ! 1145: Define this macro if the target machine has register windows. This C ! 1146: expression returns the register number as seen by the calling function ! 1147: corresponding to the register number @var{in} as seen by the called ! 1148: function. Return @var{in} if register number @var{in} is not an inbound ! 1149: register. ! 1150: ! 1151: @ignore ! 1152: @findex PC_REGNUM ! 1153: @item PC_REGNUM ! 1154: If the program counter has a register number, define this as that ! 1155: register number. Otherwise, do not define it. ! 1156: @end ignore ! 1157: @end table ! 1158: ! 1159: @node Allocation Order ! 1160: @subsection Order of Allocation of Registers ! 1161: @cindex order of register allocation ! 1162: @cindex register allocation order ! 1163: ! 1164: @table @code ! 1165: @findex REG_ALLOC_ORDER ! 1166: @item REG_ALLOC_ORDER ! 1167: If defined, an initializer for a vector of integers, containing the ! 1168: numbers of hard registers in the order in which GNU CC should prefer ! 1169: to use them (from most preferred to least). ! 1170: ! 1171: If this macro is not defined, registers are used lowest numbered first ! 1172: (all else being equal). ! 1173: ! 1174: One use of this macro is on machines where the highest numbered ! 1175: registers must always be saved and the save-multiple-registers ! 1176: instruction supports only sequences of consecutive registers. On such ! 1177: machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists ! 1178: the highest numbered allocatable register first. ! 1179: ! 1180: @findex ORDER_REGS_FOR_LOCAL_ALLOC ! 1181: @item ORDER_REGS_FOR_LOCAL_ALLOC ! 1182: A C statement (sans semicolon) to choose the order in which to allocate ! 1183: hard registers for pseudo-registers local to a basic block. ! 1184: ! 1185: Store the desired register order in the array @code{reg_alloc_order}. ! 1186: Element 0 should be the register to allocate first; element 1, the next ! 1187: register; and so on. ! 1188: ! 1189: The macro body should not assume anything about the contents of ! 1190: @code{reg_alloc_order} before execution of the macro. ! 1191: ! 1192: On most machines, it is not necessary to define this macro. ! 1193: @end table ! 1194: ! 1195: @node Values in Registers ! 1196: @subsection How Values Fit in Registers ! 1197: ! 1198: This section discusses the macros that describe which kinds of values ! 1199: (specifically, which machine modes) each register can hold, and how many ! 1200: consecutive registers are needed for a given mode. ! 1201: ! 1202: @table @code ! 1203: @findex HARD_REGNO_NREGS ! 1204: @item HARD_REGNO_NREGS (@var{regno}, @var{mode}) ! 1205: A C expression for the number of consecutive hard registers, starting ! 1206: at register number @var{regno}, required to hold a value of mode ! 1207: @var{mode}. ! 1208: ! 1209: On a machine where all registers are exactly one word, a suitable ! 1210: definition of this macro is ! 1211: ! 1212: @smallexample ! 1213: #define HARD_REGNO_NREGS(REGNO, MODE) \ ! 1214: ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \ ! 1215: / UNITS_PER_WORD)) ! 1216: @end smallexample ! 1217: ! 1218: @findex HARD_REGNO_MODE_OK ! 1219: @item HARD_REGNO_MODE_OK (@var{regno}, @var{mode}) ! 1220: A C expression that is nonzero if it is permissible to store a value ! 1221: of mode @var{mode} in hard register number @var{regno} (or in several ! 1222: registers starting with that one). For a machine where all registers ! 1223: are equivalent, a suitable definition is ! 1224: ! 1225: @smallexample ! 1226: #define HARD_REGNO_MODE_OK(REGNO, MODE) 1 ! 1227: @end smallexample ! 1228: ! 1229: It is not necessary for this macro to check for the numbers of fixed ! 1230: registers, because the allocation mechanism considers them to be always ! 1231: occupied. ! 1232: ! 1233: @cindex register pairs ! 1234: On some machines, double-precision values must be kept in even/odd ! 1235: register pairs. The way to implement that is to define this macro ! 1236: to reject odd register numbers for such modes. ! 1237: ! 1238: @ignore ! 1239: @c I think this is not true now ! 1240: GNU CC assumes that it can always move values between registers and ! 1241: (suitably addressed) memory locations. If it is impossible to move a ! 1242: value of a certain mode between memory and certain registers, then ! 1243: @code{HARD_REGNO_MODE_OK} must not allow this mode in those registers. ! 1244: @end ignore ! 1245: ! 1246: The minimum requirement for a mode to be OK in a register is that the ! 1247: @samp{mov@var{mode}} instruction pattern support moves between the ! 1248: register and any other hard register for which the mode is OK; and that ! 1249: moving a value into the register and back out not alter it. ! 1250: ! 1251: Since the same instruction used to move @code{SImode} will work for all ! 1252: narrower integer modes, it is not necessary on any machine for ! 1253: @code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided ! 1254: you define patterns @samp{movhi}, etc., to take advantage of this. This ! 1255: is useful because of the interaction between @code{HARD_REGNO_MODE_OK} ! 1256: and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes ! 1257: to be tieable. ! 1258: ! 1259: Many machines have special registers for floating point arithmetic. ! 1260: Often people assume that floating point machine modes are allowed only ! 1261: in floating point registers. This is not true. Any registers that ! 1262: can hold integers can safely @emph{hold} a floating point machine ! 1263: mode, whether or not floating arithmetic can be done on it in those ! 1264: registers. Integer move instructions can be used to move the values. ! 1265: ! 1266: On some machines, though, the converse is true: fixed-point machine ! 1267: modes may not go in floating registers. This is true if the floating ! 1268: registers normalize any value stored in them, because storing a ! 1269: non-floating value there would garble it. In this case, ! 1270: @code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in ! 1271: floating registers. But if the floating registers do not automatically ! 1272: normalize, if you can store any bit pattern in one and retrieve it ! 1273: unchanged without a trap, then any machine mode may go in a floating ! 1274: register, so you can define this macro to say so. ! 1275: ! 1276: On some machines, such as the Sparc and the Mips, we get better code ! 1277: by defining @code{HARD_REGNO_MODE_OK} to forbid integers in floating ! 1278: registers, even though the hardware is capable of handling them. This ! 1279: is because transferring values between floating registers and general ! 1280: registers is so slow that it is better to keep the integer in memory. ! 1281: ! 1282: The primary significance of special floating registers is rather that ! 1283: they are the registers acceptable in floating point arithmetic ! 1284: instructions. However, this is of no concern to ! 1285: @code{HARD_REGNO_MODE_OK}. You handle it by writing the proper ! 1286: constraints for those instructions. ! 1287: ! 1288: On some machines, the floating registers are especially slow to access, ! 1289: so that it is better to store a value in a stack frame than in such a ! 1290: register if floating point arithmetic is not being done. As long as the ! 1291: floating registers are not in class @code{GENERAL_REGS}, they will not ! 1292: be used unless some pattern's constraint asks for one. ! 1293: ! 1294: @findex MODES_TIEABLE_P ! 1295: @item MODES_TIEABLE_P (@var{mode1}, @var{mode2}) ! 1296: A C expression that is nonzero if it is desirable to choose register ! 1297: allocation so as to avoid move instructions between a value of mode ! 1298: @var{mode1} and a value of mode @var{mode2}. ! 1299: ! 1300: If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and ! 1301: @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are ever different ! 1302: for any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1}, ! 1303: @var{mode2})} must be zero. ! 1304: @end table ! 1305: ! 1306: @node Leaf Functions ! 1307: @subsection Handling Leaf Functions ! 1308: ! 1309: @cindex leaf functions ! 1310: @cindex functions, leaf ! 1311: On some machines, a leaf function (i.e., one which makes no calls) can run ! 1312: more efficiently if it does not make its own register window. Often this ! 1313: means it is required to receive its arguments in the registers where they ! 1314: are passed by the caller, instead of the registers where they would ! 1315: normally arrive. ! 1316: ! 1317: The special treatment for leaf functions generally applies only when ! 1318: other conditions are met; for example, often they may use only those ! 1319: registers for its own variables and temporaries. We use the term ``leaf ! 1320: function'' to mean a function that is suitable for this special ! 1321: handling, so that functions with no calls are not necessarily ``leaf ! 1322: functions''. ! 1323: ! 1324: GNU CC assigns register numbers before it knows whether the function is ! 1325: suitable for leaf function treatment. So it needs to renumber the ! 1326: registers in order to output a leaf function. The following macros ! 1327: accomplish this. ! 1328: ! 1329: @table @code ! 1330: @findex LEAF_REGISTERS ! 1331: @item LEAF_REGISTERS ! 1332: A C initializer for a vector, indexed by hard register number, which ! 1333: contains 1 for a register that is allowable in a candidate for leaf ! 1334: function treatment. ! 1335: ! 1336: If leaf function treatment involves renumbering the registers, then the ! 1337: registers marked here should be the ones before renumbering---those that ! 1338: GNU CC would ordinarily allocate. The registers which will actually be ! 1339: used in the assembler code, after renumbering, should not be marked with 1 ! 1340: in this vector. ! 1341: ! 1342: Define this macro only if the target machine offers a way to optimize ! 1343: the treatment of leaf functions. ! 1344: ! 1345: @findex LEAF_REG_REMAP ! 1346: @item LEAF_REG_REMAP (@var{regno}) ! 1347: A C expression whose value is the register number to which @var{regno} ! 1348: should be renumbered, when a function is treated as a leaf function. ! 1349: ! 1350: If @var{regno} is a register number which should not appear in a leaf ! 1351: function before renumbering, then the expression should yield -1, which ! 1352: will cause the compiler to abort. ! 1353: ! 1354: Define this macro only if the target machine offers a way to optimize the ! 1355: treatment of leaf functions, and registers need to be renumbered to do ! 1356: this. ! 1357: ! 1358: @findex REG_LEAF_ALLOC_ORDER ! 1359: @item REG_LEAF_ALLOC_ORDER ! 1360: If defined, an initializer for a vector of integers, containing the ! 1361: numbers of hard registers in the order in which the GNU CC should prefer ! 1362: to use them (from most preferred to least) in a leaf function. If this ! 1363: macro is not defined, REG_ALLOC_ORDER is used for both non-leaf and ! 1364: leaf-functions. ! 1365: @c *important*.. is the above all-caps phrase supposed tobe in code ! 1366: @c font? --mew 2feb93 ! 1367: @end table ! 1368: ! 1369: @findex leaf_function ! 1370: Normally, @code{FUNCTION_PROLOGUE} and @code{FUNCTION_EPILOGUE} must ! 1371: treat leaf functions specially. It can test the C variable ! 1372: @code{leaf_function} which is nonzero for leaf functions. (The variable ! 1373: @code{leaf_function} is defined only if @code{LEAF_REGISTERS} is ! 1374: defined.) ! 1375: @c changed this to fix overfull. ALSO: why the "it" at the beginning ! 1376: @c of the next paragraph?! --mew 2feb93 ! 1377: ! 1378: @node Stack Registers ! 1379: @subsection Registers That Form a Stack ! 1380: ! 1381: There are special features to handle computers where some of the ! 1382: ``registers'' form a stack, as in the 80387 coprocessor for the 80386. ! 1383: Stack registers are normally written by pushing onto the stack, and are ! 1384: numbered relative to the top of the stack. ! 1385: ! 1386: Currently, GNU CC can only handle one group of stack-like registers, and ! 1387: they must be consecutively numbered. ! 1388: ! 1389: @table @code ! 1390: @findex STACK_REGS ! 1391: @item STACK_REGS ! 1392: Define this if the machine has any stack-like registers. ! 1393: ! 1394: @findex FIRST_STACK_REG ! 1395: @item FIRST_STACK_REG ! 1396: The number of the first stack-like register. This one is the top ! 1397: of the stack. ! 1398: ! 1399: @findex LAST_STACK_REG ! 1400: @item LAST_STACK_REG ! 1401: The number of the last stack-like register. This one is the bottom of ! 1402: the stack. ! 1403: @end table ! 1404: ! 1405: @node Obsolete Register Macros ! 1406: @subsection Obsolete Macros for Controlling Register Usage ! 1407: ! 1408: These features do not work very well. They exist because they used to ! 1409: be required to generate correct code for the 80387 coprocessor of the ! 1410: 80386. They are no longer used by that machine description and may be ! 1411: removed in a later version of the compiler. Don't use them! ! 1412: ! 1413: @table @code ! 1414: @findex OVERLAPPING_REGNO_P ! 1415: @item OVERLAPPING_REGNO_P (@var{regno}) ! 1416: If defined, this is a C expression whose value is nonzero if hard ! 1417: register number @var{regno} is an overlapping register. This means a ! 1418: hard register which overlaps a hard register with a different number. ! 1419: (Such overlap is undesirable, but occasionally it allows a machine to ! 1420: be supported which otherwise could not be.) This macro must return ! 1421: nonzero for @emph{all} the registers which overlap each other. GNU CC ! 1422: can use an overlapping register only in certain limited ways. It can ! 1423: be used for allocation within a basic block, and may be spilled for ! 1424: reloading; that is all. ! 1425: ! 1426: If this macro is not defined, it means that none of the hard registers ! 1427: overlap each other. This is the usual situation. ! 1428: ! 1429: @findex INSN_CLOBBERS_REGNO_P ! 1430: @item INSN_CLOBBERS_REGNO_P (@var{insn}, @var{regno}) ! 1431: If defined, this is a C expression whose value should be nonzero if ! 1432: the insn @var{insn} has the effect of mysteriously clobbering the ! 1433: contents of hard register number @var{regno}. By ``mysterious'' we ! 1434: mean that the insn's RTL expression doesn't describe such an effect. ! 1435: ! 1436: If this macro is not defined, it means that no insn clobbers registers ! 1437: mysteriously. This is the usual situation; all else being equal, ! 1438: it is best for the RTL expression to show all the activity. ! 1439: ! 1440: @cindex death notes ! 1441: @findex PRESERVE_DEATH_INFO_REGNO_P ! 1442: @item PRESERVE_DEATH_INFO_REGNO_P (@var{regno}) ! 1443: If defined, this is a C expression whose value is nonzero if accurate ! 1444: @code{REG_DEAD} notes are needed for hard register number @var{regno} ! 1445: at the time of outputting the assembler code. When this is so, a few ! 1446: optimizations that take place after register allocation and could ! 1447: invalidate the death notes are not done when this register is ! 1448: involved. ! 1449: ! 1450: You would arrange to preserve death info for a register when some of the ! 1451: code in the machine description which is executed to write the assembler ! 1452: code looks at the death notes. This is necessary only when the actual ! 1453: hardware feature which GNU CC thinks of as a register is not actually a ! 1454: register of the usual sort. (It might, for example, be a hardware ! 1455: stack.) ! 1456: ! 1457: If this macro is not defined, it means that no death notes need to be ! 1458: preserved. This is the usual situation. ! 1459: @end table ! 1460: ! 1461: @node Register Classes ! 1462: @section Register Classes ! 1463: @cindex register class definitions ! 1464: @cindex class definitions, register ! 1465: ! 1466: On many machines, the numbered registers are not all equivalent. ! 1467: For example, certain registers may not be allowed for indexed addressing; ! 1468: certain registers may not be allowed in some instructions. These machine ! 1469: restrictions are described to the compiler using @dfn{register classes}. ! 1470: ! 1471: You define a number of register classes, giving each one a name and saying ! 1472: which of the registers belong to it. Then you can specify register classes ! 1473: that are allowed as operands to particular instruction patterns. ! 1474: ! 1475: @findex ALL_REGS ! 1476: @findex NO_REGS ! 1477: In general, each register will belong to several classes. In fact, one ! 1478: class must be named @code{ALL_REGS} and contain all the registers. Another ! 1479: class must be named @code{NO_REGS} and contain no registers. Often the ! 1480: union of two classes will be another class; however, this is not required. ! 1481: ! 1482: @findex GENERAL_REGS ! 1483: One of the classes must be named @code{GENERAL_REGS}. There is nothing ! 1484: terribly special about the name, but the operand constraint letters ! 1485: @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is ! 1486: the same as @code{ALL_REGS}, just define it as a macro which expands ! 1487: to @code{ALL_REGS}. ! 1488: ! 1489: Order the classes so that if class @var{x} is contained in class @var{y} ! 1490: then @var{x} has a lower class number than @var{y}. ! 1491: ! 1492: The way classes other than @code{GENERAL_REGS} are specified in operand ! 1493: constraints is through machine-dependent operand constraint letters. ! 1494: You can define such letters to correspond to various classes, then use ! 1495: them in operand constraints. ! 1496: ! 1497: You should define a class for the union of two classes whenever some ! 1498: instruction allows both classes. For example, if an instruction allows ! 1499: either a floating point (coprocessor) register or a general register for a ! 1500: certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS} ! 1501: which includes both of them. Otherwise you will get suboptimal code. ! 1502: ! 1503: You must also specify certain redundant information about the register ! 1504: classes: for each class, which classes contain it and which ones are ! 1505: contained in it; for each pair of classes, the largest class contained ! 1506: in their union. ! 1507: ! 1508: When a value occupying several consecutive registers is expected in a ! 1509: certain class, all the registers used must belong to that class. ! 1510: Therefore, register classes cannot be used to enforce a requirement for ! 1511: a register pair to start with an even-numbered register. The way to ! 1512: specify this requirement is with @code{HARD_REGNO_MODE_OK}. ! 1513: ! 1514: Register classes used for input-operands of bitwise-and or shift ! 1515: instructions have a special requirement: each such class must have, for ! 1516: each fixed-point machine mode, a subclass whose registers can transfer that ! 1517: mode to or from memory. For example, on some machines, the operations for ! 1518: single-byte values (@code{QImode}) are limited to certain registers. When ! 1519: this is so, each register class that is used in a bitwise-and or shift ! 1520: instruction must have a subclass consisting of registers from which ! 1521: single-byte values can be loaded or stored. This is so that ! 1522: @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return. ! 1523: ! 1524: @table @code ! 1525: @findex enum reg_class ! 1526: @item enum reg_class ! 1527: An enumeral type that must be defined with all the register class names ! 1528: as enumeral values. @code{NO_REGS} must be first. @code{ALL_REGS} ! 1529: must be the last register class, followed by one more enumeral value, ! 1530: @code{LIM_REG_CLASSES}, which is not a register class but rather ! 1531: tells how many classes there are. ! 1532: ! 1533: Each register class has a number, which is the value of casting ! 1534: the class name to type @code{int}. The number serves as an index ! 1535: in many of the tables described below. ! 1536: ! 1537: @findex N_REG_CLASSES ! 1538: @item N_REG_CLASSES ! 1539: The number of distinct register classes, defined as follows: ! 1540: ! 1541: @example ! 1542: #define N_REG_CLASSES (int) LIM_REG_CLASSES ! 1543: @end example ! 1544: ! 1545: @findex REG_CLASS_NAMES ! 1546: @item REG_CLASS_NAMES ! 1547: An initializer containing the names of the register classes as C string ! 1548: constants. These names are used in writing some of the debugging dumps. ! 1549: ! 1550: @findex REG_CLASS_CONTENTS ! 1551: @item REG_CLASS_CONTENTS ! 1552: An initializer containing the contents of the register classes, as integers ! 1553: which are bit masks. The @var{n}th integer specifies the contents of class ! 1554: @var{n}. The way the integer @var{mask} is interpreted is that ! 1555: register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1. ! 1556: ! 1557: When the machine has more than 32 registers, an integer does not suffice. ! 1558: Then the integers are replaced by sub-initializers, braced groupings containing ! 1559: several integers. Each sub-initializer must be suitable as an initializer ! 1560: for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}. ! 1561: ! 1562: @findex REGNO_REG_CLASS ! 1563: @item REGNO_REG_CLASS (@var{regno}) ! 1564: A C expression whose value is a register class containing hard register ! 1565: @var{regno}. In general there is more than one such class; choose a class ! 1566: which is @dfn{minimal}, meaning that no smaller class also contains the ! 1567: register. ! 1568: ! 1569: @findex BASE_REG_CLASS ! 1570: @item BASE_REG_CLASS ! 1571: A macro whose definition is the name of the class to which a valid ! 1572: base register must belong. A base register is one used in an address ! 1573: which is the register value plus a displacement. ! 1574: ! 1575: @findex INDEX_REG_CLASS ! 1576: @item INDEX_REG_CLASS ! 1577: A macro whose definition is the name of the class to which a valid ! 1578: index register must belong. An index register is one used in an ! 1579: address where its value is either multiplied by a scale factor or ! 1580: added to another register (as well as added to a displacement). ! 1581: ! 1582: @findex REG_CLASS_FROM_LETTER ! 1583: @item REG_CLASS_FROM_LETTER (@var{char}) ! 1584: A C expression which defines the machine-dependent operand constraint ! 1585: letters for register classes. If @var{char} is such a letter, the ! 1586: value should be the register class corresponding to it. Otherwise, ! 1587: the value should be @code{NO_REGS}. The register letter @samp{r}, ! 1588: corresponding to class @code{GENERAL_REGS}, will not be passed ! 1589: to this macro; you do not need to handle it. ! 1590: ! 1591: @findex REGNO_OK_FOR_BASE_P ! 1592: @item REGNO_OK_FOR_BASE_P (@var{num}) ! 1593: A C expression which is nonzero if register number @var{num} is ! 1594: suitable for use as a base register in operand addresses. It may be ! 1595: either a suitable hard register or a pseudo register that has been ! 1596: allocated such a hard register. ! 1597: ! 1598: @findex REGNO_OK_FOR_INDEX_P ! 1599: @item REGNO_OK_FOR_INDEX_P (@var{num}) ! 1600: A C expression which is nonzero if register number @var{num} is ! 1601: suitable for use as an index register in operand addresses. It may be ! 1602: either a suitable hard register or a pseudo register that has been ! 1603: allocated such a hard register. ! 1604: ! 1605: The difference between an index register and a base register is that ! 1606: the index register may be scaled. If an address involves the sum of ! 1607: two registers, neither one of them scaled, then either one may be ! 1608: labeled the ``base'' and the other the ``index''; but whichever ! 1609: labeling is used must fit the machine's constraints of which registers ! 1610: may serve in each capacity. The compiler will try both labelings, ! 1611: looking for one that is valid, and will reload one or both registers ! 1612: only if neither labeling works. ! 1613: ! 1614: @findex PREFERRED_RELOAD_CLASS ! 1615: @item PREFERRED_RELOAD_CLASS (@var{x}, @var{class}) ! 1616: A C expression that places additional restrictions on the register class ! 1617: to use when it is necessary to copy value @var{x} into a register in class ! 1618: @var{class}. The value is a register class; perhaps @var{class}, or perhaps ! 1619: another, smaller class. On many machines, the following definition is ! 1620: safe: ! 1621: ! 1622: @example ! 1623: #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS ! 1624: @end example ! 1625: ! 1626: Sometimes returning a more restrictive class makes better code. For ! 1627: example, on the 68000, when @var{x} is an integer constant that is in range ! 1628: for a @samp{moveq} instruction, the value of this macro is always ! 1629: @code{DATA_REGS} as long as @var{class} includes the data registers. ! 1630: Requiring a data register guarantees that a @samp{moveq} will be used. ! 1631: ! 1632: If @var{x} is a @code{const_double}, by returning @code{NO_REGS} ! 1633: you can force @var{x} into a memory constant. This is useful on ! 1634: certain machines where immediate floating values cannot be loaded into ! 1635: certain kinds of registers. ! 1636: ! 1637: @findex PREFERRED_OUTPUT_RELOAD_CLASS ! 1638: @item PREFERRED_OUTPUT_RELOAD_CLASS (@var{x}, @var{class}) ! 1639: Like @code{PREFERRED_RELOAD_CLASS}, but for output reloads instead of ! 1640: input reloads. If you don't define this macro, the default is to use ! 1641: @var{class}, unchanged. ! 1642: ! 1643: @findex LIMIT_RELOAD_CLASS ! 1644: @item LIMIT_RELOAD_CLASS (@var{mode}, @var{class}) ! 1645: A C expression that places additional restrictions on the register class ! 1646: to use when it is necessary to be able to hold a value of mode ! 1647: @var{mode} in a reload register for which class @var{class} would ! 1648: ordinarily be used. ! 1649: ! 1650: Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when ! 1651: there are certain modes that simply can't go in certain reload classes. ! 1652: ! 1653: The value is a register class; perhaps @var{class}, or perhaps another, ! 1654: smaller class. ! 1655: ! 1656: Don't define this macro unless the target machine has limitations which ! 1657: require the macro to do something nontrivial. ! 1658: ! 1659: @findex SECONDARY_RELOAD_CLASS ! 1660: @findex SECONDARY_INPUT_RELOAD_CLASS ! 1661: @findex SECONDARY_OUTPUT_RELOAD_CLASS ! 1662: @item SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) ! 1663: @itemx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) ! 1664: @itemx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x}) ! 1665: Many machines have some registers that cannot be copied directly to or ! 1666: from memory or even from other types of registers. An example is the ! 1667: @samp{MQ} register, which on most machines, can only be copied to or ! 1668: from general registers, but not memory. Some machines allow copying all ! 1669: registers to and from memory, but require a scratch register for stores ! 1670: to some memory locations (e.g., those with symbolic address on the RT, ! 1671: and those with certain symbolic address on the Sparc when compiling ! 1672: PIC). In some cases, both an intermediate and a scratch register are ! 1673: required. ! 1674: ! 1675: You should define these macros to indicate to the reload phase that it may ! 1676: need to allocate at least one register for a reload in addition to the ! 1677: register to contain the data. Specifically, if copying @var{x} to a ! 1678: register @var{class} in @var{mode} requires an intermediate register, ! 1679: you should define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the ! 1680: largest register class all of whose registers can be used as ! 1681: intermediate registers or scratch registers. ! 1682: ! 1683: If copying a register @var{class} in @var{mode} to @var{x} requires an ! 1684: intermediate or scratch register, @code{SECONDARY_OUTPUT_RELOAD_CLASS} ! 1685: should be defined to return the largest register class required. If the ! 1686: requirements for input and output reloads are the same, the macro ! 1687: @code{SECONDARY_RELOAD_CLASS} should be used instead of defining both ! 1688: macros identically. ! 1689: ! 1690: The values returned by these macros are often @code{GENERAL_REGS}. ! 1691: Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x} ! 1692: can be directly copied to or from a register of @var{class} in ! 1693: @var{mode} without requiring a scratch register. Do not define this ! 1694: macro if it would always return @code{NO_REGS}. ! 1695: ! 1696: If a scratch register is required (either with or without an ! 1697: intermediate register), you should define patterns for ! 1698: @samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required ! 1699: (@pxref{Standard Names}. These patterns, which will normally be ! 1700: implemented with a @code{define_expand}, should be similar to the ! 1701: @samp{mov@var{m}} patterns, except that operand 2 is the scratch ! 1702: register. ! 1703: ! 1704: Define constraints for the reload register and scratch register that ! 1705: contain a single register class. If the original reload register (whose ! 1706: class is @var{class}) can meet the constraint given in the pattern, the ! 1707: value returned by these macros is used for the class of the scratch ! 1708: register. Otherwise, two additional reload registers are required. ! 1709: Their classes are obtained from the constraints in the insn pattern. ! 1710: ! 1711: @var{x} might be a pseudo-register or a @code{subreg} of a ! 1712: pseudo-register, which could either be in a hard register or in memory. ! 1713: Use @code{true_regnum} to find out; it will return -1 if the pseudo is ! 1714: in memory and the hard register number if it is in a register. ! 1715: ! 1716: These macros should not be used in the case where a particular class of ! 1717: registers can only be copied to memory and not to another class of ! 1718: registers. In that case, secondary reload registers are not needed and ! 1719: would not be helpful. Instead, a stack location must be used to perform ! 1720: the copy and the @code{mov@var{m}} pattern should use memory as a ! 1721: intermediate storage. This case often occurs between floating-point and ! 1722: general registers. ! 1723: ! 1724: @findex SECONDARY_MEMORY_NEEDED ! 1725: @item SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m}) ! 1726: Certain machines have the property that some registers cannot be copied ! 1727: to some other registers without using memory. Define this macro on ! 1728: those machines to be a C expression that is non-zero if objects of mode ! 1729: @var{m} in registers of @var{class1} can only be copied to registers of ! 1730: class @var{class2} by storing a register of @var{class1} into memory ! 1731: and loading that memory location into a register of @var{class2}. ! 1732: ! 1733: Do not define this macro if its value would always be zero. ! 1734: ! 1735: @findex SECONDARY_MEMORY_NEEDED_RTX ! 1736: @item SECONDARY_MEMORY_NEEDED_RTX (@var{mode}) ! 1737: Normally, when @code{SECONDARY_MEMORY_NEEDED} is defined, the compiler ! 1738: will allocate a stack slot when a memory location for a register copy ! 1739: is needed. If this macro is defined, the compiler instead uses the ! 1740: memory location defined by this macro. ! 1741: ! 1742: @findex SMALL_REGISTER_CLASSES ! 1743: @item SMALL_REGISTER_CLASSES ! 1744: Normally the compiler will avoid choosing spill registers from registers ! 1745: that have been explicitly mentioned in the rtl (these registers are ! 1746: normally those used to pass parameters and return values). However, ! 1747: some machines have so few registers of certain classes that there would ! 1748: not be enough registers to use as spill registers if this were done. ! 1749: ! 1750: You should define @code{SMALL_REGISTER_CLASSES} on those machines. When ! 1751: it is defined, the compiler allows registers explicitly used in the rtl ! 1752: to be used as spill registers but prevents the compiler from extending ! 1753: the lifetime of these registers. ! 1754: ! 1755: Defining this macro is always safe, but unnecessarily defining this macro ! 1756: will reduce the amount of optimizations that can be performed in some ! 1757: cases. If this macro is not defined but needs to be, the compiler will ! 1758: run out of reload registers and print a fatal error message. ! 1759: ! 1760: For most machines, this macro should not be defined. ! 1761: ! 1762: @findex CLASS_LIKELY_SPILLED_P ! 1763: @item CLASS_LIKELY_SPILLED_P (@var{class}) ! 1764: A C expression whose value is nonzero if pseudos that have been assigned ! 1765: to registers of class @var{class} would likely be spilled because ! 1766: registers of @var{class} are needed for spill registers. ! 1767: ! 1768: The default value of this macro returns 1 if @var{class} has exactly one ! 1769: register and zero otherwise. On most machines, this default should be ! 1770: used. Only define this macro to some other expression if pseudo ! 1771: allocated by @file{local-alloc.c} end up in memory because their hard ! 1772: registers were needed for spill regisers. If this macro returns nonzero ! 1773: for those classes, those pseudos will only be allocated by ! 1774: @file{global.c}, which knows how to reallocate the pseudo to another ! 1775: register. If there would not be another register available for ! 1776: reallocation, you should not change the definition of this macro since ! 1777: the only effect of such a definition would be to slow down register ! 1778: allocation. ! 1779: ! 1780: @findex CLASS_MAX_NREGS ! 1781: @item CLASS_MAX_NREGS (@var{class}, @var{mode}) ! 1782: A C expression for the maximum number of consecutive registers ! 1783: of class @var{class} needed to hold a value of mode @var{mode}. ! 1784: ! 1785: This is closely related to the macro @code{HARD_REGNO_NREGS}. ! 1786: In fact, the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})} ! 1787: should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno}, @var{mode})} ! 1788: for all @var{regno} values in the class @var{class}. ! 1789: ! 1790: This macro helps control the handling of multiple-word values ! 1791: in the reload pass. ! 1792: @end table ! 1793: ! 1794: Three other special macros describe which operands fit which constraint ! 1795: letters. ! 1796: ! 1797: @table @code ! 1798: @findex CONST_OK_FOR_LETTER_P ! 1799: @item CONST_OK_FOR_LETTER_P (@var{value}, @var{c}) ! 1800: A C expression that defines the machine-dependent operand constraint letters ! 1801: that specify particular ranges of integer values. If @var{c} is one ! 1802: of those letters, the expression should check that @var{value}, an integer, ! 1803: is in the appropriate range and return 1 if so, 0 otherwise. If @var{c} is ! 1804: not one of those letters, the value should be 0 regardless of @var{value}. ! 1805: ! 1806: @findex CONST_DOUBLE_OK_FOR_LETTER_P ! 1807: @item CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c}) ! 1808: A C expression that defines the machine-dependent operand constraint ! 1809: letters that specify particular ranges of @code{const_double} values. ! 1810: ! 1811: If @var{c} is one of those letters, the expression should check that ! 1812: @var{value}, an RTX of code @code{const_double}, is in the appropriate ! 1813: range and return 1 if so, 0 otherwise. If @var{c} is not one of those ! 1814: letters, the value should be 0 regardless of @var{value}. ! 1815: ! 1816: @code{const_double} is used for all floating-point constants and for ! 1817: @code{DImode} fixed-point constants. A given letter can accept either ! 1818: or both kinds of values. It can use @code{GET_MODE} to distinguish ! 1819: between these kinds. ! 1820: ! 1821: @findex EXTRA_CONSTRAINT ! 1822: @item EXTRA_CONSTRAINT (@var{value}, @var{c}) ! 1823: A C expression that defines the optional machine-dependent constraint ! 1824: letters that can be used to segregate specific types of operands, ! 1825: usually memory references, for the target machine. Normally this macro ! 1826: will not be defined. If it is required for a particular target machine, ! 1827: it should return 1 if @var{value} corresponds to the operand type ! 1828: represented by the constraint letter @var{c}. If @var{c} is not defined ! 1829: as an extra constraint, the value returned should be 0 regardless of ! 1830: @var{value}. ! 1831: ! 1832: For example, on the ROMP, load instructions cannot have their output in r0 if ! 1833: the memory reference contains a symbolic address. Constraint letter ! 1834: @samp{Q} is defined as representing a memory address that does ! 1835: @emph{not} contain a symbolic address. An alternative is specified with ! 1836: a @samp{Q} constraint on the input and @samp{r} on the output. The next ! 1837: alternative specifies @samp{m} on the input and a register class that ! 1838: does not include r0 on the output. ! 1839: @end table ! 1840: ! 1841: @node Stack and Calling ! 1842: @section Stack Layout and Calling Conventions ! 1843: @cindex calling conventions ! 1844: ! 1845: @menu ! 1846: * Frame Layout:: ! 1847: * Frame Registers:: ! 1848: * Elimination:: ! 1849: * Stack Arguments:: ! 1850: * Register Arguments:: ! 1851: * Scalar Return:: ! 1852: * Aggregate Return:: ! 1853: * Caller Saves:: ! 1854: * Function Entry:: ! 1855: * Profiling:: ! 1856: @end menu ! 1857: ! 1858: @node Frame Layout ! 1859: @subsection Basic Stack Layout ! 1860: @cindex stack frame layout ! 1861: @cindex frame layout ! 1862: ! 1863: @table @code ! 1864: @findex STACK_GROWS_DOWNWARD ! 1865: @item STACK_GROWS_DOWNWARD ! 1866: Define this macro if pushing a word onto the stack moves the stack ! 1867: pointer to a smaller address. ! 1868: ! 1869: When we say, ``define this macro if @dots{},'' it means that the ! 1870: compiler checks this macro only with @code{#ifdef} so the precise ! 1871: definition used does not matter. ! 1872: ! 1873: @findex FRAME_GROWS_DOWNWARD ! 1874: @item FRAME_GROWS_DOWNWARD ! 1875: Define this macro if the addresses of local variable slots are at negative ! 1876: offsets from the frame pointer. ! 1877: ! 1878: @findex ARGS_GROW_DOWNWARD ! 1879: @item ARGS_GROW_DOWNWARD ! 1880: Define this macro if successive arguments to a function occupy decreasing ! 1881: addresses on the stack. ! 1882: ! 1883: @findex STARTING_FRAME_OFFSET ! 1884: @item STARTING_FRAME_OFFSET ! 1885: Offset from the frame pointer to the first local variable slot to be allocated. ! 1886: ! 1887: If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by ! 1888: subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}. ! 1889: Otherwise, it is found by adding the length of the first slot to the ! 1890: value @code{STARTING_FRAME_OFFSET}. ! 1891: @c i'm not sure if the above is still correct.. had to change it to get ! 1892: @c rid of an overfull. --mew 2feb93 ! 1893: ! 1894: @findex STACK_POINTER_OFFSET ! 1895: @item STACK_POINTER_OFFSET ! 1896: Offset from the stack pointer register to the first location at which ! 1897: outgoing arguments are placed. If not specified, the default value of ! 1898: zero is used. This is the proper value for most machines. ! 1899: ! 1900: If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above ! 1901: the first location at which outgoing arguments are placed. ! 1902: ! 1903: @findex FIRST_PARM_OFFSET ! 1904: @item FIRST_PARM_OFFSET (@var{fundecl}) ! 1905: Offset from the argument pointer register to the first argument's ! 1906: address. On some machines it may depend on the data type of the ! 1907: function. ! 1908: ! 1909: If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above ! 1910: the first argument's address. ! 1911: ! 1912: @findex STACK_DYNAMIC_OFFSET ! 1913: @item STACK_DYNAMIC_OFFSET (@var{fundecl}) ! 1914: Offset from the stack pointer register to an item dynamically allocated ! 1915: on the stack, e.g., by @code{alloca}. ! 1916: ! 1917: The default value for this macro is @code{STACK_POINTER_OFFSET} plus the ! 1918: length of the outgoing arguments. The default is correct for most ! 1919: machines. See @file{function.c} for details. ! 1920: ! 1921: @findex DYNAMIC_CHAIN_ADDRESS ! 1922: @item DYNAMIC_CHAIN_ADDRESS (@var{frameaddr}) ! 1923: A C expression whose value is RTL representing the address in a stack ! 1924: frame where the pointer to the caller's frame is stored. Assume that ! 1925: @var{frameaddr} is an RTL expression for the address of the stack frame ! 1926: itself. ! 1927: ! 1928: If you don't define this macro, the default is to return the value ! 1929: of @var{frameaddr}---that is, the stack frame address is also the ! 1930: address of the stack word that points to the previous frame. ! 1931: ! 1932: @findex SETUP_FRAME_ADDRESSES ! 1933: @item SERTUP_FRAME_ADDRESSES () ! 1934: If defined, a C expression that produces the machine-specific code to ! 1935: setup the stack so that arbitrary frames can be accessed. For example, ! 1936: on the Sparc, we must flush all of the register windows to the stack ! 1937: before we can access arbitrary stack frames. ! 1938: This macro will seldom need to be defined. ! 1939: ! 1940: @findex RETURN_ADDR_RTX ! 1941: @item RETURN_ADDR_RTX (@var{count}, @var{frameaddr}) ! 1942: A C expression whose value is RTL representing the value of the return ! 1943: address for the frame @var{count} steps up from the current frame. ! 1944: @var{frameaddr} is the frame pointer of the @var{count} frame, or ! 1945: the frame pointer of the @var{count} @minus{} 1 frame if ! 1946: @code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined. ! 1947: ! 1948: @findex RETURN_ADDR_IN_PREVIOUS_FRAME ! 1949: @item RETURN_ADDR_IN_PREVIOUS_FRAME ! 1950: Define this if the return address of a particular stack frame is accessed ! 1951: from the frame pointer of the previous stack frame. ! 1952: @end table ! 1953: ! 1954: @need 2000 ! 1955: @node Frame Registers ! 1956: @subsection Registers That Address the Stack Frame ! 1957: ! 1958: @table @code ! 1959: @findex STACK_POINTER_REGNUM ! 1960: @item STACK_POINTER_REGNUM ! 1961: The register number of the stack pointer register, which must also be a ! 1962: fixed register according to @code{FIXED_REGISTERS}. On most machines, ! 1963: the hardware determines which register this is. ! 1964: ! 1965: @findex FRAME_POINTER_REGNUM ! 1966: @item FRAME_POINTER_REGNUM ! 1967: The register number of the frame pointer register, which is used to ! 1968: access automatic variables in the stack frame. On some machines, the ! 1969: hardware determines which register this is. On other machines, you can ! 1970: choose any register you wish for this purpose. ! 1971: ! 1972: @findex HARD_FRAME_POINTER_REGNUM ! 1973: @item HARD_FRAME_POINTER_REGNUM ! 1974: On some machines the offset between the frame pointer and starting ! 1975: offset of the automatic variables is not known until after register ! 1976: allocation has been done (for example, because the saved registers are ! 1977: between these two locations). On those machines, ! 1978: @code{FRAME_POINTER_REGNUM} as a special, fixed register to be used ! 1979: internally until the offset is known, and define ! 1980: @code{HARD_FRAME_POINTER_REGNUM} to be the hard register used for the ! 1981: frame pointer. ! 1982: ! 1983: You should define this macro only in the very rare circumstances when it ! 1984: is not possible to calculate the offset between the frame pointer and ! 1985: the automatic variables until after register allocation has been ! 1986: completed. When this macro is defined, you must also indicate in your ! 1987: definition of @code{ELIMINABLE_REGS} how to eliminate ! 1988: @code{FRAME_POINTER_REGNUM} into either @code{HARD_FRAME_POINTER_REGNUM} ! 1989: or @code{STACK_POINTER_REGNUM}. ! 1990: ! 1991: Do not define this macro if it would be the same as ! 1992: @code{FRAME_POINTER_REGNUM}. ! 1993: ! 1994: @findex ARG_POINTER_REGNUM ! 1995: @item ARG_POINTER_REGNUM ! 1996: The register number of the arg pointer register, which is used to access ! 1997: the function's argument list. On some machines, this is the same as the ! 1998: frame pointer register. On some machines, the hardware determines which ! 1999: register this is. On other machines, you can choose any register you ! 2000: wish for this purpose. If this is not the same register as the frame ! 2001: pointer register, then you must mark it as a fixed register according to ! 2002: @code{FIXED_REGISTERS}, or arrange to be able to eliminate it ! 2003: (@pxref{Elimination}). ! 2004: ! 2005: @findex STATIC_CHAIN_REGNUM ! 2006: @findex STATIC_CHAIN_INCOMING_REGNUM ! 2007: @item STATIC_CHAIN_REGNUM ! 2008: @itemx STATIC_CHAIN_INCOMING_REGNUM ! 2009: Register numbers used for passing a function's static chain pointer. If ! 2010: register windows are used, the register number as seen by the called ! 2011: function is @code{STATIC_CHAIN_INCOMING_REGNUM}, while the register ! 2012: number as seen by the calling function is @code{STATIC_CHAIN_REGNUM}. If ! 2013: these registers are the same, @code{STATIC_CHAIN_INCOMING_REGNUM} need ! 2014: not be defined.@refill ! 2015: ! 2016: The static chain register need not be a fixed register. ! 2017: ! 2018: If the static chain is passed in memory, these macros should not be ! 2019: defined; instead, the next two macros should be defined. ! 2020: ! 2021: @findex STATIC_CHAIN ! 2022: @findex STATIC_CHAIN_INCOMING ! 2023: @item STATIC_CHAIN ! 2024: @itemx STATIC_CHAIN_INCOMING ! 2025: If the static chain is passed in memory, these macros provide rtx giving ! 2026: @code{mem} expressions that denote where they are stored. ! 2027: @code{STATIC_CHAIN} and @code{STATIC_CHAIN_INCOMING} give the locations ! 2028: as seen by the calling and called functions, respectively. Often the former ! 2029: will be at an offset from the stack pointer and the latter at an offset from ! 2030: the frame pointer.@refill ! 2031: ! 2032: @findex stack_pointer_rtx ! 2033: @findex frame_pointer_rtx ! 2034: @findex arg_pointer_rtx ! 2035: The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and ! 2036: @code{arg_pointer_rtx} will have been initialized prior to the use of these ! 2037: macros and should be used to refer to those items. ! 2038: ! 2039: If the static chain is passed in a register, the two previous macros should ! 2040: be defined instead. ! 2041: @end table ! 2042: ! 2043: @node Elimination ! 2044: @subsection Eliminating Frame Pointer and Arg Pointer ! 2045: ! 2046: @table @code ! 2047: @findex FRAME_POINTER_REQUIRED ! 2048: @item FRAME_POINTER_REQUIRED ! 2049: A C expression which is nonzero if a function must have and use a frame ! 2050: pointer. This expression is evaluated in the reload pass. If its value is ! 2051: nonzero the function will have a frame pointer. ! 2052: ! 2053: The expression can in principle examine the current function and decide ! 2054: according to the facts, but on most machines the constant 0 or the ! 2055: constant 1 suffices. Use 0 when the machine allows code to be generated ! 2056: with no frame pointer, and doing so saves some time or space. Use 1 ! 2057: when there is no possible advantage to avoiding a frame pointer. ! 2058: ! 2059: In certain cases, the compiler does not know how to produce valid code ! 2060: without a frame pointer. The compiler recognizes those cases and ! 2061: automatically gives the function a frame pointer regardless of what ! 2062: @code{FRAME_POINTER_REQUIRED} says. You don't need to worry about ! 2063: them.@refill ! 2064: ! 2065: In a function that does not require a frame pointer, the frame pointer ! 2066: register can be allocated for ordinary usage, unless you mark it as a ! 2067: fixed register. See @code{FIXED_REGISTERS} for more information. ! 2068: ! 2069: This macro is ignored and you do not need to define it if the function ! 2070: @code{ELIMINABLE_REGS} is defined. ! 2071: ! 2072: @findex INITIAL_FRAME_POINTER_OFFSET ! 2073: @findex get_frame_size ! 2074: @item INITIAL_FRAME_POINTER_OFFSET (@var{depth-var}) ! 2075: A C statement to store in the variable @var{depth-var} the difference ! 2076: between the frame pointer and the stack pointer values immediately after ! 2077: the function prologue. The value would be computed from information ! 2078: such as the result of @code{get_frame_size ()} and the tables of ! 2079: registers @code{regs_ever_live} and @code{call_used_regs}. ! 2080: ! 2081: If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and ! 2082: need not be defined. Otherwise, it must be defined even if ! 2083: @code{FRAME_POINTER_REQUIRED} is defined to always be true; in that ! 2084: case, you may set @var{depth-var} to anything. ! 2085: ! 2086: @findex ELIMINABLE_REGS ! 2087: @item ELIMINABLE_REGS ! 2088: If defined, this macro specifies a table of register pairs used to ! 2089: eliminate unneeded registers that point into the stack frame. If it is not ! 2090: defined, the only elimination attempted by the compiler is to replace ! 2091: references to the frame pointer with references to the stack pointer. ! 2092: ! 2093: The definition of this macro is a list of structure initializations, each ! 2094: of which specifies an original and replacement register. ! 2095: ! 2096: On some machines, the position of the argument pointer is not known until ! 2097: the compilation is completed. In such a case, a separate hard register ! 2098: must be used for the argument pointer. This register can be eliminated by ! 2099: replacing it with either the frame pointer or the argument pointer, ! 2100: depending on whether or not the frame pointer has been eliminated. ! 2101: ! 2102: In this case, you might specify: ! 2103: @example ! 2104: #define ELIMINABLE_REGS \ ! 2105: @{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \ ! 2106: @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \ ! 2107: @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@} ! 2108: @end example ! 2109: ! 2110: Note that the elimination of the argument pointer with the stack pointer is ! 2111: specified first since that is the preferred elimination. ! 2112: ! 2113: @findex CAN_ELIMINATE ! 2114: @item CAN_ELIMINATE (@var{from-reg}, @var{to-reg}) ! 2115: A C expression that returns non-zero if the compiler is allowed to try ! 2116: to replace register number @var{from-reg} with register number ! 2117: @var{to-reg}. This macro need only be defined if @code{ELIMINABLE_REGS} ! 2118: is defined, and will usually be the constant 1, since most of the cases ! 2119: preventing register elimination are things that the compiler already ! 2120: knows about. ! 2121: ! 2122: @findex INITIAL_ELIMINATION_OFFSET ! 2123: @item INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var}) ! 2124: This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It ! 2125: specifies the initial difference between the specified pair of ! 2126: registers. This macro must be defined if @code{ELIMINABLE_REGS} is ! 2127: defined. ! 2128: ! 2129: @findex LONGJMP_RESTORE_FROM_STACK ! 2130: @item LONGJMP_RESTORE_FROM_STACK ! 2131: Define this macro if the @code{longjmp} function restores registers from ! 2132: the stack frames, rather than from those saved specifically by ! 2133: @code{setjmp}. Certain quantities must not be kept in registers across ! 2134: a call to @code{setjmp} on such machines. ! 2135: @end table ! 2136: ! 2137: @node Stack Arguments ! 2138: @subsection Passing Function Arguments on the Stack ! 2139: @cindex arguments on stack ! 2140: @cindex stack arguments ! 2141: ! 2142: The macros in this section control how arguments are passed ! 2143: on the stack. See the following section for other macros that ! 2144: control passing certain arguments in registers. ! 2145: ! 2146: @table @code ! 2147: @findex PROMOTE_PROTOTYPES ! 2148: @item PROMOTE_PROTOTYPES ! 2149: Define this macro if an argument declared in a prototype as an ! 2150: integral type smaller than @code{int} should actually be passed as an ! 2151: @code{int}. In addition to avoiding errors in certain cases of ! 2152: mismatch, it also makes for better code on certain machines. ! 2153: ! 2154: @findex PUSH_ROUNDING ! 2155: @item PUSH_ROUNDING (@var{npushed}) ! 2156: A C expression that is the number of bytes actually pushed onto the ! 2157: stack when an instruction attempts to push @var{npushed} bytes. ! 2158: ! 2159: If the target machine does not have a push instruction, do not define ! 2160: this macro. That directs GNU CC to use an alternate strategy: to ! 2161: allocate the entire argument block and then store the arguments into ! 2162: it. ! 2163: ! 2164: On some machines, the definition ! 2165: ! 2166: @example ! 2167: #define PUSH_ROUNDING(BYTES) (BYTES) ! 2168: @end example ! 2169: ! 2170: @noindent ! 2171: will suffice. But on other machines, instructions that appear ! 2172: to push one byte actually push two bytes in an attempt to maintain ! 2173: alignment. Then the definition should be ! 2174: ! 2175: @example ! 2176: #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) ! 2177: @end example ! 2178: ! 2179: @findex ACCUMULATE_OUTGOING_ARGS ! 2180: @findex current_function_outgoing_args_size ! 2181: @item ACCUMULATE_OUTGOING_ARGS ! 2182: If defined, the maximum amount of space required for outgoing arguments ! 2183: will be computed and placed into the variable ! 2184: @code{current_function_outgoing_args_size}. No space will be pushed ! 2185: onto the stack for each call; instead, the function prologue should ! 2186: increase the stack frame size by this amount. ! 2187: ! 2188: Defining both @code{PUSH_ROUNDING} and @code{ACCUMULATE_OUTGOING_ARGS} ! 2189: is not proper. ! 2190: ! 2191: @findex REG_PARM_STACK_SPACE ! 2192: @item REG_PARM_STACK_SPACE (@var{fndecl}) ! 2193: Define this macro if functions should assume that stack space has been ! 2194: allocated for arguments even when their values are passed in ! 2195: registers. ! 2196: ! 2197: The value of this macro is the size, in bytes, of the area reserved for ! 2198: arguments passed in registers for the function represented by @var{fndecl}. ! 2199: ! 2200: This space can be allocated by the caller, or be a part of the ! 2201: machine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE} says ! 2202: which. ! 2203: @c above is overfull. not sure what to do. --mew 5feb93 did ! 2204: @c something, not sure if it looks good. --mew 10feb93 ! 2205: ! 2206: @findex MAYBE_REG_PARM_STACK_SPACE ! 2207: @findex FINAL_REG_PARM_STACK_SPACE ! 2208: @item MAYBE_REG_PARM_STACK_SPACE ! 2209: @itemx FINAL_REG_PARM_STACK_SPACE (@var{const_size}, @var{var_size}) ! 2210: Define these macros in addition to the one above if functions might ! 2211: allocate stack space for arguments even when their values are passed ! 2212: in registers. These should be used when the stack space allocated ! 2213: for arguments in registers is not a simple constant independent of the ! 2214: function declaration. ! 2215: ! 2216: The value of the first macro is the size, in bytes, of the area that ! 2217: we should initially assume would be reserved for arguments passed in registers. ! 2218: ! 2219: The value of the second macro is the actual size, in bytes, of the area ! 2220: that will be reserved for arguments passed in registers. This takes two ! 2221: arguments: an integer representing the number of bytes of fixed sized ! 2222: arguments on the stack, and a tree representing the number of bytes of ! 2223: variable sized arguments on the stack. ! 2224: ! 2225: When these macros are defined, @code{REG_PARM_STACK_SPACE} will only be ! 2226: called for libcall functions, the current function, or for a function ! 2227: being called when it is known that such stack space must be allocated. ! 2228: In each case this value can be easily computed. ! 2229: ! 2230: When deciding whether a called function needs such stack space, and how ! 2231: much space to reserve, GNU CC uses these two macros instead of ! 2232: @code{REG_PARM_STACK_SPACE}. ! 2233: ! 2234: @findex OUTGOING_REG_PARM_STACK_SPACE ! 2235: @item OUTGOING_REG_PARM_STACK_SPACE ! 2236: Define this if it is the responsibility of the caller to allocate the area ! 2237: reserved for arguments passed in registers. ! 2238: ! 2239: If @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls ! 2240: whether the space for these arguments counts in the value of ! 2241: @code{current_function_outgoing_args_size}. ! 2242: ! 2243: @findex STACK_PARMS_IN_REG_PARM_AREA ! 2244: @item STACK_PARMS_IN_REG_PARM_AREA ! 2245: Define this macro if @code{REG_PARM_STACK_SPACE} is defined, but the ! 2246: stack parameters don't skip the area specified by it. ! 2247: @c i changed this, makes more sens and it should have taken care of the ! 2248: @c overfull.. not as specific, tho. --mew 5feb93 ! 2249: ! 2250: Normally, when a parameter is not passed in registers, it is placed on the ! 2251: stack beyond the @code{REG_PARM_STACK_SPACE} area. Defining this macro ! 2252: suppresses this behavior and causes the parameter to be passed on the ! 2253: stack in its natural location. ! 2254: ! 2255: @findex RETURN_POPS_ARGS ! 2256: @item RETURN_POPS_ARGS (@var{funtype}, @var{stack-size}) ! 2257: A C expression that should indicate the number of bytes of its own ! 2258: arguments that a function pops on returning, or 0 if the ! 2259: function pops no arguments and the caller must therefore pop them all ! 2260: after the function returns. ! 2261: ! 2262: @var{funtype} is a C variable whose value is a tree node that ! 2263: describes the function in question. Normally it is a node of type ! 2264: @code{FUNCTION_TYPE} that describes the data type of the function. ! 2265: From this it is possible to obtain the data types of the value and ! 2266: arguments (if known). ! 2267: ! 2268: When a call to a library function is being considered, @var{funtype} ! 2269: will contain an identifier node for the library function. Thus, if ! 2270: you need to distinguish among various library functions, you can do so ! 2271: by their names. Note that ``library function'' in this context means ! 2272: a function used to perform arithmetic, whose name is known specially ! 2273: in the compiler and was not mentioned in the C code being compiled. ! 2274: ! 2275: @var{stack-size} is the number of bytes of arguments passed on the ! 2276: stack. If a variable number of bytes is passed, it is zero, and ! 2277: argument popping will always be the responsibility of the calling function. ! 2278: ! 2279: On the Vax, all functions always pop their arguments, so the definition ! 2280: of this macro is @var{stack-size}. On the 68000, using the standard ! 2281: calling convention, no functions pop their arguments, so the value of ! 2282: the macro is always 0 in this case. But an alternative calling ! 2283: convention is available in which functions that take a fixed number of ! 2284: arguments pop them but other functions (such as @code{printf}) pop ! 2285: nothing (the caller pops all). When this convention is in use, ! 2286: @var{funtype} is examined to determine whether a function takes a fixed ! 2287: number of arguments. ! 2288: @end table ! 2289: ! 2290: @node Register Arguments ! 2291: @subsection Passing Arguments in Registers ! 2292: @cindex arguments in registers ! 2293: @cindex registers arguments ! 2294: ! 2295: This section describes the macros which let you control how various ! 2296: types of arguments are passed in registers or how they are arranged in ! 2297: the stack. ! 2298: ! 2299: @table @code ! 2300: @findex FUNCTION_ARG ! 2301: @item FUNCTION_ARG (@var{cum}, @var{mode}, @var{type}, @var{named}) ! 2302: A C expression that controls whether a function argument is passed ! 2303: in a register, and which register. ! 2304: ! 2305: The arguments are @var{cum}, which summarizes all the previous ! 2306: arguments; @var{mode}, the machine mode of the argument; @var{type}, ! 2307: the data type of the argument as a tree node or 0 if that is not known ! 2308: (which happens for C support library functions); and @var{named}, ! 2309: which is 1 for an ordinary argument and 0 for nameless arguments that ! 2310: correspond to @samp{@dots{}} in the called function's prototype. ! 2311: ! 2312: The value of the expression should either be a @code{reg} RTX for the ! 2313: hard register in which to pass the argument, or zero to pass the ! 2314: argument on the stack. ! 2315: ! 2316: For machines like the Vax and 68000, where normally all arguments are ! 2317: pushed, zero suffices as a definition. ! 2318: ! 2319: @cindex @file{stdarg.h} and register arguments ! 2320: The usual way to make the ANSI library @file{stdarg.h} work on a machine ! 2321: where some arguments are usually passed in registers, is to cause ! 2322: nameless arguments to be passed on the stack instead. This is done ! 2323: by making @code{FUNCTION_ARG} return 0 whenever @var{named} is 0. ! 2324: ! 2325: @cindex @code{MUST_PASS_IN_STACK}, and @code{FUNCTION_ARG} ! 2326: @cindex @code{REG_PARM_STACK_SPACE}, and @code{FUNCTION_ARG} ! 2327: You may use the macro @code{MUST_PASS_IN_STACK (@var{mode}, @var{type})} ! 2328: in the definition of this macro to determine if this argument is of a ! 2329: type that must be passed in the stack. If @code{REG_PARM_STACK_SPACE} ! 2330: is not defined and @code{FUNCTION_ARG} returns non-zero for such an ! 2331: argument, the compiler will abort. If @code{REG_PARM_STACK_SPACE} is ! 2332: defined, the argument will be computed in the stack and then loaded into ! 2333: a register. ! 2334: ! 2335: @findex FUNCTION_INCOMING_ARG ! 2336: @item FUNCTION_INCOMING_ARG (@var{cum}, @var{mode}, @var{type}, @var{named}) ! 2337: Define this macro if the target machine has ``register windows'', so ! 2338: that the register in which a function sees an arguments is not ! 2339: necessarily the same as the one in which the caller passed the ! 2340: argument. ! 2341: ! 2342: For such machines, @code{FUNCTION_ARG} computes the register in which ! 2343: the caller passes the value, and @code{FUNCTION_INCOMING_ARG} should ! 2344: be defined in a similar fashion to tell the function being called ! 2345: where the arguments will arrive. ! 2346: ! 2347: If @code{FUNCTION_INCOMING_ARG} is not defined, @code{FUNCTION_ARG} ! 2348: serves both purposes.@refill ! 2349: ! 2350: @findex FUNCTION_ARG_PARTIAL_NREGS ! 2351: @item FUNCTION_ARG_PARTIAL_NREGS (@var{cum}, @var{mode}, @var{type}, @var{named}) ! 2352: A C expression for the number of words, at the beginning of an ! 2353: argument, must be put in registers. The value must be zero for ! 2354: arguments that are passed entirely in registers or that are entirely ! 2355: pushed on the stack. ! 2356: ! 2357: On some machines, certain arguments must be passed partially in ! 2358: registers and partially in memory. On these machines, typically the ! 2359: first @var{n} words of arguments are passed in registers, and the rest ! 2360: on the stack. If a multi-word argument (a @code{double} or a ! 2361: structure) crosses that boundary, its first few words must be passed ! 2362: in registers and the rest must be pushed. This macro tells the ! 2363: compiler when this occurs, and how many of the words should go in ! 2364: registers. ! 2365: ! 2366: @code{FUNCTION_ARG} for these arguments should return the first ! 2367: register to be used by the caller for this argument; likewise ! 2368: @code{FUNCTION_INCOMING_ARG}, for the called function. ! 2369: ! 2370: @findex FUNCTION_ARG_PASS_BY_REFERENCE ! 2371: @item FUNCTION_ARG_PASS_BY_REFERENCE (@var{cum}, @var{mode}, @var{type}, @var{named}) ! 2372: A C expression that indicates when an argument must be passed by reference. ! 2373: If nonzero for an argument, a copy of that argument is made in memory and a ! 2374: pointer to the argument is passed instead of the argument itself. ! 2375: The pointer is passed in whatever way is appropriate for passing a pointer ! 2376: to that type. ! 2377: ! 2378: On machines where @code{REG_PARM_STACK_SPACE} is not defined, a suitable ! 2379: definition of this macro might be ! 2380: @smallexample ! 2381: #define FUNCTION_ARG_PASS_BY_REFERENCE\ ! 2382: (CUM, MODE, TYPE, NAMED) \ ! 2383: MUST_PASS_IN_STACK (MODE, TYPE) ! 2384: @end smallexample ! 2385: @c this is *still* too long. --mew 5feb93 ! 2386: ! 2387: @findex FUNCTION_ARG_CALLEE_COPIES ! 2388: @item FUNCTION_ARG_CALLEE_COPIES (@var{cum}, @var{mode}, @var{type}, @var{named}) ! 2389: If defined, a C expression that indicates when it is the called function's ! 2390: responsibility to make a copy of arguments passed by invisible reference. ! 2391: Normally, the caller makes a copy and passes the address of the copy to the ! 2392: routine being called. When FUNCTION_ARG_CALLEE_COPIES is defined and is ! 2393: nonzero, the caller does not make a copy. Instead, it passes a pointer to the ! 2394: ``live'' value. The called function must not modify this value. If it can be ! 2395: determined that the value won't be modified, it need not make a copy; ! 2396: otherwise a copy must be made. ! 2397: ! 2398: @findex CUMULATIVE_ARGS ! 2399: @item CUMULATIVE_ARGS ! 2400: A C type for declaring a variable that is used as the first argument of ! 2401: @code{FUNCTION_ARG} and other related values. For some target machines, ! 2402: the type @code{int} suffices and can hold the number of bytes of ! 2403: argument so far. ! 2404: ! 2405: There is no need to record in @code{CUMULATIVE_ARGS} anything about the ! 2406: arguments that have been passed on the stack. The compiler has other ! 2407: variables to keep track of that. For target machines on which all ! 2408: arguments are passed on the stack, there is no need to store anything in ! 2409: @code{CUMULATIVE_ARGS}; however, the data structure must exist and ! 2410: should not be empty, so use @code{int}. ! 2411: ! 2412: @findex INIT_CUMULATIVE_ARGS ! 2413: @item INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype}, @var{libname}) ! 2414: A C statement (sans semicolon) for initializing the variable @var{cum} ! 2415: for the state at the beginning of the argument list. The variable has ! 2416: type @code{CUMULATIVE_ARGS}. The value of @var{fntype} is the tree node ! 2417: for the data type of the function which will receive the args, or 0 ! 2418: if the args are to a compiler support library function. ! 2419: ! 2420: When processing a call to a compiler support library function, ! 2421: @var{libname} identifies which one. It is a @code{symbol_ref} rtx which ! 2422: contains the name of the function, as a string. @var{libname} is 0 when ! 2423: an ordinary C function call is being processed. Thus, each time this ! 2424: macro is called, either @var{libname} or @var{fntype} is nonzero, but ! 2425: never both of them at once. ! 2426: ! 2427: @findex INIT_CUMULATIVE_INCOMING_ARGS ! 2428: @item INIT_CUMULATIVE_INCOMING_ARGS (@var{cum}, @var{fntype}, @var{libname}) ! 2429: Like @code{INIT_CUMULATIVE_ARGS} but overrides it for the purposes of ! 2430: finding the arguments for the function being compiled. If this macro is ! 2431: undefined, @code{INIT_CUMULATIVE_ARGS} is used instead. ! 2432: ! 2433: The value passed for @var{libname} is always 0, since library routines ! 2434: with special calling conventions are never compiled with GNU CC. The ! 2435: argument @var{libname} exists for symmetry with ! 2436: @code{INIT_CUMULATIVE_ARGS}. ! 2437: @c could use "this macro" in place of @code{INIT_CUMULATIVE_ARGS}, maybe. ! 2438: @c --mew 5feb93 i switched the order of the sentences. --mew 10feb93 ! 2439: ! 2440: @findex FUNCTION_ARG_ADVANCE ! 2441: @item FUNCTION_ARG_ADVANCE (@var{cum}, @var{mode}, @var{type}, @var{named}) ! 2442: A C statement (sans semicolon) to update the summarizer variable ! 2443: @var{cum} to advance past an argument in the argument list. The ! 2444: values @var{mode}, @var{type} and @var{named} describe that argument. ! 2445: Once this is done, the variable @var{cum} is suitable for analyzing ! 2446: the @emph{following} argument with @code{FUNCTION_ARG}, etc.@refill ! 2447: ! 2448: This macro need not do anything if the argument in question was passed ! 2449: on the stack. The compiler knows how to track the amount of stack space ! 2450: used for arguments without any special help. ! 2451: ! 2452: @findex FUNCTION_ARG_PADDING ! 2453: @item FUNCTION_ARG_PADDING (@var{mode}, @var{type}) ! 2454: If defined, a C expression which determines whether, and in which direction, ! 2455: to pad out an argument with extra space. The value should be of type ! 2456: @code{enum direction}: either @code{upward} to pad above the argument, ! 2457: @code{downward} to pad below, or @code{none} to inhibit padding. ! 2458: ! 2459: The @emph{amount} of padding is always just enough to reach the next ! 2460: multiple of @code{FUNCTION_ARG_BOUNDARY}; this macro does not control ! 2461: it. ! 2462: ! 2463: This macro has a default definition which is right for most systems. ! 2464: For little-endian machines, the default is to pad upward. For ! 2465: big-endian machines, the default is to pad downward for an argument of ! 2466: constant size shorter than an @code{int}, and upward otherwise. ! 2467: ! 2468: @findex FUNCTION_ARG_BOUNDARY ! 2469: @item FUNCTION_ARG_BOUNDARY (@var{mode}, @var{type}) ! 2470: If defined, a C expression that gives the alignment boundary, in bits, ! 2471: of an argument with the specified mode and type. If it is not defined, ! 2472: @code{PARM_BOUNDARY} is used for all arguments. ! 2473: ! 2474: @findex FUNCTION_ARG_REGNO_P ! 2475: @item FUNCTION_ARG_REGNO_P (@var{regno}) ! 2476: A C expression that is nonzero if @var{regno} is the number of a hard ! 2477: register in which function arguments are sometimes passed. This does ! 2478: @emph{not} include implicit arguments such as the static chain and ! 2479: the structure-value address. On many machines, no registers can be ! 2480: used for this purpose since all function arguments are pushed on the ! 2481: stack. ! 2482: @end table ! 2483: ! 2484: @node Scalar Return ! 2485: @subsection How Scalar Function Values Are Returned ! 2486: @cindex return values in registers ! 2487: @cindex values, returned by functions ! 2488: @cindex scalars, returned as values ! 2489: ! 2490: This section discusses the macros that control returning scalars as ! 2491: values---values that can fit in registers. ! 2492: ! 2493: @table @code ! 2494: @findex TRADITIONAL_RETURN_FLOAT ! 2495: @item TRADITIONAL_RETURN_FLOAT ! 2496: Define this macro if @samp{-traditional} should not cause functions ! 2497: declared to return @code{float} to convert the value to @code{double}. ! 2498: ! 2499: @findex FUNCTION_VALUE ! 2500: @item FUNCTION_VALUE (@var{valtype}, @var{func}) ! 2501: A C expression to create an RTX representing the place where a ! 2502: function returns a value of data type @var{valtype}. @var{valtype} is ! 2503: a tree node representing a data type. Write @code{TYPE_MODE ! 2504: (@var{valtype})} to get the machine mode used to represent that type. ! 2505: On many machines, only the mode is relevant. (Actually, on most ! 2506: machines, scalar values are returned in the same place regardless of ! 2507: mode).@refill ! 2508: ! 2509: If @code{PROMOTE_FUNCTION_RETURN} is defined, you must apply the same ! 2510: promotion rules specified in @code{PROMOTE_MODE} if @var{valtype} is a ! 2511: scalar type. ! 2512: ! 2513: If the precise function being called is known, @var{func} is a tree ! 2514: node (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null ! 2515: pointer. This makes it possible to use a different value-returning ! 2516: convention for specific functions when all their calls are ! 2517: known.@refill ! 2518: ! 2519: @code{FUNCTION_VALUE} is not used for return vales with aggregate data ! 2520: types, because these are returned in another way. See ! 2521: @code{STRUCT_VALUE_REGNUM} and related macros, below. ! 2522: ! 2523: @findex FUNCTION_OUTGOING_VALUE ! 2524: @item FUNCTION_OUTGOING_VALUE (@var{valtype}, @var{func}) ! 2525: Define this macro if the target machine has ``register windows'' ! 2526: so that the register in which a function returns its value is not ! 2527: the same as the one in which the caller sees the value. ! 2528: ! 2529: For such machines, @code{FUNCTION_VALUE} computes the register in which ! 2530: the caller will see the value. @code{FUNCTION_OUTGOING_VALUE} should be ! 2531: defined in a similar fashion to tell the function where to put the ! 2532: value.@refill ! 2533: ! 2534: If @code{FUNCTION_OUTGOING_VALUE} is not defined, ! 2535: @code{FUNCTION_VALUE} serves both purposes.@refill ! 2536: ! 2537: @code{FUNCTION_OUTGOING_VALUE} is not used for return vales with ! 2538: aggregate data types, because these are returned in another way. See ! 2539: @code{STRUCT_VALUE_REGNUM} and related macros, below. ! 2540: ! 2541: @findex LIBCALL_VALUE ! 2542: @item LIBCALL_VALUE (@var{mode}) ! 2543: A C expression to create an RTX representing the place where a library ! 2544: function returns a value of mode @var{mode}. If the precise function ! 2545: being called is known, @var{func} is a tree node ! 2546: (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null ! 2547: pointer. This makes it possible to use a different value-returning ! 2548: convention for specific functions when all their calls are ! 2549: known.@refill ! 2550: ! 2551: Note that ``library function'' in this context means a compiler ! 2552: support routine, used to perform arithmetic, whose name is known ! 2553: specially by the compiler and was not mentioned in the C code being ! 2554: compiled. ! 2555: ! 2556: The definition of @code{LIBRARY_VALUE} need not be concerned aggregate ! 2557: data types, because none of the library functions returns such types. ! 2558: ! 2559: @findex FUNCTION_VALUE_REGNO_P ! 2560: @item FUNCTION_VALUE_REGNO_P (@var{regno}) ! 2561: A C expression that is nonzero if @var{regno} is the number of a hard ! 2562: register in which the values of called function may come back. ! 2563: ! 2564: A register whose use for returning values is limited to serving as the ! 2565: second of a pair (for a value of type @code{double}, say) need not be ! 2566: recognized by this macro. So for most machines, this definition ! 2567: suffices: ! 2568: ! 2569: @example ! 2570: #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0) ! 2571: @end example ! 2572: ! 2573: If the machine has register windows, so that the caller and the called ! 2574: function use different registers for the return value, this macro ! 2575: should recognize only the caller's register numbers. ! 2576: ! 2577: @findex APPLY_RESULT_SIZE ! 2578: @item APPLY_RESULT_SIZE ! 2579: Define this macro if @samp{untyped_call} and @samp{untyped_return} ! 2580: need more space than is implied by @code{FUNCTION_VALUE_REGNO_P} for ! 2581: saving and restoring an arbitrary return value. ! 2582: @end table ! 2583: ! 2584: @node Aggregate Return ! 2585: @subsection How Large Values Are Returned ! 2586: @cindex aggregates as return values ! 2587: @cindex large return values ! 2588: @cindex returning aggregate values ! 2589: @cindex structure value address ! 2590: ! 2591: When a function value's mode is @code{BLKmode} (and in some other ! 2592: cases), the value is not returned according to @code{FUNCTION_VALUE} ! 2593: (@pxref{Scalar Return}). Instead, the caller passes the address of a ! 2594: block of memory in which the value should be stored. This address ! 2595: is called the @dfn{structure value address}. ! 2596: ! 2597: This section describes how to control returning structure values in ! 2598: memory. ! 2599: ! 2600: @table @code ! 2601: @findex RETURN_IN_MEMORY ! 2602: @item RETURN_IN_MEMORY (@var{type}) ! 2603: A C expression which can inhibit the returning of certain function ! 2604: values in registers, based on the type of value. A nonzero value says ! 2605: to return the function value in memory, just as large structures are ! 2606: always returned. Here @var{type} will be a C expression of type ! 2607: @code{tree}, representing the data type of the value. ! 2608: ! 2609: Note that values of mode @code{BLKmode} must be explicitly handled ! 2610: by this macro. Also, the option @samp{-fpcc-struct-return} ! 2611: takes effect regardless of this macro. On most systems, it is ! 2612: possible to leave the macro undefined; this causes a default ! 2613: definition to be used, whose value is the constant 1 for @code{BLKmode} ! 2614: values, and 0 otherwise. ! 2615: ! 2616: Do not use this macro to indicate that structures and unions should always ! 2617: be returned in memory. You should instead use @code{DEFAULT_PCC_STRUCT_RETURN} ! 2618: to indicate this. ! 2619: ! 2620: @findex DEFAULT_PCC_STRUCT_RETURN ! 2621: @item DEFAULT_PCC_STRUCT_RETURN ! 2622: Define this macro to be 1 if all structure and union return values must be ! 2623: in memory. Since this results in slower code, this should be defined ! 2624: only if needed for compatibility with other compilers or with an ABI. ! 2625: If you define this macro to be 0, then the conventions used for structure ! 2626: and union return values are decided by the @code{RETURN_IN_MEMORY} macro. ! 2627: ! 2628: If not defined, this defaults to the value 1. ! 2629: ! 2630: @findex STRUCT_VALUE_REGNUM ! 2631: @item STRUCT_VALUE_REGNUM ! 2632: If the structure value address is passed in a register, then ! 2633: @code{STRUCT_VALUE_REGNUM} should be the number of that register. ! 2634: ! 2635: @findex STRUCT_VALUE ! 2636: @item STRUCT_VALUE ! 2637: If the structure value address is not passed in a register, define ! 2638: @code{STRUCT_VALUE} as an expression returning an RTX for the place ! 2639: where the address is passed. If it returns 0, the address is passed as ! 2640: an ``invisible'' first argument. ! 2641: ! 2642: @findex STRUCT_VALUE_INCOMING_REGNUM ! 2643: @item STRUCT_VALUE_INCOMING_REGNUM ! 2644: On some architectures the place where the structure value address ! 2645: is found by the called function is not the same place that the ! 2646: caller put it. This can be due to register windows, or it could ! 2647: be because the function prologue moves it to a different place. ! 2648: ! 2649: If the incoming location of the structure value address is in a ! 2650: register, define this macro as the register number. ! 2651: ! 2652: @findex STRUCT_VALUE_INCOMING ! 2653: @item STRUCT_VALUE_INCOMING ! 2654: If the incoming location is not a register, then you should define ! 2655: @code{STRUCT_VALUE_INCOMING} as an expression for an RTX for where the ! 2656: called function should find the value. If it should find the value on ! 2657: the stack, define this to create a @code{mem} which refers to the frame ! 2658: pointer. A definition of 0 means that the address is passed as an ! 2659: ``invisible'' first argument. ! 2660: ! 2661: @findex PCC_STATIC_STRUCT_RETURN ! 2662: @item PCC_STATIC_STRUCT_RETURN ! 2663: Define this macro if the usual system convention on the target machine ! 2664: for returning structures and unions is for the called function to return ! 2665: the address of a static variable containing the value. ! 2666: ! 2667: Do not define this if the usual system convention is for the caller to ! 2668: pass an address to the subroutine. ! 2669: ! 2670: This macro has effect in @samp{-fpcc-struct-return} mode, but it does ! 2671: nothing when you use @samp{-freg-struct-return} mode. ! 2672: @end table ! 2673: ! 2674: @node Caller Saves ! 2675: @subsection Caller-Saves Register Allocation ! 2676: ! 2677: If you enable it, GNU CC can save registers around function calls. This ! 2678: makes it possible to use call-clobbered registers to hold variables that ! 2679: must live across calls. ! 2680: ! 2681: @table @code ! 2682: @findex DEFAULT_CALLER_SAVES ! 2683: @item DEFAULT_CALLER_SAVES ! 2684: Define this macro if function calls on the target machine do not preserve ! 2685: any registers; in other words, if @code{CALL_USED_REGISTERS} has 1 ! 2686: for all registers. This macro enables @samp{-fcaller-saves} by default. ! 2687: Eventually that option will be enabled by default on all machines and both ! 2688: the option and this macro will be eliminated. ! 2689: ! 2690: @findex CALLER_SAVE_PROFITABLE ! 2691: @item CALLER_SAVE_PROFITABLE (@var{refs}, @var{calls}) ! 2692: A C expression to determine whether it is worthwhile to consider placing ! 2693: a pseudo-register in a call-clobbered hard register and saving and ! 2694: restoring it around each function call. The expression should be 1 when ! 2695: this is worth doing, and 0 otherwise. ! 2696: ! 2697: If you don't define this macro, a default is used which is good on most ! 2698: machines: @code{4 * @var{calls} < @var{refs}}. ! 2699: @end table ! 2700: ! 2701: @node Function Entry ! 2702: @subsection Function Entry and Exit ! 2703: @cindex function entry and exit ! 2704: @cindex prologue ! 2705: @cindex epilogue ! 2706: ! 2707: This section describes the macros that output function entry ! 2708: (@dfn{prologue}) and exit (@dfn{epilogue}) code. ! 2709: ! 2710: @table @code ! 2711: @findex FUNCTION_PROLOGUE ! 2712: @item FUNCTION_PROLOGUE (@var{file}, @var{size}) ! 2713: A C compound statement that outputs the assembler code for entry to a ! 2714: function. The prologue is responsible for setting up the stack frame, ! 2715: initializing the frame pointer register, saving registers that must be ! 2716: saved, and allocating @var{size} additional bytes of storage for the ! 2717: local variables. @var{size} is an integer. @var{file} is a stdio ! 2718: stream to which the assembler code should be output. ! 2719: ! 2720: The label for the beginning of the function need not be output by this ! 2721: macro. That has already been done when the macro is run. ! 2722: ! 2723: @findex regs_ever_live ! 2724: To determine which registers to save, the macro can refer to the array ! 2725: @code{regs_ever_live}: element @var{r} is nonzero if hard register ! 2726: @var{r} is used anywhere within the function. This implies the function ! 2727: prologue should save register @var{r}, provided it is not one of the ! 2728: call-used registers. (@code{FUNCTION_EPILOGUE} must likewise use ! 2729: @code{regs_ever_live}.) ! 2730: ! 2731: On machines that have ``register windows'', the function entry code does ! 2732: not save on the stack the registers that are in the windows, even if ! 2733: they are supposed to be preserved by function calls; instead it takes ! 2734: appropriate steps to ``push'' the register stack, if any non-call-used ! 2735: registers are used in the function. ! 2736: ! 2737: @findex frame_pointer_needed ! 2738: On machines where functions may or may not have frame-pointers, the ! 2739: function entry code must vary accordingly; it must set up the frame ! 2740: pointer if one is wanted, and not otherwise. To determine whether a ! 2741: frame pointer is in wanted, the macro can refer to the variable ! 2742: @code{frame_pointer_needed}. The variable's value will be 1 at run ! 2743: time in a function that needs a frame pointer. @xref{Elimination}. ! 2744: ! 2745: The function entry code is responsible for allocating any stack space ! 2746: required for the function. This stack space consists of the regions ! 2747: listed below. In most cases, these regions are allocated in the ! 2748: order listed, with the last listed region closest to the top of the ! 2749: stack (the lowest address if @code{STACK_GROWS_DOWNWARD} is defined, and ! 2750: the highest address if it is not defined). You can use a different order ! 2751: for a machine if doing so is more convenient or required for ! 2752: compatibility reasons. Except in cases where required by standard ! 2753: or by a debugger, there is no reason why the stack layout used by GCC ! 2754: need agree with that used by other compilers for a machine. ! 2755: ! 2756: @itemize @bullet ! 2757: @item ! 2758: @findex current_function_pretend_args_size ! 2759: A region of @code{current_function_pretend_args_size} bytes of ! 2760: uninitialized space just underneath the first argument arriving on the ! 2761: stack. (This may not be at the very start of the allocated stack region ! 2762: if the calling sequence has pushed anything else since pushing the stack ! 2763: arguments. But usually, on such machines, nothing else has been pushed ! 2764: yet, because the function prologue itself does all the pushing.) This ! 2765: region is used on machines where an argument may be passed partly in ! 2766: registers and partly in memory, and, in some cases to support the ! 2767: features in @file{varargs.h} and @file{stdargs.h}. ! 2768: ! 2769: @item ! 2770: An area of memory used to save certain registers used by the function. ! 2771: The size of this area, which may also include space for such things as ! 2772: the return address and pointers to previous stack frames, is ! 2773: machine-specific and usually depends on which registers have been used ! 2774: in the function. Machines with register windows often do not require ! 2775: a save area. ! 2776: ! 2777: @item ! 2778: A region of at least @var{size} bytes, possibly rounded up to an allocation ! 2779: boundary, to contain the local variables of the function. On some machines, ! 2780: this region and the save area may occur in the opposite order, with the ! 2781: save area closer to the top of the stack. ! 2782: ! 2783: @item ! 2784: @cindex @code{ACCUMULATE_OUTGOING_ARGS} and stack frames ! 2785: Optionally, when @code{ACCUMULATE_OUTGOING_ARGS} is defined, a region of ! 2786: @code{current_function_outgoing_args_size} bytes to be used for outgoing ! 2787: argument lists of the function. @xref{Stack Arguments}. ! 2788: @end itemize ! 2789: ! 2790: Normally, it is necessary for the macros @code{FUNCTION_PROLOGUE} and ! 2791: @code{FUNCTION_EPILOGUE} to treat leaf functions specially. The C ! 2792: variable @code{leaf_function} is nonzero for such a function. ! 2793: ! 2794: @findex EXIT_IGNORE_STACK ! 2795: @item EXIT_IGNORE_STACK ! 2796: Define this macro as a C expression that is nonzero if the return ! 2797: instruction or the function epilogue ignores the value of the stack ! 2798: pointer; in other words, if it is safe to delete an instruction to ! 2799: adjust the stack pointer before a return from the function. ! 2800: ! 2801: Note that this macro's value is relevant only for functions for which ! 2802: frame pointers are maintained. It is never safe to delete a final ! 2803: stack adjustment in a function that has no frame pointer, and the ! 2804: compiler knows this regardless of @code{EXIT_IGNORE_STACK}. ! 2805: ! 2806: @findex FUNCTION_EPILOGUE ! 2807: @item FUNCTION_EPILOGUE (@var{file}, @var{size}) ! 2808: A C compound statement that outputs the assembler code for exit from a ! 2809: function. The epilogue is responsible for restoring the saved ! 2810: registers and stack pointer to their values when the function was ! 2811: called, and returning control to the caller. This macro takes the ! 2812: same arguments as the macro @code{FUNCTION_PROLOGUE}, and the ! 2813: registers to restore are determined from @code{regs_ever_live} and ! 2814: @code{CALL_USED_REGISTERS} in the same way. ! 2815: ! 2816: On some machines, there is a single instruction that does all the work ! 2817: of returning from the function. On these machines, give that ! 2818: instruction the name @samp{return} and do not define the macro ! 2819: @code{FUNCTION_EPILOGUE} at all. ! 2820: ! 2821: Do not define a pattern named @samp{return} if you want the ! 2822: @code{FUNCTION_EPILOGUE} to be used. If you want the target switches ! 2823: to control whether return instructions or epilogues are used, define a ! 2824: @samp{return} pattern with a validity condition that tests the target ! 2825: switches appropriately. If the @samp{return} pattern's validity ! 2826: condition is false, epilogues will be used. ! 2827: ! 2828: On machines where functions may or may not have frame-pointers, the ! 2829: function exit code must vary accordingly. Sometimes the code for these ! 2830: two cases is completely different. To determine whether a frame pointer ! 2831: is wanted, the macro can refer to the variable ! 2832: @code{frame_pointer_needed}. The variable's value will be 1 when compiling ! 2833: a function that needs a frame pointer. ! 2834: ! 2835: Normally, @code{FUNCTION_PROLOGUE} and @code{FUNCTION_EPILOGUE} must ! 2836: treat leaf functions specially. The C variable @code{leaf_function} is ! 2837: nonzero for such a function. @xref{Leaf Functions}. ! 2838: ! 2839: On some machines, some functions pop their arguments on exit while ! 2840: others leave that for the caller to do. For example, the 68020 when ! 2841: given @samp{-mrtd} pops arguments in functions that take a fixed ! 2842: number of arguments. ! 2843: ! 2844: @findex current_function_pops_args ! 2845: Your definition of the macro @code{RETURN_POPS_ARGS} decides which ! 2846: functions pop their own arguments. @code{FUNCTION_EPILOGUE} needs to ! 2847: know what was decided. The variable that is called ! 2848: @code{current_function_pops_args} is the number of bytes of its ! 2849: arguments that a function should pop. @xref{Scalar Return}. ! 2850: @c what is the "its arguments" in the above sentence referring to, pray ! 2851: @c tell? --mew 5feb93 ! 2852: ! 2853: @findex DELAY_SLOTS_FOR_EPILOGUE ! 2854: @item DELAY_SLOTS_FOR_EPILOGUE ! 2855: Define this macro if the function epilogue contains delay slots to which ! 2856: instructions from the rest of the function can be ``moved''. The ! 2857: definition should be a C expression whose value is an integer ! 2858: representing the number of delay slots there. ! 2859: ! 2860: @findex ELIGIBLE_FOR_EPILOGUE_DELAY ! 2861: @item ELIGIBLE_FOR_EPILOGUE_DELAY (@var{insn}, @var{n}) ! 2862: A C expression that returns 1 if @var{insn} can be placed in delay ! 2863: slot number @var{n} of the epilogue. ! 2864: ! 2865: The argument @var{n} is an integer which identifies the delay slot now ! 2866: being considered (since different slots may have different rules of ! 2867: eligibility). It is never negative and is always less than the number ! 2868: of epilogue delay slots (what @code{DELAY_SLOTS_FOR_EPILOGUE} returns). ! 2869: If you reject a particular insn for a given delay slot, in principle, it ! 2870: may be reconsidered for a subsequent delay slot. Also, other insns may ! 2871: (at least in principle) be considered for the so far unfilled delay ! 2872: slot. ! 2873: ! 2874: @findex current_function_epilogue_delay_list ! 2875: @findex final_scan_insn ! 2876: The insns accepted to fill the epilogue delay slots are put in an RTL ! 2877: list made with @code{insn_list} objects, stored in the variable ! 2878: @code{current_function_epilogue_delay_list}. The insn for the first ! 2879: delay slot comes first in the list. Your definition of the macro ! 2880: @code{FUNCTION_EPILOGUE} should fill the delay slots by outputting the ! 2881: insns in this list, usually by calling @code{final_scan_insn}. ! 2882: ! 2883: You need not define this macro if you did not define ! 2884: @code{DELAY_SLOTS_FOR_EPILOGUE}. ! 2885: @end table ! 2886: ! 2887: @node Profiling ! 2888: @subsection Generating Code for Profiling ! 2889: @cindex profiling, code generation ! 2890: ! 2891: These macros will help you generate code for profiling. ! 2892: ! 2893: @table @code ! 2894: @findex FUNCTION_PROFILER ! 2895: @item FUNCTION_PROFILER (@var{file}, @var{labelno}) ! 2896: A C statement or compound statement to output to @var{file} some ! 2897: assembler code to call the profiling subroutine @code{mcount}. ! 2898: Before calling, the assembler code must load the address of a ! 2899: counter variable into a register where @code{mcount} expects to ! 2900: find the address. The name of this variable is @samp{LP} followed ! 2901: by the number @var{labelno}, so you would generate the name using ! 2902: @samp{LP%d} in a @code{fprintf}. ! 2903: ! 2904: @findex mcount ! 2905: The details of how the address should be passed to @code{mcount} are ! 2906: determined by your operating system environment, not by GNU CC. To ! 2907: figure them out, compile a small program for profiling using the ! 2908: system's installed C compiler and look at the assembler code that ! 2909: results. ! 2910: ! 2911: @findex PROFILE_BEFORE_PROLOGUE ! 2912: @item PROFILE_BEFORE_PROLOGUE ! 2913: Define this macro if the code for function profiling should come before ! 2914: the function prologue. Normally, the profiling code comes after. ! 2915: ! 2916: @findex FUNCTION_BLOCK_PROFILER ! 2917: @findex __bb_init_func ! 2918: @item FUNCTION_BLOCK_PROFILER (@var{file}, @var{labelno}) ! 2919: A C statement or compound statement to output to @var{file} some ! 2920: assembler code to initialize basic-block profiling for the current ! 2921: object module. This code should call the subroutine ! 2922: @code{__bb_init_func} once per object module, passing it as its sole ! 2923: argument the address of a block allocated in the object module. ! 2924: ! 2925: The name of the block is a local symbol made with this statement: ! 2926: ! 2927: @example ! 2928: ASM_GENERATE_INTERNAL_LABEL (@var{buffer}, "LPBX", 0); ! 2929: @end example ! 2930: ! 2931: Of course, since you are writing the definition of ! 2932: @code{ASM_GENERATE_INTERNAL_LABEL} as well as that of this macro, you ! 2933: can take a short cut in the definition of this macro and use the name ! 2934: that you know will result. ! 2935: ! 2936: The first word of this block is a flag which will be nonzero if the ! 2937: object module has already been initialized. So test this word first, ! 2938: and do not call @code{__bb_init_func} if the flag is nonzero. ! 2939: ! 2940: @findex BLOCK_PROFILER ! 2941: @item BLOCK_PROFILER (@var{file}, @var{blockno}) ! 2942: A C statement or compound statement to increment the count associated ! 2943: with the basic block number @var{blockno}. Basic blocks are numbered ! 2944: separately from zero within each compilation. The count associated ! 2945: with block number @var{blockno} is at index @var{blockno} in a vector ! 2946: of words; the name of this array is a local symbol made with this ! 2947: statement: ! 2948: ! 2949: @example ! 2950: ASM_GENERATE_INTERNAL_LABEL (@var{buffer}, "LPBX", 2); ! 2951: @end example ! 2952: ! 2953: @c This paragraph is the same as one a few paragraphs up. ! 2954: @c That is not an error. ! 2955: Of course, since you are writing the definition of ! 2956: @code{ASM_GENERATE_INTERNAL_LABEL} as well as that of this macro, you ! 2957: can take a short cut in the definition of this macro and use the name ! 2958: that you know will result. ! 2959: ! 2960: @findex BLOCK_PROFILER_CODE ! 2961: @item BLOCK_PROFILER_CODE ! 2962: A C function or functions which are needed in the library to ! 2963: support block profiling. ! 2964: @end table ! 2965: ! 2966: @node Varargs ! 2967: @section Implementing the Varargs Macros ! 2968: @cindex varargs implementation ! 2969: ! 2970: GNU CC comes with an implementation of @file{varargs.h} and ! 2971: @file{stdarg.h} that work without change on machines that pass arguments ! 2972: on the stack. Other machines require their own implementations of ! 2973: varargs, and the two machine independent header files must have ! 2974: conditionals to include it. ! 2975: ! 2976: ANSI @file{stdarg.h} differs from traditional @file{varargs.h} mainly in ! 2977: the calling convention for @code{va_start}. The traditional ! 2978: implementation takes just one argument, which is the variable in which ! 2979: to store the argument pointer. The ANSI implementation of ! 2980: @code{va_start} takes an additional second argument. The user is ! 2981: supposed to write the last named argument of the function here. ! 2982: ! 2983: However, @code{va_start} should not use this argument. The way to find ! 2984: the end of the named arguments is with the built-in functions described ! 2985: below. ! 2986: ! 2987: @table @code ! 2988: @findex __builtin_saveregs ! 2989: @item __builtin_saveregs () ! 2990: Use this built-in function to save the argument registers in memory so ! 2991: that the varargs mechanism can access them. Both ANSI and traditional ! 2992: versions of @code{va_start} must use @code{__builtin_saveregs}, unless ! 2993: you use @code{SETUP_INCOMING_VARARGS} (see below) instead. ! 2994: ! 2995: On some machines, @code{__builtin_saveregs} is open-coded under the ! 2996: control of the macro @code{EXPAND_BUILTIN_SAVEREGS}. On other machines, ! 2997: it calls a routine written in assembler language, found in ! 2998: @file{libgcc2.c}. ! 2999: ! 3000: Code generated for the call to @code{__builtin_saveregs} appears at the ! 3001: beginning of the function, as opposed to where the call to ! 3002: @code{__builtin_saveregs} is written, regardless of what the code is. ! 3003: This is because the registers must be saved before the function starts ! 3004: to use them for its own purposes. ! 3005: @c i rewrote the first sentence above to fix an overfull hbox. --mew ! 3006: @c 10feb93 ! 3007: ! 3008: @findex __builtin_args_info ! 3009: @item __builtin_args_info (@var{category}) ! 3010: Use this built-in function to find the first anonymous arguments in ! 3011: registers. ! 3012: ! 3013: In general, a machine may have several categories of registers used for ! 3014: arguments, each for a particular category of data types. (For example, ! 3015: on some machines, floating-point registers are used for floating-point ! 3016: arguments while other arguments are passed in the general registers.) ! 3017: To make non-varargs functions use the proper calling convention, you ! 3018: have defined the @code{CUMULATIVE_ARGS} data type to record how many ! 3019: registers in each category have been used so far ! 3020: ! 3021: @code{__builtin_args_info} accesses the same data structure of type ! 3022: @code{CUMULATIVE_ARGS} after the ordinary argument layout is finished ! 3023: with it, with @var{category} specifying which word to access. Thus, the ! 3024: value indicates the first unused register in a given category. ! 3025: ! 3026: Normally, you would use @code{__builtin_args_info} in the implementation ! 3027: of @code{va_start}, accessing each category just once and storing the ! 3028: value in the @code{va_list} object. This is because @code{va_list} will ! 3029: have to update the values, and there is no way to alter the ! 3030: values accessed by @code{__builtin_args_info}. ! 3031: ! 3032: @findex __builtin_next_arg ! 3033: @item __builtin_next_arg () ! 3034: This is the equivalent of @code{__builtin_args_info}, for stack ! 3035: arguments. It returns the address of the first anonymous stack ! 3036: argument, as type @code{void *}. If @code{ARGS_GROW_DOWNWARD}, it ! 3037: returns the address of the location above the first anonymous stack ! 3038: argument. Use it in @code{va_start} to initialize the pointer for ! 3039: fetching arguments from the stack. ! 3040: ! 3041: @findex __builtin_classify_type ! 3042: @item __builtin_classify_type (@var{object}) ! 3043: Since each machine has its own conventions for which data types are ! 3044: passed in which kind of register, your implementation of @code{va_arg} ! 3045: has to embody these conventions. The easiest way to categorize the ! 3046: specified data type is to use @code{__builtin_classify_type} together ! 3047: with @code{sizeof} and @code{__alignof__}. ! 3048: ! 3049: @code{__builtin_classify_type} ignores the value of @var{object}, ! 3050: considering only its data type. It returns an integer describing what ! 3051: kind of type that is---integer, floating, pointer, structure, and so on. ! 3052: ! 3053: The file @file{typeclass.h} defines an enumeration that you can use to ! 3054: interpret the values of @code{__builtin_classify_type}. ! 3055: @end table ! 3056: ! 3057: These machine description macros help implement varargs: ! 3058: ! 3059: @table @code ! 3060: @findex EXPAND_BUILTIN_SAVEREGS ! 3061: @item EXPAND_BUILTIN_SAVEREGS (@var{args}) ! 3062: If defined, is a C expression that produces the machine-specific code ! 3063: for a call to @code{__builtin_saveregs}. This code will be moved to the ! 3064: very beginning of the function, before any parameter access are made. ! 3065: The return value of this function should be an RTX that contains the ! 3066: value to use as the return of @code{__builtin_saveregs}. ! 3067: ! 3068: The argument @var{args} is a @code{tree_list} containing the arguments ! 3069: that were passed to @code{__builtin_saveregs}. ! 3070: ! 3071: If this macro is not defined, the compiler will output an ordinary ! 3072: call to the library function @samp{__builtin_saveregs}. ! 3073: ! 3074: @c !!! a bug in texinfo; how to make the entry on the @item line allow ! 3075: @c more than one line of text... help... --mew 10feb93 ! 3076: @findex SETUP_INCOMING_VARARGS ! 3077: @item SETUP_INCOMING_VARARGS (@var{args_so_far}, @var{mode}, @var{type}, ! 3078: @var{pretend_args_size}, @var{second_time}) ! 3079: This macro offers an alternative to using @code{__builtin_saveregs} and ! 3080: defining the macro @code{EXPAND_BUILTIN_SAVEREGS}. Use it to store the ! 3081: anonymous register arguments into the stack so that all the arguments ! 3082: appear to have been passed consecutively on the stack. Once this is ! 3083: done, you can use the standard implementation of varargs that works for ! 3084: machines that pass all their arguments on the stack. ! 3085: ! 3086: The argument @var{args_so_far} is the @code{CUMULATIVE_ARGS} data ! 3087: structure, containing the values that obtain after processing of the ! 3088: named arguments. The arguments @var{mode} and @var{type} describe the ! 3089: last named argument---its machine mode and its data type as a tree node. ! 3090: ! 3091: The macro implementation should do two things: first, push onto the ! 3092: stack all the argument registers @emph{not} used for the named ! 3093: arguments, and second, store the size of the data thus pushed into the ! 3094: @code{int}-valued variable whose name is supplied as the argument ! 3095: @var{pretend_args_size}. The value that you store here will serve as ! 3096: additional offset for setting up the stack frame. ! 3097: ! 3098: Because you must generate code to push the anonymous arguments at ! 3099: compile time without knowing their data types, ! 3100: @code{SETUP_INCOMING_VARARGS} is only useful on machines that have just ! 3101: a single category of argument register and use it uniformly for all data ! 3102: types. ! 3103: ! 3104: If the argument @var{second_time} is nonzero, it means that the ! 3105: arguments of the function are being analyzed for the second time. This ! 3106: happens for an inline function, which is not actually compiled until the ! 3107: end of the source file. The macro @code{SETUP_INCOMING_VARARGS} should ! 3108: not generate any instructions in this case. ! 3109: @end table ! 3110: ! 3111: @node Trampolines ! 3112: @section Trampolines for Nested Functions ! 3113: @cindex trampolines for nested functions ! 3114: @cindex nested functions, trampolines for ! 3115: ! 3116: A @dfn{trampoline} is a small piece of code that is created at run time ! 3117: when the address of a nested function is taken. It normally resides on ! 3118: the stack, in the stack frame of the containing function. These macros ! 3119: tell GNU CC how to generate code to allocate and initialize a ! 3120: trampoline. ! 3121: ! 3122: The instructions in the trampoline must do two things: load a constant ! 3123: address into the static chain register, and jump to the real address of ! 3124: the nested function. On CISC machines such as the m68k, this requires ! 3125: two instructions, a move immediate and a jump. Then the two addresses ! 3126: exist in the trampoline as word-long immediate operands. On RISC ! 3127: machines, it is often necessary to load each address into a register in ! 3128: two parts. Then pieces of each address form separate immediate ! 3129: operands. ! 3130: ! 3131: The code generated to initialize the trampoline must store the variable ! 3132: parts---the static chain value and the function address---into the ! 3133: immediate operands of the instructions. On a CISC machine, this is ! 3134: simply a matter of copying each address to a memory reference at the ! 3135: proper offset from the start of the trampoline. On a RISC machine, it ! 3136: may be necessary to take out pieces of the address and store them ! 3137: separately. ! 3138: ! 3139: @table @code ! 3140: @findex TRAMPOLINE_TEMPLATE ! 3141: @item TRAMPOLINE_TEMPLATE (@var{file}) ! 3142: A C statement to output, on the stream @var{file}, assembler code for a ! 3143: block of data that contains the constant parts of a trampoline. This ! 3144: code should not include a label---the label is taken care of ! 3145: automatically. ! 3146: ! 3147: @findex TRAMPOLINE_SECTION ! 3148: @item TRAMPOLINE_SECTION ! 3149: The name of a subroutine to switch to the section in which the ! 3150: trampoline template is to be placed (@pxref{Sections}). The default is ! 3151: a value of @samp{readonly_data_section}, which places the trampoline in ! 3152: the section containing read-only data. ! 3153: ! 3154: @findex TRAMPOLINE_SIZE ! 3155: @item TRAMPOLINE_SIZE ! 3156: A C expression for the size in bytes of the trampoline, as an integer. ! 3157: ! 3158: @findex TRAMPOLINE_ALIGNMENT ! 3159: @item TRAMPOLINE_ALIGNMENT ! 3160: Alignment required for trampolines, in bits. ! 3161: ! 3162: If you don't define this macro, the value of @code{BIGGEST_ALIGNMENT} ! 3163: is used for aligning trampolines. ! 3164: ! 3165: @findex INITIALIZE_TRAMPOLINE ! 3166: @item INITIALIZE_TRAMPOLINE (@var{addr}, @var{fnaddr}, @var{static_chain}) ! 3167: A C statement to initialize the variable parts of a trampoline. ! 3168: @var{addr} is an RTX for the address of the trampoline; @var{fnaddr} is ! 3169: an RTX for the address of the nested function; @var{static_chain} is an ! 3170: RTX for the static chain value that should be passed to the function ! 3171: when it is called. ! 3172: ! 3173: @findex ALLOCATE_TRAMPOLINE ! 3174: @item ALLOCATE_TRAMPOLINE (@var{fp}) ! 3175: A C expression to allocate run-time space for a trampoline. The ! 3176: expression value should be an RTX representing a memory reference to the ! 3177: space for the trampoline. ! 3178: ! 3179: @cindex @code{FUNCTION_EPILOGUE} and trampolines ! 3180: @cindex @code{FUNCTION_PROLOGUE} and trampolines ! 3181: If this macro is not defined, by default the trampoline is allocated as ! 3182: a stack slot. This default is right for most machines. The exceptions ! 3183: are machines where it is impossible to execute instructions in the stack ! 3184: area. On such machines, you may have to implement a separate stack, ! 3185: using this macro in conjunction with @code{FUNCTION_PROLOGUE} and ! 3186: @code{FUNCTION_EPILOGUE}. ! 3187: ! 3188: @var{fp} points to a data structure, a @code{struct function}, which ! 3189: describes the compilation status of the immediate containing function of ! 3190: the function which the trampoline is for. Normally (when ! 3191: @code{ALLOCATE_TRAMPOLINE} is not defined), the stack slot for the ! 3192: trampoline is in the stack frame of this containing function. Other ! 3193: allocation strategies probably must do something analogous with this ! 3194: information. ! 3195: @end table ! 3196: ! 3197: Implementing trampolines is difficult on many machines because they have ! 3198: separate instruction and data caches. Writing into a stack location ! 3199: fails to clear the memory in the instruction cache, so when the program ! 3200: jumps to that location, it executes the old contents. ! 3201: ! 3202: Here are two possible solutions. One is to clear the relevant parts of ! 3203: the instruction cache whenever a trampoline is set up. The other is to ! 3204: make all trampolines identical, by having them jump to a standard ! 3205: subroutine. The former technique makes trampoline execution faster; the ! 3206: latter makes initialization faster. ! 3207: ! 3208: To clear the instruction cache when a trampoline is initialized, define ! 3209: the following macros which describe the shape of the cache. ! 3210: ! 3211: @table @code ! 3212: @findex INSN_CACHE_SIZE ! 3213: @item INSN_CACHE_SIZE ! 3214: The total size in bytes of the cache. ! 3215: ! 3216: @findex INSN_CACHE_LINE_WIDTH ! 3217: @item INSN_CACHE_LINE_WIDTH ! 3218: The length in bytes of each cache line. The cache is divided into cache ! 3219: lines which are disjoint slots, each holding a contiguous chunk of data ! 3220: fetched from memory. Each time data is brought into the cache, an ! 3221: entire line is read at once. The data loaded into a cache line is ! 3222: always aligned on a boundary equal to the line size. ! 3223: ! 3224: @findex INSN_CACHE_DEPTH ! 3225: @item INSN_CACHE_DEPTH ! 3226: The number of alternative cache lines that can hold any particular memory ! 3227: location. ! 3228: @end table ! 3229: ! 3230: Alternatively, if the machine has system calls or instructions to clear ! 3231: the instruction cache directly, you can define the following macro. ! 3232: ! 3233: @table @code ! 3234: @findex CLEAR_INSN_CACHE (BEG, END) ! 3235: @item ! 3236: If defined, expands to a C expression clearing the @emph{instruction ! 3237: cache} in the specified interval. If it is not defined, and the macro ! 3238: INSN_CACHE_SIZE is defined, some generic code is generated to clear the ! 3239: cache. The definition of this macro would typically be a series of ! 3240: @code{asm} statements. Both @var{BEG} and @var{END} are both pointer ! 3241: expressions. ! 3242: @end table ! 3243: ! 3244: To use a standard subroutine, define the following macro. In addition, ! 3245: you must make sure that the instructions in a trampoline fill an entire ! 3246: cache line with identical instructions, or else ensure that the ! 3247: beginning of the trampoline code is always aligned at the same point in ! 3248: its cache line. Look in @file{m68k.h} as a guide. ! 3249: ! 3250: @table @code ! 3251: @findex TRANSFER_FROM_TRAMPOLINE ! 3252: @item TRANSFER_FROM_TRAMPOLINE ! 3253: Define this macro if trampolines need a special subroutine to do their ! 3254: work. The macro should expand to a series of @code{asm} statements ! 3255: which will be compiled with GNU CC. They go in a library function named ! 3256: @code{__transfer_from_trampoline}. ! 3257: ! 3258: If you need to avoid executing the ordinary prologue code of a compiled ! 3259: C function when you jump to the subroutine, you can do so by placing a ! 3260: special label of your own in the assembler code. Use one @code{asm} ! 3261: statement to generate an assembler label, and another to make the label ! 3262: global. Then trampolines can use that label to jump directly to your ! 3263: special assembler code. ! 3264: @end table ! 3265: ! 3266: @node Library Calls ! 3267: @section Implicit Calls to Library Routines ! 3268: @cindex library subroutine names ! 3269: @cindex @file{libgcc.a} ! 3270: ! 3271: @table @code ! 3272: @findex MULSI3_LIBCALL ! 3273: @item MULSI3_LIBCALL ! 3274: A C string constant giving the name of the function to call for ! 3275: multiplication of one signed full-word by another. If you do not ! 3276: define this macro, the default name is used, which is @code{__mulsi3}, ! 3277: a function defined in @file{libgcc.a}. ! 3278: ! 3279: @findex DIVSI3_LIBCALL ! 3280: @item DIVSI3_LIBCALL ! 3281: A C string constant giving the name of the function to call for ! 3282: division of one signed full-word by another. If you do not define ! 3283: this macro, the default name is used, which is @code{__divsi3}, a ! 3284: function defined in @file{libgcc.a}. ! 3285: ! 3286: @findex UDIVSI3_LIBCALL ! 3287: @item UDIVSI3_LIBCALL ! 3288: A C string constant giving the name of the function to call for ! 3289: division of one unsigned full-word by another. If you do not define ! 3290: this macro, the default name is used, which is @code{__udivsi3}, a ! 3291: function defined in @file{libgcc.a}. ! 3292: ! 3293: @findex MODSI3_LIBCALL ! 3294: @item MODSI3_LIBCALL ! 3295: A C string constant giving the name of the function to call for the ! 3296: remainder in division of one signed full-word by another. If you do ! 3297: not define this macro, the default name is used, which is ! 3298: @code{__modsi3}, a function defined in @file{libgcc.a}. ! 3299: ! 3300: @findex UMODSI3_LIBCALL ! 3301: @item UMODSI3_LIBCALL ! 3302: A C string constant giving the name of the function to call for the ! 3303: remainder in division of one unsigned full-word by another. If you do ! 3304: not define this macro, the default name is used, which is ! 3305: @code{__umodsi3}, a function defined in @file{libgcc.a}. ! 3306: ! 3307: @findex MULDI3_LIBCALL ! 3308: @item MULDI3_LIBCALL ! 3309: A C string constant giving the name of the function to call for ! 3310: multiplication of one signed double-word by another. If you do not ! 3311: define this macro, the default name is used, which is @code{__muldi3}, ! 3312: a function defined in @file{libgcc.a}. ! 3313: ! 3314: @findex DIVDI3_LIBCALL ! 3315: @item DIVDI3_LIBCALL ! 3316: A C string constant giving the name of the function to call for ! 3317: division of one signed double-word by another. If you do not define ! 3318: this macro, the default name is used, which is @code{__divdi3}, a ! 3319: function defined in @file{libgcc.a}. ! 3320: ! 3321: @findex UDIVDI3_LIBCALL ! 3322: @item UDIVDI3_LIBCALL ! 3323: A C string constant giving the name of the function to call for ! 3324: division of one unsigned full-word by another. If you do not define ! 3325: this macro, the default name is used, which is @code{__udivdi3}, a ! 3326: function defined in @file{libgcc.a}. ! 3327: ! 3328: @findex MODDI3_LIBCALL ! 3329: @item MODDI3_LIBCALL ! 3330: A C string constant giving the name of the function to call for the ! 3331: remainder in division of one signed double-word by another. If you do ! 3332: not define this macro, the default name is used, which is ! 3333: @code{__moddi3}, a function defined in @file{libgcc.a}. ! 3334: ! 3335: @findex UMODDI3_LIBCALL ! 3336: @item UMODDI3_LIBCALL ! 3337: A C string constant giving the name of the function to call for the ! 3338: remainder in division of one unsigned full-word by another. If you do ! 3339: not define this macro, the default name is used, which is ! 3340: @code{__umoddi3}, a function defined in @file{libgcc.a}. ! 3341: ! 3342: @findex TARGET_EDOM ! 3343: @cindex @code{EDOM}, implicit usage ! 3344: @item TARGET_EDOM ! 3345: The value of @code{EDOM} on the target machine, as a C integer constant ! 3346: expression. If you don't define this macro, GNU CC does not attempt to ! 3347: deposit the value of @code{EDOM} into @code{errno} directly. Look in ! 3348: @file{/usr/include/errno.h} to find the value of @code{EDOM} on your ! 3349: system. ! 3350: ! 3351: If you do not define @code{TARGET_EDOM}, then compiled code reports ! 3352: domain errors by calling the library function and letting it report the ! 3353: error. If mathematical functions on your system use @code{matherr} when ! 3354: there is an error, then you should leave @code{TARGET_EDOM} undefined so ! 3355: that @code{matherr} is used normally. ! 3356: ! 3357: @findex GEN_ERRNO_RTX ! 3358: @cindex @code{errno}, implicit usage ! 3359: @item GEN_ERRNO_RTX ! 3360: Define this macro as a C expression to create an rtl expression that ! 3361: refers to the global ``variable'' @code{errno}. (On certain systems, ! 3362: @code{errno} may not actually be a variable.) If you don't define this ! 3363: macro, a reasonable default is used. ! 3364: ! 3365: @findex TARGET_MEM_FUNCTIONS ! 3366: @cindex @code{bcopy}, implicit usage ! 3367: @cindex @code{memcpy}, implicit usage ! 3368: @cindex @code{bzero}, implicit usage ! 3369: @cindex @code{memset}, implicit usage ! 3370: @item TARGET_MEM_FUNCTIONS ! 3371: Define this macro if GNU CC should generate calls to the System V ! 3372: (and ANSI C) library functions @code{memcpy} and @code{memset} ! 3373: rather than the BSD functions @code{bcopy} and @code{bzero}. ! 3374: ! 3375: @findex LIBGCC_NEEDS_DOUBLE ! 3376: @item LIBGCC_NEEDS_DOUBLE ! 3377: Define this macro if only @code{float} arguments cannot be passed to ! 3378: library routines (so they must be converted to @code{double}). This ! 3379: macro affects both how library calls are generated and how the library ! 3380: routines in @file{libgcc1.c} accept their arguments. It is useful on ! 3381: machines where floating and fixed point arguments are passed ! 3382: differently, such as the i860. ! 3383: ! 3384: @findex FLOAT_ARG_TYPE ! 3385: @item FLOAT_ARG_TYPE ! 3386: Define this macro to override the type used by the library routines to ! 3387: pick up arguments of type @code{float}. (By default, they use a union ! 3388: of @code{float} and @code{int}.) ! 3389: ! 3390: The obvious choice would be @code{float}---but that won't work with ! 3391: traditional C compilers that expect all arguments declared as @code{float} ! 3392: to arrive as @code{double}. To avoid this conversion, the library routines ! 3393: ask for the value as some other type and then treat it as a @code{float}. ! 3394: ! 3395: On some systems, no other type will work for this. For these systems, ! 3396: you must use @code{LIBGCC_NEEDS_DOUBLE} instead, to force conversion of ! 3397: the values @code{double} before they are passed. ! 3398: ! 3399: @findex FLOATIFY ! 3400: @item FLOATIFY (@var{passed-value}) ! 3401: Define this macro to override the way library routines redesignate a ! 3402: @code{float} argument as a @code{float} instead of the type it was ! 3403: passed as. The default is an expression which takes the @code{float} ! 3404: field of the union. ! 3405: ! 3406: @findex FLOAT_VALUE_TYPE ! 3407: @item FLOAT_VALUE_TYPE ! 3408: Define this macro to override the type used by the library routines to ! 3409: return values that ought to have type @code{float}. (By default, they ! 3410: use @code{int}.) ! 3411: ! 3412: The obvious choice would be @code{float}---but that won't work with ! 3413: traditional C compilers gratuitously convert values declared as ! 3414: @code{float} into @code{double}. ! 3415: ! 3416: @findex INTIFY ! 3417: @item INTIFY (@var{float-value}) ! 3418: Define this macro to override the way the value of a ! 3419: @code{float}-returning library routine should be packaged in order to ! 3420: return it. These functions are actually declared to return type ! 3421: @code{FLOAT_VALUE_TYPE} (normally @code{int}). ! 3422: ! 3423: These values can't be returned as type @code{float} because traditional ! 3424: C compilers would gratuitously convert the value to a @code{double}. ! 3425: ! 3426: A local variable named @code{intify} is always available when the macro ! 3427: @code{INTIFY} is used. It is a union of a @code{float} field named ! 3428: @code{f} and a field named @code{i} whose type is ! 3429: @code{FLOAT_VALUE_TYPE} or @code{int}. ! 3430: ! 3431: If you don't define this macro, the default definition works by copying ! 3432: the value through that union. ! 3433: ! 3434: @findex nongcc_SI_type ! 3435: @item nongcc_SI_type ! 3436: Define this macro as the name of the data type corresponding to ! 3437: @code{SImode} in the system's own C compiler. ! 3438: ! 3439: You need not define this macro if that type is @code{long int}, as it usually ! 3440: is. ! 3441: ! 3442: @findex nongcc_word_type ! 3443: @item nongcc_word_type ! 3444: Define this macro as the name of the data type corresponding to the ! 3445: word_mode in the system's own C compiler. ! 3446: ! 3447: You need not define this macro if that type is @code{long int}, as it usually ! 3448: is. ! 3449: ! 3450: @findex perform_@dots{} ! 3451: @item perform_@dots{} ! 3452: Define these macros to supply explicit C statements to carry out various ! 3453: arithmetic operations on types @code{float} and @code{double} in the ! 3454: library routines in @file{libgcc1.c}. See that file for a full list ! 3455: of these macros and their arguments. ! 3456: ! 3457: On most machines, you don't need to define any of these macros, because ! 3458: the C compiler that comes with the system takes care of doing them. ! 3459: ! 3460: @findex NEXT_OBJC_RUNTIME ! 3461: @item NEXT_OBJC_RUNTIME ! 3462: Define this macro to generate code for Objective C message sending using ! 3463: the calling convention of the NeXT system. This calling convention ! 3464: involves passing the object, the selector and the method arguments all ! 3465: at once to the method-lookup library function. ! 3466: ! 3467: The default calling convention passes just the object and the selector ! 3468: to the lookup function, which returns a pointer to the method. ! 3469: @end table ! 3470: ! 3471: @node Addressing Modes ! 3472: @section Addressing Modes ! 3473: @cindex addressing modes ! 3474: ! 3475: @table @code ! 3476: @findex HAVE_POST_INCREMENT ! 3477: @item HAVE_POST_INCREMENT ! 3478: Define this macro if the machine supports post-increment addressing. ! 3479: ! 3480: @findex HAVE_PRE_INCREMENT ! 3481: @findex HAVE_POST_DECREMENT ! 3482: @findex HAVE_PRE_DECREMENT ! 3483: @item HAVE_PRE_INCREMENT ! 3484: @itemx HAVE_POST_DECREMENT ! 3485: @itemx HAVE_PRE_DECREMENT ! 3486: Similar for other kinds of addressing. ! 3487: ! 3488: @findex CONSTANT_ADDRESS_P ! 3489: @item CONSTANT_ADDRESS_P (@var{x}) ! 3490: A C expression that is 1 if the RTX @var{x} is a constant which ! 3491: is a valid address. On most machines, this can be defined as ! 3492: @code{CONSTANT_P (@var{x})}, but a few machines are more restrictive ! 3493: in which constant addresses are supported. ! 3494: ! 3495: @findex CONSTANT_P ! 3496: @code{CONSTANT_P} accepts integer-values expressions whose values are ! 3497: not explicitly known, such as @code{symbol_ref}, @code{label_ref}, and ! 3498: @code{high} expressions and @code{const} arithmetic expressions, in ! 3499: addition to @code{const_int} and @code{const_double} expressions. ! 3500: ! 3501: @findex MAX_REGS_PER_ADDRESS ! 3502: @item MAX_REGS_PER_ADDRESS ! 3503: A number, the maximum number of registers that can appear in a valid ! 3504: memory address. Note that it is up to you to specify a value equal to ! 3505: the maximum number that @code{GO_IF_LEGITIMATE_ADDRESS} would ever ! 3506: accept. ! 3507: ! 3508: @findex GO_IF_LEGITIMATE_ADDRESS ! 3509: @item GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label}) ! 3510: A C compound statement with a conditional @code{goto @var{label};} ! 3511: executed if @var{x} (an RTX) is a legitimate memory address on the ! 3512: target machine for a memory operand of mode @var{mode}. ! 3513: ! 3514: It usually pays to define several simpler macros to serve as ! 3515: subroutines for this one. Otherwise it may be too complicated to ! 3516: understand. ! 3517: ! 3518: This macro must exist in two variants: a strict variant and a ! 3519: non-strict one. The strict variant is used in the reload pass. It ! 3520: must be defined so that any pseudo-register that has not been ! 3521: allocated a hard register is considered a memory reference. In ! 3522: contexts where some kind of register is required, a pseudo-register ! 3523: with no hard register must be rejected. ! 3524: ! 3525: The non-strict variant is used in other passes. It must be defined to ! 3526: accept all pseudo-registers in every context where some kind of ! 3527: register is required. ! 3528: ! 3529: @findex REG_OK_STRICT ! 3530: Compiler source files that want to use the strict variant of this ! 3531: macro define the macro @code{REG_OK_STRICT}. You should use an ! 3532: @code{#ifdef REG_OK_STRICT} conditional to define the strict variant ! 3533: in that case and the non-strict variant otherwise. ! 3534: ! 3535: Subroutines to check for acceptable registers for various purposes (one ! 3536: for base registers, one for index registers, and so on) are typically ! 3537: among the subroutines used to define @code{GO_IF_LEGITIMATE_ADDRESS}. ! 3538: Then only these subroutine macros need have two variants; the higher ! 3539: levels of macros may be the same whether strict or not.@refill ! 3540: ! 3541: Normally, constant addresses which are the sum of a @code{symbol_ref} ! 3542: and an integer are stored inside a @code{const} RTX to mark them as ! 3543: constant. Therefore, there is no need to recognize such sums ! 3544: specifically as legitimate addresses. Normally you would simply ! 3545: recognize any @code{const} as legitimate. ! 3546: ! 3547: Usually @code{PRINT_OPERAND_ADDRESS} is not prepared to handle constant ! 3548: sums that are not marked with @code{const}. It assumes that a naked ! 3549: @code{plus} indicates indexing. If so, then you @emph{must} reject such ! 3550: naked constant sums as illegitimate addresses, so that none of them will ! 3551: be given to @code{PRINT_OPERAND_ADDRESS}. ! 3552: ! 3553: @cindex @code{ENCODE_SECTION_INFO} and address validation ! 3554: On some machines, whether a symbolic address is legitimate depends on ! 3555: the section that the address refers to. On these machines, define the ! 3556: macro @code{ENCODE_SECTION_INFO} to store the information into the ! 3557: @code{symbol_ref}, and then check for it here. When you see a ! 3558: @code{const}, you will have to look inside it to find the ! 3559: @code{symbol_ref} in order to determine the section. @xref{Assembler ! 3560: Format}. ! 3561: ! 3562: @findex saveable_obstack ! 3563: The best way to modify the name string is by adding text to the ! 3564: beginning, with suitable punctuation to prevent any ambiguity. Allocate ! 3565: the new name in @code{saveable_obstack}. You will have to modify ! 3566: @code{ASM_OUTPUT_LABELREF} to remove and decode the added text and ! 3567: output the name accordingly, and define @code{STRIP_NAME_ENCODING} to ! 3568: access the original name string. ! 3569: ! 3570: You can check the information stored here into the @code{symbol_ref} in ! 3571: the definitions of the macros @code{GO_IF_LEGITIMATE_ADDRESS} and ! 3572: @code{PRINT_OPERAND_ADDRESS}. ! 3573: ! 3574: @findex REG_OK_FOR_BASE_P ! 3575: @item REG_OK_FOR_BASE_P (@var{x}) ! 3576: A C expression that is nonzero if @var{x} (assumed to be a @code{reg} ! 3577: RTX) is valid for use as a base register. For hard registers, it ! 3578: should always accept those which the hardware permits and reject the ! 3579: others. Whether the macro accepts or rejects pseudo registers must be ! 3580: controlled by @code{REG_OK_STRICT} as described above. This usually ! 3581: requires two variant definitions, of which @code{REG_OK_STRICT} ! 3582: controls the one actually used. ! 3583: ! 3584: @findex REG_OK_FOR_INDEX_P ! 3585: @item REG_OK_FOR_INDEX_P (@var{x}) ! 3586: A C expression that is nonzero if @var{x} (assumed to be a @code{reg} ! 3587: RTX) is valid for use as an index register. ! 3588: ! 3589: The difference between an index register and a base register is that ! 3590: the index register may be scaled. If an address involves the sum of ! 3591: two registers, neither one of them scaled, then either one may be ! 3592: labeled the ``base'' and the other the ``index''; but whichever ! 3593: labeling is used must fit the machine's constraints of which registers ! 3594: may serve in each capacity. The compiler will try both labelings, ! 3595: looking for one that is valid, and will reload one or both registers ! 3596: only if neither labeling works. ! 3597: ! 3598: @findex LEGITIMIZE_ADDRESS ! 3599: @item LEGITIMIZE_ADDRESS (@var{x}, @var{oldx}, @var{mode}, @var{win}) ! 3600: A C compound statement that attempts to replace @var{x} with a valid ! 3601: memory address for an operand of mode @var{mode}. @var{win} will be a ! 3602: C statement label elsewhere in the code; the macro definition may use ! 3603: ! 3604: @example ! 3605: GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{win}); ! 3606: @end example ! 3607: ! 3608: @noindent ! 3609: to avoid further processing if the address has become legitimate. ! 3610: ! 3611: @findex break_out_memory_refs ! 3612: @var{x} will always be the result of a call to @code{break_out_memory_refs}, ! 3613: and @var{oldx} will be the operand that was given to that function to produce ! 3614: @var{x}. ! 3615: ! 3616: The code generated by this macro should not alter the substructure of ! 3617: @var{x}. If it transforms @var{x} into a more legitimate form, it ! 3618: should assign @var{x} (which will always be a C variable) a new value. ! 3619: ! 3620: It is not necessary for this macro to come up with a legitimate ! 3621: address. The compiler has standard ways of doing so in all cases. In ! 3622: fact, it is safe for this macro to do nothing. But often a ! 3623: machine-dependent strategy can generate better code. ! 3624: ! 3625: @findex GO_IF_MODE_DEPENDENT_ADDRESS ! 3626: @item GO_IF_MODE_DEPENDENT_ADDRESS (@var{addr}, @var{label}) ! 3627: A C statement or compound statement with a conditional @code{goto ! 3628: @var{label};} executed if memory address @var{x} (an RTX) can have ! 3629: different meanings depending on the machine mode of the memory ! 3630: reference it is used for or if the address is valid for some modes ! 3631: but not others. ! 3632: ! 3633: Autoincrement and autodecrement addresses typically have mode-dependent ! 3634: effects because the amount of the increment or decrement is the size ! 3635: of the operand being addressed. Some machines have other mode-dependent ! 3636: addresses. Many RISC machines have no mode-dependent addresses. ! 3637: ! 3638: You may assume that @var{addr} is a valid address for the machine. ! 3639: ! 3640: @findex LEGITIMATE_CONSTANT_P ! 3641: @item LEGITIMATE_CONSTANT_P (@var{x}) ! 3642: A C expression that is nonzero if @var{x} is a legitimate constant for ! 3643: an immediate operand on the target machine. You can assume that ! 3644: @var{x} satisfies @code{CONSTANT_P}, so you need not check this. In fact, ! 3645: @samp{1} is a suitable definition for this macro on machines where ! 3646: anything @code{CONSTANT_P} is valid.@refill ! 3647: @end table ! 3648: ! 3649: @node Condition Code ! 3650: @section Condition Code Status ! 3651: @cindex condition code status ! 3652: ! 3653: @findex cc_status ! 3654: The file @file{conditions.h} defines a variable @code{cc_status} to ! 3655: describe how the condition code was computed (in case the interpretation of ! 3656: the condition code depends on the instruction that it was set by). This ! 3657: variable contains the RTL expressions on which the condition code is ! 3658: currently based, and several standard flags. ! 3659: ! 3660: Sometimes additional machine-specific flags must be defined in the machine ! 3661: description header file. It can also add additional machine-specific ! 3662: information by defining @code{CC_STATUS_MDEP}. ! 3663: ! 3664: @table @code ! 3665: @findex CC_STATUS_MDEP ! 3666: @item CC_STATUS_MDEP ! 3667: C code for a data type which is used for declaring the @code{mdep} ! 3668: component of @code{cc_status}. It defaults to @code{int}. ! 3669: ! 3670: This macro is not used on machines that do not use @code{cc0}. ! 3671: ! 3672: @findex CC_STATUS_MDEP_INIT ! 3673: @item CC_STATUS_MDEP_INIT ! 3674: A C expression to initialize the @code{mdep} field to ``empty''. ! 3675: The default definition does nothing, since most machines don't use ! 3676: the field anyway. If you want to use the field, you should probably ! 3677: define this macro to initialize it. ! 3678: ! 3679: This macro is not used on machines that do not use @code{cc0}. ! 3680: ! 3681: @findex NOTICE_UPDATE_CC ! 3682: @item NOTICE_UPDATE_CC (@var{exp}, @var{insn}) ! 3683: A C compound statement to set the components of @code{cc_status} ! 3684: appropriately for an insn @var{insn} whose body is @var{exp}. It is ! 3685: this macro's responsibility to recognize insns that set the condition ! 3686: code as a byproduct of other activity as well as those that explicitly ! 3687: set @code{(cc0)}. ! 3688: ! 3689: This macro is not used on machines that do not use @code{cc0}. ! 3690: ! 3691: If there are insns that do not set the condition code but do alter ! 3692: other machine registers, this macro must check to see whether they ! 3693: invalidate the expressions that the condition code is recorded as ! 3694: reflecting. For example, on the 68000, insns that store in address ! 3695: registers do not set the condition code, which means that usually ! 3696: @code{NOTICE_UPDATE_CC} can leave @code{cc_status} unaltered for such ! 3697: insns. But suppose that the previous insn set the condition code ! 3698: based on location @samp{a4@@(102)} and the current insn stores a new ! 3699: value in @samp{a4}. Although the condition code is not changed by ! 3700: this, it will no longer be true that it reflects the contents of ! 3701: @samp{a4@@(102)}. Therefore, @code{NOTICE_UPDATE_CC} must alter ! 3702: @code{cc_status} in this case to say that nothing is known about the ! 3703: condition code value. ! 3704: ! 3705: The definition of @code{NOTICE_UPDATE_CC} must be prepared to deal ! 3706: with the results of peephole optimization: insns whose patterns are ! 3707: @code{parallel} RTXs containing various @code{reg}, @code{mem} or ! 3708: constants which are just the operands. The RTL structure of these ! 3709: insns is not sufficient to indicate what the insns actually do. What ! 3710: @code{NOTICE_UPDATE_CC} should do when it sees one is just to run ! 3711: @code{CC_STATUS_INIT}. ! 3712: ! 3713: A possible definition of @code{NOTICE_UPDATE_CC} is to call a function ! 3714: that looks at an attribute (@pxref{Insn Attributes}) named, for example, ! 3715: @samp{cc}. This avoids having detailed information about patterns in ! 3716: two places, the @file{md} file and in @code{NOTICE_UPDATE_CC}. ! 3717: ! 3718: @findex EXTRA_CC_MODES ! 3719: @item EXTRA_CC_MODES ! 3720: A list of names to be used for additional modes for condition code ! 3721: values in registers (@pxref{Jump Patterns}). These names are added ! 3722: to @code{enum machine_mode} and all have class @code{MODE_CC}. By ! 3723: convention, they should start with @samp{CC} and end with @samp{mode}. ! 3724: ! 3725: You should only define this macro if your machine does not use @code{cc0} ! 3726: and only if additional modes are required. ! 3727: ! 3728: @findex EXTRA_CC_NAMES ! 3729: @item EXTRA_CC_NAMES ! 3730: A list of C strings giving the names for the modes listed in ! 3731: @code{EXTRA_CC_MODES}. For example, the Sparc defines this macro and ! 3732: @code{EXTRA_CC_MODES} as ! 3733: ! 3734: @smallexample ! 3735: #define EXTRA_CC_MODES CC_NOOVmode, CCFPmode ! 3736: #define EXTRA_CC_NAMES "CC_NOOV", "CCFP" ! 3737: @end smallexample ! 3738: ! 3739: This macro is not required if @code{EXTRA_CC_MODES} is not defined. ! 3740: ! 3741: @findex SELECT_CC_MODE ! 3742: @item SELECT_CC_MODE (@var{op}, @var{x}, @var{y}) ! 3743: Returns a mode from class @code{MODE_CC} to be used when comparison ! 3744: operation code @var{op} is applied to rtx @var{x} and @var{y}. For ! 3745: example, on the Sparc, @code{SELECT_CC_MODE} is defined as (see ! 3746: @pxref{Jump Patterns} for a description of the reason for this ! 3747: definition) ! 3748: ! 3749: @smallexample ! 3750: #define SELECT_CC_MODE(OP,X,Y) \ ! 3751: (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ ! 3752: ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode) \ ! 3753: : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS \ ! 3754: || GET_CODE (X) == NEG) \ ! 3755: ? CC_NOOVmode : CCmode)) ! 3756: @end smallexample ! 3757: ! 3758: This macro is not required if @code{EXTRA_CC_MODES} is not defined. ! 3759: @end table ! 3760: ! 3761: @node Costs ! 3762: @section Describing Relative Costs of Operations ! 3763: @cindex costs of instructions ! 3764: @cindex relative costs ! 3765: @cindex speed of instructions ! 3766: ! 3767: These macros let you describe the relative speed of various operations ! 3768: on the target machine. ! 3769: ! 3770: @table @code ! 3771: @findex CONST_COSTS ! 3772: @item CONST_COSTS (@var{x}, @var{code}, @var{outer_code}) ! 3773: A part of a C @code{switch} statement that describes the relative costs ! 3774: of constant RTL expressions. It must contain @code{case} labels for ! 3775: expression codes @code{const_int}, @code{const}, @code{symbol_ref}, ! 3776: @code{label_ref} and @code{const_double}. Each case must ultimately ! 3777: reach a @code{return} statement to return the relative cost of the use ! 3778: of that kind of constant value in an expression. The cost may depend on ! 3779: the precise value of the constant, which is available for examination in ! 3780: @var{x}, and the rtx code of the expression in which it is contained, ! 3781: found in @var{outer_code}. ! 3782: ! 3783: @var{code} is the expression code---redundant, since it can be ! 3784: obtained with @code{GET_CODE (@var{x})}. ! 3785: ! 3786: @findex RTX_COSTS ! 3787: @findex COSTS_N_INSNS ! 3788: @item RTX_COSTS (@var{x}, @var{code}, @var{outer_code}) ! 3789: Like @code{CONST_COSTS} but applies to nonconstant RTL expressions. ! 3790: This can be used, for example, to indicate how costly a multiply ! 3791: instruction is. In writing this macro, you can use the construct ! 3792: @code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast ! 3793: instructions. @var{outer_code} is the code of the expression in which ! 3794: @var{x} is contained. ! 3795: ! 3796: This macro is optional; do not define it if the default cost assumptions ! 3797: are adequate for the target machine. ! 3798: ! 3799: @findex ADDRESS_COST ! 3800: @item ADDRESS_COST (@var{address}) ! 3801: An expression giving the cost of an addressing mode that contains ! 3802: @var{address}. If not defined, the cost is computed from ! 3803: the @var{address} expression and the @code{CONST_COSTS} values. ! 3804: ! 3805: For most CISC machines, the default cost is a good approximation of the ! 3806: true cost of the addressing mode. However, on RISC machines, all ! 3807: instructions normally have the same length and execution time. Hence ! 3808: all addresses will have equal costs. ! 3809: ! 3810: In cases where more than one form of an address is known, the form with ! 3811: the lowest cost will be used. If multiple forms have the same, lowest, ! 3812: cost, the one that is the most complex will be used. ! 3813: ! 3814: For example, suppose an address that is equal to the sum of a register ! 3815: and a constant is used twice in the same basic block. When this macro ! 3816: is not defined, the address will be computed in a register and memory ! 3817: references will be indirect through that register. On machines where ! 3818: the cost of the addressing mode containing the sum is no higher than ! 3819: that of a simple indirect reference, this will produce an additional ! 3820: instruction and possibly require an additional register. Proper ! 3821: specification of this macro eliminates this overhead for such machines. ! 3822: ! 3823: Similar use of this macro is made in strength reduction of loops. ! 3824: ! 3825: @var{address} need not be valid as an address. In such a case, the cost ! 3826: is not relevant and can be any value; invalid addresses need not be ! 3827: assigned a different cost. ! 3828: ! 3829: On machines where an address involving more than one register is as ! 3830: cheap as an address computation involving only one register, defining ! 3831: @code{ADDRESS_COST} to reflect this can cause two registers to be live ! 3832: over a region of code where only one would have been if ! 3833: @code{ADDRESS_COST} were not defined in that manner. This effect should ! 3834: be considered in the definition of this macro. Equivalent costs should ! 3835: probably only be given to addresses with different numbers of registers ! 3836: on machines with lots of registers. ! 3837: ! 3838: This macro will normally either not be defined or be defined as a ! 3839: constant. ! 3840: ! 3841: @findex REGISTER_MOVE_COST ! 3842: @item REGISTER_MOVE_COST (@var{from}, @var{to}) ! 3843: A C expression for the cost of moving data from a register in class ! 3844: @var{from} to one in class @var{to}. The classes are expressed using ! 3845: the enumeration values such as @code{GENERAL_REGS}. A value of 4 is the ! 3846: default; other values are interpreted relative to that. ! 3847: ! 3848: It is not required that the cost always equal 2 when @var{from} is the ! 3849: same as @var{to}; on some machines it is expensive to move between ! 3850: registers if they are not general registers. ! 3851: ! 3852: If reload sees an insn consisting of a single @code{set} between two ! 3853: hard registers, and if @code{REGISTER_MOVE_COST} applied to their ! 3854: classes returns a value of 2, reload does not check to ensure that the ! 3855: constraints of the insn are met. Setting a cost of other than 2 will ! 3856: allow reload to verify that the constraints are met. You should do this ! 3857: if the @samp{mov@var{m}} pattern's constraints do not allow such copying. ! 3858: ! 3859: @findex MEMORY_MOVE_COST ! 3860: @item MEMORY_MOVE_COST (@var{m}) ! 3861: A C expression for the cost of moving data of mode @var{m} between a ! 3862: register and memory. A value of 2 is the default; this cost is relative ! 3863: to those in @code{REGISTER_MOVE_COST}. ! 3864: ! 3865: If moving between registers and memory is more expensive than between ! 3866: two registers, you should define this macro to express the relative cost. ! 3867: ! 3868: @findex BRANCH_COST ! 3869: @item BRANCH_COST ! 3870: A C expression for the cost of a branch instruction. A value of 1 is ! 3871: the default; other values are interpreted relative to that. ! 3872: @end table ! 3873: ! 3874: Here are additional macros which do not specify precise relative costs, ! 3875: but only that certain actions are more expensive than GNU CC would ! 3876: ordinarily expect. ! 3877: ! 3878: @table @code ! 3879: @findex SLOW_BYTE_ACCESS ! 3880: @item SLOW_BYTE_ACCESS ! 3881: Define this macro as a C expression which is nonzero if accessing less ! 3882: than a word of memory (i.e. a @code{char} or a @code{short}) is no ! 3883: faster than accessing a word of memory, i.e., if such access ! 3884: require more than one instruction or if there is no difference in cost ! 3885: between byte and (aligned) word loads. ! 3886: ! 3887: When this macro is not defined, the compiler will access a field by ! 3888: finding the smallest containing object; when it is defined, a fullword ! 3889: load will be used if alignment permits. Unless bytes accesses are ! 3890: faster than word accesses, using word accesses is preferable since it ! 3891: may eliminate subsequent memory access if subsequent accesses occur to ! 3892: other fields in the same word of the structure, but to different bytes. ! 3893: ! 3894: @findex SLOW_ZERO_EXTEND ! 3895: @item SLOW_ZERO_EXTEND ! 3896: Define this macro if zero-extension (of a @code{char} or @code{short} ! 3897: to an @code{int}) can be done faster if the destination is a register ! 3898: that is known to be zero. ! 3899: ! 3900: If you define this macro, you must have instruction patterns that ! 3901: recognize RTL structures like this: ! 3902: ! 3903: @smallexample ! 3904: (set (strict_low_part (subreg:QI (reg:SI @dots{}) 0)) @dots{}) ! 3905: @end smallexample ! 3906: ! 3907: @noindent ! 3908: and likewise for @code{HImode}. ! 3909: ! 3910: @findex SLOW_UNALIGNED_ACCESS ! 3911: @item SLOW_UNALIGNED_ACCESS ! 3912: Define this macro to be the value 1 if unaligned accesses have a cost ! 3913: many times greater than aligned accesses, for example if they are ! 3914: emulated in a trap handler. ! 3915: ! 3916: When this macro is non-zero, the compiler will act as if ! 3917: @code{STRICT_ALIGNMENT} were non-zero when generating code for block ! 3918: moves. This can cause significantly more instructions to be produced. ! 3919: Therefore, do not set this macro non-zero if unaligned accesses only add a ! 3920: cycle or two to the time for a memory access. ! 3921: ! 3922: If the value of this macro is always zero, it need not be defined. ! 3923: ! 3924: @findex DONT_REDUCE_ADDR ! 3925: @item DONT_REDUCE_ADDR ! 3926: Define this macro to inhibit strength reduction of memory addresses. ! 3927: (On some machines, such strength reduction seems to do harm rather ! 3928: than good.) ! 3929: ! 3930: @findex MOVE_RATIO ! 3931: @item MOVE_RATIO ! 3932: The number of scalar move insns which should be generated instead of a ! 3933: string move insn or a library call. Increasing the value will always ! 3934: make code faster, but eventually incurs high cost in increased code size. ! 3935: ! 3936: If you don't define this, a reasonable default is used. ! 3937: ! 3938: @findex NO_FUNCTION_CSE ! 3939: @item NO_FUNCTION_CSE ! 3940: Define this macro if it is as good or better to call a constant ! 3941: function address than to call an address kept in a register. ! 3942: ! 3943: @findex NO_RECURSIVE_FUNCTION_CSE ! 3944: @item NO_RECURSIVE_FUNCTION_CSE ! 3945: Define this macro if it is as good or better for a function to call ! 3946: itself with an explicit address than to call an address kept in a ! 3947: register. ! 3948: ! 3949: @findex ADJUST_COST ! 3950: @item ADJUST_COST (@var{insn}, @var{link}, @var{dep_insn}, @var{cost}) ! 3951: A C statement (sans semicolon) to update the integer variable @var{cost} ! 3952: based on the relationship between @var{insn} that is dependent on ! 3953: @var{dep_insn} through the dependence @var{link}. The default is to ! 3954: make no adjustment to @var{cost}. This can be used for example to ! 3955: specify to the scheduler that an output- or anti-dependence does not ! 3956: incur the same cost as a data-dependence. ! 3957: @end table ! 3958: ! 3959: @node Sections ! 3960: @section Dividing the Output into Sections (Texts, Data, @dots{}) ! 3961: @c the above section title is WAY too long. maybe cut the part between ! 3962: @c the (...)? --mew 10feb93 ! 3963: ! 3964: An object file is divided into sections containing different types of ! 3965: data. In the most common case, there are three sections: the @dfn{text ! 3966: section}, which holds instructions and read-only data; the @dfn{data ! 3967: section}, which holds initialized writable data; and the @dfn{bss ! 3968: section}, which holds uninitialized data. Some systems have other kinds ! 3969: of sections. ! 3970: ! 3971: The compiler must tell the assembler when to switch sections. These ! 3972: macros control what commands to output to tell the assembler this. You ! 3973: can also define additional sections. ! 3974: ! 3975: @table @code ! 3976: @findex TEXT_SECTION_ASM_OP ! 3977: @item TEXT_SECTION_ASM_OP ! 3978: A C expression whose value is a string containing the assembler ! 3979: operation that should precede instructions and read-only data. Normally ! 3980: @code{".text"} is right. ! 3981: ! 3982: @findex DATA_SECTION_ASM_OP ! 3983: @item DATA_SECTION_ASM_OP ! 3984: A C expression whose value is a string containing the assembler ! 3985: operation to identify the following data as writable initialized data. ! 3986: Normally @code{".data"} is right. ! 3987: ! 3988: @findex SHARED_SECTION_ASM_OP ! 3989: @item SHARED_SECTION_ASM_OP ! 3990: if defined, a C expression whose value is a string containing the ! 3991: assembler operation to identify the following data as shared data. If ! 3992: not defined, @code{DATA_SECTION_ASM_OP} will be used. ! 3993: ! 3994: @findex INIT_SECTION_ASM_OP ! 3995: @item INIT_SECTION_ASM_OP ! 3996: if defined, a C expression whose value is a string containing the ! 3997: assembler operation to identify the following data as initialization ! 3998: code. If not defined, GNU CC will assume such a section does not ! 3999: exist. ! 4000: ! 4001: @findex EXTRA_SECTIONS ! 4002: @findex in_text ! 4003: @findex in_data ! 4004: @item EXTRA_SECTIONS ! 4005: A list of names for sections other than the standard two, which are ! 4006: @code{in_text} and @code{in_data}. You need not define this macro ! 4007: on a system with no other sections (that GCC needs to use). ! 4008: ! 4009: @findex EXTRA_SECTION_FUNCTIONS ! 4010: @findex text_section ! 4011: @findex data_section ! 4012: @item EXTRA_SECTION_FUNCTIONS ! 4013: One or more functions to be defined in @file{varasm.c}. These ! 4014: functions should do jobs analogous to those of @code{text_section} and ! 4015: @code{data_section}, for your additional sections. Do not define this ! 4016: macro if you do not define @code{EXTRA_SECTIONS}. ! 4017: ! 4018: @findex READONLY_DATA_SECTION ! 4019: @item READONLY_DATA_SECTION ! 4020: On most machines, read-only variables, constants, and jump tables are ! 4021: placed in the text section. If this is not the case on your machine, ! 4022: this macro should be defined to be the name of a function (either ! 4023: @code{data_section} or a function defined in @code{EXTRA_SECTIONS}) that ! 4024: switches to the section to be used for read-only items. ! 4025: ! 4026: If these items should be placed in the text section, this macro should ! 4027: not be defined. ! 4028: ! 4029: @findex SELECT_SECTION ! 4030: @item SELECT_SECTION (@var{exp}, @var{reloc}) ! 4031: A C statement or statements to switch to the appropriate section for ! 4032: output of @var{exp}. You can assume that @var{exp} is either a ! 4033: @code{VAR_DECL} node or a constant of some sort. @var{reloc} ! 4034: indicates whether the initial value of @var{exp} requires link-time ! 4035: relocations. Select the section by calling @code{text_section} or one ! 4036: of the alternatives for other sections. ! 4037: ! 4038: Do not define this macro if you put all read-only variables and ! 4039: constants in the read-only data section (usually the text section). ! 4040: ! 4041: @findex SELECT_RTX_SECTION ! 4042: @item SELECT_RTX_SECTION (@var{mode}, @var{rtx}) ! 4043: A C statement or statements to switch to the appropriate section for ! 4044: output of @var{rtx} in mode @var{mode}. You can assume that @var{rtx} ! 4045: is some kind of constant in RTL. The argument @var{mode} is redundant ! 4046: except in the case of a @code{const_int} rtx. Select the section by ! 4047: calling @code{text_section} or one of the alternatives for other ! 4048: sections. ! 4049: ! 4050: Do not define this macro if you put all constants in the read-only ! 4051: data section. ! 4052: ! 4053: @findex JUMP_TABLES_IN_TEXT_SECTION ! 4054: @item JUMP_TABLES_IN_TEXT_SECTION ! 4055: Define this macro if jump tables (for @code{tablejump} insns) should be ! 4056: output in the text section, along with the assembler instructions. ! 4057: Otherwise, the readonly data section is used. ! 4058: ! 4059: This macro is irrelevant if there is no separate readonly data section. ! 4060: ! 4061: @findex ENCODE_SECTION_INFO ! 4062: @item ENCODE_SECTION_INFO (@var{decl}) ! 4063: Define this macro if references to a symbol must be treated differently ! 4064: depending on something about the variable or function named by the ! 4065: symbol (such as what section it is in). ! 4066: ! 4067: The macro definition, if any, is executed immediately after the rtl for ! 4068: @var{decl} has been created and stored in @code{DECL_RTL (@var{decl})}. ! 4069: The value of the rtl will be a @code{mem} whose address is a ! 4070: @code{symbol_ref}. ! 4071: ! 4072: @cindex @code{SYMBOL_REF_FLAG}, in @code{ENCODE_SECTION_INFO} ! 4073: The usual thing for this macro to do is to record a flag in the ! 4074: @code{symbol_ref} (such as @code{SYMBOL_REF_FLAG}) or to store a ! 4075: modified name string in the @code{symbol_ref} (if one bit is not enough ! 4076: information). ! 4077: ! 4078: @findex STRIP_NAME_ENCODING ! 4079: @item STRIP_NAME_ENCODING (@var{var}, @var{sym_name}) ! 4080: Decode @var{sym_name} and store the real name part in @var{var}, sans ! 4081: the characters that encode section info. Define this macro if ! 4082: @code{ENCODE_SECTION_INFO} alters the symbol's name string. ! 4083: @end table ! 4084: ! 4085: @node PIC ! 4086: @section Position Independent Code ! 4087: @cindex position independent code ! 4088: @cindex PIC ! 4089: ! 4090: This section describes macros that help implement generation of position ! 4091: independent code. Simply defining these macros is not enough to ! 4092: generate valid PIC; you must also add support to the macros ! 4093: @code{GO_IF_LEGITIMATE_ADDRESS} and @code{PRINT_OPERAND_ADDRESS}, as ! 4094: well as @code{LEGITIMIZE_ADDRESS}. You must modify the definition of ! 4095: @samp{movsi} to do something appropriate when the source operand ! 4096: contains a symbolic address. You may also need to alter the handling of ! 4097: switch statements so that they use relative addresses. ! 4098: @c i rearranged the order of the macros above to try to force one of ! 4099: @c them to the next line, to eliminate an overfull hbox. --mew 10feb93 ! 4100: ! 4101: @table @code ! 4102: @findex PIC_OFFSET_TABLE_REGNUM ! 4103: @item PIC_OFFSET_TABLE_REGNUM ! 4104: The register number of the register used to address a table of static ! 4105: data addresses in memory. In some cases this register is defined by a ! 4106: processor's ``application binary interface'' (ABI). When this macro ! 4107: is defined, RTL is generated for this register once, as with the stack ! 4108: pointer and frame pointer registers. If this macro is not defined, it ! 4109: is up to the machine-dependent files to allocate such a register (if ! 4110: necessary). ! 4111: ! 4112: @findex FINALIZE_PIC ! 4113: @item FINALIZE_PIC ! 4114: By generating position-independent code, when two different programs (A ! 4115: and B) share a common library (libC.a), the text of the library can be ! 4116: shared whether or not the library is linked at the same address for both ! 4117: programs. In some of these environments, position-independent code ! 4118: requires not only the use of different addressing modes, but also ! 4119: special code to enable the use of these addressing modes. ! 4120: ! 4121: The @code{FINALIZE_PIC} macro serves as a hook to emit these special ! 4122: codes once the function is being compiled into assembly code, but not ! 4123: before. (It is not done before, because in the case of compiling an ! 4124: inline function, it would lead to multiple PIC prologues being ! 4125: included in functions which used inline functions and were compiled to ! 4126: assembly language.) ! 4127: ! 4128: @findex LEGITIMATE_PIC_OPERAND_P ! 4129: @item LEGITIMATE_PIC_OPERAND_P (@var{x}) ! 4130: A C expression that is nonzero if @var{x} is a legitimate immediate ! 4131: operand on the target machine when generating position independent code. ! 4132: You can assume that @var{x} satisfies @code{CONSTANT_P}, so you need not ! 4133: check this. You can also assume @var{flag_pic} is true, so you need not ! 4134: check it either. You need not define this macro if all constants ! 4135: (including @code{SYMBOL_REF}) can be immediate operands when generating ! 4136: position independent code. ! 4137: @end table ! 4138: ! 4139: @node Assembler Format ! 4140: @section Defining the Output Assembler Language ! 4141: ! 4142: This section describes macros whose principal purpose is to describe how ! 4143: to write instructions in assembler language--rather than what the ! 4144: instructions do. ! 4145: ! 4146: @menu ! 4147: * File Framework:: Structural information for the assembler file. ! 4148: * Data Output:: Output of constants (numbers, strings, addresses). ! 4149: * Uninitialized Data:: Output of uninitialized variables. ! 4150: * Label Output:: Output and generation of labels. ! 4151: * Initialization:: General principles of initialization ! 4152: and termination routines. ! 4153: * Macros for Initialization:: ! 4154: Specific macros that control the handling of ! 4155: initialization and termination routines. ! 4156: * Instruction Output:: Output of actual instructions. ! 4157: * Dispatch Tables:: Output of jump tables. ! 4158: * Alignment Output:: Pseudo ops for alignment and skipping data. ! 4159: @end menu ! 4160: ! 4161: @node File Framework ! 4162: @subsection The Overall Framework of an Assembler File ! 4163: @cindex assembler format ! 4164: @cindex output of assembler code ! 4165: ! 4166: @table @code ! 4167: @findex ASM_FILE_START ! 4168: @item ASM_FILE_START (@var{stream}) ! 4169: A C expression which outputs to the stdio stream @var{stream} ! 4170: some appropriate text to go at the start of an assembler file. ! 4171: ! 4172: Normally this macro is defined to output a line containing ! 4173: @samp{#NO_APP}, which is a comment that has no effect on most ! 4174: assemblers but tells the GNU assembler that it can save time by not ! 4175: checking for certain assembler constructs. ! 4176: ! 4177: On systems that use SDB, it is necessary to output certain commands; ! 4178: see @file{attasm.h}. ! 4179: ! 4180: @findex ASM_FILE_END ! 4181: @item ASM_FILE_END (@var{stream}) ! 4182: A C expression which outputs to the stdio stream @var{stream} ! 4183: some appropriate text to go at the end of an assembler file. ! 4184: ! 4185: If this macro is not defined, the default is to output nothing ! 4186: special at the end of the file. Most systems don't require any ! 4187: definition. ! 4188: ! 4189: On systems that use SDB, it is necessary to output certain commands; ! 4190: see @file{attasm.h}. ! 4191: ! 4192: @findex ASM_IDENTIFY_GCC ! 4193: @item ASM_IDENTIFY_GCC (@var{file}) ! 4194: A C statement to output assembler commands which will identify ! 4195: the object file as having been compiled with GNU CC (or another ! 4196: GNU compiler). ! 4197: ! 4198: If you don't define this macro, the string @samp{gcc_compiled.:} ! 4199: is output. This string is calculated to define a symbol which, ! 4200: on BSD systems, will never be defined for any other reason. ! 4201: GDB checks for the presence of this symbol when reading the ! 4202: symbol table of an executable. ! 4203: ! 4204: On non-BSD systems, you must arrange communication with GDB in ! 4205: some other fashion. If GDB is not used on your system, you can ! 4206: define this macro with an empty body. ! 4207: ! 4208: @findex ASM_COMMENT_START ! 4209: @item ASM_COMMENT_START ! 4210: A C string constant describing how to begin a comment in the target ! 4211: assembler language. The compiler assumes that the comment will end at ! 4212: the end of the line. ! 4213: ! 4214: @findex ASM_APP_ON ! 4215: @item ASM_APP_ON ! 4216: A C string constant for text to be output before each @code{asm} ! 4217: statement or group of consecutive ones. Normally this is ! 4218: @code{"#APP"}, which is a comment that has no effect on most ! 4219: assemblers but tells the GNU assembler that it must check the lines ! 4220: that follow for all valid assembler constructs. ! 4221: ! 4222: @findex ASM_APP_OFF ! 4223: @item ASM_APP_OFF ! 4224: A C string constant for text to be output after each @code{asm} ! 4225: statement or group of consecutive ones. Normally this is ! 4226: @code{"#NO_APP"}, which tells the GNU assembler to resume making the ! 4227: time-saving assumptions that are valid for ordinary compiler output. ! 4228: ! 4229: @findex ASM_OUTPUT_SOURCE_FILENAME ! 4230: @item ASM_OUTPUT_SOURCE_FILENAME (@var{stream}, @var{name}) ! 4231: A C statement to output COFF information or DWARF debugging information ! 4232: which indicates that filename @var{name} is the current source file to ! 4233: the stdio stream @var{stream}. ! 4234: ! 4235: This macro need not be defined if the standard form of output ! 4236: for the file format in use is appropriate. ! 4237: ! 4238: @findex ASM_OUTPUT_SOURCE_LINE ! 4239: @item ASM_OUTPUT_SOURCE_LINE (@var{stream}, @var{line}) ! 4240: A C statement to output DBX or SDB debugging information before code ! 4241: for line number @var{line} of the current source file to the ! 4242: stdio stream @var{stream}. ! 4243: ! 4244: This macro need not be defined if the standard form of debugging ! 4245: information for the debugger in use is appropriate. ! 4246: ! 4247: @findex ASM_OUTPUT_IDENT ! 4248: @item ASM_OUTPUT_IDENT (@var{stream}, @var{string}) ! 4249: A C statement to output something to the assembler file to handle a ! 4250: @samp{#ident} directive containing the text @var{string}. If this ! 4251: macro is not defined, nothing is output for a @samp{#ident} directive. ! 4252: ! 4253: @findex OBJC_PROLOGUE ! 4254: @item OBJC_PROLOGUE ! 4255: A C statement to output any assembler statements which are required to ! 4256: precede any Objective C object definitions or message sending. The ! 4257: statement is executed only when compiling an Objective C program. ! 4258: @end table ! 4259: ! 4260: @need 2000 ! 4261: @node Data Output ! 4262: @subsection Output of Data ! 4263: ! 4264: @table @code ! 4265: @findex ASM_OUTPUT_LONG_DOUBLE ! 4266: @findex ASM_OUTPUT_DOUBLE ! 4267: @findex ASM_OUTPUT_FLOAT ! 4268: @item ASM_OUTPUT_LONG_DOUBLE (@var{stream}, @var{value}) ! 4269: @itemx ASM_OUTPUT_DOUBLE (@var{stream}, @var{value}) ! 4270: @itemx ASM_OUTPUT_FLOAT (@var{stream}, @var{value}) ! 4271: A C statement to output to the stdio stream @var{stream} an assembler ! 4272: instruction to assemble a floating-point constant of @code{TFmode}, ! 4273: @code{DFmode} or @code{SFmode}, respectively, whose value is ! 4274: @var{value}. @var{value} will be a C expression of type ! 4275: @code{REAL_VALUE_TYPE}. Macros such as ! 4276: @code{REAL_VALUE_TO_TARGET_DOUBLE} are useful for writing these ! 4277: definitions. ! 4278: ! 4279: @findex ASM_OUTPUT_QUADRUPLE_INT ! 4280: @findex ASM_OUTPUT_DOUBLE_INT ! 4281: @findex ASM_OUTPUT_INT ! 4282: @findex ASM_OUTPUT_SHORT ! 4283: @findex ASM_OUTPUT_CHAR ! 4284: @findex output_addr_const ! 4285: @item ASM_OUTPUT_QUADRUPLE_INT (@var{stream}, @var{exp}) ! 4286: @itemx ASM_OUTPUT_DOUBLE_INT (@var{stream}, @var{exp}) ! 4287: @itemx ASM_OUTPUT_INT (@var{stream}, @var{exp}) ! 4288: @itemx ASM_OUTPUT_SHORT (@var{stream}, @var{exp}) ! 4289: @itemx ASM_OUTPUT_CHAR (@var{stream}, @var{exp}) ! 4290: A C statement to output to the stdio stream @var{stream} an assembler ! 4291: instruction to assemble an integer of 16, 8, 4, 2 or 1 bytes, ! 4292: respectively, whose value is @var{value}. The argument @var{exp} will ! 4293: be an RTL expression which represents a constant value. Use ! 4294: @samp{output_addr_const (@var{stream}, @var{exp})} to output this value ! 4295: as an assembler expression.@refill ! 4296: ! 4297: For sizes larger than @code{UNITS_PER_WORD}, if the action of a macro ! 4298: would be identical to repeatedly calling the macro corresponding to ! 4299: a size of @code{UNITS_PER_WORD}, once for each word, you need not define ! 4300: the macro. ! 4301: ! 4302: @findex ASM_OUTPUT_BYTE ! 4303: @item ASM_OUTPUT_BYTE (@var{stream}, @var{value}) ! 4304: A C statement to output to the stdio stream @var{stream} an assembler ! 4305: instruction to assemble a single byte containing the number @var{value}. ! 4306: ! 4307: @findex ASM_BYTE_OP ! 4308: @item ASM_BYTE_OP ! 4309: A C string constant giving the pseudo-op to use for a sequence of ! 4310: single-byte constants. If this macro is not defined, the default is ! 4311: @code{"byte"}. ! 4312: ! 4313: @findex ASM_OUTPUT_ASCII ! 4314: @item ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len}) ! 4315: A C statement to output to the stdio stream @var{stream} an assembler ! 4316: instruction to assemble a string constant containing the @var{len} ! 4317: bytes at @var{ptr}. @var{ptr} will be a C expression of type ! 4318: @code{char *} and @var{len} a C expression of type @code{int}. ! 4319: ! 4320: If the assembler has a @code{.ascii} pseudo-op as found in the ! 4321: Berkeley Unix assembler, do not define the macro ! 4322: @code{ASM_OUTPUT_ASCII}. ! 4323: ! 4324: @findex ASM_OUTPUT_POOL_PROLOGUE ! 4325: @item ASM_OUTPUT_POOL_PROLOGUE (@var{file} @var{funname} @var{fundecl} @var{size}) ! 4326: A C statement to output assembler commands to define the start of the ! 4327: constant pool for a function. @var{funname} is a string giving ! 4328: the name of the function. Should the return type of the function ! 4329: be required, it can be obtained via @var{fundecl}. @var{size} ! 4330: is the size, in bytes, of the constant pool that will be written ! 4331: immediately after this call. ! 4332: ! 4333: If no constant-pool prefix is required, the usual case, this macro need ! 4334: not be defined. ! 4335: ! 4336: @findex ASM_OUTPUT_SPECIAL_POOL_ENTRY ! 4337: @item ASM_OUTPUT_SPECIAL_POOL_ENTRY (@var{file}, @var{x}, @var{mode}, @var{align}, @var{labelno}, @var{jumpto}) ! 4338: A C statement (with or without semicolon) to output a constant in the ! 4339: constant pool, if it needs special treatment. (This macro need not do ! 4340: anything for RTL expressions that can be output normally.) ! 4341: ! 4342: The argument @var{file} is the standard I/O stream to output the ! 4343: assembler code on. @var{x} is the RTL expression for the constant to ! 4344: output, and @var{mode} is the machine mode (in case @var{x} is a ! 4345: @samp{const_int}). @var{align} is the required alignment for the value ! 4346: @var{x}; you should output an assembler directive to force this much ! 4347: alignment. ! 4348: ! 4349: The argument @var{labelno} is a number to use in an internal label for ! 4350: the address of this pool entry. The definition of this macro is ! 4351: responsible for outputting the label definition at the proper place. ! 4352: Here is how to do this: ! 4353: ! 4354: @example ! 4355: ASM_OUTPUT_INTERNAL_LABEL (@var{file}, "LC", @var{labelno}); ! 4356: @end example ! 4357: ! 4358: When you output a pool entry specially, you should end with a ! 4359: @code{goto} to the label @var{jumpto}. This will prevent the same pool ! 4360: entry from being output a second time in the usual manner. ! 4361: ! 4362: You need not define this macro if it would do nothing. ! 4363: ! 4364: @findex ASM_OPEN_PAREN ! 4365: @findex ASM_CLOSE_PAREN ! 4366: @item ASM_OPEN_PAREN ! 4367: @itemx ASM_CLOSE_PAREN ! 4368: These macros are defined as C string constant, describing the syntax ! 4369: in the assembler for grouping arithmetic expressions. The following ! 4370: definitions are correct for most assemblers: ! 4371: ! 4372: @example ! 4373: #define ASM_OPEN_PAREN "(" ! 4374: #define ASM_CLOSE_PAREN ")" ! 4375: @end example ! 4376: @end table ! 4377: ! 4378: These macros are provided by @file{real.h} for writing the definitions ! 4379: of @code{ASM_OUTPUT_DOUBLE} and the like: ! 4380: ! 4381: @table @code ! 4382: @item REAL_VALUE_TO_TARGET_SINGLE (@var{x}, @var{l}) ! 4383: @itemx REAL_VALUE_TO_TARGET_DOUBLE (@var{x}, @var{l}) ! 4384: @itemx REAL_VALUE_TO_TARGET_LONG_DOUBLE (@var{x}, @var{l}) ! 4385: @findex REAL_VALUE_TO_TARGET_SINGLE ! 4386: @findex REAL_VALUE_TO_TARGET_DOUBLE ! 4387: @findex REAL_VALUE_TO_TARGET_LONG_DOUBLE ! 4388: These translate @var{x}, of type @code{REAL_VALUE_TYPE}, to the target's ! 4389: floating point representation, and store its bit pattern in the array of ! 4390: @code{long int} whose address is @var{l}. The number of elements in the ! 4391: output array is determined by the size of the desired target floating ! 4392: point data type: 32 bits of it go in each @code{long int} array ! 4393: element. Each array element holds 32 bits of the result, even if ! 4394: @code{long int} is wider than 32 bits on the host machine. ! 4395: ! 4396: The array element values are designed so that you can print them out ! 4397: using @code{fprintf} in the order they should appear in the target ! 4398: machine's memory. ! 4399: ! 4400: @item REAL_VALUE_TO_DECIMAL (@var{x}, @var{format}, @var{string}) ! 4401: @findex REAL_VALUE_TO_DECIMAL ! 4402: This macro converts @var{x}, of type @code{REAL_VALUE_TYPE}, to a ! 4403: decimal number and stores it as a string into @var{string}. ! 4404: You must pass, as @var{string}, the address of a long enough block ! 4405: of space to hold the result. ! 4406: ! 4407: The argument @var{format} is a @code{printf}-specification that serves ! 4408: as a suggestion for how to format the output string. ! 4409: @end table ! 4410: ! 4411: @node Uninitialized Data ! 4412: @subsection Output of Uninitialized Variables ! 4413: ! 4414: Each of the macros in this section is used to do the whole job of ! 4415: outputting a single uninitialized variable. ! 4416: ! 4417: @table @code ! 4418: @findex ASM_OUTPUT_COMMON ! 4419: @item ASM_OUTPUT_COMMON (@var{stream}, @var{name}, @var{size}, @var{rounded}) ! 4420: A C statement (sans semicolon) to output to the stdio stream ! 4421: @var{stream} the assembler definition of a common-label named ! 4422: @var{name} whose size is @var{size} bytes. The variable @var{rounded} ! 4423: is the size rounded up to whatever alignment the caller wants. ! 4424: ! 4425: Use the expression @code{assemble_name (@var{stream}, @var{name})} to ! 4426: output the name itself; before and after that, output the additional ! 4427: assembler syntax for defining the name, and a newline. ! 4428: ! 4429: This macro controls how the assembler definitions of uninitialized ! 4430: global variables are output. ! 4431: ! 4432: @findex ASM_OUTPUT_ALIGNED_COMMON ! 4433: @item ASM_OUTPUT_ALIGNED_COMMON (@var{stream}, @var{name}, @var{size}, @var{alignment}) ! 4434: Like @code{ASM_OUTPUT_COMMON} except takes the required alignment as a ! 4435: separate, explicit argument. If you define this macro, it is used in ! 4436: place of @code{ASM_OUTPUT_COMMON}, and gives you more flexibility in ! 4437: handling the required alignment of the variable. ! 4438: ! 4439: @findex ASM_OUTPUT_SHARED_COMMON ! 4440: @item ASM_OUTPUT_SHARED_COMMON (@var{stream}, @var{name}, @var{size}, @var{rounded}) ! 4441: If defined, it is similar to @code{ASM_OUTPUT_COMMON}, except that it ! 4442: is used when @var{name} is shared. If not defined, @code{ASM_OUTPUT_COMMON} ! 4443: will be used. ! 4444: ! 4445: @findex ASM_OUTPUT_LOCAL ! 4446: @item ASM_OUTPUT_LOCAL (@var{stream}, @var{name}, @var{size}, @var{rounded}) ! 4447: A C statement (sans semicolon) to output to the stdio stream ! 4448: @var{stream} the assembler definition of a local-common-label named ! 4449: @var{name} whose size is @var{size} bytes. The variable @var{rounded} ! 4450: is the size rounded up to whatever alignment the caller wants. ! 4451: ! 4452: Use the expression @code{assemble_name (@var{stream}, @var{name})} to ! 4453: output the name itself; before and after that, output the additional ! 4454: assembler syntax for defining the name, and a newline. ! 4455: ! 4456: This macro controls how the assembler definitions of uninitialized ! 4457: static variables are output. ! 4458: ! 4459: @findex ASM_OUTPUT_ALIGNED_LOCAL ! 4460: @item ASM_OUTPUT_ALIGNED_LOCAL (@var{stream}, @var{name}, @var{size}, @var{alignment}) ! 4461: Like @code{ASM_OUTPUT_LOCAL} except takes the required alignment as a ! 4462: separate, explicit argument. If you define this macro, it is used in ! 4463: place of @code{ASM_OUTPUT_LOCAL}, and gives you more flexibility in ! 4464: handling the required alignment of the variable. ! 4465: ! 4466: @findex ASM_OUTPUT_SHARED_LOCAL ! 4467: @item ASM_OUTPUT_SHARED_LOCAL (@var{stream}, @var{name}, @var{size}, @var{rounded}) ! 4468: If defined, it is similar to @code{ASM_OUTPUT_LOCAL}, except that it ! 4469: is used when @var{name} is shared. If not defined, @code{ASM_OUTPUT_LOCAL} ! 4470: will be used. ! 4471: @end table ! 4472: ! 4473: @node Label Output ! 4474: @subsection Output and Generation of Labels ! 4475: ! 4476: @table @code ! 4477: @findex ASM_OUTPUT_LABEL ! 4478: @findex assemble_name ! 4479: @item ASM_OUTPUT_LABEL (@var{stream}, @var{name}) ! 4480: A C statement (sans semicolon) to output to the stdio stream ! 4481: @var{stream} the assembler definition of a label named @var{name}. ! 4482: Use the expression @code{assemble_name (@var{stream}, @var{name})} to ! 4483: output the name itself; before and after that, output the additional ! 4484: assembler syntax for defining the name, and a newline. ! 4485: ! 4486: @findex ASM_DECLARE_FUNCTION_NAME ! 4487: @item ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl}) ! 4488: A C statement (sans semicolon) to output to the stdio stream ! 4489: @var{stream} any text necessary for declaring the name @var{name} of a ! 4490: function which is being defined. This macro is responsible for ! 4491: outputting the label definition (perhaps using ! 4492: @code{ASM_OUTPUT_LABEL}). The argument @var{decl} is the ! 4493: @code{FUNCTION_DECL} tree node representing the function. ! 4494: ! 4495: If this macro is not defined, then the function name is defined in the ! 4496: usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}). ! 4497: ! 4498: @findex ASM_DECLARE_FUNCTION_SIZE ! 4499: @item ASM_DECLARE_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl}) ! 4500: A C statement (sans semicolon) to output to the stdio stream ! 4501: @var{stream} any text necessary for declaring the size of a function ! 4502: which is being defined. The argument @var{name} is the name of the ! 4503: function. The argument @var{decl} is the @code{FUNCTION_DECL} tree node ! 4504: representing the function. ! 4505: ! 4506: If this macro is not defined, then the function size is not defined. ! 4507: ! 4508: @findex ASM_DECLARE_OBJECT_NAME ! 4509: @item ASM_DECLARE_OBJECT_NAME (@var{stream}, @var{name}, @var{decl}) ! 4510: A C statement (sans semicolon) to output to the stdio stream ! 4511: @var{stream} any text necessary for declaring the name @var{name} of an ! 4512: initialized variable which is being defined. This macro must output the ! 4513: label definition (perhaps using @code{ASM_OUTPUT_LABEL}). The argument ! 4514: @var{decl} is the @code{VAR_DECL} tree node representing the variable. ! 4515: ! 4516: If this macro is not defined, then the variable name is defined in the ! 4517: usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}). ! 4518: ! 4519: @findex ASM_FINISH_DECLARE_OBJECT ! 4520: @item ASM_FINISH_DECLARE_OBJECT (@var{stream}, @var{decl}, @var{toplevel}, @var{atend}) ! 4521: A C statement (sans semicolon) to finish up declaring a variable name ! 4522: once the compiler has processed its initializer fully and thus has had a ! 4523: chance to determine the size of an array when controlled by an ! 4524: initializer. This is used on systems where it's necessary to declare ! 4525: something about the size of the object. ! 4526: ! 4527: If you don't define this macro, that is equivalent to defining it to do ! 4528: nothing. ! 4529: ! 4530: @findex ASM_GLOBALIZE_LABEL ! 4531: @item ASM_GLOBALIZE_LABEL (@var{stream}, @var{name}) ! 4532: A C statement (sans semicolon) to output to the stdio stream ! 4533: @var{stream} some commands that will make the label @var{name} global; ! 4534: that is, available for reference from other files. Use the expression ! 4535: @code{assemble_name (@var{stream}, @var{name})} to output the name ! 4536: itself; before and after that, output the additional assembler syntax ! 4537: for making that name global, and a newline. ! 4538: ! 4539: @findex ASM_OUTPUT_EXTERNAL ! 4540: @item ASM_OUTPUT_EXTERNAL (@var{stream}, @var{decl}, @var{name}) ! 4541: A C statement (sans semicolon) to output to the stdio stream ! 4542: @var{stream} any text necessary for declaring the name of an external ! 4543: symbol named @var{name} which is referenced in this compilation but ! 4544: not defined. The value of @var{decl} is the tree node for the ! 4545: declaration. ! 4546: ! 4547: This macro need not be defined if it does not need to output anything. ! 4548: The GNU assembler and most Unix assemblers don't require anything. ! 4549: ! 4550: @findex ASM_OUTPUT_EXTERNAL_LIBCALL ! 4551: @item ASM_OUTPUT_EXTERNAL_LIBCALL (@var{stream}, @var{symref}) ! 4552: A C statement (sans semicolon) to output on @var{stream} an assembler ! 4553: pseudo-op to declare a library function name external. The name of the ! 4554: library function is given by @var{symref}, which has type @code{rtx} and ! 4555: is a @code{symbol_ref}. ! 4556: ! 4557: This macro need not be defined if it does not need to output anything. ! 4558: The GNU assembler and most Unix assemblers don't require anything. ! 4559: ! 4560: @findex ASM_OUTPUT_LABELREF ! 4561: @item ASM_OUTPUT_LABELREF (@var{stream}, @var{name}) ! 4562: A C statement (sans semicolon) to output to the stdio stream ! 4563: @var{stream} a reference in assembler syntax to a label named ! 4564: @var{name}. This should add @samp{_} to the front of the name, if that ! 4565: is customary on your operating system, as it is in most Berkeley Unix ! 4566: systems. This macro is used in @code{assemble_name}. ! 4567: ! 4568: @ignore @c Seems not to exist anymore. ! 4569: @findex ASM_OUTPUT_LABELREF_AS_INT ! 4570: @item ASM_OUTPUT_LABELREF_AS_INT (@var{file}, @var{label}) ! 4571: Define this macro for systems that use the program @code{collect2}. ! 4572: The definition should be a C statement to output a word containing ! 4573: a reference to the label @var{label}. ! 4574: @end ignore ! 4575: ! 4576: @findex ASM_OUTPUT_INTERNAL_LABEL ! 4577: @item ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{prefix}, @var{num}) ! 4578: A C statement to output to the stdio stream @var{stream} a label whose ! 4579: name is made from the string @var{prefix} and the number @var{num}. ! 4580: ! 4581: It is absolutely essential that these labels be distinct from the labels ! 4582: used for user-level functions and variables. Otherwise, certain programs ! 4583: will have name conflicts with internal labels. ! 4584: ! 4585: It is desirable to exclude internal labels from the symbol table of the ! 4586: object file. Most assemblers have a naming convention for labels that ! 4587: should be excluded; on many systems, the letter @samp{L} at the ! 4588: beginning of a label has this effect. You should find out what ! 4589: convention your system uses, and follow it. ! 4590: ! 4591: The usual definition of this macro is as follows: ! 4592: ! 4593: @example ! 4594: fprintf (@var{stream}, "L%s%d:\n", @var{prefix}, @var{num}) ! 4595: @end example ! 4596: ! 4597: @findex ASM_GENERATE_INTERNAL_LABEL ! 4598: @item ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num}) ! 4599: A C statement to store into the string @var{string} a label whose name ! 4600: is made from the string @var{prefix} and the number @var{num}. ! 4601: ! 4602: This string, when output subsequently by @code{assemble_name}, should ! 4603: produce the output that @code{ASM_OUTPUT_INTERNAL_LABEL} would produce ! 4604: with the same @var{prefix} and @var{num}. ! 4605: ! 4606: If the string begins with @samp{*}, then @code{assemble_name} will ! 4607: output the rest of the string unchanged. It is often convenient for ! 4608: @code{ASM_GENERATE_INTERNAL_LABEL} to use @samp{*} in this way. If the ! 4609: string doesn't start with @samp{*}, then @code{ASM_OUTPUT_LABELREF} gets ! 4610: to output the string, and may change it. (Of course, ! 4611: @code{ASM_OUTPUT_LABELREF} is also part of your machine description, so ! 4612: you should know what it does on your machine.) ! 4613: ! 4614: @findex ASM_FORMAT_PRIVATE_NAME ! 4615: @item ASM_FORMAT_PRIVATE_NAME (@var{outvar}, @var{name}, @var{number}) ! 4616: A C expression to assign to @var{outvar} (which is a variable of type ! 4617: @code{char *}) a newly allocated string made from the string ! 4618: @var{name} and the number @var{number}, with some suitable punctuation ! 4619: added. Use @code{alloca} to get space for the string. ! 4620: ! 4621: The string will be used as an argument to @code{ASM_OUTPUT_LABELREF} to ! 4622: produce an assembler label for an internal static variable whose name is ! 4623: @var{name}. Therefore, the string must be such as to result in valid ! 4624: assembler code. The argument @var{number} is different each time this ! 4625: macro is executed; it prevents conflicts between similarly-named ! 4626: internal static variables in different scopes. ! 4627: ! 4628: Ideally this string should not be a valid C identifier, to prevent any ! 4629: conflict with the user's own symbols. Most assemblers allow periods ! 4630: or percent signs in assembler symbols; putting at least one of these ! 4631: between the name and the number will suffice. ! 4632: ! 4633: @findex OBJC_GEN_METHOD_LABEL ! 4634: @item OBJC_GEN_METHOD_LABEL (@var{buf}, @var{is_inst}, @var{class_name}, @var{cat_name}, @var{sel_name}) ! 4635: Define this macro to override the default assembler names used for ! 4636: Objective C methods. ! 4637: ! 4638: The default name is a unique method number followed by the name of the ! 4639: class (e.g.@: @samp{_1_Foo}). For methods in categories, the name of ! 4640: the category is also included in the assembler name (e.g.@: ! 4641: @samp{_1_Foo_Bar}). ! 4642: ! 4643: These names are safe on most systems, but make debugging difficult since ! 4644: the method's selector is not present in the name. Therefore, particular ! 4645: systems define other ways of computing names. ! 4646: ! 4647: @var{buf} is an expression of type @code{char *} which gives you a ! 4648: buffer in which to store the name; its length is as long as ! 4649: @var{class_name}, @var{cat_name} and @var{sel_name} put together, plus ! 4650: 50 characters extra. ! 4651: ! 4652: The argument @var{is_inst} specifies whether the method is an instance ! 4653: method or a class method; @var{class_name} is the name of the class; ! 4654: @var{cat_name} is the name of the category (or NULL if the method is not ! 4655: in a category); and @var{sel_name} is the name of the selector. ! 4656: ! 4657: On systems where the assembler can handle quoted names, you can use this ! 4658: macro to provide more human-readable names. ! 4659: @end table ! 4660: ! 4661: @node Initialization ! 4662: @subsection How Initialization Functions Are Handled ! 4663: @cindex initialization routines ! 4664: @cindex termination routines ! 4665: @cindex constructors, output of ! 4666: @cindex destructors, output of ! 4667: ! 4668: The compiled code for certain languages includes @dfn{constructors} ! 4669: (also called @dfn{initialization routines})---functions to initialize ! 4670: data in the program when the program is started. These functions need ! 4671: to be called before the program is ``started''---that is to say, before ! 4672: @code{main} is called. ! 4673: ! 4674: Compiling some languages generates @dfn{destructors} (also called ! 4675: @dfn{termination routines}) that should be called when the program ! 4676: terminates. ! 4677: ! 4678: To make the initialization and termination functions work, the compiler ! 4679: must output something in the assembler code to cause those functions to ! 4680: be called at the appropriate time. When you port the compiler to a new ! 4681: system, you need to specify how to do this. ! 4682: ! 4683: There are two major ways that GCC currently supports the execution of ! 4684: initialization and termination functions. Each way has two variants. ! 4685: Much of the structure is common to all four variations. ! 4686: ! 4687: @findex __CTOR_LIST__ ! 4688: @findex __DTOR_LIST__ ! 4689: The linker must build two lists of these functions---a list of ! 4690: initialization functions, called @code{__CTOR_LIST__}, and a list of ! 4691: termination functions, called @code{__DTOR_LIST__}. ! 4692: ! 4693: Each list always begins with an ignored function pointer (which may hold ! 4694: 0, @minus{}1, or a count of the function pointers after it, depending on ! 4695: the environment). This is followed by a series of zero or more function ! 4696: pointers to constructors (or destructors), followed by a function ! 4697: pointer containing zero. ! 4698: ! 4699: Depending on the operating system and its executable file format, either ! 4700: @file{crtstuff.c} or @file{libgcc2.c} traverses these lists at startup ! 4701: time and exit time. Constructors are called in forward order of the ! 4702: list; destructors in reverse order. ! 4703: ! 4704: The best way to handle static constructors works only for object file ! 4705: formats which provide arbitrarily-named sections. A section is set ! 4706: aside for a list of constructors, and another for a list of destructors. ! 4707: Traditionally these are called @samp{.ctors} and @samp{.dtors}. Each ! 4708: object file that defines an initialization function also puts a word in ! 4709: the constructor section to point to that function. The linker ! 4710: accumulates all these words into one contiguous @samp{.ctors} section. ! 4711: Termination functions are handled similarly. ! 4712: ! 4713: To use this method, you need appropriate definitions of the macros ! 4714: @code{ASM_OUTPUT_CONSTRUCTOR} and @code{ASM_OUTPUT_DESTRUCTOR}. Usually ! 4715: you can get them by including @file{svr4.h}. ! 4716: ! 4717: When arbitrary sections are available, there are two variants, depending ! 4718: upon how the code in @file{crtstuff.c} is called. On systems that ! 4719: support an @dfn{init} section which is executed at program startup, ! 4720: parts of @file{crtstuff.c} are compiled into that section. The ! 4721: program is linked by the @code{gcc} driver like this: ! 4722: ! 4723: @example ! 4724: ld -o @var{output_file} crtbegin.o @dots{} crtend.o -lgcc ! 4725: @end example ! 4726: ! 4727: The head of a function (@code{__do_global_ctors}) appears in the init ! 4728: section of @file{crtbegin.o}; the remainder of the function appears in ! 4729: the init section of @file{crtend.o}. The linker will pull these two ! 4730: parts of the section together, making a whole function. If any of the ! 4731: user's object files linked into the middle of it contribute code, then that ! 4732: code will be executed as part of the body of @code{__do_global_ctors}. ! 4733: ! 4734: To use this variant, you must define the @code{INIT_SECTION_ASM_OP} ! 4735: macro properly. ! 4736: ! 4737: If no init section is available, do not define ! 4738: @code{INIT_SECTION_ASM_OP}. Then @code{__do_global_ctors} is built into ! 4739: the text section like all other functions, and resides in ! 4740: @file{libgcc.a}. When GCC compiles any function called @code{main}, it ! 4741: inserts a procedure call to @code{__main} as the first executable code ! 4742: after the function prologue. The @code{__main} function, also defined ! 4743: in @file{libgcc2.c}, simply calls @file{__do_global_ctors}. ! 4744: ! 4745: In file formats that don't support arbitrary sections, there are again ! 4746: two variants. In the simplest variant, the GNU linker (GNU @code{ld}) ! 4747: and an `a.out' format must be used. In this case, ! 4748: @code{ASM_OUTPUT_CONSTRUCTOR} is defined to produce a @code{.stabs} ! 4749: entry of type @samp{N_SETT}, referencing the name @code{__CTOR_LIST__}, ! 4750: and with the address of the void function containing the initialization ! 4751: code as its value. The GNU linker recognizes this as a request to add ! 4752: the value to a ``set''; the values are accumulated, and are eventually ! 4753: placed in the executable as a vector in the format described above, with ! 4754: a leading (ignored) count and a trailing zero element. ! 4755: @code{ASM_OUTPUT_DESTRUCTOR} is handled similarly. Since no init ! 4756: section is available, the absence of @code{INIT_SECTION_ASM_OP} causes ! 4757: the compilation of @code{main} to call @code{__main} as above, starting ! 4758: the initialization process. ! 4759: ! 4760: The last variant uses neither arbitrary sections nor the GNU linker. ! 4761: This is preferable when you want to do dynamic linking and when using ! 4762: file formats which the GNU linker does not support, such as `ECOFF'. In ! 4763: this case, @code{ASM_OUTPUT_CONSTRUCTOR} does not produce an ! 4764: @code{N_SETT} symbol; initialization and termination functions are ! 4765: recognized simply by their names. This requires an extra program in the ! 4766: linkage step, called @code{collect2}. This program pretends to be the ! 4767: linker, for use with GNU CC; it does its job by running the ordinary ! 4768: linker, but also arranges to include the vectors of initialization and ! 4769: termination functions. These functions are called via @code{__main} as ! 4770: described above. ! 4771: ! 4772: Choosing among these configuration options has been simplified by a set ! 4773: of operating-system-dependent files in the @file{config} subdirectory. ! 4774: These files define all of the relevant parameters. Usually it is ! 4775: sufficient to include one into your specific machine-dependent ! 4776: configuration file. These files are: ! 4777: ! 4778: @table @file ! 4779: @item aoutos.h ! 4780: For operating systems using the `a.out' format. ! 4781: ! 4782: @item next.h ! 4783: For operating systems using the `MachO' format. ! 4784: ! 4785: @item svr3.h ! 4786: For System V Release 3 and similar systems using `COFF' format. ! 4787: ! 4788: @item svr4.h ! 4789: For System V Release 4 and similar systems using `ELF' format. ! 4790: ! 4791: @item vms.h ! 4792: For the VMS operating system. ! 4793: @end table ! 4794: ! 4795: @ifinfo ! 4796: The following section describes the specific macros that control and ! 4797: customize the handling of initialization and termination functions. ! 4798: @end ifinfo ! 4799: ! 4800: @node Macros for Initialization ! 4801: @subsection Macros Controlling Initialization Routines ! 4802: ! 4803: Here are the macros that control how the compiler handles initialization ! 4804: and termination functions: ! 4805: ! 4806: @table @code ! 4807: @findex INIT_SECTION_ASM_OP ! 4808: @item INIT_SECTION_ASM_OP ! 4809: If defined, a C string constant for the assembler operation to identify ! 4810: the following data as initialization code. If not defined, GNU CC will ! 4811: assume such a section does not exist. When you are using special ! 4812: sections for initialization and termination functions, this macro also ! 4813: controls how @file{crtstuff.c} and @file{libgcc2.c} arrange to run the ! 4814: initialization functions. ! 4815: ! 4816: @item ASM_OUTPUT_CONSTRUCTOR (@var{stream}, @var{name}) ! 4817: @findex ASM_OUTPUT_CONSTRUCTOR ! 4818: Define this macro as a C statement to output on the stream @var{stream} ! 4819: the assembler code to arrange to call the function named @var{name} at ! 4820: initialization time. ! 4821: ! 4822: Assume that @var{name} is the name of a C function generated ! 4823: automatically by the compiler. This function takes no arguments. Use ! 4824: the function @code{assemble_name} to output the name @var{name}; this ! 4825: performs any system-specific syntactic transformations such as adding an ! 4826: underscore. ! 4827: ! 4828: If you don't define this macro, nothing special is output to arrange to ! 4829: call the function. This is correct when the function will be called in ! 4830: some other manner---for example, by means of the @code{collect2} program, ! 4831: which looks through the symbol table to find these functions by their ! 4832: names. ! 4833: ! 4834: @item ASM_OUTPUT_DESTRUCTOR (@var{stream}, @var{name}) ! 4835: @findex ASM_OUTPUT_DESTRUCTOR ! 4836: This is like @code{ASM_OUTPUT_CONSTRUCTOR} but used for termination ! 4837: functions rather than initialization functions. ! 4838: @end table ! 4839: ! 4840: If your system uses @code{collect2} as the means of processing ! 4841: constructors, then that program normally uses @code{nm} to scan an ! 4842: object file for constructor functions to be called. On certain kinds of ! 4843: systems, you can define these macros to make @code{collect2} work faster ! 4844: (and, in some cases, make it work at all): ! 4845: ! 4846: @table @code ! 4847: @findex OBJECT_FORMAT_COFF ! 4848: @item OBJECT_FORMAT_COFF ! 4849: Define this macro if the system uses COFF (Common Object File Format) ! 4850: object files, so that @code{collect2} can assume this format and scan ! 4851: object files directly for dynamic constructor/destructor functions. ! 4852: ! 4853: @findex OBJECT_FORMAT_ROSE ! 4854: @item OBJECT_FORMAT_ROSE ! 4855: Define this macro if the system uses ROSE format object files, so that ! 4856: @code{collect2} can assume this format and scan object files directly ! 4857: for dynamic constructor/destructor functions. ! 4858: @end table ! 4859: ! 4860: These macros are effective only in a native compiler; @code{collect2} as ! 4861: part of a cross compiler always uses @code{nm}. ! 4862: ! 4863: @table @code ! 4864: @findex REAL_NM_FILE_NAME ! 4865: @item REAL_NM_FILE_NAME ! 4866: Define this macro as a C string constant containing the file name to use ! 4867: to execute @code{nm}. The default is to search the path normally for ! 4868: @code{nm}. ! 4869: @end table ! 4870: ! 4871: @node Instruction Output ! 4872: @subsection Output of Assembler Instructions ! 4873: ! 4874: @table @code ! 4875: @findex REGISTER_NAMES ! 4876: @item REGISTER_NAMES ! 4877: A C initializer containing the assembler's names for the machine ! 4878: registers, each one as a C string constant. This is what translates ! 4879: register numbers in the compiler into assembler language. ! 4880: ! 4881: @findex ADDITIONAL_REGISTER_NAMES ! 4882: @item ADDITIONAL_REGISTER_NAMES ! 4883: If defined, a C initializer for an array of structures containing a name ! 4884: and a register number. This macro defines additional names for hard ! 4885: registers, thus allowing the @code{asm} option in declarations to refer ! 4886: to registers using alternate names. ! 4887: ! 4888: @findex ASM_OUTPUT_OPCODE ! 4889: @item ASM_OUTPUT_OPCODE (@var{stream}, @var{ptr}) ! 4890: Define this macro if you are using an unusual assembler that ! 4891: requires different names for the machine instructions. ! 4892: ! 4893: The definition is a C statement or statements which output an ! 4894: assembler instruction opcode to the stdio stream @var{stream}. The ! 4895: macro-operand @var{ptr} is a variable of type @code{char *} which ! 4896: points to the opcode name in its ``internal'' form---the form that is ! 4897: written in the machine description. The definition should output the ! 4898: opcode name to @var{stream}, performing any translation you desire, and ! 4899: increment the variable @var{ptr} to point at the end of the opcode ! 4900: so that it will not be output twice. ! 4901: ! 4902: In fact, your macro definition may process less than the entire opcode ! 4903: name, or more than the opcode name; but if you want to process text ! 4904: that includes @samp{%}-sequences to substitute operands, you must take ! 4905: care of the substitution yourself. Just be sure to increment ! 4906: @var{ptr} over whatever text should not be output normally. ! 4907: ! 4908: @findex recog_operand ! 4909: If you need to look at the operand values, they can be found as the ! 4910: elements of @code{recog_operand}. ! 4911: ! 4912: If the macro definition does nothing, the instruction is output ! 4913: in the usual way. ! 4914: ! 4915: @findex FINAL_PRESCAN_INSN ! 4916: @item FINAL_PRESCAN_INSN (@var{insn}, @var{opvec}, @var{noperands}) ! 4917: If defined, a C statement to be executed just prior to the output of ! 4918: assembler code for @var{insn}, to modify the extracted operands so ! 4919: they will be output differently. ! 4920: ! 4921: Here the argument @var{opvec} is the vector containing the operands ! 4922: extracted from @var{insn}, and @var{noperands} is the number of ! 4923: elements of the vector which contain meaningful data for this insn. ! 4924: The contents of this vector are what will be used to convert the insn ! 4925: template into assembler code, so you can change the assembler output ! 4926: by changing the contents of the vector. ! 4927: ! 4928: This macro is useful when various assembler syntaxes share a single ! 4929: file of instruction patterns; by defining this macro differently, you ! 4930: can cause a large class of instructions to be output differently (such ! 4931: as with rearranged operands). Naturally, variations in assembler ! 4932: syntax affecting individual insn patterns ought to be handled by ! 4933: writing conditional output routines in those patterns. ! 4934: ! 4935: If this macro is not defined, it is equivalent to a null statement. ! 4936: ! 4937: @findex PRINT_OPERAND ! 4938: @item PRINT_OPERAND (@var{stream}, @var{x}, @var{code}) ! 4939: A C compound statement to output to stdio stream @var{stream} the ! 4940: assembler syntax for an instruction operand @var{x}. @var{x} is an ! 4941: RTL expression. ! 4942: ! 4943: @var{code} is a value that can be used to specify one of several ways ! 4944: of printing the operand. It is used when identical operands must be ! 4945: printed differently depending on the context. @var{code} comes from ! 4946: the @samp{%} specification that was used to request printing of the ! 4947: operand. If the specification was just @samp{%@var{digit}} then ! 4948: @var{code} is 0; if the specification was @samp{%@var{ltr} ! 4949: @var{digit}} then @var{code} is the ASCII code for @var{ltr}. ! 4950: ! 4951: @findex reg_names ! 4952: If @var{x} is a register, this macro should print the register's name. ! 4953: The names can be found in an array @code{reg_names} whose type is ! 4954: @code{char *[]}. @code{reg_names} is initialized from ! 4955: @code{REGISTER_NAMES}. ! 4956: ! 4957: When the machine description has a specification @samp{%@var{punct}} ! 4958: (a @samp{%} followed by a punctuation character), this macro is called ! 4959: with a null pointer for @var{x} and the punctuation character for ! 4960: @var{code}. ! 4961: ! 4962: @findex PRINT_OPERAND_PUNCT_VALID_P ! 4963: @item PRINT_OPERAND_PUNCT_VALID_P (@var{code}) ! 4964: A C expression which evaluates to true if @var{code} is a valid ! 4965: punctuation character for use in the @code{PRINT_OPERAND} macro. If ! 4966: @code{PRINT_OPERAND_PUNCT_VALID_P} is not defined, it means that no ! 4967: punctuation characters (except for the standard one, @samp{%}) are used ! 4968: in this way. ! 4969: ! 4970: @findex PRINT_OPERAND_ADDRESS ! 4971: @item PRINT_OPERAND_ADDRESS (@var{stream}, @var{x}) ! 4972: A C compound statement to output to stdio stream @var{stream} the ! 4973: assembler syntax for an instruction operand that is a memory reference ! 4974: whose address is @var{x}. @var{x} is an RTL expression. ! 4975: ! 4976: @cindex @code{ENCODE_SECTION_INFO} usage ! 4977: On some machines, the syntax for a symbolic address depends on the ! 4978: section that the address refers to. On these machines, define the macro ! 4979: @code{ENCODE_SECTION_INFO} to store the information into the ! 4980: @code{symbol_ref}, and then check for it here. @xref{Assembler Format}. ! 4981: ! 4982: @findex DBR_OUTPUT_SEQEND ! 4983: @findex dbr_sequence_length ! 4984: @item DBR_OUTPUT_SEQEND(@var{file}) ! 4985: A C statement, to be executed after all slot-filler instructions have ! 4986: been output. If necessary, call @code{dbr_sequence_length} to ! 4987: determine the number of slots filled in a sequence (zero if not ! 4988: currently outputting a sequence), to decide how many no-ops to output, ! 4989: or whatever. ! 4990: ! 4991: Don't define this macro if it has nothing to do, but it is helpful in ! 4992: reading assembly output if the extent of the delay sequence is made ! 4993: explicit (e.g. with white space). ! 4994: ! 4995: @findex final_sequence ! 4996: Note that output routines for instructions with delay slots must be ! 4997: prepared to deal with not being output as part of a sequence (i.e. ! 4998: when the scheduling pass is not run, or when no slot fillers could be ! 4999: found.) The variable @code{final_sequence} is null when not ! 5000: processing a sequence, otherwise it contains the @code{sequence} rtx ! 5001: being output. ! 5002: ! 5003: @findex REGISTER_PREFIX ! 5004: @findex LOCAL_LABEL_PREFIX ! 5005: @findex USER_LABEL_PREFIX ! 5006: @findex IMMEDIATE_PREFIX ! 5007: @findex asm_fprintf ! 5008: @item REGISTER_PREFIX ! 5009: @itemx LOCAL_LABEL_PREFIX ! 5010: @itemx USER_LABEL_PREFIX ! 5011: @itemx IMMEDIATE_PREFIX ! 5012: If defined, C string expressions to be used for the @samp{%R}, @samp{%L}, ! 5013: @samp{%U}, and @samp{%I} options of @code{asm_fprintf} (see ! 5014: @file{final.c}). These are useful when a single @file{md} file must ! 5015: support multiple assembler formats. In that case, the various @file{tm.h} ! 5016: files can define these macros differently. ! 5017: ! 5018: @findex ASSEMBLER_DIALECT ! 5019: @item ASSEMBLER_DIALECT ! 5020: If your target supports multiple dialects of assembler language (such as ! 5021: different opcodes), define this macro as a C expression that gives the ! 5022: numeric index of the assembler langauge dialect to use, with zero as the ! 5023: first variant. ! 5024: ! 5025: If this macro is defined, you may use ! 5026: @samp{@{option0|option1|option2@dots{}@}} constructs in the output ! 5027: templates of patterns (@pxref{Output Template}) or in the first argument ! 5028: of @code{asm_fprintf}. This construct outputs @samp{option0}, ! 5029: @samp{option1} or @samp{option2}, etc., if the value of ! 5030: @code{ASSEMBLER_DIALECT} is zero, one or two, etc. Any special ! 5031: characters within these strings retain their usual meaning. ! 5032: ! 5033: If you do not define this macro, the characters @samp{@{}, @samp{|} and ! 5034: @samp{@}} do not have any special meaning when used in templates or ! 5035: operands to @code{asm_fprintf}. ! 5036: ! 5037: Define the macros @code{REGISTER_PREFIX}, @code{LOCAL_LABEL_PREFIX}, ! 5038: @code{USER_LABEL_PREFIX} and @code{IMMEDIATE_PREFIX} if you can express ! 5039: the variations in assemble language syntax with that mechanism. Define ! 5040: @code{ASSEMBLER_DIALECT} and use the @samp{@{option0|option1@}} syntax ! 5041: if the syntax variant are larger and involve such things as different ! 5042: opcodes or operand order. ! 5043: ! 5044: @findex ASM_OUTPUT_REG_PUSH ! 5045: @item ASM_OUTPUT_REG_PUSH (@var{stream}, @var{regno}) ! 5046: A C expression to output to @var{stream} some assembler code ! 5047: which will push hard register number @var{regno} onto the stack. ! 5048: The code need not be optimal, since this macro is used only when ! 5049: profiling. ! 5050: ! 5051: @findex ASM_OUTPUT_REG_POP ! 5052: @item ASM_OUTPUT_REG_POP (@var{stream}, @var{regno}) ! 5053: A C expression to output to @var{stream} some assembler code ! 5054: which will pop hard register number @var{regno} off of the stack. ! 5055: The code need not be optimal, since this macro is used only when ! 5056: profiling. ! 5057: @end table ! 5058: ! 5059: @node Dispatch Tables ! 5060: @subsection Output of Dispatch Tables ! 5061: ! 5062: @table @code ! 5063: @cindex dispatch table ! 5064: @findex ASM_OUTPUT_ADDR_DIFF_ELT ! 5065: @item ASM_OUTPUT_ADDR_DIFF_ELT (@var{stream}, @var{value}, @var{rel}) ! 5066: This macro should be provided on machines where the addresses ! 5067: in a dispatch table are relative to the table's own address. ! 5068: ! 5069: The definition should be a C statement to output to the stdio stream ! 5070: @var{stream} an assembler pseudo-instruction to generate a difference ! 5071: between two labels. @var{value} and @var{rel} are the numbers of two ! 5072: internal labels. The definitions of these labels are output using ! 5073: @code{ASM_OUTPUT_INTERNAL_LABEL}, and they must be printed in the same ! 5074: way here. For example, ! 5075: ! 5076: @example ! 5077: fprintf (@var{stream}, "\t.word L%d-L%d\n", ! 5078: @var{value}, @var{rel}) ! 5079: @end example ! 5080: ! 5081: @findex ASM_OUTPUT_ADDR_VEC_ELT ! 5082: @item ASM_OUTPUT_ADDR_VEC_ELT (@var{stream}, @var{value}) ! 5083: This macro should be provided on machines where the addresses ! 5084: in a dispatch table are absolute. ! 5085: ! 5086: The definition should be a C statement to output to the stdio stream ! 5087: @var{stream} an assembler pseudo-instruction to generate a reference to ! 5088: a label. @var{value} is the number of an internal label whose ! 5089: definition is output using @code{ASM_OUTPUT_INTERNAL_LABEL}. ! 5090: For example, ! 5091: ! 5092: @example ! 5093: fprintf (@var{stream}, "\t.word L%d\n", @var{value}) ! 5094: @end example ! 5095: ! 5096: @findex ASM_OUTPUT_CASE_LABEL ! 5097: @item ASM_OUTPUT_CASE_LABEL (@var{stream}, @var{prefix}, @var{num}, @var{table}) ! 5098: Define this if the label before a jump-table needs to be output ! 5099: specially. The first three arguments are the same as for ! 5100: @code{ASM_OUTPUT_INTERNAL_LABEL}; the fourth argument is the ! 5101: jump-table which follows (a @code{jump_insn} containing an ! 5102: @code{addr_vec} or @code{addr_diff_vec}). ! 5103: ! 5104: This feature is used on system V to output a @code{swbeg} statement ! 5105: for the table. ! 5106: ! 5107: If this macro is not defined, these labels are output with ! 5108: @code{ASM_OUTPUT_INTERNAL_LABEL}. ! 5109: ! 5110: @findex ASM_OUTPUT_CASE_END ! 5111: @item ASM_OUTPUT_CASE_END (@var{stream}, @var{num}, @var{table}) ! 5112: Define this if something special must be output at the end of a ! 5113: jump-table. The definition should be a C statement to be executed ! 5114: after the assembler code for the table is written. It should write ! 5115: the appropriate code to stdio stream @var{stream}. The argument ! 5116: @var{table} is the jump-table insn, and @var{num} is the label-number ! 5117: of the preceding label. ! 5118: ! 5119: If this macro is not defined, nothing special is output at the end of ! 5120: the jump-table. ! 5121: @end table ! 5122: ! 5123: @node Alignment Output ! 5124: @subsection Assembler Commands for Alignment ! 5125: ! 5126: @table @code ! 5127: @findex ASM_OUTPUT_ALIGN_CODE ! 5128: @item ASM_OUTPUT_ALIGN_CODE (@var{file}) ! 5129: A C expression to output text to align the location counter in the way ! 5130: that is desirable at a point in the code that is reached only by ! 5131: jumping. ! 5132: ! 5133: This macro need not be defined if you don't want any special alignment ! 5134: to be done at such a time. Most machine descriptions do not currently ! 5135: define the macro. ! 5136: ! 5137: @findex ASM_OUTPUT_LOOP_ALIGN ! 5138: @item ASM_OUTPUT_LOOP_ALIGN (@var{file}) ! 5139: A C expression to output text to align the location counter in the way ! 5140: that is desirable at the beginning of a loop. ! 5141: ! 5142: This macro need not be defined if you don't want any special alignment ! 5143: to be done at such a time. Most machine descriptions do not currently ! 5144: define the macro. ! 5145: ! 5146: @findex ASM_OUTPUT_SKIP ! 5147: @item ASM_OUTPUT_SKIP (@var{stream}, @var{nbytes}) ! 5148: A C statement to output to the stdio stream @var{stream} an assembler ! 5149: instruction to advance the location counter by @var{nbytes} bytes. ! 5150: Those bytes should be zero when loaded. @var{nbytes} will be a C ! 5151: expression of type @code{int}. ! 5152: ! 5153: @findex ASM_NO_SKIP_IN_TEXT ! 5154: @item ASM_NO_SKIP_IN_TEXT ! 5155: Define this macro if @code{ASM_OUTPUT_SKIP} should not be used in the ! 5156: text section because it fails put zeros in the bytes that are skipped. ! 5157: This is true on many Unix systems, where the pseudo--op to skip bytes ! 5158: produces no-op instructions rather than zeros when used in the text ! 5159: section. ! 5160: ! 5161: @findex ASM_OUTPUT_ALIGN ! 5162: @item ASM_OUTPUT_ALIGN (@var{stream}, @var{power}) ! 5163: A C statement to output to the stdio stream @var{stream} an assembler ! 5164: command to advance the location counter to a multiple of 2 to the ! 5165: @var{power} bytes. @var{power} will be a C expression of type @code{int}. ! 5166: @end table ! 5167: ! 5168: @need 3000 ! 5169: @node Debugging Info ! 5170: @section Controlling Debugging Information Format ! 5171: @c this should have some text in here.... --mew 10feb93 ! 5172: ! 5173: @menu ! 5174: * All Debuggers:: Macros that affect all debugging formats uniformly. ! 5175: * DBX Options:: Macros enabling specific options in DBX format. ! 5176: * DBX Hooks:: Hook macros for varying DBX format. ! 5177: * File Names and DBX:: Macros controlling output of file names in DBX format. ! 5178: * SDB and DWARF:: Macros for SDB (COFF) and DWARF formats. ! 5179: @end menu ! 5180: ! 5181: @node All Debuggers ! 5182: @subsection Macros Affecting All Debugging Formats ! 5183: ! 5184: @table @code ! 5185: @findex DBX_REGISTER_NUMBER ! 5186: @item DBX_REGISTER_NUMBER (@var{regno}) ! 5187: A C expression that returns the DBX register number for the compiler ! 5188: register number @var{regno}. In simple cases, the value of this ! 5189: expression may be @var{regno} itself. But sometimes there are some ! 5190: registers that the compiler knows about and DBX does not, or vice ! 5191: versa. In such cases, some register may need to have one number in ! 5192: the compiler and another for DBX. ! 5193: ! 5194: If two registers have consecutive numbers inside GNU CC, and they can be ! 5195: used as a pair to hold a multiword value, then they @emph{must} have ! 5196: consecutive numbers after renumbering with @code{DBX_REGISTER_NUMBER}. ! 5197: Otherwise, debuggers will be unable to access such a pair, because they ! 5198: expect register pairs to be consecutive in their own numbering scheme. ! 5199: ! 5200: If you find yourself defining @code{DBX_REGISTER_NUMBER} in way that ! 5201: does not preserve register pairs, then what you must do instead is ! 5202: redefine the actual register numbering scheme. ! 5203: ! 5204: @findex DEBUGGER_AUTO_OFFSET ! 5205: @item DEBUGGER_AUTO_OFFSET (@var{x}) ! 5206: A C expression that returns the integer offset value for an automatic ! 5207: variable having address @var{x} (an RTL expression). The default ! 5208: computation assumes that @var{x} is based on the frame-pointer and ! 5209: gives the offset from the frame-pointer. This is required for targets ! 5210: that produce debugging output for DBX or COFF-style debugging output ! 5211: for SDB and allow the frame-pointer to be eliminated when the ! 5212: @samp{-g} options is used. ! 5213: ! 5214: @findex DEBUGGER_ARG_OFFSET ! 5215: @item DEBUGGER_ARG_OFFSET (@var{offset}, @var{x}) ! 5216: A C expression that returns the integer offset value for an argument ! 5217: having address @var{x} (an RTL expression). The nominal offset is ! 5218: @var{offset}. ! 5219: ! 5220: @findex PREFERRED_DEBUGGING_TYPE ! 5221: @item PREFERRED_DEBUGGING_TYPE ! 5222: A C expression that returns the type of debugging output GNU CC produces ! 5223: when the user specifies @samp{-g} or @samp{-ggdb}. Define this if you ! 5224: have arranged for GNU CC to support more than one format of debugging ! 5225: output. Currently, the allowable values are @code{DBX_DEBUG}, ! 5226: @code{SDB_DEBUG}, @code{DWARF_DEBUG}, and @code{XCOFF_DEBUG}. ! 5227: ! 5228: The value of this macro only affects the default debugging output; the ! 5229: user can always get a specific type of output by using @samp{-gstabs}, ! 5230: @samp{-gcoff}, @samp{-gdwarf}, or @samp{-gxcoff}. ! 5231: @end table ! 5232: ! 5233: @node DBX Options ! 5234: @subsection Specific Options for DBX Output ! 5235: ! 5236: @table @code ! 5237: @findex DBX_DEBUGGING_INFO ! 5238: @item DBX_DEBUGGING_INFO ! 5239: Define this macro if GNU CC should produce debugging output for DBX ! 5240: in response to the @samp{-g} option. ! 5241: ! 5242: @findex XCOFF_DEBUGGING_INFO ! 5243: @item XCOFF_DEBUGGING_INFO ! 5244: Define this macro if GNU CC should produce XCOFF format debugging output ! 5245: in response to the @samp{-g} option. This is a variant of DBX format. ! 5246: ! 5247: @findex DEFAULT_GDB_EXTENSIONS ! 5248: @item DEFAULT_GDB_EXTENSIONS ! 5249: Define this macro to control whether GNU CC should by default generate ! 5250: GDB's extended version of DBX debugging information (assuming DBX-format ! 5251: debugging information is enabled at all). If you don't define the ! 5252: macro, the default is 1: always generate the extended information ! 5253: if there is any occasion to. ! 5254: ! 5255: @findex DEBUG_SYMS_TEXT ! 5256: @item DEBUG_SYMS_TEXT ! 5257: Define this macro if all @code{.stabs} commands should be output while ! 5258: in the text section. ! 5259: ! 5260: @findex ASM_STABS_OP ! 5261: @item ASM_STABS_OP ! 5262: A C string constant naming the assembler pseudo op to use instead of ! 5263: @code{.stabs} to define an ordinary debugging symbol. If you don't ! 5264: define this macro, @code{.stabs} is used. This macro applies only to ! 5265: DBX debugging information format. ! 5266: ! 5267: @findex ASM_STABD_OP ! 5268: @item ASM_STABD_OP ! 5269: A C string constant naming the assembler pseudo op to use instead of ! 5270: @code{.stabd} to define a debugging symbol whose value is the current ! 5271: location. If you don't define this macro, @code{.stabd} is used. ! 5272: This macro applies only to DBX debugging information format. ! 5273: ! 5274: @findex ASM_STABN_OP ! 5275: @item ASM_STABN_OP ! 5276: A C string constant naming the assembler pseudo op to use instead of ! 5277: @code{.stabn} to define a debugging symbol with no name. If you don't ! 5278: define this macro, @code{.stabn} is used. This macro applies only to ! 5279: DBX debugging information format. ! 5280: ! 5281: @findex DBX_NO_XREFS ! 5282: @item DBX_NO_XREFS ! 5283: Define this macro if DBX on your system does not support the construct ! 5284: @samp{xs@var{tagname}}. On some systems, this construct is used to ! 5285: describe a forward reference to a structure named @var{tagname}. ! 5286: On other systems, this construct is not supported at all. ! 5287: ! 5288: @findex DBX_CONTIN_LENGTH ! 5289: @item DBX_CONTIN_LENGTH ! 5290: A symbol name in DBX-format debugging information is normally ! 5291: continued (split into two separate @code{.stabs} directives) when it ! 5292: exceeds a certain length (by default, 80 characters). On some ! 5293: operating systems, DBX requires this splitting; on others, splitting ! 5294: must not be done. You can inhibit splitting by defining this macro ! 5295: with the value zero. You can override the default splitting-length by ! 5296: defining this macro as an expression for the length you desire. ! 5297: ! 5298: @findex DBX_CONTIN_CHAR ! 5299: @item DBX_CONTIN_CHAR ! 5300: Normally continuation is indicated by adding a @samp{\} character to ! 5301: the end of a @code{.stabs} string when a continuation follows. To use ! 5302: a different character instead, define this macro as a character ! 5303: constant for the character you want to use. Do not define this macro ! 5304: if backslash is correct for your system. ! 5305: ! 5306: @findex DBX_STATIC_STAB_DATA_SECTION ! 5307: @item DBX_STATIC_STAB_DATA_SECTION ! 5308: Define this macro if it is necessary to go to the data section before ! 5309: outputting the @samp{.stabs} pseudo-op for a non-global static ! 5310: variable. ! 5311: ! 5312: @findex DBX_TYPE_DECL_STABS_CODE ! 5313: @item DBX_TYPE_DECL_STABS_CODE ! 5314: The value to use in the ``code'' field of the @code{.stabs} directive ! 5315: for a typedef. The default is @code{N_LSYM}. ! 5316: ! 5317: @findex DBX_STATIC_CONST_VAR_CODE ! 5318: @item DBX_STATIC_CONST_VAR_CODE ! 5319: The value to use in the ``code'' field of the @code{.stabs} directive ! 5320: for a static variable located in the text section. DBX format does not ! 5321: provide any ``right'' way to do this. The default is @code{N_FUN}. ! 5322: ! 5323: @findex DBX_REGPARM_STABS_CODE ! 5324: @item DBX_REGPARM_STABS_CODE ! 5325: The value to use in the ``code'' field of the @code{.stabs} directive ! 5326: for a parameter passed in registers. DBX format does not provide any ! 5327: ``right'' way to do this. The default is @code{N_RSYM}. ! 5328: ! 5329: @findex DBX_REGPARM_STABS_LETTER ! 5330: @item DBX_REGPARM_STABS_LETTER ! 5331: The letter to use in DBX symbol data to identify a symbol as a parameter ! 5332: passed in registers. DBX format does not customarily provide any way to ! 5333: do this. The default is @code{'P'}. ! 5334: ! 5335: @findex DBX_MEMPARM_STABS_LETTER ! 5336: @item DBX_MEMPARM_STABS_LETTER ! 5337: The letter to use in DBX symbol data to identify a symbol as a stack ! 5338: parameter. The default is @code{'p'}. ! 5339: ! 5340: @findex DBX_FUNCTION_FIRST ! 5341: @item DBX_FUNCTION_FIRST ! 5342: Define this macro if the DBX information for a function and its ! 5343: arguments should precede the assembler code for the function. Normally, ! 5344: in DBX format, the debugging information entirely follows the assembler ! 5345: code. ! 5346: ! 5347: @findex DBX_LBRAC_FIRST ! 5348: @item DBX_LBRAC_FIRST ! 5349: Define this macro if the @code{N_LBRAC} symbol for a block should ! 5350: precede the debugging information for variables and functions defined in ! 5351: that block. Normally, in DBX format, the @code{N_LBRAC} symbol comes ! 5352: first. ! 5353: @end table ! 5354: ! 5355: @node DBX Hooks ! 5356: @subsection Open-Ended Hooks for DBX Format ! 5357: ! 5358: @table @code ! 5359: @findex DBX_OUTPUT_LBRAC ! 5360: @item DBX_OUTPUT_LBRAC (@var{stream}, @var{name}) ! 5361: Define this macro to say how to output to @var{stream} the debugging ! 5362: information for the start of a scope level for variable names. The ! 5363: argument @var{name} is the name of an assembler symbol (for use with ! 5364: @code{assemble_name}) whose value is the address where the scope begins. ! 5365: ! 5366: @findex DBX_OUTPUT_RBRAC ! 5367: @item DBX_OUTPUT_RBRAC (@var{stream}, @var{name}) ! 5368: Like @code{DBX_OUTPUT_LBRAC}, but for the end of a scope level. ! 5369: ! 5370: @findex DBX_OUTPUT_ENUM ! 5371: @item DBX_OUTPUT_ENUM (@var{stream}, @var{type}) ! 5372: Define this macro if the target machine requires special handling to ! 5373: output an enumeration type. The definition should be a C statement ! 5374: (sans semicolon) to output the appropriate information to @var{stream} ! 5375: for the type @var{type}. ! 5376: ! 5377: @findex DBX_OUTPUT_FUNCTION_END ! 5378: @item DBX_OUTPUT_FUNCTION_END (@var{stream}, @var{function}) ! 5379: Define this macro if the target machine requires special output at the ! 5380: end of the debugging information for a function. The definition should ! 5381: be a C statement (sans semicolon) to output the appropriate information ! 5382: to @var{stream}. @var{function} is the @code{FUNCTION_DECL} node for ! 5383: the function. ! 5384: ! 5385: @findex DBX_OUTPUT_STANDARD_TYPES ! 5386: @item DBX_OUTPUT_STANDARD_TYPES (@var{syms}) ! 5387: Define this macro if you need to control the order of output of the ! 5388: standard data types at the beginning of compilation. The argument ! 5389: @var{syms} is a @code{tree} which is a chain of all the predefined ! 5390: global symbols, including names of data types. ! 5391: ! 5392: Normally, DBX output starts with definitions of the types for integers ! 5393: and characters, followed by all the other predefined types of the ! 5394: particular language in no particular order. ! 5395: ! 5396: On some machines, it is necessary to output different particular types ! 5397: first. To do this, define @code{DBX_OUTPUT_STANDARD_TYPES} to output ! 5398: those symbols in the necessary order. Any predefined types that you ! 5399: don't explicitly output will be output afterward in no particular order. ! 5400: ! 5401: Be careful not to define this macro so that it works only for C. There ! 5402: are no global variables to access most of the built-in types, because ! 5403: another language may have another set of types. The way to output a ! 5404: particular type is to look through @var{syms} to see if you can find it. ! 5405: Here is an example: ! 5406: ! 5407: @smallexample ! 5408: @{ ! 5409: tree decl; ! 5410: for (decl = syms; decl; decl = TREE_CHAIN (decl)) ! 5411: if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), ! 5412: "long int")) ! 5413: dbxout_symbol (decl); ! 5414: @dots{} ! 5415: @} ! 5416: @end smallexample ! 5417: ! 5418: @noindent ! 5419: This does nothing if the expected type does not exist. ! 5420: ! 5421: See the function @code{init_decl_processing} in @file{c-decl.c} to find ! 5422: the names to use for all the built-in C types. ! 5423: ! 5424: Here is another way of finding a particular type: ! 5425: ! 5426: @c this is still overfull. --mew 10feb93 ! 5427: @smallexample ! 5428: @{ ! 5429: tree decl; ! 5430: for (decl = syms; decl; decl = TREE_CHAIN (decl)) ! 5431: if (TREE_CODE (decl) == TYPE_DECL ! 5432: && (TREE_CODE (TREE_TYPE (decl)) ! 5433: == INTEGER_CST) ! 5434: && TYPE_PRECISION (TREE_TYPE (decl)) == 16 ! 5435: && TYPE_UNSIGNED (TREE_TYPE (decl))) ! 5436: @group ! 5437: /* @r{This must be @code{unsigned short}.} */ ! 5438: dbxout_symbol (decl); ! 5439: @dots{} ! 5440: @} ! 5441: @end group ! 5442: @end smallexample ! 5443: @end table ! 5444: ! 5445: @node File Names and DBX ! 5446: @subsection File Names in DBX Format ! 5447: ! 5448: @table @code ! 5449: @findex DBX_WORKING_DIRECTORY ! 5450: @item DBX_WORKING_DIRECTORY ! 5451: Define this if DBX wants to have the current directory recorded in each ! 5452: object file. ! 5453: ! 5454: Note that the working directory is always recorded if GDB extensions are ! 5455: enabled. ! 5456: ! 5457: @findex DBX_OUTPUT_MAIN_SOURCE_FILENAME ! 5458: @item DBX_OUTPUT_MAIN_SOURCE_FILENAME (@var{stream}, @var{name}) ! 5459: A C statement to output DBX debugging information to the stdio stream ! 5460: @var{stream} which indicates that file @var{name} is the main source ! 5461: file---the file specified as the input file for compilation. ! 5462: This macro is called only once, at the beginning of compilation. ! 5463: ! 5464: This macro need not be defined if the standard form of output ! 5465: for DBX debugging information is appropriate. ! 5466: ! 5467: @findex DBX_OUTPUT_MAIN_SOURCE_DIRECTORY ! 5468: @item DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (@var{stream}, @var{name}) ! 5469: A C statement to output DBX debugging information to the stdio stream ! 5470: @var{stream} which indicates that the current directory during ! 5471: compilation is named @var{name}. ! 5472: ! 5473: This macro need not be defined if the standard form of output ! 5474: for DBX debugging information is appropriate. ! 5475: ! 5476: @findex DBX_OUTPUT_MAIN_SOURCE_FILE_END ! 5477: @item DBX_OUTPUT_MAIN_SOURCE_FILE_END (@var{stream}, @var{name}) ! 5478: A C statement to output DBX debugging information at the end of ! 5479: compilation of the main source file @var{name}. ! 5480: ! 5481: If you don't define this macro, nothing special is output at the end ! 5482: of compilation, which is correct for most machines. ! 5483: ! 5484: @findex DBX_OUTPUT_SOURCE_FILENAME ! 5485: @item DBX_OUTPUT_SOURCE_FILENAME (@var{stream}, @var{name}) ! 5486: A C statement to output DBX debugging information to the stdio stream ! 5487: @var{stream} which indicates that file @var{name} is the current source ! 5488: file. This output is generated each time input shifts to a different ! 5489: source file as a result of @samp{#include}, the end of an included file, ! 5490: or a @samp{#line} command. ! 5491: ! 5492: This macro need not be defined if the standard form of output ! 5493: for DBX debugging information is appropriate. ! 5494: @end table ! 5495: ! 5496: @need 2000 ! 5497: @node SDB and DWARF ! 5498: @subsection Macros for SDB and DWARF Output ! 5499: ! 5500: @table @code ! 5501: @findex SDB_DEBUGGING_INFO ! 5502: @item SDB_DEBUGGING_INFO ! 5503: Define this macro if GNU CC should produce COFF-style debugging output ! 5504: for SDB in response to the @samp{-g} option. ! 5505: ! 5506: @findex DWARF_DEBUGGING_INFO ! 5507: @item DWARF_DEBUGGING_INFO ! 5508: Define this macro if GNU CC should produce dwarf format debugging output ! 5509: in response to the @samp{-g} option. ! 5510: ! 5511: @findex PUT_SDB_@dots{} ! 5512: @item PUT_SDB_@dots{} ! 5513: Define these macros to override the assembler syntax for the special ! 5514: SDB assembler directives. See @file{sdbout.c} for a list of these ! 5515: macros and their arguments. If the standard syntax is used, you need ! 5516: not define them yourself. ! 5517: ! 5518: @findex SDB_DELIM ! 5519: @item SDB_DELIM ! 5520: Some assemblers do not support a semicolon as a delimiter, even between ! 5521: SDB assembler directives. In that case, define this macro to be the ! 5522: delimiter to use (usually @samp{\n}). It is not necessary to define ! 5523: a new set of @code{PUT_SDB_@var{op}} macros if this is the only change ! 5524: required. ! 5525: ! 5526: @findex SDB_GENERATE_FAKE ! 5527: @item SDB_GENERATE_FAKE ! 5528: Define this macro to override the usual method of constructing a dummy ! 5529: name for anonymous structure and union types. See @file{sdbout.c} for ! 5530: more information. ! 5531: ! 5532: @findex SDB_ALLOW_UNKNOWN_REFERENCES ! 5533: @item SDB_ALLOW_UNKNOWN_REFERENCES ! 5534: Define this macro to allow references to unknown structure, ! 5535: union, or enumeration tags to be emitted. Standard COFF does not ! 5536: allow handling of unknown references, MIPS ECOFF has support for ! 5537: it. ! 5538: ! 5539: @findex SDB_ALLOW_FORWARD_REFERENCES ! 5540: @item SDB_ALLOW_FORWARD_REFERENCES ! 5541: Define this macro to allow references to structure, union, or ! 5542: enumeration tags that have not yet been seen to be handled. Some ! 5543: assemblers choke if forward tags are used, while some require it. ! 5544: @end table ! 5545: ! 5546: @node Cross-compilation ! 5547: @section Cross Compilation and Floating Point ! 5548: @cindex cross compilation and floating point ! 5549: @cindex floating point and cross compilation ! 5550: ! 5551: While all modern machines use 2's complement representation for integers, ! 5552: there are a variety of representations for floating point numbers. This ! 5553: means that in a cross-compiler the representation of floating point numbers ! 5554: in the compiled program may be different from that used in the machine ! 5555: doing the compilation. ! 5556: ! 5557: @findex atof ! 5558: Because different representation systems may offer different amounts of ! 5559: range and precision, the cross compiler cannot safely use the host ! 5560: machine's floating point arithmetic. Therefore, floating point constants ! 5561: must be represented in the target machine's format. This means that the ! 5562: cross compiler cannot use @code{atof} to parse a floating point constant; ! 5563: it must have its own special routine to use instead. Also, constant ! 5564: folding must emulate the target machine's arithmetic (or must not be done ! 5565: at all). ! 5566: ! 5567: The macros in the following table should be defined only if you are cross ! 5568: compiling between different floating point formats. ! 5569: ! 5570: Otherwise, don't define them. Then default definitions will be set up which ! 5571: use @code{double} as the data type, @code{==} to test for equality, etc. ! 5572: ! 5573: You don't need to worry about how many times you use an operand of any ! 5574: of these macros. The compiler never uses operands which have side effects. ! 5575: ! 5576: @table @code ! 5577: @findex REAL_VALUE_TYPE ! 5578: @item REAL_VALUE_TYPE ! 5579: A macro for the C data type to be used to hold a floating point value ! 5580: in the target machine's format. Typically this would be a ! 5581: @code{struct} containing an array of @code{int}. ! 5582: ! 5583: @findex REAL_VALUES_EQUAL ! 5584: @item REAL_VALUES_EQUAL (@var{x}, @var{y}) ! 5585: A macro for a C expression which compares for equality the two values, ! 5586: @var{x} and @var{y}, both of type @code{REAL_VALUE_TYPE}. ! 5587: ! 5588: @findex REAL_VALUES_LESS ! 5589: @item REAL_VALUES_LESS (@var{x}, @var{y}) ! 5590: A macro for a C expression which tests whether @var{x} is less than ! 5591: @var{y}, both values being of type @code{REAL_VALUE_TYPE} and ! 5592: interpreted as floating point numbers in the target machine's ! 5593: representation. ! 5594: ! 5595: @findex REAL_VALUE_LDEXP ! 5596: @findex ldexp ! 5597: @item REAL_VALUE_LDEXP (@var{x}, @var{scale}) ! 5598: A macro for a C expression which performs the standard library ! 5599: function @code{ldexp}, but using the target machine's floating point ! 5600: representation. Both @var{x} and the value of the expression have ! 5601: type @code{REAL_VALUE_TYPE}. The second argument, @var{scale}, is an ! 5602: integer. ! 5603: ! 5604: @findex REAL_VALUE_FIX ! 5605: @item REAL_VALUE_FIX (@var{x}) ! 5606: A macro whose definition is a C expression to convert the target-machine ! 5607: floating point value @var{x} to a signed integer. @var{x} has type ! 5608: @code{REAL_VALUE_TYPE}. ! 5609: ! 5610: @findex REAL_VALUE_UNSIGNED_FIX ! 5611: @item REAL_VALUE_UNSIGNED_FIX (@var{x}) ! 5612: A macro whose definition is a C expression to convert the target-machine ! 5613: floating point value @var{x} to an unsigned integer. @var{x} has type ! 5614: @code{REAL_VALUE_TYPE}. ! 5615: ! 5616: @findex REAL_VALUE_RNDZINT ! 5617: @item REAL_VALUE_RNDZINT (@var{x}) ! 5618: A macro whose definition is a C expression to round the target-machine ! 5619: floating point value @var{x} towards zero to an integer value (but still ! 5620: as a floating point number). @var{x} has type @code{REAL_VALUE_TYPE}, ! 5621: and so does the value. ! 5622: ! 5623: @findex REAL_VALUE_UNSIGNED_RNDZINT ! 5624: @item REAL_VALUE_UNSIGNED_RNDZINT (@var{x}) ! 5625: A macro whose definition is a C expression to round the target-machine ! 5626: floating point value @var{x} towards zero to an unsigned integer value ! 5627: (but still represented as a floating point number). @var{x} has type ! 5628: @code{REAL_VALUE_TYPE}, and so does the value. ! 5629: ! 5630: @findex REAL_VALUE_ATOF ! 5631: @item REAL_VALUE_ATOF (@var{string}, @var{mode}) ! 5632: A macro for a C expression which converts @var{string}, an expression of ! 5633: type @code{char *}, into a floating point number in the target machine's ! 5634: representation for mode @var{mode}. The value has type ! 5635: @code{REAL_VALUE_TYPE}. ! 5636: ! 5637: @findex REAL_INFINITY ! 5638: @item REAL_INFINITY ! 5639: Define this macro if infinity is a possible floating point value, and ! 5640: therefore division by 0 is legitimate. ! 5641: ! 5642: @findex REAL_VALUE_ISINF ! 5643: @findex isinf ! 5644: @item REAL_VALUE_ISINF (@var{x}) ! 5645: A macro for a C expression which determines whether @var{x}, a floating ! 5646: point value, is infinity. The value has type @code{int}. ! 5647: By default, this is defined to call @code{isinf}. ! 5648: ! 5649: @findex REAL_VALUE_ISNAN ! 5650: @findex isnan ! 5651: @item REAL_VALUE_ISNAN (@var{x}) ! 5652: A macro for a C expression which determines whether @var{x}, a floating ! 5653: point value, is a ``nan'' (not-a-number). The value has type ! 5654: @code{int}. By default, this is defined to call @code{isnan}. ! 5655: @end table ! 5656: ! 5657: @cindex constant folding and floating point ! 5658: Define the following additional macros if you want to make floating ! 5659: point constant folding work while cross compiling. If you don't ! 5660: define them, cross compilation is still possible, but constant folding ! 5661: will not happen for floating point values. ! 5662: ! 5663: @table @code ! 5664: @findex REAL_ARITHMETIC ! 5665: @item REAL_ARITHMETIC (@var{output}, @var{code}, @var{x}, @var{y}) ! 5666: A macro for a C statement which calculates an arithmetic operation of ! 5667: the two floating point values @var{x} and @var{y}, both of type ! 5668: @code{REAL_VALUE_TYPE} in the target machine's representation, to ! 5669: produce a result of the same type and representation which is stored ! 5670: in @var{output} (which will be a variable). ! 5671: ! 5672: The operation to be performed is specified by @var{code}, a tree code ! 5673: which will always be one of the following: @code{PLUS_EXPR}, ! 5674: @code{MINUS_EXPR}, @code{MULT_EXPR}, @code{RDIV_EXPR}, ! 5675: @code{MAX_EXPR}, @code{MIN_EXPR}.@refill ! 5676: ! 5677: @cindex overflow while constant folding ! 5678: The expansion of this macro is responsible for checking for overflow. ! 5679: If overflow happens, the macro expansion should execute the statement ! 5680: @code{return 0;}, which indicates the inability to perform the ! 5681: arithmetic operation requested. ! 5682: ! 5683: @findex REAL_VALUE_NEGATE ! 5684: @item REAL_VALUE_NEGATE (@var{x}) ! 5685: A macro for a C expression which returns the negative of the floating ! 5686: point value @var{x}. Both @var{x} and the value of the expression ! 5687: have type @code{REAL_VALUE_TYPE} and are in the target machine's ! 5688: floating point representation. ! 5689: ! 5690: There is no way for this macro to report overflow, since overflow ! 5691: can't happen in the negation operation. ! 5692: ! 5693: @findex REAL_VALUE_TRUNCATE ! 5694: @item REAL_VALUE_TRUNCATE (@var{mode}, @var{x}) ! 5695: A macro for a C expression which converts the floating point value ! 5696: @var{x} to mode @var{mode}. ! 5697: ! 5698: Both @var{x} and the value of the expression are in the target machine's ! 5699: floating point representation and have type @code{REAL_VALUE_TYPE}. ! 5700: However, the value should have an appropriate bit pattern to be output ! 5701: properly as a floating constant whose precision accords with mode ! 5702: @var{mode}. ! 5703: ! 5704: There is no way for this macro to report overflow. ! 5705: ! 5706: @findex REAL_VALUE_TO_INT ! 5707: @item REAL_VALUE_TO_INT (@var{low}, @var{high}, @var{x}) ! 5708: A macro for a C expression which converts a floating point value ! 5709: @var{x} into a double-precision integer which is then stored into ! 5710: @var{low} and @var{high}, two variables of type @var{int}. ! 5711: ! 5712: @item REAL_VALUE_FROM_INT (@var{x}, @var{low}, @var{high}) ! 5713: @findex REAL_VALUE_FROM_INT ! 5714: A macro for a C expression which converts a double-precision integer ! 5715: found in @var{low} and @var{high}, two variables of type @var{int}, ! 5716: into a floating point value which is then stored into @var{x}. ! 5717: @end table ! 5718: ! 5719: @node Misc ! 5720: @section Miscellaneous Parameters ! 5721: @cindex parameters, miscellaneous ! 5722: ! 5723: @table @code ! 5724: @item PREDICATE_CODES ! 5725: @findex PREDICATE_CODES ! 5726: Define this if you have defined special-purpose predicates in the file ! 5727: @file{@var{machine}.c}. This macro is called within an initializer of an ! 5728: array of structures. The first field in the structure is the name of a ! 5729: predicate and the second field is an array of rtl codes. For each ! 5730: predicate, list all rtl codes that can be in expressions matched by the ! 5731: predicate. The list should have a trailing comma. Here is an example ! 5732: of two entries in the list for a typical RISC machine: ! 5733: ! 5734: @smallexample ! 5735: #define PREDICATE_CODES \ ! 5736: @{"gen_reg_rtx_operand", @{SUBREG, REG@}@}, \ ! 5737: @{"reg_or_short_cint_operand", @{SUBREG, REG, CONST_INT@}@}, ! 5738: @end smallexample ! 5739: ! 5740: Defining this macro does not affect the generated code (however, ! 5741: incorrect definitions that omit an rtl code that may be matched by the ! 5742: predicate can cause the compiler to malfunction). Instead, it allows ! 5743: the table built by @file{genrecog} to be more compact and efficient, ! 5744: thus speeding up the compiler. The most important predicates to include ! 5745: in the list specified by this macro are thoses used in the most insn ! 5746: patterns. ! 5747: ! 5748: @findex CASE_VECTOR_MODE ! 5749: @item CASE_VECTOR_MODE ! 5750: An alias for a machine mode name. This is the machine mode that ! 5751: elements of a jump-table should have. ! 5752: ! 5753: @findex CASE_VECTOR_PC_RELATIVE ! 5754: @item CASE_VECTOR_PC_RELATIVE ! 5755: Define this macro if jump-tables should contain relative addresses. ! 5756: ! 5757: @findex CASE_DROPS_THROUGH ! 5758: @item CASE_DROPS_THROUGH ! 5759: Define this if control falls through a @code{case} insn when the index ! 5760: value is out of range. This means the specified default-label is ! 5761: actually ignored by the @code{case} insn proper. ! 5762: ! 5763: @findex CASE_VALUES_THRESHOLD ! 5764: @item CASE_VALUES_THRESHOLD ! 5765: Define this to be the smallest number of different values for which it ! 5766: is best to use a jump-table instead of a tree of conditional branches. ! 5767: The default is four for machines with a @code{casesi} instruction and ! 5768: five otherwise. This is best for most machines. ! 5769: ! 5770: @findex WORD_REGISTER_OPERATIONS ! 5771: @item WORD_REGISTER_OPERATIONS ! 5772: Define this macro if operations between registers with integral mode ! 5773: smaller than a word are always performed on the entire register. ! 5774: Most RISC machines have this property and most CISC machines do not. ! 5775: ! 5776: @findex LOAD_EXTEND_OP ! 5777: @item LOAD_EXTEND_OP (@var{mode}) ! 5778: Define this macro to be a C expression indicating when insns that read ! 5779: memory in @var{mode}, an integral mode narrower than a word, set the ! 5780: bits outside of @var{mode} to be either the sign-extension or the ! 5781: zero-extension of the data read. Return @code{SIGN_EXTEND} for values ! 5782: of @var{mode} for which the ! 5783: insn sign-extends, @code{ZERO_EXTEND} for which it zero-extends, and ! 5784: @code{NIL} for other modes. ! 5785: ! 5786: This macro is not called with @var{mode} non-integral or with a width ! 5787: greater than or equal to @code{BITS_PER_WORD}, so you may return any ! 5788: value in this case. Do not define this macro if it would always return ! 5789: @code{NIL}. On machines where this macro is defined, you will normally ! 5790: define it as the constant @code{SIGN_EXTEND} or @code{ZERO_EXTEND}. ! 5791: ! 5792: @findex IMPLICIT_FIX_EXPR ! 5793: @item IMPLICIT_FIX_EXPR ! 5794: An alias for a tree code that should be used by default for conversion ! 5795: of floating point values to fixed point. Normally, ! 5796: @code{FIX_ROUND_EXPR} is used.@refill ! 5797: ! 5798: @findex FIXUNS_TRUNC_LIKE_FIX_TRUNC ! 5799: @item FIXUNS_TRUNC_LIKE_FIX_TRUNC ! 5800: Define this macro if the same instructions that convert a floating ! 5801: point number to a signed fixed point number also convert validly to an ! 5802: unsigned one. ! 5803: ! 5804: @findex EASY_DIV_EXPR ! 5805: @item EASY_DIV_EXPR ! 5806: An alias for a tree code that is the easiest kind of division to ! 5807: compile code for in the general case. It may be ! 5808: @code{TRUNC_DIV_EXPR}, @code{FLOOR_DIV_EXPR}, @code{CEIL_DIV_EXPR} or ! 5809: @code{ROUND_DIV_EXPR}. These four division operators differ in how ! 5810: they round the result to an integer. @code{EASY_DIV_EXPR} is used ! 5811: when it is permissible to use any of those kinds of division and the ! 5812: choice should be made on the basis of efficiency.@refill ! 5813: ! 5814: @findex MOVE_MAX ! 5815: @item MOVE_MAX ! 5816: The maximum number of bytes that a single instruction can move quickly ! 5817: from memory to memory. ! 5818: ! 5819: @findex MAX_MOVE_MAX ! 5820: @item MAX_MOVE_MAX ! 5821: The maximum number of bytes that a single instruction can move quickly ! 5822: from memory to memory. If this is undefined, the default is ! 5823: @code{MOVE_MAX}. Otherwise, it is the constant value that is the ! 5824: largest value that @code{MOVE_MAX} can have at run-time. ! 5825: ! 5826: @findex SHIFT_COUNT_TRUNCATED ! 5827: @item SHIFT_COUNT_TRUNCATED ! 5828: A C expression that is nonzero if on this machine the number of bits ! 5829: actually used for the count of a shift operation is equal to the number ! 5830: of bits needed to represent the size of the object being shifted. When ! 5831: this macro is non-zero, the compiler will assume that it is safe to omit ! 5832: a sign-extend, zero-extend, and certain bitwise `and' instructions that ! 5833: truncates the count of a shift operation. On machines that have ! 5834: instructions that act on bitfields at variable positions, which may ! 5835: include `bit test' instructions, a nonzero @code{SHIFT_COUNT_TRUNCATED} ! 5836: also enables deletion of truncations of the values that serve as ! 5837: arguments to bitfield instructions. ! 5838: ! 5839: If both types of instructions truncate the count (for shifts) and ! 5840: position (for bitfield operations), or if no variable-position bitfield ! 5841: instructions exist, you should define this macro. ! 5842: ! 5843: However, on some machines, such as the 80386 and the 680x0, truncation ! 5844: only applies to shift operations and not the (real or pretended) ! 5845: bitfield operations. Define @code{SHIFT_COUNT_TRUNCATED} to be zero on ! 5846: such machines. Instead, add patterns to the @file{md} file that include ! 5847: the implied truncation of the shift instructions. ! 5848: ! 5849: You need not define this macro if it would always have the value of zero. ! 5850: ! 5851: @findex TRULY_NOOP_TRUNCATION ! 5852: @item TRULY_NOOP_TRUNCATION (@var{outprec}, @var{inprec}) ! 5853: A C expression which is nonzero if on this machine it is safe to ! 5854: ``convert'' an integer of @var{inprec} bits to one of @var{outprec} ! 5855: bits (where @var{outprec} is smaller than @var{inprec}) by merely ! 5856: operating on it as if it had only @var{outprec} bits. ! 5857: ! 5858: On many machines, this expression can be 1. ! 5859: ! 5860: @c rearranged this, removed the phrase "it is reported that". this was ! 5861: @c to fix an overfull hbox. --mew 10feb93 ! 5862: When @code{TRULY_NOOP_TRUNCATION} returns 1 for a pair of sizes for ! 5863: modes for which @code{MODES_TIEABLE_P} is 0, suboptimal code can result. ! 5864: If this is the case, making @code{TRULY_NOOP_TRUNCATION} return 0 in ! 5865: such cases may improve things. ! 5866: ! 5867: @findex STORE_FLAG_VALUE ! 5868: @item STORE_FLAG_VALUE ! 5869: A C expression describing the value returned by a comparison operator ! 5870: with an integral mode and stored by a store-flag instruction ! 5871: (@samp{s@var{cond}}) when the condition is true. This description must ! 5872: apply to @emph{all} the @samp{s@var{cond}} patterns and all the ! 5873: comparison operators whose results have a @code{MODE_INT} mode. ! 5874: ! 5875: A value of 1 or -1 means that the instruction implementing the ! 5876: comparison operator returns exactly 1 or -1 when the comparison is true ! 5877: and 0 when the comparison is false. Otherwise, the value indicates ! 5878: which bits of the result are guaranteed to be 1 when the comparison is ! 5879: true. This value is interpreted in the mode of the comparison ! 5880: operation, which is given by the mode of the first operand in the ! 5881: @samp{s@var{cond}} pattern. Either the low bit or the sign bit of ! 5882: @code{STORE_FLAG_VALUE} be on. Presently, only those bits are used by ! 5883: the compiler. ! 5884: ! 5885: If @code{STORE_FLAG_VALUE} is neither 1 or -1, the compiler will ! 5886: generate code that depends only on the specified bits. It can also ! 5887: replace comparison operators with equivalent operations if they cause ! 5888: the required bits to be set, even if the remaining bits are undefined. ! 5889: For example, on a machine whose comparison operators return an ! 5890: @code{SImode} value and where @code{STORE_FLAG_VALUE} is defined as ! 5891: @samp{0x80000000}, saying that just the sign bit is relevant, the ! 5892: expression ! 5893: ! 5894: @smallexample ! 5895: (ne:SI (and:SI @var{x} (const_int @var{power-of-2})) (const_int 0)) ! 5896: @end smallexample ! 5897: ! 5898: @noindent ! 5899: can be converted to ! 5900: ! 5901: @smallexample ! 5902: (ashift:SI @var{x} (const_int @var{n})) ! 5903: @end smallexample ! 5904: ! 5905: @noindent ! 5906: where @var{n} is the appropriate shift count to move the bit being ! 5907: tested into the sign bit. ! 5908: ! 5909: There is no way to describe a machine that always sets the low-order bit ! 5910: for a true value, but does not guarantee the value of any other bits, ! 5911: but we do not know of any machine that has such an instruction. If you ! 5912: are trying to port GNU CC to such a machine, include an instruction to ! 5913: perform a logical-and of the result with 1 in the pattern for the ! 5914: comparison operators and let us know ! 5915: @ifset USING ! 5916: (@pxref{Bug Reporting,,How to Report Bugs}). ! 5917: @end ifset ! 5918: @ifclear USING ! 5919: (@pxref{Bug Reporting,,How to Report Bugs,gcc.info,Using GCC}). ! 5920: @end ifclear ! 5921: ! 5922: Often, a machine will have multiple instructions that obtain a value ! 5923: from a comparison (or the condition codes). Here are rules to guide the ! 5924: choice of value for @code{STORE_FLAG_VALUE}, and hence the instructions ! 5925: to be used: ! 5926: ! 5927: @itemize @bullet ! 5928: @item ! 5929: Use the shortest sequence that yields a valid definition for ! 5930: @code{STORE_FLAG_VALUE}. It is more efficient for the compiler to ! 5931: ``normalize'' the value (convert it to, e.g., 1 or 0) than for the ! 5932: comparison operators to do so because there may be opportunities to ! 5933: combine the normalization with other operations. ! 5934: ! 5935: @item ! 5936: For equal-length sequences, use a value of 1 or -1, with -1 being ! 5937: slightly preferred on machines with expensive jumps and 1 preferred on ! 5938: other machines. ! 5939: ! 5940: @item ! 5941: As a second choice, choose a value of @samp{0x80000001} if instructions ! 5942: exist that set both the sign and low-order bits but do not define the ! 5943: others. ! 5944: ! 5945: @item ! 5946: Otherwise, use a value of @samp{0x80000000}. ! 5947: @end itemize ! 5948: ! 5949: Many machines can produce both the value chosen for ! 5950: @code{STORE_FLAG_VALUE} and its negation in the same number of ! 5951: instructions. On those machines, you should also define a pattern for ! 5952: those cases, e.g., one matching ! 5953: ! 5954: @smallexample ! 5955: (set @var{A} (neg:@var{m} (ne:@var{m} @var{B} @var{C}))) ! 5956: @end smallexample ! 5957: ! 5958: Some machines can also perform @code{and} or @code{plus} operations on ! 5959: condition code values with less instructions than the corresponding ! 5960: @samp{s@var{cond}} insn followed by @code{and} or @code{plus}. On those ! 5961: machines, define the appropriate patterns. Use the names @code{incscc} ! 5962: and @code{decscc}, respectively, for the the patterns which perform ! 5963: @code{plus} or @code{minus} operations on condition code values. See ! 5964: @file{rs6000.md} for some examples. The GNU Superoptizer can be used to ! 5965: find such instruction sequences on other machines. ! 5966: ! 5967: You need not define @code{STORE_FLAG_VALUE} if the machine has no store-flag ! 5968: instructions. ! 5969: ! 5970: @findex FLOAT_STORE_FLAG_VALUE ! 5971: @item FLOAT_STORE_FLAG_VALUE ! 5972: A C expression that gives a non-zero floating point value that is ! 5973: returned when comparison operators with floating-point results are true. ! 5974: Define this macro on machine that have comparison operations that return ! 5975: floating-point values. If there are no such operations, do not define ! 5976: this macro. ! 5977: ! 5978: @findex Pmode ! 5979: @item Pmode ! 5980: An alias for the machine mode for pointers. Normally the definition ! 5981: can be ! 5982: ! 5983: @smallexample ! 5984: #define Pmode SImode ! 5985: @end smallexample ! 5986: ! 5987: @findex FUNCTION_MODE ! 5988: @item FUNCTION_MODE ! 5989: An alias for the machine mode used for memory references to functions ! 5990: being called, in @code{call} RTL expressions. On most machines this ! 5991: should be @code{QImode}. ! 5992: ! 5993: @findex INTEGRATE_THRESHOLD ! 5994: @item INTEGRATE_THRESHOLD (@var{decl}) ! 5995: A C expression for the maximum number of instructions above which the ! 5996: function @var{decl} should not be inlined. @var{decl} is a ! 5997: @code{FUNCTION_DECL} node. ! 5998: ! 5999: The default definition of this macro is 64 plus 8 times the number of ! 6000: arguments that the function accepts. Some people think a larger ! 6001: threshold should be used on RISC machines. ! 6002: ! 6003: @findex SCCS_DIRECTIVE ! 6004: @item SCCS_DIRECTIVE ! 6005: Define this if the preprocessor should ignore @code{#sccs} directives ! 6006: and print no error message. ! 6007: ! 6008: @findex NO_IMPLICIT_EXTERN_C ! 6009: @item NO_IMPLICIT_EXTERN_C ! 6010: Define this macro if the system header files support C++ as well as C. ! 6011: This macro inhibits the usual method of using system header files in ! 6012: C++, which is to pretend that the file's contents are enclosed in ! 6013: @samp{extern "C" @{@dots{}@}}. ! 6014: ! 6015: @findex HANDLE_PRAGMA ! 6016: @findex #pragma ! 6017: @findex pragma ! 6018: @item HANDLE_PRAGMA (@var{stream}) ! 6019: Define this macro if you want to implement any pragmas. If defined, it ! 6020: should be a C statement to be executed when @code{#pragma} is seen. The ! 6021: argument @var{stream} is the stdio input stream from which the source ! 6022: text can be read. ! 6023: ! 6024: It is generally a bad idea to implement new uses of @code{#pragma}. The ! 6025: only reason to define this macro is for compatibility with other ! 6026: compilers that do support @code{#pragma} for the sake of any user ! 6027: programs which already use it. ! 6028: ! 6029: @findex DOLLARS_IN_IDENTIFIERS ! 6030: @item DOLLARS_IN_IDENTIFIERS ! 6031: Define this macro to control use of the character @samp{$} in identifier ! 6032: names. The value should be 0, 1, or 2. 0 means @samp{$} is not allowed ! 6033: by default; 1 means it is allowed by default if @samp{-traditional} is ! 6034: used; 2 means it is allowed by default provided @samp{-ansi} is not used. ! 6035: 1 is the default; there is no need to define this macro in that case. ! 6036: ! 6037: @findex NO_DOLLAR_IN_LABEL ! 6038: @item NO_DOLLAR_IN_LABEL ! 6039: Define this macro if the assembler does not accept the character ! 6040: @samp{$} in label names. By default constructors and destructors in ! 6041: G++ have @samp{$} in the identifiers. If this macro is defined, ! 6042: @samp{.} is used instead. ! 6043: ! 6044: @findex NO_DOT_IN_LABEL ! 6045: @item NO_DOT_IN_LABEL ! 6046: Define this macro if the assembler does not accept the character ! 6047: @samp{.} in label names. By default constructors and destructors in G++ ! 6048: have names that use @samp{.}. If this macro is defined, these names ! 6049: are rewritten to avoid @samp{.}. ! 6050: ! 6051: @findex DEFAULT_MAIN_RETURN ! 6052: @item DEFAULT_MAIN_RETURN ! 6053: Define this macro if the target system expects every program's @code{main} ! 6054: function to return a standard ``success'' value by default (if no other ! 6055: value is explicitly returned). ! 6056: ! 6057: The definition should be a C statement (sans semicolon) to generate the ! 6058: appropriate rtl instructions. It is used only when compiling the end of ! 6059: @code{main}. ! 6060: ! 6061: @item HAVE_ATEXIT ! 6062: @findex HAVE_ATEXIT ! 6063: Define this if the target system supports the function ! 6064: @code{atexit} from the ANSI C standard. If this is not defined, ! 6065: and @code{INIT_SECTION_ASM_OP} is not defined, a default ! 6066: @code{exit} function will be provided to support C++. ! 6067: ! 6068: @item EXIT_BODY ! 6069: @findex EXIT_BODY ! 6070: Define this if your @code{exit} function needs to do something ! 6071: besides calling an external function @code{_cleanup} before ! 6072: terminating with @code{_exit}. The @code{EXIT_BODY} macro is ! 6073: only needed if netiher @code{HAVE_ATEXIT} nor ! 6074: @code{INIT_SECTION_ASM_OP} are defined. ! 6075: ! 6076: @findex INSN_SETS_ARE_DELAYED ! 6077: @item INSN_SETS_ARE_DELAYED (@var{insn}) ! 6078: Define this macro as a C expression that is nonzero if it is safe for the ! 6079: delay slot scheduler to place instructions in the delay slot of @var{insn}, ! 6080: even if they appear to use a resource set or clobbered in @var{insn}. ! 6081: @var{insn} is always a @code{jump_insn} or an @code{insn}; GNU CC knows that ! 6082: every @code{call_insn} has this behavior. On machines where some @code{insn} ! 6083: or @code{jump_insn} is really a function call and hence has this behavior, ! 6084: you should define this macro. ! 6085: ! 6086: You need not define this macro if it would always return zero. ! 6087: ! 6088: @findex INSN_REFERENCES_ARE_DELAYED ! 6089: @item INSN_REFERENCES_ARE_DELAYED (@var{insn}) ! 6090: Define this macro as a C expression that is nonzero if it is safe for the ! 6091: delay slot scheduler to place instructions in the delay slot of @var{insn}, ! 6092: even if they appear to set or clobber a resource referenced in @var{insn}. ! 6093: @var{insn} is always a @code{jump_insn} or an @code{insn}. On machines where ! 6094: some @code{insn} or @code{jump_insn} is really a function call and its operands ! 6095: are registers whose use is actually in the subroutine it calls, you should ! 6096: define this macro. Doing so allows the delay slot scheduler to move ! 6097: instructions which copy arguments into the argument registers into the delay ! 6098: slot of @var{insn}. ! 6099: ! 6100: You need not define this macro if it would always return zero. ! 6101: @end table
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.