| 
							- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 - <html>
 - <!-- Copyright (C) 1988-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
 - <head>
 - <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 - <title>Parameterized Names (GNU Compiler Collection (GCC) Internals)</title>
 - 
 - <meta name="description" content="Parameterized Names (GNU Compiler Collection (GCC) Internals)">
 - <meta name="keywords" content="Parameterized Names (GNU Compiler Collection (GCC) Internals)">
 - <meta name="resource-type" content="document">
 - <meta name="distribution" content="global">
 - <meta name="Generator" content="makeinfo">
 - <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="Iterators.html#Iterators" rel="up" title="Iterators">
 - <link href="Target-Macros.html#Target-Macros" rel="next" title="Target Macros">
 - <link href="Subst-Iterators.html#Subst-Iterators" rel="prev" title="Subst Iterators">
 - <style type="text/css">
 - <!--
 - a.summary-letter {text-decoration: none}
 - blockquote.indentedblock {margin-right: 0em}
 - blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
 - blockquote.smallquotation {font-size: smaller}
 - div.display {margin-left: 3.2em}
 - div.example {margin-left: 3.2em}
 - div.lisp {margin-left: 3.2em}
 - div.smalldisplay {margin-left: 3.2em}
 - div.smallexample {margin-left: 3.2em}
 - 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.nolinebreak {white-space: nowrap}
 - span.roman {font-family: initial; font-weight: normal}
 - span.sansserif {font-family: sans-serif; font-weight: normal}
 - ul.no-bullet {list-style: none}
 - -->
 - </style>
 - 
 - 
 - </head>
 - 
 - <body lang="en">
 - <a name="Parameterized-Names"></a>
 - <div class="header">
 - <p>
 - Previous: <a href="Subst-Iterators.html#Subst-Iterators" accesskey="p" rel="prev">Subst Iterators</a>, Up: <a href="Iterators.html#Iterators" accesskey="u" rel="up">Iterators</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="Parameterized-Names-1"></a>
 - <h4 class="subsection">17.23.5 Parameterized Names</h4>
 - <a name="index-_0040-in-instruction-pattern-names"></a>
 - <p>Ports sometimes need to apply iterators using C++ code, in order to
 - get the code or RTL pattern for a specific instruction.  For example,
 - suppose we have the ‘<samp>neon_vq<absneg><mode></samp>’ pattern given above:
 - </p>
 - <div class="smallexample">
 - <pre class="smallexample">(define_int_iterator QABSNEG [UNSPEC_VQABS UNSPEC_VQNEG])
 - 
 - (define_int_attr absneg [(UNSPEC_VQABS "abs") (UNSPEC_VQNEG "neg")])
 - 
 - (define_insn "neon_vq<absneg><mode>"
 -   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
 - 	(unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
 - 		       (match_operand:SI 2 "immediate_operand" "i")]
 - 		      QABSNEG))]
 -   …
 - )
 - </pre></div>
 - 
 - <p>A port might need to generate this pattern for a variable
 - ‘<samp>QABSNEG</samp>’ value and a variable ‘<samp>VDQIW</samp>’ mode.  There are two
 - ways of doing this.  The first is to build the rtx for the pattern
 - directly from C++ code; this is a valid technique and avoids any risk
 - of combinatorial explosion.  The second is to prefix the instruction
 - name with the special character ‘<samp>@</samp>’, which tells GCC to generate
 - the four additional functions below.  In each case, <var>name</var> is the
 - name of the instruction without the leading ‘<samp>@</samp>’ character,
 - without the ‘<samp><…></samp>’ placeholders, and with any underscore
 - before a ‘<samp><…></samp>’ placeholder removed if keeping it would
 - lead to a double or trailing underscore.
 - </p>
 - <dl compact="compact">
 - <dt>‘<samp>insn_code maybe_code_for_<var>name</var> (<var>i1</var>, <var>i2</var>, …)</samp>’</dt>
 - <dd><p>See whether replacing the first ‘<samp><…></samp>’ placeholder with
 - iterator value <var>i1</var>, the second with iterator value <var>i2</var>, and
 - so on, gives a valid instruction.  Return its code if so, otherwise
 - return <code>CODE_FOR_nothing</code>.
 - </p>
 - </dd>
 - <dt>‘<samp>insn_code code_for_<var>name</var> (<var>i1</var>, <var>i2</var>, …)</samp>’</dt>
 - <dd><p>Same, but abort the compiler if the requested instruction does not exist.
 - </p>
 - </dd>
 - <dt>‘<samp>rtx maybe_gen_<var>name</var> (<var>i1</var>, <var>i2</var>, …, <var>op0</var>, <var>op1</var>, …)</samp>’</dt>
 - <dd><p>Check for a valid instruction in the same way as
 - <code>maybe_code_for_<var>name</var></code>.  If the instruction exists,
 - generate an instance of it using the operand values given by <var>op0</var>,
 - <var>op1</var>, and so on, otherwise return null.
 - </p>
 - </dd>
 - <dt>‘<samp>rtx gen_<var>name</var> (<var>i1</var>, <var>i2</var>, …, <var>op0</var>, <var>op1</var>, …)</samp>’</dt>
 - <dd><p>Same, but abort the compiler if the requested instruction does not exist,
 - or if the instruction generator invoked the <code>FAIL</code> macro.
 - </p></dd>
 - </dl>
 - 
 - <p>For example, changing the pattern above to:
 - </p>
 - <div class="smallexample">
 - <pre class="smallexample">(define_insn "@neon_vq<absneg><mode>"
 -   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
 - 	(unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
 - 		       (match_operand:SI 2 "immediate_operand" "i")]
 - 		      QABSNEG))]
 -   …
 - )
 - </pre></div>
 - 
 - <p>would define the same patterns as before, but in addition would generate
 - the four functions below:
 - </p>
 - <div class="smallexample">
 - <pre class="smallexample">insn_code maybe_code_for_neon_vq (int, machine_mode);
 - insn_code code_for_neon_vq (int, machine_mode);
 - rtx maybe_gen_neon_vq (int, machine_mode, rtx, rtx, rtx);
 - rtx gen_neon_vq (int, machine_mode, rtx, rtx, rtx);
 - </pre></div>
 - 
 - <p>Calling ‘<samp>code_for_neon_vq (UNSPEC_VQABS, V8QImode)</samp>’
 - would then give <code>CODE_FOR_neon_vqabsv8qi</code>.
 - </p>
 - <p>It is possible to have multiple ‘<samp>@</samp>’ patterns with the same
 - name and same types of iterator.  For example:
 - </p>
 - <div class="smallexample">
 - <pre class="smallexample">(define_insn "@some_arithmetic_op<mode>"
 -   [(set (match_operand:INTEGER_MODES 0 "register_operand") …)]
 -   …
 - )
 - 
 - (define_insn "@some_arithmetic_op<mode>"
 -   [(set (match_operand:FLOAT_MODES 0 "register_operand") …)]
 -   …
 - )
 - </pre></div>
 - 
 - <p>would produce a single set of functions that handles both
 - <code>INTEGER_MODES</code> and <code>FLOAT_MODES</code>.
 - </p>
 - <p>It is also possible for these ‘<samp>@</samp>’ patterns to have different
 - numbers of operands from each other.  For example, patterns with
 - a binary rtl code might take three operands (one output and two inputs)
 - while patterns with a ternary rtl code might take four operands (one
 - output and three inputs).  This combination would produce separate
 - ‘<samp>maybe_gen_<var>name</var></samp>’ and ‘<samp>gen_<var>name</var></samp>’ functions for
 - each operand count, but it would still produce a single
 - ‘<samp>maybe_code_for_<var>name</var></samp>’ and a single ‘<samp>code_for_<var>name</var></samp>’.
 - </p>
 - 
 - <hr>
 - <div class="header">
 - <p>
 - Previous: <a href="Subst-Iterators.html#Subst-Iterators" accesskey="p" rel="prev">Subst Iterators</a>, Up: <a href="Iterators.html#Iterators" accesskey="u" rel="up">Iterators</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>
 
 
  |