xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/doc/generic.texi (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1*8feb0f0bSmrg@c Copyright (C) 2004-2020 Free Software Foundation, Inc.
21debfc3dSmrg@c This is part of the GCC manual.
31debfc3dSmrg@c For copying conditions, see the file gcc.texi.
41debfc3dSmrg
51debfc3dSmrg@c ---------------------------------------------------------------------
61debfc3dSmrg@c GENERIC
71debfc3dSmrg@c ---------------------------------------------------------------------
81debfc3dSmrg
91debfc3dSmrg@node GENERIC
101debfc3dSmrg@chapter GENERIC
111debfc3dSmrg@cindex GENERIC
121debfc3dSmrg
131debfc3dSmrgThe purpose of GENERIC is simply to provide a
141debfc3dSmrglanguage-independent way of representing an entire function in
151debfc3dSmrgtrees.  To this end, it was necessary to add a few new tree codes
161debfc3dSmrgto the back end, but almost everything was already there.  If you
171debfc3dSmrgcan express it with the codes in @code{gcc/tree.def}, it's
181debfc3dSmrgGENERIC@.
191debfc3dSmrg
201debfc3dSmrgEarly on, there was a great deal of debate about how to think
211debfc3dSmrgabout statements in a tree IL@.  In GENERIC, a statement is
221debfc3dSmrgdefined as any expression whose value, if any, is ignored.  A
231debfc3dSmrgstatement will always have @code{TREE_SIDE_EFFECTS} set (or it
241debfc3dSmrgwill be discarded), but a non-statement expression may also have
251debfc3dSmrgside effects.  A @code{CALL_EXPR}, for instance.
261debfc3dSmrg
271debfc3dSmrgIt would be possible for some local optimizations to work on the
281debfc3dSmrgGENERIC form of a function; indeed, the adapted tree inliner
291debfc3dSmrgworks fine on GENERIC, but the current compiler performs inlining
301debfc3dSmrgafter lowering to GIMPLE (a restricted form described in the next
311debfc3dSmrgsection). Indeed, currently the frontends perform this lowering
321debfc3dSmrgbefore handing off to @code{tree_rest_of_compilation}, but this
331debfc3dSmrgseems inelegant.
341debfc3dSmrg
351debfc3dSmrg@menu
361debfc3dSmrg* Deficiencies::                Topics net yet covered in this document.
371debfc3dSmrg* Tree overview::               All about @code{tree}s.
381debfc3dSmrg* Types::                       Fundamental and aggregate types.
391debfc3dSmrg* Declarations::                Type declarations and variables.
401debfc3dSmrg* Attributes::                  Declaration and type attributes.
411debfc3dSmrg* Expressions: Expression trees.            Operating on data.
421debfc3dSmrg* Statements::                  Control flow and related trees.
431debfc3dSmrg* Functions::           	Function bodies, linkage, and other aspects.
441debfc3dSmrg* Language-dependent trees::    Topics and trees specific to language front ends.
451debfc3dSmrg* C and C++ Trees::     	Trees specific to C and C++.
461debfc3dSmrg@end menu
471debfc3dSmrg
481debfc3dSmrg@c ---------------------------------------------------------------------
491debfc3dSmrg@c Deficiencies
501debfc3dSmrg@c ---------------------------------------------------------------------
511debfc3dSmrg
521debfc3dSmrg@node Deficiencies
531debfc3dSmrg@section Deficiencies
541debfc3dSmrg
551debfc3dSmrg@c The spelling of "incomplet" and "incorrekt" below is intentional.
561debfc3dSmrgThere are many places in which this document is incomplet and incorrekt.
571debfc3dSmrgIt is, as of yet, only @emph{preliminary} documentation.
581debfc3dSmrg
591debfc3dSmrg@c ---------------------------------------------------------------------
601debfc3dSmrg@c Overview
611debfc3dSmrg@c ---------------------------------------------------------------------
621debfc3dSmrg
631debfc3dSmrg@node Tree overview
641debfc3dSmrg@section Overview
651debfc3dSmrg@cindex tree
661debfc3dSmrg@findex TREE_CODE
671debfc3dSmrg
681debfc3dSmrgThe central data structure used by the internal representation is the
691debfc3dSmrg@code{tree}.  These nodes, while all of the C type @code{tree}, are of
701debfc3dSmrgmany varieties.  A @code{tree} is a pointer type, but the object to
711debfc3dSmrgwhich it points may be of a variety of types.  From this point forward,
721debfc3dSmrgwe will refer to trees in ordinary type, rather than in @code{this
731debfc3dSmrgfont}, except when talking about the actual C type @code{tree}.
741debfc3dSmrg
751debfc3dSmrgYou can tell what kind of node a particular tree is by using the
761debfc3dSmrg@code{TREE_CODE} macro.  Many, many macros take trees as input and
771debfc3dSmrgreturn trees as output.  However, most macros require a certain kind of
781debfc3dSmrgtree node as input.  In other words, there is a type-system for trees,
791debfc3dSmrgbut it is not reflected in the C type-system.
801debfc3dSmrg
811debfc3dSmrgFor safety, it is useful to configure GCC with @option{--enable-checking}.
821debfc3dSmrgAlthough this results in a significant performance penalty (since all
831debfc3dSmrgtree types are checked at run-time), and is therefore inappropriate in a
841debfc3dSmrgrelease version, it is extremely helpful during the development process.
851debfc3dSmrg
861debfc3dSmrgMany macros behave as predicates.  Many, although not all, of these
871debfc3dSmrgpredicates end in @samp{_P}.  Do not rely on the result type of these
881debfc3dSmrgmacros being of any particular type.  You may, however, rely on the fact
891debfc3dSmrgthat the type can be compared to @code{0}, so that statements like
901debfc3dSmrg@smallexample
911debfc3dSmrgif (TEST_P (t) && !TEST_P (y))
921debfc3dSmrg  x = 1;
931debfc3dSmrg@end smallexample
941debfc3dSmrg@noindent
951debfc3dSmrgand
961debfc3dSmrg@smallexample
971debfc3dSmrgint i = (TEST_P (t) != 0);
981debfc3dSmrg@end smallexample
991debfc3dSmrg@noindent
1001debfc3dSmrgare legal.  Macros that return @code{int} values now may be changed to
1011debfc3dSmrgreturn @code{tree} values, or other pointers in the future.  Even those
1021debfc3dSmrgthat continue to return @code{int} may return multiple nonzero codes
1031debfc3dSmrgwhere previously they returned only zero and one.  Therefore, you should
1041debfc3dSmrgnot write code like
1051debfc3dSmrg@smallexample
1061debfc3dSmrgif (TEST_P (t) == 1)
1071debfc3dSmrg@end smallexample
1081debfc3dSmrg@noindent
1091debfc3dSmrgas this code is not guaranteed to work correctly in the future.
1101debfc3dSmrg
1111debfc3dSmrgYou should not take the address of values returned by the macros or
1121debfc3dSmrgfunctions described here.  In particular, no guarantee is given that the
1131debfc3dSmrgvalues are lvalues.
1141debfc3dSmrg
1151debfc3dSmrgIn general, the names of macros are all in uppercase, while the names of
1161debfc3dSmrgfunctions are entirely in lowercase.  There are rare exceptions to this
1171debfc3dSmrgrule.  You should assume that any macro or function whose name is made
1181debfc3dSmrgup entirely of uppercase letters may evaluate its arguments more than
1191debfc3dSmrgonce.  You may assume that a macro or function whose name is made up
1201debfc3dSmrgentirely of lowercase letters will evaluate its arguments only once.
1211debfc3dSmrg
1221debfc3dSmrgThe @code{error_mark_node} is a special tree.  Its tree code is
1231debfc3dSmrg@code{ERROR_MARK}, but since there is only ever one node with that code,
1241debfc3dSmrgthe usual practice is to compare the tree against
1251debfc3dSmrg@code{error_mark_node}.  (This test is just a test for pointer
1261debfc3dSmrgequality.)  If an error has occurred during front-end processing the
1271debfc3dSmrgflag @code{errorcount} will be set.  If the front end has encountered
1281debfc3dSmrgcode it cannot handle, it will issue a message to the user and set
1291debfc3dSmrg@code{sorrycount}.  When these flags are set, any macro or function
1301debfc3dSmrgwhich normally returns a tree of a particular kind may instead return
1311debfc3dSmrgthe @code{error_mark_node}.  Thus, if you intend to do any processing of
1321debfc3dSmrgerroneous code, you must be prepared to deal with the
1331debfc3dSmrg@code{error_mark_node}.
1341debfc3dSmrg
1351debfc3dSmrgOccasionally, a particular tree slot (like an operand to an expression,
1361debfc3dSmrgor a particular field in a declaration) will be referred to as
1371debfc3dSmrg``reserved for the back end''.  These slots are used to store RTL when
1381debfc3dSmrgthe tree is converted to RTL for use by the GCC back end.  However, if
1391debfc3dSmrgthat process is not taking place (e.g., if the front end is being hooked
1401debfc3dSmrgup to an intelligent editor), then those slots may be used by the
1411debfc3dSmrgback end presently in use.
1421debfc3dSmrg
1431debfc3dSmrgIf you encounter situations that do not match this documentation, such
1441debfc3dSmrgas tree nodes of types not mentioned here, or macros documented to
1451debfc3dSmrgreturn entities of a particular kind that instead return entities of
1461debfc3dSmrgsome different kind, you have found a bug, either in the front end or in
1471debfc3dSmrgthe documentation.  Please report these bugs as you would any other
1481debfc3dSmrgbug.
1491debfc3dSmrg
1501debfc3dSmrg@menu
1511debfc3dSmrg* Macros and Functions::Macros and functions that can be used with all trees.
1521debfc3dSmrg* Identifiers::         The names of things.
1531debfc3dSmrg* Containers::          Lists and vectors.
1541debfc3dSmrg@end menu
1551debfc3dSmrg
1561debfc3dSmrg@c ---------------------------------------------------------------------
1571debfc3dSmrg@c Trees
1581debfc3dSmrg@c ---------------------------------------------------------------------
1591debfc3dSmrg
1601debfc3dSmrg@node Macros and Functions
1611debfc3dSmrg@subsection Trees
1621debfc3dSmrg@cindex tree
1631debfc3dSmrg@findex TREE_CHAIN
1641debfc3dSmrg@findex TREE_TYPE
1651debfc3dSmrg
1661debfc3dSmrgAll GENERIC trees have two fields in common.  First, @code{TREE_CHAIN}
1671debfc3dSmrgis a pointer that can be used as a singly-linked list to other trees.
1681debfc3dSmrgThe other is @code{TREE_TYPE}.  Many trees store the type of an
1691debfc3dSmrgexpression or declaration in this field.
1701debfc3dSmrg
1711debfc3dSmrgThese are some other functions for handling trees:
1721debfc3dSmrg
1731debfc3dSmrg@ftable @code
1741debfc3dSmrg
1751debfc3dSmrg@item tree_size
1761debfc3dSmrgReturn the number of bytes a tree takes.
1771debfc3dSmrg
1781debfc3dSmrg@item build0
1791debfc3dSmrg@itemx build1
1801debfc3dSmrg@itemx build2
1811debfc3dSmrg@itemx build3
1821debfc3dSmrg@itemx build4
1831debfc3dSmrg@itemx build5
1841debfc3dSmrg@itemx build6
1851debfc3dSmrg
1861debfc3dSmrgThese functions build a tree and supply values to put in each
1871debfc3dSmrgparameter.  The basic signature is @samp{@w{code, type, [operands]}}.
1881debfc3dSmrg@code{code} is the @code{TREE_CODE}, and @code{type} is a tree
1891debfc3dSmrgrepresenting the @code{TREE_TYPE}.  These are followed by the
1901debfc3dSmrgoperands, each of which is also a tree.
1911debfc3dSmrg
1921debfc3dSmrg@end ftable
1931debfc3dSmrg
1941debfc3dSmrg
1951debfc3dSmrg@c ---------------------------------------------------------------------
1961debfc3dSmrg@c Identifiers
1971debfc3dSmrg@c ---------------------------------------------------------------------
1981debfc3dSmrg
1991debfc3dSmrg@node Identifiers
2001debfc3dSmrg@subsection Identifiers
2011debfc3dSmrg@cindex identifier
2021debfc3dSmrg@cindex name
2031debfc3dSmrg@tindex IDENTIFIER_NODE
2041debfc3dSmrg
2051debfc3dSmrgAn @code{IDENTIFIER_NODE} represents a slightly more general concept
2061debfc3dSmrgthan the standard C or C++ concept of identifier.  In particular, an
2071debfc3dSmrg@code{IDENTIFIER_NODE} may contain a @samp{$}, or other extraordinary
2081debfc3dSmrgcharacters.
2091debfc3dSmrg
2101debfc3dSmrgThere are never two distinct @code{IDENTIFIER_NODE}s representing the
2111debfc3dSmrgsame identifier.  Therefore, you may use pointer equality to compare
2121debfc3dSmrg@code{IDENTIFIER_NODE}s, rather than using a routine like
2131debfc3dSmrg@code{strcmp}.  Use @code{get_identifier} to obtain the unique
2141debfc3dSmrg@code{IDENTIFIER_NODE} for a supplied string.
2151debfc3dSmrg
2161debfc3dSmrgYou can use the following macros to access identifiers:
2171debfc3dSmrg@ftable @code
2181debfc3dSmrg@item IDENTIFIER_POINTER
2191debfc3dSmrgThe string represented by the identifier, represented as a
2201debfc3dSmrg@code{char*}.  This string is always @code{NUL}-terminated, and contains
2211debfc3dSmrgno embedded @code{NUL} characters.
2221debfc3dSmrg
2231debfc3dSmrg@item IDENTIFIER_LENGTH
2241debfc3dSmrgThe length of the string returned by @code{IDENTIFIER_POINTER}, not
2251debfc3dSmrgincluding the trailing @code{NUL}.  This value of
2261debfc3dSmrg@code{IDENTIFIER_LENGTH (x)} is always the same as @code{strlen
2271debfc3dSmrg(IDENTIFIER_POINTER (x))}.
2281debfc3dSmrg
2291debfc3dSmrg@item IDENTIFIER_OPNAME_P
2301debfc3dSmrgThis predicate holds if the identifier represents the name of an
2311debfc3dSmrgoverloaded operator.  In this case, you should not depend on the
2321debfc3dSmrgcontents of either the @code{IDENTIFIER_POINTER} or the
2331debfc3dSmrg@code{IDENTIFIER_LENGTH}.
2341debfc3dSmrg
2351debfc3dSmrg@item IDENTIFIER_TYPENAME_P
2361debfc3dSmrgThis predicate holds if the identifier represents the name of a
2371debfc3dSmrguser-defined conversion operator.  In this case, the @code{TREE_TYPE} of
2381debfc3dSmrgthe @code{IDENTIFIER_NODE} holds the type to which the conversion
2391debfc3dSmrgoperator converts.
2401debfc3dSmrg
2411debfc3dSmrg@end ftable
2421debfc3dSmrg
2431debfc3dSmrg@c ---------------------------------------------------------------------
2441debfc3dSmrg@c Containers
2451debfc3dSmrg@c ---------------------------------------------------------------------
2461debfc3dSmrg
2471debfc3dSmrg@node Containers
2481debfc3dSmrg@subsection Containers
2491debfc3dSmrg@cindex container
2501debfc3dSmrg@cindex list
2511debfc3dSmrg@cindex vector
2521debfc3dSmrg@tindex TREE_LIST
2531debfc3dSmrg@tindex TREE_VEC
2541debfc3dSmrg@findex TREE_PURPOSE
2551debfc3dSmrg@findex TREE_VALUE
2561debfc3dSmrg@findex TREE_VEC_LENGTH
2571debfc3dSmrg@findex TREE_VEC_ELT
2581debfc3dSmrg
2591debfc3dSmrgTwo common container data structures can be represented directly with
2601debfc3dSmrgtree nodes.  A @code{TREE_LIST} is a singly linked list containing two
2611debfc3dSmrgtrees per node.  These are the @code{TREE_PURPOSE} and @code{TREE_VALUE}
2621debfc3dSmrgof each node.  (Often, the @code{TREE_PURPOSE} contains some kind of
2631debfc3dSmrgtag, or additional information, while the @code{TREE_VALUE} contains the
2641debfc3dSmrgmajority of the payload.  In other cases, the @code{TREE_PURPOSE} is
2651debfc3dSmrgsimply @code{NULL_TREE}, while in still others both the
2661debfc3dSmrg@code{TREE_PURPOSE} and @code{TREE_VALUE} are of equal stature.)  Given
2671debfc3dSmrgone @code{TREE_LIST} node, the next node is found by following the
2681debfc3dSmrg@code{TREE_CHAIN}.  If the @code{TREE_CHAIN} is @code{NULL_TREE}, then
2691debfc3dSmrgyou have reached the end of the list.
2701debfc3dSmrg
2711debfc3dSmrgA @code{TREE_VEC} is a simple vector.  The @code{TREE_VEC_LENGTH} is an
2721debfc3dSmrginteger (not a tree) giving the number of nodes in the vector.  The
2731debfc3dSmrgnodes themselves are accessed using the @code{TREE_VEC_ELT} macro, which
2741debfc3dSmrgtakes two arguments.  The first is the @code{TREE_VEC} in question; the
2751debfc3dSmrgsecond is an integer indicating which element in the vector is desired.
2761debfc3dSmrgThe elements are indexed from zero.
2771debfc3dSmrg
2781debfc3dSmrg@c ---------------------------------------------------------------------
2791debfc3dSmrg@c Types
2801debfc3dSmrg@c ---------------------------------------------------------------------
2811debfc3dSmrg
2821debfc3dSmrg@node Types
2831debfc3dSmrg@section Types
2841debfc3dSmrg@cindex type
2851debfc3dSmrg@cindex pointer
2861debfc3dSmrg@cindex reference
2871debfc3dSmrg@cindex fundamental type
2881debfc3dSmrg@cindex array
2891debfc3dSmrg@tindex VOID_TYPE
2901debfc3dSmrg@tindex INTEGER_TYPE
2911debfc3dSmrg@tindex TYPE_MIN_VALUE
2921debfc3dSmrg@tindex TYPE_MAX_VALUE
2931debfc3dSmrg@tindex REAL_TYPE
2941debfc3dSmrg@tindex FIXED_POINT_TYPE
2951debfc3dSmrg@tindex COMPLEX_TYPE
2961debfc3dSmrg@tindex ENUMERAL_TYPE
2971debfc3dSmrg@tindex BOOLEAN_TYPE
2981debfc3dSmrg@tindex POINTER_TYPE
2991debfc3dSmrg@tindex REFERENCE_TYPE
3001debfc3dSmrg@tindex FUNCTION_TYPE
3011debfc3dSmrg@tindex METHOD_TYPE
3021debfc3dSmrg@tindex ARRAY_TYPE
3031debfc3dSmrg@tindex RECORD_TYPE
3041debfc3dSmrg@tindex UNION_TYPE
3051debfc3dSmrg@tindex UNKNOWN_TYPE
3061debfc3dSmrg@tindex OFFSET_TYPE
3071debfc3dSmrg@findex TYPE_UNQUALIFIED
3081debfc3dSmrg@findex TYPE_QUAL_CONST
3091debfc3dSmrg@findex TYPE_QUAL_VOLATILE
3101debfc3dSmrg@findex TYPE_QUAL_RESTRICT
3111debfc3dSmrg@findex TYPE_MAIN_VARIANT
3121debfc3dSmrg@cindex qualified type
3131debfc3dSmrg@findex TYPE_SIZE
3141debfc3dSmrg@findex TYPE_ALIGN
3151debfc3dSmrg@findex TYPE_PRECISION
3161debfc3dSmrg@findex TYPE_ARG_TYPES
3171debfc3dSmrg@findex TYPE_METHOD_BASETYPE
3181debfc3dSmrg@findex TYPE_OFFSET_BASETYPE
3191debfc3dSmrg@findex TREE_TYPE
3201debfc3dSmrg@findex TYPE_CONTEXT
3211debfc3dSmrg@findex TYPE_NAME
3221debfc3dSmrg@findex TYPENAME_TYPE_FULLNAME
3231debfc3dSmrg@findex TYPE_FIELDS
3241debfc3dSmrg@findex TYPE_CANONICAL
3251debfc3dSmrg@findex TYPE_STRUCTURAL_EQUALITY_P
3261debfc3dSmrg@findex SET_TYPE_STRUCTURAL_EQUALITY
3271debfc3dSmrg
3281debfc3dSmrgAll types have corresponding tree nodes.  However, you should not assume
3291debfc3dSmrgthat there is exactly one tree node corresponding to each type.  There
3301debfc3dSmrgare often multiple nodes corresponding to the same type.
3311debfc3dSmrg
3321debfc3dSmrgFor the most part, different kinds of types have different tree codes.
3331debfc3dSmrg(For example, pointer types use a @code{POINTER_TYPE} code while arrays
3341debfc3dSmrguse an @code{ARRAY_TYPE} code.)  However, pointers to member functions
3351debfc3dSmrguse the @code{RECORD_TYPE} code.  Therefore, when writing a
3361debfc3dSmrg@code{switch} statement that depends on the code associated with a
3371debfc3dSmrgparticular type, you should take care to handle pointers to member
3381debfc3dSmrgfunctions under the @code{RECORD_TYPE} case label.
3391debfc3dSmrg
3401debfc3dSmrgThe following functions and macros deal with cv-qualification of types:
3411debfc3dSmrg@ftable @code
3421debfc3dSmrg@item TYPE_MAIN_VARIANT
3431debfc3dSmrgThis macro returns the unqualified version of a type.  It may be applied
3441debfc3dSmrgto an unqualified type, but it is not always the identity function in
3451debfc3dSmrgthat case.
3461debfc3dSmrg@end ftable
3471debfc3dSmrg
3481debfc3dSmrgA few other macros and functions are usable with all types:
3491debfc3dSmrg@ftable @code
3501debfc3dSmrg@item TYPE_SIZE
3511debfc3dSmrgThe number of bits required to represent the type, represented as an
3521debfc3dSmrg@code{INTEGER_CST}.  For an incomplete type, @code{TYPE_SIZE} will be
3531debfc3dSmrg@code{NULL_TREE}.
3541debfc3dSmrg
3551debfc3dSmrg@item TYPE_ALIGN
3561debfc3dSmrgThe alignment of the type, in bits, represented as an @code{int}.
3571debfc3dSmrg
3581debfc3dSmrg@item TYPE_NAME
3591debfc3dSmrgThis macro returns a declaration (in the form of a @code{TYPE_DECL}) for
3601debfc3dSmrgthe type.  (Note this macro does @emph{not} return an
3611debfc3dSmrg@code{IDENTIFIER_NODE}, as you might expect, given its name!)  You can
3621debfc3dSmrglook at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the
3631debfc3dSmrgactual name of the type.  The @code{TYPE_NAME} will be @code{NULL_TREE}
3641debfc3dSmrgfor a type that is not a built-in type, the result of a typedef, or a
3651debfc3dSmrgnamed class type.
3661debfc3dSmrg
3671debfc3dSmrg@item TYPE_CANONICAL
3681debfc3dSmrgThis macro returns the ``canonical'' type for the given type
3691debfc3dSmrgnode. Canonical types are used to improve performance in the C++ and
3701debfc3dSmrgObjective-C++ front ends by allowing efficient comparison between two
3711debfc3dSmrgtype nodes in @code{same_type_p}: if the @code{TYPE_CANONICAL} values
3721debfc3dSmrgof the types are equal, the types are equivalent; otherwise, the types
3731debfc3dSmrgare not equivalent. The notion of equivalence for canonical types is
3741debfc3dSmrgthe same as the notion of type equivalence in the language itself. For
3751debfc3dSmrginstance,
3761debfc3dSmrg
3771debfc3dSmrgWhen @code{TYPE_CANONICAL} is @code{NULL_TREE}, there is no canonical
3781debfc3dSmrgtype for the given type node. In this case, comparison between this
3791debfc3dSmrgtype and any other type requires the compiler to perform a deep,
3801debfc3dSmrg``structural'' comparison to see if the two type nodes have the same
3811debfc3dSmrgform and properties.
3821debfc3dSmrg
3831debfc3dSmrgThe canonical type for a node is always the most fundamental type in
3841debfc3dSmrgthe equivalence class of types. For instance, @code{int} is its own
3851debfc3dSmrgcanonical type. A typedef @code{I} of @code{int} will have @code{int}
3861debfc3dSmrgas its canonical type. Similarly, @code{I*}@ and a typedef @code{IP}@
3871debfc3dSmrg(defined to @code{I*}) will has @code{int*} as their canonical
3881debfc3dSmrgtype. When building a new type node, be sure to set
3891debfc3dSmrg@code{TYPE_CANONICAL} to the appropriate canonical type. If the new
3901debfc3dSmrgtype is a compound type (built from other types), and any of those
3911debfc3dSmrgother types require structural equality, use
3921debfc3dSmrg@code{SET_TYPE_STRUCTURAL_EQUALITY} to ensure that the new type also
3931debfc3dSmrgrequires structural equality. Finally, if for some reason you cannot
3941debfc3dSmrgguarantee that @code{TYPE_CANONICAL} will point to the canonical type,
3951debfc3dSmrguse @code{SET_TYPE_STRUCTURAL_EQUALITY} to make sure that the new
3961debfc3dSmrgtype--and any type constructed based on it--requires structural
3971debfc3dSmrgequality. If you suspect that the canonical type system is
3981debfc3dSmrgmiscomparing types, pass @code{--param verify-canonical-types=1} to
3991debfc3dSmrgthe compiler or configure with @code{--enable-checking} to force the
4001debfc3dSmrgcompiler to verify its canonical-type comparisons against the
4011debfc3dSmrgstructural comparisons; the compiler will then print any warnings if
4021debfc3dSmrgthe canonical types miscompare.
4031debfc3dSmrg
4041debfc3dSmrg@item TYPE_STRUCTURAL_EQUALITY_P
4051debfc3dSmrgThis predicate holds when the node requires structural equality
4061debfc3dSmrgchecks, e.g., when @code{TYPE_CANONICAL} is @code{NULL_TREE}.
4071debfc3dSmrg
4081debfc3dSmrg@item SET_TYPE_STRUCTURAL_EQUALITY
4091debfc3dSmrgThis macro states that the type node it is given requires structural
4101debfc3dSmrgequality checks, e.g., it sets @code{TYPE_CANONICAL} to
4111debfc3dSmrg@code{NULL_TREE}.
4121debfc3dSmrg
4131debfc3dSmrg@item same_type_p
4141debfc3dSmrgThis predicate takes two types as input, and holds if they are the same
4151debfc3dSmrgtype.  For example, if one type is a @code{typedef} for the other, or
4161debfc3dSmrgboth are @code{typedef}s for the same type.  This predicate also holds if
4171debfc3dSmrgthe two trees given as input are simply copies of one another; i.e.,
4181debfc3dSmrgthere is no difference between them at the source level, but, for
4191debfc3dSmrgwhatever reason, a duplicate has been made in the representation.  You
4201debfc3dSmrgshould never use @code{==} (pointer equality) to compare types; always
4211debfc3dSmrguse @code{same_type_p} instead.
4221debfc3dSmrg@end ftable
4231debfc3dSmrg
4241debfc3dSmrgDetailed below are the various kinds of types, and the macros that can
4251debfc3dSmrgbe used to access them.  Although other kinds of types are used
4261debfc3dSmrgelsewhere in G++, the types described here are the only ones that you
4271debfc3dSmrgwill encounter while examining the intermediate representation.
4281debfc3dSmrg
4291debfc3dSmrg@table @code
4301debfc3dSmrg@item VOID_TYPE
4311debfc3dSmrgUsed to represent the @code{void} type.
4321debfc3dSmrg
4331debfc3dSmrg@item INTEGER_TYPE
4341debfc3dSmrgUsed to represent the various integral types, including @code{char},
4351debfc3dSmrg@code{short}, @code{int}, @code{long}, and @code{long long}.  This code
4361debfc3dSmrgis not used for enumeration types, nor for the @code{bool} type.
4371debfc3dSmrgThe @code{TYPE_PRECISION} is the number of bits used in
4381debfc3dSmrgthe representation, represented as an @code{unsigned int}.  (Note that
4391debfc3dSmrgin the general case this is not the same value as @code{TYPE_SIZE};
4401debfc3dSmrgsuppose that there were a 24-bit integer type, but that alignment
4411debfc3dSmrgrequirements for the ABI required 32-bit alignment.  Then,
4421debfc3dSmrg@code{TYPE_SIZE} would be an @code{INTEGER_CST} for 32, while
4431debfc3dSmrg@code{TYPE_PRECISION} would be 24.)  The integer type is unsigned if
4441debfc3dSmrg@code{TYPE_UNSIGNED} holds; otherwise, it is signed.
4451debfc3dSmrg
4461debfc3dSmrgThe @code{TYPE_MIN_VALUE} is an @code{INTEGER_CST} for the smallest
4471debfc3dSmrginteger that may be represented by this type.  Similarly, the
4481debfc3dSmrg@code{TYPE_MAX_VALUE} is an @code{INTEGER_CST} for the largest integer
4491debfc3dSmrgthat may be represented by this type.
4501debfc3dSmrg
4511debfc3dSmrg@item REAL_TYPE
4521debfc3dSmrgUsed to represent the @code{float}, @code{double}, and @code{long
4531debfc3dSmrgdouble} types.  The number of bits in the floating-point representation
4541debfc3dSmrgis given by @code{TYPE_PRECISION}, as in the @code{INTEGER_TYPE} case.
4551debfc3dSmrg
4561debfc3dSmrg@item FIXED_POINT_TYPE
4571debfc3dSmrgUsed to represent the @code{short _Fract}, @code{_Fract}, @code{long
4581debfc3dSmrg_Fract}, @code{long long _Fract}, @code{short _Accum}, @code{_Accum},
4591debfc3dSmrg@code{long _Accum}, and @code{long long _Accum} types.  The number of bits
4601debfc3dSmrgin the fixed-point representation is given by @code{TYPE_PRECISION},
4611debfc3dSmrgas in the @code{INTEGER_TYPE} case.  There may be padding bits, fractional
4621debfc3dSmrgbits and integral bits.  The number of fractional bits is given by
4631debfc3dSmrg@code{TYPE_FBIT}, and the number of integral bits is given by @code{TYPE_IBIT}.
4641debfc3dSmrgThe fixed-point type is unsigned if @code{TYPE_UNSIGNED} holds; otherwise,
4651debfc3dSmrgit is signed.
4661debfc3dSmrgThe fixed-point type is saturating if @code{TYPE_SATURATING} holds; otherwise,
4671debfc3dSmrgit is not saturating.
4681debfc3dSmrg
4691debfc3dSmrg@item COMPLEX_TYPE
4701debfc3dSmrgUsed to represent GCC built-in @code{__complex__} data types.  The
4711debfc3dSmrg@code{TREE_TYPE} is the type of the real and imaginary parts.
4721debfc3dSmrg
4731debfc3dSmrg@item ENUMERAL_TYPE
4741debfc3dSmrgUsed to represent an enumeration type.  The @code{TYPE_PRECISION} gives
4751debfc3dSmrg(as an @code{int}), the number of bits used to represent the type.  If
4761debfc3dSmrgthere are no negative enumeration constants, @code{TYPE_UNSIGNED} will
4771debfc3dSmrghold.  The minimum and maximum enumeration constants may be obtained
4781debfc3dSmrgwith @code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE}, respectively; each
4791debfc3dSmrgof these macros returns an @code{INTEGER_CST}.
4801debfc3dSmrg
4811debfc3dSmrgThe actual enumeration constants themselves may be obtained by looking
4821debfc3dSmrgat the @code{TYPE_VALUES}.  This macro will return a @code{TREE_LIST},
4831debfc3dSmrgcontaining the constants.  The @code{TREE_PURPOSE} of each node will be
4841debfc3dSmrgan @code{IDENTIFIER_NODE} giving the name of the constant; the
4851debfc3dSmrg@code{TREE_VALUE} will be an @code{INTEGER_CST} giving the value
4861debfc3dSmrgassigned to that constant.  These constants will appear in the order in
4871debfc3dSmrgwhich they were declared.  The @code{TREE_TYPE} of each of these
4881debfc3dSmrgconstants will be the type of enumeration type itself.
4891debfc3dSmrg
4901debfc3dSmrg@item BOOLEAN_TYPE
4911debfc3dSmrgUsed to represent the @code{bool} type.
4921debfc3dSmrg
4931debfc3dSmrg@item POINTER_TYPE
4941debfc3dSmrgUsed to represent pointer types, and pointer to data member types.  The
4951debfc3dSmrg@code{TREE_TYPE} gives the type to which this type points.
4961debfc3dSmrg
4971debfc3dSmrg@item REFERENCE_TYPE
4981debfc3dSmrgUsed to represent reference types.  The @code{TREE_TYPE} gives the type
4991debfc3dSmrgto which this type refers.
5001debfc3dSmrg
5011debfc3dSmrg@item FUNCTION_TYPE
5021debfc3dSmrgUsed to represent the type of non-member functions and of static member
5031debfc3dSmrgfunctions.  The @code{TREE_TYPE} gives the return type of the function.
5041debfc3dSmrgThe @code{TYPE_ARG_TYPES} are a @code{TREE_LIST} of the argument types.
5051debfc3dSmrgThe @code{TREE_VALUE} of each node in this list is the type of the
5061debfc3dSmrgcorresponding argument; the @code{TREE_PURPOSE} is an expression for the
5071debfc3dSmrgdefault argument value, if any.  If the last node in the list is
5081debfc3dSmrg@code{void_list_node} (a @code{TREE_LIST} node whose @code{TREE_VALUE}
5091debfc3dSmrgis the @code{void_type_node}), then functions of this type do not take
5101debfc3dSmrgvariable arguments.  Otherwise, they do take a variable number of
5111debfc3dSmrgarguments.
5121debfc3dSmrg
5131debfc3dSmrgNote that in C (but not in C++) a function declared like @code{void f()}
5141debfc3dSmrgis an unprototyped function taking a variable number of arguments; the
5151debfc3dSmrg@code{TYPE_ARG_TYPES} of such a function will be @code{NULL}.
5161debfc3dSmrg
5171debfc3dSmrg@item METHOD_TYPE
5181debfc3dSmrgUsed to represent the type of a non-static member function.  Like a
5191debfc3dSmrg@code{FUNCTION_TYPE}, the return type is given by the @code{TREE_TYPE}.
5201debfc3dSmrgThe type of @code{*this}, i.e., the class of which functions of this
5211debfc3dSmrgtype are a member, is given by the @code{TYPE_METHOD_BASETYPE}.  The
5221debfc3dSmrg@code{TYPE_ARG_TYPES} is the parameter list, as for a
5231debfc3dSmrg@code{FUNCTION_TYPE}, and includes the @code{this} argument.
5241debfc3dSmrg
5251debfc3dSmrg@item ARRAY_TYPE
5261debfc3dSmrgUsed to represent array types.  The @code{TREE_TYPE} gives the type of
5271debfc3dSmrgthe elements in the array.  If the array-bound is present in the type,
5281debfc3dSmrgthe @code{TYPE_DOMAIN} is an @code{INTEGER_TYPE} whose
5291debfc3dSmrg@code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE} will be the lower and
5301debfc3dSmrgupper bounds of the array, respectively.  The @code{TYPE_MIN_VALUE} will
5311debfc3dSmrgalways be an @code{INTEGER_CST} for zero, while the
5321debfc3dSmrg@code{TYPE_MAX_VALUE} will be one less than the number of elements in
5331debfc3dSmrgthe array, i.e., the highest value which may be used to index an element
5341debfc3dSmrgin the array.
5351debfc3dSmrg
5361debfc3dSmrg@item RECORD_TYPE
5371debfc3dSmrgUsed to represent @code{struct} and @code{class} types, as well as
5381debfc3dSmrgpointers to member functions and similar constructs in other languages.
5391debfc3dSmrg@code{TYPE_FIELDS} contains the items contained in this type, each of
5401debfc3dSmrgwhich can be a @code{FIELD_DECL}, @code{VAR_DECL}, @code{CONST_DECL}, or
5411debfc3dSmrg@code{TYPE_DECL}.  You may not make any assumptions about the ordering
5421debfc3dSmrgof the fields in the type or whether one or more of them overlap.
5431debfc3dSmrg
5441debfc3dSmrg@item UNION_TYPE
5451debfc3dSmrgUsed to represent @code{union} types.  Similar to @code{RECORD_TYPE}
5461debfc3dSmrgexcept that all @code{FIELD_DECL} nodes in @code{TYPE_FIELD} start at
5471debfc3dSmrgbit position zero.
5481debfc3dSmrg
5491debfc3dSmrg@item QUAL_UNION_TYPE
5501debfc3dSmrgUsed to represent part of a variant record in Ada.  Similar to
5511debfc3dSmrg@code{UNION_TYPE} except that each @code{FIELD_DECL} has a
5521debfc3dSmrg@code{DECL_QUALIFIER} field, which contains a boolean expression that
5531debfc3dSmrgindicates whether the field is present in the object.  The type will only
5541debfc3dSmrghave one field, so each field's @code{DECL_QUALIFIER} is only evaluated
5551debfc3dSmrgif none of the expressions in the previous fields in @code{TYPE_FIELDS}
5561debfc3dSmrgare nonzero.  Normally these expressions will reference a field in the
5571debfc3dSmrgouter object using a @code{PLACEHOLDER_EXPR}.
5581debfc3dSmrg
5591debfc3dSmrg@item LANG_TYPE
5601debfc3dSmrgThis node is used to represent a language-specific type.  The front
5611debfc3dSmrgend must handle it.
5621debfc3dSmrg
5631debfc3dSmrg@item OFFSET_TYPE
5641debfc3dSmrgThis node is used to represent a pointer-to-data member.  For a data
5651debfc3dSmrgmember @code{X::m} the @code{TYPE_OFFSET_BASETYPE} is @code{X} and the
5661debfc3dSmrg@code{TREE_TYPE} is the type of @code{m}.
5671debfc3dSmrg
5681debfc3dSmrg@end table
5691debfc3dSmrg
5701debfc3dSmrgThere are variables whose values represent some of the basic types.
5711debfc3dSmrgThese include:
5721debfc3dSmrg@table @code
5731debfc3dSmrg@item void_type_node
5741debfc3dSmrgA node for @code{void}.
5751debfc3dSmrg
5761debfc3dSmrg@item integer_type_node
5771debfc3dSmrgA node for @code{int}.
5781debfc3dSmrg
5791debfc3dSmrg@item unsigned_type_node.
5801debfc3dSmrgA node for @code{unsigned int}.
5811debfc3dSmrg
5821debfc3dSmrg@item char_type_node.
5831debfc3dSmrgA node for @code{char}.
5841debfc3dSmrg@end table
5851debfc3dSmrg@noindent
5861debfc3dSmrgIt may sometimes be useful to compare one of these variables with a type
5871debfc3dSmrgin hand, using @code{same_type_p}.
5881debfc3dSmrg
5891debfc3dSmrg@c ---------------------------------------------------------------------
5901debfc3dSmrg@c Declarations
5911debfc3dSmrg@c ---------------------------------------------------------------------
5921debfc3dSmrg
5931debfc3dSmrg@node Declarations
5941debfc3dSmrg@section Declarations
5951debfc3dSmrg@cindex declaration
5961debfc3dSmrg@cindex variable
5971debfc3dSmrg@cindex type declaration
5981debfc3dSmrg@tindex LABEL_DECL
5991debfc3dSmrg@tindex CONST_DECL
6001debfc3dSmrg@tindex TYPE_DECL
6011debfc3dSmrg@tindex VAR_DECL
6021debfc3dSmrg@tindex PARM_DECL
6031debfc3dSmrg@tindex DEBUG_EXPR_DECL
6041debfc3dSmrg@tindex FIELD_DECL
6051debfc3dSmrg@tindex NAMESPACE_DECL
6061debfc3dSmrg@tindex RESULT_DECL
6071debfc3dSmrg@tindex TEMPLATE_DECL
6081debfc3dSmrg@tindex THUNK_DECL
6091debfc3dSmrg@findex THUNK_DELTA
6101debfc3dSmrg@findex DECL_INITIAL
6111debfc3dSmrg@findex DECL_SIZE
6121debfc3dSmrg@findex DECL_ALIGN
6131debfc3dSmrg@findex DECL_EXTERNAL
6141debfc3dSmrg
6151debfc3dSmrgThis section covers the various kinds of declarations that appear in the
6161debfc3dSmrginternal representation, except for declarations of functions
6171debfc3dSmrg(represented by @code{FUNCTION_DECL} nodes), which are described in
6181debfc3dSmrg@ref{Functions}.
6191debfc3dSmrg
6201debfc3dSmrg@menu
6211debfc3dSmrg* Working with declarations::  Macros and functions that work on
6221debfc3dSmrgdeclarations.
6231debfc3dSmrg* Internal structure:: How declaration nodes are represented.
6241debfc3dSmrg@end menu
6251debfc3dSmrg
6261debfc3dSmrg@node Working with declarations
6271debfc3dSmrg@subsection Working with declarations
6281debfc3dSmrg
6291debfc3dSmrgSome macros can be used with any kind of declaration.  These include:
6301debfc3dSmrg@ftable @code
6311debfc3dSmrg@item DECL_NAME
6321debfc3dSmrgThis macro returns an @code{IDENTIFIER_NODE} giving the name of the
6331debfc3dSmrgentity.
6341debfc3dSmrg
6351debfc3dSmrg@item TREE_TYPE
6361debfc3dSmrgThis macro returns the type of the entity declared.
6371debfc3dSmrg
6381debfc3dSmrg@item EXPR_FILENAME
6391debfc3dSmrgThis macro returns the name of the file in which the entity was
6401debfc3dSmrgdeclared, as a @code{char*}.  For an entity declared implicitly by the
6411debfc3dSmrgcompiler (like @code{__builtin_memcpy}), this will be the string
6421debfc3dSmrg@code{"<internal>"}.
6431debfc3dSmrg
6441debfc3dSmrg@item EXPR_LINENO
6451debfc3dSmrgThis macro returns the line number at which the entity was declared, as
6461debfc3dSmrgan @code{int}.
6471debfc3dSmrg
6481debfc3dSmrg@item DECL_ARTIFICIAL
6491debfc3dSmrgThis predicate holds if the declaration was implicitly generated by the
6501debfc3dSmrgcompiler.  For example, this predicate will hold of an implicitly
6511debfc3dSmrgdeclared member function, or of the @code{TYPE_DECL} implicitly
6521debfc3dSmrggenerated for a class type.  Recall that in C++ code like:
6531debfc3dSmrg@smallexample
6541debfc3dSmrgstruct S @{@};
6551debfc3dSmrg@end smallexample
6561debfc3dSmrg@noindent
6571debfc3dSmrgis roughly equivalent to C code like:
6581debfc3dSmrg@smallexample
6591debfc3dSmrgstruct S @{@};
6601debfc3dSmrgtypedef struct S S;
6611debfc3dSmrg@end smallexample
6621debfc3dSmrgThe implicitly generated @code{typedef} declaration is represented by a
6631debfc3dSmrg@code{TYPE_DECL} for which @code{DECL_ARTIFICIAL} holds.
6641debfc3dSmrg
6651debfc3dSmrg@end ftable
6661debfc3dSmrg
6671debfc3dSmrgThe various kinds of declarations include:
6681debfc3dSmrg@table @code
6691debfc3dSmrg@item LABEL_DECL
6701debfc3dSmrgThese nodes are used to represent labels in function bodies.  For more
6711debfc3dSmrginformation, see @ref{Functions}.  These nodes only appear in block
6721debfc3dSmrgscopes.
6731debfc3dSmrg
6741debfc3dSmrg@item CONST_DECL
6751debfc3dSmrgThese nodes are used to represent enumeration constants.  The value of
6761debfc3dSmrgthe constant is given by @code{DECL_INITIAL} which will be an
6771debfc3dSmrg@code{INTEGER_CST} with the same type as the @code{TREE_TYPE} of the
6781debfc3dSmrg@code{CONST_DECL}, i.e., an @code{ENUMERAL_TYPE}.
6791debfc3dSmrg
6801debfc3dSmrg@item RESULT_DECL
6811debfc3dSmrgThese nodes represent the value returned by a function.  When a value is
6821debfc3dSmrgassigned to a @code{RESULT_DECL}, that indicates that the value should
6831debfc3dSmrgbe returned, via bitwise copy, by the function.  You can use
6841debfc3dSmrg@code{DECL_SIZE} and @code{DECL_ALIGN} on a @code{RESULT_DECL}, just as
6851debfc3dSmrgwith a @code{VAR_DECL}.
6861debfc3dSmrg
6871debfc3dSmrg@item TYPE_DECL
6881debfc3dSmrgThese nodes represent @code{typedef} declarations.  The @code{TREE_TYPE}
6891debfc3dSmrgis the type declared to have the name given by @code{DECL_NAME}.  In
6901debfc3dSmrgsome cases, there is no associated name.
6911debfc3dSmrg
6921debfc3dSmrg@item VAR_DECL
6931debfc3dSmrgThese nodes represent variables with namespace or block scope, as well
6941debfc3dSmrgas static data members.  The @code{DECL_SIZE} and @code{DECL_ALIGN} are
6951debfc3dSmrganalogous to @code{TYPE_SIZE} and @code{TYPE_ALIGN}.  For a declaration,
6961debfc3dSmrgyou should always use the @code{DECL_SIZE} and @code{DECL_ALIGN} rather
6971debfc3dSmrgthan the @code{TYPE_SIZE} and @code{TYPE_ALIGN} given by the
6981debfc3dSmrg@code{TREE_TYPE}, since special attributes may have been applied to the
6991debfc3dSmrgvariable to give it a particular size and alignment.  You may use the
7001debfc3dSmrgpredicates @code{DECL_THIS_STATIC} or @code{DECL_THIS_EXTERN} to test
7011debfc3dSmrgwhether the storage class specifiers @code{static} or @code{extern} were
7021debfc3dSmrgused to declare a variable.
7031debfc3dSmrg
7041debfc3dSmrgIf this variable is initialized (but does not require a constructor),
7051debfc3dSmrgthe @code{DECL_INITIAL} will be an expression for the initializer.  The
7061debfc3dSmrginitializer should be evaluated, and a bitwise copy into the variable
7071debfc3dSmrgperformed.  If the @code{DECL_INITIAL} is the @code{error_mark_node},
7081debfc3dSmrgthere is an initializer, but it is given by an explicit statement later
7091debfc3dSmrgin the code; no bitwise copy is required.
7101debfc3dSmrg
7111debfc3dSmrgGCC provides an extension that allows either automatic variables, or
7121debfc3dSmrgglobal variables, to be placed in particular registers.  This extension
7131debfc3dSmrgis being used for a particular @code{VAR_DECL} if @code{DECL_REGISTER}
7141debfc3dSmrgholds for the @code{VAR_DECL}, and if @code{DECL_ASSEMBLER_NAME} is not
7151debfc3dSmrgequal to @code{DECL_NAME}.  In that case, @code{DECL_ASSEMBLER_NAME} is
7161debfc3dSmrgthe name of the register into which the variable will be placed.
7171debfc3dSmrg
7181debfc3dSmrg@item PARM_DECL
7191debfc3dSmrgUsed to represent a parameter to a function.  Treat these nodes
7201debfc3dSmrgsimilarly to @code{VAR_DECL} nodes.  These nodes only appear in the
7211debfc3dSmrg@code{DECL_ARGUMENTS} for a @code{FUNCTION_DECL}.
7221debfc3dSmrg
7231debfc3dSmrgThe @code{DECL_ARG_TYPE} for a @code{PARM_DECL} is the type that will
7241debfc3dSmrgactually be used when a value is passed to this function.  It may be a
7251debfc3dSmrgwider type than the @code{TREE_TYPE} of the parameter; for example, the
7261debfc3dSmrgordinary type might be @code{short} while the @code{DECL_ARG_TYPE} is
7271debfc3dSmrg@code{int}.
7281debfc3dSmrg
7291debfc3dSmrg@item DEBUG_EXPR_DECL
7301debfc3dSmrgUsed to represent an anonymous debug-information temporary created to
7311debfc3dSmrghold an expression as it is optimized away, so that its value can be
7321debfc3dSmrgreferenced in debug bind statements.
7331debfc3dSmrg
7341debfc3dSmrg@item FIELD_DECL
7351debfc3dSmrgThese nodes represent non-static data members.  The @code{DECL_SIZE} and
7361debfc3dSmrg@code{DECL_ALIGN} behave as for @code{VAR_DECL} nodes.
7371debfc3dSmrgThe position of the field within the parent record is specified by a
7381debfc3dSmrgcombination of three attributes.  @code{DECL_FIELD_OFFSET} is the position,
7391debfc3dSmrgcounting in bytes, of the @code{DECL_OFFSET_ALIGN}-bit sized word containing
7401debfc3dSmrgthe bit of the field closest to the beginning of the structure.
7411debfc3dSmrg@code{DECL_FIELD_BIT_OFFSET} is the bit offset of the first bit of the field
7421debfc3dSmrgwithin this word; this may be nonzero even for fields that are not bit-fields,
7431debfc3dSmrgsince @code{DECL_OFFSET_ALIGN} may be greater than the natural alignment
7441debfc3dSmrgof the field's type.
7451debfc3dSmrg
7461debfc3dSmrgIf @code{DECL_C_BIT_FIELD} holds, this field is a bit-field.  In a bit-field,
7471debfc3dSmrg@code{DECL_BIT_FIELD_TYPE} also contains the type that was originally
7481debfc3dSmrgspecified for it, while DECL_TYPE may be a modified type with lesser precision,
7491debfc3dSmrgaccording to the size of the bit field.
7501debfc3dSmrg
7511debfc3dSmrg@item NAMESPACE_DECL
7521debfc3dSmrgNamespaces provide a name hierarchy for other declarations.  They
7531debfc3dSmrgappear in the @code{DECL_CONTEXT} of other @code{_DECL} nodes.
7541debfc3dSmrg
7551debfc3dSmrg@end table
7561debfc3dSmrg
7571debfc3dSmrg@node Internal structure
7581debfc3dSmrg@subsection Internal structure
7591debfc3dSmrg
7601debfc3dSmrg@code{DECL} nodes are represented internally as a hierarchy of
7611debfc3dSmrgstructures.
7621debfc3dSmrg
7631debfc3dSmrg@menu
7641debfc3dSmrg* Current structure hierarchy::  The current DECL node structure
7651debfc3dSmrghierarchy.
7661debfc3dSmrg* Adding new DECL node types:: How to add a new DECL node to a
7671debfc3dSmrgfrontend.
7681debfc3dSmrg@end menu
7691debfc3dSmrg
7701debfc3dSmrg@node Current structure hierarchy
7711debfc3dSmrg@subsubsection Current structure hierarchy
7721debfc3dSmrg
7731debfc3dSmrg@table @code
7741debfc3dSmrg
7751debfc3dSmrg@item struct tree_decl_minimal
7761debfc3dSmrgThis is the minimal structure to inherit from in order for common
7771debfc3dSmrg@code{DECL} macros to work.  The fields it contains are a unique ID,
7781debfc3dSmrgsource location, context, and name.
7791debfc3dSmrg
7801debfc3dSmrg@item struct tree_decl_common
7811debfc3dSmrgThis structure inherits from @code{struct tree_decl_minimal}.  It
7821debfc3dSmrgcontains fields that most @code{DECL} nodes need, such as a field to
7831debfc3dSmrgstore alignment, machine mode, size, and attributes.
7841debfc3dSmrg
7851debfc3dSmrg@item struct tree_field_decl
7861debfc3dSmrgThis structure inherits from @code{struct tree_decl_common}.  It is
7871debfc3dSmrgused to represent @code{FIELD_DECL}.
7881debfc3dSmrg
7891debfc3dSmrg@item struct tree_label_decl
7901debfc3dSmrgThis structure inherits from @code{struct tree_decl_common}.  It is
7911debfc3dSmrgused to represent @code{LABEL_DECL}.
7921debfc3dSmrg
7931debfc3dSmrg@item struct tree_translation_unit_decl
7941debfc3dSmrgThis structure inherits from @code{struct tree_decl_common}.  It is
7951debfc3dSmrgused to represent @code{TRANSLATION_UNIT_DECL}.
7961debfc3dSmrg
7971debfc3dSmrg@item struct tree_decl_with_rtl
7981debfc3dSmrgThis structure inherits from @code{struct tree_decl_common}.  It
7991debfc3dSmrgcontains a field to store the low-level RTL associated with a
8001debfc3dSmrg@code{DECL} node.
8011debfc3dSmrg
8021debfc3dSmrg@item struct tree_result_decl
8031debfc3dSmrgThis structure inherits from @code{struct tree_decl_with_rtl}.  It is
8041debfc3dSmrgused to represent @code{RESULT_DECL}.
8051debfc3dSmrg
8061debfc3dSmrg@item struct tree_const_decl
8071debfc3dSmrgThis structure inherits from @code{struct tree_decl_with_rtl}.  It is
8081debfc3dSmrgused to represent @code{CONST_DECL}.
8091debfc3dSmrg
8101debfc3dSmrg@item struct tree_parm_decl
8111debfc3dSmrgThis structure inherits from @code{struct tree_decl_with_rtl}.  It is
8121debfc3dSmrgused to represent @code{PARM_DECL}.
8131debfc3dSmrg
8141debfc3dSmrg@item struct tree_decl_with_vis
8151debfc3dSmrgThis structure inherits from @code{struct tree_decl_with_rtl}.  It
8161debfc3dSmrgcontains fields necessary to store visibility information, as well as
8171debfc3dSmrga section name and assembler name.
8181debfc3dSmrg
8191debfc3dSmrg@item struct tree_var_decl
8201debfc3dSmrgThis structure inherits from @code{struct tree_decl_with_vis}.  It is
8211debfc3dSmrgused to represent @code{VAR_DECL}.
8221debfc3dSmrg
8231debfc3dSmrg@item struct tree_function_decl
8241debfc3dSmrgThis structure inherits from @code{struct tree_decl_with_vis}.  It is
8251debfc3dSmrgused to represent @code{FUNCTION_DECL}.
8261debfc3dSmrg
8271debfc3dSmrg@end table
8281debfc3dSmrg@node Adding new DECL node types
8291debfc3dSmrg@subsubsection Adding new DECL node types
8301debfc3dSmrg
8311debfc3dSmrgAdding a new @code{DECL} tree consists of the following steps
8321debfc3dSmrg
8331debfc3dSmrg@table @asis
8341debfc3dSmrg
8351debfc3dSmrg@item Add a new tree code for the @code{DECL} node
8361debfc3dSmrgFor language specific @code{DECL} nodes, there is a @file{.def} file
8371debfc3dSmrgin each frontend directory where the tree code should be added.
8381debfc3dSmrgFor @code{DECL} nodes that are part of the middle-end, the code should
8391debfc3dSmrgbe added to @file{tree.def}.
8401debfc3dSmrg
8411debfc3dSmrg@item Create a new structure type for the @code{DECL} node
8421debfc3dSmrgThese structures should inherit from one of the existing structures in
8431debfc3dSmrgthe language hierarchy by using that structure as the first member.
8441debfc3dSmrg
8451debfc3dSmrg@smallexample
8461debfc3dSmrgstruct tree_foo_decl
8471debfc3dSmrg@{
8481debfc3dSmrg   struct tree_decl_with_vis common;
8491debfc3dSmrg@}
8501debfc3dSmrg@end smallexample
8511debfc3dSmrg
8521debfc3dSmrgWould create a structure name @code{tree_foo_decl} that inherits from
8531debfc3dSmrg@code{struct tree_decl_with_vis}.
8541debfc3dSmrg
8551debfc3dSmrgFor language specific @code{DECL} nodes, this new structure type
8561debfc3dSmrgshould go in the appropriate @file{.h} file.
8571debfc3dSmrgFor @code{DECL} nodes that are part of the middle-end, the structure
8581debfc3dSmrgtype should go in @file{tree.h}.
8591debfc3dSmrg
8601debfc3dSmrg@item Add a member to the tree structure enumerator for the node
8611debfc3dSmrgFor garbage collection and dynamic checking purposes, each @code{DECL}
8621debfc3dSmrgnode structure type is required to have a unique enumerator value
8631debfc3dSmrgspecified with it.
8641debfc3dSmrgFor language specific @code{DECL} nodes, this new enumerator value
8651debfc3dSmrgshould go in the appropriate @file{.def} file.
8661debfc3dSmrgFor @code{DECL} nodes that are part of the middle-end, the enumerator
8671debfc3dSmrgvalues are specified in @file{treestruct.def}.
8681debfc3dSmrg
8691debfc3dSmrg@item Update @code{union tree_node}
8701debfc3dSmrgIn order to make your new structure type usable, it must be added to
8711debfc3dSmrg@code{union tree_node}.
8721debfc3dSmrgFor language specific @code{DECL} nodes, a new entry should be added
8731debfc3dSmrgto the appropriate @file{.h} file of the form
8741debfc3dSmrg@smallexample
8751debfc3dSmrg  struct tree_foo_decl GTY ((tag ("TS_VAR_DECL"))) foo_decl;
8761debfc3dSmrg@end smallexample
8771debfc3dSmrgFor @code{DECL} nodes that are part of the middle-end, the additional
8781debfc3dSmrgmember goes directly into @code{union tree_node} in @file{tree.h}.
8791debfc3dSmrg
8801debfc3dSmrg@item Update dynamic checking info
8811debfc3dSmrgIn order to be able to check whether accessing a named portion of
8821debfc3dSmrg@code{union tree_node} is legal, and whether a certain @code{DECL} node
8831debfc3dSmrgcontains one of the enumerated @code{DECL} node structures in the
8841debfc3dSmrghierarchy, a simple lookup table is used.
8851debfc3dSmrgThis lookup table needs to be kept up to date with the tree structure
8861debfc3dSmrghierarchy, or else checking and containment macros will fail
8871debfc3dSmrginappropriately.
8881debfc3dSmrg
8891debfc3dSmrgFor language specific @code{DECL} nodes, their is an @code{init_ts}
8901debfc3dSmrgfunction in an appropriate @file{.c} file, which initializes the lookup
8911debfc3dSmrgtable.
8921debfc3dSmrgCode setting up the table for new @code{DECL} nodes should be added
8931debfc3dSmrgthere.
8941debfc3dSmrgFor each @code{DECL} tree code and enumerator value representing a
8951debfc3dSmrgmember of the inheritance  hierarchy, the table should contain 1 if
8961debfc3dSmrgthat tree code inherits (directly or indirectly) from that member.
8971debfc3dSmrgThus, a @code{FOO_DECL} node derived from @code{struct decl_with_rtl},
8981debfc3dSmrgand enumerator value @code{TS_FOO_DECL}, would be set up as follows
8991debfc3dSmrg@smallexample
9001debfc3dSmrgtree_contains_struct[FOO_DECL][TS_FOO_DECL] = 1;
9011debfc3dSmrgtree_contains_struct[FOO_DECL][TS_DECL_WRTL] = 1;
9021debfc3dSmrgtree_contains_struct[FOO_DECL][TS_DECL_COMMON] = 1;
9031debfc3dSmrgtree_contains_struct[FOO_DECL][TS_DECL_MINIMAL] = 1;
9041debfc3dSmrg@end smallexample
9051debfc3dSmrg
9061debfc3dSmrgFor @code{DECL} nodes that are part of the middle-end, the setup code
9071debfc3dSmrggoes into @file{tree.c}.
9081debfc3dSmrg
9091debfc3dSmrg@item Add macros to access any new fields and flags
9101debfc3dSmrg
9111debfc3dSmrgEach added field or flag should have a macro that is used to access
9121debfc3dSmrgit, that performs appropriate checking to ensure only the right type of
9131debfc3dSmrg@code{DECL} nodes access the field.
9141debfc3dSmrg
9151debfc3dSmrgThese macros generally take the following form
9161debfc3dSmrg@smallexample
9171debfc3dSmrg#define FOO_DECL_FIELDNAME(NODE) FOO_DECL_CHECK(NODE)->foo_decl.fieldname
9181debfc3dSmrg@end smallexample
9191debfc3dSmrgHowever, if the structure is simply a base class for further
9201debfc3dSmrgstructures, something like the following should be used
9211debfc3dSmrg@smallexample
9221debfc3dSmrg#define BASE_STRUCT_CHECK(T) CONTAINS_STRUCT_CHECK(T, TS_BASE_STRUCT)
9231debfc3dSmrg#define BASE_STRUCT_FIELDNAME(NODE) \
9241debfc3dSmrg   (BASE_STRUCT_CHECK(NODE)->base_struct.fieldname
9251debfc3dSmrg@end smallexample
9261debfc3dSmrg
9271debfc3dSmrgReading them from the generated @file{all-tree.def} file (which in
9281debfc3dSmrgturn includes all the @file{tree.def} files), @file{gencheck.c} is
9291debfc3dSmrgused during GCC's build to generate the @code{*_CHECK} macros for all
9301debfc3dSmrgtree codes.
9311debfc3dSmrg
9321debfc3dSmrg@end table
9331debfc3dSmrg
9341debfc3dSmrg
9351debfc3dSmrg@c ---------------------------------------------------------------------
9361debfc3dSmrg@c Attributes
9371debfc3dSmrg@c ---------------------------------------------------------------------
9381debfc3dSmrg@node Attributes
9391debfc3dSmrg@section Attributes in trees
9401debfc3dSmrg@cindex attributes
9411debfc3dSmrg
9421debfc3dSmrgAttributes, as specified using the @code{__attribute__} keyword, are
9431debfc3dSmrgrepresented internally as a @code{TREE_LIST}.  The @code{TREE_PURPOSE}
9441debfc3dSmrgis the name of the attribute, as an @code{IDENTIFIER_NODE}.  The
9451debfc3dSmrg@code{TREE_VALUE} is a @code{TREE_LIST} of the arguments of the
9461debfc3dSmrgattribute, if any, or @code{NULL_TREE} if there are no arguments; the
9471debfc3dSmrgarguments are stored as the @code{TREE_VALUE} of successive entries in
9481debfc3dSmrgthe list, and may be identifiers or expressions.  The @code{TREE_CHAIN}
9491debfc3dSmrgof the attribute is the next attribute in a list of attributes applying
9501debfc3dSmrgto the same declaration or type, or @code{NULL_TREE} if there are no
9511debfc3dSmrgfurther attributes in the list.
9521debfc3dSmrg
9531debfc3dSmrgAttributes may be attached to declarations and to types; these
9541debfc3dSmrgattributes may be accessed with the following macros.  All attributes
9551debfc3dSmrgare stored in this way, and many also cause other changes to the
9561debfc3dSmrgdeclaration or type or to other internal compiler data structures.
9571debfc3dSmrg
9581debfc3dSmrg@deftypefn {Tree Macro} tree DECL_ATTRIBUTES (tree @var{decl})
9591debfc3dSmrgThis macro returns the attributes on the declaration @var{decl}.
9601debfc3dSmrg@end deftypefn
9611debfc3dSmrg
9621debfc3dSmrg@deftypefn {Tree Macro} tree TYPE_ATTRIBUTES (tree @var{type})
9631debfc3dSmrgThis macro returns the attributes on the type @var{type}.
9641debfc3dSmrg@end deftypefn
9651debfc3dSmrg
9661debfc3dSmrg
9671debfc3dSmrg@c ---------------------------------------------------------------------
9681debfc3dSmrg@c Expressions
9691debfc3dSmrg@c ---------------------------------------------------------------------
9701debfc3dSmrg
9711debfc3dSmrg@node Expression trees
9721debfc3dSmrg@section Expressions
9731debfc3dSmrg@cindex expression
9741debfc3dSmrg@findex TREE_TYPE
9751debfc3dSmrg@findex TREE_OPERAND
9761debfc3dSmrg
9771debfc3dSmrgThe internal representation for expressions is for the most part quite
9781debfc3dSmrgstraightforward.  However, there are a few facts that one must bear in
9791debfc3dSmrgmind.  In particular, the expression ``tree'' is actually a directed
9801debfc3dSmrgacyclic graph.  (For example there may be many references to the integer
9811debfc3dSmrgconstant zero throughout the source program; many of these will be
9821debfc3dSmrgrepresented by the same expression node.)  You should not rely on
9831debfc3dSmrgcertain kinds of node being shared, nor should you rely on certain kinds of
9841debfc3dSmrgnodes being unshared.
9851debfc3dSmrg
9861debfc3dSmrgThe following macros can be used with all expression nodes:
9871debfc3dSmrg
9881debfc3dSmrg@ftable @code
9891debfc3dSmrg@item TREE_TYPE
9901debfc3dSmrgReturns the type of the expression.  This value may not be precisely the
9911debfc3dSmrgsame type that would be given the expression in the original program.
9921debfc3dSmrg@end ftable
9931debfc3dSmrg
9941debfc3dSmrgIn what follows, some nodes that one might expect to always have type
9951debfc3dSmrg@code{bool} are documented to have either integral or boolean type.  At
9961debfc3dSmrgsome point in the future, the C front end may also make use of this same
9971debfc3dSmrgintermediate representation, and at this point these nodes will
9981debfc3dSmrgcertainly have integral type.  The previous sentence is not meant to
9991debfc3dSmrgimply that the C++ front end does not or will not give these nodes
10001debfc3dSmrgintegral type.
10011debfc3dSmrg
10021debfc3dSmrgBelow, we list the various kinds of expression nodes.  Except where
10031debfc3dSmrgnoted otherwise, the operands to an expression are accessed using the
10041debfc3dSmrg@code{TREE_OPERAND} macro.  For example, to access the first operand to
10051debfc3dSmrga binary plus expression @code{expr}, use:
10061debfc3dSmrg
10071debfc3dSmrg@smallexample
10081debfc3dSmrgTREE_OPERAND (expr, 0)
10091debfc3dSmrg@end smallexample
10101debfc3dSmrg@noindent
10111debfc3dSmrg
10121debfc3dSmrgAs this example indicates, the operands are zero-indexed.
10131debfc3dSmrg
10141debfc3dSmrg
10151debfc3dSmrg@menu
10161debfc3dSmrg* Constants: Constant expressions.
10171debfc3dSmrg* Storage References::
10181debfc3dSmrg* Unary and Binary Expressions::
10191debfc3dSmrg* Vectors::
10201debfc3dSmrg@end menu
10211debfc3dSmrg
10221debfc3dSmrg@node Constant expressions
10231debfc3dSmrg@subsection Constant expressions
10241debfc3dSmrg@tindex INTEGER_CST
10251debfc3dSmrg@findex tree_int_cst_lt
10261debfc3dSmrg@findex tree_int_cst_equal
10271debfc3dSmrg@tindex tree_fits_uhwi_p
10281debfc3dSmrg@tindex tree_fits_shwi_p
10291debfc3dSmrg@tindex tree_to_uhwi
10301debfc3dSmrg@tindex tree_to_shwi
10311debfc3dSmrg@tindex TREE_INT_CST_NUNITS
10321debfc3dSmrg@tindex TREE_INT_CST_ELT
10331debfc3dSmrg@tindex TREE_INT_CST_LOW
10341debfc3dSmrg@tindex REAL_CST
10351debfc3dSmrg@tindex FIXED_CST
10361debfc3dSmrg@tindex COMPLEX_CST
10371debfc3dSmrg@tindex VECTOR_CST
10381debfc3dSmrg@tindex STRING_CST
1039a2dc1f3fSmrg@tindex POLY_INT_CST
10401debfc3dSmrg@findex TREE_STRING_LENGTH
10411debfc3dSmrg@findex TREE_STRING_POINTER
10421debfc3dSmrg
10431debfc3dSmrgThe table below begins with constants, moves on to unary expressions,
10441debfc3dSmrgthen proceeds to binary expressions, and concludes with various other
10451debfc3dSmrgkinds of expressions:
10461debfc3dSmrg
10471debfc3dSmrg@table @code
10481debfc3dSmrg@item INTEGER_CST
10491debfc3dSmrgThese nodes represent integer constants.  Note that the type of these
10501debfc3dSmrgconstants is obtained with @code{TREE_TYPE}; they are not always of type
10511debfc3dSmrg@code{int}.  In particular, @code{char} constants are represented with
10521debfc3dSmrg@code{INTEGER_CST} nodes.  The value of the integer constant @code{e} is
10531debfc3dSmrgrepresented in an array of HOST_WIDE_INT.   There are enough elements
10541debfc3dSmrgin the array to represent the value without taking extra elements for
10551debfc3dSmrgredundant 0s or -1.  The number of elements used to represent @code{e}
10561debfc3dSmrgis available via @code{TREE_INT_CST_NUNITS}. Element @code{i} can be
10571debfc3dSmrgextracted by using @code{TREE_INT_CST_ELT (e, i)}.
10581debfc3dSmrg@code{TREE_INT_CST_LOW} is a shorthand for @code{TREE_INT_CST_ELT (e, 0)}.
10591debfc3dSmrg
10601debfc3dSmrgThe functions @code{tree_fits_shwi_p} and @code{tree_fits_uhwi_p}
10611debfc3dSmrgcan be used to tell if the value is small enough to fit in a
10621debfc3dSmrgsigned HOST_WIDE_INT or an unsigned HOST_WIDE_INT respectively.
10631debfc3dSmrgThe value can then be extracted using @code{tree_to_shwi} and
10641debfc3dSmrg@code{tree_to_uhwi}.
10651debfc3dSmrg
10661debfc3dSmrg@item REAL_CST
10671debfc3dSmrg
10681debfc3dSmrgFIXME: Talk about how to obtain representations of this constant, do
10691debfc3dSmrgcomparisons, and so forth.
10701debfc3dSmrg
10711debfc3dSmrg@item FIXED_CST
10721debfc3dSmrg
10731debfc3dSmrgThese nodes represent fixed-point constants.  The type of these constants
10741debfc3dSmrgis obtained with @code{TREE_TYPE}.  @code{TREE_FIXED_CST_PTR} points to
10751debfc3dSmrga @code{struct fixed_value};  @code{TREE_FIXED_CST} returns the structure
10761debfc3dSmrgitself.  @code{struct fixed_value} contains @code{data} with the size of two
10771debfc3dSmrg@code{HOST_BITS_PER_WIDE_INT} and @code{mode} as the associated fixed-point
10781debfc3dSmrgmachine mode for @code{data}.
10791debfc3dSmrg
10801debfc3dSmrg@item COMPLEX_CST
10811debfc3dSmrgThese nodes are used to represent complex number constants, that is a
10821debfc3dSmrg@code{__complex__} whose parts are constant nodes.  The
10831debfc3dSmrg@code{TREE_REALPART} and @code{TREE_IMAGPART} return the real and the
10841debfc3dSmrgimaginary parts respectively.
10851debfc3dSmrg
10861debfc3dSmrg@item VECTOR_CST
1087a2dc1f3fSmrgThese nodes are used to represent vector constants.  Each vector
1088a2dc1f3fSmrgconstant @var{v} is treated as a specific instance of an arbitrary-length
1089a2dc1f3fSmrgsequence that itself contains @samp{VECTOR_CST_NPATTERNS (@var{v})}
1090a2dc1f3fSmrginterleaved patterns.  Each pattern has the form:
1091a2dc1f3fSmrg
1092a2dc1f3fSmrg@smallexample
1093a2dc1f3fSmrg@{ @var{base0}, @var{base1}, @var{base1} + @var{step}, @var{base1} + @var{step} * 2, @dots{} @}
1094a2dc1f3fSmrg@end smallexample
1095a2dc1f3fSmrg
1096a2dc1f3fSmrgThe first three elements in each pattern are enough to determine the
1097a2dc1f3fSmrgvalues of the other elements.  However, if all @var{step}s are zero,
1098a2dc1f3fSmrgonly the first two elements are needed.  If in addition each @var{base1}
1099a2dc1f3fSmrgis equal to the corresponding @var{base0}, only the first element in
1100a2dc1f3fSmrgeach pattern is needed.  The number of encoded elements per pattern
1101a2dc1f3fSmrgis given by @samp{VECTOR_CST_NELTS_PER_PATTERN (@var{v})}.
1102a2dc1f3fSmrg
1103a2dc1f3fSmrgFor example, the constant:
1104a2dc1f3fSmrg
1105a2dc1f3fSmrg@smallexample
1106a2dc1f3fSmrg@{ 0, 1, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18 @}
1107a2dc1f3fSmrg@end smallexample
1108a2dc1f3fSmrg
1109a2dc1f3fSmrgis interpreted as an interleaving of the sequences:
1110a2dc1f3fSmrg
1111a2dc1f3fSmrg@smallexample
1112a2dc1f3fSmrg@{ 0, 2, 3, 4, 5, 6, 7, 8 @}
1113a2dc1f3fSmrg@{ 1, 6, 8, 10, 12, 14, 16, 18 @}
1114a2dc1f3fSmrg@end smallexample
1115a2dc1f3fSmrg
1116a2dc1f3fSmrgwhere the sequences are represented by the following patterns:
1117a2dc1f3fSmrg
1118a2dc1f3fSmrg@smallexample
1119a2dc1f3fSmrg@var{base0} == 0, @var{base1} == 2, @var{step} == 1
1120a2dc1f3fSmrg@var{base0} == 1, @var{base1} == 6, @var{step} == 2
1121a2dc1f3fSmrg@end smallexample
1122a2dc1f3fSmrg
1123a2dc1f3fSmrgIn this case:
1124a2dc1f3fSmrg
1125a2dc1f3fSmrg@smallexample
1126a2dc1f3fSmrgVECTOR_CST_NPATTERNS (@var{v}) == 2
1127a2dc1f3fSmrgVECTOR_CST_NELTS_PER_PATTERN (@var{v}) == 3
1128a2dc1f3fSmrg@end smallexample
1129a2dc1f3fSmrg
1130a2dc1f3fSmrgThe vector is therefore encoded using the first 6 elements
1131a2dc1f3fSmrg(@samp{@{ 0, 1, 2, 6, 3, 8 @}}), with the remaining 10 elements
1132a2dc1f3fSmrgbeing implicit extensions of them.
1133a2dc1f3fSmrg
1134a2dc1f3fSmrgSometimes this scheme can create two possible encodings of the same
1135a2dc1f3fSmrgvector.  For example @{ 0, 1 @} could be seen as two patterns with
1136a2dc1f3fSmrgone element each or one pattern with two elements (@var{base0} and
1137a2dc1f3fSmrg@var{base1}).  The canonical encoding is always the one with the
1138a2dc1f3fSmrgfewest patterns or (if both encodings have the same number of
1139a2dc1f3fSmrgpetterns) the one with the fewest encoded elements.
1140a2dc1f3fSmrg
1141a2dc1f3fSmrg@samp{vector_cst_encoding_nelts (@var{v})} gives the total number of
1142a2dc1f3fSmrgencoded elements in @var{v}, which is 6 in the example above.
1143a2dc1f3fSmrg@code{VECTOR_CST_ENCODED_ELTS (@var{v})} gives a pointer to the elements
1144a2dc1f3fSmrgencoded in @var{v} and @code{VECTOR_CST_ENCODED_ELT (@var{v}, @var{i})}
1145a2dc1f3fSmrgaccesses the value of encoded element @var{i}.
1146a2dc1f3fSmrg
1147a2dc1f3fSmrg@samp{VECTOR_CST_DUPLICATE_P (@var{v})} is true if @var{v} simply contains
1148a2dc1f3fSmrgrepeated instances of @samp{VECTOR_CST_NPATTERNS (@var{v})} values.  This is
1149a2dc1f3fSmrga shorthand for testing @samp{VECTOR_CST_NELTS_PER_PATTERN (@var{v}) == 1}.
1150a2dc1f3fSmrg
1151a2dc1f3fSmrg@samp{VECTOR_CST_STEPPED_P (@var{v})} is true if at least one
1152a2dc1f3fSmrgpattern in @var{v} has a nonzero step.  This is a shorthand for
1153a2dc1f3fSmrgtesting @samp{VECTOR_CST_NELTS_PER_PATTERN (@var{v}) == 3}.
1154a2dc1f3fSmrg
1155a2dc1f3fSmrgThe utility function @code{vector_cst_elt} gives the value of an
1156a2dc1f3fSmrgarbitrary index as a @code{tree}.  @code{vector_cst_int_elt} gives
1157a2dc1f3fSmrgthe same value as a @code{wide_int}.
11581debfc3dSmrg
11591debfc3dSmrg@item STRING_CST
11601debfc3dSmrgThese nodes represent string-constants.  The @code{TREE_STRING_LENGTH}
11611debfc3dSmrgreturns the length of the string, as an @code{int}.  The
11621debfc3dSmrg@code{TREE_STRING_POINTER} is a @code{char*} containing the string
11631debfc3dSmrgitself.  The string may not be @code{NUL}-terminated, and it may contain
11641debfc3dSmrgembedded @code{NUL} characters.  Therefore, the
11651debfc3dSmrg@code{TREE_STRING_LENGTH} includes the trailing @code{NUL} if it is
11661debfc3dSmrgpresent.
11671debfc3dSmrg
11681debfc3dSmrgFor wide string constants, the @code{TREE_STRING_LENGTH} is the number
11691debfc3dSmrgof bytes in the string, and the @code{TREE_STRING_POINTER}
11701debfc3dSmrgpoints to an array of the bytes of the string, as represented on the
11711debfc3dSmrgtarget system (that is, as integers in the target endianness).  Wide and
11721debfc3dSmrgnon-wide string constants are distinguished only by the @code{TREE_TYPE}
11731debfc3dSmrgof the @code{STRING_CST}.
11741debfc3dSmrg
11751debfc3dSmrgFIXME: The formats of string constants are not well-defined when the
11761debfc3dSmrgtarget system bytes are not the same width as host system bytes.
11771debfc3dSmrg
1178a2dc1f3fSmrg@item POLY_INT_CST
1179a2dc1f3fSmrgThese nodes represent invariants that depend on some target-specific
1180a2dc1f3fSmrgruntime parameters.  They consist of @code{NUM_POLY_INT_COEFFS}
1181a2dc1f3fSmrgcoefficients, with the first coefficient being the constant term and
1182a2dc1f3fSmrgthe others being multipliers that are applied to the runtime parameters.
1183a2dc1f3fSmrg
1184a2dc1f3fSmrg@code{POLY_INT_CST_ELT (@var{x}, @var{i})} references coefficient number
1185a2dc1f3fSmrg@var{i} of @code{POLY_INT_CST} node @var{x}.  Each coefficient is an
1186a2dc1f3fSmrg@code{INTEGER_CST}.
1187a2dc1f3fSmrg
11881debfc3dSmrg@end table
11891debfc3dSmrg
11901debfc3dSmrg@node Storage References
11911debfc3dSmrg@subsection References to storage
11921debfc3dSmrg@tindex ADDR_EXPR
11931debfc3dSmrg@tindex INDIRECT_REF
11941debfc3dSmrg@tindex MEM_REF
11951debfc3dSmrg@tindex ARRAY_REF
11961debfc3dSmrg@tindex ARRAY_RANGE_REF
11971debfc3dSmrg@tindex TARGET_MEM_REF
11981debfc3dSmrg@tindex COMPONENT_REF
11991debfc3dSmrg
12001debfc3dSmrg@table @code
12011debfc3dSmrg@item ARRAY_REF
12021debfc3dSmrgThese nodes represent array accesses.  The first operand is the array;
12031debfc3dSmrgthe second is the index.  To calculate the address of the memory
12041debfc3dSmrgaccessed, you must scale the index by the size of the type of the array
12051debfc3dSmrgelements.  The type of these expressions must be the type of a component of
12061debfc3dSmrgthe array.  The third and fourth operands are used after gimplification
12071debfc3dSmrgto represent the lower bound and component size but should not be used
12081debfc3dSmrgdirectly; call @code{array_ref_low_bound} and @code{array_ref_element_size}
12091debfc3dSmrginstead.
12101debfc3dSmrg
12111debfc3dSmrg@item ARRAY_RANGE_REF
12121debfc3dSmrgThese nodes represent access to a range (or ``slice'') of an array.  The
12131debfc3dSmrgoperands are the same as that for @code{ARRAY_REF} and have the same
12141debfc3dSmrgmeanings.  The type of these expressions must be an array whose component
12151debfc3dSmrgtype is the same as that of the first operand.  The range of that array
12161debfc3dSmrgtype determines the amount of data these expressions access.
12171debfc3dSmrg
12181debfc3dSmrg@item TARGET_MEM_REF
12191debfc3dSmrgThese nodes represent memory accesses whose address directly map to
12201debfc3dSmrgan addressing mode of the target architecture.  The first argument
12211debfc3dSmrgis @code{TMR_SYMBOL} and must be a @code{VAR_DECL} of an object with
12221debfc3dSmrga fixed address.  The second argument is @code{TMR_BASE} and the
12231debfc3dSmrgthird one is @code{TMR_INDEX}.  The fourth argument is
12241debfc3dSmrg@code{TMR_STEP} and must be an @code{INTEGER_CST}.  The fifth
12251debfc3dSmrgargument is @code{TMR_OFFSET} and must be an @code{INTEGER_CST}.
12261debfc3dSmrgAny of the arguments may be NULL if the appropriate component
12271debfc3dSmrgdoes not appear in the address.  Address of the @code{TARGET_MEM_REF}
12281debfc3dSmrgis determined in the following way.
12291debfc3dSmrg
12301debfc3dSmrg@smallexample
12311debfc3dSmrg&TMR_SYMBOL + TMR_BASE + TMR_INDEX * TMR_STEP + TMR_OFFSET
12321debfc3dSmrg@end smallexample
12331debfc3dSmrg
12341debfc3dSmrgThe sixth argument is the reference to the original memory access, which
12351debfc3dSmrgis preserved for the purposes of the RTL alias analysis.  The seventh
12361debfc3dSmrgargument is a tag representing the results of tree level alias analysis.
12371debfc3dSmrg
12381debfc3dSmrg@item ADDR_EXPR
12391debfc3dSmrgThese nodes are used to represent the address of an object.  (These
12401debfc3dSmrgexpressions will always have pointer or reference type.)  The operand may
12411debfc3dSmrgbe another expression, or it may be a declaration.
12421debfc3dSmrg
12431debfc3dSmrgAs an extension, GCC allows users to take the address of a label.  In
12441debfc3dSmrgthis case, the operand of the @code{ADDR_EXPR} will be a
12451debfc3dSmrg@code{LABEL_DECL}.  The type of such an expression is @code{void*}.
12461debfc3dSmrg
12471debfc3dSmrgIf the object addressed is not an lvalue, a temporary is created, and
12481debfc3dSmrgthe address of the temporary is used.
12491debfc3dSmrg
12501debfc3dSmrg@item INDIRECT_REF
12511debfc3dSmrgThese nodes are used to represent the object pointed to by a pointer.
12521debfc3dSmrgThe operand is the pointer being dereferenced; it will always have
12531debfc3dSmrgpointer or reference type.
12541debfc3dSmrg
12551debfc3dSmrg@item MEM_REF
12561debfc3dSmrgThese nodes are used to represent the object pointed to by a pointer
12571debfc3dSmrgoffset by a constant.
12581debfc3dSmrgThe first operand is the pointer being dereferenced; it will always have
12591debfc3dSmrgpointer or reference type.  The second operand is a pointer constant.
12601debfc3dSmrgIts type is specifying the type to be used for type-based alias analysis.
12611debfc3dSmrg
12621debfc3dSmrg@item COMPONENT_REF
12631debfc3dSmrgThese nodes represent non-static data member accesses.  The first
12641debfc3dSmrgoperand is the object (rather than a pointer to it); the second operand
12651debfc3dSmrgis the @code{FIELD_DECL} for the data member.  The third operand represents
12661debfc3dSmrgthe byte offset of the field, but should not be used directly; call
12671debfc3dSmrg@code{component_ref_field_offset} instead.
12681debfc3dSmrg
12691debfc3dSmrg
12701debfc3dSmrg@end table
12711debfc3dSmrg
12721debfc3dSmrg@node Unary and Binary Expressions
12731debfc3dSmrg@subsection Unary and Binary Expressions
12741debfc3dSmrg@tindex NEGATE_EXPR
12751debfc3dSmrg@tindex ABS_EXPR
1276c0a68be4Smrg@tindex ABSU_EXPR
12771debfc3dSmrg@tindex BIT_NOT_EXPR
12781debfc3dSmrg@tindex TRUTH_NOT_EXPR
12791debfc3dSmrg@tindex PREDECREMENT_EXPR
12801debfc3dSmrg@tindex PREINCREMENT_EXPR
12811debfc3dSmrg@tindex POSTDECREMENT_EXPR
12821debfc3dSmrg@tindex POSTINCREMENT_EXPR
12831debfc3dSmrg@tindex FIX_TRUNC_EXPR
12841debfc3dSmrg@tindex FLOAT_EXPR
12851debfc3dSmrg@tindex COMPLEX_EXPR
12861debfc3dSmrg@tindex CONJ_EXPR
12871debfc3dSmrg@tindex REALPART_EXPR
12881debfc3dSmrg@tindex IMAGPART_EXPR
12891debfc3dSmrg@tindex NON_LVALUE_EXPR
12901debfc3dSmrg@tindex NOP_EXPR
12911debfc3dSmrg@tindex CONVERT_EXPR
12921debfc3dSmrg@tindex FIXED_CONVERT_EXPR
12931debfc3dSmrg@tindex THROW_EXPR
12941debfc3dSmrg@tindex LSHIFT_EXPR
12951debfc3dSmrg@tindex RSHIFT_EXPR
12961debfc3dSmrg@tindex BIT_IOR_EXPR
12971debfc3dSmrg@tindex BIT_XOR_EXPR
12981debfc3dSmrg@tindex BIT_AND_EXPR
12991debfc3dSmrg@tindex TRUTH_ANDIF_EXPR
13001debfc3dSmrg@tindex TRUTH_ORIF_EXPR
13011debfc3dSmrg@tindex TRUTH_AND_EXPR
13021debfc3dSmrg@tindex TRUTH_OR_EXPR
13031debfc3dSmrg@tindex TRUTH_XOR_EXPR
13041debfc3dSmrg@tindex POINTER_PLUS_EXPR
1305a2dc1f3fSmrg@tindex POINTER_DIFF_EXPR
13061debfc3dSmrg@tindex PLUS_EXPR
13071debfc3dSmrg@tindex MINUS_EXPR
13081debfc3dSmrg@tindex MULT_EXPR
13091debfc3dSmrg@tindex MULT_HIGHPART_EXPR
13101debfc3dSmrg@tindex RDIV_EXPR
13111debfc3dSmrg@tindex TRUNC_DIV_EXPR
13121debfc3dSmrg@tindex FLOOR_DIV_EXPR
13131debfc3dSmrg@tindex CEIL_DIV_EXPR
13141debfc3dSmrg@tindex ROUND_DIV_EXPR
13151debfc3dSmrg@tindex TRUNC_MOD_EXPR
13161debfc3dSmrg@tindex FLOOR_MOD_EXPR
13171debfc3dSmrg@tindex CEIL_MOD_EXPR
13181debfc3dSmrg@tindex ROUND_MOD_EXPR
13191debfc3dSmrg@tindex EXACT_DIV_EXPR
13201debfc3dSmrg@tindex LT_EXPR
13211debfc3dSmrg@tindex LE_EXPR
13221debfc3dSmrg@tindex GT_EXPR
13231debfc3dSmrg@tindex GE_EXPR
13241debfc3dSmrg@tindex EQ_EXPR
13251debfc3dSmrg@tindex NE_EXPR
13261debfc3dSmrg@tindex ORDERED_EXPR
13271debfc3dSmrg@tindex UNORDERED_EXPR
13281debfc3dSmrg@tindex UNLT_EXPR
13291debfc3dSmrg@tindex UNLE_EXPR
13301debfc3dSmrg@tindex UNGT_EXPR
13311debfc3dSmrg@tindex UNGE_EXPR
13321debfc3dSmrg@tindex UNEQ_EXPR
13331debfc3dSmrg@tindex LTGT_EXPR
13341debfc3dSmrg@tindex MODIFY_EXPR
13351debfc3dSmrg@tindex INIT_EXPR
13361debfc3dSmrg@tindex COMPOUND_EXPR
13371debfc3dSmrg@tindex COND_EXPR
13381debfc3dSmrg@tindex CALL_EXPR
13391debfc3dSmrg@tindex STMT_EXPR
13401debfc3dSmrg@tindex BIND_EXPR
13411debfc3dSmrg@tindex LOOP_EXPR
13421debfc3dSmrg@tindex EXIT_EXPR
13431debfc3dSmrg@tindex CLEANUP_POINT_EXPR
13441debfc3dSmrg@tindex CONSTRUCTOR
13451debfc3dSmrg@tindex COMPOUND_LITERAL_EXPR
13461debfc3dSmrg@tindex SAVE_EXPR
13471debfc3dSmrg@tindex TARGET_EXPR
13481debfc3dSmrg@tindex VA_ARG_EXPR
13491debfc3dSmrg@tindex ANNOTATE_EXPR
13501debfc3dSmrg
13511debfc3dSmrg@table @code
13521debfc3dSmrg@item NEGATE_EXPR
13531debfc3dSmrgThese nodes represent unary negation of the single operand, for both
13541debfc3dSmrginteger and floating-point types.  The type of negation can be
13551debfc3dSmrgdetermined by looking at the type of the expression.
13561debfc3dSmrg
13571debfc3dSmrgThe behavior of this operation on signed arithmetic overflow is
13581debfc3dSmrgcontrolled by the @code{flag_wrapv} and @code{flag_trapv} variables.
13591debfc3dSmrg
13601debfc3dSmrg@item ABS_EXPR
13611debfc3dSmrgThese nodes represent the absolute value of the single operand, for
13621debfc3dSmrgboth integer and floating-point types.  This is typically used to
13631debfc3dSmrgimplement the @code{abs}, @code{labs} and @code{llabs} builtins for
13641debfc3dSmrginteger types, and the @code{fabs}, @code{fabsf} and @code{fabsl}
13651debfc3dSmrgbuiltins for floating point types.  The type of abs operation can
13661debfc3dSmrgbe determined by looking at the type of the expression.
13671debfc3dSmrg
13681debfc3dSmrgThis node is not used for complex types.  To represent the modulus
13691debfc3dSmrgor complex abs of a complex value, use the @code{BUILT_IN_CABS},
13701debfc3dSmrg@code{BUILT_IN_CABSF} or @code{BUILT_IN_CABSL} builtins, as used
13711debfc3dSmrgto implement the C99 @code{cabs}, @code{cabsf} and @code{cabsl}
13721debfc3dSmrgbuilt-in functions.
13731debfc3dSmrg
1374c0a68be4Smrg@item ABSU_EXPR
1375c0a68be4SmrgThese nodes represent the absolute value of the single operand in
1376*8feb0f0bSmrgequivalent unsigned type such that @code{ABSU_EXPR} of @code{TYPE_MIN}
1377*8feb0f0bSmrgis well defined.
1378c0a68be4Smrg
13791debfc3dSmrg@item BIT_NOT_EXPR
13801debfc3dSmrgThese nodes represent bitwise complement, and will always have integral
13811debfc3dSmrgtype.  The only operand is the value to be complemented.
13821debfc3dSmrg
13831debfc3dSmrg@item TRUTH_NOT_EXPR
13841debfc3dSmrgThese nodes represent logical negation, and will always have integral
13851debfc3dSmrg(or boolean) type.  The operand is the value being negated.  The type
13861debfc3dSmrgof the operand and that of the result are always of @code{BOOLEAN_TYPE}
13871debfc3dSmrgor @code{INTEGER_TYPE}.
13881debfc3dSmrg
13891debfc3dSmrg@item PREDECREMENT_EXPR
13901debfc3dSmrg@itemx PREINCREMENT_EXPR
13911debfc3dSmrg@itemx POSTDECREMENT_EXPR
13921debfc3dSmrg@itemx POSTINCREMENT_EXPR
13931debfc3dSmrgThese nodes represent increment and decrement expressions.  The value of
13941debfc3dSmrgthe single operand is computed, and the operand incremented or
13951debfc3dSmrgdecremented.  In the case of @code{PREDECREMENT_EXPR} and
13961debfc3dSmrg@code{PREINCREMENT_EXPR}, the value of the expression is the value
13971debfc3dSmrgresulting after the increment or decrement; in the case of
13981debfc3dSmrg@code{POSTDECREMENT_EXPR} and @code{POSTINCREMENT_EXPR} is the value
13991debfc3dSmrgbefore the increment or decrement occurs.  The type of the operand, like
14001debfc3dSmrgthat of the result, will be either integral, boolean, or floating-point.
14011debfc3dSmrg
14021debfc3dSmrg@item FIX_TRUNC_EXPR
14031debfc3dSmrgThese nodes represent conversion of a floating-point value to an
14041debfc3dSmrginteger.  The single operand will have a floating-point type, while
14051debfc3dSmrgthe complete expression will have an integral (or boolean) type.  The
14061debfc3dSmrgoperand is rounded towards zero.
14071debfc3dSmrg
14081debfc3dSmrg@item FLOAT_EXPR
14091debfc3dSmrgThese nodes represent conversion of an integral (or boolean) value to a
14101debfc3dSmrgfloating-point value.  The single operand will have integral type, while
14111debfc3dSmrgthe complete expression will have a floating-point type.
14121debfc3dSmrg
14131debfc3dSmrgFIXME: How is the operand supposed to be rounded?  Is this dependent on
14141debfc3dSmrg@option{-mieee}?
14151debfc3dSmrg
14161debfc3dSmrg@item COMPLEX_EXPR
14171debfc3dSmrgThese nodes are used to represent complex numbers constructed from two
14181debfc3dSmrgexpressions of the same (integer or real) type.  The first operand is the
14191debfc3dSmrgreal part and the second operand is the imaginary part.
14201debfc3dSmrg
14211debfc3dSmrg@item CONJ_EXPR
14221debfc3dSmrgThese nodes represent the conjugate of their operand.
14231debfc3dSmrg
14241debfc3dSmrg@item REALPART_EXPR
14251debfc3dSmrg@itemx IMAGPART_EXPR
14261debfc3dSmrgThese nodes represent respectively the real and the imaginary parts
14271debfc3dSmrgof complex numbers (their sole argument).
14281debfc3dSmrg
14291debfc3dSmrg@item NON_LVALUE_EXPR
14301debfc3dSmrgThese nodes indicate that their one and only operand is not an lvalue.
14311debfc3dSmrgA back end can treat these identically to the single operand.
14321debfc3dSmrg
14331debfc3dSmrg@item NOP_EXPR
14341debfc3dSmrgThese nodes are used to represent conversions that do not require any
14351debfc3dSmrgcode-generation.  For example, conversion of a @code{char*} to an
14361debfc3dSmrg@code{int*} does not require any code be generated; such a conversion is
14371debfc3dSmrgrepresented by a @code{NOP_EXPR}.  The single operand is the expression
14381debfc3dSmrgto be converted.  The conversion from a pointer to a reference is also
14391debfc3dSmrgrepresented with a @code{NOP_EXPR}.
14401debfc3dSmrg
14411debfc3dSmrg@item CONVERT_EXPR
14421debfc3dSmrgThese nodes are similar to @code{NOP_EXPR}s, but are used in those
14431debfc3dSmrgsituations where code may need to be generated.  For example, if an
14441debfc3dSmrg@code{int*} is converted to an @code{int} code may need to be generated
14451debfc3dSmrgon some platforms.  These nodes are never used for C++-specific
14461debfc3dSmrgconversions, like conversions between pointers to different classes in
14471debfc3dSmrgan inheritance hierarchy.  Any adjustments that need to be made in such
14481debfc3dSmrgcases are always indicated explicitly.  Similarly, a user-defined
14491debfc3dSmrgconversion is never represented by a @code{CONVERT_EXPR}; instead, the
14501debfc3dSmrgfunction calls are made explicit.
14511debfc3dSmrg
14521debfc3dSmrg@item FIXED_CONVERT_EXPR
14531debfc3dSmrgThese nodes are used to represent conversions that involve fixed-point
14541debfc3dSmrgvalues.  For example, from a fixed-point value to another fixed-point value,
14551debfc3dSmrgfrom an integer to a fixed-point value, from a fixed-point value to an
14561debfc3dSmrginteger, from a floating-point value to a fixed-point value, or from
14571debfc3dSmrga fixed-point value to a floating-point value.
14581debfc3dSmrg
14591debfc3dSmrg@item LSHIFT_EXPR
14601debfc3dSmrg@itemx RSHIFT_EXPR
14611debfc3dSmrgThese nodes represent left and right shifts, respectively.  The first
14621debfc3dSmrgoperand is the value to shift; it will always be of integral type.  The
14631debfc3dSmrgsecond operand is an expression for the number of bits by which to
14641debfc3dSmrgshift.  Right shift should be treated as arithmetic, i.e., the
14651debfc3dSmrghigh-order bits should be zero-filled when the expression has unsigned
14661debfc3dSmrgtype and filled with the sign bit when the expression has signed type.
14671debfc3dSmrgNote that the result is undefined if the second operand is larger
14681debfc3dSmrgthan or equal to the first operand's type size. Unlike most nodes, these
14691debfc3dSmrgcan have a vector as first operand and a scalar as second operand.
14701debfc3dSmrg
14711debfc3dSmrg
14721debfc3dSmrg@item BIT_IOR_EXPR
14731debfc3dSmrg@itemx BIT_XOR_EXPR
14741debfc3dSmrg@itemx BIT_AND_EXPR
14751debfc3dSmrgThese nodes represent bitwise inclusive or, bitwise exclusive or, and
14761debfc3dSmrgbitwise and, respectively.  Both operands will always have integral
14771debfc3dSmrgtype.
14781debfc3dSmrg
14791debfc3dSmrg@item TRUTH_ANDIF_EXPR
14801debfc3dSmrg@itemx TRUTH_ORIF_EXPR
14811debfc3dSmrgThese nodes represent logical ``and'' and logical ``or'', respectively.
14821debfc3dSmrgThese operators are not strict; i.e., the second operand is evaluated
14831debfc3dSmrgonly if the value of the expression is not determined by evaluation of
14841debfc3dSmrgthe first operand.  The type of the operands and that of the result are
14851debfc3dSmrgalways of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
14861debfc3dSmrg
14871debfc3dSmrg@item TRUTH_AND_EXPR
14881debfc3dSmrg@itemx TRUTH_OR_EXPR
14891debfc3dSmrg@itemx TRUTH_XOR_EXPR
14901debfc3dSmrgThese nodes represent logical and, logical or, and logical exclusive or.
14911debfc3dSmrgThey are strict; both arguments are always evaluated.  There are no
14921debfc3dSmrgcorresponding operators in C or C++, but the front end will sometimes
14931debfc3dSmrggenerate these expressions anyhow, if it can tell that strictness does
14941debfc3dSmrgnot matter.  The type of the operands and that of the result are
14951debfc3dSmrgalways of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
14961debfc3dSmrg
14971debfc3dSmrg@item POINTER_PLUS_EXPR
14981debfc3dSmrgThis node represents pointer arithmetic.  The first operand is always
14991debfc3dSmrga pointer/reference type.  The second operand is always an unsigned
1500a2dc1f3fSmrginteger type compatible with sizetype.  This and POINTER_DIFF_EXPR are
1501a2dc1f3fSmrgthe only binary arithmetic operators that can operate on pointer types.
1502a2dc1f3fSmrg
1503a2dc1f3fSmrg@item POINTER_DIFF_EXPR
1504a2dc1f3fSmrgThis node represents pointer subtraction.  The two operands always
1505a2dc1f3fSmrghave pointer/reference type.  It returns a signed integer of the same
1506a2dc1f3fSmrgprecision as the pointers.  The behavior is undefined if the difference
1507a2dc1f3fSmrgof the two pointers, seen as infinite precision non-negative integers,
1508a2dc1f3fSmrgdoes not fit in the result type.  The result does not depend on the
1509a2dc1f3fSmrgpointer type, it is not divided by the size of the pointed-to type.
15101debfc3dSmrg
15111debfc3dSmrg@item PLUS_EXPR
15121debfc3dSmrg@itemx MINUS_EXPR
15131debfc3dSmrg@itemx MULT_EXPR
15141debfc3dSmrgThese nodes represent various binary arithmetic operations.
15151debfc3dSmrgRespectively, these operations are addition, subtraction (of the second
15161debfc3dSmrgoperand from the first) and multiplication.  Their operands may have
15171debfc3dSmrgeither integral or floating type, but there will never be case in which
15181debfc3dSmrgone operand is of floating type and the other is of integral type.
15191debfc3dSmrg
15201debfc3dSmrgThe behavior of these operations on signed arithmetic overflow is
15211debfc3dSmrgcontrolled by the @code{flag_wrapv} and @code{flag_trapv} variables.
15221debfc3dSmrg
15231debfc3dSmrg@item MULT_HIGHPART_EXPR
15241debfc3dSmrgThis node represents the ``high-part'' of a widening multiplication.
15251debfc3dSmrgFor an integral type with @var{b} bits of precision, the result is
15261debfc3dSmrgthe most significant @var{b} bits of the full @math{2@var{b}} product.
15271debfc3dSmrg
15281debfc3dSmrg@item RDIV_EXPR
15291debfc3dSmrgThis node represents a floating point division operation.
15301debfc3dSmrg
15311debfc3dSmrg@item TRUNC_DIV_EXPR
15321debfc3dSmrg@itemx FLOOR_DIV_EXPR
15331debfc3dSmrg@itemx CEIL_DIV_EXPR
15341debfc3dSmrg@itemx ROUND_DIV_EXPR
15351debfc3dSmrgThese nodes represent integer division operations that return an integer
15361debfc3dSmrgresult.  @code{TRUNC_DIV_EXPR} rounds towards zero, @code{FLOOR_DIV_EXPR}
15371debfc3dSmrgrounds towards negative infinity, @code{CEIL_DIV_EXPR} rounds towards
15381debfc3dSmrgpositive infinity and @code{ROUND_DIV_EXPR} rounds to the closest integer.
15391debfc3dSmrgInteger division in C and C++ is truncating, i.e.@: @code{TRUNC_DIV_EXPR}.
15401debfc3dSmrg
15411debfc3dSmrgThe behavior of these operations on signed arithmetic overflow, when
15421debfc3dSmrgdividing the minimum signed integer by minus one, is controlled by the
15431debfc3dSmrg@code{flag_wrapv} and @code{flag_trapv} variables.
15441debfc3dSmrg
15451debfc3dSmrg@item TRUNC_MOD_EXPR
15461debfc3dSmrg@itemx FLOOR_MOD_EXPR
15471debfc3dSmrg@itemx CEIL_MOD_EXPR
15481debfc3dSmrg@itemx ROUND_MOD_EXPR
15491debfc3dSmrgThese nodes represent the integer remainder or modulus operation.
15501debfc3dSmrgThe integer modulus of two operands @code{a} and @code{b} is
15511debfc3dSmrgdefined as @code{a - (a/b)*b} where the division calculated using
15521debfc3dSmrgthe corresponding division operator.  Hence for @code{TRUNC_MOD_EXPR}
15531debfc3dSmrgthis definition assumes division using truncation towards zero, i.e.@:
15541debfc3dSmrg@code{TRUNC_DIV_EXPR}.  Integer remainder in C and C++ uses truncating
15551debfc3dSmrgdivision, i.e.@: @code{TRUNC_MOD_EXPR}.
15561debfc3dSmrg
15571debfc3dSmrg@item EXACT_DIV_EXPR
15581debfc3dSmrgThe @code{EXACT_DIV_EXPR} code is used to represent integer divisions where
15591debfc3dSmrgthe numerator is known to be an exact multiple of the denominator.  This
15601debfc3dSmrgallows the backend to choose between the faster of @code{TRUNC_DIV_EXPR},
15611debfc3dSmrg@code{CEIL_DIV_EXPR} and @code{FLOOR_DIV_EXPR} for the current target.
15621debfc3dSmrg
15631debfc3dSmrg@item LT_EXPR
15641debfc3dSmrg@itemx LE_EXPR
15651debfc3dSmrg@itemx GT_EXPR
15661debfc3dSmrg@itemx GE_EXPR
1567*8feb0f0bSmrg@itemx LTGT_EXPR
15681debfc3dSmrg@itemx EQ_EXPR
15691debfc3dSmrg@itemx NE_EXPR
1570*8feb0f0bSmrgThese nodes represent the less than, less than or equal to, greater than,
1571*8feb0f0bSmrggreater than or equal to, less or greater than, equal, and not equal
1572*8feb0f0bSmrgcomparison operators.  The first and second operands will either be both
1573*8feb0f0bSmrgof integral type, both of floating type or both of vector type, except for
1574*8feb0f0bSmrgLTGT_EXPR where they will only be both of floating type.  The result type
1575*8feb0f0bSmrgof these expressions will always be of integral, boolean or signed integral
1576*8feb0f0bSmrgvector type.  These operations return the result type's zero value for false,
1577*8feb0f0bSmrgthe result type's one value for true, and a vector whose elements are zero
1578*8feb0f0bSmrg(false) or minus one (true) for vectors.
15791debfc3dSmrg
15801debfc3dSmrgFor floating point comparisons, if we honor IEEE NaNs and either operand
15811debfc3dSmrgis NaN, then @code{NE_EXPR} always returns true and the remaining operators
15821debfc3dSmrgalways return false.  On some targets, comparisons against an IEEE NaN,
1583*8feb0f0bSmrgother than equality and inequality, may generate a floating-point exception.
15841debfc3dSmrg
15851debfc3dSmrg@item ORDERED_EXPR
15861debfc3dSmrg@itemx UNORDERED_EXPR
15871debfc3dSmrgThese nodes represent non-trapping ordered and unordered comparison
15881debfc3dSmrgoperators.  These operations take two floating point operands and
15891debfc3dSmrgdetermine whether they are ordered or unordered relative to each other.
15901debfc3dSmrgIf either operand is an IEEE NaN, their comparison is defined to be
15911debfc3dSmrgunordered, otherwise the comparison is defined to be ordered.  The
15921debfc3dSmrgresult type of these expressions will always be of integral or boolean
15931debfc3dSmrgtype.  These operations return the result type's zero value for false,
15941debfc3dSmrgand the result type's one value for true.
15951debfc3dSmrg
15961debfc3dSmrg@item UNLT_EXPR
15971debfc3dSmrg@itemx UNLE_EXPR
15981debfc3dSmrg@itemx UNGT_EXPR
15991debfc3dSmrg@itemx UNGE_EXPR
16001debfc3dSmrg@itemx UNEQ_EXPR
16011debfc3dSmrgThese nodes represent the unordered comparison operators.
16021debfc3dSmrgThese operations take two floating point operands and determine whether
16031debfc3dSmrgthe operands are unordered or are less than, less than or equal to,
16041debfc3dSmrggreater than, greater than or equal to, or equal respectively.  For
16051debfc3dSmrgexample, @code{UNLT_EXPR} returns true if either operand is an IEEE
1606*8feb0f0bSmrgNaN or the first operand is less than the second.  All these operations
1607*8feb0f0bSmrgare guaranteed not to generate a floating point exception.  The result
16081debfc3dSmrgtype of these expressions will always be of integral or boolean type.
16091debfc3dSmrgThese operations return the result type's zero value for false,
16101debfc3dSmrgand the result type's one value for true.
16111debfc3dSmrg
16121debfc3dSmrg@item MODIFY_EXPR
16131debfc3dSmrgThese nodes represent assignment.  The left-hand side is the first
16141debfc3dSmrgoperand; the right-hand side is the second operand.  The left-hand side
16151debfc3dSmrgwill be a @code{VAR_DECL}, @code{INDIRECT_REF}, @code{COMPONENT_REF}, or
16161debfc3dSmrgother lvalue.
16171debfc3dSmrg
16181debfc3dSmrgThese nodes are used to represent not only assignment with @samp{=} but
16191debfc3dSmrgalso compound assignments (like @samp{+=}), by reduction to @samp{=}
16201debfc3dSmrgassignment.  In other words, the representation for @samp{i += 3} looks
16211debfc3dSmrgjust like that for @samp{i = i + 3}.
16221debfc3dSmrg
16231debfc3dSmrg@item INIT_EXPR
16241debfc3dSmrgThese nodes are just like @code{MODIFY_EXPR}, but are used only when a
16251debfc3dSmrgvariable is initialized, rather than assigned to subsequently.  This
16261debfc3dSmrgmeans that we can assume that the target of the initialization is not
16271debfc3dSmrgused in computing its own value; any reference to the lhs in computing
16281debfc3dSmrgthe rhs is undefined.
16291debfc3dSmrg
16301debfc3dSmrg@item COMPOUND_EXPR
16311debfc3dSmrgThese nodes represent comma-expressions.  The first operand is an
16321debfc3dSmrgexpression whose value is computed and thrown away prior to the
16331debfc3dSmrgevaluation of the second operand.  The value of the entire expression is
16341debfc3dSmrgthe value of the second operand.
16351debfc3dSmrg
16361debfc3dSmrg@item COND_EXPR
16371debfc3dSmrgThese nodes represent @code{?:} expressions.  The first operand
16381debfc3dSmrgis of boolean or integral type.  If it evaluates to a nonzero value,
16391debfc3dSmrgthe second operand should be evaluated, and returned as the value of the
16401debfc3dSmrgexpression.  Otherwise, the third operand is evaluated, and returned as
16411debfc3dSmrgthe value of the expression.
16421debfc3dSmrg
16431debfc3dSmrgThe second operand must have the same type as the entire expression,
16441debfc3dSmrgunless it unconditionally throws an exception or calls a noreturn
16451debfc3dSmrgfunction, in which case it should have void type.  The same constraints
16461debfc3dSmrgapply to the third operand.  This allows array bounds checks to be
16471debfc3dSmrgrepresented conveniently as @code{(i >= 0 && i < 10) ? i : abort()}.
16481debfc3dSmrg
16491debfc3dSmrgAs a GNU extension, the C language front-ends allow the second
16501debfc3dSmrgoperand of the @code{?:} operator may be omitted in the source.
16511debfc3dSmrgFor example, @code{x ? : 3} is equivalent to @code{x ? x : 3},
1652a2dc1f3fSmrgassuming that @code{x} is an expression without side effects.
16531debfc3dSmrgIn the tree representation, however, the second operand is always
16541debfc3dSmrgpresent, possibly protected by @code{SAVE_EXPR} if the first
1655a2dc1f3fSmrgargument does cause side effects.
16561debfc3dSmrg
16571debfc3dSmrg@item CALL_EXPR
16581debfc3dSmrgThese nodes are used to represent calls to functions, including
16591debfc3dSmrgnon-static member functions.  @code{CALL_EXPR}s are implemented as
16601debfc3dSmrgexpression nodes with a variable number of operands.  Rather than using
16611debfc3dSmrg@code{TREE_OPERAND} to extract them, it is preferable to use the
16621debfc3dSmrgspecialized accessor macros and functions that operate specifically on
16631debfc3dSmrg@code{CALL_EXPR} nodes.
16641debfc3dSmrg
16651debfc3dSmrg@code{CALL_EXPR_FN} returns a pointer to the
16661debfc3dSmrgfunction to call; it is always an expression whose type is a
16671debfc3dSmrg@code{POINTER_TYPE}.
16681debfc3dSmrg
16691debfc3dSmrgThe number of arguments to the call is returned by @code{call_expr_nargs},
16701debfc3dSmrgwhile the arguments themselves can be accessed with the @code{CALL_EXPR_ARG}
16711debfc3dSmrgmacro.  The arguments are zero-indexed and numbered left-to-right.
16721debfc3dSmrgYou can iterate over the arguments using @code{FOR_EACH_CALL_EXPR_ARG}, as in:
16731debfc3dSmrg
16741debfc3dSmrg@smallexample
16751debfc3dSmrgtree call, arg;
16761debfc3dSmrgcall_expr_arg_iterator iter;
16771debfc3dSmrgFOR_EACH_CALL_EXPR_ARG (arg, iter, call)
16781debfc3dSmrg  /* arg is bound to successive arguments of call.  */
16791debfc3dSmrg  @dots{};
16801debfc3dSmrg@end smallexample
16811debfc3dSmrg
16821debfc3dSmrgFor non-static
16831debfc3dSmrgmember functions, there will be an operand corresponding to the
16841debfc3dSmrg@code{this} pointer.  There will always be expressions corresponding to
16851debfc3dSmrgall of the arguments, even if the function is declared with default
16861debfc3dSmrgarguments and some arguments are not explicitly provided at the call
16871debfc3dSmrgsites.
16881debfc3dSmrg
16891debfc3dSmrg@code{CALL_EXPR}s also have a @code{CALL_EXPR_STATIC_CHAIN} operand that
16901debfc3dSmrgis used to implement nested functions.  This operand is otherwise null.
16911debfc3dSmrg
16921debfc3dSmrg@item CLEANUP_POINT_EXPR
16931debfc3dSmrgThese nodes represent full-expressions.  The single operand is an
16941debfc3dSmrgexpression to evaluate.  Any destructor calls engendered by the creation
16951debfc3dSmrgof temporaries during the evaluation of that expression should be
16961debfc3dSmrgperformed immediately after the expression is evaluated.
16971debfc3dSmrg
16981debfc3dSmrg@item CONSTRUCTOR
16991debfc3dSmrgThese nodes represent the brace-enclosed initializers for a structure or an
17001debfc3dSmrgarray.  They contain a sequence of component values made out of a vector of
17011debfc3dSmrgconstructor_elt, which is a (@code{INDEX}, @code{VALUE}) pair.
17021debfc3dSmrg
17031debfc3dSmrgIf the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is a @code{RECORD_TYPE},
17041debfc3dSmrg@code{UNION_TYPE} or @code{QUAL_UNION_TYPE} then the @code{INDEX} of each
17051debfc3dSmrgnode in the sequence will be a @code{FIELD_DECL} and the @code{VALUE} will
17061debfc3dSmrgbe the expression used to initialize that field.
17071debfc3dSmrg
17081debfc3dSmrgIf the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is an @code{ARRAY_TYPE},
17091debfc3dSmrgthen the @code{INDEX} of each node in the sequence will be an
17101debfc3dSmrg@code{INTEGER_CST} or a @code{RANGE_EXPR} of two @code{INTEGER_CST}s.
17111debfc3dSmrgA single @code{INTEGER_CST} indicates which element of the array is being
17121debfc3dSmrgassigned to.  A @code{RANGE_EXPR} indicates an inclusive range of elements
17131debfc3dSmrgto initialize.  In both cases the @code{VALUE} is the corresponding
17141debfc3dSmrginitializer.  It is re-evaluated for each element of a
17151debfc3dSmrg@code{RANGE_EXPR}.  If the @code{INDEX} is @code{NULL_TREE}, then
17161debfc3dSmrgthe initializer is for the next available array element.
17171debfc3dSmrg
17181debfc3dSmrgIn the front end, you should not depend on the fields appearing in any
17191debfc3dSmrgparticular order.  However, in the middle end, fields must appear in
17201debfc3dSmrgdeclaration order.  You should not assume that all fields will be
17211debfc3dSmrgrepresented.  Unrepresented fields will be cleared (zeroed), unless the
17221debfc3dSmrgCONSTRUCTOR_NO_CLEARING flag is set, in which case their value becomes
17231debfc3dSmrgundefined.
17241debfc3dSmrg
17251debfc3dSmrg@item COMPOUND_LITERAL_EXPR
17261debfc3dSmrg@findex COMPOUND_LITERAL_EXPR_DECL_EXPR
17271debfc3dSmrg@findex COMPOUND_LITERAL_EXPR_DECL
17281debfc3dSmrgThese nodes represent ISO C99 compound literals.  The
17291debfc3dSmrg@code{COMPOUND_LITERAL_EXPR_DECL_EXPR} is a @code{DECL_EXPR}
17301debfc3dSmrgcontaining an anonymous @code{VAR_DECL} for
17311debfc3dSmrgthe unnamed object represented by the compound literal; the
17321debfc3dSmrg@code{DECL_INITIAL} of that @code{VAR_DECL} is a @code{CONSTRUCTOR}
17331debfc3dSmrgrepresenting the brace-enclosed list of initializers in the compound
17341debfc3dSmrgliteral.  That anonymous @code{VAR_DECL} can also be accessed directly
17351debfc3dSmrgby the @code{COMPOUND_LITERAL_EXPR_DECL} macro.
17361debfc3dSmrg
17371debfc3dSmrg@item SAVE_EXPR
17381debfc3dSmrg
17391debfc3dSmrgA @code{SAVE_EXPR} represents an expression (possibly involving
1740a2dc1f3fSmrgside effects) that is used more than once.  The side effects should
17411debfc3dSmrgoccur only the first time the expression is evaluated.  Subsequent uses
17421debfc3dSmrgshould just reuse the computed value.  The first operand to the
1743a2dc1f3fSmrg@code{SAVE_EXPR} is the expression to evaluate.  The side effects should
17441debfc3dSmrgbe executed where the @code{SAVE_EXPR} is first encountered in a
17451debfc3dSmrgdepth-first preorder traversal of the expression tree.
17461debfc3dSmrg
17471debfc3dSmrg@item TARGET_EXPR
17481debfc3dSmrgA @code{TARGET_EXPR} represents a temporary object.  The first operand
17491debfc3dSmrgis a @code{VAR_DECL} for the temporary variable.  The second operand is
17501debfc3dSmrgthe initializer for the temporary.  The initializer is evaluated and,
17511debfc3dSmrgif non-void, copied (bitwise) into the temporary.  If the initializer
17521debfc3dSmrgis void, that means that it will perform the initialization itself.
17531debfc3dSmrg
17541debfc3dSmrgOften, a @code{TARGET_EXPR} occurs on the right-hand side of an
17551debfc3dSmrgassignment, or as the second operand to a comma-expression which is
17561debfc3dSmrgitself the right-hand side of an assignment, etc.  In this case, we say
17571debfc3dSmrgthat the @code{TARGET_EXPR} is ``normal''; otherwise, we say it is
17581debfc3dSmrg``orphaned''.  For a normal @code{TARGET_EXPR} the temporary variable
17591debfc3dSmrgshould be treated as an alias for the left-hand side of the assignment,
17601debfc3dSmrgrather than as a new temporary variable.
17611debfc3dSmrg
17621debfc3dSmrgThe third operand to the @code{TARGET_EXPR}, if present, is a
17631debfc3dSmrgcleanup-expression (i.e., destructor call) for the temporary.  If this
17641debfc3dSmrgexpression is orphaned, then this expression must be executed when the
17651debfc3dSmrgstatement containing this expression is complete.  These cleanups must
17661debfc3dSmrgalways be executed in the order opposite to that in which they were
17671debfc3dSmrgencountered.  Note that if a temporary is created on one branch of a
17681debfc3dSmrgconditional operator (i.e., in the second or third operand to a
17691debfc3dSmrg@code{COND_EXPR}), the cleanup must be run only if that branch is
17701debfc3dSmrgactually executed.
17711debfc3dSmrg
17721debfc3dSmrg@item VA_ARG_EXPR
17731debfc3dSmrgThis node is used to implement support for the C/C++ variable argument-list
17741debfc3dSmrgmechanism.  It represents expressions like @code{va_arg (ap, type)}.
17751debfc3dSmrgIts @code{TREE_TYPE} yields the tree representation for @code{type} and
17761debfc3dSmrgits sole argument yields the representation for @code{ap}.
17771debfc3dSmrg
17781debfc3dSmrg@item ANNOTATE_EXPR
17791debfc3dSmrgThis node is used to attach markers to an expression. The first operand
17801debfc3dSmrgis the annotated expression, the second is an @code{INTEGER_CST} with
1781a2dc1f3fSmrga value from @code{enum annot_expr_kind}, the third is an @code{INTEGER_CST}.
17821debfc3dSmrg@end table
17831debfc3dSmrg
17841debfc3dSmrg
17851debfc3dSmrg@node Vectors
17861debfc3dSmrg@subsection Vectors
1787a2dc1f3fSmrg@tindex VEC_DUPLICATE_EXPR
1788a2dc1f3fSmrg@tindex VEC_SERIES_EXPR
17891debfc3dSmrg@tindex VEC_LSHIFT_EXPR
17901debfc3dSmrg@tindex VEC_RSHIFT_EXPR
17911debfc3dSmrg@tindex VEC_WIDEN_MULT_HI_EXPR
17921debfc3dSmrg@tindex VEC_WIDEN_MULT_LO_EXPR
17931debfc3dSmrg@tindex VEC_UNPACK_HI_EXPR
17941debfc3dSmrg@tindex VEC_UNPACK_LO_EXPR
17951debfc3dSmrg@tindex VEC_UNPACK_FLOAT_HI_EXPR
17961debfc3dSmrg@tindex VEC_UNPACK_FLOAT_LO_EXPR
1797c0a68be4Smrg@tindex VEC_UNPACK_FIX_TRUNC_HI_EXPR
1798c0a68be4Smrg@tindex VEC_UNPACK_FIX_TRUNC_LO_EXPR
17991debfc3dSmrg@tindex VEC_PACK_TRUNC_EXPR
18001debfc3dSmrg@tindex VEC_PACK_SAT_EXPR
18011debfc3dSmrg@tindex VEC_PACK_FIX_TRUNC_EXPR
1802c0a68be4Smrg@tindex VEC_PACK_FLOAT_EXPR
1803a2dc1f3fSmrg@tindex VEC_COND_EXPR
18041debfc3dSmrg@tindex SAD_EXPR
18051debfc3dSmrg
18061debfc3dSmrg@table @code
1807a2dc1f3fSmrg@item VEC_DUPLICATE_EXPR
1808a2dc1f3fSmrgThis node has a single operand and represents a vector in which every
1809a2dc1f3fSmrgelement is equal to that operand.
1810a2dc1f3fSmrg
1811a2dc1f3fSmrg@item VEC_SERIES_EXPR
1812a2dc1f3fSmrgThis node represents a vector formed from a scalar base and step,
1813a2dc1f3fSmrggiven as the first and second operands respectively.  Element @var{i}
1814a2dc1f3fSmrgof the result is equal to @samp{@var{base} + @var{i}*@var{step}}.
1815a2dc1f3fSmrg
1816a2dc1f3fSmrgThis node is restricted to integral types, in order to avoid
1817a2dc1f3fSmrgspecifying the rounding behavior for floating-point types.
1818a2dc1f3fSmrg
18191debfc3dSmrg@item VEC_LSHIFT_EXPR
18201debfc3dSmrg@itemx VEC_RSHIFT_EXPR
18211debfc3dSmrgThese nodes represent whole vector left and right shifts, respectively.
18221debfc3dSmrgThe first operand is the vector to shift; it will always be of vector type.
18231debfc3dSmrgThe second operand is an expression for the number of bits by which to
18241debfc3dSmrgshift.  Note that the result is undefined if the second operand is larger
18251debfc3dSmrgthan or equal to the first operand's type size.
18261debfc3dSmrg
18271debfc3dSmrg@item VEC_WIDEN_MULT_HI_EXPR
18281debfc3dSmrg@itemx VEC_WIDEN_MULT_LO_EXPR
18291debfc3dSmrgThese nodes represent widening vector multiplication of the high and low
18301debfc3dSmrgparts of the two input vectors, respectively.  Their operands are vectors
18311debfc3dSmrgthat contain the same number of elements (@code{N}) of the same integral type.
18321debfc3dSmrgThe result is a vector that contains half as many elements, of an integral type
18331debfc3dSmrgwhose size is twice as wide.  In the case of @code{VEC_WIDEN_MULT_HI_EXPR} the
18341debfc3dSmrghigh @code{N/2} elements of the two vector are multiplied to produce the
18351debfc3dSmrgvector of @code{N/2} products. In the case of @code{VEC_WIDEN_MULT_LO_EXPR} the
18361debfc3dSmrglow @code{N/2} elements of the two vector are multiplied to produce the
18371debfc3dSmrgvector of @code{N/2} products.
18381debfc3dSmrg
18391debfc3dSmrg@item VEC_UNPACK_HI_EXPR
18401debfc3dSmrg@itemx VEC_UNPACK_LO_EXPR
18411debfc3dSmrgThese nodes represent unpacking of the high and low parts of the input vector,
18421debfc3dSmrgrespectively.  The single operand is a vector that contains @code{N} elements
18431debfc3dSmrgof the same integral or floating point type.  The result is a vector
18441debfc3dSmrgthat contains half as many elements, of an integral or floating point type
18451debfc3dSmrgwhose size is twice as wide.  In the case of @code{VEC_UNPACK_HI_EXPR} the
18461debfc3dSmrghigh @code{N/2} elements of the vector are extracted and widened (promoted).
18471debfc3dSmrgIn the case of @code{VEC_UNPACK_LO_EXPR} the low @code{N/2} elements of the
18481debfc3dSmrgvector are extracted and widened (promoted).
18491debfc3dSmrg
18501debfc3dSmrg@item VEC_UNPACK_FLOAT_HI_EXPR
18511debfc3dSmrg@itemx VEC_UNPACK_FLOAT_LO_EXPR
18521debfc3dSmrgThese nodes represent unpacking of the high and low parts of the input vector,
18531debfc3dSmrgwhere the values are converted from fixed point to floating point.  The
18541debfc3dSmrgsingle operand is a vector that contains @code{N} elements of the same
18551debfc3dSmrgintegral type.  The result is a vector that contains half as many elements
18561debfc3dSmrgof a floating point type whose size is twice as wide.  In the case of
1857c0a68be4Smrg@code{VEC_UNPACK_FLOAT_HI_EXPR} the high @code{N/2} elements of the vector are
1858c0a68be4Smrgextracted, converted and widened.  In the case of @code{VEC_UNPACK_FLOAT_LO_EXPR}
18591debfc3dSmrgthe low @code{N/2} elements of the vector are extracted, converted and widened.
18601debfc3dSmrg
1861c0a68be4Smrg@item VEC_UNPACK_FIX_TRUNC_HI_EXPR
1862c0a68be4Smrg@itemx VEC_UNPACK_FIX_TRUNC_LO_EXPR
1863c0a68be4SmrgThese nodes represent unpacking of the high and low parts of the input vector,
1864c0a68be4Smrgwhere the values are truncated from floating point to fixed point.  The
1865c0a68be4Smrgsingle operand is a vector that contains @code{N} elements of the same
1866c0a68be4Smrgfloating point type.  The result is a vector that contains half as many
1867c0a68be4Smrgelements of an integral type whose size is twice as wide.  In the case of
1868c0a68be4Smrg@code{VEC_UNPACK_FIX_TRUNC_HI_EXPR} the high @code{N/2} elements of the
1869c0a68be4Smrgvector are extracted and converted with truncation.  In the case of
1870c0a68be4Smrg@code{VEC_UNPACK_FIX_TRUNC_LO_EXPR} the low @code{N/2} elements of the
1871c0a68be4Smrgvector are extracted and converted with truncation.
1872c0a68be4Smrg
18731debfc3dSmrg@item VEC_PACK_TRUNC_EXPR
18741debfc3dSmrgThis node represents packing of truncated elements of the two input vectors
18751debfc3dSmrginto the output vector.  Input operands are vectors that contain the same
18761debfc3dSmrgnumber of elements of the same integral or floating point type.  The result
18771debfc3dSmrgis a vector that contains twice as many elements of an integral or floating
18781debfc3dSmrgpoint type whose size is half as wide. The elements of the two vectors are
18791debfc3dSmrgdemoted and merged (concatenated) to form the output vector.
18801debfc3dSmrg
18811debfc3dSmrg@item VEC_PACK_SAT_EXPR
18821debfc3dSmrgThis node represents packing of elements of the two input vectors into the
18831debfc3dSmrgoutput vector using saturation.  Input operands are vectors that contain
18841debfc3dSmrgthe same number of elements of the same integral type.  The result is a
18851debfc3dSmrgvector that contains twice as many elements of an integral type whose size
18861debfc3dSmrgis half as wide.  The elements of the two vectors are demoted and merged
18871debfc3dSmrg(concatenated) to form the output vector.
18881debfc3dSmrg
18891debfc3dSmrg@item VEC_PACK_FIX_TRUNC_EXPR
18901debfc3dSmrgThis node represents packing of elements of the two input vectors into the
18911debfc3dSmrgoutput vector, where the values are converted from floating point
18921debfc3dSmrgto fixed point.  Input operands are vectors that contain the same number
18931debfc3dSmrgof elements of a floating point type.  The result is a vector that contains
18941debfc3dSmrgtwice as many elements of an integral type whose size is half as wide.  The
18951debfc3dSmrgelements of the two vectors are merged (concatenated) to form the output
18961debfc3dSmrgvector.
18971debfc3dSmrg
1898c0a68be4Smrg@item VEC_PACK_FLOAT_EXPR
1899c0a68be4SmrgThis node represents packing of elements of the two input vectors into the
1900c0a68be4Smrgoutput vector, where the values are converted from fixed point to floating
1901c0a68be4Smrgpoint.  Input operands are vectors that contain the same number of elements
1902c0a68be4Smrgof an integral type.  The result is a vector that contains twice as many
1903c0a68be4Smrgelements of floating point type whose size is half as wide.  The elements of
1904c0a68be4Smrgthe two vectors are merged (concatenated) to form the output vector.
1905c0a68be4Smrg
19061debfc3dSmrg@item VEC_COND_EXPR
19071debfc3dSmrgThese nodes represent @code{?:} expressions.  The three operands must be
19081debfc3dSmrgvectors of the same size and number of elements.  The second and third
19091debfc3dSmrgoperands must have the same type as the entire expression.  The first
19101debfc3dSmrgoperand is of signed integral vector type.  If an element of the first
19111debfc3dSmrgoperand evaluates to a zero value, the corresponding element of the
19121debfc3dSmrgresult is taken from the third operand. If it evaluates to a minus one
19131debfc3dSmrgvalue, it is taken from the second operand. It should never evaluate to
19141debfc3dSmrgany other value currently, but optimizations should not rely on that
19151debfc3dSmrgproperty. In contrast with a @code{COND_EXPR}, all operands are always
19161debfc3dSmrgevaluated.
19171debfc3dSmrg
19181debfc3dSmrg@item SAD_EXPR
19191debfc3dSmrgThis node represents the Sum of Absolute Differences operation.  The three
19201debfc3dSmrgoperands must be vectors of integral types.  The first and second operand
19211debfc3dSmrgmust have the same type.  The size of the vector element of the third
19221debfc3dSmrgoperand must be at lease twice of the size of the vector element of the
19231debfc3dSmrgfirst and second one.  The SAD is calculated between the first and second
19241debfc3dSmrgoperands, added to the third operand, and returned.
19251debfc3dSmrg
19261debfc3dSmrg@end table
19271debfc3dSmrg
19281debfc3dSmrg
19291debfc3dSmrg@c ---------------------------------------------------------------------
19301debfc3dSmrg@c Statements
19311debfc3dSmrg@c ---------------------------------------------------------------------
19321debfc3dSmrg
19331debfc3dSmrg@node Statements
19341debfc3dSmrg@section Statements
19351debfc3dSmrg@cindex Statements
19361debfc3dSmrg
19371debfc3dSmrgMost statements in GIMPLE are assignment statements, represented by
19381debfc3dSmrg@code{GIMPLE_ASSIGN}.  No other C expressions can appear at statement level;
19391debfc3dSmrga reference to a volatile object is converted into a
19401debfc3dSmrg@code{GIMPLE_ASSIGN}.
19411debfc3dSmrg
19421debfc3dSmrgThere are also several varieties of complex statements.
19431debfc3dSmrg
19441debfc3dSmrg@menu
19451debfc3dSmrg* Basic Statements::
19461debfc3dSmrg* Blocks::
19471debfc3dSmrg* Statement Sequences::
19481debfc3dSmrg* Empty Statements::
19491debfc3dSmrg* Jumps::
19501debfc3dSmrg* Cleanups::
19511debfc3dSmrg* OpenMP::
19521debfc3dSmrg* OpenACC::
19531debfc3dSmrg@end menu
19541debfc3dSmrg
19551debfc3dSmrg@node Basic Statements
19561debfc3dSmrg@subsection Basic Statements
19571debfc3dSmrg@cindex Basic Statements
19581debfc3dSmrg
19591debfc3dSmrg@table @code
19601debfc3dSmrg@item ASM_EXPR
19611debfc3dSmrg
19621debfc3dSmrgUsed to represent an inline assembly statement.  For an inline assembly
19631debfc3dSmrgstatement like:
19641debfc3dSmrg@smallexample
19651debfc3dSmrgasm ("mov x, y");
19661debfc3dSmrg@end smallexample
19671debfc3dSmrgThe @code{ASM_STRING} macro will return a @code{STRING_CST} node for
19681debfc3dSmrg@code{"mov x, y"}.  If the original statement made use of the
19691debfc3dSmrgextended-assembly syntax, then @code{ASM_OUTPUTS},
19701debfc3dSmrg@code{ASM_INPUTS}, and @code{ASM_CLOBBERS} will be the outputs, inputs,
19711debfc3dSmrgand clobbers for the statement, represented as @code{STRING_CST} nodes.
19721debfc3dSmrgThe extended-assembly syntax looks like:
19731debfc3dSmrg@smallexample
19741debfc3dSmrgasm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
19751debfc3dSmrg@end smallexample
19761debfc3dSmrgThe first string is the @code{ASM_STRING}, containing the instruction
19771debfc3dSmrgtemplate.  The next two strings are the output and inputs, respectively;
19781debfc3dSmrgthis statement has no clobbers.  As this example indicates, ``plain''
19791debfc3dSmrgassembly statements are merely a special case of extended assembly
19801debfc3dSmrgstatements; they have no cv-qualifiers, outputs, inputs, or clobbers.
19811debfc3dSmrgAll of the strings will be @code{NUL}-terminated, and will contain no
19821debfc3dSmrgembedded @code{NUL}-characters.
19831debfc3dSmrg
19841debfc3dSmrgIf the assembly statement is declared @code{volatile}, or if the
19851debfc3dSmrgstatement was not an extended assembly statement, and is therefore
19861debfc3dSmrgimplicitly volatile, then the predicate @code{ASM_VOLATILE_P} will hold
19871debfc3dSmrgof the @code{ASM_EXPR}.
19881debfc3dSmrg
19891debfc3dSmrg@item DECL_EXPR
19901debfc3dSmrg
19911debfc3dSmrgUsed to represent a local declaration.  The @code{DECL_EXPR_DECL} macro
19921debfc3dSmrgcan be used to obtain the entity declared.  This declaration may be a
19931debfc3dSmrg@code{LABEL_DECL}, indicating that the label declared is a local label.
19941debfc3dSmrg(As an extension, GCC allows the declaration of labels with scope.)  In
19951debfc3dSmrgC, this declaration may be a @code{FUNCTION_DECL}, indicating the
19961debfc3dSmrguse of the GCC nested function extension.  For more information,
19971debfc3dSmrg@pxref{Functions}.
19981debfc3dSmrg
19991debfc3dSmrg@item LABEL_EXPR
20001debfc3dSmrg
20011debfc3dSmrgUsed to represent a label.  The @code{LABEL_DECL} declared by this
20021debfc3dSmrgstatement can be obtained with the @code{LABEL_EXPR_LABEL} macro.  The
20031debfc3dSmrg@code{IDENTIFIER_NODE} giving the name of the label can be obtained from
20041debfc3dSmrgthe @code{LABEL_DECL} with @code{DECL_NAME}.
20051debfc3dSmrg
20061debfc3dSmrg@item GOTO_EXPR
20071debfc3dSmrg
20081debfc3dSmrgUsed to represent a @code{goto} statement.  The @code{GOTO_DESTINATION} will
20091debfc3dSmrgusually be a @code{LABEL_DECL}.  However, if the ``computed goto'' extension
20101debfc3dSmrghas been used, the @code{GOTO_DESTINATION} will be an arbitrary expression
20111debfc3dSmrgindicating the destination.  This expression will always have pointer type.
20121debfc3dSmrg
20131debfc3dSmrg@item RETURN_EXPR
20141debfc3dSmrg
20151debfc3dSmrgUsed to represent a @code{return} statement.  Operand 0 represents the
20161debfc3dSmrgvalue to return.  It should either be the @code{RESULT_DECL} for the
20171debfc3dSmrgcontaining function, or a @code{MODIFY_EXPR} or @code{INIT_EXPR}
20181debfc3dSmrgsetting the function's @code{RESULT_DECL}.  It will be
20191debfc3dSmrg@code{NULL_TREE} if the statement was just
20201debfc3dSmrg@smallexample
20211debfc3dSmrgreturn;
20221debfc3dSmrg@end smallexample
20231debfc3dSmrg
20241debfc3dSmrg@item LOOP_EXPR
20251debfc3dSmrgThese nodes represent ``infinite'' loops.  The @code{LOOP_EXPR_BODY}
20261debfc3dSmrgrepresents the body of the loop.  It should be executed forever, unless
20271debfc3dSmrgan @code{EXIT_EXPR} is encountered.
20281debfc3dSmrg
20291debfc3dSmrg@item EXIT_EXPR
20301debfc3dSmrgThese nodes represent conditional exits from the nearest enclosing
20311debfc3dSmrg@code{LOOP_EXPR}.  The single operand is the condition; if it is
20321debfc3dSmrgnonzero, then the loop should be exited.  An @code{EXIT_EXPR} will only
20331debfc3dSmrgappear within a @code{LOOP_EXPR}.
20341debfc3dSmrg
20351debfc3dSmrg@item SWITCH_STMT
20361debfc3dSmrg
20371debfc3dSmrgUsed to represent a @code{switch} statement.  The @code{SWITCH_STMT_COND}
20381debfc3dSmrgis the expression on which the switch is occurring.  See the documentation
20391debfc3dSmrgfor an @code{IF_STMT} for more information on the representation used
20401debfc3dSmrgfor the condition.  The @code{SWITCH_STMT_BODY} is the body of the switch
20411debfc3dSmrgstatement.   The @code{SWITCH_STMT_TYPE} is the original type of switch
20421debfc3dSmrgexpression as given in the source, before any compiler conversions.
20431debfc3dSmrg
20441debfc3dSmrg@item CASE_LABEL_EXPR
20451debfc3dSmrg
20461debfc3dSmrgUse to represent a @code{case} label, range of @code{case} labels, or a
20471debfc3dSmrg@code{default} label.  If @code{CASE_LOW} is @code{NULL_TREE}, then this is a
20481debfc3dSmrg@code{default} label.  Otherwise, if @code{CASE_HIGH} is @code{NULL_TREE}, then
20491debfc3dSmrgthis is an ordinary @code{case} label.  In this case, @code{CASE_LOW} is
20501debfc3dSmrgan expression giving the value of the label.  Both @code{CASE_LOW} and
20511debfc3dSmrg@code{CASE_HIGH} are @code{INTEGER_CST} nodes.  These values will have
20521debfc3dSmrgthe same type as the condition expression in the switch statement.
20531debfc3dSmrg
20541debfc3dSmrgOtherwise, if both @code{CASE_LOW} and @code{CASE_HIGH} are defined, the
20551debfc3dSmrgstatement is a range of case labels.  Such statements originate with the
20561debfc3dSmrgextension that allows users to write things of the form:
20571debfc3dSmrg@smallexample
20581debfc3dSmrgcase 2 ... 5:
20591debfc3dSmrg@end smallexample
20601debfc3dSmrgThe first value will be @code{CASE_LOW}, while the second will be
20611debfc3dSmrg@code{CASE_HIGH}.
20621debfc3dSmrg
2063a2dc1f3fSmrg@item DEBUG_BEGIN_STMT
2064a2dc1f3fSmrg
2065a2dc1f3fSmrgMarks the beginning of a source statement, for purposes of debug
2066a2dc1f3fSmrginformation generation.
2067a2dc1f3fSmrg
20681debfc3dSmrg@end table
20691debfc3dSmrg
20701debfc3dSmrg
20711debfc3dSmrg@node Blocks
20721debfc3dSmrg@subsection Blocks
20731debfc3dSmrg@cindex Blocks
20741debfc3dSmrg
20751debfc3dSmrgBlock scopes and the variables they declare in GENERIC are
20761debfc3dSmrgexpressed using the @code{BIND_EXPR} code, which in previous
20771debfc3dSmrgversions of GCC was primarily used for the C statement-expression
20781debfc3dSmrgextension.
20791debfc3dSmrg
20801debfc3dSmrgVariables in a block are collected into @code{BIND_EXPR_VARS} in
20811debfc3dSmrgdeclaration order through their @code{TREE_CHAIN} field.  Any runtime
20821debfc3dSmrginitialization is moved out of @code{DECL_INITIAL} and into a
20831debfc3dSmrgstatement in the controlled block.  When gimplifying from C or C++,
20841debfc3dSmrgthis initialization replaces the @code{DECL_STMT}.  These variables
20851debfc3dSmrgwill never require cleanups.  The scope of these variables is just the
20861debfc3dSmrgbody
20871debfc3dSmrg
20881debfc3dSmrgVariable-length arrays (VLAs) complicate this process, as their size
20891debfc3dSmrgoften refers to variables initialized earlier in the block and their
20901debfc3dSmrginitialization involves an explicit stack allocation.  To handle this,
20911debfc3dSmrgwe add an indirection and replace them with a pointer to stack space
20921debfc3dSmrgallocated by means of @code{alloca}.  In most cases, we also arrange
20931debfc3dSmrgfor this space to be reclaimed when the enclosing @code{BIND_EXPR} is
20941debfc3dSmrgexited, the exception to this being when there is an explicit call to
20951debfc3dSmrg@code{alloca} in the source code, in which case the stack is left
20961debfc3dSmrgdepressed on exit of the @code{BIND_EXPR}.
20971debfc3dSmrg
20981debfc3dSmrgA C++ program will usually contain more @code{BIND_EXPR}s than
20991debfc3dSmrgthere are syntactic blocks in the source code, since several C++
21001debfc3dSmrgconstructs have implicit scopes associated with them.  On the
21011debfc3dSmrgother hand, although the C++ front end uses pseudo-scopes to
21021debfc3dSmrghandle cleanups for objects with destructors, these don't
21031debfc3dSmrgtranslate into the GIMPLE form; multiple declarations at the same
21041debfc3dSmrglevel use the same @code{BIND_EXPR}.
21051debfc3dSmrg
21061debfc3dSmrg@node Statement Sequences
21071debfc3dSmrg@subsection Statement Sequences
21081debfc3dSmrg@cindex Statement Sequences
21091debfc3dSmrg
21101debfc3dSmrgMultiple statements at the same nesting level are collected into
21111debfc3dSmrga @code{STATEMENT_LIST}.  Statement lists are modified and
21121debfc3dSmrgtraversed using the interface in @samp{tree-iterator.h}.
21131debfc3dSmrg
21141debfc3dSmrg@node Empty Statements
21151debfc3dSmrg@subsection Empty Statements
21161debfc3dSmrg@cindex Empty Statements
21171debfc3dSmrg
21181debfc3dSmrgWhenever possible, statements with no effect are discarded.  But
21191debfc3dSmrgif they are nested within another construct which cannot be
21201debfc3dSmrgdiscarded for some reason, they are instead replaced with an
21211debfc3dSmrgempty statement, generated by @code{build_empty_stmt}.
21221debfc3dSmrgInitially, all empty statements were shared, after the pattern of
21231debfc3dSmrgthe Java front end, but this caused a lot of trouble in practice.
21241debfc3dSmrg
21251debfc3dSmrgAn empty statement is represented as @code{(void)0}.
21261debfc3dSmrg
21271debfc3dSmrg@node Jumps
21281debfc3dSmrg@subsection Jumps
21291debfc3dSmrg@cindex Jumps
21301debfc3dSmrg
21311debfc3dSmrgOther jumps are expressed by either @code{GOTO_EXPR} or
21321debfc3dSmrg@code{RETURN_EXPR}.
21331debfc3dSmrg
21341debfc3dSmrgThe operand of a @code{GOTO_EXPR} must be either a label or a
21351debfc3dSmrgvariable containing the address to jump to.
21361debfc3dSmrg
21371debfc3dSmrgThe operand of a @code{RETURN_EXPR} is either @code{NULL_TREE},
21381debfc3dSmrg@code{RESULT_DECL}, or a @code{MODIFY_EXPR} which sets the return
21391debfc3dSmrgvalue.  It would be nice to move the @code{MODIFY_EXPR} into a
21401debfc3dSmrgseparate statement, but the special return semantics in
21411debfc3dSmrg@code{expand_return} make that difficult.  It may still happen in
21421debfc3dSmrgthe future, perhaps by moving most of that logic into
21431debfc3dSmrg@code{expand_assignment}.
21441debfc3dSmrg
21451debfc3dSmrg@node Cleanups
21461debfc3dSmrg@subsection Cleanups
21471debfc3dSmrg@cindex Cleanups
21481debfc3dSmrg
21491debfc3dSmrgDestructors for local C++ objects and similar dynamic cleanups are
21501debfc3dSmrgrepresented in GIMPLE by a @code{TRY_FINALLY_EXPR}.
21511debfc3dSmrg@code{TRY_FINALLY_EXPR} has two operands, both of which are a sequence
21521debfc3dSmrgof statements to execute.  The first sequence is executed.  When it
21531debfc3dSmrgcompletes the second sequence is executed.
21541debfc3dSmrg
21551debfc3dSmrgThe first sequence may complete in the following ways:
21561debfc3dSmrg
21571debfc3dSmrg@enumerate
21581debfc3dSmrg
21591debfc3dSmrg@item Execute the last statement in the sequence and fall off the
21601debfc3dSmrgend.
21611debfc3dSmrg
21621debfc3dSmrg@item Execute a goto statement (@code{GOTO_EXPR}) to an ordinary
21631debfc3dSmrglabel outside the sequence.
21641debfc3dSmrg
21651debfc3dSmrg@item Execute a return statement (@code{RETURN_EXPR}).
21661debfc3dSmrg
21671debfc3dSmrg@item Throw an exception.  This is currently not explicitly represented in
21681debfc3dSmrgGIMPLE.
21691debfc3dSmrg
21701debfc3dSmrg@end enumerate
21711debfc3dSmrg
21721debfc3dSmrgThe second sequence is not executed if the first sequence completes by
21731debfc3dSmrgcalling @code{setjmp} or @code{exit} or any other function that does
21741debfc3dSmrgnot return.  The second sequence is also not executed if the first
21751debfc3dSmrgsequence completes via a non-local goto or a computed goto (in general
21761debfc3dSmrgthe compiler does not know whether such a goto statement exits the
21771debfc3dSmrgfirst sequence or not, so we assume that it doesn't).
21781debfc3dSmrg
21791debfc3dSmrgAfter the second sequence is executed, if it completes normally by
21801debfc3dSmrgfalling off the end, execution continues wherever the first sequence
21811debfc3dSmrgwould have continued, by falling off the end, or doing a goto, etc.
21821debfc3dSmrg
2183*8feb0f0bSmrgIf the second sequence is an @code{EH_ELSE_EXPR} selector, then the
2184*8feb0f0bSmrgsequence in its first operand is used when the first sequence completes
2185*8feb0f0bSmrgnormally, and that in its second operand is used for exceptional
2186*8feb0f0bSmrgcleanups, i.e., when an exception propagates out of the first sequence.
2187*8feb0f0bSmrg
21881debfc3dSmrg@code{TRY_FINALLY_EXPR} complicates the flow graph, since the cleanup
21891debfc3dSmrgneeds to appear on every edge out of the controlled block; this
21901debfc3dSmrgreduces the freedom to move code across these edges.  Therefore, the
21911debfc3dSmrgEH lowering pass which runs before most of the optimization passes
21921debfc3dSmrgeliminates these expressions by explicitly adding the cleanup to each
21931debfc3dSmrgedge.  Rethrowing the exception is represented using @code{RESX_EXPR}.
21941debfc3dSmrg
21951debfc3dSmrg@node OpenMP
21961debfc3dSmrg@subsection OpenMP
21971debfc3dSmrg@tindex OMP_PARALLEL
21981debfc3dSmrg@tindex OMP_FOR
21991debfc3dSmrg@tindex OMP_SECTIONS
22001debfc3dSmrg@tindex OMP_SINGLE
22011debfc3dSmrg@tindex OMP_SECTION
22021debfc3dSmrg@tindex OMP_MASTER
22031debfc3dSmrg@tindex OMP_ORDERED
22041debfc3dSmrg@tindex OMP_CRITICAL
22051debfc3dSmrg@tindex OMP_RETURN
22061debfc3dSmrg@tindex OMP_CONTINUE
22071debfc3dSmrg@tindex OMP_ATOMIC
22081debfc3dSmrg@tindex OMP_CLAUSE
22091debfc3dSmrg
22101debfc3dSmrgAll the statements starting with @code{OMP_} represent directives and
2211c0a68be4Smrgclauses used by the OpenMP API @w{@uref{https://www.openmp.org}}.
22121debfc3dSmrg
22131debfc3dSmrg@table @code
22141debfc3dSmrg@item OMP_PARALLEL
22151debfc3dSmrg
22161debfc3dSmrgRepresents @code{#pragma omp parallel [clause1 @dots{} clauseN]}. It
22171debfc3dSmrghas four operands:
22181debfc3dSmrg
22191debfc3dSmrgOperand @code{OMP_PARALLEL_BODY} is valid while in GENERIC and
22201debfc3dSmrgHigh GIMPLE forms.  It contains the body of code to be executed
22211debfc3dSmrgby all the threads.  During GIMPLE lowering, this operand becomes
22221debfc3dSmrg@code{NULL} and the body is emitted linearly after
22231debfc3dSmrg@code{OMP_PARALLEL}.
22241debfc3dSmrg
22251debfc3dSmrgOperand @code{OMP_PARALLEL_CLAUSES} is the list of clauses
22261debfc3dSmrgassociated with the directive.
22271debfc3dSmrg
22281debfc3dSmrgOperand @code{OMP_PARALLEL_FN} is created by
22291debfc3dSmrg@code{pass_lower_omp}, it contains the @code{FUNCTION_DECL}
22301debfc3dSmrgfor the function that will contain the body of the parallel
22311debfc3dSmrgregion.
22321debfc3dSmrg
22331debfc3dSmrgOperand @code{OMP_PARALLEL_DATA_ARG} is also created by
22341debfc3dSmrg@code{pass_lower_omp}. If there are shared variables to be
22351debfc3dSmrgcommunicated to the children threads, this operand will contain
22361debfc3dSmrgthe @code{VAR_DECL} that contains all the shared values and
22371debfc3dSmrgvariables.
22381debfc3dSmrg
22391debfc3dSmrg@item OMP_FOR
22401debfc3dSmrg
22411debfc3dSmrgRepresents @code{#pragma omp for [clause1 @dots{} clauseN]}.  It has
22421debfc3dSmrgsix operands:
22431debfc3dSmrg
22441debfc3dSmrgOperand @code{OMP_FOR_BODY} contains the loop body.
22451debfc3dSmrg
22461debfc3dSmrgOperand @code{OMP_FOR_CLAUSES} is the list of clauses
22471debfc3dSmrgassociated with the directive.
22481debfc3dSmrg
22491debfc3dSmrgOperand @code{OMP_FOR_INIT} is the loop initialization code of
22501debfc3dSmrgthe form @code{VAR = N1}.
22511debfc3dSmrg
22521debfc3dSmrgOperand @code{OMP_FOR_COND} is the loop conditional expression
22531debfc3dSmrgof the form @code{VAR @{<,>,<=,>=@} N2}.
22541debfc3dSmrg
22551debfc3dSmrgOperand @code{OMP_FOR_INCR} is the loop index increment of the
22561debfc3dSmrgform @code{VAR @{+=,-=@} INCR}.
22571debfc3dSmrg
2258a2dc1f3fSmrgOperand @code{OMP_FOR_PRE_BODY} contains side effect code from
22591debfc3dSmrgoperands @code{OMP_FOR_INIT}, @code{OMP_FOR_COND} and
2260a2dc1f3fSmrg@code{OMP_FOR_INC}.  These side effects are part of the
22611debfc3dSmrg@code{OMP_FOR} block but must be evaluated before the start of
22621debfc3dSmrgloop body.
22631debfc3dSmrg
22641debfc3dSmrgThe loop index variable @code{VAR} must be a signed integer variable,
22651debfc3dSmrgwhich is implicitly private to each thread.  Bounds
22661debfc3dSmrg@code{N1} and @code{N2} and the increment expression
22671debfc3dSmrg@code{INCR} are required to be loop invariant integer
22681debfc3dSmrgexpressions that are evaluated without any synchronization. The
2269a2dc1f3fSmrgevaluation order, frequency of evaluation and side effects are
22701debfc3dSmrgunspecified by the standard.
22711debfc3dSmrg
22721debfc3dSmrg@item OMP_SECTIONS
22731debfc3dSmrg
22741debfc3dSmrgRepresents @code{#pragma omp sections [clause1 @dots{} clauseN]}.
22751debfc3dSmrg
22761debfc3dSmrgOperand @code{OMP_SECTIONS_BODY} contains the sections body,
22771debfc3dSmrgwhich in turn contains a set of @code{OMP_SECTION} nodes for
22781debfc3dSmrgeach of the concurrent sections delimited by @code{#pragma omp
22791debfc3dSmrgsection}.
22801debfc3dSmrg
22811debfc3dSmrgOperand @code{OMP_SECTIONS_CLAUSES} is the list of clauses
22821debfc3dSmrgassociated with the directive.
22831debfc3dSmrg
22841debfc3dSmrg@item OMP_SECTION
22851debfc3dSmrg
22861debfc3dSmrgSection delimiter for @code{OMP_SECTIONS}.
22871debfc3dSmrg
22881debfc3dSmrg@item OMP_SINGLE
22891debfc3dSmrg
22901debfc3dSmrgRepresents @code{#pragma omp single}.
22911debfc3dSmrg
22921debfc3dSmrgOperand @code{OMP_SINGLE_BODY} contains the body of code to be
22931debfc3dSmrgexecuted by a single thread.
22941debfc3dSmrg
22951debfc3dSmrgOperand @code{OMP_SINGLE_CLAUSES} is the list of clauses
22961debfc3dSmrgassociated with the directive.
22971debfc3dSmrg
22981debfc3dSmrg@item OMP_MASTER
22991debfc3dSmrg
23001debfc3dSmrgRepresents @code{#pragma omp master}.
23011debfc3dSmrg
23021debfc3dSmrgOperand @code{OMP_MASTER_BODY} contains the body of code to be
23031debfc3dSmrgexecuted by the master thread.
23041debfc3dSmrg
23051debfc3dSmrg@item OMP_ORDERED
23061debfc3dSmrg
23071debfc3dSmrgRepresents @code{#pragma omp ordered}.
23081debfc3dSmrg
23091debfc3dSmrgOperand @code{OMP_ORDERED_BODY} contains the body of code to be
23101debfc3dSmrgexecuted in the sequential order dictated by the loop index
23111debfc3dSmrgvariable.
23121debfc3dSmrg
23131debfc3dSmrg@item OMP_CRITICAL
23141debfc3dSmrg
23151debfc3dSmrgRepresents @code{#pragma omp critical [name]}.
23161debfc3dSmrg
23171debfc3dSmrgOperand @code{OMP_CRITICAL_BODY} is the critical section.
23181debfc3dSmrg
23191debfc3dSmrgOperand @code{OMP_CRITICAL_NAME} is an optional identifier to
23201debfc3dSmrglabel the critical section.
23211debfc3dSmrg
23221debfc3dSmrg@item OMP_RETURN
23231debfc3dSmrg
23241debfc3dSmrgThis does not represent any OpenMP directive, it is an artificial
23251debfc3dSmrgmarker to indicate the end of the body of an OpenMP@. It is used
23261debfc3dSmrgby the flow graph (@code{tree-cfg.c}) and OpenMP region
23271debfc3dSmrgbuilding code (@code{omp-low.c}).
23281debfc3dSmrg
23291debfc3dSmrg@item OMP_CONTINUE
23301debfc3dSmrg
23311debfc3dSmrgSimilarly, this instruction does not represent an OpenMP
23321debfc3dSmrgdirective, it is used by @code{OMP_FOR} (and similar codes) as well as
23331debfc3dSmrg@code{OMP_SECTIONS} to mark the place where the code needs to
23341debfc3dSmrgloop to the next iteration, or the next section, respectively.
23351debfc3dSmrg
23361debfc3dSmrgIn some cases, @code{OMP_CONTINUE} is placed right before
23371debfc3dSmrg@code{OMP_RETURN}.  But if there are cleanups that need to
23381debfc3dSmrgoccur right after the looping body, it will be emitted between
23391debfc3dSmrg@code{OMP_CONTINUE} and @code{OMP_RETURN}.
23401debfc3dSmrg
23411debfc3dSmrg@item OMP_ATOMIC
23421debfc3dSmrg
23431debfc3dSmrgRepresents @code{#pragma omp atomic}.
23441debfc3dSmrg
23451debfc3dSmrgOperand 0 is the address at which the atomic operation is to be
23461debfc3dSmrgperformed.
23471debfc3dSmrg
23481debfc3dSmrgOperand 1 is the expression to evaluate.  The gimplifier tries
23491debfc3dSmrgthree alternative code generation strategies.  Whenever possible,
23501debfc3dSmrgan atomic update built-in is used.  If that fails, a
23511debfc3dSmrgcompare-and-swap loop is attempted.  If that also fails, a
23521debfc3dSmrgregular critical section around the expression is used.
23531debfc3dSmrg
23541debfc3dSmrg@item OMP_CLAUSE
23551debfc3dSmrg
23561debfc3dSmrgRepresents clauses associated with one of the @code{OMP_} directives.
23571debfc3dSmrgClauses are represented by separate subcodes defined in
23581debfc3dSmrg@file{tree.h}.  Clauses codes can be one of:
23591debfc3dSmrg@code{OMP_CLAUSE_PRIVATE}, @code{OMP_CLAUSE_SHARED},
23601debfc3dSmrg@code{OMP_CLAUSE_FIRSTPRIVATE},
23611debfc3dSmrg@code{OMP_CLAUSE_LASTPRIVATE}, @code{OMP_CLAUSE_COPYIN},
23621debfc3dSmrg@code{OMP_CLAUSE_COPYPRIVATE}, @code{OMP_CLAUSE_IF},
23631debfc3dSmrg@code{OMP_CLAUSE_NUM_THREADS}, @code{OMP_CLAUSE_SCHEDULE},
23641debfc3dSmrg@code{OMP_CLAUSE_NOWAIT}, @code{OMP_CLAUSE_ORDERED},
23651debfc3dSmrg@code{OMP_CLAUSE_DEFAULT}, @code{OMP_CLAUSE_REDUCTION},
23661debfc3dSmrg@code{OMP_CLAUSE_COLLAPSE}, @code{OMP_CLAUSE_UNTIED},
23671debfc3dSmrg@code{OMP_CLAUSE_FINAL}, and @code{OMP_CLAUSE_MERGEABLE}.  Each code
23681debfc3dSmrgrepresents the corresponding OpenMP clause.
23691debfc3dSmrg
23701debfc3dSmrgClauses associated with the same directive are chained together
23711debfc3dSmrgvia @code{OMP_CLAUSE_CHAIN}. Those clauses that accept a list
23721debfc3dSmrgof variables are restricted to exactly one, accessed with
23731debfc3dSmrg@code{OMP_CLAUSE_VAR}.  Therefore, multiple variables under the
23741debfc3dSmrgsame clause @code{C} need to be represented as multiple @code{C} clauses
23751debfc3dSmrgchained together.  This facilitates adding new clauses during
23761debfc3dSmrgcompilation.
23771debfc3dSmrg
23781debfc3dSmrg@end table
23791debfc3dSmrg
23801debfc3dSmrg@node OpenACC
23811debfc3dSmrg@subsection OpenACC
23821debfc3dSmrg@tindex OACC_CACHE
23831debfc3dSmrg@tindex OACC_DATA
23841debfc3dSmrg@tindex OACC_DECLARE
23851debfc3dSmrg@tindex OACC_ENTER_DATA
23861debfc3dSmrg@tindex OACC_EXIT_DATA
23871debfc3dSmrg@tindex OACC_HOST_DATA
23881debfc3dSmrg@tindex OACC_KERNELS
23891debfc3dSmrg@tindex OACC_LOOP
23901debfc3dSmrg@tindex OACC_PARALLEL
2391*8feb0f0bSmrg@tindex OACC_SERIAL
23921debfc3dSmrg@tindex OACC_UPDATE
23931debfc3dSmrg
23941debfc3dSmrgAll the statements starting with @code{OACC_} represent directives and
2395a2dc1f3fSmrgclauses used by the OpenACC API @w{@uref{https://www.openacc.org}}.
23961debfc3dSmrg
23971debfc3dSmrg@table @code
23981debfc3dSmrg@item OACC_CACHE
23991debfc3dSmrg
24001debfc3dSmrgRepresents @code{#pragma acc cache (var @dots{})}.
24011debfc3dSmrg
24021debfc3dSmrg@item OACC_DATA
24031debfc3dSmrg
24041debfc3dSmrgRepresents @code{#pragma acc data [clause1 @dots{} clauseN]}.
24051debfc3dSmrg
24061debfc3dSmrg@item OACC_DECLARE
24071debfc3dSmrg
24081debfc3dSmrgRepresents @code{#pragma acc declare [clause1 @dots{} clauseN]}.
24091debfc3dSmrg
24101debfc3dSmrg@item OACC_ENTER_DATA
24111debfc3dSmrg
24121debfc3dSmrgRepresents @code{#pragma acc enter data [clause1 @dots{} clauseN]}.
24131debfc3dSmrg
24141debfc3dSmrg@item OACC_EXIT_DATA
24151debfc3dSmrg
24161debfc3dSmrgRepresents @code{#pragma acc exit data [clause1 @dots{} clauseN]}.
24171debfc3dSmrg
24181debfc3dSmrg@item OACC_HOST_DATA
24191debfc3dSmrg
24201debfc3dSmrgRepresents @code{#pragma acc host_data [clause1 @dots{} clauseN]}.
24211debfc3dSmrg
24221debfc3dSmrg@item OACC_KERNELS
24231debfc3dSmrg
24241debfc3dSmrgRepresents @code{#pragma acc kernels [clause1 @dots{} clauseN]}.
24251debfc3dSmrg
24261debfc3dSmrg@item OACC_LOOP
24271debfc3dSmrg
24281debfc3dSmrgRepresents @code{#pragma acc loop [clause1 @dots{} clauseN]}.
24291debfc3dSmrg
24301debfc3dSmrgSee the description of the @code{OMP_FOR} code.
24311debfc3dSmrg
24321debfc3dSmrg@item OACC_PARALLEL
24331debfc3dSmrg
24341debfc3dSmrgRepresents @code{#pragma acc parallel [clause1 @dots{} clauseN]}.
24351debfc3dSmrg
2436*8feb0f0bSmrg@item OACC_SERIAL
2437*8feb0f0bSmrg
2438*8feb0f0bSmrgRepresents @code{#pragma acc serial [clause1 @dots{} clauseN]}.
2439*8feb0f0bSmrg
24401debfc3dSmrg@item OACC_UPDATE
24411debfc3dSmrg
24421debfc3dSmrgRepresents @code{#pragma acc update [clause1 @dots{} clauseN]}.
24431debfc3dSmrg
24441debfc3dSmrg@end table
24451debfc3dSmrg
24461debfc3dSmrg@c ---------------------------------------------------------------------
24471debfc3dSmrg@c Functions
24481debfc3dSmrg@c ---------------------------------------------------------------------
24491debfc3dSmrg
24501debfc3dSmrg@node Functions
24511debfc3dSmrg@section Functions
24521debfc3dSmrg@cindex function
24531debfc3dSmrg@tindex FUNCTION_DECL
24541debfc3dSmrg
24551debfc3dSmrgA function is represented by a @code{FUNCTION_DECL} node.  It stores
24561debfc3dSmrgthe basic pieces of the function such as body, parameters, and return
24571debfc3dSmrgtype as well as information on the surrounding context, visibility,
24581debfc3dSmrgand linkage.
24591debfc3dSmrg
24601debfc3dSmrg@menu
24611debfc3dSmrg* Function Basics::     Function names, body, and parameters.
24621debfc3dSmrg* Function Properties:: Context, linkage, etc.
24631debfc3dSmrg@end menu
24641debfc3dSmrg
24651debfc3dSmrg@c ---------------------------------------------------------------------
24661debfc3dSmrg@c Function Basics
24671debfc3dSmrg@c ---------------------------------------------------------------------
24681debfc3dSmrg
24691debfc3dSmrg@node Function Basics
24701debfc3dSmrg@subsection Function Basics
24711debfc3dSmrg@findex DECL_NAME
24721debfc3dSmrg@findex DECL_ASSEMBLER_NAME
24731debfc3dSmrg@findex TREE_PUBLIC
24741debfc3dSmrg@findex DECL_ARTIFICIAL
24751debfc3dSmrg@findex DECL_FUNCTION_SPECIFIC_TARGET
24761debfc3dSmrg@findex DECL_FUNCTION_SPECIFIC_OPTIMIZATION
24771debfc3dSmrg
24781debfc3dSmrgA function has four core parts: the name, the parameters, the result,
24791debfc3dSmrgand the body.  The following macros and functions access these parts
24801debfc3dSmrgof a @code{FUNCTION_DECL} as well as other basic features:
24811debfc3dSmrg@ftable @code
24821debfc3dSmrg@item DECL_NAME
24831debfc3dSmrgThis macro returns the unqualified name of the function, as an
24841debfc3dSmrg@code{IDENTIFIER_NODE}.  For an instantiation of a function template,
24851debfc3dSmrgthe @code{DECL_NAME} is the unqualified name of the template, not
24861debfc3dSmrgsomething like @code{f<int>}.  The value of @code{DECL_NAME} is
24871debfc3dSmrgundefined when used on a constructor, destructor, overloaded operator,
24881debfc3dSmrgor type-conversion operator, or any function that is implicitly
24891debfc3dSmrggenerated by the compiler.  See below for macros that can be used to
24901debfc3dSmrgdistinguish these cases.
24911debfc3dSmrg
24921debfc3dSmrg@item DECL_ASSEMBLER_NAME
24931debfc3dSmrgThis macro returns the mangled name of the function, also an
24941debfc3dSmrg@code{IDENTIFIER_NODE}.  This name does not contain leading underscores
24951debfc3dSmrgon systems that prefix all identifiers with underscores.  The mangled
24961debfc3dSmrgname is computed in the same way on all platforms; if special processing
24971debfc3dSmrgis required to deal with the object file format used on a particular
24981debfc3dSmrgplatform, it is the responsibility of the back end to perform those
24991debfc3dSmrgmodifications.  (Of course, the back end should not modify
25001debfc3dSmrg@code{DECL_ASSEMBLER_NAME} itself.)
25011debfc3dSmrg
25021debfc3dSmrgUsing @code{DECL_ASSEMBLER_NAME} will cause additional memory to be
25031debfc3dSmrgallocated (for the mangled name of the entity) so it should be used
25041debfc3dSmrgonly when emitting assembly code.  It should not be used within the
25051debfc3dSmrgoptimizers to determine whether or not two declarations are the same,
25061debfc3dSmrgeven though some of the existing optimizers do use it in that way.
25071debfc3dSmrgThese uses will be removed over time.
25081debfc3dSmrg
25091debfc3dSmrg@item DECL_ARGUMENTS
25101debfc3dSmrgThis macro returns the @code{PARM_DECL} for the first argument to the
25111debfc3dSmrgfunction.  Subsequent @code{PARM_DECL} nodes can be obtained by
25121debfc3dSmrgfollowing the @code{TREE_CHAIN} links.
25131debfc3dSmrg
25141debfc3dSmrg@item DECL_RESULT
25151debfc3dSmrgThis macro returns the @code{RESULT_DECL} for the function.
25161debfc3dSmrg
25171debfc3dSmrg@item DECL_SAVED_TREE
25181debfc3dSmrgThis macro returns the complete body of the function.
25191debfc3dSmrg
25201debfc3dSmrg@item TREE_TYPE
25211debfc3dSmrgThis macro returns the @code{FUNCTION_TYPE} or @code{METHOD_TYPE} for
25221debfc3dSmrgthe function.
25231debfc3dSmrg
25241debfc3dSmrg@item DECL_INITIAL
25251debfc3dSmrgA function that has a definition in the current translation unit will
25261debfc3dSmrghave a non-@code{NULL} @code{DECL_INITIAL}.  However, back ends should not make
25271debfc3dSmrguse of the particular value given by @code{DECL_INITIAL}.
25281debfc3dSmrg
25291debfc3dSmrgIt should contain a tree of @code{BLOCK} nodes that mirrors the scopes
25301debfc3dSmrgthat variables are bound in the function.  Each block contains a list
25311debfc3dSmrgof decls declared in a basic block, a pointer to a chain of blocks at
25321debfc3dSmrgthe next lower scope level, then a pointer to the next block at the
25331debfc3dSmrgsame level and a backpointer to the parent @code{BLOCK} or
25341debfc3dSmrg@code{FUNCTION_DECL}.  So given a function as follows:
25351debfc3dSmrg
25361debfc3dSmrg@smallexample
25371debfc3dSmrgvoid foo()
25381debfc3dSmrg@{
25391debfc3dSmrg  int a;
25401debfc3dSmrg  @{
25411debfc3dSmrg    int b;
25421debfc3dSmrg  @}
25431debfc3dSmrg  int c;
25441debfc3dSmrg@}
25451debfc3dSmrg@end smallexample
25461debfc3dSmrg
25471debfc3dSmrgyou would get the following:
25481debfc3dSmrg
25491debfc3dSmrg@smallexample
25501debfc3dSmrgtree foo = FUNCTION_DECL;
25511debfc3dSmrgtree decl_a = VAR_DECL;
25521debfc3dSmrgtree decl_b = VAR_DECL;
25531debfc3dSmrgtree decl_c = VAR_DECL;
25541debfc3dSmrgtree block_a = BLOCK;
25551debfc3dSmrgtree block_b = BLOCK;
25561debfc3dSmrgtree block_c = BLOCK;
25571debfc3dSmrgBLOCK_VARS(block_a) = decl_a;
25581debfc3dSmrgBLOCK_SUBBLOCKS(block_a) = block_b;
25591debfc3dSmrgBLOCK_CHAIN(block_a) = block_c;
25601debfc3dSmrgBLOCK_SUPERCONTEXT(block_a) = foo;
25611debfc3dSmrgBLOCK_VARS(block_b) = decl_b;
25621debfc3dSmrgBLOCK_SUPERCONTEXT(block_b) = block_a;
25631debfc3dSmrgBLOCK_VARS(block_c) = decl_c;
25641debfc3dSmrgBLOCK_SUPERCONTEXT(block_c) = foo;
25651debfc3dSmrgDECL_INITIAL(foo) = block_a;
25661debfc3dSmrg@end smallexample
25671debfc3dSmrg
25681debfc3dSmrg@end ftable
25691debfc3dSmrg
25701debfc3dSmrg@c ---------------------------------------------------------------------
25711debfc3dSmrg@c Function Properties
25721debfc3dSmrg@c ---------------------------------------------------------------------
25731debfc3dSmrg
25741debfc3dSmrg@node Function Properties
25751debfc3dSmrg@subsection Function Properties
25761debfc3dSmrg@cindex function properties
25771debfc3dSmrg@cindex statements
25781debfc3dSmrg
25791debfc3dSmrgTo determine the scope of a function, you can use the
25801debfc3dSmrg@code{DECL_CONTEXT} macro.  This macro will return the class
25811debfc3dSmrg(either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a
25821debfc3dSmrg@code{NAMESPACE_DECL}) of which the function is a member.  For a virtual
25831debfc3dSmrgfunction, this macro returns the class in which the function was
25841debfc3dSmrgactually defined, not the base class in which the virtual declaration
25851debfc3dSmrgoccurred.
25861debfc3dSmrg
25871debfc3dSmrgIn C, the @code{DECL_CONTEXT} for a function maybe another function.
25881debfc3dSmrgThis representation indicates that the GNU nested function extension
25891debfc3dSmrgis in use.  For details on the semantics of nested functions, see the
25901debfc3dSmrgGCC Manual.  The nested function can refer to local variables in its
25911debfc3dSmrgcontaining function.  Such references are not explicitly marked in the
25921debfc3dSmrgtree structure; back ends must look at the @code{DECL_CONTEXT} for the
25931debfc3dSmrgreferenced @code{VAR_DECL}.  If the @code{DECL_CONTEXT} for the
25941debfc3dSmrgreferenced @code{VAR_DECL} is not the same as the function currently
25951debfc3dSmrgbeing processed, and neither @code{DECL_EXTERNAL} nor
25961debfc3dSmrg@code{TREE_STATIC} hold, then the reference is to a local variable in
25971debfc3dSmrga containing function, and the back end must take appropriate action.
25981debfc3dSmrg
25991debfc3dSmrg@ftable @code
26001debfc3dSmrg@item DECL_EXTERNAL
26011debfc3dSmrgThis predicate holds if the function is undefined.
26021debfc3dSmrg
26031debfc3dSmrg@item TREE_PUBLIC
26041debfc3dSmrgThis predicate holds if the function has external linkage.
26051debfc3dSmrg
26061debfc3dSmrg@item TREE_STATIC
26071debfc3dSmrgThis predicate holds if the function has been defined.
26081debfc3dSmrg
26091debfc3dSmrg@item TREE_THIS_VOLATILE
26101debfc3dSmrgThis predicate holds if the function does not return normally.
26111debfc3dSmrg
26121debfc3dSmrg@item TREE_READONLY
26131debfc3dSmrgThis predicate holds if the function can only read its arguments.
26141debfc3dSmrg
26151debfc3dSmrg@item DECL_PURE_P
26161debfc3dSmrgThis predicate holds if the function can only read its arguments, but
26171debfc3dSmrgmay also read global memory.
26181debfc3dSmrg
26191debfc3dSmrg@item DECL_VIRTUAL_P
26201debfc3dSmrgThis predicate holds if the function is virtual.
26211debfc3dSmrg
26221debfc3dSmrg@item DECL_ARTIFICIAL
26231debfc3dSmrgThis macro holds if the function was implicitly generated by the
26241debfc3dSmrgcompiler, rather than explicitly declared.  In addition to implicitly
26251debfc3dSmrggenerated class member functions, this macro holds for the special
26261debfc3dSmrgfunctions created to implement static initialization and destruction, to
26271debfc3dSmrgcompute run-time type information, and so forth.
26281debfc3dSmrg
26291debfc3dSmrg@item DECL_FUNCTION_SPECIFIC_TARGET
26301debfc3dSmrgThis macro returns a tree node that holds the target options that are
26311debfc3dSmrgto be used to compile this particular function or @code{NULL_TREE} if
26321debfc3dSmrgthe function is to be compiled with the target options specified on
26331debfc3dSmrgthe command line.
26341debfc3dSmrg
26351debfc3dSmrg@item DECL_FUNCTION_SPECIFIC_OPTIMIZATION
26361debfc3dSmrgThis macro returns a tree node that holds the optimization options
26371debfc3dSmrgthat are to be used to compile this particular function or
26381debfc3dSmrg@code{NULL_TREE} if the function is to be compiled with the
26391debfc3dSmrgoptimization options specified on the command line.
26401debfc3dSmrg
26411debfc3dSmrg@end ftable
26421debfc3dSmrg
26431debfc3dSmrg@c ---------------------------------------------------------------------
26441debfc3dSmrg@c Language-dependent trees
26451debfc3dSmrg@c ---------------------------------------------------------------------
26461debfc3dSmrg
26471debfc3dSmrg@node Language-dependent trees
26481debfc3dSmrg@section Language-dependent trees
26491debfc3dSmrg@cindex language-dependent trees
26501debfc3dSmrg
26511debfc3dSmrgFront ends may wish to keep some state associated with various GENERIC
26521debfc3dSmrgtrees while parsing.  To support this, trees provide a set of flags
26531debfc3dSmrgthat may be used by the front end.  They are accessed using
26541debfc3dSmrg@code{TREE_LANG_FLAG_n} where @samp{n} is currently 0 through 6.
26551debfc3dSmrg
26561debfc3dSmrgIf necessary, a front end can use some language-dependent tree
26571debfc3dSmrgcodes in its GENERIC representation, so long as it provides a
26581debfc3dSmrghook for converting them to GIMPLE and doesn't expect them to
26591debfc3dSmrgwork with any (hypothetical) optimizers that run before the
26601debfc3dSmrgconversion to GIMPLE@. The intermediate representation used while
26611debfc3dSmrgparsing C and C++ looks very little like GENERIC, but the C and
26621debfc3dSmrgC++ gimplifier hooks are perfectly happy to take it as input and
26631debfc3dSmrgspit out GIMPLE@.
26641debfc3dSmrg
26651debfc3dSmrg
26661debfc3dSmrg
26671debfc3dSmrg@node C and C++ Trees
26681debfc3dSmrg@section C and C++ Trees
26691debfc3dSmrg
26701debfc3dSmrgThis section documents the internal representation used by GCC to
26711debfc3dSmrgrepresent C and C++ source programs.  When presented with a C or C++
26721debfc3dSmrgsource program, GCC parses the program, performs semantic analysis
26731debfc3dSmrg(including the generation of error messages), and then produces the
26741debfc3dSmrginternal representation described here.  This representation contains a
26751debfc3dSmrgcomplete representation for the entire translation unit provided as
26761debfc3dSmrginput to the front end.  This representation is then typically processed
26771debfc3dSmrgby a code-generator in order to produce machine code, but could also be
26781debfc3dSmrgused in the creation of source browsers, intelligent editors, automatic
26791debfc3dSmrgdocumentation generators, interpreters, and any other programs needing
26801debfc3dSmrgthe ability to process C or C++ code.
26811debfc3dSmrg
26821debfc3dSmrgThis section explains the internal representation.  In particular, it
26831debfc3dSmrgdocuments the internal representation for C and C++ source
26841debfc3dSmrgconstructs, and the macros, functions, and variables that can be used to
26851debfc3dSmrgaccess these constructs.  The C++ representation is largely a superset
26861debfc3dSmrgof the representation used in the C front end.  There is only one
26871debfc3dSmrgconstruct used in C that does not appear in the C++ front end and that
26881debfc3dSmrgis the GNU ``nested function'' extension.  Many of the macros documented
26891debfc3dSmrghere do not apply in C because the corresponding language constructs do
26901debfc3dSmrgnot appear in C@.
26911debfc3dSmrg
26921debfc3dSmrgThe C and C++ front ends generate a mix of GENERIC trees and ones
26931debfc3dSmrgspecific to C and C++.  These language-specific trees are higher-level
26941debfc3dSmrgconstructs than the ones in GENERIC to make the parser's job easier.
26951debfc3dSmrgThis section describes those trees that aren't part of GENERIC as well
26961debfc3dSmrgas aspects of GENERIC trees that are treated in a language-specific
26971debfc3dSmrgmanner.
26981debfc3dSmrg
26991debfc3dSmrgIf you are developing a ``back end'', be it is a code-generator or some
27001debfc3dSmrgother tool, that uses this representation, you may occasionally find
27011debfc3dSmrgthat you need to ask questions not easily answered by the functions and
27021debfc3dSmrgmacros available here.  If that situation occurs, it is quite likely
27031debfc3dSmrgthat GCC already supports the functionality you desire, but that the
27041debfc3dSmrginterface is simply not documented here.  In that case, you should ask
27051debfc3dSmrgthe GCC maintainers (via mail to @email{gcc@@gcc.gnu.org}) about
27061debfc3dSmrgdocumenting the functionality you require.  Similarly, if you find
27071debfc3dSmrgyourself writing functions that do not deal directly with your back end,
27081debfc3dSmrgbut instead might be useful to other people using the GCC front end, you
27091debfc3dSmrgshould submit your patches for inclusion in GCC@.
27101debfc3dSmrg
27111debfc3dSmrg@menu
27121debfc3dSmrg* Types for C++::               Fundamental and aggregate types.
27131debfc3dSmrg* Namespaces::                  Namespaces.
27141debfc3dSmrg* Classes::                     Classes.
27151debfc3dSmrg* Functions for C++::           Overloading and accessors for C++.
27161debfc3dSmrg* Statements for C++::          Statements specific to C and C++.
27171debfc3dSmrg* C++ Expressions::    From @code{typeid} to @code{throw}.
27181debfc3dSmrg@end menu
27191debfc3dSmrg
27201debfc3dSmrg@node Types for C++
27211debfc3dSmrg@subsection Types for C++
27221debfc3dSmrg@tindex UNKNOWN_TYPE
27231debfc3dSmrg@tindex TYPENAME_TYPE
27241debfc3dSmrg@tindex TYPEOF_TYPE
27251debfc3dSmrg@findex cp_type_quals
27261debfc3dSmrg@findex TYPE_UNQUALIFIED
27271debfc3dSmrg@findex TYPE_QUAL_CONST
27281debfc3dSmrg@findex TYPE_QUAL_VOLATILE
27291debfc3dSmrg@findex TYPE_QUAL_RESTRICT
27301debfc3dSmrg@findex TYPE_MAIN_VARIANT
27311debfc3dSmrg@cindex qualified type
27321debfc3dSmrg@findex TYPE_SIZE
27331debfc3dSmrg@findex TYPE_ALIGN
27341debfc3dSmrg@findex TYPE_PRECISION
27351debfc3dSmrg@findex TYPE_ARG_TYPES
27361debfc3dSmrg@findex TYPE_METHOD_BASETYPE
27371debfc3dSmrg@findex TYPE_PTRDATAMEM_P
27381debfc3dSmrg@findex TYPE_OFFSET_BASETYPE
27391debfc3dSmrg@findex TREE_TYPE
27401debfc3dSmrg@findex TYPE_CONTEXT
27411debfc3dSmrg@findex TYPE_NAME
27421debfc3dSmrg@findex TYPENAME_TYPE_FULLNAME
27431debfc3dSmrg@findex TYPE_FIELDS
27441debfc3dSmrg@findex TYPE_PTROBV_P
27451debfc3dSmrg
27461debfc3dSmrgIn C++, an array type is not qualified; rather the type of the array
27471debfc3dSmrgelements is qualified.  This situation is reflected in the intermediate
27481debfc3dSmrgrepresentation.  The macros described here will always examine the
27491debfc3dSmrgqualification of the underlying element type when applied to an array
27501debfc3dSmrgtype.  (If the element type is itself an array, then the recursion
27511debfc3dSmrgcontinues until a non-array type is found, and the qualification of this
27521debfc3dSmrgtype is examined.)  So, for example, @code{CP_TYPE_CONST_P} will hold of
27531debfc3dSmrgthe type @code{const int ()[7]}, denoting an array of seven @code{int}s.
27541debfc3dSmrg
27551debfc3dSmrgThe following functions and macros deal with cv-qualification of types:
27561debfc3dSmrg@ftable @code
27571debfc3dSmrg@item cp_type_quals
27581debfc3dSmrgThis function returns the set of type qualifiers applied to this type.
27591debfc3dSmrgThis value is @code{TYPE_UNQUALIFIED} if no qualifiers have been
27601debfc3dSmrgapplied.  The @code{TYPE_QUAL_CONST} bit is set if the type is
27611debfc3dSmrg@code{const}-qualified.  The @code{TYPE_QUAL_VOLATILE} bit is set if the
27621debfc3dSmrgtype is @code{volatile}-qualified.  The @code{TYPE_QUAL_RESTRICT} bit is
27631debfc3dSmrgset if the type is @code{restrict}-qualified.
27641debfc3dSmrg
27651debfc3dSmrg@item CP_TYPE_CONST_P
27661debfc3dSmrgThis macro holds if the type is @code{const}-qualified.
27671debfc3dSmrg
27681debfc3dSmrg@item CP_TYPE_VOLATILE_P
27691debfc3dSmrgThis macro holds if the type is @code{volatile}-qualified.
27701debfc3dSmrg
27711debfc3dSmrg@item CP_TYPE_RESTRICT_P
27721debfc3dSmrgThis macro holds if the type is @code{restrict}-qualified.
27731debfc3dSmrg
27741debfc3dSmrg@item CP_TYPE_CONST_NON_VOLATILE_P
27751debfc3dSmrgThis predicate holds for a type that is @code{const}-qualified, but
27761debfc3dSmrg@emph{not} @code{volatile}-qualified; other cv-qualifiers are ignored as
27771debfc3dSmrgwell: only the @code{const}-ness is tested.
27781debfc3dSmrg
27791debfc3dSmrg@end ftable
27801debfc3dSmrg
27811debfc3dSmrgA few other macros and functions are usable with all types:
27821debfc3dSmrg@ftable @code
27831debfc3dSmrg@item TYPE_SIZE
27841debfc3dSmrgThe number of bits required to represent the type, represented as an
27851debfc3dSmrg@code{INTEGER_CST}.  For an incomplete type, @code{TYPE_SIZE} will be
27861debfc3dSmrg@code{NULL_TREE}.
27871debfc3dSmrg
27881debfc3dSmrg@item TYPE_ALIGN
27891debfc3dSmrgThe alignment of the type, in bits, represented as an @code{int}.
27901debfc3dSmrg
27911debfc3dSmrg@item TYPE_NAME
27921debfc3dSmrgThis macro returns a declaration (in the form of a @code{TYPE_DECL}) for
27931debfc3dSmrgthe type.  (Note this macro does @emph{not} return an
27941debfc3dSmrg@code{IDENTIFIER_NODE}, as you might expect, given its name!)  You can
27951debfc3dSmrglook at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the
27961debfc3dSmrgactual name of the type.  The @code{TYPE_NAME} will be @code{NULL_TREE}
27971debfc3dSmrgfor a type that is not a built-in type, the result of a typedef, or a
27981debfc3dSmrgnamed class type.
27991debfc3dSmrg
28001debfc3dSmrg@item CP_INTEGRAL_TYPE
28011debfc3dSmrgThis predicate holds if the type is an integral type.  Notice that in
28021debfc3dSmrgC++, enumerations are @emph{not} integral types.
28031debfc3dSmrg
28041debfc3dSmrg@item ARITHMETIC_TYPE_P
28051debfc3dSmrgThis predicate holds if the type is an integral type (in the C++ sense)
28061debfc3dSmrgor a floating point type.
28071debfc3dSmrg
28081debfc3dSmrg@item CLASS_TYPE_P
28091debfc3dSmrgThis predicate holds for a class-type.
28101debfc3dSmrg
28111debfc3dSmrg@item TYPE_BUILT_IN
28121debfc3dSmrgThis predicate holds for a built-in type.
28131debfc3dSmrg
28141debfc3dSmrg@item TYPE_PTRDATAMEM_P
28151debfc3dSmrgThis predicate holds if the type is a pointer to data member.
28161debfc3dSmrg
28171debfc3dSmrg@item TYPE_PTR_P
28181debfc3dSmrgThis predicate holds if the type is a pointer type, and the pointee is
28191debfc3dSmrgnot a data member.
28201debfc3dSmrg
28211debfc3dSmrg@item TYPE_PTRFN_P
28221debfc3dSmrgThis predicate holds for a pointer to function type.
28231debfc3dSmrg
28241debfc3dSmrg@item TYPE_PTROB_P
28251debfc3dSmrgThis predicate holds for a pointer to object type.  Note however that it
28261debfc3dSmrgdoes not hold for the generic pointer to object type @code{void *}.  You
28271debfc3dSmrgmay use @code{TYPE_PTROBV_P} to test for a pointer to object type as
28281debfc3dSmrgwell as @code{void *}.
28291debfc3dSmrg
28301debfc3dSmrg@end ftable
28311debfc3dSmrg
28321debfc3dSmrgThe table below describes types specific to C and C++ as well as
28331debfc3dSmrglanguage-dependent info about GENERIC types.
28341debfc3dSmrg
28351debfc3dSmrg@table @code
28361debfc3dSmrg
28371debfc3dSmrg@item POINTER_TYPE
28381debfc3dSmrgUsed to represent pointer types, and pointer to data member types.  If
28391debfc3dSmrg@code{TREE_TYPE}
28401debfc3dSmrgis a pointer to data member type, then @code{TYPE_PTRDATAMEM_P} will hold.
28411debfc3dSmrgFor a pointer to data member type of the form @samp{T X::*},
28421debfc3dSmrg@code{TYPE_PTRMEM_CLASS_TYPE} will be the type @code{X}, while
28431debfc3dSmrg@code{TYPE_PTRMEM_POINTED_TO_TYPE} will be the type @code{T}.
28441debfc3dSmrg
28451debfc3dSmrg@item RECORD_TYPE
28461debfc3dSmrgUsed to represent @code{struct} and @code{class} types in C and C++.  If
28471debfc3dSmrg@code{TYPE_PTRMEMFUNC_P} holds, then this type is a pointer-to-member
28481debfc3dSmrgtype.  In that case, the @code{TYPE_PTRMEMFUNC_FN_TYPE} is a
28491debfc3dSmrg@code{POINTER_TYPE} pointing to a @code{METHOD_TYPE}.  The
28501debfc3dSmrg@code{METHOD_TYPE} is the type of a function pointed to by the
28511debfc3dSmrgpointer-to-member function.  If @code{TYPE_PTRMEMFUNC_P} does not hold,
28521debfc3dSmrgthis type is a class type.  For more information, @pxref{Classes}.
28531debfc3dSmrg
28541debfc3dSmrg@item UNKNOWN_TYPE
28551debfc3dSmrgThis node is used to represent a type the knowledge of which is
28561debfc3dSmrginsufficient for a sound processing.
28571debfc3dSmrg
28581debfc3dSmrg@item TYPENAME_TYPE
28591debfc3dSmrgUsed to represent a construct of the form @code{typename T::A}.  The
28601debfc3dSmrg@code{TYPE_CONTEXT} is @code{T}; the @code{TYPE_NAME} is an
28611debfc3dSmrg@code{IDENTIFIER_NODE} for @code{A}.  If the type is specified via a
28621debfc3dSmrgtemplate-id, then @code{TYPENAME_TYPE_FULLNAME} yields a
28631debfc3dSmrg@code{TEMPLATE_ID_EXPR}.  The @code{TREE_TYPE} is non-@code{NULL} if the
28641debfc3dSmrgnode is implicitly generated in support for the implicit typename
28651debfc3dSmrgextension; in which case the @code{TREE_TYPE} is a type node for the
28661debfc3dSmrgbase-class.
28671debfc3dSmrg
28681debfc3dSmrg@item TYPEOF_TYPE
28691debfc3dSmrgUsed to represent the @code{__typeof__} extension.  The
28701debfc3dSmrg@code{TYPE_FIELDS} is the expression the type of which is being
28711debfc3dSmrgrepresented.
28721debfc3dSmrg
28731debfc3dSmrg@end table
28741debfc3dSmrg
28751debfc3dSmrg
28761debfc3dSmrg@c ---------------------------------------------------------------------
28771debfc3dSmrg@c Namespaces
28781debfc3dSmrg@c ---------------------------------------------------------------------
28791debfc3dSmrg
28801debfc3dSmrg@node Namespaces
28811debfc3dSmrg@subsection Namespaces
28821debfc3dSmrg@cindex namespace, scope
28831debfc3dSmrg@tindex NAMESPACE_DECL
28841debfc3dSmrg
28851debfc3dSmrgThe root of the entire intermediate representation is the variable
28861debfc3dSmrg@code{global_namespace}.  This is the namespace specified with @code{::}
28871debfc3dSmrgin C++ source code.  All other namespaces, types, variables, functions,
28881debfc3dSmrgand so forth can be found starting with this namespace.
28891debfc3dSmrg
28901debfc3dSmrgHowever, except for the fact that it is distinguished as the root of the
28911debfc3dSmrgrepresentation, the global namespace is no different from any other
28921debfc3dSmrgnamespace.  Thus, in what follows, we describe namespaces generally,
28931debfc3dSmrgrather than the global namespace in particular.
28941debfc3dSmrg
28951debfc3dSmrgA namespace is represented by a @code{NAMESPACE_DECL} node.
28961debfc3dSmrg
28971debfc3dSmrgThe following macros and functions can be used on a @code{NAMESPACE_DECL}:
28981debfc3dSmrg
28991debfc3dSmrg@ftable @code
29001debfc3dSmrg@item DECL_NAME
29011debfc3dSmrgThis macro is used to obtain the @code{IDENTIFIER_NODE} corresponding to
29021debfc3dSmrgthe unqualified name of the name of the namespace (@pxref{Identifiers}).
29031debfc3dSmrgThe name of the global namespace is @samp{::}, even though in C++ the
29041debfc3dSmrgglobal namespace is unnamed.  However, you should use comparison with
29051debfc3dSmrg@code{global_namespace}, rather than @code{DECL_NAME} to determine
29061debfc3dSmrgwhether or not a namespace is the global one.  An unnamed namespace
29071debfc3dSmrgwill have a @code{DECL_NAME} equal to @code{anonymous_namespace_name}.
29081debfc3dSmrgWithin a single translation unit, all unnamed namespaces will have the
29091debfc3dSmrgsame name.
29101debfc3dSmrg
29111debfc3dSmrg@item DECL_CONTEXT
29121debfc3dSmrgThis macro returns the enclosing namespace.  The @code{DECL_CONTEXT} for
29131debfc3dSmrgthe @code{global_namespace} is @code{NULL_TREE}.
29141debfc3dSmrg
29151debfc3dSmrg@item DECL_NAMESPACE_ALIAS
29161debfc3dSmrgIf this declaration is for a namespace alias, then
29171debfc3dSmrg@code{DECL_NAMESPACE_ALIAS} is the namespace for which this one is an
29181debfc3dSmrgalias.
29191debfc3dSmrg
29201debfc3dSmrgDo not attempt to use @code{cp_namespace_decls} for a namespace which is
29211debfc3dSmrgan alias.  Instead, follow @code{DECL_NAMESPACE_ALIAS} links until you
29221debfc3dSmrgreach an ordinary, non-alias, namespace, and call
29231debfc3dSmrg@code{cp_namespace_decls} there.
29241debfc3dSmrg
29251debfc3dSmrg@item DECL_NAMESPACE_STD_P
29261debfc3dSmrgThis predicate holds if the namespace is the special @code{::std}
29271debfc3dSmrgnamespace.
29281debfc3dSmrg
29291debfc3dSmrg@item cp_namespace_decls
29301debfc3dSmrgThis function will return the declarations contained in the namespace,
29311debfc3dSmrgincluding types, overloaded functions, other namespaces, and so forth.
29321debfc3dSmrgIf there are no declarations, this function will return
29331debfc3dSmrg@code{NULL_TREE}.  The declarations are connected through their
29341debfc3dSmrg@code{TREE_CHAIN} fields.
29351debfc3dSmrg
29361debfc3dSmrgAlthough most entries on this list will be declarations,
29371debfc3dSmrg@code{TREE_LIST} nodes may also appear.  In this case, the
29381debfc3dSmrg@code{TREE_VALUE} will be an @code{OVERLOAD}.  The value of the
29391debfc3dSmrg@code{TREE_PURPOSE} is unspecified; back ends should ignore this value.
29401debfc3dSmrgAs with the other kinds of declarations returned by
29411debfc3dSmrg@code{cp_namespace_decls}, the @code{TREE_CHAIN} will point to the next
29421debfc3dSmrgdeclaration in this list.
29431debfc3dSmrg
29441debfc3dSmrgFor more information on the kinds of declarations that can occur on this
29451debfc3dSmrglist, @xref{Declarations}.  Some declarations will not appear on this
29461debfc3dSmrglist.  In particular, no @code{FIELD_DECL}, @code{LABEL_DECL}, or
29471debfc3dSmrg@code{PARM_DECL} nodes will appear here.
29481debfc3dSmrg
29491debfc3dSmrgThis function cannot be used with namespaces that have
29501debfc3dSmrg@code{DECL_NAMESPACE_ALIAS} set.
29511debfc3dSmrg
29521debfc3dSmrg@end ftable
29531debfc3dSmrg
29541debfc3dSmrg@c ---------------------------------------------------------------------
29551debfc3dSmrg@c Classes
29561debfc3dSmrg@c ---------------------------------------------------------------------
29571debfc3dSmrg
29581debfc3dSmrg@node Classes
29591debfc3dSmrg@subsection Classes
29601debfc3dSmrg@cindex class, scope
29611debfc3dSmrg@tindex RECORD_TYPE
29621debfc3dSmrg@tindex UNION_TYPE
29631debfc3dSmrg@findex CLASSTYPE_DECLARED_CLASS
29641debfc3dSmrg@findex TYPE_BINFO
29651debfc3dSmrg@findex BINFO_TYPE
29661debfc3dSmrg@findex TYPE_FIELDS
29671debfc3dSmrg@findex TYPE_VFIELD
29681debfc3dSmrg
29691debfc3dSmrgBesides namespaces, the other high-level scoping construct in C++ is the
29701debfc3dSmrgclass.  (Throughout this manual the term @dfn{class} is used to mean the
29711debfc3dSmrgtypes referred to in the ANSI/ISO C++ Standard as classes; these include
29721debfc3dSmrgtypes defined with the @code{class}, @code{struct}, and @code{union}
29731debfc3dSmrgkeywords.)
29741debfc3dSmrg
29751debfc3dSmrgA class type is represented by either a @code{RECORD_TYPE} or a
29761debfc3dSmrg@code{UNION_TYPE}.  A class declared with the @code{union} tag is
29771debfc3dSmrgrepresented by a @code{UNION_TYPE}, while classes declared with either
29781debfc3dSmrgthe @code{struct} or the @code{class} tag are represented by
29791debfc3dSmrg@code{RECORD_TYPE}s.  You can use the @code{CLASSTYPE_DECLARED_CLASS}
29801debfc3dSmrgmacro to discern whether or not a particular type is a @code{class} as
29811debfc3dSmrgopposed to a @code{struct}.  This macro will be true only for classes
29821debfc3dSmrgdeclared with the @code{class} tag.
29831debfc3dSmrg
2984a2dc1f3fSmrgAlmost all members are available on the @code{TYPE_FIELDS}
29851debfc3dSmrglist.  Given one member, the next can be found by following the
29861debfc3dSmrg@code{TREE_CHAIN}.  You should not depend in any way on the order in
29871debfc3dSmrgwhich fields appear on this list.  All nodes on this list will be
29881debfc3dSmrg@samp{DECL} nodes.  A @code{FIELD_DECL} is used to represent a non-static
29891debfc3dSmrgdata member, a @code{VAR_DECL} is used to represent a static data
29901debfc3dSmrgmember, and a @code{TYPE_DECL} is used to represent a type.  Note that
29911debfc3dSmrgthe @code{CONST_DECL} for an enumeration constant will appear on this
29921debfc3dSmrglist, if the enumeration type was declared in the class.  (Of course,
29931debfc3dSmrgthe @code{TYPE_DECL} for the enumeration type will appear here as well.)
29941debfc3dSmrgThere are no entries for base classes on this list.  In particular,
29951debfc3dSmrgthere is no @code{FIELD_DECL} for the ``base-class portion'' of an
2996a2dc1f3fSmrgobject.  If a function member is overloaded, each of the overloaded
2997a2dc1f3fSmrgfunctions appears; no @code{OVERLOAD} nodes appear on the @code{TYPE_FIELDS}
2998a2dc1f3fSmrglist.  Implicitly declared functions (including default constructors,
2999a2dc1f3fSmrgcopy constructors, assignment operators, and destructors) will appear on
3000a2dc1f3fSmrgthis list as well.
30011debfc3dSmrg
30021debfc3dSmrgThe @code{TYPE_VFIELD} is a compiler-generated field used to point to
30031debfc3dSmrgvirtual function tables.  It may or may not appear on the
30041debfc3dSmrg@code{TYPE_FIELDS} list.  However, back ends should handle the
30051debfc3dSmrg@code{TYPE_VFIELD} just like all the entries on the @code{TYPE_FIELDS}
30061debfc3dSmrglist.
30071debfc3dSmrg
30081debfc3dSmrgEvery class has an associated @dfn{binfo}, which can be obtained with
30091debfc3dSmrg@code{TYPE_BINFO}.  Binfos are used to represent base-classes.  The
30101debfc3dSmrgbinfo given by @code{TYPE_BINFO} is the degenerate case, whereby every
30111debfc3dSmrgclass is considered to be its own base-class.  The base binfos for a
30121debfc3dSmrgparticular binfo are held in a vector, whose length is obtained with
30131debfc3dSmrg@code{BINFO_N_BASE_BINFOS}.  The base binfos themselves are obtained
30141debfc3dSmrgwith @code{BINFO_BASE_BINFO} and @code{BINFO_BASE_ITERATE}.  To add a
30151debfc3dSmrgnew binfo, use @code{BINFO_BASE_APPEND}.  The vector of base binfos can
30161debfc3dSmrgbe obtained with @code{BINFO_BASE_BINFOS}, but normally you do not need
30171debfc3dSmrgto use that.  The class type associated with a binfo is given by
30181debfc3dSmrg@code{BINFO_TYPE}.  It is not always the case that @code{BINFO_TYPE
30191debfc3dSmrg(TYPE_BINFO (x))}, because of typedefs and qualified types.  Neither is
30201debfc3dSmrgit the case that @code{TYPE_BINFO (BINFO_TYPE (y))} is the same binfo as
30211debfc3dSmrg@code{y}.  The reason is that if @code{y} is a binfo representing a
30221debfc3dSmrgbase-class @code{B} of a derived class @code{D}, then @code{BINFO_TYPE
30231debfc3dSmrg(y)} will be @code{B}, and @code{TYPE_BINFO (BINFO_TYPE (y))} will be
30241debfc3dSmrg@code{B} as its own base-class, rather than as a base-class of @code{D}.
30251debfc3dSmrg
30261debfc3dSmrgThe access to a base type can be found with @code{BINFO_BASE_ACCESS}.
30271debfc3dSmrgThis will produce @code{access_public_node}, @code{access_private_node}
30281debfc3dSmrgor @code{access_protected_node}.  If bases are always public,
30291debfc3dSmrg@code{BINFO_BASE_ACCESSES} may be @code{NULL}.
30301debfc3dSmrg
30311debfc3dSmrg@code{BINFO_VIRTUAL_P} is used to specify whether the binfo is inherited
30321debfc3dSmrgvirtually or not.  The other flags, @code{BINFO_FLAG_0} to
30331debfc3dSmrg@code{BINFO_FLAG_6}, can be used for language specific use.
30341debfc3dSmrg
30351debfc3dSmrgThe following macros can be used on a tree node representing a class-type.
30361debfc3dSmrg
30371debfc3dSmrg@ftable @code
30381debfc3dSmrg@item LOCAL_CLASS_P
30391debfc3dSmrgThis predicate holds if the class is local class @emph{i.e.}@: declared
30401debfc3dSmrginside a function body.
30411debfc3dSmrg
30421debfc3dSmrg@item TYPE_POLYMORPHIC_P
30431debfc3dSmrgThis predicate holds if the class has at least one virtual function
30441debfc3dSmrg(declared or inherited).
30451debfc3dSmrg
30461debfc3dSmrg@item TYPE_HAS_DEFAULT_CONSTRUCTOR
30471debfc3dSmrgThis predicate holds whenever its argument represents a class-type with
30481debfc3dSmrgdefault constructor.
30491debfc3dSmrg
30501debfc3dSmrg@item CLASSTYPE_HAS_MUTABLE
30511debfc3dSmrg@itemx TYPE_HAS_MUTABLE_P
30521debfc3dSmrgThese predicates hold for a class-type having a mutable data member.
30531debfc3dSmrg
30541debfc3dSmrg@item CLASSTYPE_NON_POD_P
30551debfc3dSmrgThis predicate holds only for class-types that are not PODs.
30561debfc3dSmrg
30571debfc3dSmrg@item TYPE_HAS_NEW_OPERATOR
30581debfc3dSmrgThis predicate holds for a class-type that defines
30591debfc3dSmrg@code{operator new}.
30601debfc3dSmrg
30611debfc3dSmrg@item TYPE_HAS_ARRAY_NEW_OPERATOR
30621debfc3dSmrgThis predicate holds for a class-type for which
30631debfc3dSmrg@code{operator new[]} is defined.
30641debfc3dSmrg
30651debfc3dSmrg@item TYPE_OVERLOADS_CALL_EXPR
30661debfc3dSmrgThis predicate holds for class-type for which the function call
30671debfc3dSmrg@code{operator()} is overloaded.
30681debfc3dSmrg
30691debfc3dSmrg@item TYPE_OVERLOADS_ARRAY_REF
30701debfc3dSmrgThis predicate holds for a class-type that overloads
30711debfc3dSmrg@code{operator[]}
30721debfc3dSmrg
30731debfc3dSmrg@item TYPE_OVERLOADS_ARROW
30741debfc3dSmrgThis predicate holds for a class-type for which @code{operator->} is
30751debfc3dSmrgoverloaded.
30761debfc3dSmrg
30771debfc3dSmrg@end ftable
30781debfc3dSmrg
30791debfc3dSmrg@node Functions for C++
30801debfc3dSmrg@subsection Functions for C++
30811debfc3dSmrg@cindex function
30821debfc3dSmrg@tindex FUNCTION_DECL
30831debfc3dSmrg@tindex OVERLOAD
30841debfc3dSmrg@findex OVL_CURRENT
30851debfc3dSmrg@findex OVL_NEXT
30861debfc3dSmrg
30871debfc3dSmrgA function is represented by a @code{FUNCTION_DECL} node.  A set of
30881debfc3dSmrgoverloaded functions is sometimes represented by an @code{OVERLOAD} node.
30891debfc3dSmrg
30901debfc3dSmrgAn @code{OVERLOAD} node is not a declaration, so none of the
30911debfc3dSmrg@samp{DECL_} macros should be used on an @code{OVERLOAD}.  An
30921debfc3dSmrg@code{OVERLOAD} node is similar to a @code{TREE_LIST}.  Use
30931debfc3dSmrg@code{OVL_CURRENT} to get the function associated with an
30941debfc3dSmrg@code{OVERLOAD} node; use @code{OVL_NEXT} to get the next
30951debfc3dSmrg@code{OVERLOAD} node in the list of overloaded functions.  The macros
30961debfc3dSmrg@code{OVL_CURRENT} and @code{OVL_NEXT} are actually polymorphic; you can
30971debfc3dSmrguse them to work with @code{FUNCTION_DECL} nodes as well as with
30981debfc3dSmrgoverloads.  In the case of a @code{FUNCTION_DECL}, @code{OVL_CURRENT}
30991debfc3dSmrgwill always return the function itself, and @code{OVL_NEXT} will always
31001debfc3dSmrgbe @code{NULL_TREE}.
31011debfc3dSmrg
31021debfc3dSmrgTo determine the scope of a function, you can use the
31031debfc3dSmrg@code{DECL_CONTEXT} macro.  This macro will return the class
31041debfc3dSmrg(either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a
31051debfc3dSmrg@code{NAMESPACE_DECL}) of which the function is a member.  For a virtual
31061debfc3dSmrgfunction, this macro returns the class in which the function was
31071debfc3dSmrgactually defined, not the base class in which the virtual declaration
31081debfc3dSmrgoccurred.
31091debfc3dSmrg
31101debfc3dSmrgIf a friend function is defined in a class scope, the
31111debfc3dSmrg@code{DECL_FRIEND_CONTEXT} macro can be used to determine the class in
31121debfc3dSmrgwhich it was defined.  For example, in
31131debfc3dSmrg@smallexample
31141debfc3dSmrgclass C @{ friend void f() @{@} @};
31151debfc3dSmrg@end smallexample
31161debfc3dSmrg@noindent
31171debfc3dSmrgthe @code{DECL_CONTEXT} for @code{f} will be the
31181debfc3dSmrg@code{global_namespace}, but the @code{DECL_FRIEND_CONTEXT} will be the
31191debfc3dSmrg@code{RECORD_TYPE} for @code{C}.
31201debfc3dSmrg
31211debfc3dSmrg
31221debfc3dSmrgThe following macros and functions can be used on a @code{FUNCTION_DECL}:
31231debfc3dSmrg@ftable @code
31241debfc3dSmrg@item DECL_MAIN_P
31251debfc3dSmrgThis predicate holds for a function that is the program entry point
31261debfc3dSmrg@code{::code}.
31271debfc3dSmrg
31281debfc3dSmrg@item DECL_LOCAL_FUNCTION_P
31291debfc3dSmrgThis predicate holds if the function was declared at block scope, even
31301debfc3dSmrgthough it has a global scope.
31311debfc3dSmrg
31321debfc3dSmrg@item DECL_ANTICIPATED
31331debfc3dSmrgThis predicate holds if the function is a built-in function but its
31341debfc3dSmrgprototype is not yet explicitly declared.
31351debfc3dSmrg
31361debfc3dSmrg@item DECL_EXTERN_C_FUNCTION_P
31371debfc3dSmrgThis predicate holds if the function is declared as an
31381debfc3dSmrg`@code{extern "C"}' function.
31391debfc3dSmrg
31401debfc3dSmrg@item DECL_LINKONCE_P
31411debfc3dSmrgThis macro holds if multiple copies of this function may be emitted in
31421debfc3dSmrgvarious translation units.  It is the responsibility of the linker to
31431debfc3dSmrgmerge the various copies.  Template instantiations are the most common
31441debfc3dSmrgexample of functions for which @code{DECL_LINKONCE_P} holds; G++
31451debfc3dSmrginstantiates needed templates in all translation units which require them,
31461debfc3dSmrgand then relies on the linker to remove duplicate instantiations.
31471debfc3dSmrg
31481debfc3dSmrgFIXME: This macro is not yet implemented.
31491debfc3dSmrg
31501debfc3dSmrg@item DECL_FUNCTION_MEMBER_P
31511debfc3dSmrgThis macro holds if the function is a member of a class, rather than a
31521debfc3dSmrgmember of a namespace.
31531debfc3dSmrg
31541debfc3dSmrg@item DECL_STATIC_FUNCTION_P
31551debfc3dSmrgThis predicate holds if the function a static member function.
31561debfc3dSmrg
31571debfc3dSmrg@item DECL_NONSTATIC_MEMBER_FUNCTION_P
31581debfc3dSmrgThis macro holds for a non-static member function.
31591debfc3dSmrg
31601debfc3dSmrg@item DECL_CONST_MEMFUNC_P
31611debfc3dSmrgThis predicate holds for a @code{const}-member function.
31621debfc3dSmrg
31631debfc3dSmrg@item DECL_VOLATILE_MEMFUNC_P
31641debfc3dSmrgThis predicate holds for a @code{volatile}-member function.
31651debfc3dSmrg
31661debfc3dSmrg@item DECL_CONSTRUCTOR_P
31671debfc3dSmrgThis macro holds if the function is a constructor.
31681debfc3dSmrg
31691debfc3dSmrg@item DECL_NONCONVERTING_P
31701debfc3dSmrgThis predicate holds if the constructor is a non-converting constructor.
31711debfc3dSmrg
31721debfc3dSmrg@item DECL_COMPLETE_CONSTRUCTOR_P
31731debfc3dSmrgThis predicate holds for a function which is a constructor for an object
31741debfc3dSmrgof a complete type.
31751debfc3dSmrg
31761debfc3dSmrg@item DECL_BASE_CONSTRUCTOR_P
31771debfc3dSmrgThis predicate holds for a function which is a constructor for a base
31781debfc3dSmrgclass sub-object.
31791debfc3dSmrg
31801debfc3dSmrg@item DECL_COPY_CONSTRUCTOR_P
31811debfc3dSmrgThis predicate holds for a function which is a copy-constructor.
31821debfc3dSmrg
31831debfc3dSmrg@item DECL_DESTRUCTOR_P
31841debfc3dSmrgThis macro holds if the function is a destructor.
31851debfc3dSmrg
31861debfc3dSmrg@item DECL_COMPLETE_DESTRUCTOR_P
31871debfc3dSmrgThis predicate holds if the function is the destructor for an object a
31881debfc3dSmrgcomplete type.
31891debfc3dSmrg
31901debfc3dSmrg@item DECL_OVERLOADED_OPERATOR_P
31911debfc3dSmrgThis macro holds if the function is an overloaded operator.
31921debfc3dSmrg
31931debfc3dSmrg@item DECL_CONV_FN_P
31941debfc3dSmrgThis macro holds if the function is a type-conversion operator.
31951debfc3dSmrg
31961debfc3dSmrg@item DECL_GLOBAL_CTOR_P
31971debfc3dSmrgThis predicate holds if the function is a file-scope initialization
31981debfc3dSmrgfunction.
31991debfc3dSmrg
32001debfc3dSmrg@item DECL_GLOBAL_DTOR_P
32011debfc3dSmrgThis predicate holds if the function is a file-scope finalization
32021debfc3dSmrgfunction.
32031debfc3dSmrg
32041debfc3dSmrg@item DECL_THUNK_P
32051debfc3dSmrgThis predicate holds if the function is a thunk.
32061debfc3dSmrg
32071debfc3dSmrgThese functions represent stub code that adjusts the @code{this} pointer
32081debfc3dSmrgand then jumps to another function.  When the jumped-to function
32091debfc3dSmrgreturns, control is transferred directly to the caller, without
32101debfc3dSmrgreturning to the thunk.  The first parameter to the thunk is always the
32111debfc3dSmrg@code{this} pointer; the thunk should add @code{THUNK_DELTA} to this
32121debfc3dSmrgvalue.  (The @code{THUNK_DELTA} is an @code{int}, not an
32131debfc3dSmrg@code{INTEGER_CST}.)
32141debfc3dSmrg
32151debfc3dSmrgThen, if @code{THUNK_VCALL_OFFSET} (an @code{INTEGER_CST}) is nonzero
32161debfc3dSmrgthe adjusted @code{this} pointer must be adjusted again.  The complete
32171debfc3dSmrgcalculation is given by the following pseudo-code:
32181debfc3dSmrg
32191debfc3dSmrg@smallexample
32201debfc3dSmrgthis += THUNK_DELTA
32211debfc3dSmrgif (THUNK_VCALL_OFFSET)
32221debfc3dSmrg  this += (*((ptrdiff_t **) this))[THUNK_VCALL_OFFSET]
32231debfc3dSmrg@end smallexample
32241debfc3dSmrg
32251debfc3dSmrgFinally, the thunk should jump to the location given
32261debfc3dSmrgby @code{DECL_INITIAL}; this will always be an expression for the
32271debfc3dSmrgaddress of a function.
32281debfc3dSmrg
32291debfc3dSmrg@item DECL_NON_THUNK_FUNCTION_P
32301debfc3dSmrgThis predicate holds if the function is @emph{not} a thunk function.
32311debfc3dSmrg
32321debfc3dSmrg@item GLOBAL_INIT_PRIORITY
32331debfc3dSmrgIf either @code{DECL_GLOBAL_CTOR_P} or @code{DECL_GLOBAL_DTOR_P} holds,
32341debfc3dSmrgthen this gives the initialization priority for the function.  The
32351debfc3dSmrglinker will arrange that all functions for which
32361debfc3dSmrg@code{DECL_GLOBAL_CTOR_P} holds are run in increasing order of priority
32371debfc3dSmrgbefore @code{main} is called.  When the program exits, all functions for
32381debfc3dSmrgwhich @code{DECL_GLOBAL_DTOR_P} holds are run in the reverse order.
32391debfc3dSmrg
32401debfc3dSmrg@item TYPE_RAISES_EXCEPTIONS
32411debfc3dSmrgThis macro returns the list of exceptions that a (member-)function can
32421debfc3dSmrgraise.  The returned list, if non @code{NULL}, is comprised of nodes
32431debfc3dSmrgwhose @code{TREE_VALUE} represents a type.
32441debfc3dSmrg
32451debfc3dSmrg@item TYPE_NOTHROW_P
32461debfc3dSmrgThis predicate holds when the exception-specification of its arguments
32471debfc3dSmrgis of the form `@code{()}'.
32481debfc3dSmrg
32491debfc3dSmrg@item DECL_ARRAY_DELETE_OPERATOR_P
32501debfc3dSmrgThis predicate holds if the function an overloaded
32511debfc3dSmrg@code{operator delete[]}.
32521debfc3dSmrg
32531debfc3dSmrg@end ftable
32541debfc3dSmrg
32551debfc3dSmrg@c ---------------------------------------------------------------------
32561debfc3dSmrg@c Function Bodies
32571debfc3dSmrg@c ---------------------------------------------------------------------
32581debfc3dSmrg
32591debfc3dSmrg@node Statements for C++
32601debfc3dSmrg@subsection Statements for C++
32611debfc3dSmrg@cindex statements
32621debfc3dSmrg@tindex BREAK_STMT
32631debfc3dSmrg@tindex CLEANUP_STMT
32641debfc3dSmrg@findex CLEANUP_DECL
32651debfc3dSmrg@findex CLEANUP_EXPR
32661debfc3dSmrg@tindex CONTINUE_STMT
32671debfc3dSmrg@tindex DECL_STMT
32681debfc3dSmrg@findex DECL_STMT_DECL
32691debfc3dSmrg@tindex DO_STMT
32701debfc3dSmrg@findex DO_BODY
32711debfc3dSmrg@findex DO_COND
32721debfc3dSmrg@tindex EMPTY_CLASS_EXPR
32731debfc3dSmrg@tindex EXPR_STMT
32741debfc3dSmrg@findex EXPR_STMT_EXPR
32751debfc3dSmrg@tindex FOR_STMT
32761debfc3dSmrg@findex FOR_INIT_STMT
32771debfc3dSmrg@findex FOR_COND
32781debfc3dSmrg@findex FOR_EXPR
32791debfc3dSmrg@findex FOR_BODY
32801debfc3dSmrg@tindex HANDLER
32811debfc3dSmrg@tindex IF_STMT
32821debfc3dSmrg@findex IF_COND
32831debfc3dSmrg@findex THEN_CLAUSE
32841debfc3dSmrg@findex ELSE_CLAUSE
32851debfc3dSmrg@tindex RETURN_STMT
32861debfc3dSmrg@findex RETURN_EXPR
32871debfc3dSmrg@tindex SUBOBJECT
32881debfc3dSmrg@findex SUBOBJECT_CLEANUP
32891debfc3dSmrg@tindex SWITCH_STMT
32901debfc3dSmrg@findex SWITCH_COND
32911debfc3dSmrg@findex SWITCH_BODY
32921debfc3dSmrg@tindex TRY_BLOCK
32931debfc3dSmrg@findex TRY_STMTS
32941debfc3dSmrg@findex TRY_HANDLERS
32951debfc3dSmrg@findex HANDLER_PARMS
32961debfc3dSmrg@findex HANDLER_BODY
32971debfc3dSmrg@findex USING_STMT
32981debfc3dSmrg@tindex WHILE_STMT
32991debfc3dSmrg@findex WHILE_BODY
33001debfc3dSmrg@findex WHILE_COND
33011debfc3dSmrg
33021debfc3dSmrgA function that has a definition in the current translation unit will
33031debfc3dSmrghave a non-@code{NULL} @code{DECL_INITIAL}.  However, back ends should not make
33041debfc3dSmrguse of the particular value given by @code{DECL_INITIAL}.
33051debfc3dSmrg
33061debfc3dSmrgThe @code{DECL_SAVED_TREE} macro will give the complete body of the
33071debfc3dSmrgfunction.
33081debfc3dSmrg
33091debfc3dSmrg@subsubsection Statements
33101debfc3dSmrg
33111debfc3dSmrgThere are tree nodes corresponding to all of the source-level
33121debfc3dSmrgstatement constructs, used within the C and C++ frontends.  These are
33131debfc3dSmrgenumerated here, together with a list of the various macros that can
33141debfc3dSmrgbe used to obtain information about them.  There are a few macros that
33151debfc3dSmrgcan be used with all statements:
33161debfc3dSmrg
33171debfc3dSmrg@ftable @code
33181debfc3dSmrg@item STMT_IS_FULL_EXPR_P
33191debfc3dSmrgIn C++, statements normally constitute ``full expressions''; temporaries
33201debfc3dSmrgcreated during a statement are destroyed when the statement is complete.
33211debfc3dSmrgHowever, G++ sometimes represents expressions by statements; these
33221debfc3dSmrgstatements will not have @code{STMT_IS_FULL_EXPR_P} set.  Temporaries
33231debfc3dSmrgcreated during such statements should be destroyed when the innermost
33241debfc3dSmrgenclosing statement with @code{STMT_IS_FULL_EXPR_P} set is exited.
33251debfc3dSmrg
33261debfc3dSmrg@end ftable
33271debfc3dSmrg
33281debfc3dSmrgHere is the list of the various statement nodes, and the macros used to
33291debfc3dSmrgaccess them.  This documentation describes the use of these nodes in
33301debfc3dSmrgnon-template functions (including instantiations of template functions).
33311debfc3dSmrgIn template functions, the same nodes are used, but sometimes in
33321debfc3dSmrgslightly different ways.
33331debfc3dSmrg
33341debfc3dSmrgMany of the statements have substatements.  For example, a @code{while}
33351debfc3dSmrgloop will have a body, which is itself a statement.  If the substatement
33361debfc3dSmrgis @code{NULL_TREE}, it is considered equivalent to a statement
33371debfc3dSmrgconsisting of a single @code{;}, i.e., an expression statement in which
33381debfc3dSmrgthe expression has been omitted.  A substatement may in fact be a list
33391debfc3dSmrgof statements, connected via their @code{TREE_CHAIN}s.  So, you should
33401debfc3dSmrgalways process the statement tree by looping over substatements, like
33411debfc3dSmrgthis:
33421debfc3dSmrg@smallexample
33431debfc3dSmrgvoid process_stmt (stmt)
33441debfc3dSmrg     tree stmt;
33451debfc3dSmrg@{
33461debfc3dSmrg  while (stmt)
33471debfc3dSmrg    @{
33481debfc3dSmrg      switch (TREE_CODE (stmt))
33491debfc3dSmrg        @{
33501debfc3dSmrg        case IF_STMT:
33511debfc3dSmrg          process_stmt (THEN_CLAUSE (stmt));
33521debfc3dSmrg          /* @r{More processing here.}  */
33531debfc3dSmrg          break;
33541debfc3dSmrg
33551debfc3dSmrg        @dots{}
33561debfc3dSmrg        @}
33571debfc3dSmrg
33581debfc3dSmrg      stmt = TREE_CHAIN (stmt);
33591debfc3dSmrg    @}
33601debfc3dSmrg@}
33611debfc3dSmrg@end smallexample
33621debfc3dSmrgIn other words, while the @code{then} clause of an @code{if} statement
33631debfc3dSmrgin C++ can be only one statement (although that one statement may be a
33641debfc3dSmrgcompound statement), the intermediate representation will sometimes use
33651debfc3dSmrgseveral statements chained together.
33661debfc3dSmrg
33671debfc3dSmrg@table @code
33681debfc3dSmrg@item BREAK_STMT
33691debfc3dSmrg
33701debfc3dSmrgUsed to represent a @code{break} statement.  There are no additional
33711debfc3dSmrgfields.
33721debfc3dSmrg
33731debfc3dSmrg@item CLEANUP_STMT
33741debfc3dSmrg
33751debfc3dSmrgUsed to represent an action that should take place upon exit from the
33761debfc3dSmrgenclosing scope.  Typically, these actions are calls to destructors for
33771debfc3dSmrglocal objects, but back ends cannot rely on this fact.  If these nodes
33781debfc3dSmrgare in fact representing such destructors, @code{CLEANUP_DECL} will be
33791debfc3dSmrgthe @code{VAR_DECL} destroyed.  Otherwise, @code{CLEANUP_DECL} will be
33801debfc3dSmrg@code{NULL_TREE}.  In any case, the @code{CLEANUP_EXPR} is the
33811debfc3dSmrgexpression to execute.  The cleanups executed on exit from a scope
33821debfc3dSmrgshould be run in the reverse order of the order in which the associated
33831debfc3dSmrg@code{CLEANUP_STMT}s were encountered.
33841debfc3dSmrg
33851debfc3dSmrg@item CONTINUE_STMT
33861debfc3dSmrg
33871debfc3dSmrgUsed to represent a @code{continue} statement.  There are no additional
33881debfc3dSmrgfields.
33891debfc3dSmrg
33901debfc3dSmrg@item CTOR_STMT
33911debfc3dSmrg
33921debfc3dSmrgUsed to mark the beginning (if @code{CTOR_BEGIN_P} holds) or end (if
33931debfc3dSmrg@code{CTOR_END_P} holds of the main body of a constructor.  See also
33941debfc3dSmrg@code{SUBOBJECT} for more information on how to use these nodes.
33951debfc3dSmrg
33961debfc3dSmrg@item DO_STMT
33971debfc3dSmrg
33981debfc3dSmrgUsed to represent a @code{do} loop.  The body of the loop is given by
33991debfc3dSmrg@code{DO_BODY} while the termination condition for the loop is given by
34001debfc3dSmrg@code{DO_COND}.  The condition for a @code{do}-statement is always an
34011debfc3dSmrgexpression.
34021debfc3dSmrg
34031debfc3dSmrg@item EMPTY_CLASS_EXPR
34041debfc3dSmrg
34051debfc3dSmrgUsed to represent a temporary object of a class with no data whose
34061debfc3dSmrgaddress is never taken.  (All such objects are interchangeable.)  The
34071debfc3dSmrg@code{TREE_TYPE} represents the type of the object.
34081debfc3dSmrg
34091debfc3dSmrg@item EXPR_STMT
34101debfc3dSmrg
34111debfc3dSmrgUsed to represent an expression statement.  Use @code{EXPR_STMT_EXPR} to
34121debfc3dSmrgobtain the expression.
34131debfc3dSmrg
34141debfc3dSmrg@item FOR_STMT
34151debfc3dSmrg
34161debfc3dSmrgUsed to represent a @code{for} statement.  The @code{FOR_INIT_STMT} is
34171debfc3dSmrgthe initialization statement for the loop.  The @code{FOR_COND} is the
34181debfc3dSmrgtermination condition.  The @code{FOR_EXPR} is the expression executed
34191debfc3dSmrgright before the @code{FOR_COND} on each loop iteration; often, this
34201debfc3dSmrgexpression increments a counter.  The body of the loop is given by
34211debfc3dSmrg@code{FOR_BODY}.  Note that @code{FOR_INIT_STMT} and @code{FOR_BODY}
34221debfc3dSmrgreturn statements, while @code{FOR_COND} and @code{FOR_EXPR} return
34231debfc3dSmrgexpressions.
34241debfc3dSmrg
34251debfc3dSmrg@item HANDLER
34261debfc3dSmrg
34271debfc3dSmrgUsed to represent a C++ @code{catch} block.  The @code{HANDLER_TYPE}
34281debfc3dSmrgis the type of exception that will be caught by this handler; it is
34291debfc3dSmrgequal (by pointer equality) to @code{NULL} if this handler is for all
34301debfc3dSmrgtypes.  @code{HANDLER_PARMS} is the @code{DECL_STMT} for the catch
34311debfc3dSmrgparameter, and @code{HANDLER_BODY} is the code for the block itself.
34321debfc3dSmrg
34331debfc3dSmrg@item IF_STMT
34341debfc3dSmrg
34351debfc3dSmrgUsed to represent an @code{if} statement.  The @code{IF_COND} is the
34361debfc3dSmrgexpression.
34371debfc3dSmrg
34381debfc3dSmrgIf the condition is a @code{TREE_LIST}, then the @code{TREE_PURPOSE} is
34391debfc3dSmrga statement (usually a @code{DECL_STMT}).  Each time the condition is
34401debfc3dSmrgevaluated, the statement should be executed.  Then, the
34411debfc3dSmrg@code{TREE_VALUE} should be used as the conditional expression itself.
34421debfc3dSmrgThis representation is used to handle C++ code like this:
34431debfc3dSmrg
34441debfc3dSmrgC++ distinguishes between this and @code{COND_EXPR} for handling templates.
34451debfc3dSmrg
34461debfc3dSmrg@smallexample
34471debfc3dSmrgif (int i = 7) @dots{}
34481debfc3dSmrg@end smallexample
34491debfc3dSmrg
34501debfc3dSmrgwhere there is a new local variable (or variables) declared within the
34511debfc3dSmrgcondition.
34521debfc3dSmrg
34531debfc3dSmrgThe @code{THEN_CLAUSE} represents the statement given by the @code{then}
34541debfc3dSmrgcondition, while the @code{ELSE_CLAUSE} represents the statement given
34551debfc3dSmrgby the @code{else} condition.
34561debfc3dSmrg
34571debfc3dSmrg@item SUBOBJECT
34581debfc3dSmrg
34591debfc3dSmrgIn a constructor, these nodes are used to mark the point at which a
34601debfc3dSmrgsubobject of @code{this} is fully constructed.  If, after this point, an
34611debfc3dSmrgexception is thrown before a @code{CTOR_STMT} with @code{CTOR_END_P} set
34621debfc3dSmrgis encountered, the @code{SUBOBJECT_CLEANUP} must be executed.  The
34631debfc3dSmrgcleanups must be executed in the reverse order in which they appear.
34641debfc3dSmrg
34651debfc3dSmrg@item SWITCH_STMT
34661debfc3dSmrg
34671debfc3dSmrgUsed to represent a @code{switch} statement.  The @code{SWITCH_STMT_COND}
34681debfc3dSmrgis the expression on which the switch is occurring.  See the documentation
34691debfc3dSmrgfor an @code{IF_STMT} for more information on the representation used
34701debfc3dSmrgfor the condition.  The @code{SWITCH_STMT_BODY} is the body of the switch
34711debfc3dSmrgstatement.   The @code{SWITCH_STMT_TYPE} is the original type of switch
34721debfc3dSmrgexpression as given in the source, before any compiler conversions.
34731debfc3dSmrg
34741debfc3dSmrg@item TRY_BLOCK
34751debfc3dSmrgUsed to represent a @code{try} block.  The body of the try block is
34761debfc3dSmrggiven by @code{TRY_STMTS}.  Each of the catch blocks is a @code{HANDLER}
34771debfc3dSmrgnode.  The first handler is given by @code{TRY_HANDLERS}.  Subsequent
34781debfc3dSmrghandlers are obtained by following the @code{TREE_CHAIN} link from one
34791debfc3dSmrghandler to the next.  The body of the handler is given by
34801debfc3dSmrg@code{HANDLER_BODY}.
34811debfc3dSmrg
34821debfc3dSmrgIf @code{CLEANUP_P} holds of the @code{TRY_BLOCK}, then the
34831debfc3dSmrg@code{TRY_HANDLERS} will not be a @code{HANDLER} node.  Instead, it will
34841debfc3dSmrgbe an expression that should be executed if an exception is thrown in
34851debfc3dSmrgthe try block.  It must rethrow the exception after executing that code.
34861debfc3dSmrgAnd, if an exception is thrown while the expression is executing,
34871debfc3dSmrg@code{terminate} must be called.
34881debfc3dSmrg
34891debfc3dSmrg@item USING_STMT
34901debfc3dSmrgUsed to represent a @code{using} directive.  The namespace is given by
34911debfc3dSmrg@code{USING_STMT_NAMESPACE}, which will be a NAMESPACE_DECL@.  This node
34921debfc3dSmrgis needed inside template functions, to implement using directives
34931debfc3dSmrgduring instantiation.
34941debfc3dSmrg
34951debfc3dSmrg@item WHILE_STMT
34961debfc3dSmrg
34971debfc3dSmrgUsed to represent a @code{while} loop.  The @code{WHILE_COND} is the
34981debfc3dSmrgtermination condition for the loop.  See the documentation for an
34991debfc3dSmrg@code{IF_STMT} for more information on the representation used for the
35001debfc3dSmrgcondition.
35011debfc3dSmrg
35021debfc3dSmrgThe @code{WHILE_BODY} is the body of the loop.
35031debfc3dSmrg
35041debfc3dSmrg@end table
35051debfc3dSmrg
35061debfc3dSmrg@node C++ Expressions
35071debfc3dSmrg@subsection C++ Expressions
35081debfc3dSmrg
35091debfc3dSmrgThis section describes expressions specific to the C and C++ front
35101debfc3dSmrgends.
35111debfc3dSmrg
35121debfc3dSmrg@table @code
35131debfc3dSmrg@item TYPEID_EXPR
35141debfc3dSmrg
35151debfc3dSmrgUsed to represent a @code{typeid} expression.
35161debfc3dSmrg
35171debfc3dSmrg@item NEW_EXPR
35181debfc3dSmrg@itemx VEC_NEW_EXPR
35191debfc3dSmrg
35201debfc3dSmrgUsed to represent a call to @code{new} and @code{new[]} respectively.
35211debfc3dSmrg
35221debfc3dSmrg@item DELETE_EXPR
35231debfc3dSmrg@itemx VEC_DELETE_EXPR
35241debfc3dSmrg
35251debfc3dSmrgUsed to represent a call to @code{delete} and @code{delete[]} respectively.
35261debfc3dSmrg
35271debfc3dSmrg@item MEMBER_REF
35281debfc3dSmrg
35291debfc3dSmrgRepresents a reference to a member of a class.
35301debfc3dSmrg
35311debfc3dSmrg@item THROW_EXPR
35321debfc3dSmrg
35331debfc3dSmrgRepresents an instance of @code{throw} in the program.  Operand 0,
35341debfc3dSmrgwhich is the expression to throw, may be @code{NULL_TREE}.
35351debfc3dSmrg
35361debfc3dSmrg
35371debfc3dSmrg@item AGGR_INIT_EXPR
35381debfc3dSmrgAn @code{AGGR_INIT_EXPR} represents the initialization as the return
35391debfc3dSmrgvalue of a function call, or as the result of a constructor.  An
35401debfc3dSmrg@code{AGGR_INIT_EXPR} will only appear as a full-expression, or as the
35411debfc3dSmrgsecond operand of a @code{TARGET_EXPR}.  @code{AGGR_INIT_EXPR}s have
35421debfc3dSmrga representation similar to that of @code{CALL_EXPR}s.  You can use
35431debfc3dSmrgthe @code{AGGR_INIT_EXPR_FN} and @code{AGGR_INIT_EXPR_ARG} macros to access
35441debfc3dSmrgthe function to call and the arguments to pass.
35451debfc3dSmrg
35461debfc3dSmrgIf @code{AGGR_INIT_VIA_CTOR_P} holds of the @code{AGGR_INIT_EXPR}, then
35471debfc3dSmrgthe initialization is via a constructor call.  The address of the
35481debfc3dSmrg@code{AGGR_INIT_EXPR_SLOT} operand, which is always a @code{VAR_DECL},
35491debfc3dSmrgis taken, and this value replaces the first argument in the argument
35501debfc3dSmrglist.
35511debfc3dSmrg
35521debfc3dSmrgIn either case, the expression is void.
35531debfc3dSmrg
35541debfc3dSmrg
35551debfc3dSmrg@end table
3556