home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 1 / FFMCD01.bin / useful / info / gcc.info-13 (.txt) < prev    next >
GNU Info File  |  1993-09-05  |  49KB  |  961 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 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: RTL Template,  Next: Output Template,  Prev: Example,  Up: Machine Desc
  23. RTL Template
  24. ============
  25.    The RTL template is used to define which insns match the particular
  26. pattern and how to find their operands.  For named patterns, the RTL
  27. template also says how to construct an insn from specified operands.
  28.    Construction involves substituting specified operands into a copy of
  29. the template.  Matching involves determining the values that serve as
  30. the operands in the insn being matched.  Both of these activities are
  31. controlled by special expression types that direct matching and
  32. substitution of the operands.
  33. `(match_operand:M N PREDICATE CONSTRAINT)'
  34.      This expression is a placeholder for operand number N of the insn.
  35.      When constructing an insn, operand number N will be substituted
  36.      at this point.  When matching an insn, whatever appears at this
  37.      position in the insn will be taken as operand number N; but it
  38.      must satisfy PREDICATE or this instruction pattern will not match
  39.      at all.
  40.      Operand numbers must be chosen consecutively counting from zero in
  41.      each instruction pattern.  There may be only one `match_operand'
  42.      expression in the pattern for each operand number.  Usually
  43.      operands are numbered in the order of appearance in `match_operand'
  44.      expressions.
  45.      PREDICATE is a string that is the name of a C function that
  46.      accepts two arguments, an expression and a machine mode.  During
  47.      matching, the function will be called with the putative operand as
  48.      the expression and M as the mode argument (if M is not specified,
  49.      `VOIDmode' will be used, which normally causes PREDICATE to accept
  50.      any mode).  If it returns zero, this instruction pattern fails to
  51.      match.  PREDICATE may be an empty string; then it means no test is
  52.      to be done on the operand, so anything which occurs in this
  53.      position is valid.
  54.      Most of the time, PREDICATE will reject modes other than M--but
  55.      not always.  For example, the predicate `address_operand' uses M
  56.      as the mode of memory ref that the address should be valid for.
  57.      Many predicates accept `const_int' nodes even though their mode is
  58.      `VOIDmode'.
  59.      CONSTRAINT controls reloading and the choice of the best register
  60.      class to use for a value, as explained later (*note
  61.      Constraints::.).
  62.      People are often unclear on the difference between the constraint
  63.      and the predicate.  The predicate helps decide whether a given
  64.      insn matches the pattern.  The constraint plays no role in this
  65.      decision; instead, it controls various decisions in the case of an
  66.      insn which does match.
  67.      On CISC machines, the most common PREDICATE is
  68.      `"general_operand"'.  This function checks that the putative
  69.      operand is either a constant, a register or a memory reference,
  70.      and that it is valid for mode M.
  71.      For an operand that must be a register, PREDICATE should be
  72.      `"register_operand"'.  Using `"general_operand"' would be valid,
  73.      since the reload pass would copy any non-register operands through
  74.      registers, but this would make GNU CC do extra work, it would
  75.      prevent invariant operands (such as constant) from being removed
  76.      from loops, and it would prevent the register allocator from doing
  77.      the best possible job.  On RISC machines, it is usually most
  78.      efficient to allow PREDICATE to accept only objects that the
  79.      constraints allow.
  80.      For an operand that must be a constant, you must be sure to either
  81.      use `"immediate_operand"' for PREDICATE, or make the instruction
  82.      pattern's extra condition require a constant, or both.  You cannot
  83.      expect the constraints to do this work!  If the constraints allow
  84.      only constants, but the predicate allows something else, the
  85.      compiler will crash when that case arises.
  86. `(match_scratch:M N CONSTRAINT)'
  87.      This expression is also a placeholder for operand number N and
  88.      indicates that operand must be a `scratch' or `reg' expression.
  89.      When matching patterns, this is completely equivalent to
  90.           (match_operand:M N "scratch_operand" PRED)
  91.      but, when generating RTL, it produces a (`scratch':M) expression.
  92.      If the last few expressions in a `parallel' are `clobber'
  93.      expressions whose operands are either a hard register or
  94.      `match_scratch', the combiner can add them when necessary.  *Note
  95.      Side Effects::.
  96. `(match_dup N)'
  97.      This expression is also a placeholder for operand number N.  It is
  98.      used when the operand needs to appear more than once in the insn.
  99.      In construction, `match_dup' acts just like `match_operand': the
  100.      operand is substituted into the insn being constructed.  But in
  101.      matching, `match_dup' behaves differently.  It assumes that operand
  102.      number N has already been determined by a `match_operand'
  103.      appearing earlier in the recognition template, and it matches only
  104.      an identical-looking expression.
  105. `(match_operator:M N PREDICATE [OPERANDS...])'
  106.      This pattern is a kind of placeholder for a variable RTL expression
  107.      code.
  108.      When constructing an insn, it stands for an RTL expression whose
  109.      expression code is taken from that of operand N, and whose
  110.      operands are constructed from the patterns OPERANDS.
  111.      When matching an expression, it matches an expression if the
  112.      function PREDICATE returns nonzero on that expression *and* the
  113.      patterns OPERANDS match the operands of the expression.
  114.      Suppose that the function `commutative_operator' is defined as
  115.      follows, to match any expression whose operator is one of the
  116.      commutative arithmetic operators of RTL and whose mode is MODE:
  117.           int
  118.           commutative_operator (x, mode)
  119.                rtx x;
  120.                enum machine_mode mode;
  121.           {
  122.             enum rtx_code code = GET_CODE (x);
  123.             if (GET_MODE (x) != mode)
  124.               return 0;
  125.             return (GET_RTX_CLASS (code) == 'c'
  126.                     || code == EQ || code == NE);
  127.           }
  128.      Then the following pattern will match any RTL expression consisting
  129.      of a commutative operator applied to two general operands:
  130.           (match_operator:SI 3 "commutative_operator"
  131.             [(match_operand:SI 1 "general_operand" "g")
  132.              (match_operand:SI 2 "general_operand" "g")])
  133.      Here the vector `[OPERANDS...]' contains two patterns because the
  134.      expressions to be matched all contain two operands.
  135.      When this pattern does match, the two operands of the commutative
  136.      operator are recorded as operands 1 and 2 of the insn.  (This is
  137.      done by the two instances of `match_operand'.)  Operand 3 of the
  138.      insn will be the entire commutative expression: use `GET_CODE
  139.      (operands[3])' to see which commutative operator was used.
  140.      The machine mode M of `match_operator' works like that of
  141.