Output of Assembler Instructions#
This describes assembler instruction output.
-
REGISTER_NAMES#
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.
-
ADDITIONAL_REGISTER_NAMES#
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
asm
option in declarations to refer to registers using alternate names.
-
OVERLAPPING_REGISTER_NAMES#
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
asm
option in declarations to refer to registers using alternate names. UnlikeADDITIONAL_REGISTER_NAMES
, this macro should be used when the register name implies multiple underlying registers.This macro should be used when it is important that a clobber in an
asm
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’.
-
ASM_OUTPUT_OPCODE(stream, ptr)#
Define this macro if you are using an unusual assembler that requires different names for the machine instructions.
The definition is a C statement or statements which output an assembler instruction opcode to the stdio stream
stream
. The macro-operandptr
is a variable of typechar *
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 tostream
, performing any translation you desire, and increment the variableptr
to point at the end of the opcode so that it will not be output twice.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
%
-sequences to substitute operands, you must take care of the substitution yourself. Just be sure to incrementptr
over whatever text should not be output normally.If you need to look at the operand values, they can be found as the elements of
recog_data.operand
.If the macro definition does nothing, the instruction is output in the usual way.
-
FINAL_PRESCAN_INSN(insn, opvec, noperands)#
If defined, a C statement to be executed just prior to the output of assembler code for
insn
, to modify the extracted operands so they will be output differently.Here the argument
opvec
is the vector containing the operands extracted frominsn
, andnoperands
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.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.
If this macro is not defined, it is equivalent to a null statement.
-
void TARGET_ASM_FINAL_POSTSCAN_INSN(FILE *file, rtx_insn *insn, rtx *opvec, int noperands)#
If defined, this target hook is a function which is executed just after the output of assembler code for
insn
, to change the mode of the assembler if necessary.Here the argument
opvec
is the vector containing the operands extracted frominsn
, andnoperands
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.
-
PRINT_OPERAND(stream, x, code)#
A C compound statement to output to stdio stream
stream
the assembler syntax for an instruction operandx
.x
is an RTL expression.code
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.code
comes from the%
specification that was used to request printing of the operand. If the specification was just%digit
thencode
is 0; if the specification was%ltrdigit
thencode
is the ASCII code forltr
.If
x
is a register, this macro should print the register’s name. The names can be found in an arrayreg_names
whose type ischar *[]
.reg_names
is initialized fromREGISTER_NAMES
.When the machine description has a specification
%punct
(a%
followed by a punctuation character), this macro is called with a null pointer forx
and the punctuation character forcode
.
-
PRINT_OPERAND_PUNCT_VALID_P(code)#
A C expression which evaluates to true if
code
is a valid punctuation character for use in thePRINT_OPERAND
macro. IfPRINT_OPERAND_PUNCT_VALID_P
is not defined, it means that no punctuation characters (except for the standard one,%
) are used in this way.
-
PRINT_OPERAND_ADDRESS(stream, x)#
A C compound statement to output to stdio stream
stream
the assembler syntax for an instruction operand that is a memory reference whose address isx
.x
is an RTL expression.On some machines, the syntax for a symbolic address depends on the section that the address refers to. On these machines, define the hook
TARGET_ENCODE_SECTION_INFO
to store the information into thesymbol_ref
, and then check for it here. See Defining the Output Assembler Language.
-
DBR_OUTPUT_SEQEND(file)#
A C statement, to be executed after all slot-filler instructions have been output. If necessary, call
dbr_sequence_length
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.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).
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 final_sequence
is null when not
processing a sequence, otherwise it contains the sequence
rtx
being output.
-
REGISTER_PREFIX#
-
LOCAL_LABEL_PREFIX#
-
USER_LABEL_PREFIX#
-
IMMEDIATE_PREFIX#
If defined, C string expressions to be used for the
%R
,%L
,%U
, and%I
options ofasm_fprintf
(seefinal.cc
). These are useful when a singlemd
file must support multiple assembler formats. In that case, the varioustm.h
files can define these macros differently.
-
ASM_FPRINTF_EXTENSIONS(file, argptr, format)#
If defined this macro should expand to a series of
case
statements which will be parsed inside theswitch
statement of theasm_fprintf
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 parameterfile
. The varargs input pointer isargptr
and the rest of the format string, starting the character after the one that is being switched upon, is pointed to byformat
.
-
ASSEMBLER_DIALECT#
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.
If this macro is defined, you may use constructs of the form
{option0|option1|option2...}
in the output templates of patterns (see Output Templates and Operand Substitution) or in the first argument of
asm_fprintf
. This construct outputsoption0
,option1
,option2
, etc., if the value ofASSEMBLER_DIALECT
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 ofASSEMBLER_DIALECT
, the construct outputs nothing. If it’s needed to print curly braces or|
character in assembler output directly,%{
,%}
and%|
can be used.If you do not define this macro, the characters
{
,|
and}
do not have any special meaning when used in templates or operands toasm_fprintf
.Define the macros
REGISTER_PREFIX
,LOCAL_LABEL_PREFIX
,USER_LABEL_PREFIX
andIMMEDIATE_PREFIX
if you can express the variations in assembler language syntax with that mechanism. DefineASSEMBLER_DIALECT
and use theoption0|option1
syntax if the syntax variant are larger and involve such things as different opcodes or operand order.
-
ASM_OUTPUT_REG_PUSH(stream, regno)#
A C expression to output to
stream
some assembler code which will push hard register numberregno
onto the stack. The code need not be optimal, since this macro is used only when profiling.
-
ASM_OUTPUT_REG_POP(stream, regno)#
A C expression to output to
stream
some assembler code which will pop hard register numberregno
off of the stack. The code need not be optimal, since this macro is used only when profiling.