home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / gcc.i10 (.txt) < prev    next >
GNU Info File  |  1993-06-12  |  51KB  |  857 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.47 from the input
  2. file gcc.tex.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled "GNU General Public License" and "Protect
  11. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  12. original, and provided that the entire resulting derived work is
  13. distributed under the terms of a permission notice identical to this
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the sections entitled "GNU General Public
  17. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  18. permission notice, may be included in translations approved by the Free
  19. Software Foundation instead of in the original English.
  20. File: gcc.info,  Node: Conversions,  Next: RTL Declarations,  Prev: Bit Fields,  Up: RTL
  21. Conversions
  22. ===========
  23.    All conversions between machine modes must be represented by
  24. explicit conversion operations.  For example, an expression which is
  25. the sum of a byte and a full word cannot be written as `(plus:SI
  26. (reg:QI 34) (reg:SI 80))' because the `plus' operation requires two
  27. operands of the same machine mode. Therefore, the byte-sized operand is
  28. enclosed in a conversion operation, as in
  29.      (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
  30.    The conversion operation is not a mere placeholder, because there
  31. may be more than one way of converting from a given starting mode to
  32. the desired final mode.  The conversion operation code says how to do
  33.    For all conversion operations, X must not be `VOIDmode' because the
  34. mode in which to do the conversion would not be known. The conversion
  35. must either be done at compile-time or X must be placed into a register.
  36. `(sign_extend:M X)'
  37.      Represents the result of sign-extending the value X to machine
  38.      mode M.  M must be a fixed-point mode and X a fixed-point value of
  39.      a mode narrower than M.
  40. `(zero_extend:M X)'
  41.      Represents the result of zero-extending the value X to machine
  42.      mode M.  M must be a fixed-point mode and X a fixed-point value of
  43.      a mode narrower than M.
  44. `(float_extend:M X)'
  45.      Represents the result of extending the value X to machine mode M. 
  46.      M must be a floating point mode and X a floating point value of a
  47.      mode narrower than M.
  48. `(truncate:M X)'
  49.      Represents the result of truncating the value X to machine mode M.
  50.       M must be a fixed-point mode and X a fixed-point value of a mode
  51.      wider than M.
  52. `(float_truncate:M X)'
  53.      Represents the result of truncating the value X to machine mode M.
  54.       M must be a floating point mode and X a floating point value of a
  55.      mode wider than M.
  56. `(float:M X)'
  57.      Represents the result of converting fixed point value X, regarded
  58.      as signed, to floating point mode M.
  59. `(unsigned_float:M X)'
  60.      Represents the result of converting fixed point value X, regarded
  61.      as unsigned, to floating point mode M.
  62. `(fix:M X)'
  63.      When M is a fixed point mode, represents the result of converting
  64.      floating point value X to mode M, regarded as signed.  How
  65.      rounding is done is not specified, so this operation may be used
  66.      validly in compiling C code only for integer-valued operands.
  67. `(unsigned_fix:M X)'
  68.      Represents the result of converting floating point value X to
  69.      fixed point mode M, regarded as unsigned.  How rounding is done is
  70.      not specified.
  71. `(fix:M X)'
  72.      When M is a floating point mode, represents the result of
  73.      converting floating point value X (valid for mode M) to an
  74.      integer, still represented in floating point mode M, by rounding
  75.      towards zero.
  76. File: gcc.info,  Node: RTL Declarations,  Next: Side Effects,  Prev: Conversions,  Up: RTL
  77. Declarations
  78. ============
  79.    Declaration expression codes do not represent arithmetic operations
  80. but rather state assertions about their operands.
  81. `(strict_low_part (subreg:M (reg:N R) 0))'
  82.      This expression code is used in only one context: as the
  83.      destination operand of a `set' expression.  In addition, the
  84.      operand of this expression must be a non-paradoxical `subreg'
  85.      expression.
  86.      The presence of `strict_low_part' says that the part of the
  87.      register which is meaningful in mode N, but is not part of mode M,
  88.      is not to be altered.  Normally, an assignment to such a subreg is
  89.      allowed to have undefined effects on the rest of the register when
  90.      M is less than a word.
  91. File: gcc.info,  Node: Side Effects,  Next: Incdec,  Prev: RTL Declarations,  Up: RTL
  92. Side Effect Expressions
  93. =======================
  94.    The expression codes described so far represent values, not actions.
  95. But machine instructions never produce values; they are meaningful only
  96. for their side effects on the state of the machine.  Special expression
  97. codes are used to represent side effects.
  98.    The body of an instruction is always one of these side effect codes;
  99. the codes described above, which represent values, appear only as the
  100. operands of these.
  101. `(set LVAL X)'
  102.      Represents the action of storing the value of X into the place
  103.      represented by LVAL.  LVAL must be an expression representing a
  104.      place that can be stored in: `reg' (or `subreg' or
  105.      `strict_low_part'), `mem', `pc' or `cc0'.
  106.      If LVAL is a `reg', `subreg' or `mem', it has a machine mode; then
  107.      X must be valid for that mode.
  108.      If LVAL is a `reg' whose machine mode is less than the full width
  109.      of the register, then it means that the part of the register
  110.      specified by the machine mode is given the specified value and the
  111.      rest of the register receives an undefined value.  Likewise, if
  112.      LVAL is a `subreg' whose machine mode is narrower than the mode of
  113.      the register, the rest of the register can be changed in an
  114.      undefined way.
  115.      If LVAL is a `strict_low_part' of a `subreg', then the part of the
  116.      register specified by the machine mode of the `subreg' is given
  117.      the value X and the rest of the register is not changed.
  118.      If LVAL is `(cc0)', it has no machine mode, and X may be either a
  119.      `compare' expression or a value that may have any mode. The latter
  120.      case represents a "test" instruction.  The expression `(set (cc0)
  121.      (reg:M N))' is equivalent to `(set (cc0) (compare (reg:M N)
  122.      (const_int 0)))'. Use the former expression to save space during
  123.      the compilation.
  124.      If LVAL is `(pc)', we have a jump instruction, and the
  125.      possibilities for X are very limited.  It may be a `label_ref'
  126.      expression (unconditional jump).  It may be an `if_then_else'
  127.      (conditional jump), in which case either the second or the third
  128.      operand must be `(pc)' (for the case which does not jump) and the
  129.      other of the two must be a `label_ref' (for the case which does
  130.      jump).  X may also be a `mem' or `(plus:SI (pc) Y)', where Y may
  131.      be a `reg' or a `mem'; these unusual patterns are used to
  132.      represent jumps through branch tables.
  133.      If LVAL is neither `(cc0)' nor `(pc)', the mode of LVAL must not
  134.      be `VOIDmode' and the mode of X must be valid for the mode of LVAL.
  135.      LVAL is customarily accessed with the `SET_DEST' macro and X with
  136.      the `SET_SRC' macro.
  137. `(return)'
  138.      As the sole expression in a pattern, represents a return from the
  139.      current function, on machines where this can be done with one
  140.      instruction, such as Vaxes.  On machines where a multi-instruction
  141.      "epilogue" must be executed in order to return from the function,
  142.      returning is done by jumping to a label which precedes the
  143.      epilogue, and the `return' expression code is never used.
  144.      Inside an `if_then_else' expression, represents the value to be
  145.      placed in `pc' to return to the caller.
  146.      Note that an insn pattern of `(return)' is logically equivalent to
  147.      `(set (pc) (return))', but the latter form is never used.
  148. `(call FUNCTION NARGS)'
  149.      Represents a function call.  FUNCTION is a `mem' expression whose
  150.      address is the address of the function to be called. NARGS is an
  151.      expression which can be used for two purposes: on some machines it
  152.      represents the number of bytes of stack argument; on others, it
  153.      represents the number of argument registers.
  154.      Each machine has a standard machine mode which FUNCTION must have.
  155.       The machine description defines macro `FUNCTION_MODE' to expand
  156.      into the requisite mode name.  The purpose of this mode is to
  157.      specify what kind of addressing is allowed, on machines where the
  158.      allowed kinds of addressing depend on the machine mode being
  159.      addressed.
  160. `(clobber X)'
  161.      Represents the storing or possible storing of an unpredictable,
  162.      undescribed value into X, which must be a `reg', `scratch' or
  163.      `mem' expression.
  164.      One place this is used is in string instructions that store
  165.      standard values into particular hard registers.  It may not be
  166.      worth the trouble to describe the values that are stored, but it
  167.      is essential to inform the compiler that the registers will be
  168.      altered, lest it attempt to keep data in them across the string
  169.      instruction.
  170.      If X is `(mem:BLK (const_int 0))', it means that all memory
  171.      locations must be presumed clobbered.
  172.      Note that the machine description classifies certain hard
  173.      registers as "call-clobbered".  All function call instructions are
  174.      assumed by default to clobber these registers, so there is no need
  175.      to use `clobber' expressions to indicate this fact.  Also, each
  176.      function call is assumed to have the potential to alter any memory
  177.      location, unless the function is declared `const'.
  178.      If the last group of expressions in a `parallel' are each a
  179.      `clobber' expression whose arguments are `reg' or `match_scratch'
  180.      (*note RTL Template::.) expressions, the combiner phase can add
  181.      the appropriate `clobber' expressions to an insn it has
  182.      constructed when doing so will cause a pattern to be matched.
  183.      This feature can be used, for example, on a machine that whose
  184.      multiply and add instructions don't use an MQ register but which
  185.      has an add-accumulate instruction that does clobber the MQ
  186.      register.  Similarly, a combined instruction might require a
  187.      temporary register while the constituent instructions might not.
  188.      When a `clobber' expression for a register appears inside a
  189.      `parallel' with other side effects, the register allocator
  190.      guarantees that the register is unoccupied both before and after
  191.      that insn.  However, the reload phase may allocate a register used
  192.      for one of the inputs unless the `&' constraint is specified for
  193.      the selected alternative (*note Modifiers::.).  You can clobber
  194.      either a specific hard register, a pseudo register, or a `scratch'
  195.      expression; in the latter two cases, GNU CC will allocate a hard
  196.      register that is available there for use as a temporary.
  197.      For instructions that require a temporary register, you should use
  198.      `scratch' instead of a pseudo-register because this will allow the
  199.      combiner phase to add the `clobber' when required.  You do this by
  200.      coding (`clobber' (`match_scratch' ...)).  If you do clobber a
  201.      pseudo register, use one which appears nowhere else--generate a
  202.      new one each time.  Otherwise, you may confuse CSE.
  203.      There is one other known use for clobbering a pseudo register in a
  204.      `parallel': when one of the input operands of the insn is also
  205.      clobbered by the insn.  In this case, using the same pseudo
  206.      register in the clobber and elsewhere in the insn produces the
  207.      expected results.
  208. `(use X)'
  209.      Represents the use of the value of X.  It indicates that the value
  210.      in X at this point in the program is needed, even though it may
  211.      not be apparent why this is so.  Therefore, the compiler will not
  212.      attempt to delete previous instructions whose only effect is to
  213.      store a value in X.  X must be a `reg' expression.
  214.      During the delayed branch scheduling phase, X may be an insn. This
  215.      indicates that X previously was located at this place in the code
  216.      and its data dependencies need to be taken into account.  These
  217.      `use' insns will be deleted before the delayed branch scheduling
  218.      phase exits.
  219. `(parallel [X0 X1 ...])'
  220.      Represents several side effects performed in parallel.  The square
  221.      brackets stand for a vector; the operand of `parallel' is a vector
  222.      of expressions.  X0, X1 and so on are individual side effect
  223.      expressions--expressions of code `set', `call', `return',
  224.      `clobber' or `use'.
  225.      "In parallel" means that first all the values used in the
  226.      individual side-effects are computed, and second all the actual
  227.      side-effects are performed.  For example,
  228.           (parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
  229.                      (set (mem:SI (reg:SI 1)) (reg:SI 1))])
  230.      says unambiguously that the values of hard register 1 and the
  231.      memory location addressed by it are interchanged.  In both places
  232.      where `(reg:SI 1)' appears as a memory address it refers to the
  233.      value in register 1 *before* the execution of the insn.
  234.      It follows that it is *incorrect* to use `parallel' and expect the
  235.      result of one `set' to be available for the next one. For example,
  236.      people sometimes attempt to represent a jump-if-zero instruction
  237.      this way:
  238.           (parallel [(set (cc0) (reg:SI 34))
  239.                      (set (pc) (if_then_else
  240.                                   (eq (cc0) (const_int 0))
  241.                                   (label_ref ...)
  242.                                   (pc)))])
  243.      But this is incorrect, because it says that the jump condition
  244.      depends on the condition code value *before* this instruction, not
  245.      on the new value that is set by this instruction.
  246.      Peephole optimization, which takes place together with final
  247.      assembly code output, can produce insns whose patterns consist of
  248.      a `parallel' whose elements are the operands needed to output the
  249.      resulting assembler code--often `reg', `mem' or constant
  250.      expressions. This would not be well-formed RTL at any other stage
  251.      in compilation, but it is ok then because no further optimization
  252.      remains to be done. However, the definition of the macro
  253.      `NOTICE_UPDATE_CC', if any, must deal with such insns if you
  254.      define any peephole optimizations.
  255. `(sequence [INSNS ...])'
  256.      Represents a sequence of insns.  Each of the INSNS that appears in
  257.      the vector is suitable for appearing in the chain of insns, so it
  258.      must be an `insn', `jump_insn', `call_insn', `code_label',
  259.      `barrier' or `note'.
  260.      A `sequence' RTX is never placed in an actual insn during RTL
  261.      generation.  It represents the sequence of insns that result from a
  262.      `define_expand' *before* those insns are passed to `emit_insn' to
  263.      insert them in the chain of insns.  When actually inserted, the
  264.      individual sub-insns are separated out and the `sequence' is
  265.      forgotten.
  266.      After delay-slot scheduling is completed, an insn and all the
  267.      insns that reside in its delay slots are grouped together into a
  268.      `sequence'. The insn requiring the delay slot is the first insn in
  269.      the vector; subsequent insns are to be placed in the delay slot.
  270.      `INSN_ANNULLED_BRANCH_P' is set on an insn in a delay slot to
  271.      indicate that a branch insn should be used that will conditionally
  272.      annul the effect of the insns in the delay slots.  In such a case,
  273.      `INSN_FROM_TARGET_P' indicates that the insn is from the target of
  274.      the branch and should be executed only if the branch is taken;
  275.      otherwise the insn should be executed only if the branch is not
  276.      taken. *Note Delay Slots::.
  277.    These expression codes appear in place of a side effect, as the body
  278. of an insn, though strictly speaking they do not always describe side
  279. effects as such:
  280. `(asm_input S)'
  281.      Represents literal assembler code as described by the string S.
  282. `(unspec [OPERANDS ...] INDEX)'
  283. `(unspec_volatile [OPERANDS ...] INDEX)'
  284.      Represents a machine-specific operation on OPERANDS.  INDEX
  285.      selects between multiple machine-specific operations.
  286.      `unspec_volatile' is used for volatile operations and operations
  287.      that may trap; `unspec' is used for other operations.
  288.      These codes may appear inside a `pattern' of an insn, inside a
  289.      `parallel', or inside an expression.
  290. `(addr_vec:M [LR0 LR1 ...])'
  291.      Represents a table of jump addresses.  The vector elements LR0,
  292.      etc., are `label_ref' expressions.  The mode M specifies how much
  293.      space is given to each address; normally M would be `Pmode'.
  294. `(addr_diff_vec:M BASE [LR0 LR1 ...])'
  295.      Represents a table of jump addresses expressed as offsets from
  296.      BASE.  The vector elements LR0, etc., are `label_ref' expressions
  297.      and so is BASE.  The mode M specifies how much space is given to
  298.      each address-difference.
  299. File: gcc.info,  Node: Incdec,  Next: Assembler,  Prev: Side Effects,  Up: RTL
  300. Embedded Side-Effects on Addresses
  301. ==================================
  302.    Four special side-effect expression codes appear as memory addresses.
  303. `(pre_dec:M X)'
  304.      Represents the side effect of decrementing X by a standard amount
  305.      and represents also the value that X has after being decremented. 
  306.      X must be a `reg' or `mem', but most machines allow only a `reg'. 
  307.      M must be the machine mode for pointers on the machine in use. 
  308.      The amount X is decremented by is the length in bytes of the
  309.      machine mode of the containing memory reference of which this
  310.      expression serves as the address.  Here is an example of its use:
  311.           (mem:DF (pre_dec:SI (reg:SI 39)))
  312.      This says to decrement pseudo register 39 by the length of a
  313.      `DFmode' value and use the result to address a `DFmode' value.
  314. `(pre_inc:M X)'
  315.      Similar, but specifies incrementing X instead of decrementing it.
  316. `(post_dec:M X)'
  317.      Represents the same side effect as `pre_dec' but a different
  318.      value.  The value represented here is the value X has before being
  319.      decremented.
  320. `(post_inc:M X)'
  321.      Similar, but specifies incrementing X instead of decrementing it.
  322.    These embedded side effect expressions must be used with care. 
  323. Instruction patterns may not use them.  Until the `flow' pass of the
  324. compiler, they may occur only to represent pushes onto the stack.  The
  325. `flow' pass finds cases where registers are incremented or decremented
  326. in one instruction and used as an address shortly before or after;
  327. these cases are then transformed to use pre- or post-increment or
  328. -decrement.
  329.    If a register used as the operand of these expressions is used in
  330. another address in an insn, the original value of the register is used.
  331. Uses of the register outside of an address are not permitted within the
  332. same insn as a use in an embedded side effect expression because such
  333. insns behave differently on different machines and hence must be treated
  334. as ambiguous and disallowed.
  335.    An instruction that can be represented with an embedded side effect
  336. could also be represented using `parallel' containing an additional
  337. `set' to describe how the address register is altered.  This is not
  338. done because machines that allow these operations at all typically
  339. allow them wherever a memory address is called for.  Describing them as
  340. additional parallel stores would require doubling the number of entries
  341. in the machine description.
  342. File: gcc.info,  Node: Assembler,  Next: Insns,  Prev: IncDec,  Up: RTL
  343. Assembler Instructions as Expressions
  344. =====================================
  345.    The RTX code `asm_operands' represents a value produced by a
  346. user-specified assembler instruction.  It is used to represent an `asm'
  347. statement with arguments.  An `asm' statement with a single output
  348. operand, like this:
  349.      asm ("foo %1,%2,%0" : "=a" (outputvar) : "g" (x + y), "di" (*z));
  350. is represented using a single `asm_operands' RTX which represents the
  351. value that is stored in `outputvar':
  352.      (set RTX-FOR-OUTPUTVAR
  353.           (asm_operands "foo %1,%2,%0" "a" 0
  354.                         [RTX-FOR-ADDITION-RESULT RTX-FOR-*Z]
  355.                         [(asm_input:M1 "g")
  356.                          (asm_input:M2 "di")]))
  357. Here the operands of the `asm_operands' RTX are the assembler template
  358. string, the output-operand's constraint, the index-number of the output
  359. operand among the output operands specified, a vector of input operand
  360. RTX's, and a vector of input-operand modes and constraints.  The mode
  361. M1 is the mode of the sum `x+y'; M2 is that of `*z'.
  362.    When an `asm' statement has multiple output values, its insn has
  363. several such `set' RTX's inside of a `parallel'.  Each `set' contains a
  364. `asm_operands'; all of these share the same assembler template and
  365. vectors, but each contains the constraint for the respective output
  366. operand.  They are also distinguished by the output-operand index
  367. number, which is 0, 1, ... for successive output operands.
  368. File: gcc.info,  Node: Insns,  Next: Calls,  Prev: Assembler,  Up: RTL
  369. Insns
  370. =====
  371.    The RTL representation of the code for a function is a doubly-linked
  372. chain of objects called "insns".  Insns are expressions with special
  373. codes that are used for no other purpose.  Some insns are actual
  374. instructions; others represent dispatch tables for `switch' statements;
  375. others represent labels to jump to or various sorts of declarative
  376. information.
  377.    In addition to its own specific data, each insn must have a unique
  378. id-number that distinguishes it from all other insns in the current
  379. function (after delayed branch scheduling, copies of an insn with the
  380. same id-number may be present in multiple places in a function, but
  381. these copies will always be identical and will only appear inside a
  382. `sequence'), and chain pointers to the preceding and following insns. 
  383. These three fields occupy the same position in every insn, independent
  384. of the expression code of the insn.  They could be accessed with `XEXP'
  385. and `XINT', but instead three special macros are always used:
  386. `INSN_UID (I)'
  387.      Accesses the unique id of insn I.
  388. `PREV_INSN (I)'
  389.      Accesses the chain pointer to the insn preceding I. If I is the
  390.      first insn, this is a null pointer.
  391. `NEXT_INSN (I)'
  392.      Accesses the chain pointer to the insn following I. If I is the
  393.      last insn, this is a null pointer.
  394.    The first insn in the chain is obtained by calling `get_insns'; the
  395. last insn is the result of calling `get_last_insn'.  Within the chain
  396. delimited by these insns, the `NEXT_INSN' and `PREV_INSN' pointers must
  397. always correspond: if INSN is not the first insn,
  398.      NEXT_INSN (PREV_INSN (INSN)) == INSN
  399. is always true and if INSN is not the last insn,
  400.      PREV_INSN (NEXT_INSN (INSN)) == INSN
  401. is always true.
  402.    After delay slot scheduling, some of the insns in the chain might be
  403. `sequence' expressions, which contain a vector of insns.  The value of
  404. `NEXT_INSN' in all but the last of these insns is the next insn in the
  405. vector; the value of `NEXT_INSN' of the last insn in the vector is the
  406. same as the value of `NEXT_INSN' for the `sequence' in which it is
  407. contained.  Similar rules apply for `PREV_INSN'.
  408.    This means that the above invariants are not necessarily true for
  409. insns inside `sequence' expressions.  Specifically, if INSN is the
  410. first insn in a `sequence', `NEXT_INSN (PREV_INSN (INSN))' is the insn
  411. containing the `sequence' expression, as is the value of `PREV_INSN
  412. (NEXT_INSN (INSN))' is INSN is the last insn in the `sequence'
  413. expression.  You can use these expressions to find the containing
  414. `sequence' expression.
  415.    Every insn has one of the following six expression codes:
  416. `insn'
  417.      The expression code `insn' is used for instructions that do not
  418.      jump and do not do function calls.  `sequence' expressions are
  419.      always contained in insns with code `insn' even if one of those
  420.      insns should jump or do function calls.
  421.      Insns with code `insn' have four additional fields beyond the three
  422.      mandatory ones listed above.  These four are described in a table
  423.      below.
  424. `jump_insn'
  425.      The expression code `jump_insn' is used for instructions that may
  426.      jump (or, more generally, may contain `label_ref' expressions).  If
  427.      there is an instruction to return from the current function, it is
  428.      recorded as a `jump_insn'.
  429.      `jump_insn' insns have the same extra fields as `insn' insns,
  430.      accessed in the same way and in addition contains a field
  431.      `JUMP_LABEL' which is defined once jump optimization has completed.
  432.      For simple conditional and unconditional jumps, this field
  433.      contains the `code_label' to which this insn will (possibly
  434.      conditionally) branch.  In a more complex jump, `JUMP_LABEL'
  435.      records one of the labels that the insn refers to; the only way to
  436.      find the others is to scan the entire body of the insn.
  437.      Return insns count as jumps, but since they do not refer to any
  438.      labels, they have zero in the `JUMP_LABEL' field.
  439. `call_insn'
  440.      The expression code `call_insn' is used for instructions that may
  441.      do function calls.  It is important to distinguish these
  442.      instructions because they imply that certain registers and memory
  443.      locations may be altered unpredictably.
  444.      A `call_insn' insn may be preceded by insns that contain a single
  445.      `use' expression and be followed by insns the contain a single
  446.      `clobber' expression.  If so, these `use' and `clobber'
  447.      expressions are treated as being part of the function call. There
  448.      must not even be a `note' between the `call_insn' and the `use' or
  449.      `clobber' insns for this special treatment to take place.  This is
  450.      somewhat of a kludge and will be removed in a later version of GNU
  451.      CC.
  452.      `call_insn' insns have the same extra fields as `insn' insns,
  453.      accessed in the same way.
  454. `code_label'
  455.      A `code_label' insn represents a label that a jump insn can jump
  456.      to.  It contains two special fields of data in addition to the
  457.      three standard ones.  `CODE_LABEL_NUMBER' is used to hold the
  458.      "label number", a number that identifies this label uniquely among
  459.      all the labels in the compilation (not just in the current
  460.      function). Ultimately, the label is represented in the assembler
  461.      output as an assembler label, usually of the form `LN' where N is
  462.      the label number.
  463.      When a `code_label' appears in an RTL expression, it normally
  464.      appears within a `label_ref' which represents the address of the
  465.      label, as a number.
  466.      The field `LABEL_NUSES' is only defined once the jump optimization
  467.      phase is completed and contains the number of times this label is
  468.      referenced in the current function.
  469. `barrier'
  470.      Barriers are placed in the instruction stream when control cannot
  471.      flow past them.  They are placed after unconditional jump
  472.      instructions to indicate that the jumps are unconditional and
  473.      after calls to `volatile' functions, which do not return (e.g.,
  474.      `exit'). They contain no information beyond the three standard
  475.      fields.
  476. `note'
  477.      `note' insns are used to represent additional debugging and
  478.      declarative information.  They contain two nonstandard fields, an
  479.      integer which is accessed with the macro `NOTE_LINE_NUMBER' and a
  480.      string accessed with `NOTE_SOURCE_FILE'.
  481.      If `NOTE_LINE_NUMBER' is positive, the note represents the
  482.      position of a source line and `NOTE_SOURCE_FILE' is the source
  483.      file name that the line came from.  These notes control generation
  484.      of line number data in the assembler output.
  485.      Otherwise, `NOTE_LINE_NUMBER' is not really a line number but a
  486.      code with one of the following values (and `NOTE_SOURCE_FILE' must
  487.      contain a null pointer):
  488.     `NOTE_INSN_DELETED'
  489.           Such a note is completely ignorable.  Some passes of the
  490.           compiler delete insns by altering them into notes of this
  491.           kind.
  492.     `NOTE_INSN_BLOCK_BEG'
  493.     `NOTE_INSN_BLOCK_END'
  494.           These types of notes indicate the position of the beginning
  495.           and end of a level of scoping of variable names.  They
  496.           control the output of debugging information.
  497.     `NOTE_INSN_LOOP_BEG'
  498.     `NOTE_INSN_LOOP_END'
  499.           These types of notes indicate the position of the beginning
  500.           and end of a `while' or `for' loop.  They enable the loop
  501.           optimizer to find loops quickly.
  502.     `NOTE_INSN_LOOP_CONT'
  503.           Appears at the place in a loop that `continue' statements
  504.           jump to.
  505.     `NOTE_INSN_LOOP_VTOP'
  506.           This note indicates the place in a loop where the exit test
  507.           begins for those loops in which the exit test has been
  508.           duplicated.  This position becomes another virtual start of
  509.           the loop when considering loop invariants.
  510.     `NOTE_INSN_FUNCTION_END'
  511.           Appears near the end of the function body, just before the
  512.           label that `return' statements jump to (on machine where a
  513.           single instruction does not suffice for returning).  This
  514.           note may be deleted by jump optimization.
  515.     `NOTE_INSN_SETJMP'
  516.           Appears following each call to `setjmp' or a related function.
  517.      These codes are printed symbolically when they appear in debugging
  518.      dumps.
  519.    The machine mode of an insn is normally `VOIDmode', but some phases
  520. use the mode for various purposes; for example, the reload pass sets it
  521. to `HImode' if the insn needs reloading but not register elimination
  522. and `QImode' if both are required.  The common subexpression
  523. elimination pass sets the mode of an insn to `QImode' when it is the
  524. first insn in a block that has already been processed.
  525.    Here is a table of the extra fields of `insn', `jump_insn' and
  526. `call_insn' insns:
  527. `PATTERN (I)'
  528.      An expression for the side effect performed by this insn.  This
  529.      must be one of the following codes: `set', `call', `use',
  530.      `clobber', `return', `asm_input', `asm_output', `addr_vec',
  531.      `addr_diff_vec', `trap_if', `unspec', `unspec_volatile',
  532.      `parallel', or `sequence'.  If it is a `parallel', each element of
  533.      the `parallel' must be one these codes, except that `parallel'
  534.      expressions cannot be nested and `addr_vec' and `addr_diff_vec'
  535.      are not permitted inside a `parallel' expression.
  536. `INSN_CODE (I)'
  537.      An integer that says which pattern in the machine description
  538.      matches this insn, or -1 if the matching has not yet been
  539.      attempted.
  540.      Such matching is never attempted and this field remains -1 on an
  541.      insn whose pattern consists of a single `use', `clobber',
  542.      `asm_input', `addr_vec' or `addr_diff_vec' expression.
  543.      Matching is also never attempted on insns that result from an `asm'
  544.      statement.  These contain at least one `asm_operands' expression.
  545.      The function `asm_noperands' returns a non-negative value for such
  546.      insns.
  547.      In the debugging output, this field is printed as a number
  548.      followed by a symbolic representation that locates the pattern in
  549.      the `md' file as some small positive or negative offset from a
  550.      named pattern.
  551. `LOG_LINKS (I)'
  552.      A list (chain of `insn_list' expressions) giving information about
  553.      dependencies between instructions within a basic block.  Neither a
  554.      jump nor a label may come between the related insns.
  555. `REG_NOTES (I)'
  556.      A list (chain of `expr_list' and `insn_list' expressions) giving
  557.      miscellaneous information about the insn.  It is often information
  558.      pertaining to the registers used in this insn.
  559.    The `LOG_LINKS' field of an insn is a chain of `insn_list'
  560. expressions.  Each of these has two operands: the first is an insn, and
  561. the second is another `insn_list' expression (the next one in the
  562. chain).  The last `insn_list' in the chain has a null pointer as second
  563. operand.  The significant thing about the chain is which insns appear
  564. in it (as first operands of `insn_list' expressions).  Their order is
  565. not significant.
  566.    This list is originally set up by the flow analysis pass; it is a
  567. null pointer until then.  Flow only adds links for those data
  568. dependencies which can be used for instruction combination.  For each
  569. insn, the flow analysis pass adds a link to insns which store into
  570. registers values that are used for the first time in this insn.  The
  571. instruction scheduling pass adds extra links so that every dependence
  572. will be represented.  Links represent data dependencies,
  573. antidependencies and output dependencies; the machine mode of the link
  574. distinguishes these three types: antidependencies have mode
  575. `REG_DEP_ANTI', output dependencies have mode `REG_DEP_OUTPUT', and
  576. data dependencies have mode `VOIDmode'.
  577.    The `REG_NOTES' field of an insn is a chain similar to the
  578. `LOG_LINKS' field but it includes `expr_list' expressions in addition
  579. to `insn_list' expressions.  There are several kinds of register notes,
  580. which are distinguished by the machine mode, which in a register note
  581. is really understood as being an `enum reg_note'. The first operand OP
  582. of the note is data whose meaning depends on the kind of note.
  583.    The macro `REG_NOTE_KIND (X)' returns the kind of register note. 
  584. Its counterpart, the macro `PUT_REG_NOTE_KIND (X, NEWKIND)' sets the
  585. register note type of X to be NEWKIND.
  586.    Register notes are of three classes: They may say something about an
  587. input to an insn, they may say something about an output of an insn, or
  588. they may create a linkage between two insns.  There are also a set of
  589. values that are only used in `LOG_LINKS'.
  590.    These register notes annotate inputs to an insn:
  591. `REG_DEAD'
  592.      The value in OP dies in this insn; that is to say, altering the
  593.      value immediately after this insn would not affect the future
  594.      behavior of the program.
  595.      This does not necessarily mean that the register OP has no useful
  596.      value after this insn since it may also be an output of the insn. 
  597.      In such a case, however, a `REG_DEAD' note would be redundant and
  598.      is usually not present until after the reload pass, but no code
  599.      relies on this fact.
  600. `REG_INC'
  601.      The register OP is incremented (or decremented; at this level
  602.      there is no distinction) by an embedded side effect inside this
  603.      insn. This means it appears in a `post_inc', `pre_inc', `post_dec'
  604.      or `pre_dec' expression.
  605. `REG_NONNEG'
  606.      The register OP is known to have a nonnegative value when this
  607.      insn is reached.  This is used so that decrement and branch until
  608.      zero instructions, such as the m68k dbra, can be matched.
  609.      The `REG_NONNEG' note is added to insns only if the machine
  610.      description contains a pattern named
  611.      `decrement_and_branch_until_zero'.
  612. `REG_NO_CONFLICT'
  613.      This insn does not cause a conflict between OP and the item being
  614.      set by this insn even though it might appear that it does. In
  615.      other words, if the destination register and OP could otherwise be
  616.      assigned the same register, this insn does not prevent that
  617.      assignment.
  618.      Insns with this note are usually part of a block that begins with a
  619.      `clobber' insn specifying a multi-word pseudo register (which will
  620.      be the output of the block), a group of insns that each set one
  621.      word of the value and have the `REG_NO_CONFLICT' note attached,
  622.      and a final insn that copies the output to itself with an attached
  623.      `REG_EQUAL' note giving the expression being computed.  This block
  624.      is encapsulated with `REG_LIBCALL' and `REG_RETVAL' notes on the
  625.      first and last insns, respectively.
  626. `REG_LABEL'
  627.      This insn uses OP, a `code_label', but is not a `jump_insn'.  The
  628.      presence of this note allows jump optimization to be aware that OP
  629.      is, in fact, being used.
  630.    The following notes describe attributes of outputs of an insn:
  631. `REG_EQUIV'
  632. `REG_EQUAL'
  633.      This note is only valid on an insn that sets only one register and
  634.      indicates that that register will be equal to OP at run time; the
  635.      scope of this equivalence differs between the two types of notes. 
  636.      The value which the insn explicitly copies into the register may
  637.      look different from OP, but they will be equal at run time.  If the
  638.      output of the single `set' is a `strict_low_part' expression, the
  639.      note refers to the register that is contained in `SUBREG_REG' of
  640.      the `subreg' expression.
  641.      For `REG_EQUIV', the register is equivalent to OP throughout the
  642.      entire function, and could validly be replaced in all its
  643.      occurrences by OP.  ("Validly" here refers to the data flow of the
  644.      program; simple replacement may make some insns invalid.)  For
  645.      example, when a constant is loaded into a register that is never
  646.      assigned any other value, this kind of note is used.
  647.      When a parameter is copied into a pseudo-register at entry to a
  648.      function, a note of this kind records that the register is
  649.      equivalent to the stack slot where the parameter was passed. 
  650.      Although in this case the register may be set by other insns, it
  651.      is still valid to replace the register by the stack slot
  652.      throughout the function.
  653.      In the case of `REG_EQUAL', the register that is set by this insn
  654.      will be equal to OP at run time at the end of this insn but not
  655.      necessarily elsewhere in the function.  In this case, OP is
  656.      typically an arithmetic expression.  For example, when a sequence
  657.      of insns such as a library call is used to perform an arithmetic
  658.      operation, this kind of note is attached to the insn that produces
  659.      or copies the final value.
  660.      These two notes are used in different ways by the compiler passes.
  661.      `REG_EQUAL' is used by passes prior to register allocation (such as
  662.      common subexpression elimination and loop optimization) to tell
  663.      them how to think of that value.  `REG_EQUIV' notes are used by
  664.      register allocation to indicate that there is an available
  665.      substitute expression (either a constant or a `mem' expression for
  666.      the location of a parameter on the stack) that may be used in
  667.      place of a register if insufficient registers are available.
  668.      Except for stack homes for parameters, which are indicated by a
  669.      `REG_EQUIV' note and are not useful to the early optimization
  670.      passes and pseudo registers that are equivalent to a memory
  671.      location throughout there entire life, which is not detected until
  672.      later in the compilation, all equivalences are initially indicated
  673.      by an attached `REG_EQUAL' note.  In the early stages of register
  674.      allocation, a `REG_EQUAL' note is changed into a `REG_EQUIV' note
  675.      if OP is a constant and the insn represents the only set of its
  676.      destination register.
  677.      Thus, compiler passes prior to register allocation need only check
  678.      for `REG_EQUAL' notes and passes subsequent to register allocation
  679.      need only check for `REG_EQUIV' notes.
  680. `REG_UNUSED'
  681.      The register OP being set by this insn will not be used in a
  682.      subsequent insn.  This differs from a `REG_DEAD' note, which
  683.      indicates that the value in an input will not be used subsequently.
  684.      These two notes are independent; both may be present for the same
  685.      register.
  686. `REG_WAS_0'
  687.      The single output of this insn contained zero before this insn. OP
  688.      is the insn that set it to zero.  You can rely on this note if it
  689.      is present and OP has not been deleted or turned into a `note';
  690.      its absence implies nothing.
  691.    These notes describe linkages between insns.  They occur in pairs:
  692. one insn has one of a pair of notes that points to a second insn, which
  693. has the inverse note pointing back to the first insn.
  694. `REG_RETVAL'
  695.      This insn copies the value of a multi-insn sequence (for example, a
  696.      library call), and OP is the first insn of the sequence (for a
  697.      library call, the first insn that was generated to set up the
  698.      arguments for the library call).
  699.      Loop optimization uses this note to treat such a sequence as a
  700.      single operation for code motion purposes and flow analysis uses
  701.      this note to delete such sequences whose results are dead.
  702.      A `REG_EQUAL' note will also usually be attached to this insn to
  703.      provide the expression being computed by the sequence.
  704. `REG_LIBCALL'
  705.      This is the inverse of `REG_RETVAL': it is placed on the first
  706.      insn of a multi-insn sequence, and it points to the last one.
  707. `REG_CC_SETTER'
  708. `REG_CC_USER'
  709.      On machines that use `cc0', the insns which set and use `cc0' set
  710.      and use `cc0' are adjacent.  However, when branch delay slot
  711.      filling is done, this may no longer be true.  In this case a
  712.      `REG_CC_USER' note will be placed on the insn setting `cc0' to
  713.      point to the insn using `cc0' and a `REG_CC_SETTER' note will be
  714.      placed on the insn using `cc0' to point to the insn setting `cc0'.
  715.    These values are only used in the `LOG_LINKS' field, and indicate
  716. the type of dependency that each link represents.  Links which indicate
  717. a data dependence (a read after write dependence) do not use any code,
  718. they simply have mode `VOIDmode', and are printed without any
  719. descriptive text.
  720. `REG_DEP_ANTI'
  721.      This indicates an anti dependence (a write after read dependence).
  722. `REG_DEP_OUTPUT'
  723.      This indicates an output dependence (a write after write
  724.      dependence).
  725.    For convenience, the machine mode in an `insn_list' or `expr_list'
  726. is printed using these symbolic codes in debugging dumps.
  727.    The only difference between the expression codes `insn_list' and
  728. `expr_list' is that the first operand of an `insn_list' is assumed to
  729. be an insn and is printed in debugging dumps as the insn's unique id;
  730. the first operand of an `expr_list' is printed in the ordinary way as
  731. an expression.
  732. File: gcc.info,  Node: Calls,  Next: Sharing,  Prev: Insns,  Up: RTL
  733. RTL Representation of Function-Call Insns
  734. =========================================
  735.    Insns that call subroutines have the RTL expression code `call_insn'.
  736. These insns must satisfy special rules, and their bodies must use a
  737. special RTL expression code, `call'.
  738.    A `call' expression has two operands, as follows:
  739.      (call (mem:FM ADDR) NBYTES)
  740. Here NBYTES is an operand that represents the number of bytes of
  741. argument data being passed to the subroutine, FM is a machine mode
  742. (which must equal as the definition of the `FUNCTION_MODE' macro in the
  743. machine description) and ADDR represents the address of the subroutine.
  744.    For a subroutine that returns no value, the `call' expression as
  745. shown above is the entire body of the insn, except that the insn might
  746. also contain `use' or `clobber' expressions.
  747.    For a subroutine that returns a value whose mode is not `BLKmode',
  748. the value is returned in a hard register.  If this register's number is
  749. R, then the body of the call insn looks like this:
  750.      (set (reg:M R)
  751.           (call (mem:FM ADDR) NBYTES))
  752. This RTL expression makes it clear (to the optimizer passes) that the
  753. appropriate register receives a useful value in this insn.
  754.    When a subroutine returns a `BLKmode' value, it is handled by
  755. passing to the subroutine the address of a place to store the value. So
  756. the call insn itself does not "return" any value, and it has the same
  757. RTL form as a call that returns nothing.
  758.    On some machines, the call instruction itself clobbers some register,
  759. for example to contain the return address.  `call_insn' insns on these
  760. machines should have a body which is a `parallel' that contains both
  761. the `call' expression and `clobber' expressions that indicate which
  762. registers are destroyed.  Similarly, if the call instruction requires
  763. some register other than the stack pointer that is not explicitly
  764. mentioned it its RTL, a `use' subexpression should mention that
  765. register.
  766.    Functions that are called are assumed to modify all registers listed
  767. in the configuration macro `CALL_USED_REGISTERS' (*note Register
  768. Basics::.) and, with the exception of `const' functions and library
  769. calls, to modify all of memory.
  770.    Insns containing just `use' expressions directly precede the
  771. `call_insn' insn to indicate which registers contain inputs to the
  772. function.  Similarly, if registers other than those in
  773. `CALL_USED_REGISTERS' are clobbered by the called function, insns
  774. containing a single `clobber' follow immediately after the call to
  775. indicate which registers.
  776. File: gcc.info,  Node: Sharing,  Prev: Calls,  Up: RTL
  777. Structure Sharing Assumptions
  778. =============================
  779.    The compiler assumes that certain kinds of RTL expressions are
  780. unique; there do not exist two distinct objects representing the same
  781. value. In other cases, it makes an opposite assumption: that no RTL
  782. expression object of a certain kind appears in more than one place in
  783. the containing structure.
  784.    These assumptions refer to a single function; except for the RTL
  785. objects that describe global variables and external functions, and a
  786. few standard objects such as small integer constants, no RTL objects
  787. are common to two functions.
  788.    * Each pseudo-register has only a single `reg' object to represent
  789.      it, and therefore only a single machine mode.
  790.    * For any symbolic label, there is only one `symbol_ref' object
  791.      referring to it.
  792.    * There is only one `const_int' expression with value 0, only one
  793.      with value 1, and only one with value -1. Some other integer
  794.      values are also stored uniquely.
  795.    * There is only one `pc' expression.
  796.    * There is only one `cc0' expression.
  797.    * There is only one `const_double' expression with value 0 for each
  798.      floating point mode.  Likewise for values 1 and 2.
  799.    * No `label_ref' or `scratch' appears in more than one place in the
  800.      RTL structure; in other words, it is safe to do a tree-walk of all
  801.      the insns in the function and assume that each time a `label_ref'
  802.      or `scratch' is seen it is distinct from all others that are seen.
  803.    * Only one `mem' object is normally created for each static variable
  804.      or stack slot, so these objects are frequently shared in all the
  805.      places they appear.  However, separate but equal objects for these
  806.      variables are occasionally made.
  807.    * When a single `asm' statement has multiple output operands, a
  808.      distinct `asm_operands' expression is made for each output operand.
  809.      However, these all share the vector which contains the sequence of
  810.      input operands.  This sharing is used later on to test whether two
  811.      `asm_operands' expressions come from the same statement, so all
  812.      optimizations must carefully preserve the sharing if they copy the
  813.      vector at all.
  814.    * No RTL object appears in more than one place in the RTL structure
  815.      except as described above.  Many passes of the compiler rely on
  816.      this by assuming that they can modify RTL objects in place without
  817.      unwanted side-effects on other insns.
  818.    * During initial RTL generation, shared structure is freely
  819.      introduced. After all the RTL for a function has been generated,
  820.      all shared structure is copied by `unshare_all_rtl' in
  821.      `emit-rtl.c', after which the above rules are guaranteed to be
  822.      followed.
  823.    * During the combiner pass, shared structure within an insn can exist
  824.      temporarily.  However, the shared structure is copied before the
  825.      combiner is finished with the insn.  This is done by calling
  826.      `copy_rtx_if_shared', which is a subroutine of `unshare_all_rtl'.
  827. File: gcc.info,  Node: Machine Desc,  Next: Target Macros,  Prev: RTL,  Up: Top
  828. Machine Descriptions
  829. ********************
  830.    A machine description has two parts: a file of instruction patterns
  831. (`.md' file) and a C header file of macro definitions.
  832.    The `.md' file for a target machine contains a pattern for each
  833. instruction that the target machine supports (or at least each
  834. instruction that is worth telling the compiler about).  It may also
  835. contain comments. A semicolon causes the rest of the line to be a
  836. comment, unless the semicolon is inside a quoted string.
  837.    See the next chapter for information on the C header file.
  838. * Menu:
  839. * Patterns::            How to write instruction patterns.
  840. * Example::             An explained example of a `define_insn' pattern.
  841. * RTL Template::        The RTL template defines what insns match a pattern.
  842. * Output Template::     The output template says how to make assembler code
  843.                           from such an insn.
  844. * Output Statement::    For more generality, write C code to output
  845.                           the assembler code.
  846. * Constraints::         When not all operands are general operands.
  847. * Standard Names::      Names mark patterns to use for code generation.
  848. * Pattern Ordering::    When the order of patterns makes a difference.
  849. * Dependent Patterns::  Having one pattern may make you need another.
  850. * Jump Patterns::       Special considerations for patterns for jump insns.
  851. * Insn Canonicalizations::Canonicalization of Instructions
  852. * Peephole Definitions::Defining machine-specific peephole optimizations.
  853. * Expander Definitions::Generating a sequence of several RTL insns
  854.                          for a standard operation.
  855. * Insn Splitting::    Splitting Instructions into Multiple Instructions
  856. * Insn Attributes::     Specifying the value of attributes for generated insns.
  857.