Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

187 lines
9.2KB

  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>Patterns (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Patterns (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Patterns (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="Example.html#Example" rel="next" title="Example">
  31. <link href="Overview.html#Overview" rel="prev" title="Overview">
  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="Patterns"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Example.html#Example" accesskey="n" rel="next">Example</a>, Previous: <a href="Overview.html#Overview" accesskey="p" rel="prev">Overview</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="Everything-about-Instruction-Patterns"></a>
  68. <h3 class="section">17.2 Everything about Instruction Patterns</h3>
  69. <a name="index-patterns"></a>
  70. <a name="index-instruction-patterns"></a>
  71. <a name="index-define_005finsn"></a>
  72. <p>A <code>define_insn</code> expression is used to define instruction patterns
  73. to which insns may be matched. A <code>define_insn</code> expression contains
  74. an incomplete RTL expression, with pieces to be filled in later, operand
  75. constraints that restrict how the pieces can be filled in, and an output
  76. template or C code to generate the assembler output.
  77. </p>
  78. <p>A <code>define_insn</code> is an RTL expression containing four or five operands:
  79. </p>
  80. <ol>
  81. <li> An optional name <var>n</var>. When a name is present, the compiler
  82. automically generates a C++ function &lsquo;<samp>gen_<var>n</var></samp>&rsquo; that takes
  83. the operands of the instruction as arguments and returns the instruction&rsquo;s
  84. rtx pattern. The compiler also assigns the instruction a unique code
  85. &lsquo;<samp>CODE_FOR_<var>n</var></samp>&rsquo;, with all such codes belonging to an enum
  86. called <code>insn_code</code>.
  87. <p>These names serve one of two purposes. The first is to indicate that the
  88. instruction performs a certain standard job for the RTL-generation
  89. pass of the compiler, such as a move, an addition, or a conditional
  90. jump. The second is to help the target generate certain target-specific
  91. operations, such as when implementing target-specific intrinsic functions.
  92. </p>
  93. <p>It is better to prefix target-specific names with the name of the
  94. target, to avoid any clash with current or future standard names.
  95. </p>
  96. <p>The absence of a name is indicated by writing an empty string
  97. where the name should go. Nameless instruction patterns are never
  98. used for generating RTL code, but they may permit several simpler insns
  99. to be combined later on.
  100. </p>
  101. <p>For the purpose of debugging the compiler, you may also specify a
  102. name beginning with the &lsquo;<samp>*</samp>&rsquo; character. Such a name is used only
  103. for identifying the instruction in RTL dumps; it is equivalent to having
  104. a nameless pattern for all other purposes. Names beginning with the
  105. &lsquo;<samp>*</samp>&rsquo; character are not required to be unique.
  106. </p>
  107. <p>The name may also have the form &lsquo;<samp>@<var>n</var></samp>&rsquo;. This has the same
  108. effect as a name &lsquo;<samp><var>n</var></samp>&rsquo;, but in addition tells the compiler to
  109. generate further helper functions; see <a href="Parameterized-Names.html#Parameterized-Names">Parameterized Names</a> for details.
  110. </p>
  111. </li><li> The <em>RTL template</em>: This is a vector of incomplete RTL expressions
  112. which describe the semantics of the instruction (see <a href="RTL-Template.html#RTL-Template">RTL Template</a>).
  113. It is incomplete because it may contain <code>match_operand</code>,
  114. <code>match_operator</code>, and <code>match_dup</code> expressions that stand for
  115. operands of the instruction.
  116. <p>If the vector has multiple elements, the RTL template is treated as a
  117. <code>parallel</code> expression.
  118. </p>
  119. </li><li> <a name="index-pattern-conditions"></a>
  120. <a name="index-conditions_002c-in-patterns"></a>
  121. The condition: This is a string which contains a C expression. When the
  122. compiler attempts to match RTL against a pattern, the condition is
  123. evaluated. If the condition evaluates to <code>true</code>, the match is
  124. permitted. The condition may be an empty string, which is treated
  125. as always <code>true</code>.
  126. <a name="index-named-patterns-and-conditions"></a>
  127. <p>For a named pattern, the condition may not depend on the data in the
  128. insn being matched, but only the target-machine-type flags. The compiler
  129. needs to test these conditions during initialization in order to learn
  130. exactly which named instructions are available in a particular run.
  131. </p>
  132. <a name="index-operands-1"></a>
  133. <p>For nameless patterns, the condition is applied only when matching an
  134. individual insn, and only after the insn has matched the pattern&rsquo;s
  135. recognition template. The insn&rsquo;s operands may be found in the vector
  136. <code>operands</code>.
  137. </p>
  138. <p>An instruction condition cannot become more restrictive as compilation
  139. progresses. If the condition accepts a particular RTL instruction at
  140. one stage of compilation, it must continue to accept that instruction
  141. until the final pass. For example, &lsquo;<samp>!reload_completed</samp>&rsquo; and
  142. &lsquo;<samp>can_create_pseudo_p ()</samp>&rsquo; are both invalid instruction conditions,
  143. because they are true during the earlier RTL passes and false during
  144. the later ones. For the same reason, if a condition accepts an
  145. instruction before register allocation, it cannot later try to control
  146. register allocation by excluding certain register or value combinations.
  147. </p>
  148. <p>Although a condition cannot become more restrictive as compilation
  149. progresses, the condition for a nameless pattern <em>can</em> become
  150. more permissive. For example, a nameless instruction can require
  151. &lsquo;<samp>reload_completed</samp>&rsquo; to be true, in which case it only matches
  152. after register allocation.
  153. </p>
  154. </li><li> The <em>output template</em> or <em>output statement</em>: This is either
  155. a string, or a fragment of C code which returns a string.
  156. <p>When simple substitution isn&rsquo;t general enough, you can specify a piece
  157. of C code to compute the output. See <a href="Output-Statement.html#Output-Statement">Output Statement</a>.
  158. </p>
  159. </li><li> The <em>insn attributes</em>: This is an optional vector containing the values of
  160. attributes for insns matching this pattern (see <a href="Insn-Attributes.html#Insn-Attributes">Insn Attributes</a>).
  161. </li></ol>
  162. <hr>
  163. <div class="header">
  164. <p>
  165. Next: <a href="Example.html#Example" accesskey="n" rel="next">Example</a>, Previous: <a href="Overview.html#Overview" accesskey="p" rel="prev">Overview</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>
  166. </div>
  167. </body>
  168. </html>