You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 satır
8.5KB

  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>C Constraint Interface (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="C Constraint Interface (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="C Constraint Interface (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="Standard-Names.html#Standard-Names" rel="next" title="Standard Names">
  31. <link href="Define-Constraints.html#Define-Constraints" rel="prev" title="Define Constraints">
  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="C-Constraint-Interface"></a>
  62. <div class="header">
  63. <p>
  64. Previous: <a href="Define-Constraints.html#Define-Constraints" accesskey="p" rel="prev">Define Constraints</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="Testing-constraints-from-C"></a>
  68. <h4 class="subsection">17.8.8 Testing constraints from C</h4>
  69. <a name="index-testing-constraints"></a>
  70. <a name="index-constraints_002c-testing"></a>
  71. <p>It is occasionally useful to test a constraint from C code rather than
  72. implicitly via the constraint string in a <code>match_operand</code>. The
  73. generated file <samp>tm_p.h</samp> declares a few interfaces for working
  74. with constraints. At present these are defined for all constraints
  75. except <code>g</code> (which is equivalent to <code>general_operand</code>).
  76. </p>
  77. <p>Some valid constraint names are not valid C identifiers, so there is a
  78. mangling scheme for referring to them from C. Constraint names that
  79. do not contain angle brackets or underscores are left unchanged.
  80. Underscores are doubled, each &lsquo;<samp>&lt;</samp>&rsquo; is replaced with &lsquo;<samp>_l</samp>&rsquo;, and
  81. each &lsquo;<samp>&gt;</samp>&rsquo; with &lsquo;<samp>_g</samp>&rsquo;. Here are some examples:
  82. </p>
  83. <div class="example">
  84. <table>
  85. <tr><td><pre class="example"><strong>Original</strong></pre></td><td><pre class="example"><strong>Mangled</strong></pre></td></tr>
  86. <tr><td><pre class="example"><code>x</code></pre></td><td><pre class="example"><code>x</code></pre></td></tr>
  87. <tr><td><pre class="example"><code>P42x</code></pre></td><td><pre class="example"><code>P42x</code></pre></td></tr>
  88. <tr><td><pre class="example"><code>P4_x</code></pre></td><td><pre class="example"><code>P4__x</code></pre></td></tr>
  89. <tr><td><pre class="example"><code>P4&gt;x</code></pre></td><td><pre class="example"><code>P4_gx</code></pre></td></tr>
  90. <tr><td><pre class="example"><code>P4&gt;&gt;</code></pre></td><td><pre class="example"><code>P4_g_g</code></pre></td></tr>
  91. <tr><td><pre class="example"><code>P4_g&gt;</code></pre></td><td><pre class="example"><code>P4__g_g</code></pre></td></tr>
  92. </table>
  93. </div>
  94. <p>Throughout this section, the variable <var>c</var> is either a constraint
  95. in the abstract sense, or a constant from <code>enum constraint_num</code>;
  96. the variable <var>m</var> is a mangled constraint name (usually as part of
  97. a larger identifier).
  98. </p>
  99. <dl>
  100. <dt><a name="index-constraint_005fnum"></a>Enum: <strong>constraint_num</strong></dt>
  101. <dd><p>For each constraint except <code>g</code>, there is a corresponding
  102. enumeration constant: &lsquo;<samp>CONSTRAINT_</samp>&rsquo; plus the mangled name of the
  103. constraint. Functions that take an <code>enum constraint_num</code> as an
  104. argument expect one of these constants.
  105. </p></dd></dl>
  106. <dl>
  107. <dt><a name="index-satisfies_005fconstraint_005fm"></a>Function: <em>inline bool</em> <strong>satisfies_constraint_<var>m</var></strong> <em>(rtx <var>exp</var>)</em></dt>
  108. <dd><p>For each non-register constraint <var>m</var> except <code>g</code>, there is
  109. one of these functions; it returns <code>true</code> if <var>exp</var> satisfies the
  110. constraint. These functions are only visible if <samp>rtl.h</samp> was included
  111. before <samp>tm_p.h</samp>.
  112. </p></dd></dl>
  113. <dl>
  114. <dt><a name="index-constraint_005fsatisfied_005fp"></a>Function: <em>bool</em> <strong>constraint_satisfied_p</strong> <em>(rtx <var>exp</var>, enum constraint_num <var>c</var>)</em></dt>
  115. <dd><p>Like the <code>satisfies_constraint_<var>m</var></code> functions, but the
  116. constraint to test is given as an argument, <var>c</var>. If <var>c</var>
  117. specifies a register constraint, this function will always return
  118. <code>false</code>.
  119. </p></dd></dl>
  120. <dl>
  121. <dt><a name="index-reg_005fclass_005ffor_005fconstraint"></a>Function: <em>enum reg_class</em> <strong>reg_class_for_constraint</strong> <em>(enum constraint_num <var>c</var>)</em></dt>
  122. <dd><p>Returns the register class associated with <var>c</var>. If <var>c</var> is not
  123. a register constraint, or those registers are not available for the
  124. currently selected subtarget, returns <code>NO_REGS</code>.
  125. </p></dd></dl>
  126. <p>Here is an example use of <code>satisfies_constraint_<var>m</var></code>. In
  127. peephole optimizations (see <a href="Peephole-Definitions.html#Peephole-Definitions">Peephole Definitions</a>), operand
  128. constraint strings are ignored, so if there are relevant constraints,
  129. they must be tested in the C condition. In the example, the
  130. optimization is applied if operand 2 does <em>not</em> satisfy the
  131. &lsquo;<samp>K</samp>&rsquo; constraint. (This is a simplified version of a peephole
  132. definition from the i386 machine description.)
  133. </p>
  134. <div class="smallexample">
  135. <pre class="smallexample">(define_peephole2
  136. [(match_scratch:SI 3 &quot;r&quot;)
  137. (set (match_operand:SI 0 &quot;register_operand&quot; &quot;&quot;)
  138. (mult:SI (match_operand:SI 1 &quot;memory_operand&quot; &quot;&quot;)
  139. (match_operand:SI 2 &quot;immediate_operand&quot; &quot;&quot;)))]
  140. &quot;!satisfies_constraint_K (operands[2])&quot;
  141. [(set (match_dup 3) (match_dup 1))
  142. (set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))]
  143. &quot;&quot;)
  144. </pre></div>
  145. <hr>
  146. <div class="header">
  147. <p>
  148. Previous: <a href="Define-Constraints.html#Define-Constraints" accesskey="p" rel="prev">Define Constraints</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>
  149. </div>
  150. </body>
  151. </html>