DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(gcc.info.gz) Output Template

Info Catalog (gcc.info.gz) RTL Template (gcc.info.gz) Machine Desc (gcc.info.gz) Output Statement
 
 Output Templates and Operand Substitution
 =========================================
 
    The "output template" is a string which specifies how to output the
 assembler code for an instruction pattern.  Most of the template is a
 fixed string which is output literally.  The character `%' is used to
 specify where to substitute an operand; it can also be used to identify
 places where different variants of the assembler require different
 syntax.
 
    In the simplest case, a `%' followed by a digit N says to output
 operand N at that point in the string.
 
    `%' followed by a letter and a digit says to output an operand in an
 alternate fashion.  Four letters have standard, built-in meanings
 described below.  The machine description macro `PRINT_OPERAND' can
 define additional letters with nonstandard meanings.
 
    `%cDIGIT' can be used to substitute an operand that is a constant
 value without the syntax that normally indicates an immediate operand.
 
    `%nDIGIT' is like `%cDIGIT' except that the value of the constant is
 negated before printing.
 
    `%aDIGIT' can be used to substitute an operand as if it were a
 memory reference, with the actual operand treated as the address.  This
 may be useful when outputting a "load address" instruction, because
 often the assembler syntax for such an instruction requires you to
 write the operand as if it were a memory reference.
 
    `%lDIGIT' is used to substitute a `label_ref' into a jump
 instruction.
 
    `%=' outputs a number which is unique to each instruction in the
 entire compilation.  This is useful for making local labels to be
 referred to more than once in a single template that generates multiple
 assembler instructions.
 
    `%' followed by a punctuation character specifies a substitution that
 does not use an operand.  Only one case is standard: `%%' outputs a `%'
 into the assembler code.  Other nonstandard cases can be defined in the
 `PRINT_OPERAND' macro.  You must also define which punctuation
 characters are valid with the `PRINT_OPERAND_PUNCT_VALID_P' macro.
 
    The template may generate multiple assembler instructions.  Write
 the text for the instructions, with `\;' between them.
 
    When the RTL contains two operands which are required by constraint
 to match each other, the output template must refer only to the
 lower-numbered operand.  Matching operands are not always identical,
 and the rest of the compiler arranges to put the proper RTL expression
 for printing into the lower-numbered operand.
 
    One use of nonstandard letters or punctuation following `%' is to
 distinguish between different assembler languages for the same machine;
 for example, Motorola syntax versus MIT syntax for the 68000.  Motorola
 syntax requires periods in most opcode names, while MIT syntax does
 not.  For example, the opcode `movel' in MIT syntax is `move.l' in
 Motorola syntax.  The same file of patterns is used for both kinds of
 output syntax, but the character sequence `%.' is used in each place
 where Motorola syntax wants a period.  The `PRINT_OPERAND' macro for
 Motorola syntax defines the sequence to output a period; the macro for
 MIT syntax defines it to do nothing.
 
    As a special case, a template consisting of the single character `#'
 instructs the compiler to first split the insn, and then output the
 resulting instructions separately.  This helps eliminate redundancy in
 the output templates.   If you have a `define_insn' that needs to emit
 multiple assembler instructions, and there is an matching `define_split'
 already defined, then you can simply use `#' as the output template
 instead of writing an output template that emits the multiple assembler
 instructions.
 
    If the macro `ASSEMBLER_DIALECT' is defined, you can use construct
 of the form `{option0|option1|option2}' in the templates.  These
 describe multiple variants of assembler language syntax.  
 Instruction Output.
 
Info Catalog (gcc.info.gz) RTL Template (gcc.info.gz) Machine Desc (gcc.info.gz) Output Statement
automatically generated byinfo2html