Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

197 lines
9.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>Parameterized Names (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Parameterized Names (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Parameterized Names (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="Iterators.html#Iterators" rel="up" title="Iterators">
  30. <link href="Target-Macros.html#Target-Macros" rel="next" title="Target Macros">
  31. <link href="Subst-Iterators.html#Subst-Iterators" rel="prev" title="Subst Iterators">
  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="Parameterized-Names"></a>
  62. <div class="header">
  63. <p>
  64. Previous: <a href="Subst-Iterators.html#Subst-Iterators" accesskey="p" rel="prev">Subst Iterators</a>, Up: <a href="Iterators.html#Iterators" accesskey="u" rel="up">Iterators</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="Parameterized-Names-1"></a>
  68. <h4 class="subsection">17.23.5 Parameterized Names</h4>
  69. <a name="index-_0040-in-instruction-pattern-names"></a>
  70. <p>Ports sometimes need to apply iterators using C++ code, in order to
  71. get the code or RTL pattern for a specific instruction. For example,
  72. suppose we have the &lsquo;<samp>neon_vq&lt;absneg&gt;&lt;mode&gt;</samp>&rsquo; pattern given above:
  73. </p>
  74. <div class="smallexample">
  75. <pre class="smallexample">(define_int_iterator QABSNEG [UNSPEC_VQABS UNSPEC_VQNEG])
  76. (define_int_attr absneg [(UNSPEC_VQABS &quot;abs&quot;) (UNSPEC_VQNEG &quot;neg&quot;)])
  77. (define_insn &quot;neon_vq&lt;absneg&gt;&lt;mode&gt;&quot;
  78. [(set (match_operand:VDQIW 0 &quot;s_register_operand&quot; &quot;=w&quot;)
  79. (unspec:VDQIW [(match_operand:VDQIW 1 &quot;s_register_operand&quot; &quot;w&quot;)
  80. (match_operand:SI 2 &quot;immediate_operand&quot; &quot;i&quot;)]
  81. QABSNEG))]
  82. &hellip;
  83. )
  84. </pre></div>
  85. <p>A port might need to generate this pattern for a variable
  86. &lsquo;<samp>QABSNEG</samp>&rsquo; value and a variable &lsquo;<samp>VDQIW</samp>&rsquo; mode. There are two
  87. ways of doing this. The first is to build the rtx for the pattern
  88. directly from C++ code; this is a valid technique and avoids any risk
  89. of combinatorial explosion. The second is to prefix the instruction
  90. name with the special character &lsquo;<samp>@</samp>&rsquo;, which tells GCC to generate
  91. the four additional functions below. In each case, <var>name</var> is the
  92. name of the instruction without the leading &lsquo;<samp>@</samp>&rsquo; character,
  93. without the &lsquo;<samp>&lt;&hellip;&gt;</samp>&rsquo; placeholders, and with any underscore
  94. before a &lsquo;<samp>&lt;&hellip;&gt;</samp>&rsquo; placeholder removed if keeping it would
  95. lead to a double or trailing underscore.
  96. </p>
  97. <dl compact="compact">
  98. <dt>&lsquo;<samp>insn_code maybe_code_for_<var>name</var> (<var>i1</var>, <var>i2</var>, &hellip;)</samp>&rsquo;</dt>
  99. <dd><p>See whether replacing the first &lsquo;<samp>&lt;&hellip;&gt;</samp>&rsquo; placeholder with
  100. iterator value <var>i1</var>, the second with iterator value <var>i2</var>, and
  101. so on, gives a valid instruction. Return its code if so, otherwise
  102. return <code>CODE_FOR_nothing</code>.
  103. </p>
  104. </dd>
  105. <dt>&lsquo;<samp>insn_code code_for_<var>name</var> (<var>i1</var>, <var>i2</var>, &hellip;)</samp>&rsquo;</dt>
  106. <dd><p>Same, but abort the compiler if the requested instruction does not exist.
  107. </p>
  108. </dd>
  109. <dt>&lsquo;<samp>rtx maybe_gen_<var>name</var> (<var>i1</var>, <var>i2</var>, &hellip;, <var>op0</var>, <var>op1</var>, &hellip;)</samp>&rsquo;</dt>
  110. <dd><p>Check for a valid instruction in the same way as
  111. <code>maybe_code_for_<var>name</var></code>. If the instruction exists,
  112. generate an instance of it using the operand values given by <var>op0</var>,
  113. <var>op1</var>, and so on, otherwise return null.
  114. </p>
  115. </dd>
  116. <dt>&lsquo;<samp>rtx gen_<var>name</var> (<var>i1</var>, <var>i2</var>, &hellip;, <var>op0</var>, <var>op1</var>, &hellip;)</samp>&rsquo;</dt>
  117. <dd><p>Same, but abort the compiler if the requested instruction does not exist,
  118. or if the instruction generator invoked the <code>FAIL</code> macro.
  119. </p></dd>
  120. </dl>
  121. <p>For example, changing the pattern above to:
  122. </p>
  123. <div class="smallexample">
  124. <pre class="smallexample">(define_insn &quot;@neon_vq&lt;absneg&gt;&lt;mode&gt;&quot;
  125. [(set (match_operand:VDQIW 0 &quot;s_register_operand&quot; &quot;=w&quot;)
  126. (unspec:VDQIW [(match_operand:VDQIW 1 &quot;s_register_operand&quot; &quot;w&quot;)
  127. (match_operand:SI 2 &quot;immediate_operand&quot; &quot;i&quot;)]
  128. QABSNEG))]
  129. &hellip;
  130. )
  131. </pre></div>
  132. <p>would define the same patterns as before, but in addition would generate
  133. the four functions below:
  134. </p>
  135. <div class="smallexample">
  136. <pre class="smallexample">insn_code maybe_code_for_neon_vq (int, machine_mode);
  137. insn_code code_for_neon_vq (int, machine_mode);
  138. rtx maybe_gen_neon_vq (int, machine_mode, rtx, rtx, rtx);
  139. rtx gen_neon_vq (int, machine_mode, rtx, rtx, rtx);
  140. </pre></div>
  141. <p>Calling &lsquo;<samp>code_for_neon_vq (UNSPEC_VQABS, V8QImode)</samp>&rsquo;
  142. would then give <code>CODE_FOR_neon_vqabsv8qi</code>.
  143. </p>
  144. <p>It is possible to have multiple &lsquo;<samp>@</samp>&rsquo; patterns with the same
  145. name and same types of iterator. For example:
  146. </p>
  147. <div class="smallexample">
  148. <pre class="smallexample">(define_insn &quot;@some_arithmetic_op&lt;mode&gt;&quot;
  149. [(set (match_operand:INTEGER_MODES 0 &quot;register_operand&quot;) &hellip;)]
  150. &hellip;
  151. )
  152. (define_insn &quot;@some_arithmetic_op&lt;mode&gt;&quot;
  153. [(set (match_operand:FLOAT_MODES 0 &quot;register_operand&quot;) &hellip;)]
  154. &hellip;
  155. )
  156. </pre></div>
  157. <p>would produce a single set of functions that handles both
  158. <code>INTEGER_MODES</code> and <code>FLOAT_MODES</code>.
  159. </p>
  160. <p>It is also possible for these &lsquo;<samp>@</samp>&rsquo; patterns to have different
  161. numbers of operands from each other. For example, patterns with
  162. a binary rtl code might take three operands (one output and two inputs)
  163. while patterns with a ternary rtl code might take four operands (one
  164. output and three inputs). This combination would produce separate
  165. &lsquo;<samp>maybe_gen_<var>name</var></samp>&rsquo; and &lsquo;<samp>gen_<var>name</var></samp>&rsquo; functions for
  166. each operand count, but it would still produce a single
  167. &lsquo;<samp>maybe_code_for_<var>name</var></samp>&rsquo; and a single &lsquo;<samp>code_for_<var>name</var></samp>&rsquo;.
  168. </p>
  169. <hr>
  170. <div class="header">
  171. <p>
  172. Previous: <a href="Subst-Iterators.html#Subst-Iterators" accesskey="p" rel="prev">Subst Iterators</a>, Up: <a href="Iterators.html#Iterators" accesskey="u" rel="up">Iterators</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>
  173. </div>
  174. </body>
  175. </html>