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