|
|
1.1.1.2 ! root 1: This is Info file gcc.info, produced by Makeinfo-1.44 from the input 1.1 root 2: file gcc.texi. 3: 4: This file documents the use and the internals of the GNU compiler. 5: 6: Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc. 7: 8: Permission is granted to make and distribute verbatim copies of 9: this manual provided the copyright notice and this permission notice 10: are preserved on all copies. 11: 12: Permission is granted to copy and distribute modified versions of 13: this manual under the conditions for verbatim copying, provided also 14: that the section entitled "GNU General Public License" is included 15: exactly as in the original, and provided that the entire resulting 16: derived work is distributed under the terms of a permission notice 17: identical to this one. 18: 19: Permission is granted to copy and distribute translations of this 20: manual into another language, under the above conditions for modified 21: versions, except that the section entitled "GNU General Public 22: License" and this permission notice may be included in translations 23: approved by the Free Software Foundation instead of in the original 24: English. 25: 26: 1.1.1.2 ! root 27: File: gcc.info, Node: Costs, Next: Sections, Prev: Condition Code, Up: Target Macros ! 28: ! 29: Describing Relative Costs of Operations ! 30: ======================================= ! 31: ! 32: These macros let you describe the relative speed of various ! 33: operations on the target machine. ! 34: ! 35: `CONST_COSTS (X, CODE)' ! 36: A part of a C `switch' statement that describes the relative costs ! 37: of constant RTL expressions. It must contain `case' labels for ! 38: expression codes `const_int', `const', `symbol_ref', `label_ref' ! 39: and `const_double'. Each case must ultimately reach a `return' ! 40: statement to return the relative cost of the use of that kind of ! 41: constant value in an expression. The cost may depend on the ! 42: precise value of the constant, which is available for examination ! 43: in X. ! 44: ! 45: CODE is the expression code--redundant, since it can be obtained ! 46: with `GET_CODE (X)'. ! 47: ! 48: `RTX_COSTS (X, CODE)' ! 49: Like `CONST_COSTS' but applies to nonconstant RTL expressions. ! 50: This can be used, for example, to indicate how costly a multiply ! 51: instruction is. In writing this macro, you can use the construct ! 52: `COSTS_N_INSNS (N)' to specify a cost equal to N fast ! 53: instructions. ! 54: ! 55: This macro is optional; do not define it if the default cost ! 56: assumptions are adequate for the target machine. ! 57: ! 58: `ADDRESS_COST (ADDRESS)' ! 59: An expression giving the cost of an addressing mode that contains ! 60: ADDRESS. If not defined, the cost is computed from the ADDRESS ! 61: expression and the `CONST_COSTS' values. ! 62: ! 63: For most CISC machines, the default cost is a good approximation ! 64: of the true cost of the addressing mode. However, on RISC ! 65: machines, all instructions normally have the same length and ! 66: execution time. Hence all addresses will have equal costs. ! 67: ! 68: In cases where more than one form of an address is known, the ! 69: form with the lowest cost will be used. If multiple forms have ! 70: the same, lowest, cost, the one that is the most complex will be ! 71: used. ! 72: ! 73: For example, suppose an address that is equal to the sum of a ! 74: register and a constant is used twice in the same basic block. ! 75: When this macro is not defined, the address will be computed in a ! 76: register and memory references will be indirect through that ! 77: register. On machines where the cost of the addressing mode ! 78: containing the sum is no higher than that of a simple indirect ! 79: reference, this will produce an additional instruction and ! 80: possibly require an additional register. Proper specification of ! 81: this macro eliminates this overhead for such machines. ! 82: ! 83: Similar use of this macro is made in strength reduction of loops. ! 84: ! 85: ADDRESS need not be valid as an address. In such a case, the cost ! 86: is not relevant and can be any value; invalid addresses need not ! 87: be assigned a different cost. ! 88: ! 89: On machines where an address involving more than one register is ! 90: as cheap as an address computation involving only one register, ! 91: defining `ADDRESS_COST' to reflect this can cause two registers ! 92: to be live over a region of code where only one would have been if ! 93: `ADDRESS_COST' were not defined in that manner. This effect ! 94: should be considered in the definition of this macro. Equivalent ! 95: costs should probably only be given to addresses with different ! 96: numbers of registers on machines with lots of registers. ! 97: ! 98: This macro will normally either not be defined or be defined as a ! 99: constant. ! 100: ! 101: `REGISTER_MOVE_COST (FROM, TO)' ! 102: A C expression for the cost of moving data from a register in ! 103: class FROM to one in class TO. The classes are expressed using ! 104: the enumeration values such as `GENERAL_REGS'. A value of 2 is ! 105: the default; other values are interpreted relative to that. ! 106: ! 107: It is not required that the cost always equal 2 when FROM is the ! 108: same as TO; on some machines it is expensive to move between ! 109: registers if they are not general registers. ! 110: ! 111: If reload sees an insn consisting of a single `set' between two ! 112: hard registers, and if `REGISTER_MOVE_COST' applied to their ! 113: classes returns a value of 2, reload does not check to ensure ! 114: that the constraints of the insn are met. Setting a cost of ! 115: other than 2 will allow reload to verify that the constraints are ! 116: met. You should do this if the `movM' pattern's constraints do ! 117: not allow such copying. ! 118: ! 119: `MEMORY_MOVE_COST (M)' ! 120: A C expression for the cost of moving data of mode M between a ! 121: register and memory. A value of 2 is the default; this cost is ! 122: relative to those in `REGISTER_MOVE_COST'. ! 123: ! 124: If moving between registers and memory is more expensive than ! 125: between two registers, you should define this macro to express ! 126: the relative cost. ! 127: ! 128: `BRANCH_COST' ! 129: A C expression for the cost of a branch instruction. A value of ! 130: 1 is the default; other values are interpreted relative to that. ! 131: ! 132: Here are additional macros which do not specify precise relative ! 133: costs, but only that certain actions are more expensive than GNU CC ! 134: would ordinarily expect. ! 135: ! 136: `SLOW_BYTE_ACCESS' ! 137: Define this macro as a C expression which is nonzero if accessing ! 138: less than a word of memory (i.e. a `char' or a `short') is no ! 139: faster than accessing a word of memory, i.e., if such access ! 140: require more than one instruction or if there is no difference in ! 141: cost between byte and (aligned) word loads. ! 142: ! 143: When this macro is not defined, the compiler will access a field ! 144: by finding the smallest containing object; when it is defined, a ! 145: fullword load will be used if alignment permits. Unless bytes ! 146: accesses are faster than word accesses, using word accesses is ! 147: preferable since it may eliminate subsequent memory access if ! 148: subsequent accesses occur to other fields in the same word of the ! 149: structure, but to different bytes. ! 150: ! 151: `SLOW_ZERO_EXTEND' ! 152: Define this macro if zero-extension (of a `char' or `short' to an ! 153: `int') can be done faster if the destination is a register that ! 154: is known to be zero. ! 155: ! 156: If you define this macro, you must have instruction patterns that ! 157: recognize RTL structures like this: ! 158: ! 159: (set (strict_low_part (subreg:QI (reg:SI ...) 0)) ...) ! 160: ! 161: and likewise for `HImode'. ! 162: ! 163: `SLOW_UNALIGNED_ACCESS' ! 164: Define this macro to be the value 1 if unaligned accesses have a ! 165: cost many times greater than aligned accesses, for example if ! 166: they are emulated in a trap handler. ! 167: ! 168: When this macro is non-zero, the compiler will act as if ! 169: `STRICT_ALIGNMENT' were non-zero when generating code for block ! 170: moves. This can cause significantly more instructions to be ! 171: produced. Therefore, do not set this macro non-zero if unaligned ! 172: accesses only add a cycle or two to the time for a memory access. ! 173: ! 174: If the value of this macro is always zero, it need not be defined. ! 175: ! 176: `DONT_REDUCE_ADDR' ! 177: Define this macro to inhibit strength reduction of memory ! 178: addresses. (On some machines, such strength reduction seems to ! 179: do harm rather than good.) ! 180: ! 181: `MOVE_RATIO' ! 182: The number of scalar move insns which should be generated instead ! 183: of a string move insn or a library call. Increasing the value ! 184: will always make code faster, but eventually incurs high cost in ! 185: increased code size. ! 186: ! 187: If you don't define this, a reasonable default is used. ! 188: ! 189: `NO_FUNCTION_CSE' ! 190: Define this macro if it is as good or better to call a constant ! 191: function address than to call an address kept in a register. ! 192: ! 193: `NO_RECURSIVE_FUNCTION_CSE' ! 194: Define this macro if it is as good or better for a function to ! 195: call itself with an explicit address than to call an address kept ! 196: in a register. ! 197: ! 198: ! 199: File: gcc.info, Node: Sections, Next: PIC, Prev: Costs, Up: Target Macros ! 200: ! 201: Dividing the Output into Sections (Texts, Data, ...) ! 202: ==================================================== ! 203: ! 204: An object file is divided into sections containing different types ! 205: of data. In the most common case, there are three sections: the "text ! 206: section", which holds instructions and read-only data; the "data ! 207: section", which holds initialized writable data; and the "bss ! 208: section", which holds uninitialized data. Some systems have other ! 209: kinds of sections. ! 210: ! 211: The compiler must tell the assembler when to switch sections. These ! 212: macros control what commands to output to tell the assembler this. You ! 213: can also define additional sections. ! 214: ! 215: `TEXT_SECTION_ASM_OP' ! 216: A C string constant for the assembler operation that should ! 217: precede instructions and read-only data. Normally `".text"' is ! 218: right. ! 219: ! 220: `DATA_SECTION_ASM_OP' ! 221: A C string constant for the assembler operation to identify the ! 222: following data as writable initialized data. Normally `".data"' ! 223: is right. ! 224: ! 225: `SHARED_SECTION_ASM_OP' ! 226: If defined, a C string constant for the assembler operation to ! 227: identify the following data as shared data. If not defined, ! 228: `DATA_SECTION_ASM_OP' will be used. ! 229: ! 230: `INIT_SECTION_ASM_OP' ! 231: If defined, a C string constant for the assembler operation to ! 232: identify the following data as initialization code. If not ! 233: defined, GNU CC will assume such a section does not exist. ! 234: ! 235: `EXTRA_SECTIONS' ! 236: A list of names for sections other than the standard two, which ! 237: are `in_text' and `in_data'. You need not define this macro on a ! 238: system with no other sections (that GCC needs to use). ! 239: ! 240: `EXTRA_SECTION_FUNCTIONS' ! 241: One or more functions to be defined in `varasm.c'. These ! 242: functions should do jobs analogous to those of `text_section' and ! 243: `data_section', for your additional sections. Do not define this ! 244: macro if you do not define `EXTRA_SECTIONS'. ! 245: ! 246: `READONLY_DATA_SECTION' ! 247: On most machines, read-only variables, constants, and jump tables ! 248: are placed in the text section. If this is not the case on your ! 249: machine, this macro should be defined to be the name of a ! 250: function (either `data_section' or a function defined in ! 251: `EXTRA_SECTIONS') that switches to the section to be used for ! 252: read-only items. ! 253: ! 254: If these items should be placed in the text section, this macro ! 255: should not be defined. ! 256: ! 257: `SELECT_SECTION (EXP, RELOC)' ! 258: A C statement or statements to switch to the appropriate section ! 259: for output of EXP. You can assume that EXP is either a ! 260: `VAR_DECL' node or a constant of some sort. RELOC indicates ! 261: whether the initial value of EXP requires link-time relocations. ! 262: Select the section by calling `text_section' or one of the ! 263: alternatives for other sections. ! 264: ! 265: Do not define this macro if you put all read-only variables and ! 266: constants in the read-only data section (usually the text ! 267: section). ! 268: ! 269: `SELECT_RTX_SECTION (MODE, RTX)' ! 270: A C statement or statements to switch to the appropriate section ! 271: for output of RTX in mode MODE. You can assume that RTX is some ! 272: kind of constant in RTL. The argument MODE is redundant except ! 273: in the case of a `const_int' rtx. Select the section by calling ! 274: `text_section' or one of the alternatives for other sections. ! 275: ! 276: Do not define this macro if you put all constants in the read-only ! 277: data section. ! 278: ! 279: `JUMP_TABLES_IN_TEXT_SECTION' ! 280: Define this macro if jump tables (for `tablejump' insns) should be ! 281: output in the text section, along with the assembler instructions. ! 282: Otherwise, the readonly data section is used. ! 283: ! 284: This macro is irrelevant if there is no separate readonly data ! 285: section. ! 286: ! 287: `ENCODE_SECTION_INFO (DECL)' ! 288: Define this macro if references to a symbol must be treated ! 289: differently depending on something about the variable or function ! 290: named by the symbol (such as what section it is in). ! 291: ! 292: The macro definition, if any, is executed immediately after the ! 293: rtl for DECL has been created and stored in `DECL_RTL (DECL)'. ! 294: The value of the rtl will be a `mem' whose address is a ! 295: `symbol_ref'. ! 296: ! 297: The usual thing for this macro to do is to record a flag in the ! 298: `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified ! 299: name string in the `symbol_ref' (if one bit is not enough ! 300: information). ! 301: ! 302: ! 303: File: gcc.info, Node: PIC, Next: Assembler Format, Prev: Sections, Up: Target Macros ! 304: ! 305: Position Independent Code ! 306: ========================= ! 307: ! 308: This section describes macros that help implement generation of ! 309: position independent code. Simply defining these macros is not enough ! 310: to generate valid PIC; you must also add support to the macros ! 311: `GO_IF_LEGITIMATE_ADDRESS' and `LEGITIMIZE_ADDRESS', and ! 312: `PRINT_OPERAND_ADDRESS' as well. You must modify the definition of ! 313: `movsi' to do something appropriate when the source operand contains a ! 314: symbolic address. You may also need to alter the handling of switch ! 315: statements so that they use relative addresses. ! 316: ! 317: `PIC_OFFSET_TABLE_REGNUM' ! 318: The register number of the register used to address a table of ! 319: static data addresses in memory. In some cases this register is ! 320: defined by a processor's "application binary interface" (ABI). ! 321: When this macro is defined, RTL is generated for this register ! 322: once, as with the stack pointer and frame pointer registers. If ! 323: this macro is not defined, it is up to the machine-dependent ! 324: files to allocate such a register (if necessary). ! 325: ! 326: `FINALIZE_PIC' ! 327: By generating position-independent code, when two different ! 328: programs (A and B) share a common library (libC.a), the text of ! 329: the library can be shared whether or not the library is linked at ! 330: the same address for both programs. In some of these ! 331: environments, position-independent code requires not only the use ! 332: of different addressing modes, but also special code to enable ! 333: the use of these addressing modes. ! 334: ! 335: The `FINALIZE_PIC' macro serves as a hook to emit these special ! 336: codes once the function is being compiled into assembly code, but ! 337: not before. (It is not done before, because in the case of ! 338: compiling an inline function, it would lead to multiple PIC ! 339: prologues being included in functions which used inline functions ! 340: and were compiled to assembly language.) ! 341: ! 342: ! 343: File: gcc.info, Node: Assembler Format, Next: Debugging Info, Prev: PIC, Up: Target Macros ! 344: ! 345: Defining the Output Assembler Language ! 346: ====================================== ! 347: ! 348: This section describes macros whose principal purpose is to ! 349: describe how to write instructions in assembler language--rather than ! 350: what the instructions do. ! 351: ! 352: * Menu: ! 353: ! 354: * File Framework:: Structural information for the assembler file. ! 355: * Data Output:: Output of constants (numbers, strings, addresses). ! 356: * Uninitialized Data:: Output of uninitialized variables. ! 357: * Label Output:: Output and generation of labels. ! 358: * Constructor Output:: Output of initialization and termination routines. ! 359: * Instruction Output:: Output of actual instructions. ! 360: * Dispatch Tables:: Output of jump tables. ! 361: * Alignment Output:: Pseudo ops for alignment and skipping data. ! 362: ! 363: ! 364: File: gcc.info, Node: File Framework, Next: Data Output, Up: Assembler Format ! 365: ! 366: The Overall Framework of an Assembler File ! 367: ------------------------------------------ ! 368: ! 369: `ASM_FILE_START (STREAM)' ! 370: A C expression which outputs to the stdio stream STREAM some ! 371: appropriate text to go at the start of an assembler file. ! 372: ! 373: Normally this macro is defined to output a line containing ! 374: `#NO_APP', which is a comment that has no effect on most ! 375: assemblers but tells the GNU assembler that it can save time by ! 376: not checking for certain assembler constructs. ! 377: ! 378: On systems that use SDB, it is necessary to output certain ! 379: commands; see `attasm.h'. ! 380: ! 381: `ASM_FILE_END (STREAM)' ! 382: A C expression which outputs to the stdio stream STREAM some ! 383: appropriate text to go at the end of an assembler file. ! 384: ! 385: If this macro is not defined, the default is to output nothing ! 386: special at the end of the file. Most systems don't require any ! 387: definition. ! 388: ! 389: On systems that use SDB, it is necessary to output certain ! 390: commands; see `attasm.h'. ! 391: ! 392: `ASM_IDENTIFY_GCC (FILE)' ! 393: A C statement to output assembler commands which will identify ! 394: the object file as having been compiled with GNU CC (or another ! 395: GNU compiler). ! 396: ! 397: If you don't define this macro, the string `gcc_compiled.:' is ! 398: output. This string is calculated to define a symbol which, on ! 399: BSD systems, will never be defined for any other reason. GDB ! 400: checks for the presence of this symbol when reading the symbol ! 401: table of an executable. ! 402: ! 403: On non-BSD systems, you must arrange communication with GDB in ! 404: some other fashion. If GDB is not used on your system, you can ! 405: define this macro with an empty body. ! 406: ! 407: `ASM_COMMENT_START' ! 408: A C string constant describing how to begin a comment in the ! 409: target assembler language. The compiler assumes that the comment ! 410: will end at the end of the line. ! 411: ! 412: `ASM_APP_ON' ! 413: A C string constant for text to be output before each `asm' ! 414: statement or group of consecutive ones. Normally this is ! 415: `"#APP"', which is a comment that has no effect on most ! 416: assemblers but tells the GNU assembler that it must check the ! 417: lines that follow for all valid assembler constructs. ! 418: ! 419: `ASM_APP_OFF' ! 420: A C string constant for text to be output after each `asm' ! 421: statement or group of consecutive ones. Normally this is ! 422: `"#NO_APP"', which tells the GNU assembler to resume making the ! 423: time-saving assumptions that are valid for ordinary compiler ! 424: output. ! 425: ! 426: `ASM_OUTPUT_SOURCE_FILENAME (STREAM, NAME)' ! 427: A C statement to output COFF information or DWARF debugging ! 428: information which indicates that filename NAME is the current ! 429: source file to the stdio stream STREAM. ! 430: ! 431: This macro need not be defined if the standard form of output for ! 432: the file format in use is appropriate. ! 433: ! 434: `ASM_OUTPUT_SOURCE_LINE (STREAM, LINE)' ! 435: A C statement to output DBX or SDB debugging information before ! 436: code for line number LINE of the current source file to the stdio ! 437: stream STREAM. ! 438: ! 439: This macro need not be defined if the standard form of debugging ! 440: information for the debugger in use is appropriate. ! 441: ! 442: `ASM_OUTPUT_IDENT (STREAM, STRING)' ! 443: A C statement to output something to the assembler file to handle ! 444: a `#ident' directive containing the text STRING. If this macro ! 445: is not defined, nothing is output for a `#ident' directive. ! 446: ! 447: `OBJC_PROLOGUE' ! 448: A C statement to output any assembler statements which are ! 449: required to precede any Objective C object definitions or message ! 450: sending. The statement is executed only when compiling an ! 451: Objective C program. ! 452: ! 453: ! 454: File: gcc.info, Node: Data Output, Next: Uninitialized Data, Prev: File Framework, Up: Assembler Format ! 455: ! 456: Output of Data ! 457: -------------- ! 458: ! 459: `ASM_OUTPUT_LONG_DOUBLE (STREAM, VALUE)' ! 460: `ASM_OUTPUT_DOUBLE (STREAM, VALUE)' ! 461: `ASM_OUTPUT_FLOAT (STREAM, VALUE)' ! 462: A C statement to output to the stdio stream STREAM an assembler ! 463: instruction to assemble a floating-point constant of `TFmode', ! 464: `DFmode' or `SFmode', respectively, whose value is VALUE. VALUE ! 465: will be a C expression of type `REAL_VALUE__TYPE', usually ! 466: `double'. ! 467: ! 468: `ASM_OUTPUT_QUADRUPLE_INT (STREAM, EXP)' ! 469: `ASM_OUTPUT_DOUBLE_INT (STREAM, EXP)' ! 470: `ASM_OUTPUT_INT (STREAM, EXP)' ! 471: `ASM_OUTPUT_SHORT (STREAM, EXP)' ! 472: `ASM_OUTPUT_CHAR (STREAM, EXP)' ! 473: A C statement to output to the stdio stream STREAM an assembler ! 474: instruction to assemble an integer of 16, 8, 4, 2 or 1 bytes, ! 475: respectively, whose value is VALUE. The argument EXP will be an ! 476: RTL expression which represents a constant value. Use ! 477: `output_addr_const (STREAM, EXP)' to output this value as an ! 478: assembler expression. ! 479: ! 480: For sizes larger than `UNITS_PER_WORD', if the action of a macro ! 481: would be identical to repeatedly calling the macro corresponding ! 482: to a size of `UNITS_PER_WORD', once for each word, you need not ! 483: define the macro. ! 484: ! 485: `ASM_OUTPUT_BYTE (STREAM, VALUE)' ! 486: A C statement to output to the stdio stream STREAM an assembler ! 487: instruction to assemble a single byte containing the number VALUE. ! 488: ! 489: `ASM_BYTE_OP' ! 490: A C string constant giving the pseudo-op to use for a sequence of ! 491: single-byte constants. If this macro is not defined, the default ! 492: is `"byte"'. ! 493: ! 494: `ASM_OUTPUT_ASCII (STREAM, PTR, LEN)' ! 495: A C statement to output to the stdio stream STREAM an assembler ! 496: instruction to assemble a string constant containing the LEN ! 497: bytes at PTR. PTR will be a C expression of type `char *' and ! 498: LEN a C expression of type `int'. ! 499: ! 500: If the assembler has a `.ascii' pseudo-op as found in the ! 501: Berkeley Unix assembler, do not define the macro ! 502: `ASM_OUTPUT_ASCII'. ! 503: ! 504: `ASM_OUTPUT_POOL_PROLOGUE (FILE FUNNAME FUNDECL SIZE)' ! 505: A C statement to output assembler commands to define the start of ! 506: the constant pool for a function. FUNNAME is a string giving the ! 507: name of the function. Should the return type of the function be ! 508: required, it can be obtained via FUNDECL. SIZE is the size, in ! 509: bytes, of the constant pool that will be written immediately ! 510: after this call. ! 511: ! 512: If no constant-pool prefix is required, the usual case, this ! 513: macro need not be defined. ! 514: ! 515: `ASM_OUTPUT_SPECIAL_POOL_ENTRY (FILE, X, MODE, ALIGN, LABELNO, JUMPTO)' ! 516: A C statement (with or without semicolon) to output a constant in ! 517: the constant pool, if it needs special treatment. (This macro ! 518: need not do anything for RTL expressions that can be output ! 519: normally.) ! 520: ! 521: The argument FILE is the standard I/O stream to output the ! 522: assembler code on. X is the RTL expression for the constant to ! 523: output, and MODE is the machine mode (in case X is a ! 524: `const_int'). ALIGN is the required alignment for the value X; ! 525: you should output an assembler directive to force this much ! 526: alignment. ! 527: ! 528: The argument LABELNO is a number to use in an internal label for ! 529: the address of this pool entry. The definition of this macro is ! 530: responsible for outputting the label definition at the proper ! 531: place. Here is how to do this: ! 532: ! 533: ASM_OUTPUT_INTERNAL_LABEL (FILE, "LC", LABELNO); ! 534: ! 535: When you output a pool entry specially, you should end with a ! 536: `goto' to the label JUMPTO. This will prevent the same pool ! 537: entry from being output a second time in the usual manner. ! 538: ! 539: You need not define this macro if it would do nothing. ! 540: ! 541: `ASM_OPEN_PAREN' ! 542: `ASM_CLOSE_PAREN' ! 543: These macros are defined as C string constant, describing the ! 544: syntax in the assembler for grouping arithmetic expressions. The ! 545: following definitions are correct for most assemblers: ! 546: ! 547: #define ASM_OPEN_PAREN "(" ! 548: #define ASM_CLOSE_PAREN ")" ! 549: ! 550: 1.1 root 551: File: gcc.info, Node: Uninitialized Data, Next: Label Output, Prev: Data Output, Up: Assembler Format 552: 553: Output of Uninitialized Variables 554: --------------------------------- 555: 556: Each of the macros in this section is used to do the whole job of 557: outputting a single uninitialized variable. 558: 559: `ASM_OUTPUT_COMMON (STREAM, NAME, SIZE, ROUNDED)' 560: A C statement (sans semicolon) to output to the stdio stream 561: STREAM the assembler definition of a common-label named NAME 562: whose size is SIZE bytes. The variable ROUNDED is the size 563: rounded up to whatever alignment the caller wants. 564: 565: Use the expression `assemble_name (STREAM, NAME)' to output the 566: name itself; before and after that, output the additional 567: assembler syntax for defining the name, and a newline. 568: 569: This macro controls how the assembler definitions of uninitialized 570: global variables are output. 571: 572: `ASM_OUTPUT_ALIGNED_COMMON (STREAM, NAME, SIZE, ALIGNMENT)' 573: Like `ASM_OUTPUT_COMMON' except takes the required alignment as a 574: separate, explicit argument. If you define this macro, it is 575: used in place of `ASM_OUTPUT_COMMON', and gives you more 576: flexibility in handling the required alignment of the variable. 577: 578: `ASM_OUTPUT_SHARED_COMMON (STREAM, NAME, SIZE, ROUNDED)' 579: If defined, it is similar to `ASM_OUTPUT_COMMON', except that it 580: is used when NAME is shared. If not defined, `ASM_OUTPUT_COMMON' 581: will be used. 582: 583: `ASM_OUTPUT_LOCAL (STREAM, NAME, SIZE, ROUNDED)' 584: A C statement (sans semicolon) to output to the stdio stream 585: STREAM the assembler definition of a local-common-label named 586: NAME whose size is SIZE bytes. The variable ROUNDED is the size 587: rounded up to whatever alignment the caller wants. 588: 589: Use the expression `assemble_name (STREAM, NAME)' to output the 590: name itself; before and after that, output the additional 591: assembler syntax for defining the name, and a newline. 592: 593: This macro controls how the assembler definitions of uninitialized 594: static variables are output. 595: 596: `ASM_OUTPUT_ALIGNED_LOCAL (STREAM, NAME, SIZE, ALIGNMENT)' 597: Like `ASM_OUTPUT_LOCAL' except takes the required alignment as a 598: separate, explicit argument. If you define this macro, it is 599: used in place of `ASM_OUTPUT_LOCAL', and gives you more 600: flexibility in handling the required alignment of the variable. 601: 602: `ASM_OUTPUT_SHARED_LOCAL (STREAM, NAME, SIZE, ROUNDED)' 603: If defined, it is similar to `ASM_OUTPUT_LOCAL', except that it 604: is used when NAME is shared. If not defined, `ASM_OUTPUT_LOCAL' 605: will be used. 606: 607: 608: File: gcc.info, Node: Label Output, Next: Constructor Output, Prev: Uninitialized Data, Up: Assembler Format 609: 610: Output and Generation of Labels 611: ------------------------------- 612: 613: `ASM_OUTPUT_LABEL (STREAM, NAME)' 614: A C statement (sans semicolon) to output to the stdio stream 615: STREAM the assembler definition of a label named NAME. Use the 616: expression `assemble_name (STREAM, NAME)' to output the name 617: itself; before and after that, output the additional assembler 618: syntax for defining the name, and a newline. 619: 620: `ASM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL)' 621: A C statement (sans semicolon) to output to the stdio stream 622: STREAM any text necessary for declaring the name NAME of a 623: function which is being defined. This macro is responsible for 624: outputting the label definition (perhaps using 625: `ASM_OUTPUT_LABEL'). The argument DECL is the `FUNCTION_DECL' 626: tree node representing the function. 627: 628: If this macro is not defined, then the function name is defined 629: in the usual manner as a label (by means of `ASM_OUTPUT_LABEL'). 630: 631: `ASM_DECLARE_FUNCTION_SIZE (STREAM, NAME, DECL)' 632: A C statement (sans semicolon) to output to the stdio stream 633: STREAM any text necessary for declaring the size of a function 634: which is being defined. The argument NAME is the name of the 635: function. The argument DECL is the `FUNCTION_DECL' tree node 636: representing the function. 637: 638: If this macro is not defined, then the function size is not 639: defined. 640: 641: `ASM_DECLARE_OBJECT_NAME (STREAM, NAME, DECL)' 642: A C statement (sans semicolon) to output to the stdio stream 643: STREAM any text necessary for declaring the name NAME of an 644: initialized variable which is being defined. This macro must 645: output the label definition (perhaps using `ASM_OUTPUT_LABEL'). 646: The argument DECL is the `VAR_DECL' tree node representing the 647: variable. 648: 649: If this macro is not defined, then the variable name is defined 650: in the usual manner as a label (by means of `ASM_OUTPUT_LABEL'). 651: 652: `ASM_GLOBALIZE_LABEL (STREAM, NAME)' 653: A C statement (sans semicolon) to output to the stdio stream 654: STREAM some commands that will make the label NAME global; that 655: is, available for reference from other files. Use the expression 656: `assemble_name (STREAM, NAME)' to output the name itself; before 657: and after that, output the additional assembler syntax for making 658: that name global, and a newline. 659: 660: `ASM_OUTPUT_EXTERNAL (STREAM, DECL, NAME)' 661: A C statement (sans semicolon) to output to the stdio stream 662: STREAM any text necessary for declaring the name of an external 663: symbol named NAME which is referenced in this compilation but not 664: defined. The value of DECL is the tree node for the declaration. 665: 666: This macro need not be defined if it does not need to output 667: anything. The GNU assembler and most Unix assemblers don't 668: require anything. 669: 670: `ASM_OUTPUT_EXTERNAL_LIBCALL (STREAM, SYMREF)' 671: A C statement (sans semicolon) to output on STREAM an assembler 672: pseudo-op to declare a library function name external. The name 673: of the library function is given by SYMREF, which has type `rtx' 674: and is a `symbol_ref'. 675: 676: This macro need not be defined if it does not need to output 677: anything. The GNU assembler and most Unix assemblers don't 678: require anything. 679: 680: `ASM_OUTPUT_LABELREF (STREAM, NAME)' 681: A C statement (sans semicolon) to output to the stdio stream 682: STREAM a reference in assembler syntax to a label named NAME. 683: This should add `_' to the front of the name, if that is 684: customary on your operating system, as it is in most Berkeley Unix 685: systems. This macro is used in `assemble_name'. 686: 687: `ASM_OUTPUT_LABELREF_AS_INT (FILE, LABEL)' 688: Define this macro for systems that use the program `collect2'. 689: The definition should be a C statement to output a word containing 690: a reference to the label LABEL. 691: 692: `ASM_OUTPUT_INTERNAL_LABEL (STREAM, PREFIX, NUM)' 693: A C statement to output to the stdio stream STREAM a label whose 1.1.1.2 ! root 694: name is made from the string PREFIX and the number NUM. ! 695: ! 696: It is absolutely essential that these labels be distinct from the ! 697: labels used for user-level functions and variables. Otherwise, ! 698: certain programs will have name conflicts with internal labels. ! 699: ! 700: It is desirable to exclude internal labels from the symbol table ! 701: of the object file. Most assemblers have a naming convention for ! 702: labels that should be excluded; on many systems, the letter `L' ! 703: at the beginning of a label has this effect. You should find out ! 704: what convention your system uses, and follow it. ! 705: ! 706: The usual definition of this macro is as follows: 1.1 root 707: 708: fprintf (STREAM, "L%s%d:\n", PREFIX, NUM) 709: 1.1.1.2 ! root 710: `ASM_GENERATE_INTERNAL_LABEL (STRING, PREFIX, NUM)' ! 711: A C statement to store into the string STRING a label whose name ! 712: is made from the string PREFIX and the number NUM. ! 713: ! 714: This string, when output subsequently by `assemble_name', should ! 715: produce the same output that `ASM_OUTPUT_INTERNAL_LABEL' would ! 716: produce with the same PREFIX and NUM. ! 717: ! 718: If the string begins with `*', then `assemble_name' will output ! 719: the rest of the string unchanged. It is often convenient for ! 720: `ASM_GENERATE_INTERNAL_LABEL' to use `*' in this way. If the ! 721: string doesn't start with `*', then `ASM_OUTPUT_LABELREF' gets to ! 722: output the string, and may change it. (Of course, ! 723: `ASM_OUTPUT_LABELREF' is also part of your machine description, so ! 724: you should know what it does on your machine.) ! 725: 1.1 root 726: `ASM_FORMAT_PRIVATE_NAME (OUTVAR, NAME, NUMBER)' 727: A C expression to assign to OUTVAR (which is a variable of type 728: `char *') a newly allocated string made from the string NAME and 729: the number NUMBER, with some suitable punctuation added. Use 730: `alloca' to get space for the string. 731: 732: This string will be used as the argument to `ASM_OUTPUT_LABELREF' 733: to produce an assembler label for an internal static variable 734: whose name is NAME. Therefore, the string must be such as to 735: result in valid assembler code. The argument NUMBER is different 736: each time this macro is executed; it prevents conflicts between 737: similarly-named internal static variables in different scopes. 738: 739: Ideally this string should not be a valid C identifier, to 740: prevent any conflict with the user's own symbols. Most 741: assemblers allow periods or percent signs in assembler symbols; 742: putting at least one of these between the name and the number 743: will suffice. 744: 745: `OBJC_GEN_METHOD_LABEL (BUF, IS_INST, CLASS_NAME, CAT_NAME, SEL_NAME)' 746: Define this macro to override the default assembler names used for 747: Objective C methods. 748: 749: The default name is a unique method number followed by the name 750: of the class (e.g. `_1_Foo'). For methods in categories, the 751: name of the category is also included in the assembler name (e.g. 752: `_1_Foo_Bar'). 753: 754: These names are safe on most systems, but make debugging 755: difficult since the method's selector is not present in the name. 756: Therefore, particular systems define other ways of computing 757: names. 758: 1.1.1.2 ! root 759: BUF is an expression of type `char *' which gives you a buffer in ! 760: which to store the name; its length is as long as CLASS_NAME, ! 761: CAT_NAME and SEL_NAME put together, plus 50 characters extra. ! 762: ! 763: The argument IS_INST specifies whether the method is an instance ! 764: method or a class method; CLASS_NAME is the name of the class; ! 765: CAT_NAME is the name of the category (or NULL if the method is not ! 766: in a category); and SEL_NAME is the name of the selector. 1.1 root 767: 768: On systems where the assembler can handle quoted names, you can 769: use this macro to provide more human-readable names. 770: 771: 772: File: gcc.info, Node: Constructor Output, Next: Instruction Output, Prev: Label Output, Up: Assembler Format 773: 774: Output of Initialization Routines 775: --------------------------------- 776: 777: The compiled code for certain languages includes "constructors" 778: (also called "initialization routines")--functions to initialize data 779: in the program when the program is started. These functions need to 780: be called before the program is "started"--that is to say, before 781: `main' is called. 782: 783: Compiling some languages generates "destructors" (also called 784: "termination routines") that should be called when the program 785: terminates. 786: 787: To make the initialization and termination functions work, the 788: compiler must output something in the assembler code to cause those 789: functions to be called at the appropriate time. When you port the 790: compiler to a new system, you need to specify what assembler code is 791: needed to do this. 792: 793: Here are the two macros you should define if necessary: 794: 795: `ASM_OUTPUT_CONSTRUCTOR (STREAM, NAME)' 796: Define this macro as a C statement to output on the stream STREAM 797: the assembler code to arrange to call the function named NAME at 798: initialization time. 799: 800: Assume that NAME is the name of a C function generated 801: automatically by the compiler. This function takes no arguments. 802: Use the function `assemble_name' to output the name NAME; this 803: performs any system-specific syntactic transformations such as 804: adding an underscore. 805: 806: If you don't define this macro, nothing special is output to 807: arrange to call the function. This is correct when the function 808: will be called in some other manner--for example, by means of the 809: `collect' program, which looks through the symbol table to find 810: these functions by their names. If you want to use `collect', 811: then you need to arrange for it to be built and installed and 812: used on your system. 813: 814: `ASM_OUTPUT_DESTRUCTOR (STREAM, NAME)' 815: This is like `ASM_OUTPUT_CONSTRUCTOR' but used for termination 816: functions rather than initialization functions. 817: 818: 819: File: gcc.info, Node: Instruction Output, Next: Dispatch Tables, Prev: Constructor Output, Up: Assembler Format 820: 821: Output of Assembler Instructions 822: -------------------------------- 823: 824: `REGISTER_NAMES' 825: A C initializer containing the assembler's names for the machine 826: registers, each one as a C string constant. This is what 827: translates register numbers in the compiler into assembler 828: language. 829: 830: `ADDITIONAL_REGISTER_NAMES' 831: If defined, a C initializer for an array of structures containing 832: a name and a register number. This macro defines additional 833: names for hard registers, thus allowing the `asm' option in 834: declarations to refer to registers using alternate names. 835: 836: `ASM_OUTPUT_OPCODE (STREAM, PTR)' 837: Define this macro if you are using an unusual assembler that 838: requires different names for the machine instructions. 839: 840: The definition is a C statement or statements which output an 841: assembler instruction opcode to the stdio stream STREAM. The 842: macro-operand PTR is a variable of type `char *' which points to 843: the opcode name in its "internal" form--the form that is written 844: in the machine description. The definition should output the 845: opcode name to STREAM, performing any translation you desire, and 846: increment the variable PTR to point at the end of the opcode so 847: that it will not be output twice. 848: 849: In fact, your macro definition may process less than the entire 850: opcode name, or more than the opcode name; but if you want to 851: process text that includes `%'-sequences to substitute operands, 852: you must take care of the substitution yourself. Just be sure to 853: increment PTR over whatever text should not be output normally. 854: 855: If you need to look at the operand values, they can be found as 856: the elements of `recog_operand'. 857: 858: If the macro definition does nothing, the instruction is output 859: in the usual way. 860: 861: `FINAL_PRESCAN_INSN (INSN, OPVEC, NOPERANDS)' 862: If defined, a C statement to be executed just prior to the output 863: of assembler code for INSN, to modify the extracted operands so 864: they will be output differently. 865: 866: Here the argument OPVEC is the vector containing the operands 867: extracted from INSN, and NOPERANDS is the number of elements of 868: the vector which contain meaningful data for this insn. The 869: contents of this vector are what will be used to convert the insn 870: template into assembler code, so you can change the assembler 871: output by changing the contents of the vector. 872: 873: This macro is useful when various assembler syntaxes share a 874: single file of instruction patterns; by defining this macro 875: differently, you can cause a large class of instructions to be 876: output differently (such as with rearranged operands). 877: Naturally, variations in assembler syntax affecting individual 878: insn patterns ought to be handled by writing conditional output 879: routines in those patterns. 880: 881: If this macro is not defined, it is equivalent to a null 882: statement. 883: 884: `PRINT_OPERAND (STREAM, X, CODE)' 885: A C compound statement to output to stdio stream STREAM the 886: assembler syntax for an instruction operand X. X is an RTL 887: expression. 888: 889: CODE is a value that can be used to specify one of several ways 890: of printing the operand. It is used when identical operands must 891: be printed differently depending on the context. CODE comes from 892: the `%' specification that was used to request printing of the 893: operand. If the specification was just `%DIGIT' then CODE is 0; 894: if the specification was `%LTR DIGIT' then CODE is the ASCII code 895: for LTR. 896: 897: If X is a register, this macro should print the register's name. 898: The names can be found in an array `reg_names' whose type is 899: `char *[]'. `reg_names' is initialized from `REGISTER_NAMES'. 900: 901: When the machine description has a specification `%PUNCT' (a `%' 902: followed by a punctuation character), this macro is called with a 903: null pointer for X and the punctuation character for CODE. 904: 905: `PRINT_OPERAND_PUNCT_VALID_P (CODE)' 906: A C expression which evaluates to true if CODE is a valid 907: punctuation character for use in the `PRINT_OPERAND' macro. If 908: `PRINT_OPERAND_PUNCT_VALID_P' is not defined, it means that no 909: punctuation characters (except for the standard one, `%') are used 910: in this way. 911: 912: `PRINT_OPERAND_ADDRESS (STREAM, X)' 913: A C compound statement to output to stdio stream STREAM the 914: assembler syntax for an instruction operand that is a memory 915: reference whose address is X. X is an RTL expression. 916: 917: On some machines, the syntax for a symbolic address depends on the 918: section that the address refers to. On these machines, define 919: the macro `ENCODE_SECTION_INFO' to store the information into the 920: `symbol_ref', and then check for it here. *Note Assembler 921: Format::. 922: 923: `DBR_OUTPUT_SEQEND(FILE)' 924: A C statement, to be executed after all slot-filler instructions 925: have been output. If necessary, call `dbr_sequence_length' to 926: determine the number of slots filled in a sequence (zero if not 927: currently outputting a sequence), to decide how many no-ops to 928: output, or whatever. 929: 930: Don't define this macro if it has nothing to do, but it is 931: helpful in reading assembly output if the extent of the delay 932: sequence is made explicit (e.g. with white space). 933: 934: Note that output routines for instructions with delay slots must 935: be prepared to deal with not being output as part of a sequence 936: (i.e. when the scheduling pass is not run, or when no slot 937: fillers could be found.) The variable `final_sequence' is null 938: when not processing a sequence, otherwise it contains the 939: `sequence' rtx being output. 940: 941: `REGISTER_PREFIX' 942: `LOCAL_LABEL_PREFIX' 943: `USER_LABEL_PREFIX' 944: `IMMEDIATE_PREFIX' 945: If defined, C string expressions to be used for the `%R', `%L', 946: `%U', and `%I' options of `asm_fprintf' (see `final.c'). These 947: are useful when a single `md' file must support multiple 948: assembler formats. In that case, the various `tm.h' files can 949: define these macros differently. 950: 951: `ASM_OUTPUT_REG_PUSH (STREAM, REGNO)' 952: A C expression to output to STREAM some assembler code which will 953: push hard register number REGNO onto the stack. The code need 954: not be optimal, since this macro is used only when profiling. 955: 956: `ASM_OUTPUT_REG_POP (STREAM, REGNO)' 957: A C expression to output to STREAM some assembler code which will 958: pop hard register number REGNO off of the stack. The code need 959: not be optimal, since this macro is used only when profiling. 960: 961: 962: File: gcc.info, Node: Dispatch Tables, Next: Alignment Output, Prev: Instruction Output, Up: Assembler Format 963: 964: Output of Dispatch Tables 965: ------------------------- 966: 967: `ASM_OUTPUT_ADDR_DIFF_ELT (STREAM, VALUE, REL)' 968: This macro should be provided on machines where the addresses in 969: a dispatch table are relative to the table's own address. 970: 971: The definition should be a C statement to output to the stdio 972: stream STREAM an assembler pseudo-instruction to generate a 973: difference between two labels. VALUE and REL are the numbers of 974: two internal labels. The definitions of these labels are output 975: using `ASM_OUTPUT_INTERNAL_LABEL', and they must be printed in 976: the same way here. For example, 977: 978: fprintf (STREAM, "\t.word L%d-L%d\n", 979: VALUE, REL) 980: 981: `ASM_OUTPUT_ADDR_VEC_ELT (STREAM, VALUE)' 982: This macro should be provided on machines where the addresses in 983: a dispatch table are absolute. 984: 985: The definition should be a C statement to output to the stdio 986: stream STREAM an assembler pseudo-instruction to generate a 987: reference to a label. VALUE is the number of an internal label 988: whose definition is output using `ASM_OUTPUT_INTERNAL_LABEL'. 989: For example, 990: 991: fprintf (STREAM, "\t.word L%d\n", VALUE) 992: 993: `ASM_OUTPUT_CASE_LABEL (STREAM, PREFIX, NUM, TABLE)' 994: Define this if the label before a jump-table needs to be output 995: specially. The first three arguments are the same as for 996: `ASM_OUTPUT_INTERNAL_LABEL'; the fourth argument is the 997: jump-table which follows (a `jump_insn' containing an `addr_vec' 998: or `addr_diff_vec'). 999: 1000: This feature is used on system V to output a `swbeg' statement 1001: for the table. 1002: 1003: If this macro is not defined, these labels are output with 1004: `ASM_OUTPUT_INTERNAL_LABEL'. 1005: 1006: `ASM_OUTPUT_CASE_END (STREAM, NUM, TABLE)' 1007: Define this if something special must be output at the end of a 1008: jump-table. The definition should be a C statement to be executed 1009: after the assembler code for the table is written. It should 1010: write the appropriate code to stdio stream STREAM. The argument 1011: TABLE is the jump-table insn, and NUM is the label-number of the 1012: preceding label. 1013: 1014: If this macro is not defined, nothing special is output at the 1015: end of the jump-table. 1016: 1017: 1018: File: gcc.info, Node: Alignment Output, Prev: Dispatch Tables, Up: Assembler Format 1019: 1020: Assembler Commands for Alignment 1021: -------------------------------- 1022: 1023: `ASM_OUTPUT_ALIGN_CODE (FILE)' 1024: A C expression to output text to align the location counter in 1025: the way that is desirable at a point in the code that is reached 1026: only by jumping. 1027: 1028: This macro need not be defined if you don't want any special 1029: alignment to be done at such a time. Most machine descriptions 1030: do not currently define the macro. 1031: 1032: `ASM_OUTPUT_LOOP_ALIGN (FILE)' 1033: A C expression to output text to align the location counter in 1034: the way that is desirable at the beginning of a loop. 1035: 1036: This macro need not be defined if you don't want any special 1037: alignment to be done at such a time. Most machine descriptions 1038: do not currently define the macro. 1039: 1040: `ASM_OUTPUT_SKIP (STREAM, NBYTES)' 1041: A C statement to output to the stdio stream STREAM an assembler 1042: instruction to advance the location counter by NBYTES bytes. 1043: Those bytes should be zero when loaded. NBYTES will be a C 1044: expression of type `int'. 1045: 1046: `ASM_NO_SKIP_IN_TEXT' 1047: Define this macro if `ASM_OUTPUT_SKIP' should not be used in the 1048: text section because it fails put zeros in the bytes that are 1049: skipped. This is true on many Unix systems, where the pseudo--op 1050: to skip bytes produces no-op instructions rather than zeros when 1051: used in the text section. 1052: 1053: `ASM_OUTPUT_ALIGN (STREAM, POWER)' 1054: A C statement to output to the stdio stream STREAM an assembler 1055: command to advance the location counter to a multiple of 2 to the 1056: POWER bytes. POWER will be a C expression of type `int'. 1057: 1058:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.