home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / gccdoc2.zip / MD.TXT < prev    next >
Text File  |  1992-05-22  |  150KB  |  3,961 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                 INTERNALS
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.           1.  Machine Descriptions
  75.  
  76.                A machine description has two parts: a file of instruc-
  77.           tion  patterns  (`.md'  file)  and  a C header file of macro
  78.           definitions.
  79.  
  80.                The `.md' file for a target machine contains a  pattern
  81.           for each instruction that the target machine supports (or at
  82.           least each instruction that is worth  telling  the  compiler
  83.           about).   It  may also contain comments.  A semicolon causes
  84.           the rest of the line to be a comment, unless  the  semicolon
  85.           is inside a quoted string.
  86.  
  87.                See the next chapter for information on  the  C  header
  88.           file.
  89.  
  90.  
  91.  
  92.           1.1.  Everything about Instruction Patterns
  93.  
  94.                Each instruction pattern  contains  an  incomplete  RTL
  95.           expression,  with pieces to be filled in later, operand con-
  96.           straints that restrict how the pieces can be filled in,  and
  97.           an  output  pattern or C code to generate the assembler out-
  98.           put, all wrapped up in a define_insn expression.
  99.  
  100.                A define_insn is an RTL expression containing  four  or
  101.           five operands:
  102.  
  103.                1.   An optional name.  The presence of a name indicate
  104.                     that  this  instruction pattern can perform a cer-
  105.                     tain standard job for the RTL-generation  pass  of
  106.                     the  compiler.   This pass knows certain names and
  107.                     will  use  the  instruction  patterns  with  those
  108.                     names,  if  the  names  are defined in the machine
  109.                     description.
  110.  
  111.                     The absence of a name is indicated by  writing  an
  112.                     empty  string  where the name should go.  Nameless
  113.                     instruction patterns are never used for generating
  114.                     RTL  code,  but  they  may  permit several simpler
  115.                     insns to be combined later on.
  116.  
  117.                     Names that are not thus known  and  used  in  RTL-
  118.                     generation  have no effect; they are equivalent to
  119.                     no name at all.
  120.  
  121.                2.   The RTL template (see section  RTL Template) is  a
  122.                     vector  of  incomplete  RTL expressions which show
  123.                     what the instruction should look like.  It is  in-
  124.                     complete  because  it  may  contain match_operand,
  125.                     match_operator,  and  match_dup  expressions  that
  126.                     stand for operands of the instruction.
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.                     If the vector has only one element,  that  element
  141.                     is  the  template for the instruction pattern.  If
  142.                     the vector has multiple  elements,  then  the  in-
  143.                     struction  pattern  is  a parallel expression con-
  144.                     taining the elements described.
  145.  
  146.                3.   A condition.  This is a string which contains a  C
  147.                     expression that is the final test to decide wheth-
  148.                     er an insn body matches this pattern.
  149.  
  150.                     For a named pattern, the  condition  (if  present)
  151.                     may  not  depend  on  the  data  in the insn being
  152.                     matched, but only the  target-machine-type  flags.
  153.                     The compiler needs to test these conditions during
  154.                     initialization in order  to  learn  exactly  which
  155.                     named  instructions  are available in a particular
  156.                     run.
  157.  
  158.                     For nameless patterns, the  condition  is  applied
  159.                     only  when  matching  an individual insn, and only
  160.                     after the insn has matched the pattern's  recogni-
  161.                     tion  template.   The insn's operands may be found
  162.                     in the vector operands.
  163.  
  164.                4.   The output template: a string  that  says  how  to
  165.                     output  matching  insns as assembler code.  `%' in
  166.                     this string  specifies  where  to  substitute  the
  167.                     value of an operand.  See section Output Template.
  168.  
  169.                     When simple substitution isn't general enough, you
  170.                     can  specify a piece of C code to compute the out-
  171.                     put.  See section Output Statement.
  172.  
  173.                5.   Optionally, a vector containing the values of  at-
  174.                     tributes  for  insns  matching  this pattern.  See
  175.                     section Insn Attributes.
  176.  
  177.  
  178.           1.2.  Example of define_insn
  179.  
  180.                Here is an actual example of  an  instruction  pattern,
  181.           for the 68000/68020.
  182.  
  183.  
  184.               (define_insn "tstsi"
  185.                 [(set (cc0)
  186.                       (match_operand:SI 0 "general_operand" "rm"))]
  187.                 ""
  188.                 "*
  189.               { if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  190.                   return \"tstl %0\";
  191.                 return \"cmpl #0,%0\"; }")
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.                This is an instruction that sets  the  condition  codes
  209.           based  on  the value of a general operand.  It has no condi-
  210.           tion, so any insn whose RTL description has the  form  shown
  211.           may  be handled according to this pattern.  The name `tstsi'
  212.           means ``test a SImode value'' and tells the  RTL  generation
  213.           pass  that,  when  it  is necessary to test such a value, an
  214.           insn to do so can be constructed using this pattern.
  215.  
  216.                The output control string is a piece of  C  code  which
  217.           chooses which output template to return based on the kind of
  218.           operand and the specific type of CPU for which code is being
  219.           generated.
  220.  
  221.                `"rm"'  is  an  operand  constraint.   Its  meaning  is
  222.           explained below.
  223.  
  224.           1.3.  RTL Template for Generating and Recognizing Insns
  225.  
  226.                The RTL template is used to define  which  insns  match
  227.           the  particular pattern and how to find their operands.  For
  228.           named patterns, the RTL template also says how to  construct
  229.           an insn from specified operands.
  230.  
  231.                Construction involves substituting  specified  operands
  232.           into  a copy of the template.  Matching involves determining
  233.           the values that serve as the  operands  in  the  insn  being
  234.           matched.  Both of these activities are controlled by special
  235.           expression types that direct matching  and  substitution  of
  236.           the operands.
  237.  
  238.                (match_operand:m n predicate constraint)
  239.                     This  expression  is  a  placeholder  for  operand
  240.                     number  n of the insn.  When constructing an insn,
  241.                     operand number  n  will  be  substituted  at  this
  242.                     point.  When matching an insn, whatever appears at
  243.                     this position in the insn will be taken as operand
  244.                     number  n;  but  it must satisfy predicate or this
  245.                     instruction pattern will not match at all.
  246.  
  247.                     Operand  numbers  must  be  chosen   consecutively
  248.                     counting  from  zero  in each instruction pattern.
  249.                     There may be only one match_operand expression  in
  250.                     the  pattern  for  each  operand  number.  Usually
  251.                     operands are numbered in the order  of  appearance
  252.                     in match_operand expressions.
  253.  
  254.                     predicate is a string that is  the  name  of  a  C
  255.                     function that accepts two arguments, an expression
  256.                     and a machine mode.  During matching, the function
  257.                     will  be  called  with the putative operand as the
  258.                     expression and m as the mode argument (if m is not
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.                     specified,  VOIDmode  will be used, which normally
  273.                     causes predicate to accept any mode).  If  it  re-
  274.                     turns  zero,  this  instruction  pattern  fails to
  275.                     match.  predicate may be an empty string; then  it
  276.                     means  no  test  is  to be done on the operand, so
  277.                     anything which occurs in this position is valid.
  278.  
  279.                     Most of the time, predicate will reject modes oth-
  280.                     er  than  m---but  not  always.   For example, the
  281.                     predicate address_operand uses m as  the  mode  of
  282.                     memory  ref  that the address should be valid for.
  283.                     Many predicates accept const_int nodes even though
  284.                     their mode is VOIDmode.
  285.  
  286.                     constraint controls reloading and  the  choice  of
  287.                     the best register class to use for a value, as ex-
  288.                     plained later (see section  Constraints).
  289.  
  290.                     People are often unclear on the difference between
  291.                     the  constraint  and the predicate.  The predicate
  292.                     helps decide whether a given insn matches the pat-
  293.                     tern.   The constraint plays no role in this deci-
  294.                     sion; instead, it controls  various  decisions  in
  295.                     the case of an insn which does match.
  296.  
  297.                     On  CISC  machines,  predicate   is   most   often
  298.                     "general_operand".   This function checks that the
  299.                     putative operand is either a constant, a  register
  300.                     or  a  memory  reference, and that it is valid for
  301.                     mode m.
  302.  
  303.                     For an operand that must be a register,  predicate
  304.                     should  be  "register_operand".  It would be valid
  305.                     to use "general_operand", since  the  reload  pass
  306.                     would  copy  any non-register operands through re-
  307.                     gisters, but this would make GNU CC do extra work,
  308.                     it  would prevent invariant operands (such as con-
  309.                     stant) from being removed from loops, and it would
  310.                     prevent the register allocator from doing the best
  311.                     possible job.  On RISC  machines,  it  is  usually
  312.                     most  efficient  to allow predicate to accept only
  313.                     objects that the constraints allow.
  314.  
  315.                     For an operand that must be a constant, either use
  316.                     "immediate_operand" for predicate, or make the in-
  317.                     struction pattern's extra condition require a con-
  318.                     stant, or both.  You cannot expect the constraints
  319.                     to do this work!  If the  constraints  allow  only
  320.                     constants,  but  the  predicate  allows  something
  321.                     else, the compiler will crash when that  case  ar-
  322.                     ises.
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.                (match_scratch:m n constraint)
  339.                     This expression is also a placeholder for  operand
  340.                     number  n  and  indicates  that  operand must be a
  341.                     scratch or reg expression.
  342.  
  343.                     When  matching  patterns,   this   is   completely
  344.                     equivalent to
  345.  
  346.  
  347.                         (match_operand:m n "scratch_operand" pred)
  348.  
  349.  
  350.  
  351.                     but,  when  generating  RTL,  it  produces   a
  352.                     (scratch:m) expression.
  353.  
  354.                     If the last few expressions in a parallel  are
  355.                     clobber  expressions whose operands are either
  356.                     a hard register or match_scratch, the combiner
  357.                     can add them when necessary.  See section Side
  358.                     Effects.
  359.  
  360.                (match_dup n)
  361.                     This expression  is  also  a  placeholder  for
  362.                     operand number n.  It is used when the operand
  363.                     needs to appear more than once in the insn.
  364.  
  365.                     In  construction,  match_dup  behaves  exactly
  366.                     like match_operand: the operand is substituted
  367.                     into  the  insn  being  constructed.   But  in
  368.                     matching,  match_dup  behaves differently.  It
  369.                     assumes that operand number n has already been
  370.                     determined  by  a match_operand appearing ear-
  371.                     lier  in  the  recognition  template,  and  it
  372.                     matches only an identical-looking expression.
  373.  
  374.                (match_operator:m n predicate [operands...])
  375.                     This pattern is a kind of  placeholder  for  a
  376.                     variable RTL expression code.
  377.  
  378.                     When constructing an insn, it  stands  for  an
  379.                     RTL  expression whose expression code is taken
  380.                     from that of operand n, and whose operands are
  381.                     constructed from the patterns operands.
  382.  
  383.                     When matching an expression, it matches an ex-
  384.                     pression  if  the  function  predicate returns
  385.                     nonzero on that expression  and  the  patterns
  386.                     operands match the operands of the expression.
  387.  
  388.                     Suppose that the function commutative_operator
  389.                     is defined as follows, to match any expression
  390.                     whose operator is one of the  commutative  ar-
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.                     ithmetic  operators  of  RTL and whose mode is
  405.                     mode:
  406.  
  407.  
  408.                         int
  409.                         commutative_operator (x, mode)
  410.                              rtx x;
  411.                              enum machine_mode mode;
  412.                         {
  413.                           enum rtx_code code = GET_CODE (x);
  414.                           if (GET_MODE (x) != mode)
  415.                             return 0;
  416.                           return GET_RTX_CLASS (code) == 'c' || code == EQ || code == NE;
  417.                         }
  418.  
  419.  
  420.  
  421.                     Then the following pattern will match any  RTL
  422.                     expression  consisting of a commutative opera-
  423.                     tor applied to two general operands:
  424.  
  425.  
  426.                         (match_operator:SI 3 "commutative_operator"
  427.                           [(match_operand:SI 1 "general_operand" "g")
  428.                            (match_operand:SI 2 "general_operand" "g")])
  429.  
  430.  
  431.  
  432.                     Here the  vector  [operands...]  contains  two
  433.                     patterns because the expressions to be matched
  434.                     all contain two operands.
  435.  
  436.                     When this pattern does match, the two operands
  437.                     of  the  commutative  operator are recorded as
  438.                     operands 1 and 2 of the insn.  (This  is  done
  439.                     by   the   two  instances  of  match_operand.)
  440.                     Operand 3 of the insn will be the entire  com-
  441.                     mutative      expression:     use     GET_CODE
  442.                     (operands[3]) to see which commutative  opera-
  443.                     tor was used.
  444.  
  445.                     The machine mode  m  of  match_operator  works
  446.                     like  that  of  match_operand: it is passed as
  447.                     the second argument to the predicate function,
  448.                     and  that  function  is solely responsible for
  449.                     deciding whether the expression to be  matched
  450.                     ``has'' that mode.
  451.  
  452.                     When constructing an insn, argument 3  of  the
  453.                     gen-function  will specify the operation (i.e.
  454.                     the expression code) for the expression to  be
  455.                     made.   It  should be an RTL expression, whose
  456.                     expression code is copied into a  new  expres-
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.                     sion  whose  operands are arguments 1 and 2 of
  471.                     the gen-function.  The subexpressions of argu-
  472.                     ment  3 are not used; only its expression code
  473.                     matters.
  474.  
  475.                     When match_operator is used in a  pattern  for
  476.                     matching  an  insn,  it  usually  best  if the
  477.                     operand number of the match_operator is higher
  478.                     than  that of the actual operands of the insn.
  479.                     This improves register allocation because  the
  480.                     register  allocator  often looks at operands 1
  481.                     and 2 of insns to see if it  can  do  register
  482.                     tying.
  483.  
  484.                     There is no  way  to  specify  constraints  in
  485.                     match_operator.  The operand of the insn which
  486.                     corresponds to the  match_operator  never  has
  487.                     any  constraints  because it is never reloaded
  488.                     as a whole.  However, if parts of its operands
  489.                     are  matched  by match_operand patterns, those
  490.                     parts may have constraints of their own.
  491.  
  492.                (address (match_operand:m n "address_operand" ""))
  493.                     This complex of expressions is  a  placeholder
  494.                     for  an operand number n in a ``load address''
  495.                     instruction:  an  operand  which  specifies  a
  496.                     memory  location  in  the  usual  way, but for
  497.                     which the actual operand value used is the ad-
  498.                     dress of the location, not the contents of the
  499.                     location.
  500.  
  501.                     address expressions never appear in RTL  code,
  502.                     only  in  machine  descriptions.  And they are
  503.                     used only in machine descriptions that do  not
  504.                     use  the  operand  constraint  feature.   When
  505.                     operand constraints are in use, the letter `p'
  506.                     in the constraint serves this purpose.
  507.  
  508.                     m is the machine mode of the  memory  location
  509.                     being  addressed,  not the machine mode of the
  510.                     address itself.  That mode is always the  same
  511.                     on  a given target machine (it is Pmode, which
  512.                     normally is SImode), so there is no  point  in
  513.                     mentioning  it; thus, no machine mode is writ-
  514.                     ten in the address expression.   If  some  day
  515.                     support  is  added  for  machines in which ad-
  516.                     dresses of different kinds of  objects  appear
  517.                     differently  or  are used differently (such as
  518.                     the PDP-10), different formats  would  perhaps
  519.                     need  different  machine modes and these modes
  520.                     might be written in the address expression.
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.           1.4.  Output Templates and Operand Substitution
  537.  
  538.                The output template is a string which specifies how  to
  539.           output  the assembler code for an instruction pattern.  Most
  540.           of the template is a fixed string which is output literally.
  541.           The  character `%' is used to specify where to substitute an
  542.           operand; it can also be used to identify places  where  dif-
  543.           ferent variants of the assembler require different syntax.
  544.  
  545.                In the simplest case, a `%' followed by a digit n  says
  546.           to output operand n at that point in the string.
  547.  
  548.                `%' followed by a letter and a digit says to output  an
  549.           operand  in  an  alternate fashion.  Four letters have stan-
  550.           dard,  built-in  meanings  described  below.   The   machine
  551.           description   macro   PRINT_OPERAND  can  define  additional
  552.           letters with nonstandard meanings.
  553.  
  554.                `%cdigit' can be used to substitute an operand that  is
  555.           a  constant value without the syntax that normally indicates
  556.           an immediate operand.
  557.  
  558.                `%ndigit' is like `%cdigit' except that  the  value  of
  559.           the constant is negated before printing.
  560.  
  561.                `%adigit' can be used to substitute an operand as if it
  562.           were  a memory reference, with the actual operand treated as
  563.           the address.  This may be useful when  outputting  a  ``load
  564.           address''  instruction,  because  often the assembler syntax
  565.           for such an instruction requires you to write the operand as
  566.           if it were a memory reference.
  567.  
  568.                `%ldigit' is used to substitute a label_ref into a jump
  569.           instruction.
  570.  
  571.                `%' followed by a  punctuation  character  specifies  a
  572.           substitution that does not use an operand.  Only one case is
  573.           standard: `%%' outputs a `%' into the assembler code.  Other
  574.           nonstandard cases can be defined in the PRINT_OPERAND macro.
  575.           You must also define which punctuation characters are  valid
  576.           with the PRINT_OPERAND_PUNCT_VALID_P macro.
  577.  
  578.                The template may generate multiple  assembler  instruc-
  579.           tions.   Write  the  text  for  the  instructions, with `\;'
  580.           between them.
  581.  
  582.                When the RTL contains two operands which  are  required
  583.           by  constraint to match each other, the output template must
  584.           refer only to the lower-numbered operand.  Matching operands
  585.           are  not  always  identical,  and  the  rest of the compiler
  586.           arranges to put the proper RTL expression for printing  into
  587.           the lower-numbered operand.
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.                One use of nonstandard letters or punctuation following
  603.           `%'  is to distinguish between different assembler languages
  604.           for the same machine; for example,  Motorola  syntax  versus
  605.           MIT  syntax for the 68000.  Motorola syntax requires periods
  606.           in most opcode names, while MIT syntax does not.  For  exam-
  607.           ple,  the  opcode  `movel'  in  MIT  syntax  is  `move.l' in
  608.           Motorola syntax.  The same file of patterns is used for both
  609.           kinds  of  output syntax, but the character sequence `%.' is
  610.           used in each place where Motorola  syntax  wants  a  period.
  611.           The  PRINT_OPERAND  macro  for  Motorola  syntax defines the
  612.           sequence to output  a  period;  the  macro  for  MIT  syntax
  613.           defines it to do nothing.
  614.  
  615.           1.5.  C Statements for Generating Assembler Output
  616.  
  617.                Often a single fixed  template  string  cannot  produce
  618.           correct  and efficient assembler code for all the cases that
  619.           are recognized by a single instruction pattern.   For  exam-
  620.           ple,  the  opcodes  may  depend on the kinds of operands; or
  621.           some unfortunate combinations of operands may require  extra
  622.           machine instructions.
  623.  
  624.                If the output control string starts with a `@', then it
  625.           is  actually a series of templates, each on a separate line.
  626.           (Blank lines and leading spaces and tabs are ignored.)   The
  627.           templates  correspond  to  the pattern's constraint alterna-
  628.           tives (see section  Multi-Alternative).  For example,  if  a
  629.           target  machine  has a two-address add instruction `addr' to
  630.           add into a register and another `addm' to add a register  to
  631.           memory, you might write this pattern:
  632.  
  633.  
  634.               (define_insn "addsi3"
  635.                 [(set (match_operand:SI 0 "general_operand" "r,m")
  636.                       (plus:SI (match_operand:SI 1 "general_operand" "0,0")
  637.                                (match_operand:SI 2 "general_operand" "g,r")))]
  638.                 ""
  639.                 "@
  640.                  addr %1,%0
  641.                  addm %1,%0")
  642.  
  643.  
  644.  
  645.                If the output control string starts with a `*', then it
  646.           is  not  an  output template but rather a piece of C program
  647.           that should compute a template.  It should execute a  return
  648.           statement to return the template-string you want.  Most such
  649.           templates use C string literals, which  require  doublequote
  650.           characters  to  delimit  them.  To include these doublequote
  651.           characters in the string, prefix each one with `\'.
  652.  
  653.                The operands may be found in the array operands,  whose
  654.           C data type is rtx [].
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.                It is very common to select different ways of  generat-
  669.           ing  assembler code based on whether an immediate operand is
  670.           within a certain range.  Be careful when doing this, because
  671.           the  result of INTVAL is an integer on the host machine.  If
  672.           the host machine has more bits in an  int  than  the  target
  673.           machine  has in the mode in which the constant will be used,
  674.           then some of the bits you get from INTVAL will be  superflu-
  675.           ous.   For  proper results, you must carefully disregard the
  676.           values of those bits.
  677.  
  678.                It is possible to output an assembler  instruction  and
  679.           then go on to output or compute more of them, using the sub-
  680.           routine output_asm_insn.  This  receives  two  arguments:  a
  681.           template-string and a vector of operands.  The vector may be
  682.           operands, or it may be another array of rtx that you declare
  683.           locally and initialize yourself.
  684.  
  685.                When an insn pattern has multiple alternatives  in  its
  686.           constraints,  often  the appearance of the assembler code is
  687.           determined mostly by which alternative  was  matched.   When
  688.           this   is   so,   the   C   code   can   test  the  variable
  689.           which_alternative, which is the ordinal number of the alter-
  690.           native  that  was actually satisfied (0 for the first, 1 for
  691.           the second alternative, etc.).
  692.  
  693.                For example, suppose there are two opcodes for  storing
  694.           zero,  `clrreg'  for registers and `clrmem' for memory loca-
  695.           tions.  Here is how a pattern could use which_alternative to
  696.           choose between them:
  697.  
  698.  
  699.               (define_insn ""
  700.                 [(set (match_operand:SI 0 "general_operand" "r,m")
  701.                       (const_int 0))]
  702.                 ""
  703.                 "*
  704.                 return (which_alternative == 0
  705.                         ? \"clrreg %0\" : \"clrmem %0\");
  706.                 ")
  707.  
  708.  
  709.  
  710.                The example above, where the assembler code to generate
  711.           was  solely  determined  by the alternative, could also have
  712.           been specified as follows, having the output control  string
  713.           start with a `@':
  714.  
  715.  
  716.               (define_insn ""
  717.                 [(set (match_operand:SI 0 "general_operand" "r,m")
  718.                       (const_int 0))]
  719.                 ""
  720.                 "@
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.                  clrreg %0
  735.                  clrmem %0")
  736.  
  737.  
  738.  
  739.           1.6.  Operand Constraints
  740.  
  741.                Each  match_operand  in  an  instruction  pattern   can
  742.           specify a constraint for the type of operands allowed.  Con-
  743.           straints can say whether an operand may be  in  a  register,
  744.           and  which  kinds  of register; whether the operand can be a
  745.           memory reference, and which kinds of  address;  whether  the
  746.           operand  may  be  an  immediate constant, and which possible
  747.           values it  may  have.   Constraints  can  also  require  two
  748.           operands to match.
  749.  
  750.           1.6.1.  Simple Constraints
  751.  
  752.                The simplest kind of constraint is  a  string  full  of
  753.           letters, each of which describes one kind of operand that is
  754.           permitted.  Here are the letters that are allowed:
  755.  
  756.                `m'  A memory operand is allowed, with any kind of  ad-
  757.                     dress that the machine supports in general.
  758.  
  759.                `o'  A memory operand is allowed, but only if  the  ad-
  760.                     dress  is  offsettable.   This means that adding a
  761.                     small integer (actually, the width in bytes of the
  762.                     operand, as determined by its machine mode) may be
  763.                     added to the address and  the  result  is  also  a
  764.                     valid memory address.
  765.  
  766.                     For example,  an  address  which  is  constant  is
  767.                     offsettable; so is an address that is the sum of a
  768.                     register and a constant (as  long  as  a  slightly
  769.                     larger  constant  is  also  within  the  range  of
  770.                     address-offsets supported by the machine); but  an
  771.                     autoincrement  or  autodecrement  address  is  not
  772.                     offsettable.   More  complicated  indirect/indexed
  773.                     addresses  may or may not be offsettable depending
  774.                     on the other addressing  modes  that  the  machine
  775.                     supports.
  776.  
  777.                     Note that  in  an  output  operand  which  can  be
  778.                     matched  by another operand, the constraint letter
  779.                     `o' is valid only when accompanied by both `<' (if
  780.                     the  target  machine  has predecrement addressing)
  781.                     and `>' (if the target  machine  has  preincrement
  782.                     addressing).
  783.  
  784.                `V'  A memory operand that is not offsettable.  In oth-
  785.                     er  words,  anything  that  would fit the `m' con-
  786.                     straint but not the `o' constraint.
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.                `<'  A memory  operand  with  autodecrement  addressing
  801.                     (either predecrement or postdecrement) is allowed.
  802.  
  803.                `>'  A memory  operand  with  autoincrement  addressing
  804.                     (either preincrement or postincrement) is allowed.
  805.  
  806.                `r'  A register operand is allowed provided that it  is
  807.                     in a general register.
  808.  
  809.                `d', `a', `f', ...
  810.                     Other letters can be defined in  machine-dependent
  811.                     fashion  to stand for particular classes of regis-
  812.                     ters.   `d',  `a'  and  `f'  are  defined  on  the
  813.                     68000/68020  to stand for data, address and float-
  814.                     ing point registers.
  815.  
  816.                `i'  An immediate integer operand  (one  with  constant
  817.                     value)  is  allowed.   This includes symbolic con-
  818.                     stants whose values will be known only at assembly
  819.                     time.
  820.  
  821.                `n'  An immediate integer operand with a known  numeric
  822.                     value  is  allowed.   Many  systems cannot support
  823.                     assembly-time constants for operands less  than  a
  824.                     word  wide.  Constraints for these operands should
  825.                     use `n' rather than `i'.
  826.  
  827.                `I', `J', `K', ... `P'
  828.                     Other letters in the range `I' through `P' may  be
  829.                     defined  in  a machine-dependent fashion to permit
  830.                     immediate integer operands with  explicit  integer
  831.                     values  in  specified ranges.  For example, on the
  832.                     68000, `I' is defined to stand for  the  range  of
  833.                     values  1  to 8.  This is the range permitted as a
  834.                     shift count in the shift instructions.
  835.  
  836.                `E'  An immediate  floating  operand  (expression  code
  837.                     const_double)  is  allowed, but only if the target
  838.                     floating point format is the same as that  of  the
  839.                     host machine (on which the compiler is running).
  840.  
  841.                `F'  An immediate  floating  operand  (expression  code
  842.                     const_double) is allowed.
  843.  
  844.                `G', `H'
  845.                     `G' and `H' may be defined in a  machine-dependent
  846.                     fashion  to  permit immediate floating operands in
  847.                     particular ranges of values.
  848.  
  849.                `s'  An immediate integer operand whose value is not an
  850.                     explicit integer is allowed.
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.                     This might appear strange; if  an  insn  allows  a
  867.                     constant operand with a value not known at compile
  868.                     time, it certainly must allow any known value.  So
  869.                     why  use  `s' instead of `i'?  Sometimes it allows
  870.                     better code to be generated.
  871.  
  872.                     For example, on the 68000 in a  fullword  instruc-
  873.                     tion  it  is possible to use an immediate operand;
  874.                     but if the immediate value  is  between  -128  and
  875.                     127,  better  code  results from loading the value
  876.                     into a register and using the register.   This  is
  877.                     because  the  load  into  the register can be done
  878.                     with a `moveq' instruction.  We arrange  for  this
  879.                     to happen by defining the letter `K' to mean ``any
  880.                     integer outside the range -128 to 127'', and  then
  881.                     specifying `Ks' in the operand constraints.
  882.  
  883.                `g'  Any register, memory or immediate integer  operand
  884.                     is allowed, except for registers that are not gen-
  885.                     eral registers.
  886.  
  887.                `X'  Any operand whatsoever is allowed, even if it does
  888.                     not  satisfy  general_operand.   This  is normally
  889.                     used in the constraint  of  a  match_scratch  when
  890.                     certain  alternatives  will not actually require a
  891.                     scratch register.
  892.  
  893.                `0', `1', `2', ... `9'
  894.                     An operand  that  matches  the  specified  operand
  895.                     number  is  allowed.   If a digit is used together
  896.                     with letters within the same alternative, the  di-
  897.                     git should come last.
  898.  
  899.                     This is called a matching constraint and  what  it
  900.                     really means is that the assembler has only a sin-
  901.                     gle  operand  that  fills  two  roles   considered
  902.                     separate  in  the  RTL  insn.  For example, an add
  903.                     insn has two input operands and one output operand
  904.                     in  the  RTL, but on most machines an add instruc-
  905.                     tion really has only two operands, one of them  an
  906.                     input-output operand.
  907.  
  908.                     Matching constraints work  only  in  circumstances
  909.                     like  that  add  insn.   More  precisely,  the two
  910.                     operands that match must  include  one  input-only
  911.                     operand  and  one  output-only operand.  Moreover,
  912.                     the digit must be a smaller number than the number
  913.                     of the operand that uses it in the constraint.
  914.  
  915.                     For operands to match in a particular case usually
  916.                     means  that they are identical-looking RTL expres-
  917.                     sions.  But in a few special cases specific  kinds
  918.                     of  dissimilarity are allowed.  For example, *x as
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.                     an input operand will  match  *x++  as  an  output
  933.                     operand.   For  proper  results in such cases, the
  934.                     output template  should  always  use  the  output-
  935.                     operand's number when printing the operand.
  936.  
  937.                `p'  An operand that is a valid memory address  is  al-
  938.                     lowed.   This  is  for ``load address'' and ``push
  939.                     address'' instructions.
  940.  
  941.                     `p' in  the  constraint  must  be  accompanied  by
  942.                     address_operand    as   the   predicate   in   the
  943.                     match_operand.  This predicate interprets the mode
  944.                     specified  in the match_operand as the mode of the
  945.                     memory reference for which the  address  would  be
  946.                     valid.
  947.  
  948.                `Q', `R', `S', ... `U'
  949.                     Letters in the range `Q' through `U'  may  be  de-
  950.                     fined  in a machine-dependent fashion to stand for
  951.                     arbitrary operand types.  The machine  description
  952.                     macro  EXTRA_CONSTRAINT  is  passed the operand as
  953.                     its first argument and the  constraint  letter  as
  954.                     its second operand.
  955.  
  956.                     A typical use for this  would  be  to  distinguish
  957.                     certain  types  of  memory  references that affect
  958.                     other insn operands.
  959.  
  960.                     Do not define these constraint letters  to  accept
  961.                     register  references  (reg);  the reload pass does
  962.                     not expect this and would not handle it properly.
  963.  
  964.  
  965.                In order to have valid  assembler  code,  each  operand
  966.           must  satisfy  its  constraint.  But a failure to do so does
  967.           not prevent the pattern from applying to an insn.   Instead,
  968.           it  directs the compiler to modify the code so that the con-
  969.           straint will be satisfied.  Usually this is done by  copying
  970.           an operand into a register.
  971.  
  972.                Contrast, therefore, the two instruction patterns  that
  973.           follow:
  974.  
  975.  
  976.               (define_insn ""
  977.                 [(set (match_operand:SI 0 "general_operand" "r")
  978.                       (plus:SI (match_dup 0)
  979.                                (match_operand:SI 1 "general_operand" "r")))]
  980.                 ""
  981.                 "...")
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.           which has two operands, one of  which  must  appear  in  two
  999.           places, and
  1000.  
  1001.  
  1002.               (define_insn ""
  1003.                 [(set (match_operand:SI 0 "general_operand" "r")
  1004.                       (plus:SI (match_operand:SI 1 "general_operand" "0")
  1005.                                (match_operand:SI 2 "general_operand" "r")))]
  1006.                 ""
  1007.                 "...")
  1008.  
  1009.  
  1010.  
  1011.           which has three operands, two of which  are  required  by  a
  1012.           constraint  to  be identical.  If we are considering an insn
  1013.           of the form
  1014.  
  1015.  
  1016.               (insn n prev next
  1017.                 (set (reg:SI 3)
  1018.                      (plus:SI (reg:SI 6) (reg:SI 109)))
  1019.                 ...)
  1020.  
  1021.  
  1022.  
  1023.           the first pattern would not apply at all, because this  insn
  1024.           does  not  contain two identical subexpressions in the right
  1025.           place.  The pattern would say, ``That does not look like  an
  1026.           add  instruction;  try  other patterns.'' The second pattern
  1027.           would say, ``Yes, that's an add instruction,  but  there  is
  1028.           something  wrong with it.''  It would direct the reload pass
  1029.           of the compiler to generate additional  insns  to  make  the
  1030.           constraint true.  The results might look like this:
  1031.  
  1032.  
  1033.               (insn n2 prev n
  1034.                 (set (reg:SI 3) (reg:SI 6))
  1035.                 ...)
  1036.  
  1037.               (insn n n2 next
  1038.                 (set (reg:SI 3)
  1039.                      (plus:SI (reg:SI 3) (reg:SI 109)))
  1040.                 ...)
  1041.  
  1042.  
  1043.  
  1044.                It is up to you to make sure that each operand, in each
  1045.           pattern,  has constraints that can handle any RTL expression
  1046.           that could be present  for  that  operand.   (When  multiple
  1047.           alternatives  are in use, each pattern must, for each possi-
  1048.           ble combination of operand expressions, have  at  least  one
  1049.           alternative  which can handle that combination of operands.)
  1050.           The constraints don't need to allow any possible  operand---
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.           when this is the case, they do not constrain---but they must
  1065.           at least point the way to reloading any possible operand  so
  1066.           that it will fit.
  1067.  
  1068.                o+    If the constraint accepts  whatever  operands  the
  1069.                     predicate  permits, there is no problem: reloading
  1070.                     is never necessary for this operand.
  1071.  
  1072.                     For example, an operand whose  constraints  permit
  1073.                     everything  except  registers is safe provided its
  1074.                     predicate rejects registers.
  1075.  
  1076.                     An operand whose predicate accepts  only  constant
  1077.                     values  is  safe  provided its constraints include
  1078.                     the letter `i'.  If any possible constant value is
  1079.                     accepted,  then  nothing less than `i' will do; if
  1080.                     the predicate is more  selective,  then  the  con-
  1081.                     straints may also be more selective.
  1082.  
  1083.                o+    Any operand expression can be reloaded by  copying
  1084.                     it  into  a  register.   So  if  an operand's con-
  1085.                     straints allow some kind of register, it  is  cer-
  1086.                     tain  to  be safe.  It need not permit all classes
  1087.                     of registers; the compiler knows how to copy a re-
  1088.                     gister  into  another register of the proper class
  1089.                     in order to make an instruction valid.
  1090.  
  1091.                o+    A nonoffsettable memory reference can be  reloaded
  1092.                     by copying the address into a register.  So if the
  1093.                     constraint uses the letter `o', all memory  refer-
  1094.                     ences are taken care of.
  1095.  
  1096.                o+    A constant operand can be reloaded  by  allocating
  1097.                     space in memory to hold it as preinitialized data.
  1098.                     Then the memory reference can be used in place  of
  1099.                     the  constant.   So  if  the  constraint  uses the
  1100.                     letters `o' or `m', constant operands  are  not  a
  1101.                     problem.
  1102.  
  1103.                o+    If the constraint permits a constant and a  pseudo
  1104.                     register  used  in  an insn was not allocated to a
  1105.                     hard register and is equivalent to a constant, the
  1106.                     register  will  be replaced with the constant.  If
  1107.                     the predicate does not permit a constant  and  the
  1108.                     insn  is  re-recognized  for some reason, the com-
  1109.                     piler will crash.  Thus the predicate must  always
  1110.                     recognize any objects allowed by the constraint.
  1111.  
  1112.  
  1113.                If the operand's predicate can recognize registers, but
  1114.           the  constraint  does  not permit them, it can make the com-
  1115.           piler crash.  When this operand happens to  be  a  register,
  1116.           the  reload  pass  will be stymied, because it does not know
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.           how to copy a register temporarily into memory.
  1131.  
  1132.           1.6.2.  Multiple Alternative Constraints
  1133.  
  1134.                Sometimes a single instruction has multiple alternative
  1135.           sets  of  possible  operands.   For example, on the 68000, a
  1136.           logical-or instruction can combine register or an  immediate
  1137.           value  into  memory,  or  it can combine any kind of operand
  1138.           into a register; but it cannot combine one  memory  location
  1139.           into another.
  1140.  
  1141.                These constraints are represented as multiple  alterna-
  1142.           tives.   An  alternative  can  be  described  by a series of
  1143.           letters for each operand.  The  overall  constraint  for  an
  1144.           operand  is  made from the letters for this operand from the
  1145.           first alternative, a comma, the  letters  for  this  operand
  1146.           from  the  second  alternative, a comma, and so on until the
  1147.           last alternative.  Here is  how  it  is  done  for  fullword
  1148.           logical-or on the 68000:
  1149.  
  1150.  
  1151.               (define_insn "iorsi3"
  1152.                 [(set (match_operand:SI 0 "general_operand" "=m,d")
  1153.                       (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
  1154.                               (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  1155.                 ...)
  1156.  
  1157.  
  1158.  
  1159.                The first alternative has `m' (memory) for  operand  0,
  1160.           `0'  for  operand  1  (meaning it must match operand 0), and
  1161.           `dKs' for operand 2.  The second alternative has  `d'  (data
  1162.           register)  for  operand 0, `0' for operand 1, and `dmKs' for
  1163.           operand 2.  The `=' and `%' in the constraints apply to  all
  1164.           the  alternatives;  their  meaning  is explained in the next
  1165.           section (see section  Class Preferences).
  1166.  
  1167.                If all  the  operands  fit  any  one  alternative,  the
  1168.           instruction  is valid.  Otherwise, for each alternative, the
  1169.           compiler counts how many instructions must be added to  copy
  1170.           the operands so that that alternative applies.  The alterna-
  1171.           tive requiring the least copying is chosen.  If two alterna-
  1172.           tives  need  the  same amount of copying, the one that comes
  1173.           first is chosen.  These choices can be altered with the  `?'
  1174.           and `!' characters:
  1175.  
  1176.                ?    Disparage slightly the alternative  that  the  `?'
  1177.                     appears  in,  as  a choice when no alternative ap-
  1178.                     plies exactly.  The compiler regards this alterna-
  1179.                     tive as one unit more costly for each `?' that ap-
  1180.                     pears in it.
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.                !    Disparage severely the alternative  that  the  `!'
  1197.                     appears in.  This alternative can still be used if
  1198.                     it fits without reloading,  but  if  reloading  is
  1199.                     needed, some other alternative will be used.
  1200.  
  1201.  
  1202.                When an insn pattern has multiple alternatives  in  its
  1203.           constraints,  often  the appearance of the assembler code is
  1204.           determined mostly by which alternative  was  matched.   When
  1205.           this  is  so,  the C code for writing the assembler code can
  1206.           use the variable which_alternative,  which  is  the  ordinal
  1207.           number of the alternative that was actually satisfied (0 for
  1208.           the first, 1 for the second alternative, etc.).  See section
  1209.           Output Statement.
  1210.  
  1211.           1.6.3.  Register Class Preferences
  1212.  
  1213.                The operand constraints  have  another  function:  they
  1214.           enable  the compiler to decide which kind of hardware regis-
  1215.           ter a pseudo register is best allocated  to.   The  compiler
  1216.           examines  the  constraints  that apply to the insns that use
  1217.           the  pseudo  register,  looking  for  the  machine-dependent
  1218.           letters  such  as `d' and `a' that specify classes of regis-
  1219.           ters.  The pseudo register is put in  whichever  class  gets
  1220.           the most ``votes''.  The constraint letters `g' and `r' also
  1221.           vote: they vote in favor of a general register.  The machine
  1222.           description says which registers are considered general.
  1223.  
  1224.                Of  course,  on  some  machines   all   registers   are
  1225.           equivalent,  and no register classes are defined.  Then none
  1226.           of this complexity is relevant.
  1227.  
  1228.           1.6.4.  Constraint Modifier Characters
  1229.  
  1230.                `='  Means that this operand is write-only for this in-
  1231.                     struction: the previous value is discarded and re-
  1232.                     placed by output data.
  1233.  
  1234.                `+'  Means that this operand is both read  and  written
  1235.                     by the instruction.
  1236.  
  1237.                     When the compiler fixes up the operands to satisfy
  1238.                     the  constraints,  it needs to know which operands
  1239.                     are inputs to the instruction and which  are  out-
  1240.                     puts from it.  `=' identifies an output; `+' iden-
  1241.                     tifies an operand that is both input  and  output;
  1242.                     all other operands are assumed to be input only.
  1243.  
  1244.                `&'  Means (in  a  particular  alternative)  that  this
  1245.                     operand  is written before the instruction is fin-
  1246.                     ished using the input operands.   Therefore,  this
  1247.                     operand  may not lie in a register that is used as
  1248.                     an input operand or as part of any memory address.
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.                     `&' applies only to the alternative in which it is
  1263.                     written.   In  constraints  with multiple alterna-
  1264.                     tives,  sometimes  one  alternative  requires  `&'
  1265.                     while  others  do  not.   See,  for  example,  the
  1266.                     `movdf' insn of the 68000.
  1267.  
  1268.                     `&' does not obviate the need to write `='.
  1269.  
  1270.                `%'  Declares the instruction  to  be  commutative  for
  1271.                     this  operand  and  the  following  operand.  This
  1272.                     means that the compiler may  interchange  the  two
  1273.                     operands  if  that is the cheapest way to make all
  1274.                     operands fit the constraints.  This is often  used
  1275.                     in  patterns for addition instructions that really
  1276.                     have only two operands: the result must go in  one
  1277.                     of  the  arguments.   Here for example, is how the
  1278.                     68000 halfword-add instruction is defined:
  1279.  
  1280.  
  1281.                         (define_insn "addhi3"
  1282.                           [(set (match_operand:HI 0 "general_operand" "=m,r")
  1283.                              (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
  1284.                                       (match_operand:HI 2 "general_operand" "di,g")))]
  1285.                           ...)
  1286.  
  1287.  
  1288.  
  1289.                `#'  Says that all following characters, up to  the
  1290.                     next comma, are to be ignored as a constraint.
  1291.                     They are significant only for choosing  regis-
  1292.                     ter preferences.
  1293.  
  1294.                `*'  Says that the following  character  should  be
  1295.                     ignored  when  choosing  register preferences.
  1296.                     `*' has no effect on the meaning of  the  con-
  1297.                     straint  as a constraint, and no effect on re-
  1298.                     loading.
  1299.  
  1300.                     Here is an example: the 68000 has an  instruc-
  1301.                     tion  to  sign-extend a halfword in a data re-
  1302.                     gister, and can also sign-extend  a  value  by
  1303.                     copying  it  into  an address register.  While
  1304.                     either kind of  register  is  acceptable,  the
  1305.                     constraints on an address-register destination
  1306.                     are less strict, so it is best if register al-
  1307.                     location  makes  an address register its goal.
  1308.                     Therefore, `*' is used so that  the  `d'  con-
  1309.                     straint  letter (for data register) is ignored
  1310.                     when computing register preferences.
  1311.  
  1312.  
  1313.                         (define_insn "extendhisi2"
  1314.                           [(set (match_operand:SI 0 "general_operand" "=*d,a")
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.                                 (sign_extend:SI
  1329.                                  (match_operand:HI 1 "general_operand" "0,g")))]
  1330.                           ...)
  1331.  
  1332.  
  1333.  
  1334.  
  1335.           1.6.5.  Not Using Constraints
  1336.  
  1337.                Some machines are so clean that operand constraints are
  1338.           not  required.  For example, on the Vax, an operand valid in
  1339.           one context is valid  in  any  other  context.   On  such  a
  1340.           machine,  every  operand  constraint would be `g', excepting
  1341.           only operands of ``load  address''  instructions  which  are
  1342.           written  as if they referred to a memory location's contents
  1343.           but actual refer to its address.  They would have constraint
  1344.           `p'.
  1345.  
  1346.                For such machines, instead of writing `g' and  `p'  for
  1347.           all  the  constraints, you can choose to write a description
  1348.           with empty constraints.  Then you write `""'  for  the  con-
  1349.           straint  in every match_operand.  Address operands are iden-
  1350.           tified  by  writing  an  address   expression   around   the
  1351.           match_operand, not by their constraints.
  1352.  
  1353.                When  the  machine  description  has  just  empty  con-
  1354.           straints,  certain  parts of compilation are skipped, making
  1355.           the compiler faster.  However, few machines actually do  not
  1356.           need  constraints; all machine descriptions now in existence
  1357.           use constraints.
  1358.  
  1359.           1.7.  Standard Names for Patterns Used in Generation
  1360.  
  1361.                Here is a table of the instruction names that are mean-
  1362.           ingful  in  the RTL generation pass of the compiler.  Giving
  1363.           one of these names to an instruction pattern tells  the  RTL
  1364.           generation pass that it can use the pattern in to accomplish
  1365.           a certain task.
  1366.  
  1367.                `movm'
  1368.                     Here m stands for a two-letter machine mode  name,
  1369.                     in  lower  case.   This  instruction pattern moves
  1370.                     data with that machine  mode  from  operand  1  to
  1371.                     operand  0.   For example, `movsi' moves full-word
  1372.                     data.
  1373.  
  1374.                     If operand 0 is a subreg with mode m of a register
  1375.                     whose own mode is wider than m, the effect of this
  1376.                     instruction is to store the specified value in the
  1377.                     part  of  the register that corresponds to mode m.
  1378.                     The effect on the rest of the  register  is  unde-
  1379.                     fined.
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.                     This class of patterns is special in several ways.
  1395.                     First of all, each of these names must be defined,
  1396.                     because there is no other way to copy a datum from
  1397.                     one place to another.
  1398.  
  1399.                     Second, these patterns are not used solely in  the
  1400.                     RTL  generation  pass.   Even  the reload pass can
  1401.                     generate move insns  to  copy  values  from  stack
  1402.                     slots  into temporary registers.  When it does so,
  1403.                     one of the operands is a  hard  register  and  the
  1404.                     other  is  an operand that can need to be reloaded
  1405.                     into a register.
  1406.  
  1407.                     Therefore, when given such a pair of operands, the
  1408.                     pattern must generate RTL which needs no reloading
  1409.                     and needs no  temporary  registers---no  registers
  1410.                     other than the operands.  For example, if you sup-
  1411.                     port the pattern with  a  define_expand,  then  in
  1412.                     such   a   case  the  define_expand  mustn't  call
  1413.                     force_reg or any other such function  which  might
  1414.                     generate new pseudo registers.
  1415.  
  1416.                     This requirement exists even for subword modes  on
  1417.                     a  RISC  machine  where  fetching those modes from
  1418.                     memory normally requires several  insns  and  some
  1419.                     temporary registers.  Look in `spur.md' to see how
  1420.                     the requirement can be satisfied.
  1421.  
  1422.                     During reload a memory reference with  an  invalid
  1423.                     address  may be passed as an operand.  Such an ad-
  1424.                     dress will be replaced with a valid address  later
  1425.                     in  the reload pass.  In this case, nothing may be
  1426.                     done with the address  except  to  use  it  as  it
  1427.                     stands.   If it is copied, it will not be replaced
  1428.                     with a valid address.  No attempt should  be  made
  1429.                     to  make  such an address into a valid address and
  1430.                     no routine (such as change_address) that  will  do
  1431.                     so  may be called.  Note that general_operand will
  1432.                     fail when applied to such an address.
  1433.  
  1434.                     The global variable reload_in_progress (which must
  1435.                     be explicitly declared if required) can be used to
  1436.                     determine whether such  special  handling  is  re-
  1437.                     quired.
  1438.  
  1439.                     The variety of operands that have reloads  depends
  1440.                     on  the rest of the machine description, but typi-
  1441.                     cally on a RISC machine these can only  be  pseudo
  1442.                     registers  that  did not get hard registers, while
  1443.                     on other machines explicit memory references  will
  1444.                     get optional reloads.
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.                     If a scratch register is required to move  an  ob-
  1461.                     ject  to or from memory, it can be allocated using
  1462.                     gen_reg_rtx prior to reload.  But this is impossi-
  1463.                     ble  during  and after reload.  If there are cases
  1464.                     needing scratch registers after reload,  you  must
  1465.                     define     SECONDARY_INPUT_RELOAD_CLASS     and/or
  1466.                     SECONDARY_OUTPUT_RELOAD_CLASS to detect them,  and
  1467.                     provide  patterns `reload_inm' or `reload_outm' to
  1468.                     handle them.  See section Register Classes.
  1469.  
  1470.                     The constraints on a `movem'  must  permit  moving
  1471.                     any  hard register to any other hard register pro-
  1472.                     vided that HARD_REGNO_MODE_OK permits  mode  m  in
  1473.                     both  registers  and REGISTER_MOVE_COST applied to
  1474.                     their classes returns a value of 2.
  1475.  
  1476.                     It is obligatory to support floating point `movem'
  1477.                     instructions  into  and  out of any registers that
  1478.                     can hold fixed point values,  because  unions  and
  1479.                     structures (which have modes SImode or DImode) can
  1480.                     be in those registers and they may  have  floating
  1481.                     point members.
  1482.  
  1483.                     There may also be a need to  support  fixed  point
  1484.                     `movem'  instructions in and out of floating point
  1485.                     registers.  Unfortunately, I  have  forgotten  why
  1486.                     this  was so, and I don't know whether it is still
  1487.                     true.  If HARD_REGNO_MODE_OK rejects  fixed  point
  1488.                     values  in floating point registers, then the con-
  1489.                     straints of the fixed point  `movem'  instructions
  1490.                     must  be  designed  to avoid ever trying to reload
  1491.                     into a floating point register.
  1492.  
  1493.                `reload_inm'
  1494.  
  1495.                `reload_outm'
  1496.                     Like `movm', but used when a scratch  register  is
  1497.                     required  to move between operand 0 and operand 1.
  1498.                     Operand 2 describes the scratch register.  See the
  1499.                     discussion  of the SECONDARY_RELOAD_CLASS macro in
  1500.                     see section  Register Classes.
  1501.  
  1502.                `movstrictm'
  1503.                     Like `movm' except that if operand 0 is  a  subreg
  1504.                     with  mode  m  of a register whose natural mode is
  1505.                     wider, the `movstrictm' instruction is  guaranteed
  1506.                     not  to  alter any of the register except the part
  1507.                     which belongs to mode m.
  1508.  
  1509.                `addm3'
  1510.                     Add operand 2 and operand 1, storing the result in
  1511.                     operand  0.   All operands must have mode m.  This
  1512.                     can be used even on two-address machines, by means
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.                     of  constraints  requiring  operands 1 and 0 to be
  1527.                     the same location.
  1528.  
  1529.                `subm3', `mulm3'
  1530.  
  1531.                `divm3', `udivm3', `modm3', `umodm3'
  1532.  
  1533.                `sminm3', `smaxm3', `uminm3', `umaxm3'
  1534.  
  1535.                `andm3', `iorm3', `xorm3'
  1536.                     Similar, for other arithmetic operations.
  1537.  
  1538.                `mulhisi3'
  1539.                     Multiply operands 1 and 2, which have mode HImode,
  1540.                     and store a SImode product in operand 0.
  1541.  
  1542.                `mulqihi3', `mulsidi3'
  1543.                     Similar  widening-multiplication  instructions  of
  1544.                     other widths.
  1545.  
  1546.                `umulqihi3', `umulhisi3', `umulsidi3'
  1547.                     Similar widening-multiplication instructions  that
  1548.                     do unsigned multiplication.
  1549.  
  1550.                `divmodm4'
  1551.                     Signed division that produces both a quotient  and
  1552.                     a remainder.  Operand 1 is divided by operand 2 to
  1553.                     produce a quotient  stored  in  operand  0  and  a
  1554.                     remainder stored in operand 3.
  1555.  
  1556.                     For machines with  an  instruction  that  produces
  1557.                     both a quotient and a remainder, provide a pattern
  1558.                     for `divmodm4' but do  not  provide  patterns  for
  1559.                     `divm3'  and `modm3'.  This allows optimization in
  1560.                     the relatively common case when both the  quotient
  1561.                     and remainder are computed.
  1562.  
  1563.                     If an instruction that just produces a quotient or
  1564.                     just a remainder exists and is more efficient than
  1565.                     the instruction that produces both, write the out-
  1566.                     put  routine  of  `divmodm4' to call find_reg_note
  1567.                     and look for a REG_UNUSED note on the quotient  or
  1568.                     remainder  and  generate  the appropriate instruc-
  1569.                     tion.
  1570.  
  1571.                `udivmodm4'
  1572.                     Similar, but does unsigned division.
  1573.  
  1574.                `ashlm3'
  1575.                     Arithmetic-shift operand 1 left  by  a  number  of
  1576.                     bits  specified by operand 2, and store the result
  1577.                     in operand 0.  Operand 2 has mode SImode, not mode
  1578.                     m.
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.                `ashrm3', `lshlm3', `lshrm3', `rotlm3', `rotrm3'
  1593.                     Other shift and rotate instructions.
  1594.  
  1595.                     Logical and arithmetic left shift  are  the  same.
  1596.                     Machines  that  do not allow negative shift counts
  1597.                     often have only one instruction for shifting left.
  1598.                     On  such  machines,  you  should  define a pattern
  1599.                     named `ashlm3' and leave `lshlm3' undefined.
  1600.  
  1601.                `negm2'
  1602.                     Negate operand 1 and store the result  in  operand
  1603.                     0.
  1604.  
  1605.                `absm2'
  1606.                     Store the absolute value of operand 1 into operand
  1607.                     0.
  1608.  
  1609.                `sqrtm2'
  1610.                     Store the square root of operand 1 into operand 0.
  1611.  
  1612.                `ffsm2'
  1613.                     Store into operand 0 one plus  the  index  of  the
  1614.                     least  significant 1-bit of operand 1.  If operand
  1615.                     1 is zero, store zero.  m is the mode  of  operand
  1616.                     0;  operand  1's mode is specified by the instruc-
  1617.                     tion pattern, and the compiler  will  convert  the
  1618.                     operand  to  that  mode  before generating the in-
  1619.                     struction.
  1620.  
  1621.                `one_cmplm2'
  1622.                     Store the bitwise-complement  of  operand  1  into
  1623.                     operand 0.
  1624.  
  1625.                `cmpm'
  1626.                     Compare operand 0 and operand 1, and set the  con-
  1627.                     dition  codes.   The  RTL pattern should look like
  1628.                     this:
  1629.  
  1630.  
  1631.                         (set (cc0) (compare (match_operand:m 0 ...)
  1632.                                             (match_operand:m 1 ...)))
  1633.  
  1634.  
  1635.  
  1636.                `tstm'
  1637.                     Compare operand 0 against zero,  and  set  the
  1638.                     condition  codes.  The RTL pattern should look
  1639.                     like this:
  1640.  
  1641.  
  1642.                         (set (cc0) (match_operand:m 0 ...))
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.                     `tstm' patterns  should  not  be  defined  for
  1659.                     machines  that  do  not  use  (cc0).  Doing so
  1660.                     would confuse the optimizer since it would  no
  1661.                     longer be clear which set operations were com-
  1662.                     parisons.  The `cmpm' patterns should be  used
  1663.                     instead.
  1664.  
  1665.                `movstrm'
  1666.                     Block move instruction.  The addresses of  the
  1667.                     destination  and  source strings are the first
  1668.                     two operands, and both are in mode Pmode.  The
  1669.                     number  of bytes to move is the third operand,
  1670.                     in mode m.
  1671.  
  1672.                     The fourth operand is the known shared  align-
  1673.                     ment  of  the  source  and destination, in the
  1674.                     form of a const_int rtx.  Thus,  if  the  com-
  1675.                     piler  knows  that both source and destination
  1676.                     are word-aligned, it may provide the  value  4
  1677.                     for this operand.
  1678.  
  1679.                     These patterns  need  not  give  special  con-
  1680.                     sideration  to the possibility that the source
  1681.                     and destination strings might overlap.
  1682.  
  1683.                `cmpstrm'
  1684.                     Block compare instruction, with five operands.
  1685.                     Operand  0  is the output; it has mode m.  The
  1686.                     remaining four operands are like the  operands
  1687.                     of `movstrm'.  The two memory blocks specified
  1688.                     are compared byte  by  byte  in  lexicographic
  1689.                     order.   The  effect  of the instruction is to
  1690.                     store a value in operand 0  whose  sign  indi-
  1691.                     cates the result of the comparison.
  1692.  
  1693.                `floatmn2'
  1694.                     Convert signed integer operand  1  (valid  for
  1695.                     fixed  point  mode m) to floating point mode n
  1696.                     and store in operand 0 (which has mode n).
  1697.  
  1698.                `floatunsmn2'
  1699.                     Convert unsigned integer operand 1 (valid  for
  1700.                     fixed  point  mode m) to floating point mode n
  1701.                     and store in operand 0 (which has mode n).
  1702.  
  1703.                `fixmn2'
  1704.                     Convert operand 1 (valid  for  floating  point
  1705.                     mode  m)  to  fixed  point  mode n as a signed
  1706.                     number and store in operand 0 (which has  mode
  1707.                     n).  This instruction's result is defined only
  1708.                     when the value of operand 1 is an integer.
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.                `fixunsmn2'
  1725.                     Convert operand 1 (valid  for  floating  point
  1726.                     mode  m)  to fixed point mode n as an unsigned
  1727.                     number and store in operand 0 (which has  mode
  1728.                     n).  This instruction's result is defined only
  1729.                     when the value of operand 1 is an integer.
  1730.  
  1731.                `ftruncm2'
  1732.                     Convert operand 1 (valid  for  floating  point
  1733.                     mode m) to an integer value, still represented
  1734.                     in floating point mode  m,  and  store  it  in
  1735.                     operand 0 (valid for floating point mode m).
  1736.  
  1737.                `fix_truncmn2'
  1738.                     Like `fixmn2' but works for any floating point
  1739.                     value  of mode m by converting the value to an
  1740.                     integer.
  1741.  
  1742.                `fixuns_truncmn2'
  1743.                     Like `fixunsmn2' but works  for  any  floating
  1744.                     point  value of mode m by converting the value
  1745.                     to an integer.
  1746.  
  1747.                `truncmn'
  1748.                     Truncate operand 1 (valid for mode m) to  mode
  1749.                     n  and  store in operand 0 (which has mode n).
  1750.                     Both modes must be fixed point or both  float-
  1751.                     ing point.
  1752.  
  1753.                `extendmn'
  1754.                     Sign-extend operand 1 (valid for  mode  m)  to
  1755.                     mode  n and store in operand 0 (which has mode
  1756.                     n).  Both modes must be fixed  point  or  both
  1757.                     floating point.
  1758.  
  1759.                `zero_extendmn'
  1760.                     Zero-extend operand 1 (valid for  mode  m)  to
  1761.                     mode  n and store in operand 0 (which has mode
  1762.                     n).  Both modes must be fixed point.
  1763.  
  1764.                `extv'
  1765.                     Extract a bit field from operand 1 (a register
  1766.                     or  memory operand), where operand 2 specifies
  1767.                     the width in bits and operand 3  the  starting
  1768.                     bit,  and  store  it  in operand 0.  Operand 0
  1769.                     must have mode word_mode.  Operand 1 may  have
  1770.                     mode  byte_mode  or word_mode; often word_mode
  1771.                     is allowed only for registers.  Operands 2 and
  1772.                     3 must be valid for word_mode.
  1773.  
  1774.                     The RTL generation  pass  generates  this  in-
  1775.                     struction  only  with constants for operands 2
  1776.                     and 3.
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.                     The bit-field value is sign-extended to a full
  1791.                     word integer before it is stored in operand 0.
  1792.  
  1793.                `extzv'
  1794.                     Like `extv' except that the bit-field value is
  1795.                     zero-extended.
  1796.  
  1797.                `insv'
  1798.                     Store operand  3  (which  must  be  valid  for
  1799.                     word_mode)  into  a  bit  field  in operand 0,
  1800.                     where operand 1 specifies the  width  in  bits
  1801.                     and operand 2 the starting bit.  Operand 0 may
  1802.                     have  mode  byte_mode  or   word_mode;   often
  1803.                     word_mode   is  allowed  only  for  registers.
  1804.                     Operands 1 and 2 must be valid for word_mode.
  1805.  
  1806.                     The RTL generation  pass  generates  this  in-
  1807.                     struction  only  with constants for operands 1
  1808.                     and 2.
  1809.  
  1810.                `scond'
  1811.                     Store zero or nonzero in the operand according
  1812.                     to  the  condition  codes.   Value  stored  is
  1813.                     nonzero iff the condition cond is true.   cond
  1814.                     is  the name of a comparison operation expres-
  1815.                     sion code, such as eq, lt or leu.
  1816.  
  1817.                     You specify the mode  that  the  operand  must
  1818.                     have  when you write the match_operand expres-
  1819.                     sion.  The compiler automatically  sees  which
  1820.                     mode  you have used and supplies an operand of
  1821.                     that mode.
  1822.  
  1823.                     The value stored for  a  true  condition  must
  1824.                     have  1  as its low bit, or else must be nega-
  1825.                     tive.  Otherwise the instruction is not  suit-
  1826.                     able  and  you should omit it from the machine
  1827.                     description.  You describe to the compiler ex-
  1828.                     actly  which  value  is stored by defining the
  1829.                     macro STORE_FLAG_VALUE  (see  section   Misc).
  1830.                     If  a  description cannot be found that can be
  1831.                     used for all the `scond' patterns, you  should
  1832.                     omit   those   operations   from  the  machine
  1833.                     description.
  1834.  
  1835.                     These operations may fail, but  should  do  so
  1836.                     only  in  relatively  uncommon  cases; if they
  1837.                     would fail for common cases involving  integer
  1838.                     comparisons,  it  is  best  to omit these pat-
  1839.                     terns.
  1840.  
  1841.                     If these operations are omitted, the  compiler
  1842.                     will  usually  generate  code  that copies the
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.                     constant one to the target and branches around
  1857.                     an  assignment of zero to the target.  If this
  1858.                     code is more efficient than the potential  in-
  1859.                     structions  used  for the `scond' pattern fol-
  1860.                     lowed by those required to convert the  result
  1861.                     into  a 1 or a zero in SImode, you should omit
  1862.                     the  `scond'  operations  from   the   machine
  1863.                     description.
  1864.  
  1865.                `bcond'
  1866.                     Conditional branch instruction.  Operand 0  is
  1867.                     a  label_ref  that refers to the label to jump
  1868.                     to.  Jump if the condition codes  meet  condi-
  1869.                     tion cond.
  1870.  
  1871.                     Some machines do not follow the model  assumed
  1872.                     here  where  a  comparison instruction is fol-
  1873.                     lowed by a conditional branch instruction.  In
  1874.                     that  case,  the  `cmpm' (and `tstm') patterns
  1875.                     should simply store the operands away and gen-
  1876.                     erate    all   the   required   insns   in   a
  1877.                     define_expand (see section   Expander  Defini-
  1878.                     tions)  for the conditional branch operations.
  1879.                     All calls to expand `vcond' patterns  are  im-
  1880.                     mediately preceded by calls to expand either a
  1881.                     `cmpm' pattern or a `tstm' pattern.
  1882.  
  1883.                     Machines that use a pseudo  register  for  the
  1884.                     condition  code  value, or where the mode used
  1885.                     for the comparison depends  on  the  condition
  1886.                     being   tested,  should  also  use  the  above
  1887.                     mechanism.  See section Jump Patterns
  1888.  
  1889.                     The above discussion also applies  to  `scond'
  1890.                     patterns.
  1891.  
  1892.                `call'
  1893.                     Subroutine  call  instruction   returning   no
  1894.                     value.   Operand  0  is  the function to call;
  1895.                     operand 1 is the number of bytes of  arguments
  1896.                     pushed  (in mode SImode, except it is normally
  1897.                     a const_int); operand 2 is the number  of  re-
  1898.                     gisters used as operands.
  1899.  
  1900.                     On most machines, operand 2  is  not  actually
  1901.                     stored  into  the RTL pattern.  It is supplied
  1902.                     for the sake of some RISC machines which  need
  1903.                     to  put  this  information  into the assembler
  1904.                     code; they can put it in the  RTL  instead  of
  1905.                     operand 1.
  1906.  
  1907.                     Operand 0 should be a mem RTX whose address is
  1908.                     the  address  of the function.  Note, however,
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.                     that this address can be a symbol_ref  expres-
  1923.                     sion  even  if  it  would  not be a legitimate
  1924.                     memory address on the target machine.   If  it
  1925.                     is  also  not  a valid argument for a call in-
  1926.                     struction,  the  pattern  for  this  operation
  1927.                     should  be  a  define_expand (see section  Ex-
  1928.                     pander Definitions) that  places  the  address
  1929.                     into  a register and uses that register in the
  1930.                     call instruction.
  1931.  
  1932.                `call_value'
  1933.                     Subroutine call instruction returning a value.
  1934.                     Operand  0  is  the hard register in which the
  1935.                     value  is  returned.   There  are  three  more
  1936.                     operands,  the  same  as the three operands of
  1937.                     the `call' instruction (but with  numbers  in-
  1938.                     creased by one).
  1939.  
  1940.                     Subroutines that return  BLKmode  objects  use
  1941.                     the `call' insn.
  1942.  
  1943.                `call_pop', `call_value_pop'
  1944.                     Similar to  `call'  and  `call_value',  except
  1945.                     used  if  defined  and  if RETURN_POPS_ARGS is
  1946.                     non-zero.  They should emit  a  parallel  that
  1947.                     contains  both  the function call and a set to
  1948.                     indicate the  adjustment  made  to  the  frame
  1949.                     pointer.
  1950.  
  1951.                     For machines  where  RETURN_POPS_ARGS  can  be
  1952.                     non-zero,  the use of these patterns increases
  1953.                     the number of functions for  which  the  frame
  1954.                     pointer can be eliminated, if desired.
  1955.  
  1956.                `return'
  1957.                     Subroutine return instruction.  This  instruc-
  1958.                     tion  pattern name should be defined only if a
  1959.                     single instruction can do all the work of  re-
  1960.                     turning from a function.
  1961.  
  1962.                     Like the `movm' patterns, this pattern is also
  1963.                     used  after the RTL generation phase.  In this
  1964.                     case it is to support machines where  multiple
  1965.                     instructions are usually needed to return from
  1966.                     a function, but some class of  functions  only
  1967.                     requires  one  instruction  to implement a re-
  1968.                     turn.  Normally, the applicable functions  are
  1969.                     those  which do not need to save any registers
  1970.                     or allocate stack space.
  1971.  
  1972.                     For such machines, the condition specified  in
  1973.                     this   pattern   should   only  be  true  when
  1974.                     reload_completed   is   non-zero    and    the
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.                     function's epilogue would only be a single in-
  1989.                     struction.  For machines  with  register  win-
  1990.                     dows,  the routine leaf_function_p may be used
  1991.                     to determine if a register window push is  re-
  1992.                     quired.
  1993.  
  1994.                     Machines that have conditional return instruc-
  1995.                     tions should define patterns such as
  1996.  
  1997.  
  1998.                         (define_insn ""
  1999.                           [(set (pc)
  2000.                                 (if_then_else (match_operator 0 "comparison_operator"
  2001.                                                               [(cc0) (const_int 0)])
  2002.                                               (return)
  2003.                                               (pc)))]
  2004.                           "condition"
  2005.                           "...")
  2006.  
  2007.  
  2008.  
  2009.                     where condition would  normally  be  the  same
  2010.                     condition specified on the named `return' pat-
  2011.                     tern.
  2012.  
  2013.                `nop'
  2014.                     No-op instruction.  This  instruction  pattern
  2015.                     name  should always be defined to output a no-
  2016.                     op in assembler code.  (const_int 0)  will  do
  2017.                     as an RTL pattern.
  2018.  
  2019.                `indirect_jump'
  2020.                     An instruction to jump to an address which  is
  2021.                     operand  zero.  This pattern name is mandatory
  2022.                     on all machines.
  2023.  
  2024.                `casesi'
  2025.                     Instruction to jump through a dispatch  table,
  2026.                     including  bounds  checking.  This instruction
  2027.                     takes five operands:
  2028.  
  2029.                     1.   The index to  dispatch  on,  which  has  mode
  2030.                          SImode.
  2031.  
  2032.                     2.   The lower bound for indices in the table,  an
  2033.                          integer constant.
  2034.  
  2035.                     3.   The total range of indices in the table---the
  2036.                          largest  index  minus  the smallest one (both
  2037.                          inclusive).
  2038.  
  2039.                     4.   A label that precedes the table itself.
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.                     5.   A label to jump to if the index has  a  value
  2055.                          outside   the   bounds.    (If  the  machine-
  2056.                          description macro CASE_DROPS_THROUGH  is  de-
  2057.                          fined,  then  an  out-of-bounds  index  drops
  2058.                          through to the code following the jump  table
  2059.                          instead  of  jumping  to this label.  In that
  2060.                          case, this label is not actually used by  the
  2061.                          `casesi'  instruction,  but it is always pro-
  2062.                          vided as an operand.)
  2063.  
  2064.  
  2065.                     The table is a addr_vec or addr_diff_vec inside of
  2066.                     a  jump_insn.  The number of elements in the table
  2067.                     is one plus the difference between the upper bound
  2068.                     and the lower bound.
  2069.  
  2070.                `tablejump'
  2071.                     Instruction to jump to a variable  address.   This
  2072.                     is a low-level capability which can be used to im-
  2073.                     plement a dispatch table when there is no `casesi'
  2074.                     pattern.
  2075.  
  2076.                     This pattern requires two operands: the address or
  2077.                     offset,  and a label which should immediately pre-
  2078.                     cede   the   jump    table.     If    the    macro
  2079.                     CASE_VECTOR_PC_RELATIVE  is defined then the first
  2080.                     operand is an offset which counts from the address
  2081.                     of the table; otherwise, it is an absolute address
  2082.                     to jump to.
  2083.  
  2084.                     The `tablejump' insn is always the last  insn  be-
  2085.                     fore  the  jump table it uses.  Its assembler code
  2086.                     normally has no need to use  the  second  operand,
  2087.                     but  you  should incorporate it in the RTL pattern
  2088.                     so that the jump optimizer  will  not  delete  the
  2089.                     table as unreachable code.
  2090.  
  2091.  
  2092.           1.8.  When the Order of Patterns Matters
  2093.  
  2094.                Sometimes an insn can match more than  one  instruction
  2095.           pattern.  Then the pattern that appears first in the machine
  2096.           description is the one used.  Therefore, more specific  pat-
  2097.           terns  (patterns  that  will  match fewer things) and faster
  2098.           instructions (those that will produce better code when  they
  2099.           do match) should usually go first in the description.
  2100.  
  2101.                In some cases the effect of ordering the  patterns  can
  2102.           be  used  to hide a pattern when it is not valid.  For exam-
  2103.           ple, the 68000 has an instruction for converting a  fullword
  2104.           to  floating  point  and  another  for  converting a byte to
  2105.           floating point.  An instruction  converting  an  integer  to
  2106.           floating  point  could match either one.  We put the pattern
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.           to convert the fullword first to make sure that one will  be
  2121.           used  rather  than  the  other.   (Otherwise a large integer
  2122.           might be generated  as  a  single-byte  immediate  quantity,
  2123.           which  would not work.) Instead of using this pattern order-
  2124.           ing it would be possible to make the pattern for  convert-a-
  2125.           byte smart enough to deal properly with any constant value.
  2126.  
  2127.           1.9.  Interdependence of Patterns
  2128.  
  2129.                Every machine description must have a named pattern for
  2130.           each  of the conditional branch names `bcond'.  The recogni-
  2131.           tion template must always have the form
  2132.  
  2133.  
  2134.               (set (pc)
  2135.                    (if_then_else (cond (cc0) (const_int 0))
  2136.                                  (label_ref (match_operand 0 "" ""))
  2137.                                  (pc)))
  2138.  
  2139.  
  2140.  
  2141.           In  addition,  every  machine  description  must   have   an
  2142.           anonymous   pattern   for  each  of  the  possible  reverse-
  2143.           conditional branches.  Their templates look like
  2144.  
  2145.  
  2146.               (set (pc)
  2147.                    (if_then_else (cond (cc0) (const_int 0))
  2148.                                  (pc)
  2149.                                  (label_ref (match_operand 0 "" ""))))
  2150.  
  2151.  
  2152.  
  2153.           They  are  necessary  because  jump  optimization  can  turn
  2154.           direct-conditional    branches    into   reverse-conditional
  2155.           branches.
  2156.  
  2157.                It is often convenient to use the  match_operator  con-
  2158.           struct  to reduce the number of patterns that must be speci-
  2159.           fied for branches.  For example,
  2160.  
  2161.  
  2162.               (define_insn ""
  2163.                 [(set (pc)
  2164.                       (if_then_else (match_operator 0 "comparison_operator"
  2165.                                                     [(cc0) (const_int 0)])
  2166.                                     (pc)
  2167.                                     (label_ref (match_operand 1 "" ""))))]
  2168.                 "condition"
  2169.                 "...")
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.                In some cases machines support  instructions  identical
  2187.           except  for  the  machine mode of one or more operands.  For
  2188.           example, there may be ``sign-extend halfword''  and  ``sign-
  2189.           extend byte'' instructions whose patterns are
  2190.  
  2191.  
  2192.               (set (match_operand:SI 0 ...)
  2193.                    (extend:SI (match_operand:HI 1 ...)))
  2194.  
  2195.               (set (match_operand:SI 0 ...)
  2196.                    (extend:SI (match_operand:QI 1 ...)))
  2197.  
  2198.  
  2199.  
  2200.           Constant integers do not  specify  a  machine  mode,  so  an
  2201.           instruction  to  extend  a constant value could match either
  2202.           pattern.  The pattern it actually will match is the one that
  2203.           appears  first  in the file.  For correct results, this must
  2204.           be the one for the widest possible mode (HImode, here).   If
  2205.           the pattern matches the QImode instruction, the results will
  2206.           be incorrect if the constant value  does  not  actually  fit
  2207.           that mode.
  2208.  
  2209.                Such instructions to extend constants are  rarely  gen-
  2210.           erated  because  they  are optimized away, but they do occa-
  2211.           sionally happen in nonoptimized compilations.
  2212.  
  2213.                If a constraint in a pattern  allows  a  constant,  the
  2214.           reload pass may replace a register with a constant permitted
  2215.           by the constraint  in  some  cases.   Similarly  for  memory
  2216.           references.   You must ensure that the predicate permits all
  2217.           objects allowed by the constraints to prevent  the  compiler
  2218.           from crashing.
  2219.  
  2220.                Because of this substitution, you  should  not  provide
  2221.           separate  patterns for increment and decrement instructions.
  2222.           Instead, they should be generated from the same pattern that
  2223.           supports   register-register  add  insns  by  examining  the
  2224.           operands and generating the appropriate machine instruction.
  2225.  
  2226.           1.10.  Defining Jump Instruction Patterns
  2227.  
  2228.                For most machines, GNU CC assumes that the machine  has
  2229.           a  condition  code.   A  comparison  insn sets the condition
  2230.           code, recording the results of both signed and unsigned com-
  2231.           parison of the given operands.  A separate branch insn tests
  2232.           the condition code and branches or not according its  value.
  2233.           The  branch  insns come in distinct signed and unsigned fla-
  2234.           vors.  Many common machines, such as the Vax, the 68000  and
  2235.           the 32000, work this way.
  2236.  
  2237.                Some machines have distinct signed and unsigned compare
  2238.           instructions,   and  only  one  set  of  conditional  branch
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.           instructions.  The easiest way to handle these  machines  is
  2253.           to  treat  them  just  like the others until the final stage
  2254.           where assembly code is written.  At this time, when  output-
  2255.           ting  code  for  the  compare instruction, peek ahead at the
  2256.           following branch using next_cc0_user (insn).  (The  variable
  2257.           insn  refers to the insn being output, in the output-writing
  2258.           code in an instruction pattern.)  If the RTL says that is an
  2259.           unsigned  branch, output an unsigned compare; otherwise out-
  2260.           put a signed compare.  When the branch itself is output, you
  2261.           can treat signed and unsigned branches identically.
  2262.  
  2263.                The reason you can do this is that GNU CC  always  gen-
  2264.           erates  a  pair of consecutive RTL insns, possibly separated
  2265.           by note insns, one to set the condition code and one to test
  2266.           it, and keeps the pair inviolate until the end.
  2267.  
  2268.                To  go  with  this  technique,  you  must  define   the
  2269.           machine-description    macro    NOTICE_UPDATE_CC    to    do
  2270.           CC_STATUS_INIT; in other words, no  compare  instruction  is
  2271.           superfluous.
  2272.  
  2273.                Some machines have compare-and-branch instructions  and
  2274.           no  condition  code.   A  similar  technique works for them.
  2275.           When it is time to ``output'' a compare instruction,  record
  2276.           its  operands  in two static variables.  When outputting the
  2277.           branch-on-condition-code instruction that follows,  actually
  2278.           output a compare-and-branch instruction that uses the remem-
  2279.           bered operands.
  2280.  
  2281.                It also works to define patterns for compare-and-branch
  2282.           instructions.   In  optimizing compilation, the pair of com-
  2283.           pare and branch instructions will be combined  according  to
  2284.           these patterns.  But this does not happen if optimization is
  2285.           not requested.  So you must use one of the  solutions  above
  2286.           in addition to any special patterns you define.
  2287.  
  2288.                In many RISC machines, most instructions do not  affect
  2289.           the condition code and there may not even be a separate con-
  2290.           dition code register.  On these  machines,  the  restriction
  2291.           that  the  definition and use of the condition code be adja-
  2292.           cent insns is not necessary and can prevent important optim-
  2293.           izations.  For example, on the IBM RS/6000, there is a delay
  2294.           for taken branches unless the condition code register is set
  2295.           three instructions earlier than the conditional branch.  The
  2296.           instruction scheduler cannot perform this optimization if it
  2297.           is  not  permitted to separate the definition and use of the
  2298.           condition code register.
  2299.  
  2300.                On these machines, do not use (cc0), but instead use  a
  2301.           register  to  represent  the  condition code.  If there is a
  2302.           specific condition code register in the machine, use a  hard
  2303.           register.  If the condition code or comparison result can be
  2304.           placed in any general register, or  if  there  are  multiple
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.           condition registers, use a pseudo register.
  2319.  
  2320.                On some machines, the type of branch  instruction  gen-
  2321.           erated  may  depend  on  the way the condition code was pro-
  2322.           duced; for example, on the 68k and Sparc, setting the condi-
  2323.           tion  code directly from an add or subtract instruction does
  2324.           not clear the overflow bit the way that a  test  instruction
  2325.           does,  so  a  different  branch instruction must be used for
  2326.           some conditional branches.  For machines that use (cc0), the
  2327.           set   and  use  of  the  condition  code  must  be  adjacent
  2328.           (separated only by note insns) allowing flags  in  cc_status
  2329.           to  be  used.  (See section Condition Code.)  Also, the com-
  2330.           parison and branch insns can be located from each  other  by
  2331.           using the functions prev_cc0_setter and next_cc0_user.
  2332.  
  2333.                However, this is not true on machines that do  not  use
  2334.           (cc0).   On those machines, no assumptions can be made about
  2335.           the adjacency of the compare and branch insns and the  above
  2336.           methods cannot be used.  Instead, we use the machine mode of
  2337.           the condition code register to record different  formats  of
  2338.           the condition code register.
  2339.  
  2340.                Registers used to store the condition code value should
  2341.           have  a mode that is in class MODE_CC.  Normally, it will be
  2342.           CCmode.  If additional modes are required (as  for  the  add
  2343.           example  mentioned  above  in  the  Sparc), define the macro
  2344.           EXTRA_CC_MODES to list the additional  modes  required  (see
  2345.           section   Condition  Code).   Also  define EXTRA_CC_NAMES to
  2346.           list the names of those modes and SELECT_CC_MODE to choose a
  2347.           mode given an operand of a compare.
  2348.  
  2349.                If it is known during RTL generation that  a  different
  2350.           mode  will  be  required  (for  example,  if the machine has
  2351.           separate compare instructions for signed and unsigned  quan-
  2352.           tities,  like most IBM processors), they can be specified at
  2353.           that time.
  2354.  
  2355.                If the cases that require different modes would be made
  2356.           by  instruction combination, the macro SELECT_CC_MODE deter-
  2357.           mines which machine mode should be used for  the  comparison
  2358.           result.  The patterns should be written using that mode.  To
  2359.           support the case of the add on the Sparc discussed above, we
  2360.           have the pattern
  2361.  
  2362.  
  2363.               (define_insn ""
  2364.                 [(set (reg:CC_NOOV 0)
  2365.                       (compare:CC_NOOV (plus:SI (match_operand:SI 0 "register_operand" "%r")
  2366.                                                 (match_operand:SI 1 "arith_operand" "rI"))
  2367.                                        (const_int 0)))]
  2368.                 ""
  2369.                 "...")
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.                The  SELECT_CC_MODE  macro   on   the   Sparc   returns
  2387.           CC_NOOVmode for comparisons whose argument is a plus.
  2388.  
  2389.           1.11.  Canonicalization of Instructions
  2390.  
  2391.                There are often cases where  multiple  RTL  expressions
  2392.           could  represent  an  operation peformed by a single machine
  2393.           instruction.  This situation is  most  commonly  encountered
  2394.           with  logical, branch, and multiply-accumulate instructions.
  2395.           In such cases, the compiler attempts to convert these multi-
  2396.           ple  RTL  expressions into a single canonical form to reduce
  2397.           the number of insn patterns required.
  2398.  
  2399.                In addition  to  algebraic  simplifications,  following
  2400.           canonicalizations are performed:
  2401.  
  2402.                o+    For commutative and comparison operators,  a  con-
  2403.                     stant  is  always  made  the second operand.  If a
  2404.                     machine only supports a  constant  as  the  second
  2405.                     operand,  only  patterns  that match a constant in
  2406.                     the second operand need be supplied.
  2407.  
  2408.                     For these operators, if only one operand is a neg,
  2409.                     not,  mult,  plus, or minus expression, it will be
  2410.                     the first operand.
  2411.  
  2412.                o+    For the compare operator, a constant is always the
  2413.                     second  operand on machines where cc0 is used (see
  2414.                     section  Jump Patterns).  On other machines, there
  2415.                     are  rare  cases  where the compiler might want to
  2416.                     construct a compare with a constant as  the  first
  2417.                     operand.   However,  these  cases  are  not common
  2418.                     enough for it to be worthwhile to provide  a  pat-
  2419.                     tern  matching a constant as the first operand un-
  2420.                     less the machine actually has such an instruction.
  2421.  
  2422.                     An operand of neg, not, mult, plus,  or  minus  is
  2423.                     made  the  first operand under the same conditions
  2424.                     as above.
  2425.  
  2426.                o+    (minus x (const_int n)) is converted  to  (plus  x
  2427.                     (const_int -n)).
  2428.  
  2429.                o+    Within address computations (i.e., inside mem),  a
  2430.                     left  shift is converted into the appropriate mul-
  2431.                     tiplication by a power of two.
  2432.  
  2433.                     De`Morgan's Law is used to move  bitwise  negation
  2434.                     inside  a bitwise logical-and or logical-or opera-
  2435.                     tion.  If this results in only one operand being a
  2436.                     not expression, it will be the first one.
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.                     A machine that has an instruction that performs  a
  2451.                     bitwise  logical-and  of one operand with the bit-
  2452.                     wise negation of the other should specify the pat-
  2453.                     tern for that instruction as
  2454.  
  2455.  
  2456.                         (define_insn ""
  2457.                           [(set (match_operand:m 0 ...)
  2458.                                 (and:m (not:m (match_operand:m 1 ...))
  2459.                                              (match_operand:m 2 ...)))]
  2460.                           "..."
  2461.                           "...")
  2462.  
  2463.  
  2464.  
  2465.                Similarly, a pattern  for  a  ``NAND''  instruction
  2466.                should be written
  2467.  
  2468.  
  2469.                         (define_insn ""
  2470.                           [(set (match_operand:m 0 ...)
  2471.                                 (ior:m (not:m (match_operand:m 1 ...))
  2472.                                              (not:m (match_operand:m 2 ...))))]
  2473.                           "..."
  2474.                           "...")
  2475.  
  2476.  
  2477.  
  2478.                     In both cases, it is not necessary to  include
  2479.                     patterns for the many logically equivalent RTL
  2480.                     expressions.
  2481.  
  2482.                o+    The only possible  RTL  expressions  involving
  2483.                     both bitwise exclusive-or and bitwise negation
  2484.                     are (xor:m x) y) and (not:m (xor:m x y)).
  2485.  
  2486.                o+    The sum of three items, one of which is a con-
  2487.                     stant, will only appear in the form
  2488.  
  2489.  
  2490.                         (plus:m (plus:m x y) constant)
  2491.  
  2492.  
  2493.  
  2494.                o+    On machines that do not use  cc0,  (compare  x
  2495.                     (const_int 0)) will be converted to x.
  2496.  
  2497.                o+    Equality comparisons of a group of bits  (usu-
  2498.                     ally  a  single bit) with zero will be written
  2499.                     using zero_extract rather than the  equivalent
  2500.                     and or sign_extract operations.
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.           1.12.  Defining Machine-Specific Peephole Optimizers
  2517.  
  2518.                In addition to instruction patterns the `md'  file  may
  2519.           contain  definitions  of machine-specific peephole optimiza-
  2520.           tions.
  2521.  
  2522.                The combiner does not notice certain peephole optimiza-
  2523.           tions  when  the  data  flow in the program does not suggest
  2524.           that it should try them.  For example,  sometimes  two  con-
  2525.           secutive  insns  related  in  purpose  can  be combined even
  2526.           though the second one does not appear to use a register com-
  2527.           puted  in the first one.  A machine-specific peephole optim-
  2528.           izer can detect such opportunities.
  2529.  
  2530.                A definition looks like this:
  2531.  
  2532.  
  2533.               (define_peephole
  2534.                 [insn-pattern-1
  2535.                  insn-pattern-2
  2536.                  ...]
  2537.                 "condition"
  2538.                 "template"
  2539.                 "optional insn-attributes")
  2540.  
  2541.  
  2542.  
  2543.           The last string operand may be omitted if you are not  using
  2544.           any  machine-specific  information  in this machine descrip-
  2545.           tion.  If present, it must obey  the  same  rules  as  in  a
  2546.           define_insn.
  2547.  
  2548.                In this skeleton, insn-pattern-1 and so on are patterns
  2549.           to  match  consecutive insns.  The optimization applies to a
  2550.           sequence of insns when insn-pattern-1 matches the first one,
  2551.           insn-pattern-2 matches the next, and so on.
  2552.  
  2553.                Each of the insns matched by a peephole must also match
  2554.           a define_insn.  Peepholes are checked only at the last stage
  2555.           just before code generation, and  only  optionally.   There-
  2556.           fore,   any  insn  which  would  match  a  peephole  but  no
  2557.           define_insn will cause a crash  in  code  generation  in  an
  2558.           unoptimized compilation, or at various optimization stages.
  2559.  
  2560.                The  operands   of   the   insns   are   matched   with
  2561.           match_operands,  match_operator,  and  match_dup,  as usual.
  2562.           What is not usual is that the operand numbers apply  to  all
  2563.           the  insn patterns in the definition.  So, you can check for
  2564.           identical operands in two insns by  using  match_operand  in
  2565.           one insn and match_dup in the other.
  2566.  
  2567.                The operand constraints used in match_operand  patterns
  2568.           do  not  have  any direct effect on the applicability of the
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.           peephole, but they will be validated afterward, so make sure
  2583.           your  constraints  are  general enough to apply whenever the
  2584.           peephole matches.  If the  peephole  matches  but  the  con-
  2585.           straints are not satisfied, the compiler will crash.
  2586.  
  2587.                It is safe to omit constraints in all the  operands  of
  2588.           the  peephole; or you can write constraints which serve as a
  2589.           double-check on the criteria previously tested.
  2590.  
  2591.                Once a sequence of insns matches the patterns, the con-
  2592.           dition  is  checked.  This is a C expression which makes the
  2593.           final decision whether to perform the optimization (we do so
  2594.           if  the expression is nonzero).  If condition is omitted (in
  2595.           other words, the string is empty) then the  optimization  is
  2596.           applied  to  every  sequence  of insns that matches the pat-
  2597.           terns.
  2598.  
  2599.                The defined peephole optimizations  are  applied  after
  2600.           register  allocation  is  complete.  Therefore, the peephole
  2601.           definition can check which operands have ended up  in  which
  2602.           kinds of registers, just by looking at the operands.
  2603.  
  2604.                The way to refer to the operands  in  condition  is  to
  2605.           write  operands[i]  for  operand  number  i  (as  matched by
  2606.           (match_operand i ...)).  Use the variable insn to  refer  to
  2607.           the  last  of the insns being matched; use prev_nonnote_insn
  2608.           to find the preceding insns.
  2609.  
  2610.                When optimizing computations with intermediate results,
  2611.           you  can  use  condition to match only when the intermediate
  2612.           results are  not  used  elsewhere.   Use  the  C  expression
  2613.           dead_or_set_p  (insn,  op),  where insn is the insn in which
  2614.           you expect the value to be used for the last time (from  the
  2615.           value  of insn, together with use of prev_nonnote_insn), and
  2616.           op is the intermediate value (from operands[i]).
  2617.  
  2618.                Applying the optimization means replacing the  sequence
  2619.           of  insns with one new insn.  The template controls ultimate
  2620.           output of assembler code for this combined insn.   It  works
  2621.           exactly like the template of a define_insn.  Operand numbers
  2622.           in this template are the same ones used in matching the ori-
  2623.           ginal sequence of insns.
  2624.  
  2625.                The result of a defined  peephole  optimizer  does  not
  2626.           need  to  match  any  of  the  insn  patterns in the machine
  2627.           description; it does not even have an opportunity  to  match
  2628.           them.   The  peephole  optimizer definition itself serves as
  2629.           the insn pattern to control how the insn is output.
  2630.  
  2631.                Defined peephole optimizers are run as  assembler  code
  2632.           is  being  output,  so the insns they produce are never com-
  2633.           bined or rearranged in any way.
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.                Here is  an  example,  taken  from  the  68000  machine
  2649.           description:
  2650.  
  2651.  
  2652.               (define_peephole
  2653.                 [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
  2654.                  (set (match_operand:DF 0 "register_operand" "f")
  2655.                       (match_operand:DF 1 "register_operand" "ad"))]
  2656.                 "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
  2657.                 "*
  2658.               {
  2659.                 rtx xoperands[2];
  2660.                 xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  2661.               #ifdef MOTOROLA
  2662.                 output_asm_insn (\"move.l %1,(sp)\", xoperands);
  2663.                 output_asm_insn (\"move.l %1,-(sp)\", operands);
  2664.                 return \"fmove.d (sp)+,%0\";
  2665.               #else
  2666.                 output_asm_insn (\"movel %1,sp@\", xoperands);
  2667.                 output_asm_insn (\"movel %1,sp@-\", operands);
  2668.                 return \"fmoved sp@+,%0\";
  2669.               #endif
  2670.               }
  2671.               ")
  2672.  
  2673.  
  2674.  
  2675.                The effect of this optimization is to change
  2676.  
  2677.  
  2678.               jbsr _foobar
  2679.               addql #4,sp
  2680.               movel d1,sp@-
  2681.               movel d0,sp@-
  2682.               fmoved sp@+,fp0
  2683.  
  2684.  
  2685.  
  2686.           into
  2687.  
  2688.  
  2689.               jbsr _foobar
  2690.               movel d1,sp@
  2691.               movel d0,sp@-
  2692.               fmoved sp@+,fp0
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.                insn-pattern-1 and so on look almost  like  the  second
  2699.           operand  of define_insn.  There is one important difference:
  2700.           the second operand of define_insn consists of  one  or  more
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.           RTX's  enclosed  in square brackets.  Usually, there is only
  2715.           one: then the same action can be written as an element of  a
  2716.           define_peephole.   But  when there are multiple actions in a
  2717.           define_insn, they are implicitly  enclosed  in  a  parallel.
  2718.           Then  you must explicitly write the parallel, and the square
  2719.           brackets within it, in the  define_peephole.   Thus,  if  an
  2720.           insn pattern looks like this,
  2721.  
  2722.  
  2723.               (define_insn "divmodsi4"
  2724.                 [(set (match_operand:SI 0 "general_operand" "=d")
  2725.                       (div:SI (match_operand:SI 1 "general_operand" "0")
  2726.                               (match_operand:SI 2 "general_operand" "dmsK")))
  2727.                  (set (match_operand:SI 3 "general_operand" "=d")
  2728.                       (mod:SI (match_dup 1) (match_dup 2)))]
  2729.                 "TARGET_68020"
  2730.                 "divsl%.l %2,%3:%0")
  2731.  
  2732.  
  2733.  
  2734.           then the way to mention this insn in a peephole is  as  fol-
  2735.           lows:
  2736.  
  2737.  
  2738.               (define_peephole
  2739.                 [...
  2740.                  (parallel
  2741.                   [(set (match_operand:SI 0 "general_operand" "=d")
  2742.                         (div:SI (match_operand:SI 1 "general_operand" "0")
  2743.                                 (match_operand:SI 2 "general_operand" "dmsK")))
  2744.                    (set (match_operand:SI 3 "general_operand" "=d")
  2745.                         (mod:SI (match_dup 1) (match_dup 2)))])
  2746.                  ...]
  2747.                 ...)
  2748.  
  2749.  
  2750.  
  2751.           1.13.  Defining RTL Sequences for Code Generation
  2752.  
  2753.                On some target machines, some  standard  pattern  names
  2754.           for RTL generation cannot be handled with single insn, but a
  2755.           sequence of RTL insns can represent them.  For these  target
  2756.           machines,  you  can  write a define_expand to specify how to
  2757.           generate the sequence of RTL.
  2758.  
  2759.                A define_expand is an RTL expression that looks  almost
  2760.           like  a define_insn; but, unlike the latter, a define_expand
  2761.           is used only for RTL generation and it can produce more than
  2762.           one RTL insn.
  2763.  
  2764.                A define_expand RTX has four operands:
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.  
  2780.                o+    The name.  Each define_expand must  have  a  name,
  2781.                     since  the  only  use  for it is to refer to it by
  2782.                     name.
  2783.  
  2784.                o+    The RTL template.  This is just like the RTL  tem-
  2785.                     plate for a define_peephole in that it is a vector
  2786.                     of RTL expressions each being one insn.
  2787.  
  2788.                o+    The condition, a string containing a C expression.
  2789.                     This expression is used to express how the availa-
  2790.                     bility of this pattern depends  on  subclasses  of
  2791.                     target  machine,  selected by command-line options
  2792.                     when GNU CC is run.  This is just like the  condi-
  2793.                     tion of a define_insn that has a standard name.
  2794.  
  2795.                o+    The preparation statements,  a  string  containing
  2796.                     zero or more C statements which are to be executed
  2797.                     before RTL code is generated  from  the  RTL  tem-
  2798.                     plate.
  2799.  
  2800.                     Usually these statements prepare temporary  regis-
  2801.                     ters  for use as internal operands in the RTL tem-
  2802.                     plate,  but  they  can  also  generate  RTL  insns
  2803.                     directly  by  calling  routines such as emit_insn,
  2804.                     etc.  Any such insns precede the  ones  that  come
  2805.                     from the RTL template.
  2806.  
  2807.  
  2808.                Every RTL insn emitted by a  define_expand  must  match
  2809.           some define_insn in the machine description.  Otherwise, the
  2810.           compiler will crash when trying to  generate  code  for  the
  2811.           insn or trying to optimize it.
  2812.  
  2813.                The RTL template, in addition to controlling generation
  2814.           of  RTL  insns,  also describes the operands that need to be
  2815.           specified when this pattern  is  used.   In  particular,  it
  2816.           gives a predicate for each operand.
  2817.  
  2818.                A true operand, which needs to be specified in order to
  2819.           generate  RTL  from  the pattern, should be described with a
  2820.           match_operand in its first occurrence in the  RTL  template.
  2821.           This  enters information on the operand's predicate into the
  2822.           tables that record such things.  GNU CC uses the information
  2823.           to  preload  the operand into a register if that is required
  2824.           for valid RTL code.  If the operand is referred to more than
  2825.           once, subsequent references should use match_dup.
  2826.  
  2827.                The  RTL  template   may   also   refer   to   internal
  2828.           ``operands''  which  are  temporary registers or labels used
  2829.           only within the sequence made by the define_expand.   Inter-
  2830.           nal  operands  are  substituted  into  the RTL template with
  2831.           match_dup, never with  match_operand.   The  values  of  the
  2832.           internal  operands  are  not  passed  in as arguments by the
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.           compiler when it requests use  of  this  pattern.   Instead,
  2847.           they  are  computed  within  the pattern, in the preparation
  2848.           statements.  These statements compute the values  and  store
  2849.           them  into  the  appropriate  elements  of  operands so that
  2850.           match_dup can find them.
  2851.  
  2852.                There are two special macros defined  for  use  in  the
  2853.           preparation statements: DONE and FAIL.  Use them with a fol-
  2854.           lowing semicolon, as a statement.
  2855.  
  2856.                DONE
  2857.                     Use the DONE macro to end RTL generation  for  the
  2858.                     pattern.   The  only  RTL insns resulting from the
  2859.                     pattern on this occasion will be those already em-
  2860.                     itted  by  explicit  calls to emit_insn within the
  2861.                     preparation statements; the RTL template will  not
  2862.                     be generated.
  2863.  
  2864.                FAIL
  2865.                     Make the pattern fail on this  occasion.   When  a
  2866.                     pattern  fails,  it means that the pattern was not
  2867.                     truly available.  The calling routines in the com-
  2868.                     piler  will  try other strategies for code genera-
  2869.                     tion using other patterns.
  2870.  
  2871.                     Failure is currently  supported  only  for  binary
  2872.                     (addition,  multiplication,  shifting,  etc.)  and
  2873.                     bitfield (extv, extzv, and insv) operations.
  2874.  
  2875.  
  2876.                Here is an example, the definition  of  left-shift  for
  2877.           the SPUR chip:
  2878.  
  2879.  
  2880.               (define_expand "ashlsi3"
  2881.                 [(set (match_operand:SI 0 "register_operand" "")
  2882.                       (ashift:SI
  2883.                         (match_operand:SI 1 "register_operand" "")
  2884.                         (match_operand:SI 2 "nonmemory_operand" "")))]
  2885.                 ""
  2886.                 "
  2887.               {
  2888.                 if (GET_CODE (operands[2]) != CONST_INT
  2889.                     || (unsigned) INTVAL (operands[2]) > 3)
  2890.                   FAIL;
  2891.               }")
  2892.  
  2893.  
  2894.  
  2895.           This example uses define_expand so that it can  generate  an
  2896.           RTL  insn  for  shifting when the shift-count is in the sup-
  2897.           ported range of 0 to 3 but fail in other cases where machine
  2898.           insns  aren't  available.  When it fails, the compiler tries
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.           another  strategy  using  different  patterns  (such  as,  a
  2913.           library call).
  2914.  
  2915.                If  the  compiler  were  able  to   handle   nontrivial
  2916.           condition-strings  in  patterns with names, then it would be
  2917.           possible to use a define_insn in that case.  Here is another
  2918.           case  (zero-extension  on the 68000) which makes more use of
  2919.           the power of define_expand:
  2920.  
  2921.  
  2922.               (define_expand "zero_extendhisi2"
  2923.                 [(set (match_operand:SI 0 "general_operand" "")
  2924.                       (const_int 0))
  2925.                  (set (strict_low_part
  2926.                         (subreg:HI
  2927.                           (match_dup 0)
  2928.                           0))
  2929.                       (match_operand:HI 1 "general_operand" ""))]
  2930.                 ""
  2931.                 "operands[1] = make_safe_from (operands[1], operands[0]);")
  2932.  
  2933.  
  2934.  
  2935.           Here two RTL insns are generated, one to  clear  the  entire
  2936.           output  operand and the other to copy the input operand into
  2937.           its low half.  This  sequence  is  incorrect  if  the  input
  2938.           operand  refers to [the old value of] the output operand, so
  2939.           the preparation statement makes sure  this  isn't  so.   The
  2940.           function  make_safe_from  copies the operands[1] into a tem-
  2941.           porary register if it refers to operands[0].  It  does  this
  2942.           by emitting another RTL insn.
  2943.  
  2944.                Finally, a third example shows the use of  an  internal
  2945.           operand.  Zero-extension on the SPUR chip is done by and-ing
  2946.           the result against a halfword mask.  But this mask cannot be
  2947.           represented by a const_int because the constant value is too
  2948.           large to be legitimate on  this  machine.   So  it  must  be
  2949.           copied  into a register with force_reg and then the register
  2950.           used in the and.
  2951.  
  2952.  
  2953.               (define_expand "zero_extendhisi2"
  2954.                 [(set (match_operand:SI 0 "register_operand" "")
  2955.                       (and:SI (subreg:SI
  2956.                                 (match_operand:HI 1 "register_operand" "")
  2957.                                 0)
  2958.                               (match_dup 2)))]
  2959.                 ""
  2960.                 "operands[2]
  2961.                    = force_reg (SImode, gen_rtx (CONST_INT,
  2962.                                                  VOIDmode, 65535)); ")
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.                Note: If the define_expand is used to serve a  standard
  2979.           binary  or  unary  arithmetic operation or a bitfield opera-
  2980.           tion, then  the  last  insn  it  generates  must  not  be  a
  2981.           code_label,  barrier or note.  It must be an insn, jump_insn
  2982.           or call_insn.  If you don't need a real  insn  at  the  end,
  2983.           emit  an  insn  to  copy  the  result  of the operation into
  2984.           itself.  Such an insn will generate  no  code,  but  it  can
  2985.           avoid problems in the compiler.
  2986.  
  2987.           1.14.  Splitting Instructions into Multiple Instructions
  2988.  
  2989.                On machines  that  have  instructions  requiring  delay
  2990.           slots  (see  section  Delay Slots) or that have instructions
  2991.           whose output is not available for multiple cycles (see  sec-
  2992.           tion   Function  Units),  the  compiler phases that optimize
  2993.           these cases need to be able to  move  insns  into  one-cycle
  2994.           delay slots.  However, some insns may generate more than one
  2995.           machine instruction.  These insns  would  be  unable  to  be
  2996.           placed into a delay slot.
  2997.  
  2998.                It is often possible to write the single insn as a list
  2999.           of  individual  insns,  each  corresponding  to  one machine
  3000.           instruction.  The disadvantage of doing so is that  it  will
  3001.           cause  the  compilation to be slower and require more space.
  3002.           If the resulting insns are too complex, it may also suppress
  3003.           some optimizations.
  3004.  
  3005.                The define_split definition tells the compiler  how  to
  3006.           split a complex insn into several simpler insns.  This spil-
  3007.           ling will be performed if there is a reason to believe  that
  3008.           it  might improve instruction or delay slot scheduling.  The
  3009.           definition looks like this:
  3010.  
  3011.  
  3012.               (define_split
  3013.                 [insn-pattern]
  3014.                 "condition"
  3015.                 [new-insn-pattern-1
  3016.                  new-insn-pattern-2
  3017.                  ...]
  3018.                 "preparation statements")
  3019.  
  3020.  
  3021.  
  3022.                insn-pattern is a pattern that needs to  be  split  and
  3023.           condition  is  the  final  condition  to  be tested, as in a
  3024.           define_insn.  Any insn matched by a define_split  must  also
  3025.           be  matched  by a define_insn in case it does not need to be
  3026.           split.
  3027.  
  3028.                When an insn matching insn-pattern and satisfying  con-
  3029.           dition  is  found,  it is replaced in the insn list with the
  3030.           insns given by new-insn-pattern-1, new-insn-pattern-2, etc.
  3031.  
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.  
  3044.                The preparation statements are similar to those  speci-
  3045.           fied  for  define_expand (see section  Expander Definitions)
  3046.           and are executed before the new RTL is generated to  prepare
  3047.           for  the  generated code or emit some insns whose pattern is
  3048.           not fixed.
  3049.  
  3050.                As a simple case, consider the following  example  from
  3051.           the   AMD   29000   machine   description,  which  splits  a
  3052.           sign_extend from HImode to  SImode  into  a  pair  of  shift
  3053.           insns:
  3054.  
  3055.  
  3056.               (define_split
  3057.                 [(set (match_operand:SI 0 "gen_reg_operand" "")
  3058.                       (sign_extend:SI (match_operand:HI 1 "gen_reg_operand" "")))]
  3059.                 ""
  3060.                 [(set (match_dup 0)
  3061.                       (ashift:SI (match_dup 1)
  3062.                                  (const_int 16)))
  3063.                  (set (match_dup 0)
  3064.                       (ashiftrt:SI (match_dup 0)
  3065.                                    (const_int 16)))]
  3066.                 "
  3067.               { operands[1] = gen_lowpart (SImode, operands[1]); }")
  3068.  
  3069.  
  3070.  
  3071.           1.15.  Instruction Attributes
  3072.  
  3073.                In addition to describing the instruction supported  by
  3074.           the  target  machine,  the `md' file also defines a group of
  3075.           attributes and a set of values for  each.   Every  generated
  3076.           insn  is  assigned a value for each attribute.  One possible
  3077.           attribute would be the effect  that  the  insn  has  on  the
  3078.           machine's  condition  code.  This attribute can then be used
  3079.           by NOTICE_UPDATE_CC to track the condition codes.
  3080.  
  3081.           1.15.1.  Defining Attributes and their Values
  3082.  
  3083.                The define_attr  expression  is  used  to  define  each
  3084.           attribute required by the target machine.  It looks like:
  3085.  
  3086.  
  3087.               (define_attr name list-of-values default)
  3088.  
  3089.  
  3090.  
  3091.                name is a string specifying the name of  the  attribute
  3092.           being defined.
  3093.  
  3094.                list-of-values is either  a  string  that  specifies  a
  3095.           comma-separated  list  of values that can be assigned to the
  3096.           attribute, or a null string to indicate that  the  attribute
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.           takes numeric values.
  3111.  
  3112.                default is an attribute expression that gives the value
  3113.           of this attribute for insns that match patterns whose defin-
  3114.           ition does not include an explicit value for this attribute.
  3115.           See  section  Attr Example, for more information on the han-
  3116.           dling of defaults.
  3117.  
  3118.                For each defined attribute, a number of definitions are
  3119.           written  to  the  `insn-attr.h'  file.   For  cases where an
  3120.           explicit set of values is specified for  an  attribute,  the
  3121.           following are defined:
  3122.  
  3123.                o+    A   `#define'   is   written   for   the    symbol
  3124.                     `HAVE_ATTR_name'.
  3125.  
  3126.                o+    An enumeral class is defined for `attr_name'  with
  3127.                     elements   of  the  form  `upper-name_upper-value'
  3128.                     where the attribute name and value are first  con-
  3129.                     verted to upper case.
  3130.  
  3131.                o+    A function  `get_attr_name'  is  defined  that  is
  3132.                     passed an insn and returns the attribute value for
  3133.                     that insn.
  3134.  
  3135.  
  3136.                For example, if the following is present  in  the  `md'
  3137.           file:
  3138.  
  3139.  
  3140.               (define_attr "type" "branch,fp,load,store,arith" ...)
  3141.  
  3142.  
  3143.  
  3144.           the following lines will  be  written  to  the  file  `insn-
  3145.           attr.h'.
  3146.  
  3147.  
  3148.               #define HAVE_ATTR_type
  3149.               enum attr_type {TYPE_BRANCH, TYPE_FP, TYPE_LOAD,
  3150.                                TYPE_STORE, TYPE_ARITH};
  3151.               extern enum attr_type get_attr_type ();
  3152.  
  3153.  
  3154.  
  3155.                If the attribute takes numeric  values,  no  enum  type
  3156.           will  be  defined and the function to obtain the attribute's
  3157.           value will return int.
  3158.  
  3159.           1.15.2.  Attribute Expressions
  3160.  
  3161.                RTL expressions used to define attributes use the codes
  3162.           described   above   plus   a   few   specific  to  attribute
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.           definitions, to be discussed below. Attribute value  expres-
  3177.           sions must have one of the following forms:
  3178.  
  3179.                (const_int i)
  3180.                     The integer i specifies the value of a numeric at-
  3181.                     tribute.  i must be non-negative.
  3182.  
  3183.                     The value of a numeric attribute can be  specified
  3184.                     either   with   a   const_int  or  as  an  integer
  3185.                     represented as a string in  const_string,  eq_attr
  3186.                     (see  below),  and  set_attr (see section  Tagging
  3187.                     Insns) expressions.
  3188.  
  3189.                (const_string value)
  3190.                     The string value specifies  a  constant  attribute
  3191.                     value.   If  value is specified as `"*"', it means
  3192.                     that the default value of the attribute is  to  be
  3193.                     used  for  the  insn  containing  this expression.
  3194.                     `"*"' obviously cannot be used in the default  ex-
  3195.                     pression of a define_attr.
  3196.  
  3197.                     If the attribute whose value is being specified is
  3198.                     numeric,  value must be a string containing a non-
  3199.                     negative integer (normally const_int would be used
  3200.                     in  this case).  Otherwise, it must contain one of
  3201.                     the valid values for the attribute.
  3202.  
  3203.                (if_then_else test true-value false-value)
  3204.                     test specifies an attribute test, whose format  is
  3205.                     defined  below.   The  value of this expression is
  3206.                     true-value  if  test  is  true,  otherwise  it  is
  3207.                     false-value.
  3208.  
  3209.                (cond [test1 value1 ...] default)
  3210.                     The first operand of this expression is  a  vector
  3211.                     containing  an even number of expressions and con-
  3212.                     sisting of pairs of test  and  value  expressions.
  3213.                     The  value  of  the cond expression is that of the
  3214.                     value corresponding to the first true test expres-
  3215.                     sion.   If  none of the test expressions are true,
  3216.                     the value of the cond expression is  that  of  the
  3217.                     default expression.
  3218.  
  3219.  
  3220.                test expressions can have one of the following forms:
  3221.  
  3222.                (const_int i)
  3223.                     This test is true if i is non-zero and false  oth-
  3224.                     erwise.
  3225.  
  3226.                (not test)
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.                (ior test1 test2)
  3243.  
  3244.                (and test1 test2)
  3245.                     These tests are  true  if  the  indicated  logical
  3246.                     function is true.
  3247.  
  3248.                (match_operand:m n pred constraints)
  3249.                     This test is true if operand n of the  insn  whose
  3250.                     attribute  value  is  being  determined has mode m
  3251.                     (this part of the test is ignored if  m  is  VOID-
  3252.                     mode)  and  the  function  specified by the string
  3253.                     pred returns a non-zero value when passed  operand
  3254.                     n  and mode m (this part of the test is ignored if
  3255.                     pred is the null string).
  3256.  
  3257.                     The constraints operand is ignored and  should  be
  3258.                     the null string.
  3259.  
  3260.                (le arith1 arith2)
  3261.  
  3262.                (leu arith1 arith2)
  3263.  
  3264.                (lt arith1 arith2)
  3265.  
  3266.                (ltu arith1 arith2)
  3267.  
  3268.                (gt arith1 arith2)
  3269.  
  3270.                (gtu arith1 arith2)
  3271.  
  3272.                (ge arith1 arith2)
  3273.  
  3274.                (geu arith1 arith2)
  3275.  
  3276.                (ne arith1 arith2)
  3277.  
  3278.                (eq arith1 arith2)
  3279.                     These tests are true if the  indicated  comparison
  3280.                     of the two arithmetic expressions is true.  Arith-
  3281.                     metic expressions are  formed  with  plus,  minus,
  3282.                     mult,  div,  mod,  abs,  neg,  and, ior, xor, not,
  3283.                     lshift, ashift,  lshiftrt,  and  ashiftrt  expres-
  3284.                     sions.
  3285.  
  3286.                     const_int and symbol_ref are  always  valid  terms
  3287.                     (see  section  Insn Lengths,for additional forms).
  3288.                     symbol_ref is a string  denoting  a  C  expression
  3289.                     that   yields   an   int  when  evaluated  by  the
  3290.                     `get_attr_...' routine.  It should normally  be  a
  3291.                     global variable.
  3292.  
  3293.                (eq_attr name value)
  3294.                     name is a string specifying the name of an  attri-
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.  
  3305.  
  3306.  
  3307.  
  3308.                     bute.
  3309.  
  3310.                     value is a string that is either a valid value for
  3311.                     attribute  name, a comma-separated list of values,
  3312.                     or `!' followed by a value or list.  If value does
  3313.                     not  begin  with  a  `!', this test is true if the
  3314.                     value of the name attribute of the current insn is
  3315.                     in  the  list specified by value.  If value begins
  3316.                     with a `!', this test is true if  the  attribute's
  3317.                     value is not in the specified list.
  3318.  
  3319.                     For example,
  3320.  
  3321.  
  3322.                         (eq_attr "type" "load,store")
  3323.  
  3324.  
  3325.  
  3326.                is equivalent to
  3327.  
  3328.  
  3329.                         (ior (eq_attr "type" "load") (eq_attr "type" "store"))
  3330.  
  3331.  
  3332.  
  3333.                     If name specifies an  attribute  of  `alterna-
  3334.                     tive',  it refers to the value of the compiler
  3335.                     variable which_alternative (see section   Out-
  3336.                     put  Statement)  and  the values must be small
  3337.                     integers.  For example,
  3338.  
  3339.  
  3340.                         (eq_attr "alternative" "2,3")
  3341.  
  3342.  
  3343.  
  3344.                is equivalent to
  3345.  
  3346.  
  3347.                         (ior (eq (symbol_ref "which_alternative") (const_int 2))
  3348.                              (eq (symbol_ref "which_alternative") (const_int 3)))
  3349.  
  3350.  
  3351.  
  3352.                     Note that, for  most  attributes,  an  eq_attr
  3353.                     test is simplified in cases where the value of
  3354.                     the attribute being tested is  known  for  all
  3355.                     insns  matching a particular pattern.  This is
  3356.                     by far the most common case.
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.  
  3374.           1.15.3.  Assigning Attribute Values to Insns
  3375.  
  3376.                The value assigned to an attribute of an insn  is  pri-
  3377.           marily  determined  by which pattern is matched by that insn
  3378.           (or which define_peephole generated it).  Every  define_insn
  3379.           and  define_peephole  can  have an optional last argument to
  3380.           specify the values of attributes for  matching  insns.   The
  3381.           value of any attribute not specified in a particular insn is
  3382.           set to the default value for that attribute, as specified in
  3383.           its define_attr.  Extensive use of default values for attri-
  3384.           butes permits the specification of the values for  only  one
  3385.           or  two  attributes in the definition of most insn patterns,
  3386.           as seen in the example in the next section.
  3387.  
  3388.                The  optional  last   argument   of   define_insn   and
  3389.           define_peephole  is  a  vector of expressions, each of which
  3390.           defines the value for a single attribute.  The most  general
  3391.           way  of  assigning  an  attribute's  value  is  to use a set
  3392.           expression whose first operand is an attr expression  giving
  3393.           the  name of the attribute being set.  The second operand of
  3394.           the set is an attribute  expression  (see  section   Expres-
  3395.           sions) giving the value of the attribute.
  3396.  
  3397.                When the attribute value depends on  the  `alternative'
  3398.           attribute  (i.e., which is the applicable alternative in the
  3399.           constraint of the insn), the set_attr_alternative expression
  3400.           can can be used.  It allows the specification of a vector of
  3401.           attribute expressions, one for each alternative.
  3402.  
  3403.                When the generality of arbitrary attribute  expressions
  3404.           is  not  required,  the  simpler  set_attr expression can be
  3405.           used, which allows specifying a string giving either a  sin-
  3406.           gle  attribute  value or a list of attribute values, one for
  3407.           each alternative.
  3408.  
  3409.                The form of each of the above specifications  is  shown
  3410.           below.  In each case, name is a string specifying the attri-
  3411.           bute to be set.
  3412.  
  3413.                (set_attr name value-string)
  3414.                     value-string is either a string giving the desired
  3415.                     attribute  value,  or a string containing a comma-
  3416.                     separated list giving the  values  for  succeeding
  3417.                     alternatives.   The  number of elements must match
  3418.                     the number of alternatives in  the  constraint  of
  3419.                     the insn pattern.
  3420.  
  3421.                     Note that it may be useful to specify `*' for some
  3422.                     alternative,  in which case the attribute will as-
  3423.                     sume its default value for insns matching that al-
  3424.                     ternative.
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.  
  3437.  
  3438.  
  3439.  
  3440.                (set_attr_alternative name [value1 value2 ...])
  3441.                     Depending on the  alternative  of  the  insn,  the
  3442.                     value  will  be one of the specified values.  This
  3443.                     is a shorthand for using a cond with tests on  the
  3444.                     `alternative' attribute.
  3445.  
  3446.                (set (attr name) value)
  3447.                     The first operand of this set must be the  special
  3448.                     RTL  expression  attr,  whose  sole  operand  is a
  3449.                     string giving the name of the attribute being set.
  3450.                     value is the value of the attribute.
  3451.  
  3452.  
  3453.                The following shows three different ways of  represent-
  3454.           ing the same attribute value specification:
  3455.  
  3456.  
  3457.               (set_attr "type" "load,store,arith")
  3458.  
  3459.               (set_attr_alternative "type"
  3460.                                     [(const_string "load") (const_string "store")
  3461.                                      (const_string "arith")])
  3462.  
  3463.               (set (attr "type")
  3464.                    (cond [(eq_attr "alternative" "1") (const_string "load")
  3465.                           (eq_attr "alternative" "2") (const_string "store")]
  3466.                          (const_string "arith")))
  3467.  
  3468.  
  3469.  
  3470.                The define_asm_attributes expression provides a mechan-
  3471.           ism  to  specify  the  attributes assigned to insns produced
  3472.           from an asm statement. It has the form:
  3473.  
  3474.  
  3475.               (define_asm_attributes [attr-sets])
  3476.  
  3477.  
  3478.  
  3479.           where attr-sets is specified the same as for define_insn and
  3480.           define_peephole expressions.
  3481.  
  3482.                These values  will  typically  be  the  ``worst  case''
  3483.           attribute values.  For example, they might indicate that the
  3484.           condition code will be clobbered.
  3485.  
  3486.                A specification for a length attribute is handled  spe-
  3487.           cially.   To  compute  the length of an asm insn, the length
  3488.           specified in the define_asm_attributes expression is  multi-
  3489.           plied by the number of machine instructions specified in the
  3490.           asm statement, determined by counting the  number  of  semi-
  3491.           colons  and newlines in the string.  Therefore, the value of
  3492.           the length attribute specified  in  a  define_asm_attributes
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.  
  3503.  
  3504.  
  3505.  
  3506.           should  be  the  maximum possible length of a single machine
  3507.           instruction.
  3508.  
  3509.           1.15.4.  Example of Attribute Specifications
  3510.  
  3511.                The judicious use of defaulting  is  important  in  the
  3512.           efficient  use  of  insn  attributes.   Typically, insns are
  3513.           divided into types  and  an  attribute,  customarily  called
  3514.           type,  is  used  to represent this value.  This attribute is
  3515.           normally used only to define the  default  value  for  other
  3516.           attributes.  An example will clarify this usage.
  3517.  
  3518.                Assume we have a RISC machine with a condition code and
  3519.           in  which  only full-word operations are performed in regis-
  3520.           ters.  Let us assume that  we  can  divide  all  insns  into
  3521.           loads,  stores,  (integer)  arithmetic  operations, floating
  3522.           point operations, and branches.
  3523.  
  3524.                Here we will concern  ourselves  with  determining  the
  3525.           effect  of an insn on the condition code and will limit our-
  3526.           selves to the following  possible  effects:   The  condition
  3527.           code  can  be set unpredictably (clobbered), not be changed,
  3528.           be set to agree with the results of the operation,  or  only
  3529.           changed  if  the item previously set into the condition code
  3530.           has been modified.
  3531.  
  3532.                Here is part of a sample `md' file for such a machine:
  3533.  
  3534.  
  3535.               (define_attr "type" "load,store,arith,fp,branch" (const_string "arith"))
  3536.  
  3537.               (define_attr "cc" "clobber,unchanged,set,change0"
  3538.                            (cond [(eq_attr "type" "load")
  3539.                                       (const_string "change0")
  3540.                                   (eq_attr "type" "store,branch")
  3541.                                       (const_string "unchanged")
  3542.                                   (eq_attr "type" "arith")
  3543.                                       (if_then_else (match_operand:SI 0 "" "")
  3544.                                                     (const_string "set")
  3545.                                                     (const_string "clobber"))]
  3546.                                  (const_string "clobber")))
  3547.  
  3548.               (define_insn ""
  3549.                 [(set (match_operand:SI 0 "general_operand" "=r,r,m")
  3550.                       (match_operand:SI 1 "general_operand" "r,m,r"))]
  3551.                 ""
  3552.                 "@
  3553.                  move %0,%1
  3554.                  load %0,%1
  3555.                  store %0,%1"
  3556.                 [(set_attr "type" "arith,load,store")])
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.  
  3569.  
  3570.  
  3571.  
  3572.                Note that we assume in the above  example  that  arith-
  3573.           metic  operations  performed  on  quantities  smaller than a
  3574.           machine word clobber the condition code since they will  set
  3575.           the condition code to a value corresponding to the full-word
  3576.           result.
  3577.  
  3578.           1.15.5.  Computing the Length of an Insn
  3579.  
  3580.                For many machines, multiple types  of  branch  instruc-
  3581.           tions  are  provided,  each for different length branch dis-
  3582.           placements.  In most cases, the assembler  will  choose  the
  3583.           correct  instruction  to  use.   However, when the assembler
  3584.           cannot do so, GCC can when a special attribute, the `length'
  3585.           attribute,  is  defined.   This attribute must be defined to
  3586.           have numeric values by  specifying  a  null  string  in  its
  3587.           define_attr.
  3588.  
  3589.                In the case of the `length' attribute,  two  additional
  3590.           forms of arithmetic terms are allowed in test expressions:
  3591.  
  3592.                (match_dup n)
  3593.                     This refers to the address of  operand  n  of  the
  3594.                     current insn, which must be a label_ref.
  3595.  
  3596.                (pc)
  3597.                     This refers to the address of  the  current  insn.
  3598.                     It  might  have  been  more  consistent with other
  3599.                     usage to make this the address of  the  next  insn
  3600.                     but  this would be confusing because the length of
  3601.                     the current insn is to be computed.
  3602.  
  3603.  
  3604.                For normal insns, the  length  will  be  determined  by
  3605.           value  of  the  `length' attribute.  In the case of addr_vec
  3606.           and addr_diff_vec insn patterns, the length will be computed
  3607.           as the number of vectors multiplied by the size of each vec-
  3608.           tor.
  3609.  
  3610.                The following macros can be used to refine  the  length
  3611.           computation:
  3612.  
  3613.                FIRST_INSN_ADDRESS
  3614.                     When the length insn attribute is used, this macro
  3615.                     specifies  the value to be assigned to the address
  3616.                     of the first insn in a function.   If  not  speci-
  3617.                     fied, 0 is used.
  3618.  
  3619.                ADJUST_INSN_LENGTH (insn, length)
  3620.                     If defined, modifies the length  assigned  to  in-
  3621.                     struction  insn  as  a  function of the context in
  3622.                     which it is used.  length is an lvalue  that  con-
  3623.                     tains  the  initially  computed length of the insn
  3624.                     and should be updated with the correct  length  of
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.  
  3637.  
  3638.                     the  insn.  If updating is required, insn must not
  3639.                     be a varying-length insn.
  3640.  
  3641.                     This macro will normally not be required.  A  case
  3642.                     in  which  it  is  required  is the ROMP.  On this
  3643.                     machine, the size of an addr_vec insn must be  in-
  3644.                     creased  by  two  to  compensate for the fact that
  3645.                     alignment may be required.
  3646.  
  3647.  
  3648.                The routine that returns the value of the length attri-
  3649.           bute,  get_attr_value,  can be used by the output routine to
  3650.           determine the form of the branch instruction to be  written,
  3651.           as the example below illustrates.
  3652.  
  3653.                As an example of the specification  of  variable-length
  3654.           branches,  consider the IBM 360.  If we adopt the convention
  3655.           that a register will be set to the  starting  address  of  a
  3656.           function, we can jump to labels within 4K of the start using
  3657.           a four-byte instruction.   Otherwise,  we  need  a  six-byte
  3658.           sequence  to load the address from memory and then branch to
  3659.           it.
  3660.  
  3661.                On such a machine, a pattern for a  branch  instruction
  3662.           might be specified as follows:
  3663.  
  3664.  
  3665.               (define_insn "jump"
  3666.                 [(set (pc)
  3667.                       (label_ref (match_operand 0 "" "")))]
  3668.                 ""
  3669.                 "*
  3670.               {
  3671.                  return (get_attr_length (insn) == 4
  3672.                          ? \"b %l0\" : \"l r15,=a(%l0); br r15\");
  3673.               }"
  3674.                 [(set (attr "length") (if_then_else (lt (match_dup 0) (const_int 4096))
  3675.                                                     (const_int 4)
  3676.                                                     (const_int 6)))])
  3677.  
  3678.  
  3679.  
  3680.           1.15.6.  Delay Slot Scheduling
  3681.  
  3682.                The insn attribute mechanism can be used to specify the
  3683.           requirements  for  delay slots, if any, on a target machine.
  3684.           An instruction is said to  require  a  delay  slot  if  some
  3685.           instructions  that  are physically after the instruction are
  3686.           executed as if they were located before it.   Classic  exam-
  3687.           ples  are  branch and call instructions, which often execute
  3688.           the following instruction before the branch or call is  per-
  3689.           formed.
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.                On some machines, conditional branch  instructions  can
  3705.           optionally annul instructions in the delay slot.  This means
  3706.           that the instruction will not be executed for certain branch
  3707.           outcomes.   Both  instructions  that  annul if the branch is
  3708.           true and instructions that annul if the branch is false  are
  3709.           supported.
  3710.  
  3711.           Delay slot scheduling differs from instruction scheduling in
  3712.           that  determining  whether an instruction needs a delay slot
  3713.           is dependent only on the  type  of  instruction  being  gen-
  3714.           erated,  not on data flow between the instructions.  See the
  3715.           next section for a discussion of data-dependent  instruction
  3716.           scheduling.
  3717.  
  3718.                The requirement of an insn needing one  or  more  delay
  3719.           slots  is indicated via the define_delay expression.  It has
  3720.           the following form:
  3721.  
  3722.  
  3723.               (define_delay test
  3724.                             [delay-1 annul-true-1 annul-false-1
  3725.                              delay-2 annul-true-2 annul-false-2
  3726.                              ...])
  3727.  
  3728.  
  3729.  
  3730.                test is an attribute test that indicates  whether  this
  3731.           define_delay  applies  to  a  particular  insn.   If so, the
  3732.           number of required delay slots is determined by  the  length
  3733.           of  the  vector  specified  as the second argument.  An insn
  3734.           placed in delay slot n must satisfy attribute test  delay-n.
  3735.           annul-true-n is an attribute test that specifies which insns
  3736.           may be annulled if the branch is  true.   Similarly,  annul-
  3737.           false-n  specifies  which  insns  in  the  delay slot may be
  3738.           annulled if the branch is false.  If annulling is  not  sup-
  3739.           ported for that delay slot, (nil) should be coded.
  3740.  
  3741.                For example, in the common case where branch  and  call
  3742.           insns  require  a  single  delay slot, which may contain any
  3743.           insn other than a branch or call,  the  following  would  be
  3744.           placed in the `md' file:
  3745.  
  3746.  
  3747.               (define_delay (eq_attr "type" "branch,call")
  3748.                             [(eq_attr "type" "!branch,call") (nil) (nil)])
  3749.  
  3750.  
  3751.  
  3752.                Multiple define_delay expressions may be specified.  In
  3753.           this  case,  each  such expression specifies different delay
  3754.           slot requirements and there must be no insn for which  tests
  3755.           in two define_delay expressions are both true.
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768.  
  3769.  
  3770.                For example, if we have a  machine  that  requires  one
  3771.           delay  slot  for  branches but two for calls,  no delay slot
  3772.           can contain a branch or call insn, and any valid insn in the
  3773.           delay  slot  for the branch can be annulled if the branch is
  3774.           true, we might represent this as follows:
  3775.  
  3776.  
  3777.               (define_delay (eq_attr "type" "branch")
  3778.                  [(eq_attr "type" "!branch,call") (eq_attr "type" "!branch,call") (nil)])
  3779.  
  3780.               (define_delay (eq_attr "type" "call")
  3781.                             [(eq_attr "type" "!branch,call") (nil) (nil)
  3782.                              (eq_attr "type" "!branch,call") (nil) (nil)])
  3783.  
  3784.  
  3785.  
  3786.           1.15.7.  Specifying Function Units
  3787.  
  3788.                On most RISC machines,  there  are  instructions  whose
  3789.           results  are  not available for a specific number of cycles.
  3790.           Common cases are instructions that load  data  from  memory.
  3791.           On  many  machines, a pipeline stall will result if the data
  3792.           is referenced too soon after the load instruction.
  3793.  
  3794.                In addition, many newer microprocessors  have  multiple
  3795.           function units, usually one for integer and one for floating
  3796.           point, and often will incur pipeline stalls  when  a  result
  3797.           that is needed is not yet ready.
  3798.  
  3799.                The descriptions in this section allow  the  specifica-
  3800.           tion  of  how much time must elapse between the execution of
  3801.           an instruction and the time when its  result  is  used.   It
  3802.           also  allows  specification  of  when  the  execution  of an
  3803.           instruction will delay execution of similar instructions due
  3804.           to function unit conflicts.
  3805.  
  3806.                For the purposes of the specifications in this section,
  3807.           a machine is divided into function units, each of which exe-
  3808.           cute a specific class of instructions.  Function units  that
  3809.           accept  one  instruction each cycle and allow a result to be
  3810.           used in the succeeding instruction (usually via  forwarding)
  3811.           need  not  be  specified.  Classic RISC microprocessors will
  3812.           normally have a single function  unit,  which  we  can  call
  3813.           `memory'.   The  newer ``superscalar'' processors will often
  3814.           have function units for floating point  operations,  usually
  3815.           at least a floating point adder and multiplier.
  3816.  
  3817.                Each usage of a function units by a class of  insns  is
  3818.           specified  with  a  define_function_unit  expression,  which
  3819.           looks like this:
  3820.  
  3821.  
  3822.               (define_function_unit name multiplicity simultaneity
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.                                     test ready-delay busy-delay
  3837.                                    [conflict-list])
  3838.  
  3839.  
  3840.  
  3841.                name is a string giving the name of the function unit.
  3842.  
  3843.                multiplicity is an integer  specifying  the  number  of
  3844.           identical  units in the processor.  If more than one unit is
  3845.           specified, they will be scheduled independently.  Only truly
  3846.           independent units should be counted; a pipelined unit should
  3847.           be specified as a single unit.  (The only common example  of
  3848.           a  machine  that  has  multiple  function units for a single
  3849.           instruction class that are truly independent and  not  pipe-
  3850.           lined  are  the  two multiply and two increment units of the
  3851.           CDC 6600.)
  3852.  
  3853.                simultaneity specifies the maximum number of insns that
  3854.           can  be  executing  in  each  instance  of the function unit
  3855.           simultaneously or zero if the unit is pipelined and  has  no
  3856.           limit.
  3857.  
  3858.                All define_function_unit definitions referring to func-
  3859.           tion unit name must have the same name and values for multi-
  3860.           plicity and simultaneity.
  3861.  
  3862.                test is an attribute test that selects the insns we are
  3863.           describing  in  this  definition.  Note that an insn may use
  3864.           more than one function unit  and  a  function  unit  may  be
  3865.           specified in more than one define_function_unit.
  3866.  
  3867.                ready-delay is an integer that specifies the number  of
  3868.           cycles after which the result of the instruction can be used
  3869.           without introducing any stalls.
  3870.  
  3871.                busy-delay is an integer that  represents  the  default
  3872.           cost if an insn is scheduled for this unit while the unit is
  3873.           active with another insn.  If  simultaneity  is  zero,  this
  3874.           specification is ignored.  Otherwise, a zero value indicates
  3875.           that these insns  execute  on  name  in  a  fully  pipelined
  3876.           fashion, even if simultaneity is non-zero.  A non-zero value
  3877.           indicates that scheduling a new  insn  on  this  unit  while
  3878.           another  is  active  will incur a cost.  A cost of two indi-
  3879.           cates a single cycle  delay.   For  a  normal  non-pipelined
  3880.           function unit, busy-delay will be twice ready-delay.
  3881.  
  3882.                conflict-list is an optional list giving detailed  con-
  3883.           flict  costs  for  this unit.  If specified, it is a list of
  3884.           condition  test  expressions  which  are  applied  to  insns
  3885.           already  executing  in  name.   For each insn that is in the
  3886.           list, busy-delay will be used for the conflict cost, while a
  3887.           value of zero will be used for insns not in the list.
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.  
  3899.  
  3900.  
  3901.  
  3902.                Typical uses of this vector are where a floating  point
  3903.           function   unit  can  pipeline  either  single-  or  double-
  3904.           precision operations, but not both, or where a  memory  unit
  3905.           can pipeline loads, but not stores, etc.
  3906.  
  3907.                As an example, consider a classic  RISC  machine  where
  3908.           the  result  of  a load instruction is not available for two
  3909.           cycles (a single  ``delay''  instruction  is  required)  and
  3910.           where  only  one load instruction can be executed simultane-
  3911.           ously.  This would be specified as:
  3912.  
  3913.  
  3914.               (define_function_unit "memory" 1 1 (eq_attr "type" "load") 2 4)
  3915.  
  3916.  
  3917.  
  3918.                For the case of a floating point function unit that can
  3919.           pipeline  either  single  or double precision, but not both,
  3920.           the following could be specified:
  3921.  
  3922.  
  3923.               (define_function_unit
  3924.                  "fp" 1 1 (eq_attr "type" "sp_fp") 4 8 (eq_attr "type" "dp_fp")]
  3925.               (define_function_unit
  3926.                  "fp" 1 1 (eq_attr "type" "dp_fp") 4 8 (eq_attr "type" "sp_fp")]
  3927.  
  3928.  
  3929.  
  3930.                Note: No code currently exists to avoid  function  unit
  3931.           conflicts,  only data conflicts.  Hence multiplicity, simul-
  3932.           taneity, busy-cost, and conflict-list are currently ignored.
  3933.           When  such code is written, it is possible that the specifi-
  3934.           cations for these values may be changed.   It  has  recently
  3935.           come  to  our  attention  that  these specifications may not
  3936.           allow modeling of some of the newer ``superscalar''  proces-
  3937.           sors  that have insns using multiple pipelined units.  These
  3938.           insns will cause a potential conflict for  the  second  unit
  3939.           used   during  their  execution  and  there  is  no  way  of
  3940.           representing that conflict.  We welcome any examples of  how
  3941.           function  unit conflicts work in such processors and sugges-
  3942.           tions for their representation.
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.