gccint: Output Template

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