* gcc_release: New script.
[official-gcc.git] / gcc / rtl.texi
blob0620ada8ad19c6c82d91b5acc8e4afc74ff9627e
1 @c Copyright (C) 1988, 1989, 1992, 1994, 1997, 1998, 1999, 2000, 2001
2 @c Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node RTL
7 @chapter RTL Representation
8 @cindex RTL representation
9 @cindex representation of RTL
10 @cindex Register Transfer Language (RTL)
12 Most of the work of the compiler is done on an intermediate representation
13 called register transfer language.  In this language, the instructions to be
14 output are described, pretty much one by one, in an algebraic form that
15 describes what the instruction does.
17 RTL is inspired by Lisp lists.  It has both an internal form, made up of
18 structures that point at other structures, and a textual form that is used
19 in the machine description and in printed debugging dumps.  The textual
20 form uses nested parentheses to indicate the pointers in the internal form.
22 @menu
23 * RTL Objects::       Expressions vs vectors vs strings vs integers.
24 * RTL Classes::       Categories of RTL expresion objects, and their structure.
25 * Accessors::         Macros to access expression operands or vector elts.
26 * Flags::             Other flags in an RTL expression.
27 * Machine Modes::     Describing the size and format of a datum.
28 * Constants::         Expressions with constant values.
29 * Regs and Memory::   Expressions representing register contents or memory.
30 * Arithmetic::        Expressions representing arithmetic on other expressions.
31 * Comparisons::       Expressions representing comparison of expressions.
32 * Bit Fields::        Expressions representing bitfields in memory or reg.
33 * Vector Operations:: Expressions involving vector datatypes.
34 * Conversions::       Extending, truncating, floating or fixing.
35 * RTL Declarations::  Declaring volatility, constancy, etc.
36 * Side Effects::      Expressions for storing in registers, etc.
37 * Incdec::            Embedded side-effects for autoincrement addressing.
38 * Assembler::         Representing @code{asm} with operands.
39 * Insns::             Expression types for entire insns.
40 * Calls::             RTL representation of function call insns.
41 * Sharing::           Some expressions are unique; others *must* be copied.
42 * Reading RTL::       Reading textual RTL from a file.
43 @end menu
45 @node RTL Objects
46 @section RTL Object Types
47 @cindex RTL object types
49 @cindex RTL integers
50 @cindex RTL strings
51 @cindex RTL vectors
52 @cindex RTL expression
53 @cindex RTX (See RTL)
54 RTL uses five kinds of objects: expressions, integers, wide integers,
55 strings and vectors.  Expressions are the most important ones.  An RTL
56 expression (``RTX'', for short) is a C structure, but it is usually
57 referred to with a pointer; a type that is given the typedef name
58 @code{rtx}.
60 An integer is simply an @code{int}; their written form uses decimal digits.
61 A wide integer is an integral object whose type is @code{HOST_WIDE_INT}
62 (@pxref{Config}); their written form uses decimal digits.
64 A string is a sequence of characters.  In core it is represented as a
65 @code{char *} in usual C fashion, and it is written in C syntax as well.
66 However, strings in RTL may never be null.  If you write an empty string in
67 a machine description, it is represented in core as a null pointer rather
68 than as a pointer to a null character.  In certain contexts, these null
69 pointers instead of strings are valid.  Within RTL code, strings are most
70 commonly found inside @code{symbol_ref} expressions, but they appear in
71 other contexts in the RTL expressions that make up machine descriptions.  
73 A vector contains an arbitrary number of pointers to expressions.  The
74 number of elements in the vector is explicitly present in the vector.
75 The written form of a vector consists of square brackets
76 (@samp{[@dots{}]}) surrounding the elements, in sequence and with
77 whitespace separating them.  Vectors of length zero are not created;
78 null pointers are used instead.
80 @cindex expression codes
81 @cindex codes, RTL expression
82 @findex GET_CODE
83 @findex PUT_CODE
84 Expressions are classified by @dfn{expression codes} (also called RTX
85 codes).  The expression code is a name defined in @file{rtl.def}, which is
86 also (in upper case) a C enumeration constant.  The possible expression
87 codes and their meanings are machine-independent.  The code of an RTX can
88 be extracted with the macro @code{GET_CODE (@var{x})} and altered with
89 @code{PUT_CODE (@var{x}, @var{newcode})}.
91 The expression code determines how many operands the expression contains,
92 and what kinds of objects they are.  In RTL, unlike Lisp, you cannot tell
93 by looking at an operand what kind of object it is.  Instead, you must know
94 from its context---from the expression code of the containing expression.
95 For example, in an expression of code @code{subreg}, the first operand is
96 to be regarded as an expression and the second operand as an integer.  In
97 an expression of code @code{plus}, there are two operands, both of which
98 are to be regarded as expressions.  In a @code{symbol_ref} expression,
99 there is one operand, which is to be regarded as a string.
101 Expressions are written as parentheses containing the name of the
102 expression type, its flags and machine mode if any, and then the operands
103 of the expression (separated by spaces).
105 Expression code names in the @samp{md} file are written in lower case,
106 but when they appear in C code they are written in upper case.  In this
107 manual, they are shown as follows: @code{const_int}.
109 @cindex (nil)
110 @cindex nil
111 In a few contexts a null pointer is valid where an expression is normally
112 wanted.  The written form of this is @code{(nil)}.
114 @node RTL Classes
115 @section RTL Classes and Formats
116 @cindex RTL classes
117 @cindex classes of RTX codes
118 @cindex RTX codes, classes of
119 @findex GET_RTX_CLASS
121 The various expression codes are divided into several @dfn{classes},
122 which are represented by single characters.  You can determine the class
123 of an RTX code with the macro @code{GET_RTX_CLASS (@var{code})}.
124 Currently, @file{rtx.def} defines these classes:
126 @table @code
127 @item o
128 An RTX code that represents an actual object, such as a register
129 (@code{REG}) or a memory location (@code{MEM}, @code{SYMBOL_REF}).
130 Constants and basic transforms on objects (@code{ADDRESSOF},
131 @code{HIGH}, @code{LO_SUM}) are also included.  Note that @code{SUBREG}
132 and @code{STRICT_LOW_PART} are not in this class, but in class @code{x}.
134 @item <
135 An RTX code for a comparison, such as @code{NE} or @code{LT}.
137 @item 1
138 An RTX code for a unary arithmetic operation, such as @code{NEG},
139 @code{NOT}, or @code{ABS}.  This category also includes value extension
140 (sign or zero) and conversions between integer and floating point.
142 @item c
143 An RTX code for a commutative binary operation, such as @code{PLUS} or
144 @code{AND}.  @code{NE} and @code{EQ} are comparisons, so they have class
145 @code{<}.
147 @item 2
148 An RTX code for a non-commutative binary operation, such as @code{MINUS},
149 @code{DIV}, or @code{ASHIFTRT}.
151 @item b
152 An RTX code for a bitfield operation.  Currently only
153 @code{ZERO_EXTRACT} and @code{SIGN_EXTRACT}.  These have three inputs
154 and are lvalues (so they can be used for insertion as well).  @xref{Bit
155 Fields}.
157 @item 3
158 An RTX code for other three input operations.  Currently only
159 @code{IF_THEN_ELSE}.
161 @item i
162 An RTX code for an entire instruction:  @code{INSN}, @code{JUMP_INSN}, and
163 @code{CALL_INSN}. @xref{Insns}.
165 @item m
166 An RTX code for something that matches in insns, such as
167 @code{MATCH_DUP}.  These only occur in machine descriptions.
169 @item a
170 An RTX code for an auto-increment addressing mode, such as
171 @code{POST_INC}.
173 @item x
174 All other RTX codes.  This category includes the remaining codes used
175 only in machine descriptions (@code{DEFINE_*}, etc.).  It also includes
176 all the codes describing side effects (@code{SET}, @code{USE},
177 @code{CLOBBER}, etc.) and the non-insns that may appear on an insn
178 chain, such as @code{NOTE}, @code{BARRIER}, and @code{CODE_LABEL}.
179 @end table
181 @cindex RTL format
182 For each expression type @file{rtl.def} specifies the number of
183 contained objects and their kinds, with four possibilities: @samp{e} for
184 expression (actually a pointer to an expression), @samp{i} for integer,
185 @samp{w} for wide integer, @samp{s} for string, and @samp{E} for vector
186 of expressions.  The sequence of letters for an expression code is
187 called its @dfn{format}.  For example, the format of @code{subreg} is
188 @samp{ei}.@refill
190 @cindex RTL format characters
191 A few other format characters are used occasionally:
193 @table @code
194 @item u
195 @samp{u} is equivalent to @samp{e} except that it is printed differently
196 in debugging dumps.  It is used for pointers to insns.
198 @item n
199 @samp{n} is equivalent to @samp{i} except that it is printed differently
200 in debugging dumps.  It is used for the line number or code number of a
201 @code{note} insn.
203 @item S
204 @samp{S} indicates a string which is optional.  In the RTL objects in
205 core, @samp{S} is equivalent to @samp{s}, but when the object is read,
206 from an @samp{md} file, the string value of this operand may be omitted.
207 An omitted string is taken to be the null string.
209 @item V
210 @samp{V} indicates a vector which is optional.  In the RTL objects in
211 core, @samp{V} is equivalent to @samp{E}, but when the object is read
212 from an @samp{md} file, the vector value of this operand may be omitted.
213 An omitted vector is effectively the same as a vector of no elements.
215 @item 0
216 @samp{0} means a slot whose contents do not fit any normal category.
217 @samp{0} slots are not printed at all in dumps, and are often used in
218 special ways by small parts of the compiler.
219 @end table
221 There are macros to get the number of operands and the format
222 of an expression code:
224 @table @code
225 @findex GET_RTX_LENGTH
226 @item GET_RTX_LENGTH (@var{code})
227 Number of operands of an RTX of code @var{code}.
229 @findex GET_RTX_FORMAT
230 @item GET_RTX_FORMAT (@var{code})
231 The format of an RTX of code @var{code}, as a C string.
232 @end table
234 Some classes of RTX codes always have the same format.  For example, it
235 is safe to assume that all comparison operations have format @code{ee}.
237 @table @code
238 @item 1
239 All codes of this class have format @code{e}.
241 @item <
242 @itemx c
243 @itemx 2
244 All codes of these classes have format @code{ee}.
246 @item b
247 @itemx 3
248 All codes of these classes have format @code{eee}.
250 @item i
251 All codes of this class have formats that begin with @code{iuueiee}.
252 @xref{Insns}.  Note that not all RTL objects linked onto an insn chain
253 are of class @code{i}.
255 @item o
256 @itemx m
257 @itemx x
258 You can make no assumptions about the format of these codes.
259 @end table
261 @node Accessors
262 @section Access to Operands
263 @cindex accessors
264 @cindex access to operands
265 @cindex operand access
267 @findex XEXP
268 @findex XINT
269 @findex XWINT
270 @findex XSTR
271 Operands of expressions are accessed using the macros @code{XEXP},
272 @code{XINT}, @code{XWINT} and @code{XSTR}.  Each of these macros takes
273 two arguments: an expression-pointer (RTX) and an operand number
274 (counting from zero).  Thus,@refill
276 @example
277 XEXP (@var{x}, 2)
278 @end example
280 @noindent
281 accesses operand 2 of expression @var{x}, as an expression.
283 @example
284 XINT (@var{x}, 2)
285 @end example
287 @noindent
288 accesses the same operand as an integer.  @code{XSTR}, used in the same
289 fashion, would access it as a string.
291 Any operand can be accessed as an integer, as an expression or as a string.
292 You must choose the correct method of access for the kind of value actually
293 stored in the operand.  You would do this based on the expression code of
294 the containing expression.  That is also how you would know how many
295 operands there are.
297 For example, if @var{x} is a @code{subreg} expression, you know that it has
298 two operands which can be correctly accessed as @code{XEXP (@var{x}, 0)}
299 and @code{XINT (@var{x}, 1)}.  If you did @code{XINT (@var{x}, 0)}, you
300 would get the address of the expression operand but cast as an integer;
301 that might occasionally be useful, but it would be cleaner to write
302 @code{(int) XEXP (@var{x}, 0)}.  @code{XEXP (@var{x}, 1)} would also
303 compile without error, and would return the second, integer operand cast as
304 an expression pointer, which would probably result in a crash when
305 accessed.  Nothing stops you from writing @code{XEXP (@var{x}, 28)} either,
306 but this will access memory past the end of the expression with
307 unpredictable results.@refill
309 Access to operands which are vectors is more complicated.  You can use the
310 macro @code{XVEC} to get the vector-pointer itself, or the macros
311 @code{XVECEXP} and @code{XVECLEN} to access the elements and length of a
312 vector.
314 @table @code
315 @findex XVEC
316 @item XVEC (@var{exp}, @var{idx})
317 Access the vector-pointer which is operand number @var{idx} in @var{exp}.
319 @findex XVECLEN
320 @item XVECLEN (@var{exp}, @var{idx})
321 Access the length (number of elements) in the vector which is
322 in operand number @var{idx} in @var{exp}.  This value is an @code{int}.
324 @findex XVECEXP
325 @item XVECEXP (@var{exp}, @var{idx}, @var{eltnum})
326 Access element number @var{eltnum} in the vector which is
327 in operand number @var{idx} in @var{exp}.  This value is an RTX.
329 It is up to you to make sure that @var{eltnum} is not negative
330 and is less than @code{XVECLEN (@var{exp}, @var{idx})}.
331 @end table
333 All the macros defined in this section expand into lvalues and therefore
334 can be used to assign the operands, lengths and vector elements as well as
335 to access them.
337 @node Flags
338 @section Flags in an RTL Expression
339 @cindex flags in RTL expression
341 RTL expressions contain several flags (one-bit bitfields) and other
342 values that are used in certain types of expression.  Most often they
343 are accessed with the following macros:
345 @table @code
346 @findex MEM_VOLATILE_P
347 @cindex @code{mem} and @samp{/v}
348 @cindex @code{volatil}, in @code{mem}
349 @cindex @samp{/v} in RTL dump
350 @item MEM_VOLATILE_P (@var{x})
351 In @code{mem} expressions, nonzero for volatile memory references.
352 Stored in the @code{volatil} field and printed as @samp{/v}.
354 @findex MEM_IN_STRUCT_P
355 @cindex @code{mem} and @samp{/s}
356 @cindex @code{in_struct}, in @code{mem}
357 @cindex @samp{/s} in RTL dump
358 @item MEM_IN_STRUCT_P (@var{x})
359 In @code{mem} expressions, nonzero for reference to an entire structure,
360 union or array, or to a component of one.  Zero for references to a
361 scalar variable or through a pointer to a scalar.  Stored in the
362 @code{in_struct} field and printed as @samp{/s}.  If both this flag and
363 MEM_SCALAR_P are clear, then we don't know whether this MEM is in a
364 structure or not.  Both flags should never be simultaneously set.
366 @findex MEM_SCALAR_P
367 @cindex @code{mem} and @samp{/f}
368 @cindex @code{frame_related}, in@code{mem}
369 @cindex @samp{/f} in RTL dump
370 @item MEM_SCALAR_P (@var{x})
371 In @code{mem} expressions, nonzero for reference to a scalar known not
372 to be a member of a structure, union, or array.  Zero for such
373 references and for indirections through pointers, even pointers pointing
374 to scalar types.  If both this flag and MEM_STRUCT_P are clear, then we
375 don't know whether this MEM is in a structure or not.  Both flags should
376 never be simultaneously set.
378 @findex MEM_ALIAS_SET
379 @item MEM_ALIAS_SET (@var{x})
380 In @code{mem} expressions, the alias set to which @var{x} belongs.  If
381 zero, @var{x} is not in any alias set, and may alias anything.  If
382 nonzero, @var{x} may only alias objects in the same alias set.  This
383 value is set (in a language-specific manner) by the front-end.  This
384 field is not a bit-field; it is in an integer, found as the second
385 argument to the @code{mem}.
387 @findex REG_LOOP_TEST_P
388 @cindex @code{reg} and @samp{/s}
389 @cindex @code{in_struct}, in @code{reg}
390 @item REG_LOOP_TEST_P
391 In @code{reg} expressions, nonzero if this register's entire life is
392 contained in the exit test code for some loop.  Stored in the
393 @code{in_struct} field and printed as @samp{/s}.
395 @findex REG_USERVAR_P 
396 @cindex @code{reg} and @samp{/v}
397 @cindex @code{volatil}, in @code{reg}
398 @item REG_USERVAR_P (@var{x})
399 In a @code{reg}, nonzero if it corresponds to a variable present in
400 the user's source code.  Zero for temporaries generated internally by
401 the compiler.  Stored in the @code{volatil} field and printed as
402 @samp{/v}.
404 @cindex @samp{/i} in RTL dump
405 @findex REG_FUNCTION_VALUE_P 
406 @cindex @code{reg} and @samp{/i}
407 @cindex @code{integrated}, in @code{reg}
408 @item REG_FUNCTION_VALUE_P (@var{x})
409 Nonzero in a @code{reg} if it is the place in which this function's
410 value is going to be returned.  (This happens only in a hard
411 register.)  Stored in the @code{integrated} field and printed as
412 @samp{/i}.
414 The same hard register may be used also for collecting the values of
415 functions called by this one, but @code{REG_FUNCTION_VALUE_P} is zero
416 in this kind of use.
418 @findex SUBREG_PROMOTED_VAR_P
419 @cindex @code{subreg} and @samp{/s}
420 @cindex @code{in_struct}, in @code{subreg}
421 @item SUBREG_PROMOTED_VAR_P
422 Nonzero in a @code{subreg} if it was made when accessing an object that
423 was promoted to a wider mode in accord with the @code{PROMOTED_MODE} machine
424 description macro (@pxref{Storage Layout}).  In this case, the mode of
425 the @code{subreg} is the declared mode of the object and the mode of
426 @code{SUBREG_REG} is the mode of the register that holds the object.
427 Promoted variables are always either sign- or zero-extended to the wider
428 mode on every assignment.  Stored in the @code{in_struct} field and
429 printed as @samp{/s}.
431 @findex SUBREG_PROMOTED_UNSIGNED_P
432 @cindex @code{subreg} and @samp{/u}
433 @cindex @code{unchanging}, in @code{subreg}
434 @item SUBREG_PROMOTED_UNSIGNED_P
435 Nonzero in a @code{subreg} that has @code{SUBREG_PROMOTED_VAR_P} nonzero
436 if the object being referenced is kept zero-extended and zero if it
437 is kept sign-extended.  Stored in the @code{unchanging} field and
438 printed as @samp{/u}.
440 @findex RTX_UNCHANGING_P 
441 @cindex @code{reg} and @samp{/u}
442 @cindex @code{mem} and @samp{/u}
443 @cindex @code{unchanging}, in @code{reg} and @code{mem}
444 @cindex @samp{/u} in RTL dump
445 @item RTX_UNCHANGING_P (@var{x})
446 Nonzero in a @code{reg} or @code{mem} if the value is not changed.
447 (This flag is not set for memory references via pointers to constants.
448 Such pointers only guarantee that the object will not be changed
449 explicitly by the current function.  The object might be changed by
450 other functions or by aliasing.)  Stored in the
451 @code{unchanging} field and printed as @samp{/u}.
453 @findex RTX_INTEGRATED_P 
454 @cindex @code{integrated}, in @code{insn}
455 @item RTX_INTEGRATED_P (@var{insn})
456 Nonzero in an insn if it resulted from an in-line function call.
457 Stored in the @code{integrated} field and printed as @samp{/i}.
459 @findex RTX_FRAME_RELATED_P
460 @item RTX_FRAME_RELATED_P (@var{x})
461 Nonzero in an insn or expression which is part of a function prologue
462 and sets the stack pointer, sets the frame pointer, or saves a register.
463 This flag should also be set on an instruction that sets up a temporary
464 register to use in place of the frame pointer.
466 In particular, on RISC targets where there are limits on the sizes of
467 immediate constants, it is sometimes impossible to reach the register
468 save area directly from the stack pointer.  In that case, a temporary
469 register is used that is near enough to the register save area, and the
470 Canonical Frame Address, i.e., DWARF2's logical frame pointer, register
471 must (temporarily) be changed to be this temporary register.  So, the
472 instruction that sets this temporary register must be marked as
473 @code{RTX_FRAME_RELATED_P}.
475 If the marked instruction is overly complex (defined in terms of what
476 @code{dwarf2out_frame_debug_expr} can handle), you will also have to
477 create a @code{REG_FRAME_RELATED_EXPR} note and attach it to the
478 instruction.  This note should contain a simple expression of the
479 computation performed by this instruction, i.e., one that
480 @code{dwarf2out_frame_debug_expr} can handle.
482 This flag is required for exception handling support on targets with RTL
483 prologues.
485 @findex SYMBOL_REF_USED
486 @cindex @code{used}, in @code{symbol_ref}
487 @item SYMBOL_REF_USED (@var{x})
488 In a @code{symbol_ref}, indicates that @var{x} has been used.  This is
489 normally only used to ensure that @var{x} is only declared external
490 once.  Stored in the @code{used} field.
492 @findex SYMBOL_REF_FLAG
493 @cindex @code{symbol_ref} and @samp{/v}
494 @cindex @code{volatil}, in @code{symbol_ref}
495 @item SYMBOL_REF_FLAG (@var{x})
496 In a @code{symbol_ref}, this is used as a flag for machine-specific purposes.
497 Stored in the @code{volatil} field and printed as @samp{/v}.
499 @findex SYMBOL_REF_WEAK
500 @cindex @code{symbol_ref} and @samp{/i}
501 @cindex @code{integrated}, in @code{symbol_ref}
502 @item SYMBOL_REF_WEAK (@var{x})
503 In a @code{symbol_ref}, indicates that @var{x} has been declared weak.
504 Stored in the @code{integrated} field and printed as @samp{/i}.
506 @findex LABEL_OUTSIDE_LOOP_P
507 @cindex @code{label_ref} and @samp{/s}
508 @cindex @code{in_struct}, in @code{label_ref}
509 @item LABEL_OUTSIDE_LOOP_P
510 In @code{label_ref} expressions, nonzero if this is a reference to a
511 label that is outside the innermost loop containing the reference to the
512 label.  Stored in the @code{in_struct} field and printed as @samp{/s}.
514 @findex INSN_DELETED_P 
515 @cindex @code{volatil}, in @code{insn}
516 @item INSN_DELETED_P (@var{insn})
517 In an insn, nonzero if the insn has been deleted.  Stored in the
518 @code{volatil} field and printed as @samp{/v}.
520 @findex INSN_ANNULLED_BRANCH_P
521 @cindex @code{insn} and @samp{/u}
522 @cindex @code{unchanging}, in @code{insn}
523 @item INSN_ANNULLED_BRANCH_P (@var{insn})
524 In an @code{insn} in the delay slot of a branch insn, indicates that an
525 annulling branch should be used.  See the discussion under
526 @code{sequence} below.  Stored in the @code{unchanging} field and printed
527 as @samp{/u}.
529 @findex INSN_FROM_TARGET_P
530 @cindex @code{insn} and @samp{/s}
531 @cindex @code{in_struct}, in @code{insn}
532 @cindex @samp{/s} in RTL dump
533 @item INSN_FROM_TARGET_P (@var{insn})
534 In an @code{insn} in a delay slot of a branch, indicates that the insn
535 is from the target of the branch.  If the branch insn has
536 @code{INSN_ANNULLED_BRANCH_P} set, this insn will only be executed if
537 the branch is taken.  For annulled branches with
538 @code{INSN_FROM_TARGET_P} clear, the insn will be executed only if the
539 branch is not taken.  When @code{INSN_ANNULLED_BRANCH_P} is not set,
540 this insn will always be executed.  Stored in the @code{in_struct}
541 field and printed as @samp{/s}.
543 @findex CONSTANT_POOL_ADDRESS_P 
544 @cindex @code{symbol_ref} and @samp{/u}
545 @cindex @code{unchanging}, in @code{symbol_ref}
546 @item CONSTANT_POOL_ADDRESS_P (@var{x})
547 Nonzero in a @code{symbol_ref} if it refers to part of the current
548 function's ``constants pool''.  These are addresses close to the
549 beginning of the function, and GNU CC assumes they can be addressed
550 directly (perhaps with the help of base registers).  Stored in the
551 @code{unchanging} field and printed as @samp{/u}.
553 @findex CONST_CALL_P
554 @cindex @code{call_insn} and @samp{/u}
555 @cindex @code{unchanging}, in @code{call_insn}
556 @item CONST_CALL_P (@var{x})
557 In a @code{call_insn}, indicates that the insn represents a call to a const
558 function.  Stored in the @code{unchanging} field and printed as @samp{/u}.
560 @findex LABEL_PRESERVE_P
561 @cindex @code{code_label} and @samp{/i}
562 @cindex @code{in_struct}, in @code{code_label}
563 @item LABEL_PRESERVE_P (@var{x})
564 In a @code{code_label}, indicates that the label can never be deleted.
565 Labels referenced by a non-local goto will have this bit set.  Stored
566 in the @code{in_struct} field and printed as @samp{/s}.
568 @findex SCHED_GROUP_P
569 @cindex @code{insn} and @samp{/i}
570 @cindex @code{in_struct}, in @code{insn}
571 @item SCHED_GROUP_P (@var{insn})
572 During instruction scheduling, in an insn, indicates that the previous insn
573 must be scheduled together with this insn.  This is used to ensure that
574 certain groups of instructions will not be split up by the instruction
575 scheduling pass, for example, @code{use} insns before a @code{call_insn} may
576 not be separated from the @code{call_insn}.  Stored in the @code{in_struct}
577 field and printed as @samp{/s}.
578 @end table
580 These are the fields which the above macros refer to:
582 @table @code
583 @findex used
584 @item used
585 Normally, this flag is used only momentarily, at the end of RTL
586 generation for a function, to count the number of times an expression
587 appears in insns.  Expressions that appear more than once are copied,
588 according to the rules for shared structure (@pxref{Sharing}).
590 In a @code{symbol_ref}, it indicates that an external declaration for
591 the symbol has already been written.
593 In a @code{reg}, it is used by the leaf register renumbering code to ensure
594 that each register is only renumbered once.
596 @findex volatil
597 @item volatil
598 This flag is used in @code{mem}, @code{symbol_ref} and @code{reg}
599 expressions and in insns.  In RTL dump files, it is printed as
600 @samp{/v}.
602 @cindex volatile memory references
603 In a @code{mem} expression, it is 1 if the memory reference is volatile.
604 Volatile memory references may not be deleted, reordered or combined.
606 In a @code{symbol_ref} expression, it is used for machine-specific 
607 purposes.
609 In a @code{reg} expression, it is 1 if the value is a user-level variable.
610 0 indicates an internal compiler temporary.
612 In an insn, 1 means the insn has been deleted.
614 @findex in_struct
615 @item in_struct
616 In @code{mem} expressions, it is 1 if the memory datum referred to is
617 all or part of a structure or array; 0 if it is (or might be) a scalar
618 variable.  A reference through a C pointer has 0 because the pointer
619 might point to a scalar variable.  This information allows the compiler
620 to determine something about possible cases of aliasing.
622 In an insn in the delay slot of a branch, 1 means that this insn is from
623 the target of the branch.
625 During instruction scheduling, in an insn, 1 means that this insn must be
626 scheduled as part of a group together with the previous insn.
628 In @code{reg} expressions, it is 1 if the register has its entire life
629 contained within the test expression of some loop.
631 In @code{subreg} expressions, 1 means that the @code{subreg} is accessing
632 an object that has had its mode promoted from a wider mode.
634 In @code{label_ref} expressions, 1 means that the referenced label is
635 outside the innermost loop containing the insn in which the @code{label_ref}
636 was found.
638 In @code{code_label} expressions, it is 1 if the label may never be deleted.
639 This is used for labels which are the target of non-local gotos.
641 In an RTL dump, this flag is represented as @samp{/s}.
643 @findex unchanging
644 @item unchanging
645 In @code{reg} and @code{mem} expressions, 1 means
646 that the value of the expression never changes.
648 In @code{subreg} expressions, it is 1 if the @code{subreg} references an
649 unsigned object whose mode has been promoted to a wider mode.
651 In an insn, 1 means that this is an annulling branch.
653 In a @code{symbol_ref} expression, 1 means that this symbol addresses
654 something in the per-function constants pool.
656 In a @code{call_insn}, 1 means that this instruction is a call to a
657 const function.
659 In an RTL dump, this flag is represented as @samp{/u}.
661 @findex integrated
662 @item integrated
663 In some kinds of expressions, including insns, this flag means the
664 rtl was produced by procedure integration.
666 In a @code{reg} expression, this flag indicates the register
667 containing the value to be returned by the current function.  On
668 machines that pass parameters in registers, the same register number
669 may be used for parameters as well, but this flag is not set on such
670 uses.
671 @end table
673 @node Machine Modes
674 @section Machine Modes
675 @cindex machine modes
677 @findex enum machine_mode
678 A machine mode describes a size of data object and the representation used
679 for it.  In the C code, machine modes are represented by an enumeration
680 type, @code{enum machine_mode}, defined in @file{machmode.def}.  Each RTL
681 expression has room for a machine mode and so do certain kinds of tree
682 expressions (declarations and types, to be precise).
684 In debugging dumps and machine descriptions, the machine mode of an RTL
685 expression is written after the expression code with a colon to separate
686 them.  The letters @samp{mode} which appear at the end of each machine mode
687 name are omitted.  For example, @code{(reg:SI 38)} is a @code{reg}
688 expression with machine mode @code{SImode}.  If the mode is
689 @code{VOIDmode}, it is not written at all.
691 Here is a table of machine modes.  The term ``byte'' below refers to an
692 object of @code{BITS_PER_UNIT} bits (@pxref{Storage Layout}).
694 @table @code
695 @findex BImode
696 @item BImode
697 ``Bit'' mode represents a single bit, for predicate registers.
699 @findex QImode
700 @item QImode
701 ``Quarter-Integer'' mode represents a single byte treated as an integer.
703 @findex HImode
704 @item HImode
705 ``Half-Integer'' mode represents a two-byte integer.
707 @findex PSImode
708 @item PSImode
709 ``Partial Single Integer'' mode represents an integer which occupies
710 four bytes but which doesn't really use all four.  On some machines,
711 this is the right mode to use for pointers.
713 @findex SImode
714 @item SImode
715 ``Single Integer'' mode represents a four-byte integer.
717 @findex PDImode
718 @item PDImode
719 ``Partial Double Integer'' mode represents an integer which occupies
720 eight bytes but which doesn't really use all eight.  On some machines,
721 this is the right mode to use for certain pointers.
723 @findex DImode
724 @item DImode
725 ``Double Integer'' mode represents an eight-byte integer.
727 @findex TImode
728 @item TImode
729 ``Tetra Integer'' (?) mode represents a sixteen-byte integer.
731 @findex OImode
732 @item OImode
733 ``Octa Integer'' (?) mode represents a thirty-two-byte integer.
735 @findex SFmode
736 @item SFmode
737 ``Single Floating'' mode represents a single-precision (four byte) floating
738 point number.
740 @findex DFmode
741 @item DFmode
742 ``Double Floating'' mode represents a double-precision (eight byte) floating
743 point number.
745 @findex XFmode
746 @item XFmode
747 ``Extended Floating'' mode represents a triple-precision (twelve byte)
748 floating point number.  This mode is used for IEEE extended floating
749 point.  On some systems not all bits within these bytes will actually
750 be used.
752 @findex TFmode
753 @item TFmode
754 ``Tetra Floating'' mode represents a quadruple-precision (sixteen byte)
755 floating point number.
757 @findex CCmode
758 @item CCmode
759 ``Condition Code'' mode represents the value of a condition code, which
760 is a machine-specific set of bits used to represent the result of a
761 comparison operation.  Other machine-specific modes may also be used for
762 the condition code.  These modes are not used on machines that use
763 @code{cc0} (see @pxref{Condition Code}).
765 @findex BLKmode
766 @item BLKmode
767 ``Block'' mode represents values that are aggregates to which none of
768 the other modes apply.  In RTL, only memory references can have this mode,
769 and only if they appear in string-move or vector instructions.  On machines
770 which have no such instructions, @code{BLKmode} will not appear in RTL.
772 @findex VOIDmode
773 @item VOIDmode
774 Void mode means the absence of a mode or an unspecified mode.
775 For example, RTL expressions of code @code{const_int} have mode
776 @code{VOIDmode} because they can be taken to have whatever mode the context
777 requires.  In debugging dumps of RTL, @code{VOIDmode} is expressed by
778 the absence of any mode.
780 @findex SCmode
781 @findex DCmode
782 @findex XCmode
783 @findex TCmode
784 @item SCmode, DCmode, XCmode, TCmode
785 These modes stand for a complex number represented as a pair of floating
786 point values.  The floating point values are in @code{SFmode},
787 @code{DFmode}, @code{XFmode}, and @code{TFmode}, respectively.
789 @findex CQImode
790 @findex CHImode
791 @findex CSImode
792 @findex CDImode
793 @findex CTImode
794 @findex COImode
795 @item CQImode, CHImode, CSImode, CDImode, CTImode, COImode
796 These modes stand for a complex number represented as a pair of integer
797 values.  The integer values are in @code{QImode}, @code{HImode},
798 @code{SImode}, @code{DImode}, @code{TImode}, and @code{OImode},
799 respectively.
800 @end table
802 The machine description defines @code{Pmode} as a C macro which expands
803 into the machine mode used for addresses.  Normally this is the mode
804 whose size is @code{BITS_PER_WORD}, @code{SImode} on 32-bit machines.
806 The only modes which a machine description @i{must} support are
807 @code{QImode}, and the modes corresponding to @code{BITS_PER_WORD},
808 @code{FLOAT_TYPE_SIZE} and @code{DOUBLE_TYPE_SIZE}.
809 The compiler will attempt to use @code{DImode} for 8-byte structures and
810 unions, but this can be prevented by overriding the definition of
811 @code{MAX_FIXED_MODE_SIZE}.  Alternatively, you can have the compiler
812 use @code{TImode} for 16-byte structures and unions.  Likewise, you can
813 arrange for the C type @code{short int} to avoid using @code{HImode}.
815 @cindex mode classes
816 Very few explicit references to machine modes remain in the compiler and
817 these few references will soon be removed.  Instead, the machine modes
818 are divided into mode classes.  These are represented by the enumeration
819 type @code{enum mode_class} defined in @file{machmode.h}.  The possible
820 mode classes are:
822 @table @code
823 @findex MODE_INT
824 @item MODE_INT
825 Integer modes.  By default these are @code{QImode}, @code{HImode},
826 @code{SImode}, @code{DImode}, and @code{TImode}.
828 @findex MODE_PARTIAL_INT
829 @item MODE_PARTIAL_INT
830 The ``partial integer'' modes, @code{PSImode} and @code{PDImode}.
832 @findex MODE_FLOAT
833 @item MODE_FLOAT
834 floating point modes.  By default these are @code{SFmode}, @code{DFmode},
835 @code{XFmode} and @code{TFmode}.
837 @findex MODE_COMPLEX_INT
838 @item MODE_COMPLEX_INT
839 Complex integer modes.  (These are not currently implemented).
841 @findex MODE_COMPLEX_FLOAT
842 @item MODE_COMPLEX_FLOAT
843 Complex floating point modes.  By default these are @code{SCmode},
844 @code{DCmode}, @code{XCmode}, and @code{TCmode}.
846 @findex MODE_FUNCTION
847 @item MODE_FUNCTION
848 Algol or Pascal function variables including a static chain.
849 (These are not currently implemented).
851 @findex MODE_CC
852 @item MODE_CC
853 Modes representing condition code values.  These are @code{CCmode} plus
854 any modes listed in the @code{EXTRA_CC_MODES} macro.  @xref{Jump Patterns},
855 also see @ref{Condition Code}.
857 @findex MODE_RANDOM
858 @item MODE_RANDOM
859 This is a catchall mode class for modes which don't fit into the above
860 classes.  Currently @code{VOIDmode} and @code{BLKmode} are in
861 @code{MODE_RANDOM}.
862 @end table
864 Here are some C macros that relate to machine modes:
866 @table @code
867 @findex GET_MODE
868 @item GET_MODE (@var{x})
869 Returns the machine mode of the RTX @var{x}.
871 @findex PUT_MODE
872 @item PUT_MODE (@var{x}, @var{newmode})
873 Alters the machine mode of the RTX @var{x} to be @var{newmode}.
875 @findex NUM_MACHINE_MODES
876 @item NUM_MACHINE_MODES
877 Stands for the number of machine modes available on the target
878 machine.  This is one greater than the largest numeric value of any
879 machine mode.
881 @findex GET_MODE_NAME
882 @item GET_MODE_NAME (@var{m})
883 Returns the name of mode @var{m} as a string.
885 @findex GET_MODE_CLASS
886 @item GET_MODE_CLASS (@var{m})
887 Returns the mode class of mode @var{m}.
889 @findex GET_MODE_WIDER_MODE
890 @item GET_MODE_WIDER_MODE (@var{m})
891 Returns the next wider natural mode.  For example, the expression
892 @code{GET_MODE_WIDER_MODE (QImode)} returns @code{HImode}.
894 @findex GET_MODE_SIZE
895 @item GET_MODE_SIZE (@var{m})
896 Returns the size in bytes of a datum of mode @var{m}.
898 @findex GET_MODE_BITSIZE
899 @item GET_MODE_BITSIZE (@var{m})
900 Returns the size in bits of a datum of mode @var{m}.
902 @findex GET_MODE_MASK
903 @item GET_MODE_MASK (@var{m})
904 Returns a bitmask containing 1 for all bits in a word that fit within
905 mode @var{m}.  This macro can only be used for modes whose bitsize is
906 less than or equal to @code{HOST_BITS_PER_INT}.
908 @findex GET_MODE_ALIGNMENT
909 @item GET_MODE_ALIGNMENT (@var{m})
910 Return the required alignment, in bits, for an object of mode @var{m}.
912 @findex GET_MODE_UNIT_SIZE
913 @item GET_MODE_UNIT_SIZE (@var{m})
914 Returns the size in bytes of the subunits of a datum of mode @var{m}.
915 This is the same as @code{GET_MODE_SIZE} except in the case of complex
916 modes.  For them, the unit size is the size of the real or imaginary
917 part.
919 @findex GET_MODE_NUNITS
920 @item GET_MODE_NUNITS (@var{m})
921 Returns the number of units contained in a mode, i.e.,
922 @code{GET_MODE_SIZE} divided by @code{GET_MODE_UNIT_SIZE}.
924 @findex GET_CLASS_NARROWEST_MODE
925 @item GET_CLASS_NARROWEST_MODE (@var{c})
926 Returns the narrowest mode in mode class @var{c}.
927 @end table
929 @findex byte_mode
930 @findex word_mode
931 The global variables @code{byte_mode} and @code{word_mode} contain modes
932 whose classes are @code{MODE_INT} and whose bitsizes are either
933 @code{BITS_PER_UNIT} or @code{BITS_PER_WORD}, respectively.  On 32-bit
934 machines, these are @code{QImode} and @code{SImode}, respectively.
936 @node Constants
937 @section Constant Expression Types
938 @cindex RTL constants
939 @cindex RTL constant expression types
941 The simplest RTL expressions are those that represent constant values.
943 @table @code
944 @findex const_int
945 @item (const_int @var{i})
946 This type of expression represents the integer value @var{i}.  @var{i}
947 is customarily accessed with the macro @code{INTVAL} as in
948 @code{INTVAL (@var{exp})}, which is equivalent to @code{XWINT (@var{exp}, 0)}.
950 @findex const0_rtx
951 @findex const1_rtx
952 @findex const2_rtx
953 @findex constm1_rtx
954 There is only one expression object for the integer value zero; it is
955 the value of the variable @code{const0_rtx}.  Likewise, the only
956 expression for integer value one is found in @code{const1_rtx}, the only
957 expression for integer value two is found in @code{const2_rtx}, and the
958 only expression for integer value negative one is found in
959 @code{constm1_rtx}.  Any attempt to create an expression of code
960 @code{const_int} and value zero, one, two or negative one will return
961 @code{const0_rtx}, @code{const1_rtx}, @code{const2_rtx} or
962 @code{constm1_rtx} as appropriate.@refill
964 @findex const_true_rtx
965 Similarly, there is only one object for the integer whose value is
966 @code{STORE_FLAG_VALUE}.  It is found in @code{const_true_rtx}.  If
967 @code{STORE_FLAG_VALUE} is one, @code{const_true_rtx} and
968 @code{const1_rtx} will point to the same object.  If
969 @code{STORE_FLAG_VALUE} is -1, @code{const_true_rtx} and
970 @code{constm1_rtx} will point to the same object.@refill
972 @findex const_double
973 @item (const_double:@var{m} @var{addr} @var{i0} @var{i1} @dots{})
974 Represents either a floating-point constant of mode @var{m} or an
975 integer constant too large to fit into @code{HOST_BITS_PER_WIDE_INT}
976 bits but small enough to fit within twice that number of bits (GNU CC
977 does not provide a mechanism to represent even larger constants).  In
978 the latter case, @var{m} will be @code{VOIDmode}.
980 @findex CONST_DOUBLE_MEM
981 @findex CONST_DOUBLE_CHAIN
982 @var{addr} is used to contain the @code{mem} expression that corresponds
983 to the location in memory that at which the constant can be found.  If
984 it has not been allocated a memory location, but is on the chain of all
985 @code{const_double} expressions in this compilation (maintained using an
986 undisplayed field), @var{addr} contains @code{const0_rtx}.  If it is not
987 on the chain, @var{addr} contains @code{cc0_rtx}.  @var{addr} is
988 customarily accessed with the macro @code{CONST_DOUBLE_MEM} and the
989 chain field via @code{CONST_DOUBLE_CHAIN}.@refill
991 @findex CONST_DOUBLE_LOW
992 If @var{m} is @code{VOIDmode}, the bits of the value are stored in
993 @var{i0} and @var{i1}.  @var{i0} is customarily accessed with the macro
994 @code{CONST_DOUBLE_LOW} and @var{i1} with @code{CONST_DOUBLE_HIGH}.
996 If the constant is floating point (regardless of its precision), then
997 the number of integers used to store the value depends on the size of
998 @code{REAL_VALUE_TYPE} (@pxref{Cross-compilation}).  The integers
999 represent a floating point number, but not precisely in the target
1000 machine's or host machine's floating point format.  To convert them to
1001 the precise bit pattern used by the target machine, use the macro
1002 @code{REAL_VALUE_TO_TARGET_DOUBLE} and friends (@pxref{Data Output}).
1004 @findex CONST0_RTX
1005 @findex CONST1_RTX
1006 @findex CONST2_RTX
1007 The macro @code{CONST0_RTX (@var{mode})} refers to an expression with
1008 value 0 in mode @var{mode}.  If mode @var{mode} is of mode class
1009 @code{MODE_INT}, it returns @code{const0_rtx}.  Otherwise, it returns a
1010 @code{CONST_DOUBLE} expression in mode @var{mode}.  Similarly, the macro
1011 @code{CONST1_RTX (@var{mode})} refers to an expression with value 1 in
1012 mode @var{mode} and similarly for @code{CONST2_RTX}.
1014 @findex const_string
1015 @item (const_string @var{str})
1016 Represents a constant string with value @var{str}.  Currently this is
1017 used only for insn attributes (@pxref{Insn Attributes}) since constant
1018 strings in C are placed in memory.
1020 @findex symbol_ref
1021 @item (symbol_ref:@var{mode} @var{symbol})
1022 Represents the value of an assembler label for data.  @var{symbol} is
1023 a string that describes the name of the assembler label.  If it starts
1024 with a @samp{*}, the label is the rest of @var{symbol} not including
1025 the @samp{*}.  Otherwise, the label is @var{symbol}, usually prefixed
1026 with @samp{_}.
1028 The @code{symbol_ref} contains a mode, which is usually @code{Pmode}.
1029 Usually that is the only mode for which a symbol is directly valid.
1031 @findex label_ref
1032 @item (label_ref @var{label})
1033 Represents the value of an assembler label for code.  It contains one
1034 operand, an expression, which must be a @code{code_label} that appears
1035 in the instruction sequence to identify the place where the label
1036 should go.
1038 The reason for using a distinct expression type for code label
1039 references is so that jump optimization can distinguish them.
1041 @item (const:@var{m} @var{exp})
1042 Represents a constant that is the result of an assembly-time
1043 arithmetic computation.  The operand, @var{exp}, is an expression that
1044 contains only constants (@code{const_int}, @code{symbol_ref} and
1045 @code{label_ref} expressions) combined with @code{plus} and
1046 @code{minus}.  However, not all combinations are valid, since the
1047 assembler cannot do arbitrary arithmetic on relocatable symbols.
1049 @var{m} should be @code{Pmode}.
1051 @findex high
1052 @item (high:@var{m} @var{exp})
1053 Represents the high-order bits of @var{exp}, usually a
1054 @code{symbol_ref}.  The number of bits is machine-dependent and is
1055 normally the number of bits specified in an instruction that initializes
1056 the high order bits of a register.  It is used with @code{lo_sum} to
1057 represent the typical two-instruction sequence used in RISC machines to
1058 reference a global memory location.
1060 @var{m} should be @code{Pmode}.
1061 @end table
1063 @node Regs and Memory
1064 @section Registers and Memory
1065 @cindex RTL register expressions
1066 @cindex RTL memory expressions
1068 Here are the RTL expression types for describing access to machine
1069 registers and to main memory.
1071 @table @code
1072 @findex reg
1073 @cindex hard registers
1074 @cindex pseudo registers
1075 @item (reg:@var{m} @var{n})
1076 For small values of the integer @var{n} (those that are less than
1077 @code{FIRST_PSEUDO_REGISTER}), this stands for a reference to machine
1078 register number @var{n}: a @dfn{hard register}.  For larger values of
1079 @var{n}, it stands for a temporary value or @dfn{pseudo register}.
1080 The compiler's strategy is to generate code assuming an unlimited
1081 number of such pseudo registers, and later convert them into hard
1082 registers or into memory references.
1084 @var{m} is the machine mode of the reference.  It is necessary because
1085 machines can generally refer to each register in more than one mode.
1086 For example, a register may contain a full word but there may be
1087 instructions to refer to it as a half word or as a single byte, as
1088 well as instructions to refer to it as a floating point number of
1089 various precisions.
1091 Even for a register that the machine can access in only one mode,
1092 the mode must always be specified.
1094 The symbol @code{FIRST_PSEUDO_REGISTER} is defined by the machine
1095 description, since the number of hard registers on the machine is an
1096 invariant characteristic of the machine.  Note, however, that not
1097 all of the machine registers must be general registers.  All the
1098 machine registers that can be used for storage of data are given
1099 hard register numbers, even those that can be used only in certain
1100 instructions or can hold only certain types of data.
1102 A hard register may be accessed in various modes throughout one
1103 function, but each pseudo register is given a natural mode
1104 and is accessed only in that mode.  When it is necessary to describe
1105 an access to a pseudo register using a nonnatural mode, a @code{subreg}
1106 expression is used.
1108 A @code{reg} expression with a machine mode that specifies more than
1109 one word of data may actually stand for several consecutive registers.
1110 If in addition the register number specifies a hardware register, then
1111 it actually represents several consecutive hardware registers starting
1112 with the specified one.
1114 Each pseudo register number used in a function's RTL code is
1115 represented by a unique @code{reg} expression.
1117 @findex FIRST_VIRTUAL_REGISTER
1118 @findex LAST_VIRTUAL_REGISTER
1119 Some pseudo register numbers, those within the range of
1120 @code{FIRST_VIRTUAL_REGISTER} to @code{LAST_VIRTUAL_REGISTER} only
1121 appear during the RTL generation phase and are eliminated before the
1122 optimization phases.  These represent locations in the stack frame that
1123 cannot be determined until RTL generation for the function has been
1124 completed.  The following virtual register numbers are defined:
1126 @table @code
1127 @findex VIRTUAL_INCOMING_ARGS_REGNUM
1128 @item VIRTUAL_INCOMING_ARGS_REGNUM
1129 This points to the first word of the incoming arguments passed on the
1130 stack.  Normally these arguments are placed there by the caller, but the
1131 callee may have pushed some arguments that were previously passed in
1132 registers.
1134 @cindex @code{FIRST_PARM_OFFSET} and virtual registers
1135 @cindex @code{ARG_POINTER_REGNUM} and virtual registers
1136 When RTL generation is complete, this virtual register is replaced
1137 by the sum of the register given by @code{ARG_POINTER_REGNUM} and the
1138 value of @code{FIRST_PARM_OFFSET}.
1140 @findex VIRTUAL_STACK_VARS_REGNUM
1141 @cindex @code{FRAME_GROWS_DOWNWARD} and virtual registers
1142 @item VIRTUAL_STACK_VARS_REGNUM
1143 If @code{FRAME_GROWS_DOWNWARD} is defined, this points to immediately
1144 above the first variable on the stack.  Otherwise, it points to the
1145 first variable on the stack.
1147 @cindex @code{STARTING_FRAME_OFFSET} and virtual registers
1148 @cindex @code{FRAME_POINTER_REGNUM} and virtual registers
1149 @code{VIRTUAL_STACK_VARS_REGNUM} is replaced with the sum of the
1150 register given by @code{FRAME_POINTER_REGNUM} and the value
1151 @code{STARTING_FRAME_OFFSET}.
1153 @findex VIRTUAL_STACK_DYNAMIC_REGNUM
1154 @item VIRTUAL_STACK_DYNAMIC_REGNUM
1155 This points to the location of dynamically allocated memory on the stack
1156 immediately after the stack pointer has been adjusted by the amount of
1157 memory desired.
1159 @cindex @code{STACK_DYNAMIC_OFFSET} and virtual registers
1160 @cindex @code{STACK_POINTER_REGNUM} and virtual registers
1161 This virtual register is replaced by the sum of the register given by
1162 @code{STACK_POINTER_REGNUM} and the value @code{STACK_DYNAMIC_OFFSET}.
1164 @findex VIRTUAL_OUTGOING_ARGS_REGNUM
1165 @item VIRTUAL_OUTGOING_ARGS_REGNUM
1166 This points to the location in the stack at which outgoing arguments
1167 should be written when the stack is pre-pushed (arguments pushed using
1168 push insns should always use @code{STACK_POINTER_REGNUM}).
1170 @cindex @code{STACK_POINTER_OFFSET} and virtual registers
1171 This virtual register is replaced by the sum of the register given by
1172 @code{STACK_POINTER_REGNUM} and the value @code{STACK_POINTER_OFFSET}.
1173 @end table
1175 @findex subreg
1176 @item (subreg:@var{m} @var{reg} @var{wordnum})
1177 @code{subreg} expressions are used to refer to a register in a machine
1178 mode other than its natural one, or to refer to one register of
1179 a multi-word @code{reg} that actually refers to several registers.
1181 Each pseudo-register has a natural mode.  If it is necessary to
1182 operate on it in a different mode---for example, to perform a fullword
1183 move instruction on a pseudo-register that contains a single
1184 byte---the pseudo-register must be enclosed in a @code{subreg}.  In
1185 such a case, @var{wordnum} is zero.
1187 Usually @var{m} is at least as narrow as the mode of @var{reg}, in which
1188 case it is restricting consideration to only the bits of @var{reg} that
1189 are in @var{m}.
1191 Sometimes @var{m} is wider than the mode of @var{reg}.  These
1192 @code{subreg} expressions are often called @dfn{paradoxical}.  They are
1193 used in cases where we want to refer to an object in a wider mode but do
1194 not care what value the additional bits have.  The reload pass ensures
1195 that paradoxical references are only made to hard registers.
1197 The other use of @code{subreg} is to extract the individual registers of
1198 a multi-register value.  Machine modes such as @code{DImode} and
1199 @code{TImode} can indicate values longer than a word, values which
1200 usually require two or more consecutive registers.  To access one of the
1201 registers, use a @code{subreg} with mode @code{SImode} and a
1202 @var{wordnum} that says which register.
1204 Storing in a non-paradoxical @code{subreg} has undefined results for
1205 bits belonging to the same word as the @code{subreg}.  This laxity makes
1206 it easier to generate efficient code for such instructions.  To
1207 represent an instruction that preserves all the bits outside of those in
1208 the @code{subreg}, use @code{strict_low_part} around the @code{subreg}.
1210 @cindex @code{WORDS_BIG_ENDIAN}, effect on @code{subreg}
1211 The compilation parameter @code{WORDS_BIG_ENDIAN}, if set to 1, says
1212 that word number zero is the most significant part; otherwise, it is
1213 the least significant part.
1215 @cindex @code{FLOAT_WORDS_BIG_ENDIAN}, (lack of) effect on @code{subreg}
1216 On a few targets, @code{FLOAT_WORDS_BIG_ENDIAN} disagrees with
1217 @code{WORDS_BIG_ENDIAN}.
1218 However, most parts of the compiler treat floating point values as if
1219 they had the same endianness as integer values.  This works because
1220 they handle them solely as a collection of integer values, with no
1221 particular numerical value.  Only real.c and the runtime libraries
1222 care about @code{FLOAT_WORDS_BIG_ENDIAN}.
1224 @cindex combiner pass
1225 @cindex reload pass
1226 @cindex @code{subreg}, special reload handling
1227 Between the combiner pass and the reload pass, it is possible to have a
1228 paradoxical @code{subreg} which contains a @code{mem} instead of a
1229 @code{reg} as its first operand.  After the reload pass, it is also
1230 possible to have a non-paradoxical @code{subreg} which contains a
1231 @code{mem}; this usually occurs when the @code{mem} is a stack slot
1232 which replaced a pseudo register.
1234 Note that it is not valid to access a @code{DFmode} value in @code{SFmode}
1235 using a @code{subreg}.  On some machines the most significant part of a
1236 @code{DFmode} value does not have the same format as a single-precision
1237 floating value.
1239 It is also not valid to access a single word of a multi-word value in a
1240 hard register when less registers can hold the value than would be
1241 expected from its size.  For example, some 32-bit machines have
1242 floating-point registers that can hold an entire @code{DFmode} value.
1243 If register 10 were such a register @code{(subreg:SI (reg:DF 10) 1)}
1244 would be invalid because there is no way to convert that reference to
1245 a single machine register.  The reload pass prevents @code{subreg}
1246 expressions such as these from being formed.
1248 @findex SUBREG_REG
1249 @findex SUBREG_WORD
1250 The first operand of a @code{subreg} expression is customarily accessed 
1251 with the @code{SUBREG_REG} macro and the second operand is customarily
1252 accessed with the @code{SUBREG_WORD} macro.
1254 @findex scratch
1255 @cindex scratch operands
1256 @item (scratch:@var{m})
1257 This represents a scratch register that will be required for the
1258 execution of a single instruction and not used subsequently.  It is
1259 converted into a @code{reg} by either the local register allocator or
1260 the reload pass.
1262 @code{scratch} is usually present inside a @code{clobber} operation
1263 (@pxref{Side Effects}).
1265 @findex cc0
1266 @cindex condition code register
1267 @item (cc0)
1268 This refers to the machine's condition code register.  It has no
1269 operands and may not have a machine mode.  There are two ways to use it:
1271 @itemize @bullet
1272 @item
1273 To stand for a complete set of condition code flags.  This is best on
1274 most machines, where each comparison sets the entire series of flags.
1276 With this technique, @code{(cc0)} may be validly used in only two
1277 contexts: as the destination of an assignment (in test and compare
1278 instructions) and in comparison operators comparing against zero
1279 (@code{const_int} with value zero; that is to say, @code{const0_rtx}).
1281 @item
1282 To stand for a single flag that is the result of a single condition.
1283 This is useful on machines that have only a single flag bit, and in
1284 which comparison instructions must specify the condition to test.
1286 With this technique, @code{(cc0)} may be validly used in only two
1287 contexts: as the destination of an assignment (in test and compare
1288 instructions) where the source is a comparison operator, and as the
1289 first operand of @code{if_then_else} (in a conditional branch).
1290 @end itemize
1292 @findex cc0_rtx
1293 There is only one expression object of code @code{cc0}; it is the
1294 value of the variable @code{cc0_rtx}.  Any attempt to create an
1295 expression of code @code{cc0} will return @code{cc0_rtx}.
1297 Instructions can set the condition code implicitly.  On many machines,
1298 nearly all instructions set the condition code based on the value that
1299 they compute or store.  It is not necessary to record these actions
1300 explicitly in the RTL because the machine description includes a
1301 prescription for recognizing the instructions that do so (by means of
1302 the macro @code{NOTICE_UPDATE_CC}).  @xref{Condition Code}.  Only
1303 instructions whose sole purpose is to set the condition code, and
1304 instructions that use the condition code, need mention @code{(cc0)}.
1306 On some machines, the condition code register is given a register number
1307 and a @code{reg} is used instead of @code{(cc0)}.  This is usually the
1308 preferable approach if only a small subset of instructions modify the
1309 condition code.  Other machines store condition codes in general
1310 registers; in such cases a pseudo register should be used.
1312 Some machines, such as the Sparc and RS/6000, have two sets of
1313 arithmetic instructions, one that sets and one that does not set the
1314 condition code.  This is best handled by normally generating the
1315 instruction that does not set the condition code, and making a pattern
1316 that both performs the arithmetic and sets the condition code register
1317 (which would not be @code{(cc0)} in this case).  For examples, search
1318 for @samp{addcc} and @samp{andcc} in @file{sparc.md}.
1320 @findex pc
1321 @item (pc)
1322 @cindex program counter
1323 This represents the machine's program counter.  It has no operands and
1324 may not have a machine mode.  @code{(pc)} may be validly used only in
1325 certain specific contexts in jump instructions.
1327 @findex pc_rtx
1328 There is only one expression object of code @code{pc}; it is the value
1329 of the variable @code{pc_rtx}.  Any attempt to create an expression of
1330 code @code{pc} will return @code{pc_rtx}.
1332 All instructions that do not jump alter the program counter implicitly
1333 by incrementing it, but there is no need to mention this in the RTL.
1335 @findex mem
1336 @item (mem:@var{m} @var{addr} @var{alias})
1337 This RTX represents a reference to main memory at an address
1338 represented by the expression @var{addr}.  @var{m} specifies how large
1339 a unit of memory is accessed. @var{alias} specifies an alias set for the
1340 reference. In general two items are in different alias sets if they cannot
1341 reference the same memory address.
1343 @findex addressof
1344 @item (addressof:@var{m} @var{reg})
1345 This RTX represents a request for the address of register @var{reg}.  Its mode
1346 is always @code{Pmode}.  If there are any @code{addressof}
1347 expressions left in the function after CSE, @var{reg} is forced into the
1348 stack and the @code{addressof} expression is replaced with a @code{plus}
1349 expression for the address of its stack slot.
1350 @end table
1352 @node Arithmetic
1353 @section RTL Expressions for Arithmetic
1354 @cindex arithmetic, in RTL
1355 @cindex math, in RTL
1356 @cindex RTL expressions for arithmetic
1358 Unless otherwise specified, all the operands of arithmetic expressions
1359 must be valid for mode @var{m}.  An operand is valid for mode @var{m}
1360 if it has mode @var{m}, or if it is a @code{const_int} or
1361 @code{const_double} and @var{m} is a mode of class @code{MODE_INT}.
1363 For commutative binary operations, constants should be placed in the
1364 second operand.
1366 @table @code
1367 @findex plus
1368 @cindex RTL addition
1369 @cindex RTL sum
1370 @item (plus:@var{m} @var{x} @var{y})
1371 Represents the sum of the values represented by @var{x} and @var{y}
1372 carried out in machine mode @var{m}. 
1374 @findex lo_sum
1375 @item (lo_sum:@var{m} @var{x} @var{y})
1376 Like @code{plus}, except that it represents that sum of @var{x} and the
1377 low-order bits of @var{y}.  The number of low order bits is
1378 machine-dependent but is normally the number of bits in a @code{Pmode}
1379 item minus the number of bits set by the @code{high} code
1380 (@pxref{Constants}).
1382 @var{m} should be @code{Pmode}.
1384 @findex minus
1385 @cindex RTL subtraction
1386 @cindex RTL difference
1387 @item (minus:@var{m} @var{x} @var{y})
1388 Like @code{plus} but represents subtraction.
1390 @findex ss_plus
1391 @cindex RTL addition with signed saturation
1392 @item (ss_plus:@var{m} @var{x} @var{y})
1394 Like @code{plus}, but using signed saturation in case of an overflow.
1396 @findex us_plus
1397 @cindex RTL addition with unsigned saturation
1398 @item (us_plus:@var{m} @var{x} @var{y})
1400 Like @code{plus}, but using unsigned saturation in case of an overflow.
1402 @findex ss_minus
1403 @cindex RTL addition with signed saturation
1404 @item (ss_minus:@var{m} @var{x} @var{y})
1406 Like @code{minus}, but using signed saturation in case of an overflow.
1408 @findex us_minus
1409 @cindex RTL addition with unsigned saturation
1410 @item (us_minus:@var{m} @var{x} @var{y})
1412 Like @code{minus}, but using unsigned saturation in case of an overflow.
1414 @findex compare
1415 @cindex RTL comparison
1416 @item (compare:@var{m} @var{x} @var{y})
1417 Represents the result of subtracting @var{y} from @var{x} for purposes
1418 of comparison.  The result is computed without overflow, as if with
1419 infinite precision.
1421 Of course, machines can't really subtract with infinite precision.
1422 However, they can pretend to do so when only the sign of the
1423 result will be used, which is the case when the result is stored
1424 in the condition code.   And that is the only way this kind of expression
1425 may validly be used: as a value to be stored in the condition codes.
1427 The mode @var{m} is not related to the modes of @var{x} and @var{y},
1428 but instead is the mode of the condition code value.  If @code{(cc0)}
1429 is used, it is @code{VOIDmode}.  Otherwise it is some mode in class
1430 @code{MODE_CC}, often @code{CCmode}.  @xref{Condition Code}.
1432 Normally, @var{x} and @var{y} must have the same mode.  Otherwise,
1433 @code{compare} is valid only if the mode of @var{x} is in class
1434 @code{MODE_INT} and @var{y} is a @code{const_int} or
1435 @code{const_double} with mode @code{VOIDmode}.  The mode of @var{x}
1436 determines what mode the comparison is to be done in; thus it must not
1437 be @code{VOIDmode}.
1439 If one of the operands is a constant, it should be placed in the
1440 second operand and the comparison code adjusted as appropriate.  
1442 A @code{compare} specifying two @code{VOIDmode} constants is not valid
1443 since there is no way to know in what mode the comparison is to be
1444 performed; the comparison must either be folded during the compilation
1445 or the first operand must be loaded into a register while its mode is
1446 still known.
1448 @findex neg
1449 @item (neg:@var{m} @var{x})
1450 Represents the negation (subtraction from zero) of the value represented
1451 by @var{x}, carried out in mode @var{m}.
1453 @findex mult
1454 @cindex multiplication
1455 @cindex product
1456 @item (mult:@var{m} @var{x} @var{y})
1457 Represents the signed product of the values represented by @var{x} and
1458 @var{y} carried out in machine mode @var{m}.
1460 Some machines support a multiplication that generates a product wider
1461 than the operands.  Write the pattern for this as
1463 @example
1464 (mult:@var{m} (sign_extend:@var{m} @var{x}) (sign_extend:@var{m} @var{y}))
1465 @end example
1467 where @var{m} is wider than the modes of @var{x} and @var{y}, which need
1468 not be the same.
1470 Write patterns for unsigned widening multiplication similarly using
1471 @code{zero_extend}.
1473 @findex div
1474 @cindex division
1475 @cindex signed division
1476 @cindex quotient
1477 @item (div:@var{m} @var{x} @var{y})
1478 Represents the quotient in signed division of @var{x} by @var{y},
1479 carried out in machine mode @var{m}.  If @var{m} is a floating point
1480 mode, it represents the exact quotient; otherwise, the integerized
1481 quotient.
1483 Some machines have division instructions in which the operands and
1484 quotient widths are not all the same; you should represent 
1485 such instructions using @code{truncate} and @code{sign_extend} as in,
1487 @example
1488 (truncate:@var{m1} (div:@var{m2} @var{x} (sign_extend:@var{m2} @var{y})))
1489 @end example
1491 @findex udiv
1492 @cindex unsigned division
1493 @cindex division
1494 @item (udiv:@var{m} @var{x} @var{y})
1495 Like @code{div} but represents unsigned division.
1497 @findex mod
1498 @findex umod
1499 @cindex remainder
1500 @cindex division
1501 @item (mod:@var{m} @var{x} @var{y})
1502 @itemx (umod:@var{m} @var{x} @var{y})
1503 Like @code{div} and @code{udiv} but represent the remainder instead of
1504 the quotient.
1506 @findex smin
1507 @findex smax
1508 @cindex signed minimum
1509 @cindex signed maximum
1510 @item (smin:@var{m} @var{x} @var{y})
1511 @itemx (smax:@var{m} @var{x} @var{y})
1512 Represents the smaller (for @code{smin}) or larger (for @code{smax}) of
1513 @var{x} and @var{y}, interpreted as signed integers in mode @var{m}.
1515 @findex umin
1516 @findex umax
1517 @cindex unsigned minimum and maximum
1518 @item (umin:@var{m} @var{x} @var{y})
1519 @itemx (umax:@var{m} @var{x} @var{y})
1520 Like @code{smin} and @code{smax}, but the values are interpreted as unsigned
1521 integers.
1523 @findex not
1524 @cindex complement, bitwise
1525 @cindex bitwise complement
1526 @item (not:@var{m} @var{x})
1527 Represents the bitwise complement of the value represented by @var{x},
1528 carried out in mode @var{m}, which must be a fixed-point machine mode.
1530 @findex and
1531 @cindex logical-and, bitwise
1532 @cindex bitwise logical-and
1533 @item (and:@var{m} @var{x} @var{y})
1534 Represents the bitwise logical-and of the values represented by
1535 @var{x} and @var{y}, carried out in machine mode @var{m}, which must be
1536 a fixed-point machine mode.
1538 @findex ior
1539 @cindex inclusive-or, bitwise
1540 @cindex bitwise inclusive-or
1541 @item (ior:@var{m} @var{x} @var{y})
1542 Represents the bitwise inclusive-or of the values represented by @var{x}
1543 and @var{y}, carried out in machine mode @var{m}, which must be a
1544 fixed-point mode.
1546 @findex xor
1547 @cindex exclusive-or, bitwise
1548 @cindex bitwise exclusive-or
1549 @item (xor:@var{m} @var{x} @var{y})
1550 Represents the bitwise exclusive-or of the values represented by @var{x}
1551 and @var{y}, carried out in machine mode @var{m}, which must be a
1552 fixed-point mode.
1554 @findex ashift
1555 @cindex left shift
1556 @cindex shift
1557 @cindex arithmetic shift
1558 @item (ashift:@var{m} @var{x} @var{c})
1559 Represents the result of arithmetically shifting @var{x} left by @var{c}
1560 places.  @var{x} have mode @var{m}, a fixed-point machine mode.  @var{c}
1561 be a fixed-point mode or be a constant with mode @code{VOIDmode}; which
1562 mode is determined by the mode called for in the machine description
1563 entry for the left-shift instruction.  For example, on the Vax, the mode
1564 of @var{c} is @code{QImode} regardless of @var{m}.
1566 @findex lshiftrt
1567 @cindex right shift
1568 @findex ashiftrt
1569 @item (lshiftrt:@var{m} @var{x} @var{c})
1570 @itemx (ashiftrt:@var{m} @var{x} @var{c})
1571 Like @code{ashift} but for right shift.  Unlike the case for left shift,
1572 these two operations are distinct.
1574 @findex rotate
1575 @cindex rotate 
1576 @cindex left rotate
1577 @findex rotatert
1578 @cindex right rotate
1579 @item (rotate:@var{m} @var{x} @var{c})
1580 @itemx (rotatert:@var{m} @var{x} @var{c})
1581 Similar but represent left and right rotate.  If @var{c} is a constant,
1582 use @code{rotate}.
1584 @findex abs
1585 @cindex absolute value
1586 @item (abs:@var{m} @var{x})
1587 Represents the absolute value of @var{x}, computed in mode @var{m}.
1589 @findex sqrt
1590 @cindex square root
1591 @item (sqrt:@var{m} @var{x})
1592 Represents the square root of @var{x}, computed in mode @var{m}.
1593 Most often @var{m} will be a floating point mode.
1595 @findex ffs
1596 @item (ffs:@var{m} @var{x})
1597 Represents one plus the index of the least significant 1-bit in
1598 @var{x}, represented as an integer of mode @var{m}.  (The value is
1599 zero if @var{x} is zero.)  The mode of @var{x} need not be @var{m};
1600 depending on the target machine, various mode combinations may be
1601 valid.
1602 @end table
1604 @node Comparisons
1605 @section Comparison Operations
1606 @cindex RTL comparison operations
1608 Comparison operators test a relation on two operands and are considered
1609 to represent a machine-dependent nonzero value described by, but not
1610 necessarily equal to, @code{STORE_FLAG_VALUE} (@pxref{Misc})
1611 if the relation holds, or zero if it does not.  The mode of the
1612 comparison operation is independent of the mode of the data being
1613 compared.  If the comparison operation is being tested (e.g., the first
1614 operand of an @code{if_then_else}), the mode must be @code{VOIDmode}.
1615 If the comparison operation is producing data to be stored in some
1616 variable, the mode must be in class @code{MODE_INT}.  All comparison
1617 operations producing data must use the same mode, which is
1618 machine-specific.
1620 @cindex condition codes
1621 There are two ways that comparison operations may be used.  The
1622 comparison operators may be used to compare the condition codes
1623 @code{(cc0)} against zero, as in @code{(eq (cc0) (const_int 0))}.  Such
1624 a construct actually refers to the result of the preceding instruction
1625 in which the condition codes were set.  The instruction setting the
1626 condition code must be adjacent to the instruction using the condition
1627 code; only @code{note} insns may separate them.
1629 Alternatively, a comparison operation may directly compare two data
1630 objects.  The mode of the comparison is determined by the operands; they
1631 must both be valid for a common machine mode.  A comparison with both
1632 operands constant would be invalid as the machine mode could not be
1633 deduced from it, but such a comparison should never exist in RTL due to
1634 constant folding.
1636 In the example above, if @code{(cc0)} were last set to
1637 @code{(compare @var{x} @var{y})}, the comparison operation is
1638 identical to @code{(eq @var{x} @var{y})}.  Usually only one style
1639 of comparisons is supported on a particular machine, but the combine
1640 pass will try to merge the operations to produce the @code{eq} shown
1641 in case it exists in the context of the particular insn involved.
1643 Inequality comparisons come in two flavors, signed and unsigned.  Thus,
1644 there are distinct expression codes @code{gt} and @code{gtu} for signed and
1645 unsigned greater-than.  These can produce different results for the same
1646 pair of integer values: for example, 1 is signed greater-than -1 but not
1647 unsigned greater-than, because -1 when regarded as unsigned is actually
1648 @code{0xffffffff} which is greater than 1.
1650 The signed comparisons are also used for floating point values.  Floating
1651 point comparisons are distinguished by the machine modes of the operands.
1653 @table @code
1654 @findex eq
1655 @cindex equal
1656 @item (eq:@var{m} @var{x} @var{y})
1657 @code{STORE_FLAG_VALUE} if the values represented by @var{x} and @var{y}
1658 are equal, otherwise 0.
1660 @findex ne
1661 @cindex not equal
1662 @item (ne:@var{m} @var{x} @var{y})
1663 @code{STORE_FLAG_VALUE} if the values represented by @var{x} and @var{y}
1664 are not equal, otherwise 0.
1666 @findex gt
1667 @cindex greater than
1668 @item (gt:@var{m} @var{x} @var{y})
1669 @code{STORE_FLAG_VALUE} if the @var{x} is greater than @var{y}.  If they
1670 are fixed-point, the comparison is done in a signed sense.
1672 @findex gtu
1673 @cindex greater than
1674 @cindex unsigned greater than
1675 @item (gtu:@var{m} @var{x} @var{y})
1676 Like @code{gt} but does unsigned comparison, on fixed-point numbers only.
1678 @findex lt
1679 @cindex less than
1680 @findex ltu
1681 @cindex unsigned less than
1682 @item (lt:@var{m} @var{x} @var{y})
1683 @itemx (ltu:@var{m} @var{x} @var{y})
1684 Like @code{gt} and @code{gtu} but test for ``less than''.
1686 @findex ge
1687 @cindex greater than
1688 @findex geu
1689 @cindex unsigned greater than
1690 @item (ge:@var{m} @var{x} @var{y})
1691 @itemx (geu:@var{m} @var{x} @var{y})
1692 Like @code{gt} and @code{gtu} but test for ``greater than or equal''.
1694 @findex le
1695 @cindex less than or equal
1696 @findex leu
1697 @cindex unsigned less than
1698 @item (le:@var{m} @var{x} @var{y})
1699 @itemx (leu:@var{m} @var{x} @var{y})
1700 Like @code{gt} and @code{gtu} but test for ``less than or equal''.
1702 @findex if_then_else
1703 @item (if_then_else @var{cond} @var{then} @var{else})
1704 This is not a comparison operation but is listed here because it is
1705 always used in conjunction with a comparison operation.  To be
1706 precise, @var{cond} is a comparison expression.  This expression
1707 represents a choice, according to @var{cond}, between the value
1708 represented by @var{then} and the one represented by @var{else}.
1710 On most machines, @code{if_then_else} expressions are valid only
1711 to express conditional jumps.
1713 @findex cond
1714 @item (cond [@var{test1} @var{value1} @var{test2} @var{value2} @dots{}] @var{default})
1715 Similar to @code{if_then_else}, but more general.  Each of @var{test1},
1716 @var{test2}, @dots{} is performed in turn.  The result of this expression is
1717 the @var{value} corresponding to the first non-zero test, or @var{default} if
1718 none of the tests are non-zero expressions.
1720 This is currently not valid for instruction patterns and is supported only
1721 for insn attributes.  @xref{Insn Attributes}.
1722 @end table
1724 @node Bit Fields
1725 @section Bit Fields
1726 @cindex bit fields
1728 Special expression codes exist to represent bitfield instructions.
1729 These types of expressions are lvalues in RTL; they may appear
1730 on the left side of an assignment, indicating insertion of a value
1731 into the specified bit field.
1733 @table @code
1734 @findex sign_extract
1735 @cindex @code{BITS_BIG_ENDIAN}, effect on @code{sign_extract}
1736 @item (sign_extract:@var{m} @var{loc} @var{size} @var{pos})
1737 This represents a reference to a sign-extended bit field contained or
1738 starting in @var{loc} (a memory or register reference).  The bit field
1739 is @var{size} bits wide and starts at bit @var{pos}.  The compilation
1740 option @code{BITS_BIG_ENDIAN} says which end of the memory unit
1741 @var{pos} counts from.
1743 If @var{loc} is in memory, its mode must be a single-byte integer mode.
1744 If @var{loc} is in a register, the mode to use is specified by the
1745 operand of the @code{insv} or @code{extv} pattern
1746 (@pxref{Standard Names}) and is usually a full-word integer mode,
1747 which is the default if none is specified.
1749 The mode of @var{pos} is machine-specific and is also specified
1750 in the @code{insv} or @code{extv} pattern.
1752 The mode @var{m} is the same as the mode that would be used for
1753 @var{loc} if it were a register.
1755 @findex zero_extract
1756 @item (zero_extract:@var{m} @var{loc} @var{size} @var{pos})
1757 Like @code{sign_extract} but refers to an unsigned or zero-extended
1758 bit field.  The same sequence of bits are extracted, but they
1759 are filled to an entire word with zeros instead of by sign-extension.
1760 @end table
1762 @node Vector Operations
1763 @section Vector Operations
1764 @cindex vector operations
1766 All normal rtl expressions can be used with vector modes; they are
1767 interpreted as operating on each part of the vector independently.
1768 Additionally, there are a few new expressions to describe specific vector
1769 operations.
1771 @table @code
1772 @findex vec_merge
1773 @item (vec_merge:@var{m} @var{vec1} @var{vec2} @var{items})
1774 This describes a merge operation between two vectors.  The result is a vector
1775 of mode @var{m}; its elements are selected from either @var{vec1} or
1776 @var{vec2}.  Which elements are selected is described by @var{items}, which
1777 is a bit mask represented by a @code{const_int}; a zero bit indicates the
1778 corresponding element in the result vector is taken from @var{vec2} while
1779 a set bit indicates it is taken from @var{vec1}.
1781 @findex vec_select
1782 @item (vec_select:@var{m} @var{vec1} @var{selection})
1783 This describes an operation that selects parts of a vector.  @var{vec1} is
1784 the source vector, @var{selection} is a @code{parallel} that contains a
1785 @code{const_int} for each of the subparts of the result vector, giving the
1786 number of the source subpart that should be stored into it.
1788 @findex vec_concat
1789 @item (vec_concat:@var{m} @var{vec1} @var{vec2})
1790 Describes a vector concat operation.  The result is a concatenation of the
1791 vectors @var{vec1} and @var{vec2}; its length is the sum of the lengths of
1792 the two inputs.
1794 @findex vec_const
1795 @item (vec_const:@var{m} @var{subparts})
1796 This describes a constant vector.  @var{subparts} is a @code{parallel} that
1797 contains a constant for each of the subparts of the vector.
1799 @findex vec_duplicate
1800 @item (vec_duplicate:@var{m} @var{vec})
1801 This operation converts a small vector into a larger one by duplicating the
1802 input values.  The output vector mode must have the same submodes as the
1803 input vector mode, and the number of output parts must be an integer multiple
1804 of the number of input parts.
1806 @end table
1808 @node Conversions
1809 @section Conversions
1810 @cindex conversions
1811 @cindex machine mode conversions
1813 All conversions between machine modes must be represented by
1814 explicit conversion operations.  For example, an expression
1815 which is the sum of a byte and a full word cannot be written as
1816 @code{(plus:SI (reg:QI 34) (reg:SI 80))} because the @code{plus}
1817 operation requires two operands of the same machine mode.
1818 Therefore, the byte-sized operand is enclosed in a conversion
1819 operation, as in
1821 @example
1822 (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
1823 @end example
1825 The conversion operation is not a mere placeholder, because there
1826 may be more than one way of converting from a given starting mode
1827 to the desired final mode.  The conversion operation code says how
1828 to do it.
1830 For all conversion operations, @var{x} must not be @code{VOIDmode}
1831 because the mode in which to do the conversion would not be known.
1832 The conversion must either be done at compile-time or @var{x}
1833 must be placed into a register.
1835 @table @code
1836 @findex sign_extend
1837 @item (sign_extend:@var{m} @var{x})
1838 Represents the result of sign-extending the value @var{x}
1839 to machine mode @var{m}.  @var{m} must be a fixed-point mode
1840 and @var{x} a fixed-point value of a mode narrower than @var{m}.
1842 @findex zero_extend
1843 @item (zero_extend:@var{m} @var{x})
1844 Represents the result of zero-extending the value @var{x}
1845 to machine mode @var{m}.  @var{m} must be a fixed-point mode
1846 and @var{x} a fixed-point value of a mode narrower than @var{m}.
1848 @findex float_extend
1849 @item (float_extend:@var{m} @var{x})
1850 Represents the result of extending the value @var{x}
1851 to machine mode @var{m}.  @var{m} must be a floating point mode
1852 and @var{x} a floating point value of a mode narrower than @var{m}.
1854 @findex truncate
1855 @item (truncate:@var{m} @var{x})
1856 Represents the result of truncating the value @var{x}
1857 to machine mode @var{m}.  @var{m} must be a fixed-point mode
1858 and @var{x} a fixed-point value of a mode wider than @var{m}.
1860 @findex ss_truncate
1861 @item (ss_truncate:@var{m} @var{x})
1862 Represents the result of truncating the value @var{x}
1863 to machine mode @var{m}, using signed saturation in the case of
1864 overflow.  Both @var{m} and the mode of @var{x} must be fixed-point
1865 modes.
1867 @findex us_truncate
1868 @item (us_truncate:@var{m} @var{x})
1869 Represents the result of truncating the value @var{x}
1870 to machine mode @var{m}, using unsigned saturation in the case of
1871 overflow.  Both @var{m} and the mode of @var{x} must be fixed-point
1872 modes.
1874 @findex float_truncate
1875 @item (float_truncate:@var{m} @var{x})
1876 Represents the result of truncating the value @var{x}
1877 to machine mode @var{m}.  @var{m} must be a floating point mode
1878 and @var{x} a floating point value of a mode wider than @var{m}.
1880 @findex float
1881 @item (float:@var{m} @var{x})
1882 Represents the result of converting fixed point value @var{x},
1883 regarded as signed, to floating point mode @var{m}.
1885 @findex unsigned_float
1886 @item (unsigned_float:@var{m} @var{x})
1887 Represents the result of converting fixed point value @var{x},
1888 regarded as unsigned, to floating point mode @var{m}.
1890 @findex fix
1891 @item (fix:@var{m} @var{x})
1892 When @var{m} is a fixed point mode, represents the result of
1893 converting floating point value @var{x} to mode @var{m}, regarded as
1894 signed.  How rounding is done is not specified, so this operation may
1895 be used validly in compiling C code only for integer-valued operands.
1897 @findex unsigned_fix
1898 @item (unsigned_fix:@var{m} @var{x})
1899 Represents the result of converting floating point value @var{x} to
1900 fixed point mode @var{m}, regarded as unsigned.  How rounding is done
1901 is not specified.
1903 @findex fix
1904 @item (fix:@var{m} @var{x})
1905 When @var{m} is a floating point mode, represents the result of
1906 converting floating point value @var{x} (valid for mode @var{m}) to an
1907 integer, still represented in floating point mode @var{m}, by rounding
1908 towards zero.
1909 @end table
1911 @node RTL Declarations
1912 @section Declarations
1913 @cindex RTL declarations
1914 @cindex declarations, RTL
1916 Declaration expression codes do not represent arithmetic operations
1917 but rather state assertions about their operands.
1919 @table @code
1920 @findex strict_low_part
1921 @cindex @code{subreg}, in @code{strict_low_part}
1922 @item (strict_low_part (subreg:@var{m} (reg:@var{n} @var{r}) 0))
1923 This expression code is used in only one context: as the destination operand of a
1924 @code{set} expression.  In addition, the operand of this expression
1925 must be a non-paradoxical @code{subreg} expression.
1927 The presence of @code{strict_low_part} says that the part of the
1928 register which is meaningful in mode @var{n}, but is not part of
1929 mode @var{m}, is not to be altered.  Normally, an assignment to such
1930 a subreg is allowed to have undefined effects on the rest of the
1931 register when @var{m} is less than a word.
1932 @end table
1934 @node Side Effects
1935 @section Side Effect Expressions
1936 @cindex RTL side effect expressions
1938 The expression codes described so far represent values, not actions.
1939 But machine instructions never produce values; they are meaningful
1940 only for their side effects on the state of the machine.  Special
1941 expression codes are used to represent side effects.
1943 The body of an instruction is always one of these side effect codes;
1944 the codes described above, which represent values, appear only as
1945 the operands of these.
1947 @table @code
1948 @findex set
1949 @item (set @var{lval} @var{x})
1950 Represents the action of storing the value of @var{x} into the place
1951 represented by @var{lval}.  @var{lval} must be an expression
1952 representing a place that can be stored in: @code{reg} (or @code{subreg}
1953 or @code{strict_low_part}), @code{mem}, @code{pc}, @code{parallel}, or
1954 @code{cc0}.@refill
1956 If @var{lval} is a @code{reg}, @code{subreg} or @code{mem}, it has a
1957 machine mode; then @var{x} must be valid for that mode.@refill
1959 If @var{lval} is a @code{reg} whose machine mode is less than the full
1960 width of the register, then it means that the part of the register
1961 specified by the machine mode is given the specified value and the
1962 rest of the register receives an undefined value.  Likewise, if
1963 @var{lval} is a @code{subreg} whose machine mode is narrower than
1964 the mode of the register, the rest of the register can be changed in
1965 an undefined way.
1967 If @var{lval} is a @code{strict_low_part} of a @code{subreg}, then the
1968 part of the register specified by the machine mode of the
1969 @code{subreg} is given the value @var{x} and the rest of the register
1970 is not changed.@refill
1972 If @var{lval} is @code{(cc0)}, it has no machine mode, and @var{x} may
1973 be either a @code{compare} expression or a value that may have any mode.
1974 The latter case represents a ``test'' instruction.  The expression
1975 @code{(set (cc0) (reg:@var{m} @var{n}))} is equivalent to
1976 @code{(set (cc0) (compare (reg:@var{m} @var{n}) (const_int 0)))}.
1977 Use the former expression to save space during the compilation.
1979 If @var{lval} is a @code{parallel}, it is used to represent the case of
1980 a function returning a structure in multiple registers.  Each element
1981 of the @code{paralllel} is an @code{expr_list} whose first operand is a
1982 @code{reg} and whose second operand is a @code{const_int} representing the
1983 offset (in bytes) into the structure at which the data in that register
1984 corresponds.  The first element may be null to indicate that the structure
1985 is also passed partly in memory.
1987 @cindex jump instructions and @code{set}
1988 @cindex @code{if_then_else} usage
1989 If @var{lval} is @code{(pc)}, we have a jump instruction, and the
1990 possibilities for @var{x} are very limited.  It may be a
1991 @code{label_ref} expression (unconditional jump).  It may be an
1992 @code{if_then_else} (conditional jump), in which case either the
1993 second or the third operand must be @code{(pc)} (for the case which
1994 does not jump) and the other of the two must be a @code{label_ref}
1995 (for the case which does jump).  @var{x} may also be a @code{mem} or
1996 @code{(plus:SI (pc) @var{y})}, where @var{y} may be a @code{reg} or a
1997 @code{mem}; these unusual patterns are used to represent jumps through
1998 branch tables.@refill
2000 If @var{lval} is neither @code{(cc0)} nor @code{(pc)}, the mode of
2001 @var{lval} must not be @code{VOIDmode} and the mode of @var{x} must be
2002 valid for the mode of @var{lval}.
2004 @findex SET_DEST
2005 @findex SET_SRC
2006 @var{lval} is customarily accessed with the @code{SET_DEST} macro and 
2007 @var{x} with the @code{SET_SRC} macro.
2009 @findex return
2010 @item (return)
2011 As the sole expression in a pattern, represents a return from the
2012 current function, on machines where this can be done with one
2013 instruction, such as Vaxes.  On machines where a multi-instruction
2014 ``epilogue'' must be executed in order to return from the function,
2015 returning is done by jumping to a label which precedes the epilogue, and
2016 the @code{return} expression code is never used.
2018 Inside an @code{if_then_else} expression, represents the value to be
2019 placed in @code{pc} to return to the caller.
2021 Note that an insn pattern of @code{(return)} is logically equivalent to
2022 @code{(set (pc) (return))}, but the latter form is never used.
2024 @findex call
2025 @item (call @var{function} @var{nargs})
2026 Represents a function call.  @var{function} is a @code{mem} expression
2027 whose address is the address of the function to be called.
2028 @var{nargs} is an expression which can be used for two purposes: on
2029 some machines it represents the number of bytes of stack argument; on
2030 others, it represents the number of argument registers.
2032 Each machine has a standard machine mode which @var{function} must
2033 have.  The machine description defines macro @code{FUNCTION_MODE} to
2034 expand into the requisite mode name.  The purpose of this mode is to
2035 specify what kind of addressing is allowed, on machines where the
2036 allowed kinds of addressing depend on the machine mode being
2037 addressed.
2039 @findex clobber
2040 @item (clobber @var{x})
2041 Represents the storing or possible storing of an unpredictable,
2042 undescribed value into @var{x}, which must be a @code{reg},
2043 @code{scratch}, @code{parallel} or @code{mem} expression.
2045 One place this is used is in string instructions that store standard
2046 values into particular hard registers.  It may not be worth the
2047 trouble to describe the values that are stored, but it is essential to
2048 inform the compiler that the registers will be altered, lest it
2049 attempt to keep data in them across the string instruction.
2051 If @var{x} is @code{(mem:BLK (const_int 0))}, it means that all memory
2052 locations must be presumed clobbered.  If @var{x} is a @code{parallel},
2053 it has the same meaning as a @code{parallel} in a @code{set} expression.
2055 Note that the machine description classifies certain hard registers as
2056 ``call-clobbered''.  All function call instructions are assumed by
2057 default to clobber these registers, so there is no need to use
2058 @code{clobber} expressions to indicate this fact.  Also, each function
2059 call is assumed to have the potential to alter any memory location,
2060 unless the function is declared @code{const}.
2062 If the last group of expressions in a @code{parallel} are each a
2063 @code{clobber} expression whose arguments are @code{reg} or
2064 @code{match_scratch} (@pxref{RTL Template}) expressions, the combiner
2065 phase can add the appropriate @code{clobber} expressions to an insn it
2066 has constructed when doing so will cause a pattern to be matched.
2068 This feature can be used, for example, on a machine that whose multiply
2069 and add instructions don't use an MQ register but which has an
2070 add-accumulate instruction that does clobber the MQ register.  Similarly,
2071 a combined instruction might require a temporary register while the
2072 constituent instructions might not.
2074 When a @code{clobber} expression for a register appears inside a
2075 @code{parallel} with other side effects, the register allocator
2076 guarantees that the register is unoccupied both before and after that
2077 insn.  However, the reload phase may allocate a register used for one of
2078 the inputs unless the @samp{&} constraint is specified for the selected
2079 alternative (@pxref{Modifiers}).  You can clobber either a specific hard
2080 register, a pseudo register, or a @code{scratch} expression; in the
2081 latter two cases, GNU CC will allocate a hard register that is available
2082 there for use as a temporary.
2084 For instructions that require a temporary register, you should use
2085 @code{scratch} instead of a pseudo-register because this will allow the
2086 combiner phase to add the @code{clobber} when required.  You do this by
2087 coding (@code{clobber} (@code{match_scratch} @dots{})).  If you do
2088 clobber a pseudo register, use one which appears nowhere else---generate
2089 a new one each time.  Otherwise, you may confuse CSE.
2091 There is one other known use for clobbering a pseudo register in a
2092 @code{parallel}: when one of the input operands of the insn is also
2093 clobbered by the insn.  In this case, using the same pseudo register in
2094 the clobber and elsewhere in the insn produces the expected results.
2096 @findex use
2097 @item (use @var{x})
2098 Represents the use of the value of @var{x}.  It indicates that the
2099 value in @var{x} at this point in the program is needed, even though
2100 it may not be apparent why this is so.  Therefore, the compiler will
2101 not attempt to delete previous instructions whose only effect is to
2102 store a value in @var{x}.  @var{x} must be a @code{reg} expression.
2104 In some situations, it may be tempting to add a @code{use} of a
2105 register in a @code{parallel} to describe a situation where the value
2106 of a special register will modify the behaviour of the instruction.
2107 An hypothetical example might be a pattern for an addition that can
2108 either wrap around or use saturating addition depending on the value
2109 of a special control register:
2111 @example
2112 (parallel [(set (reg:SI 2) (unspec:SI [(reg:SI 3) (reg:SI 4)] 0))
2113            (use (reg:SI 1))])
2114 @end example
2116 @noindent
2118 This will not work, several of the optimizers only look at expressions
2119 locally; it is very likely that if you have multiple insns with
2120 identical inputs to the @code{unspec}, they will be optimized away even
2121 if register 1 changes in between.
2123 This means that @code{use} can @emph{only} be used to describe
2124 that the register is live.  You should think twice before adding
2125 @code{use} statements, more often you will want to use @code{unspec}
2126 instead.  The @code{use} RTX is most commonly useful to describe that
2127 a fixed register is implicitly used in an insn.  It is also safe to use
2128 in patterns where the compiler knows for other reasons that the result
2129 of the whole pattern is variable, such as @samp{movstr@var{m}} or
2130 @samp{call} patterns.
2132 During the reload phase, an insn that has a @code{use} as pattern
2133 can carry a reg_equal note.  These @code{use} insns will be deleted
2134 before the reload phase exits.
2136 During the delayed branch scheduling phase, @var{x} may be an insn.
2137 This indicates that @var{x} previously was located at this place in the
2138 code and its data dependencies need to be taken into account.  These
2139 @code{use} insns will be deleted before the delayed branch scheduling
2140 phase exits.
2142 @findex parallel
2143 @item (parallel [@var{x0} @var{x1} @dots{}])
2144 Represents several side effects performed in parallel.  The square
2145 brackets stand for a vector; the operand of @code{parallel} is a
2146 vector of expressions.  @var{x0}, @var{x1} and so on are individual
2147 side effect expressions---expressions of code @code{set}, @code{call},
2148 @code{return}, @code{clobber} or @code{use}.@refill
2150 ``In parallel'' means that first all the values used in the individual
2151 side-effects are computed, and second all the actual side-effects are
2152 performed.  For example,
2154 @example
2155 (parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
2156            (set (mem:SI (reg:SI 1)) (reg:SI 1))])
2157 @end example
2159 @noindent
2160 says unambiguously that the values of hard register 1 and the memory
2161 location addressed by it are interchanged.  In both places where
2162 @code{(reg:SI 1)} appears as a memory address it refers to the value
2163 in register 1 @emph{before} the execution of the insn.
2165 It follows that it is @emph{incorrect} to use @code{parallel} and
2166 expect the result of one @code{set} to be available for the next one.
2167 For example, people sometimes attempt to represent a jump-if-zero
2168 instruction this way:
2170 @example
2171 (parallel [(set (cc0) (reg:SI 34))
2172            (set (pc) (if_then_else
2173                         (eq (cc0) (const_int 0))
2174                         (label_ref @dots{})
2175                         (pc)))])
2176 @end example
2178 @noindent
2179 But this is incorrect, because it says that the jump condition depends
2180 on the condition code value @emph{before} this instruction, not on the
2181 new value that is set by this instruction.
2183 @cindex peephole optimization, RTL representation
2184 Peephole optimization, which takes place together with final assembly
2185 code output, can produce insns whose patterns consist of a @code{parallel}
2186 whose elements are the operands needed to output the resulting
2187 assembler code---often @code{reg}, @code{mem} or constant expressions.
2188 This would not be well-formed RTL at any other stage in compilation,
2189 but it is ok then because no further optimization remains to be done.
2190 However, the definition of the macro @code{NOTICE_UPDATE_CC}, if
2191 any, must deal with such insns if you define any peephole optimizations.
2193 @findex sequence
2194 @item (sequence [@var{insns} @dots{}])
2195 Represents a sequence of insns.  Each of the @var{insns} that appears
2196 in the vector is suitable for appearing in the chain of insns, so it
2197 must be an @code{insn}, @code{jump_insn}, @code{call_insn},
2198 @code{code_label}, @code{barrier} or @code{note}.
2200 A @code{sequence} RTX is never placed in an actual insn during RTL
2201 generation.  It represents the sequence of insns that result from a
2202 @code{define_expand} @emph{before} those insns are passed to
2203 @code{emit_insn} to insert them in the chain of insns.  When actually
2204 inserted, the individual sub-insns are separated out and the
2205 @code{sequence} is forgotten.
2207 After delay-slot scheduling is completed, an insn and all the insns that
2208 reside in its delay slots are grouped together into a @code{sequence}.
2209 The insn requiring the delay slot is the first insn in the vector;
2210 subsequent insns are to be placed in the delay slot.
2212 @code{INSN_ANNULLED_BRANCH_P} is set on an insn in a delay slot to
2213 indicate that a branch insn should be used that will conditionally annul
2214 the effect of the insns in the delay slots.  In such a case,
2215 @code{INSN_FROM_TARGET_P} indicates that the insn is from the target of
2216 the branch and should be executed only if the branch is taken; otherwise
2217 the insn should be executed only if the branch is not taken.
2218 @xref{Delay Slots}.
2219 @end table
2221 These expression codes appear in place of a side effect, as the body of
2222 an insn, though strictly speaking they do not always describe side
2223 effects as such:
2225 @table @code
2226 @findex asm_input
2227 @item (asm_input @var{s})
2228 Represents literal assembler code as described by the string @var{s}.
2230 @findex unspec
2231 @findex unspec_volatile
2232 @item (unspec [@var{operands} @dots{}] @var{index})
2233 @itemx (unspec_volatile [@var{operands} @dots{}] @var{index})
2234 Represents a machine-specific operation on @var{operands}.  @var{index}
2235 selects between multiple machine-specific operations.
2236 @code{unspec_volatile} is used for volatile operations and operations
2237 that may trap; @code{unspec} is used for other operations.
2239 These codes may appear inside a @code{pattern} of an
2240 insn, inside a @code{parallel}, or inside an expression.
2242 @findex addr_vec
2243 @item (addr_vec:@var{m} [@var{lr0} @var{lr1} @dots{}])
2244 Represents a table of jump addresses.  The vector elements @var{lr0},
2245 etc., are @code{label_ref} expressions.  The mode @var{m} specifies
2246 how much space is given to each address; normally @var{m} would be
2247 @code{Pmode}.
2249 @findex addr_diff_vec
2250 @item (addr_diff_vec:@var{m} @var{base} [@var{lr0} @var{lr1} @dots{}] @var{min} @var{max} @var{flags})
2251 Represents a table of jump addresses expressed as offsets from
2252 @var{base}.  The vector elements @var{lr0}, etc., are @code{label_ref}
2253 expressions and so is @var{base}.  The mode @var{m} specifies how much
2254 space is given to each address-difference.  @var{min} and @var{max}
2255 are set up by branch shortening and hold a label with a minimum and a
2256 maximum address, respectively.  @var{flags} indicates the relative
2257 position of @var{base}, @var{min} and @var{max} to the containing insn
2258 and of @var{min} and @var{max} to @var{base}.  See rtl.def for details.@refill
2259 @end table
2261 @node Incdec
2262 @section Embedded Side-Effects on Addresses
2263 @cindex RTL preincrement
2264 @cindex RTL postincrement
2265 @cindex RTL predecrement
2266 @cindex RTL postdecrement
2268 Six special side-effect expression codes appear as memory addresses.
2270 @table @code
2271 @findex pre_dec
2272 @item (pre_dec:@var{m} @var{x})
2273 Represents the side effect of decrementing @var{x} by a standard
2274 amount and represents also the value that @var{x} has after being
2275 decremented.  @var{x} must be a @code{reg} or @code{mem}, but most
2276 machines allow only a @code{reg}.  @var{m} must be the machine mode
2277 for pointers on the machine in use.  The amount @var{x} is decremented
2278 by is the length in bytes of the machine mode of the containing memory
2279 reference of which this expression serves as the address.  Here is an
2280 example of its use:@refill
2282 @example
2283 (mem:DF (pre_dec:SI (reg:SI 39)))
2284 @end example
2286 @noindent
2287 This says to decrement pseudo register 39 by the length of a @code{DFmode}
2288 value and use the result to address a @code{DFmode} value.
2290 @findex pre_inc
2291 @item (pre_inc:@var{m} @var{x})
2292 Similar, but specifies incrementing @var{x} instead of decrementing it.
2294 @findex post_dec
2295 @item (post_dec:@var{m} @var{x})
2296 Represents the same side effect as @code{pre_dec} but a different
2297 value.  The value represented here is the value @var{x} has @i{before}
2298 being decremented.
2300 @findex post_inc
2301 @item (post_inc:@var{m} @var{x})
2302 Similar, but specifies incrementing @var{x} instead of decrementing it.
2304 @findex post_modify
2305 @item (post_modify:@var{m} @var{x} @var{y})
2307 Represents the side effect of setting @var{x} to @var{y} and
2308 represents @var{x} before @var{x} is modified.  @var{x} must be a
2309 @code{reg} or @code{mem}, but most machines allow only a @code{reg}.
2310 @var{m} must be the machine mode for pointers on the machine in use.
2311 The amount @var{x} is decremented by is the length in bytes of the
2312 machine mode of the containing memory reference of which this expression
2313 serves as the address.  Note that this is not currently implemented.
2315 The expression @var{y} must be one of three forms:
2316 @table @code
2317 @code{(plus:@var{m} @var{x} @var{z})},
2318 @code{(minus:@var{m} @var{x} @var{z})}, or
2319 @code{(plus:@var{m} @var{x} @var{i})},
2320 @end table
2321 where @var{z} is an index register and @var{i} is a constant.
2323 Here is an example of its use:@refill
2325 @example
2326 (mem:SF (post_modify:SI (reg:SI 42) (plus (reg:SI 42) (reg:SI 48))))
2327 @end example
2329 This says to modify pseudo register 42 by adding the contents of pseudo
2330 register 48 to it, after the use of what ever 42 points to.
2332 @findex post_modify
2333 @item (pre_modify:@var{m} @var{x} @var{expr})
2334 Similar except side effects happen before the use.
2335 @end table
2337 These embedded side effect expressions must be used with care.  Instruction
2338 patterns may not use them.  Until the @samp{flow} pass of the compiler,
2339 they may occur only to represent pushes onto the stack.  The @samp{flow}
2340 pass finds cases where registers are incremented or decremented in one
2341 instruction and used as an address shortly before or after; these cases are
2342 then transformed to use pre- or post-increment or -decrement.
2344 If a register used as the operand of these expressions is used in
2345 another address in an insn, the original value of the register is used.
2346 Uses of the register outside of an address are not permitted within the
2347 same insn as a use in an embedded side effect expression because such
2348 insns behave differently on different machines and hence must be treated
2349 as ambiguous and disallowed.
2351 An instruction that can be represented with an embedded side effect
2352 could also be represented using @code{parallel} containing an additional
2353 @code{set} to describe how the address register is altered.  This is not
2354 done because machines that allow these operations at all typically
2355 allow them wherever a memory address is called for.  Describing them as
2356 additional parallel stores would require doubling the number of entries
2357 in the machine description.
2359 @node Assembler
2360 @section Assembler Instructions as Expressions
2361 @cindex assembler instructions in RTL
2363 @cindex @code{asm_operands}, usage
2364 The RTX code @code{asm_operands} represents a value produced by a
2365 user-specified assembler instruction.  It is used to represent
2366 an @code{asm} statement with arguments.  An @code{asm} statement with
2367 a single output operand, like this:
2369 @smallexample
2370 asm ("foo %1,%2,%0" : "=a" (outputvar) : "g" (x + y), "di" (*z));
2371 @end smallexample
2373 @noindent
2374 is represented using a single @code{asm_operands} RTX which represents
2375 the value that is stored in @code{outputvar}:
2377 @smallexample
2378 (set @var{rtx-for-outputvar}
2379      (asm_operands "foo %1,%2,%0" "a" 0
2380                    [@var{rtx-for-addition-result} @var{rtx-for-*z}]
2381                    [(asm_input:@var{m1} "g")
2382                     (asm_input:@var{m2} "di")]))
2383 @end smallexample
2385 @noindent
2386 Here the operands of the @code{asm_operands} RTX are the assembler
2387 template string, the output-operand's constraint, the index-number of the
2388 output operand among the output operands specified, a vector of input
2389 operand RTX's, and a vector of input-operand modes and constraints.  The
2390 mode @var{m1} is the mode of the sum @code{x+y}; @var{m2} is that of
2391 @code{*z}.
2393 When an @code{asm} statement has multiple output values, its insn has
2394 several such @code{set} RTX's inside of a @code{parallel}.  Each @code{set}
2395 contains a @code{asm_operands}; all of these share the same assembler
2396 template and vectors, but each contains the constraint for the respective
2397 output operand.  They are also distinguished by the output-operand index
2398 number, which is 0, 1, @dots{} for successive output operands.
2400 @node Insns
2401 @section Insns
2402 @cindex insns
2404 The RTL representation of the code for a function is a doubly-linked
2405 chain of objects called @dfn{insns}.  Insns are expressions with
2406 special codes that are used for no other purpose.  Some insns are
2407 actual instructions; others represent dispatch tables for @code{switch}
2408 statements; others represent labels to jump to or various sorts of
2409 declarative information.
2411 In addition to its own specific data, each insn must have a unique
2412 id-number that distinguishes it from all other insns in the current
2413 function (after delayed branch scheduling, copies of an insn with the
2414 same id-number may be present in multiple places in a function, but
2415 these copies will always be identical and will only appear inside a
2416 @code{sequence}), and chain pointers to the preceding and following
2417 insns.  These three fields occupy the same position in every insn,
2418 independent of the expression code of the insn.  They could be accessed
2419 with @code{XEXP} and @code{XINT}, but instead three special macros are
2420 always used:
2422 @table @code
2423 @findex INSN_UID
2424 @item INSN_UID (@var{i})
2425 Accesses the unique id of insn @var{i}.
2427 @findex PREV_INSN
2428 @item PREV_INSN (@var{i})
2429 Accesses the chain pointer to the insn preceding @var{i}.
2430 If @var{i} is the first insn, this is a null pointer.
2432 @findex NEXT_INSN
2433 @item NEXT_INSN (@var{i})
2434 Accesses the chain pointer to the insn following @var{i}.
2435 If @var{i} is the last insn, this is a null pointer.
2436 @end table
2438 @findex get_insns
2439 @findex get_last_insn
2440 The first insn in the chain is obtained by calling @code{get_insns}; the
2441 last insn is the result of calling @code{get_last_insn}.  Within the
2442 chain delimited by these insns, the @code{NEXT_INSN} and
2443 @code{PREV_INSN} pointers must always correspond: if @var{insn} is not
2444 the first insn,
2446 @example
2447 NEXT_INSN (PREV_INSN (@var{insn})) == @var{insn}
2448 @end example
2450 @noindent
2451 is always true and if @var{insn} is not the last insn,
2453 @example
2454 PREV_INSN (NEXT_INSN (@var{insn})) == @var{insn}
2455 @end example
2457 @noindent
2458 is always true.
2460 After delay slot scheduling, some of the insns in the chain might be
2461 @code{sequence} expressions, which contain a vector of insns.  The value
2462 of @code{NEXT_INSN} in all but the last of these insns is the next insn
2463 in the vector; the value of @code{NEXT_INSN} of the last insn in the vector
2464 is the same as the value of @code{NEXT_INSN} for the @code{sequence} in
2465 which it is contained.  Similar rules apply for @code{PREV_INSN}.
2467 This means that the above invariants are not necessarily true for insns
2468 inside @code{sequence} expressions.  Specifically, if @var{insn} is the
2469 first insn in a @code{sequence}, @code{NEXT_INSN (PREV_INSN (@var{insn}))}
2470 is the insn containing the @code{sequence} expression, as is the value
2471 of @code{PREV_INSN (NEXT_INSN (@var{insn}))} is @var{insn} is the last
2472 insn in the @code{sequence} expression.  You can use these expressions
2473 to find the containing @code{sequence} expression.@refill
2475 Every insn has one of the following six expression codes:
2477 @table @code
2478 @findex insn
2479 @item insn
2480 The expression code @code{insn} is used for instructions that do not jump
2481 and do not do function calls.  @code{sequence} expressions are always
2482 contained in insns with code @code{insn} even if one of those insns
2483 should jump or do function calls.
2485 Insns with code @code{insn} have four additional fields beyond the three
2486 mandatory ones listed above.  These four are described in a table below.
2488 @findex jump_insn
2489 @item jump_insn
2490 The expression code @code{jump_insn} is used for instructions that may
2491 jump (or, more generally, may contain @code{label_ref} expressions).  If
2492 there is an instruction to return from the current function, it is
2493 recorded as a @code{jump_insn}.
2495 @findex JUMP_LABEL
2496 @code{jump_insn} insns have the same extra fields as @code{insn} insns,
2497 accessed in the same way and in addition contain a field
2498 @code{JUMP_LABEL} which is defined once jump optimization has completed.
2500 For simple conditional and unconditional jumps, this field contains
2501 the @code{code_label} to which this insn will (possibly conditionally)
2502 branch.  In a more complex jump, @code{JUMP_LABEL} records one of the
2503 labels that the insn refers to; the only way to find the others is to
2504 scan the entire body of the insn.  In an @code{addr_vec},
2505 @code{JUMP_LABEL} is @code{NULL_RTX}.
2507 Return insns count as jumps, but since they do not refer to any
2508 labels, their @code{JUMP_LABEL} is @code{NULL_RTX}.
2510 @findex call_insn
2511 @item call_insn
2512 The expression code @code{call_insn} is used for instructions that may do
2513 function calls.  It is important to distinguish these instructions because
2514 they imply that certain registers and memory locations may be altered
2515 unpredictably.
2517 @findex CALL_INSN_FUNCTION_USAGE
2518 @code{call_insn} insns have the same extra fields as @code{insn} insns,
2519 accessed in the same way and in addition contain a field
2520 @code{CALL_INSN_FUNCTION_USAGE}, which contains a list (chain of
2521 @code{expr_list} expressions) containing @code{use} and @code{clobber}
2522 expressions that denote hard registers and @code{MEM}s used or
2523 clobbered by the called function.
2525 A @code{MEM} generally points to a stack slots in which arguments passed
2526 to the libcall by reference (@pxref{Register Arguments,
2527 FUNCTION_ARG_PASS_BY_REFERENCE}) are stored.  If the argument is
2528 caller-copied (@pxref{Register Arguments, FUNCTION_ARG_CALLEE_COPIES}),
2529 the stack slot will be mentioned in @code{CLOBBER} and @code{USE}
2530 entries; if it's callee-copied, only a @code{USE} will appear, and the
2531 @code{MEM} may point to addresses that are not stack slots.  These
2532 @code{MEM}s are used only in libcalls, because, unlike regular function
2533 calls, @code{CONST_CALL}s (which libcalls generally are, @pxref{Flags,
2534 CONST_CALL_P}) aren't assumed to read and write all memory, so flow
2535 would consider the stores dead and remove them.  Note that, since a
2536 libcall must never return values in memory (@pxref{Aggregate Return,
2537 RETURN_IN_MEMORY}), there will never be a @code{CLOBBER} for a memory
2538 address holding a return value.
2540 @code{CLOBBER}ed registers in this list augment registers specified in
2541 @code{CALL_USED_REGISTERS} (@pxref{Register Basics}).
2543 @findex code_label
2544 @findex CODE_LABEL_NUMBER
2545 @item code_label
2546 A @code{code_label} insn represents a label that a jump insn can jump
2547 to.  It contains two special fields of data in addition to the three
2548 standard ones.  @code{CODE_LABEL_NUMBER} is used to hold the @dfn{label
2549 number}, a number that identifies this label uniquely among all the
2550 labels in the compilation (not just in the current function).
2551 Ultimately, the label is represented in the assembler output as an
2552 assembler label, usually of the form @samp{L@var{n}} where @var{n} is
2553 the label number.
2555 When a @code{code_label} appears in an RTL expression, it normally
2556 appears within a @code{label_ref} which represents the address of
2557 the label, as a number.
2559 @findex LABEL_NUSES
2560 The field @code{LABEL_NUSES} is only defined once the jump optimization
2561 phase is completed and contains the number of times this label is
2562 referenced in the current function.
2564 @findex LABEL_ALTERNATE_NAME
2565 The field @code{LABEL_ALTERNATE_NAME} is used to associate a name with
2566 a @code{code_label}.  If this field is defined, the alternate name will
2567 be emitted instead of an internally generated label name.
2569 @findex barrier
2570 @item barrier
2571 Barriers are placed in the instruction stream when control cannot flow
2572 past them.  They are placed after unconditional jump instructions to
2573 indicate that the jumps are unconditional and after calls to
2574 @code{volatile} functions, which do not return (e.g., @code{exit}).
2575 They contain no information beyond the three standard fields.
2577 @findex note
2578 @findex NOTE_LINE_NUMBER
2579 @findex NOTE_SOURCE_FILE
2580 @item note
2581 @code{note} insns are used to represent additional debugging and
2582 declarative information.  They contain two nonstandard fields, an
2583 integer which is accessed with the macro @code{NOTE_LINE_NUMBER} and a
2584 string accessed with @code{NOTE_SOURCE_FILE}.
2586 If @code{NOTE_LINE_NUMBER} is positive, the note represents the
2587 position of a source line and @code{NOTE_SOURCE_FILE} is the source file name
2588 that the line came from.  These notes control generation of line
2589 number data in the assembler output.
2591 Otherwise, @code{NOTE_LINE_NUMBER} is not really a line number but a
2592 code with one of the following values (and @code{NOTE_SOURCE_FILE}
2593 must contain a null pointer):
2595 @table @code
2596 @findex NOTE_INSN_DELETED
2597 @item NOTE_INSN_DELETED
2598 Such a note is completely ignorable.  Some passes of the compiler
2599 delete insns by altering them into notes of this kind.
2601 @findex NOTE_INSN_BLOCK_BEG
2602 @findex NOTE_INSN_BLOCK_END
2603 @item NOTE_INSN_BLOCK_BEG
2604 @itemx NOTE_INSN_BLOCK_END
2605 These types of notes indicate the position of the beginning and end
2606 of a level of scoping of variable names.  They control the output
2607 of debugging information.
2609 @findex NOTE_INSN_EH_REGION_BEG
2610 @findex NOTE_INSN_EH_REGION_END
2611 @item NOTE_INSN_EH_REGION_BEG
2612 @itemx NOTE_INSN_EH_REGION_END
2613 These types of notes indicate the position of the beginning and end of a
2614 level of scoping for exception handling.  @code{NOTE_BLOCK_NUMBER}
2615 identifies which @code{CODE_LABEL} is associated with the given region.
2617 @findex NOTE_INSN_LOOP_BEG
2618 @findex NOTE_INSN_LOOP_END
2619 @item NOTE_INSN_LOOP_BEG
2620 @itemx NOTE_INSN_LOOP_END
2621 These types of notes indicate the position of the beginning and end
2622 of a @code{while} or @code{for} loop.  They enable the loop optimizer
2623 to find loops quickly.
2625 @findex NOTE_INSN_LOOP_CONT
2626 @item NOTE_INSN_LOOP_CONT
2627 Appears at the place in a loop that @code{continue} statements jump to.
2629 @findex NOTE_INSN_LOOP_VTOP
2630 @item NOTE_INSN_LOOP_VTOP
2631 This note indicates the place in a loop where the exit test begins for
2632 those loops in which the exit test has been duplicated.  This position
2633 becomes another virtual start of the loop when considering loop
2634 invariants. 
2636 @findex NOTE_INSN_FUNCTION_END
2637 @item NOTE_INSN_FUNCTION_END
2638 Appears near the end of the function body, just before the label that
2639 @code{return} statements jump to (on machine where a single instruction
2640 does not suffice for returning).  This note may be deleted by jump
2641 optimization.
2643 @findex NOTE_INSN_SETJMP
2644 @item NOTE_INSN_SETJMP
2645 Appears following each call to @code{setjmp} or a related function.
2646 @end table
2648 These codes are printed symbolically when they appear in debugging dumps.
2649 @end table
2651 @cindex @code{TImode}, in @code{insn}
2652 @cindex @code{HImode}, in @code{insn}
2653 @cindex @code{QImode}, in @code{insn}
2654 The machine mode of an insn is normally @code{VOIDmode}, but some
2655 phases use the mode for various purposes. 
2657 The common subexpression elimination pass sets the mode of an insn to
2658 @code{QImode} when it is the first insn in a block that has already
2659 been processed.
2661 The second Haifa scheduling pass, for targets that can multiple issue,
2662 sets the mode of an insn to @code{TImode} when it is believed that the
2663 instruction begins an issue group.  That is, when the instruction 
2664 cannot issue simultaneously with the previous.  This may be relied on
2665 by later passes, in particular machine-dependant reorg.
2667 Here is a table of the extra fields of @code{insn}, @code{jump_insn}
2668 and @code{call_insn} insns:
2670 @table @code
2671 @findex PATTERN
2672 @item PATTERN (@var{i})
2673 An expression for the side effect performed by this insn.  This must be
2674 one of the following codes: @code{set}, @code{call}, @code{use},
2675 @code{clobber}, @code{return}, @code{asm_input}, @code{asm_output},
2676 @code{addr_vec}, @code{addr_diff_vec}, @code{trap_if}, @code{unspec},
2677 @code{unspec_volatile}, @code{parallel}, or @code{sequence}.  If it is a @code{parallel},
2678 each element of the @code{parallel} must be one these codes, except that
2679 @code{parallel} expressions cannot be nested and @code{addr_vec} and
2680 @code{addr_diff_vec} are not permitted inside a @code{parallel} expression.
2682 @findex INSN_CODE
2683 @item INSN_CODE (@var{i})
2684 An integer that says which pattern in the machine description matches
2685 this insn, or -1 if the matching has not yet been attempted.
2687 Such matching is never attempted and this field remains -1 on an insn
2688 whose pattern consists of a single @code{use}, @code{clobber},
2689 @code{asm_input}, @code{addr_vec} or @code{addr_diff_vec} expression.
2691 @findex asm_noperands
2692 Matching is also never attempted on insns that result from an @code{asm}
2693 statement.  These contain at least one @code{asm_operands} expression.
2694 The function @code{asm_noperands} returns a non-negative value for
2695 such insns.
2697 In the debugging output, this field is printed as a number followed by
2698 a symbolic representation that locates the pattern in the @file{md}
2699 file as some small positive or negative offset from a named pattern.
2701 @findex LOG_LINKS
2702 @item LOG_LINKS (@var{i})
2703 A list (chain of @code{insn_list} expressions) giving information about
2704 dependencies between instructions within a basic block.  Neither a jump
2705 nor a label may come between the related insns.
2707 @findex REG_NOTES
2708 @item REG_NOTES (@var{i})
2709 A list (chain of @code{expr_list} and @code{insn_list} expressions)
2710 giving miscellaneous information about the insn.  It is often
2711 information pertaining to the registers used in this insn.
2712 @end table
2714 The @code{LOG_LINKS} field of an insn is a chain of @code{insn_list}
2715 expressions.  Each of these has two operands: the first is an insn,
2716 and the second is another @code{insn_list} expression (the next one in
2717 the chain).  The last @code{insn_list} in the chain has a null pointer
2718 as second operand.  The significant thing about the chain is which
2719 insns appear in it (as first operands of @code{insn_list}
2720 expressions).  Their order is not significant.
2722 This list is originally set up by the flow analysis pass; it is a null
2723 pointer until then.  Flow only adds links for those data dependencies
2724 which can be used for instruction combination.  For each insn, the flow
2725 analysis pass adds a link to insns which store into registers values
2726 that are used for the first time in this insn.  The instruction
2727 scheduling pass adds extra links so that every dependence will be
2728 represented.  Links represent data dependencies, antidependencies and
2729 output dependencies; the machine mode of the link distinguishes these
2730 three types: antidependencies have mode @code{REG_DEP_ANTI}, output
2731 dependencies have mode @code{REG_DEP_OUTPUT}, and data dependencies have
2732 mode @code{VOIDmode}.
2734 The @code{REG_NOTES} field of an insn is a chain similar to the
2735 @code{LOG_LINKS} field but it includes @code{expr_list} expressions in
2736 addition to @code{insn_list} expressions.  There are several kinds of
2737 register notes, which are distinguished by the machine mode, which in a
2738 register note is really understood as being an @code{enum reg_note}.
2739 The first operand @var{op} of the note is data whose meaning depends on
2740 the kind of note.
2742 @findex REG_NOTE_KIND
2743 @findex PUT_REG_NOTE_KIND
2744 The macro @code{REG_NOTE_KIND (@var{x})} returns the kind of
2745 register note.  Its counterpart, the macro @code{PUT_REG_NOTE_KIND
2746 (@var{x}, @var{newkind})} sets the register note type of @var{x} to be
2747 @var{newkind}.
2749 Register notes are of three classes: They may say something about an
2750 input to an insn, they may say something about an output of an insn, or
2751 they may create a linkage between two insns.  There are also a set
2752 of values that are only used in @code{LOG_LINKS}.
2754 These register notes annotate inputs to an insn:
2756 @table @code
2757 @findex REG_DEAD 
2758 @item REG_DEAD
2759 The value in @var{op} dies in this insn; that is to say, altering the
2760 value immediately after this insn would not affect the future behavior
2761 of the program.  
2763 This does not necessarily mean that the register @var{op} has no useful
2764 value after this insn since it may also be an output of the insn.  In
2765 such a case, however, a @code{REG_DEAD} note would be redundant and is
2766 usually not present until after the reload pass, but no code relies on
2767 this fact.
2769 @findex REG_INC
2770 @item REG_INC
2771 The register @var{op} is incremented (or decremented; at this level
2772 there is no distinction) by an embedded side effect inside this insn.
2773 This means it appears in a @code{post_inc}, @code{pre_inc},
2774 @code{post_dec} or @code{pre_dec} expression.
2776 @findex REG_NONNEG
2777 @item REG_NONNEG
2778 The register @var{op} is known to have a nonnegative value when this
2779 insn is reached.  This is used so that decrement and branch until zero
2780 instructions, such as the m68k dbra, can be matched.
2782 The @code{REG_NONNEG} note is added to insns only if the machine
2783 description has a @samp{decrement_and_branch_until_zero} pattern.
2785 @findex REG_NO_CONFLICT
2786 @item REG_NO_CONFLICT
2787 This insn does not cause a conflict between @var{op} and the item
2788 being set by this insn even though it might appear that it does.
2789 In other words, if the destination register and @var{op} could
2790 otherwise be assigned the same register, this insn does not
2791 prevent that assignment.
2793 Insns with this note are usually part of a block that begins with a
2794 @code{clobber} insn specifying a multi-word pseudo register (which will
2795 be the output of the block), a group of insns that each set one word of
2796 the value and have the @code{REG_NO_CONFLICT} note attached, and a final
2797 insn that copies the output to itself with an attached @code{REG_EQUAL}
2798 note giving the expression being computed.  This block is encapsulated
2799 with @code{REG_LIBCALL} and @code{REG_RETVAL} notes on the first and
2800 last insns, respectively.
2802 @findex REG_LABEL
2803 @item REG_LABEL
2804 This insn uses @var{op}, a @code{code_label}, but is not a
2805 @code{jump_insn}, or it is a @code{jump_insn} that required the label to
2806 be held in a register.  The presence of this note allows jump
2807 optimization to be aware that @var{op} is, in fact, being used, and flow
2808 optimization to build an accurate flow graph.
2809 @end table
2811 The following notes describe attributes of outputs of an insn:
2813 @table @code
2814 @findex REG_EQUIV
2815 @findex REG_EQUAL
2816 @item REG_EQUIV
2817 @itemx REG_EQUAL
2818 This note is only valid on an insn that sets only one register and
2819 indicates that that register will be equal to @var{op} at run time; the
2820 scope of this equivalence differs between the two types of notes.  The
2821 value which the insn explicitly copies into the register may look
2822 different from @var{op}, but they will be equal at run time.  If the
2823 output of the single @code{set} is a @code{strict_low_part} expression,
2824 the note refers to the register that is contained in @code{SUBREG_REG}
2825 of the @code{subreg} expression.
2827 For @code{REG_EQUIV}, the register is equivalent to @var{op} throughout
2828 the entire function, and could validly be replaced in all its
2829 occurrences by @var{op}.  (``Validly'' here refers to the data flow of
2830 the program; simple replacement may make some insns invalid.)  For
2831 example, when a constant is loaded into a register that is never
2832 assigned any other value, this kind of note is used.
2834 When a parameter is copied into a pseudo-register at entry to a function,
2835 a note of this kind records that the register is equivalent to the stack
2836 slot where the parameter was passed.  Although in this case the register
2837 may be set by other insns, it is still valid to replace the register
2838 by the stack slot throughout the function.
2840 A @code{REG_EQUIV} note is also used on an instruction which copies a
2841 register parameter into a pseudo-register at entry to a function, if
2842 there is a stack slot where that parameter could be stored.  Although
2843 other insns may set the pseudo-register, it is valid for the compiler to
2844 replace the pseudo-register by stack slot throughout the function,
2845 provided the compiler ensures that the stack slot is properly
2846 initialized by making the replacement in the initial copy instruction as
2847 well.  This is used on machines for which the calling convention
2848 allocates stack space for register parameters.  See
2849 @code{REG_PARM_STACK_SPACE} in @ref{Stack Arguments}.
2851 In the case of @code{REG_EQUAL}, the register that is set by this insn
2852 will be equal to @var{op} at run time at the end of this insn but not
2853 necessarily elsewhere in the function.  In this case, @var{op}
2854 is typically an arithmetic expression.  For example, when a sequence of
2855 insns such as a library call is used to perform an arithmetic operation,
2856 this kind of note is attached to the insn that produces or copies the
2857 final value.
2859 These two notes are used in different ways by the compiler passes.
2860 @code{REG_EQUAL} is used by passes prior to register allocation (such as
2861 common subexpression elimination and loop optimization) to tell them how
2862 to think of that value.  @code{REG_EQUIV} notes are used by register
2863 allocation to indicate that there is an available substitute expression
2864 (either a constant or a @code{mem} expression for the location of a
2865 parameter on the stack) that may be used in place of a register if
2866 insufficient registers are available.
2868 Except for stack homes for parameters, which are indicated by a
2869 @code{REG_EQUIV} note and are not useful to the early optimization
2870 passes and pseudo registers that are equivalent to a memory location
2871 throughout there entire life, which is not detected until later in
2872 the compilation, all equivalences are initially indicated by an attached
2873 @code{REG_EQUAL} note.  In the early stages of register allocation, a
2874 @code{REG_EQUAL} note is changed into a @code{REG_EQUIV} note if
2875 @var{op} is a constant and the insn represents the only set of its
2876 destination register.
2878 Thus, compiler passes prior to register allocation need only check for
2879 @code{REG_EQUAL} notes and passes subsequent to register allocation
2880 need only check for @code{REG_EQUIV} notes.
2882 @findex REG_UNUSED
2883 @item REG_UNUSED
2884 The register @var{op} being set by this insn will not be used in a
2885 subsequent insn.  This differs from a @code{REG_DEAD} note, which
2886 indicates that the value in an input will not be used subsequently.
2887 These two notes are independent; both may be present for the same
2888 register.
2890 @findex REG_WAS_0
2891 @item REG_WAS_0
2892 The single output of this insn contained zero before this insn.
2893 @var{op} is the insn that set it to zero.  You can rely on this note if
2894 it is present and @var{op} has not been deleted or turned into a @code{note};
2895 its absence implies nothing.
2896 @end table
2898 These notes describe linkages between insns.  They occur in pairs: one
2899 insn has one of a pair of notes that points to a second insn, which has
2900 the inverse note pointing back to the first insn.
2902 @table @code
2903 @findex REG_RETVAL
2904 @item REG_RETVAL
2905 This insn copies the value of a multi-insn sequence (for example, a
2906 library call), and @var{op} is the first insn of the sequence (for a
2907 library call, the first insn that was generated to set up the arguments
2908 for the library call).
2910 Loop optimization uses this note to treat such a sequence as a single
2911 operation for code motion purposes and flow analysis uses this note to
2912 delete such sequences whose results are dead.
2914 A @code{REG_EQUAL} note will also usually be attached to this insn to 
2915 provide the expression being computed by the sequence.
2917 These notes will be deleted after reload, since they are no longer
2918 accurate or useful.
2920 @findex REG_LIBCALL
2921 @item REG_LIBCALL
2922 This is the inverse of @code{REG_RETVAL}: it is placed on the first
2923 insn of a multi-insn sequence, and it points to the last one.
2925 These notes are deleted after reload, since they are no longer useful or 
2926 accurate.
2928 @findex REG_CC_SETTER
2929 @findex REG_CC_USER
2930 @item REG_CC_SETTER
2931 @itemx REG_CC_USER
2932 On machines that use @code{cc0}, the insns which set and use @code{cc0}
2933 set and use @code{cc0} are adjacent.  However, when branch delay slot
2934 filling is done, this may no longer be true.  In this case a
2935 @code{REG_CC_USER} note will be placed on the insn setting @code{cc0} to
2936 point to the insn using @code{cc0} and a @code{REG_CC_SETTER} note will
2937 be placed on the insn using @code{cc0} to point to the insn setting
2938 @code{cc0}.@refill
2939 @end table
2941 These values are only used in the @code{LOG_LINKS} field, and indicate
2942 the type of dependency that each link represents.  Links which indicate
2943 a data dependence (a read after write dependence) do not use any code,
2944 they simply have mode @code{VOIDmode}, and are printed without any
2945 descriptive text.
2947 @table @code
2948 @findex REG_DEP_ANTI
2949 @item REG_DEP_ANTI
2950 This indicates an anti dependence (a write after read dependence).
2952 @findex REG_DEP_OUTPUT
2953 @item REG_DEP_OUTPUT
2954 This indicates an output dependence (a write after write dependence).
2955 @end table
2957 These notes describe information gathered from gcov profile data.  They
2958 are stored in the @code{REG_NOTES} field of an insn as an
2959 @code{expr_list}.
2961 @table @code
2962 @findex REG_EXEC_COUNT
2963 @item REG_EXEC_COUNT
2964 This is used to indicate the number of times a basic block was executed
2965 according to the profile data.  The note is attached to the first insn in
2966 the basic block.
2968 @findex REG_BR_PROB
2969 @item REG_BR_PROB
2970 This is used to specify the ratio of branches to non-branches of a
2971 branch insn according to the profile data.  The value is stored as a
2972 value between 0 and REG_BR_PROB_BASE; larger values indicate a higher
2973 probability that the branch will be taken.
2975 @findex REG_BR_PRED
2976 @item REG_BR_PRED
2977 These notes are found in JUMP insns after delayed branch scheduling
2978 has taken place.  They indicate both the direction and the likelihood
2979 of the JUMP.  The format is a bitmask of ATTR_FLAG_* values.
2981 @findex REG_FRAME_RELATED_EXPR
2982 @item REG_FRAME_RELATED_EXPR
2983 This is used on an RTX_FRAME_RELATED_P insn wherein the attached expression
2984 is used in place of the actual insn pattern.  This is done in cases where
2985 the pattern is either complex or misleading.
2986 @end table
2988 For convenience, the machine mode in an @code{insn_list} or
2989 @code{expr_list} is printed using these symbolic codes in debugging dumps.
2991 @findex insn_list
2992 @findex expr_list
2993 The only difference between the expression codes @code{insn_list} and
2994 @code{expr_list} is that the first operand of an @code{insn_list} is
2995 assumed to be an insn and is printed in debugging dumps as the insn's
2996 unique id; the first operand of an @code{expr_list} is printed in the
2997 ordinary way as an expression.
2999 @node Calls
3000 @section RTL Representation of Function-Call Insns
3001 @cindex calling functions in RTL
3002 @cindex RTL function-call insns
3003 @cindex function-call insns
3005 Insns that call subroutines have the RTL expression code @code{call_insn}.
3006 These insns must satisfy special rules, and their bodies must use a special
3007 RTL expression code, @code{call}.
3009 @cindex @code{call} usage
3010 A @code{call} expression has two operands, as follows:
3012 @example
3013 (call (mem:@var{fm} @var{addr}) @var{nbytes})
3014 @end example
3016 @noindent
3017 Here @var{nbytes} is an operand that represents the number of bytes of
3018 argument data being passed to the subroutine, @var{fm} is a machine mode
3019 (which must equal as the definition of the @code{FUNCTION_MODE} macro in
3020 the machine description) and @var{addr} represents the address of the
3021 subroutine.
3023 For a subroutine that returns no value, the @code{call} expression as
3024 shown above is the entire body of the insn, except that the insn might
3025 also contain @code{use} or @code{clobber} expressions.
3027 @cindex @code{BLKmode}, and function return values
3028 For a subroutine that returns a value whose mode is not @code{BLKmode},
3029 the value is returned in a hard register.  If this register's number is
3030 @var{r}, then the body of the call insn looks like this:
3032 @example
3033 (set (reg:@var{m} @var{r})
3034      (call (mem:@var{fm} @var{addr}) @var{nbytes}))
3035 @end example
3037 @noindent
3038 This RTL expression makes it clear (to the optimizer passes) that the
3039 appropriate register receives a useful value in this insn.
3041 When a subroutine returns a @code{BLKmode} value, it is handled by
3042 passing to the subroutine the address of a place to store the value.
3043 So the call insn itself does not ``return'' any value, and it has the
3044 same RTL form as a call that returns nothing.
3046 On some machines, the call instruction itself clobbers some register,
3047 for example to contain the return address.  @code{call_insn} insns
3048 on these machines should have a body which is a @code{parallel}
3049 that contains both the @code{call} expression and @code{clobber}
3050 expressions that indicate which registers are destroyed.  Similarly,
3051 if the call instruction requires some register other than the stack
3052 pointer that is not explicitly mentioned it its RTL, a @code{use}
3053 subexpression should mention that register.
3055 Functions that are called are assumed to modify all registers listed in
3056 the configuration macro @code{CALL_USED_REGISTERS} (@pxref{Register
3057 Basics}) and, with the exception of @code{const} functions and library
3058 calls, to modify all of memory.
3060 Insns containing just @code{use} expressions directly precede the
3061 @code{call_insn} insn to indicate which registers contain inputs to the
3062 function.  Similarly, if registers other than those in
3063 @code{CALL_USED_REGISTERS} are clobbered by the called function, insns
3064 containing a single @code{clobber} follow immediately after the call to
3065 indicate which registers.
3067 @node Sharing
3068 @section Structure Sharing Assumptions
3069 @cindex sharing of RTL components
3070 @cindex RTL structure sharing assumptions
3072 The compiler assumes that certain kinds of RTL expressions are unique;
3073 there do not exist two distinct objects representing the same value.
3074 In other cases, it makes an opposite assumption: that no RTL expression
3075 object of a certain kind appears in more than one place in the
3076 containing structure.
3078 These assumptions refer to a single function; except for the RTL
3079 objects that describe global variables and external functions,
3080 and a few standard objects such as small integer constants,
3081 no RTL objects are common to two functions.
3083 @itemize @bullet
3084 @cindex @code{reg}, RTL sharing
3085 @item
3086 Each pseudo-register has only a single @code{reg} object to represent it,
3087 and therefore only a single machine mode.
3089 @cindex symbolic label
3090 @cindex @code{symbol_ref}, RTL sharing
3091 @item
3092 For any symbolic label, there is only one @code{symbol_ref} object
3093 referring to it.
3095 @cindex @code{const_int}, RTL sharing
3096 @item
3097 All @code{const_int} expressions with equal values are shared.
3099 @cindex @code{pc}, RTL sharing
3100 @item
3101 There is only one @code{pc} expression.
3103 @cindex @code{cc0}, RTL sharing
3104 @item
3105 There is only one @code{cc0} expression.
3107 @cindex @code{const_double}, RTL sharing
3108 @item
3109 There is only one @code{const_double} expression with value 0 for
3110 each floating point mode.  Likewise for values 1 and 2.
3112 @cindex @code{label_ref}, RTL sharing
3113 @cindex @code{scratch}, RTL sharing
3114 @item
3115 No @code{label_ref} or @code{scratch} appears in more than one place in
3116 the RTL structure; in other words, it is safe to do a tree-walk of all
3117 the insns in the function and assume that each time a @code{label_ref}
3118 or @code{scratch} is seen it is distinct from all others that are seen.
3120 @cindex @code{mem}, RTL sharing
3121 @item
3122 Only one @code{mem} object is normally created for each static
3123 variable or stack slot, so these objects are frequently shared in all
3124 the places they appear.  However, separate but equal objects for these
3125 variables are occasionally made.
3127 @cindex @code{asm_operands}, RTL sharing
3128 @item
3129 When a single @code{asm} statement has multiple output operands, a
3130 distinct @code{asm_operands} expression is made for each output operand.
3131 However, these all share the vector which contains the sequence of input
3132 operands.  This sharing is used later on to test whether two
3133 @code{asm_operands} expressions come from the same statement, so all
3134 optimizations must carefully preserve the sharing if they copy the
3135 vector at all.
3137 @item
3138 No RTL object appears in more than one place in the RTL structure
3139 except as described above.  Many passes of the compiler rely on this
3140 by assuming that they can modify RTL objects in place without unwanted
3141 side-effects on other insns.
3143 @findex unshare_all_rtl
3144 @item
3145 During initial RTL generation, shared structure is freely introduced.
3146 After all the RTL for a function has been generated, all shared
3147 structure is copied by @code{unshare_all_rtl} in @file{emit-rtl.c},
3148 after which the above rules are guaranteed to be followed.
3150 @findex copy_rtx_if_shared
3151 @item
3152 During the combiner pass, shared structure within an insn can exist
3153 temporarily.  However, the shared structure is copied before the
3154 combiner is finished with the insn.  This is done by calling
3155 @code{copy_rtx_if_shared}, which is a subroutine of
3156 @code{unshare_all_rtl}.
3157 @end itemize
3159 @node Reading RTL
3160 @section Reading RTL
3162 To read an RTL object from a file, call @code{read_rtx}.  It takes one
3163 argument, a stdio stream, and returns a single RTL object.
3165 Reading RTL from a file is very slow.  This is not currently a
3166 problem since reading RTL occurs only as part of building the
3167 compiler.
3169 People frequently have the idea of using RTL stored as text in a file as
3170 an interface between a language front end and the bulk of GNU CC.  This
3171 idea is not feasible.
3173 GNU CC was designed to use RTL internally only.  Correct RTL for a given
3174 program is very dependent on the particular target machine.  And the RTL
3175 does not contain all the information about the program.
3177 The proper way to interface GNU CC to a new language front end is with
3178 the ``tree'' data structure.  There is no manual for this data
3179 structure, but it is described in the files @file{tree.h} and
3180 @file{tree.def}.