home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / gcc.i17 (.txt) < prev    next >
GNU Info File  |  1993-06-12  |  46KB  |  775 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.47 from the input
  2. file gcc.tex.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled "GNU General Public License" and "Protect
  11. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  12. original, and provided that the entire resulting derived work is
  13. distributed under the terms of a permission notice identical to this
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the sections entitled "GNU General Public
  17. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  18. permission notice, may be included in translations approved by the Free
  19. Software Foundation instead of in the original English.
  20. File: gcc.info,  Node: Costs,  Next: Sections,  Prev: Condition Code,  Up: Target Macros
  21. Describing Relative Costs of Operations
  22. =======================================
  23.    These macros let you describe the relative speed of various
  24. operations on the target machine.
  25. `CONST_COSTS (X, CODE, OUTER_CODE)'
  26.      A part of a C `switch' statement that describes the relative costs
  27.      of constant RTL expressions.  It must contain `case' labels for
  28.      expression codes `const_int', `const', `symbol_ref', `label_ref'
  29.      and `const_double'.  Each case must ultimately reach a `return'
  30.      statement to return the relative cost of the use of that kind of
  31.      constant value in an expression.  The cost may depend on the
  32.      precise value of the constant, which is available for examination
  33.      in X, and the rtx code of the expression in which it is contained,
  34.      found in OUTER_CODE.
  35.      CODE is the expression code--redundant, since it can be obtained
  36.      with `GET_CODE (X)'.
  37. `RTX_COSTS (X, CODE, OUTER_CODE)'
  38.      Like `CONST_COSTS' but applies to nonconstant RTL expressions.
  39.      This can be used, for example, to indicate how costly a multiply
  40.      instruction is.  In writing this macro, you can use the construct
  41.      `COSTS_N_INSNS (N)' to specify a cost equal to N fast
  42.      instructions.  OUTER_CODE is the code of the expression in which X
  43.      is contained.
  44.      This macro is optional; do not define it if the default cost
  45.      assumptions are adequate for the target machine.
  46. `ADDRESS_COST (ADDRESS)'
  47.      An expression giving the cost of an addressing mode that contains
  48.      ADDRESS.  If not defined, the cost is computed from the ADDRESS
  49.      expression and the `CONST_COSTS' values.
  50.      For most CISC machines, the default cost is a good approximation
  51.      of the true cost of the addressing mode.  However, on RISC
  52.      machines, all instructions normally have the same length and
  53.      execution time.  Hence all addresses will have equal costs.
  54.      In cases where more than one form of an address is known, the form
  55.      with the lowest cost will be used.  If multiple forms have the
  56.      same, lowest, cost, the one that is the most complex will be used.
  57.      For example, suppose an address that is equal to the sum of a
  58.      register and a constant is used twice in the same basic block. 
  59.      When this macro is not defined, the address will be computed in a
  60.      register and memory references will be indirect through that
  61.      register.  On machines where the cost of the addressing mode
  62.      containing the sum is no higher than that of a simple indirect
  63.      reference, this will produce an additional instruction and
  64.      possibly require an additional register.  Proper specification of
  65.      this macro eliminates this overhead for such machines.
  66.      Similar use of this macro is made in strength reduction of loops.
  67.      ADDRESS need not be valid as an address.  In such a case, the cost
  68.      is not relevant and can be any value; invalid addresses need not be
  69.      assigned a different cost.
  70.      On machines where an address involving more than one register is as
  71.      cheap as an address computation involving only one register,
  72.      defining `ADDRESS_COST' to reflect this can cause two registers to
  73.      be live over a region of code where only one would have been if
  74.      `ADDRESS_COST' were not defined in that manner.  This effect should
  75.      be considered in the definition of this macro.  Equivalent costs
  76.      should probably only be given to addresses with different numbers
  77.      of registers on machines with lots of registers.
  78.      This macro will normally either not be defined or be defined as a
  79.      constant.
  80. `REGISTER_MOVE_COST (FROM, TO)'
  81.      A C expression for the cost of moving data from a register in class
  82.      FROM to one in class TO.  The classes are expressed using the
  83.      enumeration values such as `GENERAL_REGS'.  A value of 2 is the
  84.      default; other values are interpreted relative to that.
  85.      It is not required that the cost always equal 2 when FROM is the
  86.      same as TO; on some machines it is expensive to move between
  87.      registers if they are not general registers.
  88.      If reload sees an insn consisting of a single `set' between two
  89.      hard registers, and if `REGISTER_MOVE_COST' applied to their
  90.      classes returns a value of 2, reload does not check to ensure that
  91.      the constraints of the insn are met.  Setting a cost of other than
  92.      2 will allow reload to verify that the constraints are met.  You
  93.      should do this if the `movM' pattern's constraints do not allow
  94.      such copying.
  95. `MEMORY_MOVE_COST (M)'
  96.      A C expression for the cost of moving data of mode M between a
  97.      register and memory.  A value of 2 is the default; this cost is
  98.      relative to those in `REGISTER_MOVE_COST'.
  99.      If moving between registers and memory is more expensive than
  100.      between two registers, you should define this macro to express the
  101.      relative cost.
  102. `BRANCH_COST'
  103.      A C expression for the cost of a branch instruction.  A value of 1
  104.      is the default; other values are interpreted relative to that.
  105.    Here are additional macros which do not specify precise relative
  106. costs, but only that certain actions are more expensive than GNU CC
  107. would ordinarily expect.
  108. `SLOW_BYTE_ACCESS'
  109.      Define this macro as a C expression which is nonzero if accessing
  110.      less than a word of memory (i.e. a `char' or a `short') is no
  111.      faster than accessing a word of memory, i.e., if such access
  112.      require more than one instruction or if there is no difference in
  113.      cost between byte and (aligned) word loads.
  114.      When this macro is not defined, the compiler will access a field by
  115.      finding the smallest containing object; when it is defined, a
  116.      fullword load will be used if alignment permits.  Unless bytes
  117.      accesses are faster than word accesses, using word accesses is
  118.      preferable since it may eliminate subsequent memory access if
  119.      subsequent accesses occur to other fields in the same word of the
  120.      structure, but to different bytes.
  121. `SLOW_ZERO_EXTEND'
  122.      Define this macro if zero-extension (of a `char' or `short' to an
  123.      `int') can be done faster if the destination is a register that is
  124.      known to be zero.
  125.      If you define this macro, you must have instruction patterns that
  126.      recognize RTL structures like this:
  127.           (set (strict_low_part (subreg:QI (reg:SI ...) 0)) ...)
  128.      and likewise for `HImode'.
  129. `SLOW_UNALIGNED_ACCESS'
  130.      Define this macro to be the value 1 if unaligned accesses have a
  131.      cost many times greater than aligned accesses, for example if they
  132.      are emulated in a trap handler.
  133.      When this macro is non-zero, the compiler will act as if
  134.      `STRICT_ALIGNMENT' were non-zero when generating code for block
  135.      moves.  This can cause significantly more instructions to be
  136.      produced. Therefore, do not set this macro non-zero if unaligned
  137.      accesses only add a cycle or two to the time for a memory access.
  138.      If the value of this macro is always zero, it need not be defined.
  139. `DONT_REDUCE_ADDR'
  140.      Define this macro to inhibit strength reduction of memory
  141.      addresses. (On some machines, such strength reduction seems to do
  142.      harm rather than good.)
  143. `MOVE_RATIO'
  144.      The number of scalar move insns which should be generated instead
  145.      of a string move insn or a library call.  Increasing the value
  146.      will always make code faster, but eventually incurs high cost in
  147.      increased code size.
  148.      If you don't define this, a reasonable default is used.
  149. `NO_FUNCTION_CSE'
  150.      Define this macro if it is as good or better to call a constant
  151.      function address than to call an address kept in a register.
  152. `NO_RECURSIVE_FUNCTION_CSE'
  153.      Define this macro if it is as good or better for a function to call
  154.      itself with an explicit address than to call an address kept in a
  155.      register.
  156. `ADJUST_COST (INSN, LINK, DEP_INSN, COST)'
  157.      A C statement (sans semicolon) to update the integer variable COST
  158.      based on the relationship between INSN that is dependent on
  159.      DEP_INSN through the dependence LINK.  The default is to make no
  160.      adjustment to COST.  This can be used for example to specify to
  161.      the scheduler that an output- or anti-dependence does not incur
  162.      the same cost as a data-dependence.
  163. File: gcc.info,  Node: Sections,  Next: PIC,  Prev: Costs,  Up: Target Macros
  164. Dividing the Output into Sections (Texts, Data, ...)
  165. ====================================================
  166.    An object file is divided into sections containing different types of
  167. data.  In the most common case, there are three sections: the "text
  168. section", which holds instructions and read-only data; the "data
  169. section", which holds initialized writable data; and the "bss section",
  170. which holds uninitialized data.  Some systems have other kinds of
  171. sections.
  172.    The compiler must tell the assembler when to switch sections.  These
  173. macros control what commands to output to tell the assembler this.  You
  174. can also define additional sections.
  175. `TEXT_SECTION_ASM_OP'
  176.      A C expression whose value is a string containing the assembler
  177.      operation that should precede instructions and read-only data. 
  178.      Normally `".text"' is right.
  179. `DATA_SECTION_ASM_OP'
  180.      A C expression whose value is a string containing the assembler
  181.      operation to identify the following data as writable initialized
  182.      data. Normally `".data"' is right.
  183. `SHARED_SECTION_ASM_OP'
  184.      if defined, a C expression whose value is a string containing the
  185.      assembler operation to identify the following data as shared data.
  186.       If not defined, `DATA_SECTION_ASM_OP' will be used.
  187. `INIT_SECTION_ASM_OP'
  188.      if defined, a C expression whose value is a string containing the
  189.      assembler operation to identify the following data as
  190.      initialization code.  If not defined, GNU CC will assume such a
  191.      section does not exist.
  192. `EXTRA_SECTIONS'
  193.      A list of names for sections other than the standard two, which are
  194.      `in_text' and `in_data'.  You need not define this macro on a
  195.      system with no other sections (that GCC needs to use).
  196. `EXTRA_SECTION_FUNCTIONS'
  197.      One or more functions to be defined in `varasm.c'.  These
  198.      functions should do jobs analogous to those of `text_section' and
  199.      `data_section', for your additional sections.  Do not define this
  200.      macro if you do not define `EXTRA_SECTIONS'.
  201. `READONLY_DATA_SECTION'
  202.      On most machines, read-only variables, constants, and jump tables
  203.      are placed in the text section.  If this is not the case on your
  204.      machine, this macro should be defined to be the name of a function
  205.      (either `data_section' or a function defined in `EXTRA_SECTIONS')
  206.      that switches to the section to be used for read-only items.
  207.      If these items should be placed in the text section, this macro
  208.      should not be defined.
  209. `SELECT_SECTION (EXP, RELOC)'
  210.      A C statement or statements to switch to the appropriate section
  211.      for output of EXP.  You can assume that EXP is either a `VAR_DECL'
  212.      node or a constant of some sort.  RELOC indicates whether the
  213.      initial value of EXP requires link-time relocations.  Select the
  214.      section by calling `text_section' or one of the alternatives for
  215.      other sections.
  216.      Do not define this macro if you put all read-only variables and
  217.      constants in the read-only data section (usually the text section).
  218. `SELECT_RTX_SECTION (MODE, RTX)'
  219.      A C statement or statements to switch to the appropriate section
  220.      for output of RTX in mode MODE.  You can assume that RTX is some
  221.      kind of constant in RTL.  The argument MODE is redundant except in
  222.      the case of a `const_int' rtx.  Select the section by calling
  223.      `text_section' or one of the alternatives for other sections.
  224.      Do not define this macro if you put all constants in the read-only
  225.      data section.
  226. `JUMP_TABLES_IN_TEXT_SECTION'
  227.      Define this macro if jump tables (for `tablejump' insns) should be
  228.      output in the text section, along with the assembler instructions.
  229.      Otherwise, the readonly data section is used.
  230.      This macro is irrelevant if there is no separate readonly data
  231.      section.
  232. `ENCODE_SECTION_INFO (DECL)'
  233.      Define this macro if references to a symbol must be treated
  234.      differently depending on something about the variable or function
  235.      named by the symbol (such as what section it is in).
  236.      The macro definition, if any, is executed immediately after the
  237.      rtl for DECL has been created and stored in `DECL_RTL (DECL)'. The
  238.      value of the rtl will be a `mem' whose address is a `symbol_ref'.
  239.      The usual thing for this macro to do is to record a flag in the
  240.      `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
  241.      name string in the `symbol_ref' (if one bit is not enough
  242.      information).
  243. `STRIP_NAME_ENCODING (VAR, SYM_NAME)'
  244.      Decode SYM_NAME and store the real name part in VAR, sans the
  245.      characters that encode section info.  Define this macro if
  246.      `ENCODE_SECTION_INFO' alters the symbol's name string.
  247. File: gcc.info,  Node: PIC,  Next: Assembler Format,  Prev: Sections,  Up: Target Macros
  248. Position Independent Code
  249. =========================
  250.    This section describes macros that help implement generation of
  251. position independent code.  Simply defining these macros is not enough
  252. to generate valid PIC; you must also add support to the macros
  253. `GO_IF_LEGITIMATE_ADDRESS' and `LEGITIMIZE_ADDRESS', and
  254. `PRINT_OPERAND_ADDRESS' as well.  You must modify the definition of
  255. `movsi' to do something appropriate when the source operand contains a
  256. symbolic address.  You may also need to alter the handling of switch
  257. statements so that they use relative addresses.
  258. `PIC_OFFSET_TABLE_REGNUM'
  259.      The register number of the register used to address a table of
  260.      static data addresses in memory.  In some cases this register is
  261.      defined by a processor's "application binary interface" (ABI). 
  262.      When this macro is defined, RTL is generated for this register
  263.      once, as with the stack pointer and frame pointer registers.  If
  264.      this macro is not defined, it is up to the machine-dependent files
  265.      to allocate such a register (if necessary).
  266. `FINALIZE_PIC'
  267.      By generating position-independent code, when two different
  268.      programs (A and B) share a common library (libC.a), the text of
  269.      the library can be shared whether or not the library is linked at
  270.      the same address for both programs.  In some of these
  271.      environments, position-independent code requires not only the use
  272.      of different addressing modes, but also special code to enable the
  273.      use of these addressing modes.
  274.      The `FINALIZE_PIC' macro serves as a hook to emit these special
  275.      codes once the function is being compiled into assembly code, but
  276.      not before.  (It is not done before, because in the case of
  277.      compiling an inline function, it would lead to multiple PIC
  278.      prologues being included in functions which used inline functions
  279.      and were compiled to assembly language.)
  280. `LEGITIMATE_PIC_OPERAND_P (X)'
  281.      A C expression that is nonzero if X is a legitimate immediate
  282.      operand on the target machine when generating position independent
  283.      code. You can assume that X satisfies `CONSTANT_P', so you need not
  284.      check this.  You can also assume FLAG_PIC is true, so you need not
  285.      check it either.  You need not define this macro if all constants
  286.      (including `SYMBOL_REF') can be immediate operands when generating
  287.      position independent code.
  288. File: gcc.info,  Node: Assembler Format,  Next: Debugging Info,  Prev: PIC,  Up: Target Macros
  289. Defining the Output Assembler Language
  290. ======================================
  291.    This section describes macros whose principal purpose is to describe
  292. how to write instructions in assembler language--rather than what the
  293. instructions do.
  294. * Menu:
  295. * File Framework::       Structural information for the assembler file.
  296. * Data Output::          Output of constants (numbers, strings, addresses).
  297. * Uninitialized Data::   Output of uninitialized variables.
  298. * Label Output::         Output and generation of labels.
  299. * Initialization::       General principles of initialization
  300.                and termination routines.
  301. * Macros for Initialization::
  302.              Specific macros that control the handling of
  303.                initialization and termination routines.
  304. * Instruction Output::   Output of actual instructions.
  305. * Dispatch Tables::      Output of jump tables.
  306. * Alignment Output::     Pseudo ops for alignment and skipping data.
  307. File: gcc.info,  Node: File Framework,  Next: Data Output,  Up: Assembler Format
  308. The Overall Framework of an Assembler File
  309. ------------------------------------------
  310. `ASM_FILE_START (STREAM)'
  311.      A C expression which outputs to the stdio stream STREAM some
  312.      appropriate text to go at the start of an assembler file.
  313.      Normally this macro is defined to output a line containing
  314.      `#NO_APP', which is a comment that has no effect on most
  315.      assemblers but tells the GNU assembler that it can save time by not
  316.      checking for certain assembler constructs.
  317.      On systems that use SDB, it is necessary to output certain
  318.      commands; see `attasm.h'.
  319. `ASM_FILE_END (STREAM)'
  320.      A C expression which outputs to the stdio stream STREAM some
  321.      appropriate text to go at the end of an assembler file.
  322.      If this macro is not defined, the default is to output nothing
  323.      special at the end of the file.  Most systems don't require any
  324.      definition.
  325.      On systems that use SDB, it is necessary to output certain
  326.      commands; see `attasm.h'.
  327. `ASM_IDENTIFY_GCC (FILE)'
  328.      A C statement to output assembler commands which will identify the
  329.      object file as having been compiled with GNU CC (or another GNU
  330.      compiler).
  331.      If you don't define this macro, the string `gcc_compiled.:' is
  332.      output.  This string is calculated to define a symbol which, on
  333.      BSD systems, will never be defined for any other reason. GDB
  334.      checks for the presence of this symbol when reading the symbol
  335.      table of an executable.
  336.      On non-BSD systems, you must arrange communication with GDB in
  337.      some other fashion.  If GDB is not used on your system, you can
  338.      define this macro with an empty body.
  339. `ASM_COMMENT_START'
  340.      A C string constant describing how to begin a comment in the target
  341.      assembler language.  The compiler assumes that the comment will
  342.      end at the end of the line.
  343. `ASM_APP_ON'
  344.      A C string constant for text to be output before each `asm'
  345.      statement or group of consecutive ones.  Normally this is
  346.      `"#APP"', which is a comment that has no effect on most assemblers
  347.      but tells the GNU assembler that it must check the lines that
  348.      follow for all valid assembler constructs.
  349. `ASM_APP_OFF'
  350.      A C string constant for text to be output after each `asm'
  351.      statement or group of consecutive ones.  Normally this is
  352.      `"#NO_APP"', which tells the GNU assembler to resume making the
  353.      time-saving assumptions that are valid for ordinary compiler
  354.      output.
  355. `ASM_OUTPUT_SOURCE_FILENAME (STREAM, NAME)'
  356.      A C statement to output COFF information or DWARF debugging
  357.      information which indicates that filename NAME is the current
  358.      source file to the stdio stream STREAM.
  359.      This macro need not be defined if the standard form of output for
  360.      the file format in use is appropriate.
  361. `ASM_OUTPUT_SOURCE_LINE (STREAM, LINE)'
  362.      A C statement to output DBX or SDB debugging information before
  363.      code for line number LINE of the current source file to the stdio
  364.      stream STREAM.
  365.      This macro need not be defined if the standard form of debugging
  366.      information for the debugger in use is appropriate.
  367. `ASM_OUTPUT_IDENT (STREAM, STRING)'
  368.      A C statement to output something to the assembler file to handle a
  369.      `#ident' directive containing the text STRING.  If this macro is
  370.      not defined, nothing is output for a `#ident' directive.
  371. `OBJC_PROLOGUE'
  372.      A C statement to output any assembler statements which are
  373.      required to precede any Objective C object definitions or message
  374.      sending.  The statement is executed only when compiling an
  375.      Objective C program.
  376. File: gcc.info,  Node: Data Output,  Next: Uninitialized Data,  Prev: File Framework,  Up: Assembler Format
  377. Output of Data
  378. --------------
  379. `ASM_OUTPUT_LONG_DOUBLE (STREAM, VALUE)'
  380. `ASM_OUTPUT_DOUBLE (STREAM, VALUE)'
  381. `ASM_OUTPUT_FLOAT (STREAM, VALUE)'
  382.      A C statement to output to the stdio stream STREAM an assembler
  383.      instruction to assemble a floating-point constant of `TFmode',
  384.      `DFmode' or `SFmode', respectively, whose value is VALUE.  VALUE
  385.      will be a C expression of type `REAL_VALUE__TYPE', usually
  386.      `double'.
  387. `ASM_OUTPUT_QUADRUPLE_INT (STREAM, EXP)'
  388. `ASM_OUTPUT_DOUBLE_INT (STREAM, EXP)'
  389. `ASM_OUTPUT_INT (STREAM, EXP)'
  390. `ASM_OUTPUT_SHORT (STREAM, EXP)'
  391. `ASM_OUTPUT_CHAR (STREAM, EXP)'
  392.      A C statement to output to the stdio stream STREAM an assembler
  393.      instruction to assemble an integer of 16, 8, 4, 2 or 1 bytes,
  394.      respectively, whose value is VALUE.  The argument EXP will be an
  395.      RTL expression which represents a constant value.  Use
  396.      `output_addr_const (STREAM, EXP)' to output this value as an
  397.      assembler expression.
  398.      For sizes larger than `UNITS_PER_WORD', if the action of a macro
  399.      would be identical to repeatedly calling the macro corresponding to
  400.      a size of `UNITS_PER_WORD', once for each word, you need not define
  401.      the macro.
  402. `ASM_OUTPUT_BYTE (STREAM, VALUE)'
  403.      A C statement to output to the stdio stream STREAM an assembler
  404.      instruction to assemble a single byte containing the number VALUE.
  405. `ASM_BYTE_OP'
  406.      A C string constant giving the pseudo-op to use for a sequence of
  407.      single-byte constants.  If this macro is not defined, the default
  408.      is `"byte"'.
  409. `ASM_OUTPUT_ASCII (STREAM, PTR, LEN)'
  410.      A C statement to output to the stdio stream STREAM an assembler
  411.      instruction to assemble a string constant containing the LEN bytes
  412.      at PTR.  PTR will be a C expression of type `char *' and LEN a C
  413.      expression of type `int'.
  414.      If the assembler has a `.ascii' pseudo-op as found in the Berkeley
  415.      Unix assembler, do not define the macro `ASM_OUTPUT_ASCII'.
  416. `ASM_OUTPUT_POOL_PROLOGUE (FILE FUNNAME FUNDECL SIZE)'
  417.      A C statement to output assembler commands to define the start of
  418.      the constant pool for a function.  FUNNAME is a string giving the
  419.      name of the function.  Should the return type of the function be
  420.      required, it can be obtained via FUNDECL.  SIZE is the size, in
  421.      bytes, of the constant pool that will be written immediately after
  422.      this call.
  423.      If no constant-pool prefix is required, the usual case, this macro
  424.      need not be defined.
  425. `ASM_OUTPUT_SPECIAL_POOL_ENTRY (FILE, X, MODE, ALIGN, LABELNO, JUMPTO)'
  426.      A C statement (with or without semicolon) to output a constant in
  427.      the constant pool, if it needs special treatment.  (This macro
  428.      need not do anything for RTL expressions that can be output
  429.      normally.)
  430.      The argument FILE is the standard I/O stream to output the
  431.      assembler code on.  X is the RTL expression for the constant to
  432.      output, and MODE is the machine mode (in case X is a `const_int').
  433.       ALIGN is the required alignment for the value X; you should
  434.      output an assembler directive to force this much alignment.
  435.      The argument LABELNO is a number to use in an internal label for
  436.      the address of this pool entry.  The definition of this macro is
  437.      responsible for outputting the label definition at the proper
  438.      place. Here is how to do this:
  439.           ASM_OUTPUT_INTERNAL_LABEL (FILE, "LC", LABELNO);
  440.      When you output a pool entry specially, you should end with a
  441.      `goto' to the label JUMPTO.  This will prevent the same pool entry
  442.      from being output a second time in the usual manner.
  443.      You need not define this macro if it would do nothing.
  444. `ASM_OPEN_PAREN'
  445. `ASM_CLOSE_PAREN'
  446.      These macros are defined as C string constant, describing the
  447.      syntax in the assembler for grouping arithmetic expressions.  The
  448.      following definitions are correct for most assemblers:
  449.           #define ASM_OPEN_PAREN "("
  450.           #define ASM_CLOSE_PAREN ")"
  451. File: gcc.info,  Node: Uninitialized Data,  Next: Label Output,  Prev: Data Output,  Up: Assembler Format
  452. Output of Uninitialized Variables
  453. ---------------------------------
  454.    Each of the macros in this section is used to do the whole job of
  455. outputting a single uninitialized variable.
  456. `ASM_OUTPUT_COMMON (STREAM, NAME, SIZE, ROUNDED)'
  457.      A C statement (sans semicolon) to output to the stdio stream
  458.      STREAM the assembler definition of a common-label named NAME whose
  459.      size is SIZE bytes.  The variable ROUNDED is the size rounded up
  460.      to whatever alignment the caller wants.
  461.      Use the expression `assemble_name (STREAM, NAME)' to output the
  462.      name itself; before and after that, output the additional
  463.      assembler syntax for defining the name, and a newline.
  464.      This macro controls how the assembler definitions of uninitialized
  465.      global variables are output.
  466. `ASM_OUTPUT_ALIGNED_COMMON (STREAM, NAME, SIZE, ALIGNMENT)'
  467.      Like `ASM_OUTPUT_COMMON' except takes the required alignment as a
  468.      separate, explicit argument.  If you define this macro, it is used
  469.      in place of `ASM_OUTPUT_COMMON', and gives you more flexibility in
  470.      handling the required alignment of the variable.
  471. `ASM_OUTPUT_SHARED_COMMON (STREAM, NAME, SIZE, ROUNDED)'
  472.      If defined, it is similar to `ASM_OUTPUT_COMMON', except that it
  473.      is used when NAME is shared.  If not defined, `ASM_OUTPUT_COMMON'
  474.      will be used.
  475. `ASM_OUTPUT_LOCAL (STREAM, NAME, SIZE, ROUNDED)'
  476.      A C statement (sans semicolon) to output to the stdio stream
  477.      STREAM the assembler definition of a local-common-label named NAME
  478.      whose size is SIZE bytes.  The variable ROUNDED is the size
  479.      rounded up to whatever alignment the caller wants.
  480.      Use the expression `assemble_name (STREAM, NAME)' to output the
  481.      name itself; before and after that, output the additional
  482.      assembler syntax for defining the name, and a newline.
  483.      This macro controls how the assembler definitions of uninitialized
  484.      static variables are output.
  485. `ASM_OUTPUT_ALIGNED_LOCAL (STREAM, NAME, SIZE, ALIGNMENT)'
  486.      Like `ASM_OUTPUT_LOCAL' except takes the required alignment as a
  487.      separate, explicit argument.  If you define this macro, it is used
  488.      in place of `ASM_OUTPUT_LOCAL', and gives you more flexibility in
  489.      handling the required alignment of the variable.
  490. `ASM_OUTPUT_SHARED_LOCAL (STREAM, NAME, SIZE, ROUNDED)'
  491.      If defined, it is similar to `ASM_OUTPUT_LOCAL', except that it is
  492.      used when NAME is shared.  If not defined, `ASM_OUTPUT_LOCAL' will
  493.      be used.
  494. File: gcc.info,  Node: Label Output,  Next: Initialization,  Prev: Uninitialized Data,  Up: Assembler Format
  495. Output and Generation of Labels
  496. -------------------------------
  497. `ASM_OUTPUT_LABEL (STREAM, NAME)'
  498.      A C statement (sans semicolon) to output to the stdio stream
  499.      STREAM the assembler definition of a label named NAME. Use the
  500.      expression `assemble_name (STREAM, NAME)' to output the name
  501.      itself; before and after that, output the additional assembler
  502.      syntax for defining the name, and a newline.
  503. `ASM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL)'
  504.      A C statement (sans semicolon) to output to the stdio stream
  505.      STREAM any text necessary for declaring the name NAME of a
  506.      function which is being defined.  This macro is responsible for
  507.      outputting the label definition (perhaps using
  508.      `ASM_OUTPUT_LABEL').  The argument DECL is the `FUNCTION_DECL'
  509.      tree node representing the function.
  510.      If this macro is not defined, then the function name is defined in
  511.      the usual manner as a label (by means of `ASM_OUTPUT_LABEL').
  512. `ASM_DECLARE_FUNCTION_SIZE (STREAM, NAME, DECL)'
  513.      A C statement (sans semicolon) to output to the stdio stream
  514.      STREAM any text necessary for declaring the size of a function
  515.      which is being defined.  The argument NAME is the name of the
  516.      function.  The argument DECL is the `FUNCTION_DECL' tree node
  517.      representing the function.
  518.      If this macro is not defined, then the function size is not
  519.      defined.
  520. `ASM_DECLARE_OBJECT_NAME (STREAM, NAME, DECL)'
  521.      A C statement (sans semicolon) to output to the stdio stream
  522.      STREAM any text necessary for declaring the name NAME of an
  523.      initialized variable which is being defined.  This macro must
  524.      output the label definition (perhaps using `ASM_OUTPUT_LABEL'). 
  525.      The argument DECL is the `VAR_DECL' tree node representing the
  526.      variable.
  527.      If this macro is not defined, then the variable name is defined in
  528.      the usual manner as a label (by means of `ASM_OUTPUT_LABEL').
  529. `ASM_GLOBALIZE_LABEL (STREAM, NAME)'
  530.      A C statement (sans semicolon) to output to the stdio stream
  531.      STREAM some commands that will make the label NAME global; that
  532.      is, available for reference from other files.  Use the expression
  533.      `assemble_name (STREAM, NAME)' to output the name itself; before
  534.      and after that, output the additional assembler syntax for making
  535.      that name global, and a newline.
  536. `ASM_OUTPUT_EXTERNAL (STREAM, DECL, NAME)'
  537.      A C statement (sans semicolon) to output to the stdio stream
  538.      STREAM any text necessary for declaring the name of an external
  539.      symbol named NAME which is referenced in this compilation but not
  540.      defined.  The value of DECL is the tree node for the declaration.
  541.      This macro need not be defined if it does not need to output
  542.      anything. The GNU assembler and most Unix assemblers don't require
  543.      anything.
  544. `ASM_OUTPUT_EXTERNAL_LIBCALL (STREAM, SYMREF)'
  545.      A C statement (sans semicolon) to output on STREAM an assembler
  546.      pseudo-op to declare a library function name external.  The name
  547.      of the library function is given by SYMREF, which has type `rtx'
  548.      and is a `symbol_ref'.
  549.      This macro need not be defined if it does not need to output
  550.      anything. The GNU assembler and most Unix assemblers don't require
  551.      anything.
  552. `ASM_OUTPUT_LABELREF (STREAM, NAME)'
  553.      A C statement (sans semicolon) to output to the stdio stream
  554.      STREAM a reference in assembler syntax to a label named NAME. 
  555.      This should add `_' to the front of the name, if that is customary
  556.      on your operating system, as it is in most Berkeley Unix systems. 
  557.      This macro is used in `assemble_name'.
  558. `ASM_OUTPUT_LABELREF_AS_INT (FILE, LABEL)'
  559.      Define this macro for systems that use the program `collect2'. The
  560.      definition should be a C statement to output a word containing a
  561.      reference to the label LABEL.
  562. `ASM_OUTPUT_INTERNAL_LABEL (STREAM, PREFIX, NUM)'
  563.      A C statement to output to the stdio stream STREAM a label whose
  564.      name is made from the string PREFIX and the number NUM.
  565.      It is absolutely essential that these labels be distinct from the
  566.      labels used for user-level functions and variables.  Otherwise,
  567.      certain programs will have name conflicts with internal labels.
  568.      It is desirable to exclude internal labels from the symbol table
  569.      of the object file.  Most assemblers have a naming convention for
  570.      labels that should be excluded; on many systems, the letter `L' at
  571.      the beginning of a label has this effect.  You should find out what
  572.      convention your system uses, and follow it.
  573.      The usual definition of this macro is as follows:
  574.           fprintf (STREAM, "L%s%d:\n", PREFIX, NUM)
  575. `ASM_GENERATE_INTERNAL_LABEL (STRING, PREFIX, NUM)'
  576.      A C statement to store into the string STRING a label whose name
  577.      is made from the string PREFIX and the number NUM.
  578.      This string, when output subsequently by `assemble_name', should
  579.      produce the same output that `ASM_OUTPUT_INTERNAL_LABEL' would
  580.      produce with the same PREFIX and NUM.
  581.      If the string begins with `*', then `assemble_name' will output
  582.      the rest of the string unchanged.  It is often convenient for
  583.      `ASM_GENERATE_INTERNAL_LABEL' to use `*' in this way.  If the
  584.      string doesn't start with `*', then `ASM_OUTPUT_LABELREF' gets to
  585.      output the string, and may change it.  (Of course,
  586.      `ASM_OUTPUT_LABELREF' is also part of your machine description, so
  587.      you should know what it does on your machine.)
  588. `ASM_FORMAT_PRIVATE_NAME (OUTVAR, NAME, NUMBER)'
  589.      A C expression to assign to OUTVAR (which is a variable of type
  590.      `char *') a newly allocated string made from the string NAME and
  591.      the number NUMBER, with some suitable punctuation added.  Use
  592.      `alloca' to get space for the string.
  593.      This string will be used as the argument to `ASM_OUTPUT_LABELREF'
  594.      to produce an assembler label for an internal static variable whose
  595.      name is NAME.  Therefore, the string must be such as to result in
  596.      valid assembler code.  The argument NUMBER is different each time
  597.      this macro is executed; it prevents conflicts between
  598.      similarly-named internal static variables in different scopes.
  599.      Ideally this string should not be a valid C identifier, to prevent
  600.      any conflict with the user's own symbols.  Most assemblers allow
  601.      periods or percent signs in assembler symbols; putting at least
  602.      one of these between the name and the number will suffice.
  603. `OBJC_GEN_METHOD_LABEL (BUF, IS_INST, CLASS_NAME, CAT_NAME, SEL_NAME)'
  604.      Define this macro to override the default assembler names used for
  605.      Objective C methods.
  606.      The default name is a unique method number followed by the name of
  607.      the class (e.g. `_1_Foo').  For methods in categories, the name of
  608.      the category is also included in the assembler name (e.g.
  609.      `_1_Foo_Bar').
  610.      These names are safe on most systems, but make debugging difficult
  611.      since the method's selector is not present in the name. 
  612.      Therefore, particular systems define other ways of computing names.
  613.      BUF is an expression of type `char *' which gives you a buffer in
  614.      which to store the name; its length is as long as CLASS_NAME,
  615.      CAT_NAME and SEL_NAME put together, plus 50 characters extra.
  616.      The argument IS_INST specifies whether the method is an instance
  617.      method or a class method; CLASS_NAME is the name of the class;
  618.      CAT_NAME is the name of the category (or NULL if the method is not
  619.      in a category); and SEL_NAME is the name of the selector.
  620.      On systems where the assembler can handle quoted names, you can
  621.      use this macro to provide more human-readable names.
  622. File: gcc.info,  Node: Initialization,  Next: Macros for Initialization,  Prev: Label Output,  Up: Assembler Format
  623. How Initialization Functions Are Handled
  624. ----------------------------------------
  625.    The compiled code for certain languages includes "constructors"
  626. (also called "initialization routines")--functions to initialize data
  627. in the program when the program is started.  These functions need to be
  628. called before the program is "started"--that is to say, before `main'
  629. is called.
  630.    Compiling some languages generates "destructors" (also called
  631. "termination routines") that should be called when the program
  632. terminates.
  633.    To make the initialization and termination functions work, the
  634. compiler must output something in the assembler code to cause those
  635. functions to be called at the appropriate time.  When you port the
  636. compiler to a new system, you need to specify how to do this.
  637.    There are two major ways that GCC currently supports the execution of
  638. initialization and termination functions.  Each way has two variants.
  639. Much of the structure is common to all four variations.
  640.    The linker must build two lists of these functions--a list of
  641. initialization functions, called `__CTOR_LIST__', and a list of
  642. termination functions, called `__DTOR_LIST__'.
  643.    Each list always begins with an ignored function pointer (which may
  644. hold 0, -1, or a count of the function pointers after it, depending on
  645. the environment).  This is followed by a series of zero or more function
  646. pointers to constructors (or destructors), followed by a function
  647. pointer containing zero.
  648.    Depending on the operating system and its executable file format,
  649. either `crtstuff.c' or `libgcc2.c' traverses these lists at startup
  650. time and exit time.  Constructors are called in forward order of the
  651. list; destructors in reverse order.
  652.    The best way to handle static constructors works only for object file
  653. formats which provide arbitrarily-named sections.  A section is set
  654. aside for a list of constructors, and another for a list of destructors.
  655. Traditionally these are called `.ctors' and `.dtors'.  Each object file
  656. that defines an initialization function also puts a word in the
  657. constructor section to point to that function.  The linker accumulates
  658. all these words into one contiguous `.ctors' section. Termination
  659. functions are handled similarly.
  660.    To use this method, you need appropriate definitions of the macros
  661. `ASM_OUTPUT_CONSTRUCTOR' and `ASM_OUTPUT_DESTRUCTOR'.  Usually you can
  662. get them by including `svr4.h'.
  663.    When arbitrary sections are available, there are two variants,
  664. depending upon how the code in `crtstuff.c' is called.  On systems that
  665. support an "init" section which is executed at program startup, parts
  666. of `crtstuff.c' are compiled into that section.  The program is linked
  667. by the `gcc' driver like this:
  668.      ld -o OUTPUT_FILE crtbegin.o ... crtend.o -lgcc
  669.    The head of a function (`__do_global_ctors') appears in the init
  670. section of `crtbegin.o'; the remainder of the function appears in the
  671. init section of `crtend.o'.  The linker will pull these two parts of
  672. the section together, making a whole function.  If any of the user's
  673. object files linked into the middle of it contribute code, then that
  674. code will be executed as part of the body of `__do_global_ctors'.
  675.    To use this variant, you must define the `INIT_SECTION_ASM_OP' macro
  676. properly.
  677.    If no init section is available, do not define
  678. `INIT_SECTION_ASM_OP'.  Then `__do_global_ctors' is built into the text
  679. section like all other functions, and resides in `libgcc.a'.  When GCC
  680. compiles any function called `main', it inserts a procedure call to
  681. `__main' as the first executable code after the function prologue.  The
  682. `__main' function, also defined in `libgcc2.c', simply calls
  683. `__do_global_ctors'.
  684.    In file formats that don't support arbitrary sections, there are
  685. again two variants.  In the simplest variant, the GNU linker (GNU `ld')
  686. and an `a.out' format must be used.  In this case,
  687. `ASM_OUTPUT_CONSTRUCTOR' is defined to produce a `.stabs' entry of type
  688. `N_SETT', referencing the name `__CTOR_LIST__', and with the address of
  689. the void function containing the initialization code as its value.  The
  690. GNU linker recognizes this as a request to add the value to a "set";
  691. the values are accumulated, and are eventually placed in the executable
  692. as a vector in the format described above, with a leading (ignored)
  693. count and a trailing zero element. `ASM_OUTPUT_DESTRUCTOR' is handled
  694. similarly.  Since no init section is available, the absence of
  695. `INIT_SECTION_ASM_OP' causes the compilation of `main' to call `__main'
  696. as above, starting the initialization process.
  697.    The last variant uses neither arbitrary sections nor the GNU linker.
  698. This is preferable when you want to do dynamic linking and when using
  699. file formats which the GNU linker does not support, such as `ECOFF'.  In
  700. this case, `ASM_OUTPUT_CONSTRUCTOR' does not produce an `N_SETT'
  701. symbol; initialization and termination functions are recognized simply
  702. by their names.  This requires an extra program in the linkage step,
  703. called `collect2'.  This program pretends to be the linker, for use
  704. with GNU CC; it does its job by running the ordinary linker, but also
  705. arranges to include the vectors of initialization and termination
  706. functions.  These functions are called via `__main' as described above.
  707.    Choosing among these configuration options has been simplified by a
  708. set of operating-system-dependent files in the `config' subdirectory.
  709. These files define all of the relevant parameters.  Usually it is
  710. sufficient to include one into your specific machine-dependent
  711. configuration file.  These files are:
  712. `aoutos.h'
  713.      For operating systems using the `a.out' format.
  714. `next.h'
  715.      For operating systems using the `MachO' format.
  716. `svr3.h'
  717.      For System V Release 3 and similar systems using `COFF' format.
  718. `svr4.h'
  719.      For System V Release 4 and similar systems using `ELF' format.
  720. `vms.h'
  721.      For the VMS operating system.
  722.    The following section describes the specific macros that control and
  723. customize the handling of initialization and termination functions.
  724. File: gcc.info,  Node: Macros for Initialization,  Next: Instruction Output,  Prev: Initialization,  Up: Assembler Format
  725. Macros Controlling Initialization Routines
  726. ------------------------------------------
  727.    Here are the macros that control how the compiler handles
  728. initialization and termination functions:
  729. `INIT_SECTION_ASM_OP'
  730.      If defined, a C string constant for the assembler operation to
  731.      identify the following data as initialization code.  If not
  732.      defined, GNU CC will assume such a section does not exist.  When
  733.      you are using special sections for initialization and termination
  734.      functions, this macro also controls how `crtstuff.c' and
  735.      `libgcc2.c' arrange to run the initialization functions.
  736. `ASM_OUTPUT_CONSTRUCTOR (STREAM, NAME)'
  737.      Define this macro as a C statement to output on the stream STREAM
  738.      the assembler code to arrange to call the function named NAME at
  739.      initialization time.
  740.      Assume that NAME is the name of a C function generated
  741.      automatically by the compiler.  This function takes no arguments. 
  742.      Use the function `assemble_name' to output the name NAME; this
  743.      performs any system-specific syntactic transformations such as
  744.      adding an underscore.
  745.      If you don't define this macro, nothing special is output to
  746.      arrange to call the function.  This is correct when the function
  747.      will be called in some other manner--for example, by means of the
  748.      `collect2' program, which looks through the symbol table to find
  749.      these functions by their names.  If you want to use `collect2',
  750.      then you need to arrange for it to be built and installed and used
  751.      on your system.
  752. `ASM_OUTPUT_DESTRUCTOR (STREAM, NAME)'
  753.      This is like `ASM_OUTPUT_CONSTRUCTOR' but used for termination
  754.      functions rather than initialization functions.
  755.    If your system uses `collect2' as the means of processing
  756. constructors, then that program normally uses `nm' to scan an object
  757. file for constructor functions to be called.  On certain kinds of
  758. systems, you can define these macros to make `collect2' work faster
  759. (and, in some cases, make it work at all):
  760. `OBJECT_FORMAT_COFF'
  761.      Define this macro if the system uses COFF (Common Object File
  762.      Format) object files, so that `collect2' can assume this format
  763.      and scan object files directly for dynamic constructor/destructor
  764.      functions.
  765. `OBJECT_FORMAT_ROSE'
  766.      Define this macro if the system uses ROSE format object files, so
  767.      that `collect2' can assume this format and scan object files
  768.      directly for dynamic constructor/destructor functions.
  769.    These macros are effective only in a native compiler; `collect2' as
  770. part of a cross compiler always uses `nm'.
  771. `REAL_NM_FILE_NAME'
  772.      Define this macro as a C string constant containing the file name
  773.      to use to execute `nm'.  The default is to search the path
  774.      normally for `nm'.
  775.