Patterns.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Patterns</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Patterns">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Patterns">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Patterns"></a>
  63. <div class="header">
  64. <p>
  65. 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>
  66. </div>
  67. <hr>
  68. <a name="Everything-about-Instruction-Patterns"></a>
  69. <h3 class="section">16.2 Everything about Instruction Patterns</h3>
  70. <a name="index-patterns"></a>
  71. <a name="index-instruction-patterns"></a>
  72. <a name="index-define_005finsn"></a>
  73. <p>A <code>define_insn</code> expression is used to define instruction patterns
  74. to which insns may be matched. A <code>define_insn</code> expression contains
  75. an incomplete RTL expression, with pieces to be filled in later, operand
  76. constraints that restrict how the pieces can be filled in, and an output
  77. template or C code to generate the assembler output.
  78. </p>
  79. <p>A <code>define_insn</code> is an RTL expression containing four or five operands:
  80. </p>
  81. <ol>
  82. <li> An optional name. The presence of a name indicate that this instruction
  83. pattern can perform a certain standard job for the RTL-generation
  84. pass of the compiler. This pass knows certain names and will use
  85. the instruction patterns with those names, if the names are defined
  86. in the machine description.
  87. <p>The absence of a name is indicated by writing an empty string
  88. where the name should go. Nameless instruction patterns are never
  89. used for generating RTL code, but they may permit several simpler insns
  90. to be combined later on.
  91. </p>
  92. <p>Names that are not thus known and used in RTL-generation have no
  93. effect; they are equivalent to no name at all.
  94. </p>
  95. <p>For the purpose of debugging the compiler, you may also specify a
  96. name beginning with the &lsquo;<samp>*</samp>&rsquo; character. Such a name is used only
  97. for identifying the instruction in RTL dumps; it is equivalent to having
  98. a nameless pattern for all other purposes. Names beginning with the
  99. &lsquo;<samp>*</samp>&rsquo; character are not required to be unique.
  100. </p>
  101. </li><li> The <em>RTL template</em>: This is a vector of incomplete RTL expressions
  102. which describe the semantics of the instruction (see <a href="RTL-Template.html#RTL-Template">RTL Template</a>).
  103. It is incomplete because it may contain <code>match_operand</code>,
  104. <code>match_operator</code>, and <code>match_dup</code> expressions that stand for
  105. operands of the instruction.
  106. <p>If the vector has multiple elements, the RTL template is treated as a
  107. <code>parallel</code> expression.
  108. </p>
  109. </li><li> <a name="index-pattern-conditions"></a>
  110. <a name="index-conditions_002c-in-patterns"></a>
  111. The condition: This is a string which contains a C expression. When the
  112. compiler attempts to match RTL against a pattern, the condition is
  113. evaluated. If the condition evaluates to <code>true</code>, the match is
  114. permitted. The condition may be an empty string, which is treated
  115. as always <code>true</code>.
  116. <a name="index-named-patterns-and-conditions"></a>
  117. <p>For a named pattern, the condition may not depend on the data in the
  118. insn being matched, but only the target-machine-type flags. The compiler
  119. needs to test these conditions during initialization in order to learn
  120. exactly which named instructions are available in a particular run.
  121. </p>
  122. <a name="index-operands-1"></a>
  123. <p>For nameless patterns, the condition is applied only when matching an
  124. individual insn, and only after the insn has matched the pattern&rsquo;s
  125. recognition template. The insn&rsquo;s operands may be found in the vector
  126. <code>operands</code>.
  127. </p>
  128. <p>For an insn where the condition has once matched, it
  129. cannot later be used to control register allocation by excluding
  130. certain register or value combinations.
  131. </p>
  132. </li><li> The <em>output template</em> or <em>output statement</em>: This is either
  133. a string, or a fragment of C code which returns a string.
  134. <p>When simple substitution isn&rsquo;t general enough, you can specify a piece
  135. of C code to compute the output. See <a href="Output-Statement.html#Output-Statement">Output Statement</a>.
  136. </p>
  137. </li><li> The <em>insn attributes</em>: This is an optional vector containing the values of
  138. attributes for insns matching this pattern (see <a href="Insn-Attributes.html#Insn-Attributes">Insn Attributes</a>).
  139. </li></ol>
  140. <hr>
  141. <div class="header">
  142. <p>
  143. 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>
  144. </div>
  145. </body>
  146. </html>