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.
302 lines
17 KiB
HTML
302 lines
17 KiB
HTML
4 years ago
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>Instruction Output - GNU Compiler Collection (GCC) Internals</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html">
|
||
|
<meta name="description" content="GNU Compiler Collection (GCC) Internals">
|
||
|
<meta name="generator" content="makeinfo 4.13">
|
||
|
<link title="Top" rel="start" href="index.html#Top">
|
||
|
<link rel="up" href="Assembler-Format.html#Assembler-Format" title="Assembler Format">
|
||
|
<link rel="prev" href="Macros-for-Initialization.html#Macros-for-Initialization" title="Macros for Initialization">
|
||
|
<link rel="next" href="Dispatch-Tables.html#Dispatch-Tables" title="Dispatch Tables">
|
||
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
||
|
<!--
|
||
|
Copyright (C) 1988-2015 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.-->
|
||
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
||
|
<style type="text/css"><!--
|
||
|
pre.display { font-family:inherit }
|
||
|
pre.format { font-family:inherit }
|
||
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
||
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
||
|
pre.smallexample { font-size:smaller }
|
||
|
pre.smalllisp { font-size:smaller }
|
||
|
span.sc { font-variant:small-caps }
|
||
|
span.roman { font-family:serif; font-weight:normal; }
|
||
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="node">
|
||
|
<a name="Instruction-Output"></a>
|
||
|
<p>
|
||
|
Next: <a rel="next" accesskey="n" href="Dispatch-Tables.html#Dispatch-Tables">Dispatch Tables</a>,
|
||
|
Previous: <a rel="previous" accesskey="p" href="Macros-for-Initialization.html#Macros-for-Initialization">Macros for Initialization</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="Assembler-Format.html#Assembler-Format">Assembler Format</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h4 class="subsection">17.20.7 Output of Assembler Instructions</h4>
|
||
|
|
||
|
<!-- prevent bad page break with this line -->
|
||
|
<p>This describes assembler instruction output.
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>REGISTER_NAMES</b><var><a name="index-REGISTER_005fNAMES-4687"></a></var><br>
|
||
|
<blockquote><p>A C initializer containing the assembler's names for the machine
|
||
|
registers, each one as a C string constant. This is what translates
|
||
|
register numbers in the compiler into assembler language.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>ADDITIONAL_REGISTER_NAMES</b><var><a name="index-ADDITIONAL_005fREGISTER_005fNAMES-4688"></a></var><br>
|
||
|
<blockquote><p>If defined, a C initializer for an array of structures containing a name
|
||
|
and a register number. This macro defines additional names for hard
|
||
|
registers, thus allowing the <code>asm</code> option in declarations to refer
|
||
|
to registers using alternate names.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>OVERLAPPING_REGISTER_NAMES</b><var><a name="index-OVERLAPPING_005fREGISTER_005fNAMES-4689"></a></var><br>
|
||
|
<blockquote><p>If defined, a C initializer for an array of structures containing a
|
||
|
name, a register number and a count of the number of consecutive
|
||
|
machine registers the name overlaps. This macro defines additional
|
||
|
names for hard registers, thus allowing the <code>asm</code> option in
|
||
|
declarations to refer to registers using alternate names. Unlike
|
||
|
<code>ADDITIONAL_REGISTER_NAMES</code>, this macro should be used when the
|
||
|
register name implies multiple underlying registers.
|
||
|
|
||
|
<p>This macro should be used when it is important that a clobber in an
|
||
|
<code>asm</code> statement clobbers all the underlying values implied by the
|
||
|
register name. For example, on ARM, clobbering the double-precision
|
||
|
VFP register “d0” implies clobbering both single-precision registers
|
||
|
“s0” and “s1”.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>ASM_OUTPUT_OPCODE</b> (<var>stream, ptr</var>)<var><a name="index-ASM_005fOUTPUT_005fOPCODE-4690"></a></var><br>
|
||
|
<blockquote><p>Define this macro if you are using an unusual assembler that
|
||
|
requires different names for the machine instructions.
|
||
|
|
||
|
<p>The definition is a C statement or statements which output an
|
||
|
assembler instruction opcode to the stdio stream <var>stream</var>. The
|
||
|
macro-operand <var>ptr</var> is a variable of type <code>char *</code> which
|
||
|
points to the opcode name in its “internal” form—the form that is
|
||
|
written in the machine description. The definition should output the
|
||
|
opcode name to <var>stream</var>, performing any translation you desire, and
|
||
|
increment the variable <var>ptr</var> to point at the end of the opcode
|
||
|
so that it will not be output twice.
|
||
|
|
||
|
<p>In fact, your macro definition may process less than the entire opcode
|
||
|
name, or more than the opcode name; but if you want to process text
|
||
|
that includes ‘<samp><span class="samp">%</span></samp>’-sequences to substitute operands, you must take
|
||
|
care of the substitution yourself. Just be sure to increment
|
||
|
<var>ptr</var> over whatever text should not be output normally.
|
||
|
|
||
|
<p><a name="index-recog_005fdata_002eoperand-4691"></a>If you need to look at the operand values, they can be found as the
|
||
|
elements of <code>recog_data.operand</code>.
|
||
|
|
||
|
<p>If the macro definition does nothing, the instruction is output
|
||
|
in the usual way.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>FINAL_PRESCAN_INSN</b> (<var>insn, opvec, noperands</var>)<var><a name="index-FINAL_005fPRESCAN_005fINSN-4692"></a></var><br>
|
||
|
<blockquote><p>If defined, a C statement to be executed just prior to the output of
|
||
|
assembler code for <var>insn</var>, to modify the extracted operands so
|
||
|
they will be output differently.
|
||
|
|
||
|
<p>Here the argument <var>opvec</var> is the vector containing the operands
|
||
|
extracted from <var>insn</var>, and <var>noperands</var> is the number of
|
||
|
elements of the vector which contain meaningful data for this insn.
|
||
|
The contents of this vector are what will be used to convert the insn
|
||
|
template into assembler code, so you can change the assembler output
|
||
|
by changing the contents of the vector.
|
||
|
|
||
|
<p>This macro is useful when various assembler syntaxes share a single
|
||
|
file of instruction patterns; by defining this macro differently, you
|
||
|
can cause a large class of instructions to be output differently (such
|
||
|
as with rearranged operands). Naturally, variations in assembler
|
||
|
syntax affecting individual insn patterns ought to be handled by
|
||
|
writing conditional output routines in those patterns.
|
||
|
|
||
|
<p>If this macro is not defined, it is equivalent to a null statement.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Target Hook: void <b>TARGET_ASM_FINAL_POSTSCAN_INSN</b> (<var>FILE *file, rtx_insn *insn, rtx *opvec, int noperands</var>)<var><a name="index-TARGET_005fASM_005fFINAL_005fPOSTSCAN_005fINSN-4693"></a></var><br>
|
||
|
<blockquote><p>If defined, this target hook is a function which is executed just after the
|
||
|
output of assembler code for <var>insn</var>, to change the mode of the assembler
|
||
|
if necessary.
|
||
|
|
||
|
<p>Here the argument <var>opvec</var> is the vector containing the operands
|
||
|
extracted from <var>insn</var>, and <var>noperands</var> is the number of
|
||
|
elements of the vector which contain meaningful data for this insn.
|
||
|
The contents of this vector are what was used to convert the insn
|
||
|
template into assembler code, so you can change the assembler mode
|
||
|
by checking the contents of the vector.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>PRINT_OPERAND</b> (<var>stream, x, code</var>)<var><a name="index-PRINT_005fOPERAND-4694"></a></var><br>
|
||
|
<blockquote><p>A C compound statement to output to stdio stream <var>stream</var> the
|
||
|
assembler syntax for an instruction operand <var>x</var>. <var>x</var> is an
|
||
|
RTL expression.
|
||
|
|
||
|
<p><var>code</var> is a value that can be used to specify one of several ways
|
||
|
of printing the operand. It is used when identical operands must be
|
||
|
printed differently depending on the context. <var>code</var> comes from
|
||
|
the ‘<samp><span class="samp">%</span></samp>’ specification that was used to request printing of the
|
||
|
operand. If the specification was just ‘<samp><span class="samp">%</span><var>digit</var></samp>’ then
|
||
|
<var>code</var> is 0; if the specification was ‘<samp><span class="samp">%</span><var>ltr</var>
|
||
|
<var>digit</var></samp>’ then <var>code</var> is the ASCII code for <var>ltr</var>.
|
||
|
|
||
|
<p><a name="index-reg_005fnames-4695"></a>If <var>x</var> is a register, this macro should print the register's name.
|
||
|
The names can be found in an array <code>reg_names</code> whose type is
|
||
|
<code>char *[]</code>. <code>reg_names</code> is initialized from
|
||
|
<code>REGISTER_NAMES</code>.
|
||
|
|
||
|
<p>When the machine description has a specification ‘<samp><span class="samp">%</span><var>punct</var></samp>’
|
||
|
(a ‘<samp><span class="samp">%</span></samp>’ followed by a punctuation character), this macro is called
|
||
|
with a null pointer for <var>x</var> and the punctuation character for
|
||
|
<var>code</var>.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>PRINT_OPERAND_PUNCT_VALID_P</b> (<var>code</var>)<var><a name="index-PRINT_005fOPERAND_005fPUNCT_005fVALID_005fP-4696"></a></var><br>
|
||
|
<blockquote><p>A C expression which evaluates to true if <var>code</var> is a valid
|
||
|
punctuation character for use in the <code>PRINT_OPERAND</code> macro. If
|
||
|
<code>PRINT_OPERAND_PUNCT_VALID_P</code> is not defined, it means that no
|
||
|
punctuation characters (except for the standard one, ‘<samp><span class="samp">%</span></samp>’) are used
|
||
|
in this way.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>PRINT_OPERAND_ADDRESS</b> (<var>stream, x</var>)<var><a name="index-PRINT_005fOPERAND_005fADDRESS-4697"></a></var><br>
|
||
|
<blockquote><p>A C compound statement to output to stdio stream <var>stream</var> the
|
||
|
assembler syntax for an instruction operand that is a memory reference
|
||
|
whose address is <var>x</var>. <var>x</var> is an RTL expression.
|
||
|
|
||
|
<p><a name="index-g_t_0040code_007bTARGET_005fENCODE_005fSECTION_005fINFO_007d-usage-4698"></a>On some machines, the syntax for a symbolic address depends on the
|
||
|
section that the address refers to. On these machines, define the hook
|
||
|
<code>TARGET_ENCODE_SECTION_INFO</code> to store the information into the
|
||
|
<code>symbol_ref</code>, and then check for it here. See <a href="Assembler-Format.html#Assembler-Format">Assembler Format</a>.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<p><a name="index-dbr_005fsequence_005flength-4699"></a>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>DBR_OUTPUT_SEQEND</b> (<var>file</var>)<var><a name="index-DBR_005fOUTPUT_005fSEQEND-4700"></a></var><br>
|
||
|
<blockquote><p>A C statement, to be executed after all slot-filler instructions have
|
||
|
been output. If necessary, call <code>dbr_sequence_length</code> to
|
||
|
determine the number of slots filled in a sequence (zero if not
|
||
|
currently outputting a sequence), to decide how many no-ops to output,
|
||
|
or whatever.
|
||
|
|
||
|
<p>Don't define this macro if it has nothing to do, but it is helpful in
|
||
|
reading assembly output if the extent of the delay sequence is made
|
||
|
explicit (e.g. with white space).
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<p><a name="index-final_005fsequence-4701"></a>Note that output routines for instructions with delay slots must be
|
||
|
prepared to deal with not being output as part of a sequence
|
||
|
(i.e. when the scheduling pass is not run, or when no slot fillers could be
|
||
|
found.) The variable <code>final_sequence</code> is null when not
|
||
|
processing a sequence, otherwise it contains the <code>sequence</code> rtx
|
||
|
being output.
|
||
|
|
||
|
<p><a name="index-asm_005ffprintf-4702"></a>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>REGISTER_PREFIX</b><var><a name="index-REGISTER_005fPREFIX-4703"></a></var><br>
|
||
|
— Macro: <b>LOCAL_LABEL_PREFIX</b><var><a name="index-LOCAL_005fLABEL_005fPREFIX-4704"></a></var><br>
|
||
|
— Macro: <b>USER_LABEL_PREFIX</b><var><a name="index-USER_005fLABEL_005fPREFIX-4705"></a></var><br>
|
||
|
— Macro: <b>IMMEDIATE_PREFIX</b><var><a name="index-IMMEDIATE_005fPREFIX-4706"></a></var><br>
|
||
|
<blockquote><p>If defined, C string expressions to be used for the ‘<samp><span class="samp">%R</span></samp>’, ‘<samp><span class="samp">%L</span></samp>’,
|
||
|
‘<samp><span class="samp">%U</span></samp>’, and ‘<samp><span class="samp">%I</span></samp>’ options of <code>asm_fprintf</code> (see
|
||
|
<samp><span class="file">final.c</span></samp>). These are useful when a single <samp><span class="file">md</span></samp> file must
|
||
|
support multiple assembler formats. In that case, the various <samp><span class="file">tm.h</span></samp>
|
||
|
files can define these macros differently.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>ASM_FPRINTF_EXTENSIONS</b> (<var>file, argptr, format</var>)<var><a name="index-ASM_005fFPRINTF_005fEXTENSIONS-4707"></a></var><br>
|
||
|
<blockquote><p>If defined this macro should expand to a series of <code>case</code>
|
||
|
statements which will be parsed inside the <code>switch</code> statement of
|
||
|
the <code>asm_fprintf</code> function. This allows targets to define extra
|
||
|
printf formats which may useful when generating their assembler
|
||
|
statements. Note that uppercase letters are reserved for future
|
||
|
generic extensions to asm_fprintf, and so are not available to target
|
||
|
specific code. The output file is given by the parameter <var>file</var>.
|
||
|
The varargs input pointer is <var>argptr</var> and the rest of the format
|
||
|
string, starting the character after the one that is being switched
|
||
|
upon, is pointed to by <var>format</var>.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>ASSEMBLER_DIALECT</b><var><a name="index-ASSEMBLER_005fDIALECT-4708"></a></var><br>
|
||
|
<blockquote><p>If your target supports multiple dialects of assembler language (such as
|
||
|
different opcodes), define this macro as a C expression that gives the
|
||
|
numeric index of the assembler language dialect to use, with zero as the
|
||
|
first variant.
|
||
|
|
||
|
<p>If this macro is defined, you may use constructs of the form
|
||
|
<pre class="smallexample"> ‘<samp><span class="samp">{option0|option1|option2...}</span></samp>’
|
||
|
</pre>
|
||
|
<p class="noindent">in the output templates of patterns (see <a href="Output-Template.html#Output-Template">Output Template</a>) or in the
|
||
|
first argument of <code>asm_fprintf</code>. This construct outputs
|
||
|
‘<samp><span class="samp">option0</span></samp>’, ‘<samp><span class="samp">option1</span></samp>’, ‘<samp><span class="samp">option2</span></samp>’, etc., if the value of
|
||
|
<code>ASSEMBLER_DIALECT</code> is zero, one, two, etc. Any special characters
|
||
|
within these strings retain their usual meaning. If there are fewer
|
||
|
alternatives within the braces than the value of
|
||
|
<code>ASSEMBLER_DIALECT</code>, the construct outputs nothing. If it's needed
|
||
|
to print curly braces or ‘<samp><span class="samp">|</span></samp>’ character in assembler output directly,
|
||
|
‘<samp><span class="samp">%{</span></samp>’, ‘<samp><span class="samp">%}</span></samp>’ and ‘<samp><span class="samp">%|</span></samp>’ can be used.
|
||
|
|
||
|
<p>If you do not define this macro, the characters ‘<samp><span class="samp">{</span></samp>’, ‘<samp><span class="samp">|</span></samp>’ and
|
||
|
‘<samp><span class="samp">}</span></samp>’ do not have any special meaning when used in templates or
|
||
|
operands to <code>asm_fprintf</code>.
|
||
|
|
||
|
<p>Define the macros <code>REGISTER_PREFIX</code>, <code>LOCAL_LABEL_PREFIX</code>,
|
||
|
<code>USER_LABEL_PREFIX</code> and <code>IMMEDIATE_PREFIX</code> if you can express
|
||
|
the variations in assembler language syntax with that mechanism. Define
|
||
|
<code>ASSEMBLER_DIALECT</code> and use the ‘<samp><span class="samp">{option0|option1}</span></samp>’ syntax
|
||
|
if the syntax variant are larger and involve such things as different
|
||
|
opcodes or operand order.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>ASM_OUTPUT_REG_PUSH</b> (<var>stream, regno</var>)<var><a name="index-ASM_005fOUTPUT_005fREG_005fPUSH-4709"></a></var><br>
|
||
|
<blockquote><p>A C expression to output to <var>stream</var> some assembler code
|
||
|
which will push hard register number <var>regno</var> onto the stack.
|
||
|
The code need not be optimal, since this macro is used only when
|
||
|
profiling.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
<div class="defun">
|
||
|
— Macro: <b>ASM_OUTPUT_REG_POP</b> (<var>stream, regno</var>)<var><a name="index-ASM_005fOUTPUT_005fREG_005fPOP-4710"></a></var><br>
|
||
|
<blockquote><p>A C expression to output to <var>stream</var> some assembler code
|
||
|
which will pop hard register number <var>regno</var> off of the stack.
|
||
|
The code need not be optimal, since this macro is used only when
|
||
|
profiling.
|
||
|
</p></blockquote></div>
|
||
|
|
||
|
</body></html>
|
||
|
|