home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / gcc.info-12 (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  51KB  |  900 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 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993, 1994 Free Software Foundation,
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License," "Funding for
  13. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  14. included exactly as in the original, and provided that the entire
  15. resulting derived work is distributed under the terms of a permission
  16. notice identical to this one.
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that the sections entitled "GNU General Public
  20. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  21. `Look And Feel'", and this permission notice, may be included in
  22. translations approved by the Free Software Foundation instead of in the
  23. original English.
  24. File: gcc.info,  Node: Passes,  Next: RTL,  Prev: Interface,  Up: Top
  25. Passes and Files of the Compiler
  26. ********************************
  27.    The overall control structure of the compiler is in `toplev.c'.  This
  28. file is responsible for initialization, decoding arguments, opening and
  29. closing files, and sequencing the passes.
  30.    The parsing pass is invoked only once, to parse the entire input.
  31. The RTL intermediate code for a function is generated as the function
  32. is parsed, a statement at a time.  Each statement is read in as a
  33. syntax tree and then converted to RTL; then the storage for the tree
  34. for the statement is reclaimed.  Storage for types (and the expressions
  35. for their sizes), declarations, and a representation of the binding
  36. contours and how they nest, remain until the function is finished being
  37. compiled; these are all needed to output the debugging information.
  38.    Each time the parsing pass reads a complete function definition or
  39. top-level declaration, it calls either the function
  40. `rest_of_compilation', or the function `rest_of_decl_compilation' in
  41. `toplev.c', which are responsible for all further processing necessary,
  42. ending with output of the assembler language.  All other compiler
  43. passes run, in sequence, within `rest_of_compilation'.  When that
  44. function returns from compiling a function definition, the storage used
  45. for that function definition's compilation is entirely freed, unless it
  46. is an inline function (*note An Inline Function is As Fast As a Macro:
  47. Inline.).
  48.    Here is a list of all the passes of the compiler and their source
  49. files.  Also included is a description of where debugging dumps can be
  50. requested with `-d' options.
  51.    * Parsing.  This pass reads the entire text of a function definition,
  52.      constructing partial syntax trees.  This and RTL generation are no
  53.      longer truly separate passes (formerly they were), but it is
  54.      easier to think of them as separate.
  55.      The tree representation does not entirely follow C syntax, because
  56.      it is intended to support other languages as well.
  57.      Language-specific data type analysis is also done in this pass,
  58.      and every tree node that represents an expression has a data type
  59.      attached.  Variables are represented as declaration nodes.
  60.      Constant folding and some arithmetic simplifications are also done
  61.      during this pass.
  62.      The language-independent source files for parsing are
  63.      `stor-layout.c', `fold-const.c', and `tree.c'.  There are also
  64.      header files `tree.h' and `tree.def' which define the format of
  65.      the tree representation.
  66.      The source files to parse C are `c-parse.in', `c-decl.c',
  67.      `c-typeck.c', `c-aux-info.c', `c-convert.c', and `c-lang.c' along
  68.      with header files `c-lex.h', and `c-tree.h'.
  69.      The source files for parsing C++ are `cp-parse.y', `cp-class.c',
  70.      `cp-cvt.c', `cp-decl.c', `cp-decl2.c', `cp-dem.c', `cp-except.c',
  71.      `cp-expr.c', `cp-init.c', `cp-lex.c', `cp-method.c', `cp-ptree.c',
  72.      `cp-search.c', `cp-tree.c', `cp-type2.c', and `cp-typeck.c', along
  73.      with header files `cp-tree.def', `cp-tree.h', and `cp-decl.h'.
  74.      The special source files for parsing Objective C are
  75.      `objc-parse.y', `objc-actions.c', `objc-tree.def', and
  76.      `objc-actions.h'.  Certain C-specific files are used for this as
  77.      well.
  78.      The file `c-common.c' is also used for all of the above languages.
  79.    * RTL generation.  This is the conversion of syntax tree into RTL
  80.      code.  It is actually done statement-by-statement during parsing,
  81.      but for most purposes it can be thought of as a separate pass.
  82.      This is where the bulk of target-parameter-dependent code is found,
  83.      since often it is necessary for strategies to apply only when
  84.      certain standard kinds of instructions are available.  The purpose
  85.      of named instruction patterns is to provide this information to
  86.      the RTL generation pass.
  87.      Optimization is done in this pass for `if'-conditions that are
  88.      comparisons, boolean operations or conditional expressions.  Tail
  89.      recursion is detected at this time also.  Decisions are made about
  90.      how best to arrange loops and how to output `switch' statements.
  91.      The source files for RTL generation include `stmt.c', `calls.c',
  92.      `expr.c', `explow.c', `expmed.c', `function.c', `optabs.c' and
  93.      `emit-rtl.c'.  Also, the file `insn-emit.c', generated from the
  94.      machine description by the program `genemit', is used in this
  95.      pass.  The header file `expr.h' is used for communication within
  96.      this pass.
  97.      The header files `insn-flags.h' and `insn-codes.h', generated from
  98.      the machine description by the programs `genflags' and `gencodes',
  99.      tell this pass which standard names are available for use and
  100.      which patterns correspond to them.
  101.      Aside from debugging information output, none of the following
  102.      passes refers to the tree structure representation of the function
  103.      (only part of which is saved).
  104.      The decision of whether the function can and should be expanded
  105.      inline in its subsequent callers is made at the end of rtl
  106.      generation.  The function must meet certain criteria, currently
  107.      related to the size of the function and the types and number of
  108.      parameters it has.  Note that this function may contain loops,
  109.      recursive calls to itself (tail-recursive functions can be
  110.      inlined!), gotos, in short, all constructs supported by GNU CC.
  111.      The file `integrate.c' contains the code to save a function's rtl
  112.      for later inlining and to inline that rtl when the function is
  113.      called.  The header file `integrate.h' is also used for this
  114.      purpose.
  115.      The option `-dr' causes a debugging dump of the RTL code after
  116.      this pass.  This dump file's name is made by appending `.rtl' to
  117.      the input file name.
  118.    * Jump optimization.  This pass simplifies jumps to the following
  119.      instruction, jumps across jumps, and jumps to jumps.  It deletes
  120.      unreferenced labels and unreachable code, except that unreachable
  121.      code that contains a loop is not recognized as unreachable in this
  122.      pass.  (Such loops are deleted later in the basic block analysis.)
  123.      It also converts some code originally written with jumps into
  124.      sequences of instructions that directly set values from the
  125.      results of comparisons, if the machine has such instructions.
  126.      Jump optimization is performed two or three times.  The first time
  127.      is immediately following RTL generation.  The second time is after
  128.      CSE, but only if CSE says repeated jump optimization is needed.
  129.      The last time is right before the final pass.  That time,
  130.      cross-jumping and deletion of no-op move instructions are done
  131.      together with the optimizations described above.
  132.      The source file of this pass is `jump.c'.
  133.      The opti