選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

179 行
9.0KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Output Template (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Output Template (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Output Template (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Machine-Desc.html#Machine-Desc" rel="up" title="Machine Desc">
  30. <link href="Output-Statement.html#Output-Statement" rel="next" title="Output Statement">
  31. <link href="RTL-Template.html#RTL-Template" rel="prev" title="RTL Template">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Output-Template"></a>
  62. <div class="header">
  63. <p>
  64. 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> &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>
  65. </div>
  66. <hr>
  67. <a name="Output-Templates-and-Operand-Substitution"></a>
  68. <h3 class="section">17.5 Output Templates and Operand Substitution</h3>
  69. <a name="index-output-templates"></a>
  70. <a name="index-operand-substitution"></a>
  71. <a name="index-_0025-in-template"></a>
  72. <a name="index-percent-sign"></a>
  73. <p>The <em>output template</em> is a string which specifies how to output the
  74. assembler code for an instruction pattern. Most of the template is a
  75. fixed string which is output literally. The character &lsquo;<samp>%</samp>&rsquo; is used
  76. to specify where to substitute an operand; it can also be used to
  77. identify places where different variants of the assembler require
  78. different syntax.
  79. </p>
  80. <p>In the simplest case, a &lsquo;<samp>%</samp>&rsquo; followed by a digit <var>n</var> says to output
  81. operand <var>n</var> at that point in the string.
  82. </p>
  83. <p>&lsquo;<samp>%</samp>&rsquo; followed by a letter and a digit says to output an operand in an
  84. alternate fashion. Four letters have standard, built-in meanings described
  85. below. The machine description macro <code>PRINT_OPERAND</code> can define
  86. additional letters with nonstandard meanings.
  87. </p>
  88. <p>&lsquo;<samp>%c<var>digit</var></samp>&rsquo; can be used to substitute an operand that is a
  89. constant value without the syntax that normally indicates an immediate
  90. operand.
  91. </p>
  92. <p>&lsquo;<samp>%n<var>digit</var></samp>&rsquo; is like &lsquo;<samp>%c<var>digit</var></samp>&rsquo; except that the value of
  93. the constant is negated before printing.
  94. </p>
  95. <p>&lsquo;<samp>%a<var>digit</var></samp>&rsquo; can be used to substitute an operand as if it were a
  96. memory reference, with the actual operand treated as the address. This may
  97. be useful when outputting a &ldquo;load address&rdquo; instruction, because often the
  98. assembler syntax for such an instruction requires you to write the operand
  99. as if it were a memory reference.
  100. </p>
  101. <p>&lsquo;<samp>%l<var>digit</var></samp>&rsquo; is used to substitute a <code>label_ref</code> into a jump
  102. instruction.
  103. </p>
  104. <p>&lsquo;<samp>%=</samp>&rsquo; outputs a number which is unique to each instruction in the
  105. entire compilation. This is useful for making local labels to be
  106. referred to more than once in a single template that generates multiple
  107. assembler instructions.
  108. </p>
  109. <p>&lsquo;<samp>%</samp>&rsquo; followed by a punctuation character specifies a substitution that
  110. does not use an operand. Only one case is standard: &lsquo;<samp>%%</samp>&rsquo; outputs a
  111. &lsquo;<samp>%</samp>&rsquo; into the assembler code. Other nonstandard cases can be
  112. defined in the <code>PRINT_OPERAND</code> macro. You must also define
  113. which punctuation characters are valid with the
  114. <code>PRINT_OPERAND_PUNCT_VALID_P</code> macro.
  115. </p>
  116. <a name="index-_005c"></a>
  117. <a name="index-backslash"></a>
  118. <p>The template may generate multiple assembler instructions. Write the text
  119. for the instructions, with &lsquo;<samp>\;</samp>&rsquo; between them.
  120. </p>
  121. <a name="index-matching-operands"></a>
  122. <p>When the RTL contains two operands which are required by constraint to match
  123. each other, the output template must refer only to the lower-numbered operand.
  124. Matching operands are not always identical, and the rest of the compiler
  125. arranges to put the proper RTL expression for printing into the lower-numbered
  126. operand.
  127. </p>
  128. <p>One use of nonstandard letters or punctuation following &lsquo;<samp>%</samp>&rsquo; is to
  129. distinguish between different assembler languages for the same machine; for
  130. example, Motorola syntax versus MIT syntax for the 68000. Motorola syntax
  131. requires periods in most opcode names, while MIT syntax does not. For
  132. example, the opcode &lsquo;<samp>movel</samp>&rsquo; in MIT syntax is &lsquo;<samp>move.l</samp>&rsquo; in Motorola
  133. syntax. The same file of patterns is used for both kinds of output syntax,
  134. but the character sequence &lsquo;<samp>%.</samp>&rsquo; is used in each place where Motorola
  135. syntax wants a period. The <code>PRINT_OPERAND</code> macro for Motorola syntax
  136. defines the sequence to output a period; the macro for MIT syntax defines
  137. it to do nothing.
  138. </p>
  139. <a name="index-_0023-in-template"></a>
  140. <p>As a special case, a template consisting of the single character <code>#</code>
  141. instructs the compiler to first split the insn, and then output the
  142. resulting instructions separately. This helps eliminate redundancy in the
  143. output templates. If you have a <code>define_insn</code> that needs to emit
  144. multiple assembler instructions, and there is a matching <code>define_split</code>
  145. already defined, then you can simply use <code>#</code> as the output template
  146. instead of writing an output template that emits the multiple assembler
  147. instructions.
  148. </p>
  149. <p>Note that <code>#</code> only has an effect while generating assembly code;
  150. it does not affect whether a split occurs earlier. An associated
  151. <code>define_split</code> must exist and it must be suitable for use after
  152. register allocation.
  153. </p>
  154. <p>If the macro <code>ASSEMBLER_DIALECT</code> is defined, you can use construct
  155. of the form &lsquo;<samp>{option0|option1|option2}</samp>&rsquo; in the templates. These
  156. describe multiple variants of assembler language syntax.
  157. See <a href="Instruction-Output.html#Instruction-Output">Instruction Output</a>.
  158. </p>
  159. <hr>
  160. <div class="header">
  161. <p>
  162. 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> &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>
  163. </div>
  164. </body>
  165. </html>