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