home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / gcc.info-13 (.txt) < prev    next >
GNU Info File  |  1995-11-26  |  49KB  |  831 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  5. Boston, MA 02111-1307 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995 Free Software
  7. Foundation, Inc.
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided also
  13. that the sections entitled "GNU General Public License," "Funding for
  14. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  15. included exactly as in the original, and provided that the entire
  16. resulting derived work is distributed under the terms of a permission
  17. notice identical to this one.
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions, except that the sections entitled "GNU General Public
  21. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  22. `Look And Feel'", and this permission notice, may be included in
  23. translations approved by the Free Software Foundation instead of in the
  24. original English.
  25. File: gcc.info,  Node: VMS Misc,  Prev: Global Declarations,  Up: VMS
  26. Other VMS Issues
  27. ================
  28.    GNU CC automatically arranges for `main' to return 1 by default if
  29. you fail to specify an explicit return value.  This will be interpreted
  30. by VMS as a status code indicating a normal successful completion.
  31. Version 1 of GNU CC did not provide this default.
  32.    GNU CC on VMS works only with the GNU assembler, GAS.  You need
  33. version 1.37 or later of GAS in order to produce value debugging
  34. information for the VMS debugger.  Use the ordinary VMS linker with the
  35. object files produced by GAS.
  36.    Under previous versions of GNU CC, the generated code would
  37. occasionally give strange results when linked to the sharable `VAXCRTL'
  38. library.  Now this should work.
  39.    A caveat for use of `const' global variables: the `const' modifier
  40. must be specified in every external declaration of the variable in all
  41. of the source files that use that variable.  Otherwise the linker will
  42. issue warnings about conflicting attributes for the variable.  Your
  43. program will still work despite the warnings, but the variable will be
  44. placed in writable storage.
  45.    Although the VMS linker does distinguish between upper and lower case
  46. letters in global symbols, most VMS compilers convert all such symbols
  47. into upper case and most run-time library routines also have upper case
  48. names.  To be able to reliably call such routines, GNU CC (by means of
  49. the assembler GAS) converts global symbols into upper case like other
  50. VMS compilers.  However, since the usual practice in C is to distinguish
  51. case, GNU CC (via GAS) tries to preserve usual C behavior by augmenting
  52. each name that is not all lower case.  This means truncating the name
  53. to at most 23 characters and then adding more characters at the end
  54. which encode the case pattern of those 23.   Names which contain at
  55. least one dollar sign are an exception; they are converted directly into
  56. upper case without augmentation.
  57.    Name augmentation yields bad results for programs that use
  58. precompiled libraries (such as Xlib) which were generated by another
  59. compiler.  You can use the compiler option `/NOCASE_HACK' to inhibit
  60. augmentation; it makes external C functions and variables
  61. case-independent as is usual on VMS.  Alternatively, you could write
  62. all references to the functions and variables in such libraries using
  63. lower case; this will work on VMS, but is not portable to other
  64. systems.  The compiler option `/NAMES' also provides control over
  65. global name handling.
  66.    Function and variable names are handled somewhat differently with GNU
  67. C++.  The GNU C++ compiler performs "name mangling" on function names,
  68. which means that it adds information to the function name to describe
  69. the data types of the arguments that the function takes.  One result of
  70. this is that the name of a function can become very long.  Since the
  71. VMS linker only recognizes the first 31 characters in a name, special
  72. action is taken to ensure that each function and variable has a unique
  73. name that can be represented in 31 characters.
  74.    If the name (plus a name augmentation, if required) is less than 32
  75. characters in length, then no special action is performed.  If the name
  76. is longer than 31 characters, the assembler (GAS) will generate a hash
  77. string based upon the function name, truncate the function name to 23
  78. characters, and append the hash string to the truncated name.  If the
  79. `/VERBOSE' compiler option is used, the assembler will print both the
  80. full and truncated names of each symbol that is truncated.
  81.    The `/NOCASE_HACK' compiler option should not be used when you are
  82. compiling programs that use libg++.  libg++ has several instances of
  83. objects (i.e.  `Filebuf' and `filebuf') which become indistinguishable
  84. in a case-insensitive environment.  This leads to cases where you need
  85. to inhibit augmentation selectively (if you were using libg++ and Xlib
  86. in the same program, for example).  There is no special feature for
  87. doing this, but you can get the result by defining a macro for each
  88. mixed case symbol for which you wish to inhibit augmentation.  The
  89. macro should expand into the lower case equivalent of itself.  For
  90. example:
  91.      #define StuDlyCapS studlycaps
  92.    These macro definitions can be placed in a header file to minimize
  93. the number of changes to your source code.
  94. File: gcc.info,  Node: Portability,  Next: Interface,  Prev: VMS,  Up: Top
  95. GNU CC and Portability
  96. **********************
  97.    The main goal of GNU CC was to make a good, fast compiler for
  98. machines in the class that the GNU system aims to run on: 32-bit
  99. machines that address 8-bit bytes and have several general registers.
  100. Elegance, theoretical power and simplicity are only secondary.
  101.    GNU CC gets most of the information about the target machine from a
  102. machine description which gives an algebraic formula for each of the
  103. machine's instructions.  This is a very clean way to describe the
  104. target.  But when the compiler needs information that is difficult to
  105. express in this fashion, I have not hesitated to define an ad-hoc
  106. parameter to the machine description.  The purpose of portability is to
  107. reduce the total work needed on the compiler; it was not of interest
  108. for its own sake.
  109.    GNU CC does not contain machine dependent code, but it does contain
  110. code that depends on machine parameters such as endianness (whether the
  111. most significant byte has the highest or lowest address of the bytes in
  112. a word) and the availability of autoincrement addressing.  In the
  113. RTL-generation pass, it is often necessary to have multiple strategies
  114. for generating code for a particular kind of syntax tree, strategies
  115. that are usable for different combinations of parameters.  Often I have
  116. not tried to address all possible cases, but only the common ones or
  117. only the ones that I have encountered.  As a result, a new target may
  118. require additional strategies.  You will know if this happens because
  119. the compiler will call `abort'.  Fortunately, the new strategies can be
  120. added in a machine-independent fashion, and will affect only the target
  121. machines that need them.
  122. File: gcc.info,  Node: Interface,  Next: Passes,  Prev: Portability,  Up: Top
  123. Interfacing to GNU CC Output
  124. ****************************
  125.    GNU CC is normally configured to use the same function calling
  126. convention normally in use on the target system.  This is done with the
  127. machine-description macros described (*note Target Macros::.).
  128.    However, returning of structure and union values is done differently
  129. on some target machines.  As a result, functions compiled with PCC
  130. returning such types cannot be called from code compiled with GNU CC,
  131. and vice versa.  This does not cause trouble often because few Unix
  132. library routines return structures or unions.
  133.    GNU CC code returns structures and unions that are 1, 2, 4 or 8 bytes
  134. long in the same registers used for `int' or `double' return values.
  135. (GNU CC typically allocates variables of such types in registers also.)
  136. Structures and unions of other sizes are returned by storing them into
  137. an address passed by the caller (usually in a register).  The
  138. machine-description macros `STRUCT_VALUE' and `STRUCT_INCOMING_VALUE'
  139. tell GNU CC where to pass this address.
  140.    By contrast, PCC on most target machines returns structures and
  141. unions of any size by copying the data into an area of static storage,
  142. and then returning the address of that storage as if it were a pointer
  143. value.  The caller must copy the data from that memory area to the
  144. place where the value is wanted.  This is slower than the method used
  145. by GNU CC, and fails to be reentrant.
  146.    On some target machines, such as RISC machines and the 80386, the
  147. standard system convention is to pass to the subroutine the address of
  148. where to return the value.  On these machines, GNU CC has been
  149. configured to be compatible with the standard compiler, when this method
  150. is used.  It may not be compatible for structures of 1, 2, 4 or 8 bytes.
  151.    GNU CC uses the system's standard convention for passing arguments.
  152. On some machines, the first few arguments are passed in registers; in
  153. others, all are passed on the stack.  It would be possible to use
  154. registers for argument passing on any machine, and this would probably
  155. result in a significant speedup.  But the result would be complete
  156. incompatibility with code that follows the standard convention.  So this
  157. change is practical only if you are switching to GNU CC as the sole C
  158. compiler for the system.  We may implement register argument passing on
  159. certain machines once we have a complete GNU system so that we can
  160. compile the libraries with GNU CC.
  161.    On some machines (particularly the Sparc), certain types of arguments
  162. are passed "by invisible reference".  This means that the value is
  163. stored in memory, and the address of the memory location is passed to
  164. the subroutine.
  165.    If you use `longjmp', beware of automatic variables.  ANSI C says
  166. that automatic variables that are not declared `volatile' have undefined
  167. values after a `longjmp'.  And this is all GNU CC promises to do,
  168. because it is very difficult to restore register variables correctly,
  169. and one of GNU CC's features is that it can put variables in registers
  170. without your asking it to.
  171.    If you want a variable to be unaltered by `longjmp', and you don't
  172. want to write `volatile' because old C compilers don't accept it, just
  173. take the address of the variable.  If a variable's address is ever
  174. taken, even if just to compute it and ignore it, then the variable
  175. cannot go in a register:
  176.      {
  177.        int careful;
  178.        &careful;
  179.        ...
  180.      }
  181.    Code compiled with GNU CC may call certain library routines.  Most of
  182. them handle arithmetic for which there are no instructions.  This
  183. includes multiply and divide on some machines, and floating point
  184. operations on any machine for which floating point support is disabled
  185. with `-msoft-float'.  Some standard parts of the C library, such as
  186. `bcopy' or `memcpy', are also called automatically.  The usual function
  187. call interface is used for calling the library routines.
  188.    These library routines should be defined in the library `libgcc.a',
  189. which GNU CC automatically searches whenever it links a program.  On
  190. machines that have multiply and divide instructions, if hardware
  191. floating point is in use, normally `libgcc.a' is not needed, but it is
  192. searched just in case.
  193.    Each arithmetic function is defined in `libgcc1.c' to use the
  194. corresponding C arithmetic operator.  As long as the file is compiled
  195. with another C compiler, which supports all the C arithmetic operators,
  196. this file will work portably.  However, `libgcc1.c' does not work if
  197. compiled with GNU CC, because each arithmetic function would compile
  198. into a call to itself!
  199. File: gcc.info,  Node: Passes,  Next: RTL,  Prev: Interface,  Up: Top
  200. Passes and Files of the Compiler
  201. ********************************
  202.    The overall control structure of the compiler is in `toplev.c'.  This
  203. file is responsible for initialization, decoding arguments, opening and
  204. closing files, and sequencing the passes.
  205.    The parsing pass is invoked only once, to parse the entire input.
  206. The RTL intermediate code for a function is generated as the function
  207. is parsed, a statement at a time.  Each statement is read in as a
  208. syntax tree and then converted to RTL; then the storage for the tree
  209. for the statement is reclaimed.  Storage for types (and the expressions
  210. for their sizes), declarations, and a representation of the binding
  211. contours and how they nest, remain until the function is finished being
  212. compiled; these are all needed to output the debugging information.
  213.    Each time the parsing pass reads a complete function definition or
  214. top-level declaration, it calls either the function
  215. `rest_of_compilation', or the function `rest_of_decl_compilation' in
  216. `toplev.c', which are responsible for all further processing necessary,
  217. ending with output of the assembler language.  All other compiler
  218. passes run, in sequence, within `rest_of_compilation'.  When that
  219. function returns from compiling a function definition, the storage used
  220. for that function definition's compilation is entirely freed, unless it
  221. is an inline function (*note An Inline Function is As Fast As a Macro:
  222. Inline.).
  223.    Here is a list of all the passes of the compiler and their source
  224. files.  Also included is a description of where debugging dumps can be
  225. requested with `-d' options.
  226.    * Parsing.  This pass reads the entire text of a function definition,
  227.      constructing partial syntax trees.  This and RTL generation are no
  228.      longer truly separate passes (formerly they were), but it is
  229.      easier to think of them as separate.
  230.      The tree representation does not entirely follow C syntax, because
  231.      it is intended to support other languages as well.
  232.      Language-specific data type analysis is also done in this pass,
  233.      and every tree node that represents an expression has a data type
  234.      attached.  Variables are represented as declaration nodes.
  235.      Constant folding and some arithmetic simplifications are also done
  236.      during this pass.
  237.      The language-independent source files for parsing are
  238.      `stor-layout.c', `fold-const.c', and `tree.c'.  There are also
  239.      header files `tree.h' and `tree.def' which define the format of
  240.      the tree representation.
  241.      The source files to parse C are `c-parse.in', `c-decl.c',
  242.      `c-typeck.c', `c-aux-info.c', `c-convert.c', and `c-lang.c' along
  243.      with header files `c-lex.h', and `c-tree.h'.
  244.      The source files for parsing C++ are `cp-parse.y', `cp-class.c',
  245.      `cp-cvt.c', `cp-decl.c', `cp-decl2.c', `cp-dem.c', `cp-except.c',
  246.      `cp-expr.c', `cp-init.c', `cp-lex.c', `cp-method.c', `cp-ptree.c',
  247.      `cp-search.c', `cp-tree.c', `cp-type2.c', and `cp-typeck.c', along
  248.      with header files `cp-tree.def', `cp-tree.h', and `cp-decl.h'.
  249.      The special source files for parsing Objective C are
  250.      `objc-parse.y', `objc-actions.c', `objc-tree.def', and
  251.      `objc-actions.h'.  Certain C-specific files are used for this as
  252.      well.
  253.      The file `c-common.c' is also used for all of the above languages.
  254.    * RTL generation.  This is the conversion of syntax tree into RTL
  255.      code.  It is actually done statement-by-statement during parsing,
  256.      but for most purposes it can be thought of as a separate pass.
  257.      This is where the bulk of target-parameter-dependent code is found,
  258.      since often it is necessary for strategies to apply only when
  259.      certain standard kinds of instructions are available.  The purpose
  260.      of named instruction patterns is to provide this information to
  261.      the RTL generation pass.
  262.      Optimization is done in this pass for `if'-conditions that are
  263.      comparisons, boolean operations or conditional expressions.  Tail
  264.      recursion is detected at this time also.  Decisions are made about
  265.      how best to arrange loops and how to output `switch' statements.
  266.      The source files for RTL generation include `stmt.c', `calls.c',
  267.      `expr.c', `explow.c', `expmed.c', `function.c', `optabs.c' and
  268.      `emit-rtl.c'.  Also, the file `insn-emit.c', generated from the
  269.      machine description by the program `genemit', is used in this
  270.      pass.  The header file `expr.h' is used for communication within
  271.      this pass.
  272.      The header files `insn-flags.h' and `insn-codes.h', generated from
  273.      the machine description by the programs `genflags' and `gencodes',
  274.      tell this pass which standard names are available for use and
  275.      which patterns correspond to them.
  276.      Aside from debugging information output, none of the following
  277.      passes refers to the tree structure representation of the function
  278.      (only part of which is saved).
  279.      The decision of whether the function can and should be expanded
  280.      inline in its subsequent callers is made at the end of rtl
  281.      generation.  The function must meet certain criteria, currently
  282.      related to the size of the function and the types and number of
  283.      parameters it has.  Note that this function may contain loops,
  284.      recursive calls to itself (tail-recursive functions can be
  285.      inlined!), gotos, in short, all constructs supported by GNU CC.
  286.      The file `integrate.c' contains the code to save a function's rtl
  287.      for later inlining and to inline that rtl when the function is
  288.      called.  The header file `integrate.h' is also used for this
  289.      purpose.
  290.      The option `-dr' causes a debugging dump of the RTL code after
  291.      this pass.  This dump file's name is made by appending `.rtl' to
  292.      the input file name.
  293.    * Jump optimization.  This pass simplifies jumps to the following
  294.      instruction, jumps across jumps, and jumps to jumps.  It deletes
  295.      unreferenced labels and unreachable code, except that unreachable
  296.      code that contains a loop is not recognized as unreachable in this
  297.      pass.  (Such loops are deleted later in the basic block analysis.)
  298.      It also converts some code originally written with jumps into
  299.      sequences of instructions that directly set values from the
  300.      results of comparisons, if the machine has such instructions.
  301.      Jump optimization is performed two or three times.  The first time
  302.      is immediately following RTL generation.  The second time is after
  303.      CSE, but only if CSE says repeated jump optimization is needed.
  304.      The last time is right before the final pass.  That time,
  305.      cross-jumping and deletion of no-op move instructions are done
  306.      together with the optimizations described above.
  307.      The source file of this pass is `jump.c'.
  308.      The option `-dj' causes a debugging dump of the RTL code after
  309.      this pass is run for the first time.  This dump file's name is
  310.      made by appending `.jump' to the input file name.
  311.    * Register scan.  This pass finds the first and last use of each
  312.      register, as a guide for common subexpression elimination.  Its
  313.      source is in `regclass.c'.
  314.    * Jump threading.  This pass detects a condition jump that branches
  315.      to an identical or inverse test.  Such jumps can be `threaded'
  316.      through the second conditional test.  The source code for this
  317.      pass is in `jump.c'.  This optimization is only performed if
  318.      `-fthread-jumps' is enabled.
  319.    * Common subexpression elimination.  This pass also does constant
  320.      propagation.  Its source file is `cse.c'.  If constant propagation
  321.      causes conditional jumps to become unconditional or to become
  322.      no-ops, jump optimization is run again when CSE is finished.
  323.      The option `-ds' causes a debugging dump of the RTL code after
  324.      this pass.  This dump file's name is made by appending `.cse' to
  325.      the input file name.
  326.    * Loop optimization.  This pass moves constant expressions out of
  327.      loops, and optionally does strength-reduction and loop unrolling
  328.      as well.  Its source files are `loop.c' and `unroll.c', plus the
  329.      header `loop.h' used for communication between them.  Loop
  330.      unrolling uses some functions in `integrate.c' and the header
  331.      `integrate.h'.
  332.      The option `-dL' causes a debugging dump of the RTL code after
  333.      this pass.  This dump file's name is made by appending `.loop' to
  334.      the input file name.
  335.    * If `-frerun-cse-after-loop' was enabled, a second common
  336.      subexpression elimination pass is performed after the loop
  337.      optimization pass.  Jump threading is also done again at this time
  338.      if it was specified.
  339.      The option `-dt' causes a debugging dump of the RTL code after
  340.      this pass.  This dump file's name is made by appending `.cse2' to
  341.      the input file name.
  342.    * Stupid register allocation is performed at this point in a
  343.      nonoptimizing compilation.  It does a little data flow analysis as
  344.      well.  When stupid register allocation is in use, the next pass
  345.      executed is the reloading pass; the others in between are skipped.
  346.      The source file is `stupid.c'.
  347.    * Data flow analysis (`flow.c').  This pass divides the program into
  348.      basic blocks (and in the process deletes unreachable loops); then
  349.      it computes which pseudo-registers are live at each point in the
  350.      program, and makes the first instruction that uses a value point at
  351.      the instruction that computed the value.
  352.      This pass also deletes computations whose results are never used,
  353.      and combines memory references with add or subtract instructions
  354.      to make autoincrement or autodecrement addressing.
  355.      The option `-df' causes a debugging dump of the RTL code after
  356.      this pass.  This dump file's name is made by appending `.flow' to
  357.      the input file name.  If stupid register allocation is in use, this
  358.      dump file reflects the full results of such allocation.
  359.    * Instruction combination (`combine.c').  This pass attempts to
  360.      combine groups of two or three instructions that are related by
  361.      data flow into single instructions.  It combines the RTL
  362.      expressions for the instructions by substitution, simplifies the
  363.      result using algebra, and then attempts to match the result
  364.      against the machine description.
  365.      The option `-dc' causes a debugging dump of the RTL code after
  366.      this pass.  This dump file's name is made by appending `.combine'
  367.      to the input file name.
  368.    * Instruction scheduling (`sched.c').  This pass looks for
  369.      instructions whose output will not be available by the time that
  370.      it is used in subsequent instructions.  (Memory loads and floating
  371.      point instructions often have this behavior on RISC machines).  It
  372.      re-orders instructions within a basic block to try to separate the
  373.      definition and use of items that otherwise would cause pipeline
  374.      stalls.
  375.      Instruction scheduling is performed twice.  The first time is
  376.      immediately after instruction combination and the second is
  377.      immediately after reload.
  378.      The option `-dS' causes a debugging dump of the RTL code after this
  379.      pass is run for the first time.  The dump file's name is made by
  380.      appending `.sched' to the input file name.
  381.    * Register class preferencing.  The RTL code is scanned to find out
  382.      which register class is best for each pseudo register.  The source
  383.      file is `regclass.c'.
  384.    * Local register allocation (`local-alloc.c').  This pass allocates
  385.      hard registers to pseudo registers that are used only within one
  386.      basic block.  Because the basic block is linear, it can use fast
  387.      and powerful techniques to do a very good job.
  388.      The option `-dl' causes a debugging dump of the RTL code after
  389.      this pass.  This dump file's name is made by appending `.lreg' to
  390.      the input file name.
  391.    * Global register allocation (`global.c').  This pass allocates hard
  392.      registers for the remaining pseudo registers (those whose life
  393.      spans are not contained in one basic block).
  394.    * Reloading.  This pass renumbers pseudo registers with the hardware
  395.      registers numbers they were allocated.  Pseudo registers that did
  396.      not get hard registers are replaced with stack slots.  Then it
  397.      finds instructions that are invalid because a value has failed to
  398.      end up in a register, or has ended up in a register of the wrong
  399.      kind.  It fixes up these instructions by reloading the
  400.      problematical values temporarily into registers.  Additional
  401.      instructions are generated to do the copying.
  402.      The reload pass also optionally eliminates the frame pointer and
  403.      inserts instructions to save and restore call-clobbered registers
  404.      around calls.
  405.      Source files are `reload.c' and `reload1.c', plus the header
  406.      `reload.h' used for communication between them.
  407.      The option `-dg' causes a debugging dump of the RTL code after
  408.      this pass.  This dump file's name is made by appending `.greg' to
  409.      the input file name.
  410.    * Instruction scheduling is repeated here to try to avoid pipeline
  411.      stalls due to memory loads generated for spilled pseudo registers.
  412.      The option `-dR' causes a debugging dump of the RTL code after
  413.      this pass.  This dump file's name is made by appending `.sched2'
  414.      to the input file name.
  415.    * Jump optimization is repeated, this time including cross-jumping
  416.      and deletion of no-op move instructions.
  417.      The option `-dJ' causes a debugging dump of the RTL code after
  418.      this pass.  This dump file's name is made by appending `.jump2' to
  419.      the input file name.
  420.    * Delayed branch scheduling.  This optional pass attempts to find
  421.      instructions that can go into the delay slots of other
  422.      instructions, usually jumps and calls.  The source file name is
  423.      `reorg.c'.
  424.      The option `-dd' causes a debugging dump of the RTL code after
  425.      this pass.  This dump file's name is made by appending `.dbr' to
  426.      the input file name.
  427.    * Conversion from usage of some hard registers to usage of a register
  428.      stack may be done at this point.  Currently, this is supported only
  429.      for the floating-point registers of the Intel 80387 coprocessor.
  430.      The source file name is `reg-stack.c'.
  431.      The options `-dk' causes a debugging dump of the RTL code after
  432.      this pass.  This dump file's name is made by appending `.stack' to
  433.      the input file name.
  434.    * Final.  This pass outputs the assembler code for the function.  It
  435.      is also responsible for identifying spurious test and compare
  436.      instructions.  Machine-specific peephole optimizations are
  437.      performed at the same time.  The function entry and exit sequences
  438.      are generated directly as assembler code in this pass; they never
  439.      exist as RTL.
  440.      The source files are `final.c' plus `insn-output.c'; the latter is
  441.      generated automatically from the machine description by the tool
  442.      `genoutput'.  The header file `conditions.h' is used for
  443.      communication between these files.
  444.    * Debugging information output.  This is run after final because it
  445.      must output the stack slot offsets for pseudo registers that did
  446.      not get hard registers.  Source files are `dbxout.c' for DBX
  447.      symbol table format, `sdbout.c' for SDB symbol table format, and
  448.      `dwarfout.c' for DWARF symbol table format.
  449.    Some additional files are used by all or many passes:
  450.    * Every pass uses `machmode.def' and `machmode.h' which define the
  451.      machine modes.
  452.    * Several passes use `real.h', which defines the default
  453.      representation of floating point constants and how to operate on
  454.      them.
  455.    * All the passes that work with RTL use the header files `rtl.h' and
  456.      `rtl.def', and subroutines in file `rtl.c'.  The tools `gen*' also
  457.      use these files to read and work with the machine description RTL.
  458.    * Several passes refer to the header file `insn-config.h' which
  459.      contains a few parameters (C macro definitions) generated
  460.      automatically from the machine description RTL by the tool
  461.      `genconfig'.
  462.    * Several passes use the instruction recognizer, which consists of
  463.      `recog.c' and `recog.h', plus the files `insn-recog.c' and
  464.      `insn-extract.c' that are generated automatically from the machine
  465.      description by the tools `genrecog' and `genextract'.
  466.    * Several passes use the header files `regs.h' which defines the
  467.      information recorded about pseudo register usage, and
  468.      `basic-block.h' which defines the information recorded about basic
  469.      blocks.
  470.    * `hard-reg-set.h' defines the type `HARD_REG_SET', a bit-vector
  471.      with a bit for each hard register, and some macros to manipulate
  472.      it.  This type is just `int' if the machine has few enough hard
  473.      registers; otherwise it is an array of `int' and some of the
  474.      macros expand into loops.
  475.    * Several passes use instruction attributes.  A definition of the
  476.      attributes defined for a particular machine is in file
  477.      `insn-attr.h', which is generated from the machine description by
  478.      the program `genattr'.  The file `insn-attrtab.c' contains
  479.      subroutines to obtain the attribute values for insns.  It is
  480.      generated from the machine description by the program `genattrtab'.
  481. File: gcc.info,  Node: RTL,  Next: Machine Desc,  Prev: Passes,  Up: Top
  482. RTL Representation
  483. ******************
  484.    Most of the work of the compiler is done on an intermediate
  485. representation called register transfer language.  In this language,
  486. the instructions to be output are described, pretty much one by one, in
  487. an algebraic form that describes what the instruction does.
  488.    RTL is inspired by Lisp lists.  It has both an internal form, made
  489. up of structures that point at other structures, and a textual form
  490. that is used in the machine description and in printed debugging dumps.
  491. The textual form uses nested parentheses to indicate the pointers in
  492. the internal form.
  493. * Menu:
  494. * RTL Objects::       Expressions vs vectors vs strings vs integers.
  495. * Accessors::         Macros to access expression operands or vector elts.
  496. * Flags::             Other flags in an RTL expression.
  497. * Machine Modes::     Describing the size and format of a datum.
  498. * Constants::         Expressions with constant values.
  499. * Regs and Memory::   Expressions representing register contents or memory.
  500. * Arithmetic::        Expressions representing arithmetic on other expressions.
  501. * Comparisons::       Expressions representing comparison of expressions.
  502. * Bit Fields::        Expressions representing bitfields in memory or reg.
  503. * Conversions::       Extending, truncating, floating or fixing.
  504. * RTL Declarations::  Declaring volatility, constancy, etc.
  505. * Side Effects::      Expressions for storing in registers, etc.
  506. * Incdec::            Embedded side-effects for autoincrement addressing.
  507. * Assembler::         Representing `asm' with operands.
  508. * Insns::             Expression types for entire insns.
  509. * Calls::             RTL representation of function call insns.
  510. * Sharing::           Some expressions are unique; others *must* be copied.
  511. * Reading RTL::       Reading textual RTL from a file.
  512. File: gcc.info,  Node: RTL Objects,  Next: Accessors,  Prev: RTL,  Up: RTL
  513. RTL Object Types
  514. ================
  515.    RTL uses five kinds of objects: expressions, integers, wide integers,
  516. strings and vectors.  Expressions are the most important ones.  An RTL
  517. expression ("RTX", for short) is a C structure, but it is usually
  518. referred to with a pointer; a type that is given the typedef name `rtx'.
  519.    An integer is simply an `int'; their written form uses decimal
  520. digits.  A wide integer is an integral object whose type is
  521. `HOST_WIDE_INT' (*note Config::.); their written form uses decimal
  522. digits.
  523.    A string is a sequence of characters.  In core it is represented as a
  524. `char *' in usual C fashion, and it is written in C syntax as well.
  525. However, strings in RTL may never be null.  If you write an empty
  526. string in a machine description, it is represented in core as a null
  527. pointer rather than as a pointer to a null character.  In certain
  528. contexts, these null pointers instead of strings are valid.  Within RTL
  529. code, strings are most commonly found inside `symbol_ref' expressions,
  530. but they appear in other contexts in the RTL expressions that make up
  531. machine descriptions.
  532.    A vector contains an arbitrary number of pointers to expressions.
  533. The number of elements in the vector is explicitly present in the
  534. vector.  The written form of a vector consists of square brackets
  535. (`[...]') surrounding the elements, in sequence and with whitespace
  536. separating them.  Vectors of length zero are not created; null pointers
  537. are used instead.
  538.    Expressions are classified by "expression codes" (also called RTX
  539. codes).  The expression code is a name defined in `rtl.def', which is
  540. also (in upper case) a C enumeration constant.  The possible expression
  541. codes and their meanings are machine-independent.  The code of an RTX
  542. can be extracted with the macro `GET_CODE (X)' and altered with
  543. `PUT_CODE (X, NEWCODE)'.
  544.    The expression code determines how many operands the expression
  545. contains, and what kinds of objects they are.  In RTL, unlike Lisp, you
  546. cannot tell by looking at an operand what kind of object it is.
  547. Instead, you must know from its context--from the expression code of
  548. the containing expression.  For example, in an expression of code
  549. `subreg', the first operand is to be regarded as an expression and the
  550. second operand as an integer.  In an expression of code `plus', there
  551. are two operands, both of which are to be regarded as expressions.  In
  552. a `symbol_ref' expression, there is one operand, which is to be
  553. regarded as a string.
  554.    Expressions are written as parentheses containing the name of the
  555. expression type, its flags and machine mode if any, and then the
  556. operands of the expression (separated by spaces).
  557.    Expression code names in the `md' file are written in lower case,
  558. but when they appear in C code they are written in upper case.  In this
  559. manual, they are shown as follows: `const_int'.
  560.    In a few contexts a null pointer is valid where an expression is
  561. normally wanted.  The written form of this is `(nil)'.
  562. File: gcc.info,  Node: Accessors,  Next: Flags,  Prev: RTL Objects,  Up: RTL
  563. Access to Operands
  564. ==================
  565.    For each expression type `rtl.def' specifies the number of contained
  566. objects and their kinds, with four possibilities: `e' for expression
  567. (actually a pointer to an expression), `i' for integer, `w' for wide
  568. integer, `s' for string, and `E' for vector of expressions.  The
  569. sequence of letters for an expression code is called its "format".
  570. Thus, the format of `subreg' is `ei'.
  571.    A few other format characters are used occasionally:
  572.      `u' is equivalent to `e' except that it is printed differently in
  573.      debugging dumps.  It is used for pointers to insns.
  574.      `n' is equivalent to `i' except that it is printed differently in
  575.      debugging dumps.  It is used for the line number or code number of
  576.      a `note' insn.
  577.      `S' indicates a string which is optional.  In the RTL objects in
  578.      core, `S' is equivalent to `s', but when the object is read, from
  579.      an `md' file, the string value of this operand may be omitted.  An
  580.      omitted string is taken to be the null string.
  581.      `V' indicates a vector which is optional.  In the RTL objects in
  582.      core, `V' is equivalent to `E', but when the object is read from
  583.      an `md' file, the vector value of this operand may be omitted.  An
  584.      omitted vector is effectively the same as a vector of no elements.
  585.      `0' means a slot whose contents do not fit any normal category.
  586.      `0' slots are not printed at all in dumps, and are often used in
  587.      special ways by small parts of the compiler.
  588.    There are macros to get the number of operands, the format, and the
  589. class of an expression code:
  590. `GET_RTX_LENGTH (CODE)'
  591.      Number of operands of an RTX of code CODE.
  592. `GET_RTX_FORMAT (CODE)'
  593.      The format of an RTX of code CODE, as a C string.
  594. `GET_RTX_CLASS (CODE)'
  595.      A single character representing the type of RTX operation that code
  596.      CODE performs.
  597.      The following classes are defined:
  598.     `o'
  599.           An RTX code that represents an actual object, such as `reg' or
  600.           `mem'.  `subreg' is not in this class.
  601.     `<'
  602.           An RTX code for a comparison.  The codes in this class are
  603.           `NE', `EQ', `LE', `LT', `GE', `GT', `LEU', `LTU', `GEU',
  604.           `GTU'.
  605.     `1'
  606.           An RTX code for a unary arithmetic operation, such as `neg'.
  607.     `c'
  608.           An RTX code for a commutative binary operation, other than
  609.           `NE' and `EQ' (which have class `<').
  610.     `2'
  611.           An RTX code for a noncommutative binary operation, such as
  612.           `MINUS'.
  613.     `b'
  614.           An RTX code for a bitfield operation, either `ZERO_EXTRACT' or
  615.           `SIGN_EXTRACT'.
  616.     `3'
  617.           An RTX code for other three input operations, such as
  618.           `IF_THEN_ELSE'.
  619.     `i'
  620.           An RTX code for a machine insn (`INSN', `JUMP_INSN', and
  621.           `CALL_INSN').
  622.     `m'
  623.           An RTX code for something that matches in insns, such as
  624.           `MATCH_DUP'.
  625.     `x'
  626.           All other RTX codes.
  627.    Operands of expressions are accessed using the macros `XEXP',
  628. `XINT', `XWINT' and `XSTR'.  Each of these macros takes two arguments:
  629. an expression-pointer (RTX) and an operand number (counting from zero).
  630. Thus,
  631.      XEXP (X, 2)
  632. accesses operand 2 of expression X, as an expression.
  633.      XINT (X, 2)
  634. accesses the same operand as an integer.  `XSTR', used in the same
  635. fashion, would access it as a string.
  636.    Any operand can be accessed as an integer, as an expression or as a
  637. string.  You must choose the correct method of access for the kind of
  638. value actually stored in the operand.  You would do this based on the
  639. expression code of the containing expression.  That is also how you
  640. would know how many operands there are.
  641.    For example, if X is a `subreg' expression, you know that it has two
  642. operands which can be correctly accessed as `XEXP (X, 0)' and `XINT (X,
  643. 1)'.  If you did `XINT (X, 0)', you would get the address of the
  644. expression operand but cast as an integer; that might occasionally be
  645. useful, but it would be cleaner to write `(int) XEXP (X, 0)'.  `XEXP
  646. (X, 1)' would also compile without error, and would return the second,
  647. integer operand cast as an expression pointer, which would probably
  648. result in a crash when accessed.  Nothing stops you from writing `XEXP
  649. (X, 28)' either, but this will access memory past the end of the
  650. expression with unpredictable results.
  651.    Access to operands which are vectors is more complicated.  You can
  652. use the macro `XVEC' to get the vector-pointer itself, or the macros
  653. `XVECEXP' and `XVECLEN' to access the elements and length of a vector.
  654. `XVEC (EXP, IDX)'
  655.      Access the vector-pointer which is operand number IDX in EXP.
  656. `XVECLEN (EXP, IDX)'
  657.      Access the length (number of elements) in the vector which is in
  658.      operand number IDX in EXP.  This value is an `int'.
  659. `XVECEXP (EXP, IDX, ELTNUM)'
  660.      Access element number ELTNUM in the vector which is in operand
  661.      number IDX in EXP.  This value is an RTX.
  662.      It is up to you to make sure that ELTNUM is not negative and is
  663.      less than `XVECLEN (EXP, IDX)'.
  664.    All the macros defined in this section expand into lvalues and
  665. therefore can be used to assign the operands, lengths and vector
  666. elements as well as to access them.
  667. File: gcc.info,  Node: Flags,  Next: Machine Modes,  Prev: Accessors,  Up: RTL
  668. Flags in an RTL Expression
  669. ==========================
  670.    RTL expressions contain several flags (one-bit bitfields) that are
  671. used in certain types of expression.  Most often they are accessed with
  672. the following macros:
  673. `MEM_VOLATILE_P (X)'
  674.      In `mem' expressions, nonzero for volatile memory references.
  675.      Stored in the `volatil' field and printed as `/v'.
  676. `MEM_IN_STRUCT_P (X)'
  677.      In `mem' expressions, nonzero for reference to an entire
  678.      structure, union or array, or to a component of one.  Zero for
  679.      references to a scalar variable or through a pointer to a scalar.
  680.      Stored in the `in_struct' field and printed as `/s'.
  681. `REG_LOOP_TEST_P'
  682.      In `reg' expressions, nonzero if this register's entire life is
  683.      contained in the exit test code for some loop.  Stored in the
  684.      `in_struct' field and printed as `/s'.
  685. `REG_USERVAR_P (X)'
  686.      In a `reg', nonzero if it corresponds to a variable present in the
  687.      user's source code.  Zero for temporaries generated internally by
  688.      the compiler.  Stored in the `volatil' field and printed as `/v'.
  689. `REG_FUNCTION_VALUE_P (X)'
  690.      Nonzero in a `reg' if it is the place in which this function's
  691.      value is going to be returned.  (This happens only in a hard
  692.      register.)  Stored in the `integrated' field and printed as `/i'.
  693.      The same hard register may be used also for collecting the values
  694.      of functions called by this one, but `REG_FUNCTION_VALUE_P' is zero
  695.      in this kind of use.
  696. `SUBREG_PROMOTED_VAR_P'
  697.      Nonzero in a `subreg' if it was made when accessing an object that
  698.      was promoted to a wider mode in accord with the `PROMOTED_MODE'
  699.      machine description macro (*note Storage Layout::.).  In this
  700.      case, the mode of the `subreg' is the declared mode of the object
  701.      and the mode of `SUBREG_REG' is the mode of the register that
  702.      holds the object.  Promoted variables are always either sign- or
  703.      zero-extended to the wider mode on every assignment.  Stored in
  704.      the `in_struct' field and printed as `/s'.
  705. `SUBREG_PROMOTED_UNSIGNED_P'
  706.      Nonzero in a `subreg' that has `SUBREG_PROMOTED_VAR_P' nonzero if
  707.      the object being referenced is kept zero-extended and zero if it
  708.      is kept sign-extended.  Stored in the `unchanging' field and
  709.      printed as `/u'.
  710. `RTX_UNCHANGING_P (X)'
  711.      Nonzero in a `reg' or `mem' if the value is not changed.  (This
  712.      flag is not set for memory references via pointers to constants.
  713.      Such pointers only guarantee that the object will not be changed
  714.      explicitly by the current function.  The object might be changed by
  715.      other functions or by aliasing.)  Stored in the `unchanging' field
  716.      and printed as `/u'.
  717. `RTX_INTEGRATED_P (INSN)'
  718.      Nonzero in an insn if it resulted from an in-line function call.
  719.      Stored in the `integrated' field and printed as `/i'.  This may be
  720.      deleted; nothing currently depends on it.
  721. `SYMBOL_REF_USED (X)'
  722.      In a `symbol_ref', indicates that X has been used.  This is
  723.      normally only used to ensure that X is only declared external
  724.      once.  Stored in the `used' field.
  725. `SYMBOL_REF_FLAG (X)'
  726.      In a `symbol_ref', this is used as a flag for machine-specific
  727.      purposes.  Stored in the `volatil' field and printed as `/v'.
  728. `LABEL_OUTSIDE_LOOP_P'
  729.      In `label_ref' expressions, nonzero if this is a reference to a
  730.      label that is outside the innermost loop containing the reference
  731.      to the label.  Stored in the `in_struct' field and printed as `/s'.
  732. `INSN_DELETED_P (INSN)'
  733.      In an insn, nonzero if the insn has been deleted.  Stored in the
  734.      `volatil' field and printed as `/v'.
  735. `INSN_ANNULLED_BRANCH_P (INSN)'
  736.      In an `insn' in the delay slot of a branch insn, indicates that an
  737.      annulling branch should be used.  See the discussion under
  738.      `sequence' below.  Stored in the `unchanging' field and printed as
  739.      `/u'.
  740. `INSN_FROM_TARGET_P (INSN)'
  741.      In an `insn' in a delay slot of a branch, indicates that the insn
  742.      is from the target of the branch.  If the branch insn has
  743.      `INSN_ANNULLED_BRANCH_P' set, this insn should only be executed if
  744.      the branch is taken.  For annulled branches with this bit clear,
  745.      the insn should be executed only if the branch is not taken.
  746.      Stored in the `in_struct' field and printed as `/s'.
  747. `CONSTANT_POOL_ADDRESS_P (X)'
  748.      Nonzero in a `symbol_ref' if it refers to part of the current
  749.      function's "constants pool".  These are addresses close to the
  750.      beginning of the function, and GNU CC assumes they can be addressed
  751.      directly (perhaps with the help of base registers).  Stored in the
  752.      `unchanging' field and printed as `/u'.
  753. `CONST_CALL_P (X)'
  754.      In a `call_insn', indicates that the insn represents a call to a
  755.      const function.  Stored in the `unchanging' field and printed as
  756.      `/u'.
  757. `LABEL_PRESERVE_P (X)'
  758.      In a `code_label', indicates that the label can never be deleted.
  759.      Labels referenced by a non-local goto will have this bit set.
  760.      Stored in the `in_struct' field and printed as `/s'.
  761. `SCHED_GROUP_P (INSN)'
  762.      During instruction scheduling, in an insn, indicates that the
  763.      previous insn must be scheduled together with this insn.  This is
  764.      used to ensure that certain groups of instructions will not be
  765.      split up by the instruction scheduling pass, for example, `use'
  766.      insns before a `call_insn' may not be separated from the
  767.      `call_insn'.  Stored in the `in_struct' field and printed as `/s'.
  768.    These are the fields which the above macros refer to:
  769. `used'
  770.      Normally, this flag is used only momentarily, at the end of RTL
  771.      generation for a function, to count the number of times an
  772.      expression appears in insns.  Expressions that appear more than
  773.      once are copied, according to the rules for shared structure
  774.      (*note Sharing::.).
  775.      In a `symbol_ref', it indicates that an external declaration for
  776.      the symbol has already been written.
  777.      In a `reg', it is used by the leaf register renumbering code to
  778.      ensure that each register is only renumbered once.
  779. `volatil'
  780.      This flag is used in `mem', `symbol_ref' and `reg' expressions and
  781.      in insns.  In RTL dump files, it is printed as `/v'.
  782.      In a `mem' expression, it is 1 if the memory reference is volatile.
  783.      Volatile memory references may not be deleted, reordered or
  784.      combined.
  785.      In a `symbol_ref' expression, it is used for machine-specific
  786.      purposes.
  787.      In a `reg' expression, it is 1 if the value is a user-level
  788.      variable.  0 indicates an internal compiler temporary.
  789.      In an insn, 1 means the insn has been deleted.
  790. `in_struct'
  791.      In `mem' expressions, it is 1 if the memory datum referred to is
  792.      all or part of a structure or array; 0 if it is (or might be) a
  793.      scalar variable.  A reference through a C pointer has 0 because
  794.      the pointer might point to a scalar variable.  This information
  795.      allows the compiler to determine something about possible cases of
  796.      aliasing.
  797.      In an insn in the delay slot of a branch, 1 means that this insn
  798.      is from the target of the branch.
  799.      During instruction scheduling, in an insn, 1 means that this insn
  800.      must be scheduled as part of a group together with the previous
  801.      insn.
  802.      In `reg' expressions, it is 1 if the register has its entire life
  803.      contained within the test expression of some loop.
  804.      In `subreg' expressions, 1 means that the `subreg' is accessing an
  805.      object that has had its mode promoted from a wider mode.
  806.      In `label_ref' expressions, 1 means that the referenced label is
  807.      outside the innermost loop containing the insn in which the
  808.      `label_ref' was found.
  809.      In `code_label' expressions, it is 1 if the label may never be
  810.      deleted.  This is used for labels which are the target of
  811.      non-local gotos.
  812.      In an RTL dump, this flag is represented as `/s'.
  813. `unchanging'
  814.      In `reg' and `mem' expressions, 1 means that the value of the
  815.      expression never changes.
  816.      In `subreg' expressions, it is 1 if the `subreg' references an
  817.      unsigned object whose mode has been promoted to a wider mode.
  818.      In an insn, 1 means that this is an annulling branch.
  819.      In a `symbol_ref' expression, 1 means that this symbol addresses
  820.      something in the per-function constants pool.
  821.      In a `call_insn', 1 means that this instruction is a call to a
  822.      const function.
  823.      In an RTL dump, this flag is represented as `/u'.
  824. `integrated'
  825.      In some kinds of expressions, including insns, this flag means the
  826.      rtl was produced by procedure integration.
  827.      In a `reg' expression, this flag indicates the register containing
  828.      the value to be returned by the current function.  On machines
  829.      that pass parameters in registers, the same register number may be
  830.      used for parameters as well, but this flag is not set on such uses.
  831.