summaryrefslogtreecommitdiff
path: root/share/doc/gccint/Output-Template.html
diff options
context:
space:
mode:
Diffstat (limited to 'share/doc/gccint/Output-Template.html')
-rw-r--r--share/doc/gccint/Output-Template.html179
1 files changed, 179 insertions, 0 deletions
diff --git a/share/doc/gccint/Output-Template.html b/share/doc/gccint/Output-Template.html
new file mode 100644
index 0000000..8bc1030
--- /dev/null
+++ b/share/doc/gccint/Output-Template.html
@@ -0,0 +1,179 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- Copyright (C) 1988-2023 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.1, http://www.gnu.org/software/texinfo/ -->
+<head>
+<title>GNU Compiler Collection (GCC) Internals: Output Template</title>
+
+<meta name="description" content="GNU Compiler Collection (GCC) Internals: Output Template">
+<meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Output Template">
+<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="previous" title="RTL Template">
+<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="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="previous">RTL Template</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>
+</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 &lsquo;<samp>%</samp>&rsquo; 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 &lsquo;<samp>%</samp>&rsquo; followed by a digit <var>n</var> says to output
+operand <var>n</var> at that point in the string.
+</p>
+<p>&lsquo;<samp>%</samp>&rsquo; 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>&lsquo;<samp>%c<var>digit</var></samp>&rsquo; can be used to substitute an operand that is a
+constant value without the syntax that normally indicates an immediate
+operand.
+</p>
+<p>&lsquo;<samp>%n<var>digit</var></samp>&rsquo; is like &lsquo;<samp>%c<var>digit</var></samp>&rsquo; except that the value of
+the constant is negated before printing.
+</p>
+<p>&lsquo;<samp>%a<var>digit</var></samp>&rsquo; 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 &ldquo;load address&rdquo; 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>&lsquo;<samp>%l<var>digit</var></samp>&rsquo; is used to substitute a <code>label_ref</code> into a jump
+instruction.
+</p>
+<p>&lsquo;<samp>%=</samp>&rsquo; 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>&lsquo;<samp>%</samp>&rsquo; followed by a punctuation character specifies a substitution that
+does not use an operand. Only one case is standard: &lsquo;<samp>%%</samp>&rsquo; outputs a
+&lsquo;<samp>%</samp>&rsquo; 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 &lsquo;<samp>\;</samp>&rsquo; 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 &lsquo;<samp>%</samp>&rsquo; 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 &lsquo;<samp>movel</samp>&rsquo; in MIT syntax is &lsquo;<samp>move.l</samp>&rsquo; in Motorola
+syntax. The same file of patterns is used for both kinds of output syntax,
+but the character sequence &lsquo;<samp>%.</samp>&rsquo; 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 &lsquo;<samp>{option0|option1|option2}</samp>&rsquo; 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="previous">RTL Template</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>
+</div>
+
+
+
+</body>
+</html>