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.

176 satır
8.3KB

  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>Conditional Execution (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Conditional Execution (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Conditional Execution (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="Machine-Desc.html#Machine-Desc" rel="up" title="Machine Desc">
  30. <link href="Define-Subst.html#Define-Subst" rel="next" title="Define Subst">
  31. <link href="Processor-pipeline-description.html#Processor-pipeline-description" rel="prev" title="Processor pipeline description">
  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="Conditional-Execution"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Define-Subst.html#Define-Subst" accesskey="n" rel="next">Define Subst</a>, Previous: <a href="Insn-Attributes.html#Insn-Attributes" accesskey="p" rel="prev">Insn Attributes</a>, Up: <a href="Machine-Desc.html#Machine-Desc" accesskey="u" rel="up">Machine Desc</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="Conditional-Execution-1"></a>
  68. <h3 class="section">17.20 Conditional Execution</h3>
  69. <a name="index-conditional-execution"></a>
  70. <a name="index-predication"></a>
  71. <p>A number of architectures provide for some form of conditional
  72. execution, or predication. The hallmark of this feature is the
  73. ability to nullify most of the instructions in the instruction set.
  74. When the instruction set is large and not entirely symmetric, it
  75. can be quite tedious to describe these forms directly in the
  76. <samp>.md</samp> file. An alternative is the <code>define_cond_exec</code> template.
  77. </p>
  78. <a name="index-define_005fcond_005fexec"></a>
  79. <div class="smallexample">
  80. <pre class="smallexample">(define_cond_exec
  81. [<var>predicate-pattern</var>]
  82. &quot;<var>condition</var>&quot;
  83. &quot;<var>output-template</var>&quot;
  84. &quot;<var>optional-insn-attribues</var>&quot;)
  85. </pre></div>
  86. <p><var>predicate-pattern</var> is the condition that must be true for the
  87. insn to be executed at runtime and should match a relational operator.
  88. One can use <code>match_operator</code> to match several relational operators
  89. at once. Any <code>match_operand</code> operands must have no more than one
  90. alternative.
  91. </p>
  92. <p><var>condition</var> is a C expression that must be true for the generated
  93. pattern to match.
  94. </p>
  95. <a name="index-current_005finsn_005fpredicate"></a>
  96. <p><var>output-template</var> is a string similar to the <code>define_insn</code>
  97. output template (see <a href="Output-Template.html#Output-Template">Output Template</a>), except that the &lsquo;<samp>*</samp>&rsquo;
  98. and &lsquo;<samp>@</samp>&rsquo; special cases do not apply. This is only useful if the
  99. assembly text for the predicate is a simple prefix to the main insn.
  100. In order to handle the general case, there is a global variable
  101. <code>current_insn_predicate</code> that will contain the entire predicate
  102. if the current insn is predicated, and will otherwise be <code>NULL</code>.
  103. </p>
  104. <p><var>optional-insn-attributes</var> is an optional vector of attributes that gets
  105. appended to the insn attributes of the produced cond_exec rtx. It can
  106. be used to add some distinguishing attribute to cond_exec rtxs produced
  107. that way. An example usage would be to use this attribute in conjunction
  108. with attributes on the main pattern to disable particular alternatives under
  109. certain conditions.
  110. </p>
  111. <p>When <code>define_cond_exec</code> is used, an implicit reference to
  112. the <code>predicable</code> instruction attribute is made.
  113. See <a href="Insn-Attributes.html#Insn-Attributes">Insn Attributes</a>. This attribute must be a boolean (i.e. have
  114. exactly two elements in its <var>list-of-values</var>), with the possible
  115. values being <code>no</code> and <code>yes</code>. The default and all uses in
  116. the insns must be a simple constant, not a complex expressions. It
  117. may, however, depend on the alternative, by using a comma-separated
  118. list of values. If that is the case, the port should also define an
  119. <code>enabled</code> attribute (see <a href="Disable-Insn-Alternatives.html#Disable-Insn-Alternatives">Disable Insn Alternatives</a>), which
  120. should also allow only <code>no</code> and <code>yes</code> as its values.
  121. </p>
  122. <p>For each <code>define_insn</code> for which the <code>predicable</code>
  123. attribute is true, a new <code>define_insn</code> pattern will be
  124. generated that matches a predicated version of the instruction.
  125. For example,
  126. </p>
  127. <div class="smallexample">
  128. <pre class="smallexample">(define_insn &quot;addsi&quot;
  129. [(set (match_operand:SI 0 &quot;register_operand&quot; &quot;r&quot;)
  130. (plus:SI (match_operand:SI 1 &quot;register_operand&quot; &quot;r&quot;)
  131. (match_operand:SI 2 &quot;register_operand&quot; &quot;r&quot;)))]
  132. &quot;<var>test1</var>&quot;
  133. &quot;add %2,%1,%0&quot;)
  134. (define_cond_exec
  135. [(ne (match_operand:CC 0 &quot;register_operand&quot; &quot;c&quot;)
  136. (const_int 0))]
  137. &quot;<var>test2</var>&quot;
  138. &quot;(%0)&quot;)
  139. </pre></div>
  140. <p>generates a new pattern
  141. </p>
  142. <div class="smallexample">
  143. <pre class="smallexample">(define_insn &quot;&quot;
  144. [(cond_exec
  145. (ne (match_operand:CC 3 &quot;register_operand&quot; &quot;c&quot;) (const_int 0))
  146. (set (match_operand:SI 0 &quot;register_operand&quot; &quot;r&quot;)
  147. (plus:SI (match_operand:SI 1 &quot;register_operand&quot; &quot;r&quot;)
  148. (match_operand:SI 2 &quot;register_operand&quot; &quot;r&quot;))))]
  149. &quot;(<var>test2</var>) &amp;&amp; (<var>test1</var>)&quot;
  150. &quot;(%3) add %2,%1,%0&quot;)
  151. </pre></div>
  152. <hr>
  153. <div class="header">
  154. <p>
  155. Next: <a href="Define-Subst.html#Define-Subst" accesskey="n" rel="next">Define Subst</a>, Previous: <a href="Insn-Attributes.html#Insn-Attributes" accesskey="p" rel="prev">Insn Attributes</a>, Up: <a href="Machine-Desc.html#Machine-Desc" accesskey="u" rel="up">Machine Desc</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>
  156. </div>
  157. </body>
  158. </html>