Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

264 lines
13KB

  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 Constraints (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Define Constraints (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Define Constraints (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="C-Constraint-Interface.html#C-Constraint-Interface" rel="next" title="C Constraint Interface">
  31. <link href="Disable-Insn-Alternatives.html#Disable-Insn-Alternatives" rel="prev" title="Disable Insn Alternatives">
  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-Constraints"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="C-Constraint-Interface.html#C-Constraint-Interface" accesskey="n" rel="next">C Constraint Interface</a>, Previous: <a href="Disable-Insn-Alternatives.html#Disable-Insn-Alternatives" accesskey="p" rel="prev">Disable Insn Alternatives</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="Defining-Machine_002dSpecific-Constraints"></a>
  68. <h4 class="subsection">17.8.7 Defining Machine-Specific Constraints</h4>
  69. <a name="index-defining-constraints"></a>
  70. <a name="index-constraints_002c-defining"></a>
  71. <p>Machine-specific constraints fall into two categories: register and
  72. non-register constraints. Within the latter category, constraints
  73. which allow subsets of all possible memory or address operands should
  74. be specially marked, to give <code>reload</code> more information.
  75. </p>
  76. <p>Machine-specific constraints can be given names of arbitrary length,
  77. but they must be entirely composed of letters, digits, underscores
  78. (&lsquo;<samp>_</samp>&rsquo;), and angle brackets (&lsquo;<samp>&lt; &gt;</samp>&rsquo;). Like C identifiers, they
  79. must begin with a letter or underscore.
  80. </p>
  81. <p>In order to avoid ambiguity in operand constraint strings, no
  82. constraint can have a name that begins with any other constraint&rsquo;s
  83. name. For example, if <code>x</code> is defined as a constraint name,
  84. <code>xy</code> may not be, and vice versa. As a consequence of this rule,
  85. no constraint may begin with one of the generic constraint letters:
  86. &lsquo;<samp>E F V X g i m n o p r s</samp>&rsquo;.
  87. </p>
  88. <p>Register constraints correspond directly to register classes.
  89. See <a href="Register-Classes.html#Register-Classes">Register Classes</a>. There is thus not much flexibility in their
  90. definitions.
  91. </p>
  92. <dl>
  93. <dt><a name="index-define_005fregister_005fconstraint"></a>MD Expression: <strong>define_register_constraint</strong> <em>name regclass docstring</em></dt>
  94. <dd><p>All three arguments are string constants.
  95. <var>name</var> is the name of the constraint, as it will appear in
  96. <code>match_operand</code> expressions. If <var>name</var> is a multi-letter
  97. constraint its length shall be the same for all constraints starting
  98. with the same letter. <var>regclass</var> can be either the
  99. name of the corresponding register class (see <a href="Register-Classes.html#Register-Classes">Register Classes</a>),
  100. or a C expression which evaluates to the appropriate register class.
  101. If it is an expression, it must have no side effects, and it cannot
  102. look at the operand. The usual use of expressions is to map some
  103. register constraints to <code>NO_REGS</code> when the register class
  104. is not available on a given subarchitecture.
  105. </p>
  106. <p><var>docstring</var> is a sentence documenting the meaning of the
  107. constraint. Docstrings are explained further below.
  108. </p></dd></dl>
  109. <p>Non-register constraints are more like predicates: the constraint
  110. definition gives a boolean expression which indicates whether the
  111. constraint matches.
  112. </p>
  113. <dl>
  114. <dt><a name="index-define_005fconstraint"></a>MD Expression: <strong>define_constraint</strong> <em>name docstring exp</em></dt>
  115. <dd><p>The <var>name</var> and <var>docstring</var> arguments are the same as for
  116. <code>define_register_constraint</code>, but note that the docstring comes
  117. immediately after the name for these expressions. <var>exp</var> is an RTL
  118. expression, obeying the same rules as the RTL expressions in predicate
  119. definitions. See <a href="Defining-Predicates.html#Defining-Predicates">Defining Predicates</a>, for details. If it
  120. evaluates true, the constraint matches; if it evaluates false, it
  121. doesn&rsquo;t. Constraint expressions should indicate which RTL codes they
  122. might match, just like predicate expressions.
  123. </p>
  124. <p><code>match_test</code> C expressions have access to the
  125. following variables:
  126. </p>
  127. <dl compact="compact">
  128. <dt><var>op</var></dt>
  129. <dd><p>The RTL object defining the operand.
  130. </p></dd>
  131. <dt><var>mode</var></dt>
  132. <dd><p>The machine mode of <var>op</var>.
  133. </p></dd>
  134. <dt><var>ival</var></dt>
  135. <dd><p>&lsquo;<samp>INTVAL (<var>op</var>)</samp>&rsquo;, if <var>op</var> is a <code>const_int</code>.
  136. </p></dd>
  137. <dt><var>hval</var></dt>
  138. <dd><p>&lsquo;<samp>CONST_DOUBLE_HIGH (<var>op</var>)</samp>&rsquo;, if <var>op</var> is an integer
  139. <code>const_double</code>.
  140. </p></dd>
  141. <dt><var>lval</var></dt>
  142. <dd><p>&lsquo;<samp>CONST_DOUBLE_LOW (<var>op</var>)</samp>&rsquo;, if <var>op</var> is an integer
  143. <code>const_double</code>.
  144. </p></dd>
  145. <dt><var>rval</var></dt>
  146. <dd><p>&lsquo;<samp>CONST_DOUBLE_REAL_VALUE (<var>op</var>)</samp>&rsquo;, if <var>op</var> is a floating-point
  147. <code>const_double</code>.
  148. </p></dd>
  149. </dl>
  150. <p>The <var>*val</var> variables should only be used once another piece of the
  151. expression has verified that <var>op</var> is the appropriate kind of RTL
  152. object.
  153. </p></dd></dl>
  154. <p>Most non-register constraints should be defined with
  155. <code>define_constraint</code>. The remaining two definition expressions
  156. are only appropriate for constraints that should be handled specially
  157. by <code>reload</code> if they fail to match.
  158. </p>
  159. <dl>
  160. <dt><a name="index-define_005fmemory_005fconstraint"></a>MD Expression: <strong>define_memory_constraint</strong> <em>name docstring exp</em></dt>
  161. <dd><p>Use this expression for constraints that match a subset of all memory
  162. operands: that is, <code>reload</code> can make them match by converting the
  163. operand to the form &lsquo;<samp>(mem&nbsp;(reg&nbsp;<var>X</var>))<!-- /@w --></samp>&rsquo;, where <var>X</var> is a
  164. base register (from the register class specified by
  165. <code>BASE_REG_CLASS</code>, see <a href="Register-Classes.html#Register-Classes">Register Classes</a>).
  166. </p>
  167. <p>For example, on the S/390, some instructions do not accept arbitrary
  168. memory references, but only those that do not make use of an index
  169. register. The constraint letter &lsquo;<samp>Q</samp>&rsquo; is defined to represent a
  170. memory address of this type. If &lsquo;<samp>Q</samp>&rsquo; is defined with
  171. <code>define_memory_constraint</code>, a &lsquo;<samp>Q</samp>&rsquo; constraint can handle any
  172. memory operand, because <code>reload</code> knows it can simply copy the
  173. memory address into a base register if required. This is analogous to
  174. the way an &lsquo;<samp>o</samp>&rsquo; constraint can handle any memory operand.
  175. </p>
  176. <p>The syntax and semantics are otherwise identical to
  177. <code>define_constraint</code>.
  178. </p></dd></dl>
  179. <dl>
  180. <dt><a name="index-define_005fspecial_005fmemory_005fconstraint"></a>MD Expression: <strong>define_special_memory_constraint</strong> <em>name docstring exp</em></dt>
  181. <dd><p>Use this expression for constraints that match a subset of all memory
  182. operands: that is, <code>reload</code> cannot make them match by reloading
  183. the address as it is described for <code>define_memory_constraint</code> or
  184. such address reload is undesirable with the performance point of view.
  185. </p>
  186. <p>For example, <code>define_special_memory_constraint</code> can be useful if
  187. specifically aligned memory is necessary or desirable for some insn
  188. operand.
  189. </p>
  190. <p>The syntax and semantics are otherwise identical to
  191. <code>define_constraint</code>.
  192. </p></dd></dl>
  193. <dl>
  194. <dt><a name="index-define_005faddress_005fconstraint"></a>MD Expression: <strong>define_address_constraint</strong> <em>name docstring exp</em></dt>
  195. <dd><p>Use this expression for constraints that match a subset of all address
  196. operands: that is, <code>reload</code> can make the constraint match by
  197. converting the operand to the form &lsquo;<samp>(reg&nbsp;<var>X</var>)<!-- /@w --></samp>&rsquo;, again
  198. with <var>X</var> a base register.
  199. </p>
  200. <p>Constraints defined with <code>define_address_constraint</code> can only be
  201. used with the <code>address_operand</code> predicate, or machine-specific
  202. predicates that work the same way. They are treated analogously to
  203. the generic &lsquo;<samp>p</samp>&rsquo; constraint.
  204. </p>
  205. <p>The syntax and semantics are otherwise identical to
  206. <code>define_constraint</code>.
  207. </p></dd></dl>
  208. <p>For historical reasons, names beginning with the letters &lsquo;<samp>G H</samp>&rsquo;
  209. are reserved for constraints that match only <code>const_double</code>s, and
  210. names beginning with the letters &lsquo;<samp>I J K L M N O P</samp>&rsquo; are reserved
  211. for constraints that match only <code>const_int</code>s. This may change in
  212. the future. For the time being, constraints with these names must be
  213. written in a stylized form, so that <code>genpreds</code> can tell you did
  214. it correctly:
  215. </p>
  216. <div class="smallexample">
  217. <pre class="smallexample">(define_constraint &quot;[<var>GHIJKLMNOP</var>]&hellip;&quot;
  218. &quot;<var>doc</var>&hellip;&quot;
  219. (and (match_code &quot;const_int&quot;) ; <span class="roman"><code>const_double</code> for G/H</span>
  220. <var>condition</var>&hellip;)) ; <span class="roman">usually a <code>match_test</code></span>
  221. </pre></div>
  222. <p>It is fine to use names beginning with other letters for constraints
  223. that match <code>const_double</code>s or <code>const_int</code>s.
  224. </p>
  225. <p>Each docstring in a constraint definition should be one or more complete
  226. sentences, marked up in Texinfo format. <em>They are currently unused.</em>
  227. In the future they will be copied into the GCC manual, in <a href="Machine-Constraints.html#Machine-Constraints">Machine Constraints</a>, replacing the hand-maintained tables currently found in
  228. that section. Also, in the future the compiler may use this to give
  229. more helpful diagnostics when poor choice of <code>asm</code> constraints
  230. causes a reload failure.
  231. </p>
  232. <p>If you put the pseudo-Texinfo directive &lsquo;<samp>@internal</samp>&rsquo; at the
  233. beginning of a docstring, then (in the future) it will appear only in
  234. the internals manual&rsquo;s version of the machine-specific constraint tables.
  235. Use this for constraints that should not appear in <code>asm</code> statements.
  236. </p>
  237. <hr>
  238. <div class="header">
  239. <p>
  240. Next: <a href="C-Constraint-Interface.html#C-Constraint-Interface" accesskey="n" rel="next">C Constraint Interface</a>, Previous: <a href="Disable-Insn-Alternatives.html#Disable-Insn-Alternatives" accesskey="p" rel="prev">Disable Insn Alternatives</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>
  241. </div>
  242. </body>
  243. </html>