Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

194 rindas
8.0KB

  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>Disable Insn Alternatives (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Disable Insn Alternatives (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Disable Insn Alternatives (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="Define-Constraints.html#Define-Constraints" rel="next" title="Define Constraints">
  31. <link href="Machine-Constraints.html#Machine-Constraints" rel="prev" title="Machine 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="Disable-Insn-Alternatives"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Define-Constraints.html#Define-Constraints" accesskey="n" rel="next">Define Constraints</a>, Previous: <a href="Machine-Constraints.html#Machine-Constraints" accesskey="p" rel="prev">Machine 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="Disable-insn-alternatives-using-the-enabled-attribute"></a>
  68. <h4 class="subsection">17.8.6 Disable insn alternatives using the <code>enabled</code> attribute</h4>
  69. <a name="index-enabled"></a>
  70. <p>There are three insn attributes that may be used to selectively disable
  71. instruction alternatives:
  72. </p>
  73. <dl compact="compact">
  74. <dt><code>enabled</code></dt>
  75. <dd><p>Says whether an alternative is available on the current subtarget.
  76. </p>
  77. </dd>
  78. <dt><code>preferred_for_size</code></dt>
  79. <dd><p>Says whether an enabled alternative should be used in code that is
  80. optimized for size.
  81. </p>
  82. </dd>
  83. <dt><code>preferred_for_speed</code></dt>
  84. <dd><p>Says whether an enabled alternative should be used in code that is
  85. optimized for speed.
  86. </p></dd>
  87. </dl>
  88. <p>All these attributes should use <code>(const_int 1)</code> to allow an alternative
  89. or <code>(const_int 0)</code> to disallow it. The attributes must be a static
  90. property of the subtarget; they cannot for example depend on the
  91. current operands, on the current optimization level, on the location
  92. of the insn within the body of a loop, on whether register allocation
  93. has finished, or on the current compiler pass.
  94. </p>
  95. <p>The <code>enabled</code> attribute is a correctness property. It tells GCC to act
  96. as though the disabled alternatives were never defined in the first place.
  97. This is useful when adding new instructions to an existing pattern in
  98. cases where the new instructions are only available for certain cpu
  99. architecture levels (typically mapped to the <code>-march=</code> command-line
  100. option).
  101. </p>
  102. <p>In contrast, the <code>preferred_for_size</code> and <code>preferred_for_speed</code>
  103. attributes are strong optimization hints rather than correctness properties.
  104. <code>preferred_for_size</code> tells GCC which alternatives to consider when
  105. adding or modifying an instruction that GCC wants to optimize for size.
  106. <code>preferred_for_speed</code> does the same thing for speed. Note that things
  107. like code motion can lead to cases where code optimized for size uses
  108. alternatives that are not preferred for size, and similarly for speed.
  109. </p>
  110. <p>Although <code>define_insn</code>s can in principle specify the <code>enabled</code>
  111. attribute directly, it is often clearer to have subsiduary attributes
  112. for each architectural feature of interest. The <code>define_insn</code>s
  113. can then use these subsiduary attributes to say which alternatives
  114. require which features. The example below does this for <code>cpu_facility</code>.
  115. </p>
  116. <p>E.g. the following two patterns could easily be merged using the <code>enabled</code>
  117. attribute:
  118. </p>
  119. <div class="smallexample">
  120. <pre class="smallexample">
  121. (define_insn &quot;*movdi_old&quot;
  122. [(set (match_operand:DI 0 &quot;register_operand&quot; &quot;=d&quot;)
  123. (match_operand:DI 1 &quot;register_operand&quot; &quot; d&quot;))]
  124. &quot;!TARGET_NEW&quot;
  125. &quot;lgr %0,%1&quot;)
  126. (define_insn &quot;*movdi_new&quot;
  127. [(set (match_operand:DI 0 &quot;register_operand&quot; &quot;=d,f,d&quot;)
  128. (match_operand:DI 1 &quot;register_operand&quot; &quot; d,d,f&quot;))]
  129. &quot;TARGET_NEW&quot;
  130. &quot;@
  131. lgr %0,%1
  132. ldgr %0,%1
  133. lgdr %0,%1&quot;)
  134. </pre></div>
  135. <p>to:
  136. </p>
  137. <div class="smallexample">
  138. <pre class="smallexample">
  139. (define_insn &quot;*movdi_combined&quot;
  140. [(set (match_operand:DI 0 &quot;register_operand&quot; &quot;=d,f,d&quot;)
  141. (match_operand:DI 1 &quot;register_operand&quot; &quot; d,d,f&quot;))]
  142. &quot;&quot;
  143. &quot;@
  144. lgr %0,%1
  145. ldgr %0,%1
  146. lgdr %0,%1&quot;
  147. [(set_attr &quot;cpu_facility&quot; &quot;*,new,new&quot;)])
  148. </pre></div>
  149. <p>with the <code>enabled</code> attribute defined like this:
  150. </p>
  151. <div class="smallexample">
  152. <pre class="smallexample">
  153. (define_attr &quot;cpu_facility&quot; &quot;standard,new&quot; (const_string &quot;standard&quot;))
  154. (define_attr &quot;enabled&quot; &quot;&quot;
  155. (cond [(eq_attr &quot;cpu_facility&quot; &quot;standard&quot;) (const_int 1)
  156. (and (eq_attr &quot;cpu_facility&quot; &quot;new&quot;)
  157. (ne (symbol_ref &quot;TARGET_NEW&quot;) (const_int 0)))
  158. (const_int 1)]
  159. (const_int 0)))
  160. </pre></div>
  161. <hr>
  162. <div class="header">
  163. <p>
  164. Next: <a href="Define-Constraints.html#Define-Constraints" accesskey="n" rel="next">Define Constraints</a>, Previous: <a href="Machine-Constraints.html#Machine-Constraints" accesskey="p" rel="prev">Machine 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>
  165. </div>
  166. </body>
  167. </html>