Merge trunk version 206243 into gupc branch.
[official-gcc.git] / gcc / doc / generic.texi
blobf2dd0ffae65deee306806035144fda67d75d8666
1 @c Copyright (C) 2004-2013 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
5 @c ---------------------------------------------------------------------
6 @c GENERIC
7 @c ---------------------------------------------------------------------
9 @node GENERIC
10 @chapter GENERIC
11 @cindex GENERIC
13 The purpose of GENERIC is simply to provide a
14 language-independent way of representing an entire function in
15 trees.  To this end, it was necessary to add a few new tree codes
16 to the back end, but most everything was already there.  If you
17 can express it with the codes in @code{gcc/tree.def}, it's
18 GENERIC@.
20 Early on, there was a great deal of debate about how to think
21 about statements in a tree IL@.  In GENERIC, a statement is
22 defined as any expression whose value, if any, is ignored.  A
23 statement will always have @code{TREE_SIDE_EFFECTS} set (or it
24 will be discarded), but a non-statement expression may also have
25 side effects.  A @code{CALL_EXPR}, for instance.
27 It would be possible for some local optimizations to work on the
28 GENERIC form of a function; indeed, the adapted tree inliner
29 works fine on GENERIC, but the current compiler performs inlining
30 after lowering to GIMPLE (a restricted form described in the next
31 section). Indeed, currently the frontends perform this lowering
32 before handing off to @code{tree_rest_of_compilation}, but this
33 seems inelegant.
35 @menu
36 * Deficiencies::                Topics net yet covered in this document.
37 * Tree overview::               All about @code{tree}s.
38 * Types::                       Fundamental and aggregate types.
39 * Declarations::                Type declarations and variables.
40 * Attributes::                  Declaration and type attributes.
41 * Expressions: Expression trees.            Operating on data.
42 * Statements::                  Control flow and related trees.
43 * Functions::                   Function bodies, linkage, and other aspects.
44 * Language-dependent trees::    Topics and trees specific to language front ends.
45 * C and C++ Trees::             Trees specific to C and C++.
46 * Java Trees::                  Trees specific to Java.
47 @end menu
49 @c ---------------------------------------------------------------------
50 @c Deficiencies
51 @c ---------------------------------------------------------------------
53 @node Deficiencies
54 @section Deficiencies
56 There are many places in which this document is incomplet and incorrekt.
57 It is, as of yet, only @emph{preliminary} documentation.
59 @c ---------------------------------------------------------------------
60 @c Overview
61 @c ---------------------------------------------------------------------
63 @node Tree overview
64 @section Overview
65 @cindex tree
66 @findex TREE_CODE
68 The central data structure used by the internal representation is the
69 @code{tree}.  These nodes, while all of the C type @code{tree}, are of
70 many varieties.  A @code{tree} is a pointer type, but the object to
71 which it points may be of a variety of types.  From this point forward,
72 we will refer to trees in ordinary type, rather than in @code{this
73 font}, except when talking about the actual C type @code{tree}.
75 You can tell what kind of node a particular tree is by using the
76 @code{TREE_CODE} macro.  Many, many macros take trees as input and
77 return trees as output.  However, most macros require a certain kind of
78 tree node as input.  In other words, there is a type-system for trees,
79 but it is not reflected in the C type-system.
81 For safety, it is useful to configure GCC with @option{--enable-checking}.
82 Although this results in a significant performance penalty (since all
83 tree types are checked at run-time), and is therefore inappropriate in a
84 release version, it is extremely helpful during the development process.
86 Many macros behave as predicates.  Many, although not all, of these
87 predicates end in @samp{_P}.  Do not rely on the result type of these
88 macros being of any particular type.  You may, however, rely on the fact
89 that the type can be compared to @code{0}, so that statements like
90 @smallexample
91 if (TEST_P (t) && !TEST_P (y))
92   x = 1;
93 @end smallexample
94 @noindent
95 and
96 @smallexample
97 int i = (TEST_P (t) != 0);
98 @end smallexample
99 @noindent
100 are legal.  Macros that return @code{int} values now may be changed to
101 return @code{tree} values, or other pointers in the future.  Even those
102 that continue to return @code{int} may return multiple nonzero codes
103 where previously they returned only zero and one.  Therefore, you should
104 not write code like
105 @smallexample
106 if (TEST_P (t) == 1)
107 @end smallexample
108 @noindent
109 as this code is not guaranteed to work correctly in the future.
111 You should not take the address of values returned by the macros or
112 functions described here.  In particular, no guarantee is given that the
113 values are lvalues.
115 In general, the names of macros are all in uppercase, while the names of
116 functions are entirely in lowercase.  There are rare exceptions to this
117 rule.  You should assume that any macro or function whose name is made
118 up entirely of uppercase letters may evaluate its arguments more than
119 once.  You may assume that a macro or function whose name is made up
120 entirely of lowercase letters will evaluate its arguments only once.
122 The @code{error_mark_node} is a special tree.  Its tree code is
123 @code{ERROR_MARK}, but since there is only ever one node with that code,
124 the usual practice is to compare the tree against
125 @code{error_mark_node}.  (This test is just a test for pointer
126 equality.)  If an error has occurred during front-end processing the
127 flag @code{errorcount} will be set.  If the front end has encountered
128 code it cannot handle, it will issue a message to the user and set
129 @code{sorrycount}.  When these flags are set, any macro or function
130 which normally returns a tree of a particular kind may instead return
131 the @code{error_mark_node}.  Thus, if you intend to do any processing of
132 erroneous code, you must be prepared to deal with the
133 @code{error_mark_node}.
135 Occasionally, a particular tree slot (like an operand to an expression,
136 or a particular field in a declaration) will be referred to as
137 ``reserved for the back end''.  These slots are used to store RTL when
138 the tree is converted to RTL for use by the GCC back end.  However, if
139 that process is not taking place (e.g., if the front end is being hooked
140 up to an intelligent editor), then those slots may be used by the
141 back end presently in use.
143 If you encounter situations that do not match this documentation, such
144 as tree nodes of types not mentioned here, or macros documented to
145 return entities of a particular kind that instead return entities of
146 some different kind, you have found a bug, either in the front end or in
147 the documentation.  Please report these bugs as you would any other
148 bug.
150 @menu
151 * Macros and Functions::Macros and functions that can be used with all trees.
152 * Identifiers::         The names of things.
153 * Containers::          Lists and vectors.
154 @end menu
156 @c ---------------------------------------------------------------------
157 @c Trees
158 @c ---------------------------------------------------------------------
160 @node Macros and Functions
161 @subsection Trees
162 @cindex tree
163 @findex TREE_CHAIN
164 @findex TREE_TYPE
166 All GENERIC trees have two fields in common.  First, @code{TREE_CHAIN}
167 is a pointer that can be used as a singly-linked list to other trees.
168 The other is @code{TREE_TYPE}.  Many trees store the type of an
169 expression or declaration in this field.
171 These are some other functions for handling trees:
173 @ftable @code
175 @item tree_size
176 Return the number of bytes a tree takes.
178 @item build0
179 @itemx build1
180 @itemx build2
181 @itemx build3
182 @itemx build4
183 @itemx build5
184 @itemx build6
186 These functions build a tree and supply values to put in each
187 parameter.  The basic signature is @samp{@w{code, type, [operands]}}.
188 @code{code} is the @code{TREE_CODE}, and @code{type} is a tree
189 representing the @code{TREE_TYPE}.  These are followed by the
190 operands, each of which is also a tree.
192 @end ftable
195 @c ---------------------------------------------------------------------
196 @c Identifiers
197 @c ---------------------------------------------------------------------
199 @node Identifiers
200 @subsection Identifiers
201 @cindex identifier
202 @cindex name
203 @tindex IDENTIFIER_NODE
205 An @code{IDENTIFIER_NODE} represents a slightly more general concept
206 that the standard C or C++ concept of identifier.  In particular, an
207 @code{IDENTIFIER_NODE} may contain a @samp{$}, or other extraordinary
208 characters.
210 There are never two distinct @code{IDENTIFIER_NODE}s representing the
211 same identifier.  Therefore, you may use pointer equality to compare
212 @code{IDENTIFIER_NODE}s, rather than using a routine like
213 @code{strcmp}.  Use @code{get_identifier} to obtain the unique
214 @code{IDENTIFIER_NODE} for a supplied string.
216 You can use the following macros to access identifiers:
217 @ftable @code
218 @item IDENTIFIER_POINTER
219 The string represented by the identifier, represented as a
220 @code{char*}.  This string is always @code{NUL}-terminated, and contains
221 no embedded @code{NUL} characters.
223 @item IDENTIFIER_LENGTH
224 The length of the string returned by @code{IDENTIFIER_POINTER}, not
225 including the trailing @code{NUL}.  This value of
226 @code{IDENTIFIER_LENGTH (x)} is always the same as @code{strlen
227 (IDENTIFIER_POINTER (x))}.
229 @item IDENTIFIER_OPNAME_P
230 This predicate holds if the identifier represents the name of an
231 overloaded operator.  In this case, you should not depend on the
232 contents of either the @code{IDENTIFIER_POINTER} or the
233 @code{IDENTIFIER_LENGTH}.
235 @item IDENTIFIER_TYPENAME_P
236 This predicate holds if the identifier represents the name of a
237 user-defined conversion operator.  In this case, the @code{TREE_TYPE} of
238 the @code{IDENTIFIER_NODE} holds the type to which the conversion
239 operator converts.
241 @end ftable
243 @c ---------------------------------------------------------------------
244 @c Containers
245 @c ---------------------------------------------------------------------
247 @node Containers
248 @subsection Containers
249 @cindex container
250 @cindex list
251 @cindex vector
252 @tindex TREE_LIST
253 @tindex TREE_VEC
254 @findex TREE_PURPOSE
255 @findex TREE_VALUE
256 @findex TREE_VEC_LENGTH
257 @findex TREE_VEC_ELT
259 Two common container data structures can be represented directly with
260 tree nodes.  A @code{TREE_LIST} is a singly linked list containing two
261 trees per node.  These are the @code{TREE_PURPOSE} and @code{TREE_VALUE}
262 of each node.  (Often, the @code{TREE_PURPOSE} contains some kind of
263 tag, or additional information, while the @code{TREE_VALUE} contains the
264 majority of the payload.  In other cases, the @code{TREE_PURPOSE} is
265 simply @code{NULL_TREE}, while in still others both the
266 @code{TREE_PURPOSE} and @code{TREE_VALUE} are of equal stature.)  Given
267 one @code{TREE_LIST} node, the next node is found by following the
268 @code{TREE_CHAIN}.  If the @code{TREE_CHAIN} is @code{NULL_TREE}, then
269 you have reached the end of the list.
271 A @code{TREE_VEC} is a simple vector.  The @code{TREE_VEC_LENGTH} is an
272 integer (not a tree) giving the number of nodes in the vector.  The
273 nodes themselves are accessed using the @code{TREE_VEC_ELT} macro, which
274 takes two arguments.  The first is the @code{TREE_VEC} in question; the
275 second is an integer indicating which element in the vector is desired.
276 The elements are indexed from zero.
278 @c ---------------------------------------------------------------------
279 @c Types
280 @c ---------------------------------------------------------------------
282 @node Types
283 @section Types
284 @cindex type
285 @cindex pointer
286 @cindex reference
287 @cindex fundamental type
288 @cindex array
289 @tindex VOID_TYPE
290 @tindex INTEGER_TYPE
291 @tindex TYPE_MIN_VALUE
292 @tindex TYPE_MAX_VALUE
293 @tindex REAL_TYPE
294 @tindex FIXED_POINT_TYPE
295 @tindex COMPLEX_TYPE
296 @tindex ENUMERAL_TYPE
297 @tindex BOOLEAN_TYPE
298 @tindex POINTER_TYPE
299 @tindex REFERENCE_TYPE
300 @tindex FUNCTION_TYPE
301 @tindex METHOD_TYPE
302 @tindex ARRAY_TYPE
303 @tindex RECORD_TYPE
304 @tindex UNION_TYPE
305 @tindex UNKNOWN_TYPE
306 @tindex OFFSET_TYPE
307 @findex TYPE_UNQUALIFIED
308 @findex TYPE_QUAL_CONST
309 @findex TYPE_QUAL_VOLATILE
310 @findex TYPE_QUAL_RESTRICT
311 @findex TYPE_MAIN_VARIANT
312 @cindex qualified type
313 @findex TYPE_SIZE
314 @findex TYPE_ALIGN
315 @findex TYPE_PRECISION
316 @findex TYPE_ARG_TYPES
317 @findex TYPE_METHOD_BASETYPE
318 @findex TYPE_OFFSET_BASETYPE
319 @findex TREE_TYPE
320 @findex TYPE_CONTEXT
321 @findex TYPE_NAME
322 @findex TYPENAME_TYPE_FULLNAME
323 @findex TYPE_FIELDS
324 @findex TYPE_CANONICAL
325 @findex TYPE_STRUCTURAL_EQUALITY_P
326 @findex SET_TYPE_STRUCTURAL_EQUALITY
328 All types have corresponding tree nodes.  However, you should not assume
329 that there is exactly one tree node corresponding to each type.  There
330 are often multiple nodes corresponding to the same type.
332 For the most part, different kinds of types have different tree codes.
333 (For example, pointer types use a @code{POINTER_TYPE} code while arrays
334 use an @code{ARRAY_TYPE} code.)  However, pointers to member functions
335 use the @code{RECORD_TYPE} code.  Therefore, when writing a
336 @code{switch} statement that depends on the code associated with a
337 particular type, you should take care to handle pointers to member
338 functions under the @code{RECORD_TYPE} case label.
340 The following functions and macros deal with cv-qualification of types:
341 @ftable @code
342 @item TYPE_MAIN_VARIANT
343 This macro returns the unqualified version of a type.  It may be applied
344 to an unqualified type, but it is not always the identity function in
345 that case.
346 @end ftable
348 A few other macros and functions are usable with all types:
349 @ftable @code
350 @item TYPE_SIZE
351 The number of bits required to represent the type, represented as an
352 @code{INTEGER_CST}.  For an incomplete type, @code{TYPE_SIZE} will be
353 @code{NULL_TREE}.
355 @item TYPE_ALIGN
356 The alignment of the type, in bits, represented as an @code{int}.
358 @item TYPE_NAME
359 This macro returns a declaration (in the form of a @code{TYPE_DECL}) for
360 the type.  (Note this macro does @emph{not} return an
361 @code{IDENTIFIER_NODE}, as you might expect, given its name!)  You can
362 look at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the
363 actual name of the type.  The @code{TYPE_NAME} will be @code{NULL_TREE}
364 for a type that is not a built-in type, the result of a typedef, or a
365 named class type.
367 @item TYPE_CANONICAL
368 This macro returns the ``canonical'' type for the given type
369 node. Canonical types are used to improve performance in the C++ and
370 Objective-C++ front ends by allowing efficient comparison between two
371 type nodes in @code{same_type_p}: if the @code{TYPE_CANONICAL} values
372 of the types are equal, the types are equivalent; otherwise, the types
373 are not equivalent. The notion of equivalence for canonical types is
374 the same as the notion of type equivalence in the language itself. For
375 instance,
377 When @code{TYPE_CANONICAL} is @code{NULL_TREE}, there is no canonical
378 type for the given type node. In this case, comparison between this
379 type and any other type requires the compiler to perform a deep,
380 ``structural'' comparison to see if the two type nodes have the same
381 form and properties.
383 The canonical type for a node is always the most fundamental type in
384 the equivalence class of types. For instance, @code{int} is its own
385 canonical type. A typedef @code{I} of @code{int} will have @code{int}
386 as its canonical type. Similarly, @code{I*}@ and a typedef @code{IP}@
387 (defined to @code{I*}) will has @code{int*} as their canonical
388 type. When building a new type node, be sure to set
389 @code{TYPE_CANONICAL} to the appropriate canonical type. If the new
390 type is a compound type (built from other types), and any of those
391 other types require structural equality, use
392 @code{SET_TYPE_STRUCTURAL_EQUALITY} to ensure that the new type also
393 requires structural equality. Finally, if for some reason you cannot
394 guarantee that @code{TYPE_CANONICAL} will point to the canonical type,
395 use @code{SET_TYPE_STRUCTURAL_EQUALITY} to make sure that the new
396 type--and any type constructed based on it--requires structural
397 equality. If you suspect that the canonical type system is
398 miscomparing types, pass @code{--param verify-canonical-types=1} to
399 the compiler or configure with @code{--enable-checking} to force the
400 compiler to verify its canonical-type comparisons against the
401 structural comparisons; the compiler will then print any warnings if
402 the canonical types miscompare.
404 @item TYPE_STRUCTURAL_EQUALITY_P
405 This predicate holds when the node requires structural equality
406 checks, e.g., when @code{TYPE_CANONICAL} is @code{NULL_TREE}.
408 @item SET_TYPE_STRUCTURAL_EQUALITY
409 This macro states that the type node it is given requires structural
410 equality checks, e.g., it sets @code{TYPE_CANONICAL} to
411 @code{NULL_TREE}.
413 @item same_type_p
414 This predicate takes two types as input, and holds if they are the same
415 type.  For example, if one type is a @code{typedef} for the other, or
416 both are @code{typedef}s for the same type.  This predicate also holds if
417 the two trees given as input are simply copies of one another; i.e.,
418 there is no difference between them at the source level, but, for
419 whatever reason, a duplicate has been made in the representation.  You
420 should never use @code{==} (pointer equality) to compare types; always
421 use @code{same_type_p} instead.
422 @end ftable
424 Detailed below are the various kinds of types, and the macros that can
425 be used to access them.  Although other kinds of types are used
426 elsewhere in G++, the types described here are the only ones that you
427 will encounter while examining the intermediate representation.
429 @table @code
430 @item VOID_TYPE
431 Used to represent the @code{void} type.
433 @item INTEGER_TYPE
434 Used to represent the various integral types, including @code{char},
435 @code{short}, @code{int}, @code{long}, and @code{long long}.  This code
436 is not used for enumeration types, nor for the @code{bool} type.
437 The @code{TYPE_PRECISION} is the number of bits used in
438 the representation, represented as an @code{unsigned int}.  (Note that
439 in the general case this is not the same value as @code{TYPE_SIZE};
440 suppose that there were a 24-bit integer type, but that alignment
441 requirements for the ABI required 32-bit alignment.  Then,
442 @code{TYPE_SIZE} would be an @code{INTEGER_CST} for 32, while
443 @code{TYPE_PRECISION} would be 24.)  The integer type is unsigned if
444 @code{TYPE_UNSIGNED} holds; otherwise, it is signed.
446 The @code{TYPE_MIN_VALUE} is an @code{INTEGER_CST} for the smallest
447 integer that may be represented by this type.  Similarly, the
448 @code{TYPE_MAX_VALUE} is an @code{INTEGER_CST} for the largest integer
449 that may be represented by this type.
451 @item REAL_TYPE
452 Used to represent the @code{float}, @code{double}, and @code{long
453 double} types.  The number of bits in the floating-point representation
454 is given by @code{TYPE_PRECISION}, as in the @code{INTEGER_TYPE} case.
456 @item FIXED_POINT_TYPE
457 Used to represent the @code{short _Fract}, @code{_Fract}, @code{long
458 _Fract}, @code{long long _Fract}, @code{short _Accum}, @code{_Accum},
459 @code{long _Accum}, and @code{long long _Accum} types.  The number of bits
460 in the fixed-point representation is given by @code{TYPE_PRECISION},
461 as in the @code{INTEGER_TYPE} case.  There may be padding bits, fractional
462 bits and integral bits.  The number of fractional bits is given by
463 @code{TYPE_FBIT}, and the number of integral bits is given by @code{TYPE_IBIT}.
464 The fixed-point type is unsigned if @code{TYPE_UNSIGNED} holds; otherwise,
465 it is signed.
466 The fixed-point type is saturating if @code{TYPE_SATURATING} holds; otherwise,
467 it is not saturating.
469 @item COMPLEX_TYPE
470 Used to represent GCC built-in @code{__complex__} data types.  The
471 @code{TREE_TYPE} is the type of the real and imaginary parts.
473 @item ENUMERAL_TYPE
474 Used to represent an enumeration type.  The @code{TYPE_PRECISION} gives
475 (as an @code{int}), the number of bits used to represent the type.  If
476 there are no negative enumeration constants, @code{TYPE_UNSIGNED} will
477 hold.  The minimum and maximum enumeration constants may be obtained
478 with @code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE}, respectively; each
479 of these macros returns an @code{INTEGER_CST}.
481 The actual enumeration constants themselves may be obtained by looking
482 at the @code{TYPE_VALUES}.  This macro will return a @code{TREE_LIST},
483 containing the constants.  The @code{TREE_PURPOSE} of each node will be
484 an @code{IDENTIFIER_NODE} giving the name of the constant; the
485 @code{TREE_VALUE} will be an @code{INTEGER_CST} giving the value
486 assigned to that constant.  These constants will appear in the order in
487 which they were declared.  The @code{TREE_TYPE} of each of these
488 constants will be the type of enumeration type itself.
490 @item BOOLEAN_TYPE
491 Used to represent the @code{bool} type.
493 @item POINTER_TYPE
494 Used to represent pointer types, and pointer to data member types.  The
495 @code{TREE_TYPE} gives the type to which this type points.
497 @item REFERENCE_TYPE
498 Used to represent reference types.  The @code{TREE_TYPE} gives the type
499 to which this type refers.
501 @item FUNCTION_TYPE
502 Used to represent the type of non-member functions and of static member
503 functions.  The @code{TREE_TYPE} gives the return type of the function.
504 The @code{TYPE_ARG_TYPES} are a @code{TREE_LIST} of the argument types.
505 The @code{TREE_VALUE} of each node in this list is the type of the
506 corresponding argument; the @code{TREE_PURPOSE} is an expression for the
507 default argument value, if any.  If the last node in the list is
508 @code{void_list_node} (a @code{TREE_LIST} node whose @code{TREE_VALUE}
509 is the @code{void_type_node}), then functions of this type do not take
510 variable arguments.  Otherwise, they do take a variable number of
511 arguments.
513 Note that in C (but not in C++) a function declared like @code{void f()}
514 is an unprototyped function taking a variable number of arguments; the
515 @code{TYPE_ARG_TYPES} of such a function will be @code{NULL}.
517 @item METHOD_TYPE
518 Used to represent the type of a non-static member function.  Like a
519 @code{FUNCTION_TYPE}, the return type is given by the @code{TREE_TYPE}.
520 The type of @code{*this}, i.e., the class of which functions of this
521 type are a member, is given by the @code{TYPE_METHOD_BASETYPE}.  The
522 @code{TYPE_ARG_TYPES} is the parameter list, as for a
523 @code{FUNCTION_TYPE}, and includes the @code{this} argument.
525 @item ARRAY_TYPE
526 Used to represent array types.  The @code{TREE_TYPE} gives the type of
527 the elements in the array.  If the array-bound is present in the type,
528 the @code{TYPE_DOMAIN} is an @code{INTEGER_TYPE} whose
529 @code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE} will be the lower and
530 upper bounds of the array, respectively.  The @code{TYPE_MIN_VALUE} will
531 always be an @code{INTEGER_CST} for zero, while the
532 @code{TYPE_MAX_VALUE} will be one less than the number of elements in
533 the array, i.e., the highest value which may be used to index an element
534 in the array.
536 @item RECORD_TYPE
537 Used to represent @code{struct} and @code{class} types, as well as
538 pointers to member functions and similar constructs in other languages.
539 @code{TYPE_FIELDS} contains the items contained in this type, each of
540 which can be a @code{FIELD_DECL}, @code{VAR_DECL}, @code{CONST_DECL}, or
541 @code{TYPE_DECL}.  You may not make any assumptions about the ordering
542 of the fields in the type or whether one or more of them overlap.
544 @item UNION_TYPE
545 Used to represent @code{union} types.  Similar to @code{RECORD_TYPE}
546 except that all @code{FIELD_DECL} nodes in @code{TYPE_FIELD} start at
547 bit position zero.
549 @item QUAL_UNION_TYPE
550 Used to represent part of a variant record in Ada.  Similar to
551 @code{UNION_TYPE} except that each @code{FIELD_DECL} has a
552 @code{DECL_QUALIFIER} field, which contains a boolean expression that
553 indicates whether the field is present in the object.  The type will only
554 have one field, so each field's @code{DECL_QUALIFIER} is only evaluated
555 if none of the expressions in the previous fields in @code{TYPE_FIELDS}
556 are nonzero.  Normally these expressions will reference a field in the
557 outer object using a @code{PLACEHOLDER_EXPR}.
559 @item LANG_TYPE
560 This node is used to represent a language-specific type.  The front
561 end must handle it.
563 @item OFFSET_TYPE
564 This node is used to represent a pointer-to-data member.  For a data
565 member @code{X::m} the @code{TYPE_OFFSET_BASETYPE} is @code{X} and the
566 @code{TREE_TYPE} is the type of @code{m}.
568 @end table
570 There are variables whose values represent some of the basic types.
571 These include:
572 @table @code
573 @item void_type_node
574 A node for @code{void}.
576 @item integer_type_node
577 A node for @code{int}.
579 @item unsigned_type_node.
580 A node for @code{unsigned int}.
582 @item char_type_node.
583 A node for @code{char}.
584 @end table
585 @noindent
586 It may sometimes be useful to compare one of these variables with a type
587 in hand, using @code{same_type_p}.
589 @c ---------------------------------------------------------------------
590 @c Declarations
591 @c ---------------------------------------------------------------------
593 @node Declarations
594 @section Declarations
595 @cindex declaration
596 @cindex variable
597 @cindex type declaration
598 @tindex LABEL_DECL
599 @tindex CONST_DECL
600 @tindex TYPE_DECL
601 @tindex VAR_DECL
602 @tindex PARM_DECL
603 @tindex DEBUG_EXPR_DECL
604 @tindex FIELD_DECL
605 @tindex NAMESPACE_DECL
606 @tindex RESULT_DECL
607 @tindex TEMPLATE_DECL
608 @tindex THUNK_DECL
609 @findex THUNK_DELTA
610 @findex DECL_INITIAL
611 @findex DECL_SIZE
612 @findex DECL_ALIGN
613 @findex DECL_EXTERNAL
615 This section covers the various kinds of declarations that appear in the
616 internal representation, except for declarations of functions
617 (represented by @code{FUNCTION_DECL} nodes), which are described in
618 @ref{Functions}.
620 @menu
621 * Working with declarations::  Macros and functions that work on
622 declarations.
623 * Internal structure:: How declaration nodes are represented.
624 @end menu
626 @node Working with declarations
627 @subsection Working with declarations
629 Some macros can be used with any kind of declaration.  These include:
630 @ftable @code
631 @item DECL_NAME
632 This macro returns an @code{IDENTIFIER_NODE} giving the name of the
633 entity.
635 @item TREE_TYPE
636 This macro returns the type of the entity declared.
638 @item EXPR_FILENAME
639 This macro returns the name of the file in which the entity was
640 declared, as a @code{char*}.  For an entity declared implicitly by the
641 compiler (like @code{__builtin_memcpy}), this will be the string
642 @code{"<internal>"}.
644 @item EXPR_LINENO
645 This macro returns the line number at which the entity was declared, as
646 an @code{int}.
648 @item DECL_ARTIFICIAL
649 This predicate holds if the declaration was implicitly generated by the
650 compiler.  For example, this predicate will hold of an implicitly
651 declared member function, or of the @code{TYPE_DECL} implicitly
652 generated for a class type.  Recall that in C++ code like:
653 @smallexample
654 struct S @{@};
655 @end smallexample
656 @noindent
657 is roughly equivalent to C code like:
658 @smallexample
659 struct S @{@};
660 typedef struct S S;
661 @end smallexample
662 The implicitly generated @code{typedef} declaration is represented by a
663 @code{TYPE_DECL} for which @code{DECL_ARTIFICIAL} holds.
665 @end ftable
667 The various kinds of declarations include:
668 @table @code
669 @item LABEL_DECL
670 These nodes are used to represent labels in function bodies.  For more
671 information, see @ref{Functions}.  These nodes only appear in block
672 scopes.
674 @item CONST_DECL
675 These nodes are used to represent enumeration constants.  The value of
676 the constant is given by @code{DECL_INITIAL} which will be an
677 @code{INTEGER_CST} with the same type as the @code{TREE_TYPE} of the
678 @code{CONST_DECL}, i.e., an @code{ENUMERAL_TYPE}.
680 @item RESULT_DECL
681 These nodes represent the value returned by a function.  When a value is
682 assigned to a @code{RESULT_DECL}, that indicates that the value should
683 be returned, via bitwise copy, by the function.  You can use
684 @code{DECL_SIZE} and @code{DECL_ALIGN} on a @code{RESULT_DECL}, just as
685 with a @code{VAR_DECL}.
687 @item TYPE_DECL
688 These nodes represent @code{typedef} declarations.  The @code{TREE_TYPE}
689 is the type declared to have the name given by @code{DECL_NAME}.  In
690 some cases, there is no associated name.
692 @item VAR_DECL
693 These nodes represent variables with namespace or block scope, as well
694 as static data members.  The @code{DECL_SIZE} and @code{DECL_ALIGN} are
695 analogous to @code{TYPE_SIZE} and @code{TYPE_ALIGN}.  For a declaration,
696 you should always use the @code{DECL_SIZE} and @code{DECL_ALIGN} rather
697 than the @code{TYPE_SIZE} and @code{TYPE_ALIGN} given by the
698 @code{TREE_TYPE}, since special attributes may have been applied to the
699 variable to give it a particular size and alignment.  You may use the
700 predicates @code{DECL_THIS_STATIC} or @code{DECL_THIS_EXTERN} to test
701 whether the storage class specifiers @code{static} or @code{extern} were
702 used to declare a variable.
704 If this variable is initialized (but does not require a constructor),
705 the @code{DECL_INITIAL} will be an expression for the initializer.  The
706 initializer should be evaluated, and a bitwise copy into the variable
707 performed.  If the @code{DECL_INITIAL} is the @code{error_mark_node},
708 there is an initializer, but it is given by an explicit statement later
709 in the code; no bitwise copy is required.
711 GCC provides an extension that allows either automatic variables, or
712 global variables, to be placed in particular registers.  This extension
713 is being used for a particular @code{VAR_DECL} if @code{DECL_REGISTER}
714 holds for the @code{VAR_DECL}, and if @code{DECL_ASSEMBLER_NAME} is not
715 equal to @code{DECL_NAME}.  In that case, @code{DECL_ASSEMBLER_NAME} is
716 the name of the register into which the variable will be placed.
718 @item PARM_DECL
719 Used to represent a parameter to a function.  Treat these nodes
720 similarly to @code{VAR_DECL} nodes.  These nodes only appear in the
721 @code{DECL_ARGUMENTS} for a @code{FUNCTION_DECL}.
723 The @code{DECL_ARG_TYPE} for a @code{PARM_DECL} is the type that will
724 actually be used when a value is passed to this function.  It may be a
725 wider type than the @code{TREE_TYPE} of the parameter; for example, the
726 ordinary type might be @code{short} while the @code{DECL_ARG_TYPE} is
727 @code{int}.
729 @item DEBUG_EXPR_DECL
730 Used to represent an anonymous debug-information temporary created to
731 hold an expression as it is optimized away, so that its value can be
732 referenced in debug bind statements.
734 @item FIELD_DECL
735 These nodes represent non-static data members.  The @code{DECL_SIZE} and
736 @code{DECL_ALIGN} behave as for @code{VAR_DECL} nodes.
737 The position of the field within the parent record is specified by a
738 combination of three attributes.  @code{DECL_FIELD_OFFSET} is the position,
739 counting in bytes, of the @code{DECL_OFFSET_ALIGN}-bit sized word containing
740 the bit of the field closest to the beginning of the structure.
741 @code{DECL_FIELD_BIT_OFFSET} is the bit offset of the first bit of the field
742 within this word; this may be nonzero even for fields that are not bit-fields,
743 since @code{DECL_OFFSET_ALIGN} may be greater than the natural alignment
744 of the field's type.
746 If @code{DECL_C_BIT_FIELD} holds, this field is a bit-field.  In a bit-field,
747 @code{DECL_BIT_FIELD_TYPE} also contains the type that was originally
748 specified for it, while DECL_TYPE may be a modified type with lesser precision,
749 according to the size of the bit field.
751 @item NAMESPACE_DECL
752 Namespaces provide a name hierarchy for other declarations.  They
753 appear in the @code{DECL_CONTEXT} of other @code{_DECL} nodes.
755 @end table
757 @node Internal structure
758 @subsection Internal structure
760 @code{DECL} nodes are represented internally as a hierarchy of
761 structures.
763 @menu
764 * Current structure hierarchy::  The current DECL node structure
765 hierarchy.
766 * Adding new DECL node types:: How to add a new DECL node to a
767 frontend.
768 @end menu
770 @node Current structure hierarchy
771 @subsubsection Current structure hierarchy
773 @table @code
775 @item struct tree_decl_minimal
776 This is the minimal structure to inherit from in order for common
777 @code{DECL} macros to work.  The fields it contains are a unique ID,
778 source location, context, and name.
780 @item struct tree_decl_common
781 This structure inherits from @code{struct tree_decl_minimal}.  It
782 contains fields that most @code{DECL} nodes need, such as a field to
783 store alignment, machine mode, size, and attributes.
785 @item struct tree_field_decl
786 This structure inherits from @code{struct tree_decl_common}.  It is
787 used to represent @code{FIELD_DECL}.
789 @item struct tree_label_decl
790 This structure inherits from @code{struct tree_decl_common}.  It is
791 used to represent @code{LABEL_DECL}.
793 @item struct tree_translation_unit_decl
794 This structure inherits from @code{struct tree_decl_common}.  It is
795 used to represent @code{TRANSLATION_UNIT_DECL}.
797 @item struct tree_decl_with_rtl
798 This structure inherits from @code{struct tree_decl_common}.  It
799 contains a field to store the low-level RTL associated with a
800 @code{DECL} node.
802 @item struct tree_result_decl
803 This structure inherits from @code{struct tree_decl_with_rtl}.  It is
804 used to represent @code{RESULT_DECL}.
806 @item struct tree_const_decl
807 This structure inherits from @code{struct tree_decl_with_rtl}.  It is
808 used to represent @code{CONST_DECL}.
810 @item struct tree_parm_decl
811 This structure inherits from @code{struct tree_decl_with_rtl}.  It is
812 used to represent @code{PARM_DECL}.
814 @item struct tree_decl_with_vis
815 This structure inherits from @code{struct tree_decl_with_rtl}.  It
816 contains fields necessary to store visibility information, as well as
817 a section name and assembler name.
819 @item struct tree_var_decl
820 This structure inherits from @code{struct tree_decl_with_vis}.  It is
821 used to represent @code{VAR_DECL}.
823 @item struct tree_function_decl
824 This structure inherits from @code{struct tree_decl_with_vis}.  It is
825 used to represent @code{FUNCTION_DECL}.
827 @end table
828 @node Adding new DECL node types
829 @subsubsection Adding new DECL node types
831 Adding a new @code{DECL} tree consists of the following steps
833 @table @asis
835 @item Add a new tree code for the @code{DECL} node
836 For language specific @code{DECL} nodes, there is a @file{.def} file
837 in each frontend directory where the tree code should be added.
838 For @code{DECL} nodes that are part of the middle-end, the code should
839 be added to @file{tree.def}.
841 @item Create a new structure type for the @code{DECL} node
842 These structures should inherit from one of the existing structures in
843 the language hierarchy by using that structure as the first member.
845 @smallexample
846 struct tree_foo_decl
848    struct tree_decl_with_vis common;
850 @end smallexample
852 Would create a structure name @code{tree_foo_decl} that inherits from
853 @code{struct tree_decl_with_vis}.
855 For language specific @code{DECL} nodes, this new structure type
856 should go in the appropriate @file{.h} file.
857 For @code{DECL} nodes that are part of the middle-end, the structure
858 type should go in @file{tree.h}.
860 @item Add a member to the tree structure enumerator for the node
861 For garbage collection and dynamic checking purposes, each @code{DECL}
862 node structure type is required to have a unique enumerator value
863 specified with it.
864 For language specific @code{DECL} nodes, this new enumerator value
865 should go in the appropriate @file{.def} file.
866 For @code{DECL} nodes that are part of the middle-end, the enumerator
867 values are specified in @file{treestruct.def}.
869 @item Update @code{union tree_node}
870 In order to make your new structure type usable, it must be added to
871 @code{union tree_node}.
872 For language specific @code{DECL} nodes, a new entry should be added
873 to the appropriate @file{.h} file of the form
874 @smallexample
875   struct tree_foo_decl GTY ((tag ("TS_VAR_DECL"))) foo_decl;
876 @end smallexample
877 For @code{DECL} nodes that are part of the middle-end, the additional
878 member goes directly into @code{union tree_node} in @file{tree.h}.
880 @item Update dynamic checking info
881 In order to be able to check whether accessing a named portion of
882 @code{union tree_node} is legal, and whether a certain @code{DECL} node
883 contains one of the enumerated @code{DECL} node structures in the
884 hierarchy, a simple lookup table is used.
885 This lookup table needs to be kept up to date with the tree structure
886 hierarchy, or else checking and containment macros will fail
887 inappropriately.
889 For language specific @code{DECL} nodes, their is an @code{init_ts}
890 function in an appropriate @file{.c} file, which initializes the lookup
891 table.
892 Code setting up the table for new @code{DECL} nodes should be added
893 there.
894 For each @code{DECL} tree code and enumerator value representing a
895 member of the inheritance  hierarchy, the table should contain 1 if
896 that tree code inherits (directly or indirectly) from that member.
897 Thus, a @code{FOO_DECL} node derived from @code{struct decl_with_rtl},
898 and enumerator value @code{TS_FOO_DECL}, would be set up as follows
899 @smallexample
900 tree_contains_struct[FOO_DECL][TS_FOO_DECL] = 1;
901 tree_contains_struct[FOO_DECL][TS_DECL_WRTL] = 1;
902 tree_contains_struct[FOO_DECL][TS_DECL_COMMON] = 1;
903 tree_contains_struct[FOO_DECL][TS_DECL_MINIMAL] = 1;
904 @end smallexample
906 For @code{DECL} nodes that are part of the middle-end, the setup code
907 goes into @file{tree.c}.
909 @item Add macros to access any new fields and flags
911 Each added field or flag should have a macro that is used to access
912 it, that performs appropriate checking to ensure only the right type of
913 @code{DECL} nodes access the field.
915 These macros generally take the following form
916 @smallexample
917 #define FOO_DECL_FIELDNAME(NODE) FOO_DECL_CHECK(NODE)->foo_decl.fieldname
918 @end smallexample
919 However, if the structure is simply a base class for further
920 structures, something like the following should be used
921 @smallexample
922 #define BASE_STRUCT_CHECK(T) CONTAINS_STRUCT_CHECK(T, TS_BASE_STRUCT)
923 #define BASE_STRUCT_FIELDNAME(NODE) \
924    (BASE_STRUCT_CHECK(NODE)->base_struct.fieldname
925 @end smallexample
927 Reading them from the generated @file{all-tree.def} file (which in
928 turn includes all the @file{tree.def} files), @file{gencheck.c} is
929 used during GCC's build to generate the @code{*_CHECK} macros for all
930 tree codes.
932 @end table
935 @c ---------------------------------------------------------------------
936 @c Attributes
937 @c ---------------------------------------------------------------------
938 @node Attributes
939 @section Attributes in trees
940 @cindex attributes
942 Attributes, as specified using the @code{__attribute__} keyword, are
943 represented internally as a @code{TREE_LIST}.  The @code{TREE_PURPOSE}
944 is the name of the attribute, as an @code{IDENTIFIER_NODE}.  The
945 @code{TREE_VALUE} is a @code{TREE_LIST} of the arguments of the
946 attribute, if any, or @code{NULL_TREE} if there are no arguments; the
947 arguments are stored as the @code{TREE_VALUE} of successive entries in
948 the list, and may be identifiers or expressions.  The @code{TREE_CHAIN}
949 of the attribute is the next attribute in a list of attributes applying
950 to the same declaration or type, or @code{NULL_TREE} if there are no
951 further attributes in the list.
953 Attributes may be attached to declarations and to types; these
954 attributes may be accessed with the following macros.  All attributes
955 are stored in this way, and many also cause other changes to the
956 declaration or type or to other internal compiler data structures.
958 @deftypefn {Tree Macro} tree DECL_ATTRIBUTES (tree @var{decl})
959 This macro returns the attributes on the declaration @var{decl}.
960 @end deftypefn
962 @deftypefn {Tree Macro} tree TYPE_ATTRIBUTES (tree @var{type})
963 This macro returns the attributes on the type @var{type}.
964 @end deftypefn
967 @c ---------------------------------------------------------------------
968 @c Expressions
969 @c ---------------------------------------------------------------------
971 @node Expression trees
972 @section Expressions
973 @cindex expression
974 @findex TREE_TYPE
975 @findex TREE_OPERAND
977 The internal representation for expressions is for the most part quite
978 straightforward.  However, there are a few facts that one must bear in
979 mind.  In particular, the expression ``tree'' is actually a directed
980 acyclic graph.  (For example there may be many references to the integer
981 constant zero throughout the source program; many of these will be
982 represented by the same expression node.)  You should not rely on
983 certain kinds of node being shared, nor should you rely on certain kinds of
984 nodes being unshared.
986 The following macros can be used with all expression nodes:
988 @ftable @code
989 @item TREE_TYPE
990 Returns the type of the expression.  This value may not be precisely the
991 same type that would be given the expression in the original program.
992 @end ftable
994 In what follows, some nodes that one might expect to always have type
995 @code{bool} are documented to have either integral or boolean type.  At
996 some point in the future, the C front end may also make use of this same
997 intermediate representation, and at this point these nodes will
998 certainly have integral type.  The previous sentence is not meant to
999 imply that the C++ front end does not or will not give these nodes
1000 integral type.
1002 Below, we list the various kinds of expression nodes.  Except where
1003 noted otherwise, the operands to an expression are accessed using the
1004 @code{TREE_OPERAND} macro.  For example, to access the first operand to
1005 a binary plus expression @code{expr}, use:
1007 @smallexample
1008 TREE_OPERAND (expr, 0)
1009 @end smallexample
1010 @noindent
1012 As this example indicates, the operands are zero-indexed.
1015 @menu
1016 * Constants: Constant expressions.
1017 * Storage References::
1018 * Unary and Binary Expressions::
1019 * Vectors::
1020 @end menu
1022 @node Constant expressions
1023 @subsection Constant expressions
1024 @tindex INTEGER_CST
1025 @findex TREE_INT_CST_HIGH
1026 @findex TREE_INT_CST_LOW
1027 @findex tree_int_cst_lt
1028 @findex tree_int_cst_equal
1029 @tindex REAL_CST
1030 @tindex FIXED_CST
1031 @tindex COMPLEX_CST
1032 @tindex VECTOR_CST
1033 @tindex STRING_CST
1034 @findex TREE_STRING_LENGTH
1035 @findex TREE_STRING_POINTER
1037 The table below begins with constants, moves on to unary expressions,
1038 then proceeds to binary expressions, and concludes with various other
1039 kinds of expressions:
1041 @table @code
1042 @item INTEGER_CST
1043 These nodes represent integer constants.  Note that the type of these
1044 constants is obtained with @code{TREE_TYPE}; they are not always of type
1045 @code{int}.  In particular, @code{char} constants are represented with
1046 @code{INTEGER_CST} nodes.  The value of the integer constant @code{e} is
1047 given by
1048 @smallexample
1049 ((TREE_INT_CST_HIGH (e) << HOST_BITS_PER_WIDE_INT)
1050 + TREE_INST_CST_LOW (e))
1051 @end smallexample
1052 @noindent
1053 HOST_BITS_PER_WIDE_INT is at least thirty-two on all platforms.  Both
1054 @code{TREE_INT_CST_HIGH} and @code{TREE_INT_CST_LOW} return a
1055 @code{HOST_WIDE_INT}.  The value of an @code{INTEGER_CST} is interpreted
1056 as a signed or unsigned quantity depending on the type of the constant.
1057 In general, the expression given above will overflow, so it should not
1058 be used to calculate the value of the constant.
1060 The variable @code{integer_zero_node} is an integer constant with value
1061 zero.  Similarly, @code{integer_one_node} is an integer constant with
1062 value one.  The @code{size_zero_node} and @code{size_one_node} variables
1063 are analogous, but have type @code{size_t} rather than @code{int}.
1065 The function @code{tree_int_cst_lt} is a predicate which holds if its
1066 first argument is less than its second.  Both constants are assumed to
1067 have the same signedness (i.e., either both should be signed or both
1068 should be unsigned.)  The full width of the constant is used when doing
1069 the comparison; the usual rules about promotions and conversions are
1070 ignored.  Similarly, @code{tree_int_cst_equal} holds if the two
1071 constants are equal.  The @code{tree_int_cst_sgn} function returns the
1072 sign of a constant.  The value is @code{1}, @code{0}, or @code{-1}
1073 according on whether the constant is greater than, equal to, or less
1074 than zero.  Again, the signedness of the constant's type is taken into
1075 account; an unsigned constant is never less than zero, no matter what
1076 its bit-pattern.
1078 @item REAL_CST
1080 FIXME: Talk about how to obtain representations of this constant, do
1081 comparisons, and so forth.
1083 @item FIXED_CST
1085 These nodes represent fixed-point constants.  The type of these constants
1086 is obtained with @code{TREE_TYPE}.  @code{TREE_FIXED_CST_PTR} points to
1087 a @code{struct fixed_value};  @code{TREE_FIXED_CST} returns the structure
1088 itself.  @code{struct fixed_value} contains @code{data} with the size of two
1089 @code{HOST_BITS_PER_WIDE_INT} and @code{mode} as the associated fixed-point
1090 machine mode for @code{data}.
1092 @item COMPLEX_CST
1093 These nodes are used to represent complex number constants, that is a
1094 @code{__complex__} whose parts are constant nodes.  The
1095 @code{TREE_REALPART} and @code{TREE_IMAGPART} return the real and the
1096 imaginary parts respectively.
1098 @item VECTOR_CST
1099 These nodes are used to represent vector constants, whose parts are
1100 constant nodes.  Each individual constant node is either an integer or a
1101 double constant node.  The first operand is a @code{TREE_LIST} of the
1102 constant nodes and is accessed through @code{TREE_VECTOR_CST_ELTS}.
1104 @item STRING_CST
1105 These nodes represent string-constants.  The @code{TREE_STRING_LENGTH}
1106 returns the length of the string, as an @code{int}.  The
1107 @code{TREE_STRING_POINTER} is a @code{char*} containing the string
1108 itself.  The string may not be @code{NUL}-terminated, and it may contain
1109 embedded @code{NUL} characters.  Therefore, the
1110 @code{TREE_STRING_LENGTH} includes the trailing @code{NUL} if it is
1111 present.
1113 For wide string constants, the @code{TREE_STRING_LENGTH} is the number
1114 of bytes in the string, and the @code{TREE_STRING_POINTER}
1115 points to an array of the bytes of the string, as represented on the
1116 target system (that is, as integers in the target endianness).  Wide and
1117 non-wide string constants are distinguished only by the @code{TREE_TYPE}
1118 of the @code{STRING_CST}.
1120 FIXME: The formats of string constants are not well-defined when the
1121 target system bytes are not the same width as host system bytes.
1123 @end table
1125 @node Storage References
1126 @subsection References to storage
1127 @tindex ADDR_EXPR
1128 @tindex INDIRECT_REF
1129 @tindex MEM_REF
1130 @tindex ARRAY_REF
1131 @tindex ARRAY_RANGE_REF
1132 @tindex TARGET_MEM_REF
1133 @tindex COMPONENT_REF
1135 @table @code
1136 @item ARRAY_REF
1137 These nodes represent array accesses.  The first operand is the array;
1138 the second is the index.  To calculate the address of the memory
1139 accessed, you must scale the index by the size of the type of the array
1140 elements.  The type of these expressions must be the type of a component of
1141 the array.  The third and fourth operands are used after gimplification
1142 to represent the lower bound and component size but should not be used
1143 directly; call @code{array_ref_low_bound} and @code{array_ref_element_size}
1144 instead.
1146 @item ARRAY_RANGE_REF
1147 These nodes represent access to a range (or ``slice'') of an array.  The
1148 operands are the same as that for @code{ARRAY_REF} and have the same
1149 meanings.  The type of these expressions must be an array whose component
1150 type is the same as that of the first operand.  The range of that array
1151 type determines the amount of data these expressions access.
1153 @item TARGET_MEM_REF
1154 These nodes represent memory accesses whose address directly map to
1155 an addressing mode of the target architecture.  The first argument
1156 is @code{TMR_SYMBOL} and must be a @code{VAR_DECL} of an object with
1157 a fixed address.  The second argument is @code{TMR_BASE} and the
1158 third one is @code{TMR_INDEX}.  The fourth argument is
1159 @code{TMR_STEP} and must be an @code{INTEGER_CST}.  The fifth
1160 argument is @code{TMR_OFFSET} and must be an @code{INTEGER_CST}.
1161 Any of the arguments may be NULL if the appropriate component
1162 does not appear in the address.  Address of the @code{TARGET_MEM_REF}
1163 is determined in the following way.
1165 @smallexample
1166 &TMR_SYMBOL + TMR_BASE + TMR_INDEX * TMR_STEP + TMR_OFFSET
1167 @end smallexample
1169 The sixth argument is the reference to the original memory access, which
1170 is preserved for the purposes of the RTL alias analysis.  The seventh
1171 argument is a tag representing the results of tree level alias analysis.
1173 @item ADDR_EXPR
1174 These nodes are used to represent the address of an object.  (These
1175 expressions will always have pointer or reference type.)  The operand may
1176 be another expression, or it may be a declaration.
1178 As an extension, GCC allows users to take the address of a label.  In
1179 this case, the operand of the @code{ADDR_EXPR} will be a
1180 @code{LABEL_DECL}.  The type of such an expression is @code{void*}.
1182 If the object addressed is not an lvalue, a temporary is created, and
1183 the address of the temporary is used.
1185 @item INDIRECT_REF
1186 These nodes are used to represent the object pointed to by a pointer.
1187 The operand is the pointer being dereferenced; it will always have
1188 pointer or reference type.
1190 @item MEM_REF
1191 These nodes are used to represent the object pointed to by a pointer
1192 offset by a constant.
1193 The first operand is the pointer being dereferenced; it will always have
1194 pointer or reference type.  The second operand is a pointer constant.
1195 Its type is specifying the type to be used for type-based alias analysis.
1197 @item COMPONENT_REF
1198 These nodes represent non-static data member accesses.  The first
1199 operand is the object (rather than a pointer to it); the second operand
1200 is the @code{FIELD_DECL} for the data member.  The third operand represents
1201 the byte offset of the field, but should not be used directly; call
1202 @code{component_ref_field_offset} instead.
1205 @end table
1207 @node Unary and Binary Expressions
1208 @subsection Unary and Binary Expressions
1209 @tindex NEGATE_EXPR
1210 @tindex ABS_EXPR
1211 @tindex BIT_NOT_EXPR
1212 @tindex TRUTH_NOT_EXPR
1213 @tindex PREDECREMENT_EXPR
1214 @tindex PREINCREMENT_EXPR
1215 @tindex POSTDECREMENT_EXPR
1216 @tindex POSTINCREMENT_EXPR
1217 @tindex FIX_TRUNC_EXPR
1218 @tindex FLOAT_EXPR
1219 @tindex COMPLEX_EXPR
1220 @tindex CONJ_EXPR
1221 @tindex REALPART_EXPR
1222 @tindex IMAGPART_EXPR
1223 @tindex NON_LVALUE_EXPR
1224 @tindex NOP_EXPR
1225 @tindex CONVERT_EXPR
1226 @tindex FIXED_CONVERT_EXPR
1227 @tindex THROW_EXPR
1228 @tindex LSHIFT_EXPR
1229 @tindex RSHIFT_EXPR
1230 @tindex BIT_IOR_EXPR
1231 @tindex BIT_XOR_EXPR
1232 @tindex BIT_AND_EXPR
1233 @tindex TRUTH_ANDIF_EXPR
1234 @tindex TRUTH_ORIF_EXPR
1235 @tindex TRUTH_AND_EXPR
1236 @tindex TRUTH_OR_EXPR
1237 @tindex TRUTH_XOR_EXPR
1238 @tindex POINTER_PLUS_EXPR
1239 @tindex PLUS_EXPR
1240 @tindex MINUS_EXPR
1241 @tindex MULT_EXPR
1242 @tindex MULT_HIGHPART_EXPR
1243 @tindex RDIV_EXPR
1244 @tindex TRUNC_DIV_EXPR
1245 @tindex FLOOR_DIV_EXPR
1246 @tindex CEIL_DIV_EXPR
1247 @tindex ROUND_DIV_EXPR
1248 @tindex TRUNC_MOD_EXPR
1249 @tindex FLOOR_MOD_EXPR
1250 @tindex CEIL_MOD_EXPR
1251 @tindex ROUND_MOD_EXPR
1252 @tindex EXACT_DIV_EXPR
1253 @tindex LT_EXPR
1254 @tindex LE_EXPR
1255 @tindex GT_EXPR
1256 @tindex GE_EXPR
1257 @tindex EQ_EXPR
1258 @tindex NE_EXPR
1259 @tindex ORDERED_EXPR
1260 @tindex UNORDERED_EXPR
1261 @tindex UNLT_EXPR
1262 @tindex UNLE_EXPR
1263 @tindex UNGT_EXPR
1264 @tindex UNGE_EXPR
1265 @tindex UNEQ_EXPR
1266 @tindex LTGT_EXPR
1267 @tindex MODIFY_EXPR
1268 @tindex INIT_EXPR
1269 @tindex COMPOUND_EXPR
1270 @tindex COND_EXPR
1271 @tindex CALL_EXPR
1272 @tindex STMT_EXPR
1273 @tindex BIND_EXPR
1274 @tindex LOOP_EXPR
1275 @tindex EXIT_EXPR
1276 @tindex CLEANUP_POINT_EXPR
1277 @tindex CONSTRUCTOR
1278 @tindex COMPOUND_LITERAL_EXPR
1279 @tindex SAVE_EXPR
1280 @tindex TARGET_EXPR
1281 @tindex VA_ARG_EXPR
1282 @tindex ANNOTATE_EXPR
1284 @table @code
1285 @item NEGATE_EXPR
1286 These nodes represent unary negation of the single operand, for both
1287 integer and floating-point types.  The type of negation can be
1288 determined by looking at the type of the expression.
1290 The behavior of this operation on signed arithmetic overflow is
1291 controlled by the @code{flag_wrapv} and @code{flag_trapv} variables.
1293 @item ABS_EXPR
1294 These nodes represent the absolute value of the single operand, for
1295 both integer and floating-point types.  This is typically used to
1296 implement the @code{abs}, @code{labs} and @code{llabs} builtins for
1297 integer types, and the @code{fabs}, @code{fabsf} and @code{fabsl}
1298 builtins for floating point types.  The type of abs operation can
1299 be determined by looking at the type of the expression.
1301 This node is not used for complex types.  To represent the modulus
1302 or complex abs of a complex value, use the @code{BUILT_IN_CABS},
1303 @code{BUILT_IN_CABSF} or @code{BUILT_IN_CABSL} builtins, as used
1304 to implement the C99 @code{cabs}, @code{cabsf} and @code{cabsl}
1305 built-in functions.
1307 @item BIT_NOT_EXPR
1308 These nodes represent bitwise complement, and will always have integral
1309 type.  The only operand is the value to be complemented.
1311 @item TRUTH_NOT_EXPR
1312 These nodes represent logical negation, and will always have integral
1313 (or boolean) type.  The operand is the value being negated.  The type
1314 of the operand and that of the result are always of @code{BOOLEAN_TYPE}
1315 or @code{INTEGER_TYPE}.
1317 @item PREDECREMENT_EXPR
1318 @itemx PREINCREMENT_EXPR
1319 @itemx POSTDECREMENT_EXPR
1320 @itemx POSTINCREMENT_EXPR
1321 These nodes represent increment and decrement expressions.  The value of
1322 the single operand is computed, and the operand incremented or
1323 decremented.  In the case of @code{PREDECREMENT_EXPR} and
1324 @code{PREINCREMENT_EXPR}, the value of the expression is the value
1325 resulting after the increment or decrement; in the case of
1326 @code{POSTDECREMENT_EXPR} and @code{POSTINCREMENT_EXPR} is the value
1327 before the increment or decrement occurs.  The type of the operand, like
1328 that of the result, will be either integral, boolean, or floating-point.
1330 @item FIX_TRUNC_EXPR
1331 These nodes represent conversion of a floating-point value to an
1332 integer.  The single operand will have a floating-point type, while
1333 the complete expression will have an integral (or boolean) type.  The
1334 operand is rounded towards zero.
1336 @item FLOAT_EXPR
1337 These nodes represent conversion of an integral (or boolean) value to a
1338 floating-point value.  The single operand will have integral type, while
1339 the complete expression will have a floating-point type.
1341 FIXME: How is the operand supposed to be rounded?  Is this dependent on
1342 @option{-mieee}?
1344 @item COMPLEX_EXPR
1345 These nodes are used to represent complex numbers constructed from two
1346 expressions of the same (integer or real) type.  The first operand is the
1347 real part and the second operand is the imaginary part.
1349 @item CONJ_EXPR
1350 These nodes represent the conjugate of their operand.
1352 @item REALPART_EXPR
1353 @itemx IMAGPART_EXPR
1354 These nodes represent respectively the real and the imaginary parts
1355 of complex numbers (their sole argument).
1357 @item NON_LVALUE_EXPR
1358 These nodes indicate that their one and only operand is not an lvalue.
1359 A back end can treat these identically to the single operand.
1361 @item NOP_EXPR
1362 These nodes are used to represent conversions that do not require any
1363 code-generation.  For example, conversion of a @code{char*} to an
1364 @code{int*} does not require any code be generated; such a conversion is
1365 represented by a @code{NOP_EXPR}.  The single operand is the expression
1366 to be converted.  The conversion from a pointer to a reference is also
1367 represented with a @code{NOP_EXPR}.
1369 @item CONVERT_EXPR
1370 These nodes are similar to @code{NOP_EXPR}s, but are used in those
1371 situations where code may need to be generated.  For example, if an
1372 @code{int*} is converted to an @code{int} code may need to be generated
1373 on some platforms.  These nodes are never used for C++-specific
1374 conversions, like conversions between pointers to different classes in
1375 an inheritance hierarchy.  Any adjustments that need to be made in such
1376 cases are always indicated explicitly.  Similarly, a user-defined
1377 conversion is never represented by a @code{CONVERT_EXPR}; instead, the
1378 function calls are made explicit.
1380 @item FIXED_CONVERT_EXPR
1381 These nodes are used to represent conversions that involve fixed-point
1382 values.  For example, from a fixed-point value to another fixed-point value,
1383 from an integer to a fixed-point value, from a fixed-point value to an
1384 integer, from a floating-point value to a fixed-point value, or from
1385 a fixed-point value to a floating-point value.
1387 @item LSHIFT_EXPR
1388 @itemx RSHIFT_EXPR
1389 These nodes represent left and right shifts, respectively.  The first
1390 operand is the value to shift; it will always be of integral type.  The
1391 second operand is an expression for the number of bits by which to
1392 shift.  Right shift should be treated as arithmetic, i.e., the
1393 high-order bits should be zero-filled when the expression has unsigned
1394 type and filled with the sign bit when the expression has signed type.
1395 Note that the result is undefined if the second operand is larger
1396 than or equal to the first operand's type size. Unlike most nodes, these
1397 can have a vector as first operand and a scalar as second operand.
1400 @item BIT_IOR_EXPR
1401 @itemx BIT_XOR_EXPR
1402 @itemx BIT_AND_EXPR
1403 These nodes represent bitwise inclusive or, bitwise exclusive or, and
1404 bitwise and, respectively.  Both operands will always have integral
1405 type.
1407 @item TRUTH_ANDIF_EXPR
1408 @itemx TRUTH_ORIF_EXPR
1409 These nodes represent logical ``and'' and logical ``or'', respectively.
1410 These operators are not strict; i.e., the second operand is evaluated
1411 only if the value of the expression is not determined by evaluation of
1412 the first operand.  The type of the operands and that of the result are
1413 always of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
1415 @item TRUTH_AND_EXPR
1416 @itemx TRUTH_OR_EXPR
1417 @itemx TRUTH_XOR_EXPR
1418 These nodes represent logical and, logical or, and logical exclusive or.
1419 They are strict; both arguments are always evaluated.  There are no
1420 corresponding operators in C or C++, but the front end will sometimes
1421 generate these expressions anyhow, if it can tell that strictness does
1422 not matter.  The type of the operands and that of the result are
1423 always of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
1425 @item POINTER_PLUS_EXPR
1426 This node represents pointer arithmetic.  The first operand is always
1427 a pointer/reference type.  The second operand is always an unsigned
1428 integer type compatible with sizetype.  This is the only binary
1429 arithmetic operand that can operate on pointer types.
1431 @item PLUS_EXPR
1432 @itemx MINUS_EXPR
1433 @itemx MULT_EXPR
1434 These nodes represent various binary arithmetic operations.
1435 Respectively, these operations are addition, subtraction (of the second
1436 operand from the first) and multiplication.  Their operands may have
1437 either integral or floating type, but there will never be case in which
1438 one operand is of floating type and the other is of integral type.
1440 The behavior of these operations on signed arithmetic overflow is
1441 controlled by the @code{flag_wrapv} and @code{flag_trapv} variables.
1443 @item MULT_HIGHPART_EXPR
1444 This node represents the ``high-part'' of a widening multiplication.
1445 For an integral type with @var{b} bits of precision, the result is
1446 the most significant @var{b} bits of the full @math{2@var{b}} product.
1448 @item RDIV_EXPR
1449 This node represents a floating point division operation.
1451 @item TRUNC_DIV_EXPR
1452 @itemx FLOOR_DIV_EXPR
1453 @itemx CEIL_DIV_EXPR
1454 @itemx ROUND_DIV_EXPR
1455 These nodes represent integer division operations that return an integer
1456 result.  @code{TRUNC_DIV_EXPR} rounds towards zero, @code{FLOOR_DIV_EXPR}
1457 rounds towards negative infinity, @code{CEIL_DIV_EXPR} rounds towards
1458 positive infinity and @code{ROUND_DIV_EXPR} rounds to the closest integer.
1459 Integer division in C and C++ is truncating, i.e.@: @code{TRUNC_DIV_EXPR}.
1461 The behavior of these operations on signed arithmetic overflow, when
1462 dividing the minimum signed integer by minus one, is controlled by the
1463 @code{flag_wrapv} and @code{flag_trapv} variables.
1465 @item TRUNC_MOD_EXPR
1466 @itemx FLOOR_MOD_EXPR
1467 @itemx CEIL_MOD_EXPR
1468 @itemx ROUND_MOD_EXPR
1469 These nodes represent the integer remainder or modulus operation.
1470 The integer modulus of two operands @code{a} and @code{b} is
1471 defined as @code{a - (a/b)*b} where the division calculated using
1472 the corresponding division operator.  Hence for @code{TRUNC_MOD_EXPR}
1473 this definition assumes division using truncation towards zero, i.e.@:
1474 @code{TRUNC_DIV_EXPR}.  Integer remainder in C and C++ uses truncating
1475 division, i.e.@: @code{TRUNC_MOD_EXPR}.
1477 @item EXACT_DIV_EXPR
1478 The @code{EXACT_DIV_EXPR} code is used to represent integer divisions where
1479 the numerator is known to be an exact multiple of the denominator.  This
1480 allows the backend to choose between the faster of @code{TRUNC_DIV_EXPR},
1481 @code{CEIL_DIV_EXPR} and @code{FLOOR_DIV_EXPR} for the current target.
1483 @item LT_EXPR
1484 @itemx LE_EXPR
1485 @itemx GT_EXPR
1486 @itemx GE_EXPR
1487 @itemx EQ_EXPR
1488 @itemx NE_EXPR
1489 These nodes represent the less than, less than or equal to, greater
1490 than, greater than or equal to, equal, and not equal comparison
1491 operators.  The first and second operands will either be both of integral
1492 type, both of floating type or both of vector type.  The result type of
1493 these expressions will always be of integral, boolean or signed integral
1494 vector type.  These operations return the result type's zero value for
1495 false, the result type's one value for true, and a vector whose elements
1496 are zero (false) or minus one (true) for vectors.
1498 For floating point comparisons, if we honor IEEE NaNs and either operand
1499 is NaN, then @code{NE_EXPR} always returns true and the remaining operators
1500 always return false.  On some targets, comparisons against an IEEE NaN,
1501 other than equality and inequality, may generate a floating point exception.
1503 @item ORDERED_EXPR
1504 @itemx UNORDERED_EXPR
1505 These nodes represent non-trapping ordered and unordered comparison
1506 operators.  These operations take two floating point operands and
1507 determine whether they are ordered or unordered relative to each other.
1508 If either operand is an IEEE NaN, their comparison is defined to be
1509 unordered, otherwise the comparison is defined to be ordered.  The
1510 result type of these expressions will always be of integral or boolean
1511 type.  These operations return the result type's zero value for false,
1512 and the result type's one value for true.
1514 @item UNLT_EXPR
1515 @itemx UNLE_EXPR
1516 @itemx UNGT_EXPR
1517 @itemx UNGE_EXPR
1518 @itemx UNEQ_EXPR
1519 @itemx LTGT_EXPR
1520 These nodes represent the unordered comparison operators.
1521 These operations take two floating point operands and determine whether
1522 the operands are unordered or are less than, less than or equal to,
1523 greater than, greater than or equal to, or equal respectively.  For
1524 example, @code{UNLT_EXPR} returns true if either operand is an IEEE
1525 NaN or the first operand is less than the second.  With the possible
1526 exception of @code{LTGT_EXPR}, all of these operations are guaranteed
1527 not to generate a floating point exception.  The result
1528 type of these expressions will always be of integral or boolean type.
1529 These operations return the result type's zero value for false,
1530 and the result type's one value for true.
1532 @item MODIFY_EXPR
1533 These nodes represent assignment.  The left-hand side is the first
1534 operand; the right-hand side is the second operand.  The left-hand side
1535 will be a @code{VAR_DECL}, @code{INDIRECT_REF}, @code{COMPONENT_REF}, or
1536 other lvalue.
1538 These nodes are used to represent not only assignment with @samp{=} but
1539 also compound assignments (like @samp{+=}), by reduction to @samp{=}
1540 assignment.  In other words, the representation for @samp{i += 3} looks
1541 just like that for @samp{i = i + 3}.
1543 @item INIT_EXPR
1544 These nodes are just like @code{MODIFY_EXPR}, but are used only when a
1545 variable is initialized, rather than assigned to subsequently.  This
1546 means that we can assume that the target of the initialization is not
1547 used in computing its own value; any reference to the lhs in computing
1548 the rhs is undefined.
1550 @item COMPOUND_EXPR
1551 These nodes represent comma-expressions.  The first operand is an
1552 expression whose value is computed and thrown away prior to the
1553 evaluation of the second operand.  The value of the entire expression is
1554 the value of the second operand.
1556 @item COND_EXPR
1557 These nodes represent @code{?:} expressions.  The first operand
1558 is of boolean or integral type.  If it evaluates to a nonzero value,
1559 the second operand should be evaluated, and returned as the value of the
1560 expression.  Otherwise, the third operand is evaluated, and returned as
1561 the value of the expression.
1563 The second operand must have the same type as the entire expression,
1564 unless it unconditionally throws an exception or calls a noreturn
1565 function, in which case it should have void type.  The same constraints
1566 apply to the third operand.  This allows array bounds checks to be
1567 represented conveniently as @code{(i >= 0 && i < 10) ? i : abort()}.
1569 As a GNU extension, the C language front-ends allow the second
1570 operand of the @code{?:} operator may be omitted in the source.
1571 For example, @code{x ? : 3} is equivalent to @code{x ? x : 3},
1572 assuming that @code{x} is an expression without side-effects.
1573 In the tree representation, however, the second operand is always
1574 present, possibly protected by @code{SAVE_EXPR} if the first
1575 argument does cause side-effects.
1577 @item CALL_EXPR
1578 These nodes are used to represent calls to functions, including
1579 non-static member functions.  @code{CALL_EXPR}s are implemented as
1580 expression nodes with a variable number of operands.  Rather than using
1581 @code{TREE_OPERAND} to extract them, it is preferable to use the
1582 specialized accessor macros and functions that operate specifically on
1583 @code{CALL_EXPR} nodes.
1585 @code{CALL_EXPR_FN} returns a pointer to the
1586 function to call; it is always an expression whose type is a
1587 @code{POINTER_TYPE}.
1589 The number of arguments to the call is returned by @code{call_expr_nargs},
1590 while the arguments themselves can be accessed with the @code{CALL_EXPR_ARG}
1591 macro.  The arguments are zero-indexed and numbered left-to-right.
1592 You can iterate over the arguments using @code{FOR_EACH_CALL_EXPR_ARG}, as in:
1594 @smallexample
1595 tree call, arg;
1596 call_expr_arg_iterator iter;
1597 FOR_EACH_CALL_EXPR_ARG (arg, iter, call)
1598   /* arg is bound to successive arguments of call.  */
1599   @dots{};
1600 @end smallexample
1602 For non-static
1603 member functions, there will be an operand corresponding to the
1604 @code{this} pointer.  There will always be expressions corresponding to
1605 all of the arguments, even if the function is declared with default
1606 arguments and some arguments are not explicitly provided at the call
1607 sites.
1609 @code{CALL_EXPR}s also have a @code{CALL_EXPR_STATIC_CHAIN} operand that
1610 is used to implement nested functions.  This operand is otherwise null.
1612 @item CLEANUP_POINT_EXPR
1613 These nodes represent full-expressions.  The single operand is an
1614 expression to evaluate.  Any destructor calls engendered by the creation
1615 of temporaries during the evaluation of that expression should be
1616 performed immediately after the expression is evaluated.
1618 @item CONSTRUCTOR
1619 These nodes represent the brace-enclosed initializers for a structure or an
1620 array.  They contain a sequence of component values made out of a vector of
1621 constructor_elt, which is a (@code{INDEX}, @code{VALUE}) pair.
1623 If the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is a @code{RECORD_TYPE},
1624 @code{UNION_TYPE} or @code{QUAL_UNION_TYPE} then the @code{INDEX} of each
1625 node in the sequence will be a @code{FIELD_DECL} and the @code{VALUE} will
1626 be the expression used to initialize that field.
1628 If the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is an @code{ARRAY_TYPE},
1629 then the @code{INDEX} of each node in the sequence will be an
1630 @code{INTEGER_CST} or a @code{RANGE_EXPR} of two @code{INTEGER_CST}s.
1631 A single @code{INTEGER_CST} indicates which element of the array is being
1632 assigned to.  A @code{RANGE_EXPR} indicates an inclusive range of elements
1633 to initialize.  In both cases the @code{VALUE} is the corresponding
1634 initializer.  It is re-evaluated for each element of a
1635 @code{RANGE_EXPR}.  If the @code{INDEX} is @code{NULL_TREE}, then
1636 the initializer is for the next available array element.
1638 In the front end, you should not depend on the fields appearing in any
1639 particular order.  However, in the middle end, fields must appear in
1640 declaration order.  You should not assume that all fields will be
1641 represented.  Unrepresented fields will be cleared (zeroed), unless the
1642 CONSTRUCTOR_NO_CLEARING flag is set, in which case their value becomes
1643 undefined.
1645 @item COMPOUND_LITERAL_EXPR
1646 @findex COMPOUND_LITERAL_EXPR_DECL_EXPR
1647 @findex COMPOUND_LITERAL_EXPR_DECL
1648 These nodes represent ISO C99 compound literals.  The
1649 @code{COMPOUND_LITERAL_EXPR_DECL_EXPR} is a @code{DECL_EXPR}
1650 containing an anonymous @code{VAR_DECL} for
1651 the unnamed object represented by the compound literal; the
1652 @code{DECL_INITIAL} of that @code{VAR_DECL} is a @code{CONSTRUCTOR}
1653 representing the brace-enclosed list of initializers in the compound
1654 literal.  That anonymous @code{VAR_DECL} can also be accessed directly
1655 by the @code{COMPOUND_LITERAL_EXPR_DECL} macro.
1657 @item SAVE_EXPR
1659 A @code{SAVE_EXPR} represents an expression (possibly involving
1660 side-effects) that is used more than once.  The side-effects should
1661 occur only the first time the expression is evaluated.  Subsequent uses
1662 should just reuse the computed value.  The first operand to the
1663 @code{SAVE_EXPR} is the expression to evaluate.  The side-effects should
1664 be executed where the @code{SAVE_EXPR} is first encountered in a
1665 depth-first preorder traversal of the expression tree.
1667 @item TARGET_EXPR
1668 A @code{TARGET_EXPR} represents a temporary object.  The first operand
1669 is a @code{VAR_DECL} for the temporary variable.  The second operand is
1670 the initializer for the temporary.  The initializer is evaluated and,
1671 if non-void, copied (bitwise) into the temporary.  If the initializer
1672 is void, that means that it will perform the initialization itself.
1674 Often, a @code{TARGET_EXPR} occurs on the right-hand side of an
1675 assignment, or as the second operand to a comma-expression which is
1676 itself the right-hand side of an assignment, etc.  In this case, we say
1677 that the @code{TARGET_EXPR} is ``normal''; otherwise, we say it is
1678 ``orphaned''.  For a normal @code{TARGET_EXPR} the temporary variable
1679 should be treated as an alias for the left-hand side of the assignment,
1680 rather than as a new temporary variable.
1682 The third operand to the @code{TARGET_EXPR}, if present, is a
1683 cleanup-expression (i.e., destructor call) for the temporary.  If this
1684 expression is orphaned, then this expression must be executed when the
1685 statement containing this expression is complete.  These cleanups must
1686 always be executed in the order opposite to that in which they were
1687 encountered.  Note that if a temporary is created on one branch of a
1688 conditional operator (i.e., in the second or third operand to a
1689 @code{COND_EXPR}), the cleanup must be run only if that branch is
1690 actually executed.
1692 @item VA_ARG_EXPR
1693 This node is used to implement support for the C/C++ variable argument-list
1694 mechanism.  It represents expressions like @code{va_arg (ap, type)}.
1695 Its @code{TREE_TYPE} yields the tree representation for @code{type} and
1696 its sole argument yields the representation for @code{ap}.
1698 @item ANNOTATE_EXPR
1699 This node is used to attach markers to an expression. The first operand
1700 is the annotated expression, the second is an @code{INTEGER_CST} with
1701 a value from @code{enum annot_expr_kind}.
1702 @end table
1705 @node Vectors
1706 @subsection Vectors
1707 @tindex VEC_LSHIFT_EXPR
1708 @tindex VEC_RSHIFT_EXPR
1709 @tindex VEC_WIDEN_MULT_HI_EXPR
1710 @tindex VEC_WIDEN_MULT_LO_EXPR
1711 @tindex VEC_UNPACK_HI_EXPR
1712 @tindex VEC_UNPACK_LO_EXPR
1713 @tindex VEC_UNPACK_FLOAT_HI_EXPR
1714 @tindex VEC_UNPACK_FLOAT_LO_EXPR
1715 @tindex VEC_PACK_TRUNC_EXPR
1716 @tindex VEC_PACK_SAT_EXPR
1717 @tindex VEC_PACK_FIX_TRUNC_EXPR
1719 @table @code
1720 @item VEC_LSHIFT_EXPR
1721 @itemx VEC_RSHIFT_EXPR
1722 These nodes represent whole vector left and right shifts, respectively.
1723 The first operand is the vector to shift; it will always be of vector type.
1724 The second operand is an expression for the number of bits by which to
1725 shift.  Note that the result is undefined if the second operand is larger
1726 than or equal to the first operand's type size.
1728 @item VEC_WIDEN_MULT_HI_EXPR
1729 @itemx VEC_WIDEN_MULT_LO_EXPR
1730 These nodes represent widening vector multiplication of the high and low
1731 parts of the two input vectors, respectively.  Their operands are vectors
1732 that contain the same number of elements (@code{N}) of the same integral type.
1733 The result is a vector that contains half as many elements, of an integral type
1734 whose size is twice as wide.  In the case of @code{VEC_WIDEN_MULT_HI_EXPR} the
1735 high @code{N/2} elements of the two vector are multiplied to produce the
1736 vector of @code{N/2} products. In the case of @code{VEC_WIDEN_MULT_LO_EXPR} the
1737 low @code{N/2} elements of the two vector are multiplied to produce the
1738 vector of @code{N/2} products.
1740 @item VEC_UNPACK_HI_EXPR
1741 @itemx VEC_UNPACK_LO_EXPR
1742 These nodes represent unpacking of the high and low parts of the input vector,
1743 respectively.  The single operand is a vector that contains @code{N} elements
1744 of the same integral or floating point type.  The result is a vector
1745 that contains half as many elements, of an integral or floating point type
1746 whose size is twice as wide.  In the case of @code{VEC_UNPACK_HI_EXPR} the
1747 high @code{N/2} elements of the vector are extracted and widened (promoted).
1748 In the case of @code{VEC_UNPACK_LO_EXPR} the low @code{N/2} elements of the
1749 vector are extracted and widened (promoted).
1751 @item VEC_UNPACK_FLOAT_HI_EXPR
1752 @itemx VEC_UNPACK_FLOAT_LO_EXPR
1753 These nodes represent unpacking of the high and low parts of the input vector,
1754 where the values are converted from fixed point to floating point.  The
1755 single operand is a vector that contains @code{N} elements of the same
1756 integral type.  The result is a vector that contains half as many elements
1757 of a floating point type whose size is twice as wide.  In the case of
1758 @code{VEC_UNPACK_HI_EXPR} the high @code{N/2} elements of the vector are
1759 extracted, converted and widened.  In the case of @code{VEC_UNPACK_LO_EXPR}
1760 the low @code{N/2} elements of the vector are extracted, converted and widened.
1762 @item VEC_PACK_TRUNC_EXPR
1763 This node represents packing of truncated elements of the two input vectors
1764 into the output vector.  Input operands are vectors that contain the same
1765 number of elements of the same integral or floating point type.  The result
1766 is a vector that contains twice as many elements of an integral or floating
1767 point type whose size is half as wide. The elements of the two vectors are
1768 demoted and merged (concatenated) to form the output vector.
1770 @item VEC_PACK_SAT_EXPR
1771 This node represents packing of elements of the two input vectors into the
1772 output vector using saturation.  Input operands are vectors that contain
1773 the same number of elements of the same integral type.  The result is a
1774 vector that contains twice as many elements of an integral type whose size
1775 is half as wide.  The elements of the two vectors are demoted and merged
1776 (concatenated) to form the output vector.
1778 @item VEC_PACK_FIX_TRUNC_EXPR
1779 This node represents packing of elements of the two input vectors into the
1780 output vector, where the values are converted from floating point
1781 to fixed point.  Input operands are vectors that contain the same number
1782 of elements of a floating point type.  The result is a vector that contains
1783 twice as many elements of an integral type whose size is half as wide.  The
1784 elements of the two vectors are merged (concatenated) to form the output
1785 vector.
1787 @item VEC_COND_EXPR
1788 These nodes represent @code{?:} expressions.  The three operands must be
1789 vectors of the same size and number of elements.  The second and third
1790 operands must have the same type as the entire expression.  The first
1791 operand is of signed integral vector type.  If an element of the first
1792 operand evaluates to a zero value, the corresponding element of the
1793 result is taken from the third operand. If it evaluates to a minus one
1794 value, it is taken from the second operand. It should never evaluate to
1795 any other value currently, but optimizations should not rely on that
1796 property. In contrast with a @code{COND_EXPR}, all operands are always
1797 evaluated.
1798 @end table
1801 @c ---------------------------------------------------------------------
1802 @c Statements
1803 @c ---------------------------------------------------------------------
1805 @node Statements
1806 @section Statements
1807 @cindex Statements
1809 Most statements in GIMPLE are assignment statements, represented by
1810 @code{GIMPLE_ASSIGN}.  No other C expressions can appear at statement level;
1811 a reference to a volatile object is converted into a
1812 @code{GIMPLE_ASSIGN}.
1814 There are also several varieties of complex statements.
1816 @menu
1817 * Basic Statements::
1818 * Blocks::
1819 * Statement Sequences::
1820 * Empty Statements::
1821 * Jumps::
1822 * Cleanups::
1823 * OpenMP::
1824 @end menu
1826 @node Basic Statements
1827 @subsection Basic Statements
1828 @cindex Basic Statements
1830 @table @code
1831 @item ASM_EXPR
1833 Used to represent an inline assembly statement.  For an inline assembly
1834 statement like:
1835 @smallexample
1836 asm ("mov x, y");
1837 @end smallexample
1838 The @code{ASM_STRING} macro will return a @code{STRING_CST} node for
1839 @code{"mov x, y"}.  If the original statement made use of the
1840 extended-assembly syntax, then @code{ASM_OUTPUTS},
1841 @code{ASM_INPUTS}, and @code{ASM_CLOBBERS} will be the outputs, inputs,
1842 and clobbers for the statement, represented as @code{STRING_CST} nodes.
1843 The extended-assembly syntax looks like:
1844 @smallexample
1845 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
1846 @end smallexample
1847 The first string is the @code{ASM_STRING}, containing the instruction
1848 template.  The next two strings are the output and inputs, respectively;
1849 this statement has no clobbers.  As this example indicates, ``plain''
1850 assembly statements are merely a special case of extended assembly
1851 statements; they have no cv-qualifiers, outputs, inputs, or clobbers.
1852 All of the strings will be @code{NUL}-terminated, and will contain no
1853 embedded @code{NUL}-characters.
1855 If the assembly statement is declared @code{volatile}, or if the
1856 statement was not an extended assembly statement, and is therefore
1857 implicitly volatile, then the predicate @code{ASM_VOLATILE_P} will hold
1858 of the @code{ASM_EXPR}.
1860 @item DECL_EXPR
1862 Used to represent a local declaration.  The @code{DECL_EXPR_DECL} macro
1863 can be used to obtain the entity declared.  This declaration may be a
1864 @code{LABEL_DECL}, indicating that the label declared is a local label.
1865 (As an extension, GCC allows the declaration of labels with scope.)  In
1866 C, this declaration may be a @code{FUNCTION_DECL}, indicating the
1867 use of the GCC nested function extension.  For more information,
1868 @pxref{Functions}.
1870 @item LABEL_EXPR
1872 Used to represent a label.  The @code{LABEL_DECL} declared by this
1873 statement can be obtained with the @code{LABEL_EXPR_LABEL} macro.  The
1874 @code{IDENTIFIER_NODE} giving the name of the label can be obtained from
1875 the @code{LABEL_DECL} with @code{DECL_NAME}.
1877 @item GOTO_EXPR
1879 Used to represent a @code{goto} statement.  The @code{GOTO_DESTINATION} will
1880 usually be a @code{LABEL_DECL}.  However, if the ``computed goto'' extension
1881 has been used, the @code{GOTO_DESTINATION} will be an arbitrary expression
1882 indicating the destination.  This expression will always have pointer type.
1884 @item RETURN_EXPR
1886 Used to represent a @code{return} statement.  Operand 0 represents the
1887 value to return.  It should either be the @code{RESULT_DECL} for the
1888 containing function, or a @code{MODIFY_EXPR} or @code{INIT_EXPR}
1889 setting the function's @code{RESULT_DECL}.  It will be
1890 @code{NULL_TREE} if the statement was just
1891 @smallexample
1892 return;
1893 @end smallexample
1895 @item LOOP_EXPR
1896 These nodes represent ``infinite'' loops.  The @code{LOOP_EXPR_BODY}
1897 represents the body of the loop.  It should be executed forever, unless
1898 an @code{EXIT_EXPR} is encountered.
1900 @item EXIT_EXPR
1901 These nodes represent conditional exits from the nearest enclosing
1902 @code{LOOP_EXPR}.  The single operand is the condition; if it is
1903 nonzero, then the loop should be exited.  An @code{EXIT_EXPR} will only
1904 appear within a @code{LOOP_EXPR}.
1906 @item SWITCH_STMT
1908 Used to represent a @code{switch} statement.  The @code{SWITCH_STMT_COND}
1909 is the expression on which the switch is occurring.  See the documentation
1910 for an @code{IF_STMT} for more information on the representation used
1911 for the condition.  The @code{SWITCH_STMT_BODY} is the body of the switch
1912 statement.   The @code{SWITCH_STMT_TYPE} is the original type of switch
1913 expression as given in the source, before any compiler conversions.
1915 @item CASE_LABEL_EXPR
1917 Use to represent a @code{case} label, range of @code{case} labels, or a
1918 @code{default} label.  If @code{CASE_LOW} is @code{NULL_TREE}, then this is a
1919 @code{default} label.  Otherwise, if @code{CASE_HIGH} is @code{NULL_TREE}, then
1920 this is an ordinary @code{case} label.  In this case, @code{CASE_LOW} is
1921 an expression giving the value of the label.  Both @code{CASE_LOW} and
1922 @code{CASE_HIGH} are @code{INTEGER_CST} nodes.  These values will have
1923 the same type as the condition expression in the switch statement.
1925 Otherwise, if both @code{CASE_LOW} and @code{CASE_HIGH} are defined, the
1926 statement is a range of case labels.  Such statements originate with the
1927 extension that allows users to write things of the form:
1928 @smallexample
1929 case 2 ... 5:
1930 @end smallexample
1931 The first value will be @code{CASE_LOW}, while the second will be
1932 @code{CASE_HIGH}.
1934 @end table
1937 @node Blocks
1938 @subsection Blocks
1939 @cindex Blocks
1941 Block scopes and the variables they declare in GENERIC are
1942 expressed using the @code{BIND_EXPR} code, which in previous
1943 versions of GCC was primarily used for the C statement-expression
1944 extension.
1946 Variables in a block are collected into @code{BIND_EXPR_VARS} in
1947 declaration order through their @code{TREE_CHAIN} field.  Any runtime
1948 initialization is moved out of @code{DECL_INITIAL} and into a
1949 statement in the controlled block.  When gimplifying from C or C++,
1950 this initialization replaces the @code{DECL_STMT}.  These variables
1951 will never require cleanups.  The scope of these variables is just the
1952 body
1954 Variable-length arrays (VLAs) complicate this process, as their
1955 size often refers to variables initialized earlier in the block.
1956 To handle this, we currently split the block at that point, and
1957 move the VLA into a new, inner @code{BIND_EXPR}.  This strategy
1958 may change in the future.
1960 A C++ program will usually contain more @code{BIND_EXPR}s than
1961 there are syntactic blocks in the source code, since several C++
1962 constructs have implicit scopes associated with them.  On the
1963 other hand, although the C++ front end uses pseudo-scopes to
1964 handle cleanups for objects with destructors, these don't
1965 translate into the GIMPLE form; multiple declarations at the same
1966 level use the same @code{BIND_EXPR}.
1968 @node Statement Sequences
1969 @subsection Statement Sequences
1970 @cindex Statement Sequences
1972 Multiple statements at the same nesting level are collected into
1973 a @code{STATEMENT_LIST}.  Statement lists are modified and
1974 traversed using the interface in @samp{tree-iterator.h}.
1976 @node Empty Statements
1977 @subsection Empty Statements
1978 @cindex Empty Statements
1980 Whenever possible, statements with no effect are discarded.  But
1981 if they are nested within another construct which cannot be
1982 discarded for some reason, they are instead replaced with an
1983 empty statement, generated by @code{build_empty_stmt}.
1984 Initially, all empty statements were shared, after the pattern of
1985 the Java front end, but this caused a lot of trouble in practice.
1987 An empty statement is represented as @code{(void)0}.
1989 @node Jumps
1990 @subsection Jumps
1991 @cindex Jumps
1993 Other jumps are expressed by either @code{GOTO_EXPR} or
1994 @code{RETURN_EXPR}.
1996 The operand of a @code{GOTO_EXPR} must be either a label or a
1997 variable containing the address to jump to.
1999 The operand of a @code{RETURN_EXPR} is either @code{NULL_TREE},
2000 @code{RESULT_DECL}, or a @code{MODIFY_EXPR} which sets the return
2001 value.  It would be nice to move the @code{MODIFY_EXPR} into a
2002 separate statement, but the special return semantics in
2003 @code{expand_return} make that difficult.  It may still happen in
2004 the future, perhaps by moving most of that logic into
2005 @code{expand_assignment}.
2007 @node Cleanups
2008 @subsection Cleanups
2009 @cindex Cleanups
2011 Destructors for local C++ objects and similar dynamic cleanups are
2012 represented in GIMPLE by a @code{TRY_FINALLY_EXPR}.
2013 @code{TRY_FINALLY_EXPR} has two operands, both of which are a sequence
2014 of statements to execute.  The first sequence is executed.  When it
2015 completes the second sequence is executed.
2017 The first sequence may complete in the following ways:
2019 @enumerate
2021 @item Execute the last statement in the sequence and fall off the
2022 end.
2024 @item Execute a goto statement (@code{GOTO_EXPR}) to an ordinary
2025 label outside the sequence.
2027 @item Execute a return statement (@code{RETURN_EXPR}).
2029 @item Throw an exception.  This is currently not explicitly represented in
2030 GIMPLE.
2032 @end enumerate
2034 The second sequence is not executed if the first sequence completes by
2035 calling @code{setjmp} or @code{exit} or any other function that does
2036 not return.  The second sequence is also not executed if the first
2037 sequence completes via a non-local goto or a computed goto (in general
2038 the compiler does not know whether such a goto statement exits the
2039 first sequence or not, so we assume that it doesn't).
2041 After the second sequence is executed, if it completes normally by
2042 falling off the end, execution continues wherever the first sequence
2043 would have continued, by falling off the end, or doing a goto, etc.
2045 @code{TRY_FINALLY_EXPR} complicates the flow graph, since the cleanup
2046 needs to appear on every edge out of the controlled block; this
2047 reduces the freedom to move code across these edges.  Therefore, the
2048 EH lowering pass which runs before most of the optimization passes
2049 eliminates these expressions by explicitly adding the cleanup to each
2050 edge.  Rethrowing the exception is represented using @code{RESX_EXPR}.
2052 @node OpenMP
2053 @subsection OpenMP
2054 @tindex OMP_PARALLEL
2055 @tindex OMP_FOR
2056 @tindex OMP_SECTIONS
2057 @tindex OMP_SINGLE
2058 @tindex OMP_SECTION
2059 @tindex OMP_MASTER
2060 @tindex OMP_ORDERED
2061 @tindex OMP_CRITICAL
2062 @tindex OMP_RETURN
2063 @tindex OMP_CONTINUE
2064 @tindex OMP_ATOMIC
2065 @tindex OMP_CLAUSE
2067 All the statements starting with @code{OMP_} represent directives and
2068 clauses used by the OpenMP API @w{@uref{http://www.openmp.org/}}.
2070 @table @code
2071 @item OMP_PARALLEL
2073 Represents @code{#pragma omp parallel [clause1 @dots{} clauseN]}. It
2074 has four operands:
2076 Operand @code{OMP_PARALLEL_BODY} is valid while in GENERIC and
2077 High GIMPLE forms.  It contains the body of code to be executed
2078 by all the threads.  During GIMPLE lowering, this operand becomes
2079 @code{NULL} and the body is emitted linearly after
2080 @code{OMP_PARALLEL}.
2082 Operand @code{OMP_PARALLEL_CLAUSES} is the list of clauses
2083 associated with the directive.
2085 Operand @code{OMP_PARALLEL_FN} is created by
2086 @code{pass_lower_omp}, it contains the @code{FUNCTION_DECL}
2087 for the function that will contain the body of the parallel
2088 region.
2090 Operand @code{OMP_PARALLEL_DATA_ARG} is also created by
2091 @code{pass_lower_omp}. If there are shared variables to be
2092 communicated to the children threads, this operand will contain
2093 the @code{VAR_DECL} that contains all the shared values and
2094 variables.
2096 @item OMP_FOR
2098 Represents @code{#pragma omp for [clause1 @dots{} clauseN]}.  It
2099 has 5 operands:
2101 Operand @code{OMP_FOR_BODY} contains the loop body.
2103 Operand @code{OMP_FOR_CLAUSES} is the list of clauses
2104 associated with the directive.
2106 Operand @code{OMP_FOR_INIT} is the loop initialization code of
2107 the form @code{VAR = N1}.
2109 Operand @code{OMP_FOR_COND} is the loop conditional expression
2110 of the form @code{VAR @{<,>,<=,>=@} N2}.
2112 Operand @code{OMP_FOR_INCR} is the loop index increment of the
2113 form @code{VAR @{+=,-=@} INCR}.
2115 Operand @code{OMP_FOR_PRE_BODY} contains side-effect code from
2116 operands @code{OMP_FOR_INIT}, @code{OMP_FOR_COND} and
2117 @code{OMP_FOR_INC}.  These side-effects are part of the
2118 @code{OMP_FOR} block but must be evaluated before the start of
2119 loop body.
2121 The loop index variable @code{VAR} must be a signed integer variable,
2122 which is implicitly private to each thread.  Bounds
2123 @code{N1} and @code{N2} and the increment expression
2124 @code{INCR} are required to be loop invariant integer
2125 expressions that are evaluated without any synchronization. The
2126 evaluation order, frequency of evaluation and side-effects are
2127 unspecified by the standard.
2129 @item OMP_SECTIONS
2131 Represents @code{#pragma omp sections [clause1 @dots{} clauseN]}.
2133 Operand @code{OMP_SECTIONS_BODY} contains the sections body,
2134 which in turn contains a set of @code{OMP_SECTION} nodes for
2135 each of the concurrent sections delimited by @code{#pragma omp
2136 section}.
2138 Operand @code{OMP_SECTIONS_CLAUSES} is the list of clauses
2139 associated with the directive.
2141 @item OMP_SECTION
2143 Section delimiter for @code{OMP_SECTIONS}.
2145 @item OMP_SINGLE
2147 Represents @code{#pragma omp single}.
2149 Operand @code{OMP_SINGLE_BODY} contains the body of code to be
2150 executed by a single thread.
2152 Operand @code{OMP_SINGLE_CLAUSES} is the list of clauses
2153 associated with the directive.
2155 @item OMP_MASTER
2157 Represents @code{#pragma omp master}.
2159 Operand @code{OMP_MASTER_BODY} contains the body of code to be
2160 executed by the master thread.
2162 @item OMP_ORDERED
2164 Represents @code{#pragma omp ordered}.
2166 Operand @code{OMP_ORDERED_BODY} contains the body of code to be
2167 executed in the sequential order dictated by the loop index
2168 variable.
2170 @item OMP_CRITICAL
2172 Represents @code{#pragma omp critical [name]}.
2174 Operand @code{OMP_CRITICAL_BODY} is the critical section.
2176 Operand @code{OMP_CRITICAL_NAME} is an optional identifier to
2177 label the critical section.
2179 @item OMP_RETURN
2181 This does not represent any OpenMP directive, it is an artificial
2182 marker to indicate the end of the body of an OpenMP@. It is used
2183 by the flow graph (@code{tree-cfg.c}) and OpenMP region
2184 building code (@code{omp-low.c}).
2186 @item OMP_CONTINUE
2188 Similarly, this instruction does not represent an OpenMP
2189 directive, it is used by @code{OMP_FOR} and
2190 @code{OMP_SECTIONS} to mark the place where the code needs to
2191 loop to the next iteration (in the case of @code{OMP_FOR}) or
2192 the next section (in the case of @code{OMP_SECTIONS}).
2194 In some cases, @code{OMP_CONTINUE} is placed right before
2195 @code{OMP_RETURN}.  But if there are cleanups that need to
2196 occur right after the looping body, it will be emitted between
2197 @code{OMP_CONTINUE} and @code{OMP_RETURN}.
2199 @item OMP_ATOMIC
2201 Represents @code{#pragma omp atomic}.
2203 Operand 0 is the address at which the atomic operation is to be
2204 performed.
2206 Operand 1 is the expression to evaluate.  The gimplifier tries
2207 three alternative code generation strategies.  Whenever possible,
2208 an atomic update built-in is used.  If that fails, a
2209 compare-and-swap loop is attempted.  If that also fails, a
2210 regular critical section around the expression is used.
2212 @item OMP_CLAUSE
2214 Represents clauses associated with one of the @code{OMP_} directives.
2215 Clauses are represented by separate subcodes defined in
2216 @file{tree.h}.  Clauses codes can be one of:
2217 @code{OMP_CLAUSE_PRIVATE}, @code{OMP_CLAUSE_SHARED},
2218 @code{OMP_CLAUSE_FIRSTPRIVATE},
2219 @code{OMP_CLAUSE_LASTPRIVATE}, @code{OMP_CLAUSE_COPYIN},
2220 @code{OMP_CLAUSE_COPYPRIVATE}, @code{OMP_CLAUSE_IF},
2221 @code{OMP_CLAUSE_NUM_THREADS}, @code{OMP_CLAUSE_SCHEDULE},
2222 @code{OMP_CLAUSE_NOWAIT}, @code{OMP_CLAUSE_ORDERED},
2223 @code{OMP_CLAUSE_DEFAULT}, @code{OMP_CLAUSE_REDUCTION},
2224 @code{OMP_CLAUSE_COLLAPSE}, @code{OMP_CLAUSE_UNTIED},
2225 @code{OMP_CLAUSE_FINAL}, and @code{OMP_CLAUSE_MERGEABLE}.  Each code
2226 represents the corresponding OpenMP clause.
2228 Clauses associated with the same directive are chained together
2229 via @code{OMP_CLAUSE_CHAIN}. Those clauses that accept a list
2230 of variables are restricted to exactly one, accessed with
2231 @code{OMP_CLAUSE_VAR}.  Therefore, multiple variables under the
2232 same clause @code{C} need to be represented as multiple @code{C} clauses
2233 chained together.  This facilitates adding new clauses during
2234 compilation.
2236 @end table
2238 @c ---------------------------------------------------------------------
2239 @c Functions
2240 @c ---------------------------------------------------------------------
2242 @node Functions
2243 @section Functions
2244 @cindex function
2245 @tindex FUNCTION_DECL
2247 A function is represented by a @code{FUNCTION_DECL} node.  It stores
2248 the basic pieces of the function such as body, parameters, and return
2249 type as well as information on the surrounding context, visibility,
2250 and linkage.
2252 @menu
2253 * Function Basics::     Function names, body, and parameters.
2254 * Function Properties:: Context, linkage, etc.
2255 @end menu
2257 @c ---------------------------------------------------------------------
2258 @c Function Basics
2259 @c ---------------------------------------------------------------------
2261 @node Function Basics
2262 @subsection Function Basics
2263 @findex DECL_NAME
2264 @findex DECL_ASSEMBLER_NAME
2265 @findex TREE_PUBLIC
2266 @findex DECL_ARTIFICIAL
2267 @findex DECL_FUNCTION_SPECIFIC_TARGET
2268 @findex DECL_FUNCTION_SPECIFIC_OPTIMIZATION
2270 A function has four core parts: the name, the parameters, the result,
2271 and the body.  The following macros and functions access these parts
2272 of a @code{FUNCTION_DECL} as well as other basic features:
2273 @ftable @code
2274 @item DECL_NAME
2275 This macro returns the unqualified name of the function, as an
2276 @code{IDENTIFIER_NODE}.  For an instantiation of a function template,
2277 the @code{DECL_NAME} is the unqualified name of the template, not
2278 something like @code{f<int>}.  The value of @code{DECL_NAME} is
2279 undefined when used on a constructor, destructor, overloaded operator,
2280 or type-conversion operator, or any function that is implicitly
2281 generated by the compiler.  See below for macros that can be used to
2282 distinguish these cases.
2284 @item DECL_ASSEMBLER_NAME
2285 This macro returns the mangled name of the function, also an
2286 @code{IDENTIFIER_NODE}.  This name does not contain leading underscores
2287 on systems that prefix all identifiers with underscores.  The mangled
2288 name is computed in the same way on all platforms; if special processing
2289 is required to deal with the object file format used on a particular
2290 platform, it is the responsibility of the back end to perform those
2291 modifications.  (Of course, the back end should not modify
2292 @code{DECL_ASSEMBLER_NAME} itself.)
2294 Using @code{DECL_ASSEMBLER_NAME} will cause additional memory to be
2295 allocated (for the mangled name of the entity) so it should be used
2296 only when emitting assembly code.  It should not be used within the
2297 optimizers to determine whether or not two declarations are the same,
2298 even though some of the existing optimizers do use it in that way.
2299 These uses will be removed over time.
2301 @item DECL_ARGUMENTS
2302 This macro returns the @code{PARM_DECL} for the first argument to the
2303 function.  Subsequent @code{PARM_DECL} nodes can be obtained by
2304 following the @code{TREE_CHAIN} links.
2306 @item DECL_RESULT
2307 This macro returns the @code{RESULT_DECL} for the function.
2309 @item DECL_SAVED_TREE
2310 This macro returns the complete body of the function.
2312 @item TREE_TYPE
2313 This macro returns the @code{FUNCTION_TYPE} or @code{METHOD_TYPE} for
2314 the function.
2316 @item DECL_INITIAL
2317 A function that has a definition in the current translation unit will
2318 have a non-@code{NULL} @code{DECL_INITIAL}.  However, back ends should not make
2319 use of the particular value given by @code{DECL_INITIAL}.
2321 It should contain a tree of @code{BLOCK} nodes that mirrors the scopes
2322 that variables are bound in the function.  Each block contains a list
2323 of decls declared in a basic block, a pointer to a chain of blocks at
2324 the next lower scope level, then a pointer to the next block at the
2325 same level and a backpointer to the parent @code{BLOCK} or
2326 @code{FUNCTION_DECL}.  So given a function as follows:
2328 @smallexample
2329 void foo()
2331   int a;
2332   @{
2333     int b;
2334   @}
2335   int c;
2337 @end smallexample
2339 you would get the following:
2341 @smallexample
2342 tree foo = FUNCTION_DECL;
2343 tree decl_a = VAR_DECL;
2344 tree decl_b = VAR_DECL;
2345 tree decl_c = VAR_DECL;
2346 tree block_a = BLOCK;
2347 tree block_b = BLOCK;
2348 tree block_c = BLOCK;
2349 BLOCK_VARS(block_a) = decl_a;
2350 BLOCK_SUBBLOCKS(block_a) = block_b;
2351 BLOCK_CHAIN(block_a) = block_c;
2352 BLOCK_SUPERCONTEXT(block_a) = foo;
2353 BLOCK_VARS(block_b) = decl_b;
2354 BLOCK_SUPERCONTEXT(block_b) = block_a;
2355 BLOCK_VARS(block_c) = decl_c;
2356 BLOCK_SUPERCONTEXT(block_c) = foo;
2357 DECL_INITIAL(foo) = block_a;
2358 @end smallexample
2360 @end ftable
2362 @c ---------------------------------------------------------------------
2363 @c Function Properties
2364 @c ---------------------------------------------------------------------
2366 @node Function Properties
2367 @subsection Function Properties
2368 @cindex function properties
2369 @cindex statements
2371 To determine the scope of a function, you can use the
2372 @code{DECL_CONTEXT} macro.  This macro will return the class
2373 (either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a
2374 @code{NAMESPACE_DECL}) of which the function is a member.  For a virtual
2375 function, this macro returns the class in which the function was
2376 actually defined, not the base class in which the virtual declaration
2377 occurred.
2379 In C, the @code{DECL_CONTEXT} for a function maybe another function.
2380 This representation indicates that the GNU nested function extension
2381 is in use.  For details on the semantics of nested functions, see the
2382 GCC Manual.  The nested function can refer to local variables in its
2383 containing function.  Such references are not explicitly marked in the
2384 tree structure; back ends must look at the @code{DECL_CONTEXT} for the
2385 referenced @code{VAR_DECL}.  If the @code{DECL_CONTEXT} for the
2386 referenced @code{VAR_DECL} is not the same as the function currently
2387 being processed, and neither @code{DECL_EXTERNAL} nor
2388 @code{TREE_STATIC} hold, then the reference is to a local variable in
2389 a containing function, and the back end must take appropriate action.
2391 @ftable @code
2392 @item DECL_EXTERNAL
2393 This predicate holds if the function is undefined.
2395 @item TREE_PUBLIC
2396 This predicate holds if the function has external linkage.
2398 @item TREE_STATIC
2399 This predicate holds if the function has been defined.
2401 @item TREE_THIS_VOLATILE
2402 This predicate holds if the function does not return normally.
2404 @item TREE_READONLY
2405 This predicate holds if the function can only read its arguments.
2407 @item DECL_PURE_P
2408 This predicate holds if the function can only read its arguments, but
2409 may also read global memory.
2411 @item DECL_VIRTUAL_P
2412 This predicate holds if the function is virtual.
2414 @item DECL_ARTIFICIAL
2415 This macro holds if the function was implicitly generated by the
2416 compiler, rather than explicitly declared.  In addition to implicitly
2417 generated class member functions, this macro holds for the special
2418 functions created to implement static initialization and destruction, to
2419 compute run-time type information, and so forth.
2421 @item DECL_FUNCTION_SPECIFIC_TARGET
2422 This macro returns a tree node that holds the target options that are
2423 to be used to compile this particular function or @code{NULL_TREE} if
2424 the function is to be compiled with the target options specified on
2425 the command line.
2427 @item DECL_FUNCTION_SPECIFIC_OPTIMIZATION
2428 This macro returns a tree node that holds the optimization options
2429 that are to be used to compile this particular function or
2430 @code{NULL_TREE} if the function is to be compiled with the
2431 optimization options specified on the command line.
2433 @end ftable
2435 @c ---------------------------------------------------------------------
2436 @c Language-dependent trees
2437 @c ---------------------------------------------------------------------
2439 @node Language-dependent trees
2440 @section Language-dependent trees
2441 @cindex language-dependent trees
2443 Front ends may wish to keep some state associated with various GENERIC
2444 trees while parsing.  To support this, trees provide a set of flags
2445 that may be used by the front end.  They are accessed using
2446 @code{TREE_LANG_FLAG_n} where @samp{n} is currently 0 through 6.
2448 If necessary, a front end can use some language-dependent tree
2449 codes in its GENERIC representation, so long as it provides a
2450 hook for converting them to GIMPLE and doesn't expect them to
2451 work with any (hypothetical) optimizers that run before the
2452 conversion to GIMPLE@. The intermediate representation used while
2453 parsing C and C++ looks very little like GENERIC, but the C and
2454 C++ gimplifier hooks are perfectly happy to take it as input and
2455 spit out GIMPLE@.
2459 @node C and C++ Trees
2460 @section C and C++ Trees
2462 This section documents the internal representation used by GCC to
2463 represent C and C++ source programs.  When presented with a C or C++
2464 source program, GCC parses the program, performs semantic analysis
2465 (including the generation of error messages), and then produces the
2466 internal representation described here.  This representation contains a
2467 complete representation for the entire translation unit provided as
2468 input to the front end.  This representation is then typically processed
2469 by a code-generator in order to produce machine code, but could also be
2470 used in the creation of source browsers, intelligent editors, automatic
2471 documentation generators, interpreters, and any other programs needing
2472 the ability to process C or C++ code.
2474 This section explains the internal representation.  In particular, it
2475 documents the internal representation for C and C++ source
2476 constructs, and the macros, functions, and variables that can be used to
2477 access these constructs.  The C++ representation is largely a superset
2478 of the representation used in the C front end.  There is only one
2479 construct used in C that does not appear in the C++ front end and that
2480 is the GNU ``nested function'' extension.  Many of the macros documented
2481 here do not apply in C because the corresponding language constructs do
2482 not appear in C@.
2484 The C and C++ front ends generate a mix of GENERIC trees and ones
2485 specific to C and C++.  These language-specific trees are higher-level
2486 constructs than the ones in GENERIC to make the parser's job easier.
2487 This section describes those trees that aren't part of GENERIC as well
2488 as aspects of GENERIC trees that are treated in a language-specific
2489 manner.
2491 If you are developing a ``back end'', be it is a code-generator or some
2492 other tool, that uses this representation, you may occasionally find
2493 that you need to ask questions not easily answered by the functions and
2494 macros available here.  If that situation occurs, it is quite likely
2495 that GCC already supports the functionality you desire, but that the
2496 interface is simply not documented here.  In that case, you should ask
2497 the GCC maintainers (via mail to @email{gcc@@gcc.gnu.org}) about
2498 documenting the functionality you require.  Similarly, if you find
2499 yourself writing functions that do not deal directly with your back end,
2500 but instead might be useful to other people using the GCC front end, you
2501 should submit your patches for inclusion in GCC@.
2503 @menu
2504 * Types for C++::               Fundamental and aggregate types.
2505 * Namespaces::                  Namespaces.
2506 * Classes::                     Classes.
2507 * Functions for C++::           Overloading and accessors for C++.
2508 * Statements for C++::          Statements specific to C and C++.
2509 * C++ Expressions::    From @code{typeid} to @code{throw}.
2510 @end menu
2512 @node Types for C++
2513 @subsection Types for C++
2514 @tindex UNKNOWN_TYPE
2515 @tindex TYPENAME_TYPE
2516 @tindex TYPEOF_TYPE
2517 @findex cp_type_quals
2518 @findex TYPE_UNQUALIFIED
2519 @findex TYPE_QUAL_CONST
2520 @findex TYPE_QUAL_VOLATILE
2521 @findex TYPE_QUAL_RESTRICT
2522 @findex TYPE_MAIN_VARIANT
2523 @cindex qualified type
2524 @findex TYPE_SIZE
2525 @findex TYPE_ALIGN
2526 @findex TYPE_PRECISION
2527 @findex TYPE_ARG_TYPES
2528 @findex TYPE_METHOD_BASETYPE
2529 @findex TYPE_PTRDATAMEM_P
2530 @findex TYPE_OFFSET_BASETYPE
2531 @findex TREE_TYPE
2532 @findex TYPE_CONTEXT
2533 @findex TYPE_NAME
2534 @findex TYPENAME_TYPE_FULLNAME
2535 @findex TYPE_FIELDS
2536 @findex TYPE_PTROBV_P
2538 In C++, an array type is not qualified; rather the type of the array
2539 elements is qualified.  This situation is reflected in the intermediate
2540 representation.  The macros described here will always examine the
2541 qualification of the underlying element type when applied to an array
2542 type.  (If the element type is itself an array, then the recursion
2543 continues until a non-array type is found, and the qualification of this
2544 type is examined.)  So, for example, @code{CP_TYPE_CONST_P} will hold of
2545 the type @code{const int ()[7]}, denoting an array of seven @code{int}s.
2547 The following functions and macros deal with cv-qualification of types:
2548 @ftable @code
2549 @item cp_type_quals
2550 This function returns the set of type qualifiers applied to this type.
2551 This value is @code{TYPE_UNQUALIFIED} if no qualifiers have been
2552 applied.  The @code{TYPE_QUAL_CONST} bit is set if the type is
2553 @code{const}-qualified.  The @code{TYPE_QUAL_VOLATILE} bit is set if the
2554 type is @code{volatile}-qualified.  The @code{TYPE_QUAL_RESTRICT} bit is
2555 set if the type is @code{restrict}-qualified.
2557 @item CP_TYPE_CONST_P
2558 This macro holds if the type is @code{const}-qualified.
2560 @item CP_TYPE_VOLATILE_P
2561 This macro holds if the type is @code{volatile}-qualified.
2563 @item CP_TYPE_RESTRICT_P
2564 This macro holds if the type is @code{restrict}-qualified.
2566 @item CP_TYPE_CONST_NON_VOLATILE_P
2567 This predicate holds for a type that is @code{const}-qualified, but
2568 @emph{not} @code{volatile}-qualified; other cv-qualifiers are ignored as
2569 well: only the @code{const}-ness is tested.
2571 @end ftable
2573 A few other macros and functions are usable with all types:
2574 @ftable @code
2575 @item TYPE_SIZE
2576 The number of bits required to represent the type, represented as an
2577 @code{INTEGER_CST}.  For an incomplete type, @code{TYPE_SIZE} will be
2578 @code{NULL_TREE}.
2580 @item TYPE_ALIGN
2581 The alignment of the type, in bits, represented as an @code{int}.
2583 @item TYPE_NAME
2584 This macro returns a declaration (in the form of a @code{TYPE_DECL}) for
2585 the type.  (Note this macro does @emph{not} return an
2586 @code{IDENTIFIER_NODE}, as you might expect, given its name!)  You can
2587 look at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the
2588 actual name of the type.  The @code{TYPE_NAME} will be @code{NULL_TREE}
2589 for a type that is not a built-in type, the result of a typedef, or a
2590 named class type.
2592 @item CP_INTEGRAL_TYPE
2593 This predicate holds if the type is an integral type.  Notice that in
2594 C++, enumerations are @emph{not} integral types.
2596 @item ARITHMETIC_TYPE_P
2597 This predicate holds if the type is an integral type (in the C++ sense)
2598 or a floating point type.
2600 @item CLASS_TYPE_P
2601 This predicate holds for a class-type.
2603 @item TYPE_BUILT_IN
2604 This predicate holds for a built-in type.
2606 @item TYPE_PTRDATAMEM_P
2607 This predicate holds if the type is a pointer to data member.
2609 @item TYPE_PTR_P
2610 This predicate holds if the type is a pointer type, and the pointee is
2611 not a data member.
2613 @item TYPE_PTRFN_P
2614 This predicate holds for a pointer to function type.
2616 @item TYPE_PTROB_P
2617 This predicate holds for a pointer to object type.  Note however that it
2618 does not hold for the generic pointer to object type @code{void *}.  You
2619 may use @code{TYPE_PTROBV_P} to test for a pointer to object type as
2620 well as @code{void *}.
2622 @end ftable
2624 The table below describes types specific to C and C++ as well as
2625 language-dependent info about GENERIC types.
2627 @table @code
2629 @item POINTER_TYPE
2630 Used to represent pointer types, and pointer to data member types.  If
2631 @code{TREE_TYPE}
2632 is a pointer to data member type, then @code{TYPE_PTRDATAMEM_P} will hold.
2633 For a pointer to data member type of the form @samp{T X::*},
2634 @code{TYPE_PTRMEM_CLASS_TYPE} will be the type @code{X}, while
2635 @code{TYPE_PTRMEM_POINTED_TO_TYPE} will be the type @code{T}.
2637 @item RECORD_TYPE
2638 Used to represent @code{struct} and @code{class} types in C and C++.  If
2639 @code{TYPE_PTRMEMFUNC_P} holds, then this type is a pointer-to-member
2640 type.  In that case, the @code{TYPE_PTRMEMFUNC_FN_TYPE} is a
2641 @code{POINTER_TYPE} pointing to a @code{METHOD_TYPE}.  The
2642 @code{METHOD_TYPE} is the type of a function pointed to by the
2643 pointer-to-member function.  If @code{TYPE_PTRMEMFUNC_P} does not hold,
2644 this type is a class type.  For more information, @pxref{Classes}.
2646 @item UNKNOWN_TYPE
2647 This node is used to represent a type the knowledge of which is
2648 insufficient for a sound processing.
2650 @item TYPENAME_TYPE
2651 Used to represent a construct of the form @code{typename T::A}.  The
2652 @code{TYPE_CONTEXT} is @code{T}; the @code{TYPE_NAME} is an
2653 @code{IDENTIFIER_NODE} for @code{A}.  If the type is specified via a
2654 template-id, then @code{TYPENAME_TYPE_FULLNAME} yields a
2655 @code{TEMPLATE_ID_EXPR}.  The @code{TREE_TYPE} is non-@code{NULL} if the
2656 node is implicitly generated in support for the implicit typename
2657 extension; in which case the @code{TREE_TYPE} is a type node for the
2658 base-class.
2660 @item TYPEOF_TYPE
2661 Used to represent the @code{__typeof__} extension.  The
2662 @code{TYPE_FIELDS} is the expression the type of which is being
2663 represented.
2665 @end table
2668 @c ---------------------------------------------------------------------
2669 @c Namespaces
2670 @c ---------------------------------------------------------------------
2672 @node Namespaces
2673 @subsection Namespaces
2674 @cindex namespace, scope
2675 @tindex NAMESPACE_DECL
2677 The root of the entire intermediate representation is the variable
2678 @code{global_namespace}.  This is the namespace specified with @code{::}
2679 in C++ source code.  All other namespaces, types, variables, functions,
2680 and so forth can be found starting with this namespace.
2682 However, except for the fact that it is distinguished as the root of the
2683 representation, the global namespace is no different from any other
2684 namespace.  Thus, in what follows, we describe namespaces generally,
2685 rather than the global namespace in particular.
2687 A namespace is represented by a @code{NAMESPACE_DECL} node.
2689 The following macros and functions can be used on a @code{NAMESPACE_DECL}:
2691 @ftable @code
2692 @item DECL_NAME
2693 This macro is used to obtain the @code{IDENTIFIER_NODE} corresponding to
2694 the unqualified name of the name of the namespace (@pxref{Identifiers}).
2695 The name of the global namespace is @samp{::}, even though in C++ the
2696 global namespace is unnamed.  However, you should use comparison with
2697 @code{global_namespace}, rather than @code{DECL_NAME} to determine
2698 whether or not a namespace is the global one.  An unnamed namespace
2699 will have a @code{DECL_NAME} equal to @code{anonymous_namespace_name}.
2700 Within a single translation unit, all unnamed namespaces will have the
2701 same name.
2703 @item DECL_CONTEXT
2704 This macro returns the enclosing namespace.  The @code{DECL_CONTEXT} for
2705 the @code{global_namespace} is @code{NULL_TREE}.
2707 @item DECL_NAMESPACE_ALIAS
2708 If this declaration is for a namespace alias, then
2709 @code{DECL_NAMESPACE_ALIAS} is the namespace for which this one is an
2710 alias.
2712 Do not attempt to use @code{cp_namespace_decls} for a namespace which is
2713 an alias.  Instead, follow @code{DECL_NAMESPACE_ALIAS} links until you
2714 reach an ordinary, non-alias, namespace, and call
2715 @code{cp_namespace_decls} there.
2717 @item DECL_NAMESPACE_STD_P
2718 This predicate holds if the namespace is the special @code{::std}
2719 namespace.
2721 @item cp_namespace_decls
2722 This function will return the declarations contained in the namespace,
2723 including types, overloaded functions, other namespaces, and so forth.
2724 If there are no declarations, this function will return
2725 @code{NULL_TREE}.  The declarations are connected through their
2726 @code{TREE_CHAIN} fields.
2728 Although most entries on this list will be declarations,
2729 @code{TREE_LIST} nodes may also appear.  In this case, the
2730 @code{TREE_VALUE} will be an @code{OVERLOAD}.  The value of the
2731 @code{TREE_PURPOSE} is unspecified; back ends should ignore this value.
2732 As with the other kinds of declarations returned by
2733 @code{cp_namespace_decls}, the @code{TREE_CHAIN} will point to the next
2734 declaration in this list.
2736 For more information on the kinds of declarations that can occur on this
2737 list, @xref{Declarations}.  Some declarations will not appear on this
2738 list.  In particular, no @code{FIELD_DECL}, @code{LABEL_DECL}, or
2739 @code{PARM_DECL} nodes will appear here.
2741 This function cannot be used with namespaces that have
2742 @code{DECL_NAMESPACE_ALIAS} set.
2744 @end ftable
2746 @c ---------------------------------------------------------------------
2747 @c Classes
2748 @c ---------------------------------------------------------------------
2750 @node Classes
2751 @subsection Classes
2752 @cindex class, scope
2753 @tindex RECORD_TYPE
2754 @tindex UNION_TYPE
2755 @findex CLASSTYPE_DECLARED_CLASS
2756 @findex TYPE_BINFO
2757 @findex BINFO_TYPE
2758 @findex TYPE_FIELDS
2759 @findex TYPE_VFIELD
2760 @findex TYPE_METHODS
2762 Besides namespaces, the other high-level scoping construct in C++ is the
2763 class.  (Throughout this manual the term @dfn{class} is used to mean the
2764 types referred to in the ANSI/ISO C++ Standard as classes; these include
2765 types defined with the @code{class}, @code{struct}, and @code{union}
2766 keywords.)
2768 A class type is represented by either a @code{RECORD_TYPE} or a
2769 @code{UNION_TYPE}.  A class declared with the @code{union} tag is
2770 represented by a @code{UNION_TYPE}, while classes declared with either
2771 the @code{struct} or the @code{class} tag are represented by
2772 @code{RECORD_TYPE}s.  You can use the @code{CLASSTYPE_DECLARED_CLASS}
2773 macro to discern whether or not a particular type is a @code{class} as
2774 opposed to a @code{struct}.  This macro will be true only for classes
2775 declared with the @code{class} tag.
2777 Almost all non-function members are available on the @code{TYPE_FIELDS}
2778 list.  Given one member, the next can be found by following the
2779 @code{TREE_CHAIN}.  You should not depend in any way on the order in
2780 which fields appear on this list.  All nodes on this list will be
2781 @samp{DECL} nodes.  A @code{FIELD_DECL} is used to represent a non-static
2782 data member, a @code{VAR_DECL} is used to represent a static data
2783 member, and a @code{TYPE_DECL} is used to represent a type.  Note that
2784 the @code{CONST_DECL} for an enumeration constant will appear on this
2785 list, if the enumeration type was declared in the class.  (Of course,
2786 the @code{TYPE_DECL} for the enumeration type will appear here as well.)
2787 There are no entries for base classes on this list.  In particular,
2788 there is no @code{FIELD_DECL} for the ``base-class portion'' of an
2789 object.
2791 The @code{TYPE_VFIELD} is a compiler-generated field used to point to
2792 virtual function tables.  It may or may not appear on the
2793 @code{TYPE_FIELDS} list.  However, back ends should handle the
2794 @code{TYPE_VFIELD} just like all the entries on the @code{TYPE_FIELDS}
2795 list.
2797 The function members are available on the @code{TYPE_METHODS} list.
2798 Again, subsequent members are found by following the @code{TREE_CHAIN}
2799 field.  If a function is overloaded, each of the overloaded functions
2800 appears; no @code{OVERLOAD} nodes appear on the @code{TYPE_METHODS}
2801 list.  Implicitly declared functions (including default constructors,
2802 copy constructors, assignment operators, and destructors) will appear on
2803 this list as well.
2805 Every class has an associated @dfn{binfo}, which can be obtained with
2806 @code{TYPE_BINFO}.  Binfos are used to represent base-classes.  The
2807 binfo given by @code{TYPE_BINFO} is the degenerate case, whereby every
2808 class is considered to be its own base-class.  The base binfos for a
2809 particular binfo are held in a vector, whose length is obtained with
2810 @code{BINFO_N_BASE_BINFOS}.  The base binfos themselves are obtained
2811 with @code{BINFO_BASE_BINFO} and @code{BINFO_BASE_ITERATE}.  To add a
2812 new binfo, use @code{BINFO_BASE_APPEND}.  The vector of base binfos can
2813 be obtained with @code{BINFO_BASE_BINFOS}, but normally you do not need
2814 to use that.  The class type associated with a binfo is given by
2815 @code{BINFO_TYPE}.  It is not always the case that @code{BINFO_TYPE
2816 (TYPE_BINFO (x))}, because of typedefs and qualified types.  Neither is
2817 it the case that @code{TYPE_BINFO (BINFO_TYPE (y))} is the same binfo as
2818 @code{y}.  The reason is that if @code{y} is a binfo representing a
2819 base-class @code{B} of a derived class @code{D}, then @code{BINFO_TYPE
2820 (y)} will be @code{B}, and @code{TYPE_BINFO (BINFO_TYPE (y))} will be
2821 @code{B} as its own base-class, rather than as a base-class of @code{D}.
2823 The access to a base type can be found with @code{BINFO_BASE_ACCESS}.
2824 This will produce @code{access_public_node}, @code{access_private_node}
2825 or @code{access_protected_node}.  If bases are always public,
2826 @code{BINFO_BASE_ACCESSES} may be @code{NULL}.
2828 @code{BINFO_VIRTUAL_P} is used to specify whether the binfo is inherited
2829 virtually or not.  The other flags, @code{BINFO_MARKED_P} and
2830 @code{BINFO_FLAG_1} to @code{BINFO_FLAG_6} can be used for language
2831 specific use.
2833 The following macros can be used on a tree node representing a class-type.
2835 @ftable @code
2836 @item LOCAL_CLASS_P
2837 This predicate holds if the class is local class @emph{i.e.}@: declared
2838 inside a function body.
2840 @item TYPE_POLYMORPHIC_P
2841 This predicate holds if the class has at least one virtual function
2842 (declared or inherited).
2844 @item TYPE_HAS_DEFAULT_CONSTRUCTOR
2845 This predicate holds whenever its argument represents a class-type with
2846 default constructor.
2848 @item CLASSTYPE_HAS_MUTABLE
2849 @itemx TYPE_HAS_MUTABLE_P
2850 These predicates hold for a class-type having a mutable data member.
2852 @item CLASSTYPE_NON_POD_P
2853 This predicate holds only for class-types that are not PODs.
2855 @item TYPE_HAS_NEW_OPERATOR
2856 This predicate holds for a class-type that defines
2857 @code{operator new}.
2859 @item TYPE_HAS_ARRAY_NEW_OPERATOR
2860 This predicate holds for a class-type for which
2861 @code{operator new[]} is defined.
2863 @item TYPE_OVERLOADS_CALL_EXPR
2864 This predicate holds for class-type for which the function call
2865 @code{operator()} is overloaded.
2867 @item TYPE_OVERLOADS_ARRAY_REF
2868 This predicate holds for a class-type that overloads
2869 @code{operator[]}
2871 @item TYPE_OVERLOADS_ARROW
2872 This predicate holds for a class-type for which @code{operator->} is
2873 overloaded.
2875 @end ftable
2877 @node Functions for C++
2878 @subsection Functions for C++
2879 @cindex function
2880 @tindex FUNCTION_DECL
2881 @tindex OVERLOAD
2882 @findex OVL_CURRENT
2883 @findex OVL_NEXT
2885 A function is represented by a @code{FUNCTION_DECL} node.  A set of
2886 overloaded functions is sometimes represented by an @code{OVERLOAD} node.
2888 An @code{OVERLOAD} node is not a declaration, so none of the
2889 @samp{DECL_} macros should be used on an @code{OVERLOAD}.  An
2890 @code{OVERLOAD} node is similar to a @code{TREE_LIST}.  Use
2891 @code{OVL_CURRENT} to get the function associated with an
2892 @code{OVERLOAD} node; use @code{OVL_NEXT} to get the next
2893 @code{OVERLOAD} node in the list of overloaded functions.  The macros
2894 @code{OVL_CURRENT} and @code{OVL_NEXT} are actually polymorphic; you can
2895 use them to work with @code{FUNCTION_DECL} nodes as well as with
2896 overloads.  In the case of a @code{FUNCTION_DECL}, @code{OVL_CURRENT}
2897 will always return the function itself, and @code{OVL_NEXT} will always
2898 be @code{NULL_TREE}.
2900 To determine the scope of a function, you can use the
2901 @code{DECL_CONTEXT} macro.  This macro will return the class
2902 (either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a
2903 @code{NAMESPACE_DECL}) of which the function is a member.  For a virtual
2904 function, this macro returns the class in which the function was
2905 actually defined, not the base class in which the virtual declaration
2906 occurred.
2908 If a friend function is defined in a class scope, the
2909 @code{DECL_FRIEND_CONTEXT} macro can be used to determine the class in
2910 which it was defined.  For example, in
2911 @smallexample
2912 class C @{ friend void f() @{@} @};
2913 @end smallexample
2914 @noindent
2915 the @code{DECL_CONTEXT} for @code{f} will be the
2916 @code{global_namespace}, but the @code{DECL_FRIEND_CONTEXT} will be the
2917 @code{RECORD_TYPE} for @code{C}.
2920 The following macros and functions can be used on a @code{FUNCTION_DECL}:
2921 @ftable @code
2922 @item DECL_MAIN_P
2923 This predicate holds for a function that is the program entry point
2924 @code{::code}.
2926 @item DECL_LOCAL_FUNCTION_P
2927 This predicate holds if the function was declared at block scope, even
2928 though it has a global scope.
2930 @item DECL_ANTICIPATED
2931 This predicate holds if the function is a built-in function but its
2932 prototype is not yet explicitly declared.
2934 @item DECL_EXTERN_C_FUNCTION_P
2935 This predicate holds if the function is declared as an
2936 `@code{extern "C"}' function.
2938 @item DECL_LINKONCE_P
2939 This macro holds if multiple copies of this function may be emitted in
2940 various translation units.  It is the responsibility of the linker to
2941 merge the various copies.  Template instantiations are the most common
2942 example of functions for which @code{DECL_LINKONCE_P} holds; G++
2943 instantiates needed templates in all translation units which require them,
2944 and then relies on the linker to remove duplicate instantiations.
2946 FIXME: This macro is not yet implemented.
2948 @item DECL_FUNCTION_MEMBER_P
2949 This macro holds if the function is a member of a class, rather than a
2950 member of a namespace.
2952 @item DECL_STATIC_FUNCTION_P
2953 This predicate holds if the function a static member function.
2955 @item DECL_NONSTATIC_MEMBER_FUNCTION_P
2956 This macro holds for a non-static member function.
2958 @item DECL_CONST_MEMFUNC_P
2959 This predicate holds for a @code{const}-member function.
2961 @item DECL_VOLATILE_MEMFUNC_P
2962 This predicate holds for a @code{volatile}-member function.
2964 @item DECL_CONSTRUCTOR_P
2965 This macro holds if the function is a constructor.
2967 @item DECL_NONCONVERTING_P
2968 This predicate holds if the constructor is a non-converting constructor.
2970 @item DECL_COMPLETE_CONSTRUCTOR_P
2971 This predicate holds for a function which is a constructor for an object
2972 of a complete type.
2974 @item DECL_BASE_CONSTRUCTOR_P
2975 This predicate holds for a function which is a constructor for a base
2976 class sub-object.
2978 @item DECL_COPY_CONSTRUCTOR_P
2979 This predicate holds for a function which is a copy-constructor.
2981 @item DECL_DESTRUCTOR_P
2982 This macro holds if the function is a destructor.
2984 @item DECL_COMPLETE_DESTRUCTOR_P
2985 This predicate holds if the function is the destructor for an object a
2986 complete type.
2988 @item DECL_OVERLOADED_OPERATOR_P
2989 This macro holds if the function is an overloaded operator.
2991 @item DECL_CONV_FN_P
2992 This macro holds if the function is a type-conversion operator.
2994 @item DECL_GLOBAL_CTOR_P
2995 This predicate holds if the function is a file-scope initialization
2996 function.
2998 @item DECL_GLOBAL_DTOR_P
2999 This predicate holds if the function is a file-scope finalization
3000 function.
3002 @item DECL_THUNK_P
3003 This predicate holds if the function is a thunk.
3005 These functions represent stub code that adjusts the @code{this} pointer
3006 and then jumps to another function.  When the jumped-to function
3007 returns, control is transferred directly to the caller, without
3008 returning to the thunk.  The first parameter to the thunk is always the
3009 @code{this} pointer; the thunk should add @code{THUNK_DELTA} to this
3010 value.  (The @code{THUNK_DELTA} is an @code{int}, not an
3011 @code{INTEGER_CST}.)
3013 Then, if @code{THUNK_VCALL_OFFSET} (an @code{INTEGER_CST}) is nonzero
3014 the adjusted @code{this} pointer must be adjusted again.  The complete
3015 calculation is given by the following pseudo-code:
3017 @smallexample
3018 this += THUNK_DELTA
3019 if (THUNK_VCALL_OFFSET)
3020   this += (*((ptrdiff_t **) this))[THUNK_VCALL_OFFSET]
3021 @end smallexample
3023 Finally, the thunk should jump to the location given
3024 by @code{DECL_INITIAL}; this will always be an expression for the
3025 address of a function.
3027 @item DECL_NON_THUNK_FUNCTION_P
3028 This predicate holds if the function is @emph{not} a thunk function.
3030 @item GLOBAL_INIT_PRIORITY
3031 If either @code{DECL_GLOBAL_CTOR_P} or @code{DECL_GLOBAL_DTOR_P} holds,
3032 then this gives the initialization priority for the function.  The
3033 linker will arrange that all functions for which
3034 @code{DECL_GLOBAL_CTOR_P} holds are run in increasing order of priority
3035 before @code{main} is called.  When the program exits, all functions for
3036 which @code{DECL_GLOBAL_DTOR_P} holds are run in the reverse order.
3038 @item TYPE_RAISES_EXCEPTIONS
3039 This macro returns the list of exceptions that a (member-)function can
3040 raise.  The returned list, if non @code{NULL}, is comprised of nodes
3041 whose @code{TREE_VALUE} represents a type.
3043 @item TYPE_NOTHROW_P
3044 This predicate holds when the exception-specification of its arguments
3045 is of the form `@code{()}'.
3047 @item DECL_ARRAY_DELETE_OPERATOR_P
3048 This predicate holds if the function an overloaded
3049 @code{operator delete[]}.
3051 @end ftable
3053 @c ---------------------------------------------------------------------
3054 @c Function Bodies
3055 @c ---------------------------------------------------------------------
3057 @node Statements for C++
3058 @subsection Statements for C++
3059 @cindex statements
3060 @tindex BREAK_STMT
3061 @tindex CLEANUP_STMT
3062 @findex CLEANUP_DECL
3063 @findex CLEANUP_EXPR
3064 @tindex CONTINUE_STMT
3065 @tindex DECL_STMT
3066 @findex DECL_STMT_DECL
3067 @tindex DO_STMT
3068 @findex DO_BODY
3069 @findex DO_COND
3070 @tindex EMPTY_CLASS_EXPR
3071 @tindex EXPR_STMT
3072 @findex EXPR_STMT_EXPR
3073 @tindex FOR_STMT
3074 @findex FOR_INIT_STMT
3075 @findex FOR_COND
3076 @findex FOR_EXPR
3077 @findex FOR_BODY
3078 @tindex HANDLER
3079 @tindex IF_STMT
3080 @findex IF_COND
3081 @findex THEN_CLAUSE
3082 @findex ELSE_CLAUSE
3083 @tindex RETURN_STMT
3084 @findex RETURN_EXPR
3085 @tindex SUBOBJECT
3086 @findex SUBOBJECT_CLEANUP
3087 @tindex SWITCH_STMT
3088 @findex SWITCH_COND
3089 @findex SWITCH_BODY
3090 @tindex TRY_BLOCK
3091 @findex TRY_STMTS
3092 @findex TRY_HANDLERS
3093 @findex HANDLER_PARMS
3094 @findex HANDLER_BODY
3095 @findex USING_STMT
3096 @tindex WHILE_STMT
3097 @findex WHILE_BODY
3098 @findex WHILE_COND
3100 A function that has a definition in the current translation unit will
3101 have a non-@code{NULL} @code{DECL_INITIAL}.  However, back ends should not make
3102 use of the particular value given by @code{DECL_INITIAL}.
3104 The @code{DECL_SAVED_TREE} macro will give the complete body of the
3105 function.
3107 @subsubsection Statements
3109 There are tree nodes corresponding to all of the source-level
3110 statement constructs, used within the C and C++ frontends.  These are
3111 enumerated here, together with a list of the various macros that can
3112 be used to obtain information about them.  There are a few macros that
3113 can be used with all statements:
3115 @ftable @code
3116 @item STMT_IS_FULL_EXPR_P
3117 In C++, statements normally constitute ``full expressions''; temporaries
3118 created during a statement are destroyed when the statement is complete.
3119 However, G++ sometimes represents expressions by statements; these
3120 statements will not have @code{STMT_IS_FULL_EXPR_P} set.  Temporaries
3121 created during such statements should be destroyed when the innermost
3122 enclosing statement with @code{STMT_IS_FULL_EXPR_P} set is exited.
3124 @end ftable
3126 Here is the list of the various statement nodes, and the macros used to
3127 access them.  This documentation describes the use of these nodes in
3128 non-template functions (including instantiations of template functions).
3129 In template functions, the same nodes are used, but sometimes in
3130 slightly different ways.
3132 Many of the statements have substatements.  For example, a @code{while}
3133 loop will have a body, which is itself a statement.  If the substatement
3134 is @code{NULL_TREE}, it is considered equivalent to a statement
3135 consisting of a single @code{;}, i.e., an expression statement in which
3136 the expression has been omitted.  A substatement may in fact be a list
3137 of statements, connected via their @code{TREE_CHAIN}s.  So, you should
3138 always process the statement tree by looping over substatements, like
3139 this:
3140 @smallexample
3141 void process_stmt (stmt)
3142      tree stmt;
3144   while (stmt)
3145     @{
3146       switch (TREE_CODE (stmt))
3147         @{
3148         case IF_STMT:
3149           process_stmt (THEN_CLAUSE (stmt));
3150           /* @r{More processing here.}  */
3151           break;
3153         @dots{}
3154         @}
3156       stmt = TREE_CHAIN (stmt);
3157     @}
3159 @end smallexample
3160 In other words, while the @code{then} clause of an @code{if} statement
3161 in C++ can be only one statement (although that one statement may be a
3162 compound statement), the intermediate representation will sometimes use
3163 several statements chained together.
3165 @table @code
3166 @item BREAK_STMT
3168 Used to represent a @code{break} statement.  There are no additional
3169 fields.
3171 @item CILK_SPAWN_STMT
3173 Used to represent a spawning function in the Cilk Plus language extension.  
3174 This tree has one field that holds the name of the spawning function.
3175 @code{_Cilk_spawn} can be written in C in the following way:
3177 @smallexample
3178 @code{_Cilk_spawn} <function_name> (<parameters>);
3179 @end smallexample
3181 Detailed description for usage and functionality of @code{_Cilk_spawn} can be 
3182 found at http://www.cilkplus.org
3184 @item CILK_SYNC_STMT
3186 This statement is part of the Cilk Plus language extension.  It indicates that
3187 the current function cannot continue in parallel with its spawned children.  
3188 There are no additional fields.  @code{_Cilk_sync} can be written in C in the 
3189 following way:
3191 @smallexample
3192 @code{_Cilk_sync};
3193 @end smallexample
3195 @item CLEANUP_STMT
3197 Used to represent an action that should take place upon exit from the
3198 enclosing scope.  Typically, these actions are calls to destructors for
3199 local objects, but back ends cannot rely on this fact.  If these nodes
3200 are in fact representing such destructors, @code{CLEANUP_DECL} will be
3201 the @code{VAR_DECL} destroyed.  Otherwise, @code{CLEANUP_DECL} will be
3202 @code{NULL_TREE}.  In any case, the @code{CLEANUP_EXPR} is the
3203 expression to execute.  The cleanups executed on exit from a scope
3204 should be run in the reverse order of the order in which the associated
3205 @code{CLEANUP_STMT}s were encountered.
3207 @item CONTINUE_STMT
3209 Used to represent a @code{continue} statement.  There are no additional
3210 fields.
3212 @item CTOR_STMT
3214 Used to mark the beginning (if @code{CTOR_BEGIN_P} holds) or end (if
3215 @code{CTOR_END_P} holds of the main body of a constructor.  See also
3216 @code{SUBOBJECT} for more information on how to use these nodes.
3218 @item DO_STMT
3220 Used to represent a @code{do} loop.  The body of the loop is given by
3221 @code{DO_BODY} while the termination condition for the loop is given by
3222 @code{DO_COND}.  The condition for a @code{do}-statement is always an
3223 expression.
3225 @item EMPTY_CLASS_EXPR
3227 Used to represent a temporary object of a class with no data whose
3228 address is never taken.  (All such objects are interchangeable.)  The
3229 @code{TREE_TYPE} represents the type of the object.
3231 @item EXPR_STMT
3233 Used to represent an expression statement.  Use @code{EXPR_STMT_EXPR} to
3234 obtain the expression.
3236 @item FOR_STMT
3238 Used to represent a @code{for} statement.  The @code{FOR_INIT_STMT} is
3239 the initialization statement for the loop.  The @code{FOR_COND} is the
3240 termination condition.  The @code{FOR_EXPR} is the expression executed
3241 right before the @code{FOR_COND} on each loop iteration; often, this
3242 expression increments a counter.  The body of the loop is given by
3243 @code{FOR_BODY}.  Note that @code{FOR_INIT_STMT} and @code{FOR_BODY}
3244 return statements, while @code{FOR_COND} and @code{FOR_EXPR} return
3245 expressions.
3247 @item HANDLER
3249 Used to represent a C++ @code{catch} block.  The @code{HANDLER_TYPE}
3250 is the type of exception that will be caught by this handler; it is
3251 equal (by pointer equality) to @code{NULL} if this handler is for all
3252 types.  @code{HANDLER_PARMS} is the @code{DECL_STMT} for the catch
3253 parameter, and @code{HANDLER_BODY} is the code for the block itself.
3255 @item IF_STMT
3257 Used to represent an @code{if} statement.  The @code{IF_COND} is the
3258 expression.
3260 If the condition is a @code{TREE_LIST}, then the @code{TREE_PURPOSE} is
3261 a statement (usually a @code{DECL_STMT}).  Each time the condition is
3262 evaluated, the statement should be executed.  Then, the
3263 @code{TREE_VALUE} should be used as the conditional expression itself.
3264 This representation is used to handle C++ code like this:
3266 C++ distinguishes between this and @code{COND_EXPR} for handling templates.
3268 @smallexample
3269 if (int i = 7) @dots{}
3270 @end smallexample
3272 where there is a new local variable (or variables) declared within the
3273 condition.
3275 The @code{THEN_CLAUSE} represents the statement given by the @code{then}
3276 condition, while the @code{ELSE_CLAUSE} represents the statement given
3277 by the @code{else} condition.
3279 @item SUBOBJECT
3281 In a constructor, these nodes are used to mark the point at which a
3282 subobject of @code{this} is fully constructed.  If, after this point, an
3283 exception is thrown before a @code{CTOR_STMT} with @code{CTOR_END_P} set
3284 is encountered, the @code{SUBOBJECT_CLEANUP} must be executed.  The
3285 cleanups must be executed in the reverse order in which they appear.
3287 @item SWITCH_STMT
3289 Used to represent a @code{switch} statement.  The @code{SWITCH_STMT_COND}
3290 is the expression on which the switch is occurring.  See the documentation
3291 for an @code{IF_STMT} for more information on the representation used
3292 for the condition.  The @code{SWITCH_STMT_BODY} is the body of the switch
3293 statement.   The @code{SWITCH_STMT_TYPE} is the original type of switch
3294 expression as given in the source, before any compiler conversions.
3296 @item TRY_BLOCK
3297 Used to represent a @code{try} block.  The body of the try block is
3298 given by @code{TRY_STMTS}.  Each of the catch blocks is a @code{HANDLER}
3299 node.  The first handler is given by @code{TRY_HANDLERS}.  Subsequent
3300 handlers are obtained by following the @code{TREE_CHAIN} link from one
3301 handler to the next.  The body of the handler is given by
3302 @code{HANDLER_BODY}.
3304 If @code{CLEANUP_P} holds of the @code{TRY_BLOCK}, then the
3305 @code{TRY_HANDLERS} will not be a @code{HANDLER} node.  Instead, it will
3306 be an expression that should be executed if an exception is thrown in
3307 the try block.  It must rethrow the exception after executing that code.
3308 And, if an exception is thrown while the expression is executing,
3309 @code{terminate} must be called.
3311 @item USING_STMT
3312 Used to represent a @code{using} directive.  The namespace is given by
3313 @code{USING_STMT_NAMESPACE}, which will be a NAMESPACE_DECL@.  This node
3314 is needed inside template functions, to implement using directives
3315 during instantiation.
3317 @item WHILE_STMT
3319 Used to represent a @code{while} loop.  The @code{WHILE_COND} is the
3320 termination condition for the loop.  See the documentation for an
3321 @code{IF_STMT} for more information on the representation used for the
3322 condition.
3324 The @code{WHILE_BODY} is the body of the loop.
3326 @end table
3328 @node C++ Expressions
3329 @subsection C++ Expressions
3331 This section describes expressions specific to the C and C++ front
3332 ends.
3334 @table @code
3335 @item TYPEID_EXPR
3337 Used to represent a @code{typeid} expression.
3339 @item NEW_EXPR
3340 @itemx VEC_NEW_EXPR
3342 Used to represent a call to @code{new} and @code{new[]} respectively.
3344 @item DELETE_EXPR
3345 @itemx VEC_DELETE_EXPR
3347 Used to represent a call to @code{delete} and @code{delete[]} respectively.
3349 @item MEMBER_REF
3351 Represents a reference to a member of a class.
3353 @item THROW_EXPR
3355 Represents an instance of @code{throw} in the program.  Operand 0,
3356 which is the expression to throw, may be @code{NULL_TREE}.
3359 @item AGGR_INIT_EXPR
3360 An @code{AGGR_INIT_EXPR} represents the initialization as the return
3361 value of a function call, or as the result of a constructor.  An
3362 @code{AGGR_INIT_EXPR} will only appear as a full-expression, or as the
3363 second operand of a @code{TARGET_EXPR}.  @code{AGGR_INIT_EXPR}s have
3364 a representation similar to that of @code{CALL_EXPR}s.  You can use
3365 the @code{AGGR_INIT_EXPR_FN} and @code{AGGR_INIT_EXPR_ARG} macros to access
3366 the function to call and the arguments to pass.
3368 If @code{AGGR_INIT_VIA_CTOR_P} holds of the @code{AGGR_INIT_EXPR}, then
3369 the initialization is via a constructor call.  The address of the
3370 @code{AGGR_INIT_EXPR_SLOT} operand, which is always a @code{VAR_DECL},
3371 is taken, and this value replaces the first argument in the argument
3372 list.
3374 In either case, the expression is void.
3377 @end table
3380 @node Java Trees
3381 @section Java Trees