Instruction-Output.html 18 KB

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