Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

153 linhas
7.7KB

  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>Predicates (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Predicates (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Predicates (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="Machine_002dIndependent-Predicates.html#Machine_002dIndependent-Predicates" rel="next" title="Machine-Independent Predicates">
  31. <link href="Output-Statement.html#Output-Statement" rel="prev" title="Output Statement">
  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="Predicates"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Constraints.html#Constraints" accesskey="n" rel="next">Constraints</a>, Previous: <a href="Output-Statement.html#Output-Statement" accesskey="p" rel="prev">Output Statement</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="Predicates-1"></a>
  68. <h3 class="section">17.7 Predicates</h3>
  69. <a name="index-predicates"></a>
  70. <a name="index-operand-predicates"></a>
  71. <a name="index-operator-predicates"></a>
  72. <p>A predicate determines whether a <code>match_operand</code> or
  73. <code>match_operator</code> expression matches, and therefore whether the
  74. surrounding instruction pattern will be used for that combination of
  75. operands. GCC has a number of machine-independent predicates, and you
  76. can define machine-specific predicates as needed. By convention,
  77. predicates used with <code>match_operand</code> have names that end in
  78. &lsquo;<samp>_operand</samp>&rsquo;, and those used with <code>match_operator</code> have names
  79. that end in &lsquo;<samp>_operator</samp>&rsquo;.
  80. </p>
  81. <p>All predicates are boolean functions (in the mathematical sense) of
  82. two arguments: the RTL expression that is being considered at that
  83. position in the instruction pattern, and the machine mode that the
  84. <code>match_operand</code> or <code>match_operator</code> specifies. In this
  85. section, the first argument is called <var>op</var> and the second argument
  86. <var>mode</var>. Predicates can be called from C as ordinary two-argument
  87. functions; this can be useful in output templates or other
  88. machine-specific code.
  89. </p>
  90. <p>Operand predicates can allow operands that are not actually acceptable
  91. to the hardware, as long as the constraints give reload the ability to
  92. fix them up (see <a href="Constraints.html#Constraints">Constraints</a>). However, GCC will usually generate
  93. better code if the predicates specify the requirements of the machine
  94. instructions as closely as possible. Reload cannot fix up operands
  95. that must be constants (&ldquo;immediate operands&rdquo;); you must use a
  96. predicate that allows only constants, or else enforce the requirement
  97. in the extra condition.
  98. </p>
  99. <a name="index-predicates-and-machine-modes"></a>
  100. <a name="index-normal-predicates"></a>
  101. <a name="index-special-predicates"></a>
  102. <p>Most predicates handle their <var>mode</var> argument in a uniform manner.
  103. If <var>mode</var> is <code>VOIDmode</code> (unspecified), then <var>op</var> can have
  104. any mode. If <var>mode</var> is anything else, then <var>op</var> must have the
  105. same mode, unless <var>op</var> is a <code>CONST_INT</code> or integer
  106. <code>CONST_DOUBLE</code>. These RTL expressions always have
  107. <code>VOIDmode</code>, so it would be counterproductive to check that their
  108. mode matches. Instead, predicates that accept <code>CONST_INT</code> and/or
  109. integer <code>CONST_DOUBLE</code> check that the value stored in the
  110. constant will fit in the requested mode.
  111. </p>
  112. <p>Predicates with this behavior are called <em>normal</em>.
  113. <code>genrecog</code> can optimize the instruction recognizer based on
  114. knowledge of how normal predicates treat modes. It can also diagnose
  115. certain kinds of common errors in the use of normal predicates; for
  116. instance, it is almost always an error to use a normal predicate
  117. without specifying a mode.
  118. </p>
  119. <p>Predicates that do something different with their <var>mode</var> argument
  120. are called <em>special</em>. The generic predicates
  121. <code>address_operand</code> and <code>pmode_register_operand</code> are special
  122. predicates. <code>genrecog</code> does not do any optimizations or
  123. diagnosis when special predicates are used.
  124. </p>
  125. <table class="menu" border="0" cellspacing="0">
  126. <tr><td align="left" valign="top">&bull; <a href="Machine_002dIndependent-Predicates.html#Machine_002dIndependent-Predicates" accesskey="1">Machine-Independent Predicates</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Predicates available to all back ends.
  127. </td></tr>
  128. <tr><td align="left" valign="top">&bull; <a href="Defining-Predicates.html#Defining-Predicates" accesskey="2">Defining Predicates</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to write machine-specific predicate
  129. functions.
  130. </td></tr>
  131. </table>
  132. <hr>
  133. <div class="header">
  134. <p>
  135. Next: <a href="Constraints.html#Constraints" accesskey="n" rel="next">Constraints</a>, Previous: <a href="Output-Statement.html#Output-Statement" accesskey="p" rel="prev">Output Statement</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>
  136. </div>
  137. </body>
  138. </html>