You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
18KB

  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>Instruction Output (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Instruction Output (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Instruction Output (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="Assembler-Format.html#Assembler-Format" rel="up" title="Assembler Format">
  30. <link href="Dispatch-Tables.html#Dispatch-Tables" rel="next" title="Dispatch Tables">
  31. <link href="Macros-for-Initialization.html#Macros-for-Initialization" rel="prev" title="Macros for Initialization">
  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="Instruction-Output"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Dispatch-Tables.html#Dispatch-Tables" accesskey="n" rel="next">Dispatch Tables</a>, Previous: <a href="Macros-for-Initialization.html#Macros-for-Initialization" accesskey="p" rel="prev">Macros for Initialization</a>, Up: <a href="Assembler-Format.html#Assembler-Format" accesskey="u" rel="up">Assembler Format</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-of-Assembler-Instructions"></a>
  68. <h4 class="subsection">18.20.7 Output of Assembler Instructions</h4>
  69. <p>This describes assembler instruction output.
  70. </p>
  71. <dl>
  72. <dt><a name="index-REGISTER_005fNAMES"></a>Macro: <strong>REGISTER_NAMES</strong></dt>
  73. <dd><p>A C initializer containing the assembler&rsquo;s names for the machine
  74. registers, each one as a C string constant. This is what translates
  75. register numbers in the compiler into assembler language.
  76. </p></dd></dl>
  77. <dl>
  78. <dt><a name="index-ADDITIONAL_005fREGISTER_005fNAMES"></a>Macro: <strong>ADDITIONAL_REGISTER_NAMES</strong></dt>
  79. <dd><p>If defined, a C initializer for an array of structures containing a name
  80. and a register number. This macro defines additional names for hard
  81. registers, thus allowing the <code>asm</code> option in declarations to refer
  82. to registers using alternate names.
  83. </p></dd></dl>
  84. <dl>
  85. <dt><a name="index-OVERLAPPING_005fREGISTER_005fNAMES"></a>Macro: <strong>OVERLAPPING_REGISTER_NAMES</strong></dt>
  86. <dd><p>If defined, a C initializer for an array of structures containing a
  87. name, a register number and a count of the number of consecutive
  88. machine registers the name overlaps. This macro defines additional
  89. names for hard registers, thus allowing the <code>asm</code> option in
  90. declarations to refer to registers using alternate names. Unlike
  91. <code>ADDITIONAL_REGISTER_NAMES</code>, this macro should be used when the
  92. register name implies multiple underlying registers.
  93. </p>
  94. <p>This macro should be used when it is important that a clobber in an
  95. <code>asm</code> statement clobbers all the underlying values implied by the
  96. register name. For example, on ARM, clobbering the double-precision
  97. VFP register &ldquo;d0&rdquo; implies clobbering both single-precision registers
  98. &ldquo;s0&rdquo; and &ldquo;s1&rdquo;.
  99. </p></dd></dl>
  100. <dl>
  101. <dt><a name="index-ASM_005fOUTPUT_005fOPCODE"></a>Macro: <strong>ASM_OUTPUT_OPCODE</strong> <em>(<var>stream</var>, <var>ptr</var>)</em></dt>
  102. <dd><p>Define this macro if you are using an unusual assembler that
  103. requires different names for the machine instructions.
  104. </p>
  105. <p>The definition is a C statement or statements which output an
  106. assembler instruction opcode to the stdio stream <var>stream</var>. The
  107. macro-operand <var>ptr</var> is a variable of type <code>char *</code> which
  108. points to the opcode name in its &ldquo;internal&rdquo; form&mdash;the form that is
  109. written in the machine description. The definition should output the
  110. opcode name to <var>stream</var>, performing any translation you desire, and
  111. increment the variable <var>ptr</var> to point at the end of the opcode
  112. so that it will not be output twice.
  113. </p>
  114. <p>In fact, your macro definition may process less than the entire opcode
  115. name, or more than the opcode name; but if you want to process text
  116. that includes &lsquo;<samp>%</samp>&rsquo;-sequences to substitute operands, you must take
  117. care of the substitution yourself. Just be sure to increment
  118. <var>ptr</var> over whatever text should not be output normally.
  119. </p>
  120. <a name="index-recog_005fdata_002eoperand"></a>
  121. <p>If you need to look at the operand values, they can be found as the
  122. elements of <code>recog_data.operand</code>.
  123. </p>
  124. <p>If the macro definition does nothing, the instruction is output
  125. in the usual way.
  126. </p></dd></dl>
  127. <dl>
  128. <dt><a name="index-FINAL_005fPRESCAN_005fINSN"></a>Macro: <strong>FINAL_PRESCAN_INSN</strong> <em>(<var>insn</var>, <var>opvec</var>, <var>noperands</var>)</em></dt>
  129. <dd><p>If defined, a C statement to be executed just prior to the output of
  130. assembler code for <var>insn</var>, to modify the extracted operands so
  131. they will be output differently.
  132. </p>
  133. <p>Here the argument <var>opvec</var> is the vector containing the operands
  134. extracted from <var>insn</var>, and <var>noperands</var> is the number of
  135. elements of the vector which contain meaningful data for this insn.
  136. The contents of this vector are what will be used to convert the insn
  137. template into assembler code, so you can change the assembler output
  138. by changing the contents of the vector.
  139. </p>
  140. <p>This macro is useful when various assembler syntaxes share a single
  141. file of instruction patterns; by defining this macro differently, you
  142. can cause a large class of instructions to be output differently (such
  143. as with rearranged operands). Naturally, variations in assembler
  144. syntax affecting individual insn patterns ought to be handled by
  145. writing conditional output routines in those patterns.
  146. </p>
  147. <p>If this macro is not defined, it is equivalent to a null statement.
  148. </p></dd></dl>
  149. <dl>
  150. <dt><a name="index-TARGET_005fASM_005fFINAL_005fPOSTSCAN_005fINSN"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_FINAL_POSTSCAN_INSN</strong> <em>(FILE *<var>file</var>, rtx_insn *<var>insn</var>, rtx *<var>opvec</var>, int <var>noperands</var>)</em></dt>
  151. <dd><p>If defined, this target hook is a function which is executed just after the
  152. output of assembler code for <var>insn</var>, to change the mode of the assembler
  153. if necessary.
  154. </p>
  155. <p>Here the argument <var>opvec</var> is the vector containing the operands
  156. extracted from <var>insn</var>, and <var>noperands</var> is the number of
  157. elements of the vector which contain meaningful data for this insn.
  158. The contents of this vector are what was used to convert the insn
  159. template into assembler code, so you can change the assembler mode
  160. by checking the contents of the vector.
  161. </p></dd></dl>
  162. <dl>
  163. <dt><a name="index-PRINT_005fOPERAND"></a>Macro: <strong>PRINT_OPERAND</strong> <em>(<var>stream</var>, <var>x</var>, <var>code</var>)</em></dt>
  164. <dd><p>A C compound statement to output to stdio stream <var>stream</var> the
  165. assembler syntax for an instruction operand <var>x</var>. <var>x</var> is an
  166. RTL expression.
  167. </p>
  168. <p><var>code</var> is a value that can be used to specify one of several ways
  169. of printing the operand. It is used when identical operands must be
  170. printed differently depending on the context. <var>code</var> comes from
  171. the &lsquo;<samp>%</samp>&rsquo; specification that was used to request printing of the
  172. operand. If the specification was just &lsquo;<samp>%<var>digit</var></samp>&rsquo; then
  173. <var>code</var> is 0; if the specification was &lsquo;<samp>%<var>ltr</var>
  174. <var>digit</var></samp>&rsquo; then <var>code</var> is the ASCII code for <var>ltr</var>.
  175. </p>
  176. <a name="index-reg_005fnames-1"></a>
  177. <p>If <var>x</var> is a register, this macro should print the register&rsquo;s name.
  178. The names can be found in an array <code>reg_names</code> whose type is
  179. <code>char *[]</code>. <code>reg_names</code> is initialized from
  180. <code>REGISTER_NAMES</code>.
  181. </p>
  182. <p>When the machine description has a specification &lsquo;<samp>%<var>punct</var></samp>&rsquo;
  183. (a &lsquo;<samp>%</samp>&rsquo; followed by a punctuation character), this macro is called
  184. with a null pointer for <var>x</var> and the punctuation character for
  185. <var>code</var>.
  186. </p></dd></dl>
  187. <dl>
  188. <dt><a name="index-PRINT_005fOPERAND_005fPUNCT_005fVALID_005fP"></a>Macro: <strong>PRINT_OPERAND_PUNCT_VALID_P</strong> <em>(<var>code</var>)</em></dt>
  189. <dd><p>A C expression which evaluates to true if <var>code</var> is a valid
  190. punctuation character for use in the <code>PRINT_OPERAND</code> macro. If
  191. <code>PRINT_OPERAND_PUNCT_VALID_P</code> is not defined, it means that no
  192. punctuation characters (except for the standard one, &lsquo;<samp>%</samp>&rsquo;) are used
  193. in this way.
  194. </p></dd></dl>
  195. <dl>
  196. <dt><a name="index-PRINT_005fOPERAND_005fADDRESS"></a>Macro: <strong>PRINT_OPERAND_ADDRESS</strong> <em>(<var>stream</var>, <var>x</var>)</em></dt>
  197. <dd><p>A C compound statement to output to stdio stream <var>stream</var> the
  198. assembler syntax for an instruction operand that is a memory reference
  199. whose address is <var>x</var>. <var>x</var> is an RTL expression.
  200. </p>
  201. <a name="index-TARGET_005fENCODE_005fSECTION_005fINFO-usage"></a>
  202. <p>On some machines, the syntax for a symbolic address depends on the
  203. section that the address refers to. On these machines, define the hook
  204. <code>TARGET_ENCODE_SECTION_INFO</code> to store the information into the
  205. <code>symbol_ref</code>, and then check for it here. See <a href="Assembler-Format.html#Assembler-Format">Assembler Format</a>.
  206. </p></dd></dl>
  207. <a name="index-dbr_005fsequence_005flength"></a>
  208. <dl>
  209. <dt><a name="index-DBR_005fOUTPUT_005fSEQEND"></a>Macro: <strong>DBR_OUTPUT_SEQEND</strong> <em>(<var>file</var>)</em></dt>
  210. <dd><p>A C statement, to be executed after all slot-filler instructions have
  211. been output. If necessary, call <code>dbr_sequence_length</code> to
  212. determine the number of slots filled in a sequence (zero if not
  213. currently outputting a sequence), to decide how many no-ops to output,
  214. or whatever.
  215. </p>
  216. <p>Don&rsquo;t define this macro if it has nothing to do, but it is helpful in
  217. reading assembly output if the extent of the delay sequence is made
  218. explicit (e.g. with white space).
  219. </p></dd></dl>
  220. <a name="index-final_005fsequence"></a>
  221. <p>Note that output routines for instructions with delay slots must be
  222. prepared to deal with not being output as part of a sequence
  223. (i.e. when the scheduling pass is not run, or when no slot fillers could be
  224. found.) The variable <code>final_sequence</code> is null when not
  225. processing a sequence, otherwise it contains the <code>sequence</code> rtx
  226. being output.
  227. </p>
  228. <a name="index-asm_005ffprintf"></a>
  229. <dl>
  230. <dt><a name="index-REGISTER_005fPREFIX"></a>Macro: <strong>REGISTER_PREFIX</strong></dt>
  231. <dt><a name="index-LOCAL_005fLABEL_005fPREFIX"></a>Macro: <strong>LOCAL_LABEL_PREFIX</strong></dt>
  232. <dt><a name="index-USER_005fLABEL_005fPREFIX"></a>Macro: <strong>USER_LABEL_PREFIX</strong></dt>
  233. <dt><a name="index-IMMEDIATE_005fPREFIX"></a>Macro: <strong>IMMEDIATE_PREFIX</strong></dt>
  234. <dd><p>If defined, C string expressions to be used for the &lsquo;<samp>%R</samp>&rsquo;, &lsquo;<samp>%L</samp>&rsquo;,
  235. &lsquo;<samp>%U</samp>&rsquo;, and &lsquo;<samp>%I</samp>&rsquo; options of <code>asm_fprintf</code> (see
  236. <samp>final.c</samp>). These are useful when a single <samp>md</samp> file must
  237. support multiple assembler formats. In that case, the various <samp>tm.h</samp>
  238. files can define these macros differently.
  239. </p></dd></dl>
  240. <dl>
  241. <dt><a name="index-ASM_005fFPRINTF_005fEXTENSIONS"></a>Macro: <strong>ASM_FPRINTF_EXTENSIONS</strong> <em>(<var>file</var>, <var>argptr</var>, <var>format</var>)</em></dt>
  242. <dd><p>If defined this macro should expand to a series of <code>case</code>
  243. statements which will be parsed inside the <code>switch</code> statement of
  244. the <code>asm_fprintf</code> function. This allows targets to define extra
  245. printf formats which may useful when generating their assembler
  246. statements. Note that uppercase letters are reserved for future
  247. generic extensions to asm_fprintf, and so are not available to target
  248. specific code. The output file is given by the parameter <var>file</var>.
  249. The varargs input pointer is <var>argptr</var> and the rest of the format
  250. string, starting the character after the one that is being switched
  251. upon, is pointed to by <var>format</var>.
  252. </p></dd></dl>
  253. <dl>
  254. <dt><a name="index-ASSEMBLER_005fDIALECT"></a>Macro: <strong>ASSEMBLER_DIALECT</strong></dt>
  255. <dd><p>If your target supports multiple dialects of assembler language (such as
  256. different opcodes), define this macro as a C expression that gives the
  257. numeric index of the assembler language dialect to use, with zero as the
  258. first variant.
  259. </p>
  260. <p>If this macro is defined, you may use constructs of the form
  261. </p><div class="smallexample">
  262. <pre class="smallexample">&lsquo;<samp>{option0|option1|option2&hellip;}</samp>&rsquo;
  263. </pre></div>
  264. <p>in the output templates of patterns (see <a href="Output-Template.html#Output-Template">Output Template</a>) or in the
  265. first argument of <code>asm_fprintf</code>. This construct outputs
  266. &lsquo;<samp>option0</samp>&rsquo;, &lsquo;<samp>option1</samp>&rsquo;, &lsquo;<samp>option2</samp>&rsquo;, etc., if the value of
  267. <code>ASSEMBLER_DIALECT</code> is zero, one, two, etc. Any special characters
  268. within these strings retain their usual meaning. If there are fewer
  269. alternatives within the braces than the value of
  270. <code>ASSEMBLER_DIALECT</code>, the construct outputs nothing. If it&rsquo;s needed
  271. to print curly braces or &lsquo;<samp>|</samp>&rsquo; character in assembler output directly,
  272. &lsquo;<samp>%{</samp>&rsquo;, &lsquo;<samp>%}</samp>&rsquo; and &lsquo;<samp>%|</samp>&rsquo; can be used.
  273. </p>
  274. <p>If you do not define this macro, the characters &lsquo;<samp>{</samp>&rsquo;, &lsquo;<samp>|</samp>&rsquo; and
  275. &lsquo;<samp>}</samp>&rsquo; do not have any special meaning when used in templates or
  276. operands to <code>asm_fprintf</code>.
  277. </p>
  278. <p>Define the macros <code>REGISTER_PREFIX</code>, <code>LOCAL_LABEL_PREFIX</code>,
  279. <code>USER_LABEL_PREFIX</code> and <code>IMMEDIATE_PREFIX</code> if you can express
  280. the variations in assembler language syntax with that mechanism. Define
  281. <code>ASSEMBLER_DIALECT</code> and use the &lsquo;<samp>{option0|option1}</samp>&rsquo; syntax
  282. if the syntax variant are larger and involve such things as different
  283. opcodes or operand order.
  284. </p></dd></dl>
  285. <dl>
  286. <dt><a name="index-ASM_005fOUTPUT_005fREG_005fPUSH"></a>Macro: <strong>ASM_OUTPUT_REG_PUSH</strong> <em>(<var>stream</var>, <var>regno</var>)</em></dt>
  287. <dd><p>A C expression to output to <var>stream</var> some assembler code
  288. which will push hard register number <var>regno</var> onto the stack.
  289. The code need not be optimal, since this macro is used only when
  290. profiling.
  291. </p></dd></dl>
  292. <dl>
  293. <dt><a name="index-ASM_005fOUTPUT_005fREG_005fPOP"></a>Macro: <strong>ASM_OUTPUT_REG_POP</strong> <em>(<var>stream</var>, <var>regno</var>)</em></dt>
  294. <dd><p>A C expression to output to <var>stream</var> some assembler code
  295. which will pop hard register number <var>regno</var> off of the stack.
  296. The code need not be optimal, since this macro is used only when
  297. profiling.
  298. </p></dd></dl>
  299. <hr>
  300. <div class="header">
  301. <p>
  302. Next: <a href="Dispatch-Tables.html#Dispatch-Tables" accesskey="n" rel="next">Dispatch Tables</a>, Previous: <a href="Macros-for-Initialization.html#Macros-for-Initialization" accesskey="p" rel="prev">Macros for Initialization</a>, Up: <a href="Assembler-Format.html#Assembler-Format" accesskey="u" rel="up">Assembler Format</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>
  303. </div>
  304. </body>
  305. </html>