home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / gcc.info-15 (.txt) < prev    next >
GNU Info File  |  1995-11-26  |  51KB  |  878 lines

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