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.

177 rindas
7.6KB

  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>Define Subst Example (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Define Subst Example (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Define Subst Example (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="Define-Subst.html#Define-Subst" rel="up" title="Define Subst">
  30. <link href="Define-Subst-Pattern-Matching.html#Define-Subst-Pattern-Matching" rel="next" title="Define Subst Pattern Matching">
  31. <link href="Define-Subst.html#Define-Subst" rel="prev" title="Define Subst">
  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="Define-Subst-Example"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Define-Subst-Pattern-Matching.html#Define-Subst-Pattern-Matching" accesskey="n" rel="next">Define Subst Pattern Matching</a>, Up: <a href="Define-Subst.html#Define-Subst" accesskey="u" rel="up">Define Subst</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="define_005fsubst-Example"></a>
  68. <h4 class="subsection">17.21.1 <code>define_subst</code> Example</h4>
  69. <a name="index-define_005fsubst-1"></a>
  70. <p>To illustrate how <code>define_subst</code> works, let us examine a simple
  71. template transformation.
  72. </p>
  73. <p>Suppose there are two kinds of instructions: one that touches flags and
  74. the other that does not. The instructions of the second type could be
  75. generated with the following <code>define_subst</code>:
  76. </p>
  77. <div class="smallexample">
  78. <pre class="smallexample">(define_subst &quot;add_clobber_subst&quot;
  79. [(set (match_operand:SI 0 &quot;&quot; &quot;&quot;)
  80. (match_operand:SI 1 &quot;&quot; &quot;&quot;))]
  81. &quot;&quot;
  82. [(set (match_dup 0)
  83. (match_dup 1))
  84. (clobber (reg:CC FLAGS_REG))])
  85. </pre></div>
  86. <p>This <code>define_subst</code> can be applied to any RTL pattern containing
  87. <code>set</code> of mode SI and generates a copy with clobber when it is
  88. applied.
  89. </p>
  90. <p>Assume there is an RTL template for a <code>max</code> instruction to be used
  91. in <code>define_subst</code> mentioned above:
  92. </p>
  93. <div class="smallexample">
  94. <pre class="smallexample">(define_insn &quot;maxsi&quot;
  95. [(set (match_operand:SI 0 &quot;register_operand&quot; &quot;=r&quot;)
  96. (max:SI
  97. (match_operand:SI 1 &quot;register_operand&quot; &quot;r&quot;)
  98. (match_operand:SI 2 &quot;register_operand&quot; &quot;r&quot;)))]
  99. &quot;&quot;
  100. &quot;max\t{%2, %1, %0|%0, %1, %2}&quot;
  101. [&hellip;])
  102. </pre></div>
  103. <p>To mark the RTL template for <code>define_subst</code> application,
  104. subst-attributes are used. They should be declared in advance:
  105. </p>
  106. <div class="smallexample">
  107. <pre class="smallexample">(define_subst_attr &quot;add_clobber_name&quot; &quot;add_clobber_subst&quot; &quot;_noclobber&quot; &quot;_clobber&quot;)
  108. </pre></div>
  109. <p>Here &lsquo;<samp>add_clobber_name</samp>&rsquo; is the attribute name,
  110. &lsquo;<samp>add_clobber_subst</samp>&rsquo; is the name of the corresponding
  111. <code>define_subst</code>, the third argument (&lsquo;<samp>_noclobber</samp>&rsquo;) is the
  112. attribute value that would be substituted into the unchanged version of
  113. the source RTL template, and the last argument (&lsquo;<samp>_clobber</samp>&rsquo;) is the
  114. value that would be substituted into the second, transformed,
  115. version of the RTL template.
  116. </p>
  117. <p>Once the subst-attribute has been defined, it should be used in RTL
  118. templates which need to be processed by the <code>define_subst</code>. So,
  119. the original RTL template should be changed:
  120. </p>
  121. <div class="smallexample">
  122. <pre class="smallexample">(define_insn &quot;maxsi&lt;add_clobber_name&gt;&quot;
  123. [(set (match_operand:SI 0 &quot;register_operand&quot; &quot;=r&quot;)
  124. (max:SI
  125. (match_operand:SI 1 &quot;register_operand&quot; &quot;r&quot;)
  126. (match_operand:SI 2 &quot;register_operand&quot; &quot;r&quot;)))]
  127. &quot;&quot;
  128. &quot;max\t{%2, %1, %0|%0, %1, %2}&quot;
  129. [&hellip;])
  130. </pre></div>
  131. <p>The result of the <code>define_subst</code> usage would look like the following:
  132. </p>
  133. <div class="smallexample">
  134. <pre class="smallexample">(define_insn &quot;maxsi_noclobber&quot;
  135. [(set (match_operand:SI 0 &quot;register_operand&quot; &quot;=r&quot;)
  136. (max:SI
  137. (match_operand:SI 1 &quot;register_operand&quot; &quot;r&quot;)
  138. (match_operand:SI 2 &quot;register_operand&quot; &quot;r&quot;)))]
  139. &quot;&quot;
  140. &quot;max\t{%2, %1, %0|%0, %1, %2}&quot;
  141. [&hellip;])
  142. (define_insn &quot;maxsi_clobber&quot;
  143. [(set (match_operand:SI 0 &quot;register_operand&quot; &quot;=r&quot;)
  144. (max:SI
  145. (match_operand:SI 1 &quot;register_operand&quot; &quot;r&quot;)
  146. (match_operand:SI 2 &quot;register_operand&quot; &quot;r&quot;)))
  147. (clobber (reg:CC FLAGS_REG))]
  148. &quot;&quot;
  149. &quot;max\t{%2, %1, %0|%0, %1, %2}&quot;
  150. [&hellip;])
  151. </pre></div>
  152. <hr>
  153. <div class="header">
  154. <p>
  155. Next: <a href="Define-Subst-Pattern-Matching.html#Define-Subst-Pattern-Matching" accesskey="n" rel="next">Define Subst Pattern Matching</a>, Up: <a href="Define-Subst.html#Define-Subst" accesskey="u" rel="up">Define Subst</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>