rtl.texi revision 119256
1117395Skan@c Copyright (C) 1988, 1989, 1992, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003
290075Sobrien@c Free Software Foundation, Inc.
390075Sobrien@c This is part of the GCC manual.
490075Sobrien@c For copying conditions, see the file gcc.texi.
590075Sobrien
690075Sobrien@node RTL
790075Sobrien@chapter RTL Representation
890075Sobrien@cindex RTL representation
990075Sobrien@cindex representation of RTL
1090075Sobrien@cindex Register Transfer Language (RTL)
1190075Sobrien
1290075SobrienMost of the work of the compiler is done on an intermediate representation
1390075Sobriencalled register transfer language.  In this language, the instructions to be
1490075Sobrienoutput are described, pretty much one by one, in an algebraic form that
1590075Sobriendescribes what the instruction does.
1690075Sobrien
1790075SobrienRTL is inspired by Lisp lists.  It has both an internal form, made up of
1890075Sobrienstructures that point at other structures, and a textual form that is used
1990075Sobrienin the machine description and in printed debugging dumps.  The textual
2090075Sobrienform uses nested parentheses to indicate the pointers in the internal form.
2190075Sobrien
2290075Sobrien@menu
2390075Sobrien* RTL Objects::       Expressions vs vectors vs strings vs integers.
2490075Sobrien* RTL Classes::       Categories of RTL expression objects, and their structure.
2590075Sobrien* Accessors::         Macros to access expression operands or vector elts.
2690075Sobrien* Flags::             Other flags in an RTL expression.
2790075Sobrien* Machine Modes::     Describing the size and format of a datum.
2890075Sobrien* Constants::         Expressions with constant values.
2990075Sobrien* Regs and Memory::   Expressions representing register contents or memory.
3090075Sobrien* Arithmetic::        Expressions representing arithmetic on other expressions.
3190075Sobrien* Comparisons::       Expressions representing comparison of expressions.
3290075Sobrien* Bit-Fields::        Expressions representing bit-fields in memory or reg.
3390075Sobrien* Vector Operations:: Expressions involving vector datatypes.
3490075Sobrien* Conversions::       Extending, truncating, floating or fixing.
3590075Sobrien* RTL Declarations::  Declaring volatility, constancy, etc.
3690075Sobrien* Side Effects::      Expressions for storing in registers, etc.
3790075Sobrien* Incdec::            Embedded side-effects for autoincrement addressing.
3890075Sobrien* Assembler::         Representing @code{asm} with operands.
3990075Sobrien* Insns::             Expression types for entire insns.
4090075Sobrien* Calls::             RTL representation of function call insns.
4190075Sobrien* Sharing::           Some expressions are unique; others *must* be copied.
4290075Sobrien* Reading RTL::       Reading textual RTL from a file.
4390075Sobrien@end menu
4490075Sobrien
4590075Sobrien@node RTL Objects
4690075Sobrien@section RTL Object Types
4790075Sobrien@cindex RTL object types
4890075Sobrien
4990075Sobrien@cindex RTL integers
5090075Sobrien@cindex RTL strings
5190075Sobrien@cindex RTL vectors
5290075Sobrien@cindex RTL expression
5390075Sobrien@cindex RTX (See RTL)
5490075SobrienRTL uses five kinds of objects: expressions, integers, wide integers,
5590075Sobrienstrings and vectors.  Expressions are the most important ones.  An RTL
5690075Sobrienexpression (``RTX'', for short) is a C structure, but it is usually
5790075Sobrienreferred to with a pointer; a type that is given the typedef name
5890075Sobrien@code{rtx}.
5990075Sobrien
6090075SobrienAn integer is simply an @code{int}; their written form uses decimal
6190075Sobriendigits.  A wide integer is an integral object whose type is
6290075Sobrien@code{HOST_WIDE_INT}; their written form uses decimal digits.
6390075Sobrien
6490075SobrienA string is a sequence of characters.  In core it is represented as a
6590075Sobrien@code{char *} in usual C fashion, and it is written in C syntax as well.
6690075SobrienHowever, strings in RTL may never be null.  If you write an empty string in
6790075Sobriena machine description, it is represented in core as a null pointer rather
6890075Sobrienthan as a pointer to a null character.  In certain contexts, these null
6990075Sobrienpointers instead of strings are valid.  Within RTL code, strings are most
7090075Sobriencommonly found inside @code{symbol_ref} expressions, but they appear in
7190075Sobrienother contexts in the RTL expressions that make up machine descriptions.
7290075Sobrien
7390075SobrienIn a machine description, strings are normally written with double
7490075Sobrienquotes, as you would in C.  However, strings in machine descriptions may
7590075Sobrienextend over many lines, which is invalid C, and adjacent string
7690075Sobrienconstants are not concatenated as they are in C.  Any string constant
7790075Sobrienmay be surrounded with a single set of parentheses.  Sometimes this
7890075Sobrienmakes the machine description easier to read.
7990075Sobrien
8090075SobrienThere is also a special syntax for strings, which can be useful when C
8190075Sobriencode is embedded in a machine description.  Wherever a string can
8290075Sobrienappear, it is also valid to write a C-style brace block.  The entire
8390075Sobrienbrace block, including the outermost pair of braces, is considered to be
8490075Sobrienthe string constant.  Double quote characters inside the braces are not
8590075Sobrienspecial.  Therefore, if you write string constants in the C code, you
8690075Sobrienneed not escape each quote character with a backslash.
8790075Sobrien
8890075SobrienA vector contains an arbitrary number of pointers to expressions.  The
8990075Sobriennumber of elements in the vector is explicitly present in the vector.
9090075SobrienThe written form of a vector consists of square brackets
9190075Sobrien(@samp{[@dots{}]}) surrounding the elements, in sequence and with
9290075Sobrienwhitespace separating them.  Vectors of length zero are not created;
9390075Sobriennull pointers are used instead.
9490075Sobrien
9590075Sobrien@cindex expression codes
9690075Sobrien@cindex codes, RTL expression
9790075Sobrien@findex GET_CODE
9890075Sobrien@findex PUT_CODE
9990075SobrienExpressions are classified by @dfn{expression codes} (also called RTX
10090075Sobriencodes).  The expression code is a name defined in @file{rtl.def}, which is
10190075Sobrienalso (in upper case) a C enumeration constant.  The possible expression
10290075Sobriencodes and their meanings are machine-independent.  The code of an RTX can
10390075Sobrienbe extracted with the macro @code{GET_CODE (@var{x})} and altered with
10490075Sobrien@code{PUT_CODE (@var{x}, @var{newcode})}.
10590075Sobrien
10690075SobrienThe expression code determines how many operands the expression contains,
10790075Sobrienand what kinds of objects they are.  In RTL, unlike Lisp, you cannot tell
10890075Sobrienby looking at an operand what kind of object it is.  Instead, you must know
10990075Sobrienfrom its context---from the expression code of the containing expression.
11090075SobrienFor example, in an expression of code @code{subreg}, the first operand is
11190075Sobriento be regarded as an expression and the second operand as an integer.  In
11290075Sobrienan expression of code @code{plus}, there are two operands, both of which
11390075Sobrienare to be regarded as expressions.  In a @code{symbol_ref} expression,
11490075Sobrienthere is one operand, which is to be regarded as a string.
11590075Sobrien
11690075SobrienExpressions are written as parentheses containing the name of the
11790075Sobrienexpression type, its flags and machine mode if any, and then the operands
11890075Sobrienof the expression (separated by spaces).
11990075Sobrien
12090075SobrienExpression code names in the @samp{md} file are written in lower case,
12190075Sobrienbut when they appear in C code they are written in upper case.  In this
12290075Sobrienmanual, they are shown as follows: @code{const_int}.
12390075Sobrien
12490075Sobrien@cindex (nil)
12590075Sobrien@cindex nil
12690075SobrienIn a few contexts a null pointer is valid where an expression is normally
12790075Sobrienwanted.  The written form of this is @code{(nil)}.
12890075Sobrien
12990075Sobrien@node RTL Classes
13090075Sobrien@section RTL Classes and Formats
13190075Sobrien@cindex RTL classes
13290075Sobrien@cindex classes of RTX codes
13390075Sobrien@cindex RTX codes, classes of
13490075Sobrien@findex GET_RTX_CLASS
13590075Sobrien
13690075SobrienThe various expression codes are divided into several @dfn{classes},
13790075Sobrienwhich are represented by single characters.  You can determine the class
13890075Sobrienof an RTX code with the macro @code{GET_RTX_CLASS (@var{code})}.
13990075SobrienCurrently, @file{rtx.def} defines these classes:
14090075Sobrien
14190075Sobrien@table @code
14290075Sobrien@item o
14390075SobrienAn RTX code that represents an actual object, such as a register
14490075Sobrien(@code{REG}) or a memory location (@code{MEM}, @code{SYMBOL_REF}).
14590075SobrienConstants and basic transforms on objects (@code{ADDRESSOF},
14690075Sobrien@code{HIGH}, @code{LO_SUM}) are also included.  Note that @code{SUBREG}
14790075Sobrienand @code{STRICT_LOW_PART} are not in this class, but in class @code{x}.
14890075Sobrien
14990075Sobrien@item <
15090075SobrienAn RTX code for a comparison, such as @code{NE} or @code{LT}.
15190075Sobrien
15290075Sobrien@item 1
15390075SobrienAn RTX code for a unary arithmetic operation, such as @code{NEG},
15490075Sobrien@code{NOT}, or @code{ABS}.  This category also includes value extension
15590075Sobrien(sign or zero) and conversions between integer and floating point.
15690075Sobrien
15790075Sobrien@item c
15890075SobrienAn RTX code for a commutative binary operation, such as @code{PLUS} or
15990075Sobrien@code{AND}.  @code{NE} and @code{EQ} are comparisons, so they have class
16090075Sobrien@code{<}.
16190075Sobrien
16290075Sobrien@item 2
16390075SobrienAn RTX code for a non-commutative binary operation, such as @code{MINUS},
16490075Sobrien@code{DIV}, or @code{ASHIFTRT}.
16590075Sobrien
16690075Sobrien@item b
16790075SobrienAn RTX code for a bit-field operation.  Currently only
16890075Sobrien@code{ZERO_EXTRACT} and @code{SIGN_EXTRACT}.  These have three inputs
16990075Sobrienand are lvalues (so they can be used for insertion as well).
17090075Sobrien@xref{Bit-Fields}.
17190075Sobrien
17290075Sobrien@item 3
17390075SobrienAn RTX code for other three input operations.  Currently only
17490075Sobrien@code{IF_THEN_ELSE}.
17590075Sobrien
17690075Sobrien@item i
17790075SobrienAn RTX code for an entire instruction:  @code{INSN}, @code{JUMP_INSN}, and
17890075Sobrien@code{CALL_INSN}.  @xref{Insns}.
17990075Sobrien
18090075Sobrien@item m
18190075SobrienAn RTX code for something that matches in insns, such as
18290075Sobrien@code{MATCH_DUP}.  These only occur in machine descriptions.
18390075Sobrien
18490075Sobrien@item a
18590075SobrienAn RTX code for an auto-increment addressing mode, such as
18690075Sobrien@code{POST_INC}.
18790075Sobrien
18890075Sobrien@item x
18990075SobrienAll other RTX codes.  This category includes the remaining codes used
19090075Sobrienonly in machine descriptions (@code{DEFINE_*}, etc.).  It also includes
19190075Sobrienall the codes describing side effects (@code{SET}, @code{USE},
19290075Sobrien@code{CLOBBER}, etc.) and the non-insns that may appear on an insn
19390075Sobrienchain, such as @code{NOTE}, @code{BARRIER}, and @code{CODE_LABEL}.
19490075Sobrien@end table
19590075Sobrien
19690075Sobrien@cindex RTL format
19790075SobrienFor each expression code, @file{rtl.def} specifies the number of
19890075Sobriencontained objects and their kinds using a sequence of characters
19990075Sobriencalled the @dfn{format} of the expression code.  For example,
20090075Sobrienthe format of @code{subreg} is @samp{ei}.
20190075Sobrien
20290075Sobrien@cindex RTL format characters
20390075SobrienThese are the most commonly used format characters:
20490075Sobrien
20590075Sobrien@table @code
20690075Sobrien@item e
20790075SobrienAn expression (actually a pointer to an expression).
20890075Sobrien
20990075Sobrien@item i
21090075SobrienAn integer.
21190075Sobrien
21290075Sobrien@item w
21390075SobrienA wide integer.
21490075Sobrien
21590075Sobrien@item s
21690075SobrienA string.
21790075Sobrien
21890075Sobrien@item E
21990075SobrienA vector of expressions.
22090075Sobrien@end table
22190075Sobrien
22290075SobrienA few other format characters are used occasionally:
22390075Sobrien
22490075Sobrien@table @code
22590075Sobrien@item u
22690075Sobrien@samp{u} is equivalent to @samp{e} except that it is printed differently
22790075Sobrienin debugging dumps.  It is used for pointers to insns.
22890075Sobrien
22990075Sobrien@item n
23090075Sobrien@samp{n} is equivalent to @samp{i} except that it is printed differently
23190075Sobrienin debugging dumps.  It is used for the line number or code number of a
23290075Sobrien@code{note} insn.
23390075Sobrien
23490075Sobrien@item S
23590075Sobrien@samp{S} indicates a string which is optional.  In the RTL objects in
23690075Sobriencore, @samp{S} is equivalent to @samp{s}, but when the object is read,
23790075Sobrienfrom an @samp{md} file, the string value of this operand may be omitted.
23890075SobrienAn omitted string is taken to be the null string.
23990075Sobrien
24090075Sobrien@item V
24190075Sobrien@samp{V} indicates a vector which is optional.  In the RTL objects in
24290075Sobriencore, @samp{V} is equivalent to @samp{E}, but when the object is read
24390075Sobrienfrom an @samp{md} file, the vector value of this operand may be omitted.
24490075SobrienAn omitted vector is effectively the same as a vector of no elements.
24590075Sobrien
246117395Skan@item B
247117395Skan@samp{B} indicates a pointer to basic block structure.
248117395Skan
24990075Sobrien@item 0
25090075Sobrien@samp{0} means a slot whose contents do not fit any normal category.
25190075Sobrien@samp{0} slots are not printed at all in dumps, and are often used in
25290075Sobrienspecial ways by small parts of the compiler.
25390075Sobrien@end table
25490075Sobrien
25590075SobrienThere are macros to get the number of operands and the format
25690075Sobrienof an expression code:
25790075Sobrien
25890075Sobrien@table @code
25990075Sobrien@findex GET_RTX_LENGTH
26090075Sobrien@item GET_RTX_LENGTH (@var{code})
26190075SobrienNumber of operands of an RTX of code @var{code}.
26290075Sobrien
26390075Sobrien@findex GET_RTX_FORMAT
26490075Sobrien@item GET_RTX_FORMAT (@var{code})
26590075SobrienThe format of an RTX of code @var{code}, as a C string.
26690075Sobrien@end table
26790075Sobrien
26890075SobrienSome classes of RTX codes always have the same format.  For example, it
26990075Sobrienis safe to assume that all comparison operations have format @code{ee}.
27090075Sobrien
27190075Sobrien@table @code
27290075Sobrien@item 1
27390075SobrienAll codes of this class have format @code{e}.
27490075Sobrien
27590075Sobrien@item <
27690075Sobrien@itemx c
27790075Sobrien@itemx 2
27890075SobrienAll codes of these classes have format @code{ee}.
27990075Sobrien
28090075Sobrien@item b
28190075Sobrien@itemx 3
28290075SobrienAll codes of these classes have format @code{eee}.
28390075Sobrien
28490075Sobrien@item i
28590075SobrienAll codes of this class have formats that begin with @code{iuueiee}.
28690075Sobrien@xref{Insns}.  Note that not all RTL objects linked onto an insn chain
28790075Sobrienare of class @code{i}.
28890075Sobrien
28990075Sobrien@item o
29090075Sobrien@itemx m
29190075Sobrien@itemx x
29290075SobrienYou can make no assumptions about the format of these codes.
29390075Sobrien@end table
29490075Sobrien
29590075Sobrien@node Accessors
29690075Sobrien@section Access to Operands
29790075Sobrien@cindex accessors
29890075Sobrien@cindex access to operands
29990075Sobrien@cindex operand access
30090075Sobrien
30190075Sobrien@findex XEXP
30290075Sobrien@findex XINT
30390075Sobrien@findex XWINT
30490075Sobrien@findex XSTR
30590075SobrienOperands of expressions are accessed using the macros @code{XEXP},
30690075Sobrien@code{XINT}, @code{XWINT} and @code{XSTR}.  Each of these macros takes
30790075Sobrientwo arguments: an expression-pointer (RTX) and an operand number
30890075Sobrien(counting from zero).  Thus,
30990075Sobrien
31090075Sobrien@example
31190075SobrienXEXP (@var{x}, 2)
31290075Sobrien@end example
31390075Sobrien
31490075Sobrien@noindent
31590075Sobrienaccesses operand 2 of expression @var{x}, as an expression.
31690075Sobrien
31790075Sobrien@example
31890075SobrienXINT (@var{x}, 2)
31990075Sobrien@end example
32090075Sobrien
32190075Sobrien@noindent
32290075Sobrienaccesses the same operand as an integer.  @code{XSTR}, used in the same
32390075Sobrienfashion, would access it as a string.
32490075Sobrien
32590075SobrienAny operand can be accessed as an integer, as an expression or as a string.
32690075SobrienYou must choose the correct method of access for the kind of value actually
32790075Sobrienstored in the operand.  You would do this based on the expression code of
32890075Sobrienthe containing expression.  That is also how you would know how many
32990075Sobrienoperands there are.
33090075Sobrien
33190075SobrienFor example, if @var{x} is a @code{subreg} expression, you know that it has
33290075Sobrientwo operands which can be correctly accessed as @code{XEXP (@var{x}, 0)}
33390075Sobrienand @code{XINT (@var{x}, 1)}.  If you did @code{XINT (@var{x}, 0)}, you
33490075Sobrienwould get the address of the expression operand but cast as an integer;
33590075Sobrienthat might occasionally be useful, but it would be cleaner to write
33690075Sobrien@code{(int) XEXP (@var{x}, 0)}.  @code{XEXP (@var{x}, 1)} would also
33790075Sobriencompile without error, and would return the second, integer operand cast as
33890075Sobrienan expression pointer, which would probably result in a crash when
33990075Sobrienaccessed.  Nothing stops you from writing @code{XEXP (@var{x}, 28)} either,
34090075Sobrienbut this will access memory past the end of the expression with
34190075Sobrienunpredictable results.
34290075Sobrien
34390075SobrienAccess to operands which are vectors is more complicated.  You can use the
34490075Sobrienmacro @code{XVEC} to get the vector-pointer itself, or the macros
34590075Sobrien@code{XVECEXP} and @code{XVECLEN} to access the elements and length of a
34690075Sobrienvector.
34790075Sobrien
34890075Sobrien@table @code
34990075Sobrien@findex XVEC
35090075Sobrien@item XVEC (@var{exp}, @var{idx})
35190075SobrienAccess the vector-pointer which is operand number @var{idx} in @var{exp}.
35290075Sobrien
35390075Sobrien@findex XVECLEN
35490075Sobrien@item XVECLEN (@var{exp}, @var{idx})
35590075SobrienAccess the length (number of elements) in the vector which is
35690075Sobrienin operand number @var{idx} in @var{exp}.  This value is an @code{int}.
35790075Sobrien
35890075Sobrien@findex XVECEXP
35990075Sobrien@item XVECEXP (@var{exp}, @var{idx}, @var{eltnum})
36090075SobrienAccess element number @var{eltnum} in the vector which is
36190075Sobrienin operand number @var{idx} in @var{exp}.  This value is an RTX@.
36290075Sobrien
36390075SobrienIt is up to you to make sure that @var{eltnum} is not negative
36490075Sobrienand is less than @code{XVECLEN (@var{exp}, @var{idx})}.
36590075Sobrien@end table
36690075Sobrien
36790075SobrienAll the macros defined in this section expand into lvalues and therefore
36890075Sobriencan be used to assign the operands, lengths and vector elements as well as
36990075Sobriento access them.
37090075Sobrien
37190075Sobrien@node Flags
37290075Sobrien@section Flags in an RTL Expression
37390075Sobrien@cindex flags in RTL expression
37490075Sobrien
37590075SobrienRTL expressions contain several flags (one-bit bit-fields)
37690075Sobrienthat are used in certain types of expression.  Most often they
377117395Skanare accessed with the following macros, which expand into lvalues.
37890075Sobrien
37990075Sobrien@table @code
38090075Sobrien@findex CONSTANT_POOL_ADDRESS_P
38190075Sobrien@cindex @code{symbol_ref} and @samp{/u}
38290075Sobrien@cindex @code{unchanging}, in @code{symbol_ref}
38390075Sobrien@item CONSTANT_POOL_ADDRESS_P (@var{x})
38490075SobrienNonzero in a @code{symbol_ref} if it refers to part of the current
38590075Sobrienfunction's constant pool.  For most targets these addresses are in a
38690075Sobrien@code{.rodata} section entirely separate from the function, but for
38790075Sobriensome targets the addresses are close to the beginning of the function.
38890075SobrienIn either case GCC assumes these addresses can be addressed directly,
38990075Sobrienperhaps with the help of base registers.
39090075SobrienStored in the @code{unchanging} field and printed as @samp{/u}.
39190075Sobrien
39290075Sobrien@findex CONST_OR_PURE_CALL_P
39390075Sobrien@cindex @code{call_insn} and @samp{/u}
39490075Sobrien@cindex @code{unchanging}, in @code{call_insn}
39590075Sobrien@item CONST_OR_PURE_CALL_P (@var{x})
39690075SobrienIn a @code{call_insn}, @code{note}, or an @code{expr_list} for notes,
39790075Sobrienindicates that the insn represents a call to a const or pure function.
39890075SobrienStored in the @code{unchanging} field and printed as @samp{/u}.
39990075Sobrien
40090075Sobrien@findex INSN_ANNULLED_BRANCH_P
401117395Skan@cindex @code{jump_insn} and @samp{/u}
402117395Skan@cindex @code{call_insn} and @samp{/u}
40390075Sobrien@cindex @code{insn} and @samp{/u}
404117395Skan@cindex @code{unchanging}, in @code{jump_insn}, @code{call_insn} and @code{insn}
40590075Sobrien@item INSN_ANNULLED_BRANCH_P (@var{x})
406117395SkanIn a @code{jump_insn}, @code{call_insn}, or @code{insn} indicates
407117395Skanthat the branch is an annulling one.  See the discussion under
408117395Skan@code{sequence} below. Stored in the @code{unchanging} field and
409117395Skanprinted as @samp{/u}.
41090075Sobrien
41190075Sobrien@findex INSN_DEAD_CODE_P
41290075Sobrien@cindex @code{insn} and @samp{/s}
41390075Sobrien@cindex @code{in_struct}, in @code{insn}
41490075Sobrien@item INSN_DEAD_CODE_P (@var{x})
41590075SobrienIn an @code{insn} during the dead-code elimination pass, nonzero if the
41690075Sobrieninsn is dead.
41790075SobrienStored in the @code{in_struct} field and printed as @samp{/s}.
41890075Sobrien
41990075Sobrien@findex INSN_DELETED_P
42090075Sobrien@cindex @code{insn} and @samp{/v}
421117395Skan@cindex @code{call_insn} and @samp{/v}
422117395Skan@cindex @code{jump_insn} and @samp{/v}
423117395Skan@cindex @code{code_label} and @samp{/v}
424117395Skan@cindex @code{barrier} and @samp{/v}
425117395Skan@cindex @code{note} and @samp{/v}
426117395Skan@cindex @code{volatil}, in @code{insn}, @code{call_insn}, @code{jump_insn}, @code{code_label}, @code{barrier}, and @code{note}
42790075Sobrien@item INSN_DELETED_P (@var{x})
428117395SkanIn an @code{insn}, @code{call_insn}, @code{jump_insn}, @code{code_label},
429117395Skan@code{barrier}, or @code{note},
430117395Skannonzero if the insn has been deleted.  Stored in the
43190075Sobrien@code{volatil} field and printed as @samp{/v}.
43290075Sobrien
43390075Sobrien@findex INSN_FROM_TARGET_P
43490075Sobrien@cindex @code{insn} and @samp{/s}
435117395Skan@cindex @code{jump_insn} and @samp{/s}
436117395Skan@cindex @code{call_insn} and @samp{/s}
437117395Skan@cindex @code{in_struct}, in @code{insn} and @code{jump_insn} and @code{call_insn}
43890075Sobrien@item INSN_FROM_TARGET_P (@var{x})
439117395SkanIn an @code{insn} or @code{jump_insn} or @code{call_insn} in a delay
440117395Skanslot of a branch, indicates that the insn
44190075Sobrienis from the target of the branch.  If the branch insn has
44290075Sobrien@code{INSN_ANNULLED_BRANCH_P} set, this insn will only be executed if
44390075Sobrienthe branch is taken.  For annulled branches with
44490075Sobrien@code{INSN_FROM_TARGET_P} clear, the insn will be executed only if the
44590075Sobrienbranch is not taken.  When @code{INSN_ANNULLED_BRANCH_P} is not set,
44690075Sobrienthis insn will always be executed.  Stored in the @code{in_struct}
44790075Sobrienfield and printed as @samp{/s}.
44890075Sobrien
44990075Sobrien@findex LABEL_OUTSIDE_LOOP_P
45090075Sobrien@cindex @code{label_ref} and @samp{/s}
45190075Sobrien@cindex @code{in_struct}, in @code{label_ref}
45290075Sobrien@item LABEL_OUTSIDE_LOOP_P (@var{x})
45390075SobrienIn @code{label_ref} expressions, nonzero if this is a reference to a
45490075Sobrienlabel that is outside the innermost loop containing the reference to the
45590075Sobrienlabel.  Stored in the @code{in_struct} field and printed as @samp{/s}.
45690075Sobrien
45790075Sobrien@findex LABEL_PRESERVE_P
45890075Sobrien@cindex @code{code_label} and @samp{/i}
459117395Skan@cindex @code{note} and @samp{/i}
460117395Skan@cindex @code{in_struct}, in @code{code_label} and @code{note}
46190075Sobrien@item LABEL_PRESERVE_P (@var{x})
462117395SkanIn a @code{code_label} or @code{note}, indicates that the label is referenced by
46390075Sobriencode or data not visible to the RTL of a given function.
46490075SobrienLabels referenced by a non-local goto will have this bit set.  Stored
46590075Sobrienin the @code{in_struct} field and printed as @samp{/s}.
46690075Sobrien
46790075Sobrien@findex LABEL_REF_NONLOCAL_P
46890075Sobrien@cindex @code{label_ref} and @samp{/v}
469117395Skan@cindex @code{reg_label} and @samp{/v}
470117395Skan@cindex @code{volatil}, in @code{label_ref} and @code{reg_label}
47190075Sobrien@item LABEL_REF_NONLOCAL_P (@var{x})
47290075SobrienIn @code{label_ref} and @code{reg_label} expressions, nonzero if this is
47390075Sobriena reference to a non-local label.
47490075SobrienStored in the @code{volatil} field and printed as @samp{/v}.
47590075Sobrien
47690075Sobrien@findex MEM_IN_STRUCT_P
47790075Sobrien@cindex @code{mem} and @samp{/s}
47890075Sobrien@cindex @code{in_struct}, in @code{mem}
47990075Sobrien@item MEM_IN_STRUCT_P (@var{x})
48090075SobrienIn @code{mem} expressions, nonzero for reference to an entire structure,
48190075Sobrienunion or array, or to a component of one.  Zero for references to a
48290075Sobrienscalar variable or through a pointer to a scalar.  If both this flag and
48390075Sobrien@code{MEM_SCALAR_P} are clear, then we don't know whether this @code{mem}
48490075Sobrienis in a structure or not.  Both flags should never be simultaneously set.
48590075SobrienStored in the @code{in_struct} field and printed as @samp{/s}.
48690075Sobrien
48790075Sobrien@findex MEM_KEEP_ALIAS_SET_P
48890075Sobrien@cindex @code{mem} and @samp{/j}
48990075Sobrien@cindex @code{jump}, in @code{mem}
49090075Sobrien@item MEM_KEEP_ALIAS_SET_P (@var{x})
49190075SobrienIn @code{mem} expressions, 1 if we should keep the alias set for this
49290075Sobrienmem unchanged when we access a component.  Set to 1, for example, when we
49390075Sobrienare already in a non-addressable component of an aggregate.
49490075SobrienStored in the @code{jump} field and printed as @samp{/j}.
49590075Sobrien
49690075Sobrien@findex MEM_SCALAR_P
49790075Sobrien@cindex @code{mem} and @samp{/f}
49890075Sobrien@cindex @code{frame_related}, in @code{mem}
49990075Sobrien@item MEM_SCALAR_P (@var{x})
50090075SobrienIn @code{mem} expressions, nonzero for reference to a scalar known not
50190075Sobriento be a member of a structure, union, or array.  Zero for such
50290075Sobrienreferences and for indirections through pointers, even pointers pointing
50396263Sobriento scalar types.  If both this flag and @code{MEM_IN_STRUCT_P} are clear,
50496263Sobrienthen we don't know whether this @code{mem} is in a structure or not.
50596263SobrienBoth flags should never be simultaneously set.
50690075SobrienStored in the @code{frame_related} field and printed as @samp{/f}.
50790075Sobrien
50890075Sobrien@findex MEM_VOLATILE_P
50990075Sobrien@cindex @code{mem} and @samp{/v}
510117395Skan@cindex @code{asm_input} and @samp{/v}
511117395Skan@cindex @code{asm_operands} and @samp{/v}
512117395Skan@cindex @code{volatil}, in @code{mem}, @code{asm_operands}, and @code{asm_input}
51390075Sobrien@item MEM_VOLATILE_P (@var{x})
514117395SkanIn @code{mem}, @code{asm_operands}, and @code{asm_input} expressions,
515117395Skannonzero for volatile memory references.
51690075SobrienStored in the @code{volatil} field and printed as @samp{/v}.
51790075Sobrien
51890075Sobrien@findex REG_FUNCTION_VALUE_P
51990075Sobrien@cindex @code{reg} and @samp{/i}
52090075Sobrien@cindex @code{integrated}, in @code{reg}
52190075Sobrien@item REG_FUNCTION_VALUE_P (@var{x})
52290075SobrienNonzero in a @code{reg} if it is the place in which this function's
52390075Sobrienvalue is going to be returned.  (This happens only in a hard
52490075Sobrienregister.)  Stored in the @code{integrated} field and printed as
52590075Sobrien@samp{/i}.
52690075Sobrien
52790075Sobrien@findex REG_LOOP_TEST_P
52890075Sobrien@cindex @code{reg} and @samp{/s}
52990075Sobrien@cindex @code{in_struct}, in @code{reg}
53090075Sobrien@item REG_LOOP_TEST_P (@var{x})
53190075SobrienIn @code{reg} expressions, nonzero if this register's entire life is
53290075Sobriencontained in the exit test code for some loop.  Stored in the
53390075Sobrien@code{in_struct} field and printed as @samp{/s}.
53490075Sobrien
53590075Sobrien@findex REG_POINTER
53690075Sobrien@cindex @code{reg} and @samp{/f}
53790075Sobrien@cindex @code{frame_related}, in @code{reg}
53890075Sobrien@item REG_POINTER (@var{x})
53990075SobrienNonzero in a @code{reg} if the register holds a pointer.  Stored in the
54090075Sobrien@code{frame_related} field and printed as @samp{/f}.
54190075Sobrien
54290075Sobrien@findex REG_USERVAR_P
54390075Sobrien@cindex @code{reg} and @samp{/v}
54490075Sobrien@cindex @code{volatil}, in @code{reg}
54590075Sobrien@item REG_USERVAR_P (@var{x})
54690075SobrienIn a @code{reg}, nonzero if it corresponds to a variable present in
54790075Sobrienthe user's source code.  Zero for temporaries generated internally by
54890075Sobrienthe compiler.  Stored in the @code{volatil} field and printed as
54990075Sobrien@samp{/v}.
55090075Sobrien
55190075SobrienThe same hard register may be used also for collecting the values of
55290075Sobrienfunctions called by this one, but @code{REG_FUNCTION_VALUE_P} is zero
55390075Sobrienin this kind of use.
55490075Sobrien
55590075Sobrien@findex RTX_FRAME_RELATED_P
55690075Sobrien@cindex @code{insn} and @samp{/f}
557117395Skan@cindex @code{call_insn} and @samp{/f}
558117395Skan@cindex @code{jump_insn} and @samp{/f}
559117395Skan@cindex @code{barrier} and @samp{/f}
560117395Skan@cindex @code{set} and @samp{/f}
561117395Skan@cindex @code{frame_related}, in @code{insn}, @code{call_insn}, @code{jump_insn}, @code{barrier}, and @code{set}
56290075Sobrien@item RTX_FRAME_RELATED_P (@var{x})
563117395SkanNonzero in an @code{insn}, @code{call_insn}, @code{jump_insn},
564117395Skan@code{barrier}, or @code{set} which is part of a function prologue
56590075Sobrienand sets the stack pointer, sets the frame pointer, or saves a register.
56690075SobrienThis flag should also be set on an instruction that sets up a temporary
56790075Sobrienregister to use in place of the frame pointer.
56890075SobrienStored in the @code{frame_related} field and printed as @samp{/f}.
56990075Sobrien
57090075SobrienIn particular, on RISC targets where there are limits on the sizes of
57190075Sobrienimmediate constants, it is sometimes impossible to reach the register
57290075Sobriensave area directly from the stack pointer.  In that case, a temporary
57390075Sobrienregister is used that is near enough to the register save area, and the
57490075SobrienCanonical Frame Address, i.e., DWARF2's logical frame pointer, register
57590075Sobrienmust (temporarily) be changed to be this temporary register.  So, the
57690075Sobrieninstruction that sets this temporary register must be marked as
57790075Sobrien@code{RTX_FRAME_RELATED_P}.
57890075Sobrien
57990075SobrienIf the marked instruction is overly complex (defined in terms of what
58090075Sobrien@code{dwarf2out_frame_debug_expr} can handle), you will also have to
58190075Sobriencreate a @code{REG_FRAME_RELATED_EXPR} note and attach it to the
58290075Sobrieninstruction.  This note should contain a simple expression of the
58390075Sobriencomputation performed by this instruction, i.e., one that
58490075Sobrien@code{dwarf2out_frame_debug_expr} can handle.
58590075Sobrien
58690075SobrienThis flag is required for exception handling support on targets with RTL
58790075Sobrienprologues.
58890075Sobrien
58990075Sobrien@findex RTX_INTEGRATED_P
59090075Sobrien@cindex @code{insn} and @samp{/i}
591117395Skan@cindex @code{call_insn} and @samp{/i}
592117395Skan@cindex @code{jump_insn} and @samp{/i}
593117395Skan@cindex @code{barrier} and @samp{/i}
594117395Skan@cindex @code{code_label} and @samp{/i}
595117395Skan@cindex @code{insn_list} and @samp{/i}
596117395Skan@cindex @code{const} and @samp{/i}
597117395Skan@cindex @code{note} and @samp{/i}
598117395Skan@cindex @code{integrated}, in @code{insn}, @code{call_insn}, @code{jump_insn}, @code{barrier}, @code{code_label}, @code{insn_list}, @code{const}, and @code{note}
59990075Sobrien@item RTX_INTEGRATED_P (@var{x})
600117395SkanNonzero in an @code{insn}, @code{call_insn}, @code{jump_insn}, @code{barrier},
601117395Skan@code{code_label}, @code{insn_list}, @code{const}, or @code{note} if it
60290075Sobrienresulted from an in-line function call.
60390075SobrienStored in the @code{integrated} field and printed as @samp{/i}.
60490075Sobrien
60590075Sobrien@findex RTX_UNCHANGING_P
60690075Sobrien@cindex @code{reg} and @samp{/u}
60790075Sobrien@cindex @code{mem} and @samp{/u}
608117395Skan@cindex @code{concat} and @samp{/u}
60990075Sobrien@cindex @code{unchanging}, in @code{reg} and @code{mem}
61090075Sobrien@item RTX_UNCHANGING_P (@var{x})
611119256SkanNonzero in a @code{reg}, @code{mem}, or @code{concat} if the register or
612119256Skanmemory is set at most once, anywhere.  This does not mean that it is
613119256Skanfunction invariant.
614119256Skan
615119256SkanGCC uses this flag to determine whether two references conflict.  As
616119256Skanimplemented by @code{true_dependence} in @file{alias.c} for memory
617119256Skanreferences, unchanging memory can't conflict with non-unchanging memory;
618119256Skana non-unchanging read can conflict with a non-unchanging write; an
619119256Skanunchanging read can conflict with an unchanging write (since there may
620119256Skanbe a single store to this address to initialize it); and an unchanging
621119256Skanstore can conflict with a non-unchanging read.  This means we must make
622119256Skanconservative assumptions when choosing the value of this flag for a
623119256Skanmemory reference to an object containing both unchanging and
624119256Skannon-unchanging fields: we must set the flag when writing to the object
625119256Skanand clear it when reading from the object.
626119256Skan
62790075SobrienStored in the @code{unchanging} field and printed as @samp{/u}.
62890075Sobrien
62990075Sobrien@findex SCHED_GROUP_P
630117395Skan@cindex @code{insn} and @samp{/s}
631117395Skan@cindex @code{call_insn} and @samp{/s}
632117395Skan@cindex @code{jump_insn} and @samp{/s}
633117395Skan@cindex @code{in_struct}, in @code{insn}, @code{jump_insn} and @code{call_insn}
63490075Sobrien@item SCHED_GROUP_P (@var{x})
635117395SkanDuring instruction scheduling, in an @code{insn}, @code{call_insn} or
636117395Skan@code{jump_insn}, indicates that the
63790075Sobrienprevious insn must be scheduled together with this insn.  This is used to
63890075Sobrienensure that certain groups of instructions will not be split up by the
63990075Sobrieninstruction scheduling pass, for example, @code{use} insns before
64090075Sobriena @code{call_insn} may not be separated from the @code{call_insn}.
64190075SobrienStored in the @code{in_struct} field and printed as @samp{/s}.
64290075Sobrien
64390075Sobrien@findex SET_IS_RETURN_P
64490075Sobrien@cindex @code{insn} and @samp{/j}
64590075Sobrien@cindex @code{jump}, in @code{insn}
64690075Sobrien@item SET_IS_RETURN_P (@var{x})
64790075SobrienFor a @code{set}, nonzero if it is for a return.
64890075SobrienStored in the @code{jump} field and printed as @samp{/j}.
64990075Sobrien
65090075Sobrien@findex SIBLING_CALL_P
65190075Sobrien@cindex @code{call_insn} and @samp{/j}
65290075Sobrien@cindex @code{jump}, in @code{call_insn}
65390075Sobrien@item SIBLING_CALL_P (@var{x})
65490075SobrienFor a @code{call_insn}, nonzero if the insn is a sibling call.
65590075SobrienStored in the @code{jump} field and printed as @samp{/j}.
65690075Sobrien
65790075Sobrien@findex STRING_POOL_ADDRESS_P
65890075Sobrien@cindex @code{symbol_ref} and @samp{/f}
65990075Sobrien@cindex @code{frame_related}, in @code{symbol_ref}
66090075Sobrien@item STRING_POOL_ADDRESS_P (@var{x})
66190075SobrienFor a @code{symbol_ref} expression, nonzero if it addresses this function's
66290075Sobrienstring constant pool.
66390075SobrienStored in the @code{frame_related} field and printed as @samp{/f}.
66490075Sobrien
66590075Sobrien@findex SUBREG_PROMOTED_UNSIGNED_P
666117395Skan@cindex @code{subreg} and @samp{/u} and @samp{/v}
66790075Sobrien@cindex @code{unchanging}, in @code{subreg}
668117395Skan@cindex @code{volatil}, in @code{subreg}
66990075Sobrien@item SUBREG_PROMOTED_UNSIGNED_P (@var{x})
670117395SkanReturns a value greater then zero for a @code{subreg} that has
671117395Skan@code{SUBREG_PROMOTED_VAR_P} nonzero if the object being referenced is kept
672117395Skanzero-extended, zero if it is kept sign-extended, and less then zero if it is
673117395Skanextended some other way via the @code{ptr_extend} instruction.
674117395SkanStored in the @code{unchanging}
675117395Skanfield and @code{volatil} field, printed as @samp{/u} and @samp{/v}.
676117395SkanThis macro may only be used to get the value it may not be used to change
677117395Skanthe value.  Use @code{SUBREG_PROMOTED_UNSIGNED_SET} to change the value.
67890075Sobrien
679117395Skan@findex SUBREG_PROMOTED_UNSIGNED_SET
680117395Skan@cindex @code{subreg} and @samp{/u}
681117395Skan@cindex @code{unchanging}, in @code{subreg}
682117395Skan@cindex @code{volatil}, in @code{subreg}
683117395Skan@item SUBREG_PROMOTED_UNSIGNED_SET (@var{x})
684117395SkanSet the @code{unchanging} and @code{volatil} fields in a @code{subreg}
685117395Skanto reflect zero, sign, or other extension.  If @code{volatil} is
686117395Skanzero, then @code{unchanging} as nonzero means zero extension and as
687117395Skanzero means sign extension. If @code{volatil} is nonzero then some
688117395Skanother type of extension was done via the @code{ptr_extend} instruction.
689117395Skan
69090075Sobrien@findex SUBREG_PROMOTED_VAR_P
69190075Sobrien@cindex @code{subreg} and @samp{/s}
69290075Sobrien@cindex @code{in_struct}, in @code{subreg}
69390075Sobrien@item SUBREG_PROMOTED_VAR_P (@var{x})
69490075SobrienNonzero in a @code{subreg} if it was made when accessing an object that
69590075Sobrienwas promoted to a wider mode in accord with the @code{PROMOTED_MODE} machine
69690075Sobriendescription macro (@pxref{Storage Layout}).  In this case, the mode of
69790075Sobrienthe @code{subreg} is the declared mode of the object and the mode of
69890075Sobrien@code{SUBREG_REG} is the mode of the register that holds the object.
69990075SobrienPromoted variables are always either sign- or zero-extended to the wider
70090075Sobrienmode on every assignment.  Stored in the @code{in_struct} field and
70190075Sobrienprinted as @samp{/s}.
70290075Sobrien
70390075Sobrien@findex SYMBOL_REF_USED
70490075Sobrien@cindex @code{used}, in @code{symbol_ref}
70590075Sobrien@item SYMBOL_REF_USED (@var{x})
70690075SobrienIn a @code{symbol_ref}, indicates that @var{x} has been used.  This is
70790075Sobriennormally only used to ensure that @var{x} is only declared external
70890075Sobrienonce.  Stored in the @code{used} field.
70990075Sobrien
71090075Sobrien@findex SYMBOL_REF_WEAK
71190075Sobrien@cindex @code{symbol_ref} and @samp{/i}
71290075Sobrien@cindex @code{integrated}, in @code{symbol_ref}
71390075Sobrien@item SYMBOL_REF_WEAK (@var{x})
71490075SobrienIn a @code{symbol_ref}, indicates that @var{x} has been declared weak.
71590075SobrienStored in the @code{integrated} field and printed as @samp{/i}.
716119256Skan
717119256Skan@findex SYMBOL_REF_FLAG
718119256Skan@cindex @code{symbol_ref} and @samp{/v}
719119256Skan@cindex @code{volatil}, in @code{symbol_ref}
720119256Skan@item SYMBOL_REF_FLAG (@var{x})
721119256SkanIn a @code{symbol_ref}, this is used as a flag for machine-specific purposes.
722119256SkanStored in the @code{volatil} field and printed as @samp{/v}.
723119256Skan
724119256SkanMost uses of @code{SYMBOL_REF_FLAG} are historic and may be subsumed
725119256Skanby @code{SYMBOL_REF_FLAGS}.  Certainly use of @code{SYMBOL_REF_FLAGS}
726119256Skanis mandatory if the target requires more than one bit of storage.
72790075Sobrien@end table
72890075Sobrien
72990075SobrienThese are the fields to which the above macros refer:
73090075Sobrien
73190075Sobrien@table @code
73290075Sobrien@findex call
73390075Sobrien@cindex @samp{/c} in RTL dump
73490075Sobrien@item call
735117395SkanThis flag is currently unused.
73690075Sobrien
73790075SobrienIn an RTL dump, this flag is represented as @samp{/c}.
73890075Sobrien
73990075Sobrien@findex frame_related
74090075Sobrien@cindex @samp{/f} in RTL dump
74190075Sobrien@item frame_related
74290075SobrienIn an @code{insn} or @code{set} expression, 1 means that it is part of
74390075Sobriena function prologue and sets the stack pointer, sets the frame pointer,
74490075Sobriensaves a register, or sets up a temporary register to use in place of the
74590075Sobrienframe pointer.
74690075Sobrien
74790075SobrienIn @code{reg} expressions, 1 means that the register holds a pointer.
74890075Sobrien
74990075SobrienIn @code{symbol_ref} expressions, 1 means that the reference addresses
75090075Sobrienthis function's string constant pool.
75190075Sobrien
75290075SobrienIn @code{mem} expressions, 1 means that the reference is to a scalar.
75390075Sobrien
75490075SobrienIn an RTL dump, this flag is represented as @samp{/f}.
75590075Sobrien
75690075Sobrien@findex in_struct
75790075Sobrien@cindex @samp{/s} in RTL dump
75890075Sobrien@item in_struct
75990075SobrienIn @code{mem} expressions, it is 1 if the memory datum referred to is
76090075Sobrienall or part of a structure or array; 0 if it is (or might be) a scalar
76190075Sobrienvariable.  A reference through a C pointer has 0 because the pointer
76290075Sobrienmight point to a scalar variable.  This information allows the compiler
76390075Sobriento determine something about possible cases of aliasing.
76490075Sobrien
76590075SobrienIn @code{reg} expressions, it is 1 if the register has its entire life
76690075Sobriencontained within the test expression of some loop.
76790075Sobrien
76890075SobrienIn @code{subreg} expressions, 1 means that the @code{subreg} is accessing
76990075Sobrienan object that has had its mode promoted from a wider mode.
77090075Sobrien
77190075SobrienIn @code{label_ref} expressions, 1 means that the referenced label is
77290075Sobrienoutside the innermost loop containing the insn in which the @code{label_ref}
77390075Sobrienwas found.
77490075Sobrien
77590075SobrienIn @code{code_label} expressions, it is 1 if the label may never be deleted.
77690075SobrienThis is used for labels which are the target of non-local gotos.  Such a
77790075Sobrienlabel that would have been deleted is replaced with a @code{note} of type
77890075Sobrien@code{NOTE_INSN_DELETED_LABEL}.
77990075Sobrien
78090075SobrienIn an @code{insn} during dead-code elimination, 1 means that the insn is
78190075Sobriendead code.
78290075Sobrien
783117395SkanIn an @code{insn} or @code{jump_insn} during reorg for an insn in the
784117395Skandelay slot of a branch,
78590075Sobrien1 means that this insn is from the target of the branch.
78690075Sobrien
78790075SobrienIn an @code{insn} during instruction scheduling, 1 means that this insn
78890075Sobrienmust be scheduled as part of a group together with the previous insn.
78990075Sobrien
79090075SobrienIn an RTL dump, this flag is represented as @samp{/s}.
79190075Sobrien
79290075Sobrien@findex integrated
79390075Sobrien@cindex @samp{/i} in RTL dump
79490075Sobrien@item integrated
79590075SobrienIn an @code{insn}, @code{insn_list}, or @code{const}, 1 means the RTL was
79690075Sobrienproduced by procedure integration.
79790075Sobrien
79890075SobrienIn @code{reg} expressions, 1 means the register contains
79990075Sobrienthe value to be returned by the current function.  On
80090075Sobrienmachines that pass parameters in registers, the same register number
80190075Sobrienmay be used for parameters as well, but this flag is not set on such
80290075Sobrienuses.
80390075Sobrien
80490075SobrienIn @code{symbol_ref} expressions, 1 means the referenced symbol is weak.
80590075Sobrien
80690075SobrienIn an RTL dump, this flag is represented as @samp{/i}.
80790075Sobrien
80890075Sobrien@findex jump
80990075Sobrien@cindex @samp{/j} in RTL dump
81090075Sobrien@item jump
81190075SobrienIn a @code{mem} expression, 1 means we should keep the alias set for this
81290075Sobrienmem unchanged when we access a component.
81390075Sobrien
81490075SobrienIn a @code{set}, 1 means it is for a return.
81590075Sobrien
81690075SobrienIn a @code{call_insn}, 1 means it is a sibling call.
81790075Sobrien
81890075SobrienIn an RTL dump, this flag is represented as @samp{/j}.
81990075Sobrien
82090075Sobrien@findex unchanging
82190075Sobrien@cindex @samp{/u} in RTL dump
82290075Sobrien@item unchanging
82390075SobrienIn @code{reg} and @code{mem} expressions, 1 means
82490075Sobrienthat the value of the expression never changes.
82590075Sobrien
82690075SobrienIn @code{subreg} expressions, it is 1 if the @code{subreg} references an
82790075Sobrienunsigned object whose mode has been promoted to a wider mode.
82890075Sobrien
829117395SkanIn an @code{insn} or @code{jump_insn} in the delay slot of a branch
830117395Skaninstruction, 1 means an annulling branch should be used.
83190075Sobrien
83290075SobrienIn a @code{symbol_ref} expression, 1 means that this symbol addresses
83390075Sobriensomething in the per-function constant pool.
83490075Sobrien
83590075SobrienIn a @code{call_insn}, @code{note}, or an @code{expr_list} of notes,
83690075Sobrien1 means that this instruction is a call to a const or pure function.
83790075Sobrien
83890075SobrienIn an RTL dump, this flag is represented as @samp{/u}.
83990075Sobrien
84090075Sobrien@findex used
84190075Sobrien@item used
84290075SobrienThis flag is used directly (without an access macro) at the end of RTL
84390075Sobriengeneration for a function, to count the number of times an expression
84490075Sobrienappears in insns.  Expressions that appear more than once are copied,
84590075Sobrienaccording to the rules for shared structure (@pxref{Sharing}).
84690075Sobrien
84790075SobrienFor a @code{reg}, it is used directly (without an access macro) by the
84890075Sobrienleaf register renumbering code to ensure that each register is only
84990075Sobrienrenumbered once.
85090075Sobrien
85190075SobrienIn a @code{symbol_ref}, it indicates that an external declaration for
85290075Sobrienthe symbol has already been written.
85390075Sobrien
85490075Sobrien@findex volatil
85590075Sobrien@cindex @samp{/v} in RTL dump
85690075Sobrien@item volatil
85790075Sobrien@cindex volatile memory references
858117395SkanIn a @code{mem}, @code{asm_operands}, or @code{asm_input}
859117395Skanexpression, it is 1 if the memory
86090075Sobrienreference is volatile.  Volatile memory references may not be deleted,
86190075Sobrienreordered or combined.
86290075Sobrien
86390075SobrienIn a @code{symbol_ref} expression, it is used for machine-specific
86490075Sobrienpurposes.
86590075Sobrien
86690075SobrienIn a @code{reg} expression, it is 1 if the value is a user-level variable.
86790075Sobrien0 indicates an internal compiler temporary.
86890075Sobrien
86990075SobrienIn an @code{insn}, 1 means the insn has been deleted.
87090075Sobrien
87190075SobrienIn @code{label_ref} and @code{reg_label} expressions, 1 means a reference
87290075Sobriento a non-local label.
87390075Sobrien
87490075SobrienIn an RTL dump, this flag is represented as @samp{/v}.
87590075Sobrien@end table
87690075Sobrien
87790075Sobrien@node Machine Modes
87890075Sobrien@section Machine Modes
87990075Sobrien@cindex machine modes
88090075Sobrien
88190075Sobrien@findex enum machine_mode
88290075SobrienA machine mode describes a size of data object and the representation used
88390075Sobrienfor it.  In the C code, machine modes are represented by an enumeration
88490075Sobrientype, @code{enum machine_mode}, defined in @file{machmode.def}.  Each RTL
88590075Sobrienexpression has room for a machine mode and so do certain kinds of tree
88690075Sobrienexpressions (declarations and types, to be precise).
88790075Sobrien
88890075SobrienIn debugging dumps and machine descriptions, the machine mode of an RTL
88990075Sobrienexpression is written after the expression code with a colon to separate
89090075Sobrienthem.  The letters @samp{mode} which appear at the end of each machine mode
89190075Sobrienname are omitted.  For example, @code{(reg:SI 38)} is a @code{reg}
89290075Sobrienexpression with machine mode @code{SImode}.  If the mode is
89390075Sobrien@code{VOIDmode}, it is not written at all.
89490075Sobrien
89590075SobrienHere is a table of machine modes.  The term ``byte'' below refers to an
89690075Sobrienobject of @code{BITS_PER_UNIT} bits (@pxref{Storage Layout}).
89790075Sobrien
89890075Sobrien@table @code
89990075Sobrien@findex BImode
90090075Sobrien@item BImode
90190075Sobrien``Bit'' mode represents a single bit, for predicate registers.
90290075Sobrien
90390075Sobrien@findex QImode
90490075Sobrien@item QImode
90590075Sobrien``Quarter-Integer'' mode represents a single byte treated as an integer.
90690075Sobrien
90790075Sobrien@findex HImode
90890075Sobrien@item HImode
90990075Sobrien``Half-Integer'' mode represents a two-byte integer.
91090075Sobrien
91190075Sobrien@findex PSImode
91290075Sobrien@item PSImode
91390075Sobrien``Partial Single Integer'' mode represents an integer which occupies
91490075Sobrienfour bytes but which doesn't really use all four.  On some machines,
91590075Sobrienthis is the right mode to use for pointers.
91690075Sobrien
91790075Sobrien@findex SImode
91890075Sobrien@item SImode
91990075Sobrien``Single Integer'' mode represents a four-byte integer.
92090075Sobrien
92190075Sobrien@findex PDImode
92290075Sobrien@item PDImode
92390075Sobrien``Partial Double Integer'' mode represents an integer which occupies
92490075Sobrieneight bytes but which doesn't really use all eight.  On some machines,
92590075Sobrienthis is the right mode to use for certain pointers.
92690075Sobrien
92790075Sobrien@findex DImode
92890075Sobrien@item DImode
92990075Sobrien``Double Integer'' mode represents an eight-byte integer.
93090075Sobrien
93190075Sobrien@findex TImode
93290075Sobrien@item TImode
93390075Sobrien``Tetra Integer'' (?) mode represents a sixteen-byte integer.
93490075Sobrien
93590075Sobrien@findex OImode
93690075Sobrien@item OImode
93790075Sobrien``Octa Integer'' (?) mode represents a thirty-two-byte integer.
93890075Sobrien
93990075Sobrien@findex QFmode
94090075Sobrien@item QFmode
94190075Sobrien``Quarter-Floating'' mode represents a quarter-precision (single byte)
94290075Sobrienfloating point number.
94390075Sobrien
94490075Sobrien@findex HFmode
94590075Sobrien@item HFmode
94690075Sobrien``Half-Floating'' mode represents a half-precision (two byte) floating
94790075Sobrienpoint number.
94890075Sobrien
94990075Sobrien@findex TQFmode
95090075Sobrien@item TQFmode
95190075Sobrien``Three-Quarter-Floating'' (?) mode represents a three-quarter-precision
95290075Sobrien(three byte) floating point number.
95390075Sobrien
95490075Sobrien@findex SFmode
95590075Sobrien@item SFmode
95690075Sobrien``Single Floating'' mode represents a four byte floating point number.
95790075SobrienIn the common case, of a processor with IEEE arithmetic and 8-bit bytes,
95890075Sobrienthis is a single-precision IEEE floating point number; it can also be
95990075Sobrienused for double-precision (on processors with 16-bit bytes) and
96090075Sobriensingle-precision VAX and IBM types.
96190075Sobrien
96290075Sobrien@findex DFmode
96390075Sobrien@item DFmode
96490075Sobrien``Double Floating'' mode represents an eight byte floating point number.
96590075SobrienIn the common case, of a processor with IEEE arithmetic and 8-bit bytes,
96690075Sobrienthis is a double-precision IEEE floating point number.
96790075Sobrien
96890075Sobrien@findex XFmode
96990075Sobrien@item XFmode
97090075Sobrien``Extended Floating'' mode represents a twelve byte floating point
97190075Sobriennumber.  This mode is used for IEEE extended floating point.  On some
97290075Sobriensystems not all bits within these bytes will actually be used.
97390075Sobrien
97490075Sobrien@findex TFmode
97590075Sobrien@item TFmode
97690075Sobrien``Tetra Floating'' mode represents a sixteen byte floating point number.
97790075SobrienThis gets used for both the 96-bit extended IEEE floating-point types
97890075Sobrienpadded to 128 bits, and true 128-bit extended IEEE floating-point types.
97990075Sobrien
98090075Sobrien@findex CCmode
98190075Sobrien@item CCmode
98290075Sobrien``Condition Code'' mode represents the value of a condition code, which
98390075Sobrienis a machine-specific set of bits used to represent the result of a
98490075Sobriencomparison operation.  Other machine-specific modes may also be used for
98590075Sobrienthe condition code.  These modes are not used on machines that use
98690075Sobrien@code{cc0} (see @pxref{Condition Code}).
98790075Sobrien
98890075Sobrien@findex BLKmode
98990075Sobrien@item BLKmode
99090075Sobrien``Block'' mode represents values that are aggregates to which none of
99190075Sobrienthe other modes apply.  In RTL, only memory references can have this mode,
99290075Sobrienand only if they appear in string-move or vector instructions.  On machines
99390075Sobrienwhich have no such instructions, @code{BLKmode} will not appear in RTL@.
99490075Sobrien
99590075Sobrien@findex VOIDmode
99690075Sobrien@item VOIDmode
99790075SobrienVoid mode means the absence of a mode or an unspecified mode.
99890075SobrienFor example, RTL expressions of code @code{const_int} have mode
99990075Sobrien@code{VOIDmode} because they can be taken to have whatever mode the context
100090075Sobrienrequires.  In debugging dumps of RTL, @code{VOIDmode} is expressed by
100190075Sobrienthe absence of any mode.
100290075Sobrien
100390075Sobrien@findex QCmode
100490075Sobrien@findex HCmode
100590075Sobrien@findex SCmode
100690075Sobrien@findex DCmode
100790075Sobrien@findex XCmode
100890075Sobrien@findex TCmode
100990075Sobrien@item QCmode, HCmode, SCmode, DCmode, XCmode, TCmode
101090075SobrienThese modes stand for a complex number represented as a pair of floating
101190075Sobrienpoint values.  The floating point values are in @code{QFmode},
101290075Sobrien@code{HFmode}, @code{SFmode}, @code{DFmode}, @code{XFmode}, and
101390075Sobrien@code{TFmode}, respectively.
101490075Sobrien
101590075Sobrien@findex CQImode
101690075Sobrien@findex CHImode
101790075Sobrien@findex CSImode
101890075Sobrien@findex CDImode
101990075Sobrien@findex CTImode
102090075Sobrien@findex COImode
102190075Sobrien@item CQImode, CHImode, CSImode, CDImode, CTImode, COImode
102290075SobrienThese modes stand for a complex number represented as a pair of integer
102390075Sobrienvalues.  The integer values are in @code{QImode}, @code{HImode},
102490075Sobrien@code{SImode}, @code{DImode}, @code{TImode}, and @code{OImode},
102590075Sobrienrespectively.
102690075Sobrien@end table
102790075Sobrien
102890075SobrienThe machine description defines @code{Pmode} as a C macro which expands
102990075Sobrieninto the machine mode used for addresses.  Normally this is the mode
103090075Sobrienwhose size is @code{BITS_PER_WORD}, @code{SImode} on 32-bit machines.
103190075Sobrien
103290075SobrienThe only modes which a machine description @i{must} support are
103390075Sobrien@code{QImode}, and the modes corresponding to @code{BITS_PER_WORD},
103490075Sobrien@code{FLOAT_TYPE_SIZE} and @code{DOUBLE_TYPE_SIZE}.
103590075SobrienThe compiler will attempt to use @code{DImode} for 8-byte structures and
103690075Sobrienunions, but this can be prevented by overriding the definition of
103790075Sobrien@code{MAX_FIXED_MODE_SIZE}.  Alternatively, you can have the compiler
103890075Sobrienuse @code{TImode} for 16-byte structures and unions.  Likewise, you can
103990075Sobrienarrange for the C type @code{short int} to avoid using @code{HImode}.
104090075Sobrien
104190075Sobrien@cindex mode classes
104290075SobrienVery few explicit references to machine modes remain in the compiler and
104390075Sobrienthese few references will soon be removed.  Instead, the machine modes
104490075Sobrienare divided into mode classes.  These are represented by the enumeration
104590075Sobrientype @code{enum mode_class} defined in @file{machmode.h}.  The possible
104690075Sobrienmode classes are:
104790075Sobrien
104890075Sobrien@table @code
104990075Sobrien@findex MODE_INT
105090075Sobrien@item MODE_INT
105190075SobrienInteger modes.  By default these are @code{BImode}, @code{QImode},
105290075Sobrien@code{HImode}, @code{SImode}, @code{DImode}, @code{TImode}, and
105390075Sobrien@code{OImode}.
105490075Sobrien
105590075Sobrien@findex MODE_PARTIAL_INT
105690075Sobrien@item MODE_PARTIAL_INT
105790075SobrienThe ``partial integer'' modes, @code{PQImode}, @code{PHImode},
105890075Sobrien@code{PSImode} and @code{PDImode}.
105990075Sobrien
106090075Sobrien@findex MODE_FLOAT
106190075Sobrien@item MODE_FLOAT
106290075SobrienFloating point modes.  By default these are @code{QFmode},
106390075Sobrien@code{HFmode}, @code{TQFmode}, @code{SFmode}, @code{DFmode},
106490075Sobrien@code{XFmode} and @code{TFmode}.
106590075Sobrien
106690075Sobrien@findex MODE_COMPLEX_INT
106790075Sobrien@item MODE_COMPLEX_INT
106890075SobrienComplex integer modes.  (These are not currently implemented).
106990075Sobrien
107090075Sobrien@findex MODE_COMPLEX_FLOAT
107190075Sobrien@item MODE_COMPLEX_FLOAT
107290075SobrienComplex floating point modes.  By default these are @code{QCmode},
107390075Sobrien@code{HCmode}, @code{SCmode}, @code{DCmode}, @code{XCmode}, and
107490075Sobrien@code{TCmode}.
107590075Sobrien
107690075Sobrien@findex MODE_FUNCTION
107790075Sobrien@item MODE_FUNCTION
107890075SobrienAlgol or Pascal function variables including a static chain.
107990075Sobrien(These are not currently implemented).
108090075Sobrien
108190075Sobrien@findex MODE_CC
108290075Sobrien@item MODE_CC
108390075SobrienModes representing condition code values.  These are @code{CCmode} plus
108490075Sobrienany modes listed in the @code{EXTRA_CC_MODES} macro.  @xref{Jump Patterns},
108590075Sobrienalso see @ref{Condition Code}.
108690075Sobrien
108790075Sobrien@findex MODE_RANDOM
108890075Sobrien@item MODE_RANDOM
108990075SobrienThis is a catchall mode class for modes which don't fit into the above
109090075Sobrienclasses.  Currently @code{VOIDmode} and @code{BLKmode} are in
109190075Sobrien@code{MODE_RANDOM}.
109290075Sobrien@end table
109390075Sobrien
109490075SobrienHere are some C macros that relate to machine modes:
109590075Sobrien
109690075Sobrien@table @code
109790075Sobrien@findex GET_MODE
109890075Sobrien@item GET_MODE (@var{x})
109990075SobrienReturns the machine mode of the RTX @var{x}.
110090075Sobrien
110190075Sobrien@findex PUT_MODE
110290075Sobrien@item PUT_MODE (@var{x}, @var{newmode})
110390075SobrienAlters the machine mode of the RTX @var{x} to be @var{newmode}.
110490075Sobrien
110590075Sobrien@findex NUM_MACHINE_MODES
110690075Sobrien@item NUM_MACHINE_MODES
110790075SobrienStands for the number of machine modes available on the target
110890075Sobrienmachine.  This is one greater than the largest numeric value of any
110990075Sobrienmachine mode.
111090075Sobrien
111190075Sobrien@findex GET_MODE_NAME
111290075Sobrien@item GET_MODE_NAME (@var{m})
111390075SobrienReturns the name of mode @var{m} as a string.
111490075Sobrien
111590075Sobrien@findex GET_MODE_CLASS
111690075Sobrien@item GET_MODE_CLASS (@var{m})
111790075SobrienReturns the mode class of mode @var{m}.
111890075Sobrien
111990075Sobrien@findex GET_MODE_WIDER_MODE
112090075Sobrien@item GET_MODE_WIDER_MODE (@var{m})
112190075SobrienReturns the next wider natural mode.  For example, the expression
112290075Sobrien@code{GET_MODE_WIDER_MODE (QImode)} returns @code{HImode}.
112390075Sobrien
112490075Sobrien@findex GET_MODE_SIZE
112590075Sobrien@item GET_MODE_SIZE (@var{m})
112690075SobrienReturns the size in bytes of a datum of mode @var{m}.
112790075Sobrien
112890075Sobrien@findex GET_MODE_BITSIZE
112990075Sobrien@item GET_MODE_BITSIZE (@var{m})
113090075SobrienReturns the size in bits of a datum of mode @var{m}.
113190075Sobrien
113290075Sobrien@findex GET_MODE_MASK
113390075Sobrien@item GET_MODE_MASK (@var{m})
113490075SobrienReturns a bitmask containing 1 for all bits in a word that fit within
113590075Sobrienmode @var{m}.  This macro can only be used for modes whose bitsize is
113690075Sobrienless than or equal to @code{HOST_BITS_PER_INT}.
113790075Sobrien
113890075Sobrien@findex GET_MODE_ALIGNMENT
113990075Sobrien@item GET_MODE_ALIGNMENT (@var{m})
114090075SobrienReturn the required alignment, in bits, for an object of mode @var{m}.
114190075Sobrien
114290075Sobrien@findex GET_MODE_UNIT_SIZE
114390075Sobrien@item GET_MODE_UNIT_SIZE (@var{m})
114490075SobrienReturns the size in bytes of the subunits of a datum of mode @var{m}.
114590075SobrienThis is the same as @code{GET_MODE_SIZE} except in the case of complex
114690075Sobrienmodes.  For them, the unit size is the size of the real or imaginary
114790075Sobrienpart.
114890075Sobrien
114990075Sobrien@findex GET_MODE_NUNITS
115090075Sobrien@item GET_MODE_NUNITS (@var{m})
115190075SobrienReturns the number of units contained in a mode, i.e.,
115290075Sobrien@code{GET_MODE_SIZE} divided by @code{GET_MODE_UNIT_SIZE}.
115390075Sobrien
115490075Sobrien@findex GET_CLASS_NARROWEST_MODE
115590075Sobrien@item GET_CLASS_NARROWEST_MODE (@var{c})
115690075SobrienReturns the narrowest mode in mode class @var{c}.
115790075Sobrien@end table
115890075Sobrien
115990075Sobrien@findex byte_mode
116090075Sobrien@findex word_mode
116190075SobrienThe global variables @code{byte_mode} and @code{word_mode} contain modes
116290075Sobrienwhose classes are @code{MODE_INT} and whose bitsizes are either
116390075Sobrien@code{BITS_PER_UNIT} or @code{BITS_PER_WORD}, respectively.  On 32-bit
116490075Sobrienmachines, these are @code{QImode} and @code{SImode}, respectively.
116590075Sobrien
116690075Sobrien@node Constants
116790075Sobrien@section Constant Expression Types
116890075Sobrien@cindex RTL constants
116990075Sobrien@cindex RTL constant expression types
117090075Sobrien
117190075SobrienThe simplest RTL expressions are those that represent constant values.
117290075Sobrien
117390075Sobrien@table @code
117490075Sobrien@findex const_int
117590075Sobrien@item (const_int @var{i})
117690075SobrienThis type of expression represents the integer value @var{i}.  @var{i}
117790075Sobrienis customarily accessed with the macro @code{INTVAL} as in
117890075Sobrien@code{INTVAL (@var{exp})}, which is equivalent to @code{XWINT (@var{exp}, 0)}.
117990075Sobrien
118090075Sobrien@findex const0_rtx
118190075Sobrien@findex const1_rtx
118290075Sobrien@findex const2_rtx
118390075Sobrien@findex constm1_rtx
118490075SobrienThere is only one expression object for the integer value zero; it is
118590075Sobrienthe value of the variable @code{const0_rtx}.  Likewise, the only
118690075Sobrienexpression for integer value one is found in @code{const1_rtx}, the only
118790075Sobrienexpression for integer value two is found in @code{const2_rtx}, and the
118890075Sobrienonly expression for integer value negative one is found in
118990075Sobrien@code{constm1_rtx}.  Any attempt to create an expression of code
119090075Sobrien@code{const_int} and value zero, one, two or negative one will return
119190075Sobrien@code{const0_rtx}, @code{const1_rtx}, @code{const2_rtx} or
119290075Sobrien@code{constm1_rtx} as appropriate.
119390075Sobrien
119490075Sobrien@findex const_true_rtx
119590075SobrienSimilarly, there is only one object for the integer whose value is
119690075Sobrien@code{STORE_FLAG_VALUE}.  It is found in @code{const_true_rtx}.  If
119790075Sobrien@code{STORE_FLAG_VALUE} is one, @code{const_true_rtx} and
119890075Sobrien@code{const1_rtx} will point to the same object.  If
119990075Sobrien@code{STORE_FLAG_VALUE} is @minus{}1, @code{const_true_rtx} and
120090075Sobrien@code{constm1_rtx} will point to the same object.
120190075Sobrien
120290075Sobrien@findex const_double
120390075Sobrien@item (const_double:@var{m} @var{addr} @var{i0} @var{i1} @dots{})
120490075SobrienRepresents either a floating-point constant of mode @var{m} or an
120590075Sobrieninteger constant too large to fit into @code{HOST_BITS_PER_WIDE_INT}
120690075Sobrienbits but small enough to fit within twice that number of bits (GCC
120790075Sobriendoes not provide a mechanism to represent even larger constants).  In
120890075Sobrienthe latter case, @var{m} will be @code{VOIDmode}.
120990075Sobrien
121096263Sobrien@findex const_vector
121196263Sobrien@item (const_vector:@var{m} [@var{x0} @var{x1} @dots{}])
121296263SobrienRepresents a vector constant.  The square brackets stand for the vector
121396263Sobriencontaining the constant elements.  @var{x0}, @var{x1} and so on are
121496263Sobrienthe @code{const_int} or @code{const_double} elements.
121596263Sobrien
121696263SobrienThe number of units in a @code{const_vector} is obtained with the macro
121796263Sobrien@code{CONST_VECTOR_NUNITS} as in @code{CONST_VECTOR_NUNITS (@var{v})}.
121896263Sobrien
121996263SobrienIndividual elements in a vector constant are accessed with the macro
122096263Sobrien@code{CONST_VECTOR_ELT} as in @code{CONST_VECTOR_ELT (@var{v}, @var{n})}
122196263Sobrienwhere @var{v} is the vector constant and @var{n} is the element
122296263Sobriendesired.
122396263Sobrien
122490075Sobrien@findex CONST_DOUBLE_MEM
122590075Sobrien@findex CONST_DOUBLE_CHAIN
122690075Sobrien@var{addr} is used to contain the @code{mem} expression that corresponds
122790075Sobriento the location in memory that at which the constant can be found.  If
122890075Sobrienit has not been allocated a memory location, but is on the chain of all
122990075Sobrien@code{const_double} expressions in this compilation (maintained using an
123090075Sobrienundisplayed field), @var{addr} contains @code{const0_rtx}.  If it is not
123190075Sobrienon the chain, @var{addr} contains @code{cc0_rtx}.  @var{addr} is
123290075Sobriencustomarily accessed with the macro @code{CONST_DOUBLE_MEM} and the
123390075Sobrienchain field via @code{CONST_DOUBLE_CHAIN}.
123490075Sobrien
123590075Sobrien@findex CONST_DOUBLE_LOW
123690075SobrienIf @var{m} is @code{VOIDmode}, the bits of the value are stored in
123790075Sobrien@var{i0} and @var{i1}.  @var{i0} is customarily accessed with the macro
123890075Sobrien@code{CONST_DOUBLE_LOW} and @var{i1} with @code{CONST_DOUBLE_HIGH}.
123990075Sobrien
124090075SobrienIf the constant is floating point (regardless of its precision), then
124190075Sobrienthe number of integers used to store the value depends on the size of
1242117395Skan@code{REAL_VALUE_TYPE} (@pxref{Floating Point}).  The integers
124390075Sobrienrepresent a floating point number, but not precisely in the target
124490075Sobrienmachine's or host machine's floating point format.  To convert them to
124590075Sobrienthe precise bit pattern used by the target machine, use the macro
124690075Sobrien@code{REAL_VALUE_TO_TARGET_DOUBLE} and friends (@pxref{Data Output}).
124790075Sobrien
124890075Sobrien@findex CONST0_RTX
124990075Sobrien@findex CONST1_RTX
125090075Sobrien@findex CONST2_RTX
125190075SobrienThe macro @code{CONST0_RTX (@var{mode})} refers to an expression with
125290075Sobrienvalue 0 in mode @var{mode}.  If mode @var{mode} is of mode class
125396263Sobrien@code{MODE_INT}, it returns @code{const0_rtx}.  If mode @var{mode} is of
125496263Sobrienmode class @code{MODE_FLOAT}, it returns a @code{CONST_DOUBLE}
125596263Sobrienexpression in mode @var{mode}.  Otherwise, it returns a
125696263Sobrien@code{CONST_VECTOR} expression in mode @var{mode}.  Similarly, the macro
125790075Sobrien@code{CONST1_RTX (@var{mode})} refers to an expression with value 1 in
125896263Sobrienmode @var{mode} and similarly for @code{CONST2_RTX}.  The
125996263Sobrien@code{CONST1_RTX} and @code{CONST2_RTX} macros are undefined
126096263Sobrienfor vector modes.
126190075Sobrien
126290075Sobrien@findex const_string
126390075Sobrien@item (const_string @var{str})
126490075SobrienRepresents a constant string with value @var{str}.  Currently this is
126590075Sobrienused only for insn attributes (@pxref{Insn Attributes}) since constant
126690075Sobrienstrings in C are placed in memory.
126790075Sobrien
126890075Sobrien@findex symbol_ref
126990075Sobrien@item (symbol_ref:@var{mode} @var{symbol})
127090075SobrienRepresents the value of an assembler label for data.  @var{symbol} is
127190075Sobriena string that describes the name of the assembler label.  If it starts
127290075Sobrienwith a @samp{*}, the label is the rest of @var{symbol} not including
127390075Sobrienthe @samp{*}.  Otherwise, the label is @var{symbol}, usually prefixed
127490075Sobrienwith @samp{_}.
127590075Sobrien
127690075SobrienThe @code{symbol_ref} contains a mode, which is usually @code{Pmode}.
127790075SobrienUsually that is the only mode for which a symbol is directly valid.
127890075Sobrien
127990075Sobrien@findex label_ref
128090075Sobrien@item (label_ref @var{label})
128190075SobrienRepresents the value of an assembler label for code.  It contains one
128290075Sobrienoperand, an expression, which must be a @code{code_label} or a @code{note}
128390075Sobrienof type @code{NOTE_INSN_DELETED_LABEL} that appears in the instruction
128490075Sobriensequence to identify the place where the label should go.
128590075Sobrien
128690075SobrienThe reason for using a distinct expression type for code label
128790075Sobrienreferences is so that jump optimization can distinguish them.
128890075Sobrien
128990075Sobrien@item (const:@var{m} @var{exp})
129090075SobrienRepresents a constant that is the result of an assembly-time
129190075Sobrienarithmetic computation.  The operand, @var{exp}, is an expression that
129290075Sobriencontains only constants (@code{const_int}, @code{symbol_ref} and
129390075Sobrien@code{label_ref} expressions) combined with @code{plus} and
129490075Sobrien@code{minus}.  However, not all combinations are valid, since the
129590075Sobrienassembler cannot do arbitrary arithmetic on relocatable symbols.
129690075Sobrien
129790075Sobrien@var{m} should be @code{Pmode}.
129890075Sobrien
129990075Sobrien@findex high
130090075Sobrien@item (high:@var{m} @var{exp})
130190075SobrienRepresents the high-order bits of @var{exp}, usually a
130290075Sobrien@code{symbol_ref}.  The number of bits is machine-dependent and is
130390075Sobriennormally the number of bits specified in an instruction that initializes
130490075Sobrienthe high order bits of a register.  It is used with @code{lo_sum} to
130590075Sobrienrepresent the typical two-instruction sequence used in RISC machines to
130690075Sobrienreference a global memory location.
130790075Sobrien
130890075Sobrien@var{m} should be @code{Pmode}.
130990075Sobrien@end table
131090075Sobrien
131190075Sobrien@node Regs and Memory
131290075Sobrien@section Registers and Memory
131390075Sobrien@cindex RTL register expressions
131490075Sobrien@cindex RTL memory expressions
131590075Sobrien
131690075SobrienHere are the RTL expression types for describing access to machine
131790075Sobrienregisters and to main memory.
131890075Sobrien
131990075Sobrien@table @code
132090075Sobrien@findex reg
132190075Sobrien@cindex hard registers
132290075Sobrien@cindex pseudo registers
132390075Sobrien@item (reg:@var{m} @var{n})
132490075SobrienFor small values of the integer @var{n} (those that are less than
132590075Sobrien@code{FIRST_PSEUDO_REGISTER}), this stands for a reference to machine
132690075Sobrienregister number @var{n}: a @dfn{hard register}.  For larger values of
132790075Sobrien@var{n}, it stands for a temporary value or @dfn{pseudo register}.
132890075SobrienThe compiler's strategy is to generate code assuming an unlimited
132990075Sobriennumber of such pseudo registers, and later convert them into hard
133090075Sobrienregisters or into memory references.
133190075Sobrien
133290075Sobrien@var{m} is the machine mode of the reference.  It is necessary because
133390075Sobrienmachines can generally refer to each register in more than one mode.
133490075SobrienFor example, a register may contain a full word but there may be
133590075Sobrieninstructions to refer to it as a half word or as a single byte, as
133690075Sobrienwell as instructions to refer to it as a floating point number of
133790075Sobrienvarious precisions.
133890075Sobrien
133990075SobrienEven for a register that the machine can access in only one mode,
134090075Sobrienthe mode must always be specified.
134190075Sobrien
134290075SobrienThe symbol @code{FIRST_PSEUDO_REGISTER} is defined by the machine
134390075Sobriendescription, since the number of hard registers on the machine is an
134490075Sobrieninvariant characteristic of the machine.  Note, however, that not
134590075Sobrienall of the machine registers must be general registers.  All the
134690075Sobrienmachine registers that can be used for storage of data are given
134790075Sobrienhard register numbers, even those that can be used only in certain
134890075Sobrieninstructions or can hold only certain types of data.
134990075Sobrien
135090075SobrienA hard register may be accessed in various modes throughout one
135190075Sobrienfunction, but each pseudo register is given a natural mode
135290075Sobrienand is accessed only in that mode.  When it is necessary to describe
135390075Sobrienan access to a pseudo register using a nonnatural mode, a @code{subreg}
135490075Sobrienexpression is used.
135590075Sobrien
135690075SobrienA @code{reg} expression with a machine mode that specifies more than
135790075Sobrienone word of data may actually stand for several consecutive registers.
135890075SobrienIf in addition the register number specifies a hardware register, then
135990075Sobrienit actually represents several consecutive hardware registers starting
136090075Sobrienwith the specified one.
136190075Sobrien
136290075SobrienEach pseudo register number used in a function's RTL code is
136390075Sobrienrepresented by a unique @code{reg} expression.
136490075Sobrien
136590075Sobrien@findex FIRST_VIRTUAL_REGISTER
136690075Sobrien@findex LAST_VIRTUAL_REGISTER
136790075SobrienSome pseudo register numbers, those within the range of
136890075Sobrien@code{FIRST_VIRTUAL_REGISTER} to @code{LAST_VIRTUAL_REGISTER} only
136990075Sobrienappear during the RTL generation phase and are eliminated before the
137090075Sobrienoptimization phases.  These represent locations in the stack frame that
137190075Sobriencannot be determined until RTL generation for the function has been
137290075Sobriencompleted.  The following virtual register numbers are defined:
137390075Sobrien
137490075Sobrien@table @code
137590075Sobrien@findex VIRTUAL_INCOMING_ARGS_REGNUM
137690075Sobrien@item VIRTUAL_INCOMING_ARGS_REGNUM
137790075SobrienThis points to the first word of the incoming arguments passed on the
137890075Sobrienstack.  Normally these arguments are placed there by the caller, but the
137990075Sobriencallee may have pushed some arguments that were previously passed in
138090075Sobrienregisters.
138190075Sobrien
138290075Sobrien@cindex @code{FIRST_PARM_OFFSET} and virtual registers
138390075Sobrien@cindex @code{ARG_POINTER_REGNUM} and virtual registers
138490075SobrienWhen RTL generation is complete, this virtual register is replaced
138590075Sobrienby the sum of the register given by @code{ARG_POINTER_REGNUM} and the
138690075Sobrienvalue of @code{FIRST_PARM_OFFSET}.
138790075Sobrien
138890075Sobrien@findex VIRTUAL_STACK_VARS_REGNUM
138990075Sobrien@cindex @code{FRAME_GROWS_DOWNWARD} and virtual registers
139090075Sobrien@item VIRTUAL_STACK_VARS_REGNUM
139190075SobrienIf @code{FRAME_GROWS_DOWNWARD} is defined, this points to immediately
139290075Sobrienabove the first variable on the stack.  Otherwise, it points to the
139390075Sobrienfirst variable on the stack.
139490075Sobrien
139590075Sobrien@cindex @code{STARTING_FRAME_OFFSET} and virtual registers
139690075Sobrien@cindex @code{FRAME_POINTER_REGNUM} and virtual registers
139790075Sobrien@code{VIRTUAL_STACK_VARS_REGNUM} is replaced with the sum of the
139890075Sobrienregister given by @code{FRAME_POINTER_REGNUM} and the value
139990075Sobrien@code{STARTING_FRAME_OFFSET}.
140090075Sobrien
140190075Sobrien@findex VIRTUAL_STACK_DYNAMIC_REGNUM
140290075Sobrien@item VIRTUAL_STACK_DYNAMIC_REGNUM
140390075SobrienThis points to the location of dynamically allocated memory on the stack
140490075Sobrienimmediately after the stack pointer has been adjusted by the amount of
140590075Sobrienmemory desired.
140690075Sobrien
140790075Sobrien@cindex @code{STACK_DYNAMIC_OFFSET} and virtual registers
140890075Sobrien@cindex @code{STACK_POINTER_REGNUM} and virtual registers
140990075SobrienThis virtual register is replaced by the sum of the register given by
141090075Sobrien@code{STACK_POINTER_REGNUM} and the value @code{STACK_DYNAMIC_OFFSET}.
141190075Sobrien
141290075Sobrien@findex VIRTUAL_OUTGOING_ARGS_REGNUM
141390075Sobrien@item VIRTUAL_OUTGOING_ARGS_REGNUM
141490075SobrienThis points to the location in the stack at which outgoing arguments
141590075Sobrienshould be written when the stack is pre-pushed (arguments pushed using
141690075Sobrienpush insns should always use @code{STACK_POINTER_REGNUM}).
141790075Sobrien
141890075Sobrien@cindex @code{STACK_POINTER_OFFSET} and virtual registers
141990075SobrienThis virtual register is replaced by the sum of the register given by
142090075Sobrien@code{STACK_POINTER_REGNUM} and the value @code{STACK_POINTER_OFFSET}.
142190075Sobrien@end table
142290075Sobrien
142390075Sobrien@findex subreg
142490075Sobrien@item (subreg:@var{m} @var{reg} @var{bytenum})
142590075Sobrien@code{subreg} expressions are used to refer to a register in a machine
142690075Sobrienmode other than its natural one, or to refer to one register of
142790075Sobriena multi-part @code{reg} that actually refers to several registers.
142890075Sobrien
142990075SobrienEach pseudo-register has a natural mode.  If it is necessary to
143090075Sobrienoperate on it in a different mode---for example, to perform a fullword
143190075Sobrienmove instruction on a pseudo-register that contains a single
143290075Sobrienbyte---the pseudo-register must be enclosed in a @code{subreg}.  In
143390075Sobriensuch a case, @var{bytenum} is zero.
143490075Sobrien
143590075SobrienUsually @var{m} is at least as narrow as the mode of @var{reg}, in which
143690075Sobriencase it is restricting consideration to only the bits of @var{reg} that
143790075Sobrienare in @var{m}.
143890075Sobrien
143990075SobrienSometimes @var{m} is wider than the mode of @var{reg}.  These
144090075Sobrien@code{subreg} expressions are often called @dfn{paradoxical}.  They are
144190075Sobrienused in cases where we want to refer to an object in a wider mode but do
144290075Sobriennot care what value the additional bits have.  The reload pass ensures
144390075Sobrienthat paradoxical references are only made to hard registers.
144490075Sobrien
144590075SobrienThe other use of @code{subreg} is to extract the individual registers of
144690075Sobriena multi-register value.  Machine modes such as @code{DImode} and
144790075Sobrien@code{TImode} can indicate values longer than a word, values which
144890075Sobrienusually require two or more consecutive registers.  To access one of the
144990075Sobrienregisters, use a @code{subreg} with mode @code{SImode} and a
145090075Sobrien@var{bytenum} offset that says which register.
145190075Sobrien
145290075SobrienStoring in a non-paradoxical @code{subreg} has undefined results for
145390075Sobrienbits belonging to the same word as the @code{subreg}.  This laxity makes
145490075Sobrienit easier to generate efficient code for such instructions.  To
145590075Sobrienrepresent an instruction that preserves all the bits outside of those in
145690075Sobrienthe @code{subreg}, use @code{strict_low_part} around the @code{subreg}.
145790075Sobrien
145890075Sobrien@cindex @code{WORDS_BIG_ENDIAN}, effect on @code{subreg}
145990075SobrienThe compilation parameter @code{WORDS_BIG_ENDIAN}, if set to 1, says
146090075Sobrienthat byte number zero is part of the most significant word; otherwise,
146190075Sobrienit is part of the least significant word.
146290075Sobrien
146390075Sobrien@cindex @code{BYTES_BIG_ENDIAN}, effect on @code{subreg}
146490075SobrienThe compilation parameter @code{BYTES_BIG_ENDIAN}, if set to 1, says
146590075Sobrienthat byte number zero is the most significant byte within a word;
146690075Sobrienotherwise, it is the least significant byte within a word.
146790075Sobrien
146890075Sobrien@cindex @code{FLOAT_WORDS_BIG_ENDIAN}, (lack of) effect on @code{subreg}
146990075SobrienOn a few targets, @code{FLOAT_WORDS_BIG_ENDIAN} disagrees with
147090075Sobrien@code{WORDS_BIG_ENDIAN}.
147190075SobrienHowever, most parts of the compiler treat floating point values as if
147290075Sobrienthey had the same endianness as integer values.  This works because
147390075Sobrienthey handle them solely as a collection of integer values, with no
147490075Sobrienparticular numerical value.  Only real.c and the runtime libraries
147590075Sobriencare about @code{FLOAT_WORDS_BIG_ENDIAN}.
147690075Sobrien
147790075Sobrien@cindex combiner pass
147890075Sobrien@cindex reload pass
147990075Sobrien@cindex @code{subreg}, special reload handling
148090075SobrienBetween the combiner pass and the reload pass, it is possible to have a
148190075Sobrienparadoxical @code{subreg} which contains a @code{mem} instead of a
148290075Sobrien@code{reg} as its first operand.  After the reload pass, it is also
148390075Sobrienpossible to have a non-paradoxical @code{subreg} which contains a
148490075Sobrien@code{mem}; this usually occurs when the @code{mem} is a stack slot
148590075Sobrienwhich replaced a pseudo register.
148690075Sobrien
148790075SobrienNote that it is not valid to access a @code{DFmode} value in @code{SFmode}
148890075Sobrienusing a @code{subreg}.  On some machines the most significant part of a
148990075Sobrien@code{DFmode} value does not have the same format as a single-precision
149090075Sobrienfloating value.
149190075Sobrien
149290075SobrienIt is also not valid to access a single word of a multi-word value in a
149390075Sobrienhard register when less registers can hold the value than would be
149490075Sobrienexpected from its size.  For example, some 32-bit machines have
149590075Sobrienfloating-point registers that can hold an entire @code{DFmode} value.
149690075SobrienIf register 10 were such a register @code{(subreg:SI (reg:DF 10) 1)}
149790075Sobrienwould be invalid because there is no way to convert that reference to
149890075Sobriena single machine register.  The reload pass prevents @code{subreg}
149990075Sobrienexpressions such as these from being formed.
150090075Sobrien
150190075Sobrien@findex SUBREG_REG
150290075Sobrien@findex SUBREG_BYTE
150390075SobrienThe first operand of a @code{subreg} expression is customarily accessed
150490075Sobrienwith the @code{SUBREG_REG} macro and the second operand is customarily
150590075Sobrienaccessed with the @code{SUBREG_BYTE} macro.
150690075Sobrien
150790075Sobrien@findex scratch
150890075Sobrien@cindex scratch operands
150990075Sobrien@item (scratch:@var{m})
151090075SobrienThis represents a scratch register that will be required for the
151190075Sobrienexecution of a single instruction and not used subsequently.  It is
151290075Sobrienconverted into a @code{reg} by either the local register allocator or
151390075Sobrienthe reload pass.
151490075Sobrien
151590075Sobrien@code{scratch} is usually present inside a @code{clobber} operation
151690075Sobrien(@pxref{Side Effects}).
151790075Sobrien
151890075Sobrien@findex cc0
151990075Sobrien@cindex condition code register
152090075Sobrien@item (cc0)
152190075SobrienThis refers to the machine's condition code register.  It has no
152290075Sobrienoperands and may not have a machine mode.  There are two ways to use it:
152390075Sobrien
152490075Sobrien@itemize @bullet
152590075Sobrien@item
152690075SobrienTo stand for a complete set of condition code flags.  This is best on
152790075Sobrienmost machines, where each comparison sets the entire series of flags.
152890075Sobrien
152990075SobrienWith this technique, @code{(cc0)} may be validly used in only two
153090075Sobriencontexts: as the destination of an assignment (in test and compare
153190075Sobrieninstructions) and in comparison operators comparing against zero
153290075Sobrien(@code{const_int} with value zero; that is to say, @code{const0_rtx}).
153390075Sobrien
153490075Sobrien@item
153590075SobrienTo stand for a single flag that is the result of a single condition.
153690075SobrienThis is useful on machines that have only a single flag bit, and in
153790075Sobrienwhich comparison instructions must specify the condition to test.
153890075Sobrien
153990075SobrienWith this technique, @code{(cc0)} may be validly used in only two
154090075Sobriencontexts: as the destination of an assignment (in test and compare
154190075Sobrieninstructions) where the source is a comparison operator, and as the
154290075Sobrienfirst operand of @code{if_then_else} (in a conditional branch).
154390075Sobrien@end itemize
154490075Sobrien
154590075Sobrien@findex cc0_rtx
154690075SobrienThere is only one expression object of code @code{cc0}; it is the
154790075Sobrienvalue of the variable @code{cc0_rtx}.  Any attempt to create an
154890075Sobrienexpression of code @code{cc0} will return @code{cc0_rtx}.
154990075Sobrien
155090075SobrienInstructions can set the condition code implicitly.  On many machines,
155190075Sobriennearly all instructions set the condition code based on the value that
155290075Sobrienthey compute or store.  It is not necessary to record these actions
155390075Sobrienexplicitly in the RTL because the machine description includes a
155490075Sobrienprescription for recognizing the instructions that do so (by means of
155590075Sobrienthe macro @code{NOTICE_UPDATE_CC}).  @xref{Condition Code}.  Only
155690075Sobrieninstructions whose sole purpose is to set the condition code, and
155790075Sobrieninstructions that use the condition code, need mention @code{(cc0)}.
155890075Sobrien
155990075SobrienOn some machines, the condition code register is given a register number
156090075Sobrienand a @code{reg} is used instead of @code{(cc0)}.  This is usually the
156190075Sobrienpreferable approach if only a small subset of instructions modify the
156290075Sobriencondition code.  Other machines store condition codes in general
156390075Sobrienregisters; in such cases a pseudo register should be used.
156490075Sobrien
1565117395SkanSome machines, such as the SPARC and RS/6000, have two sets of
156690075Sobrienarithmetic instructions, one that sets and one that does not set the
156790075Sobriencondition code.  This is best handled by normally generating the
156890075Sobrieninstruction that does not set the condition code, and making a pattern
156990075Sobrienthat both performs the arithmetic and sets the condition code register
157090075Sobrien(which would not be @code{(cc0)} in this case).  For examples, search
157190075Sobrienfor @samp{addcc} and @samp{andcc} in @file{sparc.md}.
157290075Sobrien
157390075Sobrien@findex pc
157490075Sobrien@item (pc)
157590075Sobrien@cindex program counter
157690075SobrienThis represents the machine's program counter.  It has no operands and
157790075Sobrienmay not have a machine mode.  @code{(pc)} may be validly used only in
157890075Sobriencertain specific contexts in jump instructions.
157990075Sobrien
158090075Sobrien@findex pc_rtx
158190075SobrienThere is only one expression object of code @code{pc}; it is the value
158290075Sobrienof the variable @code{pc_rtx}.  Any attempt to create an expression of
158390075Sobriencode @code{pc} will return @code{pc_rtx}.
158490075Sobrien
158590075SobrienAll instructions that do not jump alter the program counter implicitly
158690075Sobrienby incrementing it, but there is no need to mention this in the RTL@.
158790075Sobrien
158890075Sobrien@findex mem
158990075Sobrien@item (mem:@var{m} @var{addr} @var{alias})
159090075SobrienThis RTX represents a reference to main memory at an address
159190075Sobrienrepresented by the expression @var{addr}.  @var{m} specifies how large
159290075Sobriena unit of memory is accessed.  @var{alias} specifies an alias set for the
159390075Sobrienreference.  In general two items are in different alias sets if they cannot
159490075Sobrienreference the same memory address.
159590075Sobrien
1596117395SkanThe construct @code{(mem:BLK (scratch))} is considered to alias all
1597117395Skanother memories.  Thus it may be used as a memory barrier in epilogue
1598117395Skanstack deallocation patterns.
1599117395Skan
160090075Sobrien@findex addressof
160190075Sobrien@item (addressof:@var{m} @var{reg})
160290075SobrienThis RTX represents a request for the address of register @var{reg}.  Its mode
160390075Sobrienis always @code{Pmode}.  If there are any @code{addressof}
160490075Sobrienexpressions left in the function after CSE, @var{reg} is forced into the
160590075Sobrienstack and the @code{addressof} expression is replaced with a @code{plus}
160690075Sobrienexpression for the address of its stack slot.
160790075Sobrien@end table
160890075Sobrien
160990075Sobrien@node Arithmetic
161090075Sobrien@section RTL Expressions for Arithmetic
161190075Sobrien@cindex arithmetic, in RTL
161290075Sobrien@cindex math, in RTL
161390075Sobrien@cindex RTL expressions for arithmetic
161490075Sobrien
161590075SobrienUnless otherwise specified, all the operands of arithmetic expressions
161690075Sobrienmust be valid for mode @var{m}.  An operand is valid for mode @var{m}
161790075Sobrienif it has mode @var{m}, or if it is a @code{const_int} or
161890075Sobrien@code{const_double} and @var{m} is a mode of class @code{MODE_INT}.
161990075Sobrien
162090075SobrienFor commutative binary operations, constants should be placed in the
162190075Sobriensecond operand.
162290075Sobrien
162390075Sobrien@table @code
162490075Sobrien@findex plus
162590075Sobrien@cindex RTL addition
162690075Sobrien@cindex RTL sum
162790075Sobrien@item (plus:@var{m} @var{x} @var{y})
162890075SobrienRepresents the sum of the values represented by @var{x} and @var{y}
162990075Sobriencarried out in machine mode @var{m}.
163090075Sobrien
163190075Sobrien@findex lo_sum
163290075Sobrien@item (lo_sum:@var{m} @var{x} @var{y})
163390075SobrienLike @code{plus}, except that it represents that sum of @var{x} and the
163490075Sobrienlow-order bits of @var{y}.  The number of low order bits is
163590075Sobrienmachine-dependent but is normally the number of bits in a @code{Pmode}
163690075Sobrienitem minus the number of bits set by the @code{high} code
163790075Sobrien(@pxref{Constants}).
163890075Sobrien
163990075Sobrien@var{m} should be @code{Pmode}.
164090075Sobrien
164190075Sobrien@findex minus
164290075Sobrien@cindex RTL subtraction
164390075Sobrien@cindex RTL difference
164490075Sobrien@item (minus:@var{m} @var{x} @var{y})
164590075SobrienLike @code{plus} but represents subtraction.
164690075Sobrien
164790075Sobrien@findex ss_plus
164890075Sobrien@cindex RTL addition with signed saturation
164990075Sobrien@item (ss_plus:@var{m} @var{x} @var{y})
165090075Sobrien
165190075SobrienLike @code{plus}, but using signed saturation in case of an overflow.
165290075Sobrien
165390075Sobrien@findex us_plus
165490075Sobrien@cindex RTL addition with unsigned saturation
165590075Sobrien@item (us_plus:@var{m} @var{x} @var{y})
165690075Sobrien
165790075SobrienLike @code{plus}, but using unsigned saturation in case of an overflow.
165890075Sobrien
165990075Sobrien@findex ss_minus
166090075Sobrien@cindex RTL addition with signed saturation
166190075Sobrien@item (ss_minus:@var{m} @var{x} @var{y})
166290075Sobrien
166390075SobrienLike @code{minus}, but using signed saturation in case of an overflow.
166490075Sobrien
166590075Sobrien@findex us_minus
166690075Sobrien@cindex RTL addition with unsigned saturation
166790075Sobrien@item (us_minus:@var{m} @var{x} @var{y})
166890075Sobrien
166990075SobrienLike @code{minus}, but using unsigned saturation in case of an overflow.
167090075Sobrien
167190075Sobrien@findex compare
167290075Sobrien@cindex RTL comparison
167390075Sobrien@item (compare:@var{m} @var{x} @var{y})
167490075SobrienRepresents the result of subtracting @var{y} from @var{x} for purposes
167590075Sobrienof comparison.  The result is computed without overflow, as if with
167690075Sobrieninfinite precision.
167790075Sobrien
167890075SobrienOf course, machines can't really subtract with infinite precision.
167990075SobrienHowever, they can pretend to do so when only the sign of the result will
168090075Sobrienbe used, which is the case when the result is stored in the condition
168190075Sobriencode.  And that is the @emph{only} way this kind of expression may
168290075Sobrienvalidly be used: as a value to be stored in the condition codes, either
168390075Sobrien@code{(cc0)} or a register.  @xref{Comparisons}.
168490075Sobrien
168590075SobrienThe mode @var{m} is not related to the modes of @var{x} and @var{y}, but
168690075Sobrieninstead is the mode of the condition code value.  If @code{(cc0)} is
168790075Sobrienused, it is @code{VOIDmode}.  Otherwise it is some mode in class
168890075Sobrien@code{MODE_CC}, often @code{CCmode}.  @xref{Condition Code}.  If @var{m}
168990075Sobrienis @code{VOIDmode} or @code{CCmode}, the operation returns sufficient
169090075Sobrieninformation (in an unspecified format) so that any comparison operator
169190075Sobriencan be applied to the result of the @code{COMPARE} operation.  For other
169290075Sobrienmodes in class @code{MODE_CC}, the operation only returns a subset of
169390075Sobrienthis information.
169490075Sobrien
169590075SobrienNormally, @var{x} and @var{y} must have the same mode.  Otherwise,
169690075Sobrien@code{compare} is valid only if the mode of @var{x} is in class
169790075Sobrien@code{MODE_INT} and @var{y} is a @code{const_int} or
169890075Sobrien@code{const_double} with mode @code{VOIDmode}.  The mode of @var{x}
169990075Sobriendetermines what mode the comparison is to be done in; thus it must not
170090075Sobrienbe @code{VOIDmode}.
170190075Sobrien
170290075SobrienIf one of the operands is a constant, it should be placed in the
170390075Sobriensecond operand and the comparison code adjusted as appropriate.
170490075Sobrien
170590075SobrienA @code{compare} specifying two @code{VOIDmode} constants is not valid
170690075Sobriensince there is no way to know in what mode the comparison is to be
170790075Sobrienperformed; the comparison must either be folded during the compilation
170890075Sobrienor the first operand must be loaded into a register while its mode is
170990075Sobrienstill known.
171090075Sobrien
171190075Sobrien@findex neg
171290075Sobrien@item (neg:@var{m} @var{x})
171390075SobrienRepresents the negation (subtraction from zero) of the value represented
171490075Sobrienby @var{x}, carried out in mode @var{m}.
171590075Sobrien
171690075Sobrien@findex mult
171790075Sobrien@cindex multiplication
171890075Sobrien@cindex product
171990075Sobrien@item (mult:@var{m} @var{x} @var{y})
172090075SobrienRepresents the signed product of the values represented by @var{x} and
172190075Sobrien@var{y} carried out in machine mode @var{m}.
172290075Sobrien
172390075SobrienSome machines support a multiplication that generates a product wider
172490075Sobrienthan the operands.  Write the pattern for this as
172590075Sobrien
172690075Sobrien@example
172790075Sobrien(mult:@var{m} (sign_extend:@var{m} @var{x}) (sign_extend:@var{m} @var{y}))
172890075Sobrien@end example
172990075Sobrien
173090075Sobrienwhere @var{m} is wider than the modes of @var{x} and @var{y}, which need
173190075Sobriennot be the same.
173290075Sobrien
173390075SobrienFor unsigned widening multiplication, use the same idiom, but with
173490075Sobrien@code{zero_extend} instead of @code{sign_extend}.
173590075Sobrien
173690075Sobrien@findex div
173790075Sobrien@cindex division
173890075Sobrien@cindex signed division
173990075Sobrien@cindex quotient
174090075Sobrien@item (div:@var{m} @var{x} @var{y})
174190075SobrienRepresents the quotient in signed division of @var{x} by @var{y},
174290075Sobriencarried out in machine mode @var{m}.  If @var{m} is a floating point
174390075Sobrienmode, it represents the exact quotient; otherwise, the integerized
174490075Sobrienquotient.
174590075Sobrien
174690075SobrienSome machines have division instructions in which the operands and
174790075Sobrienquotient widths are not all the same; you should represent
174890075Sobriensuch instructions using @code{truncate} and @code{sign_extend} as in,
174990075Sobrien
175090075Sobrien@example
175190075Sobrien(truncate:@var{m1} (div:@var{m2} @var{x} (sign_extend:@var{m2} @var{y})))
175290075Sobrien@end example
175390075Sobrien
175490075Sobrien@findex udiv
175590075Sobrien@cindex unsigned division
175690075Sobrien@cindex division
175790075Sobrien@item (udiv:@var{m} @var{x} @var{y})
175890075SobrienLike @code{div} but represents unsigned division.
175990075Sobrien
176090075Sobrien@findex mod
176190075Sobrien@findex umod
176290075Sobrien@cindex remainder
176390075Sobrien@cindex division
176490075Sobrien@item (mod:@var{m} @var{x} @var{y})
176590075Sobrien@itemx (umod:@var{m} @var{x} @var{y})
176690075SobrienLike @code{div} and @code{udiv} but represent the remainder instead of
176790075Sobrienthe quotient.
176890075Sobrien
176990075Sobrien@findex smin
177090075Sobrien@findex smax
177190075Sobrien@cindex signed minimum
177290075Sobrien@cindex signed maximum
177390075Sobrien@item (smin:@var{m} @var{x} @var{y})
177490075Sobrien@itemx (smax:@var{m} @var{x} @var{y})
177590075SobrienRepresents the smaller (for @code{smin}) or larger (for @code{smax}) of
177690075Sobrien@var{x} and @var{y}, interpreted as signed integers in mode @var{m}.
177790075Sobrien
177890075Sobrien@findex umin
177990075Sobrien@findex umax
178090075Sobrien@cindex unsigned minimum and maximum
178190075Sobrien@item (umin:@var{m} @var{x} @var{y})
178290075Sobrien@itemx (umax:@var{m} @var{x} @var{y})
178390075SobrienLike @code{smin} and @code{smax}, but the values are interpreted as unsigned
178490075Sobrienintegers.
178590075Sobrien
178690075Sobrien@findex not
178790075Sobrien@cindex complement, bitwise
178890075Sobrien@cindex bitwise complement
178990075Sobrien@item (not:@var{m} @var{x})
179090075SobrienRepresents the bitwise complement of the value represented by @var{x},
179190075Sobriencarried out in mode @var{m}, which must be a fixed-point machine mode.
179290075Sobrien
179390075Sobrien@findex and
179490075Sobrien@cindex logical-and, bitwise
179590075Sobrien@cindex bitwise logical-and
179690075Sobrien@item (and:@var{m} @var{x} @var{y})
179790075SobrienRepresents the bitwise logical-and of the values represented by
179890075Sobrien@var{x} and @var{y}, carried out in machine mode @var{m}, which must be
179990075Sobriena fixed-point machine mode.
180090075Sobrien
180190075Sobrien@findex ior
180290075Sobrien@cindex inclusive-or, bitwise
180390075Sobrien@cindex bitwise inclusive-or
180490075Sobrien@item (ior:@var{m} @var{x} @var{y})
180590075SobrienRepresents the bitwise inclusive-or of the values represented by @var{x}
180690075Sobrienand @var{y}, carried out in machine mode @var{m}, which must be a
180790075Sobrienfixed-point mode.
180890075Sobrien
180990075Sobrien@findex xor
181090075Sobrien@cindex exclusive-or, bitwise
181190075Sobrien@cindex bitwise exclusive-or
181290075Sobrien@item (xor:@var{m} @var{x} @var{y})
181390075SobrienRepresents the bitwise exclusive-or of the values represented by @var{x}
181490075Sobrienand @var{y}, carried out in machine mode @var{m}, which must be a
181590075Sobrienfixed-point mode.
181690075Sobrien
181790075Sobrien@findex ashift
181890075Sobrien@cindex left shift
181990075Sobrien@cindex shift
182090075Sobrien@cindex arithmetic shift
182190075Sobrien@item (ashift:@var{m} @var{x} @var{c})
182290075SobrienRepresents the result of arithmetically shifting @var{x} left by @var{c}
182390075Sobrienplaces.  @var{x} have mode @var{m}, a fixed-point machine mode.  @var{c}
182490075Sobrienbe a fixed-point mode or be a constant with mode @code{VOIDmode}; which
182590075Sobrienmode is determined by the mode called for in the machine description
182690075Sobrienentry for the left-shift instruction.  For example, on the VAX, the mode
182790075Sobrienof @var{c} is @code{QImode} regardless of @var{m}.
182890075Sobrien
182990075Sobrien@findex lshiftrt
183090075Sobrien@cindex right shift
183190075Sobrien@findex ashiftrt
183290075Sobrien@item (lshiftrt:@var{m} @var{x} @var{c})
183390075Sobrien@itemx (ashiftrt:@var{m} @var{x} @var{c})
183490075SobrienLike @code{ashift} but for right shift.  Unlike the case for left shift,
183590075Sobrienthese two operations are distinct.
183690075Sobrien
183790075Sobrien@findex rotate
183890075Sobrien@cindex rotate
183990075Sobrien@cindex left rotate
184090075Sobrien@findex rotatert
184190075Sobrien@cindex right rotate
184290075Sobrien@item (rotate:@var{m} @var{x} @var{c})
184390075Sobrien@itemx (rotatert:@var{m} @var{x} @var{c})
184490075SobrienSimilar but represent left and right rotate.  If @var{c} is a constant,
184590075Sobrienuse @code{rotate}.
184690075Sobrien
184790075Sobrien@findex abs
184890075Sobrien@cindex absolute value
184990075Sobrien@item (abs:@var{m} @var{x})
185090075SobrienRepresents the absolute value of @var{x}, computed in mode @var{m}.
185190075Sobrien
185290075Sobrien@findex sqrt
185390075Sobrien@cindex square root
185490075Sobrien@item (sqrt:@var{m} @var{x})
185590075SobrienRepresents the square root of @var{x}, computed in mode @var{m}.
185690075SobrienMost often @var{m} will be a floating point mode.
185790075Sobrien
185890075Sobrien@findex ffs
185990075Sobrien@item (ffs:@var{m} @var{x})
186090075SobrienRepresents one plus the index of the least significant 1-bit in
186190075Sobrien@var{x}, represented as an integer of mode @var{m}.  (The value is
186290075Sobrienzero if @var{x} is zero.)  The mode of @var{x} need not be @var{m};
186390075Sobriendepending on the target machine, various mode combinations may be
186490075Sobrienvalid.
186590075Sobrien@end table
186690075Sobrien
186790075Sobrien@node Comparisons
186890075Sobrien@section Comparison Operations
186990075Sobrien@cindex RTL comparison operations
187090075Sobrien
187190075SobrienComparison operators test a relation on two operands and are considered
187290075Sobriento represent a machine-dependent nonzero value described by, but not
187390075Sobriennecessarily equal to, @code{STORE_FLAG_VALUE} (@pxref{Misc})
1874117395Skanif the relation holds, or zero if it does not, for comparison operators
1875117395Skanwhose results have a `MODE_INT' mode, and
1876117395Skan@code{FLOAT_STORE_FLAG_VALUE} (@pxref{Misc}) if the relation holds, or
1877117395Skanzero if it does not, for comparison operators that return floating-point
1878117395Skanvalues.  The mode of the comparison operation is independent of the mode
1879117395Skanof the data being compared.  If the comparison operation is being tested
1880117395Skan(e.g., the first operand of an @code{if_then_else}), the mode must be
1881117395Skan@code{VOIDmode}.
188290075Sobrien
188390075Sobrien@cindex condition codes
188490075SobrienThere are two ways that comparison operations may be used.  The
188590075Sobriencomparison operators may be used to compare the condition codes
188690075Sobrien@code{(cc0)} against zero, as in @code{(eq (cc0) (const_int 0))}.  Such
188790075Sobriena construct actually refers to the result of the preceding instruction
188890075Sobrienin which the condition codes were set.  The instruction setting the
188990075Sobriencondition code must be adjacent to the instruction using the condition
189090075Sobriencode; only @code{note} insns may separate them.
189190075Sobrien
189290075SobrienAlternatively, a comparison operation may directly compare two data
189390075Sobrienobjects.  The mode of the comparison is determined by the operands; they
189490075Sobrienmust both be valid for a common machine mode.  A comparison with both
189590075Sobrienoperands constant would be invalid as the machine mode could not be
189690075Sobriendeduced from it, but such a comparison should never exist in RTL due to
189790075Sobrienconstant folding.
189890075Sobrien
189990075SobrienIn the example above, if @code{(cc0)} were last set to
190090075Sobrien@code{(compare @var{x} @var{y})}, the comparison operation is
190190075Sobrienidentical to @code{(eq @var{x} @var{y})}.  Usually only one style
190290075Sobrienof comparisons is supported on a particular machine, but the combine
190390075Sobrienpass will try to merge the operations to produce the @code{eq} shown
190490075Sobrienin case it exists in the context of the particular insn involved.
190590075Sobrien
190690075SobrienInequality comparisons come in two flavors, signed and unsigned.  Thus,
190790075Sobrienthere are distinct expression codes @code{gt} and @code{gtu} for signed and
190890075Sobrienunsigned greater-than.  These can produce different results for the same
190990075Sobrienpair of integer values: for example, 1 is signed greater-than @minus{}1 but not
191090075Sobrienunsigned greater-than, because @minus{}1 when regarded as unsigned is actually
191190075Sobrien@code{0xffffffff} which is greater than 1.
191290075Sobrien
191390075SobrienThe signed comparisons are also used for floating point values.  Floating
191490075Sobrienpoint comparisons are distinguished by the machine modes of the operands.
191590075Sobrien
191690075Sobrien@table @code
191790075Sobrien@findex eq
191890075Sobrien@cindex equal
191990075Sobrien@item (eq:@var{m} @var{x} @var{y})
192090075Sobrien@code{STORE_FLAG_VALUE} if the values represented by @var{x} and @var{y}
192190075Sobrienare equal, otherwise 0.
192290075Sobrien
192390075Sobrien@findex ne
192490075Sobrien@cindex not equal
192590075Sobrien@item (ne:@var{m} @var{x} @var{y})
192690075Sobrien@code{STORE_FLAG_VALUE} if the values represented by @var{x} and @var{y}
192790075Sobrienare not equal, otherwise 0.
192890075Sobrien
192990075Sobrien@findex gt
193090075Sobrien@cindex greater than
193190075Sobrien@item (gt:@var{m} @var{x} @var{y})
193290075Sobrien@code{STORE_FLAG_VALUE} if the @var{x} is greater than @var{y}.  If they
193390075Sobrienare fixed-point, the comparison is done in a signed sense.
193490075Sobrien
193590075Sobrien@findex gtu
193690075Sobrien@cindex greater than
193790075Sobrien@cindex unsigned greater than
193890075Sobrien@item (gtu:@var{m} @var{x} @var{y})
193990075SobrienLike @code{gt} but does unsigned comparison, on fixed-point numbers only.
194090075Sobrien
194190075Sobrien@findex lt
194290075Sobrien@cindex less than
194390075Sobrien@findex ltu
194490075Sobrien@cindex unsigned less than
194590075Sobrien@item (lt:@var{m} @var{x} @var{y})
194690075Sobrien@itemx (ltu:@var{m} @var{x} @var{y})
194790075SobrienLike @code{gt} and @code{gtu} but test for ``less than''.
194890075Sobrien
194990075Sobrien@findex ge
195090075Sobrien@cindex greater than
195190075Sobrien@findex geu
195290075Sobrien@cindex unsigned greater than
195390075Sobrien@item (ge:@var{m} @var{x} @var{y})
195490075Sobrien@itemx (geu:@var{m} @var{x} @var{y})
195590075SobrienLike @code{gt} and @code{gtu} but test for ``greater than or equal''.
195690075Sobrien
195790075Sobrien@findex le
195890075Sobrien@cindex less than or equal
195990075Sobrien@findex leu
196090075Sobrien@cindex unsigned less than
196190075Sobrien@item (le:@var{m} @var{x} @var{y})
196290075Sobrien@itemx (leu:@var{m} @var{x} @var{y})
196390075SobrienLike @code{gt} and @code{gtu} but test for ``less than or equal''.
196490075Sobrien
196590075Sobrien@findex if_then_else
196690075Sobrien@item (if_then_else @var{cond} @var{then} @var{else})
196790075SobrienThis is not a comparison operation but is listed here because it is
196890075Sobrienalways used in conjunction with a comparison operation.  To be
196990075Sobrienprecise, @var{cond} is a comparison expression.  This expression
197090075Sobrienrepresents a choice, according to @var{cond}, between the value
197190075Sobrienrepresented by @var{then} and the one represented by @var{else}.
197290075Sobrien
197390075SobrienOn most machines, @code{if_then_else} expressions are valid only
197490075Sobriento express conditional jumps.
197590075Sobrien
197690075Sobrien@findex cond
197790075Sobrien@item (cond [@var{test1} @var{value1} @var{test2} @var{value2} @dots{}] @var{default})
197890075SobrienSimilar to @code{if_then_else}, but more general.  Each of @var{test1},
197990075Sobrien@var{test2}, @dots{} is performed in turn.  The result of this expression is
198090075Sobrienthe @var{value} corresponding to the first nonzero test, or @var{default} if
198190075Sobriennone of the tests are nonzero expressions.
198290075Sobrien
198390075SobrienThis is currently not valid for instruction patterns and is supported only
198490075Sobrienfor insn attributes.  @xref{Insn Attributes}.
198590075Sobrien@end table
198690075Sobrien
198790075Sobrien@node Bit-Fields
198890075Sobrien@section Bit-Fields
198990075Sobrien@cindex bit-fields
199090075Sobrien
199190075SobrienSpecial expression codes exist to represent bit-field instructions.
199290075SobrienThese types of expressions are lvalues in RTL; they may appear
199390075Sobrienon the left side of an assignment, indicating insertion of a value
199490075Sobrieninto the specified bit-field.
199590075Sobrien
199690075Sobrien@table @code
199790075Sobrien@findex sign_extract
199890075Sobrien@cindex @code{BITS_BIG_ENDIAN}, effect on @code{sign_extract}
199990075Sobrien@item (sign_extract:@var{m} @var{loc} @var{size} @var{pos})
200090075SobrienThis represents a reference to a sign-extended bit-field contained or
200190075Sobrienstarting in @var{loc} (a memory or register reference).  The bit-field
200290075Sobrienis @var{size} bits wide and starts at bit @var{pos}.  The compilation
200390075Sobrienoption @code{BITS_BIG_ENDIAN} says which end of the memory unit
200490075Sobrien@var{pos} counts from.
200590075Sobrien
200690075SobrienIf @var{loc} is in memory, its mode must be a single-byte integer mode.
200790075SobrienIf @var{loc} is in a register, the mode to use is specified by the
200890075Sobrienoperand of the @code{insv} or @code{extv} pattern
200990075Sobrien(@pxref{Standard Names}) and is usually a full-word integer mode,
201090075Sobrienwhich is the default if none is specified.
201190075Sobrien
201290075SobrienThe mode of @var{pos} is machine-specific and is also specified
201390075Sobrienin the @code{insv} or @code{extv} pattern.
201490075Sobrien
201590075SobrienThe mode @var{m} is the same as the mode that would be used for
201690075Sobrien@var{loc} if it were a register.
201790075Sobrien
201890075Sobrien@findex zero_extract
201990075Sobrien@item (zero_extract:@var{m} @var{loc} @var{size} @var{pos})
202090075SobrienLike @code{sign_extract} but refers to an unsigned or zero-extended
202190075Sobrienbit-field.  The same sequence of bits are extracted, but they
202290075Sobrienare filled to an entire word with zeros instead of by sign-extension.
202390075Sobrien@end table
202490075Sobrien
202590075Sobrien@node Vector Operations
202690075Sobrien@section Vector Operations
202790075Sobrien@cindex vector operations
202890075Sobrien
202990075SobrienAll normal RTL expressions can be used with vector modes; they are
203090075Sobrieninterpreted as operating on each part of the vector independently.
203190075SobrienAdditionally, there are a few new expressions to describe specific vector
203290075Sobrienoperations.
203390075Sobrien
203490075Sobrien@table @code
203590075Sobrien@findex vec_merge
203690075Sobrien@item (vec_merge:@var{m} @var{vec1} @var{vec2} @var{items})
203790075SobrienThis describes a merge operation between two vectors.  The result is a vector
203890075Sobrienof mode @var{m}; its elements are selected from either @var{vec1} or
203990075Sobrien@var{vec2}.  Which elements are selected is described by @var{items}, which
204090075Sobrienis a bit mask represented by a @code{const_int}; a zero bit indicates the
204190075Sobriencorresponding element in the result vector is taken from @var{vec2} while
204290075Sobriena set bit indicates it is taken from @var{vec1}.
204390075Sobrien
204490075Sobrien@findex vec_select
204590075Sobrien@item (vec_select:@var{m} @var{vec1} @var{selection})
204690075SobrienThis describes an operation that selects parts of a vector.  @var{vec1} is
204790075Sobrienthe source vector, @var{selection} is a @code{parallel} that contains a
204890075Sobrien@code{const_int} for each of the subparts of the result vector, giving the
204990075Sobriennumber of the source subpart that should be stored into it.
205090075Sobrien
205190075Sobrien@findex vec_concat
205290075Sobrien@item (vec_concat:@var{m} @var{vec1} @var{vec2})
205390075SobrienDescribes a vector concat operation.  The result is a concatenation of the
205490075Sobrienvectors @var{vec1} and @var{vec2}; its length is the sum of the lengths of
205590075Sobrienthe two inputs.
205690075Sobrien
205790075Sobrien@findex vec_const
205890075Sobrien@item (vec_const:@var{m} @var{subparts})
205990075SobrienThis describes a constant vector.  @var{subparts} is a @code{parallel} that
206090075Sobriencontains a constant for each of the subparts of the vector.
206190075Sobrien
206290075Sobrien@findex vec_duplicate
206390075Sobrien@item (vec_duplicate:@var{m} @var{vec})
206490075SobrienThis operation converts a small vector into a larger one by duplicating the
206590075Sobrieninput values.  The output vector mode must have the same submodes as the
206690075Sobrieninput vector mode, and the number of output parts must be an integer multiple
206790075Sobrienof the number of input parts.
206890075Sobrien
206990075Sobrien@end table
207090075Sobrien
207190075Sobrien@node Conversions
207290075Sobrien@section Conversions
207390075Sobrien@cindex conversions
207490075Sobrien@cindex machine mode conversions
207590075Sobrien
207690075SobrienAll conversions between machine modes must be represented by
207790075Sobrienexplicit conversion operations.  For example, an expression
207890075Sobrienwhich is the sum of a byte and a full word cannot be written as
207990075Sobrien@code{(plus:SI (reg:QI 34) (reg:SI 80))} because the @code{plus}
208090075Sobrienoperation requires two operands of the same machine mode.
208190075SobrienTherefore, the byte-sized operand is enclosed in a conversion
208290075Sobrienoperation, as in
208390075Sobrien
208490075Sobrien@example
208590075Sobrien(plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
208690075Sobrien@end example
208790075Sobrien
208890075SobrienThe conversion operation is not a mere placeholder, because there
208990075Sobrienmay be more than one way of converting from a given starting mode
209090075Sobriento the desired final mode.  The conversion operation code says how
209190075Sobriento do it.
209290075Sobrien
209390075SobrienFor all conversion operations, @var{x} must not be @code{VOIDmode}
209490075Sobrienbecause the mode in which to do the conversion would not be known.
209590075SobrienThe conversion must either be done at compile-time or @var{x}
209690075Sobrienmust be placed into a register.
209790075Sobrien
209890075Sobrien@table @code
209990075Sobrien@findex sign_extend
210090075Sobrien@item (sign_extend:@var{m} @var{x})
210190075SobrienRepresents the result of sign-extending the value @var{x}
210290075Sobriento machine mode @var{m}.  @var{m} must be a fixed-point mode
210390075Sobrienand @var{x} a fixed-point value of a mode narrower than @var{m}.
210490075Sobrien
210590075Sobrien@findex zero_extend
210690075Sobrien@item (zero_extend:@var{m} @var{x})
210790075SobrienRepresents the result of zero-extending the value @var{x}
210890075Sobriento machine mode @var{m}.  @var{m} must be a fixed-point mode
210990075Sobrienand @var{x} a fixed-point value of a mode narrower than @var{m}.
211090075Sobrien
211190075Sobrien@findex float_extend
211290075Sobrien@item (float_extend:@var{m} @var{x})
211390075SobrienRepresents the result of extending the value @var{x}
211490075Sobriento machine mode @var{m}.  @var{m} must be a floating point mode
211590075Sobrienand @var{x} a floating point value of a mode narrower than @var{m}.
211690075Sobrien
211790075Sobrien@findex truncate
211890075Sobrien@item (truncate:@var{m} @var{x})
211990075SobrienRepresents the result of truncating the value @var{x}
212090075Sobriento machine mode @var{m}.  @var{m} must be a fixed-point mode
212190075Sobrienand @var{x} a fixed-point value of a mode wider than @var{m}.
212290075Sobrien
212390075Sobrien@findex ss_truncate
212490075Sobrien@item (ss_truncate:@var{m} @var{x})
212590075SobrienRepresents the result of truncating the value @var{x}
212690075Sobriento machine mode @var{m}, using signed saturation in the case of
212790075Sobrienoverflow.  Both @var{m} and the mode of @var{x} must be fixed-point
212890075Sobrienmodes.
212990075Sobrien
213090075Sobrien@findex us_truncate
213190075Sobrien@item (us_truncate:@var{m} @var{x})
213290075SobrienRepresents the result of truncating the value @var{x}
213390075Sobriento machine mode @var{m}, using unsigned saturation in the case of
213490075Sobrienoverflow.  Both @var{m} and the mode of @var{x} must be fixed-point
213590075Sobrienmodes.
213690075Sobrien
213790075Sobrien@findex float_truncate
213890075Sobrien@item (float_truncate:@var{m} @var{x})
213990075SobrienRepresents the result of truncating the value @var{x}
214090075Sobriento machine mode @var{m}.  @var{m} must be a floating point mode
214190075Sobrienand @var{x} a floating point value of a mode wider than @var{m}.
214290075Sobrien
214390075Sobrien@findex float
214490075Sobrien@item (float:@var{m} @var{x})
214590075SobrienRepresents the result of converting fixed point value @var{x},
214690075Sobrienregarded as signed, to floating point mode @var{m}.
214790075Sobrien
214890075Sobrien@findex unsigned_float
214990075Sobrien@item (unsigned_float:@var{m} @var{x})
215090075SobrienRepresents the result of converting fixed point value @var{x},
215190075Sobrienregarded as unsigned, to floating point mode @var{m}.
215290075Sobrien
215390075Sobrien@findex fix
215490075Sobrien@item (fix:@var{m} @var{x})
215590075SobrienWhen @var{m} is a fixed point mode, represents the result of
215690075Sobrienconverting floating point value @var{x} to mode @var{m}, regarded as
215790075Sobriensigned.  How rounding is done is not specified, so this operation may
215890075Sobrienbe used validly in compiling C code only for integer-valued operands.
215990075Sobrien
216090075Sobrien@findex unsigned_fix
216190075Sobrien@item (unsigned_fix:@var{m} @var{x})
216290075SobrienRepresents the result of converting floating point value @var{x} to
216390075Sobrienfixed point mode @var{m}, regarded as unsigned.  How rounding is done
216490075Sobrienis not specified.
216590075Sobrien
216690075Sobrien@findex fix
216790075Sobrien@item (fix:@var{m} @var{x})
216890075SobrienWhen @var{m} is a floating point mode, represents the result of
216990075Sobrienconverting floating point value @var{x} (valid for mode @var{m}) to an
217090075Sobrieninteger, still represented in floating point mode @var{m}, by rounding
217190075Sobrientowards zero.
217290075Sobrien@end table
217390075Sobrien
217490075Sobrien@node RTL Declarations
217590075Sobrien@section Declarations
217690075Sobrien@cindex RTL declarations
217790075Sobrien@cindex declarations, RTL
217890075Sobrien
217990075SobrienDeclaration expression codes do not represent arithmetic operations
218090075Sobrienbut rather state assertions about their operands.
218190075Sobrien
218290075Sobrien@table @code
218390075Sobrien@findex strict_low_part
218490075Sobrien@cindex @code{subreg}, in @code{strict_low_part}
218590075Sobrien@item (strict_low_part (subreg:@var{m} (reg:@var{n} @var{r}) 0))
218690075SobrienThis expression code is used in only one context: as the destination operand of a
218790075Sobrien@code{set} expression.  In addition, the operand of this expression
218890075Sobrienmust be a non-paradoxical @code{subreg} expression.
218990075Sobrien
219090075SobrienThe presence of @code{strict_low_part} says that the part of the
219190075Sobrienregister which is meaningful in mode @var{n}, but is not part of
219290075Sobrienmode @var{m}, is not to be altered.  Normally, an assignment to such
219390075Sobriena subreg is allowed to have undefined effects on the rest of the
219490075Sobrienregister when @var{m} is less than a word.
219590075Sobrien@end table
219690075Sobrien
219790075Sobrien@node Side Effects
219890075Sobrien@section Side Effect Expressions
219990075Sobrien@cindex RTL side effect expressions
220090075Sobrien
220190075SobrienThe expression codes described so far represent values, not actions.
220290075SobrienBut machine instructions never produce values; they are meaningful
220390075Sobrienonly for their side effects on the state of the machine.  Special
220490075Sobrienexpression codes are used to represent side effects.
220590075Sobrien
220690075SobrienThe body of an instruction is always one of these side effect codes;
220790075Sobrienthe codes described above, which represent values, appear only as
220890075Sobrienthe operands of these.
220990075Sobrien
221090075Sobrien@table @code
221190075Sobrien@findex set
221290075Sobrien@item (set @var{lval} @var{x})
221390075SobrienRepresents the action of storing the value of @var{x} into the place
221490075Sobrienrepresented by @var{lval}.  @var{lval} must be an expression
2215119256Skanrepresenting a place that can be stored in: @code{reg} (or @code{subreg},
2216119256Skan@code{strict_low_part} or @code{zero_extract}), @code{mem}, @code{pc},
2217119256Skan@code{parallel}, or @code{cc0}.
221890075Sobrien
221990075SobrienIf @var{lval} is a @code{reg}, @code{subreg} or @code{mem}, it has a
222090075Sobrienmachine mode; then @var{x} must be valid for that mode.
222190075Sobrien
222290075SobrienIf @var{lval} is a @code{reg} whose machine mode is less than the full
222390075Sobrienwidth of the register, then it means that the part of the register
222490075Sobrienspecified by the machine mode is given the specified value and the
222590075Sobrienrest of the register receives an undefined value.  Likewise, if
222690075Sobrien@var{lval} is a @code{subreg} whose machine mode is narrower than
222790075Sobrienthe mode of the register, the rest of the register can be changed in
222890075Sobrienan undefined way.
222990075Sobrien
2230119256SkanIf @var{lval} is a @code{strict_low_part} or @code{zero_extract} 
2231119256Skanof a @code{subreg}, then the part of the register specified by the
2232119256Skanmachine mode of the @code{subreg} is given the value @var{x} and
2233119256Skanthe rest of the register is not changed.
223490075Sobrien
223590075SobrienIf @var{lval} is @code{(cc0)}, it has no machine mode, and @var{x} may
223690075Sobrienbe either a @code{compare} expression or a value that may have any mode.
223790075SobrienThe latter case represents a ``test'' instruction.  The expression
223890075Sobrien@code{(set (cc0) (reg:@var{m} @var{n}))} is equivalent to
223990075Sobrien@code{(set (cc0) (compare (reg:@var{m} @var{n}) (const_int 0)))}.
224090075SobrienUse the former expression to save space during the compilation.
224190075Sobrien
224290075SobrienIf @var{lval} is a @code{parallel}, it is used to represent the case of
224390075Sobriena function returning a structure in multiple registers.  Each element
224490075Sobrienof the @code{parallel} is an @code{expr_list} whose first operand is a
224590075Sobrien@code{reg} and whose second operand is a @code{const_int} representing the
224690075Sobrienoffset (in bytes) into the structure at which the data in that register
224790075Sobriencorresponds.  The first element may be null to indicate that the structure
224890075Sobrienis also passed partly in memory.
224990075Sobrien
225090075Sobrien@cindex jump instructions and @code{set}
225190075Sobrien@cindex @code{if_then_else} usage
225290075SobrienIf @var{lval} is @code{(pc)}, we have a jump instruction, and the
225390075Sobrienpossibilities for @var{x} are very limited.  It may be a
225490075Sobrien@code{label_ref} expression (unconditional jump).  It may be an
225590075Sobrien@code{if_then_else} (conditional jump), in which case either the
225690075Sobriensecond or the third operand must be @code{(pc)} (for the case which
225790075Sobriendoes not jump) and the other of the two must be a @code{label_ref}
225890075Sobrien(for the case which does jump).  @var{x} may also be a @code{mem} or
225990075Sobrien@code{(plus:SI (pc) @var{y})}, where @var{y} may be a @code{reg} or a
226090075Sobrien@code{mem}; these unusual patterns are used to represent jumps through
226190075Sobrienbranch tables.
226290075Sobrien
226390075SobrienIf @var{lval} is neither @code{(cc0)} nor @code{(pc)}, the mode of
226490075Sobrien@var{lval} must not be @code{VOIDmode} and the mode of @var{x} must be
226590075Sobrienvalid for the mode of @var{lval}.
226690075Sobrien
226790075Sobrien@findex SET_DEST
226890075Sobrien@findex SET_SRC
226990075Sobrien@var{lval} is customarily accessed with the @code{SET_DEST} macro and
227090075Sobrien@var{x} with the @code{SET_SRC} macro.
227190075Sobrien
227290075Sobrien@findex return
227390075Sobrien@item (return)
227490075SobrienAs the sole expression in a pattern, represents a return from the
227590075Sobriencurrent function, on machines where this can be done with one
227690075Sobrieninstruction, such as VAXen.  On machines where a multi-instruction
227790075Sobrien``epilogue'' must be executed in order to return from the function,
227890075Sobrienreturning is done by jumping to a label which precedes the epilogue, and
227990075Sobrienthe @code{return} expression code is never used.
228090075Sobrien
228190075SobrienInside an @code{if_then_else} expression, represents the value to be
228290075Sobrienplaced in @code{pc} to return to the caller.
228390075Sobrien
228490075SobrienNote that an insn pattern of @code{(return)} is logically equivalent to
228590075Sobrien@code{(set (pc) (return))}, but the latter form is never used.
228690075Sobrien
228790075Sobrien@findex call
228890075Sobrien@item (call @var{function} @var{nargs})
228990075SobrienRepresents a function call.  @var{function} is a @code{mem} expression
229090075Sobrienwhose address is the address of the function to be called.
229190075Sobrien@var{nargs} is an expression which can be used for two purposes: on
229290075Sobriensome machines it represents the number of bytes of stack argument; on
229390075Sobrienothers, it represents the number of argument registers.
229490075Sobrien
229590075SobrienEach machine has a standard machine mode which @var{function} must
229690075Sobrienhave.  The machine description defines macro @code{FUNCTION_MODE} to
229790075Sobrienexpand into the requisite mode name.  The purpose of this mode is to
229890075Sobrienspecify what kind of addressing is allowed, on machines where the
229990075Sobrienallowed kinds of addressing depend on the machine mode being
230090075Sobrienaddressed.
230190075Sobrien
230290075Sobrien@findex clobber
230390075Sobrien@item (clobber @var{x})
230490075SobrienRepresents the storing or possible storing of an unpredictable,
230590075Sobrienundescribed value into @var{x}, which must be a @code{reg},
230690075Sobrien@code{scratch}, @code{parallel} or @code{mem} expression.
230790075Sobrien
230890075SobrienOne place this is used is in string instructions that store standard
230990075Sobrienvalues into particular hard registers.  It may not be worth the
231090075Sobrientrouble to describe the values that are stored, but it is essential to
231190075Sobrieninform the compiler that the registers will be altered, lest it
231290075Sobrienattempt to keep data in them across the string instruction.
231390075Sobrien
2314117395SkanIf @var{x} is @code{(mem:BLK (const_int 0))} or 
2315117395Skan@code{(mem:BLK (scratch))}, it means that all memory
231690075Sobrienlocations must be presumed clobbered.  If @var{x} is a @code{parallel},
231790075Sobrienit has the same meaning as a @code{parallel} in a @code{set} expression.
231890075Sobrien
231990075SobrienNote that the machine description classifies certain hard registers as
232090075Sobrien``call-clobbered''.  All function call instructions are assumed by
232190075Sobriendefault to clobber these registers, so there is no need to use
232290075Sobrien@code{clobber} expressions to indicate this fact.  Also, each function
232390075Sobriencall is assumed to have the potential to alter any memory location,
232490075Sobrienunless the function is declared @code{const}.
232590075Sobrien
232690075SobrienIf the last group of expressions in a @code{parallel} are each a
232790075Sobrien@code{clobber} expression whose arguments are @code{reg} or
232890075Sobrien@code{match_scratch} (@pxref{RTL Template}) expressions, the combiner
232990075Sobrienphase can add the appropriate @code{clobber} expressions to an insn it
233090075Sobrienhas constructed when doing so will cause a pattern to be matched.
233190075Sobrien
233290075SobrienThis feature can be used, for example, on a machine that whose multiply
233390075Sobrienand add instructions don't use an MQ register but which has an
233490075Sobrienadd-accumulate instruction that does clobber the MQ register.  Similarly,
233590075Sobriena combined instruction might require a temporary register while the
233690075Sobrienconstituent instructions might not.
233790075Sobrien
233890075SobrienWhen a @code{clobber} expression for a register appears inside a
233990075Sobrien@code{parallel} with other side effects, the register allocator
234090075Sobrienguarantees that the register is unoccupied both before and after that
234190075Sobrieninsn.  However, the reload phase may allocate a register used for one of
234290075Sobrienthe inputs unless the @samp{&} constraint is specified for the selected
234390075Sobrienalternative (@pxref{Modifiers}).  You can clobber either a specific hard
234490075Sobrienregister, a pseudo register, or a @code{scratch} expression; in the
234590075Sobrienlatter two cases, GCC will allocate a hard register that is available
234690075Sobrienthere for use as a temporary.
234790075Sobrien
234890075SobrienFor instructions that require a temporary register, you should use
234990075Sobrien@code{scratch} instead of a pseudo-register because this will allow the
235090075Sobriencombiner phase to add the @code{clobber} when required.  You do this by
235190075Sobriencoding (@code{clobber} (@code{match_scratch} @dots{})).  If you do
235290075Sobrienclobber a pseudo register, use one which appears nowhere else---generate
235390075Sobriena new one each time.  Otherwise, you may confuse CSE@.
235490075Sobrien
235590075SobrienThere is one other known use for clobbering a pseudo register in a
235690075Sobrien@code{parallel}: when one of the input operands of the insn is also
235790075Sobrienclobbered by the insn.  In this case, using the same pseudo register in
235890075Sobrienthe clobber and elsewhere in the insn produces the expected results.
235990075Sobrien
236090075Sobrien@findex use
236190075Sobrien@item (use @var{x})
236290075SobrienRepresents the use of the value of @var{x}.  It indicates that the
236390075Sobrienvalue in @var{x} at this point in the program is needed, even though
236490075Sobrienit may not be apparent why this is so.  Therefore, the compiler will
236590075Sobriennot attempt to delete previous instructions whose only effect is to
236690075Sobrienstore a value in @var{x}.  @var{x} must be a @code{reg} expression.
236790075Sobrien
236890075SobrienIn some situations, it may be tempting to add a @code{use} of a
236990075Sobrienregister in a @code{parallel} to describe a situation where the value
237090075Sobrienof a special register will modify the behavior of the instruction.
237190075SobrienAn hypothetical example might be a pattern for an addition that can
237290075Sobrieneither wrap around or use saturating addition depending on the value
237390075Sobrienof a special control register:
237490075Sobrien
2375103445Skan@smallexample
237696263Sobrien(parallel [(set (reg:SI 2) (unspec:SI [(reg:SI 3)
237790075Sobrien                                       (reg:SI 4)] 0))
237890075Sobrien           (use (reg:SI 1))])
2379103445Skan@end smallexample
238090075Sobrien
238190075Sobrien@noindent
238290075Sobrien
238390075SobrienThis will not work, several of the optimizers only look at expressions
238490075Sobrienlocally; it is very likely that if you have multiple insns with
238590075Sobrienidentical inputs to the @code{unspec}, they will be optimized away even
238690075Sobrienif register 1 changes in between.
238790075Sobrien
238890075SobrienThis means that @code{use} can @emph{only} be used to describe
238990075Sobrienthat the register is live.  You should think twice before adding
239090075Sobrien@code{use} statements, more often you will want to use @code{unspec}
239190075Sobrieninstead.  The @code{use} RTX is most commonly useful to describe that
239290075Sobriena fixed register is implicitly used in an insn.  It is also safe to use
239390075Sobrienin patterns where the compiler knows for other reasons that the result
239490075Sobrienof the whole pattern is variable, such as @samp{movstr@var{m}} or
239590075Sobrien@samp{call} patterns.
239690075Sobrien
239790075SobrienDuring the reload phase, an insn that has a @code{use} as pattern
239890075Sobriencan carry a reg_equal note.  These @code{use} insns will be deleted
239990075Sobrienbefore the reload phase exits.
240090075Sobrien
240190075SobrienDuring the delayed branch scheduling phase, @var{x} may be an insn.
240290075SobrienThis indicates that @var{x} previously was located at this place in the
240390075Sobriencode and its data dependencies need to be taken into account.  These
240490075Sobrien@code{use} insns will be deleted before the delayed branch scheduling
240590075Sobrienphase exits.
240690075Sobrien
240790075Sobrien@findex parallel
240890075Sobrien@item (parallel [@var{x0} @var{x1} @dots{}])
240990075SobrienRepresents several side effects performed in parallel.  The square
241090075Sobrienbrackets stand for a vector; the operand of @code{parallel} is a
241190075Sobrienvector of expressions.  @var{x0}, @var{x1} and so on are individual
241290075Sobrienside effect expressions---expressions of code @code{set}, @code{call},
241390075Sobrien@code{return}, @code{clobber} or @code{use}.
241490075Sobrien
241590075Sobrien``In parallel'' means that first all the values used in the individual
241690075Sobrienside-effects are computed, and second all the actual side-effects are
241790075Sobrienperformed.  For example,
241890075Sobrien
241990075Sobrien@example
242090075Sobrien(parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
242190075Sobrien           (set (mem:SI (reg:SI 1)) (reg:SI 1))])
242290075Sobrien@end example
242390075Sobrien
242490075Sobrien@noindent
242590075Sobriensays unambiguously that the values of hard register 1 and the memory
242690075Sobrienlocation addressed by it are interchanged.  In both places where
242790075Sobrien@code{(reg:SI 1)} appears as a memory address it refers to the value
242890075Sobrienin register 1 @emph{before} the execution of the insn.
242990075Sobrien
243090075SobrienIt follows that it is @emph{incorrect} to use @code{parallel} and
243190075Sobrienexpect the result of one @code{set} to be available for the next one.
243290075SobrienFor example, people sometimes attempt to represent a jump-if-zero
243390075Sobrieninstruction this way:
243490075Sobrien
243590075Sobrien@example
243690075Sobrien(parallel [(set (cc0) (reg:SI 34))
243790075Sobrien           (set (pc) (if_then_else
243890075Sobrien                        (eq (cc0) (const_int 0))
243990075Sobrien                        (label_ref @dots{})
244090075Sobrien                        (pc)))])
244190075Sobrien@end example
244290075Sobrien
244390075Sobrien@noindent
244490075SobrienBut this is incorrect, because it says that the jump condition depends
244590075Sobrienon the condition code value @emph{before} this instruction, not on the
244690075Sobriennew value that is set by this instruction.
244790075Sobrien
244890075Sobrien@cindex peephole optimization, RTL representation
244990075SobrienPeephole optimization, which takes place together with final assembly
245090075Sobriencode output, can produce insns whose patterns consist of a @code{parallel}
245190075Sobrienwhose elements are the operands needed to output the resulting
245290075Sobrienassembler code---often @code{reg}, @code{mem} or constant expressions.
245390075SobrienThis would not be well-formed RTL at any other stage in compilation,
245490075Sobrienbut it is ok then because no further optimization remains to be done.
245590075SobrienHowever, the definition of the macro @code{NOTICE_UPDATE_CC}, if
245690075Sobrienany, must deal with such insns if you define any peephole optimizations.
245790075Sobrien
245890075Sobrien@findex cond_exec
245990075Sobrien@item (cond_exec [@var{cond} @var{expr}])
246090075SobrienRepresents a conditionally executed expression.  The @var{expr} is
246190075Sobrienexecuted only if the @var{cond} is nonzero.  The @var{cond} expression
246290075Sobrienmust not have side-effects, but the @var{expr} may very well have
246390075Sobrienside-effects.
246490075Sobrien
246590075Sobrien@findex sequence
246690075Sobrien@item (sequence [@var{insns} @dots{}])
246790075SobrienRepresents a sequence of insns.  Each of the @var{insns} that appears
246890075Sobrienin the vector is suitable for appearing in the chain of insns, so it
246990075Sobrienmust be an @code{insn}, @code{jump_insn}, @code{call_insn},
247090075Sobrien@code{code_label}, @code{barrier} or @code{note}.
247190075Sobrien
247290075SobrienA @code{sequence} RTX is never placed in an actual insn during RTL
247390075Sobriengeneration.  It represents the sequence of insns that result from a
247490075Sobrien@code{define_expand} @emph{before} those insns are passed to
247590075Sobrien@code{emit_insn} to insert them in the chain of insns.  When actually
247690075Sobrieninserted, the individual sub-insns are separated out and the
247790075Sobrien@code{sequence} is forgotten.
247890075Sobrien
247990075SobrienAfter delay-slot scheduling is completed, an insn and all the insns that
248090075Sobrienreside in its delay slots are grouped together into a @code{sequence}.
248190075SobrienThe insn requiring the delay slot is the first insn in the vector;
248290075Sobriensubsequent insns are to be placed in the delay slot.
248390075Sobrien
248490075Sobrien@code{INSN_ANNULLED_BRANCH_P} is set on an insn in a delay slot to
248590075Sobrienindicate that a branch insn should be used that will conditionally annul
248690075Sobrienthe effect of the insns in the delay slots.  In such a case,
248790075Sobrien@code{INSN_FROM_TARGET_P} indicates that the insn is from the target of
248890075Sobrienthe branch and should be executed only if the branch is taken; otherwise
248990075Sobrienthe insn should be executed only if the branch is not taken.
249090075Sobrien@xref{Delay Slots}.
249190075Sobrien@end table
249290075Sobrien
249390075SobrienThese expression codes appear in place of a side effect, as the body of
249490075Sobrienan insn, though strictly speaking they do not always describe side
249590075Sobrieneffects as such:
249690075Sobrien
249790075Sobrien@table @code
249890075Sobrien@findex asm_input
249990075Sobrien@item (asm_input @var{s})
250090075SobrienRepresents literal assembler code as described by the string @var{s}.
250190075Sobrien
250290075Sobrien@findex unspec
250390075Sobrien@findex unspec_volatile
250490075Sobrien@item (unspec [@var{operands} @dots{}] @var{index})
250590075Sobrien@itemx (unspec_volatile [@var{operands} @dots{}] @var{index})
250690075SobrienRepresents a machine-specific operation on @var{operands}.  @var{index}
250790075Sobrienselects between multiple machine-specific operations.
250890075Sobrien@code{unspec_volatile} is used for volatile operations and operations
250990075Sobrienthat may trap; @code{unspec} is used for other operations.
251090075Sobrien
251190075SobrienThese codes may appear inside a @code{pattern} of an
251290075Sobrieninsn, inside a @code{parallel}, or inside an expression.
251390075Sobrien
251490075Sobrien@findex addr_vec
251590075Sobrien@item (addr_vec:@var{m} [@var{lr0} @var{lr1} @dots{}])
251690075SobrienRepresents a table of jump addresses.  The vector elements @var{lr0},
251790075Sobrienetc., are @code{label_ref} expressions.  The mode @var{m} specifies
251890075Sobrienhow much space is given to each address; normally @var{m} would be
251990075Sobrien@code{Pmode}.
252090075Sobrien
252190075Sobrien@findex addr_diff_vec
252290075Sobrien@item (addr_diff_vec:@var{m} @var{base} [@var{lr0} @var{lr1} @dots{}] @var{min} @var{max} @var{flags})
252390075SobrienRepresents a table of jump addresses expressed as offsets from
252490075Sobrien@var{base}.  The vector elements @var{lr0}, etc., are @code{label_ref}
252590075Sobrienexpressions and so is @var{base}.  The mode @var{m} specifies how much
252690075Sobrienspace is given to each address-difference.  @var{min} and @var{max}
252790075Sobrienare set up by branch shortening and hold a label with a minimum and a
252890075Sobrienmaximum address, respectively.  @var{flags} indicates the relative
252990075Sobrienposition of @var{base}, @var{min} and @var{max} to the containing insn
253090075Sobrienand of @var{min} and @var{max} to @var{base}.  See rtl.def for details.
253190075Sobrien
253290075Sobrien@findex prefetch
253390075Sobrien@item (prefetch:@var{m} @var{addr} @var{rw} @var{locality})
253490075SobrienRepresents prefetch of memory at address @var{addr}.
253590075SobrienOperand @var{rw} is 1 if the prefetch is for data to be written, 0 otherwise;
253690075Sobrientargets that do not support write prefetches should treat this as a normal
253790075Sobrienprefetch.
253890075SobrienOperand @var{locality} specifies the amount of temporal locality; 0 if there
253990075Sobrienis none or 1, 2, or 3 for increasing levels of temporal locality;
254090075Sobrientargets that do not support locality hints should ignore this.
254190075Sobrien
254290075SobrienThis insn is used to minimize cache-miss latency by moving data into a
254390075Sobriencache before it is accessed.  It should use only non-faulting data prefetch
254490075Sobrieninstructions.
254590075Sobrien@end table
254690075Sobrien
254790075Sobrien@node Incdec
254890075Sobrien@section Embedded Side-Effects on Addresses
254990075Sobrien@cindex RTL preincrement
255090075Sobrien@cindex RTL postincrement
255190075Sobrien@cindex RTL predecrement
255290075Sobrien@cindex RTL postdecrement
255390075Sobrien
255490075SobrienSix special side-effect expression codes appear as memory addresses.
255590075Sobrien
255690075Sobrien@table @code
255790075Sobrien@findex pre_dec
255890075Sobrien@item (pre_dec:@var{m} @var{x})
255990075SobrienRepresents the side effect of decrementing @var{x} by a standard
256090075Sobrienamount and represents also the value that @var{x} has after being
256190075Sobriendecremented.  @var{x} must be a @code{reg} or @code{mem}, but most
256290075Sobrienmachines allow only a @code{reg}.  @var{m} must be the machine mode
256390075Sobrienfor pointers on the machine in use.  The amount @var{x} is decremented
256490075Sobrienby is the length in bytes of the machine mode of the containing memory
256590075Sobrienreference of which this expression serves as the address.  Here is an
256690075Sobrienexample of its use:
256790075Sobrien
256890075Sobrien@example
256990075Sobrien(mem:DF (pre_dec:SI (reg:SI 39)))
257090075Sobrien@end example
257190075Sobrien
257290075Sobrien@noindent
257390075SobrienThis says to decrement pseudo register 39 by the length of a @code{DFmode}
257490075Sobrienvalue and use the result to address a @code{DFmode} value.
257590075Sobrien
257690075Sobrien@findex pre_inc
257790075Sobrien@item (pre_inc:@var{m} @var{x})
257890075SobrienSimilar, but specifies incrementing @var{x} instead of decrementing it.
257990075Sobrien
258090075Sobrien@findex post_dec
258190075Sobrien@item (post_dec:@var{m} @var{x})
258290075SobrienRepresents the same side effect as @code{pre_dec} but a different
258390075Sobrienvalue.  The value represented here is the value @var{x} has @i{before}
258490075Sobrienbeing decremented.
258590075Sobrien
258690075Sobrien@findex post_inc
258790075Sobrien@item (post_inc:@var{m} @var{x})
258890075SobrienSimilar, but specifies incrementing @var{x} instead of decrementing it.
258990075Sobrien
259090075Sobrien@findex post_modify
259190075Sobrien@item (post_modify:@var{m} @var{x} @var{y})
259290075Sobrien
259390075SobrienRepresents the side effect of setting @var{x} to @var{y} and
259490075Sobrienrepresents @var{x} before @var{x} is modified.  @var{x} must be a
259590075Sobrien@code{reg} or @code{mem}, but most machines allow only a @code{reg}.
259690075Sobrien@var{m} must be the machine mode for pointers on the machine in use.
259790075Sobrien
259890075SobrienThe expression @var{y} must be one of three forms:
259990075Sobrien@table @code
260090075Sobrien@code{(plus:@var{m} @var{x} @var{z})},
260190075Sobrien@code{(minus:@var{m} @var{x} @var{z})}, or
260290075Sobrien@code{(plus:@var{m} @var{x} @var{i})},
260390075Sobrien@end table
260490075Sobrienwhere @var{z} is an index register and @var{i} is a constant.
260590075Sobrien
260690075SobrienHere is an example of its use:
260790075Sobrien
2608103445Skan@smallexample
260990075Sobrien(mem:SF (post_modify:SI (reg:SI 42) (plus (reg:SI 42)
261090075Sobrien                                          (reg:SI 48))))
2611103445Skan@end smallexample
261290075Sobrien
261390075SobrienThis says to modify pseudo register 42 by adding the contents of pseudo
261490075Sobrienregister 48 to it, after the use of what ever 42 points to.
261590075Sobrien
2616117395Skan@findex pre_modify
261790075Sobrien@item (pre_modify:@var{m} @var{x} @var{expr})
261890075SobrienSimilar except side effects happen before the use.
261990075Sobrien@end table
262090075Sobrien
262190075SobrienThese embedded side effect expressions must be used with care.  Instruction
262290075Sobrienpatterns may not use them.  Until the @samp{flow} pass of the compiler,
262390075Sobrienthey may occur only to represent pushes onto the stack.  The @samp{flow}
262490075Sobrienpass finds cases where registers are incremented or decremented in one
262590075Sobrieninstruction and used as an address shortly before or after; these cases are
262690075Sobrienthen transformed to use pre- or post-increment or -decrement.
262790075Sobrien
262890075SobrienIf a register used as the operand of these expressions is used in
262990075Sobrienanother address in an insn, the original value of the register is used.
263090075SobrienUses of the register outside of an address are not permitted within the
263190075Sobriensame insn as a use in an embedded side effect expression because such
263290075Sobrieninsns behave differently on different machines and hence must be treated
263390075Sobrienas ambiguous and disallowed.
263490075Sobrien
263590075SobrienAn instruction that can be represented with an embedded side effect
263690075Sobriencould also be represented using @code{parallel} containing an additional
263790075Sobrien@code{set} to describe how the address register is altered.  This is not
263890075Sobriendone because machines that allow these operations at all typically
263990075Sobrienallow them wherever a memory address is called for.  Describing them as
264090075Sobrienadditional parallel stores would require doubling the number of entries
264190075Sobrienin the machine description.
264290075Sobrien
264390075Sobrien@node Assembler
264490075Sobrien@section Assembler Instructions as Expressions
264590075Sobrien@cindex assembler instructions in RTL
264690075Sobrien
264790075Sobrien@cindex @code{asm_operands}, usage
264890075SobrienThe RTX code @code{asm_operands} represents a value produced by a
264990075Sobrienuser-specified assembler instruction.  It is used to represent
265090075Sobrienan @code{asm} statement with arguments.  An @code{asm} statement with
265190075Sobriena single output operand, like this:
265290075Sobrien
265390075Sobrien@smallexample
265490075Sobrienasm ("foo %1,%2,%0" : "=a" (outputvar) : "g" (x + y), "di" (*z));
265590075Sobrien@end smallexample
265690075Sobrien
265790075Sobrien@noindent
265890075Sobrienis represented using a single @code{asm_operands} RTX which represents
265990075Sobrienthe value that is stored in @code{outputvar}:
266090075Sobrien
266190075Sobrien@smallexample
266290075Sobrien(set @var{rtx-for-outputvar}
266390075Sobrien     (asm_operands "foo %1,%2,%0" "a" 0
266490075Sobrien                   [@var{rtx-for-addition-result} @var{rtx-for-*z}]
266590075Sobrien                   [(asm_input:@var{m1} "g")
266690075Sobrien                    (asm_input:@var{m2} "di")]))
266790075Sobrien@end smallexample
266890075Sobrien
266990075Sobrien@noindent
267090075SobrienHere the operands of the @code{asm_operands} RTX are the assembler
267190075Sobrientemplate string, the output-operand's constraint, the index-number of the
267290075Sobrienoutput operand among the output operands specified, a vector of input
267390075Sobrienoperand RTX's, and a vector of input-operand modes and constraints.  The
267490075Sobrienmode @var{m1} is the mode of the sum @code{x+y}; @var{m2} is that of
267590075Sobrien@code{*z}.
267690075Sobrien
267790075SobrienWhen an @code{asm} statement has multiple output values, its insn has
267890075Sobrienseveral such @code{set} RTX's inside of a @code{parallel}.  Each @code{set}
267990075Sobriencontains a @code{asm_operands}; all of these share the same assembler
268090075Sobrientemplate and vectors, but each contains the constraint for the respective
268190075Sobrienoutput operand.  They are also distinguished by the output-operand index
268290075Sobriennumber, which is 0, 1, @dots{} for successive output operands.
268390075Sobrien
268490075Sobrien@node Insns
268590075Sobrien@section Insns
268690075Sobrien@cindex insns
268790075Sobrien
268890075SobrienThe RTL representation of the code for a function is a doubly-linked
268990075Sobrienchain of objects called @dfn{insns}.  Insns are expressions with
269090075Sobrienspecial codes that are used for no other purpose.  Some insns are
269190075Sobrienactual instructions; others represent dispatch tables for @code{switch}
269290075Sobrienstatements; others represent labels to jump to or various sorts of
269390075Sobriendeclarative information.
269490075Sobrien
269590075SobrienIn addition to its own specific data, each insn must have a unique
269690075Sobrienid-number that distinguishes it from all other insns in the current
269790075Sobrienfunction (after delayed branch scheduling, copies of an insn with the
269890075Sobriensame id-number may be present in multiple places in a function, but
269990075Sobrienthese copies will always be identical and will only appear inside a
270090075Sobrien@code{sequence}), and chain pointers to the preceding and following
270190075Sobrieninsns.  These three fields occupy the same position in every insn,
270290075Sobrienindependent of the expression code of the insn.  They could be accessed
270390075Sobrienwith @code{XEXP} and @code{XINT}, but instead three special macros are
270490075Sobrienalways used:
270590075Sobrien
270690075Sobrien@table @code
270790075Sobrien@findex INSN_UID
270890075Sobrien@item INSN_UID (@var{i})
270990075SobrienAccesses the unique id of insn @var{i}.
271090075Sobrien
271190075Sobrien@findex PREV_INSN
271290075Sobrien@item PREV_INSN (@var{i})
271390075SobrienAccesses the chain pointer to the insn preceding @var{i}.
271490075SobrienIf @var{i} is the first insn, this is a null pointer.
271590075Sobrien
271690075Sobrien@findex NEXT_INSN
271790075Sobrien@item NEXT_INSN (@var{i})
271890075SobrienAccesses the chain pointer to the insn following @var{i}.
271990075SobrienIf @var{i} is the last insn, this is a null pointer.
272090075Sobrien@end table
272190075Sobrien
272290075Sobrien@findex get_insns
272390075Sobrien@findex get_last_insn
272490075SobrienThe first insn in the chain is obtained by calling @code{get_insns}; the
272590075Sobrienlast insn is the result of calling @code{get_last_insn}.  Within the
272690075Sobrienchain delimited by these insns, the @code{NEXT_INSN} and
272790075Sobrien@code{PREV_INSN} pointers must always correspond: if @var{insn} is not
272890075Sobrienthe first insn,
272990075Sobrien
273090075Sobrien@example
273190075SobrienNEXT_INSN (PREV_INSN (@var{insn})) == @var{insn}
273290075Sobrien@end example
273390075Sobrien
273490075Sobrien@noindent
273590075Sobrienis always true and if @var{insn} is not the last insn,
273690075Sobrien
273790075Sobrien@example
273890075SobrienPREV_INSN (NEXT_INSN (@var{insn})) == @var{insn}
273990075Sobrien@end example
274090075Sobrien
274190075Sobrien@noindent
274290075Sobrienis always true.
274390075Sobrien
274490075SobrienAfter delay slot scheduling, some of the insns in the chain might be
274590075Sobrien@code{sequence} expressions, which contain a vector of insns.  The value
274690075Sobrienof @code{NEXT_INSN} in all but the last of these insns is the next insn
274790075Sobrienin the vector; the value of @code{NEXT_INSN} of the last insn in the vector
274890075Sobrienis the same as the value of @code{NEXT_INSN} for the @code{sequence} in
274990075Sobrienwhich it is contained.  Similar rules apply for @code{PREV_INSN}.
275090075Sobrien
275190075SobrienThis means that the above invariants are not necessarily true for insns
275290075Sobrieninside @code{sequence} expressions.  Specifically, if @var{insn} is the
275390075Sobrienfirst insn in a @code{sequence}, @code{NEXT_INSN (PREV_INSN (@var{insn}))}
275490075Sobrienis the insn containing the @code{sequence} expression, as is the value
275590075Sobrienof @code{PREV_INSN (NEXT_INSN (@var{insn}))} if @var{insn} is the last
275690075Sobrieninsn in the @code{sequence} expression.  You can use these expressions
275790075Sobriento find the containing @code{sequence} expression.
275890075Sobrien
275990075SobrienEvery insn has one of the following six expression codes:
276090075Sobrien
276190075Sobrien@table @code
276290075Sobrien@findex insn
276390075Sobrien@item insn
276490075SobrienThe expression code @code{insn} is used for instructions that do not jump
276590075Sobrienand do not do function calls.  @code{sequence} expressions are always
276690075Sobriencontained in insns with code @code{insn} even if one of those insns
276790075Sobrienshould jump or do function calls.
276890075Sobrien
276990075SobrienInsns with code @code{insn} have four additional fields beyond the three
277090075Sobrienmandatory ones listed above.  These four are described in a table below.
277190075Sobrien
277290075Sobrien@findex jump_insn
277390075Sobrien@item jump_insn
277490075SobrienThe expression code @code{jump_insn} is used for instructions that may
277590075Sobrienjump (or, more generally, may contain @code{label_ref} expressions).  If
277690075Sobrienthere is an instruction to return from the current function, it is
277790075Sobrienrecorded as a @code{jump_insn}.
277890075Sobrien
277990075Sobrien@findex JUMP_LABEL
278090075Sobrien@code{jump_insn} insns have the same extra fields as @code{insn} insns,
278190075Sobrienaccessed in the same way and in addition contain a field
278290075Sobrien@code{JUMP_LABEL} which is defined once jump optimization has completed.
278390075Sobrien
278490075SobrienFor simple conditional and unconditional jumps, this field contains
278590075Sobrienthe @code{code_label} to which this insn will (possibly conditionally)
278690075Sobrienbranch.  In a more complex jump, @code{JUMP_LABEL} records one of the
278790075Sobrienlabels that the insn refers to; the only way to find the others is to
278890075Sobrienscan the entire body of the insn.  In an @code{addr_vec},
278990075Sobrien@code{JUMP_LABEL} is @code{NULL_RTX}.
279090075Sobrien
279190075SobrienReturn insns count as jumps, but since they do not refer to any
279290075Sobrienlabels, their @code{JUMP_LABEL} is @code{NULL_RTX}.
279390075Sobrien
279490075Sobrien@findex call_insn
279590075Sobrien@item call_insn
279690075SobrienThe expression code @code{call_insn} is used for instructions that may do
279790075Sobrienfunction calls.  It is important to distinguish these instructions because
279890075Sobrienthey imply that certain registers and memory locations may be altered
279990075Sobrienunpredictably.
280090075Sobrien
280190075Sobrien@findex CALL_INSN_FUNCTION_USAGE
280290075Sobrien@code{call_insn} insns have the same extra fields as @code{insn} insns,
280390075Sobrienaccessed in the same way and in addition contain a field
280490075Sobrien@code{CALL_INSN_FUNCTION_USAGE}, which contains a list (chain of
280590075Sobrien@code{expr_list} expressions) containing @code{use} and @code{clobber}
280690075Sobrienexpressions that denote hard registers and @code{MEM}s used or
280790075Sobrienclobbered by the called function.
280890075Sobrien
280990075SobrienA @code{MEM} generally points to a stack slots in which arguments passed
281090075Sobriento the libcall by reference (@pxref{Register Arguments,
281190075SobrienFUNCTION_ARG_PASS_BY_REFERENCE}) are stored.  If the argument is
281290075Sobriencaller-copied (@pxref{Register Arguments, FUNCTION_ARG_CALLEE_COPIES}),
281390075Sobrienthe stack slot will be mentioned in @code{CLOBBER} and @code{USE}
281490075Sobrienentries; if it's callee-copied, only a @code{USE} will appear, and the
281590075Sobrien@code{MEM} may point to addresses that are not stack slots.  These
281690075Sobrien@code{MEM}s are used only in libcalls, because, unlike regular function
281790075Sobriencalls, @code{CONST_CALL}s (which libcalls generally are, @pxref{Flags,
281890075SobrienCONST_CALL_P}) aren't assumed to read and write all memory, so flow
281990075Sobrienwould consider the stores dead and remove them.  Note that, since a
282090075Sobrienlibcall must never return values in memory (@pxref{Aggregate Return,
282190075SobrienRETURN_IN_MEMORY}), there will never be a @code{CLOBBER} for a memory
282290075Sobrienaddress holding a return value.
282390075Sobrien
282490075Sobrien@code{CLOBBER}ed registers in this list augment registers specified in
282590075Sobrien@code{CALL_USED_REGISTERS} (@pxref{Register Basics}).
282690075Sobrien
282790075Sobrien@findex code_label
282890075Sobrien@findex CODE_LABEL_NUMBER
282990075Sobrien@item code_label
283090075SobrienA @code{code_label} insn represents a label that a jump insn can jump
283190075Sobriento.  It contains two special fields of data in addition to the three
283290075Sobrienstandard ones.  @code{CODE_LABEL_NUMBER} is used to hold the @dfn{label
283390075Sobriennumber}, a number that identifies this label uniquely among all the
283490075Sobrienlabels in the compilation (not just in the current function).
283590075SobrienUltimately, the label is represented in the assembler output as an
283690075Sobrienassembler label, usually of the form @samp{L@var{n}} where @var{n} is
283790075Sobrienthe label number.
283890075Sobrien
283990075SobrienWhen a @code{code_label} appears in an RTL expression, it normally
284090075Sobrienappears within a @code{label_ref} which represents the address of
284190075Sobrienthe label, as a number.
284290075Sobrien
284390075SobrienBesides as a @code{code_label}, a label can also be represented as a
284490075Sobrien@code{note} of type @code{NOTE_INSN_DELETED_LABEL}.
284590075Sobrien
284690075Sobrien@findex LABEL_NUSES
284790075SobrienThe field @code{LABEL_NUSES} is only defined once the jump optimization
2848117395Skanphase is completed.  It contains the number of times this label is
284990075Sobrienreferenced in the current function.
285090075Sobrien
2851117395Skan@findex LABEL_KIND
2852117395Skan@findex SET_LABEL_KIND
2853117395Skan@findex LABEL_ALT_ENTRY_P
2854117395Skan@cindex alternate entry points
2855117395SkanThe field @code{LABEL_KIND} differentiates four different types of
2856117395Skanlabels: @code{LABEL_NORMAL}, @code{LABEL_STATIC_ENTRY},
2857117395Skan@code{LABEL_GLOBAL_ENTRY}, and @code{LABEL_WEAK_ENTRY}.  The only labels
2858117395Skanthat do not have type @code{LABEL_NORMAL} are @dfn{alternate entry
2859117395Skanpoints} to the current function.  These may be static (visible only in
2860117395Skanthe containing translation unit), global (exposed to all translation
2861117395Skanunits), or weak (global, but can be overridden by another symbol with the
2862117395Skansame name).
286390075Sobrien
2864117395SkanMuch of the compiler treats all four kinds of label identically.  Some
2865117395Skanof it needs to know whether or not a label is an alternate entry point;
2866117395Skanfor this purpose, the macro @code{LABEL_ALT_ENTRY_P} is provided.  It is
2867117395Skanequivalent to testing whether @samp{LABEL_KIND (label) == LABEL_NORMAL}.
2868117395SkanThe only place that cares about the distinction between static, global,
2869117395Skanand weak alternate entry points, besides the front-end code that creates
2870117395Skanthem, is the function @code{output_alternate_entry_point}, in
2871117395Skan@file{final.c}.
2872117395Skan
2873117395SkanTo set the kind of a label, use the @code{SET_LABEL_KIND} macro.
2874117395Skan
287590075Sobrien@findex barrier
287690075Sobrien@item barrier
287790075SobrienBarriers are placed in the instruction stream when control cannot flow
287890075Sobrienpast them.  They are placed after unconditional jump instructions to
287990075Sobrienindicate that the jumps are unconditional and after calls to
288090075Sobrien@code{volatile} functions, which do not return (e.g., @code{exit}).
288190075SobrienThey contain no information beyond the three standard fields.
288290075Sobrien
288390075Sobrien@findex note
288490075Sobrien@findex NOTE_LINE_NUMBER
288590075Sobrien@findex NOTE_SOURCE_FILE
288690075Sobrien@item note
288790075Sobrien@code{note} insns are used to represent additional debugging and
288890075Sobriendeclarative information.  They contain two nonstandard fields, an
288990075Sobrieninteger which is accessed with the macro @code{NOTE_LINE_NUMBER} and a
289090075Sobrienstring accessed with @code{NOTE_SOURCE_FILE}.
289190075Sobrien
289290075SobrienIf @code{NOTE_LINE_NUMBER} is positive, the note represents the
289390075Sobrienposition of a source line and @code{NOTE_SOURCE_FILE} is the source file name
289490075Sobrienthat the line came from.  These notes control generation of line
289590075Sobriennumber data in the assembler output.
289690075Sobrien
289790075SobrienOtherwise, @code{NOTE_LINE_NUMBER} is not really a line number but a
289890075Sobriencode with one of the following values (and @code{NOTE_SOURCE_FILE}
289990075Sobrienmust contain a null pointer):
290090075Sobrien
290190075Sobrien@table @code
290290075Sobrien@findex NOTE_INSN_DELETED
290390075Sobrien@item NOTE_INSN_DELETED
290490075SobrienSuch a note is completely ignorable.  Some passes of the compiler
290590075Sobriendelete insns by altering them into notes of this kind.
290690075Sobrien
290790075Sobrien@findex NOTE_INSN_DELETED_LABEL
290890075Sobrien@item NOTE_INSN_DELETED_LABEL
290990075SobrienThis marks what used to be a @code{code_label}, but was not used for other
291090075Sobrienpurposes than taking its address and was transformed to mark that no
291190075Sobriencode jumps to it.
291290075Sobrien
291390075Sobrien@findex NOTE_INSN_BLOCK_BEG
291490075Sobrien@findex NOTE_INSN_BLOCK_END
291590075Sobrien@item NOTE_INSN_BLOCK_BEG
291690075Sobrien@itemx NOTE_INSN_BLOCK_END
291790075SobrienThese types of notes indicate the position of the beginning and end
291890075Sobrienof a level of scoping of variable names.  They control the output
291990075Sobrienof debugging information.
292090075Sobrien
292190075Sobrien@findex NOTE_INSN_EH_REGION_BEG
292290075Sobrien@findex NOTE_INSN_EH_REGION_END
292390075Sobrien@item NOTE_INSN_EH_REGION_BEG
292490075Sobrien@itemx NOTE_INSN_EH_REGION_END
292590075SobrienThese types of notes indicate the position of the beginning and end of a
292690075Sobrienlevel of scoping for exception handling.  @code{NOTE_BLOCK_NUMBER}
292790075Sobrienidentifies which @code{CODE_LABEL} or @code{note} of type
292890075Sobrien@code{NOTE_INSN_DELETED_LABEL} is associated with the given region.
292990075Sobrien
293090075Sobrien@findex NOTE_INSN_LOOP_BEG
293190075Sobrien@findex NOTE_INSN_LOOP_END
293290075Sobrien@item NOTE_INSN_LOOP_BEG
293390075Sobrien@itemx NOTE_INSN_LOOP_END
293490075SobrienThese types of notes indicate the position of the beginning and end
293590075Sobrienof a @code{while} or @code{for} loop.  They enable the loop optimizer
293690075Sobriento find loops quickly.
293790075Sobrien
293890075Sobrien@findex NOTE_INSN_LOOP_CONT
293990075Sobrien@item NOTE_INSN_LOOP_CONT
294090075SobrienAppears at the place in a loop that @code{continue} statements jump to.
294190075Sobrien
294290075Sobrien@findex NOTE_INSN_LOOP_VTOP
294390075Sobrien@item NOTE_INSN_LOOP_VTOP
294490075SobrienThis note indicates the place in a loop where the exit test begins for
294590075Sobrienthose loops in which the exit test has been duplicated.  This position
294690075Sobrienbecomes another virtual start of the loop when considering loop
294790075Sobrieninvariants.
294890075Sobrien
294990075Sobrien@findex NOTE_INSN_FUNCTION_END
295090075Sobrien@item NOTE_INSN_FUNCTION_END
295190075SobrienAppears near the end of the function body, just before the label that
295290075Sobrien@code{return} statements jump to (on machine where a single instruction
295390075Sobriendoes not suffice for returning).  This note may be deleted by jump
295490075Sobrienoptimization.
295590075Sobrien
295690075Sobrien@findex NOTE_INSN_SETJMP
295790075Sobrien@item NOTE_INSN_SETJMP
295890075SobrienAppears following each call to @code{setjmp} or a related function.
295990075Sobrien@end table
296090075Sobrien
296190075SobrienThese codes are printed symbolically when they appear in debugging dumps.
296290075Sobrien@end table
296390075Sobrien
296490075Sobrien@cindex @code{TImode}, in @code{insn}
296590075Sobrien@cindex @code{HImode}, in @code{insn}
296690075Sobrien@cindex @code{QImode}, in @code{insn}
296790075SobrienThe machine mode of an insn is normally @code{VOIDmode}, but some
296890075Sobrienphases use the mode for various purposes.
296990075Sobrien
297090075SobrienThe common subexpression elimination pass sets the mode of an insn to
297190075Sobrien@code{QImode} when it is the first insn in a block that has already
297290075Sobrienbeen processed.
297390075Sobrien
297490075SobrienThe second Haifa scheduling pass, for targets that can multiple issue,
297590075Sobriensets the mode of an insn to @code{TImode} when it is believed that the
297690075Sobrieninstruction begins an issue group.  That is, when the instruction
297790075Sobriencannot issue simultaneously with the previous.  This may be relied on
297890075Sobrienby later passes, in particular machine-dependent reorg.
297990075Sobrien
298090075SobrienHere is a table of the extra fields of @code{insn}, @code{jump_insn}
298190075Sobrienand @code{call_insn} insns:
298290075Sobrien
298390075Sobrien@table @code
298490075Sobrien@findex PATTERN
298590075Sobrien@item PATTERN (@var{i})
298690075SobrienAn expression for the side effect performed by this insn.  This must be
298790075Sobrienone of the following codes: @code{set}, @code{call}, @code{use},
298890075Sobrien@code{clobber}, @code{return}, @code{asm_input}, @code{asm_output},
298990075Sobrien@code{addr_vec}, @code{addr_diff_vec}, @code{trap_if}, @code{unspec},
299090075Sobrien@code{unspec_volatile}, @code{parallel}, @code{cond_exec}, or @code{sequence}.  If it is a @code{parallel},
299190075Sobrieneach element of the @code{parallel} must be one these codes, except that
299290075Sobrien@code{parallel} expressions cannot be nested and @code{addr_vec} and
299390075Sobrien@code{addr_diff_vec} are not permitted inside a @code{parallel} expression.
299490075Sobrien
299590075Sobrien@findex INSN_CODE
299690075Sobrien@item INSN_CODE (@var{i})
299790075SobrienAn integer that says which pattern in the machine description matches
299890075Sobrienthis insn, or @minus{}1 if the matching has not yet been attempted.
299990075Sobrien
300090075SobrienSuch matching is never attempted and this field remains @minus{}1 on an insn
300190075Sobrienwhose pattern consists of a single @code{use}, @code{clobber},
300290075Sobrien@code{asm_input}, @code{addr_vec} or @code{addr_diff_vec} expression.
300390075Sobrien
300490075Sobrien@findex asm_noperands
300590075SobrienMatching is also never attempted on insns that result from an @code{asm}
300690075Sobrienstatement.  These contain at least one @code{asm_operands} expression.
300790075SobrienThe function @code{asm_noperands} returns a non-negative value for
300890075Sobriensuch insns.
300990075Sobrien
301090075SobrienIn the debugging output, this field is printed as a number followed by
301190075Sobriena symbolic representation that locates the pattern in the @file{md}
301290075Sobrienfile as some small positive or negative offset from a named pattern.
301390075Sobrien
301490075Sobrien@findex LOG_LINKS
301590075Sobrien@item LOG_LINKS (@var{i})
301690075SobrienA list (chain of @code{insn_list} expressions) giving information about
301790075Sobriendependencies between instructions within a basic block.  Neither a jump
301890075Sobriennor a label may come between the related insns.
301990075Sobrien
302090075Sobrien@findex REG_NOTES
302190075Sobrien@item REG_NOTES (@var{i})
302290075SobrienA list (chain of @code{expr_list} and @code{insn_list} expressions)
302390075Sobriengiving miscellaneous information about the insn.  It is often
302490075Sobrieninformation pertaining to the registers used in this insn.
302590075Sobrien@end table
302690075Sobrien
302790075SobrienThe @code{LOG_LINKS} field of an insn is a chain of @code{insn_list}
302890075Sobrienexpressions.  Each of these has two operands: the first is an insn,
302990075Sobrienand the second is another @code{insn_list} expression (the next one in
303090075Sobrienthe chain).  The last @code{insn_list} in the chain has a null pointer
303190075Sobrienas second operand.  The significant thing about the chain is which
303290075Sobrieninsns appear in it (as first operands of @code{insn_list}
303390075Sobrienexpressions).  Their order is not significant.
303490075Sobrien
303590075SobrienThis list is originally set up by the flow analysis pass; it is a null
303690075Sobrienpointer until then.  Flow only adds links for those data dependencies
303790075Sobrienwhich can be used for instruction combination.  For each insn, the flow
303890075Sobrienanalysis pass adds a link to insns which store into registers values
303990075Sobrienthat are used for the first time in this insn.  The instruction
304090075Sobrienscheduling pass adds extra links so that every dependence will be
304190075Sobrienrepresented.  Links represent data dependencies, antidependencies and
304290075Sobrienoutput dependencies; the machine mode of the link distinguishes these
304390075Sobrienthree types: antidependencies have mode @code{REG_DEP_ANTI}, output
304490075Sobriendependencies have mode @code{REG_DEP_OUTPUT}, and data dependencies have
304590075Sobrienmode @code{VOIDmode}.
304690075Sobrien
304790075SobrienThe @code{REG_NOTES} field of an insn is a chain similar to the
304890075Sobrien@code{LOG_LINKS} field but it includes @code{expr_list} expressions in
304990075Sobrienaddition to @code{insn_list} expressions.  There are several kinds of
305090075Sobrienregister notes, which are distinguished by the machine mode, which in a
305190075Sobrienregister note is really understood as being an @code{enum reg_note}.
305290075SobrienThe first operand @var{op} of the note is data whose meaning depends on
305390075Sobrienthe kind of note.
305490075Sobrien
305590075Sobrien@findex REG_NOTE_KIND
305690075Sobrien@findex PUT_REG_NOTE_KIND
305790075SobrienThe macro @code{REG_NOTE_KIND (@var{x})} returns the kind of
305890075Sobrienregister note.  Its counterpart, the macro @code{PUT_REG_NOTE_KIND
305990075Sobrien(@var{x}, @var{newkind})} sets the register note type of @var{x} to be
306090075Sobrien@var{newkind}.
306190075Sobrien
306290075SobrienRegister notes are of three classes: They may say something about an
306390075Sobrieninput to an insn, they may say something about an output of an insn, or
306490075Sobrienthey may create a linkage between two insns.  There are also a set
306590075Sobrienof values that are only used in @code{LOG_LINKS}.
306690075Sobrien
306790075SobrienThese register notes annotate inputs to an insn:
306890075Sobrien
306990075Sobrien@table @code
307090075Sobrien@findex REG_DEAD
307190075Sobrien@item REG_DEAD
307290075SobrienThe value in @var{op} dies in this insn; that is to say, altering the
307390075Sobrienvalue immediately after this insn would not affect the future behavior
307490075Sobrienof the program.
307590075Sobrien
307690075SobrienIt does not follow that the register @var{op} has no useful value after
307790075Sobrienthis insn since @var{op} is not necessarily modified by this insn.
307890075SobrienRather, no subsequent instruction uses the contents of @var{op}.
307990075Sobrien
308090075Sobrien@findex REG_UNUSED
308190075Sobrien@item REG_UNUSED
308290075SobrienThe register @var{op} being set by this insn will not be used in a
308390075Sobriensubsequent insn.  This differs from a @code{REG_DEAD} note, which
308490075Sobrienindicates that the value in an input will not be used subsequently.
308590075SobrienThese two notes are independent; both may be present for the same
308690075Sobrienregister.
308790075Sobrien
308890075Sobrien@findex REG_INC
308990075Sobrien@item REG_INC
309090075SobrienThe register @var{op} is incremented (or decremented; at this level
309190075Sobrienthere is no distinction) by an embedded side effect inside this insn.
309290075SobrienThis means it appears in a @code{post_inc}, @code{pre_inc},
309390075Sobrien@code{post_dec} or @code{pre_dec} expression.
309490075Sobrien
309590075Sobrien@findex REG_NONNEG
309690075Sobrien@item REG_NONNEG
309790075SobrienThe register @var{op} is known to have a nonnegative value when this
309890075Sobrieninsn is reached.  This is used so that decrement and branch until zero
309990075Sobrieninstructions, such as the m68k dbra, can be matched.
310090075Sobrien
310190075SobrienThe @code{REG_NONNEG} note is added to insns only if the machine
310290075Sobriendescription has a @samp{decrement_and_branch_until_zero} pattern.
310390075Sobrien
310490075Sobrien@findex REG_NO_CONFLICT
310590075Sobrien@item REG_NO_CONFLICT
310690075SobrienThis insn does not cause a conflict between @var{op} and the item
310790075Sobrienbeing set by this insn even though it might appear that it does.
310890075SobrienIn other words, if the destination register and @var{op} could
310990075Sobrienotherwise be assigned the same register, this insn does not
311090075Sobrienprevent that assignment.
311190075Sobrien
311290075SobrienInsns with this note are usually part of a block that begins with a
311390075Sobrien@code{clobber} insn specifying a multi-word pseudo register (which will
311490075Sobrienbe the output of the block), a group of insns that each set one word of
311590075Sobrienthe value and have the @code{REG_NO_CONFLICT} note attached, and a final
311690075Sobrieninsn that copies the output to itself with an attached @code{REG_EQUAL}
311790075Sobriennote giving the expression being computed.  This block is encapsulated
311890075Sobrienwith @code{REG_LIBCALL} and @code{REG_RETVAL} notes on the first and
311990075Sobrienlast insns, respectively.
312090075Sobrien
312190075Sobrien@findex REG_LABEL
312290075Sobrien@item REG_LABEL
312390075SobrienThis insn uses @var{op}, a @code{code_label} or a @code{note} of type
312490075Sobrien@code{NOTE_INSN_DELETED_LABEL}, but is not a
312590075Sobrien@code{jump_insn}, or it is a @code{jump_insn} that required the label to
312690075Sobrienbe held in a register.  The presence of this note allows jump
312790075Sobrienoptimization to be aware that @var{op} is, in fact, being used, and flow
312890075Sobrienoptimization to build an accurate flow graph.
312990075Sobrien@end table
313090075Sobrien
313190075SobrienThe following notes describe attributes of outputs of an insn:
313290075Sobrien
313390075Sobrien@table @code
313490075Sobrien@findex REG_EQUIV
313590075Sobrien@findex REG_EQUAL
313690075Sobrien@item REG_EQUIV
313790075Sobrien@itemx REG_EQUAL
313890075SobrienThis note is only valid on an insn that sets only one register and
313990075Sobrienindicates that that register will be equal to @var{op} at run time; the
314090075Sobrienscope of this equivalence differs between the two types of notes.  The
314190075Sobrienvalue which the insn explicitly copies into the register may look
314290075Sobriendifferent from @var{op}, but they will be equal at run time.  If the
314390075Sobrienoutput of the single @code{set} is a @code{strict_low_part} expression,
314490075Sobrienthe note refers to the register that is contained in @code{SUBREG_REG}
314590075Sobrienof the @code{subreg} expression.
314690075Sobrien
314790075SobrienFor @code{REG_EQUIV}, the register is equivalent to @var{op} throughout
314890075Sobrienthe entire function, and could validly be replaced in all its
314990075Sobrienoccurrences by @var{op}.  (``Validly'' here refers to the data flow of
315090075Sobrienthe program; simple replacement may make some insns invalid.)  For
315190075Sobrienexample, when a constant is loaded into a register that is never
315290075Sobrienassigned any other value, this kind of note is used.
315390075Sobrien
315490075SobrienWhen a parameter is copied into a pseudo-register at entry to a function,
315590075Sobriena note of this kind records that the register is equivalent to the stack
315690075Sobrienslot where the parameter was passed.  Although in this case the register
315790075Sobrienmay be set by other insns, it is still valid to replace the register
315890075Sobrienby the stack slot throughout the function.
315990075Sobrien
316090075SobrienA @code{REG_EQUIV} note is also used on an instruction which copies a
316190075Sobrienregister parameter into a pseudo-register at entry to a function, if
316290075Sobrienthere is a stack slot where that parameter could be stored.  Although
316390075Sobrienother insns may set the pseudo-register, it is valid for the compiler to
316490075Sobrienreplace the pseudo-register by stack slot throughout the function,
316590075Sobrienprovided the compiler ensures that the stack slot is properly
316690075Sobrieninitialized by making the replacement in the initial copy instruction as
316790075Sobrienwell.  This is used on machines for which the calling convention
316890075Sobrienallocates stack space for register parameters.  See
316990075Sobrien@code{REG_PARM_STACK_SPACE} in @ref{Stack Arguments}.
317090075Sobrien
317190075SobrienIn the case of @code{REG_EQUAL}, the register that is set by this insn
317290075Sobrienwill be equal to @var{op} at run time at the end of this insn but not
317390075Sobriennecessarily elsewhere in the function.  In this case, @var{op}
317490075Sobrienis typically an arithmetic expression.  For example, when a sequence of
317590075Sobrieninsns such as a library call is used to perform an arithmetic operation,
317690075Sobrienthis kind of note is attached to the insn that produces or copies the
317790075Sobrienfinal value.
317890075Sobrien
317990075SobrienThese two notes are used in different ways by the compiler passes.
318090075Sobrien@code{REG_EQUAL} is used by passes prior to register allocation (such as
318190075Sobriencommon subexpression elimination and loop optimization) to tell them how
318290075Sobriento think of that value.  @code{REG_EQUIV} notes are used by register
318390075Sobrienallocation to indicate that there is an available substitute expression
318490075Sobrien(either a constant or a @code{mem} expression for the location of a
318590075Sobrienparameter on the stack) that may be used in place of a register if
318690075Sobrieninsufficient registers are available.
318790075Sobrien
318890075SobrienExcept for stack homes for parameters, which are indicated by a
318990075Sobrien@code{REG_EQUIV} note and are not useful to the early optimization
319090075Sobrienpasses and pseudo registers that are equivalent to a memory location
319190075Sobrienthroughout their entire life, which is not detected until later in
319290075Sobrienthe compilation, all equivalences are initially indicated by an attached
319390075Sobrien@code{REG_EQUAL} note.  In the early stages of register allocation, a
319490075Sobrien@code{REG_EQUAL} note is changed into a @code{REG_EQUIV} note if
319590075Sobrien@var{op} is a constant and the insn represents the only set of its
319690075Sobriendestination register.
319790075Sobrien
319890075SobrienThus, compiler passes prior to register allocation need only check for
319990075Sobrien@code{REG_EQUAL} notes and passes subsequent to register allocation
320090075Sobrienneed only check for @code{REG_EQUIV} notes.
320190075Sobrien
320290075Sobrien@findex REG_WAS_0
320390075Sobrien@item REG_WAS_0
320490075SobrienThe single output of this insn contained zero before this insn.
320590075Sobrien@var{op} is the insn that set it to zero.  You can rely on this note if
320690075Sobrienit is present and @var{op} has not been deleted or turned into a @code{note};
320790075Sobrienits absence implies nothing.
320890075Sobrien@end table
320990075Sobrien
321090075SobrienThese notes describe linkages between insns.  They occur in pairs: one
321190075Sobrieninsn has one of a pair of notes that points to a second insn, which has
321290075Sobrienthe inverse note pointing back to the first insn.
321390075Sobrien
321490075Sobrien@table @code
321590075Sobrien@findex REG_RETVAL
321690075Sobrien@item REG_RETVAL
321790075SobrienThis insn copies the value of a multi-insn sequence (for example, a
321890075Sobrienlibrary call), and @var{op} is the first insn of the sequence (for a
321990075Sobrienlibrary call, the first insn that was generated to set up the arguments
322090075Sobrienfor the library call).
322190075Sobrien
322290075SobrienLoop optimization uses this note to treat such a sequence as a single
322390075Sobrienoperation for code motion purposes and flow analysis uses this note to
322490075Sobriendelete such sequences whose results are dead.
322590075Sobrien
322690075SobrienA @code{REG_EQUAL} note will also usually be attached to this insn to
322790075Sobrienprovide the expression being computed by the sequence.
322890075Sobrien
322990075SobrienThese notes will be deleted after reload, since they are no longer
323090075Sobrienaccurate or useful.
323190075Sobrien
323290075Sobrien@findex REG_LIBCALL
323390075Sobrien@item REG_LIBCALL
323490075SobrienThis is the inverse of @code{REG_RETVAL}: it is placed on the first
323590075Sobrieninsn of a multi-insn sequence, and it points to the last one.
323690075Sobrien
323790075SobrienThese notes are deleted after reload, since they are no longer useful or
323890075Sobrienaccurate.
323990075Sobrien
324090075Sobrien@findex REG_CC_SETTER
324190075Sobrien@findex REG_CC_USER
324290075Sobrien@item REG_CC_SETTER
324390075Sobrien@itemx REG_CC_USER
324490075SobrienOn machines that use @code{cc0}, the insns which set and use @code{cc0}
324590075Sobrienset and use @code{cc0} are adjacent.  However, when branch delay slot
324690075Sobrienfilling is done, this may no longer be true.  In this case a
324790075Sobrien@code{REG_CC_USER} note will be placed on the insn setting @code{cc0} to
324890075Sobrienpoint to the insn using @code{cc0} and a @code{REG_CC_SETTER} note will
324990075Sobrienbe placed on the insn using @code{cc0} to point to the insn setting
325090075Sobrien@code{cc0}.
325190075Sobrien@end table
325290075Sobrien
325390075SobrienThese values are only used in the @code{LOG_LINKS} field, and indicate
325490075Sobrienthe type of dependency that each link represents.  Links which indicate
325590075Sobriena data dependence (a read after write dependence) do not use any code,
325690075Sobrienthey simply have mode @code{VOIDmode}, and are printed without any
325790075Sobriendescriptive text.
325890075Sobrien
325990075Sobrien@table @code
326090075Sobrien@findex REG_DEP_ANTI
326190075Sobrien@item REG_DEP_ANTI
326290075SobrienThis indicates an anti dependence (a write after read dependence).
326390075Sobrien
326490075Sobrien@findex REG_DEP_OUTPUT
326590075Sobrien@item REG_DEP_OUTPUT
326690075SobrienThis indicates an output dependence (a write after write dependence).
326790075Sobrien@end table
326890075Sobrien
326990075SobrienThese notes describe information gathered from gcov profile data.  They
327090075Sobrienare stored in the @code{REG_NOTES} field of an insn as an
327190075Sobrien@code{expr_list}.
327290075Sobrien
327390075Sobrien@table @code
327490075Sobrien@findex REG_BR_PROB
327590075Sobrien@item REG_BR_PROB
327690075SobrienThis is used to specify the ratio of branches to non-branches of a
327790075Sobrienbranch insn according to the profile data.  The value is stored as a
327890075Sobrienvalue between 0 and REG_BR_PROB_BASE; larger values indicate a higher
327990075Sobrienprobability that the branch will be taken.
328090075Sobrien
328190075Sobrien@findex REG_BR_PRED
328290075Sobrien@item REG_BR_PRED
328390075SobrienThese notes are found in JUMP insns after delayed branch scheduling
328490075Sobrienhas taken place.  They indicate both the direction and the likelihood
328590075Sobrienof the JUMP@.  The format is a bitmask of ATTR_FLAG_* values.
328690075Sobrien
328790075Sobrien@findex REG_FRAME_RELATED_EXPR
328890075Sobrien@item REG_FRAME_RELATED_EXPR
328990075SobrienThis is used on an RTX_FRAME_RELATED_P insn wherein the attached expression
329090075Sobrienis used in place of the actual insn pattern.  This is done in cases where
329190075Sobrienthe pattern is either complex or misleading.
329290075Sobrien@end table
329390075Sobrien
329490075SobrienFor convenience, the machine mode in an @code{insn_list} or
329590075Sobrien@code{expr_list} is printed using these symbolic codes in debugging dumps.
329690075Sobrien
329790075Sobrien@findex insn_list
329890075Sobrien@findex expr_list
329990075SobrienThe only difference between the expression codes @code{insn_list} and
330090075Sobrien@code{expr_list} is that the first operand of an @code{insn_list} is
330190075Sobrienassumed to be an insn and is printed in debugging dumps as the insn's
330290075Sobrienunique id; the first operand of an @code{expr_list} is printed in the
330390075Sobrienordinary way as an expression.
330490075Sobrien
330590075Sobrien@node Calls
330690075Sobrien@section RTL Representation of Function-Call Insns
330790075Sobrien@cindex calling functions in RTL
330890075Sobrien@cindex RTL function-call insns
330990075Sobrien@cindex function-call insns
331090075Sobrien
331190075SobrienInsns that call subroutines have the RTL expression code @code{call_insn}.
331290075SobrienThese insns must satisfy special rules, and their bodies must use a special
331390075SobrienRTL expression code, @code{call}.
331490075Sobrien
331590075Sobrien@cindex @code{call} usage
331690075SobrienA @code{call} expression has two operands, as follows:
331790075Sobrien
331890075Sobrien@example
331990075Sobrien(call (mem:@var{fm} @var{addr}) @var{nbytes})
332090075Sobrien@end example
332190075Sobrien
332290075Sobrien@noindent
332390075SobrienHere @var{nbytes} is an operand that represents the number of bytes of
332490075Sobrienargument data being passed to the subroutine, @var{fm} is a machine mode
332590075Sobrien(which must equal as the definition of the @code{FUNCTION_MODE} macro in
332690075Sobrienthe machine description) and @var{addr} represents the address of the
332790075Sobriensubroutine.
332890075Sobrien
332990075SobrienFor a subroutine that returns no value, the @code{call} expression as
333090075Sobrienshown above is the entire body of the insn, except that the insn might
333190075Sobrienalso contain @code{use} or @code{clobber} expressions.
333290075Sobrien
333390075Sobrien@cindex @code{BLKmode}, and function return values
333490075SobrienFor a subroutine that returns a value whose mode is not @code{BLKmode},
333590075Sobrienthe value is returned in a hard register.  If this register's number is
333690075Sobrien@var{r}, then the body of the call insn looks like this:
333790075Sobrien
333890075Sobrien@example
333990075Sobrien(set (reg:@var{m} @var{r})
334090075Sobrien     (call (mem:@var{fm} @var{addr}) @var{nbytes}))
334190075Sobrien@end example
334290075Sobrien
334390075Sobrien@noindent
334490075SobrienThis RTL expression makes it clear (to the optimizer passes) that the
334590075Sobrienappropriate register receives a useful value in this insn.
334690075Sobrien
334790075SobrienWhen a subroutine returns a @code{BLKmode} value, it is handled by
334890075Sobrienpassing to the subroutine the address of a place to store the value.
334990075SobrienSo the call insn itself does not ``return'' any value, and it has the
335090075Sobriensame RTL form as a call that returns nothing.
335190075Sobrien
335290075SobrienOn some machines, the call instruction itself clobbers some register,
335390075Sobrienfor example to contain the return address.  @code{call_insn} insns
335490075Sobrienon these machines should have a body which is a @code{parallel}
335590075Sobrienthat contains both the @code{call} expression and @code{clobber}
335690075Sobrienexpressions that indicate which registers are destroyed.  Similarly,
335790075Sobrienif the call instruction requires some register other than the stack
335890075Sobrienpointer that is not explicitly mentioned it its RTL, a @code{use}
335990075Sobriensubexpression should mention that register.
336090075Sobrien
336190075SobrienFunctions that are called are assumed to modify all registers listed in
336290075Sobrienthe configuration macro @code{CALL_USED_REGISTERS} (@pxref{Register
336390075SobrienBasics}) and, with the exception of @code{const} functions and library
336490075Sobriencalls, to modify all of memory.
336590075Sobrien
336690075SobrienInsns containing just @code{use} expressions directly precede the
336790075Sobrien@code{call_insn} insn to indicate which registers contain inputs to the
336890075Sobrienfunction.  Similarly, if registers other than those in
336990075Sobrien@code{CALL_USED_REGISTERS} are clobbered by the called function, insns
337090075Sobriencontaining a single @code{clobber} follow immediately after the call to
337190075Sobrienindicate which registers.
337290075Sobrien
337390075Sobrien@node Sharing
337490075Sobrien@section Structure Sharing Assumptions
337590075Sobrien@cindex sharing of RTL components
337690075Sobrien@cindex RTL structure sharing assumptions
337790075Sobrien
337890075SobrienThe compiler assumes that certain kinds of RTL expressions are unique;
337990075Sobrienthere do not exist two distinct objects representing the same value.
338090075SobrienIn other cases, it makes an opposite assumption: that no RTL expression
338190075Sobrienobject of a certain kind appears in more than one place in the
338290075Sobriencontaining structure.
338390075Sobrien
338490075SobrienThese assumptions refer to a single function; except for the RTL
338590075Sobrienobjects that describe global variables and external functions,
338690075Sobrienand a few standard objects such as small integer constants,
338790075Sobrienno RTL objects are common to two functions.
338890075Sobrien
338990075Sobrien@itemize @bullet
339090075Sobrien@cindex @code{reg}, RTL sharing
339190075Sobrien@item
339290075SobrienEach pseudo-register has only a single @code{reg} object to represent it,
339390075Sobrienand therefore only a single machine mode.
339490075Sobrien
339590075Sobrien@cindex symbolic label
339690075Sobrien@cindex @code{symbol_ref}, RTL sharing
339790075Sobrien@item
339890075SobrienFor any symbolic label, there is only one @code{symbol_ref} object
339990075Sobrienreferring to it.
340090075Sobrien
340190075Sobrien@cindex @code{const_int}, RTL sharing
340290075Sobrien@item
340390075SobrienAll @code{const_int} expressions with equal values are shared.
340490075Sobrien
340590075Sobrien@cindex @code{pc}, RTL sharing
340690075Sobrien@item
340790075SobrienThere is only one @code{pc} expression.
340890075Sobrien
340990075Sobrien@cindex @code{cc0}, RTL sharing
341090075Sobrien@item
341190075SobrienThere is only one @code{cc0} expression.
341290075Sobrien
341390075Sobrien@cindex @code{const_double}, RTL sharing
341490075Sobrien@item
341590075SobrienThere is only one @code{const_double} expression with value 0 for
341690075Sobrieneach floating point mode.  Likewise for values 1 and 2.
341790075Sobrien
341896263Sobrien@cindex @code{const_vector}, RTL sharing
341996263Sobrien@item
342096263SobrienThere is only one @code{const_vector} expression with value 0 for
342196263Sobrieneach vector mode, be it an integer or a double constant vector.
342296263Sobrien
342390075Sobrien@cindex @code{label_ref}, RTL sharing
342490075Sobrien@cindex @code{scratch}, RTL sharing
342590075Sobrien@item
342690075SobrienNo @code{label_ref} or @code{scratch} appears in more than one place in
342790075Sobrienthe RTL structure; in other words, it is safe to do a tree-walk of all
342890075Sobrienthe insns in the function and assume that each time a @code{label_ref}
342990075Sobrienor @code{scratch} is seen it is distinct from all others that are seen.
343090075Sobrien
343190075Sobrien@cindex @code{mem}, RTL sharing
343290075Sobrien@item
343390075SobrienOnly one @code{mem} object is normally created for each static
343490075Sobrienvariable or stack slot, so these objects are frequently shared in all
343590075Sobrienthe places they appear.  However, separate but equal objects for these
343690075Sobrienvariables are occasionally made.
343790075Sobrien
343890075Sobrien@cindex @code{asm_operands}, RTL sharing
343990075Sobrien@item
344090075SobrienWhen a single @code{asm} statement has multiple output operands, a
344190075Sobriendistinct @code{asm_operands} expression is made for each output operand.
344290075SobrienHowever, these all share the vector which contains the sequence of input
344390075Sobrienoperands.  This sharing is used later on to test whether two
344490075Sobrien@code{asm_operands} expressions come from the same statement, so all
344590075Sobrienoptimizations must carefully preserve the sharing if they copy the
344690075Sobrienvector at all.
344790075Sobrien
344890075Sobrien@item
344990075SobrienNo RTL object appears in more than one place in the RTL structure
345090075Sobrienexcept as described above.  Many passes of the compiler rely on this
345190075Sobrienby assuming that they can modify RTL objects in place without unwanted
345290075Sobrienside-effects on other insns.
345390075Sobrien
345490075Sobrien@findex unshare_all_rtl
345590075Sobrien@item
345690075SobrienDuring initial RTL generation, shared structure is freely introduced.
345790075SobrienAfter all the RTL for a function has been generated, all shared
345890075Sobrienstructure is copied by @code{unshare_all_rtl} in @file{emit-rtl.c},
345990075Sobrienafter which the above rules are guaranteed to be followed.
346090075Sobrien
346190075Sobrien@findex copy_rtx_if_shared
346290075Sobrien@item
346390075SobrienDuring the combiner pass, shared structure within an insn can exist
346490075Sobrientemporarily.  However, the shared structure is copied before the
346590075Sobriencombiner is finished with the insn.  This is done by calling
346690075Sobrien@code{copy_rtx_if_shared}, which is a subroutine of
346790075Sobrien@code{unshare_all_rtl}.
346890075Sobrien@end itemize
346990075Sobrien
347090075Sobrien@node Reading RTL
347190075Sobrien@section Reading RTL
347290075Sobrien
347390075SobrienTo read an RTL object from a file, call @code{read_rtx}.  It takes one
347490075Sobrienargument, a stdio stream, and returns a single RTL object.  This routine
347590075Sobrienis defined in @file{read-rtl.c}.  It is not available in the compiler
347690075Sobrienitself, only the various programs that generate the compiler back end
347790075Sobrienfrom the machine description.
347890075Sobrien
347990075SobrienPeople frequently have the idea of using RTL stored as text in a file as
348090075Sobrienan interface between a language front end and the bulk of GCC@.  This
348190075Sobrienidea is not feasible.
348290075Sobrien
348390075SobrienGCC was designed to use RTL internally only.  Correct RTL for a given
348490075Sobrienprogram is very dependent on the particular target machine.  And the RTL
348590075Sobriendoes not contain all the information about the program.
348690075Sobrien
348790075SobrienThe proper way to interface GCC to a new language front end is with
348890075Sobrienthe ``tree'' data structure, described in the files @file{tree.h} and
348990075Sobrien@file{tree.def}.  The documentation for this structure (@pxref{Trees})
349090075Sobrienis incomplete.
3491