<html lang="en"> <head> <title>Patterns - GNU Compiler Collection (GCC) Internals</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Compiler Collection (GCC) Internals"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Machine-Desc.html#Machine-Desc" title="Machine Desc"> <link rel="prev" href="Overview.html#Overview" title="Overview"> <link rel="next" href="Example.html#Example" title="Example"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- 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.--> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Patterns"></a> <p> Next: <a rel="next" accesskey="n" href="Example.html#Example">Example</a>, Previous: <a rel="previous" accesskey="p" href="Overview.html#Overview">Overview</a>, Up: <a rel="up" accesskey="u" href="Machine-Desc.html#Machine-Desc">Machine Desc</a> <hr> </div> <h3 class="section">16.2 Everything about Instruction Patterns</h3> <p><a name="index-patterns-3242"></a><a name="index-instruction-patterns-3243"></a> <a name="index-define_005finsn-3244"></a>A <code>define_insn</code> expression is used to define instruction patterns to which insns may be matched. A <code>define_insn</code> expression contains an incomplete RTL expression, with pieces to be filled in later, operand constraints that restrict how the pieces can be filled in, and an output template or C code to generate the assembler output. <p>A <code>define_insn</code> is an RTL expression containing four or five operands: <ol type=1 start=1> <li>An optional name. The presence of a name indicate that this instruction pattern can perform a certain standard job for the RTL-generation pass of the compiler. This pass knows certain names and will use the instruction patterns with those names, if the names are defined in the machine description. <p>The absence of a name is indicated by writing an empty string where the name should go. Nameless instruction patterns are never used for generating RTL code, but they may permit several simpler insns to be combined later on. <p>Names that are not thus known and used in RTL-generation have no effect; they are equivalent to no name at all. <p>For the purpose of debugging the compiler, you may also specify a name beginning with the ‘<samp><span class="samp">*</span></samp>’ character. Such a name is used only for identifying the instruction in RTL dumps; it is equivalent to having a nameless pattern for all other purposes. Names beginning with the ‘<samp><span class="samp">*</span></samp>’ character are not required to be unique. <li>The <dfn>RTL template</dfn>: This is a vector of incomplete RTL expressions which describe the semantics of the instruction (see <a href="RTL-Template.html#RTL-Template">RTL Template</a>). It is incomplete because it may contain <code>match_operand</code>, <code>match_operator</code>, and <code>match_dup</code> expressions that stand for operands of the instruction. <p>If the vector has multiple elements, the RTL template is treated as a <code>parallel</code> expression. <li><a name="index-pattern-conditions-3245"></a><a name="index-conditions_002c-in-patterns-3246"></a>The condition: This is a string which contains a C expression. When the compiler attempts to match RTL against a pattern, the condition is evaluated. If the condition evaluates to <code>true</code>, the match is permitted. The condition may be an empty string, which is treated as always <code>true</code>. <p><a name="index-named-patterns-and-conditions-3247"></a>For a named pattern, the condition may not depend on the data in the insn being matched, but only the target-machine-type flags. The compiler needs to test these conditions during initialization in order to learn exactly which named instructions are available in a particular run. <p><a name="index-operands-3248"></a>For nameless patterns, the condition is applied only when matching an individual insn, and only after the insn has matched the pattern's recognition template. The insn's operands may be found in the vector <code>operands</code>. <p>For an insn where the condition has once matched, it cannot later be used to control register allocation by excluding certain register or value combinations. <li>The <dfn>output template</dfn> or <dfn>output statement</dfn>: This is either a string, or a fragment of C code which returns a string. <p>When simple substitution isn't general enough, you can specify a piece of C code to compute the output. See <a href="Output-Statement.html#Output-Statement">Output Statement</a>. <li>The <dfn>insn attributes</dfn>: This is an optional vector containing the values of attributes for insns matching this pattern (see <a href="Insn-Attributes.html#Insn-Attributes">Insn Attributes</a>). </ol> </body></html>