You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
9.0 KiB
HTML
179 lines
9.0 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- Copyright (C) 1988-2018 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.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Output Template (GNU Compiler Collection (GCC) Internals)</title>
|
|
|
|
<meta name="description" content="Output Template (GNU Compiler Collection (GCC) Internals)">
|
|
<meta name="keywords" content="Output Template (GNU Compiler Collection (GCC) Internals)">
|
|
<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="Output-Statement.html#Output-Statement" rel="next" title="Output Statement">
|
|
<link href="RTL-Template.html#RTL-Template" rel="prev" title="RTL Template">
|
|
<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="Output-Template"></a>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Output-Statement.html#Output-Statement" accesskey="n" rel="next">Output Statement</a>, Previous: <a href="RTL-Template.html#RTL-Template" accesskey="p" rel="prev">RTL Template</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="Output-Templates-and-Operand-Substitution"></a>
|
|
<h3 class="section">17.5 Output Templates and Operand Substitution</h3>
|
|
<a name="index-output-templates"></a>
|
|
<a name="index-operand-substitution"></a>
|
|
|
|
<a name="index-_0025-in-template"></a>
|
|
<a name="index-percent-sign"></a>
|
|
<p>The <em>output template</em> is a string which specifies how to output the
|
|
assembler code for an instruction pattern. Most of the template is a
|
|
fixed string which is output literally. The character ‘<samp>%</samp>’ is used
|
|
to specify where to substitute an operand; it can also be used to
|
|
identify places where different variants of the assembler require
|
|
different syntax.
|
|
</p>
|
|
<p>In the simplest case, a ‘<samp>%</samp>’ followed by a digit <var>n</var> says to output
|
|
operand <var>n</var> at that point in the string.
|
|
</p>
|
|
<p>‘<samp>%</samp>’ followed by a letter and a digit says to output an operand in an
|
|
alternate fashion. Four letters have standard, built-in meanings described
|
|
below. The machine description macro <code>PRINT_OPERAND</code> can define
|
|
additional letters with nonstandard meanings.
|
|
</p>
|
|
<p>‘<samp>%c<var>digit</var></samp>’ can be used to substitute an operand that is a
|
|
constant value without the syntax that normally indicates an immediate
|
|
operand.
|
|
</p>
|
|
<p>‘<samp>%n<var>digit</var></samp>’ is like ‘<samp>%c<var>digit</var></samp>’ except that the value of
|
|
the constant is negated before printing.
|
|
</p>
|
|
<p>‘<samp>%a<var>digit</var></samp>’ can be used to substitute an operand as if it were a
|
|
memory reference, with the actual operand treated as the address. This may
|
|
be useful when outputting a “load address” instruction, because often the
|
|
assembler syntax for such an instruction requires you to write the operand
|
|
as if it were a memory reference.
|
|
</p>
|
|
<p>‘<samp>%l<var>digit</var></samp>’ is used to substitute a <code>label_ref</code> into a jump
|
|
instruction.
|
|
</p>
|
|
<p>‘<samp>%=</samp>’ outputs a number which is unique to each instruction in the
|
|
entire compilation. This is useful for making local labels to be
|
|
referred to more than once in a single template that generates multiple
|
|
assembler instructions.
|
|
</p>
|
|
<p>‘<samp>%</samp>’ followed by a punctuation character specifies a substitution that
|
|
does not use an operand. Only one case is standard: ‘<samp>%%</samp>’ outputs a
|
|
‘<samp>%</samp>’ into the assembler code. Other nonstandard cases can be
|
|
defined in the <code>PRINT_OPERAND</code> macro. You must also define
|
|
which punctuation characters are valid with the
|
|
<code>PRINT_OPERAND_PUNCT_VALID_P</code> macro.
|
|
</p>
|
|
<a name="index-_005c"></a>
|
|
<a name="index-backslash"></a>
|
|
<p>The template may generate multiple assembler instructions. Write the text
|
|
for the instructions, with ‘<samp>\;</samp>’ between them.
|
|
</p>
|
|
<a name="index-matching-operands"></a>
|
|
<p>When the RTL contains two operands which are required by constraint to match
|
|
each other, the output template must refer only to the lower-numbered operand.
|
|
Matching operands are not always identical, and the rest of the compiler
|
|
arranges to put the proper RTL expression for printing into the lower-numbered
|
|
operand.
|
|
</p>
|
|
<p>One use of nonstandard letters or punctuation following ‘<samp>%</samp>’ is to
|
|
distinguish between different assembler languages for the same machine; for
|
|
example, Motorola syntax versus MIT syntax for the 68000. Motorola syntax
|
|
requires periods in most opcode names, while MIT syntax does not. For
|
|
example, the opcode ‘<samp>movel</samp>’ in MIT syntax is ‘<samp>move.l</samp>’ in Motorola
|
|
syntax. The same file of patterns is used for both kinds of output syntax,
|
|
but the character sequence ‘<samp>%.</samp>’ is used in each place where Motorola
|
|
syntax wants a period. The <code>PRINT_OPERAND</code> macro for Motorola syntax
|
|
defines the sequence to output a period; the macro for MIT syntax defines
|
|
it to do nothing.
|
|
</p>
|
|
<a name="index-_0023-in-template"></a>
|
|
<p>As a special case, a template consisting of the single character <code>#</code>
|
|
instructs the compiler to first split the insn, and then output the
|
|
resulting instructions separately. This helps eliminate redundancy in the
|
|
output templates. If you have a <code>define_insn</code> that needs to emit
|
|
multiple assembler instructions, and there is a matching <code>define_split</code>
|
|
already defined, then you can simply use <code>#</code> as the output template
|
|
instead of writing an output template that emits the multiple assembler
|
|
instructions.
|
|
</p>
|
|
<p>Note that <code>#</code> only has an effect while generating assembly code;
|
|
it does not affect whether a split occurs earlier. An associated
|
|
<code>define_split</code> must exist and it must be suitable for use after
|
|
register allocation.
|
|
</p>
|
|
<p>If the macro <code>ASSEMBLER_DIALECT</code> is defined, you can use construct
|
|
of the form ‘<samp>{option0|option1|option2}</samp>’ in the templates. These
|
|
describe multiple variants of assembler language syntax.
|
|
See <a href="Instruction-Output.html#Instruction-Output">Instruction Output</a>.
|
|
</p>
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Output-Statement.html#Output-Statement" accesskey="n" rel="next">Output Statement</a>, Previous: <a href="RTL-Template.html#RTL-Template" accesskey="p" rel="prev">RTL Template</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>
|