home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / msdos / djgpp / docs / gcc / gcc.i11 < prev    next >
Encoding:
GNU Info File  |  1993-05-29  |  49.9 KB  |  1,106 lines

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