You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
8.1KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Multi-Alternative (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Multi-Alternative (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Multi-Alternative (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Constraints.html#Constraints" rel="up" title="Constraints">
  30. <link href="Class-Preferences.html#Class-Preferences" rel="next" title="Class Preferences">
  31. <link href="Simple-Constraints.html#Simple-Constraints" rel="prev" title="Simple Constraints">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Multi_002dAlternative"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Class-Preferences.html#Class-Preferences" accesskey="n" rel="next">Class Preferences</a>, Previous: <a href="Simple-Constraints.html#Simple-Constraints" accesskey="p" rel="prev">Simple Constraints</a>, Up: <a href="Constraints.html#Constraints" accesskey="u" rel="up">Constraints</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Multiple-Alternative-Constraints"></a>
  68. <h4 class="subsection">17.8.2 Multiple Alternative Constraints</h4>
  69. <a name="index-multiple-alternative-constraints"></a>
  70. <p>Sometimes a single instruction has multiple alternative sets of possible
  71. operands. For example, on the 68000, a logical-or instruction can combine
  72. register or an immediate value into memory, or it can combine any kind of
  73. operand into a register; but it cannot combine one memory location into
  74. another.
  75. </p>
  76. <p>These constraints are represented as multiple alternatives. An alternative
  77. can be described by a series of letters for each operand. The overall
  78. constraint for an operand is made from the letters for this operand
  79. from the first alternative, a comma, the letters for this operand from
  80. the second alternative, a comma, and so on until the last alternative.
  81. All operands for a single instruction must have the same number of
  82. alternatives.
  83. Here is how it is done for fullword logical-or on the 68000:
  84. </p>
  85. <div class="smallexample">
  86. <pre class="smallexample">(define_insn &quot;iorsi3&quot;
  87. [(set (match_operand:SI 0 &quot;general_operand&quot; &quot;=m,d&quot;)
  88. (ior:SI (match_operand:SI 1 &quot;general_operand&quot; &quot;%0,0&quot;)
  89. (match_operand:SI 2 &quot;general_operand&quot; &quot;dKs,dmKs&quot;)))]
  90. &hellip;)
  91. </pre></div>
  92. <p>The first alternative has &lsquo;<samp>m</samp>&rsquo; (memory) for operand 0, &lsquo;<samp>0</samp>&rsquo; for
  93. operand 1 (meaning it must match operand 0), and &lsquo;<samp>dKs</samp>&rsquo; for operand
  94. 2. The second alternative has &lsquo;<samp>d</samp>&rsquo; (data register) for operand 0,
  95. &lsquo;<samp>0</samp>&rsquo; for operand 1, and &lsquo;<samp>dmKs</samp>&rsquo; for operand 2. The &lsquo;<samp>=</samp>&rsquo; and
  96. &lsquo;<samp>%</samp>&rsquo; in the constraints apply to all the alternatives; their
  97. meaning is explained in the next section (see <a href="Class-Preferences.html#Class-Preferences">Class Preferences</a>).
  98. </p>
  99. <p>If all the operands fit any one alternative, the instruction is valid.
  100. Otherwise, for each alternative, the compiler counts how many instructions
  101. must be added to copy the operands so that that alternative applies.
  102. The alternative requiring the least copying is chosen. If two alternatives
  103. need the same amount of copying, the one that comes first is chosen.
  104. These choices can be altered with the &lsquo;<samp>?</samp>&rsquo; and &lsquo;<samp>!</samp>&rsquo; characters:
  105. </p>
  106. <dl compact="compact">
  107. <dd><a name="index-_003f-in-constraint"></a>
  108. <a name="index-question-mark"></a>
  109. </dd>
  110. <dt><code>?</code></dt>
  111. <dd><p>Disparage slightly the alternative that the &lsquo;<samp>?</samp>&rsquo; appears in,
  112. as a choice when no alternative applies exactly. The compiler regards
  113. this alternative as one unit more costly for each &lsquo;<samp>?</samp>&rsquo; that appears
  114. in it.
  115. </p>
  116. <a name="index-_0021-in-constraint"></a>
  117. <a name="index-exclamation-point"></a>
  118. </dd>
  119. <dt><code>!</code></dt>
  120. <dd><p>Disparage severely the alternative that the &lsquo;<samp>!</samp>&rsquo; appears in.
  121. This alternative can still be used if it fits without reloading,
  122. but if reloading is needed, some other alternative will be used.
  123. </p>
  124. <a name="index-_005e-in-constraint"></a>
  125. <a name="index-caret"></a>
  126. </dd>
  127. <dt><code>^</code></dt>
  128. <dd><p>This constraint is analogous to &lsquo;<samp>?</samp>&rsquo; but it disparages slightly
  129. the alternative only if the operand with the &lsquo;<samp>^</samp>&rsquo; needs a reload.
  130. </p>
  131. <a name="index-_0024-in-constraint"></a>
  132. <a name="index-dollar-sign"></a>
  133. </dd>
  134. <dt><code>$</code></dt>
  135. <dd><p>This constraint is analogous to &lsquo;<samp>!</samp>&rsquo; but it disparages severely
  136. the alternative only if the operand with the &lsquo;<samp>$</samp>&rsquo; needs a reload.
  137. </p></dd>
  138. </dl>
  139. <p>When an insn pattern has multiple alternatives in its constraints, often
  140. the appearance of the assembler code is determined mostly by which
  141. alternative was matched. When this is so, the C code for writing the
  142. assembler code can use the variable <code>which_alternative</code>, which is
  143. the ordinal number of the alternative that was actually satisfied (0 for
  144. the first, 1 for the second alternative, etc.). See <a href="Output-Statement.html#Output-Statement">Output Statement</a>.
  145. </p>
  146. <hr>
  147. <div class="header">
  148. <p>
  149. Next: <a href="Class-Preferences.html#Class-Preferences" accesskey="n" rel="next">Class Preferences</a>, Previous: <a href="Simple-Constraints.html#Simple-Constraints" accesskey="p" rel="prev">Simple Constraints</a>, Up: <a href="Constraints.html#Constraints" accesskey="u" rel="up">Constraints</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  150. </div>
  151. </body>
  152. </html>