| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <!-- Copyright (C) 1988-2015 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being "Funding Free Software", the Front-Cover |
| Texts being (a) (see below), and with the Back-Cover Texts being (b) |
| (see below). A copy of the license is included in the section entitled |
| "GNU Free Documentation License". |
| |
| (a) The FSF's Front-Cover Text is: |
| |
| A GNU Manual |
| |
| (b) The FSF's Back-Cover Text is: |
| |
| You have freedom to copy and modify this GNU Manual, like GNU |
| software. Copies published by the Free Software Foundation raise |
| funds for GNU development. --> |
| <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> |
| <head> |
| <title>GNU Compiler Collection (GCC) Internals: Predicates</title> |
| |
| <meta name="description" content="GNU Compiler Collection (GCC) Internals: Predicates"> |
| <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Predicates"> |
| <meta name="resource-type" content="document"> |
| <meta name="distribution" content="global"> |
| <meta name="Generator" content="makeinfo"> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| <link href="index.html#Top" rel="start" title="Top"> |
| <link href="Option-Index.html#Option-Index" rel="index" title="Option Index"> |
| <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> |
| <link href="Machine-Desc.html#Machine-Desc" rel="up" title="Machine Desc"> |
| <link href="Machine_002dIndependent-Predicates.html#Machine_002dIndependent-Predicates" rel="next" title="Machine-Independent Predicates"> |
| <link href="Output-Statement.html#Output-Statement" rel="prev" title="Output Statement"> |
| <style type="text/css"> |
| <!-- |
| a.summary-letter {text-decoration: none} |
| blockquote.smallquotation {font-size: smaller} |
| div.display {margin-left: 3.2em} |
| div.example {margin-left: 3.2em} |
| div.indentedblock {margin-left: 3.2em} |
| div.lisp {margin-left: 3.2em} |
| div.smalldisplay {margin-left: 3.2em} |
| div.smallexample {margin-left: 3.2em} |
| div.smallindentedblock {margin-left: 3.2em; font-size: smaller} |
| div.smalllisp {margin-left: 3.2em} |
| kbd {font-style:oblique} |
| pre.display {font-family: inherit} |
| pre.format {font-family: inherit} |
| pre.menu-comment {font-family: serif} |
| pre.menu-preformatted {font-family: serif} |
| pre.smalldisplay {font-family: inherit; font-size: smaller} |
| pre.smallexample {font-size: smaller} |
| pre.smallformat {font-family: inherit; font-size: smaller} |
| pre.smalllisp {font-size: smaller} |
| span.nocodebreak {white-space:nowrap} |
| span.nolinebreak {white-space:nowrap} |
| span.roman {font-family:serif; font-weight:normal} |
| span.sansserif {font-family:sans-serif; font-weight:normal} |
| ul.no-bullet {list-style: none} |
| --> |
| </style> |
| |
| |
| </head> |
| |
| <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> |
| <a name="Predicates"></a> |
| <div class="header"> |
| <p> |
| 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> [<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> |
| </div> |
| <hr> |
| <a name="Predicates-1"></a> |
| <h3 class="section">16.7 Predicates</h3> |
| <a name="index-predicates"></a> |
| <a name="index-operand-predicates"></a> |
| <a name="index-operator-predicates"></a> |
| |
| <p>A predicate determines whether a <code>match_operand</code> or |
| <code>match_operator</code> expression matches, and therefore whether the |
| surrounding instruction pattern will be used for that combination of |
| operands. GCC has a number of machine-independent predicates, and you |
| can define machine-specific predicates as needed. By convention, |
| predicates used with <code>match_operand</code> have names that end in |
| ‘<samp>_operand</samp>’, and those used with <code>match_operator</code> have names |
| that end in ‘<samp>_operator</samp>’. |
| </p> |
| <p>All predicates are Boolean functions (in the mathematical sense) of |
| two arguments: the RTL expression that is being considered at that |
| position in the instruction pattern, and the machine mode that the |
| <code>match_operand</code> or <code>match_operator</code> specifies. In this |
| section, the first argument is called <var>op</var> and the second argument |
| <var>mode</var>. Predicates can be called from C as ordinary two-argument |
| functions; this can be useful in output templates or other |
| machine-specific code. |
| </p> |
| <p>Operand predicates can allow operands that are not actually acceptable |
| to the hardware, as long as the constraints give reload the ability to |
| fix them up (see <a href="Constraints.html#Constraints">Constraints</a>). However, GCC will usually generate |
| better code if the predicates specify the requirements of the machine |
| instructions as closely as possible. Reload cannot fix up operands |
| that must be constants (“immediate operands”); you must use a |
| predicate that allows only constants, or else enforce the requirement |
| in the extra condition. |
| </p> |
| <a name="index-predicates-and-machine-modes"></a> |
| <a name="index-normal-predicates"></a> |
| <a name="index-special-predicates"></a> |
| <p>Most predicates handle their <var>mode</var> argument in a uniform manner. |
| If <var>mode</var> is <code>VOIDmode</code> (unspecified), then <var>op</var> can have |
| any mode. If <var>mode</var> is anything else, then <var>op</var> must have the |
| same mode, unless <var>op</var> is a <code>CONST_INT</code> or integer |
| <code>CONST_DOUBLE</code>. These RTL expressions always have |
| <code>VOIDmode</code>, so it would be counterproductive to check that their |
| mode matches. Instead, predicates that accept <code>CONST_INT</code> and/or |
| integer <code>CONST_DOUBLE</code> check that the value stored in the |
| constant will fit in the requested mode. |
| </p> |
| <p>Predicates with this behavior are called <em>normal</em>. |
| <code>genrecog</code> can optimize the instruction recognizer based on |
| knowledge of how normal predicates treat modes. It can also diagnose |
| certain kinds of common errors in the use of normal predicates; for |
| instance, it is almost always an error to use a normal predicate |
| without specifying a mode. |
| </p> |
| <p>Predicates that do something different with their <var>mode</var> argument |
| are called <em>special</em>. The generic predicates |
| <code>address_operand</code> and <code>pmode_register_operand</code> are special |
| predicates. <code>genrecog</code> does not do any optimizations or |
| diagnosis when special predicates are used. |
| </p> |
| <table class="menu" border="0" cellspacing="0"> |
| <tr><td align="left" valign="top">• <a href="Machine_002dIndependent-Predicates.html#Machine_002dIndependent-Predicates" accesskey="1">Machine-Independent Predicates</a>:</td><td> </td><td align="left" valign="top">Predicates available to all back ends. |
| </td></tr> |
| <tr><td align="left" valign="top">• <a href="Defining-Predicates.html#Defining-Predicates" accesskey="2">Defining Predicates</a>:</td><td> </td><td align="left" valign="top">How to write machine-specific predicate |
| functions. |
| </td></tr> |
| </table> |
| |
| <hr> |
| <div class="header"> |
| <p> |
| 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> [<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> |
| </div> |
| |
| |
| |
| </body> |
| </html> |