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-14 (.txt) < prev    next >
GNU Info File  |  1994-02-21  |  33KB  |  691 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: Output Statement,  Next: Constraints,  Prev: Output Template,  Up: Machine Desc
  23. C Statements for Assembler Output
  24. =================================
  25.    Often a single fixed template string cannot produce correct and
  26. efficient assembler code for all the cases that are recognized by a
  27. single instruction pattern.  For example, the opcodes may depend on the
  28. kinds of operands; or some unfortunate combinations of operands may
  29. require extra machine instructions.
  30.    If the output control string starts with a `@', then it is actually
  31. a series of templates, each on a separate line.  (Blank lines and
  32. leading spaces and tabs are ignored.)  The templates correspond to the
  33. pattern's constraint alternatives (*note Multi-Alternative::.).  For
  34. example, if a target machine has a two-address add instruction `addr'
  35. to add into a register and another `addm' to add a register to memory,
  36. you might write this pattern:
  37.      (define_insn "addsi3"
  38.        [(set (match_operand:SI 0 "general_operand" "=r,m")
  39.              (plus:SI (match_operand:SI 1 "general_operand" "0,0")
  40.                       (match_operand:SI 2 "general_operand" "g,r")))]
  41.        ""
  42.        "@
  43.         addr %2,%0
  44.         addm %2,%0")
  45.    If the output control string starts with a `*', then it is not an
  46. output template but rather a piece of C program that should compute a
  47. template.  It should execute a `return' statement to return the
  48. template-string you want.  Most such templates use C string literals,
  49. which require doublequote characters to delimit them.  To include these
  50. doublequote characters in the string, prefix each one with `\'.
  51.    The operands may be found in the array `operands', whose C data type
  52. is `rtx []'.
  53.    It is very common to select different ways of generating assembler
  54. code based on whether an immediate operand is within a certain range.
  55. Be careful when doing this, because the result of `INTVAL' is an
  56. integer on the host machine.  If the host machine has more bits in an
  57. `int' than the target machine has in the mode in which the constant
  58. will be used, then some of the bits you get from `INTVAL' will be
  59. superfluous.  For proper results, you must carefully disregard the
  60. values of those bits.
  61.    It is possible to output an assembler instruction and then go on to
  62. output or compute more of them, using the subroutine `output_asm_insn'.
  63. This receives two arguments: a template-string and a vector of
  64. operands.  The vector may be `operands', or it may be another array of
  65. `rtx' that you declare locally and initialize yourself.
  66.    When an insn pattern has multiple alternatives in its constraints,
  67. often the appearance of the assembler code is determined mostly by
  68. which alternative was matched.  When this is so, the C code can test
  69. the variable `which_alternative', which is the ordinal number of the
  70. alternative that was actually satisfied (0 for the first, 1 for the
  71. second alternative, etc.).
  72.    For example, suppose there are two opcodes for storing zero, `clrreg'
  73. for registers and `clrmem' for memory locations.  Here is how a pattern
  74. could use `which_alternative' to choose between them:
  75.      (define_insn ""
  76.        [(set (match_operand:SI 0 "general_operand" "=r,m")
  77.              (const_int 0))]
  78.        ""
  79.        "*
  80.        return (which_alternative == 0
  81.                ? \"clrreg %0\" : \"clrmem %0\");
  82.        ")
  83.    The example above, where the assembler code to generate was *solely*
  84. determined by the alternative, could also have been specified as
  85. follows, having the output control string start with a `@':
  86.      (define_insn ""
  87.        [(set (match_operand:SI 0 "general_operand" "=r,m")
  88.              (const_int 0))]
  89.        ""
  90.        "@
  91.         clrreg %0
  92.         clrmem %0")
  93. File: gcc.info,  Node: Constraints,  Next: Standard Names,  Prev: Output Statement,  Up: Machine Desc
  94. Operand Constraints
  95. ===================
  96.    Each `match_operand' in an instruction pattern can specify a
  97. constraint for the type of operands allowed.  Constraints can say
  98. whether an operand may be in a register, and which kinds of register;
  99. whether the operand can be a memory reference, and which kinds of
  100. address; whether the operand may be an immediate constant, and which
  101. possible values it may have.  Constraints can also require two operands
  102. to match.
  103. * Menu:
  104. * Simple Constraints::  Basic use of constraints.
  105. * Multi-Alternative::   When an insn has two alternative constraint-patterns.
  106. * Class Preferences::   Constraints guide which hard register to put things in.
  107. * Modifiers::           More precise control over effects of constraints.
  108. * Machine Constraints:: Existing constraints for some particular machines.
  109. * No Constraints::      Describing a clean machine without constraints.
  110. File: gcc.info,  Node: Simple Constraints,  Next: Multi-Alternative,  Up: Constraints
  111. Simple Constraints
  112. ------------------
  113.    The simplest kind of constraint is a string full of letters, each of
  114. which describes one kind of operand that is permitted.  Here are the
  115. letters that are allowed:
  116.      A memory operand is allowed, with any kind of address that the
  117.      machine supports in general.
  118.      A memory operand is allowed, but only if the address is
  119.      "offsettable".  This means that adding a small integer (actually,
  120.      the width in bytes of the operand, as determined by its machine
  121.      mode) may be added to the address and the result is also a valid
  122.      memory address.
  123.      For example, an address which is constant is offsettable; so is an
  124.      address that is the sum of a register and a constant (as long as a
  125.      slightly larger constant is also within the range of
  126.      address-offsets supported by the machine); but an autoincrement or
  127.      autodecrement address is not offsettable.  More complicated
  128.      indirect/indexed addresses may or may not be offsettable depending
  129.      on the other addressing modes that the machine supports.
  130.      Note that in an output operand which can be matched by another
  131.      operand, the constraint letter `o' is valid only when accompanied
  132.      by both `<' (if the target machine has predecrement addressing)
  133.      and `>' (if the target machine has preincrement addressing).
  134.      A memory operand that is not offsettable.  In other words,
  135.      anything that would fit the `m' constraint but not the `o'
  136.      constraint.
  137.      A memory operand with autodecrement addressing (either
  138.      predecrement or postdecrement) is allowed.
  139.      A memory operand with autoincrement addressing (either
  140.      preincrement or postincrement) is allowed.
  141.      A register operand is allowed provided that it is in a general
  142.      register.
  143. `d', `a', `f', ...
  144.      Other letters can be defined in machine-dependent fashion to stand
  145.      for particular classes of registers.  `d', `a' and `f' are defined
  146.      on the 68000/68020 to stand for data, address and floating point
  147.      registers.
  148.      An immediate integer operand (one with constant value) is allowed.
  149.      This